lucid_works 0.6.29 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +1 -1
- data/Rakefile +25 -0
- data/config/locales/en.yml +171 -83
- data/lib/lucid_works/associations/has_many.rb +2 -2
- data/lib/lucid_works/associations/has_one.rb +1 -1
- data/lib/lucid_works/associations/proxy.rb +3 -3
- data/lib/lucid_works/associations.rb +2 -2
- data/lib/lucid_works/base.rb +21 -48
- data/lib/lucid_works/collection/click.rb +17 -0
- data/lib/lucid_works/collection/settings.rb +0 -1
- data/lib/lucid_works/collection.rb +22 -3
- data/lib/lucid_works/crawler.rb +13 -0
- data/lib/lucid_works/datasource/history.rb +5 -9
- data/lib/lucid_works/datasource/status.rb +8 -11
- data/lib/lucid_works/datasource.rb +67 -32
- data/lib/lucid_works/datasource_property.rb +18 -0
- data/lib/lucid_works/datasource_type.rb +23 -0
- data/lib/lucid_works/exceptions.rb +1 -0
- data/lib/lucid_works/field.rb +43 -2
- data/lib/lucid_works/fieldtype.rb +28 -0
- data/lib/lucid_works/gem_version.rb +1 -1
- data/lib/lucid_works/jdbcdriver.rb +30 -0
- data/lib/lucid_works/role.rb +59 -0
- data/lib/lucid_works/schema/attribute.rb +86 -0
- data/lib/lucid_works/schema/boolean_attribute.rb +34 -0
- data/lib/lucid_works/schema/custom_attribute.rb +15 -0
- data/lib/lucid_works/schema/integer_attribute.rb +32 -0
- data/lib/lucid_works/schema/iso8601_attribute.rb +31 -0
- data/lib/lucid_works/schema/string_attribute.rb +22 -0
- data/lib/lucid_works/schema.rb +66 -97
- data/lib/lucid_works/server.rb +14 -0
- data/lib/lucid_works.rb +12 -0
- data/spec/fixtures/fake_file_ds_to_be_deleted/.gitkeep +0 -0
- data/spec/fixtures/fake_file_ds_to_be_updated/.gitkeep +0 -0
- data/spec/fixtures/fake_file_ds_to_get_index_of/.gitkeep +0 -0
- data/spec/fixtures/fake_file_ds_to_get_schedule_of/.gitkeep +0 -0
- data/spec/fixtures/fake_file_ds_to_get_status_of/.gitkeep +0 -0
- data/spec/fixtures/fake_file_ds_to_mess_with_job_of/.gitkeep +0 -0
- data/spec/fixtures/fake_file_ds_to_test_progress/.gitkeep +0 -0
- data/spec/lib/lucid_works/associations/has_many_spec.rb +4 -3
- data/spec/lib/lucid_works/associations/has_one_spec.rb +4 -3
- data/spec/lib/lucid_works/base_spec.rb +110 -62
- data/spec/lib/lucid_works/collection/activity/history_spec.rb +1 -1
- data/spec/lib/lucid_works/collection_spec.rb +17 -17
- data/spec/lib/lucid_works/datasource/history_spec.rb +4 -4
- data/spec/lib/lucid_works/datasource/status_spec.rb +7 -7
- data/spec/lib/lucid_works/datasource_spec.rb +9 -8
- data/spec/lib/lucid_works/field_spec.rb +101 -2
- data/spec/lib/lucid_works/fieldtype_spec.rb +156 -0
- data/spec/lib/lucid_works/schema/attribute_spec.rb +136 -0
- data/spec/lib/lucid_works/schema_spec.rb +53 -27
- data/spec/spec_helper.rb +3 -50
- data/spec/support/active_model_lint.rb +21 -0
- data/spec/support/lucid_works.rb +52 -0
- metadata +36 -2
@@ -2,7 +2,8 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe LucidWorks::Schema do
|
4
4
|
before do
|
5
|
-
@
|
5
|
+
@mock_model = double('a model')
|
6
|
+
@schema = LucidWorks::Schema.new(@mock_model)
|
6
7
|
@schema.instance_eval do
|
7
8
|
attribute :astring, :string, :primary_key => true
|
8
9
|
attribute :abool, :boolean
|
@@ -13,53 +14,53 @@ describe LucidWorks::Schema do
|
|
13
14
|
end
|
14
15
|
|
15
16
|
describe "#attribute" do
|
16
|
-
before { @schema = LucidWorks::Schema.new }
|
17
|
+
before { @schema = LucidWorks::Schema.new(@mock_model) }
|
17
18
|
|
18
|
-
|
19
|
+
context "using default type" do
|
19
20
|
it "should create a string attribute" do
|
20
|
-
@schema.
|
21
|
-
|
21
|
+
@schema.instance_eval do
|
22
|
+
attribute :foo
|
23
|
+
end
|
24
|
+
@schema[:foo].type.should == :string
|
22
25
|
end
|
23
26
|
end
|
24
27
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
28
|
+
context "with a name that cannot be represented as a ruby identifier" do
|
29
|
+
before do
|
30
|
+
@schema.instance_eval do
|
31
|
+
attribute 'dash-dash', :string
|
32
|
+
end
|
30
33
|
end
|
31
|
-
end
|
32
34
|
|
33
|
-
|
34
|
-
|
35
|
-
@schema.
|
36
|
-
@schema[:foo][:type].should == attr_type
|
35
|
+
it "should map the name to something usable" do
|
36
|
+
@schema.should have_attribute(:dash_dash)
|
37
|
+
@schema[:dash_dash].type.should == :string
|
37
38
|
end
|
38
39
|
end
|
39
40
|
end
|
40
41
|
|
41
42
|
describe "instance_eval" do
|
42
43
|
it "should process the block in its context and create an attribute list" do
|
43
|
-
@schema.should ==
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
44
|
+
@schema[:astring].type.should == :string
|
45
|
+
@schema[:astring].type.should == :string
|
46
|
+
@schema[:anint].type.should == :integer
|
47
|
+
@schema[:baz].type.should == :integer
|
48
|
+
@schema[:abool].type.should == :boolean
|
49
|
+
@schema[:nullstring].type.should == :string
|
50
|
+
@schema[:nullstring].nil_when_blank?.should be_true
|
51
|
+
@schema[:time].type.should == :iso8601
|
51
52
|
@schema.primary_key.should == :astring
|
52
53
|
end
|
53
54
|
end
|
54
55
|
|
55
56
|
describe "#primary_key" do
|
56
57
|
it "should default to 'id'" do
|
57
|
-
LucidWorks::Schema.new.primary_key.should == :id
|
58
|
+
LucidWorks::Schema.new(@mock_model).primary_key.should == :id
|
58
59
|
end
|
59
60
|
|
60
61
|
context "when given an argument" do
|
61
62
|
it "should set the primary key to the provided value" do
|
62
|
-
schema = LucidWorks::Schema.new
|
63
|
+
schema = LucidWorks::Schema.new(@mock_model)
|
63
64
|
schema.primary_key 'astring'
|
64
65
|
schema.primary_key.should == :astring
|
65
66
|
end
|
@@ -68,13 +69,13 @@ describe LucidWorks::Schema do
|
|
68
69
|
|
69
70
|
describe "#dynamic_attributes" do
|
70
71
|
it "should default to true" do
|
71
|
-
schema = LucidWorks::Schema.new
|
72
|
+
schema = LucidWorks::Schema.new(@mock_model)
|
72
73
|
schema.dynamic_attributes.should be_true
|
73
74
|
end
|
74
75
|
|
75
76
|
context "when given an argument" do
|
76
77
|
it "should set dynamic_attributes to the provided value" do
|
77
|
-
schema = LucidWorks::Schema.new
|
78
|
+
schema = LucidWorks::Schema.new(@mock_model)
|
78
79
|
schema.dynamic_attributes false
|
79
80
|
schema.dynamic_attributes.should be_false
|
80
81
|
end
|
@@ -179,4 +180,29 @@ describe LucidWorks::Schema do
|
|
179
180
|
@schema.has_attribute?(:not_an_attribute).should be_false
|
180
181
|
end
|
181
182
|
end
|
183
|
+
|
184
|
+
describe "#reset!" do
|
185
|
+
it "should reset the schema to only those attributes defined via attribute/attributes" do
|
186
|
+
schema = LucidWorks::Schema.new(@mock_model)
|
187
|
+
schema.instance_eval do
|
188
|
+
attributes :original_attr1, :original_attr2, :type => :string
|
189
|
+
end
|
190
|
+
schema.add_attribute(:added_attr1, :string)
|
191
|
+
schema.add_attribute(:added_attr2, :string)
|
192
|
+
|
193
|
+
@mock_model.should respond_to('added_attr1')
|
194
|
+
@mock_model.should respond_to('added_attr1=')
|
195
|
+
@mock_model.should respond_to('added_attr2')
|
196
|
+
@mock_model.should respond_to('added_attr2=')
|
197
|
+
|
198
|
+
schema.reset!
|
199
|
+
|
200
|
+
@mock_model.should_not respond_to('added_attr1')
|
201
|
+
@mock_model.should_not respond_to('added_attr1=')
|
202
|
+
@mock_model.should_not respond_to('added_attr2')
|
203
|
+
@mock_model.should_not respond_to('added_attr2=')
|
204
|
+
|
205
|
+
schema.keys.should == %w{original_attr1 original_attr2}
|
206
|
+
end
|
207
|
+
end
|
182
208
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,55 +1,8 @@
|
|
1
1
|
require 'lucid_works'
|
2
2
|
require 'timecop'
|
3
3
|
|
4
|
-
|
5
|
-
server_uri = ENV['LUCIDWORKS_SERVER_URI']
|
6
|
-
raise "
|
7
|
-
These tests require a real live LucidWorks server,
|
8
|
-
please set LUCIDWORKS_SERVER_URI environment variable,
|
9
|
-
e.g. export LUCIDWORKS_SERVER_URI=http://localhost:8888 " unless server_uri
|
10
|
-
LucidWorks::Server.new(server_uri)
|
11
|
-
end
|
12
|
-
|
13
|
-
class LucidWorks::Server
|
14
|
-
DUMMY_COLLECTION_NAME = 'collection_that_should_never_exist'
|
15
|
-
DEFAULT_COLLECTION_NAME = 'collection1'
|
16
|
-
|
17
|
-
# Reset set of collections to contain 1 collection with the default name "collection1".
|
18
|
-
#
|
19
|
-
# LWE-CORE will not allow deletion of the last collection, so:
|
20
|
-
# create a junk empty one
|
21
|
-
# delete all the others
|
22
|
-
# create the default one
|
23
|
-
# delete the junk one
|
24
|
-
#
|
25
|
-
def reset_collections!
|
26
|
-
notes = [ "Resetting all collections:" ]
|
27
|
-
|
28
|
-
collections = self.collections!
|
29
|
-
|
30
|
-
dummy_collection = collections.find { |c| c.name == DUMMY_COLLECTION_NAME }
|
31
|
-
if dummy_collection
|
32
|
-
notes << "Using dummy collection #{dummy_collection.name}"
|
33
|
-
collections.delete_if { |c| c.name == DUMMY_COLLECTION_NAME }
|
34
|
-
else
|
35
|
-
dummy_collection = self.create_collection(:name => DUMMY_COLLECTION_NAME)
|
36
|
-
notes << "Created collection #{dummy_collection.name}"
|
37
|
-
end
|
38
|
-
|
39
|
-
collections.each do |c|
|
40
|
-
# TODO: figure out how to delete and recreate logs collection
|
41
|
-
# For now just don't delete it
|
42
|
-
unless c.name == 'LucidWorksLogs'
|
43
|
-
c.destroy
|
44
|
-
notes << "Deleted collection '#{c.name}'"
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
default_collection = self.create_collection(:name => DEFAULT_COLLECTION_NAME)
|
49
|
-
notes << "Created collection '#{default_collection.name}'"
|
4
|
+
Dir[File.join(File.dirname(__FILE__), "support/**/*.rb")].each {|f| require f}
|
50
5
|
|
51
|
-
|
52
|
-
|
53
|
-
notes
|
54
|
-
end
|
6
|
+
def fixture_path(file)
|
7
|
+
File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', file))
|
55
8
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# https://gist.github.com/639089
|
2
|
+
|
3
|
+
# adapted from rspec-rails http://github.com/rspec/rspec-rails/blob/master/spec/rspec/rails/mocks/mock_model_spec.rb
|
4
|
+
|
5
|
+
shared_examples_for "ActiveModel" do
|
6
|
+
require 'test/unit/assertions'
|
7
|
+
require 'active_model/lint'
|
8
|
+
include Test::Unit::Assertions
|
9
|
+
include ActiveModel::Lint::Tests
|
10
|
+
|
11
|
+
# to_s is to support ruby-1.9
|
12
|
+
ActiveModel::Lint::Tests.public_instance_methods.map{|m| m.to_s}.grep(/^test/).each do |m|
|
13
|
+
example m.gsub('_',' ') do
|
14
|
+
send m
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def model
|
19
|
+
subject
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
def connect_to_live_server
|
2
|
+
server_uri = ENV['LUCIDWORKS_SERVER_URI']
|
3
|
+
raise "
|
4
|
+
These tests require a real live LucidWorks server,
|
5
|
+
please set LUCIDWORKS_SERVER_URI environment variable, e.g.
|
6
|
+
export LUCIDWORKS_SERVER_URI=http://localhost:8888\n" unless server_uri
|
7
|
+
LucidWorks::Server.new(server_uri)
|
8
|
+
end
|
9
|
+
|
10
|
+
class LucidWorks::Server
|
11
|
+
DUMMY_COLLECTION_NAME = 'collection_that_should_never_exist'
|
12
|
+
DEFAULT_COLLECTION_NAME = 'collection1'
|
13
|
+
|
14
|
+
# Reset set of collections to contain 1 collection with the default name "collection1".
|
15
|
+
#
|
16
|
+
# LWE-CORE will not allow deletion of the last collection, so:
|
17
|
+
# create a junk empty one
|
18
|
+
# delete all the others
|
19
|
+
# create the default one
|
20
|
+
# delete the junk one
|
21
|
+
#
|
22
|
+
def reset_collections!
|
23
|
+
notes = [ "Resetting all collections:" ]
|
24
|
+
|
25
|
+
collections = self.collections!
|
26
|
+
|
27
|
+
dummy_collection = collections.find { |c| c.name == DUMMY_COLLECTION_NAME }
|
28
|
+
if dummy_collection
|
29
|
+
notes << "Using dummy collection #{dummy_collection.name}"
|
30
|
+
collections.delete_if { |c| c.name == DUMMY_COLLECTION_NAME }
|
31
|
+
else
|
32
|
+
dummy_collection = self.create_collection(:name => DUMMY_COLLECTION_NAME)
|
33
|
+
notes << "Created collection #{dummy_collection.name}"
|
34
|
+
end
|
35
|
+
|
36
|
+
collections.each do |c|
|
37
|
+
# TODO: figure out how to delete and recreate logs collection
|
38
|
+
# For now just don't delete it
|
39
|
+
unless c.name == 'LucidWorksLogs'
|
40
|
+
c.destroy
|
41
|
+
notes << "Deleted collection '#{c.name}'"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
default_collection = self.create_collection(:name => DEFAULT_COLLECTION_NAME)
|
46
|
+
notes << "Created collection '#{default_collection.name}'"
|
47
|
+
|
48
|
+
dummy_collection.destroy
|
49
|
+
notes << "Deleted collection #{dummy_collection.name}"
|
50
|
+
notes
|
51
|
+
end
|
52
|
+
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.
|
5
|
+
version: 0.7.1
|
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-
|
13
|
+
date: 2011-08-23 00:00:00 -04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -120,6 +120,7 @@ files:
|
|
120
120
|
- lib/lucid_works/associations/proxy.rb
|
121
121
|
- lib/lucid_works/base.rb
|
122
122
|
- lib/lucid_works/collection.rb
|
123
|
+
- lib/lucid_works/collection/click.rb
|
123
124
|
- lib/lucid_works/collection/index.rb
|
124
125
|
- lib/lucid_works/collection/info.rb
|
125
126
|
- lib/lucid_works/collection/settings.rb
|
@@ -131,9 +132,13 @@ files:
|
|
131
132
|
- lib/lucid_works/datasource/job.rb
|
132
133
|
- lib/lucid_works/datasource/schedule.rb
|
133
134
|
- lib/lucid_works/datasource/status.rb
|
135
|
+
- lib/lucid_works/datasource_property.rb
|
136
|
+
- lib/lucid_works/datasource_type.rb
|
134
137
|
- lib/lucid_works/exceptions.rb
|
135
138
|
- lib/lucid_works/field.rb
|
139
|
+
- lib/lucid_works/fieldtype.rb
|
136
140
|
- lib/lucid_works/gem_version.rb
|
141
|
+
- lib/lucid_works/jdbcdriver.rb
|
137
142
|
- lib/lucid_works/logs.rb
|
138
143
|
- lib/lucid_works/logs/index.rb
|
139
144
|
- lib/lucid_works/logs/index/summary.rb
|
@@ -141,13 +146,27 @@ files:
|
|
141
146
|
- lib/lucid_works/logs/query/summary.rb
|
142
147
|
- lib/lucid_works/patch_restclient.rb
|
143
148
|
- lib/lucid_works/patch_time.rb
|
149
|
+
- lib/lucid_works/role.rb
|
144
150
|
- lib/lucid_works/schema.rb
|
151
|
+
- lib/lucid_works/schema/attribute.rb
|
152
|
+
- lib/lucid_works/schema/boolean_attribute.rb
|
153
|
+
- lib/lucid_works/schema/custom_attribute.rb
|
154
|
+
- lib/lucid_works/schema/integer_attribute.rb
|
155
|
+
- lib/lucid_works/schema/iso8601_attribute.rb
|
156
|
+
- lib/lucid_works/schema/string_attribute.rb
|
145
157
|
- lib/lucid_works/server.rb
|
146
158
|
- lib/lucid_works/simple_naming.rb
|
147
159
|
- lib/lucid_works/synonym.rb
|
148
160
|
- lib/lucid_works/utils.rb
|
149
161
|
- lib/lucid_works/version.rb
|
150
162
|
- lucid_works.gemspec
|
163
|
+
- spec/fixtures/fake_file_ds_to_be_deleted/.gitkeep
|
164
|
+
- spec/fixtures/fake_file_ds_to_be_updated/.gitkeep
|
165
|
+
- spec/fixtures/fake_file_ds_to_get_index_of/.gitkeep
|
166
|
+
- spec/fixtures/fake_file_ds_to_get_schedule_of/.gitkeep
|
167
|
+
- spec/fixtures/fake_file_ds_to_get_status_of/.gitkeep
|
168
|
+
- spec/fixtures/fake_file_ds_to_mess_with_job_of/.gitkeep
|
169
|
+
- spec/fixtures/fake_file_ds_to_test_progress/.gitkeep
|
151
170
|
- spec/lib/lucid_works/associations/has_many_spec.rb
|
152
171
|
- spec/lib/lucid_works/associations/has_one_spec.rb
|
153
172
|
- spec/lib/lucid_works/associations_spec.rb
|
@@ -163,11 +182,15 @@ files:
|
|
163
182
|
- spec/lib/lucid_works/datasource/status_spec.rb
|
164
183
|
- spec/lib/lucid_works/datasource_spec.rb
|
165
184
|
- spec/lib/lucid_works/field_spec.rb
|
185
|
+
- spec/lib/lucid_works/fieldtype_spec.rb
|
166
186
|
- spec/lib/lucid_works/patch_time_spec.rb
|
187
|
+
- spec/lib/lucid_works/schema/attribute_spec.rb
|
167
188
|
- spec/lib/lucid_works/schema_spec.rb
|
168
189
|
- spec/lib/lucid_works/server_spec.rb
|
169
190
|
- spec/lib/lucid_works/utils_spec.rb
|
170
191
|
- spec/spec_helper.rb
|
192
|
+
- spec/support/active_model_lint.rb
|
193
|
+
- spec/support/lucid_works.rb
|
171
194
|
has_rdoc: true
|
172
195
|
homepage: ""
|
173
196
|
licenses: []
|
@@ -197,6 +220,13 @@ signing_key:
|
|
197
220
|
specification_version: 3
|
198
221
|
summary: Ruby wrapper for the LucidWorks REST API
|
199
222
|
test_files:
|
223
|
+
- spec/fixtures/fake_file_ds_to_be_deleted/.gitkeep
|
224
|
+
- spec/fixtures/fake_file_ds_to_be_updated/.gitkeep
|
225
|
+
- spec/fixtures/fake_file_ds_to_get_index_of/.gitkeep
|
226
|
+
- spec/fixtures/fake_file_ds_to_get_schedule_of/.gitkeep
|
227
|
+
- spec/fixtures/fake_file_ds_to_get_status_of/.gitkeep
|
228
|
+
- spec/fixtures/fake_file_ds_to_mess_with_job_of/.gitkeep
|
229
|
+
- spec/fixtures/fake_file_ds_to_test_progress/.gitkeep
|
200
230
|
- spec/lib/lucid_works/associations/has_many_spec.rb
|
201
231
|
- spec/lib/lucid_works/associations/has_one_spec.rb
|
202
232
|
- spec/lib/lucid_works/associations_spec.rb
|
@@ -212,8 +242,12 @@ test_files:
|
|
212
242
|
- spec/lib/lucid_works/datasource/status_spec.rb
|
213
243
|
- spec/lib/lucid_works/datasource_spec.rb
|
214
244
|
- spec/lib/lucid_works/field_spec.rb
|
245
|
+
- spec/lib/lucid_works/fieldtype_spec.rb
|
215
246
|
- spec/lib/lucid_works/patch_time_spec.rb
|
247
|
+
- spec/lib/lucid_works/schema/attribute_spec.rb
|
216
248
|
- spec/lib/lucid_works/schema_spec.rb
|
217
249
|
- spec/lib/lucid_works/server_spec.rb
|
218
250
|
- spec/lib/lucid_works/utils_spec.rb
|
219
251
|
- spec/spec_helper.rb
|
252
|
+
- spec/support/active_model_lint.rb
|
253
|
+
- spec/support/lucid_works.rb
|