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 CHANGED
@@ -2,6 +2,7 @@
2
2
  *.rbc
3
3
  .bundle
4
4
  .config
5
+ .rvmrc
5
6
  Gemfile.lock
6
7
  InstalledFiles
7
8
  coverage
data/Rakefile CHANGED
@@ -1 +1,8 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'rspec/core/rake_task'
3
+
4
+ desc "Run specs"
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ desc "Run specs (default)"
8
+ task :default => :spec
@@ -1,4 +1,5 @@
1
1
  require "coerced_attr_writer/version"
2
+ require "coerced_attr_writer/core_ext/class"
2
3
 
3
4
  module CoercedAttrWriter
4
5
  end
@@ -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.dup
42
- string = string.split(/[^a-z0-9]/i).map { |word| word.capitalize }.join
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
@@ -1,3 +1,3 @@
1
1
  module CoercedAttrWriter
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,4 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+
4
+ Bundler.require(:default, :development, :test)
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.1
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-09 00:00:00.000000000 Z
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