dusen 0.4.10 → 0.4.11

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -6,23 +6,12 @@ Comprehensive search solution for ActiveRecord and MySQL
6
6
 
7
7
  Dusen lets you search ActiveRecord model when all you have is MySQL (no Solr, Sphinx, etc.). Here's what Dusen does for you:
8
8
 
9
- 1. It takes a text query in Google-like syntax (e.g. `some words "a phrase" filetype:pdf`)
9
+ 1. It takes a text query in Google-like search syntax e.g. `some words "a phrase" filetype:pdf -excluded -"excluded phrase" filetype:-txt`)
10
10
  2. It parses the query into individual tokens.
11
11
  3. It lets you define simple mappers that convert a token to an ActiveRecord scope chain. Mappers can match tokens using ActiveRecord's `where` or perform full text searches with either [LIKE queries](#processing-full-text-search-queries-with-like-queries) or [FULLTEXT indexes](#processing-full-text-queries-with-fulltext-indexes) (see [performance analysis](https://makandracards.com/makandra/12813-performance-analysis-of-mysql-s-fulltext-indexes-and-like-queries-for-full-text-search)).
12
12
  4. It gives your model a method `Model.search('some query')` that performs all of the above and returns an ActiveRecord scope chain.
13
13
 
14
14
 
15
- Installation
16
- ------------
17
-
18
- In your `Gemfile` say:
19
-
20
- gem 'dusen'
21
-
22
- Now run `bundle install` and restart your server.
23
-
24
-
25
-
26
15
  Processing full text search queries with LIKE queries
27
16
  -----------------------------------------------------
28
17
 
@@ -300,6 +289,22 @@ Here are some method calls to get you started:
300
289
  syntax.search(Contact, query) # => #<ActiveRecord::Relation>
301
290
 
302
291
 
292
+ Supported Rails versions
293
+ ------------------------
294
+
295
+ Dusen is tested against Rails 3.0 and Rails 3.2. There is also a branch rails-2-3, which is tested against Rails 2.3.
296
+
297
+
298
+ Installation
299
+ ------------
300
+
301
+ In your `Gemfile` say:
302
+
303
+ gem 'dusen'
304
+
305
+ Now run `bundle install` and restart your server.
306
+
307
+
303
308
  Development
304
309
  -----------
305
310
 
@@ -314,7 +319,7 @@ If you would like to contribute:
314
319
  - Push your changes **with passing specs**.
315
320
  - Send me a pull request.
316
321
 
317
- I'm very eager to keep this gem leightweight and on topic. If you're unsure whether a change would make it into the gem, [talk to me beforehand](mailto:henning.koch@makandra.de).
322
+ I'm very eager to keep this gem lightweight and on topic. If you're unsure whether a change would make it into the gem, [talk to me beforehand](mailto:henning.koch@makandra.de).
318
323
 
319
324
 
320
325
  Credits
data/dusen.gemspec CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
16
16
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
17
  s.require_paths = ["lib"]
18
18
 
19
- s.add_dependency('activerecord')
19
+ s.add_dependency('activerecord', '>=3.0')
20
20
  s.add_dependency('edge_rider', '>=0.2.5')
21
21
 
22
22
  end
data/lib/dusen/parser.rb CHANGED
@@ -4,7 +4,7 @@ module Dusen
4
4
  class Parser
5
5
 
6
6
  WESTERNISH_WORD_CHARACTER = '\\w\\-\\.;@_ÄÖÜäöüß' # this is wrong on so many levels
7
- TEXT_QUERY = /(?:"([^"]+)"|([#{WESTERNISH_WORD_CHARACTER}]+))/
7
+ TEXT_QUERY = /(?:(\-)?"([^"]+)"|(\-)?([#{WESTERNISH_WORD_CHARACTER}]+))/
8
8
  FIELD_QUERY = /(\w+)\:#{TEXT_QUERY}/
9
9
 
10
10
  def self.parse(query_string)
@@ -17,16 +17,20 @@ module Dusen
17
17
 
18
18
  def self.extract_text_query_tokens(query_string, query)
19
19
  while query_string.sub!(TEXT_QUERY, '')
20
- value = "#{$1}#{$2}"
21
- query << Token.new(value)
20
+ value = "#{$2}#{$4}"
21
+ exclude = "#{$1}#{$3}" == "-"
22
+ options = { :field => 'text', :value => value, :exclude => exclude }
23
+ query << Token.new(options)
22
24
  end
23
25
  end
24
26
 
25
27
  def self.extract_field_query_tokens(query_string, query)
26
28
  while query_string.sub!(FIELD_QUERY, '')
27
29
  field = $1
28
- value = "#{$2}#{$3}"
29
- query << Token.new(field, value)
30
+ value = "#{$3}#{$5}"
31
+ exclude = "#{$2}#{$4}" == "-"
32
+ options = { :field => field, :value => value, :exclude => exclude }
33
+ query << Token.new(options)
30
34
  end
31
35
  end
32
36
 
data/lib/dusen/query.rb CHANGED
@@ -34,12 +34,29 @@ module Dusen
34
34
  end
35
35
 
36
36
  def condensed
37
- texts = tokens.select(&:text?).collect(&:value)
37
+ include_texts = include.select(&:text?).collect(&:value)
38
+ exclude_texts = exclude.select(&:text?).collect(&:value)
38
39
  field_tokens = tokens.reject(&:text?)
40
+
39
41
  condensed_tokens = field_tokens
40
- condensed_tokens << Token.new(texts) if texts.present?
42
+ if include_texts.present?
43
+ options = { :field => 'text', :value => include_texts, :exclude => false }
44
+ condensed_tokens << Token.new(options)
45
+ end
46
+ if exclude_texts.present?
47
+ options = { :field => 'text', :value => exclude_texts, :exclude => true }
48
+ condensed_tokens << Token.new(options)
49
+ end
41
50
  self.class.new(condensed_tokens)
42
51
  end
43
52
 
53
+ def include
54
+ self.class.new tokens.reject(&:exclude?)
55
+ end
56
+
57
+ def exclude
58
+ self.class.new tokens.select(&:exclude?)
59
+ end
60
+
44
61
  end
45
62
  end
data/lib/dusen/syntax.rb CHANGED
@@ -17,14 +17,27 @@ module Dusen
17
17
  end
18
18
 
19
19
  def search(root_scope, query)
20
- scope = root_scope
21
20
  query = parse(query) if query.is_a?(String)
22
21
  query = query.condensed
23
- query.each do |token|
24
- scoper = @scopers[token.field] || unknown_scoper
25
- scope = scoper.call(scope, token.value)
22
+ matches = find_parsed_query(root_scope, query.include)
23
+ if query.exclude.any?
24
+ exclude_matches = find_parsed_query(root_scope, query.exclude)
25
+
26
+ # extract conditions that were added by exclude tokens
27
+ sql = exclude_matches.to_sql
28
+ root_pattern = /\A#{Regexp.quote root_scope.to_sql}/
29
+ sql =~ root_pattern or raise "Could not find ..."
30
+ sql = sql.sub(root_pattern, '')
31
+
32
+ # negate conditions
33
+ sql = sql.sub(/^\s*WHERE\s*/i, '')
34
+ sql = sql.sub(/^\s*AND\s*/i, '')
35
+ sql = "NOT COALESCE(#{sql}, 0)"
36
+
37
+ matches.scoped(:conditions => sql)
38
+ else
39
+ matches
26
40
  end
27
- scope
28
41
  end
29
42
 
30
43
  def fields
@@ -51,5 +64,14 @@ module Dusen
51
64
  @unknown_scoper || DEFAULT_UNKNOWN_SCOPER
52
65
  end
53
66
 
67
+ def find_parsed_query(root_scope, query)
68
+ scope = root_scope
69
+ query.each do |token|
70
+ scoper = @scopers[token.field] || unknown_scoper
71
+ scope = scoper.call(scope, token.value)
72
+ end
73
+ scope
74
+ end
75
+
54
76
  end
55
77
  end
data/lib/dusen/token.rb CHANGED
@@ -3,16 +3,12 @@
3
3
  module Dusen
4
4
  class Token
5
5
 
6
- attr_reader :field, :value
6
+ attr_reader :field, :value, :exclude
7
7
 
8
- def initialize(*args)
9
- if args.length == 2
10
- @field, @value = args
11
- else
12
- @field = 'text'
13
- @value = args.first
14
- end
15
- @field = @field.to_s
8
+ def initialize(options)
9
+ @value = options.fetch(:value)
10
+ @exclude = options.fetch(:exclude)
11
+ @field = options.fetch(:field).to_s
16
12
  end
17
13
 
18
14
  def to_s
@@ -23,5 +19,9 @@ module Dusen
23
19
  field == 'text'
24
20
  end
25
21
 
22
+ def exclude?
23
+ exclude
24
+ end
25
+
26
26
  end
27
27
  end
data/lib/dusen/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module Dusen
4
- VERSION = '0.4.10'
4
+ VERSION = '0.4.11'
5
5
  end
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- dusen (0.4.9)
5
- activerecord
4
+ dusen (0.4.10)
5
+ activerecord (>= 3.0)
6
6
  edge_rider (>= 0.2.5)
7
7
 
8
8
  GEM
@@ -41,7 +41,7 @@ GEM
41
41
  columnize (0.3.6)
42
42
  database_cleaner (1.0.1)
43
43
  diff-lcs (1.2.4)
44
- edge_rider (0.2.5)
44
+ edge_rider (0.3.0)
45
45
  activerecord
46
46
  erubis (2.6.6)
47
47
  abstract (>= 1.0.0)
@@ -1,8 +1,8 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- dusen (0.4.9)
5
- activerecord
4
+ dusen (0.4.10)
5
+ activerecord (>= 3.0)
6
6
  edge_rider (>= 0.2.5)
7
7
 
8
8
  GEM
@@ -41,7 +41,7 @@ GEM
41
41
  columnize (0.3.6)
42
42
  database_cleaner (1.0.1)
43
43
  diff-lcs (1.2.4)
44
- edge_rider (0.2.5)
44
+ edge_rider (0.3.0)
45
45
  activerecord
46
46
  erubis (2.7.0)
47
47
  hike (1.2.2)
@@ -4,7 +4,7 @@ require 'spec_helper'
4
4
 
5
5
  shared_examples_for 'model with search syntax' do
6
6
 
7
- describe '.search' do
7
+ describe '#search' do
8
8
 
9
9
  it 'should find records by given words' do
10
10
  match = subject.create!(:name => 'Abraham')
@@ -78,6 +78,62 @@ shared_examples_for 'model with search syntax' do
78
78
  subject.search('Baden-Baden').to_a.should == [match]
79
79
  end
80
80
 
81
+ context 'with excludes' do
82
+
83
+ it 'should exclude words with prefix - (minus)' do
84
+ match = subject.create!(:name => 'Sunny Flower')
85
+ no_match = subject.create!(:name => 'Sunny Power')
86
+ no_match2 = subject.create!(:name => 'Absolutly no match')
87
+ subject.search('Sunny -Power').to_a.should == [match]
88
+ end
89
+
90
+ it 'should exclude phrases with prefix - (minus)' do
91
+ match = subject.create!(:name => 'Buch Tastatur Schreibtisch')
92
+ no_match = subject.create!(:name => 'Buch Schreibtisch Tastatur')
93
+ no_match2 = subject.create!(:name => 'Absolutly no match')
94
+ subject.search('Buch -"Schreibtisch Tastatur"').to_a.should == [match]
95
+ end
96
+
97
+ it 'should exclude qualified fields with prefix - (minus)' do
98
+ match = subject.create!(:name => 'Abraham', :city => 'Foohausen')
99
+ no_match = subject.create!(:name => 'Abraham', :city => 'Barhausen')
100
+ no_match2 = subject.create!(:name => 'Absolutly no match')
101
+ subject.search('Abraham city:-Barhausen').to_a.should == [match]
102
+ end
103
+
104
+ it 'should work if the query only contains excluded words' do
105
+ match = subject.create!(:name => 'Sunny Flower')
106
+ no_match = subject.create!(:name => 'Sunny Power')
107
+ subject.search('-Power').to_a.should == [match]
108
+ end
109
+
110
+ it 'should work if the query only contains excluded phrases' do
111
+ match = subject.create!(:name => 'Buch Tastatur Schreibtisch')
112
+ no_match = subject.create!(:name => 'Buch Schreibtisch Tastatur')
113
+ subject.search('-"Schreibtisch Tastatur"').to_a.should == [match]
114
+ end
115
+
116
+ it 'should work if the query only contains excluded qualified fields' do
117
+ match = subject.create!(:name => 'Abraham', :city => 'Foohausen')
118
+ no_match = subject.create!(:name => 'Abraham', :city => 'Barhausen')
119
+ subject.search('city:-Barhausen').to_a.should == [match]
120
+ end
121
+
122
+ it 'respects an existing scope chain when there are only excluded tokens (bugfix)' do
123
+ match = subject.create!(:name => 'Abraham', :city => 'Foohausen')
124
+ no_match = subject.create!(:name => 'Abraham', :city => 'Barhausen')
125
+ subject.scoped(:conditions => { :name => 'Abraham' }).search('-Barhausen').to_a.should == [match]
126
+ end
127
+
128
+ it 'should work if there are fields contained in the search that are NULL (needs NOT COALESCE in syntax#search)' do
129
+ match = subject.create!(:name => 'Sunny Flower', :city => nil, :email => nil)
130
+ no_match = subject.create!(:name => 'Sunny Power', :city => nil, :email => nil)
131
+ no_match2 = subject.create!(:name => 'Absolutly no match')
132
+ subject.search('Sunny -Power').to_a.should == [match]
133
+ end
134
+
135
+ end
136
+
81
137
  context 'when the given query is blank' do
82
138
 
83
139
  it 'returns all records' do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dusen
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 10
10
- version: 0.4.10
9
+ - 11
10
+ version: 0.4.11
11
11
  platform: ruby
12
12
  authors:
13
13
  - Henning Koch
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2014-05-05 00:00:00 +02:00
18
+ date: 2015-03-30 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -26,10 +26,11 @@ dependencies:
26
26
  requirements:
27
27
  - - ">="
28
28
  - !ruby/object:Gem::Version
29
- hash: 3
29
+ hash: 7
30
30
  segments:
31
+ - 3
31
32
  - 0
32
- version: "0"
33
+ version: "3.0"
33
34
  type: :runtime
34
35
  version_requirements: *id001
35
36
  - !ruby/object:Gem::Dependency
@@ -84,19 +85,6 @@ files:
84
85
  - lib/dusen/token.rb
85
86
  - lib/dusen/util.rb
86
87
  - lib/dusen/version.rb
87
- - spec/rails-2.3/Gemfile
88
- - spec/rails-2.3/Gemfile.lock
89
- - spec/rails-2.3/Rakefile
90
- - spec/rails-2.3/app_root/config/boot.rb
91
- - spec/rails-2.3/app_root/config/environment.rb
92
- - spec/rails-2.3/app_root/config/environments/test.rb
93
- - spec/rails-2.3/app_root/config/initializers/fix_missing_source_file.rb
94
- - spec/rails-2.3/app_root/config/preinitializer.rb
95
- - spec/rails-2.3/app_root/config/routes.rb
96
- - spec/rails-2.3/app_root/log/.gitignore
97
- - spec/rails-2.3/rcov.opts
98
- - spec/rails-2.3/spec.opts
99
- - spec/rails-2.3/spec/spec_helper.rb
100
88
  - spec/rails-3.0/.rspec
101
89
  - spec/rails-3.0/Gemfile
102
90
  - spec/rails-3.0/Gemfile.lock
@@ -1,13 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'rails', '~>2.3'
4
- gem 'rspec', '~>1.3'
5
- gem 'rspec-rails', '~>1.3'
6
- gem 'mysql2', '~>0.2.0'
7
- gem 'ruby-debug', :platforms => :ruby_18
8
- gem 'test-unit', '~>1.2', :platforms => :ruby_19
9
- gem 'hoe', '=2.8.0', :platforms => :ruby_19
10
- gem 'database_cleaner'
11
- gem 'andand'
12
-
13
- gem 'dusen', :path => '../..'
@@ -1,66 +0,0 @@
1
- PATH
2
- remote: ../..
3
- specs:
4
- dusen (0.4.9)
5
- activerecord
6
- edge_rider (>= 0.2.5)
7
-
8
- GEM
9
- remote: https://rubygems.org/
10
- specs:
11
- actionmailer (2.3.18)
12
- actionpack (= 2.3.18)
13
- actionpack (2.3.18)
14
- activesupport (= 2.3.18)
15
- rack (~> 1.1.0)
16
- activerecord (2.3.18)
17
- activesupport (= 2.3.18)
18
- activeresource (2.3.18)
19
- activesupport (= 2.3.18)
20
- activesupport (2.3.18)
21
- andand (1.3.3)
22
- columnize (0.3.6)
23
- database_cleaner (1.0.1)
24
- edge_rider (0.2.5)
25
- activerecord
26
- hoe (2.8.0)
27
- rake (>= 0.8.7)
28
- linecache (0.46)
29
- rbx-require-relative (> 0.0.4)
30
- mysql2 (0.2.18)
31
- rack (1.1.6)
32
- rails (2.3.18)
33
- actionmailer (= 2.3.18)
34
- actionpack (= 2.3.18)
35
- activerecord (= 2.3.18)
36
- activeresource (= 2.3.18)
37
- activesupport (= 2.3.18)
38
- rake (>= 0.8.3)
39
- rake (10.0.4)
40
- rbx-require-relative (0.0.9)
41
- rspec (1.3.2)
42
- rspec-rails (1.3.4)
43
- rack (>= 1.0.0)
44
- rspec (~> 1.3.1)
45
- ruby-debug (0.10.4)
46
- columnize (>= 0.1)
47
- ruby-debug-base (~> 0.10.4.0)
48
- ruby-debug-base (0.10.4)
49
- linecache (>= 0.3)
50
- test-unit (1.2.3)
51
- hoe (>= 1.5.1)
52
-
53
- PLATFORMS
54
- ruby
55
-
56
- DEPENDENCIES
57
- andand
58
- database_cleaner
59
- dusen!
60
- hoe (= 2.8.0)
61
- mysql2 (~> 0.2.0)
62
- rails (~> 2.3)
63
- rspec (~> 1.3)
64
- rspec-rails (~> 1.3)
65
- ruby-debug
66
- test-unit (~> 1.2)
@@ -1,11 +0,0 @@
1
- require 'rake'
2
- require 'spec/rake/spectask'
3
-
4
- desc 'Default: Run all specs for a specific rails version.'
5
- task :default => :spec
6
-
7
- desc "Run all specs for a specific rails version"
8
- Spec::Rake::SpecTask.new() do |t|
9
- t.spec_opts = ['--options', "\"spec.opts\""]
10
- t.spec_files = defined?(SPEC) ? SPEC : FileList['**/*_spec.rb', '../shared/spec/**/*_spec.rb']
11
- end
@@ -1,130 +0,0 @@
1
- # encoding: utf-8
2
-
3
- # Allow customization of the rails framework path
4
- RAILS_FRAMEWORK_ROOT = (ENV['RAILS_FRAMEWORK_ROOT'] || "#{File.dirname(__FILE__)}/../../../../../../vendor/rails") unless defined?(RAILS_FRAMEWORK_ROOT)
5
-
6
- # Don't change this file!
7
- # Configure your app in config/environment.rb and config/environments/*.rb
8
-
9
- RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
10
-
11
- module Rails
12
- class << self
13
- def boot!
14
- unless booted?
15
- preinitialize
16
- pick_boot.run
17
- end
18
- end
19
-
20
- def booted?
21
- defined? Rails::Initializer
22
- end
23
-
24
- def pick_boot
25
- (vendor_rails? ? VendorBoot : GemBoot).new
26
- end
27
-
28
- def vendor_rails?
29
- File.exist?(RAILS_FRAMEWORK_ROOT)
30
- end
31
-
32
- def preinitialize
33
- load(preinitializer_path) if File.exist?(preinitializer_path)
34
- end
35
-
36
- def preinitializer_path
37
- "#{RAILS_ROOT}/config/preinitializer.rb"
38
- end
39
- end
40
-
41
- class Boot
42
- def run
43
- load_initializer
44
- Rails::Initializer.run(:set_load_path)
45
- end
46
- end
47
-
48
- class VendorBoot < Boot
49
- def load_initializer
50
- require "#{RAILS_FRAMEWORK_ROOT}/railties/lib/initializer"
51
- Rails::Initializer.run(:install_gem_spec_stubs)
52
- end
53
- end
54
-
55
- class GemBoot < Boot
56
- def load_initializer
57
- self.class.load_rubygems
58
- load_rails_gem
59
- require 'initializer'
60
- end
61
-
62
- def load_rails_gem
63
- if version = self.class.gem_version
64
- gem 'rails', version
65
- else
66
- gem 'rails'
67
- end
68
- rescue Gem::LoadError => load_error
69
- $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
70
- exit 1
71
- end
72
-
73
- class << self
74
- def rubygems_version
75
- Gem::RubyGemsVersion rescue nil
76
- end
77
-
78
- def gem_version
79
- if defined? RAILS_GEM_VERSION
80
- RAILS_GEM_VERSION
81
- elsif ENV.include?('RAILS_GEM_VERSION')
82
- ENV['RAILS_GEM_VERSION']
83
- else
84
- parse_gem_version(read_environment_rb)
85
- end
86
- end
87
-
88
- def load_rubygems
89
- require 'rubygems'
90
- min_version = '1.1.1'
91
- unless rubygems_version >= min_version
92
- $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
93
- exit 1
94
- end
95
-
96
- rescue LoadError
97
- $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
98
- exit 1
99
- end
100
-
101
- def parse_gem_version(text)
102
- $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
103
- end
104
-
105
- private
106
- def read_environment_rb
107
- environment_rb = "#{RAILS_ROOT}/config/environment.rb"
108
- environment_rb = "#{HELPER_RAILS_ROOT}/config/environment.rb" unless File.exists?(environment_rb)
109
- File.read(environment_rb)
110
- end
111
- end
112
- end
113
- end
114
-
115
- class Rails::Boot
116
- def run
117
- load_initializer
118
-
119
- Rails::Initializer.class_eval do
120
- def load_gems
121
- @bundler_loaded ||= Bundler.require :default, Rails.env
122
- end
123
- end
124
-
125
- Rails::Initializer.run(:set_load_path)
126
- end
127
- end
128
-
129
- # All that for this:
130
- Rails.boot!
@@ -1,16 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require File.join(File.dirname(__FILE__), 'boot')
4
-
5
- Rails::Initializer.run do |config|
6
- config.cache_classes = false
7
- config.whiny_nils = true
8
- config.action_controller.session = { :key => "_myapp_session", :secret => "gwirofjweroijger8924rt2zfwehfuiwehb1378rifowenfoqwphf23" }
9
- config.plugin_locators.unshift(
10
- Class.new(Rails::Plugin::Locator) do
11
- def plugins
12
- [Rails::Plugin.new(File.expand_path('.'))]
13
- end
14
- end
15
- ) unless defined?(PluginTestHelper::PluginLocator)
16
- end
File without changes
@@ -1 +0,0 @@
1
- MissingSourceFile::REGEXPS.push([/^cannot load such file -- (.+)$/i, 1])
@@ -1,22 +0,0 @@
1
- # encoding: utf-8
2
-
3
- begin
4
- require "rubygems"
5
- require "bundler"
6
- rescue LoadError
7
- raise "Could not load the bundler gem. Install it with `gem install bundler`."
8
- end
9
-
10
- if Gem::Version.new(Bundler::VERSION) <= Gem::Version.new("0.9.24")
11
- raise RuntimeError, "Your bundler version is too old for Rails 2.3." +
12
- "Run `gem install bundler` to upgrade."
13
- end
14
-
15
- begin
16
- # Set up load paths for all bundled gems
17
- ENV["BUNDLE_GEMFILE"] = File.expand_path("../../Gemfile", __FILE__)
18
- Bundler.setup
19
- rescue Bundler::GemNotFound
20
- raise RuntimeError, "Bundler couldn't find some gems." +
21
- "Did you run `bundle install`?"
22
- end
@@ -1,15 +0,0 @@
1
- # encoding: utf-8
2
-
3
- ActionController::Routing::Routes.draw do |map|
4
-
5
- map.resource :dashboard, :member => { :error => :post }
6
-
7
- map.resources :songs
8
-
9
- map.resources :users
10
-
11
- map.resources :risks
12
-
13
- map.resources :cakes, :member => { :custom_action => :get }
14
-
15
- end
@@ -1 +0,0 @@
1
- *.log
@@ -1,2 +0,0 @@
1
- --exclude "spec/*,gems/*"
2
- --rails
@@ -1,24 +0,0 @@
1
- # encoding: utf-8
2
-
3
- $: << File.join(File.dirname(__FILE__), "/../../lib" )
4
-
5
- ENV['RAILS_ENV'] = 'test'
6
-
7
- # Load the Rails environment and testing framework
8
- require "#{File.dirname(__FILE__)}/../app_root/config/environment"
9
- require 'spec/rails'
10
- DatabaseCleaner.strategy = :truncation
11
-
12
- # Requires supporting files with custom matchers and macros, etc in ./support/ and its subdirectories.
13
- Dir[File.expand_path(File.join(File.dirname(__FILE__),'support','**','*.rb'))].each {|f| require f}
14
-
15
- # Run the migrations
16
- Dusen::Util.migrate_test_database
17
-
18
- Spec::Runner.configure do |config|
19
- config.use_transactional_fixtures = false
20
- config.use_instantiated_fixtures = false
21
- config.before(:each) do
22
- DatabaseCleaner.clean
23
- end
24
- end
@@ -1,4 +0,0 @@
1
- --colour
2
- --format progress
3
- --loadby mtime
4
- --reverse