acts_as_cleo 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -1,6 +1,20 @@
1
1
  = acts_as_cleo
2
2
 
3
- Acts As Cleo is a Rails gem that allows for easy integration with Linked In's Open Source type ahead manager.
3
+
4
+ = WARNING
5
+
6
+ This gem is still in beta. The main Cleo functionality works but the hooks into active record objects are not done yet.
7
+
8
+ * Cleo.find
9
+ * Cleo.update
10
+ * Cleo.delete
11
+ * Cleo.create
12
+
13
+ As of this moment you need to pass a constructed Cleo::Result object to the above methods for them to function correctly.
14
+
15
+ Feel free to use this gem and provide feedback / patch requests.
16
+
17
+ Acts As Cleo is a Rails gem that allows for easy integration with Linked In's Open Source type ahead manager.
4
18
 
5
19
  Verify that you have downloaded and installed cleo locally.
6
20
 
@@ -15,7 +29,7 @@ Verify that you have downloaded and installed cleo locally.
15
29
  * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
16
30
 
17
31
  == To test
18
- * rake start:cleo
32
+ * verify that cleo is running locally.
19
33
  * rake
20
34
 
21
35
  == Copyright
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
data/acts_as_cleo.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "acts_as_cleo"
8
- s.version = "0.0.2"
8
+ s.version = "0.0.3"
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"]
@@ -34,6 +34,8 @@ Gem::Specification.new do |s|
34
34
  "lib/cleo/result.rb",
35
35
  "lib/cleo/server.rb",
36
36
  "lib/common_methods.rb",
37
+ "lib/generators/acts_as_cleo/install_generator.rb",
38
+ "lib/generators/acts_as_cleo/templates/install.rb",
37
39
  "lib/instance_methods.rb",
38
40
  "test/config/cleo.yml",
39
41
  "test/data/xml/cleo/element.xml",
@@ -46,6 +48,7 @@ Gem::Specification.new do |s|
46
48
  "test/db/migrate/004_create_electronics.rb",
47
49
  "test/db/migrate/005_create_authors.rb",
48
50
  "test/db/migrate/006_create_postings.rb",
51
+ "test/db/migrate/007_cleo_table.rb",
49
52
  "test/db/test.db",
50
53
  "test/fixtures/authors.yml",
51
54
  "test/fixtures/books.yml",
@@ -59,8 +62,12 @@ Gem::Specification.new do |s|
59
62
  "test/models/electronic.rb",
60
63
  "test/models/movie.rb",
61
64
  "test/test_acts_as_cleo.rb",
65
+ "test/test_install_generator.rb",
62
66
  "test/unit/test_acts_methods.rb",
63
67
  "test/unit/test_cleo.rb",
68
+ "test/unit/test_common_methods.rb",
69
+ "test/unit/test_instance_methods.rb",
70
+ "test/unit/test_model_to_cleo.rb",
64
71
  "test/unit/test_result_parser.rb"
65
72
  ]
66
73
  s.homepage = "http://github.com/blue-dog-archolite/acts_as_cleo"
data/lib/acts_methods.rb CHANGED
@@ -2,8 +2,10 @@ module ActsAsCleo
2
2
  module ActsMethods
3
3
  def acts_as_cleo(opts = {})
4
4
  extend ClassMethods
5
+ extend CommonMethods
6
+
7
+ #Instance Methods Correctly Included
5
8
  include InstanceMethods
6
- include CommonMethods
7
9
 
8
10
  before_create :set_cleo_id
9
11
  after_commit :sync_with_cleo
data/lib/cleo.rb CHANGED
@@ -46,6 +46,149 @@ module Cleo
46
46
  def self.delete(obj)
47
47
  obj = obj.to_cleo_result unless obj.is_a?(Cleo::Result)
48
48
 
49
+ =begin
50
+
51
+
52
+
53
+
54
+
55
+
56
+ ```````````````` ` ;
57
+ `:+#@@@@@@@@@@@@@@@@#@##@
58
+ ,:#@@@+';,.`````````````.@@@@#`
59
+ `+@@#.` .+` +''@@#@. ;;;;;; ,::;;:.`;;;;;: :;;;:: ,;;:;;. ;;;:;: ::;;:;
60
+ '@@:` .@@. ,@'@#` +@+` '';''' :'''''..';'''; '''';'`:'''''. ';'''; ;'''''
61
+ :##@@@@@' #@,;@+@'@; '@# '` :' .'` '; :' '. ;;
62
+ .#@@@@@@@@@@@@@@+#####: @@ @@@#@, .@# '. :' .'` '; :' '. ':
63
+ `;@@@####;,,,,,,,'######@@+'`` @#`@@@@#` @# '''''. :''''; .''''' '''''. :''''; ''''' ;'''':
64
+ @#@@; `;;@@@@+@`+@@@, .; #@. '.`` :'``` .'``` ';` ` :'`` ` '.`` ;:` `
65
+ .#@##` `;+@@@@+@'#@@@` '@ '` :' .'` '; :' '. ;;
66
+ `'@@@+` .@,@@@@+@@.` #@ '` :' .'` '; :' '` ;;
67
+ @@@@, `: #@'@@@@#:, @` '` :' .'` '; :' '` ;:
68
+ `:@@@+, ,` '@`@:@@@@; ;# ` `` ` ` ` ` `
69
+ ;@@@@' .@. @':@;@@@# @;
70
+ +@@@@# ` ,@. ,@.#@@@@@. +@:
71
+ :@;+@@: +, #@. +#:@@:@@@ #@#
72
+ `@:,@@' `, :` @@+,@:#@@#@@@ .@@+
73
+ `@''@@' @+ @@@#@'@@@#;#@ ;@@: ;;;;;; ,;;;;;.`;;;;;: :;;;;; ,;;;;;` ;;;;;, :;;;;:
74
+ #';@@: ,#+ `@@@@@@@@@@.@# ;@@, ':,,,, :',::,`.':,,,, ';,,:, :',,,,` ':,,,. ;',,,,
75
+ .#`#@# ,` `. `;# ,@@@@@@@@@:'@, ` #@# '` :' .'` ;; :' '` ':
76
+ ,#@' `+:;#': ++@@@@@@@# #@ +#@#####;` .@@, ',.,,` :',,,. .',,,. ';,,,` :',,,. `',,,, ;;,.,`
77
+ ;+++@@' .@@+#. `@+@+@@@@@: @# @@.....,@@` ;@` '''''. :''''; .''''' '''''. :''''; ''''' ;'''':
78
+ +@@@@@` `;#:, ,@+@#@@@@@.`@+ `++` `'@` ## '.``` :'```` .'.``` ';``` :'```` '.``` ;;```
79
+ ;:::;::#@@;` :#; '@@@@@@@@@,;@` #@: @@. ,@@ '` :' .'` '; :' '. ;;
80
+ ,@@@@@@@@@@@@##, ,@; @@@@@@@@@@,;' +@` ,#@@@@@ #@: '` :' .'` '; :' '` ';
81
+ ,@@@,,@@@@@@#++; '+ `@@@@@#@@@@ +@` +:. `+@@ :@@: ;` ,; `;` ;: ,; ;` ;:
82
+ @@@, ,#@@@@@@@@+: `@@@@@+@@@@ @, #. '@# @@@,
83
+ @@@' ;@@@@@@@@#; . `@:@@'#@@@# ++ #. @@; ;@@+
84
+ .@@@' .+@@@@@@@@. ',@@'@@,#+ '@ #. @@+ @@@@:
85
+ #@@' `+@@','@#` + `@@'@@ #+ ,@: #. ,@#; +@;+@`
86
+ .#@@; ;@@@@@@: ,` `@@+@@ #' .@: #. `@+@, `@@ ,@`
87
+ :;#@@, .@@@+', `+ @@;#@ #: #. #+'@` ;@. +@ '''''; ,'''''..;''''; '';'''`:'''''. ';'''; ;'''''
88
+ @:@@: ,### : #. @@##+ .@ +' '+ +; `@' `@. ':,,,, :',,,,`.':,,,, ';,,,, :',,,,` ':,,,, ;;,,,,
89
+ :@#@, ,@#' # : `# :@@@, `@' :@,`````;@. `@' '@ +' '` :' .'` '; :' '. ;;
90
+ #@@' `@@@' #, : +, @@@, ,@ #@@@@@@@: ;@` ,@, `; ',... :'...` .'.`.. ';...` :'...` ',.`. ';...`
91
+ @@@ `#@@, ;+ #. ;' :@@. ,# ``````. #+ `@+ '''''. :''''; .''''' '''''. :'''': ''''' ;'''':
92
+ :@': `......` @@@, ; .# .@` `@@ ,# @` ,@ '` :' .'` '; :'` '. ;;
93
+ @@@ `'#@@@@@@@@; :@@@` . @ #` `@@ ,# :+ @; '` :' .'` '; :' '. ';
94
+ +@@+ `+@#:` `+@`+@@@ ` .' `@@ ,# @. `@'.`'. :' .'` '; :' '. ';
95
+ @:@+ ;@@. ;@'@@@, #. +@ ,# '# #@+ ;` ,; `;` ;: :; ;` ;:
96
+ . @; ##: +@'@@@ .@ :@ ,# ,@. +@@+
97
+ ;@` +#` #:;@@#` #. .@, @: ##@'
98
+ @@` +#` ;' `@@#, ,` @' ;' '@;@ .,,,,,` ,,,,,. .,.,,, .,,,,` .,,,,,
99
+ `@@ .@@###. '# '@@# ;@` ;' ##+' :';;;;. ';;;;: ;';;;; .';;;;. ';;;;;
100
+ ;@' +@:,,@@@ `@' ,#` #: ;' +@.@` :' '. ;; `' '.
101
+ +@; .@ `@, .@@+``@: .@` ;' `@'## :'` '. ;; `' '.
102
+ +` @@ `@: :# `+' @ ,@, ;; #@`@: :''''; '''''` ;'''': `''''' '''''.
103
+ @` @@ ,@ @; #, #@ #; ;@ '# :'...` ',... ;;...` `'.... ',...`
104
+ @. '@: ,@ :@ #. ++ '# @+ #: :' '. ;; `' '.
105
+ @..@@ ,@ :@ #. @+ @# '@ :+ :' '. ;; `' '.
106
+ @`#@' ,@ :@ `@` #:` `'#` `@,,@ :'` '. ;; `' '.
107
+ @,@@` ,@ +@ +' #@#` '@+ ##`@.
108
+ @#@@ ,@ :@: @` ``;;;;;;;;;;.` .#@' '@+ .@'@,
109
+ @@+@ ,@; .+@. #@ `'#@@''''''@''@@@#: .@#'``.;+++++++++##+` '#@+
110
+ @#'@ ,@#++++@@: `@, #@; .@+,` '@@; ,@@@@@@+'+'+++++;. @@+
111
+ @,#' ,@'+###: #; ,@#. `@` ,@'` ,+:., ';.```........` @@+
112
+ @.@` ,@ '+ @@@. `@ #@#` .:: ``````` ``` '@@+ :'''';. '';''; ;''''; `''''', ;'';';
113
+ @+# ,@ #@. `+@#@' `@ @@@#` .:#+, '#@+ :';;;;. ';;;;: ;';;;;``';;;;. ';;;;;
114
+ @@' `@: .@. `@@#`,#; `@ ;@`:'@+, . .@@# :'` '. ;; `' '.
115
+ @@: @: #: `@@; `@: `@# .@; .'@@' '@@ :'```` ',``` ;;``` `'```` '.```
116
+ @@` '+ '@ `@@: +# `@## `@: `;@, `:; : ,@@` :''''; ''''' ;'''': `''''' ''''',
117
+ @. @. '# +@, #@#; `@ '@@::@+ @@@''@@'` ;# @@; :'` ` '.``` ;;``` `'```` '.```
118
+ @. ,@ #@. ,@# `+@@@+ `@ `+@@+ ,+ ;@@' .#. :@# :' '. ;; `' '.
119
+ @. .; '# '@. ,@+ @',;#'` `@ ,+' `;' #@` :' '. ;; `' '.
120
+ @` ;# #; ;@, @'+ '# :@+,`@ @#` `@ .@+ :' '. ;; `' '.
121
+ @` #. ,@+ .#@, @.+ ,@` `@@#@ `@+ ` @#
122
+ @, #. #@. ;@; `@`+ @. `#@` `@, @@`
123
+ @@@#. # '@@;;;;;;;;#@, :@.+ @. ;@. +@.
124
+ @@@#. ,'` .'+++++++++. ''+#;` @. ## ;@.
125
+ @@@#. ;:` ## ,@@+ .@. `@: ;@,
126
+ @@@#. '.. `@: .@@@@@@@@@@@` :# @@' ,;;;;;. ;;;;;: :;;;;;``;;;;;. ;;;;;;
127
+ @@@#. ` '+: ,@. ,@;```````` ;# @@# :'....` ':.... ;;.... `'....` ',....
128
+ @@@#. `#,` ,@ ,@` .@+ @@# :' '. ;; `' '.
129
+ @@@#. ,,,, ` ,@ ;@ ,#` @# :'.... ',... ;;...` `'.... ',...`
130
+ @@@#. # ,@ `;;'@` `` '# @@ :';''; ''''' ;'''': `''''' '''''.
131
+ @@##: ., ,@ `#@#@@+ ,@@, `@ @@ :'` '. ;; `'` '. `
132
+ @@@,# : ,@#@. .+@, @@. #+ @@ :' '. ;; `' '.
133
+ @@@,# , ,@+ `'@#, +@ :@` '# :' '. ;; `' '.
134
+ @@@,+ ,@ ,##, #: @. ;@ :'` '. ;: `' ;.
135
+ @@@ @ ,@ ,@: +: #. ;@
136
+ @@@`@ ,@ .++. `#@. +; #. ;@
137
+ ,@@:@` ,@ `##:,@+'+@:. '; ,@@@#; #. `@.
138
+ `@@+@, ,@ .@@ ;@@, @. '+ :@@, @. `@.
139
+ #@@@; : :@ ,#' @ #. `'@, @. `@. ` ` `` ` ` `` ` `
140
+ #@@@@ ; +# ##. @. #. `@, @` `@. .' ', ;; ,'`.', ;' ,' '.
141
+ #@@@@ `; +# `@. :@`'@@# @. :@.:@` `@. .' '. ;; ,' `', ;' ,' '.
142
+ '@@@@, ' `; ## ;@` `'@#;.@@`'# #. ;@;@ `@. .' '. :; ,'``', ;' ,' '.
143
+ `@@@'' , `; `@, `@' ,@@: ## @##. +@@ `@. .' '. ;; ,' `', ;' ,' '.
144
+ ;@@,@ , `; :@ ++ ,'` ``'@#: `@` @@. #' `@. .' ', ;: ,' `', ;' ,' `'.
145
+ `@@,@: : ; '# #. .##@@@@@@@@@. :@` ,'+ `@` `@. .; '` :; ,' `', ;' .' '.
146
+ #@'## ` '; #. `@ ```,@@+'## .@+ .@: @+ `@. `'` .'` ,' ;' ': `'; `'` .'`
147
+ ;@@.@. ' :# .#: ;@, `@ :@: `;@:.. `'# `@. :'::'; `';::', .'::;'` :'::':
148
+ .@@.@' # +; +# @; @.#; ````.@#.;;+`.+@. `@. ,;;,` `,;;` .;;:` ,;;,
149
+ @@;@@ , # `@, @: .@; ;@@ `:#@@@@@@@@@@@@@@. `@.
150
+ @@@@@. .., '@` `@` @+ `;;@@'.` `@.#.
151
+ `@@@@; ;.` @; .# @` ;@#'. `@#@,
152
+ `@@@#+ ; + ,#` '' '+ `'#. `@@+
153
+ `@@@## @ + +; #. :@` '@@ `@@` `` . `` `. .` `. . `
154
+ @@@@@ @ ' .@` #. .+@@@@: @+ :#@: ;@# .' ', ;; ,' `', ;' ,' '.
155
+ ''+@@` `: : #@ #..@'. .@ :@` `+@#. ;@' .' '. ;; ,' `', ;' ,' '.
156
+ `@.@@` `: `@, +:@, `@+@: @@: `@@: .' '. :; ,' `', ;' ,' '.
157
+ @+#@, +. '+` .@: `@' :#: ::';###;` .,#@# .' ', :; ,' .', ;' ,' '.
158
+ ,@+@@` + @` +' ` ,@@' `@. ``` ##@@' .; ', :; ,' .', ;' ,' '.
159
+ #@@@. @ .@` @. @@# .# @+@@:. .' '` ,; ,' `', ;' .' '.
160
+ `@@@# @ .# +# :#+ '` :@` :##@@@. `', ,'` ,'. ;; ;; `': `',` .'`
161
+ #@@@, @ .# @@, :@; @+ ':`. `, ';#@@# :''''; .'';''. ,'''''` :'''',
162
+ `@@@@` `; .# `#@:.#+ #; :@, +. :+. @'@@@. `..` `...` `..`` `..`
163
+ @@@@@ '` .# `@+ .@#` '+ '@, ': # ;@,@@;
164
+ @@#@@: .#` ;@: `@@; '@. +@, @ `, #@@@@.
165
+ `::@:+@+ :@##` +@@, `+@ ,# ,+ @@#@'
166
+ ` .@#.@@: ;@+, `@# .;@#` + '` , @#@+
167
+ #+,@@,;@@. ,'@;,. ;'.:'','+#+` `: ,, `@;#` `. .` .` `. `.` .` `. `.`
168
+ :@@@@@@'@@: +@@#::+#` ``'@# + ` ,@@' .' '. '; :'``'` ;, ,' `'.
169
+ ;#@@@@@@# ,+@@@: `;@@, + #@@; .' '. '; :'``'` ;, ,' `'`
170
+ +@@+@@@@+` .:+@@@@@@+. ; :@@@ .' '. '; :'`.'` ;, ,' `'.
171
+ @@``.#@@@` `````` . @@## .' '. '; :'``'` ;, ,' `'`
172
+ +@' ,@@@:` ,@@ .' '. '; :'``'` ;, ,' `'`.:::
173
+ ;@@ `@@@@+ #@@ .' '` '; :' `'` ;, .' `'.,;;;`
174
+ `@@. '@@@@; `@@' `', .' ;'` ;; ': .'` `', ,'`
175
+ #@; ;@@@@; #@@ :''''. ;''';` `'''': :''''.
176
+ +@+ .@@@@#` .@@@ `.`` `.` ``.` `.`
177
+ :@+ .#@@#. @@@'
178
+ `@@, :#@@#` ;@@#
179
+ ` :@@@#` .+@@.
180
+ .@@+` ;#@@#`
181
+ '@@. `'@@##+`
182
+ ;@@, .;#@@#,
183
+ `+@@, `````...:'#@@@@@@@#`
184
+ #@@@+,` .,'##@@@@@@@@@@@@#;,`
185
+ ,;+@@@@';:. ,'+@@@@@#+;;;;;;;;;;`
186
+ .:+@@@@@', ``,#@@@@;`
187
+ `;##@@@##+++++#@@@@@##+;
188
+ ,#@@@#@@@#+;,`
189
+
190
+ =end
191
+
49
192
  result = `curl -v -X DELETE #{Cleo::Server.url}#{obj.id}`
50
193
 
51
194
  #TODO I HATE THIS. Make this use Rails and not a fracking curl call
@@ -3,15 +3,5 @@ module ActsAsCleo
3
3
  def query(query, opts = {})
4
4
  Cleo.query(query)
5
5
  end
6
-
7
- def cleo_id
8
- record_type = self.cleo_config[:type]
9
- cr = Cleo::Reference.find_by_reference_and_id(record_type, self.id)
10
- return cr.nil? ? nil : cr.id
11
- end
12
-
13
- def cleo_id=( new_id)
14
- #this needs to be rerolled to pull an Cleo::Reference record and persist it.
15
- end
16
6
  end
17
7
  end
@@ -0,0 +1,28 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/migration'
3
+ require 'active_record'
4
+ require 'rails/generators/active_record'
5
+
6
+ module ActsAsCleo
7
+ module Generators
8
+ class InstallGenerator < Rails::Generators::Base
9
+ include Rails::Generators::Migration
10
+
11
+ source_root File.expand_path("../templates", __FILE__)
12
+
13
+ # Implement the required interface for Rails::Generators::Migration.
14
+ def self.next_migration_number(dirname) #:nodoc:
15
+ next_migration_number = current_migration_number(dirname) + 1
16
+ if ActiveRecord::Base.timestamped_migrations
17
+ [Time.now.utc.strftime("%Y%m%d%H%M%S"), "%.14d" % next_migration_number].max
18
+ else
19
+ "%.3d" % next_migration_number
20
+ end
21
+ end
22
+
23
+ def copy_migration
24
+ migration_template 'install.rb', 'db/migrate/install_acts_as_audited.rb'
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,14 @@
1
+ class <%= migration_class_name %> < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :cleo_references do
4
+ t.timestamps
5
+ t.string :record_type
6
+ t.integer :cleo_id
7
+ t.integer :record_id
8
+ end
9
+ end
10
+
11
+ def down
12
+ drop_table :cleo_references
13
+ end
14
+ end
@@ -19,6 +19,16 @@ module ActsAsCleo
19
19
  end
20
20
  #end callback hooks
21
21
 
22
+ def cleo_id
23
+ record_type = self.cleo_config[:type]
24
+ # cr = Cleo::Reference.find_by_reference_and_id(record_type, self.id)
25
+ # return cr.nil? ? nil : cr.id
26
+ end
27
+
28
+ def cleo_id=( new_id)
29
+ #this needs to be rerolled to pull an Cleo::Reference record and persist it.
30
+ end#
31
+
22
32
  def to_cleo_result
23
33
  #take self and change it into a Cleo::Result and return
24
34
  cr = Cleo::Result.new
@@ -35,7 +45,14 @@ module ActsAsCleo
35
45
  cr.name = cr.term.first if cr.name.blank?
36
46
 
37
47
  score = self.send(self.cleo_config[:score])
38
- cr.score = score.nil? ? 0 : score.count
48
+
49
+ if score.nil?
50
+ cr.score = 0
51
+ elsif score.respond_to?("count")
52
+ cr.score = score.count
53
+ else
54
+ cr.score = score
55
+ end
39
56
 
40
57
  cr
41
58
  end
@@ -0,0 +1,14 @@
1
+ class CleoTable < ActiveRecord::Migration
2
+ def up
3
+ create_table :cleo_references , :force => true do |t|
4
+ t.timestamps
5
+ t.string :record_type
6
+ t.integer :cleo_id
7
+ t.integer :record_id
8
+ end
9
+ end
10
+
11
+ def self.down
12
+ drop_table :cleo_references
13
+ end
14
+ end
data/test/db/test.db CHANGED
Binary file
data/test/models/book.rb CHANGED
@@ -10,6 +10,6 @@ class Book < ActiveRecord::Base
10
10
  acts_as_cleo :terms => %w{name author}, :score => "cleo_score", :name => "name"
11
11
 
12
12
  def cleo_score
13
- Random.rand(10...47)
13
+ 1000
14
14
  end
15
15
  end
@@ -0,0 +1,18 @@
1
+ require 'helper'
2
+ require 'generators/acts_as_cleo/install_generator'
3
+
4
+ class InstallGeneratorTest < Rails::Generators::TestCase
5
+ destination File.expand_path('../../tmp', __FILE__)
6
+ setup :prepare_destination
7
+ tests ActsAsCleo::Generators::InstallGenerator
8
+
9
+ should "generate a migration" do
10
+ run_generator %w(install)
11
+
12
+ Dir['/tmp/db/migrate/*.rb'].each do |m|
13
+ assert_migration m do |content|
14
+ assert_match /class InstallActsAsCleo/, content
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,7 @@
1
+ require 'helper'
2
+
3
+ class TestCommonMethods < Test::Unit::TestCase
4
+ should "respond to query call" do
5
+ assert Book.respond_to?("query")
6
+ end
7
+ end
@@ -0,0 +1,12 @@
1
+ require 'helper'
2
+
3
+ class TestInstanceMethods < Test::Unit::TestCase
4
+ def setup
5
+ @b = Book.new
6
+ end
7
+ %w{cleo_id cleo_id= sync_with_cleo set_cleo_id remove_from_cleo to_cleo_result as_cleo}.each do |resp|
8
+ should "respond to cleo_id and cleo_id=" do
9
+ assert @b.respond_to?(resp), "ActiveRecord Model with acts_as_cleo should respond to #{resp}"
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,18 @@
1
+ require 'helper'
2
+
3
+ class TestModelToCleo < Test::Unit::TestCase
4
+ should "convert from model to cleo result" do
5
+ b = Book.new(:name => "Suncrusher", :author => "Tad Williams")
6
+ assert b.respond_to?("as_cleo")
7
+ assert b.respond_to?("to_cleo_result")
8
+
9
+ cb = nil
10
+ assert_nothing_raised do
11
+ cb = b.as_cleo
12
+ end
13
+
14
+ assert_equal cb.name, b.name
15
+ assert_equal cb.score, b.cleo_score
16
+ assert_equal 2, cb.terms.count
17
+ end
18
+ end
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: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-03-21 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: happymapper
16
- requirement: &70295738594440 !ruby/object:Gem::Requirement
16
+ requirement: &70264219062420 !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: *70295738594440
24
+ version_requirements: *70264219062420
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rails
27
- requirement: &70295738593960 !ruby/object:Gem::Requirement
27
+ requirement: &70264219061880 !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: *70295738593960
35
+ version_requirements: *70264219061880
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: shoulda
38
- requirement: &70295738593480 !ruby/object:Gem::Requirement
38
+ requirement: &70264219061000 !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: :development
45
45
  prerelease: false
46
- version_requirements: *70295738593480
46
+ version_requirements: *70264219061000
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rdoc
49
- requirement: &70295738593000 !ruby/object:Gem::Requirement
49
+ requirement: &70264219060360 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '3.12'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70295738593000
57
+ version_requirements: *70264219060360
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: bundler
60
- requirement: &70295738592520 !ruby/object:Gem::Requirement
60
+ requirement: &70264219059760 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 1.0.0
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70295738592520
68
+ version_requirements: *70264219059760
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: jeweler
71
- requirement: &70295738592040 !ruby/object:Gem::Requirement
71
+ requirement: &70264219059200 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ~>
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 1.8.3
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70295738592040
79
+ version_requirements: *70264219059200
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: simplecov
82
- requirement: &70295738591560 !ruby/object:Gem::Requirement
82
+ requirement: &70264219058720 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70295738591560
90
+ version_requirements: *70264219058720
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: ruby-debug19
93
- requirement: &70295738591080 !ruby/object:Gem::Requirement
93
+ requirement: &70264219058220 !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: *70295738591080
101
+ version_requirements: *70264219058220
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: fixtures
104
- requirement: &70295738590600 !ruby/object:Gem::Requirement
104
+ requirement: &70264219057680 !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: *70295738590600
112
+ version_requirements: *70264219057680
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: sqlite3
115
- requirement: &70295738590120 !ruby/object:Gem::Requirement
115
+ requirement: &70264219057120 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,7 +120,7 @@ dependencies:
120
120
  version: '0'
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *70295738590120
123
+ version_requirements: *70264219057120
124
124
  description: LinkedIn Open Source type ahead tool's REST API as a ruby gem
125
125
  email: Blue.Dog.Archolite@gmail.com
126
126
  executables: []
@@ -146,6 +146,8 @@ files:
146
146
  - lib/cleo/result.rb
147
147
  - lib/cleo/server.rb
148
148
  - lib/common_methods.rb
149
+ - lib/generators/acts_as_cleo/install_generator.rb
150
+ - lib/generators/acts_as_cleo/templates/install.rb
149
151
  - lib/instance_methods.rb
150
152
  - test/config/cleo.yml
151
153
  - test/data/xml/cleo/element.xml
@@ -158,6 +160,7 @@ files:
158
160
  - test/db/migrate/004_create_electronics.rb
159
161
  - test/db/migrate/005_create_authors.rb
160
162
  - test/db/migrate/006_create_postings.rb
163
+ - test/db/migrate/007_cleo_table.rb
161
164
  - test/db/test.db
162
165
  - test/fixtures/authors.yml
163
166
  - test/fixtures/books.yml
@@ -171,8 +174,12 @@ files:
171
174
  - test/models/electronic.rb
172
175
  - test/models/movie.rb
173
176
  - test/test_acts_as_cleo.rb
177
+ - test/test_install_generator.rb
174
178
  - test/unit/test_acts_methods.rb
175
179
  - test/unit/test_cleo.rb
180
+ - test/unit/test_common_methods.rb
181
+ - test/unit/test_instance_methods.rb
182
+ - test/unit/test_model_to_cleo.rb
176
183
  - test/unit/test_result_parser.rb
177
184
  homepage: http://github.com/blue-dog-archolite/acts_as_cleo
178
185
  licenses:
@@ -187,6 +194,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
187
194
  - - ! '>='
188
195
  - !ruby/object:Gem::Version
189
196
  version: '0'
197
+ segments:
198
+ - 0
199
+ hash: 1569020174324415562
190
200
  required_rubygems_version: !ruby/object:Gem::Requirement
191
201
  none: false
192
202
  requirements: