zweikopf 1.0.0 → 1.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.
- checksums.yaml +7 -0
- data/.ruby-version +1 -0
- data/.travis.yml +1 -1
- data/README.md +9 -3
- data/Rakefile +1 -0
- data/deps/clojure-1.7.0.jar +0 -0
- data/lib/zweikopf/transformer.rb +2 -3
- data/lib/zweikopf/version.rb +1 -1
- data/project.clj +3 -4
- data/spec/fixtures/clj_lazy_seq1.clj +1 -0
- data/spec/zweikopf/transformer_clojure_to_ruby_spec.rb +17 -0
- data/src/zweikopf/multi.clj +14 -1
- data/test/zweikopf/core_test.clj +2 -0
- metadata +103 -104
- data/.rvmrc +0 -1
- data/deps/clojure-1.4.0.jar +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 441deb2e56212d746e64102a8c2abc9ae8669b70
|
4
|
+
data.tar.gz: 0536cdae458df55db90f1143866bff17ff595bc9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 095f62e14737396c05c4ae783e099c854797fe67474f3e2a1cf48859d0879c063a7c43a0fadd928236ac13050e952a3e994d18a2fc31d3cfefe675019ea9b7aa
|
7
|
+
data.tar.gz: b6e2f02aaa5e436f79d60ceebda64e56efd89e872e43607a3a07bef54b03ca14dff369bc7d720ef8a2aab33e800a28fc1ac255fe43afc9655483efb5b911dd98
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
jruby-1.7.10
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Zweikopf, a two-headed JVM friend of yours.
|
2
2
|
[](http://travis-ci.org/ifesdjeen/zweikopf)
|
3
3
|
|
4
|
-
Zweikopf helps you to interoperate between Clojure and JRuby on JVM.
|
4
|
+
Zweikopf ([pronunciation](http://translate.google.de/translate_tts?ie=UTF-8&q=zweikopf&tl=de&total=1&idx=0&textlen=8&prev=input)) helps you to interoperate between Clojure and JRuby on JVM.
|
5
5
|
|
6
6
|
## Installation
|
7
7
|
|
@@ -20,8 +20,15 @@ Or install it yourself as:
|
|
20
20
|
For Clojure-driven projects, add this line to your `project.clj`:
|
21
21
|
|
22
22
|
```clojure
|
23
|
-
[zweikopf "0.
|
23
|
+
[zweikopf "1.0.0"]
|
24
24
|
```
|
25
|
+
|
26
|
+
For Ruby-driven ones, just add the following line to your Gemspec:
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
gem "zweikopf", "~> 1.0.0"
|
30
|
+
```
|
31
|
+
|
25
32
|
## Usage
|
26
33
|
|
27
34
|
### From Ruby code: Clojure->Ruby transformations
|
@@ -169,4 +176,3 @@ Distributed under the Eclipse Public License, the same as Clojure.
|
|
169
176
|
|
170
177
|
|
171
178
|
[](https://bitdeli.com/free "Bitdeli Badge")
|
172
|
-
|
data/Rakefile
CHANGED
Binary file
|
data/lib/zweikopf/transformer.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
java_import "clojure.lang.IPersistentMap"
|
2
|
-
java_import "clojure.lang.
|
3
|
-
java_import "clojure.lang.IPersistentList"
|
2
|
+
java_import "clojure.lang.Seqable"
|
4
3
|
java_import "clojure.lang.Keyword"
|
5
4
|
java_import "clojure.lang.Ratio"
|
6
5
|
|
@@ -36,7 +35,7 @@ module Zweikopf
|
|
36
35
|
obj
|
37
36
|
elsif obj.is_a?(IPersistentMap)
|
38
37
|
Hash.from_clj(obj, &block)
|
39
|
-
elsif obj.is_a?(
|
38
|
+
elsif obj.is_a?(Seqable)
|
40
39
|
Array.from_clj(obj, &block)
|
41
40
|
elsif obj.is_a?(::Keyword)
|
42
41
|
Keyword.from_clj(obj)
|
data/lib/zweikopf/version.rb
CHANGED
data/project.clj
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
(defproject zweikopf "1.0.
|
1
|
+
(defproject zweikopf "1.0.1"
|
2
2
|
:description "jruby clojure interop"
|
3
|
-
:dependencies [[org.clojure/clojure "1.
|
4
|
-
[org.jruby/jruby-complete "1.7.
|
5
|
-
:profiles {:dev {:dependencies []}})
|
3
|
+
:dependencies [[org.clojure/clojure "1.7.0"]
|
4
|
+
[org.jruby/jruby-complete "1.7.10"]])
|
@@ -0,0 +1 @@
|
|
1
|
+
(lazy-seq [:a 1 :b 2 :c 3])
|
@@ -66,6 +66,23 @@ describe Zweikopf do
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
+
context "when given a clojure lazy seq" do
|
70
|
+
|
71
|
+
#
|
72
|
+
# Environment
|
73
|
+
#
|
74
|
+
|
75
|
+
let(:clj_lazy_seq) { load_fixture(:clj_lazy_seq1) }
|
76
|
+
|
77
|
+
#
|
78
|
+
# Examples
|
79
|
+
#
|
80
|
+
|
81
|
+
it "creates a Ruby array" do
|
82
|
+
Zweikopf::Transformer.from_clj(clj_lazy_seq).should eql([:a, 1, :b, 2, :c, 3])
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
69
86
|
|
70
87
|
context "when given a hash that contains array that has a hash as an item" do
|
71
88
|
|
data/src/zweikopf/multi.clj
CHANGED
@@ -10,6 +10,7 @@
|
|
10
10
|
RubyObject
|
11
11
|
RubyRational
|
12
12
|
RubyString
|
13
|
+
RubyStruct
|
13
14
|
RubySymbol)))
|
14
15
|
|
15
16
|
(defprotocol Clojurize
|
@@ -53,6 +54,18 @@
|
|
53
54
|
(clojurize [this _]
|
54
55
|
(clojure.lang.Keyword/intern (.toString this)))
|
55
56
|
|
57
|
+
RubyStruct
|
58
|
+
(clojurize [this ruby]
|
59
|
+
(let [context (.getCurrentContext (runtime ruby))
|
60
|
+
null-block org.jruby.runtime.Block/NULL_BLOCK]
|
61
|
+
(persistent!
|
62
|
+
(reduce (fn [acc [key val]]
|
63
|
+
(assoc! acc
|
64
|
+
(keyword (clojurize key ruby))
|
65
|
+
(clojurize val ruby)))
|
66
|
+
(transient {})
|
67
|
+
(call-ruby ruby (.each_pair this context null-block) :to_a)))))
|
68
|
+
|
56
69
|
RubyHash
|
57
70
|
(clojurize [this ruby]
|
58
71
|
(persistent!
|
@@ -134,7 +147,7 @@
|
|
134
147
|
|
135
148
|
clojure.lang.Keyword
|
136
149
|
(rubyize [this ruby]
|
137
|
-
(.
|
150
|
+
(.newSymbol (runtime ruby) (name this)))
|
138
151
|
|
139
152
|
java.lang.Object
|
140
153
|
(rubyize [this _]
|
data/test/zweikopf/core_test.clj
CHANGED
@@ -19,6 +19,8 @@
|
|
19
19
|
(is (= 1/3 (clojurize (ruby-eval "Rational(1,3)")))))
|
20
20
|
(testing "Big Decimals"
|
21
21
|
(is (= 12.34M (clojurize (ruby-eval "require 'bigdecimal'; BigDecimal.new(12.34,4)"))))))
|
22
|
+
(testing "Struct"
|
23
|
+
(is (= {:a 1 :b 2} (clojurize (ruby-eval "Struct.new(:a, :b).new(1, 2)")))))
|
22
24
|
(testing "Empty hash"
|
23
25
|
(is (= {} (clojurize (ruby-eval "{}")))))
|
24
26
|
(testing "Non-empty hash"
|
metadata
CHANGED
@@ -1,116 +1,115 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: zweikopf
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
version: 1.0.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.1
|
6
5
|
platform: ruby
|
7
|
-
authors:
|
8
|
-
|
9
|
-
autorequire:
|
6
|
+
authors:
|
7
|
+
- Oleksandr Petrov
|
8
|
+
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
11
|
+
date: 2015-08-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - '>='
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: '0'
|
19
|
+
name: rake
|
20
|
+
prerelease: false
|
21
|
+
type: :development
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
name: rspec
|
34
|
+
prerelease: false
|
35
|
+
type: :development
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
37
41
|
description: Rubygem for jruby/clojure interop
|
38
|
-
email:
|
39
|
-
|
42
|
+
email:
|
43
|
+
- oleksandr.petrov@gmail.com
|
40
44
|
executables: []
|
41
|
-
|
42
45
|
extensions: []
|
43
|
-
|
44
46
|
extra_rdoc_files: []
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
homepage:
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- .rspec
|
50
|
+
- .ruby-version
|
51
|
+
- .travis.yml
|
52
|
+
- Gemfile
|
53
|
+
- LICENSE
|
54
|
+
- README.md
|
55
|
+
- Rakefile
|
56
|
+
- deps/clojure-1.7.0.jar
|
57
|
+
- lib/zweikopf.rb
|
58
|
+
- lib/zweikopf/array.rb
|
59
|
+
- lib/zweikopf/hash.rb
|
60
|
+
- lib/zweikopf/keyword.rb
|
61
|
+
- lib/zweikopf/primitive.rb
|
62
|
+
- lib/zweikopf/transformer.rb
|
63
|
+
- lib/zweikopf/version.rb
|
64
|
+
- project.clj
|
65
|
+
- spec/fixtures/clj_array1.clj
|
66
|
+
- spec/fixtures/clj_deep_hash1.clj
|
67
|
+
- spec/fixtures/clj_hash1.clj
|
68
|
+
- spec/fixtures/clj_lazy_seq1.clj
|
69
|
+
- spec/fixtures/complex_hash.clj
|
70
|
+
- spec/fixtures/empty_hash.clj
|
71
|
+
- spec/spec_helper.rb
|
72
|
+
- spec/support/loader.rb
|
73
|
+
- spec/zweikopf/performance_spec.rb
|
74
|
+
- spec/zweikopf/transformer_clojure_to_ruby_spec.rb
|
75
|
+
- spec/zweikopf/transformer_ruby_to_clojure_spec.rb
|
76
|
+
- src/zweikopf/core.clj
|
77
|
+
- src/zweikopf/multi.clj
|
78
|
+
- test/zweikopf/core_test.clj
|
79
|
+
- zweikopf.gemspec
|
80
|
+
homepage: ''
|
79
81
|
licenses: []
|
80
|
-
|
81
|
-
post_install_message:
|
82
|
+
metadata: {}
|
83
|
+
post_install_message:
|
82
84
|
rdoc_options: []
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
- - ">="
|
96
|
-
- !ruby/object:Gem::Version
|
97
|
-
version: "0"
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
98
97
|
requirements: []
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
specification_version: 3
|
98
|
+
rubyforge_project:
|
99
|
+
rubygems_version: 2.1.9
|
100
|
+
signing_key:
|
101
|
+
specification_version: 4
|
104
102
|
summary: Its good, try it out!
|
105
|
-
test_files:
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
103
|
+
test_files:
|
104
|
+
- spec/fixtures/clj_array1.clj
|
105
|
+
- spec/fixtures/clj_deep_hash1.clj
|
106
|
+
- spec/fixtures/clj_hash1.clj
|
107
|
+
- spec/fixtures/clj_lazy_seq1.clj
|
108
|
+
- spec/fixtures/complex_hash.clj
|
109
|
+
- spec/fixtures/empty_hash.clj
|
110
|
+
- spec/spec_helper.rb
|
111
|
+
- spec/support/loader.rb
|
112
|
+
- spec/zweikopf/performance_spec.rb
|
113
|
+
- spec/zweikopf/transformer_clojure_to_ruby_spec.rb
|
114
|
+
- spec/zweikopf/transformer_ruby_to_clojure_spec.rb
|
115
|
+
- test/zweikopf/core_test.clj
|
data/.rvmrc
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
rvm use jruby-1.6.7.2
|
data/deps/clojure-1.4.0.jar
DELETED
Binary file
|