rasper 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG ADDED
@@ -0,0 +1,9 @@
1
+ Rasper
2
+ ======
3
+
4
+
5
+ 2013-02-22 Rodrigo Manhães <rmanhaes@gmail.com>
6
+ 0.1.2
7
+
8
+ - Dropped configuration directly on specific classes. All configurations now
9
+ should be applied to Rasper::Config.
data/README.rst CHANGED
@@ -31,6 +31,15 @@ For running tests, JAR files should be stored in ``java/jars`` directory.
31
31
  Usage
32
32
  -----
33
33
 
34
+ Before doing anything, you should configure Rasper::
35
+
36
+ Rasper::Config.configure do |config|
37
+ config.jar_dir = "/dir/of/jars"
38
+ config.jasper_dir = "/dir/of/compiled/reports"
39
+ config.image_dir = "/dir/of/images"
40
+ end
41
+
42
+
34
43
  To compile a JRXML file, just run::
35
44
 
36
45
  Rasper::Compiler.compile("path-to-jrxml-file", "output-directory")
@@ -43,8 +52,7 @@ directory as JRXML file.
43
52
 
44
53
  Having a compiled jasper file, you can generate a PDF report::
45
54
 
46
- Rasper::Report.jasper_dir = "/home/user/jasper/directory"
47
- Rasper::Report.image_dir = "/home/user/image/directory"
55
+
48
56
  pdf_content = Rasper::Report.generate('programmers', [
49
57
  { name: 'Linus', software: 'Linux' },
50
58
  { name: 'Yukihiro', software: 'Ruby' },
@@ -0,0 +1,21 @@
1
+ module Rasper
2
+ class Config
3
+ class << self
4
+ attr_reader :jar_dir, :jasper_dir, :image_dir
5
+ end
6
+
7
+ def self.configure
8
+ conf = Configuration.new
9
+ yield conf
10
+ @jar_dir = conf.jar_dir
11
+ @jasper_dir = conf.jasper_dir
12
+ @image_dir = conf.image_dir
13
+ end
14
+
15
+ private
16
+
17
+ class Configuration
18
+ attr_accessor :jar_dir, :jasper_dir, :image_dir
19
+ end
20
+ end
21
+ end
@@ -1,12 +1,8 @@
1
1
  module Rasper
2
2
  class JARLoader
3
- class << self
4
- attr_accessor :jar_dir
5
-
6
- def load
7
- Dir.entries(jar_dir).each do |lib|
8
- require File.join(jar_dir, lib) if lib =~ /\.jar$/
9
- end
3
+ def self.load
4
+ Dir.entries(Config.jar_dir).each do |lib|
5
+ require File.join(Config.jar_dir, lib) if lib =~ /\.jar$/
10
6
  end
11
7
  end
12
8
  end
data/lib/rasper/report.rb CHANGED
@@ -13,12 +13,10 @@ require 'active_support/core_ext'
13
13
  module Rasper
14
14
  class Report
15
15
  class << self
16
- attr_accessor :jasper_dir, :image_dir
17
-
18
16
  def generate(jasper_name, data, params = {})
19
17
  set_file_resolver(params)
20
18
 
21
- file_name = File.join(jasper_dir || '.', jasper_name + '.jasper')
19
+ file_name = File.join(Config.jasper_dir || '.', jasper_name + '.jasper')
22
20
  jasper_content = File.read(file_name)
23
21
  data = { jasper_name => data }.to_xml
24
22
  xpath_criteria = "/hash/#{jasper_name}/#{jasper_name.singularize}"
@@ -34,7 +32,7 @@ module Rasper
34
32
 
35
33
  def set_file_resolver(params)
36
34
  resolver = FileResolver.new
37
- image_directory = image_dir
35
+ image_directory = Config.image_dir
38
36
  resolver.singleton_class.instance_eval do
39
37
  define_method :resolve_file do |filename|
40
38
  java::io::File.new("#{image_directory}/#{filename}")
@@ -1,3 +1,3 @@
1
1
  module Rasper
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
data/lib/rasper.rb CHANGED
@@ -4,4 +4,5 @@ module Rasper
4
4
  autoload :Compiler, 'rasper/compiler'
5
5
  autoload :Report, 'rasper/report'
6
6
  autoload :JARLoader, 'rasper/jar_loader'
7
+ autoload :Config, 'rasper/config'
7
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rasper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-18 00:00:00.000000000 Z
12
+ date: 2013-02-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: builder
@@ -114,10 +114,12 @@ files:
114
114
  - lib/rasper/report.rb
115
115
  - lib/rasper/version.rb
116
116
  - lib/rasper/jar_loader.rb
117
+ - lib/rasper/config.rb
117
118
  - README.rst
118
119
  - LICENSE.txt
119
120
  - Rakefile
120
121
  - Gemfile
122
+ - CHANGELOG
121
123
  - bin/rasper
122
124
  homepage: https://github.com/rodrigomanhaes/rasper
123
125
  licenses: