urmum 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 566135a23494d1c681ca731511c6719398b9caf7
4
+ data.tar.gz: 139b589eecf1dcc259c2cf24a831fbc001071e60
5
+ SHA512:
6
+ metadata.gz: 54895bc52cfcda4232fcc02d7e2425681b6124c1b5965e478c56075f0ff1e63db2f5bf85d9fa0f312ffe978116653dcdf4a8fd698387299d676f5d9902cffcf0
7
+ data.tar.gz: d9a033a6c72aaae8d1d5ceacd76f0e983e794430faac817e0adf9e3577a5247d7c45cd69ac61ea042aef6ac8990dcd56e805b48676f40be5efb93f64c1c38a1e
@@ -0,0 +1,17 @@
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
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1 @@
1
+ ruby-2.0.0-p247
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in urmum.gemspec
4
+ gemspec
@@ -0,0 +1,24 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard :rspec do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+
9
+ # Rails example
10
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
11
+ watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
12
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
13
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
14
+ watch('config/routes.rb') { "spec/routing" }
15
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
16
+
17
+ # Capybara features specs
18
+ watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
19
+
20
+ # Turnip features and steps
21
+ watch(%r{^spec/acceptance/(.+)\.feature$})
22
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
23
+ end
24
+
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Duncan Stuart
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.
@@ -0,0 +1,29 @@
1
+ # Urmum
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'urmum'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install urmum
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
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 new Pull Request
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'urmum'
4
+
5
+ puts Insulter.new.insult_with(ARGV.join(" "))
@@ -0,0 +1,5 @@
1
+ require "urmum/version"
2
+ require "urmum/insulter"
3
+
4
+ module Urmum
5
+ end
@@ -0,0 +1,40 @@
1
+ require 'engtagger'
2
+ require 'pry'
3
+
4
+ class Insulter
5
+ INSULT_BEGINNINGS = [
6
+ "You're",
7
+ "Your face is",
8
+ "Your mum is",
9
+ "Your mum's face is"
10
+ ]
11
+ FALLBACK = "That's what she said"
12
+
13
+ def initialize
14
+ @tagger = EngTagger.new
15
+ end
16
+
17
+ def insult_with(string)
18
+ # Try and match against the beginning of the string. If so, get the next beginning from the array
19
+ regexp = Regexp.new(%{^(?<start>#{INSULT_BEGINNINGS.join("|")}) (?<article>an|a) (?<thing>.*)})
20
+ if matches = string.capitalize.match(regexp)
21
+ index = INSULT_BEGINNINGS.index(matches[:start]) + 1
22
+ if index < INSULT_BEGINNINGS.length
23
+ return "#{INSULT_BEGINNINGS[index]} #{matches[:article]} #{matches[:thing]}"
24
+ else
25
+ return FALLBACK
26
+ end
27
+ end
28
+ tagged_string = @tagger.add_tags(string)
29
+ nouns = @tagger.get_nouns(tagged_string)
30
+
31
+ if nouns.empty?
32
+ FALLBACK
33
+ else
34
+ thing = nouns.keys.last
35
+ "You're a #{thing}"
36
+ end
37
+
38
+ # binding.pry
39
+ end
40
+ end
@@ -0,0 +1,3 @@
1
+ module Urmum
2
+ VERSION = "0.0.0"
3
+ end
@@ -0,0 +1,5 @@
1
+ require 'simplecov'
2
+ SimpleCov.start
3
+
4
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
5
+ require 'urmum'
@@ -0,0 +1,64 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Insulter" do
4
+ let (:insulter) { Insulter.new }
5
+
6
+ describe ".insult_with" do
7
+ CLASSIC_CHAIN = [
8
+ [ "You're a", "Your face is a" ],
9
+ [ "You're an", "Your face is an" ],
10
+ [ "Your face is a", "Your mum is a" ],
11
+ [ "Your face is an", "Your mum is an" ],
12
+ [ "Your mum is a", "Your mum's face is a" ],
13
+ [ "Your mum is an", "Your mum's face is an" ],
14
+ ]
15
+ CLASSIC_CHAIN.each do | insult, response |
16
+ context "when insulted with \"#{insult} thing!\"" do
17
+ subject { insulter.insult_with("#{insult} thing!") }
18
+ it { should == "#{response} thing!" }
19
+ end
20
+ end
21
+
22
+ END_OF_CHAIN = [
23
+ "Your mum's face is a",
24
+ "Your mum's face is an",
25
+ ]
26
+ END_OF_CHAIN.each do | insult |
27
+ context "when insulted with \"#{insult} thing!\"" do
28
+ subject { insulter.insult_with("#{insult} thing!") }
29
+ it { should == "That's what she said" }
30
+ end
31
+ end
32
+
33
+ it "should be case-insensitive" do
34
+ insulter.insult_with("yOuR Face IS A thing!").should == "Your mum is a thing!"
35
+ end
36
+
37
+ context "when the input doesn't lend itself to insults" do
38
+ subject { insulter.insult_with("running")}
39
+ it { should == "That's what she said" }
40
+ end
41
+
42
+ it "should handle an exclamation mark at the end of the input"
43
+ it "should respond differently if there is no string after a 'You're a'"
44
+ it "should treat 'ur' the same as 'you're' and your"
45
+ it "should handle mum's the same as mum is"
46
+
47
+ context "when passed a single word" do
48
+ context "which is a noun" do
49
+ subject { insulter.insult_with("thing") }
50
+ it "should respond \"You're a <<noun>>\"" do
51
+ subject.should == "You're a thing"
52
+ end
53
+ end
54
+ end
55
+
56
+ context "when passed a phrase of several words" do
57
+ context "which includes some nouns" do
58
+ it "should insult using the last noun" do
59
+ insulter.insult_with("I made an axe and hacked through the floor").should == "You're a floor"
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe Urmum do
4
+ it 'should have a version number' do
5
+ Urmum::VERSION.should_not be_nil
6
+ end
7
+ end
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'urmum/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "urmum"
8
+ spec.version = Urmum::VERSION
9
+ spec.authors = ["Duncan Stuart"]
10
+ spec.email = ["dgmstuart@gmail.com"]
11
+ spec.description = %q{Taking natural language and throwing it back at you as "you're a"/"your mum's a" jokes}
12
+ spec.summary = %q{Mostly to annoy my colleauge A}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
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_runtime_dependency "engtagger"
22
+ spec.add_runtime_dependency "active_support"
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.3"
25
+ spec.add_development_dependency "rake"
26
+ spec.add_development_dependency "rspec"
27
+ spec.add_development_dependency "guard-rspec"
28
+ spec.add_development_dependency "simplecov"
29
+ end
metadata ADDED
@@ -0,0 +1,164 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: urmum
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Duncan Stuart
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-18 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: engtagger
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: active_support
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
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: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ~>
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ~>
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: guard-rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Taking natural language and throwing it back at you as "you're a"/"your
112
+ mum's a" jokes
113
+ email:
114
+ - dgmstuart@gmail.com
115
+ executables:
116
+ - urmum
117
+ extensions: []
118
+ extra_rdoc_files: []
119
+ files:
120
+ - .gitignore
121
+ - .rspec
122
+ - .ruby-version
123
+ - .travis.yml
124
+ - Gemfile
125
+ - Guardfile
126
+ - LICENSE.txt
127
+ - README.md
128
+ - Rakefile
129
+ - bin/urmum
130
+ - lib/urmum.rb
131
+ - lib/urmum/insulter.rb
132
+ - lib/urmum/version.rb
133
+ - spec/spec_helper.rb
134
+ - spec/urmum/insulter_spec.rb
135
+ - spec/urmum_spec.rb
136
+ - urmum.gemspec
137
+ homepage: ''
138
+ licenses:
139
+ - MIT
140
+ metadata: {}
141
+ post_install_message:
142
+ rdoc_options: []
143
+ require_paths:
144
+ - lib
145
+ required_ruby_version: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ required_rubygems_version: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - '>='
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
155
+ requirements: []
156
+ rubyforge_project:
157
+ rubygems_version: 2.0.7
158
+ signing_key:
159
+ specification_version: 4
160
+ summary: Mostly to annoy my colleauge A
161
+ test_files:
162
+ - spec/spec_helper.rb
163
+ - spec/urmum/insulter_spec.rb
164
+ - spec/urmum_spec.rb