class Appium::Thor::Config

Public Class Methods

options() click to toggle source

Returns all options as symbols. Required for defining delegators in init.rb

# File lib/appium_thor/config.rb, line 32
def self.options
  string_options + [:docs_block]
end
set(&block) click to toggle source

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

# 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() click to toggle source

the subset of options that operate on strings

# File lib/appium_thor/config.rb, line 37
def self.string_options
  %w[gem_name github_name github_owner branch version_file].map(&:to_sym)
end

Public Instance Methods

docs_block(&block) click to toggle source

block of code to execute that contains documentation generation logic

# 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() click to toggle source

Returns true if all options are truthy

# 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