mdex_client 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/Rakefile +9 -0
- data/lib/mdex_client.rb +1 -0
- data/lib/mdex_client/active_record/extensions.rb +77 -0
- data/lib/mdex_client/client.rb +91 -0
- data/lib/mdex_client/fake_mdex.rb +1 -0
- data/lib/mdex_client/fake_mdex/fake_mdex.rb +23 -0
- data/lib/mdex_client/fake_mdex/mdex.wsdl +787 -0
- data/lib/mdex_client/fake_mdex/mdex_response.xml +7 -0
- data/lib/mdex_client/mdata/aggregate_record.rb +15 -0
- data/lib/mdex_client/mdata/aggregation_key.rb +19 -0
- data/lib/mdex_client/mdata/dimension.rb +51 -0
- data/lib/mdex_client/mdata/dimension_value.rb +47 -0
- data/lib/mdex_client/mdata/geocode.rb +14 -0
- data/lib/mdex_client/mdata/navigation_query.rb +135 -0
- data/lib/mdex_client/mdata/navigation_result.rb +75 -0
- data/lib/mdex_client/mdata/node.rb +64 -0
- data/lib/mdex_client/mdata/range_filter.rb +163 -0
- data/lib/mdex_client/mdata/record.rb +59 -0
- data/lib/mdex_client/mdata/refinement_config.rb +44 -0
- data/lib/mdex_client/mdata/search.rb +36 -0
- data/lib/mdex_client/mdata/sort.rb +26 -0
- data/lib/mdex_client/version.rb +3 -0
- data/mdex_client.gemspec +25 -0
- data/spec/spec_helper.rb +21 -0
- metadata +151 -0
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'mdex_client/mdata/node'
|
2
|
+
|
3
|
+
module MDEXClient
|
4
|
+
module MData
|
5
|
+
class Record < Node
|
6
|
+
class Attributes < Hash
|
7
|
+
def initialize(*args)
|
8
|
+
super(*args)
|
9
|
+
|
10
|
+
@dimension_value_ids = {}
|
11
|
+
@dimension_ids = {}
|
12
|
+
end
|
13
|
+
|
14
|
+
def dimension_value_id(key)
|
15
|
+
@dimension_value_ids[key]
|
16
|
+
end
|
17
|
+
|
18
|
+
def dimension_id(key)
|
19
|
+
@dimension_ids[key]
|
20
|
+
end
|
21
|
+
|
22
|
+
def dimension_keys
|
23
|
+
@dimension_ids.keys
|
24
|
+
end
|
25
|
+
|
26
|
+
def property_keys
|
27
|
+
keys - dimension_keys
|
28
|
+
end
|
29
|
+
|
30
|
+
def <<(node)
|
31
|
+
key = node["Key"]
|
32
|
+
self[key] = node.text
|
33
|
+
|
34
|
+
if node.name == "AssignedDimensionValue"
|
35
|
+
@dimension_value_ids[key] = node["Id"]
|
36
|
+
@dimension_ids[key] = node["DimensionId"]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
attr_accessor :id, :attributes, :snippets
|
42
|
+
|
43
|
+
def initialize(element_or_hash=nil)
|
44
|
+
@attributes = Attributes.new
|
45
|
+
super(element_or_hash)
|
46
|
+
end
|
47
|
+
|
48
|
+
def initialize_from_element!
|
49
|
+
@id = @element["Id"]
|
50
|
+
|
51
|
+
xpath("mdata:Attributes/mdata:AssignedDimensionValue | mdata:Attributes/mdata:Property").each do |attribute|
|
52
|
+
@attributes << attribute
|
53
|
+
end
|
54
|
+
|
55
|
+
@snippets = property_list("mdata:Snippets/mdata:Snippet")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'mdex_client/mdata/node'
|
2
|
+
|
3
|
+
module MDEXClient
|
4
|
+
module MData
|
5
|
+
class RefinementConfig < Node
|
6
|
+
attr_accessor :dimension_value_id, :maximum_dimension_value_count
|
7
|
+
attr_writer :expose, :limit_dimension_values, :order_by_record_count
|
8
|
+
|
9
|
+
def initialize_from_element!
|
10
|
+
@dimension_value_id = @element["DimensionValueId"].to_i
|
11
|
+
@expose = (@element["Expose"] == "true")
|
12
|
+
@limit_dimension_values = (@element["LimitDimensionValues"] == "true")
|
13
|
+
@order_by_record_count = (@element["OrderByRecordCount"] == "true")
|
14
|
+
|
15
|
+
if element["MaximumDimensionValueCount"]
|
16
|
+
@maximum_dimension_value_count = @element["MaximumDimensionValueCount"].to_i
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def expose?
|
21
|
+
@expose
|
22
|
+
end
|
23
|
+
|
24
|
+
def limit_dimension_values?
|
25
|
+
@limit_dimension_values
|
26
|
+
end
|
27
|
+
|
28
|
+
def order_by_record_count?
|
29
|
+
@order_by_record_count
|
30
|
+
end
|
31
|
+
|
32
|
+
def write_xml!(xml)
|
33
|
+
attrs = { "DimensionValueId" => dimension_value_id }
|
34
|
+
%w(Expose LimitDimensionValues OrderByRecordCount).each do |attribute|
|
35
|
+
value = self.send("#{attribute.underscore}?")
|
36
|
+
attrs[attribute] = value.to_s unless value.nil?
|
37
|
+
end
|
38
|
+
attrs["MaximumDimensionValueCount"] = maximum_dimension_value_count unless maximum_dimension_value_count.nil?
|
39
|
+
|
40
|
+
xml.mdata :RefinementConfig, attrs
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'mdex_client/mdata/node'
|
2
|
+
|
3
|
+
module MDEXClient
|
4
|
+
module MData
|
5
|
+
class Search < Node
|
6
|
+
MODES = %w(All AllAny AllPartial Any Boolean Partial PartialMax Unknown)
|
7
|
+
|
8
|
+
attr_accessor :key, :query, :relevance_ranking_strategy, :mode, :snippet_length,
|
9
|
+
:enable_snippeting
|
10
|
+
|
11
|
+
def write_xml!(xml)
|
12
|
+
attributes = { "Key" => key }
|
13
|
+
%w(RelevanceRankingStrategy Mode SnippetLength EnableSnippeting).each do |attribute|
|
14
|
+
value = send(attribute.underscore)
|
15
|
+
attributes[attribute] = value.to_s if value
|
16
|
+
end
|
17
|
+
|
18
|
+
xml.mdata :Search, attributes, query
|
19
|
+
end
|
20
|
+
|
21
|
+
def mode=(new_mode)
|
22
|
+
if new_mode.nil?
|
23
|
+
@mode = nil
|
24
|
+
else
|
25
|
+
new_mode_normalized = new_mode.to_s.classify
|
26
|
+
|
27
|
+
if MODES.include?(new_mode_normalized)
|
28
|
+
@mode = new_mode_normalized
|
29
|
+
else
|
30
|
+
raise "#{new_mode} is not a valid mode. Valid modes are: #{MODES.join(", ")}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'mdex_client/mdata/node'
|
2
|
+
|
3
|
+
module MDEXClient
|
4
|
+
module MData
|
5
|
+
class Sort < Node
|
6
|
+
attr_accessor :key, :direction, :reference_geocode
|
7
|
+
|
8
|
+
def initialize_from_element!
|
9
|
+
@key = element["Key"]
|
10
|
+
@direction = element["Direction"]
|
11
|
+
|
12
|
+
rgc = element.xpath("mdata:ReferenceGeocode").first
|
13
|
+
@reference_geocode = Geocode.new(rgc) if rgc
|
14
|
+
end
|
15
|
+
|
16
|
+
def write_xml!(xml)
|
17
|
+
xml.mdata :Sort, "Key" => key, "Direction" => direction do |xml|
|
18
|
+
if reference_geocode
|
19
|
+
xml.mdata :ReferenceGeocode, "Latitude" => reference_geocode.latitude,
|
20
|
+
"Longitude" => reference_geocode.longitude
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/mdex_client.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/mdex_client/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Nat Budin"]
|
6
|
+
gem.email = ["natbudin@gmail.com"]
|
7
|
+
gem.description = %q{A Rubyish API client for Endeca's MDEX search engine, using the XQuery API}
|
8
|
+
gem.summary = %q{Search client for Endeca MDEX engine}
|
9
|
+
gem.homepage = ""
|
10
|
+
|
11
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
12
|
+
gem.files = `git ls-files`.split("\n")
|
13
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
14
|
+
gem.name = "mdex_client"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = MDEXClient::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency "savon"
|
19
|
+
gem.add_dependency "nokogiri"
|
20
|
+
gem.add_development_dependency "rspec", "~> 2.6.0"
|
21
|
+
gem.add_development_dependency "rack", "~> 1.3.0"
|
22
|
+
gem.add_development_dependency "simplecov"
|
23
|
+
gem.add_development_dependency "simplecov-rcov"
|
24
|
+
gem.add_development_dependency "webmock", "~> 1.7.0"
|
25
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# SimpleCov needs to be started first
|
2
|
+
require 'simplecov'
|
3
|
+
require 'simplecov-rcov'
|
4
|
+
SimpleCov.formatter = SimpleCov::Formatter::RcovFormatter
|
5
|
+
SimpleCov.start do
|
6
|
+
add_filter '.bundle/'
|
7
|
+
end
|
8
|
+
|
9
|
+
# Set up webmock
|
10
|
+
require 'webmock/rspec'
|
11
|
+
|
12
|
+
RSpec.configure do |config|
|
13
|
+
# == Mock Framework
|
14
|
+
#
|
15
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
16
|
+
#
|
17
|
+
# config.mock_with :mocha
|
18
|
+
# config.mock_with :flexmock
|
19
|
+
# config.mock_with :rr
|
20
|
+
config.mock_with :rspec
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mdex_client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Nat Budin
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-05-30 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: savon
|
16
|
+
requirement: &70271123124680 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70271123124680
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: nokogiri
|
27
|
+
requirement: &70271123124260 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70271123124260
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rspec
|
38
|
+
requirement: &70271123123720 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ~>
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 2.6.0
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70271123123720
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rack
|
49
|
+
requirement: &70271123123040 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.3.0
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70271123123040
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: simplecov
|
60
|
+
requirement: &70271123122520 !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ! '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
type: :development
|
67
|
+
prerelease: false
|
68
|
+
version_requirements: *70271123122520
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov-rcov
|
71
|
+
requirement: &70271123121840 !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: *70271123121840
|
80
|
+
- !ruby/object:Gem::Dependency
|
81
|
+
name: webmock
|
82
|
+
requirement: &70271123121100 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ~>
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: 1.7.0
|
88
|
+
type: :development
|
89
|
+
prerelease: false
|
90
|
+
version_requirements: *70271123121100
|
91
|
+
description: A Rubyish API client for Endeca's MDEX search engine, using the XQuery
|
92
|
+
API
|
93
|
+
email:
|
94
|
+
- natbudin@gmail.com
|
95
|
+
executables: []
|
96
|
+
extensions: []
|
97
|
+
extra_rdoc_files: []
|
98
|
+
files:
|
99
|
+
- .gitignore
|
100
|
+
- Gemfile
|
101
|
+
- Rakefile
|
102
|
+
- lib/mdex_client.rb
|
103
|
+
- lib/mdex_client/active_record/extensions.rb
|
104
|
+
- lib/mdex_client/client.rb
|
105
|
+
- lib/mdex_client/fake_mdex.rb
|
106
|
+
- lib/mdex_client/fake_mdex/fake_mdex.rb
|
107
|
+
- lib/mdex_client/fake_mdex/mdex.wsdl
|
108
|
+
- lib/mdex_client/fake_mdex/mdex_response.xml
|
109
|
+
- lib/mdex_client/mdata/aggregate_record.rb
|
110
|
+
- lib/mdex_client/mdata/aggregation_key.rb
|
111
|
+
- lib/mdex_client/mdata/dimension.rb
|
112
|
+
- lib/mdex_client/mdata/dimension_value.rb
|
113
|
+
- lib/mdex_client/mdata/geocode.rb
|
114
|
+
- lib/mdex_client/mdata/navigation_query.rb
|
115
|
+
- lib/mdex_client/mdata/navigation_result.rb
|
116
|
+
- lib/mdex_client/mdata/node.rb
|
117
|
+
- lib/mdex_client/mdata/range_filter.rb
|
118
|
+
- lib/mdex_client/mdata/record.rb
|
119
|
+
- lib/mdex_client/mdata/refinement_config.rb
|
120
|
+
- lib/mdex_client/mdata/search.rb
|
121
|
+
- lib/mdex_client/mdata/sort.rb
|
122
|
+
- lib/mdex_client/version.rb
|
123
|
+
- mdex_client.gemspec
|
124
|
+
- spec/spec_helper.rb
|
125
|
+
homepage: ''
|
126
|
+
licenses: []
|
127
|
+
post_install_message:
|
128
|
+
rdoc_options: []
|
129
|
+
require_paths:
|
130
|
+
- lib
|
131
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
132
|
+
none: false
|
133
|
+
requirements:
|
134
|
+
- - ! '>='
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
|
+
none: false
|
139
|
+
requirements:
|
140
|
+
- - ! '>='
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
requirements: []
|
144
|
+
rubyforge_project:
|
145
|
+
rubygems_version: 1.8.10
|
146
|
+
signing_key:
|
147
|
+
specification_version: 3
|
148
|
+
summary: Search client for Endeca MDEX engine
|
149
|
+
test_files:
|
150
|
+
- spec/spec_helper.rb
|
151
|
+
has_rdoc:
|