torba 0.7.0 → 1.0.0

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: a22c7a165ee7472c946d1071f7b0b0a7c4435048
4
- data.tar.gz: a7df1df4c4f0557d90302c1a76c83e25ef1d0be7
3
+ metadata.gz: dffb3d16bfcf61e1a3140263cad47fc52626ef52
4
+ data.tar.gz: 1b60520eed5966d1a4cf78461f3f5676ca65d36b
5
5
  SHA512:
6
- metadata.gz: 36462194a06c6b4ec1a48508f819ed4057f6ab401fc9a69d356d723dd67a99a64195bc594132309047121ae6e06a5af5079da310e4d42c854b2ff47027a8bcf1
7
- data.tar.gz: 07fe683e3025332f05d11f60a735842e2b1f7b8b26c964a516acfd92470a1382090cbf02f8d05e354a86e1b6dc605b41790c76e63847be09fde509f823056115
6
+ metadata.gz: de9720c5da6dacb684e29e0f2a1d8d4d256e7dfbee348552d073074578bad552e19742ccc768ff1897cfd87c6aa3ff42a8f5025ecc58476f4b28de1820644787
7
+ data.tar.gz: 90b3a95611f4839a78aebf35e5146f5b510d969cc2c0278a4787f4034f597f7d42767bef40f3b213ac5780fa2ca18d7978083f15a3cdca319375d3c683b25c78
data/.yardopts CHANGED
@@ -1 +1,3 @@
1
1
  --no-private
2
+ -
3
+ CHANGELOG.md
data/CHANGELOG.md CHANGED
@@ -1,5 +1,35 @@
1
1
  ## Unreleased
2
2
 
3
+ ## Version 1.0.0
4
+
5
+ ### Breaking changes
6
+
7
+ * Rails support has been removed. Use [torba-rails][torba-rails] instead.
8
+ * `torba/verify` no longer checks, whether it is executed within Rake task
9
+ or not. This was a workaround for Rails support, which is no longer a goal
10
+ of this gem.
11
+ * `torba/verify` no longer checks `TORBA_DONT_VERIFY` env variable. Same as
12
+ above.
13
+
14
+ ### Upgrading notes
15
+
16
+ If you are a non-Rails user, this should be a non-breaking update. In rare cases,
17
+ when you depend on old behaviour of `torba/verify`, please, add the conditionals
18
+ to your application code.
19
+
20
+ Rails users should:
21
+
22
+ 1. Replace `gem "torba"` with `gem "torba-rails"` in the Gemfile.
23
+ 2. Remove `require "torba/verify"` from `boot.rb`.
24
+ 3. Remove `require "torba/rails"` from `application.rb`.
25
+ 4. Unset obsolete `TORBA_DONT_VERIFY` env variable if present.
26
+
27
+ ### Enhancements
28
+
29
+ * Rake task accepts a block to be executed before packing process
30
+
31
+ [torba-rails]: https://github.com/torba-rb/torba-rails
32
+
3
33
  ## Version 0.7.0
4
34
 
5
35
  ### Enhancements
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.7.0)
20
+ [Released version](http://rubydoc.info/gems/torba/1.0.0)
21
21
 
22
22
  ## Why
23
23
 
@@ -53,29 +53,20 @@ Problems with the Bower:
53
53
 
54
54
  ## Installation
55
55
 
56
- Add this line to your application's Gemfile and run `bundle`:
56
+ ### Rails
57
57
 
58
- ```ruby
59
- gem 'torba'
60
- ```
58
+ Use [torba-rails][torba-rails-github].
61
59
 
62
- ### Rails
60
+ ### Sinatra
63
61
 
64
- in boot.rb
62
+ See this [example project][sinatra-example].
65
63
 
66
- ```diff
67
- require 'bundler/setup' # Set up gems listed in the Gemfile.
68
- +require 'torba/verify'
69
- ```
64
+ ### Other Ruby application
70
65
 
71
- in config/application.rb
66
+ Add this line to your application's Gemfile and run bundle:
72
67
 
73
- ```diff
74
- # Require the gems listed in Gemfile, including any gems
75
- # you've limited to :test, :development, or :production.
76
- Bundler.require(*Rails.groups)
77
- +
78
- +require 'torba/rails'
68
+ ```ruby
69
+ gem 'torba'
79
70
  ```
80
71
 
81
72
  ## Usage
@@ -87,14 +78,8 @@ in config/application.rb
87
78
  3. Add "require" [Sprockets directives][sprockets-directives] to your "application.js"
88
79
  and/or "@import" [Sass directives][sass-import] to "application.css".
89
80
 
90
- 4. Non JS/CSS assets are automatically added to precompile list, nothing to do here.
91
-
92
81
  If any changes made to the Torbafile, run `bundle exec torba pack` again.
93
82
 
94
- ### Examples
95
-
96
- See fully configured [Rails application][rails-example].
97
-
98
83
  ### Torbafile
99
84
 
100
85
  Torbafile is an assets specification. It is a plain text file that contains one or more
@@ -179,6 +164,10 @@ You can omit the name, it will be equal to the package name:
179
164
  npm package: "coffee-script", version: "1.9.2"
180
165
  ```
181
166
 
167
+ ### Examples
168
+
169
+ See [Torbafiles][torbafile-examples] used for testing.
170
+
182
171
  ### "Packing the torba" process
183
172
 
184
173
  When you run `torba pack` the following happens:
@@ -248,58 +237,6 @@ gh_release "lightslider", source: "sachinchoolur/lightslider", tag: "1.1.2", imp
248
237
 
249
238
  In addition to this "path/" is treated as a shortcut for "path/**/*" glob pattern.
250
239
 
251
- Be careful to **import only that you really need**. Everything that is non JS or CSS asset is
252
- going to be precompiled by Sprockets and accessible publicly. See [Rails ticket][rails-ticket-vendoring]
253
- that explains this problem (and why Rails >= 4 precompiles only application.js/css in vendor by
254
- default), except that Torba does have a way to specify exact list of files to import.
255
-
256
- ## Deployment
257
-
258
- In Rails apps, Torba automatically hooks into the existing `assets:precompile`
259
- Rake task to ensure that `torba pack` is executed. This means that Rails
260
- deployments will "just work", although there are some optimizations you can make
261
- as explained below.
262
-
263
- ### Heroku
264
-
265
- You will need to specify some config vars to ensure Torba's files are placed in
266
- locations suitable for the Heroku platform.
267
-
268
- `TORBA_HOME_PATH` should be within your app so that Torba's assets are included
269
- in the slug.
270
-
271
- `TORBA_CACHE_PATH` should make use of the `tmp/cache/assets` directory. This is
272
- where the Ruby buildpack expects cached files to be stored related to the
273
- `assets:precompile` step. This way Torba doesn't have to download packages fresh
274
- every time.
275
-
276
- ```bash
277
- heroku config:set TORBA_HOME_PATH=vendor/torba TORBA_CACHE_PATH=tmp/cache/assets/torba
278
- ```
279
-
280
- Now your Heroku app is good to go.
281
-
282
- ### Capistrano
283
-
284
- Specify the `TORBA_HOME_PATH` env variable pointing to a persistent directory
285
- writable by your deploy user and shared across releases. Capistrano's `shared`
286
- directory is good for this.
287
-
288
- For Capistrano 3, you can set this up in `config/deploy.rb`:
289
- ```
290
- set :default_env, { torba_home_path: shared_path.join('vendor/torba') }
291
- ```
292
-
293
- ### Troubleshooting
294
-
295
- If you are getting an error like `Your Torba is not packed yet` when trying to
296
- run `rake assets:precompile` (or `bin/rails assets:precompile` in Rails 5),
297
- set the `TORBA_DONT_VERIFY` environment variable, like this:
298
-
299
- ```bash
300
- TORBA_DONT_VERIFY=1 bin/rake assets:precompile
301
- ```
302
-
303
240
  [bower]: http://bower.io/
304
241
  [sprockets]: https://github.com/rails/sprockets/
305
242
  [sprockets-load-path]: https://github.com/rails/sprockets#the-load-path
@@ -310,6 +247,7 @@ TORBA_DONT_VERIFY=1 bin/rake assets:precompile
310
247
  [rails-assets]: https://rails-assets.org/
311
248
  [bower-rails]: https://github.com/rharriso/bower-rails
312
249
  [semver]: http://semver.org/
313
- [rails-ticket-vendoring]: https://github.com/rails/rails/pull/7968
314
250
  [npm]: https://npmjs.com
315
- [rails-example]: https://github.com/torba-rb/rails-example
251
+ [torba-rails-github]: https://github.com/torba-rb/torba-rails
252
+ [sinatra-example]: https://github.com/xfalcox/sinatra-assets-seed
253
+ [torbafile-examples]: https://github.com/torba-rb/torba/tree/master/test/fixtures/torbafiles
@@ -18,6 +18,12 @@ module Torba
18
18
  # require "torba/rake_task"
19
19
  # Torba::RakeTask.new("torba:pack", :before => "assets:precompile")
20
20
  #
21
+ # You can also provide a block, which will be executed before packing process:
22
+ #
23
+ # Torba::RakeTask.new do
24
+ # # some preconfiguration to be run when the "torba:pack" task is executed
25
+ # end
26
+ #
21
27
  # Note that when you require "torba/rails" in a Rails app, this Rake task is
22
28
  # installed for you automatically. You only need to install the task yourself
23
29
  # if you are using something different, like Sinatra.
@@ -25,17 +31,18 @@ module Torba
25
31
  class RakeTask < Rake::TaskLib
26
32
  attr_reader :torba_pack_task_name
27
33
 
28
- def initialize(name="torba:pack", options={})
34
+ def initialize(name="torba:pack", options={}, &before_pack)
29
35
  @torba_pack_task_name = name
30
- define_task
36
+ define_task(before_pack)
31
37
  install_as_prerequisite(options[:before]) if options[:before]
32
38
  end
33
39
 
34
40
  private
35
41
 
36
- def define_task
42
+ def define_task(before_pack_proc)
37
43
  desc "Download and prepare all packages defined in Torbafile"
38
44
  task torba_pack_task_name do
45
+ before_pack_proc.call if before_pack_proc
39
46
  Torba.pretty_errors { Torba.pack }
40
47
  end
41
48
  end
data/lib/torba/verify.rb CHANGED
@@ -1,14 +1,7 @@
1
1
  require "torba"
2
2
 
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
3
+ if STDOUT.tty?
4
+ Torba.pretty_errors { Torba.verify }
5
+ else
6
+ Torba.verify
14
7
  end
@@ -15,7 +15,7 @@ module Torba
15
15
  "TORBA_EDITOR" => "echo torba_editor", "VISUAL" => "echo visual", "EDITOR" => "echo editor"
16
16
  })
17
17
  assert status.success?, err
18
- compare_dirs "test/fixtures/home_path/01", path_to_packaged("trumbowyg")
18
+ assert_dirs_equal "test/fixtures/home_path/01", path_to_packaged("trumbowyg")
19
19
  end
20
20
 
21
21
  def test_uses_torba_editor_first
@@ -6,28 +6,28 @@ module Torba
6
6
  out, err, status = torba("pack", torbafile: "01_zip.rb")
7
7
  assert status.success?, err
8
8
  assert_includes out, "Torba has been packed!"
9
- compare_dirs "test/fixtures/home_path/01", path_to_packaged("trumbowyg")
9
+ assert_dirs_equal "test/fixtures/home_path/01", path_to_packaged("trumbowyg")
10
10
  end
11
11
 
12
12
  def test_targz
13
13
  out, err, status = torba("pack", torbafile: "01_targz.rb")
14
14
  assert status.success?, err
15
15
  assert_includes out, "Torba has been packed!"
16
- compare_dirs "test/fixtures/home_path/01", path_to_packaged("trumbowyg")
16
+ assert_dirs_equal "test/fixtures/home_path/01", path_to_packaged("trumbowyg")
17
17
  end
18
18
 
19
19
  def test_gh_release
20
20
  out, err, status = torba("pack", torbafile: "01_gh_release.rb")
21
21
  assert status.success?, err
22
22
  assert_includes out, "Torba has been packed!"
23
- compare_dirs "test/fixtures/home_path/01", path_to_packaged("trumbowyg")
23
+ assert_dirs_equal "test/fixtures/home_path/01", path_to_packaged("trumbowyg")
24
24
  end
25
25
 
26
26
  def test_npm
27
27
  out, err, status = torba("pack", torbafile: "02_npm.rb")
28
28
  assert status.success?, err
29
29
  assert_includes out, "Torba has been packed!"
30
- compare_dirs "test/fixtures/home_path/02", path_to_packaged("lo_dash")
30
+ assert_dirs_equal "test/fixtures/home_path/02", path_to_packaged("lo_dash")
31
31
  end
32
32
 
33
33
  def test_without_image_asset_specified_in_import
@@ -43,7 +43,7 @@ OUT
43
43
  out, err, status = torba("pack", torbafile: "03_not_existed_assets.rb")
44
44
  assert status.success?, err
45
45
  assert_includes out, "Torba has been packed!"
46
- compare_dirs "test/fixtures/home_path/03", path_to_packaged("bourbon")
46
+ assert_dirs_equal "test/fixtures/home_path/03", path_to_packaged("bourbon")
47
47
  end
48
48
  end
49
49
  end
@@ -5,7 +5,7 @@ module Torba
5
5
  def test_runs_pack
6
6
  out, err, status = torba("show trumbowyg", torbafile: "01_zip.rb")
7
7
  assert status.success?, err
8
- compare_dirs "test/fixtures/home_path/01", path_to_packaged("trumbowyg")
8
+ assert_dirs_equal "test/fixtures/home_path/01", path_to_packaged("trumbowyg")
9
9
  end
10
10
 
11
11
  def test_outputs_package_directory
@@ -34,6 +34,19 @@ module Torba
34
34
  Rake::Task["torba:pack"].invoke
35
35
  end
36
36
 
37
+ def test_calls_a_block_before_torba_pack
38
+ Rake::Task.clear
39
+
40
+ configuration = Object.new
41
+
42
+ order = sequence("correct order")
43
+ configuration.expects(:setup).in_sequence(order)
44
+ Torba.expects(:pack).in_sequence(order)
45
+
46
+ task = Torba::RakeTask.new("torba:pack") { configuration.setup }
47
+ Rake::Task["torba:pack"].invoke
48
+ end
49
+
37
50
  def test_defines_task_if_doesnt_exist
38
51
  Rake::Task.clear
39
52
  Torba::RakeTask.new("torba:pack", :before => "something:else")
data/test/test_helper.rb CHANGED
@@ -3,6 +3,7 @@ require "torba"
3
3
  require "torba/remote_sources/common"
4
4
 
5
5
  require "minitest/autorun"
6
+ require "minitest/assert_dirs_equal"
6
7
  require "mocha/mini_test"
7
8
  require "tmpdir"
8
9
  require "fileutils"
@@ -52,32 +53,6 @@ module Torba
52
53
  assert path, "Couldn't find packaged #{name.inspect} in #{home.inspect}"
53
54
  path
54
55
  end
55
-
56
- def read_without_newline(path)
57
- content = File.read(path)
58
- content.strip
59
- rescue ArgumentError # ignore binary files
60
- content
61
- end
62
-
63
- def compare_dirs(expected, actual)
64
- expected_paths = Dir.glob("#{expected}/**/*").map{ |path| path.sub(expected, "")}
65
-
66
- expected_paths.each do |path|
67
- actual_file = File.join(actual, path)
68
- assert_exists actual_file
69
-
70
- unless File.directory?(actual_file)
71
- expected_file = File.join(expected, path)
72
- assert_equal read_without_newline(expected_file), read_without_newline(actual_file), "#{expected_file.inspect} should be equal to #{actual_file.inspect}"
73
- end
74
- end
75
-
76
- actual_paths = Dir.glob("#{actual}/**/*").map{ |path| path.sub(actual, "")}
77
-
78
- paths_diff = actual_paths - expected_paths
79
- assert_empty paths_diff, "#{expected.inspect} contains extra paths #{paths_diff.inspect}"
80
- end
81
56
  end
82
57
 
83
58
  module Exec
data/torba.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "torba"
3
- spec.version = "0.7.0"
3
+ spec.version = "1.0.0"
4
4
  spec.authors = ["Andrii Malyshko"]
5
5
  spec.email = ["mail@nashbridges.me"]
6
6
  spec.description = "Bundler for Sprockets"
@@ -20,4 +20,5 @@ Gem::Specification.new do |spec|
20
20
  spec.add_development_dependency "rake", "~> 10.0"
21
21
  spec.add_development_dependency "minitest", "~> 5.4"
22
22
  spec.add_development_dependency "mocha"
23
+ spec.add_development_dependency "assert_dirs_equal", "~> 0.1"
23
24
  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.7.0
4
+ version: 1.0.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-03-13 00:00:00.000000000 Z
11
+ date: 2016-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: assert_dirs_equal
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.1'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.1'
83
97
  description: Bundler for Sprockets
84
98
  email:
85
99
  - mail@nashbridges.me
@@ -104,7 +118,6 @@ files:
104
118
  - lib/torba/import_list.rb
105
119
  - lib/torba/manifest.rb
106
120
  - lib/torba/package.rb
107
- - lib/torba/rails.rb
108
121
  - lib/torba/rake_task.rb
109
122
  - lib/torba/remote_sources/common.rb
110
123
  - lib/torba/remote_sources/get_file.rb
data/lib/torba/rails.rb DELETED
@@ -1,13 +0,0 @@
1
- module Torba
2
- class Engine < Rails::Engine
3
- initializer "torba.assets" do |app|
4
- Rails.application.config.assets.paths.concat(Torba.load_path)
5
- Rails.application.config.assets.precompile.concat(Torba.non_js_css_logical_paths)
6
- end
7
-
8
- rake_tasks do
9
- require "torba/rake_task"
10
- Torba::RakeTask.new("torba:pack", :before => "assets:precompile")
11
- end
12
- end
13
- end