henrietta_pussycat 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ coverage
2
+ pkg
data/Rakefile ADDED
@@ -0,0 +1,32 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rcov/rcovtask'
4
+
5
+ begin
6
+ require 'jeweler'
7
+ Jeweler::Tasks.new do |s|
8
+ s.name = "henrietta_pussycat"
9
+ s.summary = "Replaces words with 'meow' in strings in different ways"
10
+ s.email = "erica.kwan@gmail.com"
11
+ s.homepage = "http://github.com/pui/henrietta_pussycat"
12
+ s.description = "Replaces words with 'meow' in strings in different ways"
13
+ s.authors = ["Erica Kwan"]
14
+ end
15
+ Jeweler::GemcutterTasks.new
16
+ rescue LoadError
17
+ puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
18
+ end
19
+
20
+ Rake::TestTask.new do |t|
21
+ t.libs << 'lib'
22
+ t.pattern = 'test/**/*_test.rb'
23
+ t.verbose = false
24
+ end
25
+
26
+ Rcov::RcovTask.new do |t|
27
+ t.libs << "test"
28
+ t.test_files = FileList['test/*_test.rb']
29
+ t.verbose = true
30
+ end
31
+
32
+ task :default => :test
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.1
@@ -0,0 +1,45 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{henrietta_pussycat}
8
+ s.version = "0.1.1"
9
+
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-05}
13
+ s.description = %q{Replaces words with 'meow' in strings in different ways}
14
+ s.email = %q{erica.kwan@gmail.com}
15
+ s.files = [
16
+ ".gitignore",
17
+ "Rakefile",
18
+ "VERSION",
19
+ "henrietta_pussycat.gemspec",
20
+ "lib/henrietta_pussycat.rb",
21
+ "lib/henrietta_pussycat/meow.rb",
22
+ "readme.rdoc",
23
+ "test/meow_test.rb",
24
+ "test/test_helper.rb"
25
+ ]
26
+ s.homepage = %q{http://github.com/pui/henrietta_pussycat}
27
+ s.rdoc_options = ["--charset=UTF-8"]
28
+ s.require_paths = ["lib"]
29
+ s.rubygems_version = %q{1.3.5}
30
+ s.summary = %q{Replaces words with 'meow' in strings in different ways}
31
+ s.test_files = [
32
+ "test/meow_test.rb",
33
+ "test/test_helper.rb"
34
+ ]
35
+
36
+ if s.respond_to? :specification_version then
37
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
38
+ s.specification_version = 3
39
+
40
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
41
+ else
42
+ end
43
+ else
44
+ end
45
+ end
@@ -0,0 +1,22 @@
1
+ module HenriettaPussycat
2
+ class Meow
3
+ def self.random_meow_insert(sentence)
4
+ pick_string = sentence.gsub(/[^\w]/i, "")
5
+ index = rand(pick_string.length - 1)
6
+ substitute_character = pick_string[index..index]
7
+ sentence.gsub(/\b\w*#{substitute_character}\w*\b/i, "meow")
8
+ end
9
+
10
+ # TODO: Do not replace Mr. Rogers
11
+ def self.classic_meow_insert(sentence)
12
+ mod_sentence = String.new(sentence)
13
+ sentence.scan(/\w+\'*\w*/) do |word|
14
+ unless word.match(/\bbeautiful\b|\btelephone\b/i)
15
+ mod_sentence.gsub!(/\b#{word}\b/, "meow")
16
+ end
17
+ end
18
+ mod_sentence
19
+ end
20
+ end
21
+ end
22
+
@@ -0,0 +1,10 @@
1
+ unless defined? HenriettaPussycat
2
+
3
+ $:.unshift File.dirname(__FILE__)
4
+ require 'henrietta_pussycat/meow'
5
+
6
+ module HenriettaPussycat
7
+ extend self
8
+ end
9
+
10
+ end
data/readme.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = Henrietta Pussycat
2
+
3
+ Gem for replacing words in a string with 'meow'. Not at all useful, but expresses my love for Mr. Rogers' Neighborhood.
data/test/meow_test.rb ADDED
@@ -0,0 +1,38 @@
1
+ require File.dirname(__FILE__) + '/test_helper'
2
+
3
+ include HenriettaPussycat
4
+
5
+ class MeowTest < Test::Unit::TestCase
6
+
7
+ context "Using Meow" do
8
+
9
+ context "random_meow_insert" do
10
+ should "return an empty string if an empty string is passed" do
11
+ sentence = Meow.random_meow_insert(" ")
12
+ assert sentence.strip.empty?
13
+ end
14
+
15
+ should "replace words in a string randomly with meows" do
16
+ sentence = Meow.random_meow_insert("It's a beautiful day in the neighborhood, a beautiful day in the neighborhood.")
17
+ assert sentence.include?("meow")
18
+ end
19
+ end
20
+
21
+ context "classic_meow_insert" do
22
+ should "return an empty string if an empty string is passed" do
23
+ sentence = Meow.classic_meow_insert(" ")
24
+ assert sentence.strip.empty?
25
+ end
26
+
27
+ should "replace all words in a string with meows when the word is not 'beautiful' or 'telephone'" do
28
+ sentence = Meow.classic_meow_insert("It's a beautiful day in the neighborhood, a beautiful day in the neighborhood. Telephone!")
29
+ assert sentence == "meow meow beautiful meow meow meow meow, meow beautiful meow meow meow meow. Telephone!"
30
+ end
31
+
32
+ should "return a sentence full of meows when 'beautiful' and 'telephone' are not present" do
33
+ sentence = Meow.classic_meow_insert("Beautifully designed spoons, cups and forks.")
34
+ assert sentence == "meow meow meow, meow meow meow."
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,8 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ require File.dirname(__FILE__) + '/../lib/henrietta_pussycat'
6
+
7
+ class Test::Unit::TestCase
8
+ end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: henrietta_pussycat
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - Erica Kwan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-12-05 00:00:00 -08:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Replaces words with 'meow' in strings in different ways
17
+ email: erica.kwan@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - .gitignore
26
+ - Rakefile
27
+ - VERSION
28
+ - henrietta_pussycat.gemspec
29
+ - lib/henrietta_pussycat.rb
30
+ - lib/henrietta_pussycat/meow.rb
31
+ - readme.rdoc
32
+ - test/meow_test.rb
33
+ - test/test_helper.rb
34
+ has_rdoc: true
35
+ homepage: http://github.com/pui/henrietta_pussycat
36
+ licenses: []
37
+
38
+ post_install_message:
39
+ rdoc_options:
40
+ - --charset=UTF-8
41
+ require_paths:
42
+ - lib
43
+ required_ruby_version: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: "0"
48
+ version:
49
+ required_rubygems_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ version:
55
+ requirements: []
56
+
57
+ rubyforge_project:
58
+ rubygems_version: 1.3.5
59
+ signing_key:
60
+ specification_version: 3
61
+ summary: Replaces words with 'meow' in strings in different ways
62
+ test_files:
63
+ - test/meow_test.rb
64
+ - test/test_helper.rb