random_phrase 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/Rakefile +1 -0
- data/lib/random_phrase.rb +16 -0
- data/lib/random_phrase/config/words +6 -0
- data/lib/random_phrase/core_ext/array.rb +5 -0
- data/lib/random_phrase/dictionary.rb +14 -0
- data/lib/random_phrase/version.rb +3 -0
- data/random_phrase.gemspec +24 -0
- data/spec/lib/core_ext/array_spec.rb +15 -0
- data/spec/lib/dictionary_spec.rb +21 -0
- data/spec/lib/random_phrase_spec.rb +28 -0
- data/spec/spec_helper.rb +2 -0
- metadata +76 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "random_phrase/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "random_phrase"
|
7
|
+
s.version = RandomPhrase::VERSION
|
8
|
+
s.authors = ["Yosem Sweet"]
|
9
|
+
s.email = ["yosem.sweet@suite101.com"]
|
10
|
+
s.homepage = "https://github.com/yosemsweet/random_phrase"
|
11
|
+
s.summary = %q{Generate a simple random phrase}
|
12
|
+
s.description = %q{This gem provides random phrase functionality and extends Array with a random .pick}
|
13
|
+
|
14
|
+
s.rubyforge_project = "random_phrase"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
s.add_development_dependency "rspec"
|
23
|
+
# s.add_runtime_dependency "rest-client"
|
24
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Array do
|
4
|
+
context "#pick" do
|
5
|
+
it "should respond to pick" do
|
6
|
+
[].should respond_to(:pick)
|
7
|
+
end
|
8
|
+
|
9
|
+
it "should return a random element" do
|
10
|
+
a = [1,2,3,4,5,6,7,8,9,10]
|
11
|
+
a.pick.should_not == a.pick
|
12
|
+
a.find_index(a.pick).should_not be_nil
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe RandomPhrase::Dictionary do
|
4
|
+
context "module methods" do
|
5
|
+
context "::load" do
|
6
|
+
it "should respond to load" do
|
7
|
+
RandomPhrase::Dictionary.should respond_to(:load)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
context "::word" do
|
12
|
+
it "should respond to words" do
|
13
|
+
RandomPhrase::Dictionary.should respond_to(:words)
|
14
|
+
end
|
15
|
+
|
16
|
+
it "should return an array" do
|
17
|
+
RandomPhrase::Dictionary.words.should be_kind_of(Array)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe RandomPhrase do
|
4
|
+
context "module methods" do
|
5
|
+
it "should respond to phrase an optional word count" do
|
6
|
+
RandomPhrase.should respond_to(:phrase)
|
7
|
+
RandomPhrase.should respond_to(:phrase).with(1)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should return a string" do
|
11
|
+
RandomPhrase.phrase.should be_kind_of(String)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should default to 1 word" do
|
15
|
+
RandomPhrase.phrase.split.count.should == 1
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should return as many words as are asked for" do
|
19
|
+
RandomPhrase.phrase(2).split.count.should == 2
|
20
|
+
RandomPhrase.phrase(3).split.count.should == 3
|
21
|
+
RandomPhrase.phrase(10).split.count.should == 10
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should return different phrases on successive calls" do
|
25
|
+
RandomPhrase.phrase.should_not == RandomPhrase.phrase
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: random_phrase
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Yosem Sweet
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-09-30 00:00:00.000000000 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
requirement: &2156608540 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *2156608540
|
26
|
+
description: This gem provides random phrase functionality and extends Array with
|
27
|
+
a random .pick
|
28
|
+
email:
|
29
|
+
- yosem.sweet@suite101.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- .gitignore
|
35
|
+
- Gemfile
|
36
|
+
- Rakefile
|
37
|
+
- lib/random_phrase.rb
|
38
|
+
- lib/random_phrase/config/words
|
39
|
+
- lib/random_phrase/core_ext/array.rb
|
40
|
+
- lib/random_phrase/dictionary.rb
|
41
|
+
- lib/random_phrase/version.rb
|
42
|
+
- random_phrase.gemspec
|
43
|
+
- spec/lib/core_ext/array_spec.rb
|
44
|
+
- spec/lib/dictionary_spec.rb
|
45
|
+
- spec/lib/random_phrase_spec.rb
|
46
|
+
- spec/spec_helper.rb
|
47
|
+
has_rdoc: true
|
48
|
+
homepage: https://github.com/yosemsweet/random_phrase
|
49
|
+
licenses: []
|
50
|
+
post_install_message:
|
51
|
+
rdoc_options: []
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ! '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
requirements: []
|
67
|
+
rubyforge_project: random_phrase
|
68
|
+
rubygems_version: 1.6.2
|
69
|
+
signing_key:
|
70
|
+
specification_version: 3
|
71
|
+
summary: Generate a simple random phrase
|
72
|
+
test_files:
|
73
|
+
- spec/lib/core_ext/array_spec.rb
|
74
|
+
- spec/lib/dictionary_spec.rb
|
75
|
+
- spec/lib/random_phrase_spec.rb
|
76
|
+
- spec/spec_helper.rb
|