rake_dependencies 0.15.0 → 0.15.1

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
  SHA1:
3
- metadata.gz: 29e8e583e7c5859401458e311bfb8a2927dfdc46
4
- data.tar.gz: 74d8ce83b0b5a2396690e5f1a161c27293dd8199
3
+ metadata.gz: 2459e767c6d75e7403a8acaf2762bea9724a2ab7
4
+ data.tar.gz: 256c57de9efcd14a7f93d1e52d60a4acaa97434d
5
5
  SHA512:
6
- metadata.gz: a9deda431f25704fe700cee20ac9c6173ef4587c122ffeecb42c5b80d05619e9f665901ae59fa2453404f989e68493a1e99789e6985cc1b265d478d2245716bb
7
- data.tar.gz: c398b26c4a0660f9b3580e11c74d4eaaa943e464a1dd03596c15818090aa31ed176045f11f65ab6fd8e643ea621fd7d8dcb6393da336a3602f1fc10d006e8a87
6
+ metadata.gz: fa689ac1ddb647cf51b4fd8ce01be49a04df862a213c72952feaa3e3721a288e0871eeb8f00852a93398cd49066a4f060f08c27d2e58ec879756af6542a9975f
7
+ data.tar.gz: a90d311a420ee48c4de850a52aa781450af3c76bc707cc643acc140073774634f86aa4d6a00762959024acae39f0aa8170074e1d56f0edbd48f9a1534793dcac
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rake_dependencies (0.15.0)
4
+ rake_dependencies (0.15.1)
5
5
  hamster (~> 3.0)
6
6
  minitar (~> 0.6)
7
7
  rubyzip (~> 1.1)
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # RakeDependencies
2
2
 
3
- Rake tasks for managing build dependencies.
3
+ Rake tasks for managing binary dependencies used within a build.
4
4
 
5
5
  ## Installation
6
6
 
@@ -20,20 +20,234 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- TODO: Write usage instructions here
23
+ RakeDependencies provides a suite of tasklibs for downloading and extracting a
24
+ distribution of some dependency. The simplest way to configure all of these
25
+ tasks is via the `RakeDependencies::Tasks::All` tasklib. The following provides
26
+ an example usage with terraform as the target dependency:
24
27
 
28
+ ```ruby
29
+ RakeDependencies::Tasks::All.new do |t|
30
+ t.namespace = :terraform
31
+ t.dependency = 'terraform'
32
+ t.version = '0.9.0'
33
+ t.path = File.join('vendor', 'terraform')
34
+ t.type = :zip
35
+
36
+ t.os_ids = {mac: 'darwin', linux: 'linux'}
37
+
38
+ t.uri_template =
39
+ 'https://releases.hashicorp.com/terraform/<%= @version %>/' +
40
+ 'terraform_<%= @version %>_<%= @os_id %>_amd64<%= @ext %>'
41
+ t.file_name_template =
42
+ 'terraform_<%= @version %>_<%= @os_id %>_amd64<%= @ext %>'
43
+
44
+ t.needs_fetch = lambda do |parameters|
45
+ terraform_binary = File.join(
46
+ parameters[:path], parameters[:binary_directory], 'terraform')
47
+
48
+ !(File.exist?(terraform_binary) &&
49
+ `#{terraform_binary} -version`.lines.first =~ /#{parameters[:version]}/)
50
+ end
51
+ end
52
+ ```
53
+
54
+ With this in place, a number of tasks will be defined:
55
+ ```bash
56
+ > rake -T
57
+ rake terraform:clean # Clean vendored terraform
58
+ rake terraform:download # Download terraform distribution
59
+ rake terraform:ensure # Ensure terraform present
60
+ rake terraform:extract # Extract terraform archive
61
+ rake terraform:fetch # Fetch terraform
62
+ ```
63
+
64
+ The tasks perform the following:
65
+ * `<ns>:clean` - recursively deletes the directory containing the dependency
66
+ * `<ns>:download` - downloads the distribution from the provided path into the
67
+ dependency directory
68
+ * `<ns>:extract` - extracts, in the case of a compressed archive, or copies, in
69
+ the case of an uncompressed distribution, the binaries into the binary
70
+ directory under the dependency directory
71
+ * `<ns>:fetch` - downloads then extracts
72
+ * `<ns>:ensure` - checks whether the dependency needs to be fetched and cleans
73
+ and fetches if necessary
74
+
75
+ With these tasks defined, any task that requires the dependency to be present
76
+ should depend on `<ns>:ensure`. Continuing the terraform example:
77
+
78
+ ```ruby
79
+ task :provision_database => ['terraform:ensure'] do
80
+ sh('vendor/terraform/bin/terraform apply infra/database')
81
+ end
82
+ ```
83
+
84
+ The `RakeDependencies::Tasks::All` tasklib supports the following configuration
85
+ parameters:
86
+
87
+ | Name | Description | Default | Required |
88
+ |-------------------------------|-----------------------------------------------------------------------------------------------------------------------|----------------------------------|:--------:|
89
+ | `namespace` | The namespace in which to define the tasks | - | no |
90
+ | `dependency` | The name of the dependency, used in status reporting | - | yes |
91
+ | `version` | The version of the dependency to manage, only required if used in templates or `needs_fetch` | - | no |
92
+ | `path` | The path in which to install the dependency | - | yes |
93
+ | `type` | The archive type of the distribution, one of `:zip`, `:tar_gz`, `:tgz` or `:uncompressed` | `:zip` | yes |
94
+ | `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
+ | `distribution_directory` | The name of the directory under the supplied path into which to download the distribution | `'dist'` | yes |
96
+ | `binary_directory` | The name of the directory under the supplied path into which to extract/copy the binaries | `'bin'` | yes |
97
+ | `uri_template` | A template for the URI of the distribution | - | yes |
98
+ | `file_name_template` | A template for the name of the downloaded file | - | yes |
99
+ | `target_name_template` | A template for the name of the binary after extraction/copying | - | no |
100
+ | `strip_path_template` | A template for the path to strip within an archive before extracting | - | no |
101
+ | `needs_fetch` | A lambda taking a parameter map that should return `true` if the dependency needs to be fetched, `false` otherwise | Will always return `true` | no |
102
+ | `clean_task_name` | The name of the clean task, required if it should be different from the default | `:clean` | yes |
103
+ | `download_task_name` | The name of the download task, required if it should be different from the default | `:download` | yes |
104
+ | `extract_task_name` | The name of the extract task, required if it should be different from the default | `:extract` | yes |
105
+ | `fetch_task_name` | The name of the fetch task, required if it should be different from the default | `:fetch` | yes |
106
+ | `ensure_task_name` | The name of the ensure task, required if it should be different from the default | `:ensure` | yes |
107
+
108
+ Notes:
109
+ * Each of the templates will have the following instance variables in scope when
110
+ rendered:
111
+ * `@version`: the supplied version string
112
+ * `@platform`: the platform on which the task is executing, on of `:mac` or
113
+ `:linux`
114
+ * `@os_id`: the OS identifier derived from the platform on which the task is
115
+ executing and the provided `os_ids` map
116
+ * `@ext`: the file extension corresponding to the provided `type`, one of
117
+ `.zip`, `.tar.gz`, `.tgz` or empty string for uncompressed files
118
+ * The `needs_fetch` lambda will receive a map with the following entries:
119
+ * `path`: the supplied path
120
+ * `version`: the supplied version string
121
+ * `binary_directory`: the supplied or default binary directory
122
+
123
+ The `RakeDependencies::Tasks::All` tasklib uses each of the following tasklibs
124
+ in its definition:
125
+ * `RakeDependencies::Tasks::Clean`
126
+ * `RakeDependencies::Tasks::Download`
127
+ * `RakeDependencies::Tasks::Extract`
128
+ * `RakeDependencies::Tasks::Fetch`
129
+ * `RakeDependencies::Tasks::Ensure`
130
+
131
+ ### `RakeDependencies::Tasks::Clean`
132
+
133
+ The `RakeDependencies::Tasks::Clean` tasklib supports the following
134
+ configuration parameters:
135
+
136
+ | Name | Description | Default | Required |
137
+ |--------------|---------------------------------------------------------------------------|----------------------------------|:--------:|
138
+ | `name` | The name of the task, required if it should be different from the default | `:clean` | yes |
139
+ | `path` | The path in which the dependency is installed | - | yes |
140
+ | `dependency` | The name of the dependency, used in status reporting | - | yes |
141
+
142
+ ### `RakeDependencies::Tasks::Download`
143
+
144
+ The `RakeDependencies::Tasks::Download` tasklib supports the following
145
+ configuration parameters:
146
+
147
+ | Name | Description | Default | Required |
148
+ |--------------------------|------------------------------------------------------------------------------------------------------|----------------------------------|:--------:|
149
+ | `name` | The name of the task, required if it should be different from the default | `:download` | yes |
150
+ | `dependency` | The name of the dependency, used in status reporting | - | yes |
151
+ | `version` | The version of the dependency to manage, only required if used in templates | - | no |
152
+ | `path` | The path in which to install the dependency | - | yes |
153
+ | `type` | The archive type of the distribution, one of `:zip`, `:tar_gz`, `:tgz` or `:uncompressed` | `:zip` | yes |
154
+ | `os_ids` | A map of platforms to OS identifiers to use in templates, containing entries for `:mac` and `:linux` | `{:mac: 'mac', :linux: 'linux'}` | yes |
155
+ | `distribution_directory` | The name of the directory under the supplied path into which to download the distribution | `'dist'` | yes |
156
+ | `uri_template` | A template for the URI of the distribution | - | yes |
157
+ | `file_name_template` | A template for the name of the downloaded file | - | yes |
158
+
159
+ Notes:
160
+ * The templates have the same instance variables in scope when rendered as
161
+ mentioned above.
162
+
163
+ ### `RakeDependencies::Tasks::Extract`
164
+
165
+ The `RakeDependencies::Tasks::Extract` tasklib supports the following
166
+ configuration parameters:
167
+
168
+ | Name | Description | Default | Required |
169
+ |--------------------------|------------------------------------------------------------------------------------------------------|------------------------------------|:--------:|
170
+ | `name` | The name of the task, required if it should be different from the default | `:extract` | yes |
171
+ | `dependency` | The name of the dependency, used in status reporting | - | yes |
172
+ | `version` | The version of the dependency to manage, only required if used in templates | - | no |
173
+ | `path` | The path in which to install the dependency | - | yes |
174
+ | `type` | The archive type of the distribution, one of `:zip`, `:tar_gz`, `:tgz` or `:uncompressed` | `:zip` | yes |
175
+ | `os_ids` | A map of platforms to OS identifiers to use in templates, containing entries for `:mac` and `:linux` | `{:mac: 'mac', :linux: 'linux'}` | yes |
176
+ | `extractors` | A map of archive types to extractor classes, see notes for further details | Extractors for all supported types | yes |
177
+ | `distribution_directory` | The name of the directory under the supplied path into which the distribution was downloaded | `'dist'` | yes |
178
+ | `binary_directory` | The name of the directory under the supplied path into which to extract/copy the binaries | `'bin'` | yes |
179
+ | `file_name_template` | A template for the name of the downloaded file | - | yes |
180
+ | `target_name_template` | A template for the name to give the binary after extraction/copying | - | no |
181
+ | `strip_path_template` | A template for the path to strip within an archive before extracting | - | no |
182
+
183
+ Notes:
184
+ * The templates have the same instance variables in scope when rendered as
185
+ mentioned above.
186
+ * The extractors map has entries for the following keys:
187
+ * `:zip`: An extractor class for zip files
188
+ * `:tar_gz`: An extractor class for tar.gz files
189
+ * `:tgz`: An alias for `:tar_gz` using the same extractor class
190
+ * `:uncompressed`: An extractor class that copies the source to the
191
+ destination
192
+ * The extractor map can be overridden but should include entries for all of the
193
+ above.
194
+
195
+ ### `RakeDependencies::Tasks::Fetch`
196
+
197
+ The `RakeDependencies::Tasks::Fetch` tasklib supports the following
198
+ configuration parameters:
199
+
200
+ | Name | Description | Default | Required |
201
+ |---------------------|---------------------------------------------------------------------------|--------------------------------|:--------:|
202
+ | `name` | The name of the task, required if it should be different from the default | `:fetch` | yes |
203
+ | `dependency` | The name of the dependency, used in status reporting | - | yes |
204
+ | `download_task` | The full name including namespaces of the download task | `<current-namespace>:download` | yes |
205
+ | `extract_task` | The full name including namespaces of the extract task | `<current-namespace>:extract` | yes |
206
+
207
+ ### `RakeDependencies::Tasks::Ensure`
208
+
209
+ The `RakeDependencies::Tasks::Fetch` tasklib supports the following
210
+ configuration parameters:
211
+
212
+ | Name | Description | Default | Required |
213
+ |--------------------|-----------------------------------------------------------------------------------------------------------------------|--------------------------------|:--------:|
214
+ | `name` | The name of the task, required if it should be different from the default | `:fetch` | yes |
215
+ | `dependency` | The name of the dependency, used in status reporting | - | yes |
216
+ | `version` | The version of the dependency to manage, only required if used in templates | - | no |
217
+ | `path` | The path in which to install the dependency | - | yes |
218
+ | `binary_directory` | The name of the directory under the supplied path into which to extract/copy the binaries | `'bin'` | yes |
219
+ | `needs_fetch` | A lambda taking a parameter map that should return `true` if the dependency needs to be fetched, `false` otherwise | Will always return `true` | no |
220
+ | `clean_task` | The full name including namespaces of the clean task | `<current-namespace>:clean` | yes |
221
+ | `download_task` | The full name including namespaces of the download task | `<current-namespace>:download` | yes |
222
+ | `extract_task` | The full name including namespaces of the extract task | `<current-namespace>:extract` | yes |
223
+
224
+ Notes:
225
+ * The templates have the same instance variables in scope when rendered as
226
+ mentioned above.
227
+ * The needs_fetch method receives the same parameter map as mentioned above.
228
+
25
229
  ## Development
26
230
 
27
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
231
+ After checking out the repo, run `bin/setup` to install dependencies. Then,
232
+ run `rake spec` to run the tests. You can also run `bin/console` for an
233
+ interactive prompt that will allow you to experiment.
28
234
 
29
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
235
+ To install this gem onto your local machine, run `bundle exec rake install`. To
236
+ release a new version, update the version number in `version.rb`, and then run
237
+ `bundle exec rake release`, which will create a git tag for the version, push
238
+ git commits and tags, and push the `.gem` file to
239
+ [rubygems.org](https://rubygems.org).
30
240
 
31
241
  ## Contributing
32
242
 
33
- Bug reports and pull requests are welcome on GitHub at https://github.com/tobyclemson/rake_dependencies. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
243
+ Bug reports and pull requests are welcome on GitHub at
244
+ https://github.com/tobyclemson/rake_dependencies. This project is intended to
245
+ be a safe, welcoming space for collaboration, and contributors are expected to
246
+ adhere to the [Contributor Covenant](http://contributor-covenant.org) code of
247
+ conduct.
34
248
 
35
249
 
36
250
  ## License
37
251
 
38
- The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
39
-
252
+ The gem is available as open source under the terms of the
253
+ [MIT License](http://opensource.org/licenses/MIT).
@@ -36,68 +36,78 @@ module RakeDependencies
36
36
  alias namespace= containing_namespace=
37
37
 
38
38
  def define
39
- namespace containing_namespace do
40
- Clean.new do |t|
41
- t.name = clean_task_name
42
-
43
- t.dependency = dependency
44
- t.path = path
39
+ if containing_namespace
40
+ namespace containing_namespace do
41
+ define_tasks
45
42
  end
46
- Download.new do |t|
47
- t.name = download_task_name
43
+ else
44
+ define_tasks
45
+ end
46
+ end
48
47
 
49
- t.dependency = dependency
50
- t.version = version
51
- t.path = path
52
- t.type = type
48
+ private
53
49
 
54
- t.os_ids = os_ids
50
+ def define_tasks
51
+ Clean.new do |t|
52
+ t.name = clean_task_name
55
53
 
56
- t.distribution_directory = distribution_directory
54
+ t.dependency = dependency
55
+ t.path = path
56
+ end
57
+ Download.new do |t|
58
+ t.name = download_task_name
57
59
 
58
- t.uri_template = uri_template
59
- t.file_name_template = file_name_template
60
- end
61
- Extract.new do |t|
62
- t.name = extract_task_name
60
+ t.dependency = dependency
61
+ t.version = version
62
+ t.path = path
63
+ t.type = type
63
64
 
64
- t.dependency = dependency
65
- t.version = version
66
- t.path = path
67
- t.type = type
65
+ t.os_ids = os_ids
68
66
 
69
- t.os_ids = os_ids
67
+ t.distribution_directory = distribution_directory
70
68
 
71
- t.distribution_directory = distribution_directory
72
- t.binary_directory = binary_directory
69
+ t.uri_template = uri_template
70
+ t.file_name_template = file_name_template
71
+ end
72
+ Extract.new do |t|
73
+ t.name = extract_task_name
73
74
 
74
- t.file_name_template = file_name_template
75
- t.strip_path_template = strip_path_template
76
- t.target_name_template = target_name_template
77
- end
78
- Fetch.new do |t|
79
- t.name = fetch_task_name
75
+ t.dependency = dependency
76
+ t.version = version
77
+ t.path = path
78
+ t.type = type
80
79
 
81
- t.dependency = dependency
80
+ t.os_ids = os_ids
82
81
 
83
- t.download_task = download_task_name
84
- t.extract_task = extract_task_name
85
- end
86
- Ensure.new do |t|
87
- t.name = ensure_task_name
82
+ t.distribution_directory = distribution_directory
83
+ t.binary_directory = binary_directory
88
84
 
89
- t.dependency = dependency
90
- t.version = version
91
- t.path = path
85
+ t.file_name_template = file_name_template
86
+ t.strip_path_template = strip_path_template
87
+ t.target_name_template = target_name_template
88
+ end
89
+ Fetch.new do |t|
90
+ t.name = fetch_task_name
92
91
 
93
- t.binary_directory = binary_directory
92
+ t.dependency = dependency
94
93
 
95
- t.needs_fetch = needs_fetch
94
+ t.download_task = download_task_name
95
+ t.extract_task = extract_task_name
96
+ end
97
+ Ensure.new do |t|
98
+ t.name = ensure_task_name
96
99
 
97
- t.clean_task = clean_task_name
98
- t.download_task = download_task_name
99
- t.extract_task = extract_task_name
100
- end
100
+ t.dependency = dependency
101
+ t.version = version
102
+ t.path = path
103
+
104
+ t.binary_directory = binary_directory
105
+
106
+ t.needs_fetch = needs_fetch
107
+
108
+ t.clean_task = clean_task_name
109
+ t.download_task = download_task_name
110
+ t.extract_task = extract_task_name
101
111
  end
102
112
  end
103
113
  end
@@ -1,3 +1,3 @@
1
1
  module RakeDependencies
2
- VERSION = "0.15.0"
2
+ VERSION = "0.15.1"
3
3
  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.15.0
4
+ version: 0.15.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toby Clemson