rack-scriptstacker 0.1.1 → 0.1.2

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
  SHA1:
3
- metadata.gz: cc281f256f78497a6f6af1718b8d8c13826795aa
4
- data.tar.gz: aa30c150530591876cc4b4275250b17ca2bee526
3
+ metadata.gz: a914ef1f5f89b0925e4ae1edc1ab4ac5440adf9b
4
+ data.tar.gz: 2714b80f7f59306baa672aa2cf005a3840dd9d80
5
5
  SHA512:
6
- metadata.gz: 5904dc5fabccb038ae238e4f0a132713d61027ee6445fcee5075558a2b13f739398f1aba8ea96648c2e4269e4a25b3741d67c0c5cea3f98547717ba73adbb454
7
- data.tar.gz: 7acc8417e626b0322b3efc02ba4e4e431ed6d5c3d5647415013a62e863cbbfaf2abdc01cb3bd11d61326f3b8a3610b9f5f2e8cfd9179acef1a6b8a47924673fb
6
+ metadata.gz: c26c47ebd502140d558b493a664ee7e32ce6d35fbe210bbd89b43e9e85e77256c5f48afeeac9f613d74227eb746c481b20a1b15ab99d1e90eb25d8fc3ed010cc
7
+ data.tar.gz: f357d5aa3aa3bb3e04e2bf1dab8e310553a4326c0728bd27950bc0a10418c22c00f1af4028c66e15c88476af5da285f7824042012766d593873d3a3ea32771e9
data/.gitignore CHANGED
@@ -1 +1,2 @@
1
1
  Gemfile.lock
2
+ pkg/
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class ScriptStacker
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
@@ -1,14 +1,8 @@
1
- require 'rack/scriptstacker/version'
2
1
  require 'rack'
3
2
 
4
- class ::Hash
5
- def recursive_merge other
6
- merger = proc do |key, v1, v2|
7
- Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2
8
- end
9
- self.merge(other, &merger)
10
- end
11
- end
3
+ require 'cantrips/hash/recursive_merge'
4
+
5
+ require 'rack/scriptstacker/version'
12
6
 
13
7
  module Rack
14
8
  class ScriptStacker
@@ -4,22 +4,23 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'rack/scriptstacker/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
- spec.name = "rack-scriptstacker"
7
+ spec.name = 'rack-scriptstacker'
8
8
  spec.version = Rack::ScriptStacker::VERSION
9
- spec.authors = ["Max Cantor"]
10
- spec.email = ["max@maxcantor.net"]
9
+ spec.authors = ['Max Cantor']
10
+ spec.email = ['max@maxcantor.net']
11
11
  spec.summary = %q{Quickly inject static file lists into served HTML.}
12
- spec.homepage = "http://github.com/mcantor/rack-scriptstacker"
13
- spec.license = "MIT"
12
+ spec.homepage = 'http://github.com/mcantor/rack-scriptstacker'
13
+ spec.license = 'WTFPL'
14
14
 
15
- spec.files = `git ls-files -z`.split("\x0")
16
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
- spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
- spec.require_paths = ["lib"]
15
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ spec.bindir = 'exe'
17
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
18
+ spec.require_paths = ['lib']
19
19
 
20
- spec.add_dependency "rack", "~> 1.6"
20
+ spec.add_dependency 'rack', '~> 1.6'
21
+ spec.add_dependency 'cantrips'
21
22
 
22
- spec.add_development_dependency "bundler", "~> 1.7"
23
- spec.add_development_dependency "rake", "~> 10.0"
24
- spec.add_development_dependency "rspec", "~> 3.3"
23
+ spec.add_development_dependency 'bundler', '~> 1.10'
24
+ spec.add_development_dependency 'rake', '~> 10.0'
25
+ spec.add_development_dependency 'rspec'
25
26
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-scriptstacker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Cantor
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2015-07-22 00:00:00.000000000 Z
11
+ date: 2015-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -24,20 +24,34 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: cantrips
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: bundler
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - "~>"
32
46
  - !ruby/object:Gem::Version
33
- version: '1.7'
47
+ version: '1.10'
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
52
  - - "~>"
39
53
  - !ruby/object:Gem::Version
40
- version: '1.7'
54
+ version: '1.10'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rake
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -56,16 +70,16 @@ dependencies:
56
70
  name: rspec
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - "~>"
73
+ - - ">="
60
74
  - !ruby/object:Gem::Version
61
- version: '3.3'
75
+ version: '0'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - "~>"
80
+ - - ">="
67
81
  - !ruby/object:Gem::Version
68
- version: '3.3'
82
+ version: '0'
69
83
  description:
70
84
  email:
71
85
  - max@maxcantor.net
@@ -76,17 +90,14 @@ files:
76
90
  - ".gitignore"
77
91
  - ".rspec"
78
92
  - Gemfile
79
- - LICENSE.txt
80
93
  - README.md
81
94
  - Rakefile
82
95
  - lib/rack/scriptstacker.rb
83
96
  - lib/rack/scriptstacker/version.rb
84
97
  - rack-scriptstacker.gemspec
85
- - spec/scriptstacker_spec.rb
86
- - spec/spec_helper.rb
87
98
  homepage: http://github.com/mcantor/rack-scriptstacker
88
99
  licenses:
89
- - MIT
100
+ - WTFPL
90
101
  metadata: {}
91
102
  post_install_message:
92
103
  rdoc_options: []
@@ -108,6 +119,4 @@ rubygems_version: 2.4.5
108
119
  signing_key:
109
120
  specification_version: 4
110
121
  summary: Quickly inject static file lists into served HTML.
111
- test_files:
112
- - spec/scriptstacker_spec.rb
113
- - spec/spec_helper.rb
122
+ test_files: []
data/LICENSE.txt DELETED
@@ -1,22 +0,0 @@
1
- Copyright (c) 2015 Max Cantor
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,204 +0,0 @@
1
- require 'pry'
2
- require 'rack/scriptstacker'
3
-
4
- def smart_deindent str
5
- first_line_indent = str.match(/^\s*/).to_s.size
6
- str.gsub(/^\s{#{first_line_indent}}/, '')
7
- end
8
-
9
- def app_with_body body
10
- lambda { |env| [200, {'Content-Type' => 'text/html'}, [body]] }
11
- end
12
-
13
- describe Rack::ScriptStacker do
14
- let(:js_files) { ['main.js', 'util.js'] }
15
- let(:vendor_js_files) { ['jquery.js', 'blogo_web.js'] }
16
- let(:css_files) { ['main.css', '_whatever.css'] }
17
- let(:config) do
18
- {
19
- configure_static: false,
20
- inject_mode: Rack::ScriptStacker::InjectMode::SLOT
21
- }
22
- end
23
- let(:stack_spec) do
24
- Proc.new {
25
- css 'static/css'
26
- javascript 'static/javascripts'
27
- }
28
- end
29
- let(:middleware) do
30
- Rack::ScriptStacker.new app_with_body(body), config, &stack_spec
31
- end
32
-
33
- before :each do
34
- allow_any_instance_of(Rack::ScriptStackerUtils::Stacker).to receive(:files_for).with('static/css/').and_return(css_files)
35
- allow_any_instance_of(Rack::ScriptStackerUtils::Stacker).to receive(:files_for).with('static/javascripts/').and_return(js_files)
36
- allow_any_instance_of(Rack::ScriptStackerUtils::Stacker).to receive(:files_for).with('vendor/javascripts/').and_return(vendor_js_files)
37
- if middleware
38
- @response = middleware.call nil
39
- @response_body = @response[2][0]
40
- end
41
- end
42
-
43
- context 'inactive' do
44
- let(:body) { '<div>whatever</div>' }
45
- it 'does not change without replacement slots' do
46
- expect(@response_body).to eq('<div>whatever</div>')
47
- end
48
- end
49
-
50
- context 'javascript' do
51
- let(:body) do
52
- smart_deindent(<<-HTML)
53
- <body>
54
- <div>lmao</div>
55
- <!-- ScriptStacker: JAVASCRIPT //-->
56
- </body>
57
- HTML
58
- end
59
- it 'injects tags' do
60
- expect(@response_body).to eq(smart_deindent(<<-HTML))
61
- <body>
62
- <div>lmao</div>
63
- <script type="text/javascript" src="/static/javascripts/main.js"></script>
64
- <script type="text/javascript" src="/static/javascripts/util.js"></script>
65
- </body>
66
- HTML
67
- end
68
- end
69
-
70
- context 'css' do
71
- let(:body) do
72
- smart_deindent(<<-HTML)
73
- <head>
74
- <!-- ScriptStacker: CSS //-->
75
- </head>
76
- HTML
77
- end
78
- it 'injects tags' do
79
- expect(@response_body).to eq(smart_deindent(<<-HTML))
80
- <head>
81
- <link rel="stylesheet" type="text/css" href="/static/css/main.css" />
82
- <link rel="stylesheet" type="text/css" href="/static/css/_whatever.css" />
83
- </head>
84
- HTML
85
- end
86
- end
87
-
88
- context 'multiple specs for one stacker' do
89
- let(:stack_spec) do
90
- Proc.new {
91
- javascript 'vendor/javascripts'
92
- javascript 'static/javascripts'
93
- }
94
- end
95
- let(:body) do
96
- smart_deindent(<<-HTML)
97
- <body>
98
- <div>lmao</div>
99
- <!-- ScriptStacker: JAVASCRIPT //-->
100
- </body>
101
- HTML
102
- end
103
- it 'injects tags in order' do
104
- expect(@response_body).to eq(smart_deindent(<<-HTML))
105
- <body>
106
- <div>lmao</div>
107
- <script type="text/javascript" src="/vendor/javascripts/jquery.js"></script>
108
- <script type="text/javascript" src="/vendor/javascripts/blogo_web.js"></script>
109
- <script type="text/javascript" src="/static/javascripts/main.js"></script>
110
- <script type="text/javascript" src="/static/javascripts/util.js"></script>
111
- </body>
112
- HTML
113
- end
114
- end
115
-
116
- context 'static file auto-configuration' do
117
- let(:body) { '<div>whatever</div>' }
118
- it 'configures static automatically' do
119
- expect(Rack::Static).to receive(:new).with(
120
- duck_type(:call), {
121
- urls: ['/static/css/', '/static/javascripts/']
122
- }
123
- )
124
- Rack::ScriptStacker.new app_with_body(body), configure_static: true do
125
- css 'static/css'
126
- javascript 'static/javascripts'
127
- end
128
- end
129
- end
130
-
131
- context 'auto-inject' do
132
- let(:config) do
133
- {
134
- configure_static: false,
135
- inject_mode: Rack::ScriptStacker::InjectMode::TAG
136
- }
137
- end
138
- let(:body) do
139
- smart_deindent(<<-HTML)
140
- <html>
141
- <head>
142
- <title>OH RLY</title>
143
- </head>
144
- <body>
145
- <div>ya rly</div>
146
- </body>
147
- </html>
148
- HTML
149
- end
150
- it 'injects before the <head> and <body> tags' do
151
- expect(@response_body).to eq(smart_deindent(<<-HTML))
152
- <html>
153
- <head>
154
- <title>OH RLY</title>
155
- <link rel="stylesheet" type="text/css" href="/static/css/main.css" />
156
- <link rel="stylesheet" type="text/css" href="/static/css/_whatever.css" />
157
- </head>
158
- <body>
159
- <div>ya rly</div>
160
- <script type="text/javascript" src="/static/javascripts/main.js"></script>
161
- <script type="text/javascript" src="/static/javascripts/util.js"></script>
162
- </body>
163
- </html>
164
- HTML
165
- end
166
- end
167
- end
168
-
169
- describe Rack::ScriptStackerUtils::PathSpec do
170
- let(:css_spec) { Rack::ScriptStackerUtils::PathSpec.new(
171
- 'static/css/' => '/stylesheets'
172
- )}
173
- let(:js_spec) { Rack::ScriptStackerUtils::PathSpec.new(
174
- 'static/javascripts' => 'static/js/'
175
- )}
176
-
177
- context 'serve path' do
178
- it 'always serves with absolute paths' do
179
- expect(js_spec.serve_path).to start_with('/')
180
- end
181
- it 'appends a slash when there is none, for concatenation simplicity' do
182
- expect(css_spec.serve_path).to end_with('/')
183
- end
184
- it 'does not prepend a redundant slash' do
185
- expect(css_spec.serve_path[0..1]).to_not start_with('//')
186
- end
187
- it 'does not append a redundant slash' do
188
- expect(js_spec.serve_path[-2..-1]).to_not end_with('//')
189
- end
190
- end
191
-
192
- context 'source path' do
193
- it 'appends a slash when there is none, for concatenation simplicity' do
194
- expect(js_spec.source_path).to end_with('/')
195
- end
196
- it 'does not prepend a slash, because local files are relative to pwd' do
197
- expect(css_spec.source_path).to_not start_with('/')
198
- end
199
- it 'does not append a redundant slash' do
200
- expect(css_spec.source_path).to_not end_with('//')
201
- end
202
- end
203
- end
204
-
data/spec/spec_helper.rb DELETED
@@ -1,96 +0,0 @@
1
- # This file was generated by the `rspec --init` command. Conventionally, all
2
- # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
- # The generated `.rspec` file contains `--require spec_helper` which will cause
4
- # this file to always be loaded, without a need to explicitly require it in any
5
- # files.
6
- #
7
- # Given that it is always loaded, you are encouraged to keep this file as
8
- # light-weight as possible. Requiring heavyweight dependencies from this file
9
- # will add to the boot time of your test suite on EVERY test run, even for an
10
- # individual file that may not need all of that loaded. Instead, consider making
11
- # a separate helper file that requires the additional dependencies and performs
12
- # the additional setup, and require it from the spec files that actually need
13
- # it.
14
- #
15
- # The `.rspec` file also contains a few flags that are not defaults but that
16
- # users commonly want.
17
- #
18
- # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
19
- RSpec.configure do |config|
20
- # rspec-expectations config goes here. You can use an alternate
21
- # assertion/expectation library such as wrong or the stdlib/minitest
22
- # assertions if you prefer.
23
- config.expect_with :rspec do |expectations|
24
- # This option will default to `true` in RSpec 4. It makes the `description`
25
- # and `failure_message` of custom matchers include text for helper methods
26
- # defined using `chain`, e.g.:
27
- # be_bigger_than(2).and_smaller_than(4).description
28
- # # => "be bigger than 2 and smaller than 4"
29
- # ...rather than:
30
- # # => "be bigger than 2"
31
- expectations.include_chain_clauses_in_custom_matcher_descriptions = true
32
- end
33
-
34
- # rspec-mocks config goes here. You can use an alternate test double
35
- # library (such as bogus or mocha) by changing the `mock_with` option here.
36
- config.mock_with :rspec do |mocks|
37
- # Prevents you from mocking or stubbing a method that does not exist on
38
- # a real object. This is generally recommended, and will default to
39
- # `true` in RSpec 4.
40
- mocks.verify_partial_doubles = true
41
- end
42
-
43
- # The settings below are suggested to provide a good initial experience
44
- # with RSpec, but feel free to customize to your heart's content.
45
- =begin
46
- # These two settings work together to allow you to limit a spec run
47
- # to individual examples or groups you care about by tagging them with
48
- # `:focus` metadata. When nothing is tagged with `:focus`, all examples
49
- # get run.
50
- config.filter_run :focus
51
- config.run_all_when_everything_filtered = true
52
-
53
- # Allows RSpec to persist some state between runs in order to support
54
- # the `--only-failures` and `--next-failure` CLI options. We recommend
55
- # you configure your source control system to ignore this file.
56
- config.example_status_persistence_file_path = "spec/examples.txt"
57
-
58
- # Limits the available syntax to the non-monkey patched syntax that is
59
- # recommended. For more details, see:
60
- # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
61
- # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
62
- # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
63
- config.disable_monkey_patching!
64
-
65
- # This setting enables warnings. It's recommended, but in some cases may
66
- # be too noisy due to issues in dependencies.
67
- config.warnings = true
68
-
69
- # Many RSpec users commonly either run the entire suite or an individual
70
- # file, and it's useful to allow more verbose output when running an
71
- # individual spec file.
72
- if config.files_to_run.one?
73
- # Use the documentation formatter for detailed output,
74
- # unless a formatter has already been configured
75
- # (e.g. via a command-line flag).
76
- config.default_formatter = 'doc'
77
- end
78
-
79
- # Print the 10 slowest examples and example groups at the
80
- # end of the spec run, to help surface which specs are running
81
- # particularly slow.
82
- config.profile_examples = 10
83
-
84
- # Run specs in random order to surface order dependencies. If you find an
85
- # order dependency and want to debug it, you can fix the order by providing
86
- # the seed, which is printed after each run.
87
- # --seed 1234
88
- config.order = :random
89
-
90
- # Seed global randomization in this process using the `--seed` CLI option.
91
- # Setting this allows you to use `--seed` to deterministically reproduce
92
- # test failures related to randomization by passing the same `--seed` value
93
- # as the one that triggered the failure.
94
- Kernel.srand config.seed
95
- =end
96
- end