Module: Antsy

Defined in:
lib/antsy.rb,
lib/antsy/version.rb

Constant Summary collapse

VERSION =
'0.0.7'

Class Method Summary collapse

Class Method Details

.argsObject

parse the specified file, whose contents look like this:

arg1=foo arg2=bar

and return a hash like this:

{:arg1 => 'foo', :arg2 => 'bar'}


11
12
13
14
15
# File 'lib/antsy.rb', line 11

def self.args()
  Hash[
    Shellwords::shellwords(File.read(ARGV.first)).map { |kv| kv.split('=') }
  ].inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
end

.changed!(data = {}) ⇒ Object



22
23
24
25
26
# File 'lib/antsy.rb', line 22

def self.changed!(data={})
  data[:changed] = true
  puts data.to_json
  exit 0
end

.fail!(msg) ⇒ Object



17
18
19
20
# File 'lib/antsy.rb', line 17

def self.fail!(msg)
  puts ({ 'failed' => true, 'msg' => msg }.to_json)
  exit 1
end

.no_change!(data = {}) ⇒ Object



28
29
30
31
32
# File 'lib/antsy.rb', line 28

def self.no_change!(data={})
  data[:changed] = false
  puts data.to_json
  exit 0
end

.skipped!(msg = '') ⇒ Object



34
35
36
37
# File 'lib/antsy.rb', line 34

def self.skipped!(msg = '')
  puts ({ 'skipped' => true, 'changed' => false, 'msg' => msg }.to_json)
  exit 0
end