lucid_works 0.2.0 → 0.3.9

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.
@@ -0,0 +1,47 @@
1
+ require 'spec_helper'
2
+ require 'active_support/core_ext'
3
+
4
+ describe LucidWorks::Datasource::History do
5
+
6
+ before :all do
7
+ fake_server = "http://127.0.0.1:123456"
8
+ @fake_server = LucidWorks::Server.new(fake_server)
9
+ @fake_server_uri = "#{fake_server}/api"
10
+ end
11
+
12
+ describe "#doc_count" do
13
+ it "should sum counds of Updated, New and Unchanged" do
14
+ # History doesn't actually descend drectly from server, but for this test that doesn't matter
15
+ RestClient.should_receive(:get).
16
+ with("#{@fake_server_uri}/history").and_return('[{"numUpdated":11,"numNew":22,"numUnchanged":33}]')
17
+ histories = LucidWorks::Datasource::History.all(:parent => @fake_server)
18
+ histories.first.doc_count.should == 66
19
+ end
20
+ end
21
+
22
+ describe "#crawl_stopped" do
23
+ it "should be tested" do
24
+ pending "write some tests"
25
+ # TODO
26
+ end
27
+ end
28
+
29
+ describe "#crawl_started" do
30
+ it "should be tested" do
31
+ pending "write some tests"
32
+ # TODO
33
+ end
34
+ end
35
+
36
+ describe "#duration" do
37
+ it "should be tested" do
38
+ include ActiveSupport::Duration
39
+
40
+ history = LucidWorks::Datasource::History.new(:parent => @fake_server)
41
+ now = Time.now
42
+ history.stub(:crawl_started) { now.advance(:seconds => -15) }
43
+ history.stub(:crawl_stopped) { now.advance(:seconds => -10) }
44
+ history.duration.should == 5.seconds
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,52 @@
1
+ require 'spec_helper'
2
+
3
+ describe LucidWorks::Datasource::Status do
4
+ describe "state predicate methods" do
5
+ it "should be tested" do
6
+ pending "write some tests"
7
+ # TODO
8
+ end
9
+ end
10
+
11
+ describe "#none?" do
12
+ it "should be tested" do
13
+ pending "write some tests"
14
+ # TODO
15
+ end
16
+ end
17
+
18
+ describe "#stopped?" do
19
+ it "should be tested" do
20
+ pending "write some tests"
21
+ # TODO
22
+ end
23
+ end
24
+
25
+ describe "#post_processing?" do
26
+ it "should be tested" do
27
+ pending "write some tests"
28
+ # TODO
29
+ end
30
+ end
31
+
32
+ describe "#doc_count" do
33
+ it "should be tested" do
34
+ pending "write some tests"
35
+ # TODO
36
+ end
37
+ end
38
+
39
+ describe "#crawl_started_to_date_time" do
40
+ it "should be tested" do
41
+ pending "write some tests"
42
+ # TODO
43
+ end
44
+ end
45
+
46
+ describe "#elapsed_time" do
47
+ it "should be tested" do
48
+ pending "write some tests"
49
+ # TODO
50
+ end
51
+ end
52
+ end
@@ -15,27 +15,11 @@ describe LucidWorks::Datasource do
15
15
 
16
16
  describe ".create" do
17
17
 
18
- context "with no parameters" do
19
- before do
20
- @parameters = {
21
- :parent => @collection
22
- }
23
- end
24
-
25
- it "should not create a datasource, and add a base error" do
26
- d = nil
27
- lambda {
28
- d = LucidWorks::Datasource.create(@parameters)
29
- }.should_not change(self, :datasource_count)
30
- d.errors[:base].should == ["No input content found"]
31
- end
32
- end
33
-
34
18
  context "without a crawler specified" do
35
19
  before do
36
20
  @parameters = {
37
21
  :collection => @collection,
38
- :type => LucidWorks::Datasource::TYPES[:WebDataSource][:type],
22
+ :type => 'web',
39
23
  :name => "foo"
40
24
  }
41
25
  end
@@ -73,8 +57,8 @@ describe LucidWorks::Datasource do
73
57
  @parameters = {
74
58
  :collection => @collection,
75
59
  :name => "foo",
76
- :crawler => "lucid.aperture",
77
- :type => LucidWorks::Datasource::TYPES[:WebDataSource][:type],
60
+ :crawler => LucidWorks::Datasource::CRAWLERS['web'],
61
+ :type => 'web',
78
62
  :url => "invalid url",
79
63
  :crawl_depth => "invalid crawl depth"
80
64
  }
@@ -95,8 +79,8 @@ describe LucidWorks::Datasource do
95
79
  before do
96
80
  @parameters = {
97
81
  :collection => @collection,
98
- :crawler => "lucid.aperture",
99
- :type => LucidWorks::Datasource::TYPES[:WebDataSource][:type],
82
+ :crawler => LucidWorks::Datasource::CRAWLERS['web'],
83
+ :type => 'web',
100
84
  :name => "Lucid Imagination Website",
101
85
  :url => "http://www.lucidimagination.com/",
102
86
  :crawl_depth => 2,
@@ -125,8 +109,8 @@ describe LucidWorks::Datasource do
125
109
  before do
126
110
  @datasource = LucidWorks::Datasource.create(
127
111
  :collection => @collection,
128
- :crawler => "lucid.aperture",
129
- :type => LucidWorks::Datasource::TYPES[:FileSystemDataSource][:type],
112
+ :crawler => LucidWorks::Datasource::CRAWLERS['file'],
113
+ :type => 'file',
130
114
  :name => "slash_temp",
131
115
  :path => "/tmp",
132
116
  :crawl_depth => 2
@@ -147,8 +131,8 @@ describe LucidWorks::Datasource do
147
131
  before do
148
132
  @datasource = LucidWorks::Datasource.create(
149
133
  :collection => @collection,
150
- :crawler => "lucid.aperture",
151
- :type => LucidWorks::Datasource::TYPES[:FileSystemDataSource][:type],
134
+ :crawler => LucidWorks::Datasource::CRAWLERS['file'],
135
+ :type => 'file',
152
136
  :name => "datasource we are going to update",
153
137
  :path => "/fake_ds_to_be_updated",
154
138
  :crawl_depth => 2
@@ -169,8 +153,8 @@ describe LucidWorks::Datasource do
169
153
  before do
170
154
  @datasource = LucidWorks::Datasource.create(
171
155
  :collection => @collection,
172
- :crawler => "lucid.aperture",
173
- :type => LucidWorks::Datasource::TYPES[:FileSystemDataSource][:type],
156
+ :crawler => LucidWorks::Datasource::CRAWLERS['file'],
157
+ :type => 'file',
174
158
  :name => "datasource we are going to delete",
175
159
  :path => "/fake_ds_to_be_deleted",
176
160
  :crawl_depth => 2
@@ -194,8 +178,8 @@ describe LucidWorks::Datasource do
194
178
  before :all do
195
179
  @datasource = LucidWorks::Datasource.create(
196
180
  :collection => @collection,
197
- :crawler => "lucid.aperture",
198
- :type => LucidWorks::Datasource::TYPES[:FileSystemDataSource][:type],
181
+ :crawler => LucidWorks::Datasource::CRAWLERS['file'],
182
+ :type => 'file',
199
183
  :name => "datasource we are going to get a status of",
200
184
  :path => "/fake_ds_to_get_status_of",
201
185
  :crawl_depth => 2
@@ -220,8 +204,8 @@ describe LucidWorks::Datasource do
220
204
  it "should retrieve the datasource's schedule" do
221
205
  @datasource = LucidWorks::Datasource.create(
222
206
  :collection => @collection,
223
- :crawler => "lucid.aperture",
224
- :type => LucidWorks::Datasource::TYPES[:FileSystemDataSource][:type],
207
+ :crawler => LucidWorks::Datasource::CRAWLERS['file'],
208
+ :type => 'file',
225
209
  :name => "datasource we are going to get a schedule of",
226
210
  :path => "/fake_ds_to_get_schedule_of",
227
211
  :crawl_depth => 2
@@ -242,15 +226,15 @@ describe LucidWorks::Datasource do
242
226
  it "should return a new LucidWorks::Datasource::Index for this datasource" do
243
227
  @datasource = LucidWorks::Datasource.create(
244
228
  :collection => @collection,
245
- :crawler => "lucid.aperture",
246
- :type => LucidWorks::Datasource::TYPES[:FileSystemDataSource][:type],
229
+ :crawler => LucidWorks::Datasource::CRAWLERS['file'],
230
+ :type => 'file',
247
231
  :name => "datasource we are going to get a index of",
248
232
  :path => "/fake_ds_to_get_index_of",
249
233
  :crawl_depth => 2
250
234
  )
251
235
  @datasource.should be_valid
252
236
 
253
- index = @datasource.build_index
237
+ index = @datasource.index
254
238
  index.should be_a(LucidWorks::Datasource::Index)
255
239
  index.should be_persisted # special case - singletons are always considered persisted
256
240
  end
@@ -261,8 +245,8 @@ describe LucidWorks::Datasource do
261
245
  @collection = @server.collections.first
262
246
  @datasource = LucidWorks::Datasource.create(
263
247
  :collection => @collection,
264
- :crawler => "lucid.aperture",
265
- :type => LucidWorks::Datasource::TYPES[:FileSystemDataSource][:type],
248
+ :crawler => LucidWorks::Datasource::CRAWLERS['file'],
249
+ :type => 'file',
266
250
  :name => "datasource we are going to empty",
267
251
  :path => "/fake_ds_to_empty",
268
252
  :crawl_depth => 2
@@ -276,5 +260,18 @@ describe LucidWorks::Datasource do
276
260
  @datasource.empty!
277
261
  end
278
262
 
263
+ describe "#progress" do
264
+ context "when the datasource has no prior history" do
265
+ it "should return nil"
266
+ end
267
+ context "when the datasource has history" do
268
+ context "and the most last crawl duration was longer then our current crawl duration" do
269
+ it "should return the fraction completed (between 0.0 and 1.0)"
270
+ end
271
+ context "and the most recent crawl duration was no longer our current duration" do
272
+ it "should return nil"
273
+ end
274
+ end
275
+ end
279
276
  end
280
277
  end
@@ -0,0 +1,23 @@
1
+ require 'spec_helper'
2
+
3
+ describe LucidWorks::Field do
4
+ before :all do
5
+ @server = connect_to_live_server
6
+ @server.reset_collections!
7
+ @collection = @server.collections.first
8
+ end
9
+
10
+ it "should use the ORM" do
11
+ LucidWorks::Field.new(:parent => @collection).should be_a(LucidWorks::Base)
12
+ end
13
+
14
+ describe "CRUD" do
15
+ describe "find" do
16
+ it "should retrieve a field" do
17
+ field = LucidWorks::Field.find('body', :parent => @collection)
18
+ field.should be_a(LucidWorks::Field)
19
+ field.should respond_to(:field_type)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,50 @@
1
+ require 'spec_helper'
2
+
3
+ describe LucidWorks::Schema do
4
+ before do
5
+ @schema = LucidWorks::Schema.new
6
+ @schema.instance_eval do
7
+ attribute :foo
8
+ attribute :abool, :boolean
9
+ attributes :bar, :baz, :type => :integer
10
+ end
11
+ end
12
+
13
+ describe "instance_eval" do
14
+ it "should process the block in its context and create an attribute list" do
15
+ @schema.should == {
16
+ 'foo' => {'type' => :string},
17
+ 'bar' => {'type' => :integer},
18
+ 'baz' => {'type' => :integer},
19
+ 'abool' => {'type' => :boolean}
20
+ }
21
+ end
22
+ end
23
+
24
+ describe "create_accessors_for_attributes" do
25
+ before do
26
+ class ClassWithAddedAccessors ; end
27
+ @schema.create_accessors_for_attributes(ClassWithAddedAccessors)
28
+ end
29
+
30
+ it "should add readers and writers for all attributes" do
31
+ ClassWithAddedAccessors.new.should respond_to(:foo, :foo=)
32
+ ClassWithAddedAccessors.new.should respond_to(:bar, :bar=)
33
+ ClassWithAddedAccessors.new.should respond_to(:abool, :abool=)
34
+ end
35
+
36
+ it "should also add a predicate method for boolean attributes" do
37
+ ClassWithAddedAccessors.new.should respond_to(:abool?)
38
+ end
39
+ end
40
+
41
+ describe "#has_attribute?" do
42
+ it "should return true if the schema has that attribute" do
43
+ @schema.has_attribute?(:foo).should be_true
44
+ end
45
+
46
+ it "should return false if the schema does not have that attribute" do
47
+ @schema.has_attribute?(:not_an_attribute).should be_false
48
+ end
49
+ end
50
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: lucid_works
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.0
5
+ version: 0.3.9
6
6
  platform: ruby
7
7
  authors:
8
8
  - Sam Pierson
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-03-15 00:00:00 -07:00
13
+ date: 2011-03-24 00:00:00 -07:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -72,7 +72,11 @@ files:
72
72
  - .rspec
73
73
  - .rvmrc
74
74
  - Gemfile
75
+ - LICENSE
76
+ - NOTICE
77
+ - README.rdoc
75
78
  - Rakefile
79
+ - config/locales/en.yml
76
80
  - lib/lucid_works.rb
77
81
  - lib/lucid_works/associations.rb
78
82
  - lib/lucid_works/base.rb
@@ -80,25 +84,33 @@ files:
80
84
  - lib/lucid_works/collection/index.rb
81
85
  - lib/lucid_works/collection/info.rb
82
86
  - lib/lucid_works/collection/settings.rb
87
+ - lib/lucid_works/crawler.rb
83
88
  - lib/lucid_works/datasource.rb
89
+ - lib/lucid_works/datasource/crawldata.rb
84
90
  - lib/lucid_works/datasource/history.rb
85
91
  - lib/lucid_works/datasource/index.rb
86
92
  - lib/lucid_works/datasource/schedule.rb
87
93
  - lib/lucid_works/datasource/status.rb
88
94
  - lib/lucid_works/exceptions.rb
95
+ - lib/lucid_works/field.rb
89
96
  - lib/lucid_works/logs.rb
90
97
  - lib/lucid_works/logs/index.rb
91
98
  - lib/lucid_works/logs/index/summary.rb
92
99
  - lib/lucid_works/logs/query.rb
93
100
  - lib/lucid_works/logs/query/summary.rb
94
101
  - lib/lucid_works/patch_restclient.rb
102
+ - lib/lucid_works/schema.rb
95
103
  - lib/lucid_works/server.rb
96
104
  - lib/lucid_works/version.rb
97
105
  - lucid_works.gemspec
98
106
  - spec/lib/lucid_works/associations_spec.rb
99
107
  - spec/lib/lucid_works/base_spec.rb
100
108
  - spec/lib/lucid_works/collection_spec.rb
109
+ - spec/lib/lucid_works/datasource/history_spec.rb
110
+ - spec/lib/lucid_works/datasource/status_spec.rb
101
111
  - spec/lib/lucid_works/datasource_spec.rb
112
+ - spec/lib/lucid_works/field_spec.rb
113
+ - spec/lib/lucid_works/schema_spec.rb
102
114
  - spec/lib/lucid_works/server_spec.rb
103
115
  - spec/spec_helper.rb
104
116
  has_rdoc: true
@@ -133,6 +145,10 @@ test_files:
133
145
  - spec/lib/lucid_works/associations_spec.rb
134
146
  - spec/lib/lucid_works/base_spec.rb
135
147
  - spec/lib/lucid_works/collection_spec.rb
148
+ - spec/lib/lucid_works/datasource/history_spec.rb
149
+ - spec/lib/lucid_works/datasource/status_spec.rb
136
150
  - spec/lib/lucid_works/datasource_spec.rb
151
+ - spec/lib/lucid_works/field_spec.rb
152
+ - spec/lib/lucid_works/schema_spec.rb
137
153
  - spec/lib/lucid_works/server_spec.rb
138
154
  - spec/spec_helper.rb