middleman-ya_lorem_ja 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +23 -12
- data/features/helpers_ya_lorem_ja.feature +1 -3
- data/features/helpers_ya_lorem_ja_change_resource.feature +21 -0
- data/features/support/hook.rb +8 -0
- data/fixtures/chuumon_no_ooi_ryouriten/config.rb +1 -0
- data/fixtures/chuumon_no_ooi_ryouriten/source/word.html.erb +10 -0
- data/fixtures/test-app/source/word.html.erb +1 -0
- data/lib/middleman-ya_lorem_ja/extension.rb +37 -6
- data/lib/middleman-ya_lorem_ja/version.rb +1 -1
- data/middleman-ya_lorem_ja.gemspec +1 -1
- metadata +11 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fc24b3fba7ae575aea5f5bd676730f1eadba19cb
|
4
|
+
data.tar.gz: 6e10933c024dc696b9bf22a25ded771a78d0d6da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f3f10ef94327ae8fa57f3e5d8f47c66de3d08934034e64111a969f03e31faa860a9b9469029ab5b453b4bd49bd5133e0c8bcdf8463cd0d4cdafefa8f8e6bbad9
|
7
|
+
data.tar.gz: 4d3466fc13266d841a830fac40738b6e28ad436de6a45037a8ddd2e6aed1235bd6311ea000034232e1c68f519913417c309f34c17b18a888f6794b236267df19
|
data/README.md
CHANGED
@@ -2,13 +2,20 @@
|
|
2
2
|
|
3
3
|
Middleman 用の日本語 lorem 拡張です。
|
4
4
|
|
5
|
-
##
|
5
|
+
## Installation
|
6
6
|
|
7
|
-
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'middleman-ya_lorem_ja'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install middleman-ya_lorem_ja
|
8
18
|
|
9
|
-
```
|
10
|
-
gem "middleman-ya_lorem_ja" , :git => 'git://github.com/tanalab2/middleman-ya_lorem_ja'
|
11
|
-
```
|
12
19
|
|
13
20
|
あとは、 middleman の config.rb に以下を追加し、 ya_lorem_ja を有効化してください。
|
14
21
|
|
@@ -16,12 +23,21 @@ gem "middleman-ya_lorem_ja" , :git => 'git://github.com/tanalab2/middleman-ya_lo
|
|
16
23
|
activate :ya_lorem_ja
|
17
24
|
```
|
18
25
|
|
26
|
+
また、以下により、文章リソースを変更できます。(:resource_nameを指定しない場合は、坂口安吾「風博士」が使用されます。)
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
# 宮沢賢治「注文の多い料理店」を使用する場合
|
30
|
+
activate :ya_lorem_ja, :resource_name => :chuumon_no_ooi_ryouriten
|
31
|
+
```
|
32
|
+
|
19
33
|
ya_lorem_ja が有効になり、 erb ファイルなどで、
|
20
34
|
lorem_ja オブジェクトが使用できるようになります。
|
21
35
|
|
22
36
|
erb に以下を記載した場合は、
|
23
37
|
|
24
38
|
``` ruby
|
39
|
+
<h1><%= lorem_ja.date%></h1>
|
40
|
+
<img src="<%= lorem_ja.image('200x200')%>"/>
|
25
41
|
<h1><%= lorem_ja.word %></h1>
|
26
42
|
<h2><%= lorem_ja.words(5) %></h2>
|
27
43
|
<p><%= lorem_ja.sentence %></p>
|
@@ -35,6 +51,8 @@ erb に以下を記載した場合は、
|
|
35
51
|
以下のように出力されます。
|
36
52
|
|
37
53
|
``` html
|
54
|
+
<h1>2001年03月19日</h1>
|
55
|
+
<img src="http://placehold.it/200x200"/>
|
38
56
|
<h1>風博士の遺書</h1>
|
39
57
|
<h2>諸氏よ、誰人かよく蛸を懲す勇士なきや</h2>
|
40
58
|
<p>余の妻は麗わしきこと高山植物の如く、実に単なる植物ではなかったのである!</p>
|
@@ -87,13 +105,6 @@ erb に以下を記載した場合は、
|
|
87
105
|
|
88
106
|
* [lorem.rb](https://github.com/middleman/middleman/middleman-core/lib/middleman-more/extensions/lorem.rb )
|
89
107
|
|
90
|
-
* [坂口安吾「風博士」](http://www.aozora.gr.jp/cards/001095/card42616.html)
|
91
|
-
|
92
|
-
文の配列は、青空文庫から拝借しました。
|
93
|
-
|
94
|
-
* [middleman-ya_lorem_ja を使用したサンプルページ](http://discountinnovations.com/articles/middleman/lorem_ja.html)
|
95
|
-
|
96
|
-
|
97
108
|
## License
|
98
109
|
* MIT
|
99
110
|
|
@@ -13,7 +13,5 @@ Feature: Lorem generating helper
|
|
13
13
|
Then I should see "#paragraphs3" contents have "3" paragraphs
|
14
14
|
Then I should see "#date" contents match "\d{4}年\d{2}月\d{2}日"
|
15
15
|
Then I should see "#image" contents match "^http://placehold.it/20x20"
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
Then I should see "#resource_name" contents match "kazehakase"
|
19
17
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
Feature: Lorem generating helper
|
2
|
+
|
3
|
+
Scenario: Lorem Helper
|
4
|
+
Given the Server is running at "chuumon_no_ooi_ryouriten"
|
5
|
+
Then going to "/word.html" should not raise an exception
|
6
|
+
Then I should see "#word" contents have over "2" chars
|
7
|
+
Then I should see "#words5" contents have over "10" chars
|
8
|
+
Then I should see "#sentence" contents have over "#{2*6}" chars
|
9
|
+
Then I should see "#sentence" contents have "1" sentences
|
10
|
+
Then I should see "#sentences3" contents have over "6" chars
|
11
|
+
Then I should see "#sentences3" contents have "3" sentences
|
12
|
+
Then I should see "#paragraph" contents have "1" paragraphs
|
13
|
+
Then I should see "#paragraphs3" contents have "3" paragraphs
|
14
|
+
Then I should see "#date" contents match "\d{4}年\d{2}月\d{2}日"
|
15
|
+
Then I should see "#image" contents match "^http://placehold.it/20x20"
|
16
|
+
Then I should see "#resource_name" contents match "chuumon_no_ooi_ryouriten"
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
@@ -0,0 +1,8 @@
|
|
1
|
+
After do |scenario|
|
2
|
+
# Do something after each scenario.
|
3
|
+
# The +scenario+ argument is optional, but
|
4
|
+
# if you use it, you can inspect status with
|
5
|
+
# the #failed?, #passed? and #exception methods.
|
6
|
+
|
7
|
+
::Middleman::YaLoremJa::Extension::YaLoremJaObj.reset_instance
|
8
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
activate :ya_lorem_ja, :resource_name => :chuumon_no_ooi_ryouriten
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<div id="#resource_name"><%= lorem_ja.resource_name %></div>
|
2
|
+
<div id="#word"><%= lorem_ja.word %></div>
|
3
|
+
<div id="#words5"><%= lorem_ja.words(5) %></div>
|
4
|
+
<div id="#sentence"><%= lorem_ja.sentence %></div>
|
5
|
+
<div id="#sentences3"><%= lorem_ja.sentences(3) %></div>
|
6
|
+
<div id="#paragraph"><%= lorem_ja.paragraph %></div>
|
7
|
+
<div id="#paragraphs3"><%= lorem_ja.paragraphs(3) %></div>
|
8
|
+
<div id="#date"><%= lorem_ja.date %></div>
|
9
|
+
<div id="#image"><%= lorem_ja.image("20x20") %></div>
|
10
|
+
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
2
|
require 'ya_lorem_ja'
|
3
|
-
require '
|
3
|
+
require 'thread'
|
4
4
|
|
5
5
|
# -*- coding: utf-8 -*-
|
6
6
|
# https://github.com/middleman/middleman/blob/v3-stable/middleman-core/lib/middleman-more/extensions/lorem.rb
|
@@ -8,7 +8,12 @@ require 'singleton'
|
|
8
8
|
module Middleman
|
9
9
|
module YaLoremJa
|
10
10
|
class Extension < ::Middleman::Extension
|
11
|
-
|
11
|
+
|
12
|
+
EXTENSION_NAME = :ya_lorem_ja
|
13
|
+
option :resource_name, ::YaLoremJa::Lorem::DEFAULT_RESOURCE_NAME, 'resource name'
|
14
|
+
option :char_count_range, ::YaLoremJa::Lorem::DEFAULT_CHAR_COUNT_RANGE_IN_WORD, 'character count range in a word'
|
15
|
+
option :word_count_range, ::YaLoremJa::Lorem::DEFAULT_WORD_COUNT_RANGE_IN_SENTENCE, 'word count range in a sentence'
|
16
|
+
option :sentence_count_range, ::YaLoremJa::Lorem::DEFAULT_SENTENCE_COUNT_RANGE_IN_PARAGRAPH, 'sentence count range in a paragraph'
|
12
17
|
|
13
18
|
def initialize(app, options_hash={}, &block)
|
14
19
|
# Call super to build options from the options_hash
|
@@ -18,7 +23,8 @@ module Middleman
|
|
18
23
|
# require 'necessary/library'
|
19
24
|
|
20
25
|
# set up your extension
|
21
|
-
# puts options.my_option
|
26
|
+
# puts options.my_option
|
27
|
+
app.set EXTENSION_NAME, options
|
22
28
|
end
|
23
29
|
|
24
30
|
def after_configuration
|
@@ -35,12 +41,37 @@ module Middleman
|
|
35
41
|
# end
|
36
42
|
|
37
43
|
class YaLoremJaObj < ::YaLoremJa::Lorem
|
38
|
-
|
44
|
+
@@singleton__instance__ = nil
|
45
|
+
@@singleton__mutex__ = Mutex.new
|
46
|
+
def self.instance(resource_name=DEFAULT_RESOURCE_NAME, char_count_range=DEFAULT_CHAR_COUNT_RANGE_IN_WORD, word_count_range=DEFAULT_WORD_COUNT_RANGE_IN_SENTENCE, sentence_count_range=DEFAULT_SENTENCE_COUNT_RANGE_IN_PARAGRAPH)
|
47
|
+
return @@singleton__instance__ if @@singleton__instance__
|
48
|
+
@@singleton__mutex__.synchronize {
|
49
|
+
return @@singleton__instance__ if @@singleton__instance__
|
50
|
+
@@singleton__instance__ = new(resource_name, char_count_range, word_count_range, sentence_count_range)
|
51
|
+
}
|
52
|
+
@@singleton__instance__
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.reset_instance
|
56
|
+
@@singleton__mutex__.synchronize {
|
57
|
+
@@singleton__instance__ = nil if @@singleton__instance__
|
58
|
+
}
|
59
|
+
end
|
60
|
+
|
61
|
+
private
|
62
|
+
def initialize(resource_name, char_count_range, word_count_range, sentence_count_range)
|
63
|
+
super(resource_name, char_count_range, word_count_range, sentence_count_range)
|
64
|
+
end
|
65
|
+
private_class_method :new
|
39
66
|
end
|
40
67
|
|
41
68
|
helpers do
|
42
69
|
def lorem_ja
|
43
|
-
|
70
|
+
ext_settings = config[::Middleman::YaLoremJa::Extension::EXTENSION_NAME]
|
71
|
+
return YaLoremJaObj.instance(ext_settings.resource_name,
|
72
|
+
ext_settings.char_count_range,
|
73
|
+
ext_settings.word_count_range,
|
74
|
+
ext_settings.sentence_count_range)
|
44
75
|
end
|
45
76
|
end
|
46
77
|
end
|
@@ -52,4 +83,4 @@ end
|
|
52
83
|
# version of class name
|
53
84
|
|
54
85
|
# MyExtension.register(:my_extension)
|
55
|
-
::Middleman::YaLoremJa::Extension.register(
|
86
|
+
::Middleman::YaLoremJa::Extension.register(::Middleman::YaLoremJa::Extension::EXTENSION_NAME)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-ya_lorem_ja
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kenji tanaka
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: middleman-core
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.0.
|
33
|
+
version: 0.0.3
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.0.
|
40
|
+
version: 0.0.3
|
41
41
|
description: Yet Another Japanese Lorem Ipsum generator For Middleman
|
42
42
|
email:
|
43
43
|
executables: []
|
@@ -49,7 +49,11 @@ files:
|
|
49
49
|
- README.md
|
50
50
|
- Rakefile
|
51
51
|
- features/helpers_ya_lorem_ja.feature
|
52
|
+
- features/helpers_ya_lorem_ja_change_resource.feature
|
52
53
|
- features/support/env.rb
|
54
|
+
- features/support/hook.rb
|
55
|
+
- fixtures/chuumon_no_ooi_ryouriten/config.rb
|
56
|
+
- fixtures/chuumon_no_ooi_ryouriten/source/word.html.erb
|
53
57
|
- fixtures/test-app/config.rb
|
54
58
|
- fixtures/test-app/source/word.html.erb
|
55
59
|
- lib/middleman-ya_lorem_ja.rb
|
@@ -79,11 +83,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
83
|
version: '0'
|
80
84
|
requirements: []
|
81
85
|
rubyforge_project:
|
82
|
-
rubygems_version: 2.
|
86
|
+
rubygems_version: 2.4.5
|
83
87
|
signing_key:
|
84
88
|
specification_version: 4
|
85
89
|
summary: Yet Another Japanese Lorem Ipsum generator For Middleman
|
86
90
|
test_files:
|
87
91
|
- features/helpers_ya_lorem_ja.feature
|
92
|
+
- features/helpers_ya_lorem_ja_change_resource.feature
|
88
93
|
- features/support/env.rb
|
94
|
+
- features/support/hook.rb
|
89
95
|
has_rdoc:
|