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 +4 -4
- data/README.md +50 -1
- data/lib/kaizan/version.rb +1 -1
- data/lib/kaizan.rb +1 -11
- metadata +1 -2
- data/spec/dummy/db/migrate/20150627055616_create_samples.rb +0 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9e950163593d3a9535165adcc61292c893884a2
|
4
|
+
data.tar.gz: 44031f7d1121a12749280611af6f9bbe72258cd7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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"><xmp>not safe string</li>
|
81
|
+
<li class="case2">string</li>
|
82
|
+
<li class="case3"><xmp>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
|
+
```
|
data/lib/kaizan/version.rb
CHANGED
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,
|
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.
|
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
|