laserlemon-search_party 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/MIT-LICENSE ADDED
@@ -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.
data/Manifest ADDED
@@ -0,0 +1,9 @@
1
+ init.rb
2
+ lib/search_party.rb
3
+ MIT-LICENSE
4
+ Rakefile
5
+ README.rdoc
6
+ test/search_party_test.rb
7
+ test/test_helper.rb
8
+ VERSION.yml
9
+ Manifest
data/README.rdoc ADDED
@@ -0,0 +1,13 @@
1
+ = search_party
2
+
3
+ == Installation
4
+
5
+ script/plugin install git://github.com/laserlemon/search_party.git
6
+
7
+ == Example
8
+
9
+ Coming soon...
10
+
11
+ == Tips
12
+
13
+ Coming soon...
data/Rakefile ADDED
@@ -0,0 +1,14 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'echoe'
4
+
5
+ Echoe.new('search_party', '0.1.0') do |g|
6
+ g.description = %(Parse your query parameters into more meaningful values)
7
+ g.url = 'http://github.com/laserlemon/search_party'
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 }
data/VERSION.yml ADDED
@@ -0,0 +1,4 @@
1
+ ---
2
+ :major: 0
3
+ :minor: 1
4
+ :patch: 0
data/init.rb ADDED
@@ -0,0 +1 @@
1
+ require 'search_party'
@@ -0,0 +1,39 @@
1
+ module LaserLemon
2
+ module SearchParty
3
+ def self.included(base)
4
+ base.class_inheritable_hash :search_parameter_models
5
+ base.search_parameter_models = {}
6
+
7
+ base.class_inheritable_array :search_parameter_patterns
8
+ base.search_parameter_patterns = []
9
+ end
10
+
11
+ def search_parameters
12
+ @search_parameters ||= begin
13
+ query_parameters.symbolize_keys.inject({}) do |new_parameters, (key, value)|
14
+ parsed_value = parse_search_parameter(value)
15
+ if search_parameter_model = self.class.search_parameter_models[key]
16
+ new_values = [*parsed_value].map{|v| search_parameter_model.respond_to?(:from_param) ? search_parameter_model.from_param(v) : search_parameter_model.find_by_id(v) }
17
+ new_value = (parsed_value.is_a?(Array) ? new_values.dup : new_values.first)
18
+ else
19
+ new_value = parsed_value
20
+ end
21
+ new_value.nil? ? new_parameters : new_parameters.update(key => new_value)
22
+ end
23
+ end
24
+ end
25
+
26
+ private
27
+
28
+ def parse_search_parameter(value)
29
+ if p = self.class.search_parameter_patterns.detect{|r,v| match = r.match(value) }
30
+ v = p.last
31
+ v.respond_to?(:call) ? v.call(value, $~) : v
32
+ else
33
+ value
34
+ end
35
+ end
36
+ end
37
+ end
38
+
39
+ ActionController::Request.send(:include, LaserLemon::SearchParty)
@@ -0,0 +1,31 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{search_party}
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-06-23}
10
+ s.description = %q{Parse your query parameters into more meaningful values}
11
+ s.email = %q{steve@laserlemon.com}
12
+ s.extra_rdoc_files = ["lib/search_party.rb", "README.rdoc"]
13
+ s.files = ["init.rb", "lib/search_party.rb", "MIT-LICENSE", "Rakefile", "README.rdoc", "test/search_party_test.rb", "test/test_helper.rb", "VERSION.yml", "Manifest", "search_party.gemspec"]
14
+ s.homepage = %q{http://github.com/laserlemon/search_party}
15
+ s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Search_party", "--main", "README.rdoc"]
16
+ s.require_paths = ["lib"]
17
+ s.rubyforge_project = %q{search_party}
18
+ s.rubygems_version = %q{1.3.4}
19
+ s.summary = %q{Parse your query parameters into more meaningful values}
20
+ s.test_files = ["test/search_party_test.rb", "test/test_helper.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
@@ -0,0 +1,8 @@
1
+ require 'test_helper'
2
+
3
+ class SearchPartyTest < ActiveSupport::TestCase
4
+ # Replace this with your real tests.
5
+ test "the truth" do
6
+ assert true
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ require 'rubygems'
2
+ require 'active_support'
3
+ require 'active_support/test_case'
metadata ADDED
@@ -0,0 +1,69 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: laserlemon-search_party
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-06-23 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description: Parse your query parameters into more meaningful values
17
+ email: steve@laserlemon.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - lib/search_party.rb
24
+ - README.rdoc
25
+ files:
26
+ - init.rb
27
+ - lib/search_party.rb
28
+ - MIT-LICENSE
29
+ - Rakefile
30
+ - README.rdoc
31
+ - test/search_party_test.rb
32
+ - test/test_helper.rb
33
+ - VERSION.yml
34
+ - Manifest
35
+ - search_party.gemspec
36
+ has_rdoc: false
37
+ homepage: http://github.com/laserlemon/search_party
38
+ post_install_message:
39
+ rdoc_options:
40
+ - --line-numbers
41
+ - --inline-source
42
+ - --title
43
+ - Search_party
44
+ - --main
45
+ - README.rdoc
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: "0"
53
+ version:
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: "1.2"
59
+ version:
60
+ requirements: []
61
+
62
+ rubyforge_project: search_party
63
+ rubygems_version: 1.2.0
64
+ signing_key:
65
+ specification_version: 3
66
+ summary: Parse your query parameters into more meaningful values
67
+ test_files:
68
+ - test/search_party_test.rb
69
+ - test/test_helper.rb