lorem_ipsum_amet 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +7 -0
- data/README.md +46 -28
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/lib/lorem_ipsum_amet/base.rb +23 -5
- data/spec/lorem_ipsum/base_spec.rb +68 -2
- data/spec/spec_helper.rb +1 -1
- metadata +6 -5
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -1,77 +1,95 @@
|
|
1
1
|
# Lorem Ipsum Amet - blind text generator
|
2
2
|
===========
|
3
3
|
|
4
|
-
**Lorem Ipsum Amet** provides a simple yet powerful DSL for generating blind
|
4
|
+
**Lorem Ipsum Amet** is a gem that provides a simple yet powerful DSL for generating blind texts in your **Ruby** or **Ruby on Rails** projects.
|
5
|
+
|
6
|
+
Lots of shortcuts have been incorporated in order to make the DSL concise yet expressive to avoid lots of typing.
|
5
7
|
|
6
8
|
## Installation
|
7
9
|
|
8
10
|
Add it to your Gemfile:
|
9
11
|
|
10
|
-
|
12
|
+
gem 'lorem-ipsum-amet'
|
11
13
|
|
12
14
|
And run:
|
13
15
|
|
14
|
-
|
16
|
+
bundle install
|
15
17
|
|
16
18
|
to install it.
|
17
19
|
|
18
20
|
## Usage
|
19
21
|
|
20
|
-
The gem provides all of its features through the namespace LoremIpsum. If you are using it in a Rails project, refer to the next section.
|
22
|
+
The gem provides all of its features through the namespace LoremIpsum. If you are using it in a **Rails** project, refer to the next section.
|
21
23
|
|
22
24
|
### Examples
|
23
25
|
|
24
26
|
#### Get some lorem ipsum!
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
+
LoremIpsum.lorem_ipsum
|
29
|
+
|
30
|
+
or (alternatively)
|
31
|
+
|
32
|
+
LoremIpsum.text
|
28
33
|
|
29
34
|
#### Characters
|
30
35
|
|
31
36
|
Get 100 characters:
|
32
37
|
|
33
|
-
|
34
|
-
|
38
|
+
LoremIpsum.lorem_ipsum(100)
|
39
|
+
|
40
|
+
LoremIpsum.lorem_ipsum(characters: 100)
|
41
|
+
|
42
|
+
LoremIpsum.lorem_ipsum(c: 100)
|
43
|
+
|
44
|
+
LoremIpsum.c(100)
|
35
45
|
|
36
46
|
#### Paragraph
|
37
47
|
|
38
48
|
Get 3 paragraphs:
|
39
49
|
|
40
|
-
|
50
|
+
LoremIpsum.lorem_ipsum(paragraphs: 3)
|
51
|
+
|
52
|
+
LoremIpsum.lorem_ipsum(p: 3)
|
53
|
+
|
54
|
+
LoremIpsum.c(3)
|
41
55
|
|
42
56
|
#### Words
|
43
57
|
|
44
58
|
Get 200 words:
|
45
59
|
|
46
|
-
|
60
|
+
LoremIpsum.lorem_ipsum(words: 3)
|
61
|
+
|
62
|
+
LoremIpsum.lorem_ipsum(w: 3)
|
63
|
+
|
64
|
+
LoremIpsum.w(200)
|
47
65
|
|
48
66
|
#### HTML
|
49
67
|
|
50
68
|
Get 5 paragraphs with `<br />` breaks instead of `\n`:
|
51
69
|
|
52
|
-
|
70
|
+
LoremIpsum.lorem_ipsum(paragraphs: 5, html: true)
|
53
71
|
|
54
72
|
#### Custom paragraph join
|
55
73
|
|
56
|
-
Get 3 paragraphs joined by
|
74
|
+
Get 3 paragraphs joined by \r\n:
|
57
75
|
|
58
|
-
|
76
|
+
LoremIpsum.lorem_ipsum(paragraphs: 3, join: "\r\n")
|
59
77
|
|
60
78
|
#### Text formatting
|
61
79
|
|
62
|
-
Use the
|
80
|
+
Use the format parameter.
|
63
81
|
|
64
82
|
Title case:
|
65
83
|
|
66
|
-
|
84
|
+
LoremIpsum.lorem_ipsum(10, format: :title_case)
|
67
85
|
|
68
86
|
Upcase:
|
69
87
|
|
70
|
-
|
88
|
+
LoremIpsum.lorem_ipsum(10, format: :upcase)
|
71
89
|
|
72
90
|
Downcase:
|
73
91
|
|
74
|
-
|
92
|
+
LoremIpsum.lorem_ipsum(10, format: :downcase)
|
75
93
|
|
76
94
|
#### Different text lengths
|
77
95
|
|
@@ -79,36 +97,36 @@ There are also some shortcuts for getting different text lengths.
|
|
79
97
|
|
80
98
|
Short:
|
81
99
|
|
82
|
-
|
100
|
+
LoremIpsum.short
|
83
101
|
|
84
102
|
Medium:
|
85
103
|
|
86
|
-
|
87
|
-
|
104
|
+
LoremIpsum.medium
|
105
|
+
LoremIpsum.medium("<br />")
|
88
106
|
|
89
107
|
Long:
|
90
108
|
|
91
|
-
|
92
|
-
|
109
|
+
LoremIpsum.long
|
110
|
+
LoremIpsum.long("<br />")
|
93
111
|
|
94
112
|
Very long:
|
95
113
|
|
96
|
-
|
97
|
-
|
114
|
+
LoremIpsum.very_long
|
115
|
+
LoremIpsum.very_long("<br />")
|
98
116
|
|
99
117
|
### Rails integration
|
100
118
|
|
101
|
-
If you are using this gem in a Rails project, you can access the helper method
|
119
|
+
If you are using this gem in a Rails project, you can access the helper method lorem_ipsum to get exactly the same functionality as described in the examples before.
|
102
120
|
|
103
121
|
The html option is activated by default.
|
104
122
|
|
105
123
|
ERB:
|
106
124
|
|
107
|
-
|
125
|
+
<%= text_area_tag 'placeholder', lorem_ipsum %>
|
108
126
|
|
109
127
|
HAML:
|
110
128
|
|
111
|
-
|
129
|
+
%p= lorem_ipsum(paragraphs: 5)
|
112
130
|
|
113
131
|
## Bug reports and contributions
|
114
132
|
|
@@ -120,5 +138,5 @@ If you discover any bugs or need a feature, feel free to create an issue on GitH
|
|
120
138
|
|
121
139
|
## License
|
122
140
|
|
123
|
-
MIT License.
|
141
|
+
MIT License. Refer to [License file](https://github.com/yagooar/lorem_ipsum_amet/blob/master/LICENSE.txt)
|
124
142
|
|
data/Rakefile
CHANGED
@@ -18,8 +18,8 @@ Jeweler::Tasks.new do |gem|
|
|
18
18
|
gem.name = 'lorem_ipsum_amet'
|
19
19
|
gem.homepage = 'http://yagooar.github.com/lorem_ipsum_amet/'
|
20
20
|
gem.license = 'MIT'
|
21
|
-
gem.summary = %Q{Lorem Ipsum generator}
|
22
|
-
gem.description = %Q{Generate blind texts with
|
21
|
+
gem.summary = %Q{Lorem Ipsum generator for Ruby and Rails}
|
22
|
+
gem.description = %Q{Generate blind texts with tons of options in Ruby and Ruby on Rails}
|
23
23
|
gem.email = 'yagooar@gmail.com'
|
24
24
|
gem.authors = ['Mateusz Sojka']
|
25
25
|
gem.require_paths = ['lib']
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
@@ -14,10 +14,16 @@ module LoremIpsumAmet
|
|
14
14
|
|
15
15
|
if params[:characters]
|
16
16
|
Character.new(self, params.delete(:characters), join_element).text
|
17
|
+
elsif params[:c]
|
18
|
+
Character.new(self, params.delete(:c), join_element).text
|
17
19
|
elsif params[:paragraphs]
|
18
20
|
Paragraph.new(self, params.delete(:paragraphs), join_element).text
|
21
|
+
elsif params[:p]
|
22
|
+
Paragraph.new(self, params.delete(:p), join_element).text
|
19
23
|
elsif params[:words]
|
20
24
|
Word.new(self, params.delete(:words), join_element).text
|
25
|
+
elsif params[:w]
|
26
|
+
Word.new(self, params.delete(:w), join_element).text
|
21
27
|
else
|
22
28
|
paragraphs.first
|
23
29
|
end
|
@@ -30,24 +36,36 @@ module LoremIpsumAmet
|
|
30
36
|
end
|
31
37
|
|
32
38
|
def short
|
33
|
-
|
39
|
+
lorem_ipsum(words: 8)
|
34
40
|
end
|
35
41
|
|
36
42
|
def medium(join_element = "\n")
|
37
|
-
|
43
|
+
lorem_ipsum(paragraphs: 2, join: join_element)
|
38
44
|
end
|
39
45
|
|
40
46
|
def long(join_element = "\n")
|
41
|
-
|
47
|
+
lorem_ipsum(paragraphs: 8, join: join_element)
|
42
48
|
end
|
43
49
|
|
44
50
|
def very_long(join_element = "\n")
|
45
|
-
|
51
|
+
lorem_ipsum(paragraphs: 24, join: join_element)
|
46
52
|
end
|
47
53
|
|
48
54
|
# http://goo.gl/m0MMz ;)
|
49
55
|
def the_lord_of_the_rings_long(join_element = "\n")
|
50
|
-
|
56
|
+
lorem_ipsum(words: 500000, join: join_element)
|
57
|
+
end
|
58
|
+
|
59
|
+
def c(characters, join_element = "\n")
|
60
|
+
lorem_ipsum(characters, join: join_element)
|
61
|
+
end
|
62
|
+
|
63
|
+
def p(paragraphs, join_element = "\n")
|
64
|
+
lorem_ipsum(paragraphs: paragraphs, join: join_element)
|
65
|
+
end
|
66
|
+
|
67
|
+
def w(words, join_element = "\n")
|
68
|
+
lorem_ipsum(words: words, join: join_element)
|
51
69
|
end
|
52
70
|
|
53
71
|
private
|
@@ -32,6 +32,10 @@ describe LoremIpsumAmet::Base do
|
|
32
32
|
expect(subject.lorem_ipsum(characters: 20)).to eq(first_paragraph[0...20])
|
33
33
|
end
|
34
34
|
|
35
|
+
it 'returns a given amount of characters (short syntax)' do
|
36
|
+
expect(subject.lorem_ipsum(c: 20)).to eq(first_paragraph[0...20])
|
37
|
+
end
|
38
|
+
|
35
39
|
describe 'join element' do
|
36
40
|
|
37
41
|
it 'returns paragraphs separated by the given join element' do
|
@@ -48,6 +52,20 @@ describe LoremIpsumAmet::Base do
|
|
48
52
|
|
49
53
|
end
|
50
54
|
|
55
|
+
describe '#c' do
|
56
|
+
|
57
|
+
it 'returns the given number of characters' do
|
58
|
+
expect(subject.c(25)).to eq(first_paragraph[0...25])
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'returns the given number of characters with custom join' do
|
62
|
+
two_paragraphs = [first_paragraph, second_paragraph].join("\r\n")
|
63
|
+
|
64
|
+
expect(subject.c(two_paragraphs.length, "\r\n")).to eq(two_paragraphs)
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
51
69
|
end
|
52
70
|
|
53
71
|
describe 'paragraphs' do
|
@@ -57,6 +75,11 @@ describe LoremIpsumAmet::Base do
|
|
57
75
|
expect(subject.lorem_ipsum(paragraphs: 2)).to eq(two_paragraphs)
|
58
76
|
end
|
59
77
|
|
78
|
+
it 'returns a given amount of paragraphs (short syntax)' do
|
79
|
+
two_paragraphs = [first_paragraph, second_paragraph].join("\n")
|
80
|
+
expect(subject.lorem_ipsum(p: 2)).to eq(two_paragraphs)
|
81
|
+
end
|
82
|
+
|
60
83
|
it 'returns a given amount of paragraphs (more paragraphs than in raw text)' do
|
61
84
|
seven_paragraphs = [raw_text, first_paragraph].join("\n")
|
62
85
|
expect(subject.lorem_ipsum(paragraphs: 7)).to eq(seven_paragraphs)
|
@@ -76,6 +99,23 @@ describe LoremIpsumAmet::Base do
|
|
76
99
|
expect(subject.lorem_ipsum(paragraphs: 2, html: true)).to eq(two_paragraphs)
|
77
100
|
end
|
78
101
|
|
102
|
+
|
103
|
+
describe '#p' do
|
104
|
+
|
105
|
+
it 'returns the given number of paragraphs' do
|
106
|
+
two_paragraphs = [first_paragraph, second_paragraph].join("\n")
|
107
|
+
|
108
|
+
expect(subject.p(2)).to eq(two_paragraphs)
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'returns the given number of paragraphs (with custom join)' do
|
112
|
+
two_paragraphs = [first_paragraph, second_paragraph].join("\r\n")
|
113
|
+
|
114
|
+
expect(subject.p(2, "\r\n")).to eq(two_paragraphs)
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
|
79
119
|
end
|
80
120
|
|
81
121
|
end
|
@@ -88,6 +128,12 @@ describe LoremIpsumAmet::Base do
|
|
88
128
|
expect(subject.lorem_ipsum(words: 8)).to eq(eight_words)
|
89
129
|
end
|
90
130
|
|
131
|
+
it 'returns a given amount of words (short syntax)' do
|
132
|
+
eight_words = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit.'
|
133
|
+
|
134
|
+
expect(subject.lorem_ipsum(w: 8)).to eq(eight_words)
|
135
|
+
end
|
136
|
+
|
91
137
|
it 'returns a given amount of words (more than in the whole text)' do
|
92
138
|
seven_paragraphs = [raw_text, first_paragraph].join("\n")
|
93
139
|
words = seven_paragraphs.split.size
|
@@ -101,6 +147,24 @@ describe LoremIpsumAmet::Base do
|
|
101
147
|
|
102
148
|
expect(subject.lorem_ipsum(words: words, join: "\r\n")).to eq(seven_paragraphs)
|
103
149
|
end
|
150
|
+
|
151
|
+
describe '#w' do
|
152
|
+
|
153
|
+
it 'returns the given amount of words' do
|
154
|
+
eight_words = 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit.'
|
155
|
+
|
156
|
+
expect(subject.w(8)).to eq(eight_words)
|
157
|
+
end
|
158
|
+
|
159
|
+
it 'returns a given amount of words separated by \r\n' do
|
160
|
+
seven_paragraphs = [raw_text, first_paragraph].join("\n").gsub("\n", "\r\n")
|
161
|
+
words = seven_paragraphs.split.size
|
162
|
+
|
163
|
+
expect(subject.w(words, "\r\n")).to eq(seven_paragraphs)
|
164
|
+
end
|
165
|
+
|
166
|
+
end
|
167
|
+
|
104
168
|
end
|
105
169
|
|
106
170
|
describe 'text format' do
|
@@ -169,10 +233,12 @@ describe LoremIpsumAmet::Base do
|
|
169
233
|
|
170
234
|
end
|
171
235
|
|
172
|
-
describe '
|
173
|
-
|
236
|
+
describe '#text' do
|
237
|
+
|
238
|
+
it 'is an alias of #lorem_ipsum' do
|
174
239
|
expect(subject.method(:text)).to eq(subject.method(:lorem_ipsum))
|
175
240
|
end
|
241
|
+
|
176
242
|
end
|
177
243
|
|
178
244
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lorem_ipsum_amet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -107,7 +107,7 @@ dependencies:
|
|
107
107
|
- - ! '>='
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '0'
|
110
|
-
description: Generate blind texts with
|
110
|
+
description: Generate blind texts with tons of options in Ruby and Ruby on Rails
|
111
111
|
email: yagooar@gmail.com
|
112
112
|
executables: []
|
113
113
|
extensions: []
|
@@ -115,6 +115,7 @@ extra_rdoc_files:
|
|
115
115
|
- LICENSE.txt
|
116
116
|
- README.md
|
117
117
|
files:
|
118
|
+
- CHANGELOG.md
|
118
119
|
- Gemfile
|
119
120
|
- Gemfile.lock
|
120
121
|
- LICENSE.txt
|
@@ -147,7 +148,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
147
148
|
version: '0'
|
148
149
|
segments:
|
149
150
|
- 0
|
150
|
-
hash:
|
151
|
+
hash: 2022820521436179043
|
151
152
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
153
|
none: false
|
153
154
|
requirements:
|
@@ -159,5 +160,5 @@ rubyforge_project:
|
|
159
160
|
rubygems_version: 1.8.23
|
160
161
|
signing_key:
|
161
162
|
specification_version: 3
|
162
|
-
summary: Lorem Ipsum generator
|
163
|
+
summary: Lorem Ipsum generator for Ruby and Rails
|
163
164
|
test_files: []
|