dogeify 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +17 -0
- data/.rspec +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +52 -0
- data/Rakefile +5 -0
- data/bin/dogeify +8 -0
- data/dogeify.gemspec +26 -0
- data/lib/dogeify.rb +27 -0
- data/lib/dogeify/all.rb +2 -0
- data/lib/dogeify/core_ext.rb +2 -0
- data/lib/dogeify/core_ext/array.rb +8 -0
- data/lib/dogeify/core_ext/string.rb +7 -0
- data/lib/dogeify/version.rb +3 -0
- data/spec/core_ext/array_spec.rb +20 -0
- data/spec/core_ext/string_spec.rb +16 -0
- data/spec/dogeify_spec.rb +24 -0
- data/spec/spec_helper.rb +1 -0
- data/tasks/debug.rake +4 -0
- metadata +124 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
YWRhY2E4OTJlNDEwNWIyMjI0MGZhZmEwZjhkNTllMTdkYmQzYjRhMQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZWZmOTFlZjcyZDEwNWVhZDdmNjgwZjk2Mzc4YzM3M2QzZTVlYjVkYw==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NWIxNTEyNTQ0ZDRjNmYwOGRiNDRkMWE0N2JiMjE4NTdkNWM5ZTE5Yjc0Zjcx
|
10
|
+
OWI0ZjVlNGNjODBkZmJlOTljYmFjMDk0YjIzODcyYzAxNTMzNGYwYTQxMGVl
|
11
|
+
ZDEzMjkyMzk1YzUwZTVlZWIxZDg4NWY5YzQ0NGZkMzg5ZGNlODQ=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
Zjk4NjQwZjY4N2YyZjYxZGY2YjczYmI4YWU2YzY2YzM0YTNjZmFhZmM5NzMy
|
14
|
+
YjY4NWYyMWM3MTU2ZjgxZmI0NDFmZTBlNTgzMjVmODE3MzMwNDAxN2EyYjE1
|
15
|
+
MGFkZDE4ZGZjZTVjNTNhZjUxZmQ3N2JhZGVhZTEzZjRlYjliN2Q=
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Matt Huggins
|
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,52 @@
|
|
1
|
+
# Dogeify
|
2
|
+
|
3
|
+
Convert English to [Doge](http://en.wikipedia.org/wiki/Doge_(meme))!
|
4
|
+
|
5
|
+
Please note that this gem is using an extremely simple language natural
|
6
|
+
processor, so parsing is not perfect, but it works.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
gem 'dogeify'
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install dogeify
|
21
|
+
|
22
|
+
## Usage
|
23
|
+
|
24
|
+
There are several ways of using Dogeify. The first way is to go through the
|
25
|
+
`Dogeify` class itself.
|
26
|
+
|
27
|
+
require 'dogeify'
|
28
|
+
|
29
|
+
dogifier = Dogify.new
|
30
|
+
dogifier.process('My grandmom gave me a sweater for Christmas.')
|
31
|
+
# => "so grandmom. such sweater. very christmas. wow."
|
32
|
+
|
33
|
+
The second way is to modify the String or Array classes by including either
|
34
|
+
core extension.
|
35
|
+
|
36
|
+
require 'dogeify/core_ext/array' # extends only Array
|
37
|
+
require 'dogeify/core_ext/string' # extends only String
|
38
|
+
require 'dogeify/core_ext' # extends both Array/String
|
39
|
+
|
40
|
+
'My grandmom gave me a sweater for Christmas.'.dogify
|
41
|
+
# => "so grandmom. such sweater. very christmas. wow."
|
42
|
+
|
43
|
+
['I like turtles.', 'It is during our darkest moments that we must focus to see the light.'].dogify
|
44
|
+
# => ["so turtles. wow.", "so darkest. such moments. very light. wow."]
|
45
|
+
|
46
|
+
## Contributing
|
47
|
+
|
48
|
+
1. Fork it
|
49
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
50
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
51
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
52
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bin/dogeify
ADDED
data/dogeify.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'dogeify/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "dogeify"
|
8
|
+
spec.version = Dogeify::VERSION
|
9
|
+
spec.authors = ["Matt Huggins"]
|
10
|
+
spec.email = ["matt.huggins@gmail.com"]
|
11
|
+
spec.description = %q{Convert everyday boring English into doge speak!}
|
12
|
+
spec.summary = %q{English to doge translations}
|
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_dependency 'engtagger'
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
24
|
+
spec.add_development_dependency 'rake'
|
25
|
+
spec.add_development_dependency 'rspec'
|
26
|
+
end
|
data/lib/dogeify.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'dogeify/version'
|
2
|
+
require 'engtagger'
|
3
|
+
|
4
|
+
class Dogeify
|
5
|
+
ADJECTIVES = %w(so such very much many).freeze
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@tagger = EngTagger.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def process(str)
|
12
|
+
tagged_str = tagger.add_tags(str.downcase)
|
13
|
+
phrases = tagger.get_nouns(tagged_str).keys
|
14
|
+
|
15
|
+
phrases = phrases.each_with_index.map { |phrase, i| "#{adjective(i)} #{phrase}." }
|
16
|
+
phrases << 'wow.'
|
17
|
+
phrases.join(' ')
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
attr_reader :tagger
|
23
|
+
|
24
|
+
def adjective(i)
|
25
|
+
ADJECTIVES[i % ADJECTIVES.size]
|
26
|
+
end
|
27
|
+
end
|
data/lib/dogeify/all.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Array do
|
4
|
+
subject { ['My grandmom gave me a sweater for Christmas.', 'I like turtles.', 'I am a banana.'] }
|
5
|
+
|
6
|
+
describe '#dogeify' do
|
7
|
+
it 'delegates to Dogeify#process for each element' do
|
8
|
+
subject.each do |item|
|
9
|
+
expect_any_instance_of(Dogeify).to receive(:process).with(item).once
|
10
|
+
end
|
11
|
+
|
12
|
+
subject.dogeify
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'returns an array of strings' do
|
16
|
+
expect(subject.dogeify).to be_an Array
|
17
|
+
expect(subject.dogeify.map(&:class).uniq).to eq [String]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe String do
|
4
|
+
subject { 'My grandmom gave me a sweater for Christmas.' }
|
5
|
+
|
6
|
+
describe '#dogeify' do
|
7
|
+
it 'delegates to Dogeify#process' do
|
8
|
+
expect_any_instance_of(Dogeify).to receive(:process).with(subject)
|
9
|
+
subject.dogeify
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'returns a string' do
|
13
|
+
expect(subject.dogeify).to be_a String
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Dogeify do
|
4
|
+
subject { Dogeify.new }
|
5
|
+
|
6
|
+
describe '#process' do
|
7
|
+
let(:input) { 'My grandmom gave me a sweater for Christmas.' }
|
8
|
+
let(:output) { subject.process(input) }
|
9
|
+
|
10
|
+
it 'converts to lowercase' do
|
11
|
+
expect(output.downcase).to eq output
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'combines nouns with doge adjectives' do
|
15
|
+
expect(output).to match /so grandmom\./i
|
16
|
+
expect(output).to match /such sweater\./i
|
17
|
+
expect(output).to match /very christmas\./i
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'always appends "wow."' do
|
21
|
+
expect(output).to end_with 'wow.'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'dogeify/all'
|
data/tasks/debug.rake
ADDED
metadata
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dogeify
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Matt Huggins
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-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: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
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
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
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
|
+
description: Convert everyday boring English into doge speak!
|
70
|
+
email:
|
71
|
+
- matt.huggins@gmail.com
|
72
|
+
executables:
|
73
|
+
- dogeify
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- .gitignore
|
78
|
+
- .rspec
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/dogeify
|
84
|
+
- dogeify.gemspec
|
85
|
+
- lib/dogeify.rb
|
86
|
+
- lib/dogeify/all.rb
|
87
|
+
- lib/dogeify/core_ext.rb
|
88
|
+
- lib/dogeify/core_ext/array.rb
|
89
|
+
- lib/dogeify/core_ext/string.rb
|
90
|
+
- lib/dogeify/version.rb
|
91
|
+
- spec/core_ext/array_spec.rb
|
92
|
+
- spec/core_ext/string_spec.rb
|
93
|
+
- spec/dogeify_spec.rb
|
94
|
+
- spec/spec_helper.rb
|
95
|
+
- tasks/debug.rake
|
96
|
+
homepage: ''
|
97
|
+
licenses:
|
98
|
+
- MIT
|
99
|
+
metadata: {}
|
100
|
+
post_install_message:
|
101
|
+
rdoc_options: []
|
102
|
+
require_paths:
|
103
|
+
- lib
|
104
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - ! '>='
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
110
|
+
requirements:
|
111
|
+
- - ! '>='
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
version: '0'
|
114
|
+
requirements: []
|
115
|
+
rubyforge_project:
|
116
|
+
rubygems_version: 2.2.1
|
117
|
+
signing_key:
|
118
|
+
specification_version: 4
|
119
|
+
summary: English to doge translations
|
120
|
+
test_files:
|
121
|
+
- spec/core_ext/array_spec.rb
|
122
|
+
- spec/core_ext/string_spec.rb
|
123
|
+
- spec/dogeify_spec.rb
|
124
|
+
- spec/spec_helper.rb
|