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
-
#docs_block(&block) ⇒ Object
block of code to execute that contains documentation generation logic.
-
#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
32 33 34 |
# File 'lib/appium_thor/config.rb', line 32 def self. + [:docs_block] 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
59 60 61 62 63 64 |
# File 'lib/appium_thor/config.rb', line 59 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
37 38 39 |
# File 'lib/appium_thor/config.rb', line 37 def self. %w[gem_name github_name github_owner branch version_file].map(&:to_sym) end |
Instance Method Details
#docs_block(&block) ⇒ Object
block of code to execute that contains documentation generation logic
26 27 28 29 |
# File 'lib/appium_thor/config.rb', line 26 def docs_block(&block) return @docs_block if @docs_block @docs_block = block end |
#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 |