Class: Werk::Base
- Inherits:
-
Object
- Object
- Werk::Base
- Defined in:
- lib/werk/base.rb
Instance Method Summary collapse
-
#initialize(runtime_options = {}) ⇒ Base
constructor
A new instance of Base.
- #requires_variables(vars) ⇒ Object
Methods included from Commands
#list, #markaccepted, #markfortest, #markrejected, #mergeandclose, #show, #start
Methods included from Git
#repo_branch, #repo_checkout, #repo_current_head, #repo_merge, #repo_pull, #repo_push
Methods included from Trac
#ticket_actions, #ticket_annotate, #ticket_list, #ticket_show
Constructor Details
#initialize(runtime_options = {}) ⇒ Base
Returns a new instance of Base.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/werk/base.rb', line 14 def initialize( = {}) if [:rcfile] && File.file?([:rcfile]) # If the user explicitly specified an rcfile, just use that instead = YAML.load_file(File.([:rcfile])) else # Go all the way to the root looking for .werkrcs, then apply them in # reverse order to ensure local changes trump more global ones current = Dir.pwd = {} loop do %w( .werkrc ).each do |file| if File.file?(file) # Do this backwards so we give more nested files precendece puts "Loading options from #{File.join(Dir.pwd,file)}" if [:verbose] = YAML.load_file(file).merge() end end pwd = Dir.pwd Dir.chdir("..") break if pwd == Dir.pwd # if changing the directory made no difference, then we're at the top end Dir.chdir(current) end # Now read in any explicitly specified arguments .merge!() .each do |option, value| self.instance_variable_set "@#{option.to_s}", value end end |
Instance Method Details
#requires_variables(vars) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/werk/base.rb', line 46 def requires_variables(vars) vars.each do |option| if !self.instance_variable_defined? "@#{option}" puts(<<-EOM) You need to specify a value for #{option}. To do so, add a line like #{option}: <value> to your ~/.werkrc file (or any other .werkrc up the directory hierarchy) EOM exit end end end |