small-ops 0.0.1.pre → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/small-setup.rb +23 -2
  2. metadata +4 -4
data/lib/small-setup.rb CHANGED
@@ -17,15 +17,24 @@ OptionParser.new do |opts|
17
17
  opts.on("-p", "--prefix prefix", "Set etcd prefix path") do |p|
18
18
  options[:prefix] = p
19
19
  end
20
- opts.on("-d","--daemon","what") do |d|
20
+ opts.on("-d","--daemon","Run in background") do |d|
21
21
  options[:daemon]=d
22
22
  end
23
+ opts.on("-o","--output file","Output file") do |o|
24
+ options[:output]=o
25
+ end
26
+ opts.on("-i","--input file","Input file") do |o|
27
+ options[:input]=o
28
+ end
23
29
  end.parse!
24
30
 
31
+
25
32
  @host = options[:host] || ENV['HOST'] || `hostname -I | awk '{ print $1 }'`.gsub("\n","")
26
33
  @etcd = options[:etcd] || ENV['ETCD'] || "http://#{@host}:4001"
27
34
  @prefix = options[:prefix] || ENV['PREFIX'] || ""
28
- @foreground = !options[:daemon] || true
35
+ @foreground = !options[:daemon]
36
+ @output = options[:output] || false
37
+ @input = options[:input] || false
29
38
 
30
39
  def http_get(uri)
31
40
  JSON.parse(Net::HTTP.get(URI(uri)))
@@ -84,3 +93,15 @@ def eflatten(obj)
84
93
  flat
85
94
  end
86
95
 
96
+ def nodes2obj(nodes,prefix)
97
+ obj={}
98
+ nodes.each {|node|
99
+ if node['dir'] && node['nodes'] then
100
+ obj[node['key'].gsub(prefix,'')]=nodes2obj( node['nodes'],"#{ node['key'] }/" )
101
+ elsif node['value'] then
102
+ obj[node['key'].gsub(prefix,'')]=node['value']
103
+ end
104
+ }
105
+ obj
106
+ end
107
+
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: small-ops
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.pre
5
- prerelease: 6
4
+ version: 0.0.2
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Diogo Silva
@@ -38,9 +38,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
38
38
  required_rubygems_version: !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
- - - ! '>'
41
+ - - ! '>='
42
42
  - !ruby/object:Gem::Version
43
- version: 1.3.1
43
+ version: '0'
44
44
  requirements: []
45
45
  rubyforge_project:
46
46
  rubygems_version: 1.8.23