dot_grid 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +5 -0
- data/.ruby-version +1 -0
- data/.travis.yml +14 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +57 -0
- data/LICENSE +20 -0
- data/README.md +50 -0
- data/Rakefile +5 -0
- data/base +4 -0
- data/bin/dotgrid +25 -0
- data/dot_grid.gemspec +25 -0
- data/lib/dot_grid/generator.rb +37 -0
- data/lib/dot_grid/grid.rb +29 -0
- data/lib/dot_grid/page.rb +34 -0
- data/lib/dot_grid/planner.rb +68 -0
- data/lib/dot_grid/version.rb +3 -0
- data/lib/dot_grid.rb +7 -0
- data/spec/lib/dot_grid/generator_spec.rb +80 -0
- data/spec/lib/dot_grid/grid_spec.rb +19 -0
- data/spec/lib/dot_grid/page_spec.rb +54 -0
- data/spec/lib/dot_grid/planner_spec.rb +59 -0
- data/spec/spec_helper.rb +8 -0
- metadata +157 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b2eb07008921026109c18d4bbd3a5b8ef26749ad
|
4
|
+
data.tar.gz: 105ac72b97ae095b5d65152bfebb9a3b2a1f4d54
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7f336bf84d1e03da4caf6052f841d2293148875617b8e812c43a14ef2386e0d12b43366301dd4e451f64037906748712426cca488ed37e45e1dff8e73a80212b
|
7
|
+
data.tar.gz: 139f2c99cf31b99c14ffad24c73549fadea6b206f475dfbd553e6c17daae69fc422f62a6a6a9f6ff64387a123bc35602844bcb3c1670581df7d00de7fb6607a6
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0.0
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
dot_grid (0.0.1)
|
5
|
+
prawn (~> 1.0.0)
|
6
|
+
require_all (~> 1.3.2)
|
7
|
+
trollop (~> 2.0)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
coveralls (0.7.0)
|
13
|
+
multi_json (~> 1.3)
|
14
|
+
rest-client
|
15
|
+
simplecov (>= 0.7)
|
16
|
+
term-ansicolor
|
17
|
+
thor
|
18
|
+
diff-lcs (1.2.5)
|
19
|
+
docile (1.1.3)
|
20
|
+
mime-types (2.3)
|
21
|
+
multi_json (1.10.1)
|
22
|
+
pdf-core (0.2.5)
|
23
|
+
prawn (1.0.0)
|
24
|
+
pdf-core (~> 0.2.2)
|
25
|
+
ttfunk (~> 1.1.1)
|
26
|
+
rake (10.3.2)
|
27
|
+
require_all (1.3.2)
|
28
|
+
rest-client (1.6.7)
|
29
|
+
mime-types (>= 1.16)
|
30
|
+
rspec (2.14.1)
|
31
|
+
rspec-core (~> 2.14.0)
|
32
|
+
rspec-expectations (~> 2.14.0)
|
33
|
+
rspec-mocks (~> 2.14.0)
|
34
|
+
rspec-core (2.14.8)
|
35
|
+
rspec-expectations (2.14.5)
|
36
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
37
|
+
rspec-mocks (2.14.6)
|
38
|
+
simplecov (0.8.2)
|
39
|
+
docile (~> 1.1.0)
|
40
|
+
multi_json
|
41
|
+
simplecov-html (~> 0.8.0)
|
42
|
+
simplecov-html (0.8.0)
|
43
|
+
term-ansicolor (1.3.0)
|
44
|
+
tins (~> 1.0)
|
45
|
+
thor (0.19.1)
|
46
|
+
tins (1.3.0)
|
47
|
+
trollop (2.0)
|
48
|
+
ttfunk (1.1.1)
|
49
|
+
|
50
|
+
PLATFORMS
|
51
|
+
ruby
|
52
|
+
|
53
|
+
DEPENDENCIES
|
54
|
+
coveralls
|
55
|
+
dot_grid!
|
56
|
+
rake (~> 10.3.2)
|
57
|
+
rspec (~> 2.14.1)
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2013 Scott LaBounty
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/slabounty/dot_grid.svg?branch=master)](https://travis-ci.org/slabounty/dot_grid)
|
2
|
+
[![Coverage Status](https://coveralls.io/repos/slabounty/dot_grid/badge.png?branch=master)](https://coveralls.io/r/slabounty/dot_grid?branch=master)
|
3
|
+
[![Code Climate](https://codeclimate.com/github/slabounty/dot_grid.png)](https://codeclimate.com/github/slabounty/dot_grid)
|
4
|
+
|
5
|
+
# DotGrid: dot grid planning pages
|
6
|
+
|
7
|
+
A simple ruby file for generating dot grid graph paper.
|
8
|
+
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
gem install dot_grid
|
12
|
+
|
13
|
+
## CLI
|
14
|
+
|
15
|
+
A basic dot grid page can be generated like this ...
|
16
|
+
|
17
|
+
bin/dotgrid -f dotgrid.pdf --grid-color CFBAEC --dot-weight 0.5 -m 0.0
|
18
|
+
|
19
|
+
A basic planning page can be generated like this ...
|
20
|
+
|
21
|
+
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
|
22
|
+
|
23
|
+
To get help on the command and its options ...
|
24
|
+
bin/dotgrid --help
|
25
|
+
|
26
|
+
|
27
|
+
The options and their defaults are ...
|
28
|
+
|
29
|
+
<table>
|
30
|
+
<thead>
|
31
|
+
<tr>
|
32
|
+
<th>Long Option</th><th>Short Option</th><th>Default</th>
|
33
|
+
</tr>
|
34
|
+
</thead>
|
35
|
+
<tbody>
|
36
|
+
<tr><td>file-name</td><td>-f</td><td>dotgrid.pdf</td></tr>
|
37
|
+
<tr><td>grid</td><td>-g</td><td>true</td></tr>
|
38
|
+
<tr><td>dot-weight</td><td>-d</td><td>1.5</td></tr>
|
39
|
+
<tr><td>margin</td><td>-m</td><td>0.5</td></tr>
|
40
|
+
<tr><td>page-size</td><td>-p</td><td>LETTER</td></tr>
|
41
|
+
<tr><td>grid-color</td><td>-r</td><td>B3B3B3</td></tr>
|
42
|
+
<tr><td>spacing</td><td>-s</td><td>5</td></tr>
|
43
|
+
<tr><td>pages</td><td>-a</td><td>1</td></tr>
|
44
|
+
<tr><td>planner</td><td>-l</td><td>false</td></tr>
|
45
|
+
<tr><td>planner-color-1</td><td>-n</td><td>CCCCCC</td></tr>
|
46
|
+
<tr><td>planner-color-2</td><td>-e</td><td>0099FF</td></tr>
|
47
|
+
</tbody>
|
48
|
+
</table>
|
49
|
+
|
50
|
+
## Examples
|
data/Rakefile
ADDED
data/base
ADDED
@@ -0,0 +1,4 @@
|
|
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
|
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
|
data/bin/dotgrid
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler/setup'
|
5
|
+
|
6
|
+
# require your gems as usual
|
7
|
+
require 'require_all'
|
8
|
+
require 'trollop'
|
9
|
+
require_all 'lib'
|
10
|
+
|
11
|
+
opts = Trollop::options do
|
12
|
+
opt :file_name, "File Name", :type => :string, :default => "dotgrid.pdf"
|
13
|
+
opt :grid, "Add a Grid Page", default: true
|
14
|
+
opt :dot_weight, "Dot Weight", :type => :float, :default => 1.5
|
15
|
+
opt :margin, "Border", :type => :float, :default => 0.5
|
16
|
+
opt :page_size, "Page Size (LEGAL, LETTER)", :type => :string, :default => "LETTER"
|
17
|
+
opt :grid_color, "Grid Color (RGB)", :type => :string, :default => "B3B3B3"
|
18
|
+
opt :spacing, "Dot Spacing (mm)", :type => :integer, :default => 5
|
19
|
+
opt :pages, "Number of pages", :type => :integer, :default => 1
|
20
|
+
opt :planner, "Add a Planner Page"
|
21
|
+
opt :planner_color_1, "Planner Left and Footer color", type: :string, default: "CCCCCC"
|
22
|
+
opt :planner_color_2, "Planner Right color", type: :string, default: "0099ff"
|
23
|
+
end
|
24
|
+
|
25
|
+
dot_grid_generator = DotGrid::Generator.new(opts).generate
|
data/dot_grid.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/dot_grid/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Scott LaBounty"]
|
6
|
+
gem.email = ["slabounty@gmail.com"]
|
7
|
+
gem.description = %q{Dot Grid planner PDF generator.}
|
8
|
+
gem.summary = %q{Dot Grid planner PDF generator.}
|
9
|
+
gem.homepage = "http://github.com/slabounty/dot_grid"
|
10
|
+
gem.licenses = %w[MIT]
|
11
|
+
|
12
|
+
gem.files = `git ls-files`.split($\)
|
13
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
14
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
15
|
+
gem.name = "dot_grid"
|
16
|
+
gem.require_paths = ["lib"]
|
17
|
+
gem.version = DotGrid::VERSION
|
18
|
+
|
19
|
+
gem.add_development_dependency "rspec", '~> 2.14.1'
|
20
|
+
gem.add_development_dependency "rake", '~> 10.3.2'
|
21
|
+
gem.add_development_dependency "coveralls"
|
22
|
+
gem.add_dependency "prawn", '~> 1.0.0'
|
23
|
+
gem.add_dependency "trollop", '~> 2.0'
|
24
|
+
gem.add_dependency "require_all", '~> 1.3.2'
|
25
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'prawn'
|
2
|
+
require "prawn/measurement_extensions"
|
3
|
+
|
4
|
+
module DotGrid
|
5
|
+
class Generator
|
6
|
+
attr_accessor(
|
7
|
+
:pdf,
|
8
|
+
:file_name,
|
9
|
+
:page_size,
|
10
|
+
:grid,
|
11
|
+
:grid_page,
|
12
|
+
:margin,
|
13
|
+
:pages,
|
14
|
+
:planner,
|
15
|
+
:planner_page
|
16
|
+
)
|
17
|
+
|
18
|
+
def initialize(params)
|
19
|
+
@file_name = params[:file_name] || "dotgrid.pdf"
|
20
|
+
@page_size = params[:page_size] || "LETTER"
|
21
|
+
@margin = params[:margin] || 0.5
|
22
|
+
@pages = params[:pages] || 1
|
23
|
+
@pdf = Prawn::Document.new(margin: margin, page_size: page_size, skip_page_creation: true)
|
24
|
+
params[:pdf] = pdf
|
25
|
+
@grid_page = DotGrid::Grid.new(params) if params[:grid]
|
26
|
+
@planner_page = DotGrid::Planner.new(params) if params[:planner]
|
27
|
+
end
|
28
|
+
|
29
|
+
def generate
|
30
|
+
(1..pages).each do |page|
|
31
|
+
planner_page.generate if planner_page
|
32
|
+
grid_page.generate if grid_page
|
33
|
+
end
|
34
|
+
pdf.render_file file_name
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module DotGrid
|
2
|
+
class Grid < Page
|
3
|
+
attr_accessor(
|
4
|
+
:dot_weight,
|
5
|
+
:grid_color,
|
6
|
+
:spacing,
|
7
|
+
)
|
8
|
+
|
9
|
+
def initialize(params)
|
10
|
+
super
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
def page_rows
|
15
|
+
(page_height / spacing).floor
|
16
|
+
end
|
17
|
+
|
18
|
+
def page_columns
|
19
|
+
(page_width / spacing).floor
|
20
|
+
end
|
21
|
+
|
22
|
+
def generate
|
23
|
+
pdf.start_new_page
|
24
|
+
num_columns = page_columns
|
25
|
+
num_rows = page_rows
|
26
|
+
draw_dot_grid(num_rows, num_columns, 0, pdf.bounds.height)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module DotGrid
|
2
|
+
class Page
|
3
|
+
attr_accessor(
|
4
|
+
:pdf,
|
5
|
+
:dot_weight,
|
6
|
+
:grid_color,
|
7
|
+
:spacing
|
8
|
+
)
|
9
|
+
|
10
|
+
def initialize(params)
|
11
|
+
@pdf = params[:pdf]
|
12
|
+
@dot_weight = params[:dot_weight] || 1.5
|
13
|
+
@grid_color = params[:grid_color] || "B3B3B3"
|
14
|
+
@spacing = params[:spacing] ? params[:spacing].mm : 5.mm
|
15
|
+
end
|
16
|
+
|
17
|
+
def page_width
|
18
|
+
pdf.bounds.width
|
19
|
+
end
|
20
|
+
|
21
|
+
def page_height
|
22
|
+
pdf.bounds.height
|
23
|
+
end
|
24
|
+
|
25
|
+
def draw_dot_grid(rows, columns, left_start, height_start)
|
26
|
+
pdf.fill_color grid_color
|
27
|
+
(1..rows).each do |row|
|
28
|
+
(1..columns).each do |col|
|
29
|
+
pdf.fill_circle [left_start + (col-1)*spacing, height_start - spacing - (row-1)*spacing], dot_weight
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
module DotGrid
|
2
|
+
class Planner < Page
|
3
|
+
attr_accessor(
|
4
|
+
:planner_color_1,
|
5
|
+
:planner_color_2
|
6
|
+
)
|
7
|
+
|
8
|
+
def initialize(params)
|
9
|
+
super
|
10
|
+
@planner_color_1 = params[:planner_color_1] || "CCCCCC"
|
11
|
+
@planner_color_2 = params[:planner_color_2] || "0099ff"
|
12
|
+
end
|
13
|
+
|
14
|
+
def generate
|
15
|
+
pdf.start_new_page
|
16
|
+
|
17
|
+
width = page_width
|
18
|
+
height = page_height
|
19
|
+
header_height = 0.05 * height
|
20
|
+
|
21
|
+
square_grid_rows = 45
|
22
|
+
square_grid_columns = 13
|
23
|
+
|
24
|
+
header_left_color = planner_color_1
|
25
|
+
header_left_start = width*0.05
|
26
|
+
header_left_width = square_grid_columns*spacing
|
27
|
+
|
28
|
+
header_gap_start = header_left_start + header_left_width
|
29
|
+
header_gap_width = width*0.03
|
30
|
+
|
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
|
34
|
+
|
35
|
+
# Header left
|
36
|
+
pdf.fill_color header_left_color
|
37
|
+
pdf.fill_rectangle [header_left_start, height], header_left_width, header_height
|
38
|
+
|
39
|
+
# Header right
|
40
|
+
pdf.fill_color header_right_color
|
41
|
+
pdf.fill_rectangle [header_right_start, height], header_right_width, header_height
|
42
|
+
|
43
|
+
# 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)
|
45
|
+
|
46
|
+
# Dot Grid Right
|
47
|
+
draw_dot_grid(46, 28, header_right_start, height-header_height)
|
48
|
+
|
49
|
+
# Footer
|
50
|
+
draw_footer(planner_color_1, header_left_start, header_height*2, width-header_left_start)
|
51
|
+
end
|
52
|
+
|
53
|
+
def draw_square_grid_left(square_grid_rows, square_grid_columns, grid_color, left_start, height_start, spacing)
|
54
|
+
pdf.fill_color grid_color
|
55
|
+
(1..square_grid_rows).each do |row|
|
56
|
+
(1..square_grid_columns).each do |col|
|
57
|
+
pdf.fill_rectangle [left_start + (col-1)*spacing, height_start - (row-1)*spacing], spacing-1 ,spacing-1
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
def draw_footer(footer_color, footer_start, footer_height, footer_width)
|
64
|
+
pdf.fill_color footer_color
|
65
|
+
pdf.fill_rectangle [footer_start, footer_height], footer_width, footer_height
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
data/lib/dot_grid.rb
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "DotGrid::Generator" do
|
4
|
+
describe "#initialize" do
|
5
|
+
let(:subject) { DotGrid::Generator.new({}) }
|
6
|
+
|
7
|
+
it "has a default file name" do
|
8
|
+
expect(subject.file_name).to eq("dotgrid.pdf")
|
9
|
+
end
|
10
|
+
|
11
|
+
it "has a default file page size" do
|
12
|
+
expect(subject.page_size).to eq("LETTER")
|
13
|
+
end
|
14
|
+
|
15
|
+
it "has a default file margin" do
|
16
|
+
expect(subject.margin).to eq(0.5)
|
17
|
+
end
|
18
|
+
|
19
|
+
it "has a default number of pages" do
|
20
|
+
expect(subject.pages).to eq(1)
|
21
|
+
end
|
22
|
+
|
23
|
+
it "creates a pdf file" do
|
24
|
+
expect(Prawn::Document).to receive(:new)
|
25
|
+
subject
|
26
|
+
end
|
27
|
+
|
28
|
+
context "when there is a grid parameter" do
|
29
|
+
it "creates a new grid page" do
|
30
|
+
expect(DotGrid::Grid).to receive(:new)
|
31
|
+
DotGrid::Generator.new({:grid => true})
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context "when there is a planner parameter" do
|
36
|
+
it "creates a new grid page" do
|
37
|
+
expect(DotGrid::Planner).to receive(:new)
|
38
|
+
DotGrid::Generator.new({:planner => true})
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
describe "#generate" do
|
44
|
+
context "when there is a planner page" do
|
45
|
+
let(:subject) { DotGrid::Generator.new(:planner => true)}
|
46
|
+
it "generates a new planner page" do
|
47
|
+
expect(subject.planner_page).to receive(:generate)
|
48
|
+
subject.generate
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
context "when there is a grid page" do
|
53
|
+
let(:subject) { DotGrid::Generator.new(:grid => true)}
|
54
|
+
it "generates a new grid page" do
|
55
|
+
expect(subject.grid_page).to receive(:generate)
|
56
|
+
subject.generate
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context "when there are multiple pages" do
|
61
|
+
let(:subject) { DotGrid::Generator.new(:grid => true, :planner => true, :pages => 2)}
|
62
|
+
|
63
|
+
it "generates grid for each page" do
|
64
|
+
expect(subject.grid_page).to receive(:generate).twice
|
65
|
+
subject.generate
|
66
|
+
end
|
67
|
+
|
68
|
+
it "generates a planner for each page" do
|
69
|
+
expect(subject.planner_page).to receive(:generate).twice
|
70
|
+
subject.generate
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
it "renders a file with the file name" do
|
75
|
+
subject = DotGrid::Generator.new({})
|
76
|
+
expect(subject.pdf).to receive(:render_file).with(subject.file_name)
|
77
|
+
subject.generate
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "DotGrid::Grid" do
|
4
|
+
describe "#initialize" do
|
5
|
+
let(:subject) { DotGrid::Grid.new({}) }
|
6
|
+
|
7
|
+
it "calculates the number of rows" do
|
8
|
+
allow(subject).to receive(:page_height).and_return(22)
|
9
|
+
allow(subject).to receive(:spacing).and_return(5)
|
10
|
+
expect(subject.page_rows).to eq(4)
|
11
|
+
end
|
12
|
+
|
13
|
+
it "calculates the number of columns" do
|
14
|
+
allow(subject).to receive(:page_width).and_return(44)
|
15
|
+
allow(subject).to receive(:spacing).and_return(6)
|
16
|
+
expect(subject.page_columns).to eq(7)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "DotGrid::Page" do
|
4
|
+
describe "#initialize" do
|
5
|
+
let(:subject) { DotGrid::Page.new({}) }
|
6
|
+
|
7
|
+
it "has a default dot weight" do
|
8
|
+
expect(subject.dot_weight).to eq(1.5)
|
9
|
+
end
|
10
|
+
|
11
|
+
it "has a default grid color" do
|
12
|
+
expect(subject.grid_color).to eq("B3B3B3")
|
13
|
+
end
|
14
|
+
|
15
|
+
it "has a default spacing" do
|
16
|
+
expect(subject.spacing).to eq(5.mm)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
describe "#page_width" do
|
21
|
+
let(:pdf) { double('pdf', bounds: double(:width => 42)) }
|
22
|
+
let(:subject) { DotGrid::Page.new({:pdf => pdf}) }
|
23
|
+
|
24
|
+
it "uses the pdf to calculate the page width" do
|
25
|
+
expect(subject.page_width).to eq(42)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "#page_height" do
|
30
|
+
let(:pdf) { double('pdf', bounds: double(:height => 22)) }
|
31
|
+
let(:subject) { DotGrid::Page.new({:pdf => pdf}) }
|
32
|
+
|
33
|
+
it "uses the pdf to calculate the page height" do
|
34
|
+
expect(subject.page_height).to eq(22)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe "#draw_dot_grid" do
|
39
|
+
let(:pdf) { double('pdf', bounds: double(:height => 22)) }
|
40
|
+
let(:subject) { DotGrid::Page.new({:pdf => pdf, :grid_color => "CCDDEE"}) }
|
41
|
+
|
42
|
+
it "sets the pdf fill color" do
|
43
|
+
allow(pdf).to receive(:fill_circle)
|
44
|
+
expect(pdf).to receive(:fill_color).with("CCDDEE")
|
45
|
+
subject.draw_dot_grid(1, 1, 100, 200)
|
46
|
+
end
|
47
|
+
|
48
|
+
it "fills the correct number of circles for the grid" do
|
49
|
+
allow(pdf).to receive(:fill_color)
|
50
|
+
expect(pdf).to receive(:fill_circle).exactly(4).times
|
51
|
+
subject.draw_dot_grid(2, 2, 100, 200)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "DotGrid::Planner" do
|
4
|
+
describe "#initialize" do
|
5
|
+
let(:subject) { DotGrid::Planner.new({}) }
|
6
|
+
|
7
|
+
it "has a default planner color 1" do
|
8
|
+
expect(subject.planner_color_1).to eq("CCCCCC")
|
9
|
+
end
|
10
|
+
|
11
|
+
it "has a default planner color 2" do
|
12
|
+
expect(subject.planner_color_2).to eq("0099ff")
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#generate" do
|
17
|
+
let(:pdf) { double('pdf') }
|
18
|
+
let(:subject) { DotGrid::Planner.new({:pdf => pdf }) }
|
19
|
+
|
20
|
+
before do
|
21
|
+
allow(subject).to receive(:page_width).and_return(10)
|
22
|
+
allow(subject).to receive(:page_height).and_return(20)
|
23
|
+
allow(pdf).to receive(:start_new_page)
|
24
|
+
allow(pdf).to receive(:fill_color)
|
25
|
+
allow(pdf).to receive(:fill_rectangle)
|
26
|
+
allow(pdf).to receive(:fill_circle)
|
27
|
+
end
|
28
|
+
|
29
|
+
it "starts a new page" do
|
30
|
+
expect(pdf).to receive(:start_new_page)
|
31
|
+
subject.generate
|
32
|
+
end
|
33
|
+
|
34
|
+
it "gets the page_width" do
|
35
|
+
expect(subject).to receive(:page_width)
|
36
|
+
subject.generate
|
37
|
+
end
|
38
|
+
|
39
|
+
it "gets the page_height" do
|
40
|
+
expect(subject).to receive(:page_height)
|
41
|
+
subject.generate
|
42
|
+
end
|
43
|
+
|
44
|
+
it "draws the left square grid" do
|
45
|
+
expect(subject).to receive(:draw_square_grid_left)
|
46
|
+
subject.generate
|
47
|
+
end
|
48
|
+
|
49
|
+
it "draws the dot grid" do
|
50
|
+
expect(subject).to receive(:draw_dot_grid)
|
51
|
+
subject.generate
|
52
|
+
end
|
53
|
+
|
54
|
+
it "draws the footer" do
|
55
|
+
expect(subject).to receive(:draw_footer)
|
56
|
+
subject.generate
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,157 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dot_grid
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Scott LaBounty
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-05-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 2.14.1
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 2.14.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 10.3.2
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 10.3.2
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: coveralls
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: prawn
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.0.0
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.0.0
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: trollop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '2.0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '2.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: require_all
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.3.2
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.3.2
|
97
|
+
description: Dot Grid planner PDF generator.
|
98
|
+
email:
|
99
|
+
- slabounty@gmail.com
|
100
|
+
executables:
|
101
|
+
- dotgrid
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- .coveralls.yml
|
106
|
+
- .gitignore
|
107
|
+
- .ruby-version
|
108
|
+
- .travis.yml
|
109
|
+
- Gemfile
|
110
|
+
- Gemfile.lock
|
111
|
+
- LICENSE
|
112
|
+
- README.md
|
113
|
+
- Rakefile
|
114
|
+
- base
|
115
|
+
- bin/dotgrid
|
116
|
+
- dot_grid.gemspec
|
117
|
+
- lib/dot_grid.rb
|
118
|
+
- lib/dot_grid/generator.rb
|
119
|
+
- lib/dot_grid/grid.rb
|
120
|
+
- lib/dot_grid/page.rb
|
121
|
+
- lib/dot_grid/planner.rb
|
122
|
+
- lib/dot_grid/version.rb
|
123
|
+
- spec/lib/dot_grid/generator_spec.rb
|
124
|
+
- spec/lib/dot_grid/grid_spec.rb
|
125
|
+
- spec/lib/dot_grid/page_spec.rb
|
126
|
+
- spec/lib/dot_grid/planner_spec.rb
|
127
|
+
- spec/spec_helper.rb
|
128
|
+
homepage: http://github.com/slabounty/dot_grid
|
129
|
+
licenses:
|
130
|
+
- MIT
|
131
|
+
metadata: {}
|
132
|
+
post_install_message:
|
133
|
+
rdoc_options: []
|
134
|
+
require_paths:
|
135
|
+
- lib
|
136
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
137
|
+
requirements:
|
138
|
+
- - '>='
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: '0'
|
141
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - '>='
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
requirements: []
|
147
|
+
rubyforge_project:
|
148
|
+
rubygems_version: 2.1.11
|
149
|
+
signing_key:
|
150
|
+
specification_version: 4
|
151
|
+
summary: Dot Grid planner PDF generator.
|
152
|
+
test_files:
|
153
|
+
- spec/lib/dot_grid/generator_spec.rb
|
154
|
+
- spec/lib/dot_grid/grid_spec.rb
|
155
|
+
- spec/lib/dot_grid/page_spec.rb
|
156
|
+
- spec/lib/dot_grid/planner_spec.rb
|
157
|
+
- spec/spec_helper.rb
|