henrietta_pussycat 0.1.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +13 -7
- data/VERSION +1 -1
- data/henrietta_pussycat.gemspec +6 -3
- data/lib/henrietta_pussycat/meow.rb +15 -10
- data/test/meow_test.rb +9 -7
- metadata +14 -4
data/Rakefile
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'rake'
|
2
2
|
require 'rake/testtask'
|
3
|
-
require 'rcov/rcovtask'
|
4
3
|
|
5
4
|
begin
|
6
5
|
require 'jeweler'
|
@@ -10,11 +9,12 @@ begin
|
|
10
9
|
s.email = "erica.kwan@gmail.com"
|
11
10
|
s.homepage = "http://github.com/pui/henrietta_pussycat"
|
12
11
|
s.description = "Replaces words with 'meow' in strings in different ways"
|
13
|
-
s.authors = ["Erica Kwan"]
|
12
|
+
s.authors = ["Erica Kwan", "Jacob Vorreuter"]
|
13
|
+
s.add_development_dependency "shoulda", ">= 2.10"
|
14
14
|
end
|
15
15
|
Jeweler::GemcutterTasks.new
|
16
16
|
rescue LoadError
|
17
|
-
puts "Jeweler, or one of its dependencies, is not available. Install it with:
|
17
|
+
puts "Jeweler, or one of its dependencies, is not available. Install it with: gem install jeweler"
|
18
18
|
end
|
19
19
|
|
20
20
|
Rake::TestTask.new do |t|
|
@@ -22,11 +22,17 @@ Rake::TestTask.new do |t|
|
|
22
22
|
t.pattern = 'test/**/*_test.rb'
|
23
23
|
t.verbose = false
|
24
24
|
end
|
25
|
+
task :test => :check_dependencies
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
27
|
+
begin
|
28
|
+
require 'rcov/rcovtask'
|
29
|
+
Rcov::RcovTask.new do |t|
|
30
|
+
t.libs << "test"
|
31
|
+
t.test_files = FileList['test/*_test.rb']
|
32
|
+
t.verbose = true
|
33
|
+
end
|
34
|
+
rescue LoadError
|
35
|
+
puts "RCov is not installed. Install it with: gem install rcov"
|
30
36
|
end
|
31
37
|
|
32
38
|
task :default => :test
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
1.0.0
|
data/henrietta_pussycat.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{henrietta_pussycat}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "1.0.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Erica Kwan"]
|
12
|
-
s.date = %q{2009-12-
|
11
|
+
s.authors = ["Erica Kwan", "Jacob Vorreuter"]
|
12
|
+
s.date = %q{2009-12-23}
|
13
13
|
s.description = %q{Replaces words with 'meow' in strings in different ways}
|
14
14
|
s.email = %q{erica.kwan@gmail.com}
|
15
15
|
s.files = [
|
@@ -38,8 +38,11 @@ Gem::Specification.new do |s|
|
|
38
38
|
s.specification_version = 3
|
39
39
|
|
40
40
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
41
|
+
s.add_development_dependency(%q<shoulda>, [">= 2.10"])
|
41
42
|
else
|
43
|
+
s.add_dependency(%q<shoulda>, [">= 2.10"])
|
42
44
|
end
|
43
45
|
else
|
46
|
+
s.add_dependency(%q<shoulda>, [">= 2.10"])
|
44
47
|
end
|
45
48
|
end
|
@@ -6,17 +6,22 @@ module HenriettaPussycat
|
|
6
6
|
substitute_character = pick_string[index..index]
|
7
7
|
sentence.gsub(/\b\w*#{substitute_character}\w*\b/i, "meow")
|
8
8
|
end
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
9
|
+
|
10
|
+
def self.classic_meow_insert(sentence, word_array=['beautiful', 'telephone', 'Mr. Rogers'])
|
11
|
+
if word_array.size > 0
|
12
|
+
match_word = word_array.pop
|
13
|
+
chunks = sentence.split(/\b(#{match_word})\b/i)
|
14
|
+
chunks.map! do |chunk|
|
15
|
+
if chunk.match(/\b(#{match_word})\b/i)
|
16
|
+
chunk
|
17
|
+
else
|
18
|
+
classic_meow_insert(chunk, word_array.dup)
|
19
|
+
end
|
16
20
|
end
|
21
|
+
chunks.join("")
|
22
|
+
else
|
23
|
+
sentence.gsub(/\w+\'*\w*/, "meow")
|
17
24
|
end
|
18
|
-
mod_sentence
|
19
25
|
end
|
20
26
|
end
|
21
|
-
end
|
22
|
-
|
27
|
+
end
|
data/test/meow_test.rb
CHANGED
@@ -24,15 +24,17 @@ class MeowTest < Test::Unit::TestCase
|
|
24
24
|
assert sentence.strip.empty?
|
25
25
|
end
|
26
26
|
|
27
|
-
should "
|
28
|
-
sentence = Meow.classic_meow_insert("
|
29
|
-
|
27
|
+
should "return a sentence full of meows when 'beautiful', 'telephone' and 'Mr. Rogers' are not present" do
|
28
|
+
sentence = Meow.classic_meow_insert("Beautifully designed spoons, cups and forks.")
|
29
|
+
assert_equal "meow meow meow, meow meow meow.", sentence
|
30
30
|
end
|
31
31
|
|
32
|
-
should "
|
33
|
-
sentence = Meow.classic_meow_insert("
|
34
|
-
|
32
|
+
should "replace all words in a string with meows when the word is not 'beautiful', 'telephone' or 'Mr. Rogers'" do
|
33
|
+
sentence = Meow.classic_meow_insert("It's a beautiful day Mr. Rogers, in the neighborhood, a beautiful day in the neighborhood. Telephone!")
|
34
|
+
assert_equal "meow meow beautiful meow Mr. Rogers, meow meow meow, meow beautiful meow meow meow meow. Telephone!", sentence
|
35
35
|
end
|
36
36
|
end
|
37
|
+
|
37
38
|
end
|
38
|
-
|
39
|
+
|
40
|
+
end
|
metadata
CHANGED
@@ -1,18 +1,28 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: henrietta_pussycat
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erica Kwan
|
8
|
+
- Jacob Vorreuter
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
12
|
|
12
|
-
date: 2009-12-
|
13
|
+
date: 2009-12-23 00:00:00 -08:00
|
13
14
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: shoulda
|
18
|
+
type: :development
|
19
|
+
version_requirement:
|
20
|
+
version_requirements: !ruby/object:Gem::Requirement
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: "2.10"
|
25
|
+
version:
|
16
26
|
description: Replaces words with 'meow' in strings in different ways
|
17
27
|
email: erica.kwan@gmail.com
|
18
28
|
executables: []
|