dot_grid 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +6 -6
- data/README.md +8 -11
- data/base +12 -6
- data/bin/dotgrid +1 -6
- data/dot_grid.gemspec +1 -1
- data/lib/dot_grid/generator.rb +9 -22
- data/lib/dot_grid/page/factory.rb +20 -0
- data/lib/dot_grid/version.rb +1 -1
- data/lib/dot_grid.rb +1 -0
- data/spec/lib/dot_grid/generator_spec.rb +3 -64
- data/spec/lib/dot_grid/page/factory_spec.rb +18 -0
- metadata +7 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c613a6399306399f56670ee1d5c71eb19f0482fa
|
4
|
+
data.tar.gz: 1e84551b573e9a4da0ce43ef124e934da2361e1b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2537b83875baf3ac3a25bbaee024eddd5152a51f02fd3b1194bad971739cafe74b09652533a5477d3683e71e9df4153f3f6cc64e2a414911b38fd604ad62a9ea
|
7
|
+
data.tar.gz: 51f22e55418a3b4c594da771c0fa4906cff45adb163308351e21571555e5239e114f2fcc0cc8be1188160caadda44ddaae3b4a48c7366ed3d701d852daca0e31
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
dot_grid (0.0.
|
5
|
-
prawn (~> 1.
|
4
|
+
dot_grid (0.0.6)
|
5
|
+
prawn (~> 1.1.0)
|
6
6
|
require_all (~> 1.3.2)
|
7
7
|
trollop (~> 2.0)
|
8
8
|
|
@@ -20,9 +20,9 @@ GEM
|
|
20
20
|
mime-types (2.3)
|
21
21
|
multi_json (1.10.1)
|
22
22
|
pdf-core (0.2.5)
|
23
|
-
prawn (1.
|
24
|
-
pdf-core (~> 0.2.
|
25
|
-
ttfunk (~> 1.
|
23
|
+
prawn (1.1.0)
|
24
|
+
pdf-core (~> 0.2.5)
|
25
|
+
ttfunk (~> 1.2.0)
|
26
26
|
rake (10.3.2)
|
27
27
|
require_all (1.3.2)
|
28
28
|
rest-client (1.6.7)
|
@@ -45,7 +45,7 @@ GEM
|
|
45
45
|
thor (0.19.1)
|
46
46
|
tins (1.3.0)
|
47
47
|
trollop (2.0)
|
48
|
-
ttfunk (1.
|
48
|
+
ttfunk (1.2.0)
|
49
49
|
|
50
50
|
PLATFORMS
|
51
51
|
ruby
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
[![Build Status](https://travis-ci.org/slabounty/dot_grid.svg?branch=master)](https://travis-ci.org/slabounty/dot_grid)
|
2
2
|
[![Coverage Status](https://coveralls.io/repos/slabounty/dot_grid/badge.png?branch=master)](https://coveralls.io/r/slabounty/dot_grid?branch=master)
|
3
3
|
[![Code Climate](https://codeclimate.com/github/slabounty/dot_grid.png)](https://codeclimate.com/github/slabounty/dot_grid)
|
4
|
+
[![Dependency Status](https://gemnasium.com/slabounty/dot_grid.svg)](https://gemnasium.com/slabounty/dot_grid)
|
4
5
|
|
5
6
|
# DotGrid: dot grid planning pages
|
6
7
|
|
@@ -14,11 +15,11 @@ A simple ruby file for generating dot grid graph paper.
|
|
14
15
|
|
15
16
|
A basic dot grid page can be generated like this ...
|
16
17
|
|
17
|
-
bin/dotgrid -f
|
18
|
+
bin/dotgrid -f dot_grid.pdf --page-types dot-grid --spacing 5 --grid-color CFBAEC --dot-weight 0.5 -m 0.0
|
18
19
|
|
19
20
|
A basic planning page can be generated like this ...
|
20
21
|
|
21
|
-
|
22
|
+
bin/dotgrid -f planner_w5_c2dfff.pdf --page-types planner --grid-color CFBAEC --dot-weight 0.5 -m 0.0 --planner-color-1 dddddd --planner-color-2 C2DFFF
|
22
23
|
|
23
24
|
To get help on the command and its options ...
|
24
25
|
bin/dotgrid --help
|
@@ -34,17 +35,13 @@ The options and their defaults are ...
|
|
34
35
|
</thead>
|
35
36
|
<tbody>
|
36
37
|
<tr><td>file-name</td><td>-f</td><td>dotgrid.pdf</td></tr>
|
37
|
-
<tr><td>
|
38
|
+
<tr><td>page-types</td><td>-p</td><td>Types of pages desired: DotGrid, Planner, Grid, HorizontalRule, Checkerboard (default: Planner)</td></tr>
|
38
39
|
<tr><td>dot-weight</td><td>-d</td><td>1.5</td></tr>
|
39
40
|
<tr><td>margin</td><td>-m</td><td>0.5</td></tr>
|
40
|
-
<tr><td>page-size</td><td>-
|
41
|
-
<tr><td>grid-color</td><td>-
|
41
|
+
<tr><td>page-size</td><td>-a</td><td>LETTER</td></tr>
|
42
|
+
<tr><td>grid-color</td><td>-g</td><td>B3B3B3</td></tr>
|
42
43
|
<tr><td>spacing</td><td>-s</td><td>5</td></tr>
|
43
|
-
<tr><td>
|
44
|
-
<tr><td>planner</td><td>-
|
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>
|
44
|
+
<tr><td>planner-color-1</td><td>-l</td><td>CCCCCC</td></tr>
|
45
|
+
<tr><td>planner-color-2</td><td>-n</td><td>0099FF</td></tr>
|
47
46
|
</tbody>
|
48
47
|
</table>
|
49
|
-
|
50
|
-
## Examples
|
data/base
CHANGED
@@ -1,15 +1,21 @@
|
|
1
1
|
# Base planner
|
2
|
-
bin/dotgrid -f
|
3
|
-
bin/dotgrid -f
|
2
|
+
bin/dotgrid -f planner_w5_c2dfff.pdf --page-types planner --grid-color CFBAEC --dot-weight 0.5 --margin 0.0 --planner-color-1 dddddd --planner-color-2 C2DFFF
|
3
|
+
bin/dotgrid -f planner_w75_c2dfff.pdf --page-types planner --grid-color CFBAEC --dot-weight 0.75 --margin 0.0 --planner-color-1 dddddd --planner-color-2 C2DFFF
|
4
4
|
|
5
5
|
# Dot grid
|
6
|
-
bin/dotgrid -f dot_grid_c2dfff.pdf --
|
6
|
+
bin/dotgrid -f dot_grid_c2dfff.pdf --page-types dot_grid --spacing 5 --grid-color CFBAEC --margin 0.0
|
7
7
|
|
8
8
|
# Regular grid
|
9
|
-
bin/dotgrid -f grid_c2dfff.pdf --
|
9
|
+
bin/dotgrid -f grid_c2dfff.pdf --page-types grid --spacing 5 --grid-color CFBAEC --margin 0.0
|
10
10
|
|
11
11
|
# Horizontal rule
|
12
|
-
bin/dotgrid -f horizontal_rule_c2dfff.pdf --horizontal-rule
|
12
|
+
bin/dotgrid -f horizontal_rule_c2dfff.pdf --page-types horizontal-rule --spacing 5 --grid-color CFBAEC --margin 0.0
|
13
13
|
|
14
14
|
# Checkerboard
|
15
|
-
bin/dotgrid -f checkerboard_c2dfff.pdf --
|
15
|
+
bin/dotgrid -f checkerboard_c2dfff.pdf --page-types checkerboard --spacing 5 --grid-color CFBAEC --margin 0.0
|
16
|
+
|
17
|
+
# Page Types (either with no spaces after commas or in quotes).
|
18
|
+
bin/dotgrid -f page_types.pdf --page-types "planner, checkerboard, grid, dot_grid" --spacing 5 --grid-color CFBAEC --margin 0.0
|
19
|
+
|
20
|
+
# Everything all at once ...
|
21
|
+
bin/dotgrid -f page_types.pdf --page-types "planner, checkerboard, grid, dot_grid, horizontal_rule" --spacing 5 --grid-color CFBAEC -m 0.0
|
data/bin/dotgrid
CHANGED
@@ -10,17 +10,12 @@ require_all 'lib'
|
|
10
10
|
|
11
11
|
opts = Trollop::options do
|
12
12
|
opt :file_name, "File Name", :type => :string, :default => "dotgrid.pdf"
|
13
|
-
opt :
|
13
|
+
opt :page_types, "Types of pages desired: Types of pages desired: DotGrid, Planner, Grid, HorizontalRule, Checkerboard", type: :string, default: "Planner"
|
14
14
|
opt :dot_weight, "Dot Weight", :type => :float, :default => 1.5
|
15
15
|
opt :margin, "Border", :type => :float, :default => 0.5
|
16
16
|
opt :page_size, "Page Size (LEGAL, LETTER)", :type => :string, :default => "LETTER"
|
17
17
|
opt :grid_color, "Grid Color (RGB)", :type => :string, :default => "B3B3B3"
|
18
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 :grid, "Add a Regular Grid page"
|
22
|
-
opt :horizontal_rule, "Add a Horizontal Rule page"
|
23
|
-
opt :checkerboard, "Add a Checkerboard page"
|
24
19
|
opt :planner_color_1, "Planner Left and Footer color", type: :string, default: "CCCCCC"
|
25
20
|
opt :planner_color_2, "Planner Right color", type: :string, default: "0099ff"
|
26
21
|
end
|
data/dot_grid.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |gem|
|
|
19
19
|
gem.add_development_dependency "rspec", '~> 2.14.1'
|
20
20
|
gem.add_development_dependency "rake", '~> 10.3.2'
|
21
21
|
gem.add_development_dependency "coveralls"
|
22
|
-
gem.add_dependency "prawn", '~> 1.
|
22
|
+
gem.add_dependency "prawn", '~> 1.1.0'
|
23
23
|
gem.add_dependency "trollop", '~> 2.0'
|
24
24
|
gem.add_dependency "require_all", '~> 1.3.2'
|
25
25
|
end
|
data/lib/dot_grid/generator.rb
CHANGED
@@ -7,42 +7,29 @@ module DotGrid
|
|
7
7
|
:pdf,
|
8
8
|
:file_name,
|
9
9
|
:page_size,
|
10
|
-
:grid,
|
11
|
-
:dot_grid_page,
|
12
|
-
:grid_page,
|
13
10
|
:margin,
|
14
11
|
:pages,
|
15
|
-
:
|
16
|
-
:planner_page,
|
17
|
-
:horizontal_rule,
|
18
|
-
:horizontal_rule_page,
|
19
|
-
:checkerboard,
|
20
|
-
:checkerboard_page,
|
12
|
+
:page_types
|
21
13
|
)
|
22
14
|
|
23
15
|
def initialize(params)
|
24
16
|
@file_name = params[:file_name] || "dotgrid.pdf"
|
25
17
|
@page_size = params[:page_size] || "LETTER"
|
26
18
|
@margin = params[:margin] || 0.5
|
27
|
-
@
|
19
|
+
@page_types = params[:page_types] ? params[:page_types].split(",") : ["planner"]
|
28
20
|
@pdf = Prawn::Document.new(margin: margin, page_size: page_size, skip_page_creation: true)
|
29
21
|
params[:pdf] = pdf
|
22
|
+
@pages = create_pages(params)
|
23
|
+
end
|
30
24
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
@checkerboard_page = DotGrid::Page::Checkerboard.new(params) if params[:checkerboard]
|
25
|
+
def create_pages(params)
|
26
|
+
page_types.map do |p|
|
27
|
+
DotGrid::Page::Factory.build(p.strip, params.clone)
|
28
|
+
end
|
36
29
|
end
|
37
30
|
|
38
31
|
def generate
|
39
|
-
|
40
|
-
planner_page.generate if planner_page
|
41
|
-
grid_page.generate if grid_page
|
42
|
-
dot_grid_page.generate if dot_grid_page
|
43
|
-
horizontal_rule_page.generate if horizontal_rule_page
|
44
|
-
checkerboard_page.generate if checkerboard_page
|
45
|
-
end
|
32
|
+
pages.each { |page| page.generate }
|
46
33
|
pdf.render_file file_name
|
47
34
|
end
|
48
35
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module DotGrid
|
2
|
+
module Page
|
3
|
+
class Factory
|
4
|
+
class UnknownPageExeception < Exception; end
|
5
|
+
|
6
|
+
PAGES = {
|
7
|
+
'dot_grid' => ::DotGrid::Page::DotGrid,
|
8
|
+
'planner' => ::DotGrid::Page::Planner,
|
9
|
+
'grid' => ::DotGrid::Page::Grid,
|
10
|
+
'horizontal_rule' => ::DotGrid::Page::HorizontalRule,
|
11
|
+
'checkerboard' => ::DotGrid::Page::Checkerboard
|
12
|
+
}
|
13
|
+
|
14
|
+
def self.build(page_type, params)
|
15
|
+
raise UnknownPageExeception, "Unknown page type: #{page_type}" unless PAGES[page_type]
|
16
|
+
PAGES[page_type].new(params)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/dot_grid/version.rb
CHANGED
data/lib/dot_grid.rb
CHANGED
@@ -16,77 +16,16 @@ describe "DotGrid::Generator" do
|
|
16
16
|
expect(subject.margin).to eq(0.5)
|
17
17
|
end
|
18
18
|
|
19
|
-
it "has a default number of pages" do
|
20
|
-
expect(subject.pages).to eq(1)
|
21
|
-
end
|
22
|
-
|
23
19
|
it "creates a pdf file" do
|
24
|
-
expect(
|
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::Page::DotGrid).to receive(:new)
|
31
|
-
DotGrid::Generator.new({:dot_grid => true})
|
32
|
-
end
|
20
|
+
expect(subject.pdf).to be_a(Prawn::Document)
|
33
21
|
end
|
34
22
|
|
35
|
-
|
36
|
-
|
37
|
-
expect(DotGrid::Page::Planner).to receive(:new)
|
38
|
-
DotGrid::Generator.new({:planner => true})
|
39
|
-
end
|
23
|
+
it "creates the pages" do
|
24
|
+
expect(subject.page_types).to have(1).page
|
40
25
|
end
|
41
26
|
end
|
42
27
|
|
43
28
|
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 dot grid page" do
|
53
|
-
let(:subject) { DotGrid::Generator.new(:dot_grid => true)}
|
54
|
-
it "generates a new grid page" do
|
55
|
-
expect(subject.dot_grid_page).to receive(:generate)
|
56
|
-
subject.generate
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
context "when there is a grid page" do
|
61
|
-
let(:subject) { DotGrid::Generator.new(:grid => true)}
|
62
|
-
it "generates a new grid page" do
|
63
|
-
expect(subject.grid_page).to receive(:generate)
|
64
|
-
subject.generate
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
context "when there is a horizontal rule page" do
|
69
|
-
let(:subject) { DotGrid::Generator.new(:horizontal_rule => true)}
|
70
|
-
it "generates a new horizontal rule page" do
|
71
|
-
expect(subject.horizontal_rule_page).to receive(:generate)
|
72
|
-
subject.generate
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
context "when there are multiple pages" do
|
77
|
-
let(:subject) { DotGrid::Generator.new(:dot_grid => true, :planner => true, :pages => 2)}
|
78
|
-
|
79
|
-
it "generates grid for each page" do
|
80
|
-
expect(subject.dot_grid_page).to receive(:generate).twice
|
81
|
-
subject.generate
|
82
|
-
end
|
83
|
-
|
84
|
-
it "generates a planner for each page" do
|
85
|
-
expect(subject.planner_page).to receive(:generate).twice
|
86
|
-
subject.generate
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
29
|
it "renders a file with the file name" do
|
91
30
|
subject = DotGrid::Generator.new({})
|
92
31
|
expect(subject.pdf).to receive(:render_file).with(subject.file_name)
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "DotGrid::Page::Factory" do
|
4
|
+
describe ".build" do
|
5
|
+
context "when the page is unknown" do
|
6
|
+
it "raises an exception" do
|
7
|
+
expect {DotGrid::Page::Factory.build('xyz', {})}.to raise_error( DotGrid::Page::Factory::UnknownPageExeception)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
context "when the page is known" do
|
12
|
+
it "builds the page" do
|
13
|
+
expect(::DotGrid::Page::Planner).to receive(:new)
|
14
|
+
DotGrid::Page::Factory.build('planner', {})
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
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.
|
4
|
+
version: 0.0.6
|
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-07-
|
11
|
+
date: 2014-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ~>
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.
|
61
|
+
version: 1.1.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 1.
|
68
|
+
version: 1.1.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: trollop
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -119,6 +119,7 @@ files:
|
|
119
119
|
- lib/dot_grid/generator.rb
|
120
120
|
- lib/dot_grid/page/checkerboard.rb
|
121
121
|
- lib/dot_grid/page/dot_grid.rb
|
122
|
+
- lib/dot_grid/page/factory.rb
|
122
123
|
- lib/dot_grid/page/grid.rb
|
123
124
|
- lib/dot_grid/page/horizontal_rule.rb
|
124
125
|
- lib/dot_grid/page/page.rb
|
@@ -133,6 +134,7 @@ files:
|
|
133
134
|
- spec/lib/dot_grid/generator_spec.rb
|
134
135
|
- spec/lib/dot_grid/page/checkerboard_spec.rb
|
135
136
|
- spec/lib/dot_grid/page/dot_grid_spec.rb
|
137
|
+
- spec/lib/dot_grid/page/factory_spec.rb
|
136
138
|
- spec/lib/dot_grid/page/grid_spec.rb
|
137
139
|
- spec/lib/dot_grid/page/horizontal_rule_spec.rb
|
138
140
|
- spec/lib/dot_grid/page/page_spec.rb
|
@@ -171,6 +173,7 @@ test_files:
|
|
171
173
|
- spec/lib/dot_grid/generator_spec.rb
|
172
174
|
- spec/lib/dot_grid/page/checkerboard_spec.rb
|
173
175
|
- spec/lib/dot_grid/page/dot_grid_spec.rb
|
176
|
+
- spec/lib/dot_grid/page/factory_spec.rb
|
174
177
|
- spec/lib/dot_grid/page/grid_spec.rb
|
175
178
|
- spec/lib/dot_grid/page/horizontal_rule_spec.rb
|
176
179
|
- spec/lib/dot_grid/page/page_spec.rb
|