casper-client 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/casper-client.gemspec +1 -1
- data/lib/casper-client.rb +11 -3
- data/spec/casper_client_spec.rb +18 -0
- data/spec/data/report.jrxml +10 -2
- metadata +2 -2
data/casper-client.gemspec
CHANGED
data/lib/casper-client.rb
CHANGED
@@ -6,15 +6,23 @@ module Casper
|
|
6
6
|
|
7
7
|
class Client
|
8
8
|
|
9
|
-
|
9
|
+
DEFAULT_HOST = 'http://casper.jrs-labs.com:8080'
|
10
10
|
|
11
11
|
def self.build(options={}, &block)
|
12
|
-
options = {:host =>
|
12
|
+
options = {:host => DEFAULT_HOST}.merge!(options)
|
13
13
|
report = Report.new
|
14
14
|
report.instance_eval(&block)
|
15
15
|
RestClient.post options[:host], report.to_json, :content_type => :json, :accept => :json
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
|
+
def self.report options={}
|
19
|
+
Client.build options do |report|
|
20
|
+
report.template = options[:template]
|
21
|
+
report.xml = options[:xml]
|
22
|
+
report.xpath = options[:xpath]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
18
26
|
end
|
19
27
|
|
20
28
|
class Report
|
data/spec/casper_client_spec.rb
CHANGED
@@ -62,6 +62,24 @@ describe Casper::Client do
|
|
62
62
|
report.xpath = '//root'
|
63
63
|
end
|
64
64
|
end
|
65
|
+
|
66
|
+
it 'should build the correct request to a report without a block as param' do
|
67
|
+
RestClient.should_receive(:post).with(
|
68
|
+
'http://casper.jrs-labs.com:8080',
|
69
|
+
{:casper =>
|
70
|
+
{
|
71
|
+
:jrxml => Base64.encode64(open(File.join(File.dirname(__FILE__),'data/report.jrxml')).read),
|
72
|
+
:data => Base64.encode64(open(File.join(File.dirname(__FILE__),'data/dataset.xml')).read),
|
73
|
+
:xpath => '//root'
|
74
|
+
}
|
75
|
+
}.to_json, :content_type => :json, :accept => :json
|
76
|
+
)
|
77
|
+
report = Casper::Client.report(
|
78
|
+
:template => open(File.join(File.dirname(__FILE__),'data/report.jrxml')),
|
79
|
+
:xml => open(File.join(File.dirname(__FILE__),'data/dataset.xml')),
|
80
|
+
:xpath => '//root'
|
81
|
+
)
|
82
|
+
end
|
65
83
|
|
66
84
|
end
|
67
85
|
|
data/spec/data/report.jrxml
CHANGED
@@ -16,7 +16,15 @@
|
|
16
16
|
<band splitType="Stretch"/>
|
17
17
|
</background>
|
18
18
|
<title>
|
19
|
-
<band height="79" splitType="Stretch"
|
19
|
+
<band height="79" splitType="Stretch">
|
20
|
+
<staticText>
|
21
|
+
<reportElement style="Title" x="10" y="10" width="545" height="67"/>
|
22
|
+
<textElement textAlignment="Right" verticalAlignment="Middle">
|
23
|
+
<font size="54" isBold="false" pdfFontName="Helvetica"/>
|
24
|
+
</textElement>
|
25
|
+
<text><![CDATA[Orçamento]]></text>
|
26
|
+
</staticText>
|
27
|
+
</band>
|
20
28
|
</title>
|
21
29
|
<pageHeader>
|
22
30
|
<band height="35" splitType="Stretch"/>
|
@@ -58,4 +66,4 @@
|
|
58
66
|
<summary>
|
59
67
|
<band height="42" splitType="Stretch"/>
|
60
68
|
</summary>
|
61
|
-
</jasperReport>
|
69
|
+
</jasperReport>
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: casper-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Daniel Tamiosso
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-05-
|
13
|
+
date: 2011-05-15 00:00:00 -03:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|