nsi-lapesi 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +2 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +54 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +19 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/lib/nsi-lapesi.rb +8 -0
- data/lib/nsi-lapesi/configuration.rb +29 -0
- data/lib/nsi-lapesi/errors.rb +6 -0
- data/lib/nsi-lapesi/fake_server.rb +21 -0
- data/lib/nsi-lapesi/indexer.rb +61 -0
- data/lib/nsi-lapesi/searcher.rb +26 -0
- data/nsi-lapesi.gemspec +82 -0
- data/spec/configuration_spec.rb +37 -0
- data/spec/indexer_spec.rb +37 -0
- data/spec/resources/debian.jpg +0 -0
- data/spec/spec_helper.rb +13 -0
- metadata +213 -0
data/.document
ADDED
data/.rspec
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
|
3
|
+
gem 'builder'
|
4
|
+
gem 'libxml-xmlrpc'
|
5
|
+
gem 'xml-simple'
|
6
|
+
|
7
|
+
group :test, :development do
|
8
|
+
gem "rspec", "~> 2.8.0"
|
9
|
+
gem "rdoc", "~> 3.12"
|
10
|
+
gem "bundler", "~> 1.2.1"
|
11
|
+
gem "jeweler", "~> 1.8.3"
|
12
|
+
gem "simplecov"
|
13
|
+
gem "debugger"
|
14
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
builder (3.1.3)
|
5
|
+
columnize (0.3.6)
|
6
|
+
debugger (1.2.0)
|
7
|
+
columnize (>= 0.3.1)
|
8
|
+
debugger-linecache (~> 1.1.1)
|
9
|
+
debugger-ruby_core_source (~> 1.1.3)
|
10
|
+
debugger-linecache (1.1.2)
|
11
|
+
debugger-ruby_core_source (>= 1.1.1)
|
12
|
+
debugger-ruby_core_source (1.1.3)
|
13
|
+
diff-lcs (1.1.3)
|
14
|
+
git (1.2.5)
|
15
|
+
jeweler (1.8.4)
|
16
|
+
bundler (~> 1.0)
|
17
|
+
git (>= 1.2.5)
|
18
|
+
rake
|
19
|
+
rdoc
|
20
|
+
json (1.7.5)
|
21
|
+
libxml-ruby (2.3.3)
|
22
|
+
libxml-xmlrpc (0.1.5)
|
23
|
+
libxml-ruby (> 0.0.0)
|
24
|
+
multi_json (1.3.6)
|
25
|
+
rake (0.9.2.2)
|
26
|
+
rdoc (3.12)
|
27
|
+
json (~> 1.4)
|
28
|
+
rspec (2.8.0)
|
29
|
+
rspec-core (~> 2.8.0)
|
30
|
+
rspec-expectations (~> 2.8.0)
|
31
|
+
rspec-mocks (~> 2.8.0)
|
32
|
+
rspec-core (2.8.0)
|
33
|
+
rspec-expectations (2.8.0)
|
34
|
+
diff-lcs (~> 1.1.2)
|
35
|
+
rspec-mocks (2.8.0)
|
36
|
+
simplecov (0.6.4)
|
37
|
+
multi_json (~> 1.0)
|
38
|
+
simplecov-html (~> 0.5.3)
|
39
|
+
simplecov-html (0.5.3)
|
40
|
+
xml-simple (1.1.1)
|
41
|
+
|
42
|
+
PLATFORMS
|
43
|
+
ruby
|
44
|
+
|
45
|
+
DEPENDENCIES
|
46
|
+
builder
|
47
|
+
bundler (~> 1.2.1)
|
48
|
+
debugger
|
49
|
+
jeweler (~> 1.8.3)
|
50
|
+
libxml-xmlrpc
|
51
|
+
rdoc (~> 3.12)
|
52
|
+
rspec (~> 2.8.0)
|
53
|
+
simplecov
|
54
|
+
xml-simple
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2012 Pedro Henrique Linhares
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= nsi-lapesi
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Contributing to nsi-lapesi
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
9
|
+
* Fork the project.
|
10
|
+
* Start a feature/bugfix branch.
|
11
|
+
* Commit and push until you are happy with your contribution.
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2012 Pedro Henrique Linhares. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "nsi-lapesi"
|
18
|
+
gem.homepage = "http://github.com/pedrolinhares/nsi-lapesi"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Gem de acesso ao servico Lapesi}
|
21
|
+
gem.description = %Q{Gem de acesso ao servico Lapesi}
|
22
|
+
gem.email = "pedrolmota@gmail.com"
|
23
|
+
gem.authors = ["Pedro Henrique Linhares"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
35
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
36
|
+
spec.rcov = true
|
37
|
+
end
|
38
|
+
|
39
|
+
task :default => :spec
|
40
|
+
|
41
|
+
require 'rdoc/task'
|
42
|
+
Rake::RDocTask.new do |rdoc|
|
43
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
|
+
|
45
|
+
rdoc.rdoc_dir = 'rdoc'
|
46
|
+
rdoc.title = "nsi-lapesi #{version}"
|
47
|
+
rdoc.rdoc_files.include('README*')
|
48
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/lib/nsi-lapesi.rb
ADDED
@@ -0,0 +1,8 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/nsi-lapesi/indexer'
|
2
|
+
require File.dirname(__FILE__) + '/nsi-lapesi/configuration'
|
3
|
+
require File.dirname(__FILE__) + '/nsi-lapesi/errors'
|
4
|
+
require File.dirname(__FILE__) + '/nsi-lapesi/fake_server'
|
5
|
+
require File.dirname(__FILE__) + '/nsi-lapesi/searcher'
|
6
|
+
|
7
|
+
module NSILapesi
|
8
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module NSILapesi
|
2
|
+
class Configuration
|
3
|
+
class << self
|
4
|
+
def host(host = nil)
|
5
|
+
@host = host unless host.nil?
|
6
|
+
@host
|
7
|
+
end
|
8
|
+
|
9
|
+
def port(port = nil)
|
10
|
+
@port = port unless port.nil?
|
11
|
+
@port
|
12
|
+
end
|
13
|
+
|
14
|
+
def path(path = nil)
|
15
|
+
@path = path unless path.nil?
|
16
|
+
@path
|
17
|
+
end
|
18
|
+
|
19
|
+
def configure
|
20
|
+
yield self if block_given?
|
21
|
+
settings
|
22
|
+
end
|
23
|
+
|
24
|
+
def settings
|
25
|
+
{host: @host, port: @port, path: @path}
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "xmlrpc/server"
|
2
|
+
|
3
|
+
module NSILapesi
|
4
|
+
class FakeServer
|
5
|
+
def addImage(contract, image)
|
6
|
+
100
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.start
|
10
|
+
@thread = Thread.new do
|
11
|
+
server = XMLRPC::Server.new(8080)
|
12
|
+
server.add_handler("ImageIndexer", NSILapesi::FakeServer.new)
|
13
|
+
server.serve
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.stop
|
18
|
+
@thread.kill
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'builder'
|
2
|
+
require 'xmlrpc/client'
|
3
|
+
|
4
|
+
require File.dirname(__FILE__) + '/configuration'
|
5
|
+
require File.dirname(__FILE__) + '/errors'
|
6
|
+
|
7
|
+
module NSILapesi
|
8
|
+
class Indexer
|
9
|
+
|
10
|
+
MIMETYPES = ['jpeg', 'jpg']
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
params = Configuration.settings
|
14
|
+
@server = XMLRPC::Client.new(params[:host], params[:path], params[:port])
|
15
|
+
end
|
16
|
+
|
17
|
+
def add_image(params = {})
|
18
|
+
params = {image: '', id: '', author: 'Lapesi', title: 'LapesiImage', format: 'jpg',
|
19
|
+
type: 'Artigo', keywords: ['lapesi'], publicationdate: ''}.merge(params)
|
20
|
+
|
21
|
+
image = params.delete(:image)
|
22
|
+
contract = create_xml_contract params
|
23
|
+
|
24
|
+
raise Errors::ImageFormatNotSupported if not MIMETYPES.include? params[:format]
|
25
|
+
|
26
|
+
begin
|
27
|
+
image_content = (image.class == String)? image : image.read
|
28
|
+
status_code = @server.call("ImageIndexer.addImage", XMLRPC::Base64.new(contract),
|
29
|
+
XMLRPC::Base64.new(image_content))
|
30
|
+
rescue Exception
|
31
|
+
status_code = 111
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def del_image(id)
|
36
|
+
begin
|
37
|
+
status_code = @server.call("ImageIndexer.delImage", id)
|
38
|
+
rescue Exception
|
39
|
+
status_code = 111
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def create_xml_contract(params = {})
|
46
|
+
params[:publicationdate] = Time.now.strftime("%d/%m/%Y") if params[:publicationdate].empty?
|
47
|
+
|
48
|
+
contract = Builder::XmlMarkup.new(indent: 2)
|
49
|
+
contract.instruct! :xml, :encoding => "iso-8859-1"
|
50
|
+
contract.document do |doc|
|
51
|
+
doc.tag!(:id, params[:id])
|
52
|
+
doc.tag!(:author, params[:author])
|
53
|
+
doc.tag!(:title, params[:title])
|
54
|
+
doc.tag!('publication-date', params[:publicationdate])
|
55
|
+
doc.tag!(:format, params[:format])
|
56
|
+
doc.tag!(:type, params[:type])
|
57
|
+
doc.tag!(:keywords, params[:keywords].join(', '))
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'xmlsimple'
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/configuration'
|
4
|
+
require File.dirname(__FILE__) + '/errors'
|
5
|
+
|
6
|
+
module NSILapesi
|
7
|
+
class Searcher
|
8
|
+
def initialize
|
9
|
+
params = Configuration.settings
|
10
|
+
@server = XMLRPC::Client.new(params[:host], params[:path], params[:port])
|
11
|
+
end
|
12
|
+
|
13
|
+
def search_image(image, limit = 5)
|
14
|
+
image_content = image.read
|
15
|
+
|
16
|
+
results_xml = @server.call("ImageSearcher.searchImage", XMLRPC::Base64.new(image_content), limit)
|
17
|
+
results = XmlSimple.xml_in results_xml
|
18
|
+
|
19
|
+
if results['code'] == '100'
|
20
|
+
results['item']
|
21
|
+
else
|
22
|
+
[]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/nsi-lapesi.gemspec
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "nsi-lapesi"
|
8
|
+
s.version = "0.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Pedro Henrique Linhares"]
|
12
|
+
s.date = "2012-10-19"
|
13
|
+
s.description = "Gem de acesso ao servico Lapesi"
|
14
|
+
s.email = "pedrolmota@gmail.com"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"LICENSE.txt",
|
17
|
+
"README.rdoc"
|
18
|
+
]
|
19
|
+
s.files = [
|
20
|
+
".document",
|
21
|
+
".rspec",
|
22
|
+
"Gemfile",
|
23
|
+
"Gemfile.lock",
|
24
|
+
"LICENSE.txt",
|
25
|
+
"README.rdoc",
|
26
|
+
"Rakefile",
|
27
|
+
"VERSION",
|
28
|
+
"lib/nsi-lapesi.rb",
|
29
|
+
"lib/nsi-lapesi/configuration.rb",
|
30
|
+
"lib/nsi-lapesi/errors.rb",
|
31
|
+
"lib/nsi-lapesi/fake_server.rb",
|
32
|
+
"lib/nsi-lapesi/indexer.rb",
|
33
|
+
"lib/nsi-lapesi/searcher.rb",
|
34
|
+
"nsi-lapesi.gemspec",
|
35
|
+
"spec/configuration_spec.rb",
|
36
|
+
"spec/indexer_spec.rb",
|
37
|
+
"spec/resources/debian.jpg",
|
38
|
+
"spec/spec_helper.rb"
|
39
|
+
]
|
40
|
+
s.homepage = "http://github.com/pedrolinhares/nsi-lapesi"
|
41
|
+
s.licenses = ["MIT"]
|
42
|
+
s.require_paths = ["lib"]
|
43
|
+
s.rubygems_version = "1.8.24"
|
44
|
+
s.summary = "Gem de acesso ao servico Lapesi"
|
45
|
+
|
46
|
+
if s.respond_to? :specification_version then
|
47
|
+
s.specification_version = 3
|
48
|
+
|
49
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
50
|
+
s.add_runtime_dependency(%q<builder>, [">= 0"])
|
51
|
+
s.add_runtime_dependency(%q<libxml-xmlrpc>, [">= 0"])
|
52
|
+
s.add_runtime_dependency(%q<xml-simple>, [">= 0"])
|
53
|
+
s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
|
54
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
55
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.2.1"])
|
56
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.3"])
|
57
|
+
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
58
|
+
s.add_development_dependency(%q<debugger>, [">= 0"])
|
59
|
+
else
|
60
|
+
s.add_dependency(%q<builder>, [">= 0"])
|
61
|
+
s.add_dependency(%q<libxml-xmlrpc>, [">= 0"])
|
62
|
+
s.add_dependency(%q<xml-simple>, [">= 0"])
|
63
|
+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
64
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
65
|
+
s.add_dependency(%q<bundler>, ["~> 1.2.1"])
|
66
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
67
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
68
|
+
s.add_dependency(%q<debugger>, [">= 0"])
|
69
|
+
end
|
70
|
+
else
|
71
|
+
s.add_dependency(%q<builder>, [">= 0"])
|
72
|
+
s.add_dependency(%q<libxml-xmlrpc>, [">= 0"])
|
73
|
+
s.add_dependency(%q<xml-simple>, [">= 0"])
|
74
|
+
s.add_dependency(%q<rspec>, ["~> 2.8.0"])
|
75
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
76
|
+
s.add_dependency(%q<bundler>, ["~> 1.2.1"])
|
77
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.3"])
|
78
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
79
|
+
s.add_dependency(%q<debugger>, [">= 0"])
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "NSILapesi::Configuration" do
|
4
|
+
Configuration = NSILapesi::Configuration
|
5
|
+
|
6
|
+
it 'sets server host' do
|
7
|
+
Configuration.host 'localhost'
|
8
|
+
Configuration.instance_variable_get(:@host).should == 'localhost'
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'sets server port' do
|
12
|
+
Configuration.port '8080'
|
13
|
+
Configuration.instance_variable_get(:@port).should == '8080'
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'sets server path' do
|
17
|
+
Configuration.path '/serverpath/'
|
18
|
+
Configuration.instance_variable_get(:@path).should == '/serverpath/'
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'settings returns hash with configurations' do
|
22
|
+
Configuration.host 'localhost'
|
23
|
+
Configuration.port '80'
|
24
|
+
Configuration.path '/path/'
|
25
|
+
Configuration.settings.should == {host: 'localhost', port: '80', path: '/path/'}
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'configure method receives a block to define configurations parameters' do
|
29
|
+
Configuration.configure do |conf|
|
30
|
+
conf.host 'localhost'
|
31
|
+
conf.port '80'
|
32
|
+
conf.path '/path/'
|
33
|
+
end
|
34
|
+
|
35
|
+
Configuration.settings.should == {host: 'localhost', port: '80', path: '/path/'}
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
|
+
|
3
|
+
describe "NsiLapesi::Indexer" do
|
4
|
+
|
5
|
+
before(:each) do
|
6
|
+
NSILapesi::Configuration.configure do |conf|
|
7
|
+
conf.host 'localhost'
|
8
|
+
conf.port 8080
|
9
|
+
conf.path '/'
|
10
|
+
end
|
11
|
+
|
12
|
+
@indexer = NSILapesi::Indexer.new
|
13
|
+
NSILapesi::FakeServer.start
|
14
|
+
sleep(1)
|
15
|
+
end
|
16
|
+
|
17
|
+
after(:all) do
|
18
|
+
NSILapesi::FakeServer.stop
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'can add an image to lapesi' do
|
22
|
+
img = File.open('spec/resources/debian.jpg')
|
23
|
+
code = @indexer.add_image(image: img, id: '1', author: 'Foo',
|
24
|
+
title: 'BarFoo', format: 'jpg',
|
25
|
+
type: 'Artigo', keywords: ['teste'])
|
26
|
+
code.should == 100
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should create xml contract' do
|
30
|
+
hoje = Time.now.strftime("%d/%m/%Y")
|
31
|
+
expected_contract = %[<?xml version="1.0" encoding="iso-8859-1"?>\n<document>\n <id>1</id>\n <author>Foo</author>\n <title>BarFoo</title>\n <publication-date>#{hoje}</publication-date>\n <format>jpg</format>\n <type>Artigo</type>\n <keywords>teste</keywords>\n</document>\n]
|
32
|
+
contract = @indexer.send(:create_xml_contract, id: '1', author: 'Foo',
|
33
|
+
title: 'BarFoo', format: 'jpg', type: 'Artigo',
|
34
|
+
publicationdate: '', keywords: ['teste'])
|
35
|
+
contract.should == expected_contract
|
36
|
+
end
|
37
|
+
end
|
Binary file
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
|
+
require 'rspec'
|
4
|
+
require 'nsi-lapesi'
|
5
|
+
require 'debugger'
|
6
|
+
|
7
|
+
# Requires supporting files with custom matchers and macros, etc,
|
8
|
+
# in ./support/ and its subdirectories.
|
9
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
10
|
+
|
11
|
+
RSpec.configure do |config|
|
12
|
+
|
13
|
+
end
|
metadata
ADDED
@@ -0,0 +1,213 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nsi-lapesi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Pedro Henrique Linhares
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-10-19 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: builder
|
16
|
+
requirement: !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: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: libxml-xmlrpc
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: xml-simple
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rspec
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 2.8.0
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 2.8.0
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rdoc
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '3.12'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '3.12'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: bundler
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 1.2.1
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: 1.2.1
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: jeweler
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ~>
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 1.8.3
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ~>
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: 1.8.3
|
126
|
+
- !ruby/object:Gem::Dependency
|
127
|
+
name: simplecov
|
128
|
+
requirement: !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ! '>='
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
version: '0'
|
134
|
+
type: :development
|
135
|
+
prerelease: false
|
136
|
+
version_requirements: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
- !ruby/object:Gem::Dependency
|
143
|
+
name: debugger
|
144
|
+
requirement: !ruby/object:Gem::Requirement
|
145
|
+
none: false
|
146
|
+
requirements:
|
147
|
+
- - ! '>='
|
148
|
+
- !ruby/object:Gem::Version
|
149
|
+
version: '0'
|
150
|
+
type: :development
|
151
|
+
prerelease: false
|
152
|
+
version_requirements: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
description: Gem de acesso ao servico Lapesi
|
159
|
+
email: pedrolmota@gmail.com
|
160
|
+
executables: []
|
161
|
+
extensions: []
|
162
|
+
extra_rdoc_files:
|
163
|
+
- LICENSE.txt
|
164
|
+
- README.rdoc
|
165
|
+
files:
|
166
|
+
- .document
|
167
|
+
- .rspec
|
168
|
+
- Gemfile
|
169
|
+
- Gemfile.lock
|
170
|
+
- LICENSE.txt
|
171
|
+
- README.rdoc
|
172
|
+
- Rakefile
|
173
|
+
- VERSION
|
174
|
+
- lib/nsi-lapesi.rb
|
175
|
+
- lib/nsi-lapesi/configuration.rb
|
176
|
+
- lib/nsi-lapesi/errors.rb
|
177
|
+
- lib/nsi-lapesi/fake_server.rb
|
178
|
+
- lib/nsi-lapesi/indexer.rb
|
179
|
+
- lib/nsi-lapesi/searcher.rb
|
180
|
+
- nsi-lapesi.gemspec
|
181
|
+
- spec/configuration_spec.rb
|
182
|
+
- spec/indexer_spec.rb
|
183
|
+
- spec/resources/debian.jpg
|
184
|
+
- spec/spec_helper.rb
|
185
|
+
homepage: http://github.com/pedrolinhares/nsi-lapesi
|
186
|
+
licenses:
|
187
|
+
- MIT
|
188
|
+
post_install_message:
|
189
|
+
rdoc_options: []
|
190
|
+
require_paths:
|
191
|
+
- lib
|
192
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
193
|
+
none: false
|
194
|
+
requirements:
|
195
|
+
- - ! '>='
|
196
|
+
- !ruby/object:Gem::Version
|
197
|
+
version: '0'
|
198
|
+
segments:
|
199
|
+
- 0
|
200
|
+
hash: -1326426549261268832
|
201
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
202
|
+
none: false
|
203
|
+
requirements:
|
204
|
+
- - ! '>='
|
205
|
+
- !ruby/object:Gem::Version
|
206
|
+
version: '0'
|
207
|
+
requirements: []
|
208
|
+
rubyforge_project:
|
209
|
+
rubygems_version: 1.8.24
|
210
|
+
signing_key:
|
211
|
+
specification_version: 3
|
212
|
+
summary: Gem de acesso ao servico Lapesi
|
213
|
+
test_files: []
|