keynote 0.3.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +9 -29
- data/CHANGELOG.md +12 -0
- data/README.md +21 -12
- data/lib/keynote/cache.rb +3 -1
- data/lib/keynote/inline.rb +4 -4
- data/lib/keynote/presenter.rb +1 -1
- data/lib/keynote/rumble.rb +28 -9
- data/lib/keynote/version.rb +1 -1
- data/scenarios.yml +25 -0
- data/scenarios/rails31.docker-compose.yml +15 -0
- data/scenarios/rails31.dockerfile +5 -0
- data/{gemfiles → scenarios}/rails31.gemfile +2 -3
- data/scenarios/rails32.docker-compose.yml +15 -0
- data/scenarios/rails32.dockerfile +5 -0
- data/{gemfiles → scenarios}/rails32.gemfile +1 -3
- data/scenarios/rails40.docker-compose.yml +15 -0
- data/scenarios/rails40.dockerfile +5 -0
- data/{gemfiles → scenarios}/rails40.gemfile +1 -3
- data/scenarios/rails41.docker-compose.yml +15 -0
- data/scenarios/rails41.dockerfile +5 -0
- data/{gemfiles → scenarios}/rails41.gemfile +1 -3
- data/scenarios/rails42.docker-compose.yml +15 -0
- data/scenarios/rails42.dockerfile +5 -0
- data/{gemfiles → scenarios}/rails42.gemfile +1 -3
- data/scenarios/rails50.docker-compose.yml +15 -0
- data/scenarios/rails50.dockerfile +5 -0
- data/{gemfiles → scenarios}/rails50.gemfile +1 -3
- data/scenarios/rails51.docker-compose.yml +15 -0
- data/scenarios/rails51.dockerfile +5 -0
- data/scenarios/rails51.gemfile +6 -0
- data/spec/generator_spec.rb +15 -15
- data/spec/inline_spec.rb +8 -2
- data/spec/keynote_spec.rb +3 -4
- data/spec/presenter_spec.rb +2 -2
- data/spec/rumble_spec.rb +29 -0
- metadata +25 -10
- data/Appraisals +0 -29
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4bb2837127985cda52b837475d149b7a0445de3d
|
4
|
+
data.tar.gz: 1c76f12e8ab9ac25fbcd18183d3e5687a560faed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a95130c4b619eefa804e6bb2df56eb1f07271a7163e63f7b635aaa518485e7dc252ef41102325b8f09f5a0c7dd21aeb62045ed579a43262843b403d188e23258
|
7
|
+
data.tar.gz: 713dd5c6bbb3d69dc74e5e15360706ab61b92b81cfef00169279ddfb30dde8577ce2d7e680566d88a549d9908d65539ad57a8d1ddfff2207ae27cae37bfbe0e9
|
data/.travis.yml
CHANGED
@@ -1,31 +1,11 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
-
|
4
|
-
|
5
|
-
-
|
6
|
-
-
|
7
|
-
|
8
|
-
|
9
|
-
-
|
10
|
-
- gemfiles/rails40.gemfile
|
11
|
-
- gemfiles/rails41.gemfile
|
12
|
-
- gemfiles/rails42.gemfile
|
13
|
-
- gemfiles/rails50.gemfile
|
14
|
-
matrix:
|
15
|
-
exclude:
|
16
|
-
- rvm: 2.2.5
|
17
|
-
gemfile: gemfiles/rails31.gemfile
|
18
|
-
- rvm: 2.2.5
|
19
|
-
gemfile: gemfiles/rails32.gemfile
|
20
|
-
- rvm: 2.3.1
|
21
|
-
gemfile: gemfiles/rails31.gemfile
|
22
|
-
- rvm: 2.3.1
|
23
|
-
gemfile: gemfiles/rails32.gemfile
|
24
|
-
- rvm: jruby-9.1.5.0
|
25
|
-
gemfile: gemfiles/rails31.gemfile
|
26
|
-
- rvm: jruby-9.1.5.0
|
27
|
-
gemfile: gemfiles/rails32.gemfile
|
28
|
-
- rvm: 2.1.9
|
29
|
-
gemfile: gemfiles/rails50.gemfile
|
1
|
+
sudo: required
|
2
|
+
services:
|
3
|
+
- docker
|
4
|
+
before_install:
|
5
|
+
- wget https://github.com/rf-/roadshow/releases/download/v1.0.0/roadshow-linux64
|
6
|
+
- chmod +x roadshow-linux64
|
7
|
+
install: "true" # disable default `bundle install`
|
8
|
+
script:
|
9
|
+
- ./roadshow-linux64 run
|
30
10
|
notifications:
|
31
11
|
email: false
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
## v1.0.0
|
2
|
+
* Add support for Rails 5.1.
|
3
|
+
* Fix all Ruby warnings generated by Keynote itself.
|
4
|
+
* Rumble: Always escape quotation marks in HTML attributes, even if the string
|
5
|
+
is already marked as HTML-safe.
|
6
|
+
* Rumble: Allow user to pass in a `data` hash to generate data attributes.
|
7
|
+
* Rumble: Allow user to pass in an array value for an attribute, which will be
|
8
|
+
joined by spaces.
|
9
|
+
|
10
|
+
## v0.3.1
|
11
|
+
* Add support for Rails 5.0. (@dra)
|
12
|
+
|
1
13
|
## v0.3.0
|
2
14
|
* Drop support for Rails 3.0 and Ruby 1.9.2; add support for Rails 4.2.
|
3
15
|
* Drop support for MiniTest::Rails versions older than 2.0; add support for 2.0
|
data/README.md
CHANGED
@@ -29,7 +29,7 @@ class UserPresenter < Keynote::Presenter
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def profile_link
|
32
|
-
link_to user, display_name, data: {user_id: user.id}
|
32
|
+
link_to user, display_name, data: { user_id: user.id }
|
33
33
|
end
|
34
34
|
end
|
35
35
|
```
|
@@ -62,8 +62,8 @@ fragments. Here's a small example:
|
|
62
62
|
|
63
63
|
``` ruby
|
64
64
|
build_html do
|
65
|
-
div :
|
66
|
-
h1 'Hello World', :
|
65
|
+
div id: :content do
|
66
|
+
h1 'Hello World', class: :main
|
67
67
|
end
|
68
68
|
end
|
69
69
|
```
|
@@ -147,7 +147,7 @@ underlying objects, it's easy to do it explicitly with ActiveSupport's
|
|
147
147
|
|
148
148
|
class UserPresenter < Keynote::Presenter
|
149
149
|
presents :user
|
150
|
-
delegate :first_name, :last_name, :
|
150
|
+
delegate :first_name, :last_name, to: :user
|
151
151
|
|
152
152
|
def display_name
|
153
153
|
"#{first_name} #{last_name}"
|
@@ -156,7 +156,7 @@ end
|
|
156
156
|
```
|
157
157
|
|
158
158
|
You can also generate prefixed methods like `user_first_name` by passing
|
159
|
-
|
159
|
+
`prefix: true` to the `delegate` method.
|
160
160
|
|
161
161
|
## Rationale
|
162
162
|
|
@@ -225,23 +225,32 @@ Test::Unit or MiniTest::Rails if applicable.
|
|
225
225
|
|
226
226
|
## Compatibility
|
227
227
|
|
228
|
-
Keynote is supported on Rails 3.1
|
229
|
-
|
228
|
+
Keynote is supported on Rails 3.1 through 5.1. Keynote presenters are testable
|
229
|
+
with Test::Unit, RSpec, and MiniTest::Rails (>= 2.0).
|
230
230
|
|
231
231
|
If you find problems with any of the above integrations, please open an issue.
|
232
232
|
|
233
233
|
## Development
|
234
234
|
|
235
|
-
|
235
|
+
This repo uses [Roadshow] to generate a [Docker Compose] file for each
|
236
|
+
supported version of Rails (with a compatible version of Ruby for each one).
|
237
|
+
|
238
|
+
To run specs across all versions, you can either [get the Roadshow tool] and
|
239
|
+
run `roadshow run`, or use Docker Compose directly:
|
236
240
|
|
237
|
-
``` bash
|
238
|
-
$ bundle install
|
239
|
-
$ bundle exec appraisal install
|
240
|
-
$ bundle exec rake appraisal
|
241
241
|
```
|
242
|
+
$ for fn in scenarios/*.docker-compose-yml; do docker-compose -f $fn run --rm scenario; done
|
243
|
+
```
|
244
|
+
|
245
|
+
To update the set of scenarios, edit `scenarios.yml` and run `roadshow
|
246
|
+
generate`, although the Gemfiles in the `scenarios` directory need to be
|
247
|
+
maintained manually.
|
242
248
|
|
243
249
|
Feel free to submit pull requests according to the usual conventions for Ruby
|
244
250
|
projects.
|
245
251
|
|
246
252
|
[DisplayCase]: https://github.com/objects-on-rails/display-case
|
247
253
|
[Draper]: https://github.com/drapergem/draper
|
254
|
+
[Roadshow]: https://github.com/rf-/roadshow
|
255
|
+
[Docker Compose]: https://docs.docker.com/compose/
|
256
|
+
[get the Roadshow tool]: https://github.com/rf-/roadshow/releases
|
data/lib/keynote/cache.rb
CHANGED
@@ -26,7 +26,9 @@ module Keynote
|
|
26
26
|
end
|
27
27
|
|
28
28
|
# Initialize our cache on the view context if it doesn't already exist.
|
29
|
-
if
|
29
|
+
if view.instance_variable_defined?(:@_keynote_cache)
|
30
|
+
cache = view.instance_variable_get(:@_keynote_cache)
|
31
|
+
else
|
30
32
|
cache = {}
|
31
33
|
view.instance_variable_set(:@_keynote_cache, cache)
|
32
34
|
end
|
data/lib/keynote/inline.rb
CHANGED
@@ -173,10 +173,10 @@ module Keynote
|
|
173
173
|
|
174
174
|
private
|
175
175
|
|
176
|
-
def read_template(source_file,
|
176
|
+
def read_template(source_file, line_num)
|
177
177
|
result = ""
|
178
178
|
|
179
|
-
File.foreach(source_file).drop(
|
179
|
+
File.foreach(source_file).drop(line_num).each do |line|
|
180
180
|
if line =~ COMMENTED_LINE
|
181
181
|
result << $1 << "\n"
|
182
182
|
else
|
@@ -228,7 +228,7 @@ module Keynote
|
|
228
228
|
|
229
229
|
compile(view, view.class)
|
230
230
|
|
231
|
-
@source = nil if @virtual_path
|
231
|
+
@source = nil if defined?(@virtual_path) && @virtual_path
|
232
232
|
@compiled = true
|
233
233
|
end
|
234
234
|
end
|
@@ -248,7 +248,7 @@ module Keynote
|
|
248
248
|
|
249
249
|
compile(view.class)
|
250
250
|
|
251
|
-
@source = nil if @virtual_path
|
251
|
+
@source = nil if defined?(@virtual_path) && @virtual_path
|
252
252
|
@compiled = true
|
253
253
|
end
|
254
254
|
end
|
data/lib/keynote/presenter.rb
CHANGED
data/lib/keynote/rumble.rb
CHANGED
@@ -228,6 +228,7 @@ module Keynote
|
|
228
228
|
@instance = instance
|
229
229
|
@name = name
|
230
230
|
@sc = sc
|
231
|
+
@done, @content = nil
|
231
232
|
end
|
232
233
|
|
233
234
|
def attributes
|
@@ -266,6 +267,14 @@ module Keynote
|
|
266
267
|
content = nil
|
267
268
|
end
|
268
269
|
|
270
|
+
# Flatten `data` hash into individual attributes if necessary
|
271
|
+
if attrs && attrs[:data].is_a?(Hash)
|
272
|
+
attrs = attrs.dup
|
273
|
+
attrs.delete(:data).each do |key, value|
|
274
|
+
attrs[:"data-#{key}"] = value.to_s
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
269
278
|
merge_attributes(attrs) if attrs
|
270
279
|
|
271
280
|
if block_given?
|
@@ -314,10 +323,18 @@ module Keynote
|
|
314
323
|
|
315
324
|
def attrs_to_s
|
316
325
|
attributes.inject("") do |res, (name, value)|
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
326
|
+
next unless value
|
327
|
+
|
328
|
+
value =
|
329
|
+
if value.is_a?(Array)
|
330
|
+
value.map { |val| Rumble.html_escape(val) }.join(" ")
|
331
|
+
elsif value == true
|
332
|
+
name
|
333
|
+
else
|
334
|
+
Rumble.html_escape(value)
|
335
|
+
end
|
336
|
+
|
337
|
+
res << " #{name}=\"#{value.gsub('"'.freeze, '"'.freeze)}\""
|
321
338
|
res
|
322
339
|
end
|
323
340
|
end
|
@@ -326,7 +343,9 @@ module Keynote
|
|
326
343
|
# Generate HTML using Rumble tag methods. If tag methods are called
|
327
344
|
# outside a `build_html` block, they'll raise an exception.
|
328
345
|
def build_html
|
329
|
-
|
346
|
+
if defined?(@rumble_context)
|
347
|
+
ctx = @rumble_context
|
348
|
+
end
|
330
349
|
@rumble_context = Context.new
|
331
350
|
yield
|
332
351
|
rumble_cleanup(ctx).to_s
|
@@ -337,7 +356,7 @@ module Keynote
|
|
337
356
|
def text(str = nil, &blk)
|
338
357
|
str = Rumble.html_escape(str || blk.call)
|
339
358
|
|
340
|
-
if @rumble_context
|
359
|
+
if defined?(@rumble_context) && @rumble_context
|
341
360
|
@rumble_context << str
|
342
361
|
else
|
343
362
|
str
|
@@ -346,12 +365,12 @@ module Keynote
|
|
346
365
|
|
347
366
|
# @private
|
348
367
|
def rumble_context
|
349
|
-
@rumble_context
|
368
|
+
defined?(@rumble_context) ? @rumble_context : nil
|
350
369
|
end
|
351
370
|
|
352
371
|
# @private
|
353
372
|
def rumble_cleanup(value = nil)
|
354
|
-
@rumble_context
|
373
|
+
defined?(@rumble_context) ? @rumble_context : nil
|
355
374
|
ensure
|
356
375
|
@rumble_context = value
|
357
376
|
end
|
@@ -359,7 +378,7 @@ module Keynote
|
|
359
378
|
private
|
360
379
|
|
361
380
|
def rumble_tag(name, sc, content = nil, attrs = nil, &blk)
|
362
|
-
if !@rumble_context
|
381
|
+
if !defined?(@rumble_context) || !@rumble_context
|
363
382
|
raise Rumble::Error, "Must enclose tags in `rumble { ... }` block"
|
364
383
|
end
|
365
384
|
|
data/lib/keynote/version.rb
CHANGED
data/scenarios.yml
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
project: keynote
|
2
|
+
|
3
|
+
shared:
|
4
|
+
from: ruby:2.4
|
5
|
+
cmd: "(bundle check || bundle install) && bundle exec rake"
|
6
|
+
service:
|
7
|
+
volumes:
|
8
|
+
- bundle_{{scenario_name}}:/usr/local/bundle
|
9
|
+
environment:
|
10
|
+
BUNDLE_GEMFILE: scenarios/{{scenario_name}}.gemfile
|
11
|
+
volumes:
|
12
|
+
bundle_{{scenario_name}}:
|
13
|
+
|
14
|
+
scenarios:
|
15
|
+
rails31:
|
16
|
+
from: ruby:2.0
|
17
|
+
rails32:
|
18
|
+
from: ruby:2.0
|
19
|
+
rails40:
|
20
|
+
from: ruby:2.3
|
21
|
+
rails41:
|
22
|
+
from: ruby:2.3
|
23
|
+
rails42: {}
|
24
|
+
rails50: {}
|
25
|
+
rails51: {}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
version: "2"
|
3
|
+
services:
|
4
|
+
scenario:
|
5
|
+
build:
|
6
|
+
context: ..
|
7
|
+
dockerfile: scenarios/rails31.dockerfile
|
8
|
+
image: keynote_scenario_rails31
|
9
|
+
volumes:
|
10
|
+
- "..:/scenario"
|
11
|
+
- "bundle_rails31:/usr/local/bundle"
|
12
|
+
environment:
|
13
|
+
BUNDLE_GEMFILE: scenarios/rails31.gemfile
|
14
|
+
volumes:
|
15
|
+
bundle_rails31: {}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
version: "2"
|
3
|
+
services:
|
4
|
+
scenario:
|
5
|
+
build:
|
6
|
+
context: ..
|
7
|
+
dockerfile: scenarios/rails32.dockerfile
|
8
|
+
image: keynote_scenario_rails32
|
9
|
+
volumes:
|
10
|
+
- "..:/scenario"
|
11
|
+
- "bundle_rails32:/usr/local/bundle"
|
12
|
+
environment:
|
13
|
+
BUNDLE_GEMFILE: scenarios/rails32.gemfile
|
14
|
+
volumes:
|
15
|
+
bundle_rails32: {}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
version: "2"
|
3
|
+
services:
|
4
|
+
scenario:
|
5
|
+
build:
|
6
|
+
context: ..
|
7
|
+
dockerfile: scenarios/rails40.dockerfile
|
8
|
+
image: keynote_scenario_rails40
|
9
|
+
volumes:
|
10
|
+
- "..:/scenario"
|
11
|
+
- "bundle_rails40:/usr/local/bundle"
|
12
|
+
environment:
|
13
|
+
BUNDLE_GEMFILE: scenarios/rails40.gemfile
|
14
|
+
volumes:
|
15
|
+
bundle_rails40: {}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
version: "2"
|
3
|
+
services:
|
4
|
+
scenario:
|
5
|
+
build:
|
6
|
+
context: ..
|
7
|
+
dockerfile: scenarios/rails41.dockerfile
|
8
|
+
image: keynote_scenario_rails41
|
9
|
+
volumes:
|
10
|
+
- "..:/scenario"
|
11
|
+
- "bundle_rails41:/usr/local/bundle"
|
12
|
+
environment:
|
13
|
+
BUNDLE_GEMFILE: scenarios/rails41.gemfile
|
14
|
+
volumes:
|
15
|
+
bundle_rails41: {}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
version: "2"
|
3
|
+
services:
|
4
|
+
scenario:
|
5
|
+
build:
|
6
|
+
context: ..
|
7
|
+
dockerfile: scenarios/rails42.dockerfile
|
8
|
+
image: keynote_scenario_rails42
|
9
|
+
volumes:
|
10
|
+
- "..:/scenario"
|
11
|
+
- "bundle_rails42:/usr/local/bundle"
|
12
|
+
environment:
|
13
|
+
BUNDLE_GEMFILE: scenarios/rails42.gemfile
|
14
|
+
volumes:
|
15
|
+
bundle_rails42: {}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
version: "2"
|
3
|
+
services:
|
4
|
+
scenario:
|
5
|
+
build:
|
6
|
+
context: ..
|
7
|
+
dockerfile: scenarios/rails50.dockerfile
|
8
|
+
image: keynote_scenario_rails50
|
9
|
+
volumes:
|
10
|
+
- "..:/scenario"
|
11
|
+
- "bundle_rails50:/usr/local/bundle"
|
12
|
+
environment:
|
13
|
+
BUNDLE_GEMFILE: scenarios/rails50.gemfile
|
14
|
+
volumes:
|
15
|
+
bundle_rails50: {}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
version: "2"
|
3
|
+
services:
|
4
|
+
scenario:
|
5
|
+
build:
|
6
|
+
context: ..
|
7
|
+
dockerfile: scenarios/rails51.dockerfile
|
8
|
+
image: keynote_scenario_rails51
|
9
|
+
volumes:
|
10
|
+
- "..:/scenario"
|
11
|
+
- "bundle_rails51:/usr/local/bundle"
|
12
|
+
environment:
|
13
|
+
BUNDLE_GEMFILE: scenarios/rails51.gemfile
|
14
|
+
volumes:
|
15
|
+
bundle_rails51: {}
|
data/spec/generator_spec.rb
CHANGED
@@ -28,7 +28,7 @@ describe "generators" do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def file_contents(path)
|
31
|
-
|
31
|
+
File.read(File.join(output_path, path))
|
32
32
|
end
|
33
33
|
|
34
34
|
describe "when the test_framework is :test_unit" do
|
@@ -46,24 +46,24 @@ describe "generators" do
|
|
46
46
|
)
|
47
47
|
|
48
48
|
file_contents('app/presenters/post_presenter.rb').
|
49
|
-
must_match
|
49
|
+
must_match(/class PostPresenter < Keynote::Presenter/)
|
50
50
|
|
51
51
|
file_contents('test/unit/presenters/post_presenter_test.rb').
|
52
|
-
must_match
|
52
|
+
must_match(/class PostPresenterTest < Keynote::TestCase/)
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
56
|
it "does not add a 'presents' line" do
|
57
57
|
invoke_generator 'post' do |files|
|
58
58
|
file_contents('app/presenters/post_presenter.rb').
|
59
|
-
wont_match
|
59
|
+
wont_match(/presents/)
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
63
|
it "generates an appropriate present() call" do
|
64
64
|
invoke_generator 'post' do |files|
|
65
65
|
file_contents('test/unit/presenters/post_presenter_test.rb').
|
66
|
-
must_match
|
66
|
+
must_match(/present\(:post\)/)
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
@@ -71,14 +71,14 @@ describe "generators" do
|
|
71
71
|
it "adds a 'presents' line" do
|
72
72
|
invoke_generator 'post', 'foo' do |files|
|
73
73
|
file_contents('app/presenters/post_presenter.rb').
|
74
|
-
must_match
|
74
|
+
must_match(/presents :foo$/)
|
75
75
|
end
|
76
76
|
end
|
77
77
|
|
78
78
|
it "generates an appropriate present() call" do
|
79
79
|
invoke_generator 'post', 'foo' do |files|
|
80
80
|
file_contents('test/unit/presenters/post_presenter_test.rb').
|
81
|
-
must_match
|
81
|
+
must_match(/present\(:post, :foo\)/)
|
82
82
|
end
|
83
83
|
end
|
84
84
|
end
|
@@ -87,14 +87,14 @@ describe "generators" do
|
|
87
87
|
it "adds a 'presents' line" do
|
88
88
|
invoke_generator 'post', 'foo', 'bar' do |files|
|
89
89
|
file_contents('app/presenters/post_presenter.rb').
|
90
|
-
must_match
|
90
|
+
must_match(/presents :foo, :bar$/)
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
94
|
it "generates an appropriate present() call" do
|
95
95
|
invoke_generator 'post', 'foo', 'bar' do |files|
|
96
96
|
file_contents('test/unit/presenters/post_presenter_test.rb').
|
97
|
-
must_match
|
97
|
+
must_match(/present\(:post, :foo, :bar\)/)
|
98
98
|
end
|
99
99
|
end
|
100
100
|
end
|
@@ -112,10 +112,10 @@ describe "generators" do
|
|
112
112
|
)
|
113
113
|
|
114
114
|
file_contents('app/presenters/post_presenter.rb').
|
115
|
-
must_match
|
115
|
+
must_match(/class PostPresenter < Keynote::Presenter/)
|
116
116
|
|
117
117
|
file_contents('spec/presenters/post_presenter_spec.rb').
|
118
|
-
must_match
|
118
|
+
must_match(/describe PostPresenter do/)
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
@@ -131,10 +131,10 @@ describe "generators" do
|
|
131
131
|
)
|
132
132
|
|
133
133
|
file_contents('app/presenters/post_presenter.rb').
|
134
|
-
must_match
|
134
|
+
must_match(/class PostPresenter < Keynote::Presenter/)
|
135
135
|
|
136
136
|
file_contents('test/presenters/post_presenter_test.rb').
|
137
|
-
must_match
|
137
|
+
must_match(/describe PostPresenter do/)
|
138
138
|
end
|
139
139
|
end
|
140
140
|
|
@@ -150,10 +150,10 @@ describe "generators" do
|
|
150
150
|
)
|
151
151
|
|
152
152
|
file_contents('app/presenters/post_presenter.rb').
|
153
|
-
must_match
|
153
|
+
must_match(/class PostPresenter < Keynote::Presenter/)
|
154
154
|
|
155
155
|
file_contents('test/presenters/post_presenter_test.rb').
|
156
|
-
must_match
|
156
|
+
must_match(/class PostPresenterTest < Keynote::TestCase/)
|
157
157
|
end
|
158
158
|
end
|
159
159
|
end
|
data/spec/inline_spec.rb
CHANGED
@@ -114,8 +114,14 @@ module Keynote
|
|
114
114
|
end
|
115
115
|
|
116
116
|
e.must_be_instance_of ActionView::Template::Error
|
117
|
-
|
118
|
-
e.original_exception
|
117
|
+
|
118
|
+
if e.respond_to?(:original_exception)
|
119
|
+
e.original_exception.must_be_instance_of RuntimeError
|
120
|
+
e.original_exception.message.must_equal "UH OH"
|
121
|
+
else
|
122
|
+
e.cause.must_be_instance_of RuntimeError
|
123
|
+
e.cause.message.must_equal "UH OH"
|
124
|
+
end
|
119
125
|
end
|
120
126
|
|
121
127
|
it "should remove leading indentation" do
|
data/spec/keynote_spec.rb
CHANGED
@@ -118,11 +118,10 @@ describe Keynote do
|
|
118
118
|
|
119
119
|
describe "when there's no view context" do
|
120
120
|
it "shouldn't cache" do
|
121
|
-
|
122
|
-
model_2 = Normal.new
|
121
|
+
model = Normal.new
|
123
122
|
|
124
|
-
presented_1 = Keynote.present(nil,
|
125
|
-
presented_2 = Keynote.present(nil,
|
123
|
+
presented_1 = Keynote.present(nil, model)
|
124
|
+
presented_2 = Keynote.present(nil, model)
|
126
125
|
|
127
126
|
presented_1.wont_be :equal?, presented_2
|
128
127
|
end
|
data/spec/presenter_spec.rb
CHANGED
@@ -122,7 +122,7 @@ describe Keynote::Presenter do
|
|
122
122
|
describe "#inspect" do
|
123
123
|
it "includes the class name" do
|
124
124
|
CombinedPresenter.new(:view, :a, :b).inspect.
|
125
|
-
must_match
|
125
|
+
must_match(/^#<CombinedPresenter /)
|
126
126
|
end
|
127
127
|
|
128
128
|
it "shows .inspect output for each presented object" do
|
@@ -173,7 +173,7 @@ describe Keynote::Presenter do
|
|
173
173
|
end
|
174
174
|
|
175
175
|
err.wont_be_nil
|
176
|
-
err.message.must_match
|
176
|
+
err.message.must_match(/Keynote::Presenter/)
|
177
177
|
end
|
178
178
|
end
|
179
179
|
end
|
data/spec/rumble_spec.rb
CHANGED
@@ -24,6 +24,7 @@ class TestRumble < klass
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def setup
|
27
|
+
@rumble_context = nil
|
27
28
|
super
|
28
29
|
assert_nil @rumble_context
|
29
30
|
end
|
@@ -58,6 +59,34 @@ class TestRumble < klass
|
|
58
59
|
end
|
59
60
|
end
|
60
61
|
|
62
|
+
def test_string_data
|
63
|
+
assert_rumble '<div data="whatever"></div>' do
|
64
|
+
div data: "whatever"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_hash_data
|
69
|
+
str = <<-HTML
|
70
|
+
<div data-modal="true" data-safe=""""" data-unsafe=""&quot;"">
|
71
|
+
</div>
|
72
|
+
HTML
|
73
|
+
|
74
|
+
assert_rumble str do
|
75
|
+
div data: { modal: true, safe: '"""'.html_safe, unsafe: '"""' }
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_array_attrs
|
80
|
+
str = <<-HTML
|
81
|
+
<div class="hello "uns&amp;fe" "w&rld"">
|
82
|
+
</div>
|
83
|
+
HTML
|
84
|
+
|
85
|
+
assert_rumble str do
|
86
|
+
div class: ["hello", '"uns&fe"', '"w&rld"'.html_safe]
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
61
90
|
def test_several
|
62
91
|
str = <<-HTML
|
63
92
|
<p>Hello</p>
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: keynote
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Fitzgerald
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -163,18 +163,11 @@ files:
|
|
163
163
|
- ".gitignore"
|
164
164
|
- ".travis.yml"
|
165
165
|
- ".yardopts"
|
166
|
-
- Appraisals
|
167
166
|
- CHANGELOG.md
|
168
167
|
- Gemfile
|
169
168
|
- LICENSE
|
170
169
|
- README.md
|
171
170
|
- Rakefile
|
172
|
-
- gemfiles/rails31.gemfile
|
173
|
-
- gemfiles/rails32.gemfile
|
174
|
-
- gemfiles/rails40.gemfile
|
175
|
-
- gemfiles/rails41.gemfile
|
176
|
-
- gemfiles/rails42.gemfile
|
177
|
-
- gemfiles/rails50.gemfile
|
178
171
|
- keynote.gemspec
|
179
172
|
- lib/generators/presenter_generator.rb
|
180
173
|
- lib/generators/templates/keynote_mini_test_spec.rb
|
@@ -196,6 +189,28 @@ files:
|
|
196
189
|
- lib/keynote/testing/test_present_method.rb
|
197
190
|
- lib/keynote/testing/test_unit.rb
|
198
191
|
- lib/keynote/version.rb
|
192
|
+
- scenarios.yml
|
193
|
+
- scenarios/rails31.docker-compose.yml
|
194
|
+
- scenarios/rails31.dockerfile
|
195
|
+
- scenarios/rails31.gemfile
|
196
|
+
- scenarios/rails32.docker-compose.yml
|
197
|
+
- scenarios/rails32.dockerfile
|
198
|
+
- scenarios/rails32.gemfile
|
199
|
+
- scenarios/rails40.docker-compose.yml
|
200
|
+
- scenarios/rails40.dockerfile
|
201
|
+
- scenarios/rails40.gemfile
|
202
|
+
- scenarios/rails41.docker-compose.yml
|
203
|
+
- scenarios/rails41.dockerfile
|
204
|
+
- scenarios/rails41.gemfile
|
205
|
+
- scenarios/rails42.docker-compose.yml
|
206
|
+
- scenarios/rails42.dockerfile
|
207
|
+
- scenarios/rails42.gemfile
|
208
|
+
- scenarios/rails50.docker-compose.yml
|
209
|
+
- scenarios/rails50.dockerfile
|
210
|
+
- scenarios/rails50.gemfile
|
211
|
+
- scenarios/rails51.docker-compose.yml
|
212
|
+
- scenarios/rails51.dockerfile
|
213
|
+
- scenarios/rails51.gemfile
|
199
214
|
- spec/benchmarks.rb
|
200
215
|
- spec/generator_spec.rb
|
201
216
|
- spec/helper.rb
|
@@ -224,7 +239,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
224
239
|
version: '0'
|
225
240
|
requirements: []
|
226
241
|
rubyforge_project:
|
227
|
-
rubygems_version: 2.
|
242
|
+
rubygems_version: 2.6.8
|
228
243
|
signing_key:
|
229
244
|
specification_version: 4
|
230
245
|
summary: Flexible presenters for Rails.
|
data/Appraisals
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
appraise "rails31" do
|
2
|
-
gem "rails", "3.1.12"
|
3
|
-
gem "minitest", "< 5"
|
4
|
-
end
|
5
|
-
|
6
|
-
appraise "rails32" do
|
7
|
-
gem "rails", "3.2.22.5"
|
8
|
-
gem "minitest", "< 5"
|
9
|
-
end
|
10
|
-
|
11
|
-
appraise "rails40" do
|
12
|
-
gem "rails", "4.0.13"
|
13
|
-
gem "minitest", "< 5"
|
14
|
-
end
|
15
|
-
|
16
|
-
appraise "rails41" do
|
17
|
-
gem "rails", "4.1.16"
|
18
|
-
gem "minitest", "~> 5.0"
|
19
|
-
end
|
20
|
-
|
21
|
-
appraise "rails42" do
|
22
|
-
gem "rails", "4.2.7.1"
|
23
|
-
gem "minitest", "~> 5.0"
|
24
|
-
end
|
25
|
-
|
26
|
-
appraise "rails50" do
|
27
|
-
gem "rails", "5.0.0.1"
|
28
|
-
gem "minitest", "~> 5.0"
|
29
|
-
end
|