catspeak 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 41adf4891d414729a4f08359441855875e750cca5d7b589174418067e3047774
4
+ data.tar.gz: 8df653cff0dd9669c2eb305757eba8f920ab147414eea6a764eaef6bece42d2d
5
+ SHA512:
6
+ metadata.gz: f686a8bb5219d1223c4808c986545e79cff08f290647b8d7f6c92a70896f82caace90a70a9582fb3cfc507b75b8bd293f6904a8a4f8eee7c03fca181f4b7793e
7
+ data.tar.gz: 0e5bcb4bf25db5c5edbb7713eb2320f57ea1f9d6810a01922a9e97fa0a032ab28023d4e7534b7dca9ba56eb2812665d720b3ca87fe50f71d6714f13001660062
@@ -0,0 +1,46 @@
1
+ # Catspeak
2
+
3
+ This is a gem for translating human language to cat language.
4
+
5
+ ## Installation
6
+
7
+ gem install catspeak
8
+
9
+ ## Usage
10
+
11
+ To use catspeak, you have to require the gem
12
+
13
+ require 'catspeak'
14
+
15
+ To create a new cat,
16
+
17
+ tom = Catspeak::Cat.new("Tom")
18
+
19
+ To translate human language to cat language,
20
+
21
+ puts tom.speak("Hello!")
22
+
23
+ You will get
24
+
25
+ "meaO?-?- Me--Mw--mIU\\(-.-)/ "
26
+
27
+ To translate cat language back to human language,
28
+
29
+ puts tom.listen("meaO?-?- Me--Mw--mIU\\(-.-)/ ")
30
+
31
+ You will get
32
+
33
+ "Hello!"
34
+
35
+
36
+ ## Licence
37
+
38
+ MIT licence
39
+
40
+ Copyright (C) 2012-2019 by Chungsang Tom Lam
41
+
42
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
43
+
44
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
45
+
46
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
21
21
  # specify any dependencies here; for example:
22
22
  s.add_development_dependency "rspec"
23
23
  # s.add_runtime_dependency "rest-client"
24
+
24
25
  end
25
26
 
26
27
 
@@ -3,7 +3,14 @@ require "catspeak/cat"
3
3
 
4
4
  module Catspeak
5
5
  def cat(name = '')
6
- Cat.new(name)
7
- end
6
+ Cat.new(name)
7
+ end
8
8
  end
9
9
 
10
+
11
+
12
+
13
+
14
+
15
+
16
+
@@ -1,6 +1,6 @@
1
1
  require 'catspeak/translator'
2
2
 
3
-
3
+ # TODO: add unicode spec
4
4
  module Catspeak
5
5
 
6
6
  class Cat
@@ -16,12 +16,9 @@ module Catspeak
16
16
  human_to_cat(@name,statement)
17
17
  end
18
18
 
19
- def hear(statement = '')
19
+ def listen(statement = '')
20
20
  cat_to_human(@name,statement)
21
21
  end
22
22
 
23
23
  end
24
-
25
-
26
-
27
24
  end
@@ -3,6 +3,14 @@ require 'catspeak/encrypter'
3
3
 
4
4
  module Translator
5
5
  module NumberLang
6
+ # TODO: consider restructuring the whole Gem. There should be no "NumberLang".
7
+ # Instead there should be a HumanLang, which define "human_to_number" and "number_to_human"
8
+ # While CatLang also define "cat_to_number" and "cat_to_human"
9
+ # And the Cat class simply implement both humanlang and catlang
10
+ # Together with the concept of making CatLang module a generic module. There should be 2 generic module of translator. Say "encrypt translator" and "dictionary translator", the HumanLang and and CatLang implement them respectively.
11
+
12
+ # TODO: HumanLang class should be English instead. So that future lang can deal with Unicode languages
13
+
6
14
  def human_to_number(name, human_text)
7
15
  number_text = human_text
8
16
  #number_text = Zlib::deflate(human_text, 1)
@@ -23,6 +31,12 @@ module Translator
23
31
 
24
32
  end
25
33
 
34
+ # TODO: should turn this CatLang module into a generic Lang module.
35
+ # Where there are char_dict instead of cat_char_dict ....etc.
36
+ # And the CatLang should just overwrite the char_dict files with cat specific dictionary
37
+ # The cat specific thing should be specified in the Cat Class, in the Cat class it should include the CatLang to show that it's a cat
38
+
39
+
26
40
  module CatLang
27
41
  include NumberLang
28
42
 
@@ -66,13 +80,18 @@ module Translator
66
80
 
67
81
  def cat_tone_dict
68
82
  [
69
- ' ' ,' ' ,'!!~' ,'~!!','~??','?~?','!~!',
70
- '.' ,'. ' ,'...' ,'??~p',
83
+ ' ' ,' ' ,' ',
84
+ '.' ,'. ' ,'...' ,'... ',' ...',' ... ',
85
+ '??~','!!~' ,'~!!','~??','?~?','!~!',' ??~',' !!~' ,' ~!!',' ~??',' ?~?',' !~!',
71
86
  '^','^^','^ ','^^ ','~^','~^ ','~~^','~~^ ','~~?','~~? ','~~!','~~! ',
72
87
  ' ~~^',' ~~^ ',' ~~?',' ~~? ',' ~~!',' ~~! ',' ~^',' ~^ ',
73
- '! ','~ ','- ','? ','. ',
74
- ' !',' ~',' -',' ?',' .',
75
- ' ! ',' ~ ',' - ',' ? ',' . ',
88
+ ',',', ',
89
+ ':',': ',
90
+ '! ','~ ','- ','? ','. ',', ',': ',
91
+ ' !',' ~',' -',' ?',' .',' ,',' :',
92
+ ' ! ',' ~ ',' - ',' ? ',' . ',' , ',' : ',
93
+ ' !!',' ??',' ~~',
94
+ "'"," '","' ",
76
95
  '!' ,'!!' ,'!!!' ,'!!!!','! ' ,'!! ' ,'!!! ' ,'!!!! ',
77
96
  '~' ,'~~' ,'~~~' ,'~~~~','~ ' ,'~~ ' ,'~~~ ' ,'~~~~ ',
78
97
  '-' ,'--' ,'---' ,'----','- ' ,'-- ' ,'--- ' ,'---- ',
@@ -81,28 +100,20 @@ module Translator
81
100
  "?!!!", "?!!?", "?!?!", "?!??", "??!!", "??!?", "???!",
82
101
  "!!!? ", "!!?! ", "!!?? ", "!?!! ", "!?!? ", "!??! ", "!??? ",
83
102
  "?!!! ", "?!!? ", "?!?! ", "?!?? ", "??!! ", "??!? ", "???! ",
84
- "~~~?", "~~?~", "~~??", "~?~~", "~?~?", "~??~", "~???",
85
- "?~~~", "?~~?", "?~?~", "?~??", "??~~", "??~?", "???~",
86
- "~~~? ", "~~?~ ", "~~?? ", "~?~~ ", "~?~? ", "~??~ ", "~??? ",
87
- "?~~~ ", "?~~? ", "?~?~ ", "?~?? ", "??~~ ", "??~? ", "???~ ",
88
- "~~~!", "~~!~", "~~!!", "~!~~", "~!~!", "~!!~", "~!!!",
89
- "!~~~", "!~~!", "!~!~", "!~!!", "!!~~", "!!~!", "!!!~",
90
- "~~~! ", "~~!~ ", "~~!! ", "~!~~ ", "~!~! ", "~!!~ ", "~!!! ",
91
- "!~~~ ", "!~~! ", "!~!~ ", "!~!! ", "!!~~ ", "!!~! ", "!!!~ ",
92
- "---?", "--?-", "--??", "-?--", "-?-?", "-??-", "-???",
93
- "?---", "?--?", "?-?-", "?-??", "??--", "??-?", "???-",
94
- "---? ", "--?- ", "--?? ", "-?-- ", "-?-? ", "-??- ", "-??? ",
95
- "?--- ", "?--? ", "?-?- ", "?-?? ", "??-- ", "??-? ", "???- ",
96
- "---!", "--!-", "--!!", "-!--", "-!-!", "-!!-", "-!!!",
97
- "!---", "!--!", "!-!-", "!-!!", "!!--", "!!-!", "!!!-",
98
- "---! ", "--!- ", "--!! ", "-!-- ", "-!-! ", "-!!- ", "-!!! ",
99
- "!--- ", "!--! ", "!-!- ", "!-!! ", "!!-- ", "!!-! ", "!!!- ",
103
+ "~~~?", "~~??", "~?~?", "~???", "?~~~", "?~~?", "?~?~", "?~??", "??~~", "??~?", "???~",
104
+ "~~~? ", "~~?? ", "~?~? ", "~??? ", "?~~~ ", "?~~? ", "?~?~ ", "?~?? ", "??~~ ", "??~? ", "???~ ",
105
+ "~~~!", "~~!!", "~!~!", "~!!!", "!~~~", "!~~!", "!~!~", "!~!!", "!!~~", "!!~!", "!!!~",
106
+ "~~~! ", "~~!! ", "~!~! ", "~!!! ", "!~~~ ", "!~~! ", "!~!~ ", "!~!! ", "!!~~ ", "!!~! ", "!!!~ ",
107
+ "---?", "--??", "-?-?", "-???", "?---", "?-?-", "?-??", "??-?", "???-",
108
+ "---!", "--!!", "-!-!", "-!!!", "!---", "!-!-", "!-!!", "!!-!", "!!!-",
109
+ "---? ", "--?? ", "-?-? ", "-??? ", "?--- ", "?-?- ", "?-?? ", "??-? ", "???- ",
110
+ "---! ", "--!! ", "-!-! ", "-!!! ", "!--- ", "!-!- ", "!-!! ", "!!-! ", "!!!- ",
100
111
  '=(>.<)=', '-(>.<)-','=(".")=','-(".")-',"=('.')=","-('.')-",
101
- '\(>.<)/', '\(".")/','=(^.^)=','-(^.^)-','\(^.^)/','=(*.*)=',
102
- '-(*.*)-', '\(*.*)/','=(`.`)=','-(`.`)-','\(`.`)/','=(-.-)=','\(-.-)/',
112
+ '\(>.<)/', '\(".")/','=(^.^)=','-(^.^)-','\(^.^)/','=(~.~)=', '-(~.~)-', '\(~.~)/',
113
+ '=(*.*)=', '-(*.*)-', '\(*.*)/','=(`.`)=','-(`.`)-','\(`.`)/','=(-.-)=','\(-.-)/',
103
114
  '=(>.<)= ', '-(>.<)- ','=(".")= ','-(".")- ',"=('.')= ","-('.')- ",
104
- '\(>.<)/ ', '\(".")/ ','=(^.^)= ','-(^.^)- ','\(^.^)/ ','=(*.*)= ',
105
- '-(*.*)- ', '\(*.*)/ ','=(`.`)= ','-(`.`)- ','\(`.`)/ ','=(-.-)= ','\(-.-)/ '
115
+ '\(>.<)/ ', '\(".")/ ','=(^.^)= ','-(^.^)- ','\(^.^)/ ','=(~.~)= ', '-(~.~)- ', '\(~.~)/ ',
116
+ '=(*.*)= ', '-(*.*)- ', '\(*.*)/ ','=(`.`)= ','-(`.`)- ','\(`.`)/ ','=(-.-)= ','\(-.-)/ '
106
117
  ]
107
118
 
108
119
  end
@@ -133,7 +144,7 @@ module Translator
133
144
 
134
145
  def human_to_cat(name, human_text)
135
146
  number_text = human_to_number(name, human_text)
136
- cat_text = number_to_cat(number_text)
147
+ number_to_cat(number_text)
137
148
  end
138
149
 
139
150
  def cat_to_human(name, cat_text)
@@ -142,13 +153,16 @@ module Translator
142
153
  end
143
154
 
144
155
  def decompose(statement)
145
- a1 = statement.split(/\W+/)
146
- a2 = statement.split(/\w+/)
147
- a2.delete_at(0)
148
- a2.each_index do |i|
149
- a1.insert(2*i+1,a2[i])
150
- end
151
- a1
156
+ # TODO: should get the regular expression from the dictionary. Simply get all the characters from it and get the unique characters
157
+
158
+ statement.scan(/(\w+)?(\W+)?/).flatten.compact
159
+ #a1 = statement.split(/\W+/)
160
+ #a2 = statement.split(/\w+/)
161
+ #a2.delete_at(0)
162
+ #a2.each_index do |i|
163
+ # a1.insert(2*i+1,a2[i])
164
+ #end
165
+ #a1
152
166
 
153
167
  #a3 = []
154
168
  #a1.each_index do |i|
@@ -1,3 +1,3 @@
1
1
  module Catspeak
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
data/logfile ADDED
@@ -0,0 +1,83 @@
1
+ commit e6580fd785f44b53db4223b6063cc0e01cef1b89
2
+ Author: Chungsang Tom Lam <erinata@gmail.com>
3
+ Date: Sun Feb 21 04:12:02 2016 -0500
4
+
5
+ fix typo
6
+
7
+ commit 3f5aa895ba583b52c6617a194863d6a009d34772
8
+ Author: erinata <erinata@gmail.com>
9
+ Date: Tue Apr 3 07:13:55 2012 -0500
10
+
11
+ write readme
12
+
13
+ commit 45603b7f0c727b67507ee8251e02f40c6360641a
14
+ Author: erinata <erinata@gmail.com>
15
+ Date: Fri Mar 30 20:12:35 2012 -0500
16
+
17
+ at more comment as TODO
18
+
19
+ commit 998cbba60e5d7abf87f6949a59f43853403c05e6
20
+ Author: erinata <erinata@gmail.com>
21
+ Date: Tue Mar 27 00:32:36 2012 -0500
22
+
23
+ use better method to decompose
24
+
25
+ commit 1ead258e584ed9e7b5ce84284e570f29f24ccef8
26
+ Author: erinata <erinata@gmail.com>
27
+ Date: Mon Mar 26 14:17:32 2012 -0500
28
+
29
+ treak the cat dict a little bit
30
+
31
+ commit 3a9bd4d3912f46425c69903f686c2bf54d118f6a
32
+ Author: erinata <erinata@gmail.com>
33
+ Date: Mon Mar 26 04:51:20 2012 -0500
34
+
35
+ change dictionary
36
+
37
+ commit 741cb3cdfced1b81eea7bc71b6c6b8ff5996b4dc
38
+ Author: erinata <erinata@gmail.com>
39
+ Date: Mon Mar 26 01:04:14 2012 -0500
40
+
41
+ dummy
42
+
43
+ commit f2dd052fad0a4507667c434bcfa38c9f1147913e
44
+ Author: erinata <erinata@gmail.com>
45
+ Date: Mon Mar 26 00:12:24 2012 -0500
46
+
47
+ add hear method
48
+
49
+ commit d51eb0515f5325748979d25044e9ed1333afe8de
50
+ Author: erinata <erinata@gmail.com>
51
+ Date: Sun Mar 25 06:53:02 2012 -0500
52
+
53
+ add translator to speak
54
+
55
+ commit 27fc15f671f1c6b9de45d5e03d710c5649bd6e9f
56
+ Author: erinata <erinata@gmail.com>
57
+ Date: Sun Mar 25 06:50:02 2012 -0500
58
+
59
+ Add CatLang
60
+
61
+ commit 2e20371d21010f4a8752cc7876c0a742a8571c2f
62
+ Author: erinata <erinata@gmail.com>
63
+ Date: Sat Mar 24 21:17:43 2012 -0500
64
+
65
+ add spec
66
+
67
+ commit 688a25307c79a44d052df651dd627f8769eccf20
68
+ Author: erinata <erinata@gmail.com>
69
+ Date: Tue Mar 20 14:51:52 2012 -0500
70
+
71
+ add class method to make new cat
72
+
73
+ commit 43c10d910677dbf6f266c6bb1f9d440b9ebedf37
74
+ Author: erinata <erinata@gmail.com>
75
+ Date: Tue Mar 20 14:45:42 2012 -0500
76
+
77
+ add stub for cat class and speak method
78
+
79
+ commit a6bdb9a74562eef3b0c5c39e117ac8b920fbaedd
80
+ Author: erinata <erinata@gmail.com>
81
+ Date: Tue Mar 20 14:25:18 2012 -0500
82
+
83
+ initial commit
@@ -14,11 +14,11 @@ describe 'Cat' do
14
14
  end
15
15
 
16
16
  it "should speak in cat lang" do
17
- Catspeak::Cat.new('Kitty').speak('Hello').should == 'MM M^Mu!M~MEOW!!!Mi? Ma'
18
- end
17
+ Catspeak::Cat.new('Kitty').speak('Hello').should == 'mEOU MAow??!!maow-??? MeeoW????'
18
+ end
19
19
 
20
20
  it "should understand cat lang" do
21
- Catspeak::Cat.new('Kitty').hear('MM M^Mu!M~MEOW!!!Mi? Ma').should == 'Hello'
21
+ Catspeak::Cat.new('Kitty').listen('mEOU MAow??!!maow-??? MeeoW????').should == 'Hello'
22
22
  end
23
23
 
24
24
  end
@@ -7,5 +7,8 @@ describe "Catspeak" do
7
7
  cat().should be_an_instance_of Catspeak::Cat
8
8
  end
9
9
 
10
+ # TODO create custom animals by supplying characters and let the Gem from the char and tone dictionary
11
+
10
12
  end
11
13
 
14
+
@@ -1,4 +1,4 @@
1
- require 'catspeak\Translator'
1
+ require 'catspeak/Translator'
2
2
 
3
3
  describe "NumberLang" do
4
4
  include Translator::NumberLang
@@ -14,6 +14,8 @@ describe "NumberLang" do
14
14
  end
15
15
 
16
16
  describe "CatLang" do
17
+ # TODO: test should cover whether the char and tone dictionary have mutually exclusive characters
18
+
17
19
  include Translator::CatLang
18
20
 
19
21
  it "should translate cat lang to number lang" do
@@ -25,11 +27,11 @@ describe "CatLang" do
25
27
  end
26
28
 
27
29
  it "should translate human lang to cat lang" do
28
- human_to_cat("Kitty","Hello").should == 'mEOU MAow?~?~maow!---MeeoW?!!! '
30
+ human_to_cat("Kitty","Hello").should == 'mEOU MAow??!!maow-??? MeeoW????'
29
31
  end
30
32
 
31
33
  it "should translate cat lang to human lang" do
32
- cat_to_human("Kitty",'mEOU MAow?~?~maow!---MeeoW?!!! ').should == "Hello"
34
+ cat_to_human("Kitty",'mEOU MAow??!!maow-??? MeeoW????').should == "Hello"
33
35
  end
34
36
 
35
37
  it "should be consistent in translating betwen cat and human lang" do
metadata CHANGED
@@ -1,27 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: catspeak
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
5
- prerelease:
4
+ version: 0.3.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - erinata
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-03-26 00:00:00.000000000 Z
11
+ date: 2019-04-14 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rspec
16
- requirement: &25494168 !ruby/object:Gem::Requirement
17
- none: false
15
+ requirement: !ruby/object:Gem::Requirement
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
- version_requirements: *25494168
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
25
27
  description: You can view it as some kind of encryption and decrpytion gem...........
26
28
  but cats do speak.
27
29
  email:
@@ -30,9 +32,10 @@ executables: []
30
32
  extensions: []
31
33
  extra_rdoc_files: []
32
34
  files:
33
- - .gitignore
34
- - .rspec
35
+ - ".gitignore"
36
+ - ".rspec"
35
37
  - Gemfile
38
+ - README.md
36
39
  - Rakefile
37
40
  - catspeak.gemspec
38
41
  - lib/catspeak.rb
@@ -40,31 +43,34 @@ files:
40
43
  - lib/catspeak/encrypter.rb
41
44
  - lib/catspeak/translator.rb
42
45
  - lib/catspeak/version.rb
46
+ - logfile
43
47
  - spec/cat_spec.rb
44
48
  - spec/catspeak_spec.rb
45
49
  - spec/translator_spec.rb
46
50
  homepage: ''
47
51
  licenses: []
52
+ metadata: {}
48
53
  post_install_message:
49
54
  rdoc_options: []
50
55
  require_paths:
51
56
  - lib
52
57
  required_ruby_version: !ruby/object:Gem::Requirement
53
- none: false
54
58
  requirements:
55
- - - ! '>='
59
+ - - ">="
56
60
  - !ruby/object:Gem::Version
57
61
  version: '0'
58
62
  required_rubygems_version: !ruby/object:Gem::Requirement
59
- none: false
60
63
  requirements:
61
- - - ! '>='
64
+ - - ">="
62
65
  - !ruby/object:Gem::Version
63
66
  version: '0'
64
67
  requirements: []
65
68
  rubyforge_project: catspeak
66
- rubygems_version: 1.8.17
69
+ rubygems_version: 2.7.7
67
70
  signing_key:
68
- specification_version: 3
71
+ specification_version: 4
69
72
  summary: Catspeak provides translation between Human Language and Cats' language
70
- test_files: []
73
+ test_files:
74
+ - spec/cat_spec.rb
75
+ - spec/catspeak_spec.rb
76
+ - spec/translator_spec.rb