acts_as_cleo 2.1.2 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,47 +1,42 @@
1
1
  = acts_as_cleo
2
2
 
3
- === To enable
4
-
5
- Create a cleo.yml in your config directory.
3
+ Acts As Cleo now has support for Redis backed asynchronous operations.
6
4
 
7
- development:
8
- url: "http://localhost:8080/cleo-primer/"
9
5
 
10
- production:
11
- url: "http://localhost:8080/cleo-primer/"
12
6
 
7
+ Optional parameters are:
8
+ queue: "my_queue_to_process"
13
9
 
14
- Acts As Cleo now has support for Redis backed asynchronous operations.
10
+ queue defaults to "cleo"
15
11
 
16
- To enable this, change your cleo.yml to include
12
+ To enable Redis, change your cleo.yml to include
17
13
  async: true
18
14
 
19
15
  async defaults to false
20
16
 
21
- Optional parameters are:
22
- queue: "my_queue_to_process"
17
+ To disable auto flushing of indexer queue
18
+ auto_flush: false
23
19
 
24
- queue defaults to "cleo"
20
+ By default, auto indexer flushing is enabled
25
21
 
26
22
  === Usage
27
23
 
28
-
29
24
  Cleo.find(int) # Find Cleo entry by Cleo native id
30
25
  Cleo.update(Cleo::Result) # Pass any acts_as_cleo object to this method to have it update the Cleo entry
31
26
  Cleo.delete(int) # Delete by Cleo id, also accepts any acts_as_cleo object or Cleo::Result
32
27
  Cleo.create(obj) # Creates new entry on Cleo index. Accepts any acts_as_cleo object or Cleo::Result
33
- Cleo.query(string) # Takes string search param and returns array of Cleo::Reference objects
28
+ Cleo.query(string) # Takes string search param and returns array of Cleo::Result objects
34
29
 
35
30
  To enable on an ActiveRecord::Base model:
36
31
 
37
- acts_as_cleo
32
+ class MyObject < ActiveRecord::Base
33
+ acts_as_cleo
34
+ end
38
35
 
36
+ Or add optional parameters
39
37
  acts_as_cleo :terms => %w{terms to be stored}
40
-
41
38
  acts_as_cleo :except => %w{columns to be ignored}
42
-
43
39
  acts_as_cleo :score=> "method or column to be used"
44
-
45
40
  acts_as_cleo :terms => %w{name value other}, :score => "my_score_method"
46
41
 
47
42
  Default functionality takes all column_names and uses them as terms for Cleo search.
@@ -85,7 +80,7 @@ This generate command will install the following files:
85
80
  * config/initalizers/cleo_initalizer.rb
86
81
 
87
82
  === Database migration
88
- * db/migrate/#{timestamp or sequence number}_install_acts_as_audited.rb
83
+ * db/migrate/#{timestamp or sequence number}_install_acts_as_cleo.rb
89
84
 
90
85
 
91
86
  Verify server settings in config/cleo.yml
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.1.2
1
+ 2.2.0
data/acts_as_cleo.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "acts_as_cleo"
8
- s.version = "2.1.2"
8
+ s.version = "2.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Robert R. Meyer"]
12
- s.date = "2012-03-23"
12
+ s.date = "2012-03-26"
13
13
  s.description = "LinkedIn Open Source type ahead tool's REST API as a ruby gem. Now with Reddis support."
14
14
  s.email = "Blue.Dog.Archolite@gmail.com"
15
15
  s.extra_rdoc_files = [
data/lib/cleo.rb CHANGED
@@ -78,9 +78,16 @@ module Cleo
78
78
  end
79
79
 
80
80
  private
81
+ def self.flush
82
+ uri = URI.parse Cleo::Server.url + "flush"
83
+ request = Net::HTTP::Post.new(uri.path)
84
+ Net::HTTP.new(uri.host, uri.port).start { |http| http.request request }
85
+ end
86
+
81
87
  def self.good_response_code?(response)
82
88
  case response
83
89
  when Net::HTTPOK
90
+ flush if Cleo::Server.auto_flush?
84
91
  true # success response
85
92
  when Net::HTTPClientError, Net::HTTPInternalServerError
86
93
  false # non-success response
data/lib/cleo/server.rb CHANGED
@@ -8,7 +8,15 @@ module Cleo
8
8
  parts += %w{rest elements}
9
9
  @@configuration[:url] = parts.join('/') + '/'
10
10
 
11
- @@configuration[:run_async] = new_config.has_key?(:run_async) ? new_config[:run_async] : false
11
+ if new_config.has_key?(:async)
12
+ @@configuration[:async] = new_config[:async]
13
+ elsif new_config.has_key?(:run_async)
14
+ @@configuration[:async] = new_config[:run_async]
15
+ else
16
+ @@configuration[:async] = false
17
+ end
18
+
19
+ @@configuration[:auto_flush] = new_config.has_key?(:auto_flush) ? new_config[:auto_flush] : true
12
20
  @@configuration[:queue] = new_config.has_key?(:queue) ? new_config[:queue] : "cleo"
13
21
 
14
22
  env = ENV['QUEUE'] || ''
@@ -28,8 +36,12 @@ module Cleo
28
36
  @@configuration[:url]
29
37
  end
30
38
 
39
+ def self.auto_flush?
40
+ @@configuration[:auto_flush]
41
+ end
42
+
31
43
  def self.async?
32
- @@configuration[:run_async]
44
+ @@configuration[:async]
33
45
  end
34
46
 
35
47
  def self.queue
@@ -21,7 +21,7 @@ module ActsAsCleo
21
21
  end
22
22
 
23
23
  #create migration
24
- migration_template 'install.rb', 'db/migrate/install_acts_as_audited.rb'
24
+ migration_template 'install.rb', 'db/migrate/install_acts_as_cleo.rb'
25
25
  end
26
26
 
27
27
  def self.next_migration_number(dirname)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_cleo
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 2.2.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-03-23 00:00:00.000000000Z
12
+ date: 2012-03-26 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: happymapper
16
- requirement: &70094839813820 !ruby/object:Gem::Requirement
16
+ requirement: &70187991206160 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70094839813820
24
+ version_requirements: *70187991206160
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rails
27
- requirement: &70094839813340 !ruby/object:Gem::Requirement
27
+ requirement: &70187991205680 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 3.1.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70094839813340
35
+ version_requirements: *70187991205680
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: resque
38
- requirement: &70094839812860 !ruby/object:Gem::Requirement
38
+ requirement: &70187991205200 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70094839812860
46
+ version_requirements: *70187991205200
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: shoulda
49
- requirement: &70094839812380 !ruby/object:Gem::Requirement
49
+ requirement: &70187991204720 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70094839812380
57
+ version_requirements: *70187991204720
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rdoc
60
- requirement: &70094839811900 !ruby/object:Gem::Requirement
60
+ requirement: &70187991204240 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ~>
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '3.12'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70094839811900
68
+ version_requirements: *70187991204240
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: bundler
71
- requirement: &70094839811420 !ruby/object:Gem::Requirement
71
+ requirement: &70187991203760 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 1.0.0
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70094839811420
79
+ version_requirements: *70187991203760
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: jeweler
82
- requirement: &70094839810940 !ruby/object:Gem::Requirement
82
+ requirement: &70187991203280 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 1.8.3
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70094839810940
90
+ version_requirements: *70187991203280
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: simplecov
93
- requirement: &70094839810460 !ruby/object:Gem::Requirement
93
+ requirement: &70187991202800 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70094839810460
101
+ version_requirements: *70187991202800
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: ruby-debug19
104
- requirement: &70094839809980 !ruby/object:Gem::Requirement
104
+ requirement: &70187991202320 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *70094839809980
112
+ version_requirements: *70187991202320
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: fixtures
115
- requirement: &70094839809500 !ruby/object:Gem::Requirement
115
+ requirement: &70187991201840 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: '0'
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *70094839809500
123
+ version_requirements: *70187991201840
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: sqlite3
126
- requirement: &70094839809020 !ruby/object:Gem::Requirement
126
+ requirement: &70187991201360 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ! '>='
@@ -131,7 +131,7 @@ dependencies:
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
- version_requirements: *70094839809020
134
+ version_requirements: *70187991201360
135
135
  description: LinkedIn Open Source type ahead tool's REST API as a ruby gem. Now with
136
136
  Reddis support.
137
137
  email: Blue.Dog.Archolite@gmail.com