action_component 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +5 -5
- data/action_component.gemspec +6 -4
- data/lib/action_component/base.rb +16 -0
- data/lib/action_component/elements.rb +3 -7
- data/lib/action_component/version.rb +1 -1
- data/spec/action_component/base_spec.rb +19 -0
- data/spec/action_component/elements_spec.rb +16 -8
- metadata +25 -9
- data/spec/examples.txt +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c40a85133d9515f6130d1ef47ae902ca393dd071
|
4
|
+
data.tar.gz: 7aab855f6a751caad576ab268505ef2acec1053a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8c35cfee98e7bb48b6f11d7b947ed51a6a04d4afed3cf38fa59d0c141258c7afd5bf09e27b0ce9ee02ecbbc36e6c6db4b0bc4af28cdea3b9499da9944778d97
|
7
|
+
data.tar.gz: f2f6ae0fd3847fab3bccf2ac74a3456e9191f94aa6b9e9084a7cee1a98ca70239f307a55c1fba5aa0412a14c547ef9d4e21af1bc5033545ee26f0d37a57c2be9
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
action_component (0.1.
|
5
|
-
actionpack (>= 4)
|
6
|
-
activesupport (>= 4)
|
7
|
-
railties (>= 4)
|
4
|
+
action_component (0.1.2)
|
5
|
+
actionpack (>= 4, < 6)
|
6
|
+
activesupport (>= 4, < 6)
|
7
|
+
railties (>= 4, < 6)
|
8
8
|
|
9
9
|
GEM
|
10
10
|
remote: http://rubygems.org/
|
@@ -77,7 +77,7 @@ PLATFORMS
|
|
77
77
|
|
78
78
|
DEPENDENCIES
|
79
79
|
action_component!
|
80
|
-
rspec
|
80
|
+
rspec (~> 3.5)
|
81
81
|
|
82
82
|
BUNDLED WITH
|
83
83
|
1.12.5
|
data/action_component.gemspec
CHANGED
@@ -13,11 +13,13 @@ Gem::Specification.new do |s|
|
|
13
13
|
s.summary = %q{React-style components for Rails}
|
14
14
|
s.description = %q{React-style components for Rails, mixing together the controller and a DSL language for HTML views.}
|
15
15
|
|
16
|
-
s.
|
17
|
-
s.add_dependency "activesupport", ">= 4"
|
18
|
-
s.add_dependency "railties", ">= 4"
|
16
|
+
s.required_ruby_version = '>= 2.0'
|
19
17
|
|
20
|
-
s.
|
18
|
+
s.add_dependency "actionpack", [">= 4", "< 6"]
|
19
|
+
s.add_dependency "activesupport", [">= 4", "< 6"]
|
20
|
+
s.add_dependency "railties", [">= 4", "< 6"]
|
21
|
+
|
22
|
+
s.add_development_dependency "rspec", "~> 3.5"
|
21
23
|
|
22
24
|
s.files = `git ls-files`.split("\n")
|
23
25
|
s.test_files = `git ls-files -- spec/*`.split("\n")
|
@@ -45,6 +45,14 @@ module ActionComponent
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
+
def text(content)
|
49
|
+
@_view.concat content
|
50
|
+
nil
|
51
|
+
end
|
52
|
+
|
53
|
+
alias_method :text_node, :text
|
54
|
+
alias_method :insert, :text
|
55
|
+
|
48
56
|
def render(*args)
|
49
57
|
@_view.concat(@_view.render(*args))
|
50
58
|
end
|
@@ -54,5 +62,13 @@ module ActionComponent
|
|
54
62
|
end
|
55
63
|
|
56
64
|
alias_method :render_component, :component
|
65
|
+
|
66
|
+
def form_for(*args, &block)
|
67
|
+
text @_view.form_for(*args, &block)
|
68
|
+
end
|
69
|
+
|
70
|
+
def form_tag(*args, &block)
|
71
|
+
text @_view.form_tag(*args, &block)
|
72
|
+
end
|
57
73
|
end
|
58
74
|
end
|
@@ -21,9 +21,6 @@ module ActionComponent
|
|
21
21
|
|
22
22
|
included do
|
23
23
|
define_tags *ELEMENTS
|
24
|
-
|
25
|
-
alias_method :text_node, :text
|
26
|
-
alias_method :insert, :text
|
27
24
|
end
|
28
25
|
|
29
26
|
class_methods do
|
@@ -40,10 +37,6 @@ module ActionComponent
|
|
40
37
|
|
41
38
|
private
|
42
39
|
|
43
|
-
def text(content)
|
44
|
-
@_view.concat content
|
45
|
-
end
|
46
|
-
|
47
40
|
def doctype(text = "html")
|
48
41
|
@_view.concat("<!doctype #{h(text)}>".html_safe)
|
49
42
|
end
|
@@ -51,6 +44,9 @@ module ActionComponent
|
|
51
44
|
def element(name, first = nil, second = nil, &block)
|
52
45
|
if first.is_a?(Hash)
|
53
46
|
opts = first
|
47
|
+
elsif second.is_a?(String) || second.is_a?(Symbol)
|
48
|
+
opts = {class: second.to_s}
|
49
|
+
text = first
|
54
50
|
else
|
55
51
|
opts = second
|
56
52
|
text = first
|
@@ -47,6 +47,8 @@ RSpec.describe ActionComponent::Base do
|
|
47
47
|
|
48
48
|
div datetime_formatter(@post.posted_at), class: "datetime"
|
49
49
|
|
50
|
+
text "!"
|
51
|
+
|
50
52
|
render "some_view"
|
51
53
|
|
52
54
|
component AuthorComponent, author: @post.author
|
@@ -74,6 +76,7 @@ RSpec.describe ActionComponent::Base do
|
|
74
76
|
[:concat, "content_tag [\"h2\", \"Test Post\", nil]"],
|
75
77
|
[:content_tag, "div", "28 November 2016 11:09", {:class=>"datetime"}],
|
76
78
|
[:concat, "content_tag [\"div\", \"28 November 2016 11:09\", {:class=>\"datetime\"}]"],
|
79
|
+
[:concat, "!"],
|
77
80
|
[:render, "some_view"],
|
78
81
|
[:concat, "render [\"some_view\"]"],
|
79
82
|
[:content_tag, "div", "Roger Nesbitt", nil],
|
@@ -82,4 +85,20 @@ RSpec.describe ActionComponent::Base do
|
|
82
85
|
]
|
83
86
|
end
|
84
87
|
end
|
88
|
+
|
89
|
+
describe "auto-inserting methods" do
|
90
|
+
let(:view) { double }
|
91
|
+
|
92
|
+
%w(form_for form_tag).each do |method|
|
93
|
+
it "forwards #{method} to the view and inserts its value" do
|
94
|
+
expect(view).to receive(method).with(1, 2).and_yield.and_return("result")
|
95
|
+
expect(view).to receive(:concat).with("result")
|
96
|
+
|
97
|
+
called = false
|
98
|
+
subject.send(method, 1, 2) { called = true }
|
99
|
+
|
100
|
+
expect(called).to be true
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
85
104
|
end
|
@@ -23,14 +23,6 @@ RSpec.describe ActionComponent::Elements do
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
describe "#text" do
|
27
|
-
it "concats the supplied text" do
|
28
|
-
subject.send(:text, "some content")
|
29
|
-
|
30
|
-
expect(view.calls).to eq [[:concat, 'some content']]
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
26
|
describe "#doctype" do
|
35
27
|
it "concats a doctype tag" do
|
36
28
|
subject.send(:doctype)
|
@@ -112,5 +104,21 @@ RSpec.describe ActionComponent::Elements do
|
|
112
104
|
}.to raise_error ActionComponent::RenderError
|
113
105
|
end
|
114
106
|
end
|
107
|
+
|
108
|
+
context "when the second argument is a string" do
|
109
|
+
it "converts the second argument into a hash with the class set" do
|
110
|
+
subject.send(:element, :name, 'text', 'blue')
|
111
|
+
|
112
|
+
expect(view.calls.first).to eq [:content_tag, :name, 'text', {class: 'blue'}]
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
context "when the second argument is a symbol" do
|
117
|
+
it "converts the second argument into a hash with the class set" do
|
118
|
+
subject.send(:element, :name, 'text', :blue)
|
119
|
+
|
120
|
+
expect(view.calls.first).to eq [:content_tag, :name, 'text', {class: 'blue'}]
|
121
|
+
end
|
122
|
+
end
|
115
123
|
end
|
116
124
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: action_component
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roger Nesbitt
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -17,6 +17,9 @@ dependencies:
|
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '4'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '6'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -24,6 +27,9 @@ dependencies:
|
|
24
27
|
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '4'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '6'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: activesupport
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -31,6 +37,9 @@ dependencies:
|
|
31
37
|
- - ">="
|
32
38
|
- !ruby/object:Gem::Version
|
33
39
|
version: '4'
|
40
|
+
- - "<"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '6'
|
34
43
|
type: :runtime
|
35
44
|
prerelease: false
|
36
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -38,6 +47,9 @@ dependencies:
|
|
38
47
|
- - ">="
|
39
48
|
- !ruby/object:Gem::Version
|
40
49
|
version: '4'
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '6'
|
41
53
|
- !ruby/object:Gem::Dependency
|
42
54
|
name: railties
|
43
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -45,6 +57,9 @@ dependencies:
|
|
45
57
|
- - ">="
|
46
58
|
- !ruby/object:Gem::Version
|
47
59
|
version: '4'
|
60
|
+
- - "<"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '6'
|
48
63
|
type: :runtime
|
49
64
|
prerelease: false
|
50
65
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -52,20 +67,23 @@ dependencies:
|
|
52
67
|
- - ">="
|
53
68
|
- !ruby/object:Gem::Version
|
54
69
|
version: '4'
|
70
|
+
- - "<"
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '6'
|
55
73
|
- !ruby/object:Gem::Dependency
|
56
74
|
name: rspec
|
57
75
|
requirement: !ruby/object:Gem::Requirement
|
58
76
|
requirements:
|
59
|
-
- - "
|
77
|
+
- - "~>"
|
60
78
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
79
|
+
version: '3.5'
|
62
80
|
type: :development
|
63
81
|
prerelease: false
|
64
82
|
version_requirements: !ruby/object:Gem::Requirement
|
65
83
|
requirements:
|
66
|
-
- - "
|
84
|
+
- - "~>"
|
67
85
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
86
|
+
version: '3.5'
|
69
87
|
description: React-style components for Rails, mixing together the controller and
|
70
88
|
a DSL language for HTML views.
|
71
89
|
email:
|
@@ -91,7 +109,6 @@ files:
|
|
91
109
|
- spec/action_component/base_spec.rb
|
92
110
|
- spec/action_component/constraints_spec.rb
|
93
111
|
- spec/action_component/elements_spec.rb
|
94
|
-
- spec/examples.txt
|
95
112
|
- spec/fake_view.rb
|
96
113
|
- spec/spec_helper.rb
|
97
114
|
homepage: https://github.com/mogest/action_component
|
@@ -106,7 +123,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
106
123
|
requirements:
|
107
124
|
- - ">="
|
108
125
|
- !ruby/object:Gem::Version
|
109
|
-
version: '0'
|
126
|
+
version: '2.0'
|
110
127
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
128
|
requirements:
|
112
129
|
- - ">="
|
@@ -122,6 +139,5 @@ test_files:
|
|
122
139
|
- spec/action_component/base_spec.rb
|
123
140
|
- spec/action_component/constraints_spec.rb
|
124
141
|
- spec/action_component/elements_spec.rb
|
125
|
-
- spec/examples.txt
|
126
142
|
- spec/fake_view.rb
|
127
143
|
- spec/spec_helper.rb
|
data/spec/examples.txt
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
example_id | status | run_time |
|
2
|
-
------------------------------------------------- | ------ | --------------- |
|
3
|
-
./spec/action_component/base_spec.rb[1:1:1] | passed | 0.01317 seconds |
|
4
|
-
./spec/action_component/base_spec.rb[1:2:1] | passed | 0.00018 seconds |
|
5
|
-
./spec/action_component/base_spec.rb[1:3:1] | passed | 0.00012 seconds |
|
6
|
-
./spec/action_component/base_spec.rb[1:4:1] | passed | 0.00139 seconds |
|
7
|
-
./spec/action_component/constraints_spec.rb[1:1] | passed | 0.00006 seconds |
|
8
|
-
./spec/action_component/constraints_spec.rb[1:2] | passed | 0.00012 seconds |
|
9
|
-
./spec/action_component/constraints_spec.rb[1:3] | passed | 0.00017 seconds |
|
10
|
-
./spec/action_component/constraints_spec.rb[1:4] | passed | 0.00202 seconds |
|
11
|
-
./spec/action_component/elements_spec.rb[1:1:1] | passed | 0.00017 seconds |
|
12
|
-
./spec/action_component/elements_spec.rb[1:2:1] | passed | 0.00009 seconds |
|
13
|
-
./spec/action_component/elements_spec.rb[1:3:1] | passed | 0.00015 seconds |
|
14
|
-
./spec/action_component/elements_spec.rb[1:3:2] | passed | 0.00448 seconds |
|
15
|
-
./spec/action_component/elements_spec.rb[1:4:1] | passed | 0.00014 seconds |
|
16
|
-
./spec/action_component/elements_spec.rb[1:5:1:1] | passed | 0.00015 seconds |
|
17
|
-
./spec/action_component/elements_spec.rb[1:5:2:1] | passed | 0.0001 seconds |
|
18
|
-
./spec/action_component/elements_spec.rb[1:5:3:1] | passed | 0.00019 seconds |
|
19
|
-
./spec/action_component/elements_spec.rb[1:5:4:1] | passed | 0.00014 seconds |
|
20
|
-
./spec/action_component/elements_spec.rb[1:5:5:1] | passed | 0.00148 seconds |
|
21
|
-
./spec/action_component/elements_spec.rb[1:5:6:1] | passed | 0.00024 seconds |
|