torba 0.4.2 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +19 -0
- data/README.md +48 -5
- data/lib/torba/cli.rb +1 -0
- data/lib/torba/rails.rb +5 -0
- data/lib/torba/rake_task.rb +53 -0
- data/lib/torba/remote_sources/get_file.rb +1 -1
- data/lib/torba/verify.rb +11 -4
- data/test/rake_task_test.rb +56 -0
- data/test/test_helper.rb +1 -0
- data/torba.gemspec +2 -1
- metadata +19 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 243b26b521d8876f13cb0fc7fcda5caf65250340
|
4
|
+
data.tar.gz: 7f0d92ece3a5cc9a0bc4cd7659c1d719bf8ceaa2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10938f10db53cb9e5161afda6cc47c7a935039522bb2c8085b6f2a6459af4988b7127b01edc540c8330df6f856348b1d644d8e3426698ad92f38655ab491a63f
|
7
|
+
data.tar.gz: 1acaab48fc64102ee7f550dce7e5fa4d7fbf46dfa9196e9b4b069087c4f45cde780376b7dd313ddfb68cb046b781b6f55cf3675fab05fae1e85129d5904ab67f
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,24 @@
|
|
1
1
|
## Unreleased
|
2
2
|
|
3
|
+
## Version 0.5.0
|
4
|
+
|
5
|
+
### Upgrading notes
|
6
|
+
|
7
|
+
Rails users are advised to remove manual execution of `torba pack` from
|
8
|
+
their deployment scripts, since the command now is a part of
|
9
|
+
`rake assets:precompile`.
|
10
|
+
|
11
|
+
### Enhancements
|
12
|
+
|
13
|
+
* Support deployment to Heroku
|
14
|
+
* `torba pack` is automatically injected into `rake assets:precompile`
|
15
|
+
in Rails applications
|
16
|
+
* `torba install` command is a mapping for `torba pack`
|
17
|
+
|
18
|
+
### Bug fixes
|
19
|
+
|
20
|
+
* Retry 5 times if fetching a remote file fails
|
21
|
+
|
3
22
|
## Version 0.4.2
|
4
23
|
|
5
24
|
### Bug fixes
|
data/README.md
CHANGED
@@ -17,7 +17,7 @@ Production ready.
|
|
17
17
|
|
18
18
|
## Documentation
|
19
19
|
|
20
|
-
[Released version](http://rubydoc.info/gems/torba/0.
|
20
|
+
[Released version](http://rubydoc.info/gems/torba/0.5.0)
|
21
21
|
|
22
22
|
## Why
|
23
23
|
|
@@ -251,10 +251,53 @@ default), except that Torba does have a way to specify exact list of files to im
|
|
251
251
|
|
252
252
|
## Deployment
|
253
253
|
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
254
|
+
In Rails apps, Torba automatically hooks into the existing `assets:precompile`
|
255
|
+
Rake task to ensure that `torba pack` is executed. This means that Rails
|
256
|
+
deployments will "just work", although there are some optimizations you can make
|
257
|
+
as explained below.
|
258
|
+
|
259
|
+
### Heroku
|
260
|
+
|
261
|
+
You will need to specify some config vars to ensure Torba's files are placed in
|
262
|
+
locations suitable for the Heroku platform.
|
263
|
+
|
264
|
+
`TORBA_HOME_PATH` should be within your app so that Torba's assets are included
|
265
|
+
in the slug.
|
266
|
+
|
267
|
+
`TORBA_CACHE_PATH` should make use of the `tmp/cache/assets` directory. This is
|
268
|
+
where the Ruby buildpack expects cached files to be stored related to the
|
269
|
+
`assets:precompile` step. This way Torba doesn't have to download packages fresh
|
270
|
+
every time.
|
271
|
+
|
272
|
+
```bash
|
273
|
+
heroku config:set TORBA_HOME_PATH=vendor/torba TORBA_CACHE_PATH=tmp/cache/assets/torba
|
274
|
+
```
|
275
|
+
|
276
|
+
Now your Heroku app is good to go.
|
277
|
+
|
278
|
+
### Capistrano
|
279
|
+
|
280
|
+
Specify the `TORBA_HOME_PATH` env variable pointing to a persistent directory
|
281
|
+
writable by your deploy user and shared across releases. Capistrano's `shared`
|
282
|
+
directory is good for this.
|
283
|
+
|
284
|
+
For example:
|
285
|
+
|
286
|
+
```bash
|
287
|
+
export TORBA_HOME_PATH=/var/www/my_app/shared/torba
|
288
|
+
```
|
289
|
+
|
290
|
+
There is no need to add a symlink.
|
291
|
+
|
292
|
+
### Troubleshooting
|
293
|
+
|
294
|
+
If you are getting an error like `Your Torba is not packed yet` when trying to
|
295
|
+
run `rake assets:precompile` (or `bin/rails assets:precompile` in Rails 5),
|
296
|
+
set the `TORBA_DONT_VERIFY` environment variable, like this:
|
297
|
+
|
298
|
+
```bash
|
299
|
+
TORBA_DONT_VERIFY=1 bin/rake assets:precompile
|
300
|
+
```
|
258
301
|
|
259
302
|
[bower]: http://bower.io/
|
260
303
|
[sprockets]: https://github.com/rails/sprockets/
|
data/lib/torba/cli.rb
CHANGED
data/lib/torba/rails.rb
CHANGED
@@ -4,5 +4,10 @@ module Torba
|
|
4
4
|
Rails.application.config.assets.paths.concat(Torba.load_path)
|
5
5
|
Rails.application.config.assets.precompile.concat(Torba.non_js_css_logical_paths)
|
6
6
|
end
|
7
|
+
|
8
|
+
rake_tasks do
|
9
|
+
require "torba/rake_task"
|
10
|
+
Torba::RakeTask.new("torba:pack", :before => "assets:precompile")
|
11
|
+
end
|
7
12
|
end
|
8
13
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require "torba"
|
2
|
+
require "rake/tasklib"
|
3
|
+
|
4
|
+
module Torba
|
5
|
+
# Calling Torba::RakeTask.new defines a "torba:pack" Rake task that does the
|
6
|
+
# same thing as `bundle exec torba pack`. Furthermore, if the :before option
|
7
|
+
# is specified, the "torba:pack" task will be installed as a prerequisite to
|
8
|
+
# the specified task.
|
9
|
+
#
|
10
|
+
# This is useful for deployment because it allows for packing as part of the
|
11
|
+
# "assets:precompile" flow, which platforms like Heroku already know to
|
12
|
+
# invoke. By hooking into "assets:precompile" as a prerequisite, Torba can
|
13
|
+
# participate automatically, with no change to the deployment process.
|
14
|
+
#
|
15
|
+
# Typical use is as follows:
|
16
|
+
#
|
17
|
+
# # In Rakefile
|
18
|
+
# require "torba/rake_task"
|
19
|
+
# Torba::RakeTask.new("torba:pack", :before => "assets:precompile")
|
20
|
+
#
|
21
|
+
# Note that when you require "torba/rails" in a Rails app, this Rake task is
|
22
|
+
# installed for you automatically. You only need to install the task yourself
|
23
|
+
# if you are using something different, like Sinatra.
|
24
|
+
#
|
25
|
+
class RakeTask < Rake::TaskLib
|
26
|
+
attr_reader :torba_pack_task_name
|
27
|
+
|
28
|
+
def initialize(name="torba:pack", options={})
|
29
|
+
@torba_pack_task_name = name
|
30
|
+
define_task
|
31
|
+
install_as_prerequisite(options[:before]) if options[:before]
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def define_task
|
37
|
+
desc "Download and prepare all packages defined in Torbafile"
|
38
|
+
task torba_pack_task_name do
|
39
|
+
Torba.pretty_errors { Torba.pack }
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def install_as_prerequisite(other_task)
|
44
|
+
ensure_task_defined(other_task)
|
45
|
+
Rake::Task[other_task].enhance([torba_pack_task_name])
|
46
|
+
end
|
47
|
+
|
48
|
+
def ensure_task_defined(other_task)
|
49
|
+
return if Rake::Task.task_defined?(other_task)
|
50
|
+
Rake::Task.define_task(other_task)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -14,7 +14,7 @@ module Torba
|
|
14
14
|
|
15
15
|
Torba.ui.info "downloading '#{url}'"
|
16
16
|
|
17
|
-
command = "curl -Lf -o #{tempfile.path} #{url}"
|
17
|
+
command = "curl --retry 5 --retry-max-time 60 -Lf -o #{tempfile.path} #{url}"
|
18
18
|
system(command) || raise(Errors::ShellCommandFailed.new(command))
|
19
19
|
|
20
20
|
tempfile
|
data/lib/torba/verify.rb
CHANGED
@@ -1,7 +1,14 @@
|
|
1
1
|
require "torba"
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
# We purposely skip verification during Rake execution, because Rake is used to
|
4
|
+
# run the Torba:RakeTask during the "assets:precompile" stage of deployment. In
|
5
|
+
# this case it is OK that the Torbafile hasn't been packed yet, because we are
|
6
|
+
# about to do so.
|
7
|
+
#
|
8
|
+
unless ENV["TORBA_DONT_VERIFY"] || defined?(Rake::Task)
|
9
|
+
if STDOUT.tty?
|
10
|
+
Torba.pretty_errors { Torba.verify }
|
11
|
+
else
|
12
|
+
Torba.verify
|
13
|
+
end
|
7
14
|
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require "test_helper"
|
2
|
+
require "torba/rake_task"
|
3
|
+
|
4
|
+
module Torba
|
5
|
+
class RakeTaskTest < Minitest::Test
|
6
|
+
include Rake::DSL
|
7
|
+
|
8
|
+
def setup
|
9
|
+
task "environment"
|
10
|
+
task "assets:precompile" => "environment"
|
11
|
+
Torba::RakeTask.new("torba:pack", :before => "assets:precompile")
|
12
|
+
end
|
13
|
+
|
14
|
+
def teardown
|
15
|
+
Rake::Task.clear
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_torba_pack_task_is_defined
|
19
|
+
assert(Rake::Task.task_defined?("torba:pack"))
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_torba_pack_task_has_description
|
23
|
+
torba_task = Rake::Task["torba:pack"]
|
24
|
+
torba_task.comment =~ /Torbafile/
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_torba_pack_is_installed_as_prerequisite
|
28
|
+
precompile_task = Rake::Task["assets:precompile"]
|
29
|
+
assert_equal(%w(environment torba:pack), precompile_task.prerequisites)
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_invoking_torba_pack
|
33
|
+
Torba.expects(:pack).once
|
34
|
+
Rake::Task["torba:pack"].invoke
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_defines_task_if_doesnt_exist
|
38
|
+
Rake::Task.clear
|
39
|
+
Torba::RakeTask.new("torba:pack", :before => "something:else")
|
40
|
+
|
41
|
+
assert(Rake::Task.task_defined?("something:else"))
|
42
|
+
other_task = Rake::Task["something:else"]
|
43
|
+
assert_equal(%w(torba:pack), other_task.prerequisites)
|
44
|
+
end
|
45
|
+
|
46
|
+
def test_alternative_task_name_can_be_specified
|
47
|
+
Rake::Task.clear
|
48
|
+
Torba::RakeTask.new("package")
|
49
|
+
|
50
|
+
assert(Rake::Task.task_defined?("package"))
|
51
|
+
|
52
|
+
Torba.expects(:pack).once
|
53
|
+
Rake::Task["package"].invoke
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
data/test/test_helper.rb
CHANGED
data/torba.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "torba"
|
3
|
-
spec.version = "0.
|
3
|
+
spec.version = "0.5.0"
|
4
4
|
spec.authors = ["Andrii Malyshko"]
|
5
5
|
spec.email = ["mail@nashbridges.me"]
|
6
6
|
spec.description = "Bundler for Sprockets"
|
@@ -19,4 +19,5 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.add_development_dependency "bundler", "~> 1.6"
|
20
20
|
spec.add_development_dependency "rake", "~> 10.0"
|
21
21
|
spec.add_development_dependency "minitest", "~> 5.4"
|
22
|
+
spec.add_development_dependency "mocha"
|
22
23
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: torba
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrii Malyshko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '5.4'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: mocha
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
69
83
|
description: Bundler for Sprockets
|
70
84
|
email:
|
71
85
|
- mail@nashbridges.me
|
@@ -91,6 +105,7 @@ files:
|
|
91
105
|
- lib/torba/manifest.rb
|
92
106
|
- lib/torba/package.rb
|
93
107
|
- lib/torba/rails.rb
|
108
|
+
- lib/torba/rake_task.rb
|
94
109
|
- lib/torba/remote_sources/common.rb
|
95
110
|
- lib/torba/remote_sources/get_file.rb
|
96
111
|
- lib/torba/remote_sources/github_release.rb
|
@@ -106,6 +121,7 @@ files:
|
|
106
121
|
- test/package/import_list_test.rb
|
107
122
|
- test/package/logical_paths_test.rb
|
108
123
|
- test/package_test.rb
|
124
|
+
- test/rake_task_test.rb
|
109
125
|
- test/remote_sources/common_test.rb
|
110
126
|
- test/remote_sources/get_file_test.rb
|
111
127
|
- test/remote_sources/github_release_test.rb
|
@@ -146,6 +162,7 @@ test_files:
|
|
146
162
|
- test/package/import_list_test.rb
|
147
163
|
- test/package/logical_paths_test.rb
|
148
164
|
- test/package_test.rb
|
165
|
+
- test/rake_task_test.rb
|
149
166
|
- test/remote_sources/common_test.rb
|
150
167
|
- test/remote_sources/get_file_test.rb
|
151
168
|
- test/remote_sources/github_release_test.rb
|