prep 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+
6
+ gem "hpdf", ">= 2.0.8"
7
+
8
+ # Add dependencies to develop your gem here.
9
+ # Include everything needed to run rake, tests, features, etc.
10
+ group :development do
11
+ gem "rspec", "~> 2.3.0"
12
+ gem "bundler", "~> 1.0.0"
13
+ gem "jeweler", "~> 1.5.2"
14
+ gem "rcov", ">= 0"
15
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,30 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ diff-lcs (1.1.2)
5
+ git (1.2.5)
6
+ hpdf (2.0.8)
7
+ jeweler (1.5.2)
8
+ bundler (~> 1.0.0)
9
+ git (>= 1.2.5)
10
+ rake
11
+ rake (0.8.7)
12
+ rcov (0.9.9)
13
+ rspec (2.3.0)
14
+ rspec-core (~> 2.3.0)
15
+ rspec-expectations (~> 2.3.0)
16
+ rspec-mocks (~> 2.3.0)
17
+ rspec-core (2.3.1)
18
+ rspec-expectations (2.3.0)
19
+ diff-lcs (~> 1.1.2)
20
+ rspec-mocks (2.3.0)
21
+
22
+ PLATFORMS
23
+ ruby
24
+
25
+ DEPENDENCIES
26
+ bundler (~> 1.0.0)
27
+ hpdf (>= 2.0.8)
28
+ jeweler (~> 1.5.2)
29
+ rcov
30
+ rspec (~> 2.3.0)
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 Tetsuhisa MAKINO
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,24 @@
1
+ = PREP
2
+
3
+ PREP は PDF Reporter Generator です。
4
+ 帳票のレイアウト定義を YAML 形式ファイルで記述し、オブジェクトをロード、
5
+ 描画に必要な差し込み用データを実行時に与えることで、帳票 PDF を生成します。
6
+
7
+ PREP は PDF そのものの生成に HPDF[http://libharu.sourceforge.net/index.html] を
8
+ 利用しています。詳細な説明、構成要素の追加等についてはそちらを参照してください。
9
+
10
+ == 基本的な考え方
11
+
12
+ PREP は YAML 形式で帳票のレイアウトを規定します。
13
+ PREP が捉える帳票の形は木構造となります。直線(Line)、矩形(Rectanble)、ラベル(Label)を
14
+ 基本的な構成要素と捉えます。
15
+
16
+ (そのうち書きます)
17
+
18
+ 当面は examples を参考にしてください。
19
+
20
+ == Copyright
21
+
22
+ Copyright (c) 2011 Tetsuhisa MAKINO. See LICENSE.txt for
23
+ further details.
24
+
data/Rakefile ADDED
@@ -0,0 +1,51 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'rake'
11
+
12
+ require 'jeweler'
13
+ Jeweler::Tasks.new do |gem|
14
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
15
+ gem.name = "prep"
16
+ gem.homepage = "http://github.com/maki-tetsu/prep"
17
+ gem.license = "MIT"
18
+ gem.summary = %Q{PREP is PDF Report generator depends on HPDF.}
19
+ gem.description = %Q{PREP is PDF Report generator depends on HPDF.}
20
+ gem.email = "tim.makino@gmail.com"
21
+ gem.authors = ["Tetsuhisa MAKINO"]
22
+ # Include your dependencies below. Runtime dependencies are required when using your gem,
23
+ # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
24
+ # gem.add_runtime_dependency 'jabber4r', '> 0.1'
25
+ # gem.add_development_dependency 'rspec', '> 1.2.3'
26
+ end
27
+ Jeweler::RubygemsDotOrgTasks.new
28
+
29
+ require 'rspec/core'
30
+ require 'rspec/core/rake_task'
31
+ RSpec::Core::RakeTask.new(:spec) do |spec|
32
+ spec.pattern = FileList['spec/**/*_spec.rb']
33
+ end
34
+
35
+ RSpec::Core::RakeTask.new(:rcov) do |spec|
36
+ spec.pattern = 'spec/**/*_spec.rb'
37
+ spec.rcov = true
38
+ end
39
+
40
+ task :default => :spec
41
+
42
+ require 'rake/rdoctask'
43
+ Rake::RDocTask.new do |rdoc|
44
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
45
+
46
+ rdoc.rdoc_dir = 'rdoc'
47
+ rdoc.title = "prep #{version}"
48
+ rdoc.options << "-c utf8"
49
+ rdoc.rdoc_files.include('README*')
50
+ rdoc.rdoc_files.include('lib/**/*.rb')
51
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.2.2
data/bin/prep-helper ADDED
@@ -0,0 +1,48 @@
1
+ #!/usr/bin/env ruby
2
+ require 'nkf'
3
+
4
+ # OS 判定
5
+ def is_win?
6
+ return RUBY_PLATFORM.downcase =~ /mswin(?!ce)|mingw|cygwin|bccwin/
7
+ end
8
+
9
+ # 文字列変換
10
+ def conv(msg)
11
+ if is_win?
12
+ encoding = 'cp932'
13
+ else
14
+ encoding = 'utf8'
15
+ end
16
+
17
+ return NKF.nkf("--oc=#{encoding}", msg)
18
+ end
19
+
20
+ # usage
21
+ def usage
22
+ puts conv("Usage: #{File.basename($0)} report_yaml_file_path")
23
+ end
24
+
25
+ # 文字コード指定(utf8 固定)
26
+ $KCODE='u'
27
+
28
+ # 引数判定
29
+ # 引数は帳票定義ファイルのパスのみ
30
+ if ARGV.size != 1
31
+ usage
32
+ exit
33
+ end
34
+
35
+ yaml_file_path = ARGV.shift
36
+
37
+ unless File.exists?(yaml_file_path)
38
+ STDERR.puts(conv("帳票レイアウト定義ファイル「#{yaml_file_path}」が見つかりません"))
39
+ exit
40
+ end
41
+
42
+ require File.join(File.dirname(__FILE__), "..", "lib", "prep")
43
+ PREP::Core::Group.allow_all = true
44
+ prep = PREP::Core::Prep.new(yaml_file_path)
45
+ require 'pp'
46
+ pp prep.generate_sample_dataset
47
+
48
+ exit
data/bin/prep-test ADDED
@@ -0,0 +1,51 @@
1
+ #!/usr/bin/env ruby
2
+ require 'nkf'
3
+
4
+ # OS 判定
5
+ def is_win?
6
+ return RUBY_PLATFORM.downcase =~ /mswin(?!ce)|mingw|cygwin|bccwin/
7
+ end
8
+
9
+ # 文字列変換
10
+ def conv(msg)
11
+ if is_win?
12
+ encoding = 'cp932'
13
+ else
14
+ encoding = 'utf8'
15
+ end
16
+
17
+ return NKF.nkf("--oc=#{encoding}", msg)
18
+ end
19
+
20
+ # usage
21
+ def usage
22
+ puts conv("Usage: #{File.basename($0)} report_yaml_file_path pdf_output_path")
23
+ end
24
+
25
+ # 文字コード指定(utf8 固定)
26
+ $KCODE='u'
27
+
28
+ # 引数判定
29
+ # 引数は帳票定義ファイルと出力PDFファイルパス
30
+ if ARGV.size != 2
31
+ usage
32
+ exit
33
+ end
34
+
35
+ yaml_file_path = ARGV.shift
36
+ output_file_path = ARGV.shift
37
+
38
+ unless File.exists?(yaml_file_path)
39
+ STDERR.puts(conv("帳票レイアウト定義ファイル「#{yaml_file_path}」が見つかりません"))
40
+ exit
41
+ end
42
+
43
+ require File.join(File.dirname(__FILE__), "..", "lib", "prep")
44
+ PREP::Core::Group.allow_all = true
45
+ ENV['DEBUG'] = 'true'
46
+ prep = PREP::Core::Prep.new(yaml_file_path)
47
+ require 'pp'
48
+ values = prep.generate_sample_dataset
49
+ prep.generate(output_file_path, values)
50
+
51
+ exit
@@ -0,0 +1,4 @@
1
+ require File.join(File.dirname(__FILE__), "..", "lib", "prep")
2
+
3
+ prep = PREP::Core::Prep.new("group_sample.yml")
4
+ prep.generate("#{$0}.pdf")
@@ -0,0 +1,4 @@
1
+ require File.join(File.dirname(__FILE__), "..", "lib", "prep")
2
+
3
+ prep = PREP::Core::Prep.new("sample.yml")
4
+ prep.generate("#{$0}.pdf", { :content => { :title => "外部引き渡しタイトル文字列" } })
@@ -0,0 +1,19 @@
1
+ require File.join(File.dirname(__FILE__), "..", "lib", "prep")
2
+
3
+ prep = PREP::Core::Prep.new("sample2.yml")
4
+ values = {
5
+ :content => {
6
+ :table => {
7
+ :values => [
8
+ { :column01_label => 101, :column02_label => 102, :column03_label => 103 },
9
+ { :column01_label => 201, :column02_label => 202, :column03_label => 203 },
10
+ { :column01_label => 301, :column02_label => 302, :column03_label => 303 },
11
+ { :column01_label => 401, :column02_label => 402, :column03_label => 403 },
12
+ { :column01_label => 501, :column02_label => 502, :column03_label => 503 },
13
+ { :column01_label => 601, :column02_label => 602, :column03_label => 603 },
14
+ { :column01_label => 701, :column02_label => 702, :column03_label => 703 },
15
+ ]
16
+ }
17
+ }
18
+ }
19
+ prep.generate("#{$0}.pdf", values)
@@ -0,0 +1,20 @@
1
+ require File.join(File.dirname(__FILE__), "..", "lib", "prep")
2
+
3
+ prep = PREP::Core::Prep.new("sample3.yml")
4
+ values = {
5
+ :content => {
6
+ :table => {
7
+ :values => [
8
+ { :column01_label => "03/01", :column02_label => 102, :column03_label => 103, :column04_label => 104 },
9
+ { :column01_label => "03/02", :column02_label => 202, :column03_label => 203, :column04_label => 204 },
10
+ { :column01_label => "03/03", :column02_label => 302, :column03_label => 303, :column04_label => 304 },
11
+ { :column01_label => "03/04", :column02_label => 402, :column03_label => 403, :column04_label => 404 },
12
+ { :column01_label => "03/05", :column02_label => 502, :column03_label => 503, :column04_label => 504 },
13
+ { :column01_label => "03/06", :column02_label => 602, :column03_label => 603, :column04_label => 604 },
14
+ { :column01_label => "03/07", :column02_label => 702, :column03_label => 703, :column04_label => 704 },
15
+ { :column01_label => "03/08", :column02_label => 702, :column03_label => 703, :column04_label => 704 },
16
+ ]
17
+ }
18
+ }
19
+ }
20
+ prep.generate("#{$0}.pdf", values)
@@ -0,0 +1,31 @@
1
+ require File.join(File.dirname(__FILE__), "..", "lib", "prep")
2
+
3
+ prep = PREP::Core::Prep.new("sample3.yml")
4
+ values = {
5
+ :header => {
6
+ :title => "任意のタイトルさんだよー。 とても長い場合にどうなるのかを確認してみます。",
7
+ },
8
+ :content => {
9
+ :table => {
10
+ :values => [
11
+ { :column01_label => "03/01", :column02_label => 102, :column03_label => 103, :column04_label => 104 },
12
+ { :column01_label => "03/02", :column02_label => 202, :column03_label => 203, :column04_label => 204 },
13
+ { :column01_label => "03/03", :column02_label => 302, :column03_label => 303, :column04_label => 304 },
14
+ { :column01_label => "03/04", :column02_label => 402, :column03_label => 403, :column04_label => 404 },
15
+ { :column01_label => "03/05", :column02_label => 502, :column03_label => 503, :column04_label => 504 },
16
+ { :column01_label => "03/06", :column02_label => 602, :column03_label => 603, :column04_label => 604 },
17
+ { :column01_label => "03/07", :column02_label => 702, :column03_label => 703, :column04_label => 704 },
18
+ { :column01_label => "03/08", :column02_label => 702, :column03_label => 703, :column04_label => 704 },
19
+ { :column01_label => "03/09", :column02_label => 102, :column03_label => 103, :column04_label => 104 },
20
+ { :column01_label => "03/10", :column02_label => 202, :column03_label => 203, :column04_label => 204 },
21
+ { :column01_label => "03/11", :column02_label => 302, :column03_label => 303, :column04_label => 304 },
22
+ { :column01_label => "03/12", :column02_label => 402, :column03_label => 403, :column04_label => 404 },
23
+ { :column01_label => "03/13", :column02_label => 502, :column03_label => 503, :column04_label => 504 },
24
+ { :column01_label => "03/14", :column02_label => 602, :column03_label => 603, :column04_label => 604 },
25
+ { :column01_label => "03/15", :column02_label => 702, :column03_label => 703, :column04_label => 704 },
26
+ { :column01_label => "03/16", :column02_label => 702, :column03_label => 703, :column04_label => 704 },
27
+ ]
28
+ }
29
+ }
30
+ }
31
+ prep.generate("#{$0}.pdf", values)
@@ -0,0 +1,74 @@
1
+ require File.join(File.dirname(__FILE__), "..", "lib", "prep")
2
+
3
+ prep = PREP::Core::Prep.new("sample5.yml")
4
+ values = {
5
+ :content => {
6
+ :out_table => {
7
+ :header => { :header_title => "hoge" },
8
+ :values => [
9
+ {
10
+ :inner_table => {
11
+ :header => { :header_title => "hogehoge" },
12
+ :values => [
13
+ { :inner_table_content_column01_label => "1-1" },
14
+ { :inner_table_content_column01_label => "1-2" },
15
+ { :inner_table_content_column01_label => "1-3" },
16
+ { :inner_table_content_column01_label => "1-4" },
17
+ ],
18
+ },
19
+ },
20
+ {
21
+ :inner_table => {
22
+ :values => [
23
+ { :inner_table_content_column01_label => "2-1" },
24
+ { :inner_table_content_column01_label => "2-2" },
25
+ { :inner_table_content_column01_label => "2-3" },
26
+ { :inner_table_content_column01_label => "2-4" },
27
+ ],
28
+ },
29
+ },
30
+ {
31
+ :inner_table => {
32
+ :values => [
33
+ { :inner_table_content_column01_label => "3-1" },
34
+ { :inner_table_content_column01_label => "3-2" },
35
+ { :inner_table_content_column01_label => "3-3" },
36
+ { :inner_table_content_column01_label => "3-4" },
37
+ ],
38
+ },
39
+ },
40
+ {
41
+ :inner_table => {
42
+ :values => [
43
+ { :inner_table_content_column01_label => "4-1" },
44
+ { :inner_table_content_column01_label => "4-2" },
45
+ { :inner_table_content_column01_label => "4-3" },
46
+ { :inner_table_content_column01_label => "4-4" },
47
+ ],
48
+ },
49
+ },
50
+ {
51
+ :inner_table => {
52
+ :values => [
53
+ { :inner_table_content_column01_label => "5-1" },
54
+ { :inner_table_content_column01_label => "5-2" },
55
+ { :inner_table_content_column01_label => "5-3" },
56
+ { :inner_table_content_column01_label => "5-4" },
57
+ ],
58
+ },
59
+ },
60
+ {
61
+ :inner_table => {
62
+ :values => [
63
+ { :inner_table_content_column01_label => "6-1" },
64
+ { :inner_table_content_column01_label => "6-2" },
65
+ { :inner_table_content_column01_label => "6-3" },
66
+ { :inner_table_content_column01_label => "6-4" },
67
+ ],
68
+ },
69
+ },
70
+ ],
71
+ }
72
+ }
73
+ }
74
+ prep.generate("#{$0}.pdf", values)
@@ -0,0 +1,40 @@
1
+ require File.join(File.dirname(__FILE__), "..", "lib", "prep")
2
+
3
+ prep = PREP::Core::Prep.new("sample6.yml")
4
+ values = {
5
+ :content => {
6
+ :out_table => {
7
+ :header => { :header_title => "hoge" },
8
+ :values => [
9
+ {
10
+ :inner_table => {
11
+ :header => { :inner_table_header_title => "First" },
12
+ :values => [
13
+ { :inner_table_content_column01_label => "1-1" },
14
+ { :inner_table_content_column01_label => "1-2" },
15
+ ],
16
+ },
17
+ },
18
+ {
19
+ :inner_table => {
20
+ :header => { :inner_table_header_title => "Second" },
21
+ :values => [
22
+ { :inner_table_content_column01_label => "2-1" },
23
+ { :inner_table_content_column01_label => "2-2" },
24
+ ],
25
+ },
26
+ },
27
+ {
28
+ :inner_table => {
29
+ :header => { :inner_table_header_title => "Third" },
30
+ :values => [
31
+ { :inner_table_content_column01_label => "3-1" },
32
+ { :inner_table_content_column01_label => "3-2" },
33
+ ],
34
+ },
35
+ },
36
+ ],
37
+ }
38
+ }
39
+ }
40
+ prep.generate("#{$0}.pdf", values)