Class: Overlay::GithubRepo
- Inherits:
-
Object
- Object
- Overlay::GithubRepo
- Defined in:
- lib/overlay/configuration.rb
Overview
Optional parameters: :branch, :use_publisher :registration_address :redis_server :redis_port :endpoint, :site,
Constant Summary collapse
- REQUIRED_PARAMS =
[:org, :repo, :auth, :root_source_path]
- REQUIRED_PUBLISHER_PARAMS =
[:redis_server, :redis_port, :registration_server]
Instance Attribute Summary collapse
-
#auth ⇒ Object
readonly
Returns the value of attribute auth.
-
#branch ⇒ Object
Returns the value of attribute branch.
-
#endpoint ⇒ Object
Returns the value of attribute endpoint.
-
#github_api ⇒ Object
Internal repo api hook.
-
#org ⇒ Object
readonly
Returns the value of attribute org.
-
#redis_port ⇒ Object
Returns the value of attribute redis_port.
-
#redis_server ⇒ Object
Returns the value of attribute redis_server.
-
#registration_server ⇒ Object
Returns the value of attribute registration_server.
-
#repo ⇒ Object
readonly
Returns the value of attribute repo.
-
#root_dest_path ⇒ Object
Returns the value of attribute root_dest_path.
-
#root_source_path ⇒ Object
Returns the value of attribute root_source_path.
-
#site ⇒ Object
Returns the value of attribute site.
-
#use_publisher ⇒ Object
Returns the value of attribute use_publisher.
Instance Method Summary collapse
-
#after_process_hook(&hook) ⇒ Object
Add code to be called after processing a hook.
-
#initialize(options = {}) ⇒ GithubRepo
constructor
A new instance of GithubRepo.
-
#initialize_api ⇒ Object
Retrieve API hook to repo.
-
#post_hook ⇒ Object
Run post_hook code.
-
#validate ⇒ Object
Make sure that this configuration has all required parameters.
Constructor Details
#initialize(options = {}) ⇒ GithubRepo
Returns a new instance of GithubRepo.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/overlay/configuration.rb', line 60 def initialize(={}) @org = [:org] @repo = [:repo] @auth = [:auth] @root_source_path = [:root_source_path] @root_dest_path = [:root_dest_path] @redis_server = [:redis_server] @redis_port = [:redis_port] @registration_server = [:registration_server] @endpoint = [:endpoint] @site = [:site] @branch = [:branch] || 'master' @use_publisher = [:use_publisher] || false # Quick sanity check validate # Create a hook to the Github API initialize_api end |
Instance Attribute Details
#auth ⇒ Object (readonly)
Returns the value of attribute auth.
52 53 54 |
# File 'lib/overlay/configuration.rb', line 52 def auth @auth end |
#branch ⇒ Object
Returns the value of attribute branch.
50 51 52 |
# File 'lib/overlay/configuration.rb', line 50 def branch @branch end |
#endpoint ⇒ Object
Returns the value of attribute endpoint.
52 53 54 |
# File 'lib/overlay/configuration.rb', line 52 def endpoint @endpoint end |
#github_api ⇒ Object
Internal repo api hook
55 56 57 |
# File 'lib/overlay/configuration.rb', line 55 def github_api @github_api end |
#org ⇒ Object (readonly)
Returns the value of attribute org.
52 53 54 |
# File 'lib/overlay/configuration.rb', line 52 def org @org end |
#redis_port ⇒ Object
Returns the value of attribute redis_port.
51 52 53 |
# File 'lib/overlay/configuration.rb', line 51 def redis_port @redis_port end |
#redis_server ⇒ Object
Returns the value of attribute redis_server.
51 52 53 |
# File 'lib/overlay/configuration.rb', line 51 def redis_server @redis_server end |
#registration_server ⇒ Object
Returns the value of attribute registration_server.
51 52 53 |
# File 'lib/overlay/configuration.rb', line 51 def registration_server @registration_server end |
#repo ⇒ Object (readonly)
Returns the value of attribute repo.
52 53 54 |
# File 'lib/overlay/configuration.rb', line 52 def repo @repo end |
#root_dest_path ⇒ Object
Returns the value of attribute root_dest_path.
50 51 52 |
# File 'lib/overlay/configuration.rb', line 50 def root_dest_path @root_dest_path end |
#root_source_path ⇒ Object
Returns the value of attribute root_source_path.
50 51 52 |
# File 'lib/overlay/configuration.rb', line 50 def root_source_path @root_source_path end |
#site ⇒ Object
Returns the value of attribute site.
52 53 54 |
# File 'lib/overlay/configuration.rb', line 52 def site @site end |
#use_publisher ⇒ Object
Returns the value of attribute use_publisher.
51 52 53 |
# File 'lib/overlay/configuration.rb', line 51 def use_publisher @use_publisher end |
Instance Method Details
#after_process_hook(&hook) ⇒ Object
Add code to be called after processing a hook
110 111 112 113 |
# File 'lib/overlay/configuration.rb', line 110 def after_process_hook(&hook) raise ArgumentError, "No block given" unless block_given? @post_hook = hook end |
#initialize_api ⇒ Object
Retrieve API hook to repo
121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/overlay/configuration.rb', line 121 def initialize_api @github_api = ::Github::Repos.new do |github_config| github_config.endpoint = @endpoint if @endpoint github_config.site = @site if @site github_config.basic_auth = @auth github_config.repo = @repo github_config.org = @org github_config.adapter = :net_http github_config.ssl = {:verify => false} end end |
#post_hook ⇒ Object
Run post_hook code
116 117 118 |
# File 'lib/overlay/configuration.rb', line 116 def post_hook @post_hook.call unless @post_hook.nil? end |
#validate ⇒ Object
Make sure that this configuration has all required parameters
96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/overlay/configuration.rb', line 96 def validate REQUIRED_PARAMS.each do |param| raise RequiredParameterError, "Overlay GithubRepo missing required paramater: #{param}" if (send(param).nil? || send(param).empty?) end # If we are using a publisher, check required publisher params if @use_publisher REQUIRED_PUBLISHER_PARAMS.each do |param| raise RequiredParameterError, "Overlay GithubRepo missing required paramater: #{param}" if (send(param).nil?) end end end |