Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Feb 24, 2026. It is now read-only.

Commit 9556ca7

Browse files
committed
implement strategies
1 parent e950bc8 commit 9556ca7

3 files changed

Lines changed: 27 additions & 6 deletions

File tree

lib/github-api-client.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@
4545
#end if GitHub::Config::Secrets
4646

4747

48+
# Strategies
49+
require 'github-api-client/strategies/ask'
50+
GitHub::Config::Options[:strategy] = GitHub::Strategies::Ask # GitHub::CachingStrategy
51+
52+
4853
# General placeholder for all of the GitHub API sweets
4954
module GitHub
5055
end
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module GitHub
2+
module Strategies
3+
module Ask
4+
class << self
5+
def should_refresh?(model)
6+
puts "Should I refresh #{Fetchers::Helpers.const_name(model)}? [y/n]"
7+
return gets.chomp == 'y'
8+
end
9+
10+
def update_strategy(model); end # no need for updating on this strategy
11+
end
12+
end
13+
end
14+
end

lib/github-api-client/strategy.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@ module GitHub
22
class CachingStrategyNotImplemented < StandardError; end
33
# Template
44
module CachingStrategy
5-
def should_refresh?(model)
6-
throw CachingStrategyNotImplemented
7-
end
8-
9-
def update_strategy(model)
10-
throw CachingStrategyNotImplemented
5+
class << self
6+
def should_refresh?(model)
7+
throw CachingStrategyNotImplemented
8+
end
9+
10+
def update_strategy(model)
11+
throw CachingStrategyNotImplemented
12+
end
1113
end
1214
end
1315
end

0 commit comments

Comments
 (0)