sap4ruby 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies to develop your gem here.
3
+ # Include everything needed to run rake, tests, features, etc.
4
+ group :development do
5
+ gem "cucumber"
6
+ gem "rspec", "~> 2.3.0"
7
+ gem "bundler", "~> 1.0.0"
8
+ gem "jeweler", "~> 1.5.2"
9
+ gem "rcov", ">= 0"
10
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Marcelo Nascimento Moraes
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
+ = sap4ruby
2
+
3
+ A library to connect with SAP using jruby
4
+
5
+ == Contributing to sap4ruby
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) 2011 Marcelo Nascimento Moraes. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,80 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |g|
14
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ g.name = "sap4ruby"
16
+ g.homepage = "http://github.com/marcelonmoraes/sap4ruby"
17
+ g.license = "MIT"
18
+ g.summary = "Connection to SAP with JRuby"
19
+ g.description = "Using jruby to connect with SAP ERP system via RFC."
20
+ g.email = "marcelonmoraes@gmail.com"
21
+ g.authors = ["Marcelo Nascimento Moraes"]
22
+ g.version = "0.0.3"
23
+
24
+ g.require_paths = ["lib"]
25
+
26
+ # Include your dependencies below. Runtime dependencies are required when using your gem,
27
+ # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
28
+ # gem.add_runtime_dependency 'jabber4r', '> 0.1'
29
+ # gem.add_development_dependency 'rspec', '> 1.2.3'
30
+ end
31
+ Jeweler::RubygemsDotOrgTasks.new
32
+
33
+ namespace :install do
34
+ namespace :macos do
35
+ desc "Installation of JCO for macos 64-bits server."
36
+ task :v64 do
37
+ p "Installation of JCO for macos 64-bits server."
38
+ end
39
+
40
+ desc "Installation of JCO for macos 32-bits server."
41
+ task :v32 do
42
+ p "Installation of JCO for macos 32-bits server."
43
+ end
44
+ end
45
+
46
+ namespace :linux do
47
+
48
+ end
49
+
50
+ namespace :windows do
51
+
52
+ end
53
+
54
+ namespace :solaris do
55
+
56
+ end
57
+ end
58
+
59
+ require 'rspec/core'
60
+ require 'rspec/core/rake_task'
61
+ RSpec::Core::RakeTask.new(:spec) do |spec|
62
+ spec.pattern = FileList['spec/**/*_spec.rb']
63
+ end
64
+
65
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
66
+ spec.pattern = 'spec/**/*_spec.rb'
67
+ spec.rcov = true
68
+ end
69
+
70
+ task :default => :spec
71
+
72
+ require 'rake/rdoctask'
73
+ Rake::RDocTask.new do |rdoc|
74
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
75
+
76
+ rdoc.rdoc_dir = 'rdoc'
77
+ rdoc.title = "sap4ruby #{version}"
78
+ rdoc.rdoc_files.include('README*')
79
+ rdoc.rdoc_files.include('lib/**/*.rb')
80
+ end
@@ -0,0 +1,9 @@
1
+ Manifest-Version: 1.0
2
+
3
+ keyname: SAP JCO
4
+ keyvendor: sap.com
5
+ keylocation: SAP AG
6
+
7
+ sapjco release: 3.0
8
+ sapjco patch level: 6
9
+ sapjco os: darwinintel
@@ -0,0 +1,9 @@
1
+ Manifest-Version: 1.0
2
+
3
+ keyname: SAP JCO
4
+ keyvendor: sap.com
5
+ keylocation: SAP AG
6
+
7
+ sapjco release: 3.0
8
+ sapjco patch level: 6
9
+ sapjco os: darwinintel64
data/lib/sap4ruby.rb ADDED
@@ -0,0 +1,6 @@
1
+ require 'ostruct'
2
+ require 'sap4ruby/version'
3
+ require 'sap4ruby/parameters'
4
+ require 'sap4ruby/modules'
5
+ require 'sap4ruby/client'
6
+ require 'sap4ruby/function_module'
@@ -0,0 +1,39 @@
1
+ module Sap4ruby
2
+ class Client
3
+ include Sap4ruby::Modules
4
+ include DestinationDataProvider
5
+
6
+ attr_accessor :connection_keys,
7
+ :abap_properties,
8
+ :sap_server
9
+
10
+ def initialize
11
+ @sap_server = "SAP_SERVER"
12
+ @abap_properties = Properties.new
13
+ @connection_keys = {
14
+ :ashost => Sap4ruby.HOST,
15
+ :sysnr => Sap4ruby.SYSNR,
16
+ :lang => Sap4ruby.LANGUAGE,
17
+ :client => Sap4ruby.CLIENT,
18
+ :user => Sap4ruby.USER,
19
+ :passwd => Sap4ruby.PASSWORD
20
+ }
21
+
22
+ @connection_keys.each do |key, value|
23
+ @abap_properties.put "jco.client.#{key}", value
24
+ end
25
+ end
26
+
27
+ def get_destination_properties(system); @abap_properties end
28
+ def set_destination_data_event_listener(eventListener); end
29
+ def supports_events; false end
30
+
31
+ class << self
32
+ def destination
33
+ provider = Client.new
34
+ Environment.register_destination_data_provider(provider) unless Environment.is_destination_data_provider_registered?
35
+ JCoDestinationManager.get_destination("SAP_SERVER")
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,61 @@
1
+ module Sap4ruby
2
+ class FunctionModule
3
+ attr_accessor :importing, :exporting, :tables
4
+
5
+ # Param on constructor
6
+ def initialize(function_module_name)
7
+ @destination = Sap4ruby::Client.destination
8
+ @function = @destination.get_repository.get_function(function_module_name)
9
+ importing_accessors,table_accessors = {}, {}
10
+
11
+ @function.get_import_parameter_list.each do |importing_parameter|
12
+ importing_sym = importing_parameter.get_name.downcase.to_sym
13
+ structure_fields = {}
14
+
15
+ if importing_parameter.is_structure?
16
+ importing_parameter.get_structure.each do |str|
17
+ structure_fields[str.get_name.downcase.to_sym] = str.get_value.to_s
18
+ end
19
+ end
20
+
21
+ param_default_value = (structure_fields.empty?) ? importing_parameter.get_value.to_s : structure_fields
22
+ importing_accessors[importing_sym] = param_default_value
23
+ end
24
+
25
+ @importing = OpenStruct.new(importing_accessors)
26
+ @function.get_table_parameter_list.each do |table_parameter|
27
+ table_sym = table_parameter.get_name.downcase.to_sym
28
+ table_accessors[table_sym] = []
29
+ end
30
+
31
+ @tables = OpenStruct.new(table_accessors)
32
+ end
33
+
34
+ def execute
35
+ @importing.each do |param, value|
36
+ if value.is_hash?
37
+
38
+ else
39
+ @function.get_import_parameter_list.set_value(param.to_s.upcase, value)
40
+ end
41
+ end
42
+
43
+ @function.execute(destination)
44
+
45
+ @function.get_export_parameter_list.each do |exporting_parameter|
46
+ if exporting_parameter.is_structure?
47
+
48
+ else
49
+ @exporting[params.get_name.to_sym] = params.get_string
50
+ end
51
+
52
+ end
53
+
54
+ @function.get_table_parameter_list.each do |table|
55
+ end
56
+ end
57
+
58
+ private
59
+ attr_accessor :destination, :function
60
+ end
61
+ end
@@ -0,0 +1,21 @@
1
+ require 'java'
2
+ require 'connectors/macosx/64-bits/sapjco3.jar'
3
+
4
+ module Sap4ruby
5
+ module Modules
6
+ java_import "java.util.Properties"
7
+ java_import "com.sap.conn.jco.AbapException"
8
+ java_import "com.sap.conn.jco.JCoContext"
9
+ java_import "com.sap.conn.jco.JCoDestination"
10
+ java_import "com.sap.conn.jco.JCoDestinationManager"
11
+ java_import "com.sap.conn.jco.JCoException"
12
+ java_import "com.sap.conn.jco.JCoField"
13
+ java_import "com.sap.conn.jco.JCoFunction"
14
+ java_import "com.sap.conn.jco.JCoFunctionTemplate"
15
+ java_import "com.sap.conn.jco.JCoStructure"
16
+ java_import "com.sap.conn.jco.JCoTable"
17
+ java_import "com.sap.conn.jco.ext.DestinationDataEventListener"
18
+ java_import "com.sap.conn.jco.ext.DestinationDataProvider"
19
+ java_import "com.sap.conn.jco.ext.Environment"
20
+ end
21
+ end
@@ -0,0 +1,14 @@
1
+ require "yaml"
2
+
3
+ SAP_CONFIG = YAML.load_file('/Users/marcelonmoraes/Development/personal/jruby/sap4ruby/sap_connection.yml')['sap_parameters']
4
+
5
+ module Sap4ruby
6
+ class << self
7
+ def HOST; SAP_CONFIG['ashost'].to_s end
8
+ def SYSNR; SAP_CONFIG['sysnr'].to_s end
9
+ def LANGUAGE; SAP_CONFIG['lang'].to_s end
10
+ def CLIENT; SAP_CONFIG['client'].to_s end
11
+ def USER; SAP_CONFIG['user'].to_s end
12
+ def PASSWORD; SAP_CONFIG['passwd'].to_s end
13
+ end
14
+ end
@@ -0,0 +1,5 @@
1
+ module Sap4ruby
2
+ class Table
3
+
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module Sap4ruby
2
+ VERSION = '0.0.1'
3
+ end
data/sap4ruby.gemspec ADDED
@@ -0,0 +1,78 @@
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 = %q{sap4ruby}
8
+ s.version = "0.0.3"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Marcelo Nascimento Moraes"]
12
+ s.date = %q{2011-03-09}
13
+ s.description = %q{Using jruby to connect with SAP ERP system via RFC.}
14
+ s.email = %q{marcelonmoraes@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE.txt",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".rspec",
22
+ "Gemfile",
23
+ "LICENSE.txt",
24
+ "README.rdoc",
25
+ "Rakefile",
26
+ "lib/connectors/macosx/32-bits/libsapjco3.jnilib",
27
+ "lib/connectors/macosx/32-bits/sapjco3.jar",
28
+ "lib/connectors/macosx/32-bits/sapjcomanifest.mf",
29
+ "lib/connectors/macosx/64-bits/libsapjco3.jnilib",
30
+ "lib/connectors/macosx/64-bits/sapjco3.jar",
31
+ "lib/connectors/macosx/64-bits/sapjcomanifest.mf",
32
+ "lib/sap4ruby.rb",
33
+ "lib/sap4ruby/client.rb",
34
+ "lib/sap4ruby/function_module.rb",
35
+ "lib/sap4ruby/modules.rb",
36
+ "lib/sap4ruby/parameters.rb",
37
+ "lib/sap4ruby/table.rb",
38
+ "lib/sap4ruby/version.rb",
39
+ "sap4ruby.gemspec",
40
+ "sap_connection.yml",
41
+ "spec/sap4ruby_spec.rb",
42
+ "spec/spec_helper.rb"
43
+ ]
44
+ s.homepage = %q{http://github.com/marcelonmoraes/sap4ruby}
45
+ s.licenses = ["MIT"]
46
+ s.require_paths = ["lib"]
47
+ s.rubygems_version = %q{1.5.3}
48
+ s.summary = %q{Connection to SAP with JRuby}
49
+ s.test_files = [
50
+ "spec/sap4ruby_spec.rb",
51
+ "spec/spec_helper.rb"
52
+ ]
53
+
54
+ if s.respond_to? :specification_version then
55
+ s.specification_version = 3
56
+
57
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
58
+ s.add_development_dependency(%q<cucumber>, [">= 0"])
59
+ s.add_development_dependency(%q<rspec>, ["~> 2.3.0"])
60
+ s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
61
+ s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
62
+ s.add_development_dependency(%q<rcov>, [">= 0"])
63
+ else
64
+ s.add_dependency(%q<cucumber>, [">= 0"])
65
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
66
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
67
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
68
+ s.add_dependency(%q<rcov>, [">= 0"])
69
+ end
70
+ else
71
+ s.add_dependency(%q<cucumber>, [">= 0"])
72
+ s.add_dependency(%q<rspec>, ["~> 2.3.0"])
73
+ s.add_dependency(%q<bundler>, ["~> 1.0.0"])
74
+ s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
75
+ s.add_dependency(%q<rcov>, [">= 0"])
76
+ end
77
+ end
78
+
@@ -0,0 +1,7 @@
1
+ sap_parameters:
2
+ ashost: 10.211.55.8
3
+ sysnr: 00
4
+ lang: en
5
+ client: 000
6
+ user: BCUSER
7
+ passwd: minisap
@@ -0,0 +1,33 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Sap4ruby" do
4
+ before :all do
5
+ @sap = Sap4ruby::Client.new
6
+ end
7
+
8
+ it "should have connection parameters in Sap4ruby module" do
9
+ Sap4ruby.HOST.should_not be_empty
10
+ Sap4ruby.SYSNR.should_not be_empty
11
+ Sap4ruby.LANGUAGE.should_not be_empty
12
+ Sap4ruby.CLIENT.should_not be_empty
13
+ Sap4ruby.USER.should_not be_empty
14
+ Sap4ruby.PASSWORD.should_not be_empty
15
+ end
16
+
17
+ it "should have connection parameters in a instance of Sap4ruby::Client class" do
18
+ @sap.connection_keys[:ashost].should_not be_empty
19
+ @sap.connection_keys[:sysnr].should_not be_empty
20
+ @sap.connection_keys[:lang].should_not be_empty
21
+ @sap.connection_keys[:client].should_not be_empty
22
+ @sap.connection_keys[:user].should_not be_empty
23
+ @sap.connection_keys[:passwd].should_not be_empty
24
+ end
25
+
26
+ it "should have fields into sap table" do
27
+ pending("not implemented")
28
+ end
29
+
30
+ it "should have sap table filled with an example context" do
31
+ pending("not implemented")
32
+ end
33
+ end
@@ -0,0 +1,12 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+ require 'rspec'
4
+ require 'sap4ruby'
5
+
6
+ # Requires supporting files with custom matchers and macros, etc,
7
+ # in ./support/ and its subdirectories.
8
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
9
+
10
+ RSpec.configure do |config|
11
+
12
+ end
metadata ADDED
@@ -0,0 +1,137 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sap4ruby
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.3
6
+ platform: ruby
7
+ authors:
8
+ - Marcelo Nascimento Moraes
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-03-09 00:00:00 -03:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: cucumber
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ type: :development
25
+ prerelease: false
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ~>
33
+ - !ruby/object:Gem::Version
34
+ version: 2.3.0
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: bundler
40
+ requirement: &id003 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 1.0.0
46
+ type: :development
47
+ prerelease: false
48
+ version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
50
+ name: jeweler
51
+ requirement: &id004 !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
54
+ - - ~>
55
+ - !ruby/object:Gem::Version
56
+ version: 1.5.2
57
+ type: :development
58
+ prerelease: false
59
+ version_requirements: *id004
60
+ - !ruby/object:Gem::Dependency
61
+ name: rcov
62
+ requirement: &id005 !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: "0"
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: *id005
71
+ description: Using jruby to connect with SAP ERP system via RFC.
72
+ email: marcelonmoraes@gmail.com
73
+ executables: []
74
+
75
+ extensions: []
76
+
77
+ extra_rdoc_files:
78
+ - LICENSE.txt
79
+ - README.rdoc
80
+ files:
81
+ - .document
82
+ - .rspec
83
+ - Gemfile
84
+ - LICENSE.txt
85
+ - README.rdoc
86
+ - Rakefile
87
+ - lib/connectors/macosx/32-bits/libsapjco3.jnilib
88
+ - lib/connectors/macosx/32-bits/sapjco3.jar
89
+ - lib/connectors/macosx/32-bits/sapjcomanifest.mf
90
+ - lib/connectors/macosx/64-bits/libsapjco3.jnilib
91
+ - lib/connectors/macosx/64-bits/sapjco3.jar
92
+ - lib/connectors/macosx/64-bits/sapjcomanifest.mf
93
+ - lib/sap4ruby.rb
94
+ - lib/sap4ruby/client.rb
95
+ - lib/sap4ruby/function_module.rb
96
+ - lib/sap4ruby/modules.rb
97
+ - lib/sap4ruby/parameters.rb
98
+ - lib/sap4ruby/table.rb
99
+ - lib/sap4ruby/version.rb
100
+ - sap4ruby.gemspec
101
+ - sap_connection.yml
102
+ - spec/sap4ruby_spec.rb
103
+ - spec/spec_helper.rb
104
+ has_rdoc: true
105
+ homepage: http://github.com/marcelonmoraes/sap4ruby
106
+ licenses:
107
+ - MIT
108
+ post_install_message:
109
+ rdoc_options: []
110
+
111
+ require_paths:
112
+ - lib
113
+ required_ruby_version: !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ hash: -378953813224327376
119
+ segments:
120
+ - 0
121
+ version: "0"
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
123
+ none: false
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: "0"
128
+ requirements: []
129
+
130
+ rubyforge_project:
131
+ rubygems_version: 1.5.3
132
+ signing_key:
133
+ specification_version: 3
134
+ summary: Connection to SAP with JRuby
135
+ test_files:
136
+ - spec/sap4ruby_spec.rb
137
+ - spec/spec_helper.rb