car_to_cat 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 69e214fb51375409c2cb53a16a192d32e7762811
4
+ data.tar.gz: fdad1a69989f15859cbac7e51090b6aeef75465b
5
+ SHA512:
6
+ metadata.gz: dd1193f4e0349f0ca7567d7eb4f6056199a058205c0c8df971f9187a139c3cda4ed04336df4d160bdd4834a8639919c913e6c13e0a7fa57aa2b2c12e33cb3fab
7
+ data.tar.gz: ac4a9c44139e91f89ca924f5f0c87bd25b442c9aff0515ad5bda89a5d9fc95cf38f5a897516fd6ff5e14b3166b963d19cc3ff786515654290231687c2197b11c
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in car_to_cat.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Dan S Turner
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # CarToCat
2
+
3
+ This gem will change the word 'car' to 'cat' and also provide a CLI to run this conversion on files.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'car_to_cat'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install car_to_cat
18
+
19
+ ## Usage
20
+
21
+ TBD
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( https://github.com/DanSTurner/car_to_cat/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new
5
+
6
+ task :default => :spec
7
+ task :test => :spec
data/bin/car_to_cat ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
4
+ require "car_to_cat"
5
+
6
+ CarToCat::Cli.new.execute(ARGV)
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'car_to_cat/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "car_to_cat"
8
+ spec.version = CarToCat::VERSION
9
+ spec.authors = ["Dan S Turner"]
10
+ spec.email = ["contact@dansturner.com"]
11
+ spec.summary = %q{Convert car to cat in strings.}
12
+ spec.description = %q{This gem will change the word 'car' to 'cat' and also provide a CLI to run this conversion on files.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+ end
data/lib/car_to_cat.rb ADDED
@@ -0,0 +1,7 @@
1
+ require "car_to_cat/version"
2
+ require "car_to_cat/base"
3
+ require "car_to_cat/cli"
4
+
5
+ module CarToCat
6
+
7
+ end
@@ -0,0 +1,14 @@
1
+ module CarToCat
2
+ class Base
3
+ def self.catify(string)
4
+ string.gsub(/(car)s?\b/i) do |match|
5
+ match[/r/] ? match.sub(/r/, "t") : match.sub(/R/, "T")
6
+ end
7
+ end
8
+
9
+ def self.convert(input_file, output_file)
10
+ contents = input_file.read
11
+ output_file.write(catify(contents))
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,13 @@
1
+ require 'car_to_cat/base'
2
+
3
+ module CarToCat
4
+ class Cli < Base
5
+ def execute(arguments)
6
+ input_file = File.new arguments[0], 'r'
7
+ output_file = File.new arguments[1], 'w'
8
+ CarToCat::Base.convert(input_file, output_file)
9
+ input_file.close
10
+ output_file.close
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ module CarToCat
2
+ VERSION = "0.0.1"
3
+ end
data/spec/base_spec.rb ADDED
@@ -0,0 +1,78 @@
1
+ require 'spec_helper'
2
+
3
+ describe "CarToCat::Base" do
4
+
5
+ subject { CarToCat::Base }
6
+
7
+ describe "when converting" do
8
+ it "should change car to cat" do
9
+ expect(subject.catify("car")).to eq("cat")
10
+ end
11
+
12
+ it "should replace all instances of car" do
13
+ expect(subject.catify("car car car")).to eq("cat cat cat")
14
+ end
15
+
16
+ it "should not change care to cate" do
17
+ expect(subject.catify("care")).to_not eq("cate")
18
+ end
19
+
20
+ it "should leave intact capitalization" do
21
+ expect(subject.catify("CAR")).to eq("CAT")
22
+ end
23
+
24
+ it "should match plural instances" do
25
+ expect(subject.catify("cars")).to eq("cats")
26
+ end
27
+ end
28
+
29
+ describe "when handling a file" do
30
+ before(:each) do
31
+ @input_file = StringIO.new (
32
+ <<-eos
33
+ In 2006, John Lasseter spoke about how they worked hard to make the
34
+ animation believable, saying: \"It took many months of trial and
35
+ error, and practicing test animation, to figure out how each car
36
+ moves and how their world works. Our supervising animators, Doug
37
+ Sweetland and Scott Clark, and the directing animators, Bobby Podesta
38
+ and James Ford Murphy, did an amazing job working with the animation
39
+ team to determine the unique movements for each character based on
40
+ its age and the type of car it was. Some cars are like sports cars
41
+ and they\'re much tighter in their suspension. Others are older
42
+ \'50s cars that are a lot looser and have more bounce to them. We
43
+ wanted to get that authenticity in there but also to make sure each
44
+ car had a unique personality. We also wanted each animator to be
45
+ able to put some of themself in the character and give it their own
46
+ spin. Every day in dailies, it was so much fun because we would see
47
+ things that we had never seen in our lives. The world of cars came
48
+ alive in a believable and unexpected way.\"[19]
49
+ eos
50
+ )
51
+ @output_file = StringIO.new
52
+ end
53
+
54
+ it "should output a catified file" do
55
+ subject.convert(@input_file, @output_file)
56
+ @output_file.string.should eq(
57
+ <<-eos
58
+ In 2006, John Lasseter spoke about how they worked hard to make the
59
+ animation believable, saying: \"It took many months of trial and
60
+ error, and practicing test animation, to figure out how each cat
61
+ moves and how their world works. Our supervising animators, Doug
62
+ Sweetland and Scott Clark, and the directing animators, Bobby Podesta
63
+ and James Ford Murphy, did an amazing job working with the animation
64
+ team to determine the unique movements for each character based on
65
+ its age and the type of cat it was. Some cats are like sports cats
66
+ and they\'re much tighter in their suspension. Others are older
67
+ \'50s cats that are a lot looser and have more bounce to them. We
68
+ wanted to get that authenticity in there but also to make sure each
69
+ cat had a unique personality. We also wanted each animator to be
70
+ able to put some of themself in the character and give it their own
71
+ spin. Every day in dailies, it was so much fun because we would see
72
+ things that we had never seen in our lives. The world of cats came
73
+ alive in a believable and unexpected way.\"[19]
74
+ eos
75
+ )
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,5 @@
1
+ require 'spec_helper'
2
+
3
+ describe "CarToCat" do
4
+
5
+ end
data/spec/cli_spec.rb ADDED
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe "CarToCat::Cli" do
4
+
5
+ before(:each) do
6
+ @cli = CarToCat::Cli.new
7
+ end
8
+
9
+ describe "running bin/car_to_cat" do
10
+ before(:each) do
11
+ @input = StringIO.new("Cars have 4 wheels and go vroom!")
12
+ @output = StringIO.new
13
+ File.stub(:new).and_return(@input, @output)
14
+ end
15
+
16
+ it "should catify the file" do
17
+ ARGV.clear.concat(['infile', 'outfile'])
18
+ eval File.read(File.join(File.dirname(__FILE__), '..', 'bin', 'car_to_cat'))
19
+ @output.string.should eql("Cats have 4 wheels and go vroom!")
20
+ end
21
+ end
22
+
23
+ end
@@ -0,0 +1,3 @@
1
+ require 'car_to_cat'
2
+ require 'car_to_cat/base'
3
+ require 'car_to_cat/cli'
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: car_to_cat
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Dan S Turner
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-04-24 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: This gem will change the word 'car' to 'cat' and also provide a CLI to
56
+ run this conversion on files.
57
+ email:
58
+ - contact@dansturner.com
59
+ executables:
60
+ - car_to_cat
61
+ extensions: []
62
+ extra_rdoc_files: []
63
+ files:
64
+ - ".gitignore"
65
+ - Gemfile
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - bin/car_to_cat
70
+ - car_to_cat.gemspec
71
+ - lib/car_to_cat.rb
72
+ - lib/car_to_cat/base.rb
73
+ - lib/car_to_cat/cli.rb
74
+ - lib/car_to_cat/version.rb
75
+ - spec/base_spec.rb
76
+ - spec/car_to_cat_spec.rb
77
+ - spec/cli_spec.rb
78
+ - spec/spec_helper.rb
79
+ homepage: ''
80
+ licenses:
81
+ - MIT
82
+ metadata: {}
83
+ post_install_message:
84
+ rdoc_options: []
85
+ require_paths:
86
+ - lib
87
+ required_ruby_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ required_rubygems_version: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ requirements: []
98
+ rubyforge_project:
99
+ rubygems_version: 2.2.2
100
+ signing_key:
101
+ specification_version: 4
102
+ summary: Convert car to cat in strings.
103
+ test_files:
104
+ - spec/base_spec.rb
105
+ - spec/car_to_cat_spec.rb
106
+ - spec/cli_spec.rb
107
+ - spec/spec_helper.rb