Class: Herdic::Client
- Inherits:
-
Object
- Object
- Herdic::Client
- Defined in:
- lib/herdic/client.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#registry ⇒ Object
readonly
Returns the value of attribute registry.
Instance Method Summary collapse
-
#initialize(file, options) ⇒ Client
constructor
A new instance of Client.
- #load_config(file) ⇒ Object
- #run_all ⇒ Object
Constructor Details
#initialize(file, options) ⇒ Client
Returns a new instance of Client.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/herdic/client.rb', line 17 def initialize(file, ) @file, @options = file, @context = binding @config_file = @options['c'] || Util.find_files_upward(Herdic.config_filename, Herdic.pwd, 1)[0] load_config @config_file if @config_file @printer = Printer.new @options @printer. @config_file @store = Store.new @config_file @registry = @store.data @cookie = (@registry[:_cookie] ||= {}) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
15 16 17 |
# File 'lib/herdic/client.rb', line 15 def config @config end |
#registry ⇒ Object (readonly)
Returns the value of attribute registry.
15 16 17 |
# File 'lib/herdic/client.rb', line 15 def registry @registry end |
Instance Method Details
#load_config(file) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/herdic/client.rb', line 33 def load_config(file) @config = {} File.open(file, 'r') do |f| @config = ERB.new(f.read).result @context end @config = Psych.load @config end |
#run_all ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/herdic/client.rb', line 43 def run_all if @options['e'] FileUtils.cp @file, Herdic.edit_request_file system "%s '%s'" % [Herdic.editor, Herdic.edit_request_file] @specs = Loader.new Herdic.edit_request_file, @file else @specs = Loader.new @file end @specs.each do |spec| # FIXME: figure out better way spec = Psych.dump spec spec = ERB.new(spec).result @context spec = Psych.load spec run spec end @store.save end |