coerced_attr_writer 0.0.1-java → 0.0.2-java
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Rakefile +7 -0
- data/lib/coerced_attr_writer.rb +1 -0
- data/lib/coerced_attr_writer/core_ext/class.rb +21 -2
- data/lib/coerced_attr_writer/version.rb +1 -1
- data/spec/spec_helper.rb +4 -0
- metadata +5 -3
data/.gitignore
CHANGED
data/Rakefile
CHANGED
data/lib/coerced_attr_writer.rb
CHANGED
@@ -4,6 +4,7 @@ class Class
|
|
4
4
|
|
5
5
|
attributes.each do |attribute|
|
6
6
|
java_setter_name = _coerced_setter_name(attribute)
|
7
|
+
camel_writer_name = _coerced_camel_writer_name(attribute)
|
7
8
|
coercion_type = "#{setter_methods[java_setter_name]}"
|
8
9
|
|
9
10
|
class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
@@ -14,6 +15,10 @@ class Class
|
|
14
15
|
|
15
16
|
set_#{attribute}(val)
|
16
17
|
end
|
18
|
+
|
19
|
+
def #{camel_writer_name}=(val)
|
20
|
+
#{attribute} = val
|
21
|
+
end
|
17
22
|
RUBY
|
18
23
|
end
|
19
24
|
end
|
@@ -38,9 +43,23 @@ class Class
|
|
38
43
|
end
|
39
44
|
|
40
45
|
def _coerced_setter_name(attribute)
|
41
|
-
string = attribute.to_s
|
42
|
-
|
46
|
+
string = _coerced_camelize(attribute.to_s)
|
47
|
+
|
43
48
|
return "set#{string}"
|
44
49
|
end
|
45
50
|
|
51
|
+
def _coerced_camel_writer_name(attribute)
|
52
|
+
string = _coerced_camelize(attribute.to_s)
|
53
|
+
string[0] = string[0].downcase
|
54
|
+
|
55
|
+
return string
|
56
|
+
end
|
57
|
+
|
58
|
+
def _coerced_camelize(string)
|
59
|
+
local_string = string.to_s.dup
|
60
|
+
local_string = local_string.split(/[^a-z0-9]/i).map { |word| word.capitalize }.join
|
61
|
+
|
62
|
+
return local_string
|
63
|
+
end
|
64
|
+
|
46
65
|
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: coerced_attr_writer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: java
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -82,6 +82,7 @@ files:
|
|
82
82
|
- lib/coerced_attr_writer.rb
|
83
83
|
- lib/coerced_attr_writer/core_ext/class.rb
|
84
84
|
- lib/coerced_attr_writer/version.rb
|
85
|
+
- spec/spec_helper.rb
|
85
86
|
homepage: ''
|
86
87
|
licenses: []
|
87
88
|
post_install_message:
|
@@ -114,4 +115,5 @@ rubygems_version: 1.8.24
|
|
114
115
|
signing_key:
|
115
116
|
specification_version: 3
|
116
117
|
summary: declarable coercible attr_writer methods for interacting with native java methods
|
117
|
-
test_files:
|
118
|
+
test_files:
|
119
|
+
- spec/spec_helper.rb
|