wordy 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -0
- data/.travis.yml +4 -0
- data/Gemfile +2 -0
- data/LICENSE +27 -0
- data/README.md +67 -0
- data/Rakefile +1 -0
- data/lib/wordy/version.rb +3 -0
- data/lib/wordy.rb +45 -0
- data/test/test_wordy.rb +42 -0
- data/wordy.gemspec +24 -0
- metadata +64 -0
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
Copyright (c) 2011 Spencer Steffen and Citrus Media Group.
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without modification,
|
5
|
+
are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
* Redistributions of source code must retain the above copyright notice,
|
8
|
+
this list of conditions and the following disclaimer.
|
9
|
+
|
10
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
11
|
+
this list of conditions and the following disclaimer in the documentation
|
12
|
+
and/or other materials provided with the distribution.
|
13
|
+
|
14
|
+
* Neither the name of Citrus Media Group nor the names of its
|
15
|
+
contributors may be used to endorse or promote products derived from this
|
16
|
+
software without specific prior written permission.
|
17
|
+
|
18
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
19
|
+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
20
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
21
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
22
|
+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
23
|
+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
24
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
25
|
+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
26
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
27
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# Wordy [![Build Status](https://secure.travis-ci.org/citrus/wordy.png)](http://travis-ci.org/citrus/wordy)
|
2
|
+
|
3
|
+
Wordy speaks lorem ipsum. You can ask Wordy for a paragraphs, sentences or words.
|
4
|
+
|
5
|
+
|
6
|
+
Usage
|
7
|
+
-----
|
8
|
+
|
9
|
+
Using wordy is simple. Here's the rundown:
|
10
|
+
|
11
|
+
$ require 'wordy'
|
12
|
+
=> true
|
13
|
+
|
14
|
+
$ Wordy.word
|
15
|
+
=> "similique"
|
16
|
+
|
17
|
+
$ Wordy.words
|
18
|
+
=> ["nobis", "laborum", "commodi"]
|
19
|
+
|
20
|
+
$ Wordy.sentence
|
21
|
+
=> "Libero necessitatibus dolore et dicta."
|
22
|
+
|
23
|
+
$ Wordy.sentences
|
24
|
+
=> ["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."]
|
25
|
+
|
26
|
+
$ Wordy.paragraph
|
27
|
+
=> "Nihil aut voluptatem cupiditate ullam et dolores officia sunt fugit. Cupiditate unde deleniti dolore exercitationem repudiandae. Inventore consequatur optio blanditiis et nisi molestias impedit explicabo."
|
28
|
+
|
29
|
+
$ Wordy.paragraphs
|
30
|
+
=> ["Autem vel amet et eaque aperiam voluptas ullam dolorem consequuntur qui illo voluptatem recusandae. Ut enim similique impedit magni molestiae qui dolorem quas quis.", "Nobis et quo error ea porro quo odio. Voluptatem mollitia doloribus eum molestias sed ipsum qui omnis totam in autem explicabo cum.", "Quas corrupti voluptas cumque ea sed itaque. Vitae voluptatum porro ipsam quae libero sequi. Rerum aut unde aut omnis eum dolorem veritatis consequatur sint. Aliquid quibusdam ad qui vitae impedit est quas deserunt. Error tempora quo optio sit aliquam quis quod est quia numquam nisi. Sequi tenetur laudantium sed et et amet aut odit.", "Beatae et atque porro inventore quia repudiandae quibusdam praesentium qui. Fuga voluptas et et tempore velit est voluptatem nemo. Illum architecto voluptas ut nisi labore expedita ea et dicta qui unde cumque quia. Temporibus voluptas sunt tempore quis dolores assumenda ullam in. Quia iusto veniam asperiores quia odio id in omnis doloremque doloribus ea aut. Accusamus eveniet qui sint vel perspiciatis veritatis et."]
|
31
|
+
|
32
|
+
$ Wordy.body
|
33
|
+
=> "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
|
+
|
35
|
+
|
36
|
+
Installation
|
37
|
+
------------
|
38
|
+
|
39
|
+
As usual, just use the `gem install` command:
|
40
|
+
|
41
|
+
(sudo) gem install wordy
|
42
|
+
|
43
|
+
Or add wordy as a gem in your Gemfile:
|
44
|
+
|
45
|
+
gem 'wordy', '~> 0.1.0'
|
46
|
+
|
47
|
+
Then run `bundle install`
|
48
|
+
|
49
|
+
|
50
|
+
Requirements
|
51
|
+
------------
|
52
|
+
|
53
|
+
Wordy has zero dependencies! All it requires is Ruby >= 1.9.
|
54
|
+
|
55
|
+
|
56
|
+
Testing
|
57
|
+
-------
|
58
|
+
|
59
|
+
Testing is done with minitest. Run the tests with:
|
60
|
+
|
61
|
+
ruby -Ilib -Itest test/test_wordy.rb
|
62
|
+
|
63
|
+
|
64
|
+
License
|
65
|
+
-------
|
66
|
+
|
67
|
+
Copyright (c) 2011 Spencer Steffen & Citrus, released under the New BSD License All rights reserved.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/wordy.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require "wordy/version"
|
2
|
+
|
3
|
+
module Wordy
|
4
|
+
|
5
|
+
extend self
|
6
|
+
|
7
|
+
WORDS = %w(alias consequatur perferendis voluptatem accusantium doloremque aperiam eaque ipsa quae illo inventore veritatis quasi architecto beatae vitae dicta sunt explicabo aspernatur aut odit aut fugit sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt neque dolorem ipsum quia dolor sit amet consectetur adipisci velit sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem ut enim ad minima veniam quis nostrum exercitationem ullam corporis nemo enim ipsam voluptatem quia voluptas sit suscipit laboriosam nisi ut aliquid ex ea commodi consequatur quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae et iusto odio dignissimos ducimus qui blanditiis praesentium laudantium totam rem voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident sed ut perspiciatis unde omnis iste natus error similique sunt in culpa qui officia deserunt mollitia animi id est laborum et dolorum fuga et harum quidem rerum facilis est et expedita distinctio nam libero tempore cum soluta nobis est eligendi optio cumque nihil impedit quo porro quisquam est qui minus id quod maxime placeat facere possimus omnis voluptas assumenda est omnis dolor repellendus temporibus autem quibusdam et aut consequatur vel illum qui dolorem eum fugiat quo voluptas nulla pariatur accusamus officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint molestiae non recusandae itaque earum rerum tenetur sapiente delectus reiciendis voluptatibus maiores doloribus asperiores repellat)
|
8
|
+
|
9
|
+
def body(count=nil, sentence_count=nil, sentence_length=nil)
|
10
|
+
paragraphs(count, sentence_count, sentence_length).join("\n\n")
|
11
|
+
end
|
12
|
+
|
13
|
+
def paragraphs(count=nil, sentence_count=nil, sentence_length=nil)
|
14
|
+
count ||= 2 + rand(3)
|
15
|
+
Array.new(count) {|i|
|
16
|
+
i = paragraph(sentence_count)
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
def paragraph(sentence_count=nil, sentence_length=nil)
|
21
|
+
sentences(sentence_count, sentence_length).join(" ")
|
22
|
+
end
|
23
|
+
|
24
|
+
def sentences(sentence_count=nil, sentence_length=nil)
|
25
|
+
sentence_count ||= 2 + rand(5)
|
26
|
+
Array.new(sentence_count) {|i|
|
27
|
+
i = sentence(sentence_length)
|
28
|
+
}
|
29
|
+
end
|
30
|
+
|
31
|
+
def sentence(length=nil)
|
32
|
+
length ||= 5 + rand(10)
|
33
|
+
words(length).join(" ").capitalize + "."
|
34
|
+
end
|
35
|
+
|
36
|
+
def words(length=nil)
|
37
|
+
length ||= 2 + rand(5)
|
38
|
+
WORDS.shuffle.take(length)
|
39
|
+
end
|
40
|
+
|
41
|
+
def word
|
42
|
+
WORDS[rand(WORDS.length)]
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
data/test/test_wordy.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'wordy'
|
3
|
+
|
4
|
+
class TestWordy < MiniTest::Unit::TestCase
|
5
|
+
|
6
|
+
def test_has_version
|
7
|
+
assert_equal String, Wordy::VERSION.class
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_has_words
|
11
|
+
assert_equal Array, Wordy::WORDS.class
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_single_word
|
15
|
+
refute_match /\s/, Wordy.word
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_words
|
19
|
+
assert_equal Array, Wordy.words.class
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_sentance
|
23
|
+
assert_match /^[A-Z].*\.$/, Wordy.sentence
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_sentences
|
27
|
+
assert_equal Array, Wordy.sentences.class
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_paragraph
|
31
|
+
assert_match /^([A-Z][a-z\s]+\.\s?){2,}$/, Wordy.paragraph
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_paragraphs
|
35
|
+
assert_equal Array, Wordy.paragraphs.class
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_body
|
39
|
+
assert_match /^([A-Z][a-z\s]+\.\s?){2,}$/, Wordy.body
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
data/wordy.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "wordy/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
|
7
|
+
s.name = "wordy"
|
8
|
+
s.version = Wordy::VERSION
|
9
|
+
s.authors = ["Spencer Steffen"]
|
10
|
+
s.email = ["spencer@citrusme.com"]
|
11
|
+
s.homepage = "https://github.com/citrus/wordy"
|
12
|
+
s.summary = %q{Wordy speaks lorem ipsum. You can ask Wordy for a paragraphs, sentences or words.}
|
13
|
+
s.description = %q{Wordy speaks lorem ipsum. You can ask Wordy for a paragraphs, sentences or words. Please see readme for more information.}
|
14
|
+
|
15
|
+
s.rubyforge_project = "wordy"
|
16
|
+
|
17
|
+
s.required_ruby_version = ">= 1.9"
|
18
|
+
|
19
|
+
s.files = `git ls-files`.split("\n")
|
20
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
21
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
22
|
+
s.require_paths = ["lib"]
|
23
|
+
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: wordy
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.1.0
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Spencer Steffen
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-10-07 00:00:00 Z
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Wordy speaks lorem ipsum. You can ask Wordy for a paragraphs, sentences or words. Please see readme for more information.
|
17
|
+
email:
|
18
|
+
- spencer@citrusme.com
|
19
|
+
executables: []
|
20
|
+
|
21
|
+
extensions: []
|
22
|
+
|
23
|
+
extra_rdoc_files: []
|
24
|
+
|
25
|
+
files:
|
26
|
+
- .gitignore
|
27
|
+
- .travis.yml
|
28
|
+
- Gemfile
|
29
|
+
- LICENSE
|
30
|
+
- README.md
|
31
|
+
- Rakefile
|
32
|
+
- lib/wordy.rb
|
33
|
+
- lib/wordy/version.rb
|
34
|
+
- test/test_wordy.rb
|
35
|
+
- wordy.gemspec
|
36
|
+
homepage: https://github.com/citrus/wordy
|
37
|
+
licenses: []
|
38
|
+
|
39
|
+
post_install_message:
|
40
|
+
rdoc_options: []
|
41
|
+
|
42
|
+
require_paths:
|
43
|
+
- lib
|
44
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
45
|
+
none: false
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: "1.9"
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: "0"
|
56
|
+
requirements: []
|
57
|
+
|
58
|
+
rubyforge_project: wordy
|
59
|
+
rubygems_version: 1.8.10
|
60
|
+
signing_key:
|
61
|
+
specification_version: 3
|
62
|
+
summary: Wordy speaks lorem ipsum. You can ask Wordy for a paragraphs, sentences or words.
|
63
|
+
test_files:
|
64
|
+
- test/test_wordy.rb
|