randomizer 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +1 -0
- data/LICENSE +20 -0
- data/README.rdoc +30 -32
- data/Rakefile +57 -27
- data/VERSION +1 -0
- data/data/female_first_names.txt +564 -0
- data/data/last_names.txt +2999 -0
- data/data/male_first_names.txt +564 -0
- data/data/text/aesop.txt +4776 -0
- data/data/text/alice_in_wonderland.txt +3718 -0
- data/data/text/lorem_ipsum.txt +99 -0
- data/data/text/the_adventures_of_sherlock_holmes.txt +12987 -0
- data/features/randomizer.feature +9 -0
- data/features/step_definitions/randomizer_steps.rb +0 -0
- data/features/support/env.rb +3 -13
- data/lib/randomizer.rb +5 -11
- data/lib/randomizer/all_avatars_site.rb +37 -0
- data/lib/randomizer/markov_text_generator.rb +73 -0
- data/lib/randomizer/name_generator.rb +34 -0
- data/lib/randomizer/random_user.rb +74 -0
- data/randomizer.gemspec +71 -0
- data/spec/randomizer_spec.rb +4 -8
- data/spec/spec.opts +1 -1
- data/spec/spec_helper.rb +8 -9
- metadata +43 -29
- data/History.txt +0 -4
- data/Manifest.txt +0 -18
- data/PostInstall.txt +0 -7
- data/features/development.feature +0 -13
- data/features/step_definitions/common_steps.rb +0 -163
- data/features/support/common.rb +0 -29
- data/features/support/matchers.rb +0 -11
- data/script/console +0 -10
- data/script/destroy +0 -14
- data/script/generate +0 -14
- data/tasks/rspec.rake +0 -21
data/History.txt
DELETED
data/Manifest.txt
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
History.txt
|
2
|
-
Manifest.txt
|
3
|
-
PostInstall.txt
|
4
|
-
README.rdoc
|
5
|
-
Rakefile
|
6
|
-
features/development.feature
|
7
|
-
features/step_definitions/common_steps.rb
|
8
|
-
features/support/common.rb
|
9
|
-
features/support/env.rb
|
10
|
-
features/support/matchers.rb
|
11
|
-
lib/randomizer.rb
|
12
|
-
script/console
|
13
|
-
script/destroy
|
14
|
-
script/generate
|
15
|
-
spec/randomizer_spec.rb
|
16
|
-
spec/spec.opts
|
17
|
-
spec/spec_helper.rb
|
18
|
-
tasks/rspec.rake
|
data/PostInstall.txt
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
Feature: Development processes of newgem itself (rake tasks)
|
2
|
-
|
3
|
-
As a Newgem maintainer or contributor
|
4
|
-
I want rake tasks to maintain and release the gem
|
5
|
-
So that I can spend time on the tests and code, and not excessive time on maintenance processes
|
6
|
-
|
7
|
-
Scenario: Generate RubyGem
|
8
|
-
Given this project is active project folder
|
9
|
-
And "pkg" folder is deleted
|
10
|
-
When I invoke task "rake gem"
|
11
|
-
Then folder "pkg" is created
|
12
|
-
And file with name matching "pkg/*.gem" is created else you should run "rake manifest" to fix this
|
13
|
-
And gem spec key "rdoc_options" contains /--mainREADME.rdoc/
|
@@ -1,163 +0,0 @@
|
|
1
|
-
Given /^this project is active project folder/ do
|
2
|
-
@active_project_folder = File.expand_path(File.dirname(__FILE__) + "/../..")
|
3
|
-
end
|
4
|
-
|
5
|
-
Given /^env variable \$([\w_]+) set to "(.*)"/ do |env_var, value|
|
6
|
-
ENV[env_var] = value
|
7
|
-
end
|
8
|
-
|
9
|
-
Given /"(.*)" folder is deleted/ do |folder|
|
10
|
-
in_project_folder { FileUtils.rm_rf folder }
|
11
|
-
end
|
12
|
-
|
13
|
-
When /^I invoke "(.*)" generator with arguments "(.*)"$/ do |generator, arguments|
|
14
|
-
@stdout = StringIO.new
|
15
|
-
in_project_folder do
|
16
|
-
if Object.const_defined?("APP_ROOT")
|
17
|
-
APP_ROOT.replace(FileUtils.pwd)
|
18
|
-
else
|
19
|
-
APP_ROOT = FileUtils.pwd
|
20
|
-
end
|
21
|
-
run_generator(generator, arguments.split(' '), SOURCES, :stdout => @stdout)
|
22
|
-
end
|
23
|
-
File.open(File.join(@tmp_root, "generator.out"), "w") do |f|
|
24
|
-
@stdout.rewind
|
25
|
-
f << @stdout.read
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
When /^I run executable "(.*)" with arguments "(.*)"/ do |executable, arguments|
|
30
|
-
@stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
|
31
|
-
in_project_folder do
|
32
|
-
system "#{executable} #{arguments} > #{@stdout} 2> #{@stdout}"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
When /^I run project executable "(.*)" with arguments "(.*)"/ do |executable, arguments|
|
37
|
-
@stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
|
38
|
-
in_project_folder do
|
39
|
-
system "ruby #{executable} #{arguments} > #{@stdout} 2> #{@stdout}"
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
When /^I run local executable "(.*)" with arguments "(.*)"/ do |executable, arguments|
|
44
|
-
@stdout = File.expand_path(File.join(@tmp_root, "executable.out"))
|
45
|
-
executable = File.expand_path(File.join(File.dirname(__FILE__), "/../../bin", executable))
|
46
|
-
in_project_folder do
|
47
|
-
system "ruby #{executable} #{arguments} > #{@stdout} 2> #{@stdout}"
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
When /^I invoke task "rake (.*)"/ do |task|
|
52
|
-
@stdout = File.expand_path(File.join(@tmp_root, "tests.out"))
|
53
|
-
in_project_folder do
|
54
|
-
system "rake #{task} --trace > #{@stdout} 2> #{@stdout}"
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
Then /^folder "(.*)" (is|is not) created/ do |folder, is|
|
59
|
-
in_project_folder do
|
60
|
-
File.exists?(folder).should(is == 'is' ? be_true : be_false)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
Then /^file "(.*)" (is|is not) created/ do |file, is|
|
65
|
-
in_project_folder do
|
66
|
-
File.exists?(file).should(is == 'is' ? be_true : be_false)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
Then /^file with name matching "(.*)" is created/ do |pattern|
|
71
|
-
in_project_folder do
|
72
|
-
Dir[pattern].should_not be_empty
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
Then /^file "(.*)" contents (does|does not) match \/(.*)\// do |file, does, regex|
|
77
|
-
in_project_folder do
|
78
|
-
actual_output = File.read(file)
|
79
|
-
(does == 'does') ?
|
80
|
-
actual_output.should(match(/#{regex}/)) :
|
81
|
-
actual_output.should_not(match(/#{regex}/))
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
Then /gem file "(.*)" and generated file "(.*)" should be the same/ do |gem_file, project_file|
|
86
|
-
File.exists?(gem_file).should be_true
|
87
|
-
File.exists?(project_file).should be_true
|
88
|
-
gem_file_contents = File.read(File.dirname(__FILE__) + "/../../#{gem_file}")
|
89
|
-
project_file_contents = File.read(File.join(@active_project_folder, project_file))
|
90
|
-
project_file_contents.should == gem_file_contents
|
91
|
-
end
|
92
|
-
|
93
|
-
Then /^(does|does not) invoke generator "(.*)"$/ do |does_invoke, generator|
|
94
|
-
actual_output = File.read(@stdout)
|
95
|
-
does_invoke == "does" ?
|
96
|
-
actual_output.should(match(/dependency\s+#{generator}/)) :
|
97
|
-
actual_output.should_not(match(/dependency\s+#{generator}/))
|
98
|
-
end
|
99
|
-
|
100
|
-
Then /help options "(.*)" and "(.*)" are displayed/ do |opt1, opt2|
|
101
|
-
actual_output = File.read(@stdout)
|
102
|
-
actual_output.should match(/#{opt1}/)
|
103
|
-
actual_output.should match(/#{opt2}/)
|
104
|
-
end
|
105
|
-
|
106
|
-
Then /^I should see$/ do |text|
|
107
|
-
actual_output = File.read(@stdout)
|
108
|
-
actual_output.should contain(text)
|
109
|
-
end
|
110
|
-
|
111
|
-
Then /^I should not see$/ do |text|
|
112
|
-
actual_output = File.read(@stdout)
|
113
|
-
actual_output.should_not contain(text)
|
114
|
-
end
|
115
|
-
|
116
|
-
Then /^I should see exactly$/ do |text|
|
117
|
-
actual_output = File.read(@stdout)
|
118
|
-
actual_output.should == text
|
119
|
-
end
|
120
|
-
|
121
|
-
Then /^I should see all (\d+) tests pass/ do |expected_test_count|
|
122
|
-
expected = %r{^#{expected_test_count} tests, \d+ assertions, 0 failures, 0 errors}
|
123
|
-
actual_output = File.read(@stdout)
|
124
|
-
actual_output.should match(expected)
|
125
|
-
end
|
126
|
-
|
127
|
-
Then /^I should see all (\d+) examples pass/ do |expected_test_count|
|
128
|
-
expected = %r{^#{expected_test_count} examples?, 0 failures}
|
129
|
-
actual_output = File.read(@stdout)
|
130
|
-
actual_output.should match(expected)
|
131
|
-
end
|
132
|
-
|
133
|
-
Then /^yaml file "(.*)" contains (\{.*\})/ do |file, yaml|
|
134
|
-
in_project_folder do
|
135
|
-
yaml = eval yaml
|
136
|
-
YAML.load(File.read(file)).should == yaml
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
Then /^Rakefile can display tasks successfully/ do
|
141
|
-
@stdout = File.expand_path(File.join(@tmp_root, "rakefile.out"))
|
142
|
-
in_project_folder do
|
143
|
-
system "rake -T > #{@stdout} 2> #{@stdout}"
|
144
|
-
end
|
145
|
-
actual_output = File.read(@stdout)
|
146
|
-
actual_output.should match(/^rake\s+\w+\s+#\s.*/)
|
147
|
-
end
|
148
|
-
|
149
|
-
Then /^task "rake (.*)" is executed successfully/ do |task|
|
150
|
-
@stdout.should_not be_nil
|
151
|
-
actual_output = File.read(@stdout)
|
152
|
-
actual_output.should_not match(/^Don't know how to build task '#{task}'/)
|
153
|
-
actual_output.should_not match(/Error/i)
|
154
|
-
end
|
155
|
-
|
156
|
-
Then /^gem spec key "(.*)" contains \/(.*)\// do |key, regex|
|
157
|
-
in_project_folder do
|
158
|
-
gem_file = Dir["pkg/*.gem"].first
|
159
|
-
gem_spec = Gem::Specification.from_yaml(`gem spec #{gem_file}`)
|
160
|
-
spec_value = gem_spec.send(key.to_sym)
|
161
|
-
spec_value.to_s.should match(/#{regex}/)
|
162
|
-
end
|
163
|
-
end
|
data/features/support/common.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
module CommonHelpers
|
2
|
-
def in_tmp_folder(&block)
|
3
|
-
FileUtils.chdir(@tmp_root, &block)
|
4
|
-
end
|
5
|
-
|
6
|
-
def in_project_folder(&block)
|
7
|
-
project_folder = @active_project_folder || @tmp_root
|
8
|
-
FileUtils.chdir(project_folder, &block)
|
9
|
-
end
|
10
|
-
|
11
|
-
def in_home_folder(&block)
|
12
|
-
FileUtils.chdir(@home_path, &block)
|
13
|
-
end
|
14
|
-
|
15
|
-
def force_local_lib_override(project_name = @project_name)
|
16
|
-
rakefile = File.read(File.join(project_name, 'Rakefile'))
|
17
|
-
File.open(File.join(project_name, 'Rakefile'), "w+") do |f|
|
18
|
-
f << "$:.unshift('#{@lib_path}')\n"
|
19
|
-
f << rakefile
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def setup_active_project_folder project_name
|
24
|
-
@active_project_folder = File.join(@tmp_root, project_name)
|
25
|
-
@project_name = project_name
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
World(CommonHelpers)
|
@@ -1,11 +0,0 @@
|
|
1
|
-
module Matchers
|
2
|
-
def contain(expected)
|
3
|
-
simple_matcher("contain #{expected.inspect}") do |given, matcher|
|
4
|
-
matcher.failure_message = "expected #{given.inspect} to contain #{expected.inspect}"
|
5
|
-
matcher.negative_failure_message = "expected #{given.inspect} not to contain #{expected.inspect}"
|
6
|
-
given.index expected
|
7
|
-
end
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
World(Matchers)
|
data/script/console
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# File: script/console
|
3
|
-
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
4
|
-
|
5
|
-
libs = " -r irb/completion"
|
6
|
-
# Perhaps use a console_lib to store any extra methods I may want available in the console
|
7
|
-
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
8
|
-
libs << " -r #{File.dirname(__FILE__) + '/../lib/randomizer.rb'}"
|
9
|
-
puts "Loading randomizer gem"
|
10
|
-
exec "#{irb} #{libs} --simple-prompt"
|
data/script/destroy
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'rubigen'
|
6
|
-
rescue LoadError
|
7
|
-
require 'rubygems'
|
8
|
-
require 'rubigen'
|
9
|
-
end
|
10
|
-
require 'rubigen/scripts/destroy'
|
11
|
-
|
12
|
-
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
-
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
-
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'rubigen'
|
6
|
-
rescue LoadError
|
7
|
-
require 'rubygems'
|
8
|
-
require 'rubigen'
|
9
|
-
end
|
10
|
-
require 'rubigen/scripts/generate'
|
11
|
-
|
12
|
-
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
-
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
-
RubiGen::Scripts::Generate.new.run(ARGV)
|
data/tasks/rspec.rake
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
begin
|
2
|
-
require 'spec'
|
3
|
-
rescue LoadError
|
4
|
-
require 'rubygems' unless ENV['NO_RUBYGEMS']
|
5
|
-
require 'spec'
|
6
|
-
end
|
7
|
-
begin
|
8
|
-
require 'spec/rake/spectask'
|
9
|
-
rescue LoadError
|
10
|
-
puts <<-EOS
|
11
|
-
To use rspec for testing you must install rspec gem:
|
12
|
-
gem install rspec
|
13
|
-
EOS
|
14
|
-
exit(0)
|
15
|
-
end
|
16
|
-
|
17
|
-
desc "Run the specs under spec/models"
|
18
|
-
Spec::Rake::SpecTask.new do |t|
|
19
|
-
t.spec_opts = ['--options', "spec/spec.opts"]
|
20
|
-
t.spec_files = FileList['spec/**/*_spec.rb']
|
21
|
-
end
|