solr_query 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/Rakefile +1 -7
  2. data/lib/solr_query.rb +11 -5
  3. metadata +2 -3
  4. data/lib/blank.rb +0 -58
data/Rakefile CHANGED
@@ -21,15 +21,9 @@ Rake::RDocTask.new(:rdoc) do |rdoc|
21
21
  rdoc.rdoc_files.include('lib/**/*.rb')
22
22
  end
23
23
 
24
-
25
24
  require "rubygems"
26
25
  require "rake/gempackagetask"
27
26
 
28
- Spec::Rake::SpecTask.new do |t|
29
- t.spec_opts = %w(--format specdoc --colour)
30
- t.libs = ["spec"]
31
- end
32
-
33
27
  # This builds the actual gem. For details of what all these options
34
28
  # mean, and other ones you can add, check the documentation here:
35
29
  #
@@ -39,7 +33,7 @@ spec = Gem::Specification.new do |s|
39
33
 
40
34
  # Change these as appropriate
41
35
  s.name = "solr_query"
42
- s.version = "1.0.0"
36
+ s.version = "1.0.1"
43
37
  s.description = "Build SOLR queries, properly escaped, with a nice API"
44
38
  s.summary = "a ruby library designed to make building nested Solr queries simple and standardized. "
45
39
  s.author = "Matthew Rudy"
@@ -1,7 +1,3 @@
1
- unless nil.respond_to?(:blank?)
2
- require File.join(File.dirname(__FILE__), "blank")
3
- end
4
-
5
1
  module SolrQuery
6
2
  class << self
7
3
  # build a query for solr
@@ -33,7 +29,7 @@ module SolrQuery
33
29
  conditions = conditions.dup # let's not accidentally kill our original params
34
30
  query_parts = []
35
31
  keyword = conditions.delete(keyword_key) # keyword is magical
36
- unless keyword.blank?
32
+ if !blank?(keyword) # ie. !keyword.blank?
37
33
  query_parts << "#{solr_value(keyword, true)}"
38
34
  end
39
35
 
@@ -101,6 +97,16 @@ module SolrQuery
101
97
  string.gsub(SOLR_ESCAPE_REGEXP, "\\\\\\0").strip
102
98
  end
103
99
  protected :escape_solr_string
100
+
101
+ def blank?(object) #:nodoc: quick rehash of rails' object.blank?
102
+ if object.is_a?(String)
103
+ object !~ /\S/
104
+ else
105
+ object.respond_to?(:empty?) ? object.empty? : !object
106
+ end
107
+ end
108
+ protected :blank?
109
+
104
110
  end
105
111
 
106
112
  SOLR_ESCAPE_CHARACTERS = %w" \ + - ! ( ) : ; ^ [ ] { } ~ * ? "
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 0
9
- version: 1.0.0
8
+ - 1
9
+ version: 1.0.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Matthew Rudy
@@ -41,7 +41,6 @@ files:
41
41
  - MIT-LICENSE
42
42
  - Rakefile
43
43
  - README
44
- - lib/blank.rb
45
44
  - lib/solr_query.rb
46
45
  has_rdoc: true
47
46
  homepage: http://github.com/matthewrudy/solr_query
@@ -1,58 +0,0 @@
1
- class Object
2
- # An object is blank if it's false, empty, or a whitespace string.
3
- # For example, "", " ", +nil+, [], and {} are blank.
4
- #
5
- # This simplifies
6
- #
7
- # if !address.nil? && !address.empty?
8
- #
9
- # to
10
- #
11
- # if !address.blank?
12
- def blank?
13
- respond_to?(:empty?) ? empty? : !self
14
- end
15
-
16
- # An object is present if it's not blank.
17
- def present?
18
- !blank?
19
- end
20
- end
21
-
22
- class NilClass #:nodoc:
23
- def blank?
24
- true
25
- end
26
- end
27
-
28
- class FalseClass #:nodoc:
29
- def blank?
30
- true
31
- end
32
- end
33
-
34
- class TrueClass #:nodoc:
35
- def blank?
36
- false
37
- end
38
- end
39
-
40
- class Array #:nodoc:
41
- alias_method :blank?, :empty?
42
- end
43
-
44
- class Hash #:nodoc:
45
- alias_method :blank?, :empty?
46
- end
47
-
48
- class String #:nodoc:
49
- def blank?
50
- self !~ /\S/
51
- end
52
- end
53
-
54
- class Numeric #:nodoc:
55
- def blank?
56
- false
57
- end
58
- end