eyemask 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 03c52d9ed9335e41ef52c481dfad96e062857de4
4
+ data.tar.gz: bf47ffad66e00a3eea12fcf3bdb929c66d102527
5
+ SHA512:
6
+ metadata.gz: 4fc4cda7e0efcfa08b338440ba94546b70f57d5cbe3b57d462fc8b2e80e89a3e4e70cc233b4e078f4dd33507aaddc61c31ba040406fcb9abe004ffd2b6c3a2cb
7
+ data.tar.gz: 526683ab490a3d6aa6ec514c714949b716b6e5b26ed415612aecc91fc95f0500ce43e855bd9c835aa2461b119b8a3bbe0ec49adf35d52c8c80546a328b0a2bfa
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
data/.travis.yml ADDED
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ cache: bundler
3
+
4
+ rvm:
5
+ - 2.2.0
6
+
7
+ script: 'bundle exec rake'
8
+
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in eyemask.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Joe Geldart
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.
data/README.md ADDED
@@ -0,0 +1,117 @@
1
+ # Eyemask
2
+
3
+ Eyemask allows you to generate rich documentation from your Cucumber specs. It works by taking the output of the JSON formatter and applying a [Liquid](http://liquidmarkup.org/) template to it. The result can be as simple as a plain text or Markdown file, or as complex as an HTML file ready to be rendered into PDF.
4
+
5
+ The purpose of Eyemask is to make it easy to maintain living documentation that can be used by the whole team -- from developers to designers to client stakeholders -- no matter whether they're more verbal or visual. It is based on some of the ideas of [Rich Pictures](http://en.wikipedia.org/wiki/Rich_picture) from soft systems research.
6
+
7
+ Eyemask assumes that the description blocks for features and scenarios (the plain text before any other content) are marked up using a variant of Markdown. We support running those blocks through Liquid, to allow template authors to use a powerful set of tags. These tags include `{% uml %}`, allowing you to embed UML diagrams using [PlantUML's syntax](http://plantuml.sourceforge.net/index.html).
8
+
9
+ This tool is still in its early days, and will evolve substantially as it is used in the wild. Please help us improve it by submitting feature requests, bug reports, and pull requests.
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'eyemask'
17
+ ```
18
+
19
+ Or, for the latest development version:
20
+
21
+ ```ruby
22
+ gem 'eyemask', git: 'https://github.com/wearefriday/eyemask'
23
+ ```
24
+
25
+ And then execute:
26
+
27
+ $ bundle
28
+
29
+ Or install it yourself as:
30
+
31
+ $ gem install eyemask
32
+
33
+ ## Usage
34
+
35
+ Eyemask is designed to be used as part of a larger toolchain. Its most basic operation takes a JSON file and outputs a Markdown file to `STDOUT`.
36
+
37
+ $ bundle exec eyemask process cucumber.json
38
+
39
+ We also support taking the JSON from `STDIN` by using `-` as the file name:
40
+
41
+ $ cat cucumber.json | bundle exec eyemask process -
42
+
43
+ You can specify a custom template by providing the `--template` option:
44
+
45
+ $ bundle exec eyemask process cucumber.json --template="path/to/template.html"
46
+
47
+ There are also some more built-in templates that can be used by refering to their name. For example, the [Prince XML](http://www.princexml.com/) template can be invoked as follows:
48
+
49
+ $ bundle exec eyemask process cucumber.json --template=princexml
50
+
51
+ It also supports customisation via *parameters*. There are four primary parameters: title, subtitle, logo, and authors. These become top-level variables available to the template:
52
+
53
+ $ bundle exec eyemask process cucumber.json --title="My Title Here"
54
+
55
+ You can also set custom parameters by passing a `--params` option. The parameters take the form 'key':'value':
56
+
57
+ $ bundle exec eyemask process cucumber.json --params=my_param:"My Value" my_other_param:2
58
+
59
+ This list of options is likely to grow as we expand the use-cases of the tool.
60
+
61
+ ## Coming soon
62
+
63
+ Here are some of the features that are planned for the future (in no particular order):
64
+
65
+ - More and improved named default templates to make Eyemask more powerful out of the box.
66
+
67
+ - Additional explanatory materials as Markdown files to explain more about your code.
68
+
69
+ - Providing textual syntaxes for more diagram types, including charts, for when you want to reduce the cost of change.
70
+
71
+ - Tags for footnotes, pullquotes, sidebars, and sidenotes.
72
+
73
+ - Index and flexible, configurable Table of Contents generation (probably based on a similar 'two-pass' approach as used by LaTeX).
74
+
75
+ - Default metadata, such as the date and time of preparation.
76
+
77
+ - Additional standard metadata params, such as version, client, project, and copyright.
78
+
79
+ - A new textual syntax and diagram renderer for 'scenario flow diagrams' allowing links from blocks to scenarios or individual steps.
80
+
81
+ - A construct/tag for cross-references of scenarios, features, etc.
82
+
83
+ - Implement support for backgrounds and scenario outlines (with variable highlighting) in the default templates
84
+
85
+ ## UML diagrams
86
+
87
+ Eyemask supports rich UML diagrams, for those occasions when a visual is the best way to explain a feature. This uses the [PlantUML](http://plantuml.sourceforge.net/index.html) command-line tool. To use this functionality, download the PlantUML JAR and create a shell script called `plantuml`, in your `PATH`, that executes the JAR passing all parameters.
88
+
89
+ ## Standard templates
90
+
91
+ Eyemask currently includes 3 different standard templates that can be used by providing their name to the `--template` option:
92
+
93
+ - `--template=markdown` -- Produces a Markdown file that can be provided to tools such as Pandoc.
94
+ - `--template=princexml` -- A traditional 'book' template designed for use with PrinceXML.
95
+ - `--template=slides` -- A clean presentation template designed for use with PrinceXML.
96
+
97
+ These templates are being tweaked and improved. Other templates will likely be added over time.
98
+
99
+ ## Making PDFs
100
+
101
+ This tool produces text files. These can be converted to nice PDFs using a few different tools. If you're producing your specifications for non-commercial uses, or have a licence, [Prince XML](http://www.princexml.com/) produces a very high quality of output. You can pipe the output of Eyemask directly into PrinceXML using a command such as:
102
+
103
+ $ bundle exec cucumber --format json | bundle exec eyemask process - --template=slides | prince -o tmp/specification.pdf -
104
+
105
+ ## Development
106
+
107
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
108
+
109
+ 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` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
110
+
111
+ ## Contributing
112
+
113
+ 1. Fork it ( https://github.com/wearefriday/eyemask/fork )
114
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
115
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
116
+ 4. Push to the branch (`git push origin my-new-feature`)
117
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,35 @@
1
+ require 'bundler/gem_tasks'
2
+
3
+ begin
4
+ require 'rspec/core/rake_task'
5
+ require 'cucumber'
6
+ require 'cucumber/rake/task'
7
+
8
+ # Default directory to look in is `/specs`
9
+ # Run with `rake spec`
10
+ RSpec::Core::RakeTask.new(:specs) do |task|
11
+ task.rspec_opts = ['--color']
12
+ end
13
+
14
+ Cucumber::Rake::Task.new(:features) do |t|
15
+ t.cucumber_opts = "--format progress"
16
+ end
17
+
18
+ rescue LoadError
19
+
20
+ desc 'RSpec rake task not available'
21
+ task :specs do
22
+ abort 'RSpec rake task is not available. Be sure to install RSpec as a gem or plugin'
23
+ end
24
+
25
+ desc 'Cucumber rake task not available'
26
+ task :features do
27
+ abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
28
+ end
29
+
30
+ end
31
+
32
+ task :test => [:build,:install,:specs, :features]
33
+
34
+
35
+ task :default => :test
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "eyemask"
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/document ADDED
@@ -0,0 +1,5 @@
1
+ #!/bin/bash
2
+
3
+ set -euo pipefail
4
+
5
+ bundle exec cucumber --format json | eyemask process - --subtitle="Eyemask Specification" --title="Friday" --authors="Joe Geldart" --template=slides | prince -o tmp/eyemask.pdf -
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/exe/eyemask ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "eyemask"
4
+
5
+ Eyemask::App.start
data/eyemask.gemspec ADDED
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'eyemask/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "eyemask"
8
+ spec.version = Eyemask::VERSION
9
+ spec.authors = ["Joe Geldart"]
10
+ spec.email = ["joe.geldart@wearefriday.com"]
11
+
12
+ spec.summary = %q{Eyemask makes it easy to create rich, engaging, living documentation that everyone can use.}
13
+ spec.homepage = "http://github.com/wearefriday/eyemask"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.8"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ spec.add_development_dependency "cucumber", "~> 1.1.1"
24
+ spec.add_development_dependency "aruba", "~> 0.6.2"
25
+ spec.add_development_dependency "rspec", "~> 3.2"
26
+ spec.add_development_dependency "pry"
27
+ spec.add_development_dependency "pry-byebug"
28
+ spec.add_runtime_dependency "multi_json", "~> 1.11.0"
29
+ spec.add_runtime_dependency "thor", "~> 0.19.1"
30
+ spec.add_runtime_dependency "redcarpet", "~> 3.2.2"
31
+ spec.add_runtime_dependency "liquid", "~> 3.0.1"
32
+ spec.add_runtime_dependency "rouge"
33
+ end
data/lib/eyemask.rb ADDED
@@ -0,0 +1,4 @@
1
+ require "eyemask/version"
2
+ require "eyemask/app"
3
+ require "eyemask/core"
4
+ require "eyemask/liquid"
@@ -0,0 +1,42 @@
1
+ require "thor"
2
+
3
+ module Eyemask
4
+
5
+ class App < Thor
6
+
7
+ desc "process", "Process one or more Cucumber JSON files to Markdown"
8
+ method_option "title", desc: "Set a custom title for the document", default: "Specification"
9
+ method_option "subtitle", desc: "Set a custom subtitle for the document"
10
+ method_option "authors", desc: "Set a list of authors for the document", type: :array, default: []
11
+ method_option "logo", desc: "Provide a URL for a logo that can be used in templates"
12
+ method_option "template", desc: "A custom Liquid template for rendering the output", default: "markdown"
13
+ method_option "params", desc: "A set of custom parameters coded as key:value", type: :hash, default: {}
14
+ def process(*file_names)
15
+ init_opts = {}
16
+ loader = Eyemask::Core::Loader.new(options)
17
+ file_names.each do |file|
18
+ loader.load(file, contents(file))
19
+ end
20
+ loader.done
21
+
22
+ init_opts[:template] = options[:template]
23
+
24
+ puts Eyemask::Core::Converter.new(init_opts).convert(loader.document)
25
+ end
26
+
27
+ no_commands do
28
+
29
+ def contents(file_name)
30
+ case file_name
31
+ when "-"
32
+ STDIN.read
33
+ else
34
+ File.open(file_name).read
35
+ end
36
+ end
37
+
38
+ end
39
+
40
+ end
41
+
42
+ end
@@ -0,0 +1,2 @@
1
+ require "eyemask/core/loader"
2
+ require "eyemask/core/converter"
@@ -0,0 +1,37 @@
1
+ require 'json'
2
+ require 'liquid'
3
+
4
+ module Eyemask
5
+ module Core
6
+ class Converter
7
+
8
+ def initialize(initiaizer_options={})
9
+ @template = ::Liquid::Template.parse(template(initiaizer_options[:template]))
10
+ end
11
+
12
+ def convert(document)
13
+ @template.render(document, registers: document).strip
14
+ end
15
+
16
+ private
17
+
18
+ def template(template)
19
+ case template
20
+ when "markdown"
21
+ File.open(template_file("markdown.md")).read
22
+ when "princexml"
23
+ File.open(template_file("princexml.html")).read
24
+ when "slides"
25
+ File.open(template_file("slides.html")).read
26
+ else
27
+ File.open(File.expand_path(template)).read
28
+ end
29
+ end
30
+
31
+ def template_file(filename)
32
+ File.join(File.dirname(File.expand_path(__FILE__)), "../../../templates/#{filename}")
33
+ end
34
+
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,47 @@
1
+ module Eyemask
2
+ module Core
3
+
4
+ class Loader
5
+
6
+ def initialize(options={})
7
+ @options = options
8
+ @contents = []
9
+ end
10
+
11
+ def load(uri, data)
12
+ @contents.concat(to_elements(uri, data))
13
+ end
14
+
15
+ def done
16
+ # DO NOTHING, HERE AS A HOOK
17
+ end
18
+
19
+ def document
20
+ doc = {}
21
+ doc["contents"] = contents
22
+ doc["title"] = @options[:title]
23
+ doc["subtitle"] = @options[:subtitle]
24
+ doc["authors"] = @options[:authors]
25
+ doc["logo"] = @options[:logo]
26
+ doc["params"] = @options[:params]
27
+ doc
28
+ end
29
+
30
+ def contents
31
+ @contents.sort{|a, b| a["uri"] <=> b["uri"] }
32
+ end
33
+
34
+ private
35
+
36
+ def to_elements(uri, data)
37
+ begin
38
+ JSON.parse(data)
39
+ rescue JSON::ParserError
40
+ []
41
+ end
42
+ end
43
+
44
+ end
45
+
46
+ end
47
+ end