jruby_coercion 0.0.6-java → 0.0.7-java

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,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 905377aebf693793f7b9d5bfc0cea6adfd08e613
4
+ data.tar.gz: 27782c5bf5ce2f1d9fb1a4553b4bab40e3394400
5
+ SHA512:
6
+ metadata.gz: be51ce50beb7a4c651638e620dafe0e09483b77e5b17468c933813049fa43c16d9d73193238abe0c29b2cb193ccbc7f267c25e2e52996b61e5fd5b728f8a96e7
7
+ data.tar.gz: a957de30192365bb02712b644ff9eb5a7813e6910a73424712d8ca0368882cd322e901fb2e67ab4998848c85f4687f9e84215757f18428b9230a8609d013f975
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # JrubyCoercion
2
+ An attempt to provide an interface for Ruby/Java coercion in JRuby that both standardizes a means of coercion between
3
+ types and provides the ability to be extensible by outside parties to register custom coercion methods.
2
4
 
3
- TODO: Write a gem description
5
+ [Inspiration - Jruby Coercion](https://www.engineyard.com/blog/2009/5-things-to-look-for-in-jruby-1-4/)
4
6
 
5
7
  ## Installation
6
8
 
@@ -17,8 +19,25 @@ Or install it yourself as:
17
19
  $ gem install jruby_coercion
18
20
 
19
21
  ## Usage
22
+ First a coercion routine must be registered and then `to_java(DestinationType)` must be called to run the coercion
23
+ routine at time of assignment, you can also check out `coerced_attr_writer` for automatic coercions when calling
24
+ java methods with Ruby objects.
20
25
 
21
- TODO: Write usage instructions here
26
+ Registering a coercion routing
27
+ ```ruby
28
+ ##
29
+ # Desire is to coerce a String (Ruby) into BigDecimal (Java)
30
+ #
31
+ ::JrubyCoercion::RubyToJava::Register.register_converter(String, java.math.BigDecimal) do |string_arg|
32
+ java.math.BigDecimal.new(string_arg)
33
+ end
34
+
35
+
36
+ "12.21".to_java(java.math.BigDecimal) # <Java::JavaMath::BigDecimal:0xe273376>
37
+ ```
38
+
39
+ Individual library/type implementors can register additional coercion routines where as the default Ruby/Java
40
+ coercion routines are registered when the gem loads.
22
41
 
23
42
  ## Contributing
24
43
 
@@ -4,6 +4,7 @@ require 'jruby_coercion/converter'
4
4
 
5
5
  class ::JrubyCoercion::Registry
6
6
 
7
+ REGISTRY_MUTEX = ::Mutex.new
7
8
  DEFAULT_KEY = "JRUBY_COERCION_DEFAULT".freeze
8
9
 
9
10
  ##
@@ -26,7 +27,7 @@ class ::JrubyCoercion::Registry
26
27
  end
27
28
 
28
29
  def self.register_converter(from_type, to_type, callable = nil, &blk)
29
- Thread.exclusive do
30
+ REGISTRY_MUTEX.synchronize do
30
31
  callable ||= blk
31
32
  to_type ||= DEFAULT_KEY
32
33
 
@@ -1,3 +1,3 @@
1
1
  module JrubyCoercion
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
metadata CHANGED
@@ -1,57 +1,65 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jruby_coercion
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.0.6
4
+ version: 0.0.7
6
5
  platform: java
7
6
  authors:
8
7
  - Brandon Dewitt
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-01-23 00:00:00.000000000Z
11
+ date: 2017-01-20 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
- name: rake
16
- version_requirements: &2056 !ruby/object:Gem::Requirement
14
+ requirement: !ruby/object:Gem::Requirement
17
15
  requirements:
18
- - - ! '>='
16
+ - - ">="
19
17
  - !ruby/object:Gem::Version
20
18
  version: '0'
21
- none: false
22
- requirement: *2056
19
+ name: rake
23
20
  prerelease: false
24
21
  type: :development
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
25
27
  - !ruby/object:Gem::Dependency
26
- name: rspec
27
- version_requirements: &2074 !ruby/object:Gem::Requirement
28
+ requirement: !ruby/object:Gem::Requirement
28
29
  requirements:
29
- - - ! '>='
30
+ - - ">="
30
31
  - !ruby/object:Gem::Version
31
32
  version: '0'
32
- none: false
33
- requirement: *2074
33
+ name: rspec
34
34
  prerelease: false
35
35
  type: :development
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
36
41
  - !ruby/object:Gem::Dependency
37
- name: pry-nav
38
- version_requirements: &2090 !ruby/object:Gem::Requirement
42
+ requirement: !ruby/object:Gem::Requirement
39
43
  requirements:
40
- - - ! '>='
44
+ - - ">="
41
45
  - !ruby/object:Gem::Version
42
46
  version: '0'
43
- none: false
44
- requirement: *2090
47
+ name: pry-nav
45
48
  prerelease: false
46
49
  type: :development
47
- description: ! ' gem to facilitate automatic coercion between jruby/java objects '
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: " gem to facilitate automatic coercion between jruby/java objects "
48
56
  email:
49
57
  - brandonsdewitt+jrubycoercion@gmail.com
50
58
  executables: []
51
59
  extensions: []
52
60
  extra_rdoc_files: []
53
61
  files:
54
- - .gitignore
62
+ - ".gitignore"
55
63
  - Gemfile
56
64
  - LICENSE.txt
57
65
  - README.md
@@ -71,30 +79,28 @@ files:
71
79
  - spec/spec_helper.rb
72
80
  homepage: ''
73
81
  licenses: []
82
+ metadata: {}
74
83
  post_install_message:
75
84
  rdoc_options: []
76
85
  require_paths:
77
86
  - lib
78
87
  required_ruby_version: !ruby/object:Gem::Requirement
79
88
  requirements:
80
- - - ! '>='
89
+ - - ">="
81
90
  - !ruby/object:Gem::Version
82
91
  version: '0'
83
- none: false
84
92
  required_rubygems_version: !ruby/object:Gem::Requirement
85
93
  requirements:
86
- - - ! '>='
94
+ - - ">="
87
95
  - !ruby/object:Gem::Version
88
96
  version: '0'
89
- none: false
90
97
  requirements: []
91
98
  rubyforge_project:
92
- rubygems_version: 1.8.15
99
+ rubygems_version: 2.4.8
93
100
  signing_key:
94
- specification_version: 3
101
+ specification_version: 4
95
102
  summary: helps coerce ruby objects into java type automatically
96
103
  test_files:
97
104
  - spec/coercions/big_decimal_spec.rb
98
105
  - spec/coercions/big_integer_spec.rb
99
106
  - spec/spec_helper.rb
100
- ...