ya_lorem_ja 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: e5512f6c17f33e8be6efbae30aa08b1ab36b44ac
4
- data.tar.gz: adb703f62f39320e831bc5601761768fd3aa451f
3
+ metadata.gz: ee9fcc6d1cc4d19a188e31de60f9e0096d4c657b
4
+ data.tar.gz: 68c8521edad996b66c165df4ae7ea0ab25a656a6
5
5
  SHA512:
6
- metadata.gz: 067d885ebc020d08a06811dcd2daef9a6ebe92ca553a92474651430fa379eb6f212d9ec8df606fe0ed979a16d872d82701661735d8cdee71152cc3bc42955b09
7
- data.tar.gz: a54799e67d9c868e1dfa98aa7931d4dafaf9e2dd185f95f3fcf6388a283549adf19fdb596a189d8faa8df22731d26d3a138a6564807e27d752b246b1947c34b0
6
+ metadata.gz: 2ac2a091906936e9b07c5d5480d11c53b49b073b999e5ec53bf226b0fd37b93298c5acc5b9ed9a97a6b1b3c96189b08805bbdf02d08126e3d24fa21729f68171
7
+ data.tar.gz: aff31a73c543fcc906c48e93b05eb816619f4b8d1680cd85fc81c3b9d75476b4214ba8d380d22327cba30575dfaa41f162f5a9ba909b28eb14b2d53a305185d5
@@ -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..20, sentence_count_range=2..5)
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
@@ -1,5 +1,5 @@
1
1
  module YaLoremJa
2
2
  ##
3
3
  # version
4
- VERSION = "0.0.1"
4
+ VERSION = "0.0.2"
5
5
  end
@@ -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
@@ -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.1
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-04 00:00:00.000000000 Z
11
+ date: 2015-08-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler