dot_grid 0.0.1 → 0.0.3

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: b2eb07008921026109c18d4bbd3a5b8ef26749ad
4
- data.tar.gz: 105ac72b97ae095b5d65152bfebb9a3b2a1f4d54
3
+ metadata.gz: 37dc6770f99c575f28ae776313c5f63d578b5bb2
4
+ data.tar.gz: 2ce9b5d286a2ee92eab7c0dbc14321827d6c3040
5
5
  SHA512:
6
- metadata.gz: 7f336bf84d1e03da4caf6052f841d2293148875617b8e812c43a14ef2386e0d12b43366301dd4e451f64037906748712426cca488ed37e45e1dff8e73a80212b
7
- data.tar.gz: 139f2c99cf31b99c14ffad24c73549fadea6b206f475dfbd553e6c17daae69fc422f62a6a6a9f6ff64387a123bc35602844bcb3c1670581df7d00de7fb6607a6
6
+ metadata.gz: 825a31391384cfd28e187a1944d29ffd13951d3506666bbc26cf1cd63e716de4a71961fd8759209f5ac9094ddc9ee785deb8bc08b6235d575a54377acc9a7a27
7
+ data.tar.gz: cc2932c0ac9baf8ae5b42685e58be4b4c704a3810bd8a0eda07466eed76903a57412b9974a3258b4207b1af89a7c46e73acf84d19d2188b45844cdbaa737d258
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- dot_grid (0.0.1)
4
+ dot_grid (0.0.3)
5
5
  prawn (~> 1.0.0)
6
6
  require_all (~> 1.3.2)
7
7
  trollop (~> 2.0)
data/base CHANGED
@@ -1,4 +1,4 @@
1
1
  # Base planner
2
- ruby dotgrid.rb -f dotgrid_w5_c2dfff_no_grid.pdf --no-grid --grid-color CFBAEC --dot-weight 0.5 -m 0.0 --planner --planner-color-1 dddddd --planner-color-2 C2DFFF
2
+ bin/dotgrid -f dotgrid_w5_c2dfff_no_grid.pdf --no-grid --grid-color CFBAEC --dot-weight 0.5 -m 0.0 --planner --planner-color-1 dddddd --planner-color-2 C2DFFF
3
3
 
4
- ruby dotgrid.rb -f dotgrid_w75_c2dfff_no_grid.pdf --no-grid --grid-color CFBAEC --dot-weight 0.75 -m 0.0 --planner --planner-color-1 dddddd --planner-color-2 C2DFFF
4
+ bin/dotgrid -f dotgrid_w75_c2dfff_no_grid.pdf --no-grid --grid-color CFBAEC --dot-weight 0.75 -m 0.0 --planner --planner-color-1 dddddd --planner-color-2 C2DFFF
@@ -5,49 +5,98 @@ module DotGrid
5
5
  :planner_color_2
6
6
  )
7
7
 
8
+ HEADER_HEIGHT = 0.05 # 5.0 %
9
+ HEADER_LEFT_START = 0.05 # 5.0%
10
+ SQUARE_GRID_WIDTH = 0.30 # 30.0%
11
+ HEADER_GAP_WIDTH = 0.03 # 3.0%
12
+ DOT_GRID_COLUMN_WIDTH = 0.62 # 62%
13
+ SQUARE_GRID_ROWS_WIDTH = 0.80 # 80%
14
+ FOOT_HEIGHT_RATIO = 2 # Ratio of footer to header
15
+
8
16
  def initialize(params)
9
17
  super
10
18
  @planner_color_1 = params[:planner_color_1] || "CCCCCC"
11
19
  @planner_color_2 = params[:planner_color_2] || "0099ff"
12
20
  end
13
21
 
14
- def generate
15
- pdf.start_new_page
22
+ def header_height
23
+ HEADER_HEIGHT * page_height
24
+ end
25
+
26
+ def square_grid_columns
27
+ ((SQUARE_GRID_WIDTH * page_width) / spacing).floor
28
+ end
29
+
30
+ def header_left_color
31
+ planner_color_1
32
+ end
16
33
 
17
- width = page_width
18
- height = page_height
19
- header_height = 0.05 * height
34
+ def header_left_start
35
+ HEADER_LEFT_START * page_width
36
+ end
37
+
38
+ def header_left_width
39
+ square_grid_columns*spacing
40
+ end
20
41
 
21
- square_grid_rows = 45
22
- square_grid_columns = 13
42
+ def header_gap_start
43
+ header_left_start + header_left_width
44
+ end
23
45
 
24
- header_left_color = planner_color_1
25
- header_left_start = width*0.05
26
- header_left_width = square_grid_columns*spacing
46
+ def header_gap_width
47
+ page_width * HEADER_GAP_WIDTH
48
+ end
27
49
 
28
- header_gap_start = header_left_start + header_left_width
29
- header_gap_width = width*0.03
50
+ def dot_grid_columns
51
+ (page_width * DOT_GRID_COLUMN_WIDTH / spacing).floor + 2
52
+ end
30
53
 
31
- header_right_color = planner_color_2
32
- header_right_start = header_gap_start + header_gap_width
33
- header_right_width = width - header_right_start
54
+ def dot_grid_rows
55
+ square_grid_rows + 1
56
+ end
57
+
58
+ def header_right_color
59
+ planner_color_2
60
+ end
61
+
62
+ def header_right_start
63
+ header_gap_start + header_gap_width
64
+ end
65
+
66
+ def header_right_width
67
+ page_width - header_right_start
68
+ end
69
+
70
+ def square_grid_rows
71
+ (page_height * SQUARE_GRID_ROWS_WIDTH / spacing).floor
72
+ end
73
+
74
+ def footer_height
75
+ header_height * FOOT_HEIGHT_RATIO
76
+ end
77
+
78
+ def generate
79
+ pdf.start_new_page
34
80
 
35
81
  # Header left
36
- pdf.fill_color header_left_color
37
- pdf.fill_rectangle [header_left_start, height], header_left_width, header_height
82
+ draw_header(header_left_start, header_left_width, header_height, header_left_color)
38
83
 
39
84
  # Header right
40
- pdf.fill_color header_right_color
41
- pdf.fill_rectangle [header_right_start, height], header_right_width, header_height
85
+ draw_header(header_right_start, header_right_width, header_height, header_right_color)
42
86
 
43
87
  # Square Grid Left
44
- draw_square_grid_left(square_grid_rows, square_grid_columns, header_left_color, header_left_start, height - header_height - spacing, spacing)
88
+ draw_square_grid_left(square_grid_rows, square_grid_columns, header_left_color, header_left_start, page_height - header_height - spacing, spacing)
45
89
 
46
90
  # Dot Grid Right
47
- draw_dot_grid(46, 28, header_right_start, height-header_height)
91
+ draw_dot_grid(dot_grid_rows, dot_grid_columns, header_right_start, page_height-header_height)
48
92
 
49
93
  # Footer
50
- draw_footer(planner_color_1, header_left_start, header_height*2, width-header_left_start)
94
+ draw_footer(planner_color_1, header_left_start, footer_height, page_width-header_left_start)
95
+ end
96
+
97
+ def draw_header(header_start, header_width, header_height, header_color)
98
+ pdf.fill_color header_color
99
+ pdf.fill_rectangle [header_start, page_height], header_width, header_height
51
100
  end
52
101
 
53
102
  def draw_square_grid_left(square_grid_rows, square_grid_columns, grid_color, left_start, height_start, spacing)
@@ -57,7 +106,6 @@ module DotGrid
57
106
  pdf.fill_rectangle [left_start + (col-1)*spacing, height_start - (row-1)*spacing], spacing-1 ,spacing-1
58
107
  end
59
108
  end
60
-
61
109
  end
62
110
 
63
111
  def draw_footer(footer_color, footer_start, footer_height, footer_width)
@@ -1,3 +1,3 @@
1
1
  module DotGrid
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -13,6 +13,94 @@ describe "DotGrid::Planner" do
13
13
  end
14
14
  end
15
15
 
16
+ describe "#header_height" do
17
+ let(:pdf) { double('pdf') }
18
+ let(:subject) { DotGrid::Planner.new({:pdf => pdf }) }
19
+
20
+ it "returns the HEADER_HEIGHT of the header height" do
21
+ allow(subject).to receive(:page_height).and_return(20)
22
+ expect(subject.header_height).to eq(DotGrid::Planner::HEADER_HEIGHT * subject.page_height)
23
+ end
24
+ end
25
+
26
+ describe "#header_height" do
27
+ let(:pdf) { double('pdf') }
28
+ let(:subject) { DotGrid::Planner.new({:pdf => pdf }) }
29
+
30
+ it "returns the HEADER_HEIGHT of the header height" do
31
+ allow(subject).to receive(:page_height).and_return(20)
32
+ expect(subject.header_height).to eq(DotGrid::Planner::HEADER_HEIGHT * subject.page_height)
33
+ end
34
+ end
35
+
36
+ describe "#square_grid_columns" do
37
+ let(:pdf) { double('pdf') }
38
+ let(:subject) { DotGrid::Planner.new({:pdf => pdf, spacing: 5 }) }
39
+
40
+ it "returns the HEADER_HEIGHT of the header height" do
41
+ allow(subject).to receive(:page_width).and_return(100)
42
+ expect(subject.square_grid_columns).to eq((DotGrid::Planner::SQUARE_GRID_WIDTH * subject.page_width / subject.spacing).floor)
43
+ end
44
+ end
45
+
46
+ describe "#header_left_color" do
47
+ let(:pdf) { double('pdf') }
48
+ let(:subject) { DotGrid::Planner.new({:pdf => pdf, planner_color_1: "DDEEFF" }) }
49
+ it "returns the planner color 1" do
50
+ expect(subject.header_left_color).to eq("DDEEFF")
51
+ end
52
+ end
53
+
54
+ describe "#header_left_start" do
55
+ let(:pdf) { double('pdf') }
56
+ let(:subject) { DotGrid::Planner.new({:pdf => pdf }) }
57
+
58
+ it "returns the the header left_start" do
59
+ allow(subject).to receive(:page_width).and_return(30)
60
+ expect(subject.header_left_start).to eq(DotGrid::Planner::HEADER_LEFT_START * subject.page_width)
61
+ end
62
+ end
63
+
64
+ describe "#header_gap_width" do
65
+ let(:pdf) { double('pdf') }
66
+ let(:subject) { DotGrid::Planner.new({:pdf => pdf }) }
67
+
68
+ it "returns the the header gap width" do
69
+ allow(subject).to receive(:page_width).and_return(30)
70
+ expect(subject.header_gap_width).to eq(DotGrid::Planner::HEADER_GAP_WIDTH * subject.page_width)
71
+ end
72
+ end
73
+
74
+ describe "#header_right_color" do
75
+ let(:pdf) { double('pdf') }
76
+ let(:subject) { DotGrid::Planner.new({:pdf => pdf, planner_color_2: "FFEEDD" }) }
77
+ it "returns the planner color 1" do
78
+ expect(subject.header_right_color).to eq("FFEEDD")
79
+ end
80
+ end
81
+
82
+ describe "#dot_grid_rows" do
83
+ let(:pdf) { double('pdf') }
84
+ let(:subject) { DotGrid::Planner.new({:pdf => pdf }) }
85
+ let(:square_grid_rows) { 10 }
86
+
87
+ it "returns the foot height" do
88
+ allow(subject).to receive(:square_grid_rows).and_return(square_grid_rows)
89
+ expect(subject.dot_grid_rows).to eq(square_grid_rows+1)
90
+ end
91
+ end
92
+
93
+ describe "#footer_height" do
94
+ let(:pdf) { double('pdf') }
95
+ let(:subject) { DotGrid::Planner.new({:pdf => pdf }) }
96
+ let(:header_height) { 100 }
97
+
98
+ it "returns the foot height" do
99
+ allow(subject).to receive(:header_height).and_return(header_height)
100
+ expect(subject.footer_height).to eq(header_height*DotGrid::Planner::FOOT_HEIGHT_RATIO)
101
+ end
102
+ end
103
+
16
104
  describe "#generate" do
17
105
  let(:pdf) { double('pdf') }
18
106
  let(:subject) { DotGrid::Planner.new({:pdf => pdf }) }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dot_grid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott LaBounty
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-26 00:00:00.000000000 Z
11
+ date: 2014-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec