casper_server 0.0.3

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,22 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2011 Tom Wilson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
data/bin/casper-server ADDED
@@ -0,0 +1,18 @@
1
+ #!/usr/bin/env ruby
2
+ require File.join(File.dirname(__FILE__), '..','lib', 'casper_server')
3
+
4
+ require 'fileutils'
5
+
6
+ if ARGV.first
7
+ project = ARGV.first
8
+ FileUtils.mkdir_p project
9
+
10
+ config_ru = ["require 'casper_server'", "run CasperServer"].join("\n")
11
+ File.open(File.join(project, 'config.ru'),'w').write(config_ru)
12
+ gemfile = ['source :rubygems', "gem 'casper_server'"].join("\n")
13
+ File.open(File.join(project, 'Gemfile'),'w').write(gemfile)
14
+ puts "****** Sucessfully Created #{project} *******"
15
+ else
16
+ puts "CasperServer A Jasper Reports Service..."
17
+ puts "(Please supply a project name for your Casper server...)"
18
+ end
@@ -0,0 +1,52 @@
1
+ require 'sinatra'
2
+ require 'haml'
3
+ require 'crack'
4
+ require 'casper_reports'
5
+ require 'base64'
6
+
7
+ class CasperServer < Sinatra::Base
8
+ VERSION = '0.0.3'
9
+ FORM = /multipart\/form-data/
10
+ XML = /application\/xml/
11
+ JSON = /application\/json/
12
+
13
+ set :public, File.dirname(__FILE__) + '/static'
14
+ set :views, File.dirname(__FILE__) + '/views'
15
+
16
+ get '/' do
17
+ haml :index
18
+ end
19
+
20
+ helpers do
21
+ def decode(data)
22
+ Base64.decode64 data
23
+ end
24
+
25
+ def get_input_data
26
+ if request.content_type =~ FORM
27
+ [ params['casper']['jrxml'][:tempfile].read, params['casper']['data'][:tempfile].read, params['casper']['xpath']]
28
+ elsif request.content_type =~ XML
29
+ #parse xml...
30
+ xml = Crack::XML.parse(request.body.read)
31
+ [ decode(xml['casper']['jrxml']), decode(xml['casper']['data']), xml['casper']['xpath']]
32
+ elsif request.content_type =~ JSON
33
+ json = Crack::JSON.parse(request.body.read)
34
+ [ decode(json['casper']['jrxml']), decode(json['casper']['data']), json['casper']['xpath']]
35
+
36
+ end
37
+ end
38
+ end
39
+
40
+ post '/' do
41
+
42
+ jrxml, xmldata, xpath = get_input_data
43
+
44
+ casper = CasperReports.new
45
+ pdf = casper.compile jrxml, xmldata, xpath
46
+
47
+ content_type "application/pdf"
48
+ attachment "casper.pdf"
49
+ pdf
50
+ end
51
+
52
+ end
@@ -0,0 +1,21 @@
1
+ %h1 Casper Reports Test Page
2
+ %p Test your report
3
+ %form{:action => '/', :method => 'POST', :enctype => "multipart/form-data"}
4
+ %fieldset
5
+ %legend JRXML
6
+ %p
7
+ %label Upload JRXML File
8
+ %input{:type => 'file', :name => 'casper[jrxml]', :id => 'casper_jrxml'}
9
+ %fieldset
10
+ %legend XML DATA
11
+ %p
12
+ %label Upload XML File
13
+ %input{:type => 'file', :name => 'casper[data]', :id => 'casper_data'}
14
+ %fieldset
15
+ %legend XPATH Query String
16
+ %p
17
+ %label Enter Query String:
18
+ %input{:type => 'text', :name => 'casper[xpath]', :id => 'casper_xpath'}
19
+ %fieldset
20
+ %p
21
+ %button Generate Report
@@ -0,0 +1,6 @@
1
+ !!! 5
2
+ %html
3
+ %head
4
+ %title Casper Reports Server
5
+ %body
6
+ = yield
data/readme.md ADDED
@@ -0,0 +1,88 @@
1
+ # Casper Server
2
+
3
+ (In Development Mode)
4
+
5
+ # What is this?
6
+
7
+ Casper Server is a Sinatra Web Server that provides an interface to the Casper Reports
8
+ library.
9
+
10
+ With this server you can send a jrxml template, a xml document and a xpath string.
11
+
12
+ # Install Gem
13
+
14
+ ```
15
+ gem install casper_server
16
+ ```
17
+
18
+ # Requirements
19
+
20
+ * Java
21
+ * JRuby
22
+ * Rack
23
+ * RVM
24
+
25
+ # How do I create a Casper Server?
26
+
27
+ ```
28
+ casper-server [name]
29
+ ```
30
+
31
+ # How do I run the Casper Server?
32
+
33
+ ```
34
+ cd [name]
35
+ rackup
36
+ ```
37
+
38
+ ---
39
+
40
+ API
41
+
42
+ ```
43
+ POST / {content-type:application/json}
44
+ #body=>
45
+ {
46
+ "casper":
47
+ {
48
+ "jrxml": <base64 encoded jrxml document>,
49
+ "data": <base64 encoded xml document>,
50
+ "xpath": <xpath query string>
51
+ }
52
+ }
53
+ ```
54
+
55
+ (XML VERSION CURRENTLY NOT WORKING!!!)
56
+ ```
57
+ POST / {content-type:application/xml}
58
+ #body=>
59
+ <casper>
60
+ <jrxml><![CDATA[{insert jrxml document here}]]></jrxml>
61
+ <data><![CDATA[{insert xml document here}]]></data>
62
+ <xpath><![CDATA[{insert xpath string here}]]></xpath>
63
+ </casper>
64
+
65
+ #RESPONSE=>
66
+ <pdf>
67
+ <base64><![CDATA[{base64encoded pdf string}]]></base64>
68
+ <pdf>
69
+
70
+ ---
71
+
72
+ TEST
73
+
74
+ ```
75
+ GET /
76
+ ```
77
+
78
+ On the web page you will be presented with three inputs and a process button.
79
+
80
+ The first input will be requesting the jrxml file
81
+ The second input will be requesting the xml document
82
+ The third input will be requesting xpath query string
83
+
84
+ Click Generate Report, and a pdf should stream to your browser.
85
+
86
+
87
+
88
+
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: casper_server
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.0.3
6
+ platform: ruby
7
+ authors:
8
+ - Tom Wilson
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-05-10 00:00:00 -04:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: rspec
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: 2.5.0
25
+ type: :development
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: rack-test
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: "0"
36
+ type: :development
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: bundler
40
+ prerelease: false
41
+ requirement: &id003 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: "0"
47
+ type: :runtime
48
+ version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
50
+ name: sinatra
51
+ prerelease: false
52
+ requirement: &id004 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: "0"
58
+ type: :runtime
59
+ version_requirements: *id004
60
+ - !ruby/object:Gem::Dependency
61
+ name: casperreports
62
+ prerelease: false
63
+ requirement: &id005 !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: "0"
69
+ type: :runtime
70
+ version_requirements: *id005
71
+ description: The JRuby Reports Server for JasperReports
72
+ email:
73
+ - tom@jackhq.com
74
+ executables:
75
+ - casper-server
76
+ extensions: []
77
+
78
+ extra_rdoc_files: []
79
+
80
+ files:
81
+ - lib/casper_server.rb
82
+ - lib/views/index.haml
83
+ - lib/views/layout.haml
84
+ - LICENSE
85
+ - readme.md
86
+ - bin/casper-server
87
+ has_rdoc: true
88
+ homepage: http://github.com/twilson63/casper_server
89
+ licenses: []
90
+
91
+ post_install_message:
92
+ rdoc_options: []
93
+
94
+ require_paths:
95
+ - - lib
96
+ required_ruby_version: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: "0"
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ none: false
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: 1.3.6
108
+ requirements: []
109
+
110
+ rubyforge_project:
111
+ rubygems_version: 1.5.1
112
+ signing_key:
113
+ specification_version: 3
114
+ summary: A JRuby Reports Server for Jasper
115
+ test_files: []
116
+