paraphrase 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,10 @@
1
+ 0.5.0 / 8-7-2012
2
+
3
+ * Cleanup ScopeMapping class
4
+ * Add ability to query from an existing ActiveRecord::Relation instance
5
+ (typically an association).
6
+ * Update syntax for generating mappings.
7
+
1
8
  0.4.0 / 7-6-2012
2
9
 
3
10
  * Setup Query#params to be HashWithIndifferentAccess.
data/README.md CHANGED
@@ -36,7 +36,7 @@ $ gem install paraphrase
36
36
  ```ruby
37
37
  class Post < ActiveRecord::Base
38
38
  register_mapping do
39
- scope :by_user, :key => :author
39
+ map :by_user, :to => :author
40
40
  end
41
41
 
42
42
  def self.by_user(author_name)
@@ -53,7 +53,7 @@ class PostQuery < Paraphrase::Query
53
53
  # into a constant name
54
54
  paraphrases Post
55
55
 
56
- scope :by_user, :key => :author
56
+ map :by_user, :to => :author
57
57
  end
58
58
  ```
59
59
 
@@ -75,17 +75,35 @@ class PostsController < ApplicationController
75
75
  end
76
76
  ```
77
77
 
78
- ### Configuring Scopes
78
+ You can scope queries from an association, useful if you have nested resources:
79
79
 
80
- In any of these contexts, the `:key` option of the `:scope` method registers
80
+ ```ruby
81
+ class PostsController < ApplicationController
82
+ respond_to :html, :json
83
+
84
+ # GET /users/1/posts
85
+ def index
86
+ @user = User.find(params[:user_id])
87
+
88
+ # This will do a join on the users table, scoping posts to the current user
89
+ @posts = @users.posts.paraphrase(params)
90
+
91
+ respond_with(@posts)
92
+ end
93
+ end
94
+ ```
95
+
96
+ ### Configuring Mappings
97
+
98
+ In any of these contexts, the `:to` option of the `:map` method registers
81
99
  attribute(s) to extract from the params supplied and what method to pass them
82
100
  to. An array of keys can be supplied to pass multiple arguments to a scope.
83
101
 
84
102
  ```ruby
85
103
  class Post < ActiveRecord::Base
86
104
  register_mapping do
87
- scope :by_user, :key => [:first_name, :last_name]
88
- scope :published_on, :key => :pub_date
105
+ map :by_user, :to => [:first_name, :last_name]
106
+ map :published_on, :to => :pub_date
89
107
  end
90
108
 
91
109
  def self.by_user(first_name, last_name)
@@ -107,8 +125,8 @@ rest of the attributes will be allowed to be nil.
107
125
  ```ruby
108
126
  class Post < ActiveRecord::Base
109
127
  register_mapping do
110
- scope :published_on, :key => :pub_date, :require => true
111
- scope :by_author, :key => [:first_name, :last_name], :require => :last_name # requires :last_name, whitelists :first_name
128
+ map :published_on, :to => :pub_date, :require => true
129
+ map :by_author, :to => [:first_name, :last_name], :require => :last_name # requires :last_name, whitelists :first_name
112
130
  end
113
131
  end
114
132
 
@@ -120,15 +138,7 @@ Alternatively, a scope can be whitelisted allowing nil values to be passed to th
120
138
  ```ruby
121
139
  class Post < ActiveRecord::Base
122
140
  register_mapping do
123
- scope :by_author, :key => [:first_name, :last_name], :allow_nil => :first_name # :first_name does not need to be specified
141
+ map :by_author, :to => [:first_name, :last_name], :allow_nil => :first_name # :first_name does not need to be specified
124
142
  end
125
143
  end
126
144
  ```
127
-
128
- ## Plans / Thoughts for the Future
129
-
130
- * Support nested hashes in params.
131
-
132
- ```ruby
133
- scope :by_author, :key => { :author => [:first_name, :last_name] }
134
- ```
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/edd_d/src/paraphrase
3
3
  specs:
4
- paraphrase (0.3.2)
4
+ paraphrase (0.4.0)
5
5
  activemodel (~> 3.0)
6
6
  activerecord (~> 3.0)
7
7
  activesupport (~> 3.0)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/edd_d/src/paraphrase
3
3
  specs:
4
- paraphrase (0.3.2)
4
+ paraphrase (0.4.0)
5
5
  activemodel (~> 3.0)
6
6
  activerecord (~> 3.0)
7
7
  activesupport (~> 3.0)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/edd_d/src/paraphrase
3
3
  specs:
4
- paraphrase (0.3.2)
4
+ paraphrase (0.4.0)
5
5
  activemodel (~> 3.0)
6
6
  activerecord (~> 3.0)
7
7
  activesupport (~> 3.0)
@@ -8,32 +8,28 @@ module Paraphrase
8
8
  class Query
9
9
  extend ActiveModel::Naming
10
10
 
11
- # @!attribute [r] scopes
12
- # @return [Array<ScopeMapping>] scopes for query
11
+ # @!attribute [r] mappings
12
+ # @return [Array<ScopeMapping>] mappings for query
13
13
  #
14
14
  # @!attribute [r] source
15
15
  # @return [ActiveRecord::Relation] source to apply scopes to
16
- class_attribute :scopes, :source, :instance_writer => false
17
-
16
+ class_attribute :mappings, :source, :instance_writer => false
18
17
 
19
18
  # Delegate enumerable methods to results
20
19
  delegate :collect, :map, :each, :select, :to_a, :to_ary, :to => :results
21
20
 
22
-
23
21
  # @!attribute [r] errors
24
22
  # @return [ActiveModel::Errors] errors from determining results
25
23
  #
26
24
  # @!attribute [r] params
27
- # @return [HashWithIndifferentAccess] filters parameters based on keys defined in scopes
25
+ # @return [HashWithIndifferentAccess] filters parameters based on keys defined in mappings
28
26
  attr_reader :errors, :params
29
27
 
30
-
31
- # Set `scopes` on inheritance to ensure they're unique per subclass
28
+ # Set `mappings` on inheritance to ensure they're unique per subclass
32
29
  def self.inherited(klass)
33
- klass.scopes = []
30
+ klass.mappings = []
34
31
  end
35
32
 
36
-
37
33
  # Specify the ActiveRecord model to use as the source for queries
38
34
  #
39
35
  # @param [String, Symbol, ActiveRecord::Base] klass name of the class to
@@ -46,24 +42,25 @@ module Paraphrase
46
42
  self.source = klass
47
43
  end
48
44
 
49
-
50
- # Add a {ScopeMapping} instance to {@@scopes .scopes}
45
+ # Add a {ScopeMapping} instance to {@@mappings .mappings}
51
46
  #
52
47
  # @see ScopeMapping#initialize
53
- def self.scope(name, options)
54
- if scopes.map(&:method_name).include?(name)
48
+ def self.map(name, options)
49
+ if mappings.map(&:method_name).include?(name)
55
50
  raise DuplicateScopeError, "scope :#{name} has already been added"
56
51
  end
57
52
 
58
- scopes << ScopeMapping.new(name, options)
53
+ mappings << ScopeMapping.new(name, options)
59
54
  end
60
55
 
61
-
62
56
  # Filters out parameters irrelevant to the query
63
57
  #
64
58
  # @param [Hash] params query parameters
65
- def initialize(params = {})
66
- keys = scopes.map(&:param_keys).flatten.map(&:to_s)
59
+ def initialize(params = {}, relation = nil)
60
+ keys = mappings.map(&:keys).flatten.map(&:to_s)
61
+
62
+ @relation = relation || source.scoped
63
+
67
64
  @params = HashWithIndifferentAccess.new(params)
68
65
  @params.select! { |key, value| keys.include?(key) }
69
66
  @params.freeze
@@ -71,22 +68,20 @@ module Paraphrase
71
68
  @errors = ActiveModel::Errors.new(self)
72
69
  end
73
70
 
74
-
75
- # Loops through {#scopes} and apply scope methods to {#source}. If values
71
+ # Loops through {#mappings} and apply scope methods to {#source}. If values
76
72
  # are missing for a required key, an empty array is returned.
77
73
  #
78
74
  # @return [ActiveRecord::Relation, Array]
79
75
  def results
80
76
  return @results if @results
81
77
 
82
- results = scopes.inject(source.scoped) do |query, scope|
78
+ results = mappings.inject(@relation) do |query, scope|
83
79
  scope.chain(self, @params, query)
84
80
  end
85
81
 
86
82
  @results = @errors.any? ? [] : results
87
83
  end
88
84
 
89
-
90
85
  def respond_to?(name)
91
86
  super || results.respond_to?(name)
92
87
  end
@@ -4,7 +4,8 @@ module Paraphrase
4
4
  class Railtie < Rails::Railtie
5
5
  initializer 'paraphrase.extend_active_record' do
6
6
  ActiveSupport.on_load :active_record do
7
- extend Paraphrase::Syntax
7
+ extend Paraphrase::Syntax::Base
8
+ ActiveRecord::Relation.send(:include, Paraphrase::Syntax::Relation)
8
9
  end
9
10
  end
10
11
  end
@@ -1,6 +1,6 @@
1
1
  module Paraphrase
2
2
  class ScopeMapping
3
- # @!attribute [r] param_keys
3
+ # @!attribute [r] keys
4
4
  # @return [Array<Symbol>] param keys to extract
5
5
  #
6
6
  # @!attribute [r] method_name
@@ -12,10 +12,9 @@ module Paraphrase
12
12
  # @!attribute [r] required_keys
13
13
  # @return [Array] keys required for query
14
14
  #
15
- # @!attribute [r] whitelisted_keys
15
+ # @!attribute [r] whitelist_keys
16
16
  # @return [Array] keys allowed to be nil
17
- attr_reader :param_keys, :method_name, :options, :required_keys, :whitelisted_keys
18
-
17
+ attr_reader :keys, :method_name, :options, :required, :whitelist
19
18
 
20
19
  # @param [Symbol] name name of the scope
21
20
  # @param [Hash] options options to configure {ScopeMapping ScopeMapping} instance
@@ -23,35 +22,20 @@ module Paraphrase
23
22
  # @option options [true] :require lists scope as required
24
23
  def initialize(name, options)
25
24
  @method_name = name
26
- @param_keys = Array(options.delete(:key))
25
+ @keys = Array(options.delete(:to))
27
26
 
28
- @required_keys = register_keys(options[:require])
29
- @whitelisted_keys = register_keys(options[:allow_nil])
27
+ @required = register_keys(options[:require])
28
+ @whitelist = register_keys(options[:allow_nil])
30
29
 
31
- if @whitelisted_keys.empty? && !@required_keys.empty?
32
- @whitelisted_keys = @param_keys - @required_keys
30
+ if @whitelist.empty? && !@required.empty?
31
+ @whitelist = @keys - @required
33
32
  end
34
33
 
35
34
  @options = options.freeze
36
35
  end
37
36
 
38
-
39
- # True if scope is required for query
40
- # @param [Symbol, String] key param key being checked
41
- def required?(key)
42
- required_keys.include?(key)
43
- end
44
-
45
-
46
- # True if nil param values can be passed to scope
47
- # @see #required?
48
- def whitelisted?(key)
49
- whitelisted_keys.include?(key)
50
- end
51
-
52
-
53
37
  # Sends {#method_name} to `chain`, extracting arguments from `params`. If
54
- # values are missing for any {#param_keys}, return the `chain` unmodified.
38
+ # values are missing for any {#keys}, return the `chain` unmodified.
55
39
  # If {#required? required}, errors are added to the {Query} instance as
56
40
  # well.
57
41
  #
@@ -60,11 +44,11 @@ module Paraphrase
60
44
  # @param [ActiveRecord::Relation, ActiveRecord::Base] chain current model scope
61
45
  # @return [ActiveRecord::Relation]
62
46
  def chain(query, params, chain)
63
- inputs = param_keys.map do |key|
47
+ inputs = keys.map do |key|
64
48
  input = params[key]
65
49
 
66
- if input.nil? && ( required?(key) || !whitelisted?(key) )
67
- query.errors.add(key, 'is required') if required?(key)
50
+ if input.nil? && ( required.include?(key) || !whitelist.include?(key) )
51
+ query.errors.add(key, 'is required') if required.include?(key)
68
52
  break []
69
53
  end
70
54
 
@@ -77,7 +61,7 @@ module Paraphrase
77
61
  private
78
62
 
79
63
  def register_keys(option)
80
- option == true ? Array(param_keys) : Array(option)
64
+ option == true ? Array(keys) : Array(option)
81
65
  end
82
66
  end
83
67
  end
@@ -1,29 +1,63 @@
1
1
  module Paraphrase
2
2
  module Syntax
3
+ module Base
4
+ def self.extended(klass)
5
+ klass.instance_eval do
6
+ class_attribute :paraphraser, :instance_writer => false, :instance_reader => false
7
+ end
8
+ end
3
9
 
4
- def self.extended(klass)
5
- klass.instance_eval do
6
- class_attribute :paraphraser, :instance_writer => false, :instance_reader => false
10
+ # Register a {Query} class mapped to `self`. If the mapping has already
11
+ # been registered, calling again will clear existing scopes and evaluate
12
+ # the block.
13
+ #
14
+ # @param [Proc] &block block to define scope mappings
15
+ def register_mapping(&block)
16
+ klass = Class.new(Query, &block)
17
+ klass.source = self
18
+ self.paraphraser = klass
7
19
  end
8
- end
9
20
 
10
- # Register a {Query} class mapped to `self`. If the mapping has already
11
- # been registered, calling again will clear existing scopes and evaluate
12
- # the block.
13
- #
14
- # @param [Proc] &block block to define scope mappings
15
- def register_mapping(&block)
16
- klass = Class.new(Query, &block)
17
- klass.source = self
18
- self.paraphraser = klass
21
+ # Instantiate the {Query} class that is mapped to `self`.
22
+ #
23
+ # @param [Hash] params query parameters
24
+ def paraphrase(params)
25
+ self.paraphraser.new(params)
26
+ end
19
27
  end
20
28
 
21
-
22
- # Instantiate the {Query} class that is mapped to `self`.
23
- #
24
- # @param [Hash] params query parameters
25
- def paraphrase(params)
26
- self.paraphraser.new(params)
29
+ module Relation
30
+ # Creates a paraphrase {Query query}, supplying `self` as the base for the
31
+ # query. Intended for scoping a query from an association:
32
+ #
33
+ # Given the following models:
34
+ #
35
+ # ```ruby
36
+ # class User < ActiveRecord::Base
37
+ # has_many :posts
38
+ # end
39
+ #
40
+ # class Post < ActiveRecord::Base
41
+ # belongs_to :user
42
+ #
43
+ # register_mapping
44
+ # map :title_like, :to => :title
45
+ # end
46
+ # end
47
+ # ```
48
+ #
49
+ # It is possible to do the following:
50
+ #
51
+ # ```ruby
52
+ # user.posts.paraphrase({ :title => 'Game of Thrones Finale' }).to_sql
53
+ # # => SELECT `posts`.* FROM `posts` INNER JOIN `users` ON `users`.`post_id` = `posts`.`id` WHERE `posts`.`title LIKE "%Game of Thrones Finale%";
54
+ # ```
55
+ #
56
+ # @param [Hash] params query params
57
+ # @return [Paraphrase::Query]
58
+ def paraphrase(params)
59
+ klass.paraphraser.new(params, self)
60
+ end
27
61
  end
28
62
  end
29
63
  end
@@ -1,3 +1,3 @@
1
1
  module Paraphrase
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
data/paraphrase.gemspec CHANGED
@@ -5,10 +5,12 @@ require File.expand_path('../lib/paraphrase/version', __FILE__)
5
5
  Gem::Specification.new do |gem|
6
6
  gem.name = "paraphrase"
7
7
  gem.version = Paraphrase::VERSION
8
- gem.summary = %q{Map param keys to class scopes}
8
+ gem.summary = %q{Map params to model scopes}
9
9
  gem.description = %q{
10
- Build customizable classes to determine which scope
11
- methods to call based on supplied parameters.
10
+ Map query parameters to model scopes, pairing one or
11
+ more keys to a scope. Parameters can be required, or
12
+ whitelisted providing fine tuned control over how
13
+ scopes are run.
12
14
  }
13
15
  gem.license = "MIT"
14
16
  gem.authors = ["Eduardo Gutierrez"]
@@ -27,8 +29,8 @@ Gem::Specification.new do |gem|
27
29
  gem.add_development_dependency 'bundler', '~> 1.0'
28
30
  gem.add_development_dependency 'yard', '~> 0.7'
29
31
  gem.add_development_dependency 'rspec', '~> 2.10'
30
- gem.add_development_dependency 'redcarpet'
31
- gem.add_development_dependency 'rake'
32
- gem.add_development_dependency 'sqlite3'
33
- gem.add_development_dependency 'appraisal'
32
+ gem.add_development_dependency 'redcarpet', '~> 2.1.1'
33
+ gem.add_development_dependency 'rake', '~> 0.9.2'
34
+ gem.add_development_dependency 'sqlite3', '~> 1.3.6'
35
+ gem.add_development_dependency 'appraisal', '0.4'
34
36
  end
@@ -3,6 +3,9 @@ require 'spec_helper'
3
3
  module Paraphrase
4
4
  describe Query do
5
5
 
6
+ class AccountSearch < Query
7
+ end
8
+
6
9
  describe ".paraphrases" do
7
10
  it "stores the class being queried" do
8
11
  AccountSearch.paraphrases :account
@@ -11,23 +14,23 @@ module Paraphrase
11
14
  end
12
15
 
13
16
  describe ".scope" do
14
- it "adds information to Query.scopes" do
17
+ it "adds information to Query.mappings" do
15
18
  AccountSearch.instance_eval do
16
- scope :name_like, :key => :name
19
+ map :name_like, :to => :name
17
20
  end
18
21
 
19
- AccountSearch.scopes.should_not be_empty
22
+ AccountSearch.mappings.should_not be_empty
20
23
  end
21
24
 
22
25
  it "raises an error if a scope is added twice" do
23
- expect { AccountSearch.instance_eval { scope :name_like, :key => :name } }.to raise_error Paraphrase::DuplicateScopeError
26
+ expect { AccountSearch.instance_eval { map :name_like, :to => :name } }.to raise_error Paraphrase::DuplicateScopeError
24
27
  end
25
28
  end
26
29
 
27
30
  describe "#initialize" do
28
31
  let(:query) { AccountSearch.new(:name => 'Tyrion Lannister', :nickname => 'Half Man') }
29
32
 
30
- it "filters out params not specified in scopes" do
33
+ it "filters out params not specified in mappings" do
31
34
  query.params.should_not have_key :nickname
32
35
  query.params.should have_key :name
33
36
  end
@@ -35,12 +38,23 @@ module Paraphrase
35
38
  it "sets up params with indifferent access" do
36
39
  query.params.should have_key 'name'
37
40
  end
41
+
42
+ it "accepts an ActiveRecord::Relation to use as the base scope" do
43
+ user = User.create!
44
+ associated_account = Account.create!(:user => user)
45
+ lonely_account = Account.create!
46
+
47
+ results = AccountSearch.new({ :name => 'Tyrion Lannister'}, user.accounts).results
48
+
49
+ results.should include associated_account
50
+ results.should_not include lonely_account
51
+ end
38
52
  end
39
53
 
40
54
  describe "#results" do
41
55
  before :all do
42
56
  AccountSearch.instance_eval do
43
- scope :title_like, :key => :title, :require => true
57
+ map :title_like, :to => :title, :require => true
44
58
  end
45
59
  end
46
60
 
@@ -2,8 +2,8 @@ require 'spec_helper'
2
2
 
3
3
  module Paraphrase
4
4
  describe ScopeMapping do
5
- let(:mapping) { ScopeMapping.new(:name_like, :key => :name) }
6
- let(:compound_mapping) { ScopeMapping.new(:name_like, :key => [:first_name, :last_name], :require => :last_name) }
5
+ let(:mapping) { ScopeMapping.new(:name_like, :to => :name) }
6
+ let(:compound_mapping) { ScopeMapping.new(:name_like, :to => [:first_name, :last_name], :require => :last_name) }
7
7
  let(:query) do
8
8
  query = double('query')
9
9
  query.stub(:errors).and_return(double('errors'))
@@ -22,14 +22,14 @@ module Paraphrase
22
22
  end
23
23
 
24
24
  it "adds errors to query object if missing and required" do
25
- required_mapping = ScopeMapping.new(:name_like, :key => :name, :require => true)
25
+ required_mapping = ScopeMapping.new(:name_like, :to => :name, :require => true)
26
26
 
27
27
  query.errors.should_receive(:add)
28
28
  required_mapping.chain(query, {}, Account)
29
29
  end
30
30
 
31
31
  it "passes through nil values if scope has been whitelisted" do
32
- mapping = ScopeMapping.new(:name_like, :key => :name, :allow_nil => true)
32
+ mapping = ScopeMapping.new(:name_like, :to => :name, :allow_nil => true)
33
33
 
34
34
  Account.should_receive(:name_like).with(nil)
35
35
  mapping.chain(query, {}, Account)
@@ -42,7 +42,7 @@ module Paraphrase
42
42
  end
43
43
 
44
44
  it "whitelists the the non-required keys of a compound key" do
45
- compound_mapping.whitelisted?(:first_name).should be_true
45
+ compound_mapping.whitelist.include?(:first_name).should be_true
46
46
  end
47
47
  end
48
48
  end
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  module Paraphrase
4
4
  describe Syntax do
5
5
  describe ".register_mapping" do
6
- it "forwards to Paraphrase.register" do
6
+ it "creates new sublcass of Query" do
7
7
  Account.register_mapping {}
8
8
  Account.paraphraser.should_not be_nil
9
9
  end
data/spec/spec_helper.rb CHANGED
@@ -1,23 +1,3 @@
1
1
  require 'rspec'
2
2
  require 'paraphrase'
3
- require 'active_record'
4
-
5
- ActiveRecord::Base.establish_connection(
6
- :adapter => 'sqlite3',
7
- :database => ':memory:'
8
- )
9
-
10
- ActiveRecord::Base.silence do
11
- ActiveRecord::Migration.verbose = false
12
-
13
- ActiveRecord::Schema.define do
14
- create_table(:accounts, :force => true) {}
15
- end
16
- end
17
-
18
- class Account < ActiveRecord::Base
19
- extend Paraphrase::Syntax
20
- end
21
-
22
- class AccountSearch < Paraphrase::Query
23
- end
3
+ require 'support/database'
@@ -0,0 +1,34 @@
1
+ require 'active_record'
2
+
3
+ ActiveRecord::Relation.send(:include, Paraphrase::Syntax::Relation)
4
+
5
+ ActiveRecord::Base.establish_connection(
6
+ :adapter => 'sqlite3',
7
+ :database => ':memory:'
8
+ )
9
+
10
+ ActiveRecord::Base.silence do
11
+ ActiveRecord::Migration.verbose = false
12
+
13
+ ActiveRecord::Schema.define do
14
+ create_table :users, :force => true do
15
+ end
16
+
17
+ create_table :accounts, :force => true do |t|
18
+ t.references :user
19
+ end
20
+ end
21
+ end
22
+
23
+ class User < ActiveRecord::Base
24
+ has_many :accounts
25
+ end
26
+
27
+ class Account < ActiveRecord::Base
28
+ extend Paraphrase::Syntax::Base
29
+ belongs_to :user
30
+
31
+ def self.name_like(*args)
32
+ scoped
33
+ end
34
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paraphrase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-07 00:00:00.000000000 Z
12
+ date: 2012-08-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activerecord
16
- requirement: &70360247937200 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '3.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70360247937200
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '3.0'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: activesupport
27
- requirement: &70360247936360 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ~>
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: '3.0'
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *70360247936360
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '3.0'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: activemodel
38
- requirement: &70360247934800 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ~>
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: '3.0'
44
54
  type: :runtime
45
55
  prerelease: false
46
- version_requirements: *70360247934800
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: bundler
49
- requirement: &70360247926020 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ~>
@@ -54,10 +69,15 @@ dependencies:
54
69
  version: '1.0'
55
70
  type: :development
56
71
  prerelease: false
57
- version_requirements: *70360247926020
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: '1.0'
58
78
  - !ruby/object:Gem::Dependency
59
79
  name: yard
60
- requirement: &70360247925260 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
61
81
  none: false
62
82
  requirements:
63
83
  - - ~>
@@ -65,10 +85,15 @@ dependencies:
65
85
  version: '0.7'
66
86
  type: :development
67
87
  prerelease: false
68
- version_requirements: *70360247925260
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '0.7'
69
94
  - !ruby/object:Gem::Dependency
70
95
  name: rspec
71
- requirement: &70360247924500 !ruby/object:Gem::Requirement
96
+ requirement: !ruby/object:Gem::Requirement
72
97
  none: false
73
98
  requirements:
74
99
  - - ~>
@@ -76,54 +101,80 @@ dependencies:
76
101
  version: '2.10'
77
102
  type: :development
78
103
  prerelease: false
79
- version_requirements: *70360247924500
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ~>
108
+ - !ruby/object:Gem::Version
109
+ version: '2.10'
80
110
  - !ruby/object:Gem::Dependency
81
111
  name: redcarpet
82
- requirement: &70360247923780 !ruby/object:Gem::Requirement
112
+ requirement: !ruby/object:Gem::Requirement
83
113
  none: false
84
114
  requirements:
85
- - - ! '>='
115
+ - - ~>
86
116
  - !ruby/object:Gem::Version
87
- version: '0'
117
+ version: 2.1.1
88
118
  type: :development
89
119
  prerelease: false
90
- version_requirements: *70360247923780
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: 2.1.1
91
126
  - !ruby/object:Gem::Dependency
92
127
  name: rake
93
- requirement: &70360247922620 !ruby/object:Gem::Requirement
128
+ requirement: !ruby/object:Gem::Requirement
94
129
  none: false
95
130
  requirements:
96
- - - ! '>='
131
+ - - ~>
97
132
  - !ruby/object:Gem::Version
98
- version: '0'
133
+ version: 0.9.2
99
134
  type: :development
100
135
  prerelease: false
101
- version_requirements: *70360247922620
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ~>
140
+ - !ruby/object:Gem::Version
141
+ version: 0.9.2
102
142
  - !ruby/object:Gem::Dependency
103
143
  name: sqlite3
104
- requirement: &70360247921580 !ruby/object:Gem::Requirement
144
+ requirement: !ruby/object:Gem::Requirement
105
145
  none: false
106
146
  requirements:
107
- - - ! '>='
147
+ - - ~>
108
148
  - !ruby/object:Gem::Version
109
- version: '0'
149
+ version: 1.3.6
110
150
  type: :development
111
151
  prerelease: false
112
- version_requirements: *70360247921580
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ~>
156
+ - !ruby/object:Gem::Version
157
+ version: 1.3.6
113
158
  - !ruby/object:Gem::Dependency
114
159
  name: appraisal
115
- requirement: &70360247921160 !ruby/object:Gem::Requirement
160
+ requirement: !ruby/object:Gem::Requirement
116
161
  none: false
117
162
  requirements:
118
- - - ! '>='
163
+ - - '='
119
164
  - !ruby/object:Gem::Version
120
- version: '0'
165
+ version: '0.4'
121
166
  type: :development
122
167
  prerelease: false
123
- version_requirements: *70360247921160
124
- description: ! "\n Build customizable classes to determine
125
- which scope\n methods to call based on supplied parameters.\n
126
- \ "
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - '='
172
+ - !ruby/object:Gem::Version
173
+ version: '0.4'
174
+ description: ! "\n Map query parameters to model scopes, pairing
175
+ one or\n more keys to a scope. Parameters can be required,
176
+ or\n whitelisted providing fine tuned control over how\n
177
+ \ scopes are run.\n "
127
178
  email: edd_d@mit.edu
128
179
  executables: []
129
180
  extensions: []
@@ -156,6 +207,7 @@ files:
156
207
  - spec/paraphrase/scope_mapping_spec.rb
157
208
  - spec/paraphrase/syntax_spec.rb
158
209
  - spec/spec_helper.rb
210
+ - spec/support/database.rb
159
211
  homepage: https://github.com/ecbypi/paraphrase
160
212
  licenses:
161
213
  - MIT
@@ -177,13 +229,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
177
229
  version: '0'
178
230
  requirements: []
179
231
  rubyforge_project:
180
- rubygems_version: 1.8.11
232
+ rubygems_version: 1.8.23
181
233
  signing_key:
182
234
  specification_version: 3
183
- summary: Map param keys to class scopes
235
+ summary: Map params to model scopes
184
236
  test_files:
185
237
  - spec/paraphrase/query_spec.rb
186
238
  - spec/paraphrase/scope_mapping_spec.rb
187
239
  - spec/paraphrase/syntax_spec.rb
188
240
  - spec/spec_helper.rb
241
+ - spec/support/database.rb
189
242
  has_rdoc: