fortitude 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +27 -0
- data/CONTRIBUTORS.md +6 -0
- data/fortitude.gemspec +6 -1
- data/lib/fortitude/version.rb +1 -1
- data/lib/fortitude/widget/content.rb +10 -0
- data/lib/fortitude/widget/start_and_end_comments.rb +1 -1
- data/spec/system/inline_system_spec.rb +58 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25c2a3082f9eea925e6db1ad349f3d9ec45a9760
|
4
|
+
data.tar.gz: 4a95b0676e6b63b98ca69148bedc517b98b4955f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88825dbca457537fb59373f3d345e119cd4b26d099befb5b56cea5885bf912161ff589775504657423e6b82b4852d7fead44df625af14bd226089dd644944ca2
|
7
|
+
data.tar.gz: 8bca6d9fa509fa98cc8abe0c630a790f9ff2f7b98544096e147aa986367332a08408b6d252533f7894552d24963f76b8d4e83898bf42f91d098035ef4653c28a
|
data/CHANGES.md
CHANGED
@@ -1,5 +1,32 @@
|
|
1
1
|
# Fortitude Releases
|
2
2
|
|
3
|
+
## 0.0.4, 24 June 2014
|
4
|
+
|
5
|
+
* Added support for building a JRuby-specific gem to the gemspec, so that things work smoothly for JRuby users.
|
6
|
+
(Thanks, [Ahto Jussila](https://github.com/ahto)!)
|
7
|
+
* Added preliminary support for inline widget classes: if you call `.inline_subclass` on any subclass of
|
8
|
+
`Fortitude::Widget` and pass a block, you'll get back a new subclass of whatever class you called it on, with a
|
9
|
+
`content` method defined as per the block you passed. For example:
|
10
|
+
|
11
|
+
my_widget_class = Fortitude::Widgets::Html5.inline_subclass do
|
12
|
+
p "hello, world!"
|
13
|
+
end
|
14
|
+
my_widget_class.new.to_html # => '<p>hello, world!</p>'
|
15
|
+
|
16
|
+
* And, similarly, if you call `.inline_html` on any subclass of `Fortitude::Widget` and pass a block, you'll get back
|
17
|
+
the HTML rendered by the new subclass of that class. For example:
|
18
|
+
|
19
|
+
html = Fortitude::Widgets::Html5.inline_html do
|
20
|
+
p "hello, world!"
|
21
|
+
end
|
22
|
+
html # => '<p>hello, world!</p>'
|
23
|
+
|
24
|
+
* Note that this will not work on `Fortitude::Widget`, because `Fortitude::Widget` has no `doctype` declared, and
|
25
|
+
therefore has no HTML tags available. You can either use one of the pre-made classes in `Fortitude::Widgets`, or,
|
26
|
+
better yet, declare your own base widget class and then use `.inline_subclass` and `.inline_html` on that. (Using
|
27
|
+
that mechanism, you can also set things like `format_output`, `start_and_end_comments`, and even things like
|
28
|
+
`needs`, mixing in or defining helper methods, and so on, and it will all work just fine.)
|
29
|
+
|
3
30
|
## 0.0.3, 23 June 2014
|
4
31
|
|
5
32
|
* Changed `Fortitude::Widget#to_html` to return the generated HTML. If you pass a `Fortitude::RenderingContext` into
|
data/CONTRIBUTORS.md
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
# Contributors to Fortitude
|
2
|
+
|
3
|
+
Fortitude is written by [Andrew Geweke](https://github.com/ageweke), with contributions from:
|
4
|
+
|
5
|
+
* [Ahto Jussila](https://github.com/ahto): a patch to provide separate MRI and JRuby gems, so that
|
6
|
+
`gem install fortitude` works properly no matter which platform you're on.
|
data/fortitude.gemspec
CHANGED
@@ -18,7 +18,12 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
19
19
|
s.require_paths = ["lib"]
|
20
20
|
|
21
|
-
|
21
|
+
if RUBY_PLATFORM =~ /java/
|
22
|
+
s.platform = 'java'
|
23
|
+
else
|
24
|
+
s.platform = Gem::Platform::RUBY
|
25
|
+
s.extensions << "ext/fortitude_native_ext/extconf.rb"
|
26
|
+
end
|
22
27
|
|
23
28
|
activesupport_spec = if RUBY_VERSION =~ /^1\.8\./
|
24
29
|
[ ">= 3.0", "< 4.0" ]
|
data/lib/fortitude/version.rb
CHANGED
@@ -7,6 +7,16 @@ module Fortitude
|
|
7
7
|
extend ActiveSupport::Concern
|
8
8
|
|
9
9
|
module ClassMethods
|
10
|
+
def inline_subclass(&block)
|
11
|
+
out = Class.new(self)
|
12
|
+
out.send(:define_method, :content, &block)
|
13
|
+
out
|
14
|
+
end
|
15
|
+
|
16
|
+
def inline_html(assigns = { }, &block)
|
17
|
+
inline_subclass(&block).new(assigns).to_html
|
18
|
+
end
|
19
|
+
|
10
20
|
# INTERNAL USE ONLY
|
11
21
|
def rebuild_run_content!(why, klass = self)
|
12
22
|
rebuilding(:run_content, why, klass) do
|
@@ -22,7 +22,7 @@ module Fortitude
|
|
22
22
|
if self.class.start_and_end_comments
|
23
23
|
fo = self.class.format_output
|
24
24
|
|
25
|
-
comment_text = "BEGIN #{self.class.name} depth #{widget_nesting_depth}"
|
25
|
+
comment_text = "BEGIN #{self.class.name || '(anonymous widget class)'} depth #{widget_nesting_depth}"
|
26
26
|
|
27
27
|
assign_keys = assigns.keys
|
28
28
|
if assign_keys.length > 0
|
@@ -0,0 +1,58 @@
|
|
1
|
+
describe "Fortitude inline-code support", :type => :system do
|
2
|
+
it "should let you get a widget class back with .new_subclass" do
|
3
|
+
wc = widget_class
|
4
|
+
new_wc = wc.inline_subclass do
|
5
|
+
p "hello, world"
|
6
|
+
end
|
7
|
+
expect(render(new_wc)).to eq("<p>hello, world</p>")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should let you pass assigns to the new subclass, and inherit settings of the parent" do
|
11
|
+
wc = widget_class do
|
12
|
+
start_and_end_comments true
|
13
|
+
format_output true
|
14
|
+
|
15
|
+
needs :name
|
16
|
+
end
|
17
|
+
|
18
|
+
new_wc = wc.inline_subclass do
|
19
|
+
div {
|
20
|
+
p "hello, #{name}"
|
21
|
+
}
|
22
|
+
end
|
23
|
+
|
24
|
+
expect(render(new_wc.new(:name => 'julia'))).to eq(%{<!-- BEGIN (anonymous widget class) depth 0: :name => \"julia\" -->
|
25
|
+
<div>
|
26
|
+
<p>hello, julia</p>
|
27
|
+
</div>
|
28
|
+
<!-- END depth 0 -->})
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should let you get rendered content back with .inline_html" do
|
32
|
+
data = ::Fortitude::Widgets::Html5.inline_html do
|
33
|
+
p "hello, world"
|
34
|
+
end
|
35
|
+
expect(data).to eq("<p>hello, world</p>")
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should let you pass assigns to the new widget with .inline_html, and inherit settings of the parent" do
|
39
|
+
wc = widget_class do
|
40
|
+
start_and_end_comments true
|
41
|
+
format_output true
|
42
|
+
|
43
|
+
needs :name
|
44
|
+
end
|
45
|
+
|
46
|
+
content = wc.inline_html(:name => 'julia') do
|
47
|
+
div {
|
48
|
+
p "hello, #{name}"
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
expect(content).to eq(%{<!-- BEGIN (anonymous widget class) depth 0: :name => \"julia\" -->
|
53
|
+
<div>
|
54
|
+
<p>hello, julia</p>
|
55
|
+
</div>
|
56
|
+
<!-- END depth 0 -->})
|
57
|
+
end
|
58
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fortitude
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Geweke
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-06-
|
11
|
+
date: 2014-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -121,6 +121,7 @@ files:
|
|
121
121
|
- ".rspec-local"
|
122
122
|
- ".travis.yml"
|
123
123
|
- CHANGES.md
|
124
|
+
- CONTRIBUTORS.md
|
124
125
|
- Gemfile
|
125
126
|
- LICENSE.txt
|
126
127
|
- README-erector.md
|
@@ -449,6 +450,7 @@ files:
|
|
449
450
|
- spec/system/formatting_system_spec.rb
|
450
451
|
- spec/system/helpers_system_spec.rb
|
451
452
|
- spec/system/id_uniqueness_system_spec.rb
|
453
|
+
- spec/system/inline_system_spec.rb
|
452
454
|
- spec/system/localization_system_spec.rb
|
453
455
|
- spec/system/method_precedence_system_spec.rb
|
454
456
|
- spec/system/needs_system_spec.rb
|
@@ -736,6 +738,7 @@ test_files:
|
|
736
738
|
- spec/system/formatting_system_spec.rb
|
737
739
|
- spec/system/helpers_system_spec.rb
|
738
740
|
- spec/system/id_uniqueness_system_spec.rb
|
741
|
+
- spec/system/inline_system_spec.rb
|
739
742
|
- spec/system/localization_system_spec.rb
|
740
743
|
- spec/system/method_precedence_system_spec.rb
|
741
744
|
- spec/system/needs_system_spec.rb
|