dcrec1-rhyme 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.
@@ -0,0 +1,51 @@
1
+ = rhyme
2
+
3
+ * FIX (url)
4
+
5
+ == DESCRIPTION:
6
+
7
+ FIX (describe your package)
8
+
9
+ == FEATURES/PROBLEMS:
10
+
11
+ * FIX (list of features or problems)
12
+
13
+ == SYNOPSIS:
14
+
15
+ require "java"
16
+ map = java.util.HashMap.new
17
+ ... (populate map) ...
18
+ hash = Rhyme.translate(map)
19
+
20
+ == REQUIREMENTS:
21
+
22
+ jruby
23
+
24
+ == INSTALL:
25
+
26
+ sudo gem install
27
+
28
+ == LICENSE:
29
+
30
+ (The MIT License)
31
+
32
+ Copyright (c) 2008 Rhyme
33
+
34
+ Permission is hereby granted, free of charge, to any person obtaining
35
+ a copy of this software and associated documentation files (the
36
+ 'Software'), to deal in the Software without restriction, including
37
+ without limitation the rights to use, copy, modify, merge, publish,
38
+ distribute, sublicense, and/or sell copies of the Software, and to
39
+ permit persons to whom the Software is furnished to do so, subject to
40
+ the following conditions:
41
+
42
+ The above copyright notice and this permission notice shall be
43
+ included in all copies or substantial portions of the Software.
44
+
45
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
46
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
47
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
48
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
49
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
50
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
51
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,23 @@
1
+ require "date"
2
+
3
+ module Rhyme
4
+
5
+ def self.translate(x)
6
+ case x.class.to_s
7
+ when "Java::JavaUtil::HashMap" then self.translate_map(x)
8
+ when "Java::JavaUtil::Date" then self.translate_date(x)
9
+ else x
10
+ end
11
+ end
12
+
13
+ def self.translate_map(map)
14
+ hash = Hash.new
15
+ map.key_set.each { |key| hash[key] = translate(map.get(key)) }
16
+ return hash
17
+ end
18
+
19
+ def self.translate_date(javaDate)
20
+ Date.parse(Time.at(javaDate.getTime).strftime('%Y/%m/%d'))
21
+ end
22
+
23
+ end
@@ -0,0 +1,11 @@
1
+ module Rhyme
2
+
3
+ module VERSION #:nodoc:
4
+ MAJOR = 0
5
+ MINOR = 0
6
+ TINY = 1
7
+
8
+ STRING = [MAJOR, MINOR, TINY].join('.')
9
+ end
10
+
11
+ end
@@ -0,0 +1,25 @@
1
+ require File.dirname(__FILE__) + '/../lib/rhyme'
2
+
3
+ require "date"
4
+ require "java"
5
+
6
+ describe Rhyme do
7
+
8
+ it "should translate a Map" do
9
+ Rhyme.translate(java.util.HashMap.new).class.should eql(Hash.new.class)
10
+ end
11
+
12
+ it "should translates map values" do
13
+ jmap = java.util.HashMap.new
14
+ jmap.put "key1", "value"
15
+ jmap.put "key2", java.util.Date.new(1234567890)
16
+ rmap = Rhyme.translate(jmap)
17
+ rmap["key1"].should eql("value")
18
+ rmap["key2"].to_s.should eql("2009-02-13")
19
+ end
20
+
21
+ it "should translate a Date" do
22
+ Rhyme.translate(java.util.Date.new(1234567890)).to_s.should eql("2009-02-13")
23
+ end
24
+
25
+ end
metadata ADDED
@@ -0,0 +1,55 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dcrec1-rhyme
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Diego Carrion
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-08-13 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: dc.rec1@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README.txt
24
+ files:
25
+ - lib/rhyme.rb
26
+ - lib/rhyme/version.rb
27
+ - README.txt
28
+ has_rdoc: true
29
+ homepage: http://www.mouseoverstudio.com/blog/
30
+ post_install_message:
31
+ rdoc_options: []
32
+
33
+ require_paths:
34
+ - lib
35
+ required_ruby_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: "0"
40
+ version:
41
+ required_rubygems_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: "0"
46
+ version:
47
+ requirements: []
48
+
49
+ rubyforge_project:
50
+ rubygems_version: 1.2.0
51
+ signing_key:
52
+ specification_version: 2
53
+ summary: A Java to Ruby objects translator
54
+ test_files:
55
+ - test/test_rhyme.rb