picky-generators 4.0.0pre1 → 4.0.0pre2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. data/lib/picky-generators/generators/all_in_one/sinatra.rb +1 -1
  2. data/lib/picky-generators/generators/selector.rb +0 -6
  3. data/lib/picky-generators/generators/server/sinatra.rb +1 -1
  4. data/lib/picky-generators.rb +0 -3
  5. data/prototypes/all_in_one/sinatra/Gemfile +2 -2
  6. data/prototypes/all_in_one/sinatra/app.rb +20 -2
  7. data/prototypes/all_in_one/sinatra/book.rb +1 -1
  8. data/prototypes/all_in_one/sinatra/views/search.haml +1 -1
  9. data/prototypes/client/sinatra/Gemfile +1 -1
  10. data/prototypes/client/sinatra/app.rb +1 -1
  11. data/prototypes/client/sinatra/views/search.haml +1 -1
  12. data/prototypes/server/sinatra/app.rb +19 -1
  13. data/prototypes/{all_in_one/sinatra → shared/server}/config.ru +2 -0
  14. data/prototypes/shared/server/tmp/pids/README +1 -0
  15. data/spec/lib/picky-generators/generators/selector_spec.rb +11 -14
  16. data/spec/lib/picky-generators/generators/server/sinatra_spec.rb +5 -5
  17. metadata +20 -36
  18. data/lib/picky-generators/generators/server/classic.rb +0 -42
  19. data/prototypes/server/classic/Gemfile +0 -27
  20. data/prototypes/server/classic/app/README +0 -4
  21. data/prototypes/server/classic/app/application.rb +0 -47
  22. data/prototypes/server/classic/app/db.yml +0 -13
  23. data/prototypes/server/classic/app/logging.rb +0 -23
  24. data/prototypes/server/classic/config.ru +0 -31
  25. data/prototypes/server/classic/log/README +0 -1
  26. data/prototypes/server/classic/script/console +0 -5
  27. data/prototypes/server/classic/spec/spec_helper.rb +0 -8
  28. data/prototypes/server/shared/data/test/library.csv +0 -540
  29. data/prototypes/server/shared/tmp/pids/README +0 -1
  30. data/prototypes/server/sinatra/config.ru +0 -14
  31. data/prototypes/server/sinatra/logging.rb +0 -24
  32. data/prototypes/server/sinatra/spec/spec_helper.rb +0 -6
  33. data/spec/lib/picky-generators/generators/server/classic_spec.rb +0 -35
  34. /data/prototypes/server/{shared → sinatra}/Rakefile +0 -0
  35. /data/prototypes/server/{shared → sinatra}/spec/integration_spec.rb +0 -0
  36. /data/prototypes/{all_in_one/sinatra → shared/server/data/development}/library.csv +0 -0
  37. /data/prototypes/{server/shared/data/development → shared/server/data/production}/library.csv +0 -0
  38. /data/prototypes/{server/shared/data/production → shared/server/data/test}/library.csv +0 -0
  39. /data/prototypes/{all_in_one/sinatra → shared/server}/logging.rb +0 -0
  40. /data/prototypes/{all_in_one/sinatra → shared/server}/spec/spec_helper.rb +0 -0
  41. /data/prototypes/{server/shared → shared/server}/unicorn.rb +0 -0
@@ -21,7 +21,7 @@ module Picky
21
21
  exclaim "Setting up Picky Sinatra Client/Server \"#{name}\"."
22
22
  create_target_directory
23
23
  copy_all_files
24
- copy_all_files expand_prototype_path('server/shared')
24
+ copy_all_files expand_prototype_path('shared/server')
25
25
  exclaim "\"#{name}\" is a great project name! Have fun :)\n"
26
26
  exclaim ""
27
27
  exclaim "Next steps:"
@@ -12,12 +12,6 @@ module Picky
12
12
  @types = {
13
13
  :client => [Client::Sinatra, :sinatra_client_name],
14
14
  :server => [Server::Sinatra, :sinatra_server_name],
15
-
16
- :sinatra_client => [Client::Sinatra, :sinatra_client_name],
17
-
18
- :classic_server => [Server::Classic, :unicorn_server_name],
19
- :sinatra_server => [Server::Sinatra, :sinatra_server_name],
20
-
21
15
  :all_in_one => [AllInOne::Sinatra, :"directory_name (use e.g. for Heroku)"]
22
16
  }
23
17
  end
@@ -21,7 +21,7 @@ module Picky
21
21
  exclaim "Setting up Picky Sinatra Server \"#{name}\"."
22
22
  create_target_directory
23
23
  copy_all_files
24
- copy_all_files expand_prototype_path('server/shared')
24
+ copy_all_files expand_prototype_path('shared/server')
25
25
  exclaim "\"#{name}\" is a great project name! Have fun :)\n"
26
26
  exclaim ""
27
27
  exclaim "Next steps:"
@@ -3,10 +3,7 @@ require File.expand_path '../picky-generators/generators/not_found_exception', _
3
3
  require File.expand_path '../picky-generators/generators/base', __FILE__
4
4
 
5
5
  require File.expand_path '../picky-generators/generators/client/sinatra', __FILE__
6
-
7
- require File.expand_path '../picky-generators/generators/server/classic', __FILE__
8
6
  require File.expand_path '../picky-generators/generators/server/sinatra', __FILE__
9
-
10
7
  require File.expand_path '../picky-generators/generators/all_in_one/sinatra', __FILE__
11
8
 
12
9
  require File.expand_path '../picky-generators/generators/selector', __FILE__
@@ -2,7 +2,7 @@ source :gemcutter
2
2
 
3
3
  # Gems required by the Picky client.
4
4
  #
5
- gem 'picky-client', '~> 4.0.0pre1'
5
+ gem 'picky-client', '~> 4.0.0pre2'
6
6
  gem 'i18n'
7
7
  gem 'activesupport', :require => 'active_support/core_ext'
8
8
  gem 'sinatra'
@@ -10,7 +10,7 @@ gem 'haml'
10
10
 
11
11
  # Gems required by the Picky server.
12
12
  #
13
- gem 'picky', '~> 4.0.0pre1'
13
+ gem 'picky', '~> 4.0.0pre2'
14
14
  gem 'rake'
15
15
  gem 'rack'
16
16
  gem 'rack_fast_escape', '2009.06.24' # Optional.
@@ -1,6 +1,7 @@
1
1
  require 'sinatra/base'
2
2
  require 'i18n'
3
3
  require 'haml'
4
+ require 'csv'
4
5
  require 'picky'
5
6
  require 'picky-client'
6
7
 
@@ -22,10 +23,27 @@ class BookSearch < Sinatra::Application
22
23
  # Server.
23
24
  #
24
25
 
26
+ # Data source.
27
+ #
28
+ class Books
29
+
30
+ def initialize
31
+ @csv = CSV.new File.open(File.expand_path("../data/#{PICKY_ENVIRONMENT}/library.csv", __FILE__))
32
+ end
33
+
34
+ def each
35
+ instance = Struct.new :id, :title, :author, :year
36
+ @csv.each do |row|
37
+ yield instance.new *row[0..3]
38
+ end
39
+ end
40
+
41
+ end
42
+
25
43
  # Define an index.
26
44
  #
27
45
  books_index = Index.new :books do
28
- source Sources::CSV.new(:title, :author, :year, file: "data/#{PICKY_ENVIRONMENT}/library.csv")
46
+ source { Books.new }
29
47
  indexing removes_characters: /[^a-z0-9\s\/\-\_\:\"\&\.]/i,
30
48
  stopwords: /\b(and|the|of|it|in|for)\b/i,
31
49
  splits_text_on: /[\s\/\-\_\:\"\&\/]/
@@ -99,7 +117,7 @@ class BookSearch < Sinatra::Application
99
117
  # rendered_entries = results.entries.map do |book| (render each book here) end
100
118
  #
101
119
 
102
- ActiveSupport::JSON.encode results
120
+ Yajl::Encoder.encode results
103
121
  end
104
122
 
105
123
  # Updates the search count while the user is typing.
@@ -14,7 +14,7 @@ class Book
14
14
 
15
15
  # Load the books on startup.
16
16
  #
17
- file_name = File.expand_path 'library.csv', File.dirname(__FILE__)
17
+ file_name = File.expand_path "../data/#{PICKY_ENVIRONMENT}/library.csv", __FILE__
18
18
  CSV.open(file_name, 'r').each do |row|
19
19
  @@books_mapping[row.shift.to_i] = row
20
20
  end
@@ -7,7 +7,7 @@
7
7
  = js 'jquery-1.5.0.min'
8
8
  = js 'history.min'
9
9
  = js 'history.adapter.jquery.min'
10
- <script src='http://raw.github.com/floere/picky/master/client/javascripts/picky.min.js' type='text/javascript'></script>
10
+ = js 'picky.min'
11
11
 
12
12
  %body
13
13
  %img{:src => "images/picky.png"}/
@@ -2,7 +2,7 @@ source :gemcutter
2
2
 
3
3
  # Gems required by the Picky client.
4
4
  #
5
- gem 'picky-client', '~> 4.0.0pre1'
5
+ gem 'picky-client', '~> 4.0.0pre2'
6
6
  gem 'i18n'
7
7
  gem 'activesupport', :require => 'active_support/core_ext'
8
8
  gem 'sinatra'
@@ -45,7 +45,7 @@ get '/search/full' do
45
45
  # rendered_entries = results.entries.map do |book| (render each book here) end
46
46
  #
47
47
 
48
- ActiveSupport::JSON.encode results
48
+ Yajl::Encoder.encode results
49
49
  end
50
50
 
51
51
  # Updates the search count while the user is typing.
@@ -7,7 +7,7 @@
7
7
  = js 'jquery-1.5.0.min'
8
8
  = js 'history.min'
9
9
  = js 'history.adapter.jquery.min'
10
- <script src='http://raw.github.com/floere/picky/master/client/javascripts/picky.min.js' type='text/javascript'></script>
10
+ = js 'picky.min'
11
11
 
12
12
  %body
13
13
  %img{:src => "images/picky.png"}/
@@ -1,4 +1,5 @@
1
1
  require 'sinatra/base'
2
+ require 'csv'
2
3
  require 'picky'
3
4
  require File.expand_path '../logging', __FILE__
4
5
 
@@ -9,10 +10,27 @@ class BookSearch < Sinatra::Application
9
10
  #
10
11
  include Picky
11
12
 
13
+ # Data source.
14
+ #
15
+ class Books
16
+
17
+ def initialize
18
+ @csv = CSV.new File.open(File.expand_path("../data/#{PICKY_ENVIRONMENT}/library.csv", __FILE__))
19
+ end
20
+
21
+ def each
22
+ instance = Struct.new :id, :title, :author, :year
23
+ @csv.each do |row|
24
+ yield instance.new *row[0..3]
25
+ end
26
+ end
27
+
28
+ end
29
+
12
30
  # Define an index.
13
31
  #
14
32
  books_index = Index.new :books do
15
- source Sources::CSV.new(:title, :author, :year, file: "data/#{PICKY_ENVIRONMENT}/library.csv")
33
+ source { Books.new }
16
34
  indexing removes_characters: /[^a-z0-9\s\/\-\_\:\"\&\.]/i,
17
35
  stopwords: /\b(and|the|of|it|in|for)\b/i,
18
36
  splits_text_on: /[\s\/\-\_\:\"\&\/]/
@@ -1,3 +1,5 @@
1
+ # Load application.
2
+ #
1
3
  require File.expand_path '../app', __FILE__
2
4
 
3
5
  # Load all indexes.
@@ -0,0 +1 @@
1
+ Temporary pids for Unicorn servers.
@@ -2,46 +2,43 @@
2
2
  require 'spec_helper'
3
3
 
4
4
  describe Picky::Generators::Selector do
5
-
5
+
6
6
  describe "main class" do
7
7
  before(:each) do
8
8
  @selector = Picky::Generators::Selector.new
9
9
  end
10
-
10
+
11
11
  describe "generator_for_class" do
12
12
  it "should return me a generator for the given class" do
13
- @selector.generator_for_class(Picky::Generators::Server::Classic, :identifier, :some_args).should be_kind_of(Picky::Generators::Server::Classic)
13
+ @selector.generator_for_class(Picky::Generators::Server::Sinatra, :identifier, :some_args).should be_kind_of(Picky::Generators::Server::Sinatra)
14
14
  end
15
15
  end
16
-
16
+
17
17
  describe "generator_for" do
18
18
  it "should not raise if a generator is available" do
19
- lambda { @selector.generator_for('all_in_one', 'some_project') }.should_not raise_error
20
- end
21
- it "should not raise if a generator is available" do
22
- lambda { @selector.generator_for('sinatra_client', 'some_project') }.should_not raise_error
19
+ lambda { @selector.generator_for('client', 'some_project') }.should_not raise_error
23
20
  end
24
21
  it "should not raise if a generator is available" do
25
- lambda { @selector.generator_for('classic_server', 'some_project') }.should_not raise_error
22
+ lambda { @selector.generator_for('server', 'some_project') }.should_not raise_error
26
23
  end
27
24
  it "should not raise if a generator is available" do
28
- lambda { @selector.generator_for('sinatra_server', 'some_project') }.should_not raise_error
25
+ lambda { @selector.generator_for('all_in_one', 'some_project') }.should_not raise_error
29
26
  end
30
27
  it "should raise if a generator is not available" do
31
28
  lambda { @selector.generator_for('blarf', 'gnorf') }.should raise_error(Picky::Generators::NotFoundException)
32
29
  end
33
30
  end
34
-
31
+
35
32
  describe "generate" do
36
33
  it "should raise a NoGeneratorException if called with the wrong params" do
37
34
  lambda { @selector.generate('blarf', 'gnorf') }.should raise_error(Picky::Generators::NotFoundException)
38
35
  end
39
36
  it "should not raise on the right params" do
40
37
  @selector.stub! :generator_for_class => stub(:generator, :generate => nil)
41
-
42
- lambda { @selector.generate('sinatra_client', 'some_project') }.should_not raise_error
38
+
39
+ lambda { @selector.generate('client', 'some_project') }.should_not raise_error
43
40
  end
44
41
  end
45
42
  end
46
-
43
+
47
44
  end
@@ -3,12 +3,12 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  describe Picky::Generators::Server::Sinatra do
6
-
6
+
7
7
  before(:each) do
8
8
  @sinatra = Picky::Generators::Server::Sinatra.new :sinatra_server, 'sinatra_server_dir_name'
9
9
  @sinatra.stub! :exclaim
10
10
  end
11
-
11
+
12
12
  context "after initialize" do
13
13
  it 'has the right identifier' do
14
14
  @sinatra.identifier.should == :sinatra_server
@@ -20,16 +20,16 @@ describe Picky::Generators::Server::Sinatra do
20
20
  @sinatra.prototype_basedir.should == File.expand_path('../../../../../../prototypes/server/sinatra', __FILE__)
21
21
  end
22
22
  end
23
-
23
+
24
24
  describe "generate" do
25
25
  it "should do things in order" do
26
26
  @sinatra.should_receive(:exclaim).once.ordered # Initial explanation
27
27
  @sinatra.should_receive(:create_target_directory).once.ordered
28
28
  @sinatra.should_receive(:copy_all_files).twice.ordered
29
29
  @sinatra.should_receive(:exclaim).at_least(8).times.ordered # Some user steps to do
30
-
30
+
31
31
  @sinatra.generate
32
32
  end
33
33
  end
34
-
34
+
35
35
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: picky-generators
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.0pre1
4
+ version: 4.0.0pre2
5
5
  prerelease: 5
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: 2011-12-06 00:00:00.000000000 Z
12
+ date: 2011-12-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &70278827867220 !ruby/object:Gem::Requirement
16
+ requirement: &70251514102680 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,29 +21,29 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *70278827867220
24
+ version_requirements: *70251514102680
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: picky
27
- requirement: &70278827866720 !ruby/object:Gem::Requirement
27
+ requirement: &70251514101780 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
31
31
  - !ruby/object:Gem::Version
32
- version: 4.0.0pre1
32
+ version: 4.0.0pre2
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70278827866720
35
+ version_requirements: *70251514101780
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: picky-client
38
- requirement: &70278827866060 !ruby/object:Gem::Requirement
38
+ requirement: &70251514100740 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
42
42
  - !ruby/object:Gem::Version
43
- version: 4.0.0pre1
43
+ version: 4.0.0pre2
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70278827866060
46
+ version_requirements: *70251514100740
47
47
  description: Generators for Picky.
48
48
  email: florian.hanke+picky-generators@gmail.com
49
49
  executables:
@@ -56,24 +56,19 @@ files:
56
56
  - lib/picky-generators/generators/client/sinatra.rb
57
57
  - lib/picky-generators/generators/not_found_exception.rb
58
58
  - lib/picky-generators/generators/selector.rb
59
- - lib/picky-generators/generators/server/classic.rb
60
59
  - lib/picky-generators/generators/server/sinatra.rb
61
60
  - lib/picky-generators.rb
62
61
  - prototypes/all_in_one/sinatra/app.rb
63
62
  - prototypes/all_in_one/sinatra/book.rb
64
- - prototypes/all_in_one/sinatra/config.ru
65
63
  - prototypes/all_in_one/sinatra/Gemfile
66
64
  - prototypes/all_in_one/sinatra/images/picky.png
67
65
  - prototypes/all_in_one/sinatra/javascripts/history.adapter.jquery.min.js
68
66
  - prototypes/all_in_one/sinatra/javascripts/history.min.js
69
67
  - prototypes/all_in_one/sinatra/javascripts/jquery-1.5.0.min.js
70
68
  - prototypes/all_in_one/sinatra/javascripts/picky.min.js
71
- - prototypes/all_in_one/sinatra/library.csv
72
69
  - prototypes/all_in_one/sinatra/log/README
73
- - prototypes/all_in_one/sinatra/logging.rb
74
70
  - prototypes/all_in_one/sinatra/Rakefile
75
71
  - prototypes/all_in_one/sinatra/spec/integration_spec.rb
76
- - prototypes/all_in_one/sinatra/spec/spec_helper.rb
77
72
  - prototypes/all_in_one/sinatra/stylesheets/application.css
78
73
  - prototypes/all_in_one/sinatra/stylesheets/picky.css
79
74
  - prototypes/all_in_one/sinatra/views/configure.haml
@@ -93,33 +88,23 @@ files:
93
88
  - prototypes/client/sinatra/stylesheets/picky.css
94
89
  - prototypes/client/sinatra/views/configure.haml
95
90
  - prototypes/client/sinatra/views/search.haml
96
- - prototypes/server/classic/app/application.rb
97
- - prototypes/server/classic/app/db.yml
98
- - prototypes/server/classic/app/logging.rb
99
- - prototypes/server/classic/app/README
100
- - prototypes/server/classic/config.ru
101
- - prototypes/server/classic/Gemfile
102
- - prototypes/server/classic/log/README
103
- - prototypes/server/classic/script/console
104
- - prototypes/server/classic/spec/spec_helper.rb
105
- - prototypes/server/shared/data/development/library.csv
106
- - prototypes/server/shared/data/production/library.csv
107
- - prototypes/server/shared/data/test/library.csv
108
- - prototypes/server/shared/Rakefile
109
- - prototypes/server/shared/spec/integration_spec.rb
110
- - prototypes/server/shared/tmp/pids/README
111
- - prototypes/server/shared/unicorn.rb
112
91
  - prototypes/server/sinatra/app.rb
113
- - prototypes/server/sinatra/config.ru
114
92
  - prototypes/server/sinatra/log/README
115
93
  - prototypes/server/sinatra/log/unicorn.stderr.log
116
94
  - prototypes/server/sinatra/log/unicorn.stdout.log
117
- - prototypes/server/sinatra/logging.rb
118
- - prototypes/server/sinatra/spec/spec_helper.rb
95
+ - prototypes/server/sinatra/Rakefile
96
+ - prototypes/server/sinatra/spec/integration_spec.rb
97
+ - prototypes/shared/server/config.ru
98
+ - prototypes/shared/server/data/development/library.csv
99
+ - prototypes/shared/server/data/production/library.csv
100
+ - prototypes/shared/server/data/test/library.csv
101
+ - prototypes/shared/server/logging.rb
102
+ - prototypes/shared/server/spec/spec_helper.rb
103
+ - prototypes/shared/server/tmp/pids/README
104
+ - prototypes/shared/server/unicorn.rb
119
105
  - spec/lib/picky-generators/generators/base_spec.rb
120
106
  - spec/lib/picky-generators/generators/client/sinatra_spec.rb
121
107
  - spec/lib/picky-generators/generators/selector_spec.rb
122
- - spec/lib/picky-generators/generators/server/classic_spec.rb
123
108
  - spec/lib/picky-generators/generators/server/sinatra_spec.rb
124
109
  - bin/picky-generate
125
110
  homepage: http://floere.github.com/picky
@@ -150,5 +135,4 @@ test_files:
150
135
  - spec/lib/picky-generators/generators/base_spec.rb
151
136
  - spec/lib/picky-generators/generators/client/sinatra_spec.rb
152
137
  - spec/lib/picky-generators/generators/selector_spec.rb
153
- - spec/lib/picky-generators/generators/server/classic_spec.rb
154
138
  - spec/lib/picky-generators/generators/server/sinatra_spec.rb
@@ -1,42 +0,0 @@
1
- module Picky
2
-
3
- module Generators
4
-
5
- module Server
6
-
7
- # Generates a new Picky Classic Server Example.
8
- #
9
- # Example:
10
- # > picky-generate classic_server my_classic_directory
11
- #
12
- class Classic < Picky::Generators::Base
13
-
14
- def initialize identifier, name, *args
15
- super identifier, name, 'server/classic', *args
16
- end
17
-
18
- #
19
- #
20
- def generate
21
- exclaim "Setting up Picky Classic Server \"#{name}\"."
22
- create_target_directory
23
- copy_all_files
24
- copy_all_files expand_prototype_path('server/shared')
25
- exclaim "\"#{name}\" is a great project name! Have fun :)\n"
26
- exclaim ""
27
- exclaim "Next steps:"
28
- exclaim "1. cd #{name}"
29
- exclaim "2. bundle install"
30
- exclaim "3. rake index"
31
- exclaim "4. rake start"
32
- exclaim "5. rake todo # (optional) shows you where Picky needs input from you"
33
- exclaim " # if you want to define your own search."
34
- end
35
-
36
- end
37
-
38
- end
39
-
40
- end
41
-
42
- end
@@ -1,27 +0,0 @@
1
- source :gemcutter
2
-
3
- # Gems required by Picky.
4
- #
5
- gem 'picky', '~> 4.0.0pre1'
6
- gem 'rake'
7
- gem 'rack'
8
- gem 'rack-mount'
9
- gem 'rack_fast_escape', '2009.06.24' # Optional.
10
- gem 'text'
11
- gem 'yajl-ruby', :require => 'yajl'
12
-
13
- # Should be optional, but isn't yet.
14
- #
15
- gem 'activesupport', '~> 3.0', :require => 'active_support/core_ext'
16
- gem 'activerecord', '~> 3.0', :require => 'active_record'
17
-
18
- # Required by your project.
19
- #
20
- gem 'unicorn'
21
- gem 'mysql' # Project specific.
22
- gem 'redis' # Project specific.
23
-
24
- group :test do
25
- gem 'picky-client', '~> 4.0.0pre1'
26
- gem 'rspec'
27
- end
@@ -1,4 +0,0 @@
1
- All your application definitions go here.
2
-
3
- /app needs a the file defined by picky:
4
- * application.rb - how to handle indexing, queries, routing.
@@ -1,47 +0,0 @@
1
- # encoding: utf-8
2
- #
3
- require File.expand_path '../logging', __FILE__
4
-
5
- # TODO Adapt the generated example
6
- # (a library books finder) to what you need.
7
- #
8
- # Questions? Mail me, IRC #picky, the google group, http://github.com/floere/picky/wiki.
9
- #
10
- class BookSearch < Picky::Application
11
-
12
- # So we don't have to write Picky::
13
- # in front of everything.
14
- #
15
- include Picky
16
-
17
- # How text is indexed. Move to Index block to make it index specific.
18
- #
19
- indexing removes_characters: /[^a-z0-9\s\/\-\_\:\"\&\.]/i,
20
- stopwords: /\b(and|the|of|it|in|for)\b/i,
21
- splits_text_on: /[\s\/\-\_\:\"\&\/]/
22
-
23
- # How query text is preprocessed. Move to Search block to make it search specific.
24
- #
25
- searching substitutes_characters_with: CharacterSubstituters::WestEuropean.new, # Normalizes special user input, Ä -> Ae, ñ -> n etc.
26
- removes_characters: /[^a-z0-9\s\/\-\_\&\.\"\~\*\:\,]/i, # Picky needs control chars *"~:, to pass through.
27
- stopwords: /\b(and|the|of|it|in|for)\b/i,
28
- splits_text_on: /[\s\/\-\&]+/,
29
- max_words: 5 # Amount of words maximally used in a search.
30
-
31
- books_index = Index.new :books do
32
- source Sources::CSV.new(:title, :author, :year, file: "data/#{PICKY_ENVIRONMENT}/library.csv")
33
- category :title,
34
- similarity: Similarity::DoubleMetaphone.new(3), # Default is no similarity.
35
- partial: Partial::Substring.new(from: 1) # Default is from: -3.
36
- category :author, partial: Partial::Substring.new(from: 1)
37
- category :year, partial: Partial::None.new
38
- end
39
-
40
- books = Search.new books_index do
41
- boost [:title, :author] => +3,
42
- [:title] => +1
43
- end
44
-
45
- route %r{\A/books\Z} => books
46
-
47
- end
@@ -1,13 +0,0 @@
1
- # Just an example, see application.rb on how this file is used.
2
- #
3
- # Note: ActiveRecord is used. Sorry.
4
- #
5
- # TODO Configure the database adapter
6
- # or ignore and use a csv source.
7
- #
8
- adapter: mysql
9
- host: localhost
10
- username: root
11
- password:
12
- database: your_database # Load this configuration and use a DB source in app/application.rb.
13
- encoding: utf8
@@ -1,23 +0,0 @@
1
- # Separate file since this is usually what is
2
- # environment specific.
3
- #
4
-
5
- # Standard logging.
6
- #
7
- require 'logger'
8
- Picky.logger = Logger.new File.expand_path('log/search.log', PICKY_ROOT)
9
-
10
- # Example with using the syslog logger.
11
- # Falling back to the standard log if it isn't available.
12
- # (For example, because it is used locally and syslog is
13
- # only available on the servers)
14
- #
15
- # begin
16
- # log_program_name = 'search/query'
17
- # Picky.logger = SyslogLogger.new log_program_name
18
- # puts "Logging on syslog #{log_program_name}."
19
- # rescue StandardError
20
- # puts "Could not connect to the syslog, using the normal log."
21
- # require 'logger'
22
- # Picky.logger = Logger.new(File.join(PICKY_ROOT, 'log/search.log'))
23
- # end
@@ -1,31 +0,0 @@
1
- # Require the gem. This loads the search framework.
2
- #
3
- require 'picky'
4
-
5
- # Load your application. This requires the following files in
6
- #
7
- # * app/application.rb
8
- #
9
- # (in that order).
10
- #
11
- Picky::Loader.load_application
12
-
13
- # Load the indexes into the memory.
14
- #
15
- Picky::Indexes.load
16
-
17
- # TODO Decide if you want to use the Unicorn killing trick. (Good with large data sets)
18
- #
19
- # Use Harakiri middleware to kill worker child after X requests.
20
- #
21
- # Works only with web servers that fork worker children and which
22
- # fork new children, like for example Unicorn.
23
- #
24
- # Rack::Harakiri.after = 50
25
- # use Rack::Harakiri
26
-
27
- # Start accepting requests.
28
- #
29
- # Note: Needs to be the same constant name as in app/application.rb.
30
- #
31
- run BookSearch
@@ -1 +0,0 @@
1
- Logs go here by default.
@@ -1,5 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: utf-8
3
- #
4
- require 'picky/console'
5
- Picky::Console.start
@@ -1,8 +0,0 @@
1
- ENV['PICKY_ENV'] = 'test'
2
-
3
- require 'picky'
4
-
5
- Picky.logger = Logger.new STDOUT
6
- puts "Using STDOUT as test log."
7
-
8
- Picky::Loader.load_application