rake_dependencies 0.16.1.pre1 → 0.16.1.pre2

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: 5ecfde2a6c47258e2065ec06ff9dcd48c629ab912fe6f5c4d01edb3c755512c8
4
- data.tar.gz: ea7f5da510d8d47f2120ec0418ae112edb08c741c41efb1810d0f2885c7ae76f
3
+ metadata.gz: b677ec56cc6b429fcb7bd61f37774b8c16b59518207ee9854077ca03f78155c1
4
+ data.tar.gz: 595cfaf1f921dd1aa59324ed36e7966978e26d550c158f90e6e7f8e6c7801232
5
5
  SHA512:
6
- metadata.gz: a76853c9f507f848cb391d4fda341a2cb8d825ecdf82d37ef76a6475eaa6945386259fccb7767b339f987a3cfed4f283810b5e0b8164d0c9c5aa8c0696c5e5f4
7
- data.tar.gz: c208cbfaec3b028d710239882b79756bc0552c795b45a040e1f30778f264a910a31a9738ebf00cd2f113e92ad8ee0279352c75002d7a07bd53134fc734877b62
6
+ metadata.gz: dc9c6ce97449ced353b879752bbbaf1ae805244123e4d5d6695dba031cdce785be80bd5624b24dbe8a9dc0e6eb6984c74740f9b83e1c0938d71a5bcb6820008e
7
+ data.tar.gz: 6fbbd0649e0fee2495911b1f4dea52728a039fb466d35be9cc02545abe14e5b65781e3ba3b6849a97b436964a926b37e759ca634418a19bf89e90301108f6215
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rake_dependencies (0.16.1.pre1)
4
+ rake_dependencies (0.16.1.pre2)
5
5
  hamster (~> 3.0)
6
6
  minitar (~> 0.6)
7
7
  rubyzip (~> 1.1)
@@ -56,7 +56,7 @@ PLATFORMS
56
56
  DEPENDENCIES
57
57
  activesupport (~> 4.2)
58
58
  bundler (~> 1.14)
59
- fakefs (~> 0.10)
59
+ fakefs (~> 0.18)
60
60
  gem-release (~> 0.7)
61
61
  rake (~> 11.0)
62
62
  rake_dependencies!
data/README.md CHANGED
@@ -81,19 +81,49 @@ task :provision_database => ['terraform:ensure'] do
81
81
  end
82
82
  ```
83
83
 
84
+ If the `installation_directory` attribute is supplied, an additional `install`
85
+ task will be defined:
86
+
87
+ ```ruby
88
+ RakeDependencies::Tasks::All.new do |t|
89
+ t.namespace = :terraform
90
+ t.dependency = 'terraform'
91
+
92
+ # ...
93
+ t.installation_directory = "#{ENV['HOME']}/bin"
94
+ # ...
95
+ end
96
+ ```
97
+
98
+ Then:
99
+
100
+ ```bash
101
+ > rake -T
102
+ rake terraform:clean # Clean vendored terraform
103
+ rake terraform:download # Download terraform distribution
104
+ rake terraform:ensure # Ensure terraform present
105
+ rake terraform:extract # Extract terraform archive
106
+ rake terraform:fetch # Fetch terraform
107
+ rake terraform:install # Install terraform
108
+ ```
109
+
110
+ The `<ns>:install` task copies the binary into the defined installation
111
+ directory which can be anywhere on the filesystem.
112
+
84
113
  The `RakeDependencies::Tasks::All` tasklib supports the following configuration
85
114
  parameters:
86
115
 
87
116
  | Name | Description | Default | Required |
88
117
  |-------------------------------|-----------------------------------------------------------------------------------------------------------------------|----------------------------------|:--------:|
89
118
  | `namespace` | The namespace in which to define the tasks | - | no |
90
- | `dependency` | The name of the dependency, used in status reporting | - | yes |
119
+ | `dependency` | The name of the dependency, used in status reporting and as the default binary name | - | yes |
91
120
  | `version` | The version of the dependency to manage, only required if used in templates or `needs_fetch` | - | no |
92
121
  | `path` | The path in which to install the dependency | - | yes |
93
122
  | `type` | The archive type of the distribution, one of `:zip`, `:tar_gz`, `:tgz` or `:uncompressed` | `:zip` | yes |
94
123
  | `os_ids` | A map of platforms to OS identifiers to use in templates, containing entries for `:mac` and `:linux` | `{:mac: 'mac', :linux: 'linux'}` | yes |
95
124
  | `distribution_directory` | The name of the directory under the supplied path into which to download the distribution | `'dist'` | yes |
96
125
  | `binary_directory` | The name of the directory under the supplied path into which to extract/copy the binaries | `'bin'` | yes |
126
+ | `installation_directory` | The name of the directory into which to install the binaries, anywhere on the file system | - | no |
97
127
  | `uri_template` | A template for the URI of the distribution | - | yes |
98
128
  | `file_name_template` | A template for the name of the downloaded file | - | yes |
99
129
  | `target_name_template` | A template for the name of the binary after extraction/copying | - | no |
@@ -102,6 +132,7 @@ parameters:
102
132
  | `clean_task_name` | The name of the clean task, required if it should be different from the default | `:clean` | yes |
103
133
  | `download_task_name` | The name of the download task, required if it should be different from the default | `:download` | yes |
104
134
  | `extract_task_name` | The name of the extract task, required if it should be different from the default | `:extract` | yes |
135
+ | `install_task_name` | The name of the install task, required if it should be different from the default | `:install` | no |
105
136
  | `fetch_task_name` | The name of the fetch task, required if it should be different from the default | `:fetch` | yes |
106
137
  | `ensure_task_name` | The name of the ensure task, required if it should be different from the default | `:ensure` | yes |
107
138
 
@@ -125,6 +156,7 @@ in its definition:
125
156
  * `RakeDependencies::Tasks::Clean`
126
157
  * `RakeDependencies::Tasks::Download`
127
158
  * `RakeDependencies::Tasks::Extract`
159
+ * `RakeDependencies::Tasks::Install`
128
160
  * `RakeDependencies::Tasks::Fetch`
129
161
  * `RakeDependencies::Tasks::Ensure`
130
162
 
@@ -192,6 +224,27 @@ Notes:
192
224
  * The extractor map can be overridden but should include entries for all of the
193
225
  above.
194
226
 
227
+ ### `RakeDependencies::Tasks::Install`
228
+
229
+ The `RakeDependencies::Tasks::Install` tasklib supports the following
230
+ configuration parameters:
231
+
232
+ | Name | Description | Default | Required |
233
+ |--------------------------|------------------------------------------------------------------------------------------------------|------------------------------------|:--------:|
234
+ | `name` | The name of the task, required if it should be different from the default | `:install` | yes |
235
+ | `dependency` | The name of the dependency, used in status reporting | - | yes |
236
+ | `version` | The version of the dependency to manage, only required if used in templates | - | no |
237
+ | `path` | The path in which to install the dependency | - | yes |
238
+ | `type` | The archive type of the original distribution, one of `:zip`, `:tar_gz`, `:tgz` or `:uncompressed` | `:zip` | yes |
239
+ | `os_ids` | A map of platforms to OS identifiers to use in templates, containing entries for `:mac` and `:linux` | `{:mac: 'mac', :linux: 'linux'}` | yes |
240
+ | `binary_directory` | The name of the directory under the supplied path into which to extract/copy the binaries | `'bin'` | yes |
241
+ | `installation_directory` | The name of the directory into which the binary should be installed | - | yes |
242
+ | `binary_name_template` | A template for the name of the binary | - | yes |
243
+
244
+ Notes:
245
+ * The templates have the same instance variables in scope when rendered as
246
+ mentioned above.
247
+
195
248
  ### `RakeDependencies::Tasks::Fetch`
196
249
 
197
250
  The `RakeDependencies::Tasks::Fetch` tasklib supports the following
@@ -220,6 +273,7 @@ configuration parameters:
220
273
  | `clean_task` | The full name including namespaces of the clean task | `<current-namespace>:clean` | yes |
221
274
  | `download_task` | The full name including namespaces of the download task | `<current-namespace>:download` | yes |
222
275
  | `extract_task` | The full name including namespaces of the extract task | `<current-namespace>:extract` | yes |
276
+ | `install_task` | The full name including namespaces of the install task | `<current-namespace>:install` | yes |
223
277
 
224
278
  Notes:
225
279
  * The templates have the same instance variables in scope when rendered as
@@ -19,6 +19,7 @@ module RakeDependencies
19
19
 
20
20
  parameter :distribution_directory, default: 'dist'
21
21
  parameter :binary_directory, default: 'bin'
22
+ parameter :installation_directory
22
23
 
23
24
  parameter :uri_template, :required => true
24
25
  parameter :file_name_template, :required => true
@@ -30,6 +31,7 @@ module RakeDependencies
30
31
  parameter :clean_task_name, :default => :clean
31
32
  parameter :download_task_name, :default => :download
32
33
  parameter :extract_task_name, :default => :extract
34
+ parameter :install_task_name, :default => :install
33
35
  parameter :fetch_task_name, :default => :fetch
34
36
  parameter :ensure_task_name, :default => :ensure
35
37
 
@@ -86,6 +88,21 @@ module RakeDependencies
86
88
  t.strip_path_template = strip_path_template
87
89
  t.target_name_template = target_name_template
88
90
  end
91
+ Install.new do |t|
92
+ t.name = install_task_name
93
+
94
+ t.dependency = dependency
95
+ t.version = version
96
+ t.path = path
97
+ t.type = type
98
+
99
+ t.os_ids = os_ids
100
+
101
+ t.binary_directory = binary_directory
102
+ t.binary_name_template = target_name_template || dependency
103
+
104
+ t.installation_directory = installation_directory
105
+ end if installation_directory
89
106
  Fetch.new do |t|
90
107
  t.name = fetch_task_name
91
108
 
@@ -108,8 +125,9 @@ module RakeDependencies
108
125
  t.clean_task = clean_task_name
109
126
  t.download_task = download_task_name
110
127
  t.extract_task = extract_task_name
128
+ t.install_task = install_task_name
111
129
  end
112
130
  end
113
131
  end
114
132
  end
115
- end
133
+ end
@@ -16,6 +16,7 @@ module RakeDependencies
16
16
  parameter :clean_task, default: :clean
17
17
  parameter :download_task, default: :download
18
18
  parameter :extract_task, default: :extract
19
+ parameter :install_task, default: :install
19
20
 
20
21
  def process_arguments args
21
22
  super(args)
@@ -27,6 +28,15 @@ module RakeDependencies
27
28
  download = Rake::Task[scoped_task_name(download_task)]
28
29
  extract = Rake::Task[scoped_task_name(extract_task)]
29
30
 
31
+ resolved_install_task = scoped_task_name(install_task)
32
+ install = if Rake::Task.task_defined?(resolved_install_task)
33
+ Rake::Task[scoped_task_name(install_task)]
34
+ else
35
+ no_op_task = Object.new
36
+ def no_op_task.invoke; end
37
+ no_op_task
38
+ end
39
+
30
40
  desc "Ensure #{dependency} present"
31
41
  task name do
32
42
  parameters = {
@@ -35,7 +45,7 @@ module RakeDependencies
35
45
  binary_directory: binary_directory
36
46
  }
37
47
  if needs_fetch.call(parameters)
38
- [clean, download, extract].map(&:invoke)
48
+ [clean, download, extract, install].map(&:invoke)
39
49
  end
40
50
  end
41
51
  end
@@ -47,4 +57,4 @@ module RakeDependencies
47
57
  end
48
58
  end
49
59
  end
50
- end
60
+ end
@@ -46,8 +46,8 @@ module RakeDependencies
46
46
  }
47
47
 
48
48
  distribution_file_name = Template.new(file_name_template)
49
- .with_parameters(parameters)
50
- .render
49
+ .with_parameters(parameters)
50
+ .render
51
51
  distribution_file_directory = File.join(path, distribution_directory)
52
52
  distribution_file_path = File.join(
53
53
  distribution_file_directory, distribution_file_name)
@@ -57,14 +57,14 @@ module RakeDependencies
57
57
  options = {}
58
58
  if strip_path_template
59
59
  options[:strip_path] = Template.new(strip_path_template)
60
- .with_parameters(parameters)
61
- .render
60
+ .with_parameters(parameters)
61
+ .render
62
62
  end
63
63
 
64
64
  if target_name_template
65
65
  options[:rename_to] = Template.new(target_name_template)
66
- .with_parameters(parameters)
67
- .render
66
+ .with_parameters(parameters)
67
+ .render
68
68
  end
69
69
 
70
70
  extractor = extractor_for_extension.new(
@@ -95,14 +95,18 @@ module RakeDependencies
95
95
 
96
96
  def ext
97
97
  case resolved_type
98
- when :tar_gz then '.tar.gz'
99
- when :tgz then '.tgz'
100
- when :zip then '.zip'
101
- when :uncompressed then ''
102
- else
103
- raise "Unknown type: #{type}"
98
+ when :tar_gz then
99
+ '.tar.gz'
100
+ when :tgz then
101
+ '.tgz'
102
+ when :zip then
103
+ '.zip'
104
+ when :uncompressed then
105
+ ''
106
+ else
107
+ raise "Unknown type: #{type}"
104
108
  end
105
109
  end
106
110
  end
107
111
  end
108
- end
112
+ end
@@ -0,0 +1,78 @@
1
+ require_relative '../tasklib'
2
+
3
+ module RakeDependencies
4
+ module Tasks
5
+ class Install < TaskLib
6
+ parameter :name, default: :install
7
+
8
+ parameter :os_ids, default: {
9
+ mac: 'mac',
10
+ linux: 'linux'
11
+ }
12
+
13
+ parameter :dependency, required: true
14
+ parameter :version
15
+ parameter :path, required: true
16
+ parameter :type, default: :zip
17
+
18
+ parameter :binary_directory, default: 'bin'
19
+ parameter :binary_name_template, required: true
20
+
21
+ parameter :installation_directory, required: true
22
+
23
+ def process_arguments args
24
+ super(args)
25
+ self.name = args[0] if args[0]
26
+ end
27
+
28
+ def define
29
+ desc "Install #{dependency}"
30
+ task name do
31
+ parameters = {
32
+ version: version,
33
+ platform: platform,
34
+ os_id: os_id,
35
+ ext: ext
36
+ }
37
+
38
+ binary_file_name = Template.new(binary_name_template)
39
+ .with_parameters(parameters)
40
+ .render
41
+ binary_file_directory = File.join(path, binary_directory)
42
+ binary_file_path = File.join(
43
+ binary_file_directory, binary_file_name)
44
+
45
+ mkdir_p installation_directory
46
+ cp binary_file_path, installation_directory
47
+ end
48
+ end
49
+
50
+ def os_id
51
+ os_ids[platform]
52
+ end
53
+
54
+ def platform
55
+ RUBY_PLATFORM =~ /darwin/ ? :mac : :linux
56
+ end
57
+
58
+ def resolved_type
59
+ type.is_a?(Hash) ? type[platform].to_sym : type.to_sym
60
+ end
61
+
62
+ def ext
63
+ case resolved_type
64
+ when :tar_gz then
65
+ '.tar.gz'
66
+ when :tgz then
67
+ '.tgz'
68
+ when :zip then
69
+ '.zip'
70
+ when :uncompressed then
71
+ ''
72
+ else
73
+ raise "Unknown type: #{type}"
74
+ end
75
+ end
76
+ end
77
+ end
78
+ end
@@ -1,6 +1,7 @@
1
1
  require_relative 'tasks/clean'
2
2
  require_relative 'tasks/download'
3
3
  require_relative 'tasks/extract'
4
+ require_relative 'tasks/install'
4
5
  require_relative 'tasks/fetch'
5
6
  require_relative 'tasks/ensure'
6
- require_relative 'tasks/all'
7
+ require_relative 'tasks/all'
@@ -1,3 +1,3 @@
1
1
  module RakeDependencies
2
- VERSION = "0.16.1.pre1"
2
+ VERSION = "0.16.1.pre2"
3
3
  end
@@ -33,6 +33,6 @@ Gem::Specification.new do |spec|
33
33
  spec.add_development_dependency 'rspec', '~> 3.0'
34
34
  spec.add_development_dependency 'gem-release', '~> 0.7'
35
35
  spec.add_development_dependency 'activesupport', '~> 4.2'
36
- spec.add_development_dependency 'fakefs', '~> 0.10'
36
+ spec.add_development_dependency 'fakefs', '~> 0.18'
37
37
  spec.add_development_dependency 'simplecov', '~> 0.13'
38
38
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rake_dependencies
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.1.pre1
4
+ version: 0.16.1.pre2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toby Clemson
@@ -128,14 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: '0.10'
131
+ version: '0.18'
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: '0.10'
138
+ version: '0.18'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: simplecov
141
141
  requirement: !ruby/object:Gem::Requirement
@@ -196,6 +196,7 @@ files:
196
196
  - lib/rake_dependencies/tasks/ensure.rb
197
197
  - lib/rake_dependencies/tasks/extract.rb
198
198
  - lib/rake_dependencies/tasks/fetch.rb
199
+ - lib/rake_dependencies/tasks/install.rb
199
200
  - lib/rake_dependencies/template.rb
200
201
  - lib/rake_dependencies/version.rb
201
202
  - rake_dependencies.gemspec