kaizan 0.0.1 → 0.0.2

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: f6efe349faef06dd9cb762511657e9c61ac0f68e
4
- data.tar.gz: 67e9da4985009e06a01b757b1a5ec0f772ef3bfc
3
+ metadata.gz: b9e950163593d3a9535165adcc61292c893884a2
4
+ data.tar.gz: 44031f7d1121a12749280611af6f9bbe72258cd7
5
5
  SHA512:
6
- metadata.gz: d8658cc4d039c52bcf86ae9a114d6bdee13283721fd4970cc075b793662d3b2e9d8e6a9ff84fc54df0b7c0cbdcd925dd346cbc85320875f1f36e53e754909f60
7
- data.tar.gz: 187912a0fa008c42df435ef0d0e1d449af492909224ab816cd36fa8fe81f29c2df1a7df86ab33262889cb3c5705e681cfc78e63c93da7714652c07f1540ca265
6
+ metadata.gz: 747fed0de080ee8195d574078024f18e370bf761fb30f4fbb3c7077a313ca31be2e62cb1ede64ba6a1949290833c033ce14e660598e1b59b48dcef510704c3f3
7
+ data.tar.gz: ab46d9608d1d60f3d5c545dcbf4dbdec4881099fda34e4272b1afb34438fff45de913fb1bc8a4e03309aa121c3d1b6d26359edc63cd586e07b0c2a59a72c8b82
data/README.md CHANGED
@@ -1,3 +1,6 @@
1
+ [![Build Status](https://travis-ci.org/mmmpa/kaizan.svg)](https://travis-ci.org/mmmpa/kaizan)
2
+ [![Coverage Status](https://coveralls.io/repos/mmmpa/kaizan/badge.svg?branch=master)](https://coveralls.io/r/mmmpa/kaizan?branch=master)
3
+
1
4
  # Kaizan
2
5
 
3
6
  Kaizan(改ざん)はActionViewのテンプレート内で、下の方から上の方の指定領域に文字列を書き込むために書かれました。
@@ -8,7 +11,7 @@ Kaizan(改ざん)はActionViewのテンプレート内で、下の方から
8
11
  <h1>モデルたち <%= altering_anchor :displayed %>/<%= @models.count %></h1>
9
12
  <ul>
10
13
  <% displayed_count = 0 %>
11
- <%= @models.each do |model| %>
14
+ <% @models.each do |model| %>
12
15
  <li><%= if model.display?
13
16
  displayed += 1
14
17
  model.full_name
@@ -39,3 +42,49 @@ gem 'kaizan'
39
42
  ```
40
43
 
41
44
  $ bundle install
45
+
46
+ ## Usage
47
+
48
+ ```html
49
+ <h1>Altering Past Buffer</h1>
50
+ <ul>
51
+ <li class="case1"><%= '<xmp>not safe string' %></li>
52
+ <li class="case2"><%= altering_anchor %></li>
53
+ <li class="case3"><%= altering_anchor %></li>
54
+ <li class="case4"><%= altering_anchor %></li>
55
+ <li class="case5"><%= altering_anchor :named_anchor %></li>
56
+ <li class="case6"><%= altering_anchor :named_anchor %></li>
57
+ <li class="case7"><%= altering_anchor :foot_line %></li>
58
+ </ul>
59
+ <%= altering_anchor %>
60
+ <% alter_past(0, :string) %>
61
+ <% alter_past(1, '<xmp>Not safe altering') %>
62
+ <% alter_past(2, '<strong>Safe altering</strong>'.html_safe) %>
63
+ <% alter_past(:named_anchor, 'Multiple altering') %>
64
+ <% alter_past(:foot_line, 'Thank you') %>
65
+ <% alter_past(:not_exit_anchor, 'Not exist') %>
66
+ <footer>Concatenated</footer>
67
+ ```
68
+
69
+ 1. `<%= %>`と`altering_anchor(name = nil)`で場所を指定する。
70
+ nameはなくても大丈夫。
71
+ 1. `alter_past(name, content)`で置換する。
72
+ nameが整数の場合、`altering_anchor`された順のインデックス位置を置換。
73
+ nameがSymbolなどの場合、`altering_anchor`で指定されたnameと同じ位置をすべて置換。
74
+ 1. 置換されないとanchor文字列が残る。
75
+ 1. htmlを入れたい場合は`html_safe`を使う。
76
+
77
+ ```html
78
+ <h1>Altering Past Buffer</h1>
79
+ <ul>
80
+ <li class="case1">&lt;xmp&gt;not safe string</li>
81
+ <li class="case2">string</li>
82
+ <li class="case3">&lt;xmp&gt;Not safe altering</li>
83
+ <li class="case4"><strong>Safe altering</strong></li>
84
+ <li class="case5">Multiple altering</li>
85
+ <li class="case6">Multiple altering</li>
86
+ <li class="case7">Thank you</li>
87
+ </ul>
88
+ <!-- altering_anchor:526c675d724f3e5b8ae68ec1e661f2b4 -->
89
+ <footer>Concatenated</footer>
90
+ ```
@@ -1,3 +1,3 @@
1
1
  module Kaizan
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
data/lib/kaizan.rb CHANGED
@@ -33,12 +33,7 @@ module ActionView
33
33
 
34
34
  def alter_past!(name, content)
35
35
  return unless (anchor = detect_anchor(name)).present?
36
- gsub_not_safety!(anchor, alter_string_safety(content))
37
- end
38
-
39
-
40
- def alter_string_safety(content)
41
- content.html_safe? ? content.to_s : html_escape_interpolated_argument_force(content.to_s)
36
+ gsub_not_safety!(anchor, html_escape_interpolated_argument(content))
42
37
  end
43
38
 
44
39
 
@@ -64,10 +59,5 @@ module ActionView
64
59
  "<!-- altering_anchor:#{SecureRandom.hex(16)} -->"
65
60
  end
66
61
  end
67
-
68
-
69
- def html_escape_interpolated_argument_force(arg)
70
- arg.to_s.gsub(ERB::Util::HTML_ESCAPE_REGEXP, ERB::Util::HTML_ESCAPE)
71
- end
72
62
  end
73
63
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kaizan
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - mmmpa
@@ -190,7 +190,6 @@ files:
190
190
  - spec/dummy/config/locales/en.yml
191
191
  - spec/dummy/config/routes.rb
192
192
  - spec/dummy/config/secrets.yml
193
- - spec/dummy/db/migrate/20150627055616_create_samples.rb
194
193
  - spec/dummy/lib/assets/.keep
195
194
  - spec/dummy/log/.keep
196
195
  - spec/dummy/public/404.html
@@ -1,8 +0,0 @@
1
- class CreateSamples < ActiveRecord::Migration
2
- def change
3
- create_table :samples do |t|
4
-
5
- t.timestamps null: false
6
- end
7
- end
8
- end