lucid_works 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,39 @@
1
+ require 'spec_helper'
2
+
3
+ describe LucidWorks::Server do
4
+ before do
5
+ @fake_server_uri = "http://fakehost.com:8888"
6
+ end
7
+
8
+ describe ".new" do
9
+ it "should require a URL" do
10
+ lambda {
11
+ LucidWorks::Server.new
12
+ }.should raise_error(ArgumentError)
13
+ end
14
+
15
+ it "should remember the server URL" do
16
+ server = LucidWorks::Server.new(@fake_server_uri)
17
+ server.uri.should == @fake_server_uri + "/api"
18
+ end
19
+ end
20
+
21
+ context "server" do
22
+ before { @server = LucidWorks::Server.new(@fake_server_uri) }
23
+
24
+ describe "#collection" do
25
+ it "should call Collection.find and pass the server" do
26
+ LucidWorks::Collection.should_receive(:find).with('foo', :parent => @server)
27
+ @server.collection('foo')
28
+ end
29
+ end
30
+
31
+ describe "#collections" do
32
+
33
+ it "should call Collection.get and pass the server" do
34
+ LucidWorks::Collection.should_receive(:all).with(:parent => @server)
35
+ @server.collections
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,47 @@
1
+ require 'lucid_works'
2
+
3
+ def connect_to_live_server
4
+ server_uri = ENV['LUCIDWORKS_SERVER_URI']
5
+ raise "
6
+ These tests require a real live LucidWorks server,
7
+ please set LUCIDWORKS_SERVER_URI environment variable,
8
+ e.g. export LUCIDWORKS_SERVER_URI=http://localhost:8888 " unless server_uri
9
+ LucidWorks::Server.new(server_uri)
10
+ end
11
+
12
+ class LucidWorks::Server
13
+ DEFAULT_COLLECTION_NAME = 'collection1'
14
+
15
+ # Reset set of collections to contain 1 collection with the default name "collection1".
16
+ #
17
+ # LWE-CORE will not allow deletion of the last collection, so:
18
+ # create a junk empty one
19
+ # delete all the others
20
+ # create the default one
21
+ # delete the junk one
22
+ #
23
+ def reset_collections!
24
+ notes = [ "Resetting all collections:" ]
25
+
26
+ collections = self.collections
27
+ if default_collection = collections.detect { |c| c.name == DEFAULT_COLLECTION_NAME }
28
+ default_collection.datasources.each do |ds|
29
+ ds.destroy
30
+ notes << "Deleted collection '#{default_collection.name}' datasource #{ds.name}"
31
+ end
32
+ default_collection.empty!
33
+ notes << "Emptied collection '#{default_collection.name}'"
34
+ else
35
+ default_collection = Collection.create(:name => DEFAULT_COLLECTION_NAME)
36
+ notes << "Created collection '#{default_collection.name}'"
37
+ end
38
+
39
+ collections.each do |c|
40
+ unless c.name == default_collection.name
41
+ c.destroy
42
+ notes << "Deleted collection '#{c.name}'"
43
+ end
44
+ end
45
+ notes
46
+ end
47
+ end
metadata ADDED
@@ -0,0 +1,133 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lucid_works
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.1
6
+ platform: ruby
7
+ authors:
8
+ - Sam Pierson
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-03-11 00:00:00 -08:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: activesupport
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: "3"
25
+ type: :runtime
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: activemodel
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: "3"
36
+ type: :runtime
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: rest-client
40
+ prerelease: false
41
+ requirement: &id003 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 1.6.1
47
+ type: :runtime
48
+ version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
50
+ name: json
51
+ prerelease: false
52
+ requirement: &id004 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: "0"
58
+ type: :runtime
59
+ version_requirements: *id004
60
+ description: Ruby wrapper for the LucidWorks REST API
61
+ email:
62
+ - sam.pierson@lucidimagination.com
63
+ executables: []
64
+
65
+ extensions: []
66
+
67
+ extra_rdoc_files: []
68
+
69
+ files:
70
+ - .autotest
71
+ - .gitignore
72
+ - .rspec
73
+ - .rvmrc
74
+ - Gemfile
75
+ - Rakefile
76
+ - lib/lucid_works.rb
77
+ - lib/lucid_works/associations.rb
78
+ - lib/lucid_works/base.rb
79
+ - lib/lucid_works/collection.rb
80
+ - lib/lucid_works/collection/index.rb
81
+ - lib/lucid_works/collection/info.rb
82
+ - lib/lucid_works/collection/settings.rb
83
+ - lib/lucid_works/datasource.rb
84
+ - lib/lucid_works/datasource/history.rb
85
+ - lib/lucid_works/datasource/index.rb
86
+ - lib/lucid_works/datasource/schedule.rb
87
+ - lib/lucid_works/datasource/status.rb
88
+ - lib/lucid_works/exceptions.rb
89
+ - lib/lucid_works/patch_restclient.rb
90
+ - lib/lucid_works/server.rb
91
+ - lib/lucid_works/version.rb
92
+ - lucid_works.gemspec
93
+ - spec/lib/lucid_works/associations_spec.rb
94
+ - spec/lib/lucid_works/base_spec.rb
95
+ - spec/lib/lucid_works/collection_spec.rb
96
+ - spec/lib/lucid_works/datasource_spec.rb
97
+ - spec/lib/lucid_works/server_spec.rb
98
+ - spec/spec_helper.rb
99
+ has_rdoc: true
100
+ homepage: ""
101
+ licenses: []
102
+
103
+ post_install_message:
104
+ rdoc_options: []
105
+
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ none: false
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: "0"
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ none: false
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: "0"
120
+ requirements: []
121
+
122
+ rubyforge_project: lucid_works
123
+ rubygems_version: 1.5.2
124
+ signing_key:
125
+ specification_version: 3
126
+ summary: Ruby wrapper for the LucidWorks REST API
127
+ test_files:
128
+ - spec/lib/lucid_works/associations_spec.rb
129
+ - spec/lib/lucid_works/base_spec.rb
130
+ - spec/lib/lucid_works/collection_spec.rb
131
+ - spec/lib/lucid_works/datasource_spec.rb
132
+ - spec/lib/lucid_works/server_spec.rb
133
+ - spec/spec_helper.rb