wordy 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +1 -0
- data/README.md +77 -7
- data/Rakefile +5 -0
- data/lib/wordy/version.rb +1 -1
- data/test/test_wordy.rb +56 -4
- data/wordy.gemspec +5 -2
- metadata +27 -6
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,12 +1,18 @@
|
|
1
1
|
# Wordy [![Build Status](https://secure.travis-ci.org/citrus/wordy.png)](http://travis-ci.org/citrus/wordy)
|
2
2
|
|
3
|
-
Wordy speaks lorem ipsum. You can ask Wordy for
|
3
|
+
### Wordy speaks lorem ipsum. You can ask Wordy for paragraphs, sentences or words.
|
4
|
+
|
5
|
+
Wordy was written to help us create sample data in our applications. Yes, there are already a ton of gems (17 as of 2011/11/5) that show up when [searching](http://rubygems.org/search?utf8=✓&query=lorem+ipsum) for 'lorem ipsum' on [rubygems](http://rubygems.org/)... so why another?
|
6
|
+
|
7
|
+
I guess the short answer is I wasn't happy with some of the other solutions. Many had poor documentation or methods and modules that I didn't need. I just wanted simple.
|
8
|
+
|
9
|
+
That's what Wordy delivers... simplicity. There are no runtime dependencies, monkey patches or unnecessary methods. Just [45 lines](https://github.com/citrus/wordy/blob/master/lib/wordy.rb) of the basics.
|
4
10
|
|
5
11
|
|
6
12
|
Usage
|
7
13
|
-----
|
8
14
|
|
9
|
-
Using wordy is
|
15
|
+
Using wordy is easy. Here's the rundown in [irb](http://en.wikipedia.org/wiki/Interactive_Ruby_Shell):
|
10
16
|
|
11
17
|
$ require 'wordy'
|
12
18
|
=> true
|
@@ -18,7 +24,7 @@ Using wordy is simple. Here's the rundown:
|
|
18
24
|
=> ["nobis", "laborum", "commodi"]
|
19
25
|
|
20
26
|
$ Wordy.sentence
|
21
|
-
=> "Libero necessitatibus dolore et dicta."
|
27
|
+
=> "Libero necessitatibus dolore et dicta."
|
22
28
|
|
23
29
|
$ Wordy.sentences
|
24
30
|
=> ["Error omnis possimus autem magni quae natus exercitationem sit fuga recusandae maiores odit.", "Perspiciatis sed nisi neque pariatur voluptas quia repudiandae quas consequatur dolore.", "Magni nam quae quas enim est qui.", "Fuga aut vitae soluta sit et laborum est est illo sequi.", "Veritatis velit exercitationem nihil sed perferendis iusto ut voluptate consequatur cum molestiae.", "Fugit exercitationem velit dolorem vel qui delectus atque officia."]
|
@@ -31,7 +37,70 @@ Using wordy is simple. Here's the rundown:
|
|
31
37
|
|
32
38
|
$ Wordy.body
|
33
39
|
=> "Aperiam ea voluptatem nostrum qui fuga et molestias quibusdam consequuntur non sed qui culpa. Incidunt minima similique repellendus distinctio debitis blanditiis ratione architecto.\n\nAliquid non excepturi voluptatem nobis laudantium. Corrupti ut aut autem sed quia ducimus eligendi eum maxime voluptas suscipit.\n\nDolor fuga est voluptas cupiditate vel quaerat consequuntur velit corrupti. Unde quod quia est nihil est nisi quo officiis nobis. Est similique ea dolorum natus. Odio voluptate facere cupiditate quo autem quod doloremque expedita delectus cum accusamus consequuntur ut.\n\nDignissimos quia blanditiis sit quis voluptates et optio maiores tenetur quia. Non aperiam quos eligendi voluptas est animi voluptatum sequi impedit. Impedit repudiandae officiis magni quia qui explicabo voluptas saepe delectus illo aliquid qui. Sunt minus sint quam omnis sed blanditiis."
|
34
|
-
|
40
|
+
|
41
|
+
|
42
|
+
That's it!
|
43
|
+
|
44
|
+
|
45
|
+
### Taking it farther
|
46
|
+
|
47
|
+
Let's get fancy. But let's keep it simple.
|
48
|
+
|
49
|
+
If I were building an app that had, say, user accounts, it might make sense to create a seed helper like the module below.
|
50
|
+
|
51
|
+
require 'wordy'
|
52
|
+
|
53
|
+
module Seeder
|
54
|
+
|
55
|
+
include Wordy
|
56
|
+
extend self
|
57
|
+
|
58
|
+
def username
|
59
|
+
Wordy.words(3).join("-")
|
60
|
+
end
|
61
|
+
|
62
|
+
def email
|
63
|
+
[ Seeder.username, "@", Seeder.username, "-", rand(100), ".com" ].join
|
64
|
+
end
|
65
|
+
|
66
|
+
def domain
|
67
|
+
[ Seeder.username, ".com" ].join
|
68
|
+
end
|
69
|
+
|
70
|
+
def url
|
71
|
+
[ "http://", Seeder.domain ].join
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
This will allow me to do the following:
|
78
|
+
|
79
|
+
$ require 'seeder'
|
80
|
+
=> true
|
81
|
+
|
82
|
+
$ Seeder.username
|
83
|
+
=> "commodi-placeat-nobis"
|
84
|
+
|
85
|
+
$ Seeder.email
|
86
|
+
=> "animi-facilis-dolores@eum-sed-est-56.com"
|
87
|
+
|
88
|
+
$ Seeder.domain
|
89
|
+
=> "qui-accusamus-voluptatum.com"
|
90
|
+
|
91
|
+
$ Seeder.url
|
92
|
+
=> "http://est-omnis-voluptatibus.com"
|
93
|
+
|
94
|
+
|
95
|
+
All of the original methods will also be available to the Seeder module:
|
96
|
+
|
97
|
+
$ Seeder.words
|
98
|
+
=> ["est", "fugiat", "possimus", "non", "labore", "magnam"]
|
99
|
+
|
100
|
+
|
101
|
+
You can use a helper module like Seeder in any app and put it anywhere. In rails, I like to keep it in `db/seeder.rb`.
|
102
|
+
|
103
|
+
|
35
104
|
|
36
105
|
Installation
|
37
106
|
------------
|
@@ -42,7 +111,7 @@ As usual, just use the `gem install` command:
|
|
42
111
|
|
43
112
|
Or add wordy as a gem in your Gemfile:
|
44
113
|
|
45
|
-
gem 'wordy', '~> 0.
|
114
|
+
gem 'wordy', '~> 0.2.0'
|
46
115
|
|
47
116
|
Then run `bundle install`
|
48
117
|
|
@@ -50,7 +119,7 @@ Then run `bundle install`
|
|
50
119
|
Requirements
|
51
120
|
------------
|
52
121
|
|
53
|
-
Wordy has zero dependencies! All it requires is Ruby >= 1.9.
|
122
|
+
Other than rake and bundler for development, Wordy has zero gem dependencies! All it requires is Ruby >= 1.9.2.
|
54
123
|
|
55
124
|
|
56
125
|
Testing
|
@@ -58,7 +127,8 @@ Testing
|
|
58
127
|
|
59
128
|
Testing is done with minitest. Run the tests with:
|
60
129
|
|
61
|
-
|
130
|
+
rake
|
131
|
+
|
62
132
|
|
63
133
|
|
64
134
|
License
|
data/Rakefile
CHANGED
data/lib/wordy/version.rb
CHANGED
data/test/test_wordy.rb
CHANGED
@@ -11,32 +11,84 @@ class TestWordy < MiniTest::Unit::TestCase
|
|
11
11
|
assert_equal Array, Wordy::WORDS.class
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
14
|
+
def test_single_word_has_no_spaces
|
15
15
|
refute_match /\s/, Wordy.word
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
|
+
def test_single_word_is_string
|
19
|
+
assert_equal String, Wordy.word.class
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_single_word_is_not_blank
|
23
|
+
assert 1 < Wordy.word.length
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_single_word_is_random
|
27
|
+
assert Wordy.word != Wordy.word
|
28
|
+
end
|
29
|
+
|
18
30
|
def test_words
|
19
31
|
assert_equal Array, Wordy.words.class
|
20
32
|
end
|
33
|
+
|
34
|
+
def test_words_contain_strings
|
35
|
+
assert_equal String, Wordy.words.first.class
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_words_are_random
|
39
|
+
assert Wordy.words != Wordy.words
|
40
|
+
end
|
21
41
|
|
22
|
-
def
|
42
|
+
def test_sentence
|
23
43
|
assert_match /^[A-Z].*\.$/, Wordy.sentence
|
24
44
|
end
|
25
|
-
|
45
|
+
|
46
|
+
def test_sentence_has_length
|
47
|
+
assert 5 < Wordy.sentence.length
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_sentence_is_random
|
51
|
+
assert Wordy.sentence != Wordy.sentence
|
52
|
+
end
|
53
|
+
|
26
54
|
def test_sentences
|
27
55
|
assert_equal Array, Wordy.sentences.class
|
28
56
|
end
|
57
|
+
|
58
|
+
def test_sentences_contain_strings
|
59
|
+
assert_equal String, Wordy.sentences.first.class
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_sentences_are_random
|
63
|
+
assert Wordy.sentences != Wordy.sentences
|
64
|
+
end
|
29
65
|
|
30
66
|
def test_paragraph
|
31
67
|
assert_match /^([A-Z][a-z\s]+\.\s?){2,}$/, Wordy.paragraph
|
32
68
|
end
|
33
69
|
|
70
|
+
def test_paragraph_is_random
|
71
|
+
assert Wordy.paragraph != Wordy.paragraph
|
72
|
+
end
|
73
|
+
|
34
74
|
def test_paragraphs
|
35
75
|
assert_equal Array, Wordy.paragraphs.class
|
36
76
|
end
|
37
77
|
|
78
|
+
def test_paragraphs_contain_strings
|
79
|
+
assert_equal String, Wordy.paragraphs.first.class
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_paragraphs_are_random
|
83
|
+
assert Wordy.paragraphs != Wordy.paragraphs
|
84
|
+
end
|
85
|
+
|
38
86
|
def test_body
|
39
87
|
assert_match /^([A-Z][a-z\s]+\.\s?){2,}$/, Wordy.body
|
40
88
|
end
|
41
89
|
|
90
|
+
def test_body_is_random
|
91
|
+
assert Wordy.body != Wordy.body
|
92
|
+
end
|
93
|
+
|
42
94
|
end
|
data/wordy.gemspec
CHANGED
@@ -9,8 +9,8 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.authors = ["Spencer Steffen"]
|
10
10
|
s.email = ["spencer@citrusme.com"]
|
11
11
|
s.homepage = "https://github.com/citrus/wordy"
|
12
|
-
s.summary = %q{Wordy speaks lorem ipsum. You can ask Wordy for
|
13
|
-
s.description = %q{Wordy speaks lorem ipsum. You can ask Wordy for
|
12
|
+
s.summary = %q{Written to help us create sample data for our applications, Wordy speaks in lorem ipsum. You can ask Wordy for paragraphs, sentences or words.}
|
13
|
+
s.description = %q{Written to help us create sample data for our applications, Wordy speaks in lorem ipsum. You can ask Wordy for paragraphs, sentences or words. Please see documentation for more information.}
|
14
14
|
|
15
15
|
s.rubyforge_project = "wordy"
|
16
16
|
|
@@ -21,4 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
22
22
|
s.require_paths = ["lib"]
|
23
23
|
|
24
|
+
s.add_development_dependency("bundler", ">= 0")
|
25
|
+
s.add_development_dependency("rake", ">= 0")
|
26
|
+
|
24
27
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: wordy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version:
|
5
|
+
version: 1.0.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Spencer Steffen
|
@@ -10,10 +10,31 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
14
|
-
dependencies:
|
15
|
-
|
16
|
-
|
13
|
+
date: 2011-11-05 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: bundler
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
type: :development
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: rake
|
28
|
+
prerelease: false
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: "0"
|
35
|
+
type: :development
|
36
|
+
version_requirements: *id002
|
37
|
+
description: Written to help us create sample data for our applications, Wordy speaks in lorem ipsum. You can ask Wordy for paragraphs, sentences or words. Please see documentation for more information.
|
17
38
|
email:
|
18
39
|
- spencer@citrusme.com
|
19
40
|
executables: []
|
@@ -59,6 +80,6 @@ rubyforge_project: wordy
|
|
59
80
|
rubygems_version: 1.8.10
|
60
81
|
signing_key:
|
61
82
|
specification_version: 3
|
62
|
-
summary: Wordy speaks lorem ipsum. You can ask Wordy for
|
83
|
+
summary: Written to help us create sample data for our applications, Wordy speaks in lorem ipsum. You can ask Wordy for paragraphs, sentences or words.
|
63
84
|
test_files:
|
64
85
|
- test/test_wordy.rb
|