partially_useful 0.1.1 → 0.2.0
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +22 -14
- data/lib/partially_useful/partial_renderer.rb +14 -2
- data/lib/partially_useful/version.rb +1 -1
- data/test/dummy/app/controllers/welcome_controller.rb +5 -0
- data/test/dummy/app/views/welcome/_content.xml.erb +1 -0
- data/test/dummy/app/views/welcome/index.xml.erb +2 -0
- data/test/partially_useful_test.rb +16 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7779586c58e09f7a1c848fd0b264d62c1472ab1f
|
4
|
+
data.tar.gz: 4f92003a40579b34591eacb1e6464dea72005e94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bdfbd42e87f9affbc4b4c7674c06bad733e9e6768927c8ff0d97b28b74663f22fe4783b7565ca629cfe23956ef4908810687e80f859418b0f12d5765853a9645
|
7
|
+
data.tar.gz: 7b31e5e9c615a219d273b5f23f8e5d2e9ddebd38c50d6b694115bfdf120bb77aaa4b7482dc5d43799360688007b267f4b959d87b4ea3a281584aef3647f51379
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,44 +1,51 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
partially_useful (0.
|
4
|
+
partially_useful (0.2.0)
|
5
5
|
railties (~> 4.0)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
actionpack (4.1.
|
11
|
-
actionview (= 4.1.
|
12
|
-
activesupport (= 4.1.
|
10
|
+
actionpack (4.1.1)
|
11
|
+
actionview (= 4.1.1)
|
12
|
+
activesupport (= 4.1.1)
|
13
13
|
rack (~> 1.5.2)
|
14
14
|
rack-test (~> 0.6.2)
|
15
|
-
actionview (4.1.
|
16
|
-
activesupport (= 4.1.
|
15
|
+
actionview (4.1.1)
|
16
|
+
activesupport (= 4.1.1)
|
17
17
|
builder (~> 3.1)
|
18
18
|
erubis (~> 2.7.0)
|
19
|
-
activesupport (4.1.
|
19
|
+
activesupport (4.1.1)
|
20
20
|
i18n (~> 0.6, >= 0.6.9)
|
21
21
|
json (~> 1.7, >= 1.7.7)
|
22
22
|
minitest (~> 5.1)
|
23
23
|
thread_safe (~> 0.1)
|
24
24
|
tzinfo (~> 1.1)
|
25
25
|
builder (3.2.2)
|
26
|
+
byebug (3.1.2)
|
27
|
+
columnize (~> 0.8)
|
28
|
+
debugger-linecache (~> 1.2)
|
29
|
+
columnize (0.8.9)
|
30
|
+
debugger-linecache (1.2.0)
|
26
31
|
erubis (2.7.0)
|
27
32
|
i18n (0.6.9)
|
28
33
|
json (1.8.1)
|
29
|
-
|
34
|
+
json (1.8.1-java)
|
35
|
+
minitest (5.3.4)
|
30
36
|
rack (1.5.2)
|
31
37
|
rack-test (0.6.2)
|
32
38
|
rack (>= 1.0)
|
33
|
-
railties (4.1.
|
34
|
-
actionpack (= 4.1.
|
35
|
-
activesupport (= 4.1.
|
39
|
+
railties (4.1.1)
|
40
|
+
actionpack (= 4.1.1)
|
41
|
+
activesupport (= 4.1.1)
|
36
42
|
rake (>= 0.8.7)
|
37
43
|
thor (>= 0.18.1, < 2.0)
|
38
|
-
rake (10.3.
|
44
|
+
rake (10.3.2)
|
39
45
|
thor (0.19.1)
|
40
|
-
thread_safe (0.3.
|
41
|
-
|
46
|
+
thread_safe (0.3.4)
|
47
|
+
thread_safe (0.3.4-java)
|
48
|
+
tzinfo (1.2.1)
|
42
49
|
thread_safe (~> 0.1)
|
43
50
|
|
44
51
|
PLATFORMS
|
@@ -47,5 +54,6 @@ PLATFORMS
|
|
47
54
|
|
48
55
|
DEPENDENCIES
|
49
56
|
bundler (~> 1.6)
|
57
|
+
byebug
|
50
58
|
partially_useful!
|
51
59
|
rake
|
@@ -6,8 +6,20 @@ module PartiallyUseful
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def render(context, options, block)
|
9
|
-
|
10
|
-
|
9
|
+
if html_context?(context)
|
10
|
+
msg = "rendering '#{options[:partial]}' with locals '#{(options[:locals] || {}).keys}'"
|
11
|
+
"<!-- start #{msg}-->\n#{original_rails_render(context, options, block)}\n<!-- end #{msg}-->\n".html_safe
|
12
|
+
else
|
13
|
+
original_rails_render(context, options, block)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
private
|
18
|
+
|
19
|
+
def html_context?(context)
|
20
|
+
if context && context.request
|
21
|
+
context.request.format.html?
|
22
|
+
end
|
11
23
|
end
|
12
24
|
end
|
13
25
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
SOME TEXT
|
@@ -3,8 +3,23 @@ require 'test_helper'
|
|
3
3
|
class PartiallyUsefulTest < ActionController::TestCase
|
4
4
|
tests WelcomeController
|
5
5
|
|
6
|
-
test "
|
6
|
+
test "rendering the index template for html adds partial rendering comments to the source" do
|
7
7
|
get :index
|
8
|
+
|
8
9
|
assert_match "<!-- start rendering 'header' with locals '[]'-->", @response.body
|
10
|
+
assert_match "<h1>Hellooooo</h1>", @response.body
|
11
|
+
end
|
12
|
+
|
13
|
+
test "calling the json endpoint does nothing" do
|
14
|
+
get :index, format: :json
|
15
|
+
|
16
|
+
assert_equal "{}", @response.body
|
17
|
+
end
|
18
|
+
|
19
|
+
test "calling the xml endpoint does not include any rendering comments" do
|
20
|
+
get :index, format: :xml
|
21
|
+
|
22
|
+
xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<welcome>SOME TEXT</welcome>"
|
23
|
+
assert_equal xml, @response.body
|
9
24
|
end
|
10
25
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: partially_useful
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- phoet
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -77,8 +77,10 @@ files:
|
|
77
77
|
- test/dummy/app/views/application/_footer.html.erb
|
78
78
|
- test/dummy/app/views/application/_header.html.erb
|
79
79
|
- test/dummy/app/views/layouts/application.html.erb
|
80
|
+
- test/dummy/app/views/welcome/_content.xml.erb
|
80
81
|
- test/dummy/app/views/welcome/_welcome.html.erb
|
81
82
|
- test/dummy/app/views/welcome/index.html.erb
|
83
|
+
- test/dummy/app/views/welcome/index.xml.erb
|
82
84
|
- test/dummy/bin/bundle
|
83
85
|
- test/dummy/bin/rails
|
84
86
|
- test/dummy/bin/rake
|
@@ -127,8 +129,10 @@ test_files:
|
|
127
129
|
- test/dummy/app/views/application/_footer.html.erb
|
128
130
|
- test/dummy/app/views/application/_header.html.erb
|
129
131
|
- test/dummy/app/views/layouts/application.html.erb
|
132
|
+
- test/dummy/app/views/welcome/_content.xml.erb
|
130
133
|
- test/dummy/app/views/welcome/_welcome.html.erb
|
131
134
|
- test/dummy/app/views/welcome/index.html.erb
|
135
|
+
- test/dummy/app/views/welcome/index.xml.erb
|
132
136
|
- test/dummy/bin/bundle
|
133
137
|
- test/dummy/bin/rails
|
134
138
|
- test/dummy/bin/rake
|
@@ -146,3 +150,4 @@ test_files:
|
|
146
150
|
- test/dummy/public/favicon.ico
|
147
151
|
- test/partially_useful_test.rb
|
148
152
|
- test/test_helper.rb
|
153
|
+
has_rdoc:
|