ya_lorem_ja 0.0.1 → 0.0.2
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/lib/ya_lorem_ja.rb +35 -2
- data/lib/ya_lorem_ja/version.rb +1 -1
- data/spec/ya_lorem_ja_spec.rb +10 -0
- data/ya_lorem_ja.gemspec +0 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ee9fcc6d1cc4d19a188e31de60f9e0096d4c657b
|
4
|
+
data.tar.gz: 68c8521edad996b66c165df4ae7ea0ab25a656a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ac2a091906936e9b07c5d5480d11c53b49b073b999e5ec53bf226b0fd37b93298c5acc5b9ed9a97a6b1b3c96189b08805bbdf02d08126e3d24fa21729f68171
|
7
|
+
data.tar.gz: aff31a73c543fcc906c48e93b05eb816619f4b8d1680cd85fc81c3b9d75476b4214ba8d380d22327cba30575dfaa41f162f5a9ba909b28eb14b2d53a305185d5
|
data/lib/ya_lorem_ja.rb
CHANGED
@@ -19,7 +19,7 @@ module YaLoremJa
|
|
19
19
|
# @param [Range] word_count_range range of word count in sentence
|
20
20
|
# @param [Range] sentence_count_range renage of sentence count in paragraph
|
21
21
|
#
|
22
|
-
def initialize(resource_name=:kazehakase, char_count_range=2..6, word_count_range=6..
|
22
|
+
def initialize(resource_name=:kazehakase, char_count_range=2..6, word_count_range=6..15, sentence_count_range=2..5)
|
23
23
|
@resource_name = resource_name
|
24
24
|
# 文章辞書の読み込み
|
25
25
|
@resource = ::YaLoremJa::WordResources.load(resource_name, char_count_range, word_count_range, sentence_count_range)
|
@@ -108,7 +108,40 @@ module YaLoremJa
|
|
108
108
|
# @return [String] paragraph
|
109
109
|
def paragraphs(total)
|
110
110
|
@resource.paragraphs(total)
|
111
|
-
end
|
111
|
+
end
|
112
|
+
|
113
|
+
|
114
|
+
def date(fmt='%Y年%m月%d日')
|
115
|
+
y = rand(20) + 1990
|
116
|
+
m = rand(12) + 1
|
117
|
+
d = rand(31) + 1
|
118
|
+
Time.local(y, m, d).strftime(fmt)
|
119
|
+
end
|
120
|
+
|
121
|
+
|
122
|
+
# Get a placeholder image, using placehold.it by default
|
123
|
+
# @param [String] size
|
124
|
+
# @param [Hash] options
|
125
|
+
# @return [String]
|
126
|
+
def image(size, options={})
|
127
|
+
domain = options[:domain] || 'http://placehold.it'
|
128
|
+
src = "#{domain}/#{size}"
|
129
|
+
hex = %w(a b c d e f 0 1 2 3 4 5 6 7 8 9)
|
130
|
+
background_color = options[:background_color]
|
131
|
+
color = options[:color]
|
132
|
+
|
133
|
+
if options[:random_color]
|
134
|
+
background_color = hex.shuffle[0...6].join
|
135
|
+
color = hex.shuffle[0...6].join
|
136
|
+
end
|
137
|
+
|
138
|
+
src << "/#{background_color.sub(/^#/, '')}" if background_color
|
139
|
+
src << '/ccc' if background_color.nil? && color
|
140
|
+
src << "/#{color.sub(/^#/, '')}" if color
|
141
|
+
src << "&text=#{Rack::Utils.escape(options[:text])}" if options[:text]
|
142
|
+
|
143
|
+
src
|
144
|
+
end
|
112
145
|
|
113
146
|
end
|
114
147
|
end
|
data/lib/ya_lorem_ja/version.rb
CHANGED
data/spec/ya_lorem_ja_spec.rb
CHANGED
@@ -88,7 +88,17 @@ describe YaLoremJa do
|
|
88
88
|
paras.split("\r\n"*2).each do |a_para|
|
89
89
|
expect(a_para.split("\r\n").count).to be >= lorem.sentence_count_range.min
|
90
90
|
end
|
91
|
+
end
|
91
92
|
|
93
|
+
it '日付を取得できること' do
|
94
|
+
lorem = YaLoremJa::Lorem.new
|
95
|
+
expect(lorem.date).to match /^\d{4}年\d{2}月\d{2}日$/
|
96
|
+
expect(lorem.date('%Y-%m-%d')).to match /^\d{4}-\d{2}-\d{2}$/
|
97
|
+
end
|
98
|
+
|
99
|
+
it '画像URLを取得できること' do
|
100
|
+
lorem = YaLoremJa::Lorem.new
|
101
|
+
expect(lorem.image('20x20')).to match %r!^http://placehold.it/20x20$!
|
92
102
|
end
|
93
103
|
|
94
104
|
end
|
data/ya_lorem_ja.gemspec
CHANGED
@@ -7,7 +7,6 @@ Gem::Specification.new do |spec|
|
|
7
7
|
spec.name = "ya_lorem_ja"
|
8
8
|
spec.version = YaLoremJa::VERSION
|
9
9
|
spec.authors = ["kenji tanaka"]
|
10
|
-
#spec.email = ["tanalab2@gmail.com"]
|
11
10
|
spec.description = %q{Yet Another Japanese Lorem Ipsum generator}
|
12
11
|
spec.summary = %q{Yet Another Japanese Lorem Ipsum generator}
|
13
12
|
spec.homepage = "https://github.com/tanalab2/ya_lorem_ja"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ya_lorem_ja
|
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
|
- kenji tanaka
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|