partially_useful 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3125492f037d17719f62948a550602aae2e899ff
4
- data.tar.gz: 63a73461a02c79816ce041ff42fb3a894ceb3d2b
3
+ metadata.gz: 7779586c58e09f7a1c848fd0b264d62c1472ab1f
4
+ data.tar.gz: 4f92003a40579b34591eacb1e6464dea72005e94
5
5
  SHA512:
6
- metadata.gz: 23923df7213aec35ea957213f0158617fe1e53125ea79984d0c3cf6cb43bee1322e856f75bee16c5b5fc002c74531063704119506e82c9024e221e97fa3f93dd
7
- data.tar.gz: 563f125fb9e34443a905a04b5352036cb40be9ddb298cb5d2be976784d861ca44838676891eea1763f2e4bae0a8d688f2ed7e2af73bd42940defb24c9d1a8bdc
6
+ metadata.gz: bdfbd42e87f9affbc4b4c7674c06bad733e9e6768927c8ff0d97b28b74663f22fe4783b7565ca629cfe23956ef4908810687e80f859418b0f12d5765853a9645
7
+ data.tar.gz: 7b31e5e9c615a219d273b5f23f8e5d2e9ddebd38c50d6b694115bfdf120bb77aaa4b7482dc5d43799360688007b267f4b959d87b4ea3a281584aef3647f51379
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.2.0
2
+
3
+ * comments only for html request
4
+
1
5
  # 0.1.1
2
6
 
3
7
  * fix the gemspec
data/Gemfile CHANGED
@@ -1,3 +1,5 @@
1
1
  source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
+
5
+ gem "byebug"
data/Gemfile.lock CHANGED
@@ -1,44 +1,51 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- partially_useful (0.1.1)
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.0)
11
- actionview (= 4.1.0)
12
- activesupport (= 4.1.0)
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.0)
16
- activesupport (= 4.1.0)
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.0)
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
- minitest (5.3.3)
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.0)
34
- actionpack (= 4.1.0)
35
- activesupport (= 4.1.0)
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.1)
44
+ rake (10.3.2)
39
45
  thor (0.19.1)
40
- thread_safe (0.3.3)
41
- tzinfo (1.1.0)
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
- msg = "rendering '#{options[:partial]}' with locals '#{(options[:locals] || {}).keys}'"
10
- "<!-- start #{msg}-->\n#{original_rails_render(context, options, block)}\n<!-- end #{msg}-->\n".html_safe
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
@@ -1,3 +1,3 @@
1
1
  module PartiallyUseful
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -1,2 +1,7 @@
1
1
  class WelcomeController < ApplicationController
2
+ respond_to :html, :json, :xml
3
+
4
+ def index
5
+ respond_with({})
6
+ end
2
7
  end
@@ -0,0 +1 @@
1
+ SOME TEXT
@@ -0,0 +1,2 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <welcome><%= render 'content' %></welcome>
@@ -3,8 +3,23 @@ require 'test_helper'
3
3
  class PartiallyUsefulTest < ActionController::TestCase
4
4
  tests WelcomeController
5
5
 
6
- test "should get index" do
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.1.1
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-05-22 00:00:00.000000000 Z
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: