obf 0.6.34 → 0.6.35

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 416bb3ff468164c0a7e151c67c9710fcabc99d5a
4
- data.tar.gz: 440441ddd3f9c072c2cfbfa8620d1cea6ca6f2c7
3
+ metadata.gz: 228e90f86ce6db43787977a6bb7cd1f6f4d39900
4
+ data.tar.gz: 203727214e253dd6a74d5a75447ae573e53b3aa7
5
5
  SHA512:
6
- metadata.gz: 3e0b2d4bff94a850f85b4205e7a6013f8ce04adbab30e0d14a040f32ba21795fe88485dcfde5f1a2549eb479ee427bb3d847304512451305a37ff60570f5eef1
7
- data.tar.gz: c09b2c367f3642fb8866a12581837b5d100f88a5774d19d8cc32dec130491a37d766c45583940501a45c3720ffd441de891c3b9ca6253f295c0f95a6b1c68e73
6
+ metadata.gz: 37fd4c26cef380a016a823e1aad43afa27a6a276b19e4bc84b411aac4cf05f1b9348780ede7ea9832582db17cd1987aa318bfd358a5ce496753724b084e6f0fe
7
+ data.tar.gz: f2724e1433bdf347639f95502df4e56162bdff565f932c75ee6562a5aa9f8b1769afb736df20c0e456591db4171f723c323f9477725d7d61565959014546aedc
@@ -326,14 +326,14 @@ module OBF::External
326
326
  OBF::External.to_obz(board, tmp_path, opts)
327
327
  end
328
328
  OBF::Utils.as_progress_percent(0.3, 1.0) do
329
- OBF::OBZ.to_pdf(tmp_path, dest_path)
329
+ OBF::OBZ.to_pdf(tmp_path, dest_path, opts)
330
330
  end
331
331
  else
332
332
  OBF::Utils.as_progress_percent(0, 0.5) do
333
333
  self.to_obf(board, tmp_path)
334
334
  end
335
335
  OBF::Utils.as_progress_percent(0.5, 1.0) do
336
- OBF::OBF.to_pdf(tmp_path, dest_path)
336
+ OBF::OBF.to_pdf(tmp_path, dest_path, opts)
337
337
  end
338
338
  end
339
339
  File.unlink(tmp_path) if File.exist?(tmp_path)
@@ -9,8 +9,8 @@ module OBF::OBF
9
9
  OBF::External.to_obf(board, dest_path)
10
10
  end
11
11
 
12
- def self.to_pdf(obf, dest_path)
13
- OBF::PDF.from_obf(obf, dest_path)
12
+ def self.to_pdf(obf, dest_path, opts={})
13
+ OBF::PDF.from_obf(obf, dest_path, nil, opts)
14
14
  end
15
15
 
16
16
  def self.to_png(obf, dest_path)
@@ -7,7 +7,7 @@ module OBF::OBZ
7
7
  OBF::External.to_obz(content, dest_path, opts)
8
8
  end
9
9
 
10
- def self.to_pdf(obz, dest_path)
11
- OBF::PDF.from_obz(obz, dest_path)
10
+ def self.to_pdf(obz, dest_path, opts={})
11
+ OBF::PDF.from_obz(obz, dest_path, opts)
12
12
  end
13
13
  end
@@ -18,18 +18,18 @@ module OBF::PDF
18
18
  @@footer_url = url
19
19
  end
20
20
 
21
- def self.from_obf(obf_json_or_path, dest_path, zipper=nil)
21
+ def self.from_obf(obf_json_or_path, dest_path, zipper=nil, opts={})
22
22
  obj = obf_json_or_path
23
23
  if obj.is_a?(String)
24
24
  obj = OBF::Utils.parse_obf(File.read(obf_json_or_path))
25
25
  else
26
26
  obj = OBF::Utils.parse_obf(obf_json_or_path)
27
27
  end
28
- build_pdf(obj, dest_path, zipper)
28
+ build_pdf(obj, dest_path, zipper, opts)
29
29
  return dest_path
30
30
  end
31
31
 
32
- def self.build_pdf(obj, dest_path, zipper)
32
+ def self.build_pdf(obj, dest_path, zipper, opts={})
33
33
  OBF::Utils.as_progress_percent(0, 1.0) do
34
34
  # parse obf, draw as pdf
35
35
  pdf = Prawn::Document.new(
@@ -47,7 +47,7 @@ module OBF::PDF
47
47
  post = (idx + 1).to_f / obj['boards'].length.to_f
48
48
  OBF::Utils.as_progress_percent(pre, post) do
49
49
  pdf.start_new_page unless idx == 0
50
- build_page(pdf, board, {'zipper' => zipper, 'pages' => obj['pages']})
50
+ build_page(pdf, board, {'zipper' => zipper, 'pages' => obj['pages'], 'headerless' => !!opts['headerless']})
51
51
  end
52
52
  end
53
53
  else
@@ -64,46 +64,50 @@ module OBF::PDF
64
64
  doc_height = 8.5*72 - 72
65
65
  default_radius = 3
66
66
  text_height = 20
67
+ header_height = 0
67
68
 
68
69
  # header
69
- pdf.bounding_box([0, doc_height], :width => doc_width, :height => 100) do
70
- if options['pages']
71
- page_num = options['pages'][obj['id']]
72
- pdf.add_dest("page#{page_num}", pdf.dest_fit)
73
- end
74
- pdf.line_width = 2
75
- pdf.font_size 16
70
+ if !options['headerless']
71
+ header_height = 100
72
+ pdf.bounding_box([0, doc_height], :width => doc_width, :height => 100) do
73
+ if options['pages']
74
+ page_num = options['pages'][obj['id']]
75
+ pdf.add_dest("page#{page_num}", pdf.dest_fit)
76
+ end
77
+ pdf.line_width = 2
78
+ pdf.font_size 16
76
79
 
77
- pdf.fill_color "eeeeee"
78
- pdf.stroke_color "888888"
79
- pdf.fill_and_stroke_rounded_rectangle [0, 100], 100, 100, default_radius
80
- pdf.fill_color "6D81D1"
81
- pdf.fill_and_stroke_polygon([5, 50], [35, 85], [35, 70], [95, 70], [95, 30], [35, 30], [35, 15])
82
- pdf.fill_color "ffffff"
83
- pdf.formatted_text_box [{:text => "Go Back", :anchor => "page1"}], :at => [10, 90], :width => 80, :height => 80, :align => :center, :valign => :center, :overflow => :shrink_to_fit
84
- pdf.fill_color "ffffff"
85
- pdf.fill_and_stroke_rounded_rectangle [110, 100], (doc_width - 200 - 20), 100, default_radius
86
- pdf.fill_color "DDDB54"
87
- pdf.fill_and_stroke do
88
- pdf.move_to 160, 50
89
- pdf.line_to 190, 70
90
- pdf.curve_to [190, 30], :bounds => [[100, 130], [100, -30]]
91
- pdf.line_to 160, 50
80
+ pdf.fill_color "eeeeee"
81
+ pdf.stroke_color "888888"
82
+ pdf.fill_and_stroke_rounded_rectangle [0, 100], 100, 100, default_radius
83
+ pdf.fill_color "6D81D1"
84
+ pdf.fill_and_stroke_polygon([5, 50], [35, 85], [35, 70], [95, 70], [95, 30], [35, 30], [35, 15])
85
+ pdf.fill_color "ffffff"
86
+ pdf.formatted_text_box [{:text => "Go Back", :anchor => "page1"}], :at => [10, 90], :width => 80, :height => 80, :align => :center, :valign => :center, :overflow => :shrink_to_fit
87
+ pdf.fill_color "ffffff"
88
+ pdf.fill_and_stroke_rounded_rectangle [110, 100], (doc_width - 200 - 20), 100, default_radius
89
+ pdf.fill_color "DDDB54"
90
+ pdf.fill_and_stroke do
91
+ pdf.move_to 160, 50
92
+ pdf.line_to 190, 70
93
+ pdf.curve_to [190, 30], :bounds => [[100, 130], [100, -30]]
94
+ pdf.line_to 160, 50
95
+ end
96
+ pdf.fill_color "444444"
97
+ pdf.text_box "Say that sentence out loud for me", :at => [210, 90], :width => (doc_width - 200 - 120), :height => 80, :align => :left, :valign => :center, :overflow => :shrink_to_fit
98
+ pdf.fill_color "eeeeee"
99
+ pdf.fill_and_stroke_rounded_rectangle [(doc_width - 100), 100], 100, 100, default_radius
100
+ pdf.fill_color "aaaaaa"
101
+ pdf.fill_and_stroke_polygon([doc_width - 100 + 5, 50], [doc_width - 100 + 35, 85], [doc_width - 100 + 95, 85], [doc_width - 100 + 95, 15], [doc_width - 100 + 35, 15])
102
+ pdf.fill_color "ffffff"
103
+ pdf.text_box "Erase", :at => [(doc_width - 100 + 10), 90], :width => 80, :height => 80, :align => :center, :valign => :center, :overflow => :shrink_to_fit
92
104
  end
93
- pdf.fill_color "444444"
94
- pdf.text_box "Say that sentence out loud for me", :at => [210, 90], :width => (doc_width - 200 - 120), :height => 80, :align => :left, :valign => :center, :overflow => :shrink_to_fit
95
- pdf.fill_color "eeeeee"
96
- pdf.fill_and_stroke_rounded_rectangle [(doc_width - 100), 100], 100, 100, default_radius
97
- pdf.fill_color "aaaaaa"
98
- pdf.fill_and_stroke_polygon([doc_width - 100 + 5, 50], [doc_width - 100 + 35, 85], [doc_width - 100 + 95, 85], [doc_width - 100 + 95, 15], [doc_width - 100 + 35, 15])
99
- pdf.fill_color "ffffff"
100
- pdf.text_box "Erase", :at => [(doc_width - 100 + 10), 90], :width => 80, :height => 80, :align => :center, :valign => :center, :overflow => :shrink_to_fit
101
105
  end
102
106
 
103
107
  # board
104
108
  pdf.font_size 12
105
109
  padding = 10
106
- grid_height = doc_height - 100 - text_height - (padding * 2)
110
+ grid_height = doc_height - header_height - text_height - (padding * 2)
107
111
  grid_width = doc_width
108
112
  if obj['grid'] && obj['grid']['rows'] > 0 && obj['grid']['columns'] > 0
109
113
  button_height = (grid_height - (padding * (obj['grid']['rows'] - 1))) / obj['grid']['rows'].to_f
@@ -169,7 +173,7 @@ module OBF::PDF
169
173
  end
170
174
  end
171
175
 
172
- def self.from_obz(obz_path, dest_path)
176
+ def self.from_obz(obz_path, dest_path, opts={})
173
177
  OBF::Utils.load_zip(obz_path) do |zipper|
174
178
  manifest = JSON.parse(zipper.read('manifest.json'))
175
179
  root = manifest['root']
@@ -207,7 +211,7 @@ module OBF::PDF
207
211
  'name' => 'Communication Board Set',
208
212
  'boards' => visited_boards,
209
213
  'pages' => pages
210
- }, dest_path, zipper)
214
+ }, dest_path, zipper, opts)
211
215
  end
212
216
  # parse obz, draw as pdf
213
217
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: obf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.34
4
+ version: 0.6.35
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Whitmer