generate-puppetfile 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- OWExOWZiYjAzNDk1NGFkYTAwMzBkMDAxMWU1NTdkMzQzNDdkNTc2Ng==
4
+ NDRjNTE2ZWYzNGU0MDNhNWYxYmYzYTg3MWI2NTc1YTJkNzlkM2U5Yg==
5
5
  data.tar.gz: !binary |-
6
- N2JlNDViOTUyODBmNDE5OGU2YjU3OTQ3YWJlMjg3Y2ExNDRkMGEyOA==
6
+ Y2JkNjk3MWUyOTU4NDRjYzIwNTM4YWQ2YzU2YTA1ZjI1ZGNlYTkwNQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MjBmNzMwYTBlODI5MTc0ZjQ5NzQwMGVkOGRhYzFmZjYyMTZkYTMyYmMxOTE2
10
- YTZhMjY4NTNiM2RiZGMyMjlmNzk5MWNkMzczYWMyYTIwODA0MTQyZjIyM2Zh
11
- MDczY2UzODQ1NmZhNTM0YjIzOTYxYTZiYmU2MThkMGFkZDRhMjY=
9
+ MmUxMTMwYjRmODdhZjk5OTE2Y2YwOTY2MTYwNjY4OTYyZTEzNjcwZDAwYTBh
10
+ MmI0YmIyMjA4ZGE5NzM4NmFiNmFkMzI4ZDYyZWFjYzU3NDQ0OGQ4NDQ1MDM2
11
+ NmZlYzAwMDg5NWM4MWZmY2U4NjJmYjg4ODlkM2NkMTcyNGFiNzE=
12
12
  data.tar.gz: !binary |-
13
- NDA3MTI0MTg4ZmQxYjUyMjI4ZDM2NTQyYWZmYmE1YzAwYjNmNzc0MDc3NjA4
14
- ODU5YjZlMzBmZTRhZDQ5YTRmMmRlOTY4NzYwYWNkYjQwNGIzZTBjNmM0OWIz
15
- MDMzYTgwNzdjZjI0OWE0MWU3MTBkNWZlYjI4YzEyZmI0NTQ2ZWM=
13
+ MjdmN2YzYWJkOTY3MzY1NmQ5ZmYzNzFlNDg2YjMwM2ExNzBkYWFiODc3NTdh
14
+ MDdkMmUzZTViNDYzMjNkOGNhMTlhM2FjZjNiYjJlYjk3NWVkODY1NzY5YzVj
15
+ NGUzZWY2MzUxYTk5NmI3M2MxZjM0YjkyYWU3Nzk0YWFhNmEzYTM=
@@ -2,6 +2,7 @@
2
2
  require 'generate_puppetfile'
3
3
  require 'generate_puppetfile/optparser'
4
4
  require 'fileutils'
5
+ require 'tempfile'
5
6
 
6
7
  module GeneratePuppetfile
7
8
  # Internal: The Bin class contains the logic for calling generate_puppetfile at the command line
@@ -45,7 +46,7 @@ module GeneratePuppetfile
45
46
  end
46
47
 
47
48
  puppetfile_contents = Hash.new
48
- extras = Array.new
49
+ extras = []
49
50
  if @options[:puppetfile]
50
51
  puts "\nProcessing the puppetfile '#{@options[:puppetfile]}'...\n\n" if @options[:debug]
51
52
  puppetfile_contents = read_puppetfile(@options[:puppetfile])
@@ -58,7 +59,7 @@ module GeneratePuppetfile
58
59
  list_forge_modules(forge_module_list) if puppetfile_contents && @options[:debug]
59
60
  list_extras(puppetfile_contents[:extras]) if puppetfile_contents[:extras] && @options[:debug]
60
61
 
61
- generate_puppetfile_contents(forge_module_list, puppetfile_contents[:extras])
62
+ generate_puppetfile_contents(forge_module_list, extras)
62
63
 
63
64
  return 0
64
65
  end
@@ -117,12 +118,16 @@ module GeneratePuppetfile
117
118
  #
118
119
  # module_list is an array of forge module names to be downloaded
119
120
  # extras is an array of strings
120
- def generate_puppetfile_contents (module_list, extras = [])
121
- workspace = `mktemp -d`
121
+ def generate_puppetfile_contents (module_list, extras)
122
+ unless module_list != [] || extras != []
123
+ puts "\nNo valid modules or existing Puppetfile content was found. Exiting.\n\n"
124
+ exit 1
125
+ end
126
+
127
+ workspace = Dir.mktmpdir
122
128
 
123
129
  modulepath = "--modulepath #{workspace.chomp} "
124
130
  silence = '>/dev/null 2>&1 '
125
- strip_colors = 'sed -r "s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g"'
126
131
 
127
132
  puts "\nInstalling modules. This may take a few minutes.\n"
128
133
  module_list.each do |name|
@@ -138,16 +143,16 @@ forge 'http://forge.puppetlabs.com'
138
143
  # Modules discovered by generate-puppetfile
139
144
  EOF
140
145
 
141
- puppetfile_body = `puppet module list #{modulepath} 2>/dev/null | #{strip_colors}`
142
- puts puppetfile_body
146
+ puppetfile_body = `puppet module list #{modulepath} 2>/dev/null`
143
147
 
148
+ puppetfile_body.gsub!(/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]/, '') # Strips ANSI color codes
144
149
  puppetfile_body.gsub!(/^\/.*$/, '')
145
- puppetfile_body.gsub!(/-/, '/')
146
- puppetfile_body.gsub!(/├── /, "mod '")
147
- puppetfile_body.gsub!(/└── /, "mod '")
148
- puppetfile_body.gsub!(/ \(v/, "', '")
149
- puppetfile_body.gsub!(/\)$/, "'")
150
- puppetfile_body.gsub!(/^$\n/, '')
150
+ puppetfile_body.gsub!(/-/, '/')
151
+ puppetfile_body.gsub!(/├── /, "mod '")
152
+ puppetfile_body.gsub!(/└── /, "mod '")
153
+ puppetfile_body.gsub!(/ \(v/, "', '")
154
+ puppetfile_body.gsub!(/\)$/, "'")
155
+ puppetfile_body.gsub!(/^$\n/, '')
151
156
 
152
157
  puppetfile_footer = "# Discovered elements from existing Puppetfile\n"
153
158
  extras.each do |line|
@@ -1,3 +1,3 @@
1
1
  module GeneratePuppetfile
2
- VERSION = '0.9.2'
2
+ VERSION = '0.9.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: generate-puppetfile
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Nelson