primedia-endeca_factory 0.3.0 → 0.4.0
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.
- data/README.rdoc +50 -0
- data/Rakefile +2 -2
- data/lib/endeca_factory.rb +29 -13
- metadata +3 -3
- data/README +0 -3
data/README.rdoc
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
= endeca_factory
|
|
2
|
+
|
|
3
|
+
== DESCRIPTION:
|
|
4
|
+
|
|
5
|
+
A gem that provides a factory for creating Endeca test objects.
|
|
6
|
+
|
|
7
|
+
== SYNOPSIS:
|
|
8
|
+
|
|
9
|
+
class Listing < Endeca::Document
|
|
10
|
+
reader :title, :subject, :description
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
Listing.factory({
|
|
14
|
+
:title => "A Title",
|
|
15
|
+
:subject => "A Subject",
|
|
16
|
+
:description => "A Description"
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
== REQUIREMENTS:
|
|
20
|
+
|
|
21
|
+
* endeca
|
|
22
|
+
|
|
23
|
+
== INSTALL:
|
|
24
|
+
|
|
25
|
+
sudo gem install primedia-endeca_factory --source=http://gems.github.com
|
|
26
|
+
|
|
27
|
+
== LICENSE:
|
|
28
|
+
|
|
29
|
+
(The MIT License)
|
|
30
|
+
|
|
31
|
+
Copyright (c) 2009 Primedia
|
|
32
|
+
|
|
33
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
34
|
+
a copy of this software and associated documentation files (the
|
|
35
|
+
"Software"), to deal in the Software without restriction, including
|
|
36
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
37
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
38
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
39
|
+
the following conditions:
|
|
40
|
+
|
|
41
|
+
The above copyright notice and this permission notice shall be
|
|
42
|
+
included in all copies or substantial portions of the Software.
|
|
43
|
+
|
|
44
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
45
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
46
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
47
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
48
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
49
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
50
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
CHANGED
|
@@ -15,7 +15,7 @@ spec = Gem::Specification.new do |s|
|
|
|
15
15
|
s.version = GEM_VERSION
|
|
16
16
|
s.platform = Gem::Platform::RUBY
|
|
17
17
|
s.has_rdoc = true
|
|
18
|
-
s.extra_rdoc_files = ["README", "LICENSE"]
|
|
18
|
+
s.extra_rdoc_files = ["README.rdoc", "LICENSE"]
|
|
19
19
|
s.summary = SUMMARY
|
|
20
20
|
s.description = s.summary
|
|
21
21
|
s.authors = AUTHORS
|
|
@@ -25,7 +25,7 @@ spec = Gem::Specification.new do |s|
|
|
|
25
25
|
|
|
26
26
|
s.require_path = 'lib'
|
|
27
27
|
s.autorequire = GEM
|
|
28
|
-
s.files = %w(LICENSE README Rakefile) + Dir.glob("{lib,spec}/**/*")
|
|
28
|
+
s.files = %w(LICENSE README.rdoc Rakefile) + Dir.glob("{lib,spec}/**/*")
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
task :default => :spec
|
data/lib/endeca_factory.rb
CHANGED
|
@@ -2,24 +2,19 @@ require 'rubygems'
|
|
|
2
2
|
require 'endeca'
|
|
3
3
|
require File.join(File.dirname(__FILE__), 'core_ext')
|
|
4
4
|
|
|
5
|
-
module Endeca
|
|
5
|
+
module Endeca #:nodoc:
|
|
6
|
+
# Endeca::Factory creates stubbed Endeca objects. It expects a hash (or array of
|
|
7
|
+
# hashes) and the class of the Document object(s) to be created.
|
|
6
8
|
class Factory
|
|
7
|
-
VERSION = "0.
|
|
8
|
-
def self.version
|
|
9
|
+
VERSION = "0.4.0" #:nodoc:
|
|
10
|
+
def self.version #:nodoc:
|
|
9
11
|
VERSION
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def self.create(params, klass)
|
|
13
|
-
new(params, klass).objects
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
attr_reader :objects
|
|
12
|
+
end
|
|
17
13
|
|
|
18
14
|
class << self; private :new end
|
|
19
|
-
|
|
20
|
-
private
|
|
15
|
+
attr_reader :objects #:nodoc:
|
|
21
16
|
|
|
22
|
-
def initialize(params, klass)
|
|
17
|
+
def initialize(params, klass) #:nodoc:
|
|
23
18
|
params = params.dup
|
|
24
19
|
@klass = klass
|
|
25
20
|
case params
|
|
@@ -29,6 +24,20 @@ module Endeca
|
|
|
29
24
|
end
|
|
30
25
|
end
|
|
31
26
|
|
|
27
|
+
# Creates stubbed Endeca::Document and Endeca::DocumentCollection objects.
|
|
28
|
+
# Pass a hash to return a single stubbed Endeca::Document object or an
|
|
29
|
+
# array of hashes to return an Endeca::DocumentCollection object with
|
|
30
|
+
# +documents+ stubbed to return the collection of documents built from the
|
|
31
|
+
# array of hashes.
|
|
32
|
+
#
|
|
33
|
+
# Example:
|
|
34
|
+
# Endeca::Factory.create({:title => "A Title"}, Listing)
|
|
35
|
+
def self.create(params, klass)
|
|
36
|
+
new(params, klass).objects
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
private
|
|
40
|
+
|
|
32
41
|
def build_from_hash(params);
|
|
33
42
|
@klass.new.tap do |document|
|
|
34
43
|
params.each do |method, value|
|
|
@@ -66,6 +75,13 @@ module Endeca
|
|
|
66
75
|
end
|
|
67
76
|
|
|
68
77
|
class Document
|
|
78
|
+
# Creates stubbed Endeca::Document and Endeca::DocumentCollection objects
|
|
79
|
+
# using its class as the Document class. See Endeca::Factory.create for
|
|
80
|
+
# usage.
|
|
81
|
+
#
|
|
82
|
+
# Example:
|
|
83
|
+
#
|
|
84
|
+
# Listing.factory([{:title => "A Title"}, {:title => "Another Title"}])
|
|
69
85
|
def self.factory(params)
|
|
70
86
|
Factory.create(params, self)
|
|
71
87
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: primedia-endeca_factory
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.4.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jason Noble
|
|
@@ -30,11 +30,11 @@ executables: []
|
|
|
30
30
|
extensions: []
|
|
31
31
|
|
|
32
32
|
extra_rdoc_files:
|
|
33
|
-
- README
|
|
33
|
+
- README.rdoc
|
|
34
34
|
- LICENSE
|
|
35
35
|
files:
|
|
36
36
|
- LICENSE
|
|
37
|
-
- README
|
|
37
|
+
- README.rdoc
|
|
38
38
|
- Rakefile
|
|
39
39
|
- lib/core_ext.rb
|
|
40
40
|
- lib/endeca_factory.rb
|
data/README
DELETED