laserlemon-with_recursive_options 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Steve Richert
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,13 @@
1
+ init.rb
2
+ lib/hash.rb
3
+ lib/mapper.rb
4
+ lib/object.rb
5
+ lib/recursive_option_merger.rb
6
+ Manifest
7
+ MIT-LICENSE
8
+ Rakefile
9
+ README.rdoc
10
+ test/test_helper.rb
11
+ test/with_recursive_options_test.rb
12
+ VERSION.yml
13
+ with_recursive_options.gemspec
@@ -0,0 +1,13 @@
1
+ = with_recursive_options
2
+
3
+ == Installation
4
+
5
+ gem install laserlemon-with_recursive_options --source http://gems.github.com
6
+
7
+ == Example
8
+
9
+ Coming soon...
10
+
11
+ == Tips
12
+
13
+ Coming soon...
@@ -0,0 +1,14 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'echoe'
4
+
5
+ Echoe.new('with_recursive_options', '0.1.0') do |g|
6
+ g.description = %(Extend Rails Object#with_options to recursively merge options)
7
+ g.url = 'http://github.com/laserlemon/with_recursive_options'
8
+ g.author = 'Steve Richert'
9
+ g.email = 'steve@laserlemon.com'
10
+ g.ignore_pattern = %w(tmp/* script/*)
11
+ g.development_dependencies = []
12
+ end
13
+
14
+ Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each{|t| load t }
@@ -0,0 +1,4 @@
1
+ ---
2
+ :major: 0
3
+ :minor: 1
4
+ :patch: 0
data/init.rb ADDED
@@ -0,0 +1,4 @@
1
+ require 'hash'
2
+ require 'recursive_option_merger'
3
+ require 'object'
4
+ require 'mapper'
@@ -0,0 +1,12 @@
1
+ class Hash
2
+ def recursive_merge(hash)
3
+ target = dup
4
+ hash.keys.each do |key|
5
+ target[key] = if hash[key].is_a?(Hash) && self[key].is_a?(Hash)
6
+ target[key].recursive_merge(hash[key])
7
+ else hash[key]
8
+ end
9
+ end
10
+ target
11
+ end
12
+ end
@@ -0,0 +1,3 @@
1
+ class ActionController::Routing::RouteSet::Mapper
2
+ alias_method :with_options, :with_recursive_options
3
+ end
@@ -0,0 +1,5 @@
1
+ class Object
2
+ def with_recursive_options(options)
3
+ yield ActiveSupport::RecursiveOptionMerger.new(self, options)
4
+ end
5
+ end
@@ -0,0 +1,14 @@
1
+ module ActiveSupport
2
+ class RecursiveOptionMerger < OptionMerger
3
+
4
+ private
5
+
6
+ def merge_argument_options!(arguments)
7
+ arguments << if arguments.last.respond_to? :to_hash
8
+ @options.recursive_merge(arguments.pop)
9
+ else
10
+ @options.dup
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,3 @@
1
+ require 'rubygems'
2
+ require 'active_support'
3
+ require 'active_support/test_case'
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class WithRecursiveOptionsTest < ActiveSupport::TestCase
4
+ # Replace this with your real tests.
5
+ test "the truth" do
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,31 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{with_recursive_options}
5
+ s.version = "0.1.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Steve Richert"]
9
+ s.date = %q{2009-05-29}
10
+ s.description = %q{Extend Rails Object#with_options to recursively merge options}
11
+ s.email = %q{steve@laserlemon.com}
12
+ s.extra_rdoc_files = ["lib/hash.rb", "lib/mapper.rb", "lib/object.rb", "lib/recursive_option_merger.rb", "README.rdoc"]
13
+ s.files = ["init.rb", "lib/hash.rb", "lib/mapper.rb", "lib/object.rb", "lib/recursive_option_merger.rb", "Manifest", "MIT-LICENSE", "Rakefile", "README.rdoc", "test/test_helper.rb", "test/with_recursive_options_test.rb", "VERSION.yml", "with_recursive_options.gemspec"]
14
+ s.homepage = %q{http://github.com/laserlemon/with_recursive_options}
15
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "With_recursive_options", "--main", "README.rdoc"]
16
+ s.require_paths = ["lib"]
17
+ s.rubyforge_project = %q{with_recursive_options}
18
+ s.rubygems_version = %q{1.3.3}
19
+ s.summary = %q{Extend Rails Object#with_options to recursively merge options}
20
+ s.test_files = ["test/test_helper.rb", "test/with_recursive_options_test.rb"]
21
+
22
+ if s.respond_to? :specification_version then
23
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
24
+ s.specification_version = 3
25
+
26
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
27
+ else
28
+ end
29
+ else
30
+ end
31
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: laserlemon-with_recursive_options
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Steve Richert
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-05-29 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Extend Rails Object#with_options to recursively merge options
17
+ email: steve@laserlemon.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - lib/hash.rb
24
+ - lib/mapper.rb
25
+ - lib/object.rb
26
+ - lib/recursive_option_merger.rb
27
+ - README.rdoc
28
+ files:
29
+ - init.rb
30
+ - lib/hash.rb
31
+ - lib/mapper.rb
32
+ - lib/object.rb
33
+ - lib/recursive_option_merger.rb
34
+ - Manifest
35
+ - MIT-LICENSE
36
+ - Rakefile
37
+ - README.rdoc
38
+ - test/test_helper.rb
39
+ - test/with_recursive_options_test.rb
40
+ - VERSION.yml
41
+ - with_recursive_options.gemspec
42
+ has_rdoc: false
43
+ homepage: http://github.com/laserlemon/with_recursive_options
44
+ post_install_message:
45
+ rdoc_options:
46
+ - --line-numbers
47
+ - --inline-source
48
+ - --title
49
+ - With_recursive_options
50
+ - --main
51
+ - README.rdoc
52
+ require_paths:
53
+ - lib
54
+ required_ruby_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: "0"
59
+ version:
60
+ required_rubygems_version: !ruby/object:Gem::Requirement
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: "1.2"
65
+ version:
66
+ requirements: []
67
+
68
+ rubyforge_project: with_recursive_options
69
+ rubygems_version: 1.2.0
70
+ signing_key:
71
+ specification_version: 3
72
+ summary: Extend Rails Object#with_options to recursively merge options
73
+ test_files:
74
+ - test/test_helper.rb
75
+ - test/with_recursive_options_test.rb