cloudit 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9698e9e003bc1317857063ac382f2e1054ad0fca
4
- data.tar.gz: fb1f1b669dac2d26ed3f06a502c3127969c34e37
3
+ metadata.gz: 58af5bbdd5276b9e5596fad6b504129f8d438612
4
+ data.tar.gz: a5fa42dd4af059fe179ab29777ae4274d6f97e68
5
5
  SHA512:
6
- metadata.gz: fafa4668b2e3640249ce14c4f3713f2e2e70f98c87a585f219ffc65449a18b542d63ffe8ceb3d32c542d04a6c7516e924d424a45403c9aabdc5c09e941ffbdb9
7
- data.tar.gz: e35911cc498ead53dc55942d98be95e2e62b1690eb9846ce9525753840a0ccf96de1ccd2e23a679dfe72629f1672781175c653aec568af26e14bd28c1833f4ce
6
+ metadata.gz: 2338ee06ff38001e96bf14c69e6ebaf3cab89440dabf211d8760bdb5d408e57dbbd077a23ce462dc67c2b7ee15ad904174ae27f4d74b21aad27254d2a77f63a3
7
+ data.tar.gz: 23bfdcbcab880040ac328b2a26a541534a89c81b9d76321fb3d0a2fd7728250f75afd71db7b41b4cc7ba683247de989f4cae8acace27275d072f6563c0d09973
@@ -5,19 +5,16 @@ class Cloudit::Command::Base
5
5
  attr_accessor :parser, :slop_opts
6
6
  end
7
7
 
8
- attr_accessor :commands
9
-
10
8
  VALID_METHODS = []
11
9
  OPTION_NAME_OFFSET = 6
12
10
 
13
- def initialize(args=[], commands)
11
+ def initialize(args=[])
14
12
  @method = if args[0].is_a?(String) && args[0].include?('-')
15
13
  nil
16
14
  else
17
15
  args.shift.strip rescue nil
18
16
  end
19
17
  @opts = parser.parse(args)
20
- @commands = commands
21
18
  end
22
19
 
23
20
  def execute
@@ -15,30 +15,31 @@ class Cloudit::Command::Generate < Cloudit::Command::Base
15
15
  if @opts.help?
16
16
  $stdout.puts slop_opts
17
17
  else
18
- generate_json
18
+ out = @opts[:output]
19
+ dir = normalize_directory @opts[:directory]
20
+
21
+ if File.exist? out
22
+ if out.eql? DEFAULT_OUT_FILE
23
+ i = 1
24
+ while File.exist? out
25
+ i += 1
26
+ out = "out#{i}.json"
27
+ end
28
+ else
29
+ $stdout.puts "cloudit: output file '#{out}' already exists"
30
+ return
31
+ end
32
+ end
33
+
34
+ json = generate_json(dir)
35
+ $stdout.puts json
36
+ File.new(out, 'w').write "#{json}\n"
19
37
  end
20
38
  end
21
39
 
22
- private
23
-
24
- def generate_json
40
+ def generate_json(dir='.')
25
41
  hash = {}
26
42
  hash_sections = {}
27
- out = @opts[:output]
28
- dir = normalize_directory @opts[:directory]
29
-
30
- if File.exist? out
31
- if out.eql? DEFAULT_OUT_FILE
32
- i = 1
33
- while File.exist? out
34
- i += 1
35
- out = "out#{i}.json"
36
- end
37
- else
38
- $stdout.puts "cloudit: output file '#{out}' already exists"
39
- return
40
- end
41
- end
42
43
 
43
44
  unless File.directory? dir
44
45
  $stdout.puts "cloudit: '#{dir}' must be a directory"
@@ -48,7 +49,7 @@ class Cloudit::Command::Generate < Cloudit::Command::Base
48
49
  for file in Dir.glob(Dir["#{dir}**/*.#{DEFAULT_MAIN_CFN_EXTENSION}"]) do
49
50
  yml = YAML::load_file(file)
50
51
  if yml.is_a?(Hash)
51
- hash.merge! YAML::load_file(file)
52
+ hash.merge! yml
52
53
  end
53
54
  end
54
55
 
@@ -67,10 +68,11 @@ class Cloudit::Command::Generate < Cloudit::Command::Base
67
68
 
68
69
  hash.merge! hash_sections
69
70
 
70
- $stdout.puts hash.to_json
71
- File.new(out, 'w').write "#{hash.to_json}\n"
71
+ hash.to_json
72
72
  end
73
73
 
74
+ private
75
+
74
76
  def normalize_directory(dir)
75
77
  if dir.end_with? '/'
76
78
  dir
@@ -1,3 +1,3 @@
1
1
  module Cloudit
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zachary Chai
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-05 00:00:00.000000000 Z
11
+ date: 2016-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: slop