teaching_printables 0.0.0 → 0.0.1
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.
- checksums.yaml +4 -4
- data/bin/flashcards_AVERY5371 +6 -0
- data/lib/teaching_printables/grid_sheet/grid_sheet.rb +57 -0
- data/lib/teaching_printables/printing/templates.rb +34 -0
- data/lib/teaching_printables/utilities.rb +8 -0
- data/lib/teaching_printables.rb +32 -92
- metadata +7 -3
- data/lib/grid_sheet.rb +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2a91589527790eb2f14edb1f075363c4fea6d5ac
|
4
|
+
data.tar.gz: e3816888c4b37ec71f00b542a39c5135222988d3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1cca5307f42898442aa5bb2dd4feaacea8e0992acafc8a3e4d2ec6b035ace8fd4b641f27aff9c4b7ff0e05ca13d1a03a702500415d960f25b97e9539684f9bc8
|
7
|
+
data.tar.gz: f5a49d0235f0c20fc05b57943abc707030ead36d0db56c6010a9a984eaa267e71c089857e16047611bd574bc75097f9b18699bd8bc8d049955feae1212ad0a0a
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require_relative "../utilities"
|
2
|
+
|
3
|
+
module TeachingPrintables
|
4
|
+
class GridSheet
|
5
|
+
include Prawn::View
|
6
|
+
|
7
|
+
GRID_OPTIONS_DEFAULT = {
|
8
|
+
columns: 2,
|
9
|
+
rows: 2,
|
10
|
+
gutter: 0,
|
11
|
+
column_width: 100,
|
12
|
+
row_height: 100
|
13
|
+
}
|
14
|
+
|
15
|
+
def initialize(args={})
|
16
|
+
@document = Prawn::Document.new(args)
|
17
|
+
@font_size = 60
|
18
|
+
update_grid_options(args)
|
19
|
+
end
|
20
|
+
|
21
|
+
def update_grid_options(options)
|
22
|
+
GRID_OPTIONS_DEFAULT.each do |k,v|
|
23
|
+
instance_variable_set("@#{k}", options[k]) unless options[k].nil?
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def make_grid(content_array)
|
28
|
+
puts grid_options
|
29
|
+
@document.define_grid(grid_options)
|
30
|
+
content_array.each_with_index {|obj,ind|
|
31
|
+
|
32
|
+
if ind > 0 && ind%10==0
|
33
|
+
@document.start_new_page
|
34
|
+
end
|
35
|
+
|
36
|
+
subs = ind2sub([@rows,@columns],ind%10)
|
37
|
+
@document.grid(subs[0],subs[1]).bounding_box do
|
38
|
+
#place_contents_in_gridbox(obj)
|
39
|
+
@document.text_box obj.to_s, align: :center, valign: :center, size: @font_size, overflow: :shrink_to_fit
|
40
|
+
end
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
def place_contents_in_gridbox(obj)
|
47
|
+
text obj.to_s, fit: [@column_width,@row_height]
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
def grid_options
|
52
|
+
keys = GRID_OPTIONS_DEFAULT.keys
|
53
|
+
Hash[keys.map { |key| [key.to_sym, instance_variable_get("@#{key}")] } ]
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module TeachingPrintables
|
2
|
+
module Printing
|
3
|
+
module Templates
|
4
|
+
|
5
|
+
COMPULABEL = {
|
6
|
+
:page_layout => :portrait,
|
7
|
+
:page_size => "LETTER",
|
8
|
+
:top_margin => 0.25.in,
|
9
|
+
:bottom_margin => 0.25.in,
|
10
|
+
:right_margin => 0.in,
|
11
|
+
:left_margin => 0.in,
|
12
|
+
:columns => 3,
|
13
|
+
:rows => 7,
|
14
|
+
:gutter => 10,
|
15
|
+
:column_width => 2.81.in,
|
16
|
+
:row_height => 1.5.in
|
17
|
+
}
|
18
|
+
|
19
|
+
AVERY5371 = {
|
20
|
+
:page_layout => :portrait,
|
21
|
+
:page_size => "LETTER",
|
22
|
+
:top_margin => 0.5.in,
|
23
|
+
:bottom_margin => 0.5.in,
|
24
|
+
:right_margin => 0.75.in,
|
25
|
+
:left_margin => 0.75.in,
|
26
|
+
:columns => 2,
|
27
|
+
:rows => 5,
|
28
|
+
:gutter => 0,
|
29
|
+
:column_width => 3.5.in,
|
30
|
+
:row_height => 2.in
|
31
|
+
}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/teaching_printables.rb
CHANGED
@@ -1,113 +1,53 @@
|
|
1
1
|
require 'prawn'
|
2
2
|
require 'prawn/measurement_extensions'
|
3
3
|
|
4
|
-
def ind2sub(siz,ind)
|
5
|
-
if !siz || !ind || !siz.is_a?(Array) || siz.count!=2 || !ind.is_a?(Integer) || ind >= siz[0]*siz[1]
|
6
|
-
raise ArgumentError
|
7
|
-
end
|
8
|
-
|
9
|
-
return [ind%siz[0],ind/siz[0]]
|
10
|
-
end
|
11
4
|
|
12
|
-
|
13
|
-
|
14
|
-
!filename.start_with?(".") && GRAPHIC_EXTENSIONS.include?(File.extname(filename))
|
15
|
-
end
|
5
|
+
require_relative "teaching_printables/grid_sheet/grid_sheet"
|
6
|
+
require_relative "teaching_printables/printing/templates"
|
16
7
|
|
17
|
-
|
18
|
-
|
19
|
-
:page_size => "LETTER",
|
20
|
-
:top_margin => 0.25.in,
|
21
|
-
:bottom_margin => 0.25.in,
|
22
|
-
:right_margin => 0.in,
|
23
|
-
:left_margin => 0.in,
|
24
|
-
:columns => 3,
|
25
|
-
:rows => 7,
|
26
|
-
:gutter => 10,
|
27
|
-
:column_width => 2.81.in,
|
28
|
-
:row_height => 1.5.in
|
29
|
-
}
|
8
|
+
module TeachingPrintables
|
9
|
+
extend self
|
30
10
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
:top_margin => 0.5.in,
|
35
|
-
:bottom_margin => 0.5.in,
|
36
|
-
:right_margin => 0.75.in,
|
37
|
-
:left_margin => 0.75.in,
|
38
|
-
:columns => 2,
|
39
|
-
:rows => 5,
|
40
|
-
:gutter => 0,
|
41
|
-
:column_width => 3.5.in,
|
42
|
-
:row_height => 2.in
|
43
|
-
}
|
11
|
+
file = __FILE__
|
12
|
+
file = File.readlink(file) if File.symlink?(file)
|
13
|
+
dir = File.dirname(file)
|
44
14
|
|
15
|
+
# The base source directory as installed on the system
|
45
16
|
|
46
|
-
|
47
|
-
include Prawn::View
|
17
|
+
BASEDIR = File.expand_path(File.join(dir, '..'))
|
48
18
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
gutter: 0,
|
53
|
-
column_width: 100,
|
54
|
-
row_height: 100
|
55
|
-
}
|
56
|
-
|
57
|
-
def initialize(args={})
|
58
|
-
@document = Prawn::Document.new(args)
|
59
|
-
@font_size = 60
|
60
|
-
update_grid_options(args)
|
19
|
+
GRAPHIC_EXTENSIONS = [".jpg",".JPG",".png",".jpeg"]
|
20
|
+
def is_image_file?(filename)
|
21
|
+
!filename.start_with?(".") && GRAPHIC_EXTENSIONS.include?(File.extname(filename))
|
61
22
|
end
|
62
23
|
|
63
|
-
|
64
|
-
|
65
|
-
|
24
|
+
|
25
|
+
class PictureGridSheet < GridSheet
|
26
|
+
def place_contents_in_gridbox(picture_filename)
|
27
|
+
image picture_filename, fit: [@column_width,@row_height]
|
66
28
|
end
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
def test_grid_sheet
|
33
|
+
gs = GridSheet.new(TeachingPrintables::Printing::Templates::AVERY5371)
|
34
|
+
content = %W[crow mow low slow tow boat moat goat oat float feet seat treat beep speed need steep wait train rain paint way play day say bay hay stay lay may ]
|
35
|
+
gs.make_grid(content)
|
36
|
+
gs.save_as("mygrid.pdf")
|
37
|
+
gs
|
67
38
|
end
|
68
39
|
|
69
|
-
def
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
if ind > 0 && ind%10==0
|
75
|
-
@document.start_new_page
|
76
|
-
end
|
77
|
-
|
78
|
-
subs = ind2sub([@rows,@columns],ind%10)
|
79
|
-
@document.grid(subs[0],subs[1]).bounding_box do
|
80
|
-
#place_contents_in_gridbox(obj)
|
81
|
-
@document.text_box obj.to_s, align: :center, valign: :center, size: @font_size, overflow: :shrink_to_fit
|
82
|
-
end
|
83
|
-
}
|
40
|
+
def grid_sheet_with_content(content_array)
|
41
|
+
gs = GridSheet.new(TeachingPrintables::Printing::Templates::AVERY5371)
|
42
|
+
gs.make_grid(content_array)
|
43
|
+
gs.save_as("mygrid.pdf")
|
44
|
+
puts "Sheet saved as mygrid.pdf"
|
84
45
|
end
|
85
|
-
def place_contents_in_gridbox(obj)
|
86
|
-
text obj.to_s, fit: [@column_width,@row_height]
|
87
|
-
end
|
88
|
-
|
89
|
-
private
|
90
|
-
def grid_options
|
91
|
-
keys = GRID_OPTIONS_DEFAULT.keys
|
92
|
-
Hash[keys.map { |key| [key.to_sym, instance_variable_get("@#{key}")] } ]
|
93
|
-
end
|
94
|
-
|
95
|
-
end
|
96
46
|
|
97
|
-
|
98
|
-
|
99
|
-
image picture_filename, fit: [@column_width,@row_height]
|
100
|
-
end
|
101
|
-
end
|
47
|
+
end
|
48
|
+
|
102
49
|
|
103
50
|
|
104
|
-
def test_grid_sheet
|
105
|
-
gs = GridSheet.new(AVERY5371)
|
106
|
-
content = %W[crow mow low slow tow boat moat goat oat float feet seat treat beep speed need steep wait train rain paint way play day say bay hay stay lay may ]
|
107
|
-
gs.make_grid(content)
|
108
|
-
gs.save_as("mygrid.pdf")
|
109
|
-
gs
|
110
|
-
end
|
111
51
|
|
112
52
|
|
113
53
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: teaching_printables
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jen Dobson
|
@@ -40,12 +40,16 @@ dependencies:
|
|
40
40
|
version: '0'
|
41
41
|
description: A gem to create printable sheets for teaching
|
42
42
|
email: jendobson@gmail.com
|
43
|
-
executables:
|
43
|
+
executables:
|
44
|
+
- flashcards_AVERY5371
|
44
45
|
extensions: []
|
45
46
|
extra_rdoc_files: []
|
46
47
|
files:
|
47
|
-
-
|
48
|
+
- bin/flashcards_AVERY5371
|
48
49
|
- lib/teaching_printables.rb
|
50
|
+
- lib/teaching_printables/grid_sheet/grid_sheet.rb
|
51
|
+
- lib/teaching_printables/printing/templates.rb
|
52
|
+
- lib/teaching_printables/utilities.rb
|
49
53
|
homepage: ''
|
50
54
|
licenses:
|
51
55
|
- MIT
|
data/lib/grid_sheet.rb
DELETED
File without changes
|