bosdk 0.1.0-universal-java-1.6 → 0.1.1-universal-java-1.6

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -7,22 +7,26 @@ A JRuby wrapper for the Business Objects SDK
7
7
  == Requirements
8
8
 
9
9
  - The Business Objects Java SDK
10
- - An environment variable 'BOE_JAVA_LIB' pointing to the Business Objects Java SDK directory
10
+ - An environment variable 'BOE_JAVA_LIB' pointing to the Business Objects Java
11
+ SDK directory
11
12
  - JRuby >= 1.4.0
12
13
 
13
14
  == Usage
14
15
 
15
16
  require 'bosdk'
16
- session = BOSDK::EnterpriseSession.new 'cms', 'Administrator', ''
17
+ boe = BOSDK::EnterpriseSession.new('cms', 'Administrator', '')
17
18
 
18
- ...do stuff with 'session.boe'...
19
+ stmt = "SELECT TOP 10 * FROM CI_SYSTEMOBJECTS WHERE SI_KIND='User'"
20
+ boe.query(stmt).each do |obj|
21
+ puts obj.title
22
+ end
19
23
 
20
- session.disconnect if session.connected?
24
+ boe.disconnect
21
25
 
22
26
  == Future Enhancements
23
27
 
24
- In the future there will be wrappers around the more commonly used portions of the SDK,
25
- including IInfoStore and IInfoObject.
28
+ In the future there may be wrappers around the more commonly used portions of
29
+ the SDK, such as IInfoObject.
26
30
 
27
31
  == Resources
28
32
 
data/bosdk.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "bosdk"
3
- s.version = "0.1.0"
3
+ s.version = "0.1.1"
4
4
 
5
5
  s.author = "Shane Emmons"
6
6
  s.description = "A JRuby wrapper for the Business Objects Java SDK"
@@ -1,22 +1,40 @@
1
1
  module BOSDK
2
+ # Creates a wrapper around the Business Objects Java SDK
2
3
  class EnterpriseSession
3
- attr_reader :boe
4
+ # The underlying IEnterpriseSession
5
+ attr_reader :session
4
6
 
7
+ # The underlying IInfoStore
8
+ attr_reader :infostore
9
+
10
+ # Creates a new EnterpriseSession object, connecting to the specified CMS.
11
+ # EnterpriseSession.new('cms', 'Administrator', '')
12
+ #
13
+ # Automatically calls disconnect when cleaned up.
5
14
  def initialize(cms, username, password)
6
- @boe = CrystalEnterprise.getSessionMgr.logon(username, password, cms, 'secEnterprise')
15
+ @session = CrystalEnterprise.getSessionMgr.logon(username, password, cms, 'secEnterprise')
16
+ @infostore = @session.getService('', 'InfoStore')
7
17
  @connected = true
8
18
 
9
19
  at_exit { disconnect }
10
20
  end
11
21
 
22
+ # Returned true/false if connected to the CMS.
12
23
  def connected?
13
24
  return @connected
14
25
  end
15
26
 
27
+ # Disconnects from the CMS is connected.
16
28
  def disconnect
17
- @boe.logoff if connected?
18
- @boe = nil
29
+ @session.logoff if connected?
30
+ @session = nil
19
31
  @connected = false
32
+ nil
33
+ end
34
+
35
+ # Queries the InfoStore with the provided statement.
36
+ def query(stmt)
37
+ @infostore.query(stmt)
20
38
  end
21
39
  end
22
40
  end
@@ -12,11 +12,13 @@ module BOSDK
12
12
  # mocks
13
13
  @session_mgr = mock("ISessionMgr").as_null_object
14
14
  @session = mock("IEnterpriseSession").as_null_object
15
+ @infostore = mock("IInfoStore").as_null_object
16
+ @infoobjects = mock("IInfoObjects").as_null_object
15
17
 
16
18
  # stubs
17
- CrystalEnterprise.should_receive(:getSessionMgr).with.and_return(@session_mgr)
19
+ CrystalEnterprise.should_receive(:getSessionMgr).and_return(@session_mgr)
18
20
  @session_mgr.should_receive(:logon).once.with('Administrator', '', 'cms', 'secEnterprise').and_return(@session)
19
- @session.should_receive(:logoff).at_most(2).with.and_return
21
+ @session.should_receive(:getService).once.with('', 'InfoStore').and_return(@infostore)
20
22
 
21
23
  @es = EnterpriseSession.new('cms', 'Administrator', '')
22
24
  end
@@ -26,18 +28,38 @@ module BOSDK
26
28
  end
27
29
 
28
30
  specify "#connected? returns 'false' when not connected to a CMS" do
31
+ @session.should_receive(:logoff).once.with.and_return
32
+
29
33
  @es.disconnect
30
34
  @es.connected?.should be_false
31
35
  end
32
36
 
33
37
  specify "#disconnect should disconnect from the CMS" do
38
+ @session.should_receive(:logoff).once.with.and_return
39
+
34
40
  @es.disconnect
35
41
  @es.connected?.should be_false
36
42
  end
37
43
 
38
44
  specify "#disconnect shouldn't raise an error when not connected" do
39
- @es.disconnect
40
- lambda{@es.disconnect}.should_not raise_exception
45
+ @session.should_receive(:logoff).once.with.and_return
46
+
47
+ lambda{2.times{ @es.disconnect }}.should_not raise_exception
48
+ end
49
+
50
+ specify "#query should send the statement to the underlying InfoStore" do
51
+ stmt = 'SELECT * FROM CI_infoobjectS'
52
+ @infostore.should_receive(:query).once.with(stmt)
53
+
54
+ results = @es.query(stmt)
55
+ end
56
+
57
+ specify "#query should return the IInfoObjects" do
58
+ stmt = 'SELECT * FROM CI_INFOOBJECTS'
59
+ @infostore.should_receive(:query).once.with(stmt).and_return(@infoobjects)
60
+
61
+ results = @es.query(stmt)
62
+ results.should == @infoobjects
41
63
  end
42
64
  end
43
65
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bosdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: universal-java-1.6
6
6
  authors:
7
7
  - Shane Emmons