transformator 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +43 -0
- data/assets/primo_search_response.xml +2878 -0
- data/assets/primo_search_response_1.xml +2467 -0
- data/examples/primo_search_response_transformation.rb +123 -0
- data/examples/search_request_transformation.rb +89 -0
- data/lib/transformator/dsl.rb +93 -0
- data/lib/transformator/format_converter/document_from_hash.rb +13 -0
- data/lib/transformator/format_converter/document_from_object.rb +20 -0
- data/lib/transformator/format_converter/document_from_xml.rb +28 -0
- data/lib/transformator/format_converter/hash_from_document.rb +61 -0
- data/lib/transformator/format_converter/xml_from_document.rb +7 -0
- data/lib/transformator/format_converter.rb +27 -0
- data/lib/transformator/transformation.rb +49 -23
- data/lib/transformator/version.rb +1 -1
- data/lib/transformator.rb +28 -0
- data/spec/examples/primo_search_response_transformation_spec.rb +19 -0
- data/spec/examples/search_request_transformation_spec.rb +48 -0
- data/spec/transformator/dsl_spec.rb +187 -0
- data/spec/transformator/format_converter/hash_from_document_spec.rb +42 -0
- data/spec/transformator/transformation_spec.rb +13 -159
- data/spec/transformator_spec.rb +8 -0
- data/transformator.gemspec +5 -2
- metadata +67 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0474274566563edf8f9f8cff236f3fdeff325375
|
4
|
+
data.tar.gz: 7d50aff06d3999b3e80cc8b50878d5f578093f5f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0c875a1285ffe4b1f726b3955a6acda7d87e5221d9d4325b626e6196e5aef1882e970e83ba4f613ee565bdfd8ecda83652babf3d748f934af50ff4a461f87a8b
|
7
|
+
data.tar.gz: fc94425c73d50d232e40053b2a0477193cd0077abe8c949748df62cf5f385a656bca2e29983ec4b5779415eb6062427e4b1427702c4e88c67d18282de35eba28
|
data/Rakefile
CHANGED
@@ -3,4 +3,47 @@ require "rspec/core/rake_task"
|
|
3
3
|
|
4
4
|
RSpec::Core::RakeTask.new(:spec)
|
5
5
|
|
6
|
+
task :benchmark do
|
7
|
+
require "benchmark/ips"
|
8
|
+
require "pry"
|
9
|
+
require_relative "./benchmark/primo_search_response_transformation"
|
10
|
+
require_relative "./lib/transformator"
|
11
|
+
|
12
|
+
Benchmark.ips do |bm|
|
13
|
+
bm.report("Transformator::Benchmark::PrimoSearchResponseTransformation") do
|
14
|
+
Transformator::Benchmark::PrimoSearchResponseTransformation.new.apply(
|
15
|
+
to: File.read(File.expand_path(File.join(File.dirname(__FILE__), "benchmark/primo_search_response_transformation/primo_response_1.xml"))),
|
16
|
+
output: :hash
|
17
|
+
)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
=begin
|
22
|
+
#
|
23
|
+
# document_from_xml
|
24
|
+
#
|
25
|
+
xml_file_name = File.join(File.dirname(__FILE__), "benchmark/primo_search_response_transformation/primo_response.xml")
|
26
|
+
outer_document = Transformator.document_from_xml(File.read(xml_file_name))
|
27
|
+
|
28
|
+
Benchmark.ips do |bm|
|
29
|
+
bm.report("Transformator.document_from_xml") do
|
30
|
+
Transformator.document_from_xml(outer_document.locate("*/searchBriefReturn").first.text)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
#
|
35
|
+
# hash_from_document
|
36
|
+
#
|
37
|
+
xml_file_name = File.join(File.dirname(__FILE__), "benchmark/primo_search_response_transformation/primo_response.xml")
|
38
|
+
outer_document = Transformator.document_from_xml(File.read(xml_file_name))
|
39
|
+
inner_document = Transformator.document_from_xml(outer_document.locate("*/searchBriefReturn").first.text)
|
40
|
+
|
41
|
+
Benchmark.ips do |bm|
|
42
|
+
bm.report("Transformator.hash_from_document") do
|
43
|
+
Transformator.hash_from_document(inner_document)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
=end
|
47
|
+
end
|
48
|
+
|
6
49
|
task :default => :spec
|