camertron-moar-lolspeak 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,5 @@
1
+ *.swp
2
+ *.gem
3
+ .bundle
4
+ Gemfile.lock
5
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in moar-lolspeak.gemspec
4
+ gemspec
data/README ADDED
@@ -0,0 +1,11 @@
1
+ Ruby module for translating text from English to lolspeak.
2
+
3
+ This code is a shameless translation of the Perl CPAN module Acme::LOLCAT.
4
+
5
+ I decided to translate the Perl module because the venerable lolspeak gem
6
+ had gained quite alot of bitrot on ruby 1.9 (UTF-8 v ASCII problems).
7
+
8
+ Usage:
9
+
10
+ require 'moar-lolspeak'
11
+ puts Moar::Lolspeak.translate('Hello, can I please have a cheezeburger?')
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,102 @@
1
+ # Shamelessly lifted from:
2
+ # http://cpansearch.perl.org/src/KCOWGILL/Acme-LOLCAT-0.0.5/lib/Acme/LOLCAT.pm
3
+
4
+ module Moar
5
+ module Lolspeak
6
+ LOL_REPLACEMENTS = {
7
+ /what/ => %w{wut whut},
8
+ /you\b/ => %w{yu yous yoo u},
9
+ /cture/ => 'kshur',
10
+ /unless/ => 'unles',
11
+ /the\b/ => 'teh',
12
+ /more/ => 'moar',
13
+ /my/ => %w{muh mah},
14
+ /are/ => %w{r is ar},
15
+ /eese/ => 'eez',
16
+ /ph/ => 'f',
17
+ /as\b/ => 'az',
18
+ /seriously/ => 'srsly',
19
+ /er\b/ => 'r',
20
+ /sion/ => 'shun',
21
+ /just/ => 'jus',
22
+ /ose\b/ => 'oze',
23
+ /eady/ => 'eddy',
24
+ /ome?\b/ => 'um',
25
+ /of\b/ => %w{of ov of},
26
+ /uestion/ => 'wesjun',
27
+ /want/ => 'wants',
28
+ /ead\b/ => 'edd',
29
+ /ucke/ => %w{ukki ukke},
30
+ /sion/ => 'shun',
31
+ /eak/ => 'ekk',
32
+ /age/ => 'uj',
33
+ /like/ => %w{likes liek},
34
+ /love/ => %w{loves lub lubs luv},
35
+ /\bis\b/ => ['ar teh','ar'],
36
+ /nd\b/ => 'n',
37
+ /who/ => 'hoo',
38
+ /'/ => %q{},
39
+ /ese\b/ => 'eez',
40
+ /outh/ => 'owf',
41
+ /scio/ => 'shu',
42
+ /esque/ => 'esk',
43
+ /ture/ => 'chur',
44
+ /\btoo?\b/ => %w{to t 2 to t},
45
+ /tious/ => 'shus',
46
+ /sure\b/ => 'shur',
47
+ /tty\b/ => 'tteh',
48
+ /were/ => 'was',
49
+ /ok\b/ => %w{'k kay},
50
+ /\ba\b/ => %q{},
51
+ /ym/ => 'im',
52
+ /thy\b/ => 'fee',
53
+ /\wly\w/ => 'li',
54
+ /que\w/ => 'kwe',
55
+ /oth/ => 'udd',
56
+ /ease/ => 'eez',
57
+ /ing\b/ => %w{in ins ng ing},
58
+ /have/ => ['has', 'hav', 'haz a'],
59
+ /your/ => %w{yur ur yore yoar},
60
+ /ove\b/ => %w{oov ove uuv uv oove},
61
+ /for/ => %w{for 4 fr fur for foar},
62
+ /thank/ => %w{fank tank thx thnx},
63
+ /good/ => %w{gud goed guud gude gewd},
64
+ /really/ => %w{rly rily rilly rilley},
65
+ /world/ => %w{wurrld whirld wurld wrld},
66
+ /i'?m\b/ => 'im',
67
+ /(?!e)ight/ => 'ite',
68
+ /(?!ues)tion/ => 'shun',
69
+ /you'?re/ => %w{yore yr},
70
+ /\boh\b(?!.*hai)/ => %w{o ohs},
71
+ /can\si\s(?:ple(?:a|e)(?:s|z)e?)?\s?have\sa/ => 'i can has',
72
+ /(?:hello|\bhi\b|\bhey\b|howdy|\byo\b),?/ => 'oh hai,',
73
+ /(?:god|allah|buddah?|diety)/ => 'ceiling cat',
74
+ }
75
+
76
+ def self.translate(phrase, add_ending = true)
77
+ phrase.downcase!
78
+
79
+ LOL_REPLACEMENTS.each_pair do |english_snippet, lol_snippet|
80
+ phrase.gsub!(english_snippet) do |match|
81
+ lol_snippet.is_a?(Array) ? lol_snippet.sample : lol_snippet
82
+ end
83
+ end
84
+
85
+ phrase.gsub!(/\s{2,}/, ' ')
86
+ phrase.gsub!(/teh teh/, 'teh') # meh, it happens sometimes.
87
+ phrase << '. kthxbye!' if rand(10) == 2 && add_ending
88
+ phrase << '. kthx.' if rand(10) == 1 && add_ending
89
+ phrase.gsub!(/(\?|!|,|\.)\./, '\1')
90
+
91
+ phrase.upcase
92
+ end
93
+ end
94
+ end
95
+
96
+ class String
97
+ unless method_defined?(:to_lolspeak)
98
+ def to_lolspeak
99
+ Moar::Lolspeak.translate(self)
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,5 @@
1
+ module Moar
2
+ module Lolspeak
3
+ VERSION = "0.0.2"
4
+ end
5
+ end
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "moar-lolspeak/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "camertron-moar-lolspeak"
7
+ s.version = Moar::Lolspeak::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Richard Norton", "Cameron Dutro"]
10
+ s.email = ["rwtnorton@gmail.com", "camertron@gmail.com"]
11
+ s.homepage = "https://github.com/camertron/moar-lolspeak"
12
+ s.summary = %q{Translates from English to lolspeak.}
13
+ s.description = %q{Shameless copy of CPAN module Acme::LOLCAT, modified for release by @camertron.}
14
+
15
+ s.rubyforge_project = "camertron-moar-lolspeak"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+ s.add_development_dependency "rspec", "~> 2.5.0"
22
+ end
@@ -0,0 +1,9 @@
1
+ require 'moar-lolspeak'
2
+
3
+ describe Moar::Lolspeak do
4
+ it "can has cheezburger" do
5
+ Moar::Lolspeak.translate(
6
+ 'Hello, can I please have a cheeseburger?').should =~
7
+ /\AOH HAI, CAN I PLEEZ HA[SZV] (?:A )?CHEEZBURGR\?/
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,72 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: camertron-moar-lolspeak
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Richard Norton
9
+ - Cameron Dutro
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2013-01-14 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rspec
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: 2.5.0
23
+ type: :development
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - ~>
29
+ - !ruby/object:Gem::Version
30
+ version: 2.5.0
31
+ description: Shameless copy of CPAN module Acme::LOLCAT, modified for release by @camertron.
32
+ email:
33
+ - rwtnorton@gmail.com
34
+ - camertron@gmail.com
35
+ executables: []
36
+ extensions: []
37
+ extra_rdoc_files: []
38
+ files:
39
+ - .gitignore
40
+ - Gemfile
41
+ - README
42
+ - Rakefile
43
+ - lib/moar-lolspeak.rb
44
+ - lib/moar-lolspeak/version.rb
45
+ - moar-lolspeak.gemspec
46
+ - spec/moar-lolspeak_spec.rb
47
+ homepage: https://github.com/camertron/moar-lolspeak
48
+ licenses: []
49
+ post_install_message:
50
+ rdoc_options: []
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ! '>='
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ! '>='
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ requirements: []
66
+ rubyforge_project: camertron-moar-lolspeak
67
+ rubygems_version: 1.8.24
68
+ signing_key:
69
+ specification_version: 3
70
+ summary: Translates from English to lolspeak.
71
+ test_files:
72
+ - spec/moar-lolspeak_spec.rb