ra10ke 2.0.0 → 3.1.0

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.
@@ -5,8 +5,10 @@ require 'table_print'
5
5
  require 'git'
6
6
 
7
7
  module Ra10ke::Dependencies
8
- class Verification
8
+ GOOD_EMOJI = ENV['GOOD_EMOJI'] || '👍'
9
+ BAD_EMOJI = ENV['BAD_EMOJI'] || '😨'
9
10
 
11
+ class Verification
10
12
  def self.version_formats
11
13
  @version_formats ||= {}
12
14
  end
@@ -20,12 +22,10 @@ module Ra10ke::Dependencies
20
22
 
21
23
  Ra10ke::Dependencies::Verification.register_version_format(:semver) do |tags|
22
24
  latest_tag = tags.map do |tag|
23
- begin
24
- Semverse::Version.new tag[/\Av?(.*)\Z/, 1]
25
- rescue Semverse::InvalidVersionFormat
26
- # ignore tags that do not comply to semver
27
- nil
28
- end
25
+ Semverse::Version.new tag[/\Av?(.*)\Z/, 1]
26
+ rescue Semverse::InvalidVersionFormat
27
+ # ignore tags that do not comply to semver
28
+ nil
29
29
  end.select { |tag| !tag.nil? }.sort.last.to_s.downcase
30
30
  latest_ref = tags.detect { |tag| tag[/\Av?(.*)\Z/, 1] == latest_tag }
31
31
  end
@@ -33,8 +33,8 @@ module Ra10ke::Dependencies
33
33
 
34
34
  def initialize(pfile)
35
35
  @puppetfile = pfile
36
- # semver is the default version format.
37
-
36
+ # semver is the default version format.
37
+
38
38
  puppetfile.load!
39
39
  end
40
40
 
@@ -49,22 +49,22 @@ module Ra10ke::Dependencies
49
49
  def ignored_modules
50
50
  # ignore file allows for "don't tell me about this"
51
51
  @ignored_modules ||= begin
52
- File.readlines('.r10kignore').each {|l| l.chomp!} if File.exist?('.r10kignore')
52
+ File.readlines('.r10kignore').each { |l| l.chomp! } if File.exist?('.r10kignore')
53
53
  end || []
54
54
  end
55
-
56
- # @summary creates an array of module hashes with version info
57
- # @param {Object} supplied_puppetfile - the parsed puppetfile object
55
+
56
+ # @summary creates an array of module hashes with version info
57
+ # @param {Object} supplied_puppetfile - the parsed puppetfile object
58
58
  # @returns {Array} array of version info for each module
59
59
  # @note does not include ignored modules or modules up2date
60
60
  def processed_modules(supplied_puppetfile = puppetfile)
61
61
  threads = []
62
62
  threads = supplied_puppetfile.modules.map do |puppet_module|
63
- Thread.new do
64
- begin
63
+ Thread.new do
65
64
  next if ignored_modules.include? puppet_module.title
66
- if puppet_module.class == ::R10K::Module::Forge
67
- module_name = puppet_module.title.gsub('/', '-')
65
+
66
+ if puppet_module.instance_of?(::R10K::Module::Forge)
67
+ module_name = puppet_module.title.tr('/', '-')
68
68
  forge_version = ::PuppetForge::Module.find(module_name).current_release.version
69
69
  installed_version = puppet_module.expected_version
70
70
  {
@@ -72,10 +72,10 @@ module Ra10ke::Dependencies
72
72
  installed: installed_version,
73
73
  latest: forge_version,
74
74
  type: 'forge',
75
- message: installed_version != forge_version ? :outdated : :current
75
+ message: (installed_version == forge_version) ? :current : :outdated,
76
76
  }
77
-
78
- elsif puppet_module.class == R10K::Module::Git
77
+
78
+ elsif puppet_module.instance_of?(R10K::Module::Git)
79
79
  # use helper; avoid `desired_ref`
80
80
  # we do not want to deal with `:control_branch`
81
81
  ref = puppet_module.version
@@ -96,10 +96,10 @@ module Ra10ke::Dependencies
96
96
  # register own version formats with
97
97
  # Ra10ke::Dependencies.register_version_format(:name, &block)
98
98
  latest_ref = get_latest_ref(remote_refs)
99
- elsif ref.match(/^[a-z0-9]{40}$/)
100
- ref = ref.slice(0,8)
99
+ elsif /^[a-z0-9]{40}$/.match?(ref)
100
+ ref = ref.slice(0, 8)
101
101
  # for sha just assume head should be tracked
102
- latest_ref = remote_refs['head'][:sha].slice(0,8)
102
+ latest_ref = remote_refs['head'][:sha].slice(0, 8)
103
103
  else
104
104
  raise "Unable to determine ref type for #{puppet_module.title}"
105
105
  end
@@ -108,26 +108,25 @@ module Ra10ke::Dependencies
108
108
  installed: ref,
109
109
  latest: latest_ref,
110
110
  type: 'git',
111
- message: ref != latest_ref ? :outdated : :current
111
+ message: (ref == latest_ref) ? :current : :outdated,
112
112
  }
113
113
 
114
114
  end
115
115
  rescue R10K::Util::Subprocess::SubprocessError => e
116
- {
117
- name: puppet_module.title,
118
- installed: nil,
119
- latest: nil,
120
- type: :error,
121
- message: e.message
122
- }
123
- end
116
+ {
117
+ name: puppet_module.title,
118
+ installed: nil,
119
+ latest: nil,
120
+ type: :error,
121
+ message: e.message,
122
+ }
124
123
  end
125
124
  end
126
125
  threads.map { |th| th.join.value }.compact
127
126
  end
128
127
 
129
- def outdated(supplied_puppetfile = puppetfile)
130
- processed_modules.find_all do | mod |
128
+ def outdated(_supplied_puppetfile = puppetfile)
129
+ processed_modules.find_all do |mod|
131
130
  mod[:message] == :outdated
132
131
  end
133
132
  end
@@ -139,7 +138,7 @@ module Ra10ke::Dependencies
139
138
  end
140
139
 
141
140
  def define_task_print_git_conversion(*_args)
142
- desc "Convert and print forge modules to git format"
141
+ desc 'Convert and print forge modules to git format'
143
142
  task :print_git_conversion do
144
143
  require 'ra10ke/git_repo'
145
144
  require 'r10k/puppetfile'
@@ -152,26 +151,26 @@ module Ra10ke::Dependencies
152
151
 
153
152
  # ignore file allows for "don't tell me about this"
154
153
  ignore_modules = []
155
- if File.exist?('.r10kignore')
156
- ignore_modules = File.readlines('.r10kignore').each {|l| l.chomp!}
154
+ ignore_modules = File.readlines('.r10kignore').each { |l| l.chomp! } if File.exist?('.r10kignore')
155
+ forge_mods = puppetfile.modules.find_all do |mod|
156
+ mod.instance_of?(R10K::Module::Forge) && mod.v3_module.homepage_url?
157
157
  end
158
- forge_mods = puppetfile.modules.find_all { |mod| mod.instance_of?(R10K::Module::Forge) && mod.v3_module.homepage_url? }
159
-
158
+
160
159
  threads = forge_mods.map do |mod|
161
- Thread.new do
162
- source_url = mod.v3_module.attributes.dig(:current_release, :metadata, :source) || mod.v3_module.homepage_url
160
+ Thread.new do
161
+ source_url = mod.v3_module.attributes.dig(:current_release, :metadata, :source) || mod.v3_module.homepage_url
163
162
  # git:// does not work with ls-remote command, convert to https
164
163
  source_url = source_url.gsub('git://', 'https://')
165
- source_url = source_url.gsub(/\Agit\@(.*)\:(.*)/) do
166
- "https://#{$1}/#{$2}"
164
+ source_url = source_url.gsub(/\Agit@(.*):(.*)/) do
165
+ "https://#{::Regexp.last_match(1)}/#{::Regexp.last_match(2)}"
167
166
  end
168
167
  repo = ::Ra10ke::GitRepo.new(source_url)
169
- ref = repo.get_ref_like(mod.expected_version)
168
+ ref = repo.get_ref_like(mod.expected_version)
170
169
  ref_name = ref ? ref[:name] : "bad url or tag #{mod.expected_version} is missing"
171
170
  <<~EOF
172
- mod '#{mod.name}',
173
- :git => '#{source_url}',
174
- :ref => '#{ref_name}'
171
+ mod '#{mod.name}',
172
+ :git => '#{source_url}',
173
+ :ref => '#{ref_name}'
175
174
 
176
175
  EOF
177
176
  end
@@ -182,13 +181,19 @@ module Ra10ke::Dependencies
182
181
  end
183
182
 
184
183
  def define_task_dependencies(*_args)
185
- desc "Print outdated forge modules"
184
+ desc 'Print outdated forge modules'
186
185
  task :dependencies do
187
186
  PuppetForge.user_agent = "ra10ke/#{Ra10ke::VERSION}"
188
187
  puppetfile = get_puppetfile
189
- PuppetForge.host = puppetfile.forge if puppetfile.forge =~ /^http/
188
+ PuppetForge.host = puppetfile.forge if /^http/.match?(puppetfile.forge)
190
189
  dependencies = Ra10ke::Dependencies::Verification.new(puppetfile)
191
190
  dependencies.print_table(dependencies.outdated)
191
+
192
+ if dependencies.outdated.any?
193
+ abort(BAD_EMOJI + ' Not all modules in the Puppetfile are up2date. '.red + BAD_EMOJI)
194
+ else
195
+ puts(GOOD_EMOJI + ' All modules in the Puppetfile are up2date. '.green + GOOD_EMOJI)
196
+ end
192
197
  end
193
198
  end
194
199
  end
@@ -5,7 +5,7 @@ require 'ra10ke/puppetfile_parser'
5
5
 
6
6
  module Ra10ke::Duplicates
7
7
  def define_task_duplicates(*_args)
8
- desc "Check Puppetfile for duplicates"
8
+ desc 'Check Puppetfile for duplicates'
9
9
  task :duplicates do
10
10
  duplicates = Ra10ke::Duplicates::Verification.new(get_puppetfile.puppetfile_path).duplicates
11
11
  exit_code = 0
@@ -82,20 +82,19 @@ module Ra10ke
82
82
  # :sha=>"fcc0532bbc5a5b65f3941738339e9cc7e3d767ce", :ref=>"refs/pull/249/head", :type=>:pull, :subtype=>:head, :name=>"249"},
83
83
  # :sha=>"8d54891fa5df75890ee15d53080c2a81b4960f92", :ref=>"refs/pull/267/head", :type=>:pull, :subtype=>:head, :name=>"267"}]
84
84
  def all_refs
85
- @all_refs ||= begin
86
- remote_refs.each_with_object([]) do |line, refs|
87
- sha, ref = line.split("\t")
88
- next refs if line.include?('redirecting')
89
- next refs if sha.eql?('ref: refs/heads/master')
90
- _, type, name, subtype = ref.chomp.split('/')
91
- next refs unless name
92
-
93
- type = :tag if type.eql?('tags')
94
- type = type.to_sym
95
- subtype = subtype.to_sym if subtype
96
- type = :branch if type.eql?(:heads)
97
- refs << { sha: sha, ref: ref.chomp, type: type, subtype: subtype, name: name }
98
- end
85
+ @all_refs ||= remote_refs.each_with_object([]) do |line, refs|
86
+ sha, ref = line.split("\t")
87
+ next refs if line.include?('redirecting')
88
+ next refs if sha.eql?('ref: refs/heads/master')
89
+
90
+ _, type, name, subtype = ref.chomp.split('/')
91
+ next refs unless name
92
+
93
+ type = :tag if type.eql?('tags')
94
+ type = type.to_sym
95
+ subtype = subtype.to_sym if subtype
96
+ type = :branch if type.eql?(:heads)
97
+ refs << { sha: sha, ref: ref.chomp, type: type, subtype: subtype, name: name }
99
98
  end
100
99
  end
101
100
 
@@ -105,10 +104,10 @@ module Ra10ke
105
104
  # @return [String] the matching ref_name or nil
106
105
  def get_ref_like(ref_name)
107
106
  return nil unless valid_url?
108
- ref = all_refs.find do |ref|
107
+
108
+ all_refs.find do |ref|
109
109
  ref[:name].include?(ref_name)
110
110
  end
111
- ref
112
111
  end
113
112
 
114
113
  # useful for mocking easily
@@ -1,27 +1,27 @@
1
1
  module Ra10ke::Install
2
2
  def define_task_install(*_args)
3
- desc "Install modules specified in Puppetfile"
3
+ desc 'Install modules specified in Puppetfile'
4
4
  task :install do
5
5
  require 'r10k/puppetfile'
6
6
 
7
7
  puppetfile = get_puppetfile
8
8
  puppetfile.load!
9
9
 
10
- puts "Processing Puppetfile for fixtures"
10
+ puts 'Processing Puppetfile for fixtures'
11
11
  puppetfile.modules.each do |mod|
12
12
  if mod.status == :insync
13
13
  puts "Skipping #{mod.name} (#{mod.version}) already in sync"
14
14
  else
15
- if mod.status == :absent
16
- msg = "installed #{mod.name}"
17
- else
18
- msg = "updated #{mod.name} from #{mod.version} to"
19
- end
15
+ msg = if mod.status == :absent
16
+ "installed #{mod.name}"
17
+ else
18
+ "updated #{mod.name} from #{mod.version} to"
19
+ end
20
20
  mod.sync
21
- if mod.status != :insync
22
- puts "Failed to sync #{mod.name}".red
23
- else
21
+ if mod.status == :insync
24
22
  puts "Successfully #{msg} #{mod.version}".green
23
+ else
24
+ puts "Failed to sync #{mod.name}".red
25
25
  end
26
26
  end
27
27
  end
@@ -18,7 +18,7 @@ class String
18
18
  colorize(33)
19
19
  end
20
20
 
21
- # removes specified markes from string.
21
+ # removes specified markes from string.
22
22
  # @return [String] - the string with markers removed
23
23
  def strip_comment(markers = ['#', "\n"])
24
24
  re = Regexp.union(markers)
@@ -1,90 +1,90 @@
1
- # it might be desirable to parse the Puppetfile as a string instead of evaling it.
1
+ # it might be desirable to parse the Puppetfile as a string instead of evaling it.
2
2
  # this module allows you to do just that.
3
3
  require 'ra10ke/monkey_patches'
4
4
 
5
5
  module Ra10ke
6
- module PuppetfileParser
7
-
8
- # @return [Array] - returns a array of hashes that contain modules with a git source
9
- def git_modules(file = puppetfile)
10
- modules(file).find_all do |mod|
11
- mod[:args].key?(:git)
12
- end
6
+ module PuppetfileParser
7
+ # @return [Array] - returns a array of hashes that contain modules with a git source
8
+ def git_modules(file = puppetfile)
9
+ modules(file).find_all do |mod|
10
+ mod[:args].key?(:git)
13
11
  end
12
+ end
14
13
 
15
- # @return [Array] - returns a array of hashes that contain modules from the Forge
16
- def forge_modules(file = puppetfile)
17
- modules(file).reject do |mod|
18
- mod[:args].key?(:git)
19
- end
14
+ # @return [Array] - returns a array of hashes that contain modules from the Forge
15
+ def forge_modules(file = puppetfile)
16
+ modules(file).reject do |mod|
17
+ mod[:args].key?(:git)
20
18
  end
19
+ end
21
20
 
22
- # @param puppetfile [String] - the absolute path to the puppetfile
23
- # @return [Array] - returns an array of module hashes that represent the puppetfile
24
- # @example
25
- # [{:namespace=>"puppetlabs", :name=>"stdlib", :args=>[]},
26
- # {:namespace=>"petems", :name=>"swap_file", :args=>["'4.0.0'"]}]
27
- def modules(puppetfile)
28
- @modules ||= begin
29
- return [] unless File.exist?(puppetfile)
30
- all_lines = File.read(puppetfile).lines.map(&:strip_comment)
31
- # remove comments from all the lines
32
- lines_without_comments = all_lines.reject { |line| line.match(/#.*\n/) || line.empty? }.join("\n")
33
- lines_without_comments.split(/^mod/).map do |line|
34
-
35
- next nil if line =~ /^forge/
36
- next nil if line.empty?
21
+ # @param puppetfile [String] - the absolute path to the puppetfile
22
+ # @return [Array] - returns an array of module hashes that represent the puppetfile
23
+ # @example
24
+ # [{:namespace=>"puppetlabs", :name=>"stdlib", :args=>[]},
25
+ # {:namespace=>"petems", :name=>"swap_file", :args=>["'4.0.0'"]}]
26
+ def modules(puppetfile)
27
+ @modules ||= begin
28
+ return [] unless File.exist?(puppetfile)
37
29
 
38
- parse_module_args(line)
39
- end.compact.uniq
40
- end
41
- end
30
+ all_lines = File.read(puppetfile).lines.map(&:strip_comment)
31
+ # remove comments from all the lines
32
+ lines_without_comments = all_lines.reject { |line| line.match(/#.*\n/) || line.empty? }.join("\n")
33
+ lines_without_comments.split(/^mod/).map do |line|
34
+ next nil if /^forge/.match?(line)
35
+ next nil if line.empty?
42
36
 
43
- # @param data [String] - the string to parse the puppetfile args out of
44
- # @return [Array] - an array of arguments in hash form
45
- # @example
46
- # {:namespace=>"puppetlabs", :name=>"stdlib", :args=>[]}
47
- # {:namespace=>"petems", :name=>"swap_file", :args=>["'4.0.0'"]}
48
- def parse_module_args(data)
49
- return {} if data.empty?
50
- args = data.split(',').map(&:strip)
51
- # we can't guarantee that there will be a namespace when git is used
52
- # remove quotes and dash and slash
53
- namespace, name = args.shift.gsub(/'|"/, '').split(%r{-|/})
54
- name ||= namespace
55
- namespace = nil if namespace == name
56
- {
57
- namespace: namespace,
58
- name: name,
59
- args: process_args(args)
60
- }
37
+ parse_module_args(line)
38
+ end.compact.uniq
61
39
  end
40
+ end
41
+
42
+ # @param data [String] - the string to parse the puppetfile args out of
43
+ # @return [Array] - an array of arguments in hash form
44
+ # @example
45
+ # {:namespace=>"puppetlabs", :name=>"stdlib", :args=>[]}
46
+ # {:namespace=>"petems", :name=>"swap_file", :args=>["'4.0.0'"]}
47
+ def parse_module_args(data)
48
+ return {} if data.empty?
49
+
50
+ args = data.split(',').map(&:strip)
51
+ # we can't guarantee that there will be a namespace when git is used
52
+ # remove quotes and dash and slash
53
+ namespace, name = args.shift.gsub(/'|"/, '').split(%r{-|/})
54
+ name ||= namespace
55
+ namespace = nil if namespace == name
56
+ {
57
+ namespace: namespace,
58
+ name: name,
59
+ args: process_args(args),
60
+ }
61
+ end
62
62
 
63
- # @return [Array] - returns an array of hashes with the args in key value pairs
64
- # @param [Array] - the arguments processed from each entry in the puppetfile
65
- # @example
66
- # [{:args=>[], :name=>"razor", :namespace=>"puppetlabs"},
67
- # {:args=>[{:version=>"0.0.3"}], :name=>"ntp", :namespace=>"puppetlabs"},
68
- # {:args=>[], :name=>"inifile", :namespace=>"puppetlabs"},
69
- # {:args=>
70
- # [{:git=>"https://github.com/nwops/reportslack.git"}, {:ref=>"1.0.20"}],
71
- # :name=>"reportslack",
72
- # :namespace=>"nwops"},
73
- # {:args=>{:git=>"git://github.com/puppetlabs/puppetlabs-apt.git"},
74
- # :name=>"apt",
75
- # :namespace=>nil}
76
- # ]
77
- def process_args(args)
78
- results = {}
79
- args.each do |arg|
80
- a = arg.gsub(/'|"/, '').split(/\A\:|\:\s|\=\>/).map(&:strip).reject(&:empty?)
81
- if a.count < 2
82
- results[:version] = a.first
83
- else
84
- results[a.first.to_sym] = a.last
85
- end
63
+ # @return [Array] - returns an array of hashes with the args in key value pairs
64
+ # @param [Array] - the arguments processed from each entry in the puppetfile
65
+ # @example
66
+ # [{:args=>[], :name=>"razor", :namespace=>"puppetlabs"},
67
+ # {:args=>[{:version=>"0.0.3"}], :name=>"ntp", :namespace=>"puppetlabs"},
68
+ # {:args=>[], :name=>"inifile", :namespace=>"puppetlabs"},
69
+ # {:args=>
70
+ # [{:git=>"https://github.com/nwops/reportslack.git"}, {:ref=>"1.0.20"}],
71
+ # :name=>"reportslack",
72
+ # :namespace=>"nwops"},
73
+ # {:args=>{:git=>"git://github.com/puppetlabs/puppetlabs-apt.git"},
74
+ # :name=>"apt",
75
+ # :namespace=>nil}
76
+ # ]
77
+ def process_args(args)
78
+ results = {}
79
+ args.each do |arg|
80
+ a = arg.gsub(/'|"/, '').split(/\A:|:\s|=>/).map(&:strip).reject(&:empty?)
81
+ if a.count < 2
82
+ results[:version] = a.first
83
+ else
84
+ results[a.first.to_sym] = a.last
86
85
  end
87
- results
88
86
  end
87
+ results
89
88
  end
89
+ end
90
90
  end
data/lib/ra10ke/solve.rb CHANGED
@@ -27,18 +27,16 @@ module Ra10ke::Solve
27
27
  PuppetForge.user_agent = "ra10ke/#{Ra10ke::VERSION}"
28
28
  puppetfile = get_puppetfile
29
29
  puppetfile.load!
30
- PuppetForge.host = puppetfile.forge if puppetfile.forge =~ /^http/
30
+ PuppetForge.host = puppetfile.forge if /^http/.match?(puppetfile.forge)
31
31
 
32
32
  # ignore file allows for "don't tell me about this"
33
33
  ignore_modules = []
34
- if File.exist?('.r10kignore')
35
- ignore_modules = File.readlines('.r10kignore').each(&:chomp!)
36
- end
34
+ ignore_modules = File.readlines('.r10kignore').each(&:chomp!) if File.exist?('.r10kignore')
37
35
  # Actual new logic begins here:
38
- cache = (ENV['XDG_CACHE_DIR'] || File.expand_path('~/.cache'))
36
+ cache = ENV['XDG_CACHE_DIR'] || File.expand_path('~/.cache')
39
37
 
40
38
  FileUtils.mkdir_p(cache)
41
-
39
+
42
40
  # Metadata cache, since the Forge is slow:
43
41
  @metadata_cache = YAML::Store.new File.join(cache, 'ra10ke.metadata_cache')
44
42
  # The graph of available module versions
@@ -54,7 +52,8 @@ module Ra10ke::Solve
54
52
 
55
53
  puppetfile.modules.each do |puppet_module|
56
54
  next if ignore_modules.include? puppet_module.title
57
- if puppet_module.class == R10K::Module::Forge
55
+
56
+ if puppet_module.instance_of?(R10K::Module::Forge)
58
57
  module_name = puppet_module.title.tr('/', '-')
59
58
  installed_version = puppet_module.expected_version
60
59
  puts "Processing Forge module #{module_name}-#{installed_version}"
@@ -81,7 +80,8 @@ module Ra10ke::Solve
81
80
  add_reqs_to_graph(mod, meta)
82
81
  end
83
82
 
84
- next unless puppet_module.class == R10K::Module::Git
83
+ next unless puppet_module.instance_of?(R10K::Module::Git)
84
+
85
85
  # This downloads the git module to modules/modulename
86
86
  meta = fetch_git_metadata(puppet_module)
87
87
  version = get_key_or_sym(meta, :version)
@@ -97,9 +97,7 @@ module Ra10ke::Solve
97
97
  end
98
98
  puts
99
99
  puts 'Resolving dependencies...'
100
- if allow_major_bump
101
- puts 'WARNING: Potentially breaking updates are allowed for this resolution'
102
- end
100
+ puts 'WARNING: Potentially breaking updates are allowed for this resolution' if allow_major_bump
103
101
  result = Solve.it!(@graph, @demands, sorted: true)
104
102
  puts
105
103
  print_module_diff(@current_modules, result)
@@ -130,7 +128,7 @@ module Ra10ke::Solve
130
128
  return {
131
129
  version: '0.0.0',
132
130
  name: puppet_module.title,
133
- dependencies: []
131
+ dependencies: [],
134
132
  }
135
133
  end
136
134
  metadata = R10K::Module::MetadataFile.new(metadata_path)
@@ -138,7 +136,7 @@ module Ra10ke::Solve
138
136
  {
139
137
  version: metadata.version,
140
138
  name: metadata.name,
141
- dependencies: metadata.dependencies
139
+ dependencies: metadata.dependencies,
142
140
  }
143
141
  end
144
142
 
@@ -150,7 +148,7 @@ module Ra10ke::Solve
150
148
  # At least puppet-extlib has malformed metadata
151
149
  def get_version_req(dep)
152
150
  req = get_key_or_sym(dep, :version_requirement)
153
- req = get_key_or_sym(dep, :version_range) unless req
151
+ req ||= get_key_or_sym(dep, :version_range)
154
152
  req
155
153
  end
156
154
 
@@ -186,17 +184,14 @@ module Ra10ke::Solve
186
184
  # actually ask the solver for the versioned thing
187
185
  @demands.add(name) unless no_demands
188
186
  ver = get_version_req(dep)
189
- unless ver
190
- # no version specified, so anything will do
191
- ver = '>=0.0.0'
192
- end
193
- ver.split(/(?=[<])/).each do |bound|
187
+ ver ||= '>=0.0.0'
188
+ ver.split(/(?=<)/).each do |bound|
194
189
  bound.strip!
195
190
  v = begin
196
- Semverse::Constraint.new(bound)
197
- rescue
198
- nil
199
- end
191
+ Semverse::Constraint.new(bound)
192
+ rescue StandardError
193
+ nil
194
+ end
200
195
  if v
201
196
  artifact.depends(name, v.to_s)
202
197
  else
@@ -206,14 +201,16 @@ module Ra10ke::Solve
206
201
  # Find the dependency in the forge, unless it's already been processed
207
202
  # and add its releases to the global graph
208
203
  next unless @processed_modules.add?(name)
204
+
209
205
  puts "Fetching module info for #{name}"
210
206
  mod = begin
211
- PuppetForge::Module.find(name)
212
- rescue
213
- # It's probably a git module
214
- nil
215
- end
207
+ PuppetForge::Module.find(name)
208
+ rescue StandardError
209
+ # It's probably a git module
210
+ nil
211
+ end
216
212
  next unless mod # Git module, or non-forge dependency. Skip to next for now.
213
+
217
214
  # Fetching metadata for all releases takes ages (which is weird, since it's mostly static info)
218
215
  mod.releases.take(FETCH_LIMIT).each do |rel|
219
216
  meta = get_release_metadata(name, rel)
data/lib/ra10ke/syntax.rb CHANGED
@@ -1,18 +1,16 @@
1
1
  module Ra10ke::Syntax
2
2
  def define_task_syntax(*_args)
3
- desc "Syntax check Puppetfile"
3
+ desc 'Syntax check Puppetfile'
4
4
  task :syntax do
5
5
  require 'r10k/action/puppetfile/check'
6
6
 
7
7
  puppetfile = R10K::Action::Puppetfile::Check.new({
8
- :root => @basedir,
9
- :moduledir => @moduledir,
10
- :puppetfile => @puppetfile_path
11
- }, '')
8
+ root: @basedir,
9
+ moduledir: @moduledir,
10
+ puppetfile: @puppetfile_path,
11
+ }, '')
12
12
 
13
- unless puppetfile.call
14
- abort("Puppetfile syntax check failed")
15
- end
13
+ abort('Puppetfile syntax check failed') unless puppetfile.call
16
14
  end
17
15
  end
18
16
  end
@@ -8,7 +8,6 @@ require 'ra10ke/git_repo'
8
8
 
9
9
  module Ra10ke
10
10
  module Validate
11
-
12
11
  GOOD_EMOJI = ENV['GOOD_EMOJI'] || '👍'
13
12
  BAD_EMOJI = ENV['BAD_EMOJI'] || '😨'
14
13
 
@@ -64,7 +63,7 @@ module Ra10ke
64
63
  ref: ref,
65
64
  valid_url?: repo.valid_url?,
66
65
  valid_ref?: valid_ref,
67
- status: valid_ref ? Ra10ke::Validate::GOOD_EMOJI : Ra10ke::Validate::BAD_EMOJI
66
+ status: valid_ref ? Ra10ke::Validate::GOOD_EMOJI : Ra10ke::Validate::BAD_EMOJI,
68
67
  }
69
68
  end
70
69
  end
@@ -1,3 +1,3 @@
1
1
  module Ra10ke
2
- VERSION = "2.0.0"
2
+ VERSION = '3.1.0'
3
3
  end
data/lib/ra10ke.rb CHANGED
@@ -48,7 +48,8 @@ module Ra10ke
48
48
  def get_puppetfile
49
49
  R10K::Puppetfile.new(@basedir, @moduledir, @puppetfile_path, @puppetfile_name, @force)
50
50
  rescue ArgumentError # R10k < 2.6.0
51
- R10K::Puppetfile.new(@basedir, @moduledir, @puppetfile_path || File.join(@basedir, @puppetfile_name || 'Puppetfile'))
51
+ R10K::Puppetfile.new(@basedir, @moduledir,
52
+ @puppetfile_path || File.join(@basedir, @puppetfile_name || 'Puppetfile'))
52
53
  end
53
54
  end
54
55
  end