muhimbi 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ OTY1ZWJmMzZkYWM4YzlmMDdmZjY1ODk5NmI0YjA5NzRmN2Y0ZjQ1MQ==
5
+ data.tar.gz: !binary |-
6
+ YTc4ODFlY2FlNDk4NjQ5MzA3MjJlMDhkYmVlYzNmNzA5NGJlMzE1OQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ OGMwYzVmZTYzOGVkYjQ5NDE4ZGJiYTMzMTk1NTg5OWMwZDA1NDIwNmRhOTMy
10
+ MDJlM2Y3OGI5ZGU3NGU3N2M5NTY1MDFhZjBmYzEwMDFmYTQ0ZWRmNDVhYTQx
11
+ ZWU3MTc1ODVjODBkNzQwNWMwNzc4YTM2YTU3ZDkxMzk3NmIyMjU=
12
+ data.tar.gz: !binary |-
13
+ YTJmMjVkY2NiOWIwMzM5ZDQxM2JjNzFhNWY5MTRiMDk2ZTA3ZjJlZGI0Njlh
14
+ NTBjN2JmYzdmMjk4MDExZmMxZDZmNjkwZTNjNGFmNjAyMWFhODUzNThhZDI1
15
+ ZWExMjY4ODczMGVhMjZlYjdhZGY1NzIyMmRiZjg2NjljZWU0NDE=
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ spec/fixtures/config.yml
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
19
+
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in muhimbi.gemspec
4
+ gem "certified"
5
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 miguel michelson
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,31 @@
1
+ # Muhimbi
2
+
3
+ This library implements a client for interact with muhimbi services.
4
+
5
+ This gem uses savon library to interface services.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'muhimbi'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install muhimbi
20
+
21
+ ## Usage
22
+
23
+ TODO: Write usage instructions here
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,9 @@
1
+ require "muhimbi/version"
2
+ require 'savon'
3
+
4
+ module Muhimbi
5
+ autoload :VERSION, 'muhimbi/version.rb'
6
+ autoload :Config, 'muhimbi/config.rb'
7
+ autoload :Client, 'muhimbi/client.rb'
8
+ autoload :Converter, 'muhimbi/converter.rb'
9
+ end
@@ -0,0 +1,40 @@
1
+ require "active_support/core_ext/class/subclasses"
2
+
3
+ module Muhimbi
4
+ class Client
5
+
6
+ def self.client
7
+ Savon.client do
8
+ wsdl Muhimbi::Config.wsdl
9
+ namespaces(
10
+ "xmlns:ns" =>"http://services.muhimbi.com/2009/10/06",
11
+ "xmlns:ns1"=>"http://types.muhimbi.com/2009/10/06",
12
+ "xmlns:ns2"=>"http://types.muhimbi.com/2010/05/17"
13
+ )
14
+ namespace_identifier :ns
15
+ #element_form_default :qualified
16
+ env_namespace :soapenv
17
+ end
18
+ end
19
+
20
+ def self.get_configuration
21
+ wsdl_res = Muhimbi::Client.client.call(:get_configuration )
22
+ wsdl_res.to_hash[:get_configuration_response][:get_configuration_result]
23
+ end
24
+
25
+ def self.get_diagnostics(opts=[])
26
+
27
+ arr = []
28
+
29
+ opts.each do |opt|
30
+ arr << {"ns1:DiagnosticRequestItem"=> { "ns1:ConverterName" => opt }}
31
+ end
32
+
33
+ msg_options = {"ns:convertersToDiagnose"=> arr }
34
+
35
+ wsdl_res = Muhimbi::Client.client.call(:get_diagnostics, message: msg_options )
36
+ wsdl_res.to_hash[:get_diagnostics_response][:get_diagnostics_result]
37
+ end
38
+
39
+ end
40
+ end
@@ -0,0 +1,13 @@
1
+ require "active_support/core_ext/module/attribute_accessors"
2
+
3
+ module Muhimbi
4
+ class Config
5
+
6
+ def self.setup
7
+ yield self
8
+ end
9
+
10
+ mattr_accessor :wsdl
11
+
12
+ end
13
+ end
@@ -0,0 +1,71 @@
1
+ require "active_support/core_ext/class/subclasses"
2
+
3
+ module Muhimbi
4
+ class Converter
5
+
6
+ attr_accessor :file_content,
7
+ :file,
8
+ :options
9
+
10
+ def initialize(opts={})
11
+
12
+ unless opts[:file].blank?
13
+ self.file_content = encode_file(opts[:file])
14
+ self.file = opts[:file]
15
+ end
16
+
17
+ self.tap do |client|
18
+ client.options ||= {}
19
+ client.defaults_options(opts)
20
+ client.options ||= opts
21
+ yield client if block_given?
22
+ end
23
+
24
+ end
25
+
26
+ def convert
27
+ wsdl_res = Muhimbi::Client.client.call(:convert , message: self.options )
28
+ wsdl_res.to_hash[:convert_response][:convert_result]
29
+ end
30
+
31
+ def method_missing(meth, opts = {})
32
+ merge_options meth, opts
33
+ end
34
+
35
+ def defaults_options(opts={})
36
+
37
+ self.sourceFile(self.file_content)
38
+
39
+ self.openOptions({
40
+ "FileExtension" => File.extname( self.file ).gsub(".", ""),
41
+ "OriginalFileName"=> File.basename( self.file)
42
+ })
43
+
44
+ self.conversionSettings({
45
+ "Format"=> "PDF",
46
+ "Fidelity"=> "Full"
47
+ })
48
+ end
49
+
50
+ private
51
+
52
+ def allowed_methods
53
+ ["sourceFile", "openOptions", "conversionSettings"]
54
+ end
55
+
56
+ def merge_options(name, opts)
57
+ name = name.to_s.camelize(:lower)
58
+ @options.merge! "ns:#{name}" => redo_opts(opts) if allowed_methods.include?(name)
59
+ end
60
+
61
+ def redo_opts(opts)
62
+ return opts unless opts.class == Hash
63
+ Hash[opts.map {|k, v| ["ns1:#{k}", v] }]
64
+ end
65
+
66
+ def encode_file(file)
67
+ Base64.strict_encode64(file.read)
68
+ end
69
+
70
+ end
71
+ end
@@ -0,0 +1,3 @@
1
+ module Muhimbi
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,30 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'muhimbi/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "muhimbi"
8
+ spec.version = Muhimbi::VERSION
9
+ spec.authors = ["miguel michelson"]
10
+ spec.email = ["miguelmichelson@gmail.com"]
11
+ spec.description = %q{Muhimbi Ruby Client}
12
+ spec.summary = %q{Muhimbi client}
13
+ spec.homepage = "http://github.com/michelson/muhimbi"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+
24
+ spec.add_development_dependency "rspec"
25
+ spec.add_development_dependency "pry"
26
+ spec.add_development_dependency "debugger"
27
+
28
+ spec.add_dependency "activesupport"
29
+ spec.add_dependency "savon"
30
+ end
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,41 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '../../spec_helper')
2
+
3
+ describe "Client class" do
4
+ before(:all) do
5
+ Muhimbi::Config.setup do |config|
6
+ config.wsdl = config_options["wsdl"]
7
+ end
8
+ @client = Muhimbi::Client.client
9
+ end
10
+
11
+ it "savon client" do
12
+ @client.class.should == Savon::Client
13
+ end
14
+
15
+ it "should have operations" do
16
+ @client.operations.class.should == Array
17
+ end
18
+
19
+ it "operations should include to convert" do
20
+ @client.operations.include?(:convert).should be_true
21
+ end
22
+
23
+ context "Get Configuration" do
24
+ before :each do
25
+ @client = Muhimbi::Client
26
+ end
27
+ it "get_configuration" do
28
+ @client.get_configuration.should_not be_blank
29
+ @client.get_configuration.keys.should include(:conversion_server_address)
30
+ end
31
+ end
32
+
33
+ context "Get Diagnostics" do
34
+ before :each do
35
+ @client = Muhimbi::Client
36
+ end
37
+ it "get_diagnostics" do
38
+ @client.get_diagnostics(["WordProcessing", "InfoPath"]).should_not be_blank
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,15 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '../../spec_helper')
2
+
3
+ describe "Config class" do
4
+ before(:all) do
5
+
6
+ Muhimbi::Config.setup do |config|
7
+ config.wsdl = config_options["wsdl"]
8
+ end
9
+ end
10
+
11
+ it "should have all the required keys" do
12
+ Muhimbi::Config.wsdl.should_not be_empty
13
+ end
14
+
15
+ end
@@ -0,0 +1,27 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '../../spec_helper')
2
+
3
+ describe "Converter" do
4
+ before(:all) do
5
+ Muhimbi::Config.setup do |config|
6
+ config.wsdl = config_options["wsdl"]
7
+ end
8
+ @client = Muhimbi::Client.client
9
+ end
10
+
11
+ context "conversion" do
12
+ before :each do
13
+ @file = File.open(File.dirname(__FILE__) + "/../fixtures/doc.doc")
14
+ @client = Muhimbi::Converter.new(file: @file)
15
+ @response = @client.convert
16
+ end
17
+
18
+ it "file should exists" do
19
+ File.exist?(@file).should be_true
20
+ end
21
+
22
+ it "client" do
23
+ @response.should_not be_blank
24
+ end
25
+ end
26
+
27
+ end
@@ -0,0 +1,27 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ require 'rspec'
3
+ require 'debugger'
4
+ require File.join(File.dirname(__FILE__), '../lib', 'muhimbi')
5
+ require 'stringio'
6
+ require "pry"
7
+
8
+ RSpec.configure do |config|
9
+
10
+ def fixture_key(filename)
11
+ File.dirname(__FILE__) + "/fixtures/#{filename}"
12
+ end
13
+
14
+ def config_options
15
+ config = YAML.load( File.open(fixture_key("config.yml")) )
16
+ return config
17
+ end
18
+
19
+ def config_setup
20
+ Ruby::Muhimbi::Config.setup do |config|
21
+ config.wsdl = config_options["wsdl"]
22
+ end
23
+ Ruby::Muhimbi::Config
24
+ end
25
+
26
+ end
27
+
metadata ADDED
@@ -0,0 +1,169 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: muhimbi
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - miguel michelson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-05-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: pry
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: debugger
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: activesupport
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: savon
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ! '>='
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Muhimbi Ruby Client
112
+ email:
113
+ - miguelmichelson@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - .gitignore
119
+ - Gemfile
120
+ - LICENSE.txt
121
+ - README.md
122
+ - Rakefile
123
+ - lib/muhimbi.rb
124
+ - lib/muhimbi/client.rb
125
+ - lib/muhimbi/config.rb
126
+ - lib/muhimbi/converter.rb
127
+ - lib/muhimbi/version.rb
128
+ - muhimbi.gemspec
129
+ - spec/.DS_Store
130
+ - spec/fixtures/doc.doc
131
+ - spec/fixtures/doc.docx
132
+ - spec/fixtures/image.jpeg
133
+ - spec/functional/client_spec.rb
134
+ - spec/functional/config_spec.rb
135
+ - spec/functional/converter_spec.rb
136
+ - spec/spec_helper.rb
137
+ homepage: http://github.com/michelson/muhimbi
138
+ licenses:
139
+ - MIT
140
+ metadata: {}
141
+ post_install_message:
142
+ rdoc_options: []
143
+ require_paths:
144
+ - lib
145
+ required_ruby_version: !ruby/object:Gem::Requirement
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ required_rubygems_version: !ruby/object:Gem::Requirement
151
+ requirements:
152
+ - - ! '>='
153
+ - !ruby/object:Gem::Version
154
+ version: '0'
155
+ requirements: []
156
+ rubyforge_project:
157
+ rubygems_version: 2.0.3
158
+ signing_key:
159
+ specification_version: 4
160
+ summary: Muhimbi client
161
+ test_files:
162
+ - spec/.DS_Store
163
+ - spec/fixtures/doc.doc
164
+ - spec/fixtures/doc.docx
165
+ - spec/fixtures/image.jpeg
166
+ - spec/functional/client_spec.rb
167
+ - spec/functional/config_spec.rb
168
+ - spec/functional/converter_spec.rb
169
+ - spec/spec_helper.rb