Class: GithubSnapBuilder::RepoConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/github_snap_builder/config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#channelObject (readonly)

Returns the value of attribute channel.



111
112
113
# File 'lib/github_snap_builder/config.rb', line 111

def channel
  @channel
end

#nameObject (readonly)

Returns the value of attribute name.



111
112
113
# File 'lib/github_snap_builder/config.rb', line 111

def name
  @name
end

#tokenObject (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

Returns:

  • (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

#validateObject



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