puppetfile-resolver 0.6.2 → 0.6.3

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
  SHA256:
3
- metadata.gz: 8d2fd19452a49b252e661370a59303f2fe7875d199252fd020dd96381f69bc50
4
- data.tar.gz: 8b21cf227604cc8108b8c38fc78e1e2597d6e66cb41465576d0cb2346a8e650f
3
+ metadata.gz: d7673218a6f7c10c7e28ae17d8bc7ebbe7da5d820ae31c4aa10781710aa26c12
4
+ data.tar.gz: a5bdc145cd5bc3233f031617e281d9a0f6927a80057a1a1ea32300cef8ea1004
5
5
  SHA512:
6
- metadata.gz: d00c160ba1f5a6ebd9f62ff4c2a9a45c3d8d931b5d08740d373c3ef4ecea722e6ae2d5d4a366ca5129d13f21016b273ef8e9d6266dc5b6c333067cf0028940b6
7
- data.tar.gz: 44e83526b762ca879863d78e57bf2d56375540e04be507e60561b5d06a3872c4b8a694373215390b6788f2000fb88fa2f27e7313bb34a02fdfeace4dc0152819
6
+ metadata.gz: 8aaeacdba844e37b2090585eaa922352520384271703f06007ce6f658e06e2cb44132ad730d1663060f28376f5018086fcff4b9a6a93363b8e3486c03929ed48
7
+ data.tar.gz: 7c7a6804f9bb7fa4404a50d087f5b931db6cbf31b021cc4bf3c2124489b9b738e65f61887352f0fb531267dfd81a3f54514e67f8e35f39f8457d6676014f984b
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
- [![CI for Puppetfile Resolver](https://github.com/glennsarti/puppetfile-resolver/workflows/CI%20for%20Puppetfile%20Resolver/badge.svg)](https://github.com/glennsarti/puppetfile-resolver/actions?query=workflow%3A%22CI+for+Puppetfile+Resolver%22)
2
- [![Gem Version](https://img.shields.io/gem/v/puppetfile-resolver)](https://rubygems.org/gems/puppetfile-resolver)
1
+ [![ci](https://github.com/puppetlabs/puppetfile-resolver/actions/workflows/ci.yml/badge.svg)](https://github.com/puppetlabs/puppetfile-resolver/actions/workflows/ci.yml)
2
+ [![Gem Version](https://badge.fury.io/rb/puppetfile-resolver.svg)](https://badge.fury.io/rb/puppetfile-resolver)
3
3
 
4
4
  # Puppetfile Resolver
5
5
 
@@ -43,7 +43,7 @@ module PuppetfileResolver
43
43
  private
44
44
 
45
45
  def to_cache_name(name)
46
- ::Digest::SHA256.hexdigest(name) + '.txt'
46
+ "#{::Digest::SHA256.hexdigest(name)}.txt"
47
47
  end
48
48
  end
49
49
  end
@@ -3,9 +3,7 @@
3
3
  module PuppetfileResolver
4
4
  module Models
5
5
  class ModuleDependency
6
- attr_accessor :name
7
- attr_accessor :owner
8
- attr_accessor :version_requirement
6
+ attr_accessor :name, :owner, :version_requirement
9
7
 
10
8
  def initialize(options = {})
11
9
  # Munge the name
@@ -7,11 +7,7 @@ require 'puppetfile-resolver/puppetfile'
7
7
  module PuppetfileResolver
8
8
  module Models
9
9
  class ModuleSpecification
10
- attr_accessor :name
11
- attr_accessor :owner
12
- attr_accessor :version
13
- attr_accessor :origin # Same as R10K module :type
14
- attr_accessor :resolver_flags
10
+ attr_accessor :name, :owner, :version, :origin, :resolver_flags # origin attr same as R10K module :type
15
11
 
16
12
  def initialize(options = {})
17
13
  require 'semantic_puppet'
@@ -5,16 +5,12 @@ require 'puppetfile-resolver/puppetfile/invalid_module'
5
5
  module PuppetfileResolver
6
6
  module Puppetfile
7
7
  class DocumentLocation
8
- attr_accessor :start_line # Base 0
9
- attr_accessor :start_char # Base 0
10
- attr_accessor :end_line # Base 0
11
- attr_accessor :end_char # Base 0
8
+ attr_accessor :start_line, :start_char, :end_line, :end_char # Base 0 # Base 0 # Base 0 # Base 0
12
9
  end
13
10
 
14
11
  class Document
15
- attr_accessor :forge_uri
12
+ attr_accessor :forge_uri, :content
16
13
  attr_reader :modules
17
- attr_accessor :content
18
14
 
19
15
  def initialize(puppetfile_content)
20
16
  @content = puppetfile_content
@@ -5,10 +5,7 @@ require 'puppetfile-resolver/puppetfile/base_module'
5
5
  module PuppetfileResolver
6
6
  module Puppetfile
7
7
  class GitModule < BaseModule
8
- attr_accessor :remote
9
- attr_accessor :ref
10
- attr_accessor :commit
11
- attr_accessor :tag
8
+ attr_accessor :remote, :ref, :commit, :tag
12
9
 
13
10
  def initialize(title)
14
11
  super
@@ -41,7 +41,7 @@ module PuppetfileResolver
41
41
 
42
42
  def find_load_line_number
43
43
  loc = Kernel.caller_locations
44
- .find { |call_loc| call_loc.absolute_path == ::PuppetfileResolver::Puppetfile::Parser::R10KEval::PUPPETFILE_MONIKER }
44
+ .find { |call_loc| call_loc.path == ::PuppetfileResolver::Puppetfile::Parser::R10KEval::PUPPETFILE_MONIKER }
45
45
  loc.nil? ? 0 : loc.lineno - 1 # Line numbers from ruby are base 1
46
46
  end
47
47
  end
@@ -15,8 +15,7 @@ module PuppetfileResolver
15
15
  end
16
16
 
17
17
  def self.to_document_module(title, _args)
18
- mod = ::PuppetfileResolver::Puppetfile::LocalModule.new(title)
19
- mod
18
+ ::PuppetfileResolver::Puppetfile::LocalModule.new(title)
20
19
  end
21
20
  end
22
21
  end
@@ -21,7 +21,7 @@ module PuppetfileResolver
21
21
  rescue StandardError, LoadError => e
22
22
  # Find the originating error from within the puppetfile
23
23
  loc = e.backtrace_locations
24
- .select { |item| item.absolute_path == PUPPETFILE_MONIKER }
24
+ .select { |item| item.path == PUPPETFILE_MONIKER }
25
25
  .first
26
26
  start_line_number = loc.nil? ? 0 : loc.lineno - 1 # Line numbers from ruby are base 1
27
27
  end_line_number = loc.nil? ? puppetfile_contents.lines.count - 1 : loc.lineno - 1 # Line numbers from ruby are base 1
@@ -65,19 +65,19 @@ module PuppetfileResolver
65
65
  def self.post_process_flags!(document)
66
66
  flag_ranges = {}
67
67
  document.content.lines.each_with_index do |line, index|
68
- if (matches = line.match(%r{^\s*# resolver:disable ([A-Za-z\/,]+)(?:\s|$)}))
68
+ if (matches = line.match(%r{^\s*# resolver:disable ([A-Za-z/,]+)(?:\s|$)}))
69
69
  flags_from_line(matches[1]).each do |flag|
70
70
  # Start a flag range if there isn't already one going
71
71
  next unless flag_ranges[flag].nil?
72
72
  flag_ranges[flag] = index
73
73
  end
74
- elsif (matches = line.match(%r{# resolver:disable ([A-Za-z\/,]+)(?:\s|$)}))
74
+ elsif (matches = line.match(%r{# resolver:disable ([A-Za-z/,]+)(?:\s|$)}))
75
75
  flags_from_line(matches[1]).each do |flag|
76
76
  # Assert the flag if we're not already within a range
77
77
  next unless flag_ranges[flag].nil?
78
78
  assert_resolver_flag(document, flag, index, index)
79
79
  end
80
- elsif (matches = line.match(%r{^\s*# resolver:enable ([A-Za-z\/,]+)(?:\s|$)}))
80
+ elsif (matches = line.match(%r{^\s*# resolver:enable ([A-Za-z/,]+)(?:\s|$)}))
81
81
  flags_from_line(matches[1]).each do |flag|
82
82
  # End a flag range if there isn't already one going
83
83
  next if flag_ranges[flag].nil?
@@ -122,8 +122,8 @@ module PuppetfileResolver
122
122
  next if mod.location.start_line.nil? || mod.location.end_line.nil?
123
123
 
124
124
  # If the module doesn't span the range we're looking for (from_line --> to_line) ignore it
125
- next unless mod.location.start_line >= from_line && mod.location.start_line <= to_line ||
126
- mod.location.end_line >= from_line && mod.location.end_line <= to_line
125
+ next unless (mod.location.start_line >= from_line && mod.location.start_line <= to_line) ||
126
+ (mod.location.end_line >= from_line && mod.location.end_line <= to_line)
127
127
  mod.resolver_flags << flag unless mod.resolver_flags.include?(flag)
128
128
  end
129
129
  nil
@@ -3,8 +3,7 @@
3
3
  module PuppetfileResolver
4
4
  module Puppetfile
5
5
  class DocumentValidationErrorBase
6
- attr_accessor :message
7
- attr_accessor :puppet_module
6
+ attr_accessor :message, :puppet_module
8
7
 
9
8
  def initialize(message, puppet_module)
10
9
  @message = message
@@ -79,8 +78,7 @@ module PuppetfileResolver
79
78
  # Resolution Validation Error classes for validating
80
79
  # a valid Puppetfile against a dependency resolution
81
80
  class DocumentResolutionErrorBase < DocumentValidationErrorBase
82
- attr_accessor :puppet_module
83
- attr_accessor :module_specification
81
+ attr_accessor :puppet_module, :module_specification
84
82
 
85
83
  def initialize(message, puppet_module, module_specification)
86
84
  super(message, puppet_module)
@@ -7,8 +7,7 @@ require 'puppetfile-resolver/models'
7
7
 
8
8
  module PuppetfileResolver
9
9
  class Resolver
10
- attr_reader :puppetfile
11
- attr_reader :dependencies_to_resolve
10
+ attr_reader :puppetfile, :dependencies_to_resolve
12
11
 
13
12
  def initialize(puppetfile_document, puppet_version = nil)
14
13
  @puppetfile = puppetfile_document
@@ -7,9 +7,7 @@ require 'puppetfile-resolver/spec_searchers/local_configuration'
7
7
  module PuppetfileResolver
8
8
  module SpecSearchers
9
9
  class Configuration
10
- attr_reader :local
11
- attr_reader :forge
12
- attr_reader :git
10
+ attr_reader :local, :forge, :git
13
11
 
14
12
  def initialize
15
13
  @local = LocalConfiguration.new
@@ -5,7 +5,6 @@ require 'English'
5
5
  require 'puppetfile-resolver/util'
6
6
  require 'puppetfile-resolver/spec_searchers/common'
7
7
  require 'puppetfile-resolver/spec_searchers/git_configuration'
8
- require 'puppetfile-resolver/util'
9
8
  require 'uri'
10
9
 
11
10
  module PuppetfileResolver
@@ -19,11 +19,11 @@ module PuppetfileResolver
19
19
  end
20
20
  return nil if repo_url.nil?
21
21
 
22
- metadata_url = 'https://raw.githubusercontent.com/' + repo_url + '/'
22
+ metadata_url = "https://raw.githubusercontent.com/#{repo_url}/"
23
23
  if puppetfile_module.ref
24
- metadata_url += puppetfile_module.ref + '/'
24
+ metadata_url += "#{puppetfile_module.ref}/"
25
25
  elsif puppetfile_module.tag
26
- metadata_url += puppetfile_module.tag + '/'
26
+ metadata_url += "#{puppetfile_module.tag}/"
27
27
  else
28
28
  # Default to master. Should it raise?
29
29
  metadata_url += 'master/'
@@ -21,11 +21,11 @@ module PuppetfileResolver
21
21
 
22
22
  # Example URL
23
23
  # https://gitlab.com/simp/pupmod-simp-crypto_policy/-/raw/0.1.4/metadata.json
24
- metadata_url = 'https://gitlab.com/' + repo_url + '/-/raw/'
24
+ metadata_url = "https://gitlab.com/#{repo_url}/-/raw/"
25
25
  if puppetfile_module.ref
26
- metadata_url += puppetfile_module.ref + '/'
26
+ metadata_url += "#{puppetfile_module.ref}/"
27
27
  elsif puppetfile_module.tag
28
- metadata_url += puppetfile_module.tag + '/'
28
+ metadata_url += "#{puppetfile_module.tag}/"
29
29
  else
30
30
  # Default to master. Should it raise?
31
31
  metadata_url += 'master/'
@@ -29,7 +29,7 @@ module PuppetfileResolver
29
29
  def self.net_http_get(uri, proxy = nil)
30
30
  uri = URI.parse(uri) unless uri.is_a?(URI)
31
31
 
32
- http_options = { :use_ssl => uri.class == URI::HTTPS }
32
+ http_options = { :use_ssl => uri.instance_of?(URI::HTTPS) }
33
33
  # Because on Windows Ruby doesn't use the Windows certificate store which has up-to date
34
34
  # CA certs, we can't depend on someone setting the environment variable correctly. So use our
35
35
  # static CA PEM file if SSL_CERT_FILE is not set.
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PuppetfileResolver
4
- VERSION ||= '0.6.2'
4
+ VERSION ||= '0.6.3'
5
5
  end
data/puppetfile-cli.rb CHANGED
@@ -72,9 +72,9 @@ else
72
72
  end
73
73
 
74
74
  # Parse the Puppetfile into an object model
75
- content = File.open(options[:path], 'rb') { |f| f.read }
75
+ content = File.binread(options[:path])
76
76
  require 'puppetfile-resolver/puppetfile/parser/r10k_eval'
77
- puppetfile = ::PuppetfileResolver::Puppetfile::Parser::R10KEval.parse(content)
77
+ puppetfile = PuppetfileResolver::Puppetfile::Parser::R10KEval.parse(content)
78
78
 
79
79
  # Make sure the Puppetfile is valid
80
80
  unless puppetfile.valid?
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,31 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ if ENV['COVERAGE'] == 'yes'
4
+ begin
5
+ require 'simplecov'
6
+ require 'simplecov-console'
7
+
8
+ SimpleCov.formatters = [
9
+ SimpleCov::Formatter::HTMLFormatter,
10
+ SimpleCov::Formatter::Console,
11
+ ]
12
+
13
+ SimpleCov.start do
14
+ track_files 'lib/**/*.rb'
15
+ add_filter '/spec'
16
+ add_filter 'lib/puppetfile-resolver/version.rb'
17
+
18
+ add_filter '/docs'
19
+
20
+ # do not track vendored files
21
+ add_filter '/vendor'
22
+ add_filter '/.vendor'
23
+ end
24
+ rescue LoadError
25
+ raise 'Add the simplecov & simplecov-console gems to Gemfile to enable this task'
26
+ end
27
+ end
28
+
3
29
  root = File.join(__dir__,'..',)
4
30
  # Add the language server into the load path
5
31
  $LOAD_PATH.unshift(File.join(root,'lib'))
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puppetfile-resolver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Glenn Sarti
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-21 00:00:00.000000000 Z
11
+ date: 2024-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: molinillo
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: webrick
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.8'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.8'
41
55
  description: Resolves the Puppet Modules in a Puppetfile with a full dependency graph,
42
56
  including Puppet version checks.
43
57
  email:
@@ -126,19 +140,19 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
140
  - !ruby/object:Gem::Version
127
141
  version: '0'
128
142
  requirements: []
129
- rubygems_version: 3.0.3
143
+ rubygems_version: 3.1.6
130
144
  signing_key:
131
145
  specification_version: 4
132
146
  summary: Dependency resolver for Puppetfiles
133
147
  test_files:
134
- - spec/unit/puppetfile-resolver/spec_searchers/git/gclone_spec.rb
148
+ - spec/fixtures/proxy.rb
149
+ - spec/fixtures/modulepath/test_module/README.md
150
+ - spec/fixtures/modulepath/test_module/metadata.json
151
+ - spec/spec_helper.rb
152
+ - spec/integration/deprecation_spec.rb
153
+ - spec/integration/kitchensink_spec.rb
154
+ - spec/integration/proxy_spec.rb
135
155
  - spec/unit/puppetfile-resolver/puppetfile/document_spec.rb
136
156
  - spec/unit/puppetfile-resolver/puppetfile/parser/r10k_eval_spec.rb
157
+ - spec/unit/puppetfile-resolver/spec_searchers/git/gclone_spec.rb
137
158
  - spec/unit/puppetfile-resolver/resolver_spec.rb
138
- - spec/integration/proxy_spec.rb
139
- - spec/integration/kitchensink_spec.rb
140
- - spec/integration/deprecation_spec.rb
141
- - spec/spec_helper.rb
142
- - spec/fixtures/modulepath/test_module/metadata.json
143
- - spec/fixtures/modulepath/test_module/README.md
144
- - spec/fixtures/proxy.rb