wirecardmapper 0.0.1

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/LICENSE ADDED
@@ -0,0 +1,3 @@
1
+ == wirecardmapper
2
+
3
+ Put appropriate LICENSE for your project here.
data/README.rdoc ADDED
@@ -0,0 +1,21 @@
1
+ = Wirecardmapper
2
+
3
+ A Ruby Object Mapper for Wirecard XML interface
4
+
5
+ == Note on Patches/Pull Requests
6
+
7
+ * Fork the project.
8
+ * Make your feature addition or bug fix.
9
+ * Add tests for it. This is important so I don't break it in a future version unintentionally.
10
+ * Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself in another branch so I can ignore when I pull)
11
+ * Send me a pull request. Bonus points for topic branches.
12
+
13
+ == Install
14
+
15
+ $ gem install wirecardmapper
16
+
17
+ == Problems or Questions?
18
+
19
+ == Copyright
20
+
21
+ See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,60 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'rake/clean'
4
+ require 'rake/gempackagetask'
5
+ require 'rake/rdoctask'
6
+ require 'rake/testtask'
7
+ require 'spec/rake/spectask'
8
+
9
+ require File.expand_path('../lib/wirecardmapper/version', __FILE__)
10
+
11
+ spec = Gem::Specification.new do |s|
12
+ s.name = 'wirecardmapper'
13
+ s.homepage = 'http://github.com/aklaiber/wirecardmapper'
14
+ s.version = WirecardMapper::Version
15
+ s.has_rdoc = false
16
+ s.extra_rdoc_files = ['README.rdoc', 'LICENSE']
17
+ s.summary = 'A Ruby Object Mapper for Wirecard XML interface'
18
+ s.description = s.summary
19
+ s.author = 'Alexander Klaiber'
20
+ s.email = 'alex.klaiber@gmail.com'
21
+ # s.executables = ['your_executable_here']
22
+ s.files = %w(LICENSE README.rdoc Rakefile) + Dir.glob("{lib,spec}/**/*")
23
+ s.require_path = "lib"
24
+ # s.bindir = "bin"
25
+
26
+ s.add_dependency 'nokogiri', '>= 1.4.2'
27
+ s.add_dependency 'uuid', '>= 2.3.1'
28
+ end
29
+
30
+ Rake::GemPackageTask.new(spec) do |p|
31
+ p.gem_spec = spec
32
+ p.need_tar = true
33
+ p.need_zip = true
34
+ end
35
+
36
+ Rake::RDocTask.new do |rdoc|
37
+ files =['README.rdoc', 'LICENSE', 'lib/**/*.rb']
38
+ rdoc.rdoc_files.add(files)
39
+ rdoc.main = "README.rdoc" # page to start on
40
+ rdoc.title = "wirecardmapper Docs"
41
+ rdoc.rdoc_dir = 'doc/rdoc' # rdoc output folder
42
+ rdoc.options << '--line-numbers'
43
+ end
44
+
45
+ #Rake::TestTask.new do |t|
46
+ # t.test_files = FileList['test/**/*.rb']
47
+ #end
48
+
49
+ Spec::Rake::SpecTask.new do |t|
50
+ t.spec_files = FileList['spec/**/*.rb']
51
+ t.libs << Dir["lib"]
52
+ end
53
+
54
+ desc 'Tags version, pushes to remote, and pushes gem'
55
+ task :release => [:spec, :gem] do
56
+ sh "git tag v#{WirecardMapper::Version}"
57
+ sh "git push origin master"
58
+ sh "git push origin v#{WirecardMapper::Version}"
59
+ sh "gem push pkg/wirecardmapper-#{WirecardMapper::Version}.gem"
60
+ end
@@ -0,0 +1,7 @@
1
+ require 'nokogiri'
2
+ require 'uuid'
3
+
4
+ module WirecardMapper
5
+ autoload :Config, 'wirecardmapper/config'
6
+ autoload :Model, 'wirecardmapper/model'
7
+ end
@@ -0,0 +1,14 @@
1
+ module WirecardMapper
2
+ module Config
3
+
4
+ class << self
5
+ attr_accessor :mode, :entity_id
6
+ attr_writer :templates_path
7
+ end
8
+
9
+ def self.templates_path
10
+ @templates_path ||= "templates/"
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,38 @@
1
+ module WirecardMapper
2
+ module Model
3
+
4
+ def request_id
5
+ UUID.generate
6
+ end
7
+
8
+ def open_xml(file_name)
9
+ xml_file = File.open(File.join(Config.templates_path, file_name))
10
+ if xml_file
11
+ return Nokogiri::XML(xml_file)
12
+ end
13
+ end
14
+
15
+ def main_xml
16
+ xml = open_xml('main.xml')
17
+ if xml
18
+ xml.at_css("issuer-request")['mode'] = Config.mode
19
+ xml.at_css("request-id").content = self.request_id
20
+ xml.at_css("entity-id").content = Config.entity_id
21
+ end
22
+ return xml
23
+ end
24
+
25
+ def get_cardinfo_xml
26
+ main_xml = self.main_xml
27
+ if main_xml
28
+ xml = open_xml('get_card_info.xml')
29
+ if xml
30
+ xml.at_css("card-id").content = self.card_id
31
+ main_xml.at_css('issuer-request').add_child(xml.at('get-card-info'))
32
+ end
33
+ end
34
+ return main_xml
35
+ end
36
+
37
+ end
38
+ end
@@ -0,0 +1,3 @@
1
+ module WirecardMapper
2
+ Version = '0.0.1'
3
+ end
@@ -0,0 +1,16 @@
1
+ require 'rubygems'
2
+
3
+ $:.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
4
+ require 'wirecardmapper'
5
+
6
+ def Model(name=nil, &block)
7
+ klass = Class.new do
8
+ extend WirecardMapper::Model
9
+ end
10
+
11
+ klass.class_eval(&block) if block_given?
12
+ klass
13
+ end
14
+
15
+ WirecardMapper::Config.mode = "test"
16
+ WirecardMapper::Config.entity_id = "Test entity id"
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ describe "RSpec Greeter" do
4
+
5
+ before(:each) do
6
+ @model = Model do
7
+ class << self
8
+ def card_id
9
+ 1234
10
+ end
11
+ end
12
+ end
13
+ end
14
+
15
+ it "should get main xml" do
16
+ xml = @model.main_xml
17
+ xml.at_css("issuer-request")['mode'].should eql('test')
18
+ xml.at_css("entity-id").content.to_s.should eql('Test entity id')
19
+ xml.at_css("request-id").content.to_s.should_not be_empty
20
+ end
21
+
22
+ it "should get get_cardinfo xml" do
23
+ xml = @model.get_cardinfo_xml
24
+ xml.at_css("issuer-request")['mode'].should eql('test')
25
+ xml.at_css("entity-id").content.to_s.should eql('Test entity id')
26
+ xml.at_css("request-id").content.to_s.should_not be_empty
27
+ xml.at_css("card-id").content.to_i.should eql(@model.card_id)
28
+ end
29
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wirecardmapper
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Alexander Klaiber
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-07-29 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: nokogiri
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 1
32
+ - 4
33
+ - 2
34
+ version: 1.4.2
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: uuid
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 1
46
+ segments:
47
+ - 2
48
+ - 3
49
+ - 1
50
+ version: 2.3.1
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ description: A Ruby Object Mapper for Wirecard XML interface
54
+ email: alex.klaiber@gmail.com
55
+ executables: []
56
+
57
+ extensions: []
58
+
59
+ extra_rdoc_files:
60
+ - README.rdoc
61
+ - LICENSE
62
+ files:
63
+ - LICENSE
64
+ - README.rdoc
65
+ - Rakefile
66
+ - lib/wirecardmapper/model.rb
67
+ - lib/wirecardmapper/version.rb
68
+ - lib/wirecardmapper/config.rb
69
+ - lib/wirecardmapper.rb
70
+ - spec/spec_helper.rb
71
+ - spec/unit/new_main.rb
72
+ has_rdoc: true
73
+ homepage: http://github.com/aklaiber/wirecardmapper
74
+ licenses: []
75
+
76
+ post_install_message:
77
+ rdoc_options: []
78
+
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ hash: 3
87
+ segments:
88
+ - 0
89
+ version: "0"
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ none: false
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ hash: 3
96
+ segments:
97
+ - 0
98
+ version: "0"
99
+ requirements: []
100
+
101
+ rubyforge_project:
102
+ rubygems_version: 1.3.7
103
+ signing_key:
104
+ specification_version: 3
105
+ summary: A Ruby Object Mapper for Wirecard XML interface
106
+ test_files: []
107
+