dasheets 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NjJjMWNkOTYwMzU1N2Q5ZTZiMGYxYzE3NGVhMDk2OWM0NjNjOTAzNA==
5
+ data.tar.gz: !binary |-
6
+ NDliZTI5ODcwOGRmNjVlNjc5NjYyNGU3ODcyMTAzMWU2MDIzYTZlNA==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ OTM2YmFiMGI0MTczOWQzOTMxNWQzOGUxNDI1ZjAwZDdiMDZmMWU2ZDgzZTlk
10
+ ZWFiNWFmMGNlNzgzZDA1NTk5YjZiZjkwOGJmMTI4ZTA4M2I1OTU4N2YwMzUy
11
+ NTJhMTdjNzk2NWRmNjg3ZDA5MDU3MDE1NDI3MWRhOTIzNGQ2Y2M=
12
+ data.tar.gz: !binary |-
13
+ ZmNlOGY4Y2FjYjFlZGFiNDk5N2E2YWZmOGUxNzkzZDJmNGM5ZmZmZGZjN2Jh
14
+ ZmYxNjcyYzAxNjdhMGJkYzNlYWU4Njc5MGRmZmQ3OTVlNzQ4NGQwNDYzODRj
15
+ OGYyZGUyNDFjZTllOGVjZjcyYTM3YTg3ZGUyZDgwNmMwOTRmNjY=
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Florian Dütsch
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,65 @@
1
+ # Dasheets
2
+
3
+ Generate your own cheatsheets as docsets for [Dash](http://kapeli.com/dash)!
4
+ Use this simple command line tool and write your cheatsheets in an easy
5
+ language (Ruby DSL).
6
+
7
+ ## Installation
8
+
9
+ $ gem install dasheets
10
+
11
+ ## Usage
12
+
13
+ Write a file (here `tmux.cheatsheet`) containing your cheatsheet-data, e. g.:
14
+
15
+ cheatsheet do
16
+ title 'TMUX-Cheatsheet'
17
+ short_name 'tmux'
18
+
19
+ category do
20
+ id 'windows'
21
+ entry do
22
+ name 'create window'
23
+ command 'PREFIX-c'
24
+ end
25
+ entry do
26
+ name 'rename window'
27
+ command 'PREFIX-,'
28
+ end
29
+ entry do
30
+ name 'go to next window'
31
+ command 'PREFIX-n'
32
+ end
33
+ end
34
+
35
+ category do
36
+ id 'panes'
37
+ entry do
38
+ name 'split horizontally'
39
+ command 'PREFIX-|'
40
+ notes 'custom mapping'
41
+ end
42
+ entry do
43
+ name 'split horizontally'
44
+ command 'PREFIX-%'
45
+ end
46
+ entry do
47
+ name 'split vertically'
48
+ command 'PREFIX-"'
49
+ end
50
+ end
51
+ end
52
+
53
+ To convert this file to a docset, call
54
+
55
+ $ dasheets generate tmux.cheatsheet
56
+
57
+
58
+ ## Contributing
59
+
60
+ Yes, please! Open issues and pull requests on the
61
+ [GitHub page](https://github.com/Nix-wie-weg/dasheets).
62
+
63
+ ## Thanks
64
+
65
+ [svenwin](https://github.com/svenwin) for the awesome name!
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/TODO ADDED
@@ -0,0 +1,5 @@
1
+ TODO
2
+ * Better documentation, more examples, ...
3
+ * Render nice HTML
4
+ * Icon
5
+ * minidown
data/bin/dasheets ADDED
@@ -0,0 +1,7 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $LOAD_PATH << File.expand_path('../../lib', __FILE__)
4
+ require 'dasheets'
5
+ require 'dasheets/cli'
6
+ Dasheets::CLI.start
7
+
data/dasheets.gemspec ADDED
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'dasheets/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'dasheets'
8
+ spec.version = Dasheets::VERSION
9
+ spec.authors = ['Florian Dütsch']
10
+ spec.email = ['florian.duetsch@nix-wie-weg.de']
11
+ spec.description = 'Generate cheatsheets for Dash'
12
+ spec.summary = spec.description
13
+ spec.homepage = 'https://github.com/Nix-wie-weg/dasheets'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.3'
22
+ spec.add_development_dependency 'rake'
23
+
24
+ spec.add_dependency 'thor'
25
+ spec.add_dependency 'haml', '~> 4.0.3'
26
+ spec.add_dependency 'sqlite3', '~> 1.3.8'
27
+ spec.add_dependency 'plist', '~> 3.1.0'
28
+ end
@@ -0,0 +1,38 @@
1
+ cheatsheet do
2
+ title 'TMUX-Cheatsheet'
3
+ short_name 'tmux'
4
+
5
+ category do
6
+ id 'windows'
7
+ entry do
8
+ name 'create window'
9
+ command 'PREFIX-c'
10
+ end
11
+ entry do
12
+ name 'rename window'
13
+ command 'PREFIX-,'
14
+ end
15
+ entry do
16
+ name 'go to next window'
17
+ command 'PREFIX-n'
18
+ end
19
+ end
20
+
21
+ category do
22
+ id 'panes'
23
+ entry do
24
+ name 'split horizontally'
25
+ command 'PREFIX-|'
26
+ notes 'custom mapping'
27
+ end
28
+ entry do
29
+ name 'split horizontally'
30
+ command 'PREFIX-%'
31
+ end
32
+ entry do
33
+ name 'split vertically'
34
+ command 'PREFIX-"'
35
+ end
36
+ end
37
+ end
38
+
@@ -0,0 +1,11 @@
1
+ require 'thor'
2
+
3
+ module Dasheets
4
+ class CLI < Thor
5
+ desc 'generate FILE', 'Generates cheatsheet out of a file'
6
+ def generate(file)
7
+ context = Dasheets::DSL::Context.new(file)
8
+ context.generate
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,67 @@
1
+ require 'plist'
2
+ require 'sqlite3'
3
+ require 'fileutils'
4
+ require 'haml'
5
+ require 'ostruct'
6
+
7
+ class Dasheets::Creator
8
+ def initialize(cheatsheet)
9
+ @cheatsheet = cheatsheet
10
+ @path = "#{@cheatsheet.short_name}.docset/Contents/"
11
+ end
12
+
13
+ def generate
14
+ FileUtils.rm_rf(@path)
15
+ FileUtils.mkdir_p(@path)
16
+ generate_html_file
17
+ generate_plist_file
18
+ generate_database
19
+ end
20
+
21
+ private
22
+
23
+ def generate_html_file
24
+ tpl_path = File.expand_path('../templates', __FILE__)
25
+
26
+ # HTML
27
+ template = File.read("#{tpl_path}/template.haml")
28
+ engine = Haml::Engine.new(template)
29
+ out = engine.render(@cheatsheet)
30
+ doc_path = "#{@path}Resources/Documents/"
31
+ FileUtils.mkdir_p(doc_path)
32
+ File.open("#{doc_path}index.html", 'w') { |file| file.write(out) }
33
+
34
+ # (static) CSS
35
+ FileUtils.cp("#{tpl_path}/style.css", doc_path)
36
+ end
37
+
38
+ def generate_plist_file
39
+ plist_data = {
40
+ 'CFBundleIdentifier' => @cheatsheet.short_name,
41
+ 'CFBundleName' => @cheatsheet.title,
42
+ 'DocSetPlatformFamily' => @cheatsheet.short_name,
43
+ 'isDashDocset' => true,
44
+ 'dashIndexFilePath' => 'index.html'
45
+ }
46
+ File.open("#{@path}Info.plist", 'w') do |file|
47
+ file.write(Plist::Emit.dump(plist_data))
48
+ end
49
+ end
50
+
51
+ def generate_database
52
+ sqlite_file = "#{@path}Resources/docSet.dsidx"
53
+ db = SQLite3::Database.new(sqlite_file)
54
+ db.execute <<-SQL
55
+ CREATE TABLE searchIndex(id INTEGER PRIMARY KEY, name TEXT,
56
+ type TEXT, path TEXT);
57
+ CREATE UNIQUE INDEX anchor ON searchIndex (name, type, path);
58
+ SQL
59
+ @cheatsheet.categories.each do |category|
60
+ category.entries.each_with_index do |entry, index|
61
+ sql = 'INSERT INTO searchIndex(name, type, path) VALUES (?, ?, ?)'
62
+ db.execute(sql, entry.name, 'Guide',
63
+ "index.html\##{category.id}-#{index}")
64
+ end
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,15 @@
1
+ class Dasheets::DSL::Category
2
+ attr_reader :entries
3
+ def initialize(&block)
4
+ @entries = []
5
+ instance_eval(&block)
6
+ end
7
+
8
+ def id(id = nil)
9
+ @id = id if id
10
+ @id
11
+ end
12
+ def entry(&block)
13
+ @entries << Dasheets::DSL::Entry.new(&block)
14
+ end
15
+ end
@@ -0,0 +1,21 @@
1
+ class Dasheets::DSL::Cheatsheet
2
+ attr_reader :categories
3
+ def initialize(&block)
4
+ @categories = []
5
+ instance_eval(&block)
6
+ end
7
+
8
+ def category(&block)
9
+ @categories << Dasheets::DSL::Category.new(&block)
10
+ end
11
+
12
+ def title(t = nil)
13
+ @title = t if t
14
+ @title
15
+ end
16
+ def short_name(s = nil)
17
+ @short_name = s if s
18
+ @short_name
19
+ end
20
+ end
21
+
@@ -0,0 +1,13 @@
1
+ class Dasheets::DSL::Context
2
+ def initialize(filename)
3
+ instance_eval(File.read(filename))
4
+ end
5
+ def generate
6
+ Dasheets::Creator.new(@data).generate
7
+ end
8
+ private
9
+
10
+ def cheatsheet(&block)
11
+ @data = Dasheets::DSL::Cheatsheet.new(&block)
12
+ end
13
+ end
@@ -0,0 +1,17 @@
1
+ class Dasheets::DSL::Entry
2
+ def initialize(&block)
3
+ instance_eval(&block)
4
+ end
5
+ def name(name = nil)
6
+ @name = name if name
7
+ @name
8
+ end
9
+ def command(c = nil)
10
+ @command = c if c
11
+ @command
12
+ end
13
+ def notes(n = nil)
14
+ @notes = n if n
15
+ @notes
16
+ end
17
+ end
@@ -0,0 +1,74 @@
1
+ /* wkhmtmltopdf needs true-type fonts */
2
+ @font-face {
3
+ font-family: 'Open Sans';
4
+ font-style: normal;
5
+ font-weight: 400;
6
+ src: url(http://themes.googleusercontent.com/static/fonts/opensans/v6/cJZKeOuBrn4kERxqtaUH3aCWcynf_cDxXwCLxiixG1c.ttf) format('truetype');
7
+ }
8
+ @font-face {
9
+ font-family: 'Droid Sans Mono';
10
+ font-style: normal;
11
+ font-weight: 400;
12
+ src: url(http://themes.googleusercontent.com/static/fonts/droidsansmono/v4/ns-m2xQYezAtqh7ai59hJYW_AySPyikQrZReizgrnuw.ttf) format('truetype');
13
+ }
14
+
15
+ h1, h2, h3, p, blockquote {
16
+ margin: 0;
17
+ padding: 0;
18
+ }
19
+ body {
20
+ font-family: 'Open Sans', sans-serif;
21
+ font-size: 10px;
22
+ line-height: 13px;
23
+ color: black;
24
+ background-color: white;
25
+ margin: 10px 13px;
26
+ }
27
+ table {
28
+ margin: 10px 0 15px 0;
29
+ border-collapse: collapse;
30
+ font-size: 10px;
31
+ }
32
+ td, th {
33
+ border: 1px solid #ddd;
34
+ padding: 1px 10px;
35
+ }
36
+
37
+ a {
38
+ color: #0069d6;
39
+ }
40
+ p {
41
+ margin-bottom: 9px;
42
+ }
43
+ h1, h2, h3 {
44
+ color: #404040;
45
+ line-height: 36px;
46
+ }
47
+ h1 {
48
+ margin-bottom: 18px;
49
+ font-size: 30px;
50
+ }
51
+ h2 {
52
+ font-size: 24px;
53
+ }
54
+ h3 {
55
+ font-size: 18px;
56
+ }
57
+
58
+ code, pre {
59
+ font-family: 'Droid Sans Mono', monospace;
60
+ }
61
+ code {
62
+ background-color: #fee9cc;
63
+ color: black;
64
+ padding: 1px 3px;
65
+ font-size: 10px;
66
+ -webkit-border-radius: 3px;
67
+ -moz-border-radius: 3px;
68
+ border-radius: 3px;
69
+ }
70
+ table, pre {
71
+ page-break-inside: avoid;
72
+ }
73
+
74
+
@@ -0,0 +1,22 @@
1
+ !!!
2
+ %html
3
+ %head
4
+ %meta{charset: 'utf-8'}
5
+ %title= title
6
+ %link{rel: 'stylesheet', href: 'style.css'}
7
+ %body
8
+
9
+ %h1= title
10
+ - categories.each do |category|
11
+ %h2= category.id
12
+ %table
13
+ %tr
14
+ %th command
15
+ %th name
16
+ %th notes
17
+ - category.entries.each_with_index do |entry, index|
18
+ %tr{id: "#{category.id}-#{index}"}
19
+ %td
20
+ %code= entry.command
21
+ %td= entry.name
22
+ %td= entry.notes
@@ -0,0 +1,3 @@
1
+ module Dasheets
2
+ VERSION = "0.0.1"
3
+ end
data/lib/dasheets.rb ADDED
@@ -0,0 +1,10 @@
1
+ require 'dasheets/version'
2
+
3
+ module Dasheets
4
+ module DSL
5
+ end
6
+ end
7
+
8
+ %w(creator dsl/cheatsheet dsl/category dsl/context dsl/entry).each do |file|
9
+ require "dasheets/#{file}"
10
+ end
metadata ADDED
@@ -0,0 +1,148 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dasheets
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Florian Dütsch
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ! '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: thor
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
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: haml
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 4.0.3
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 4.0.3
69
+ - !ruby/object:Gem::Dependency
70
+ name: sqlite3
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 1.3.8
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 1.3.8
83
+ - !ruby/object:Gem::Dependency
84
+ name: plist
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: 3.1.0
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: 3.1.0
97
+ description: Generate cheatsheets for Dash
98
+ email:
99
+ - florian.duetsch@nix-wie-weg.de
100
+ executables:
101
+ - dasheets
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - .gitignore
106
+ - Gemfile
107
+ - LICENSE.txt
108
+ - README.md
109
+ - Rakefile
110
+ - TODO
111
+ - bin/dasheets
112
+ - dasheets.gemspec
113
+ - examples/tmux.cheatsheet
114
+ - lib/dasheets.rb
115
+ - lib/dasheets/cli.rb
116
+ - lib/dasheets/creator.rb
117
+ - lib/dasheets/dsl/category.rb
118
+ - lib/dasheets/dsl/cheatsheet.rb
119
+ - lib/dasheets/dsl/context.rb
120
+ - lib/dasheets/dsl/entry.rb
121
+ - lib/dasheets/templates/style.css
122
+ - lib/dasheets/templates/template.haml
123
+ - lib/dasheets/version.rb
124
+ homepage: https://github.com/Nix-wie-weg/dasheets
125
+ licenses:
126
+ - MIT
127
+ metadata: {}
128
+ post_install_message:
129
+ rdoc_options: []
130
+ require_paths:
131
+ - lib
132
+ required_ruby_version: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - ! '>='
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ required_rubygems_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ requirements: []
143
+ rubyforge_project:
144
+ rubygems_version: 2.0.7
145
+ signing_key:
146
+ specification_version: 4
147
+ summary: Generate cheatsheets for Dash
148
+ test_files: []