Class: GithubSnapBuilder::RepoConfig
- Inherits:
-
Object
- Object
- GithubSnapBuilder::RepoConfig
- Defined in:
- lib/github_snap_builder/config.rb
Instance Attribute Summary collapse
-
#channel ⇒ Object
readonly
Returns the value of attribute channel.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
Instance Method Summary collapse
-
#initialize(name, config) ⇒ RepoConfig
constructor
A new instance of RepoConfig.
- #valid? ⇒ Boolean
- #validate ⇒ Object
Constructor Details
#initialize(name, config) ⇒ RepoConfig
Returns a new instance of RepoConfig.
113 114 115 116 117 |
# File 'lib/github_snap_builder/config.rb', line 113 def initialize(name, config) @name = name @channel = config.fetch('channel', 'edge') @token = config['token'] end |
Instance Attribute Details
#channel ⇒ Object (readonly)
Returns the value of attribute channel.
111 112 113 |
# File 'lib/github_snap_builder/config.rb', line 111 def channel @channel end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
111 112 113 |
# File 'lib/github_snap_builder/config.rb', line 111 def name @name end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
111 112 113 |
# File 'lib/github_snap_builder/config.rb', line 111 def token @token end |
Instance Method Details
#valid? ⇒ Boolean
133 134 135 136 137 138 139 140 141 |
# File 'lib/github_snap_builder/config.rb', line 133 def valid? begin validate rescue ConfigurationError return false end true end |
#validate ⇒ Object
119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/github_snap_builder/config.rb', line 119 def validate if name.nil? || !name.is_a?(String) || name.empty? raise ConfigurationFieldError, "repo name" end if channel.nil? || !channel.is_a?(String) || channel.empty? raise ConfigurationFieldError, "#{name}'s channel" end if token.nil? || !token.is_a?(String) || token.empty? raise ConfigurationFieldError, "#{name}'s token" end end |