clamsy 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,54 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Clamsy" do
4
+
5
+ behaves_like 'has standard files support'
6
+
7
+ before do
8
+ @check_processing_yields_text = lambda do |contexts, example|
9
+ generated_pdf = tmp_file('clamsy_pdf').path
10
+ expected_content = comparable_content(expected_pdf(example))
11
+ Clamsy.process(contexts, template_odt(example), generated_pdf)
12
+ comparable_content(generated_pdf).should.equal expected_content
13
+ end
14
+ end
15
+
16
+ after do
17
+ trash_tmp_files
18
+ end
19
+
20
+ it 'should do #{...} plain text replacement' do
21
+ @check_processing_yields_text[
22
+ context = {:someone => 'Peter', :mood => 'Happy'},
23
+ example = :plain_text
24
+ ]
25
+ end
26
+
27
+ it 'should do ${...} escaped (santized) replacement' do
28
+ @check_processing_yields_text[
29
+ context = {:someone => '<Peter>', :mood => '<Happy>'},
30
+ example = :escaped_text
31
+ ]
32
+ end
33
+
34
+ it 'should do {? ... ?} embedded ruby statements' do
35
+ @someone = Class.new do
36
+ attr_reader :name, :mood
37
+ def initialize(name, mood)
38
+ @name, @mood = name, mood
39
+ end
40
+ end
41
+ @check_processing_yields_text[
42
+ context = {:everyone => [@someone.new('Peter','Happy'), @someone.new('Jane','Sad')]},
43
+ example = :embedded_ruby
44
+ ]
45
+ end
46
+
47
+ it 'should concat multiple contexts processing to a single pdf' do
48
+ @check_processing_yields_text[
49
+ contexts = [{:someone => 'Peter', :mood => 'Happy'}, {:someone => 'Jane', :mood => 'Sad'}],
50
+ example = :multiple_contexts
51
+ ]
52
+ end
53
+
54
+ end
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,34 @@
1
+ require 'rubygems'
2
+ require 'bacon'
3
+ require 'differ'
4
+ require 'tempfile'
5
+
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
8
+ require 'clamsy'
9
+
10
+ shared 'has standard files support' do
11
+ class << self
12
+ def data_file(file)
13
+ File.join(File.dirname(__FILE__), 'data', file)
14
+ end
15
+ def template_odt(name)
16
+ data_file("#{name}_example.odt")
17
+ end
18
+ def expected_pdf(name)
19
+ data_file("#{name}_example.pdf")
20
+ end
21
+ def comparable_content(file)
22
+ `pdf2ps #{file} -`.grep(/^[^%][^%]?/).
23
+ reject {|line| line =~ /^q\[\-?\d+( \-?\d+){5}\]concat\n$/ }
24
+ end
25
+ def trash_tmp_files
26
+ (@trashable_tmp_files || []).select {|f| f.path }.map(&:unlink)
27
+ end
28
+ def tmp_file(file_name)
29
+ ((@trashable_tmp_files ||= []) << Tempfile.new(file_name))[-1]
30
+ end
31
+ end
32
+ end
33
+
34
+ Bacon.summary_on_exit
metadata ADDED
@@ -0,0 +1,124 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: clamsy
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - NgTzeYang
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-04-21 00:00:00 +08:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rubyzip
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ - 9
30
+ - 4
31
+ version: 0.9.4
32
+ type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: bacon
36
+ prerelease: false
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ segments:
42
+ - 1
43
+ - 1
44
+ - 0
45
+ version: 1.1.0
46
+ type: :development
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: differ
50
+ prerelease: false
51
+ requirement: &id003 !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ segments:
56
+ - 0
57
+ - 1
58
+ - 1
59
+ version: 0.1.1
60
+ type: :development
61
+ version_requirements: *id003
62
+ description: ""
63
+ email: ngty77@gmail.com
64
+ executables: []
65
+
66
+ extensions: []
67
+
68
+ extra_rdoc_files:
69
+ - LICENSE
70
+ - README.rdoc
71
+ files:
72
+ - .document
73
+ - .gitignore
74
+ - HISTORY.txt
75
+ - LICENSE
76
+ - README.rdoc
77
+ - Rakefile
78
+ - VERSION
79
+ - clamsy.gemspec
80
+ - lib/clamsy.rb
81
+ - lib/clamsy/tenjin.rb
82
+ - spec/clamsy_spec.rb
83
+ - spec/data/embedded_ruby_example.odt
84
+ - spec/data/embedded_ruby_example.pdf
85
+ - spec/data/escaped_text_example.odt
86
+ - spec/data/escaped_text_example.pdf
87
+ - spec/data/multiple_contexts_example.odt
88
+ - spec/data/multiple_contexts_example.pdf
89
+ - spec/data/plain_text_example.odt
90
+ - spec/data/plain_text_example.pdf
91
+ - spec/spec_helper.rb
92
+ has_rdoc: true
93
+ homepage: http://github.com/ngty/clamsy
94
+ licenses: []
95
+
96
+ post_install_message:
97
+ rdoc_options:
98
+ - --charset=UTF-8
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ segments:
106
+ - 0
107
+ version: "0"
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ segments:
113
+ - 0
114
+ version: "0"
115
+ requirements: []
116
+
117
+ rubyforge_project:
118
+ rubygems_version: 1.3.6
119
+ signing_key:
120
+ specification_version: 3
121
+ summary: A clumsily shellish way to generate a single pdf for multiple contexts from an odt template
122
+ test_files:
123
+ - spec/clamsy_spec.rb
124
+ - spec/spec_helper.rb