bosdk 0.1.1-universal-java-1.6 → 0.1.2-universal-java-1.6

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/README.rdoc CHANGED
@@ -14,20 +14,16 @@ A JRuby wrapper for the Business Objects SDK
14
14
  == Usage
15
15
 
16
16
  require 'bosdk'
17
- boe = BOSDK::EnterpriseSession.new('cms', 'Administrator', '')
17
+ include BOSDK
18
+ boe = EnterpriseSession.new('cms', 'Administrator', '')
18
19
 
19
20
  stmt = "SELECT TOP 10 * FROM CI_SYSTEMOBJECTS WHERE SI_KIND='User'"
20
21
  boe.query(stmt).each do |obj|
21
- puts obj.title
22
+ puts obj.path
22
23
  end
23
24
 
24
25
  boe.disconnect
25
26
 
26
- == Future Enhancements
27
-
28
- In the future there may be wrappers around the more commonly used portions of
29
- the SDK, such as IInfoObject.
30
-
31
27
  == Resources
32
28
 
33
29
  - Website: http://semmons99.github.com/bosdk
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.1"
3
+ s.version = "0.1.2"
4
4
 
5
5
  s.author = "Shane Emmons"
6
6
  s.description = "A JRuby wrapper for the Business Objects Java SDK"
@@ -9,7 +9,9 @@ Gem::Specification.new do |s|
9
9
  "README.rdoc", "MIT-LICENSE", "bosdk.gemspec", "Rakefile",
10
10
  "lib/bosdk.rb",
11
11
  "lib/bosdk/enterprise_session.rb",
12
+ "lib/bosdk/info_object.rb",
12
13
  "spec/enterprise_session_spec.rb",
14
+ "spec/info_object_spec.rb",
13
15
  ]
14
16
 
15
17
  s.homepage = "http://semmons99.github.com/bosdk"
@@ -1,5 +1,7 @@
1
+ require 'bosdk/info_object'
2
+
1
3
  module BOSDK
2
- # Creates a wrapper around the Business Objects Java SDK
4
+ # Creates a wrapper around the Business Objects Java SDK.
3
5
  class EnterpriseSession
4
6
  # The underlying IEnterpriseSession
5
7
  attr_reader :session
@@ -19,7 +21,7 @@ module BOSDK
19
21
  at_exit { disconnect }
20
22
  end
21
23
 
22
- # Returned true/false if connected to the CMS.
24
+ # Returns true/false if connected to the CMS.
23
25
  def connected?
24
26
  return @connected
25
27
  end
@@ -32,9 +34,10 @@ module BOSDK
32
34
  nil
33
35
  end
34
36
 
35
- # Queries the InfoStore with the provided statement.
37
+ # Queries the InfoStore with the provided statement, returning an Array of
38
+ # InfoObject(s).
36
39
  def query(stmt)
37
- @infostore.query(stmt)
40
+ @infostore.query(stmt).map{|o| InfoObject.new(o)}
38
41
  end
39
42
  end
40
43
  end
@@ -0,0 +1,46 @@
1
+ module BOSDK
2
+ # Creates a wrapper around an IInfoObject.
3
+ class InfoObject
4
+ # The underlying IInfoObject.
5
+ attr_reader :obj
6
+
7
+ # Creates a new InfoObject from the provided IInfoObject.
8
+ # InfoObject.new(obj)
9
+ def initialize(obj)
10
+ @obj = obj
11
+ end
12
+
13
+ # Returns true/false if #obj is a root node.
14
+ def is_root?
15
+ parent_id.nil? or parent_id == 0 or parent_id == getID
16
+ end
17
+
18
+ # Returns the parent of #obj as an InfoObject
19
+ def parent
20
+ return nil if is_root?
21
+ @parent ||= InfoObject.new(getParent)
22
+ end
23
+
24
+ # Returns the path of #obj as a String.
25
+ def path
26
+ @path ||= (is_root? ? '' : parent.path) + "/#{title}"
27
+ end
28
+
29
+ # Compares one InfoObject to another by #title.
30
+ def <=>(other_infoobject)
31
+ title <=> other_infoobject.title
32
+ end
33
+
34
+ def method_missing(method, *args)
35
+ eval "return @#{method.to_s}" if instance_variables.include?("@#{method.to_s}")
36
+ if @obj.respond_to?(method)
37
+ eval "return @#{method.to_s} = @obj.send(method, *args)"
38
+ end
39
+ super
40
+ end
41
+
42
+ def respond_to?(method)
43
+ @obj.respond_to?(method) || super
44
+ end
45
+ end
46
+ end
data/lib/bosdk.rb CHANGED
@@ -25,3 +25,4 @@ Dir.glob(ENV["BOE_JAVA_LIB"] + "/*.jar").each{|jar| require jar}
25
25
  include_class "com.crystaldecisions.sdk.framework.CrystalEnterprise"
26
26
 
27
27
  require 'bosdk/enterprise_session'
28
+ require 'bosdk/info_object'
@@ -49,17 +49,9 @@ module BOSDK
49
49
 
50
50
  specify "#query should send the statement to the underlying InfoStore" do
51
51
  stmt = 'SELECT * FROM CI_infoobjectS'
52
- @infostore.should_receive(:query).once.with(stmt)
52
+ @infostore.should_receive(:query).once.with(stmt).and_return([])
53
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
54
+ @es.query(stmt)
63
55
  end
64
56
  end
65
57
  end
@@ -0,0 +1,111 @@
1
+ # encoding: utf-8
2
+ $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib"))
3
+ require 'bosdk/info_object'
4
+
5
+ module BOSDK
6
+ describe InfoObject do
7
+ before(:each) do
8
+ # mocks
9
+ @infoobject = mock("IInfoObject").as_null_object
10
+
11
+ @obj = InfoObject.new(@infoobject)
12
+ end
13
+
14
+ specify "#is_root? should return true when #parent_id is nil" do
15
+ @infoobject.should_receive(:parent_id).once.with.and_return(nil)
16
+
17
+ @obj.is_root?.should be_true
18
+ end
19
+
20
+ specify "#is_root? should return true when #parent_id is '0'" do
21
+ @infoobject.should_receive(:parent_id).once.with.and_return(0)
22
+
23
+ @obj.is_root?.should be_true
24
+ end
25
+
26
+ specify "#is_root? should return true when #parent_id == #getID" do
27
+ @infoobject.should_receive(:parent_id).once.with.and_return(1)
28
+ @infoobject.should_receive(:getID).once.with.and_return(1)
29
+
30
+ @obj.is_root?.should be_true
31
+ end
32
+
33
+ specify "#is_root? should return false when #parent_id is not: nil, '0' or #getID" do
34
+ @infoobject.should_receive(:parent_id).once.with.and_return(1)
35
+ @infoobject.should_receive(:getID).once.with.and_return(2)
36
+
37
+ @obj.is_root?.should be_false
38
+ end
39
+
40
+ specify "#parent should return nil if #is_root? == true" do
41
+ @infoobject.should_receive(:parent_id).once.with.and_return(nil)
42
+
43
+ @obj.parent.should be_nil
44
+ end
45
+
46
+ specify "#parent should return results of #getParent if #is_root? == false" do
47
+ parent_obj = mock("IInfoObject").as_null_object
48
+ @infoobject.should_receive(:parent_id).once.with.and_return(1)
49
+ @infoobject.should_receive(:getID).once.with.and_return(2)
50
+ @infoobject.should_receive(:getParent).once.with.and_return(parent_obj)
51
+
52
+ parent = @obj.parent
53
+ parent.should be_instance_of InfoObject
54
+ parent.obj.should == parent_obj
55
+ end
56
+
57
+ specify "#parent should only call the underlying #getParent once" do
58
+ parent_obj = mock("IInfoObject").as_null_object
59
+ @infoobject.should_receive(:parent_id).once.with.and_return(1)
60
+ @infoobject.should_receive(:getID).once.with.and_return(2)
61
+ @infoobject.should_receive(:getParent).once.with.and_return(parent_obj)
62
+
63
+ 2.times{@obj.parent}
64
+ end
65
+
66
+ specify "#path should return /#title if #is_root? == true" do
67
+ @infoobject.should_receive(:parent_id).once.with.and_return(nil)
68
+ @infoobject.should_receive(:title).once.with.and_return('test obj')
69
+
70
+ @obj.path.should == '/test obj'
71
+ end
72
+
73
+ specify "#path should return #parent_title/../#title if #is_root? == false" do
74
+ parent_obj = mock("IInfoObject").as_null_object
75
+ parent_obj.should_receive(:parent_id).once.with.and_return(nil)
76
+ parent_obj.should_receive(:title).once.with.and_return('test parent')
77
+
78
+ @infoobject.should_receive(:parent_id).once.with.and_return(1)
79
+ @infoobject.should_receive(:getID).once.with.and_return(2)
80
+ @infoobject.should_receive(:title).once.with.and_return('test obj')
81
+ @infoobject.should_receive(:getParent).once.with.and_return(parent_obj)
82
+
83
+ @obj.path.should == '/test parent/test obj'
84
+ end
85
+
86
+ specify "#path should only call the underlying #title, #parent#path, etc. once" do
87
+ parent_obj = mock("IInfoObject").as_null_object
88
+ parent_obj.should_receive(:parent_id).once.with.and_return(nil)
89
+ parent_obj.should_receive(:title).once.with.and_return('test parent')
90
+
91
+ @infoobject.should_receive(:parent_id).once.with.and_return(1)
92
+ @infoobject.should_receive(:getID).once.with.and_return(2)
93
+ @infoobject.should_receive(:title).once.with.and_return('test obj')
94
+ @infoobject.should_receive(:getParent).once.with.and_return(parent_obj)
95
+
96
+ 2.times{@obj.path}
97
+ end
98
+
99
+ specify "#<=> should use #title" do
100
+ objs = []
101
+ ('a'..'c').to_a.reverse.each do |ltr|
102
+ obj = mock("IInfoObject").as_null_object
103
+ obj.should_receive(:title).once.with.and_return(ltr)
104
+ objs << InfoObject.new(obj)
105
+ end
106
+
107
+ sorted_objs = objs.sort
108
+ sorted_objs.should == objs.reverse
109
+ end
110
+ end
111
+ 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.1
4
+ version: 0.1.2
5
5
  platform: universal-java-1.6
6
6
  authors:
7
7
  - Shane Emmons
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-01-19 00:00:00 -05:00
12
+ date: 2010-01-21 00:00:00 -05:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -28,7 +28,9 @@ files:
28
28
  - Rakefile
29
29
  - lib/bosdk.rb
30
30
  - lib/bosdk/enterprise_session.rb
31
+ - lib/bosdk/info_object.rb
31
32
  - spec/enterprise_session_spec.rb
33
+ - spec/info_object_spec.rb
32
34
  has_rdoc: true
33
35
  homepage: http://semmons99.github.com/bosdk
34
36
  licenses: []