fearoffish-britify 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +4 -0
- data/Manifest.txt +14 -0
- data/README.markdown +52 -0
- data/Rakefile +24 -0
- data/bin/britify +23 -0
- data/bin/yankify +23 -0
- data/britify.gemspec +43 -0
- data/data/translations.yml +93 -0
- data/lib/britify.rb +56 -0
- data/lib/britify/command_line_parser/command_line_parser.rb +13 -0
- data/lib/britify/translate/translate.rb +30 -0
- data/spec/britify/command_line_parser/command_line_parser_spec.rb +18 -0
- data/spec/britify/translate/translate_spec.rb +53 -0
- data/spec/spec_helper.rb +17 -0
- data/tasks/ann.rake +81 -0
- data/tasks/bones.rake +21 -0
- data/tasks/gem.rake +126 -0
- data/tasks/git.rake +41 -0
- data/tasks/manifest.rake +49 -0
- data/tasks/notes.rake +28 -0
- data/tasks/post_load.rake +39 -0
- data/tasks/rdoc.rake +51 -0
- data/tasks/rubyforge.rake +57 -0
- data/tasks/setup.rb +268 -0
- data/tasks/spec.rake +55 -0
- data/tasks/svn.rake +48 -0
- data/tasks/test.rake +38 -0
- metadata +83 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
History.txt
|
2
|
+
Manifest.txt
|
3
|
+
README.markdown
|
4
|
+
Rakefile
|
5
|
+
bin/britify
|
6
|
+
bin/yankify
|
7
|
+
britify.gemspec
|
8
|
+
data/translations.yml
|
9
|
+
lib/britify.rb
|
10
|
+
lib/britify/command_line_parser/command_line_parser.rb
|
11
|
+
lib/britify/translate/translate.rb
|
12
|
+
spec/britify/command_line_parser/command_line_parser_spec.rb
|
13
|
+
spec/britify/translate/translate_spec.rb
|
14
|
+
spec/spec_helper.rb
|
data/README.markdown
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# britify
|
2
|
+
|
3
|
+
by Jamie van Dyke [http://blog.fearoffish.com/](http://blog.fearoffish.com/)
|
4
|
+
|
5
|
+
## DESCRIPTION:
|
6
|
+
|
7
|
+
### History
|
8
|
+
|
9
|
+
A clear language barrier has been evolving between Britain and the US over the years, and this gem hopes to help both sides of this barrier by translating some of the common phrases used on a daily basis by both sides. Let's look at a timeline to describe the necessity of this gem.
|
10
|
+
|
11
|
+
- England rules the waves
|
12
|
+
- Some Spanish fella 'discovered' the America's
|
13
|
+
- Nuclear weapons were created
|
14
|
+
- The US became a super power
|
15
|
+
- The US forgot about everyone else
|
16
|
+
|
17
|
+
Now, this timeline is roughly accurate bar one major fact. We're missing:
|
18
|
+
|
19
|
+
- Education was neglected, particularly in the spelling and grammar department
|
20
|
+
|
21
|
+
The common misconception is that there are two English languages. Actually, there is one correct language and one mispronounced, incorrectly spelt one.
|
22
|
+
|
23
|
+
Now, because the US has more nuclear weapons than us Brits, I have also included a yankify binary that will translate from British to Yank.
|
24
|
+
|
25
|
+
## INSTALL:
|
26
|
+
|
27
|
+
$ sudo gem install fearoffish-britify --sources=http://gems.github.com
|
28
|
+
|
29
|
+
## LICENSE:
|
30
|
+
|
31
|
+
(The MIT License)
|
32
|
+
|
33
|
+
Copyright (c) 2008 Jamie van Dyke
|
34
|
+
|
35
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
36
|
+
a copy of this software and associated documentation files (the
|
37
|
+
'Software'), to deal in the Software without restriction, including
|
38
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
39
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
40
|
+
permit persons to whom the Software is furnished to do so, subject to
|
41
|
+
the following conditions:
|
42
|
+
|
43
|
+
The above copyright notice and this permission notice shall be
|
44
|
+
included in all copies or substantial portions of the Software.
|
45
|
+
|
46
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
47
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
48
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
49
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
50
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
51
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
52
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# Look in the tasks/setup.rb file for the various options that can be
|
2
|
+
# configured in this Rakefile. The .rake files in the tasks directory
|
3
|
+
# are where the options are used.
|
4
|
+
|
5
|
+
load 'tasks/setup.rb'
|
6
|
+
|
7
|
+
ensure_in_path 'lib'
|
8
|
+
require 'britify'
|
9
|
+
|
10
|
+
task :default => 'spec:run'
|
11
|
+
|
12
|
+
PROJ.name = 'britify'
|
13
|
+
PROJ.version = '0.0.1'
|
14
|
+
PROJ.authors = 'Jamie van Dyke'
|
15
|
+
PROJ.email = 'jamie@parfa.it'
|
16
|
+
PROJ.url = 'http://blog.fearoffish.com/'
|
17
|
+
PROJ.homepage = 'http://github.com/fearoffish/britify'
|
18
|
+
PROJ.rubyforge.name = 'britify'
|
19
|
+
PROJ.summary = 'British <-> American Translator'
|
20
|
+
PROJ.description = 'Britify is an amusement project, for translating the differences between British and American slangs.'
|
21
|
+
|
22
|
+
PROJ.spec.opts << '--color'
|
23
|
+
|
24
|
+
# EOF
|
data/bin/britify
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require File.expand_path(
|
4
|
+
File.join(File.dirname(__FILE__), '..', 'lib', 'britify'))
|
5
|
+
|
6
|
+
parser = Britify::CommandLineParser.new(ARGV)
|
7
|
+
words = parser.words
|
8
|
+
|
9
|
+
if ARGV.empty?
|
10
|
+
puts "Translate American terms into British"
|
11
|
+
puts " Usage: britify american words"
|
12
|
+
exit
|
13
|
+
end
|
14
|
+
|
15
|
+
begin
|
16
|
+
translator = Britify::Translate.new
|
17
|
+
translation = translator.translate( words.join(" "), :reverse )
|
18
|
+
puts "\"#{words.join(" ")}\" => \"#{translation}\""
|
19
|
+
rescue
|
20
|
+
puts "Hell no! There's nothing like that in British!"
|
21
|
+
end
|
22
|
+
|
23
|
+
# EOF
|
data/bin/yankify
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require File.expand_path(
|
4
|
+
File.join(File.dirname(__FILE__), '..', 'lib', 'britify'))
|
5
|
+
|
6
|
+
parser = Britify::CommandLineParser.new(ARGV)
|
7
|
+
words = parser.words
|
8
|
+
|
9
|
+
if ARGV.empty?
|
10
|
+
puts "Translate British terms into American"
|
11
|
+
puts " Usage: yankify british words"
|
12
|
+
exit
|
13
|
+
end
|
14
|
+
|
15
|
+
begin
|
16
|
+
translator = Britify::Translate.new
|
17
|
+
translation = translator.translate( words.join(" ") )
|
18
|
+
puts "\"#{words.join(" ")}\" => \"#{translation}\""
|
19
|
+
rescue
|
20
|
+
puts "On yer bike! There's nothing like that in American!"
|
21
|
+
end
|
22
|
+
|
23
|
+
# EOF
|
data/britify.gemspec
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = "britify"
|
3
|
+
s.version = "0.0.1"
|
4
|
+
s.date = "2008-07-31"
|
5
|
+
s.summary = "British <-> American Translator"
|
6
|
+
s.email = "jamie@parfa.it"
|
7
|
+
s.homepage = "http://github.com/fearoffish/britify"
|
8
|
+
s.description = "Britify is an amusement project, for translating the differences between British and American slangs."
|
9
|
+
s.has_rdoc = true
|
10
|
+
s.authors = ["Jamie van Dyke"]
|
11
|
+
s.files = %w[
|
12
|
+
History.txt
|
13
|
+
Manifest.txt
|
14
|
+
README.markdown
|
15
|
+
Rakefile
|
16
|
+
bin/britify
|
17
|
+
bin/yankify
|
18
|
+
britify.gemspec
|
19
|
+
data/translations.yml
|
20
|
+
lib/britify.rb
|
21
|
+
lib/britify/command_line_parser/command_line_parser.rb
|
22
|
+
lib/britify/translate/translate.rb
|
23
|
+
spec/britify/command_line_parser/command_line_parser_spec.rb
|
24
|
+
spec/britify/translate/translate_spec.rb
|
25
|
+
spec/spec_helper.rb
|
26
|
+
tasks/ann.rake
|
27
|
+
tasks/bones.rake
|
28
|
+
tasks/gem.rake
|
29
|
+
tasks/git.rake
|
30
|
+
tasks/manifest.rake
|
31
|
+
tasks/notes.rake
|
32
|
+
tasks/post_load.rake
|
33
|
+
tasks/rdoc.rake
|
34
|
+
tasks/rubyforge.rake
|
35
|
+
tasks/setup.rb
|
36
|
+
tasks/spec.rake
|
37
|
+
tasks/svn.rake
|
38
|
+
tasks/test.rake
|
39
|
+
]
|
40
|
+
s.executables = ['britify','yankify']
|
41
|
+
s.rdoc_options = ["--main", "README.markdown"]
|
42
|
+
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.markdown"]
|
43
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
---
|
2
|
+
# British: American
|
3
|
+
shut your gob: shut your mouth
|
4
|
+
snog: make out
|
5
|
+
wonky: not straight
|
6
|
+
wellies: rubber boots
|
7
|
+
toffee nosed: stuck up
|
8
|
+
titchie: small
|
9
|
+
ticket tout: scalper
|
10
|
+
thick as a plank: stupid
|
11
|
+
telly advert: commercial
|
12
|
+
ta: thanks
|
13
|
+
ta-ra: goodbye
|
14
|
+
telly: television
|
15
|
+
suss out: find out
|
16
|
+
swanky: good appearance
|
17
|
+
swot up: study
|
18
|
+
sticking plaster: bandage
|
19
|
+
skint: poor or broke
|
20
|
+
spot on: exactly
|
21
|
+
skive: play hooky
|
22
|
+
slag: slut or lowlife
|
23
|
+
smarmy: creepy
|
24
|
+
smashing: great or wonderful
|
25
|
+
shirty: smart alecky
|
26
|
+
righto: alright okay
|
27
|
+
do a runner: run off or away
|
28
|
+
rubber: eraser
|
29
|
+
round the twist: gone mad or crazy
|
30
|
+
rasher: bacon
|
31
|
+
rabbit on: talk to much
|
32
|
+
queue: waiting line
|
33
|
+
podgy: chubby, plump
|
34
|
+
posh: ritzy
|
35
|
+
poppet: affectionate nickname
|
36
|
+
pub crawl: bar hopping
|
37
|
+
i agree: like totally
|
38
|
+
i dont agree: like whatever
|
39
|
+
big girls blouse: pansy
|
40
|
+
saige dillingham: bitch
|
41
|
+
bean: punch
|
42
|
+
chav: deliquent
|
43
|
+
bam: deliquent
|
44
|
+
bender: binge drink
|
45
|
+
rough: disgusting
|
46
|
+
ace: awesome
|
47
|
+
melon: head
|
48
|
+
badger: bother
|
49
|
+
bollocks: testicles
|
50
|
+
barmy: crazy
|
51
|
+
bent: illegal
|
52
|
+
bog: toilet
|
53
|
+
bonkers: crazy
|
54
|
+
trousers: pants
|
55
|
+
pants: crap
|
56
|
+
cacks: underwear
|
57
|
+
caned: hurt a lot
|
58
|
+
chap: man
|
59
|
+
anti-clockwise: counter-clockwise
|
60
|
+
arse: ass
|
61
|
+
arsehole: asshole
|
62
|
+
baccy: rolling tabacco
|
63
|
+
bees knees: great
|
64
|
+
blatant: obvious
|
65
|
+
knackers: testicles
|
66
|
+
knackered: tired
|
67
|
+
blimey: wow
|
68
|
+
blunt: dull
|
69
|
+
bonk: sex
|
70
|
+
bum: bottom
|
71
|
+
cheerio: good bye
|
72
|
+
chin wag: chat
|
73
|
+
chuffed: pleased
|
74
|
+
cock up: mistake
|
75
|
+
diddle: con
|
76
|
+
faff: procrastinate
|
77
|
+
fanny: vagina
|
78
|
+
fanny around: procrastinate
|
79
|
+
fit: sexy
|
80
|
+
grub: food
|
81
|
+
gutted: upset
|
82
|
+
hash: pound sign
|
83
|
+
nick: steal
|
84
|
+
nicked: arrested
|
85
|
+
pissed: drunk
|
86
|
+
angry: pissed
|
87
|
+
porkies: lies
|
88
|
+
roger: sex
|
89
|
+
scrummy: tasty
|
90
|
+
skive: evade
|
91
|
+
old sod: old bastard
|
92
|
+
todger: penis
|
93
|
+
|
data/lib/britify.rb
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# $Id$
|
2
|
+
|
3
|
+
# Equivalent to a header guard in C/C++
|
4
|
+
# Used to prevent the class/module from being loaded more than once
|
5
|
+
unless defined? Britify
|
6
|
+
|
7
|
+
module Britify
|
8
|
+
|
9
|
+
# :stopdoc:
|
10
|
+
VERSION = '1.0.0'
|
11
|
+
LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
|
12
|
+
PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
|
13
|
+
# :startdoc:
|
14
|
+
|
15
|
+
# Returns the version string for the library.
|
16
|
+
#
|
17
|
+
def self.version
|
18
|
+
VERSION
|
19
|
+
end
|
20
|
+
|
21
|
+
# Returns the library path for the module. If any arguments are given,
|
22
|
+
# they will be joined to the end of the libray path using
|
23
|
+
# <tt>File.join</tt>.
|
24
|
+
#
|
25
|
+
def self.libpath( *args )
|
26
|
+
args.empty? ? LIBPATH : ::File.join(LIBPATH, *args)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Returns the lpath for the module. If any arguments are given,
|
30
|
+
# they will be joined to the end of the path using
|
31
|
+
# <tt>File.join</tt>.
|
32
|
+
#
|
33
|
+
def self.path( *args )
|
34
|
+
args.empty? ? PATH : ::File.join(PATH, *args)
|
35
|
+
end
|
36
|
+
|
37
|
+
# Utility method used to rquire all files ending in .rb that lie in the
|
38
|
+
# directory below this file that has the same name as the filename passed
|
39
|
+
# in. Optionally, a specific _directory_ name can be passed in such that
|
40
|
+
# the _filename_ does not have to be equivalent to the directory.
|
41
|
+
#
|
42
|
+
def self.require_all_libs_relative_to( fname, dir = nil )
|
43
|
+
dir ||= ::File.basename(fname, '.*')
|
44
|
+
search_me = ::File.expand_path(
|
45
|
+
::File.join(::File.dirname(fname), dir, '**', '*.rb'))
|
46
|
+
|
47
|
+
Dir.glob(search_me).sort.each {|rb| require rb }
|
48
|
+
end
|
49
|
+
|
50
|
+
end # module Britify
|
51
|
+
|
52
|
+
Britify.require_all_libs_relative_to __FILE__
|
53
|
+
|
54
|
+
end # unless defined?
|
55
|
+
|
56
|
+
# EOF
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
|
3
|
+
module Britify
|
4
|
+
class Translate
|
5
|
+
attr_reader :translations
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
translations_file = File.join(File.dirname(__FILE__), %w[ .. .. .. data translations.yml ])
|
9
|
+
@translations = YAML.load( IO.read(translations_file) )
|
10
|
+
end
|
11
|
+
|
12
|
+
def translate( string, option = :normal )
|
13
|
+
raise ArgumentError unless string.kind_of? String
|
14
|
+
string.gsub!(/'/, '')
|
15
|
+
string.gsub!(/\W+/, ' ')
|
16
|
+
string.squeeze!(" ")
|
17
|
+
string.strip!
|
18
|
+
found = case option
|
19
|
+
when :normal
|
20
|
+
@translations[string.downcase]
|
21
|
+
when :reverse
|
22
|
+
v = @translations.find {|k,v| v == string.downcase }
|
23
|
+
v.first if v.is_a? Array
|
24
|
+
end
|
25
|
+
raise("No idea what you meant.") unless found
|
26
|
+
found
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# $Id$
|
2
|
+
|
3
|
+
require File.join(File.dirname(__FILE__), %w[ .. .. spec_helper ])
|
4
|
+
|
5
|
+
include Britify
|
6
|
+
|
7
|
+
describe CommandLineParser do
|
8
|
+
setup do
|
9
|
+
@p = CommandLineParser.new(["some", "commandline", "arguments"])
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should parse an array and return a string" do
|
13
|
+
@p.words.should == %w{ some commandline arguments }
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
# EOF
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# $Id$
|
2
|
+
|
3
|
+
require File.join(File.dirname(__FILE__), %w[ .. .. spec_helper])
|
4
|
+
|
5
|
+
include Britify
|
6
|
+
|
7
|
+
describe Translate do
|
8
|
+
setup do
|
9
|
+
@t = Translate.new
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should be instantiated without any arguments" do
|
13
|
+
lambda { Translate.new( ) }.should_not raise_error
|
14
|
+
lambda { Translate.new( "moo" ) }.should raise_error(ArgumentError)
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should have all translations in an accessor" do
|
18
|
+
@t.translations.should be_a_kind_of(Hash)
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should load the translations in from the data file on instantiation" do
|
22
|
+
IO.should_receive(:read).and_return(
|
23
|
+
"--- \nshut your gob: shut your mouth\nsnog: make out"
|
24
|
+
)
|
25
|
+
t = Translate.new
|
26
|
+
t.translations.should be_a_kind_of(Hash)
|
27
|
+
t.translations.keys.size.should == 2
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should accept a string on a translate method, and return a string" do
|
31
|
+
@t.translate("wonky").should be_instance_of(String)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should match up American terms in any case with the British equivalent" do
|
35
|
+
@t.translate( "shut your gob" ).should == "shut your mouth"
|
36
|
+
@t.translate( "POPPET" ).should == "affectionate nickname"
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should do British to American if given a :reverse option" do
|
40
|
+
@t.translate( "shut your mouth", :reverse ).should == "shut your gob"
|
41
|
+
end
|
42
|
+
|
43
|
+
it "should raise an error message if it doesn't have a translation" do
|
44
|
+
lambda { @t.translate('what the buggering hell') }.should raise_error(RuntimeError)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "should strip out any non alphabetic words" do
|
48
|
+
@t.translate( "shut, your gob????").should == "shut your mouth"
|
49
|
+
@t.translate( "big girl's blouse").should == "pansy"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# EOF
|