zweikopf 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -2,4 +2,4 @@ rvm:
2
2
  - jruby
3
3
  jdk:
4
4
  - openjdk7
5
- script: "rake && lein2 test"
5
+ script: "wget https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein && chmod +x lein && rake && ./lein test"
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # Zweikopf, a two-headed JVM friend of yours.
2
2
  [![Continuous Integration status](https://secure.travis-ci.org/ifesdjeen/zweikopf.png)](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.4.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
  [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/ifesdjeen/zweikopf/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
172
-
data/Rakefile CHANGED
@@ -8,6 +8,7 @@ task :default => 'spec:all'
8
8
  namespace :spec do
9
9
  desc "Run all specs"
10
10
  RSpec::Core::RakeTask.new('all') do |t|
11
+ # t.expect_with(:rspec) { |c| c.syntax = :should }
11
12
  t.pattern = 'spec/{**/*_spec.rb}'
12
13
  end
13
14
  end
Binary file
@@ -1,6 +1,5 @@
1
1
  java_import "clojure.lang.IPersistentMap"
2
- java_import "clojure.lang.IPersistentVector"
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?(IPersistentVector || IPersistentList)
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)
@@ -1,3 +1,3 @@
1
1
  module Zweikopf
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
data/project.clj CHANGED
@@ -1,5 +1,4 @@
1
- (defproject zweikopf "1.0.0"
1
+ (defproject zweikopf "1.0.1"
2
2
  :description "jruby clojure interop"
3
- :dependencies [[org.clojure/clojure "1.4.0"]
4
- [org.jruby/jruby-complete "1.7.1"]]
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
 
@@ -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
- (.fastNewSymbol (runtime ruby) (name this)))
150
+ (.newSymbol (runtime ruby) (name this)))
138
151
 
139
152
  java.lang.Object
140
153
  (rubyize [this _]
@@ -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
- prerelease:
5
- version: 1.0.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
6
5
  platform: ruby
7
- authors:
8
- - Oleksandr Petrov
9
- autorequire:
6
+ authors:
7
+ - Oleksandr Petrov
8
+ autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
-
13
- date: 2014-01-28 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: rake
17
- prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
19
- none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: "0"
24
- type: :development
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
27
- name: rspec
28
- prerelease: false
29
- requirement: &id002 !ruby/object:Gem::Requirement
30
- none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: "0"
35
- type: :development
36
- version_requirements: *id002
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
- - oleksandr.petrov@gmail.com
42
+ email:
43
+ - oleksandr.petrov@gmail.com
40
44
  executables: []
41
-
42
45
  extensions: []
43
-
44
46
  extra_rdoc_files: []
45
-
46
- files:
47
- - .gitignore
48
- - .rspec
49
- - .rvmrc
50
- - .travis.yml
51
- - Gemfile
52
- - LICENSE
53
- - README.md
54
- - Rakefile
55
- - deps/clojure-1.4.0.jar
56
- - lib/zweikopf.rb
57
- - lib/zweikopf/array.rb
58
- - lib/zweikopf/hash.rb
59
- - lib/zweikopf/keyword.rb
60
- - lib/zweikopf/primitive.rb
61
- - lib/zweikopf/transformer.rb
62
- - lib/zweikopf/version.rb
63
- - project.clj
64
- - spec/fixtures/clj_array1.clj
65
- - spec/fixtures/clj_deep_hash1.clj
66
- - spec/fixtures/clj_hash1.clj
67
- - spec/fixtures/complex_hash.clj
68
- - spec/fixtures/empty_hash.clj
69
- - spec/spec_helper.rb
70
- - spec/support/loader.rb
71
- - spec/zweikopf/performance_spec.rb
72
- - spec/zweikopf/transformer_clojure_to_ruby_spec.rb
73
- - spec/zweikopf/transformer_ruby_to_clojure_spec.rb
74
- - src/zweikopf/core.clj
75
- - src/zweikopf/multi.clj
76
- - test/zweikopf/core_test.clj
77
- - zweikopf.gemspec
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
- require_paths:
85
- - lib
86
- required_ruby_version: !ruby/object:Gem::Requirement
87
- none: false
88
- requirements:
89
- - - ">="
90
- - !ruby/object:Gem::Version
91
- version: "0"
92
- required_rubygems_version: !ruby/object:Gem::Requirement
93
- none: false
94
- requirements:
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
- rubyforge_project:
101
- rubygems_version: 1.8.24
102
- signing_key:
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
- - spec/fixtures/clj_array1.clj
107
- - spec/fixtures/clj_deep_hash1.clj
108
- - spec/fixtures/clj_hash1.clj
109
- - spec/fixtures/complex_hash.clj
110
- - spec/fixtures/empty_hash.clj
111
- - spec/spec_helper.rb
112
- - spec/support/loader.rb
113
- - spec/zweikopf/performance_spec.rb
114
- - spec/zweikopf/transformer_clojure_to_ruby_spec.rb
115
- - spec/zweikopf/transformer_ruby_to_clojure_spec.rb
116
- - test/zweikopf/core_test.clj
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
Binary file