docgen 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 522e85bbbc438ce5554040433d3a02dd94680dc3
4
+ data.tar.gz: 358668231571b9660518e0c138af78ce8caccd88
5
+ SHA512:
6
+ metadata.gz: bd2560accccc14f84f5a61cf6c8172ac293b583f05d09744dc3fd34b9af5ed6121632f43c7a73b9edda9babcedf41675fd342a98af426405727410ff2b4d5177
7
+ data.tar.gz: af0110752fd7d9b289838d48207810a360544f8a26a8360720e939f1445373f40dc27a57418233e96251a73d4fd3b9b4cadcd602f458f3c2d0f1175a52f6b867
@@ -0,0 +1,14 @@
1
+ temp.out
2
+ *temp.pptx
3
+ ~*
4
+ .~*
5
+ /.bundle/
6
+ /.yardoc
7
+ /Gemfile.lock
8
+ /_yardoc/
9
+ /coverage/
10
+ /doc/
11
+ /pkg/
12
+ /spec/reports/
13
+ /tmp/
14
+ .DS_Store
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,5 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.13.7
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at davenicolette@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in docgen.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2017 Dave Nicolette
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,66 @@
1
+ # Docgen
2
+
3
+ Proof of concept to apply custom updates to template files and output the resulting file in any of several formats, including text, HTML, PDF, LaTeX, and others.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'docgen'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install docgen
20
+
21
+ ## Usage
22
+
23
+ The gem takes a template document that may contain placeholders for content substitution, and applies substitution values to produce a customized output document. The substitution values are defined in a database as key-value pairs. The placeholders in the template documents contain the key values matching entries in the database.
24
+
25
+ Given a template document like this
26
+
27
+ ```
28
+ Hello, ::name::. It's a ::quality:: day today, isn't it?
29
+ ```
30
+
31
+ and substitution values like this
32
+
33
+ ```
34
+ name => Marcia
35
+ quality => dismal
36
+ ```
37
+
38
+ then a call like this
39
+
40
+ ```
41
+ docgen.gen 'pdf', template_text
42
+ ```
43
+
44
+ results in a PDF file containing the text
45
+
46
+ ```
47
+ Hello, Marcia. It's a dismal day today, isn't it?
48
+ ```
49
+
50
+ The code is under development, so it's premature to write comprehensive documentation in a refined way. See the file ```docgen_spec.rb``` for working examples of usage.
51
+
52
+ ## Development
53
+
54
+ 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.
55
+
56
+ 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).
57
+
58
+ ## Contributing
59
+
60
+ Bug reports and pull requests are welcome on GitHub at https://github.com/neopragma/docgen. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
61
+
62
+
63
+ ## License
64
+
65
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
66
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "docgen"
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
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1 @@
1
+ sqlite3 docgen < create_database.sql
@@ -0,0 +1,55 @@
1
+ drop table if exists "document_sets";
2
+ create table if not exists "document_sets" (
3
+ "id" integer not null,
4
+ "name" varchar(128) not null,
5
+ "description" varchar(256));
6
+ insert into document_sets ("id", "name", "description")
7
+ values (1, "default", "Default document set when none is specified");
8
+ insert into document_sets ("id", "name", "description")
9
+ values (2, "gcpd", "Gotham City Police Department");
10
+
11
+ drop table if exists "substitutions";
12
+ create table if not exists "substitutions" (
13
+ "set_id" integer not null,
14
+ "key" varchar(128) not null,
15
+ "value" varchar(128) not null);
16
+
17
+ /* Defaults */
18
+ insert into substitutions ("set_id", "key", "value")
19
+ values ("default", "client name", "LeadingAgile");
20
+ insert into substitutions ("set_id", "key", "value")
21
+ values ("default", "tlt", "Transformation Leadership Team");
22
+ insert into substitutions ("set_id", "key", "value")
23
+ values ("default", "ivt", "Innovation and Verification Team");
24
+ insert into substitutions ("set_id", "key", "value")
25
+ values ("default", "value stream", "Line of Business");
26
+ insert into substitutions ("set_id", "key", "value")
27
+ values ("default", "portfolio team", "Portfolio Team");
28
+ insert into substitutions ("set_id", "key", "value")
29
+ values ("default", "program team", "Program Team");
30
+ insert into substitutions ("set_id", "key", "value")
31
+ values ("default", "delivery team", "Delivery Team");
32
+ insert into substitutions ("set_id", "key", "value")
33
+ values ("default", "iteration", "Sprint");
34
+ insert into substitutions ("set_id", "key", "value")
35
+ values ("default", "product owner", "Product Owner");
36
+
37
+ /* Gotham City Police Department */
38
+ insert into substitutions ("set_id", "key", "value")
39
+ values ("gcpd", "client name", "Gotham City Police Dept.");
40
+ insert into substitutions ("set_id", "key", "value")
41
+ values ("gcpd", "tlt", "Improvement Guidance Committee");
42
+ insert into substitutions ("set_id", "key", "value")
43
+ values ("default", "ivt", "Architectural Guidance Committee");
44
+ insert into substitutions ("set_id", "key", "value")
45
+ values ("gcpd", "value stream", "Product Line");
46
+ insert into substitutions ("set_id", "key", "value")
47
+ values ("gcpd", "portfolio team", "Product Line Team");
48
+ insert into substitutions ("set_id", "key", "value")
49
+ values ("gcpd", "program team", "Coordination Team");
50
+ insert into substitutions ("set_id", "key", "value")
51
+ values ("gcpd", "delivery team", "Development Pod");
52
+ insert into substitutions ("set_id", "key", "value")
53
+ values ("gcpd", "iteration", "Development Cadence");
54
+ insert into substitutions ("set_id", "key", "value")
55
+ values ("gcpd", "product owner", "Capability Owner");
data/devinit ADDED
@@ -0,0 +1,71 @@
1
+ #!/bin/bash
2
+ # devinit
3
+ # Set up the development environment for docgen.
4
+ # (assumes bash)
5
+
6
+ declare -a debian_pkg
7
+ debian_pkg[${#debian_pkg[@]}]='git' # version control client
8
+ debian_pkg[${#debian_pkg[@]}]='build-essential' # build dependencies
9
+ debian_pkg[${#debian_pkg[@]}]="linux-headers-$(uname -r)"
10
+ debian_pkg[${#debian_pkg[@]}]='ruby'
11
+ debian_pkg[${#debian_pkg[@]}]='ruby-dev'
12
+ debian_pkg[${#debian_pkg[@]}]='sqlite3' # database for docgen
13
+ debian_pkg[${#debian_pkg[@]}]='inputenc' # kramdown LaTeX output
14
+ debian_pkg[${#debian_pkg[@]}]='fontenc'
15
+ debian_pkg[${#debian_pkg[@]}]='listings'
16
+ debian_pkg[${#debian_pkg[@]}]='hyperref'
17
+
18
+
19
+
20
+
21
+
22
+ function identify_os {
23
+ THIS_OS=
24
+ if [[ "$OSTYPE" == "linux-gnu" ]]; then
25
+ THIS_OS='Linux'
26
+ identify_linux_package_manager
27
+ else
28
+ 'Unsupported OS'
29
+ # elif [[ "$OSTYPE" == "darwin"* ]]; then
30
+ # echo 'OSX detected'
31
+ # elif [[ "$OSTYPE" == "cygwin" ]]; then
32
+ # echo 'Cygwin detected'
33
+ # elif [[ "$OSTYPE" == "msys" ]]; then
34
+ # echo 'Mingw32 detected'
35
+ # elif [[ "$OSTYPE" == "freebsd"* ]]; then
36
+ # echo 'FreeBSD detected'
37
+ # else
38
+ # echo 'OS not identified'
39
+ fi
40
+ }
41
+
42
+ function identify_linux_package_manager {
43
+ if [[ $(which apt) ]]; then
44
+ PKG_MGR='apt'
45
+ elif [[ $(which yum) ]]; then
46
+ PKG_MGR='yum'
47
+ fi
48
+ }
49
+
50
+ function install_packages {
51
+ echo '' > devinit.log
52
+ identify_os
53
+ for name in "${debian_pkg[@]}"
54
+ do
55
+ if [[ -n "$(dpkg -l | grep ${name})" ]]; then
56
+ echo "package ${name} is installed...skipping install" >> devinit.log
57
+ else
58
+ echo "installing package ${name}" >> devinit.log
59
+ sudo apt install -y "$name" &>> devinit.log
60
+ fi
61
+ done
62
+ }
63
+
64
+ function configure_postgresql {
65
+ $(sudo cp /etc/postgresql/*/main/postgresql.conf ./postgresql.conf.orig)
66
+ $(sudo cp /etc/postgresql/*/main/pg_hba.conf ./pg_hba.conf.orig)
67
+ $(sudo cp ./pg_hba.conf /etc/postgresql/*/main)
68
+ $(sudo sed -i "/#listen_addresses/c\listen_addresses = \'*\'" /etc/postgresql/*/main/postgresql.conf)
69
+ }
70
+
71
+ install_packages
@@ -0,0 +1,25 @@
1
+
2
+ package git is installed...skipping install
3
+ package build-essential is installed...skipping install
4
+ package linux-headers-4.4.0-59-generic is installed...skipping install
5
+ package ruby is installed...skipping install
6
+ package ruby-dev is installed...skipping install
7
+ package sqlite3 is installed...skipping install
8
+ installing package inputenc
9
+
10
+ WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
11
+
12
+ Reading package lists...
13
+ Building dependency tree...
14
+ Reading state information...
15
+ E: Unable to locate package inputenc
16
+ package fontenc is installed...skipping install
17
+ package listings is installed...skipping install
18
+ installing package hyperref
19
+
20
+ WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
21
+
22
+ Reading package lists...
23
+ Building dependency tree...
24
+ Reading state information...
25
+ E: Unable to locate package hyperref
data/docgen ADDED
Binary file
@@ -0,0 +1,43 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'docgen/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "docgen"
8
+ spec.version = Docgen::VERSION
9
+ spec.authors = ["Dave Nicolette"]
10
+ spec.email = ["davenicolette@gmail.com"]
11
+
12
+ spec.summary = %q{Merge boilerplate and custom content to generate documents.}
13
+ spec.description = %q{Generate documents in various formats based on standard boilerplate and custom content.}
14
+ spec.homepage = "https://github.com/neopragma/docgen"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "http://localhost"
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against " \
23
+ # "public gem pushes."
24
+ # end
25
+
26
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
27
+ f.match(%r{^(test|spec|features)/})
28
+ end
29
+ spec.bindir = "exe"
30
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
+ spec.require_paths = ["lib"]
32
+
33
+ spec.add_development_dependency "bundler", "~> 1.13"
34
+ spec.add_development_dependency "rake", "~> 10.0"
35
+ spec.add_development_dependency "rspec", "~> 3.0"
36
+ spec.add_dependency "sqlite3", "~> 1.3"
37
+ spec.add_dependency "sequel", "~> 4.43"
38
+ spec.add_dependency "kramdown", "~> 1.13"
39
+ spec.add_dependency "nokogiri", "~> 1.7"
40
+ spec.add_dependency "prawn", "~> 2.1"
41
+ spec.add_dependency "prawn-table", "~> 0.2"
42
+ spec.add_dependency "rubyzip", "~> 1.2"
43
+ end
@@ -0,0 +1,22 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <% if @converter.root.options[:encoding] %>
5
+ <meta http-equiv="Content-type" content="text/html;charset=<%= @converter.root.options[:encoding] %>">
6
+ <% end %>
7
+ <%
8
+ extend ::Kramdown::Utils::Html
9
+ title = ''
10
+ h = @converter.root.children.find {|c| c.type == :header}
11
+ if h
12
+ collector = lambda {|c| c.children.collect {|cc| cc.type == :text ? escape_html(cc.value, :text) : collector.call(cc)}.join('')}
13
+ title = collector.call(h)
14
+ end
15
+ %>
16
+ <title><%= title %></title>
17
+ <meta name="generator" content="kramdown <%= ::Kramdown::VERSION %>" />
18
+ </head>
19
+ <body>
20
+ <%= @body %>
21
+ </body>
22
+ </html>