Class: Appium::Thor::Config
- Inherits:
-
Object
- Object
- Appium::Thor::Config
- Includes:
- Singleton
- Defined in:
- lib/appium_thor/config.rb
Class Method Summary collapse
-
.options ⇒ Object
Returns all options as symbols.
-
.set(&block) ⇒ Object
Enables setting config in the Thorfile.
-
.string_options ⇒ Object
the subset of options that operate on strings.
Instance Method Summary collapse
-
#init_and_validate ⇒ Object
Returns true if all options are truthy.
Class Method Details
.options ⇒ Object
Returns all options as symbols. Required for defining delegators in init.rb
25 26 27 |
# File 'lib/appium_thor/config.rb', line 25 def self. end |
.set(&block) ⇒ Object
Enables setting config in the Thorfile
Appium::Thor::Config.set do
gem_name 'appium_thor'
github_owner 'appium'
github_name 'appium_thor'
branch 'master'
version_file 'path/to/version.rb'
end
52 53 54 55 56 57 |
# File 'lib/appium_thor/config.rb', line 52 def self.set(&block) config = self.instance config.instance_eval &block config.init_and_validate config end |
.string_options ⇒ Object
the subset of options that operate on strings
30 31 32 |
# File 'lib/appium_thor/config.rb', line 30 def self. %w[gem_name github_name github_owner branch version_file].map(&:to_sym) end |
Instance Method Details
#init_and_validate ⇒ Object
Returns true if all options are truthy
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/appium_thor/config.rb', line 7 def init_and_validate # set default values if @gem_name @github_name ||= @gem_name @version_file ||= "lib/#{@gem_name}/version.rb" end @branch ||= 'master' @github_owner ||= 'appium' # ensure all options are set all_set = @gem_name && @github_name && @github_owner && @version_file raise 'Must set gem_name, github_name, github_owner, version_file' unless all_set raise "version file doesn't exist #{@version_file}" unless File.exist?(@version_file) end |