plans 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.rspec +3 -0
- data/.versions.conf +2 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +102 -0
- data/Guardfile +46 -0
- data/LICENSE +22 -0
- data/README.md +100 -0
- data/Rakefile +6 -0
- data/bin/_guard-core +16 -0
- data/bin/console +14 -0
- data/bin/guard +16 -0
- data/bin/rake +16 -0
- data/bin/rspec +16 -0
- data/bin/setup +7 -0
- data/exe/plans +5 -0
- data/lib/plans/cli.rb +121 -0
- data/lib/plans/command.rb +61 -0
- data/lib/plans/init.rb +19 -0
- data/lib/plans/list.rb +47 -0
- data/lib/plans/new.rb +29 -0
- data/lib/plans/publish.rb +98 -0
- data/lib/plans/thumbs.rb +47 -0
- data/lib/plans/version.rb +3 -0
- data/lib/plans.rb +15 -0
- data/plans.gemspec +31 -0
- data/template/README.md +39 -0
- data/template/doc/README.md +12 -0
- data/template/doc/img/.empty_directory +0 -0
- data/template/doc/publish/.empty_directory +0 -0
- data/template/doc/reference.docx +0 -0
- data/template/doc/template.yml +3 -0
- data/template/functional/README.md +60 -0
- data/template/functional/img/.empty_directory +0 -0
- data/template/functional/publish/.empty_directory +0 -0
- data/template/functional/reference.docx +0 -0
- data/template/functional/template.yml +3 -0
- data/template/glossary/README.md +20 -0
- data/template/glossary/img/.empty_directory +0 -0
- data/template/glossary/publish/.empty_directory +0 -0
- data/template/glossary/reference.docx +0 -0
- data/template/glossary/template.yml +3 -0
- data/template/scope/README.md +127 -0
- data/template/scope/img/.empty_directory +0 -0
- data/template/scope/publish/.empty_directory +0 -0
- data/template/scope/reference.docx +0 -0
- data/template/scope/template.yml +3 -0
- data/template/users/README.md +13 -0
- data/template/users/img/.empty_directory +0 -0
- data/template/users/publish/.empty_directory +0 -0
- data/template/users/reference.docx +0 -0
- data/template/users/template.yml +3 -0
- metadata +210 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f36f44001dbc8ddb84a61c9095b71c3e24fc69a7
|
4
|
+
data.tar.gz: 7ebd2e8cd146d988773051f9cfd45a8b23c756e6
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8c2c886d74043230a8b91e53ad529b1d47123b5f1fdf7b98540e90282d7b3a14cbc69ecb58860bdb23766760bb72752ab5b8e3312c752c57806efbf760fc39c7
|
7
|
+
data.tar.gz: 76c9b7a979b23e11b020a3df2619a8ea152c044c862860fc11beb3150426f0245ed4edfec0341eedcb4da84cb63ed90c4b1100661aeced923ea20d1b71deccc2
|
data/.rspec
ADDED
data/.versions.conf
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
plans (0.1.0)
|
5
|
+
thor
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
aruba (0.13.0)
|
11
|
+
childprocess (~> 0.5.6)
|
12
|
+
contracts (~> 0.9)
|
13
|
+
cucumber (>= 1.3.19)
|
14
|
+
ffi (~> 1.9.10)
|
15
|
+
rspec-expectations (>= 2.99)
|
16
|
+
thor (~> 0.19)
|
17
|
+
builder (3.2.2)
|
18
|
+
childprocess (0.5.9)
|
19
|
+
ffi (~> 1.0, >= 1.0.11)
|
20
|
+
coderay (1.1.1)
|
21
|
+
contracts (0.13.0)
|
22
|
+
cucumber (2.3.2)
|
23
|
+
builder (>= 2.1.2)
|
24
|
+
cucumber-core (~> 1.4.0)
|
25
|
+
cucumber-wire (~> 0.0.1)
|
26
|
+
diff-lcs (>= 1.1.3)
|
27
|
+
gherkin (~> 3.2.0)
|
28
|
+
multi_json (>= 1.7.5, < 2.0)
|
29
|
+
multi_test (>= 0.1.2)
|
30
|
+
cucumber-core (1.4.0)
|
31
|
+
gherkin (~> 3.2.0)
|
32
|
+
cucumber-wire (0.0.1)
|
33
|
+
diff-lcs (1.2.5)
|
34
|
+
ffi (1.9.10)
|
35
|
+
formatador (0.2.5)
|
36
|
+
gherkin (3.2.0)
|
37
|
+
guard (2.13.0)
|
38
|
+
formatador (>= 0.2.4)
|
39
|
+
listen (>= 2.7, <= 4.0)
|
40
|
+
lumberjack (~> 1.0)
|
41
|
+
nenv (~> 0.1)
|
42
|
+
notiffany (~> 0.0)
|
43
|
+
pry (>= 0.9.12)
|
44
|
+
shellany (~> 0.0)
|
45
|
+
thor (>= 0.18.1)
|
46
|
+
guard-compat (1.2.1)
|
47
|
+
guard-rspec (4.6.4)
|
48
|
+
guard (~> 2.1)
|
49
|
+
guard-compat (~> 1.1)
|
50
|
+
rspec (>= 2.99.0, < 4.0)
|
51
|
+
listen (3.0.6)
|
52
|
+
rb-fsevent (>= 0.9.3)
|
53
|
+
rb-inotify (>= 0.9.7)
|
54
|
+
lumberjack (1.0.10)
|
55
|
+
method_source (0.8.2)
|
56
|
+
multi_json (1.11.2)
|
57
|
+
multi_test (0.1.2)
|
58
|
+
nenv (0.3.0)
|
59
|
+
notiffany (0.0.8)
|
60
|
+
nenv (~> 0.1)
|
61
|
+
shellany (~> 0.0)
|
62
|
+
pry (0.10.3)
|
63
|
+
coderay (~> 1.1.0)
|
64
|
+
method_source (~> 0.8.1)
|
65
|
+
slop (~> 3.4)
|
66
|
+
rake (10.5.0)
|
67
|
+
rb-fsevent (0.9.7)
|
68
|
+
rb-inotify (0.9.7)
|
69
|
+
ffi (>= 0.5.0)
|
70
|
+
rspec (3.4.0)
|
71
|
+
rspec-core (~> 3.4.0)
|
72
|
+
rspec-expectations (~> 3.4.0)
|
73
|
+
rspec-mocks (~> 3.4.0)
|
74
|
+
rspec-core (3.4.3)
|
75
|
+
rspec-support (~> 3.4.0)
|
76
|
+
rspec-expectations (3.4.0)
|
77
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
78
|
+
rspec-support (~> 3.4.0)
|
79
|
+
rspec-mocks (3.4.1)
|
80
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
81
|
+
rspec-support (~> 3.4.0)
|
82
|
+
rspec-support (3.4.1)
|
83
|
+
shellany (0.0.1)
|
84
|
+
slop (3.6.0)
|
85
|
+
terminal-notifier-guard (1.7.0)
|
86
|
+
thor (0.19.1)
|
87
|
+
|
88
|
+
PLATFORMS
|
89
|
+
ruby
|
90
|
+
|
91
|
+
DEPENDENCIES
|
92
|
+
aruba
|
93
|
+
bundler (~> 1.10)
|
94
|
+
guard
|
95
|
+
guard-rspec
|
96
|
+
plans!
|
97
|
+
rake (~> 10.0)
|
98
|
+
rspec
|
99
|
+
terminal-notifier-guard
|
100
|
+
|
101
|
+
BUNDLED WITH
|
102
|
+
1.11.2
|
data/Guardfile
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
## Uncomment and set this to only include directories you want to watch
|
5
|
+
# directories %w(app lib config test spec features) \
|
6
|
+
# .select{|d| Dir.exists?(d) ? d : UI.warning("Directory #{d} does not exist")}
|
7
|
+
|
8
|
+
## Note: if you are using the `directories` clause above and you are not
|
9
|
+
## watching the project directory ('.'), then you will want to move
|
10
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
11
|
+
#
|
12
|
+
# $ mkdir config
|
13
|
+
# $ mv Guardfile config/
|
14
|
+
# $ ln -s config/Guardfile .
|
15
|
+
#
|
16
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
17
|
+
|
18
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
19
|
+
# rspec may be run, below are examples of the most common uses.
|
20
|
+
# * bundler: 'bundle exec rspec'
|
21
|
+
# * bundler binstubs: 'bin/rspec'
|
22
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
23
|
+
# installed the spring binstubs per the docs)
|
24
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
25
|
+
# * 'just' rspec: 'rspec'
|
26
|
+
|
27
|
+
guard :rspec, cmd: "bin/rspec" do
|
28
|
+
require "guard/rspec/dsl"
|
29
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
30
|
+
|
31
|
+
# Feel free to open issues for suggestions and improvements
|
32
|
+
|
33
|
+
# RSpec files
|
34
|
+
rspec = dsl.rspec
|
35
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
36
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
37
|
+
watch(rspec.spec_files)
|
38
|
+
|
39
|
+
# Ruby files
|
40
|
+
ruby = dsl.ruby
|
41
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
42
|
+
|
43
|
+
# Lib files
|
44
|
+
watch(%r{^lib/plans/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
45
|
+
|
46
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Aramis Group, LLC
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, 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,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,100 @@
|
|
1
|
+
# Plans
|
2
|
+
|
3
|
+
Command line application for creating markdown documents from templates and publishing them in MS Word.
|
4
|
+
|
5
|
+
> Plans are nothing; planning is everything. --Dwight D. Eisenhower
|
6
|
+
|
7
|
+
Plans was originally created to manage functional specifications and scope documents for our projects. I prefer to write in [markdown](https://daringfireball.net/projects/markdown/), but many of our clients would prefer to review documents in MS Word. Plans (well [Pandoc](http://pandoc.org) really!) bridges that gap allowing us to create these documents in markdown and publish them in MS Word. It also allows us to manage our requirements documents more like code. We keep them all in git (either on [Github](https://github.com) or [Bitbucket](https://bitbucket.org)) and manage changes to them via pull requests. As a side benefit, the built in markdown browsing capabilities available on both BitBucket and GitHub are really handy. That's why, as you will see, most of the markdown files in the documents are named README.md. This way they are available in GitHub or BitBucket as the Readme file for the directory.
|
8
|
+
|
9
|
+
Plans ships with templates (DOC_TYPEs) for managing the requirements for a typical project.
|
10
|
+
|
11
|
+
* Vision and Scope document
|
12
|
+
* Functional Specification
|
13
|
+
* User Classes and Characteristics
|
14
|
+
* Glossary
|
15
|
+
* Plain Document
|
16
|
+
|
17
|
+
These are just examples and its easy to make your own templates. We also use plans to manage our proposals, agreements, and statements of work.
|
18
|
+
|
19
|
+
## Prerequisites
|
20
|
+
|
21
|
+
Plans has only been tested on MacOS. If you *really* want to use it in Windows, let me know.
|
22
|
+
|
23
|
+
Plans depends on [Pandoc](http://pandoc.org) and [ImageMagik](http://imagemagick.org) to do a lot of the heavy lifting. These will need to be installed first.
|
24
|
+
|
25
|
+
There are many ways to do this, but probably the easiest is to use [Homebrew](http://brew.sh).
|
26
|
+
|
27
|
+
Once homebrew is installed, you can easily install Pandoc.
|
28
|
+
|
29
|
+
$ brew install pandoc
|
30
|
+
|
31
|
+
ImageMagick works pretty much the same way.
|
32
|
+
|
33
|
+
$ brew install imagemagick
|
34
|
+
|
35
|
+
You also need Microsoft Word. :)
|
36
|
+
|
37
|
+
## Installation
|
38
|
+
|
39
|
+
Install it:
|
40
|
+
|
41
|
+
$ gem install plans
|
42
|
+
|
43
|
+
## Usage
|
44
|
+
|
45
|
+
To get started, try:
|
46
|
+
|
47
|
+
$ plans help
|
48
|
+
|
49
|
+
This will show you what plans can do. It will also let you know if you have plans installed correctly.
|
50
|
+
|
51
|
+
Plans allows you to define a set of document templates, or DOC_TYPEs. These are stored in your home directory in a `.plans` folder. To create this folder with a default set of documents do the following.
|
52
|
+
|
53
|
+
$ plans init
|
54
|
+
|
55
|
+
Then take a look at the `.plans` directory in your home directory. If you want to customize the templates, check out the README.md in the root of the `.plans` directory.
|
56
|
+
|
57
|
+
To see what types of documents you can create do the following.
|
58
|
+
|
59
|
+
$ plans list
|
60
|
+
|
61
|
+
To create a new functional specification, do the following.
|
62
|
+
|
63
|
+
$ plans new functional
|
64
|
+
|
65
|
+
You can then edit the README.md that is created by plans. To turn that markdown document into MS Word, just navigate into the directory where the file is located and type:
|
66
|
+
|
67
|
+
$ plans publish
|
68
|
+
|
69
|
+
### Images
|
70
|
+
|
71
|
+
Making an image heavy document in markdown can be kind of a pain and functional specifications for a user interface tend to have a lot of mockups, screenshots, and diagrams. With plans, you can just export those images to the `img` folder and include them like you would for markdown normally. Something like this:
|
72
|
+
|
73
|
+
![A Screenshot](./img/Fullscreen_10_12_15__11_34_AM.png)
|
74
|
+
|
75
|
+
This is all well and good, but sometimes those images are huge and they don't get automatically resized in Word. Manually resizing all of the images in a Word document rapidly becomes very tedious.
|
76
|
+
|
77
|
+
So, plans uses Imagemagick to make reasonable sized versions of any images in your documents `img` folder. To learn more, try:
|
78
|
+
|
79
|
+
$ plans help thumbs
|
80
|
+
|
81
|
+
Plans will make 200px, 400px, and 600px wide versions of these images. You can then include them in your document like this:
|
82
|
+
|
83
|
+
![A Screenshot](./img/400px/Fullscreen_10_12_15__11_34_AM.png)
|
84
|
+
|
85
|
+
No more manually resizing images in Word!
|
86
|
+
|
87
|
+
## Development
|
88
|
+
|
89
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
90
|
+
|
91
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
92
|
+
|
93
|
+
## Contributing
|
94
|
+
|
95
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/code-lever/plans.
|
96
|
+
|
97
|
+
## License
|
98
|
+
|
99
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
100
|
+
|
data/Rakefile
ADDED
data/bin/_guard-core
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application '_guard-core' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('guard', '_guard-core')
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "plans"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/guard
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'guard' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('guard', 'guard')
|
data/bin/rake
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'rake' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('rake', 'rake')
|
data/bin/rspec
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# This file was generated by Bundler.
|
4
|
+
#
|
5
|
+
# The application 'rspec' is installed as part of a gem, and
|
6
|
+
# this file is here to facilitate running it.
|
7
|
+
#
|
8
|
+
|
9
|
+
require 'pathname'
|
10
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path("../../Gemfile",
|
11
|
+
Pathname.new(__FILE__).realpath)
|
12
|
+
|
13
|
+
require 'rubygems'
|
14
|
+
require 'bundler/setup'
|
15
|
+
|
16
|
+
load Gem.bin_path('rspec-core', 'rspec')
|
data/bin/setup
ADDED
data/exe/plans
ADDED
data/lib/plans/cli.rb
ADDED
@@ -0,0 +1,121 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'plans/new'
|
3
|
+
require 'plans/list'
|
4
|
+
require 'plans/init'
|
5
|
+
require 'plans/publish'
|
6
|
+
require 'plans/thumbs'
|
7
|
+
|
8
|
+
module Plans
|
9
|
+
class CLI < Thor
|
10
|
+
include Thor::Actions
|
11
|
+
|
12
|
+
# Set the source root for Thor::Actions
|
13
|
+
def self.source_root
|
14
|
+
Plans.source_root
|
15
|
+
end
|
16
|
+
|
17
|
+
# Override for Thor.
|
18
|
+
# Have the application exit and return an error code on failure.
|
19
|
+
def self.exit_on_failure?
|
20
|
+
true
|
21
|
+
end
|
22
|
+
|
23
|
+
class_option :'plans-path',
|
24
|
+
{:type => :string,
|
25
|
+
:desc => 'The path to the .plans directory which contains the plans templates. This is your home directory by default.'}
|
26
|
+
|
27
|
+
|
28
|
+
desc 'new DOC_TYPE', 'Creates a new document of the specified type in the current directory.'
|
29
|
+
long_desc <<-NEW
|
30
|
+
`plans new DOC_TYPE` creates a new document of the specified type.
|
31
|
+
|
32
|
+
To see the available document types try `plans list`.
|
33
|
+
|
34
|
+
> $ plans new scope
|
35
|
+
NEW
|
36
|
+
|
37
|
+
def new(doc_type)
|
38
|
+
New.new(shell, options).do(doc_type)
|
39
|
+
end
|
40
|
+
|
41
|
+
desc 'list', 'List all of the document types available.'
|
42
|
+
long_desc <<-LIST
|
43
|
+
`plans list` Lists all the documents types available.
|
44
|
+
|
45
|
+
> $ plans list
|
46
|
+
LIST
|
47
|
+
|
48
|
+
def list
|
49
|
+
List.new(shell, options).do
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
desc 'init', 'Create the .plans folder in your home directory and initialize it with the default document templates'
|
54
|
+
long_desc <<-INIT
|
55
|
+
`plans init` Creates the .plans folder in your home directory and initializes it with the default document templates.
|
56
|
+
Once you have the templates customized the way you like them, its probably a good idea to put this directory
|
57
|
+
into version control.
|
58
|
+
|
59
|
+
If the directory already exists, the command does nothing.
|
60
|
+
|
61
|
+
> $ plans init
|
62
|
+
INIT
|
63
|
+
|
64
|
+
def init
|
65
|
+
Init.new(shell, options).do
|
66
|
+
end
|
67
|
+
|
68
|
+
desc 'publish', 'Create an MS Word version of the document'
|
69
|
+
long_desc <<-PUBLISH
|
70
|
+
`plans publish` will create a MS Word version of the document.
|
71
|
+
|
72
|
+
The document type is determined by inspecting the template.yml.
|
73
|
+
|
74
|
+
Overwrites any previously published versions of the Word document.
|
75
|
+
|
76
|
+
> $ plans publish
|
77
|
+
PUBLISH
|
78
|
+
method_option :toc,
|
79
|
+
{:type => :boolean,
|
80
|
+
:default => false,
|
81
|
+
:desc => 'Add a table of contents to the MS Word document. Not included by default.'}
|
82
|
+
method_option :open,
|
83
|
+
{:type => :boolean,
|
84
|
+
:default => true,
|
85
|
+
:desc => 'Open the published document after it has been rendered by Pandoc.'}
|
86
|
+
|
87
|
+
def publish(path = '.')
|
88
|
+
Publish.new(shell, options).do(path)
|
89
|
+
end
|
90
|
+
|
91
|
+
desc 'thumbs', 'Creates reduced size copies of each of the images in the img directory'
|
92
|
+
long_desc <<-THUMBS
|
93
|
+
`plans thumbs` will create reduced size versions of
|
94
|
+
each of the images in the document's img directory. Markdown isn't
|
95
|
+
very good at scaling images, so images of a known width are useful.
|
96
|
+
Images like desktop screenshots are often too large to fit on the
|
97
|
+
printed or published page without being manually scaled.
|
98
|
+
|
99
|
+
The command creates three subdirectories in the
|
100
|
+
documents img directory, one for each size of scaled image. These
|
101
|
+
are 200px, 400px, and 600px. To use these in the document, just
|
102
|
+
use the standard markdown syntax for including an image. The following
|
103
|
+
shows how to include a 400px wide version of a screenshot
|
104
|
+
|
105
|
+
`![A Screenshot](./img/400px/Fullscreen_10_12_15__11_34_AM.png)`
|
106
|
+
|
107
|
+
The thumbnail directories are removed each time the thumbnails are
|
108
|
+
generated, so do not place additional files in these directories.
|
109
|
+
|
110
|
+
> $ plans thumbs
|
111
|
+
THUMBS
|
112
|
+
|
113
|
+
def thumbs(path = '.')
|
114
|
+
Thumbs.new(shell, options).do(path)
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
|
121
|
+
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'thor'
|
2
|
+
|
3
|
+
module Plans
|
4
|
+
class Command
|
5
|
+
# To get your hands on the `from_superclass` method
|
6
|
+
include Thor::Base
|
7
|
+
|
8
|
+
# Allow us to use nice Thor helper methods like 'directory'
|
9
|
+
include Thor::Actions
|
10
|
+
|
11
|
+
# Set the source root for Thor::Actions
|
12
|
+
def self.source_root
|
13
|
+
Plans.source_root
|
14
|
+
end
|
15
|
+
|
16
|
+
attr_reader :shell, :options
|
17
|
+
|
18
|
+
# Initialize the command with the
|
19
|
+
# Thor::Shell and the options.
|
20
|
+
def initialize(shell, options)
|
21
|
+
@shell = shell
|
22
|
+
@options = options
|
23
|
+
end
|
24
|
+
|
25
|
+
# Check to see if the .plans path exists
|
26
|
+
# Prints a message for the user and raises if it does not.
|
27
|
+
#
|
28
|
+
# @param [Pathname] path the proposed path to the .plans directory.
|
29
|
+
def check_plans_pathname_exists(path)
|
30
|
+
unless path.exist?
|
31
|
+
say 'The .plans directory does not exist.', :red
|
32
|
+
say 'Run `plans init` to create a .plans folder in your home directory and initialize it with the default document templates.'
|
33
|
+
say " #{@path}"
|
34
|
+
raise_error('Plans directory does not exist.')
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# The full current path, as a pathname object.
|
39
|
+
# @return [Pathname] The full path to the directory where the command is to be executed.
|
40
|
+
def pathname(path)
|
41
|
+
Pathname(File.expand_path(path))
|
42
|
+
end
|
43
|
+
|
44
|
+
# Get the path as a pathname object to the
|
45
|
+
# .plans directory.
|
46
|
+
#
|
47
|
+
# @param [String] path The string path to the .plans directory
|
48
|
+
# or nil if the users home directory should be used.
|
49
|
+
def plans_pathname(path = nil)
|
50
|
+
path = path || Dir.home
|
51
|
+
pathname(path) + '.plans'
|
52
|
+
end
|
53
|
+
|
54
|
+
# Raise a formatted Thor exception.
|
55
|
+
#
|
56
|
+
# @param [String] msg the message to include in the exception.
|
57
|
+
def raise_error(msg)
|
58
|
+
raise Thor::Error, "Error: #{msg}"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/lib/plans/init.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'plans/command'
|
2
|
+
|
3
|
+
module Plans
|
4
|
+
class Init < Command
|
5
|
+
def do
|
6
|
+
plans_path = plans_pathname(options[:'plans-path'])
|
7
|
+
if plans_path.exist?
|
8
|
+
say 'The .plans directory already exists!', :red
|
9
|
+
say 'If you want to recreate it, you will need to manually delete it first.'
|
10
|
+
say 'The .plans directory is located here:'
|
11
|
+
say " #{plans_path}"
|
12
|
+
raise_error('Plans directory exists.')
|
13
|
+
end
|
14
|
+
FileUtils.makedirs(plans_path)
|
15
|
+
template_path = pathname(Plans.source_root) + 'template/.'
|
16
|
+
FileUtils.cp_r(template_path, plans_path)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/plans/list.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'plans/command'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
module Plans
|
5
|
+
class List < Command
|
6
|
+
|
7
|
+
def do
|
8
|
+
plans_path = plans_pathname(options[:'plans-path'])
|
9
|
+
check_plans_pathname_exists plans_path
|
10
|
+
|
11
|
+
say 'Listing all available DOC_TYPEs...'
|
12
|
+
say ''
|
13
|
+
plans_path.each_child { |x| list_template(x) }
|
14
|
+
say ''
|
15
|
+
say 'Create a new document from a template with the command `plans new DOC_TYPE`'
|
16
|
+
end
|
17
|
+
|
18
|
+
def list_template(path_name)
|
19
|
+
# must be a Pathname
|
20
|
+
return unless path_name.is_a? Pathname
|
21
|
+
# must be a directory
|
22
|
+
return unless path_name.directory?
|
23
|
+
|
24
|
+
doc_type = path_name.basename
|
25
|
+
say "DOC_TYPE: #{doc_type}"
|
26
|
+
|
27
|
+
begin
|
28
|
+
metadata = YAML.load_file(path_name + 'template.yml')
|
29
|
+
title = metadata['title'] || 'Title not found. Check template.yml.'
|
30
|
+
description = metadata['description'] || 'Description not found. Check template.yml.'
|
31
|
+
say " Title: #{title}"
|
32
|
+
say " Description: #{description}"
|
33
|
+
rescue Errno::ENOENT # File not found
|
34
|
+
say 'No template.yml found in the template directory. Did you forget to add it?', :red
|
35
|
+
end
|
36
|
+
|
37
|
+
unless (path_name + 'README.md').file?
|
38
|
+
say 'No README.md found in the template directory. Did you forget to add it?', :red
|
39
|
+
end
|
40
|
+
|
41
|
+
unless (path_name + 'reference.docx').file?
|
42
|
+
say 'No reference.docx found in template directory. Did you forget to add it?', :red
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
data/lib/plans/new.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'plans/command'
|
2
|
+
|
3
|
+
module Plans
|
4
|
+
class New < Command
|
5
|
+
|
6
|
+
def do(doc_type)
|
7
|
+
plans_path = plans_pathname(@options[:'plans-path'])
|
8
|
+
check_plans_pathname_exists plans_path
|
9
|
+
|
10
|
+
doc_path = plans_path + doc_type
|
11
|
+
check_doc_path_exists(doc_path, plans_path, doc_type)
|
12
|
+
|
13
|
+
# Set the Thor::Actions destination root to the current working directory.
|
14
|
+
self.destination_root = '.'
|
15
|
+
# copy the template directory, but don't include the reference word docs.
|
16
|
+
directory(doc_path, "./#{doc_type}", :exclude_pattern => /docx/)
|
17
|
+
end
|
18
|
+
|
19
|
+
def check_doc_path_exists(doc_path, plans_path, doc_type)
|
20
|
+
unless doc_path.exist?
|
21
|
+
say "Cannot create DOC_TYPE #{doc_type} because this template does not exist.", :red
|
22
|
+
say 'Try `plans list` to see the available DOC_TYPEs or'
|
23
|
+
say 'check the templates in the .plans directory here:'
|
24
|
+
say " #{plans_path}"
|
25
|
+
raise_error("DOC_TYPE #{doc_type} does not exist.")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|