rake_dependencies 3.2.0.pre.1 → 3.2.0.pre.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ff0040b6de7eae489ffd4ca26d423c592530c4d232b1a679c43e1408b59a6dcb
4
- data.tar.gz: 64d3c088c2fef067c3a1160a26538a1b75d97e77046c996bad87b89d07dca2c6
3
+ metadata.gz: 7673875792fa643d0d18a5f5b643792d89fa184c501e9db8052de4399c603a6f
4
+ data.tar.gz: a1fb8a84cb4ad9c60a327a9218849c34fa2573ee007190d8155347f5b5bf8a6b
5
5
  SHA512:
6
- metadata.gz: 353cadba1e2eb8c3c5121e0bc91f03943627159085474bac701c7a1a3691bc0b7f23165b3ecac9e21c6d76e227c865914a007b73b259710a448a06b7d80a0d56
7
- data.tar.gz: 35fd09975af2963cc682892aea8419b1aea5394b39658111aabae3d770f5bc51783dcb22b4c420366c3b8b8231c41ca83f094580f0136d01e4062993ad996f18
6
+ metadata.gz: fd2a1a5320c1f4e76b67ddc723d6490bd0c388aed9a30a60b8de7b41c15e2257f8847c56c644ce994ab34a2524b1a0e930e8e5ba951d6871e1cb5fd03d5a09f8
7
+ data.tar.gz: 1bd4f1e7097dcf8c1e0fdf9b49c3adaf3bbd8691f2e3d3db8ddd7ab25a1ce1a2ab876df1b69420bee130f86355630ff456265fbd0353fb6e86fbcbfc256b0543
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Specify your gem's dependencies in rake_dependencies.gemspec
data/Gemfile.lock CHANGED
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rake_dependencies (3.2.0.pre.1)
4
+ rake_dependencies (3.2.0.pre.4)
5
+ down (~> 5.3)
5
6
  hamster (~> 3.0)
6
7
  minitar (~> 0.9)
7
8
  rake_factory (~> 0.23)
@@ -17,11 +18,14 @@ GEM
17
18
  tzinfo (~> 2.0)
18
19
  addressable (2.8.0)
19
20
  public_suffix (>= 2.0.2, < 5.0)
21
+ ast (2.4.2)
20
22
  colored2 (3.1.2)
21
- concurrent-ruby (1.1.9)
23
+ concurrent-ruby (1.1.10)
22
24
  diff-lcs (1.5.0)
23
25
  docile (1.4.0)
24
- excon (0.92.0)
26
+ down (5.3.1)
27
+ addressable (~> 2.8)
28
+ excon (0.92.2)
25
29
  fakefs (1.4.1)
26
30
  faraday (1.10.0)
27
31
  faraday-em_http (~> 1.0)
@@ -61,7 +65,11 @@ GEM
61
65
  faraday (>= 0.9)
62
66
  sawyer (~> 0.8.0, >= 0.5.3)
63
67
  open4 (1.3.4)
68
+ parallel (1.22.1)
69
+ parser (3.1.1.0)
70
+ ast (~> 2.4.1)
64
71
  public_suffix (4.0.6)
72
+ rainbow (3.1.1)
65
73
  rake (13.0.6)
66
74
  rake_circle_ci (0.9.0)
67
75
  colored2 (~> 3.1)
@@ -83,6 +91,8 @@ GEM
83
91
  colored2 (~> 3.1)
84
92
  rake_factory (~> 0.23)
85
93
  sshkey (~> 2.0)
94
+ regexp_parser (2.2.1)
95
+ rexml (3.2.5)
86
96
  rspec (3.11.0)
87
97
  rspec-core (~> 3.11.0)
88
98
  rspec-expectations (~> 3.11.0)
@@ -92,10 +102,26 @@ GEM
92
102
  rspec-expectations (3.11.0)
93
103
  diff-lcs (>= 1.2.0, < 2.0)
94
104
  rspec-support (~> 3.11.0)
95
- rspec-mocks (3.11.0)
105
+ rspec-mocks (3.11.1)
96
106
  diff-lcs (>= 1.2.0, < 2.0)
97
107
  rspec-support (~> 3.11.0)
98
108
  rspec-support (3.11.0)
109
+ rubocop (1.26.1)
110
+ parallel (~> 1.10)
111
+ parser (>= 3.1.0.0)
112
+ rainbow (>= 2.2.2, < 4.0)
113
+ regexp_parser (>= 1.8, < 3.0)
114
+ rexml
115
+ rubocop-ast (>= 1.16.0, < 2.0)
116
+ ruby-progressbar (~> 1.7)
117
+ unicode-display_width (>= 1.4.0, < 3.0)
118
+ rubocop-ast (1.16.0)
119
+ parser (>= 3.1.1.0)
120
+ rubocop-rake (0.6.0)
121
+ rubocop (~> 1.0)
122
+ rubocop-rspec (2.9.0)
123
+ rubocop (~> 1.19)
124
+ ruby-progressbar (1.11.0)
99
125
  ruby2_keywords (0.0.5)
100
126
  ruby_gpg2 (0.8.0)
101
127
  lino (>= 1.5)
@@ -112,10 +138,10 @@ GEM
112
138
  sshkey (2.0.0)
113
139
  tzinfo (2.0.4)
114
140
  concurrent-ruby (~> 1.0)
141
+ unicode-display_width (2.1.0)
115
142
 
116
143
  PLATFORMS
117
144
  ruby
118
- x86_64-darwin-19
119
145
 
120
146
  DEPENDENCIES
121
147
  activesupport
@@ -129,7 +155,10 @@ DEPENDENCIES
129
155
  rake_gpg
130
156
  rake_ssh
131
157
  rspec
158
+ rubocop
159
+ rubocop-rake
160
+ rubocop-rspec
132
161
  simplecov
133
162
 
134
163
  BUNDLED WITH
135
- 2.3.9
164
+ 2.3.10
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'yaml'
2
4
  require 'rake_circle_ci'
3
5
  require 'rake_github'
@@ -5,17 +7,20 @@ require 'rake_ssh'
5
7
  require 'rake_gpg'
6
8
  require 'securerandom'
7
9
  require 'rspec/core/rake_task'
10
+ require 'rubocop/rake_task'
8
11
 
9
- task :default => :spec
10
-
11
- RSpec::Core::RakeTask.new(:spec)
12
+ task default: %i[
13
+ library:fix
14
+ test:unit
15
+ ]
12
16
 
13
17
  namespace :encryption do
14
18
  namespace :passphrase do
19
+ desc 'Generate encryption passphrase for CI GPG key'
15
20
  task :generate do
16
- File.open('config/secrets/ci/encryption.passphrase', 'w') do |f|
17
- f.write(SecureRandom.base64(36))
18
- end
21
+ FileUtils.mkdir_p('config/secrets/ci/')
22
+ File.write('config/secrets/ci/encryption.passphrase',
23
+ SecureRandom.base64(36))
19
24
  end
20
25
  end
21
26
  end
@@ -23,85 +28,102 @@ end
23
28
  namespace :keys do
24
29
  namespace :deploy do
25
30
  RakeSSH.define_key_tasks(
26
- path: 'config/secrets/ci/',
27
- comment: 'maintainers@infrablocks.io')
31
+ path: 'config/secrets/ci/',
32
+ comment: 'maintainers@infrablocks.io'
33
+ )
28
34
  end
29
35
 
30
36
  namespace :gpg do
31
37
  RakeGPG.define_generate_key_task(
32
- output_directory: 'config/secrets/ci',
33
- name_prefix: 'gpg',
34
- owner_name: 'InfraBlocks Maintainers',
35
- owner_email: 'maintainers@infrablocks.io',
36
- owner_comment: 'rake_dependencies CI Key')
38
+ output_directory: 'config/secrets/ci',
39
+ name_prefix: 'gpg',
40
+ owner_name: 'InfraBlocks Maintainers',
41
+ owner_email: 'maintainers@infrablocks.io',
42
+ owner_comment: 'rake_dependencies CI Key'
43
+ )
37
44
  end
38
45
  end
39
46
 
47
+ RuboCop::RakeTask.new
48
+
49
+ namespace :library do
50
+ desc 'Run all checks of the library'
51
+ task check: [:rubocop]
52
+
53
+ desc 'Attempt to automatically fix issues with the library'
54
+ task fix: [:'rubocop:auto_correct']
55
+ end
56
+
57
+ namespace :test do
58
+ RSpec::Core::RakeTask.new(:unit)
59
+ end
60
+
40
61
  RakeCircleCI.define_project_tasks(
41
- namespace: :circle_ci,
42
- project_slug: 'github/infrablocks/rake_dependencies'
62
+ namespace: :circle_ci,
63
+ project_slug: 'github/infrablocks/rake_dependencies'
43
64
  ) do |t|
44
65
  circle_ci_config =
45
- YAML.load_file('config/secrets/circle_ci/config.yaml')
66
+ YAML.load_file('config/secrets/circle_ci/config.yaml')
46
67
 
47
- t.api_token = circle_ci_config["circle_ci_api_token"]
68
+ t.api_token = circle_ci_config['circle_ci_api_token']
48
69
  t.environment_variables = {
49
- ENCRYPTION_PASSPHRASE:
50
- File.read('config/secrets/ci/encryption.passphrase')
51
- .chomp
70
+ ENCRYPTION_PASSPHRASE:
71
+ File.read('config/secrets/ci/encryption.passphrase')
72
+ .chomp
52
73
  }
53
74
  t.checkout_keys = []
54
75
  t.ssh_keys = [
55
- {
56
- hostname: "github.com",
57
- private_key: File.read('config/secrets/ci/ssh.private')
58
- }
76
+ {
77
+ hostname: 'github.com',
78
+ private_key: File.read('config/secrets/ci/ssh.private')
79
+ }
59
80
  ]
60
81
  end
61
82
 
62
83
  RakeGithub.define_repository_tasks(
63
- namespace: :github,
64
- repository: 'infrablocks/rake_dependencies',
84
+ namespace: :github,
85
+ repository: 'infrablocks/rake_dependencies'
65
86
  ) do |t, args|
66
87
  github_config =
67
- YAML.load_file('config/secrets/github/config.yaml')
88
+ YAML.load_file('config/secrets/github/config.yaml')
68
89
 
69
- t.access_token = github_config["github_personal_access_token"]
90
+ t.access_token = github_config['github_personal_access_token']
70
91
  t.deploy_keys = [
71
- {
72
- title: 'CircleCI',
73
- public_key: File.read('config/secrets/ci/ssh.public')
74
- }
92
+ {
93
+ title: 'CircleCI',
94
+ public_key: File.read('config/secrets/ci/ssh.public')
95
+ }
75
96
  ]
76
97
  t.branch_name = args.branch_name
77
98
  t.commit_message = args.commit_message
78
99
  end
79
100
 
80
101
  namespace :pipeline do
81
- task :prepare => [
82
- :'circle_ci:project:follow',
83
- :'circle_ci:env_vars:ensure',
84
- :'circle_ci:checkout_keys:ensure',
85
- :'circle_ci:ssh_keys:ensure',
86
- :'github:deploy_keys:ensure'
102
+ desc 'Prepare CircleCI Pipeline'
103
+ task prepare: %i[
104
+ circle_ci:project:follow
105
+ circle_ci:env_vars:ensure
106
+ circle_ci:checkout_keys:ensure
107
+ circle_ci:ssh_keys:ensure
108
+ github:deploy_keys:ensure
87
109
  ]
88
110
  end
89
111
 
90
112
  namespace :version do
91
- desc "Bump version for specified type (pre, major, minor, patch)"
113
+ desc 'Bump version for specified type (pre, major, minor, patch)'
92
114
  task :bump, [:type] do |_, args|
93
115
  bump_version_for(args.type)
94
116
  end
95
117
  end
96
118
 
97
- desc "Release gem"
119
+ desc 'Release gem'
98
120
  task :release do
99
- sh "gem release --tag --push"
121
+ sh 'gem release --tag --push'
100
122
  end
101
123
 
102
124
  def bump_version_for(version_type)
103
- sh "gem bump --version #{version_type} " +
104
- "&& bundle install " +
105
- "&& export LAST_MESSAGE=\"$(git log -1 --pretty=%B)\" " +
106
- "&& git commit -a --amend -m \"${LAST_MESSAGE} [ci skip]\""
125
+ sh "gem bump --version #{version_type} " \
126
+ '&& bundle install ' \
127
+ '&& export LAST_MESSAGE="$(git log -1 --pretty=%B)" ' \
128
+ '&& git commit -a --amend -m "${LAST_MESSAGE} [ci skip]"'
107
129
  end
data/bin/console CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
 
3
- require "bundler/setup"
4
- require "rake_dependencies"
4
+ require 'bundler/setup'
5
+ require 'rake_dependencies'
5
6
 
6
7
  # You can add fixtures and/or initialization code here to make experimenting
7
8
  # with your gem easier. You can also use a different console, if you like.
@@ -10,5 +11,5 @@ require "rake_dependencies"
10
11
  # require "pry"
11
12
  # Pry.start
12
13
 
13
- require "irb"
14
+ require 'irb'
14
15
  IRB.start(__FILE__)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'zip'
2
4
  require 'zlib'
3
5
  require 'pathname'
@@ -6,6 +8,8 @@ require 'archive/tar/minitar'
6
8
  module RakeDependencies
7
9
  module Extractors
8
10
  class ZipExtractor
11
+ attr_reader :file_path, :extract_path, :options
12
+
9
13
  def initialize(file_path, extract_path, options = {})
10
14
  @file_path = file_path
11
15
  @extract_path = extract_path
@@ -13,30 +17,92 @@ module RakeDependencies
13
17
  end
14
18
 
15
19
  def extract
16
- FileUtils.mkdir_p(@extract_path)
17
- Zip::File.open(@file_path) do |zip_file_entries|
18
- zip_file_entries.restore_permissions = true
19
- zip_file_entries.each do |entry|
20
- entry_pathname = Pathname.new(entry.name)
21
- strip_pathname = Pathname.new(@options[:strip_path] || '')
22
- target_pathname = entry_pathname.relative_path_from(strip_pathname)
20
+ create_extract_directory
21
+ extract_files
22
+
23
+ return unless requires_rename?
24
+
25
+ rename(
26
+ relative_to_extract_directory(rename_from),
27
+ relative_to_extract_directory(rename_to)
28
+ )
29
+ end
23
30
 
24
- file_path = File.join(@extract_path, target_pathname)
25
- FileUtils.mkdir_p(File.dirname(file_path))
26
- zip_file_entries.extract(entry, file_path) unless File.exist?(file_path)
31
+ private
32
+
33
+ def extract_files
34
+ Zip::File.open(file_path) do |zip_file_entries|
35
+ zip_file_entries.each do |entry|
36
+ process_zip_file_entry(zip_file_entries, entry)
27
37
  end
28
38
  end
29
- if @options[:rename_from] && @options[:rename_to]
30
- FileUtils.mkdir_p(
31
- File.dirname(File.join(@extract_path, @options[:rename_to])))
32
- FileUtils.mv(
33
- File.join(@extract_path, @options[:rename_from]),
34
- File.join(@extract_path, @options[:rename_to]))
35
- end
39
+ end
40
+
41
+ def process_zip_file_entry(zip_file_entries, entry)
42
+ target_path = relative_to_extract_directory(target_pathname(entry))
43
+ create_base_directory(target_path)
44
+ extract_file_if_needed(zip_file_entries, entry, target_path)
45
+ end
46
+
47
+ def extract_file_if_needed(zip_file_entries, entry, target_path)
48
+ return if File.exist?(target_path)
49
+
50
+ zip_file_entries.extract(entry, target_path)
51
+ end
52
+
53
+ def requires_rename?
54
+ rename_from && rename_to
55
+ end
56
+
57
+ def relative_to_extract_directory(path)
58
+ File.join(extract_path, path)
59
+ end
60
+
61
+ def create_base_directory(path)
62
+ FileUtils.mkdir_p(File.dirname(path))
63
+ end
64
+
65
+ def create_extract_directory
66
+ FileUtils.mkdir_p(extract_path)
67
+ end
68
+
69
+ def move(from, to)
70
+ FileUtils.mv(from, to)
71
+ end
72
+
73
+ def rename(from, to)
74
+ create_base_directory(to)
75
+ move(from, to)
76
+ end
77
+
78
+ def target_pathname(entry)
79
+ entry_pathname(entry).relative_path_from(strip_pathname)
80
+ end
81
+
82
+ def strip_pathname
83
+ Pathname.new(strip_path)
84
+ end
85
+
86
+ def entry_pathname(entry)
87
+ Pathname.new(entry.name)
88
+ end
89
+
90
+ def rename_to
91
+ options[:rename_to]
92
+ end
93
+
94
+ def rename_from
95
+ options[:rename_from]
96
+ end
97
+
98
+ def strip_path
99
+ options[:strip_path] || ''
36
100
  end
37
101
  end
38
102
 
39
103
  class TarGzExtractor
104
+ attr_reader :file_path, :extract_path, :options
105
+
40
106
  def initialize(file_path, extract_path, options = {})
41
107
  @file_path = file_path
42
108
  @extract_path = extract_path
@@ -44,33 +110,94 @@ module RakeDependencies
44
110
  end
45
111
 
46
112
  def extract
47
- FileUtils.mkdir_p(@extract_path)
48
- Zlib::GzipReader.open(@file_path) do |tar_file|
113
+ create_extract_directory
114
+ extract_files
115
+
116
+ return unless requires_rename?
117
+
118
+ rename(
119
+ relative_to_extract_directory(rename_from),
120
+ relative_to_extract_directory(rename_to)
121
+ )
122
+ end
123
+
124
+ private
125
+
126
+ def extract_files
127
+ Zlib::GzipReader.open(file_path) do |tar_file|
49
128
  Archive::Tar::Minitar.open(tar_file) do |tar_file_entries|
50
- tar_file_entries.each do |entry|
51
- entry_pathname = Pathname.new(entry.name)
52
- strip_pathname = Pathname.new(@options[:strip_path] || '')
53
- target_pathname = entry_pathname.relative_path_from(strip_pathname)
54
-
55
- file_path = File.join(@extract_path, target_pathname)
56
- FileUtils.mkdir_p(File.dirname(file_path))
57
- if entry.file? && !File.exist?(file_path)
58
- File.open(file_path, 'w', entry.mode) { |f| f.write(entry.read) }
59
- end
60
- end
129
+ tar_file_entries.each(&method(:process_tar_file_entry))
61
130
  end
62
131
  end
63
- if @options[:rename_from] && @options[:rename_to]
64
- FileUtils.mkdir_p(
65
- File.dirname(File.join(@extract_path, @options[:rename_to])))
66
- FileUtils.mv(
67
- File.join(@extract_path, @options[:rename_from]),
68
- File.join(@extract_path, @options[:rename_to]))
132
+ end
133
+
134
+ def process_tar_file_entry(entry)
135
+ target_path = relative_to_extract_directory(target_pathname(entry))
136
+ create_base_directory(target_path)
137
+ extract_file_if_needed(entry, target_path)
138
+ end
139
+
140
+ def extract_file_if_needed(entry, target_path)
141
+ return unless entry.file? && !File.exist?(target_path)
142
+
143
+ File.open(target_path, 'w', entry.mode) do |f|
144
+ f.write(entry.read)
69
145
  end
70
146
  end
147
+
148
+ def requires_rename?
149
+ rename_from && rename_to
150
+ end
151
+
152
+ def relative_to_extract_directory(path)
153
+ File.join(extract_path, path)
154
+ end
155
+
156
+ def create_base_directory(path)
157
+ FileUtils.mkdir_p(File.dirname(path))
158
+ end
159
+
160
+ def create_extract_directory
161
+ FileUtils.mkdir_p(extract_path)
162
+ end
163
+
164
+ def move(from, to)
165
+ FileUtils.mv(from, to)
166
+ end
167
+
168
+ def rename(from, to)
169
+ create_base_directory(to)
170
+ move(from, to)
171
+ end
172
+
173
+ def target_pathname(entry)
174
+ entry_pathname(entry).relative_path_from(strip_pathname)
175
+ end
176
+
177
+ def strip_pathname
178
+ Pathname.new(strip_path)
179
+ end
180
+
181
+ def entry_pathname(entry)
182
+ Pathname.new(entry.name)
183
+ end
184
+
185
+ def rename_to
186
+ options[:rename_to]
187
+ end
188
+
189
+ def rename_from
190
+ options[:rename_from]
191
+ end
192
+
193
+ def strip_path
194
+ options[:strip_path] || ''
195
+ end
71
196
  end
72
197
 
73
198
  class UncompressedExtractor
199
+ attr_reader :file_path, :extract_path, :options
200
+
74
201
  def initialize(file_path, extract_path, options = {})
75
202
  @file_path = file_path
76
203
  @extract_path = extract_path
@@ -78,13 +205,39 @@ module RakeDependencies
78
205
  end
79
206
 
80
207
  def extract
81
- target_name = @options[:rename_to] || File.basename(@file_path)
82
- source = @file_path
83
- destination = File.join(@extract_path, target_name)
208
+ target_name = rename_to || file_name
209
+ source_path = file_path
210
+ target_path = relative_to_extract_directory(target_name)
211
+
212
+ create_extract_directory
213
+ move(source_path, target_path)
214
+ fix_permissions(target_path)
215
+ end
216
+
217
+ private
218
+
219
+ def file_name
220
+ File.basename(file_path)
221
+ end
222
+
223
+ def fix_permissions(target_path)
224
+ FileUtils.chmod(0o755, target_path)
225
+ end
226
+
227
+ def move(source_path, target_path)
228
+ FileUtils.cp(source_path, target_path)
229
+ end
230
+
231
+ def relative_to_extract_directory(path)
232
+ File.join(extract_path, path)
233
+ end
234
+
235
+ def create_extract_directory
236
+ FileUtils.mkdir_p(extract_path)
237
+ end
84
238
 
85
- FileUtils.mkdir_p(@extract_path)
86
- FileUtils.cp(source, destination)
87
- FileUtils.chmod(0755, destination)
239
+ def rename_to
240
+ options[:rename_to]
88
241
  end
89
242
  end
90
243
  end
@@ -1 +1,3 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'rake_factory/kernel_extensions'
@@ -1,4 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module RakeDependencies
4
+ # rubocop:disable Naming/VariableNumber
2
5
  module PlatformNames
3
6
  CPU = {
4
7
  x86_64: 'amd64',
@@ -6,12 +9,13 @@ module RakeDependencies
6
9
  x86: '386',
7
10
  arm: 'arm',
8
11
  arm64: 'arm64'
9
- }
12
+ }.freeze
10
13
  OS = {
11
14
  darwin: 'darwin',
12
15
  linux: 'linux',
13
16
  mswin32: 'windows',
14
17
  mswin64: 'windows'
15
- }
18
+ }.freeze
16
19
  end
20
+ # rubocop:enable Naming/VariableNumber
17
21
  end