cheatset 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8f28151b3283255cb45de365e5fe780d45a40d30
4
- data.tar.gz: 56c4443a13322b2eebc99d16be10d28853b82f95
3
+ metadata.gz: ca0cc24cddcf9d78987370b974069d22aaa56dde
4
+ data.tar.gz: 0ec86bb8bad352172f30840555d225ba06206473
5
5
  SHA512:
6
- metadata.gz: 928309b54495c39e848ffed4c4509dfbeee2fba8810f2cbb48f7a4a972be9b6757a3a860ba7b201ab7ba47e878f3b266c1f9c5bb61a3eedb817e68c628686dd3
7
- data.tar.gz: 3d2a51abd1287d6f1bee3089ac7fa86e4094e322478b357191bd027737f6e62a08d668b971e5a8039a0eea751cc8ba12964fce3aee14bed64673ee98e3f0f0e8
6
+ metadata.gz: 898463cb1e2e65dd9b2e6f621a203e90a6eb97e783fcf04ee7cba96a90b24b205f321b656e8d099290a179d9d855d599a128594210395944dfa892501adbe6b0
7
+ data.tar.gz: 25f4ae59942847c6752b5f2de490d472a83375590f02422dee821bed83f8072751a015735d68d106818d12cf6940f16c90f9566344161673ff6f0c8e66f0734e
data/.gitignore CHANGED
@@ -16,4 +16,5 @@ spec/reports
16
16
  test/tmp
17
17
  test/version_tmp
18
18
  tmp
19
- .sass-cache/
19
+ .sass-cache/
20
+ lib/cheatset/templates/template.html
@@ -6,8 +6,9 @@ require 'ostruct'
6
6
  require 'uri'
7
7
 
8
8
  class Cheatset::Creator
9
- def initialize(cheatsheet)
9
+ def initialize(cheatsheet, filename)
10
10
  @cheatsheet = cheatsheet
11
+ @filename = filename
11
12
  @docset_path = "#{@cheatsheet.docset_file_name}.docset"
12
13
  @path = "#{@docset_path}/Contents/"
13
14
  end
@@ -39,7 +40,13 @@ class Cheatset::Creator
39
40
  FileUtils.cp("#{tpl_path}/style.css", doc_path)
40
41
 
41
42
  # resources
42
- FileUtils.cp_r("#{tpl_path}/res", doc_path)
43
+ FileUtils.cp_r("#{tpl_path}/cheatset_resources", doc_path)
44
+ resources = @cheatsheet.resources
45
+ if !resources.empty?
46
+ base_dir = File.dirname(@filename)
47
+ resources_path = "#{base_dir}/#{resources}"
48
+ FileUtils.cp_r(resources_path, doc_path)
49
+ end
43
50
  end
44
51
 
45
52
  def generate_plist_file
@@ -45,6 +45,23 @@ module Cheatset
45
45
  end
46
46
  end
47
47
  end
48
+ def self.define_markdown_list_attrs(*names)
49
+ names.each do |name|
50
+ define_method(name) do |val = nil|
51
+ if val
52
+ val = val.unindent
53
+ val = parse_markdown(val)
54
+ array = instance_variable_get("@#{name}")
55
+ if !array
56
+ instance_variable_set("@#{name}", [val])
57
+ else
58
+ instance_variable_set("@#{name}", array << val)
59
+ end
60
+ end
61
+ instance_variable_get("@#{name}")
62
+ end
63
+ end
64
+ end
48
65
  def self.define_markdown_attrs(*names)
49
66
  names.each do |name|
50
67
  define_method(name) do |val = nil|
@@ -3,6 +3,7 @@ module Cheatset
3
3
  class Category < Base
4
4
  attr_reader :entries
5
5
  define_attrs :id, :hasEntry
6
+ define_list_attrs :header
6
7
 
7
8
  def initialize(&block)
8
9
  @entries = []
@@ -2,7 +2,7 @@ module Cheatset
2
2
  module DSL
3
3
  class Cheatsheet < Base
4
4
  attr_reader :categories
5
- define_attrs :title, :docset_file_name, :keyword, :source_url, :platform, :style
5
+ define_attrs :title, :docset_file_name, :keyword, :source_url, :platform, :style, :resources
6
6
  define_markdown_attrs :introduction, :notes
7
7
 
8
8
  def initialize(&block)
@@ -3,9 +3,10 @@ module Cheatset
3
3
  class Context
4
4
  def initialize(filename)
5
5
  instance_eval(File.read(filename))
6
+ @filename = filename
6
7
  end
7
8
  def generate
8
- Cheatset::Creator.new(@data).generate
9
+ Cheatset::Creator.new(@data, @filename).generate
9
10
  end
10
11
  private
11
12
 
@@ -3,6 +3,7 @@ module Cheatset
3
3
  class Entry < Base
4
4
  define_list_attrs :command, :td_command
5
5
  define_markdown_attrs :name, :notes
6
+ define_markdown_list_attrs :td_notes
6
7
  end
7
8
  end
8
9
  end
@@ -6,7 +6,7 @@ h1, h2, h3, p, blockquote {
6
6
  font-family: 'Open Sans';
7
7
  font-style: normal;
8
8
  font-weight: 400;
9
- src: local("Open Sans"), local("OpenSans"), url(res/Open_Sans.woff) format("woff"); }
9
+ src: local("Open Sans"), local("OpenSans"), url(cheatset_resources/Open_Sans.woff) format("woff"); }
10
10
  body {
11
11
  font-family: 'Open Sans', sans-serif;
12
12
  font-size: 14px;
@@ -95,12 +95,23 @@ td.td_command {
95
95
  text-align: center;
96
96
  border-right: 1px solid #666666; }
97
97
 
98
+ td.td_notes {
99
+ border-left: 1px solid #666666; }
100
+
98
101
  td.description .name {
99
102
  font-size: 1.2em; }
100
103
 
101
104
  tr:nth-child(even) {
102
105
  background: #efefef; }
103
106
 
107
+ th {
108
+ padding: 5px 2px 5px 8px;
109
+ text-align: left;
110
+ border-left: 1px solid #666666; }
111
+
112
+ th:nth-child(1) {
113
+ border: none; }
114
+
104
115
  a {
105
116
  color: #666666; }
106
117
 
@@ -11,7 +11,7 @@ h1, h2, h3, p, blockquote {
11
11
  font-family: 'Open Sans';
12
12
  font-style: normal;
13
13
  font-weight: 400;
14
- src: local('Open Sans'), local('OpenSans'), url(res/Open_Sans.woff) format('woff');
14
+ src: local('Open Sans'), local('OpenSans'), url(cheatset_resources/Open_Sans.woff) format('woff');
15
15
  }
16
16
 
17
17
  body {
@@ -121,6 +121,10 @@ td.td_command {
121
121
  border-right: 1px solid $dark_gray;
122
122
  }
123
123
 
124
+ td.td_notes {
125
+ border-left: 1px solid $dark_gray;
126
+ }
127
+
124
128
  td.description {
125
129
  .name {
126
130
  font-size: 1.2em;
@@ -130,6 +134,16 @@ tr:nth-child(even) {
130
134
  background: $light_gray;
131
135
  }
132
136
 
137
+ th {
138
+ padding:5px 2px 5px 8px;
139
+ text-align: left;
140
+ border-left: 1px solid $dark_gray;
141
+ }
142
+
143
+ th:nth-child(1) {
144
+ border:none;
145
+ }
146
+
133
147
  a {
134
148
  color: $dark_gray;
135
149
  }
@@ -30,6 +30,11 @@
30
30
  %h2{id:"//dash_ref/Category/#{category.id.strip.gsub(/\//, '%2F')}/1"}
31
31
  = category.id
32
32
  %table
33
+ - if category.header
34
+ %tr
35
+ - category.header.each do |header|
36
+ %th~ header
37
+
33
38
  - category.entries.each_with_index do |entry, index|
34
39
  %tr{id: ("//dash_ref_#{category.id.strip.gsub(/\//, '%2F')}/Entry/#{entry.tags_stripped_name.strip.gsub(/\//, '%2F')}/0" if entry.name)}
35
40
  - if entry.command
@@ -42,9 +47,14 @@
42
47
  %td.td_command
43
48
  - if !command.empty?
44
49
  %code= CGI.escapeHTML(command)
45
- %td.description{:colspan => ("2" unless entry.command || entry.td_command)}
50
+ %td.description{:colspan => ("2" unless entry.command || entry.td_command || entry.td_notes)}
46
51
  .name~ entry.name
47
52
  .notes~ entry.notes
53
+ - if entry.td_notes
54
+ - entry.td_notes.each do |notes|
55
+ %td.td_notes
56
+ - if !notes.empty?
57
+ .td_notes~ notes
48
58
  - if notes
49
59
  %section.notes
50
60
  %h2 Notes
@@ -1,3 +1,3 @@
1
1
  module Cheatset
2
- VERSION = '1.2.1'
2
+ VERSION = '1.2.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cheatset
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bogdan Popescu
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-12 00:00:00.000000000 Z
11
+ date: 2014-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -173,7 +173,7 @@ files:
173
173
  - lib/cheatset/dsl/context.rb
174
174
  - lib/cheatset/dsl/entry.rb
175
175
  - lib/cheatset/templates/.sass-cache/c0630dfea9543a0a71b68aca4887e98819b89684/style.scssc
176
- - lib/cheatset/templates/res/Open_Sans.woff
176
+ - lib/cheatset/templates/cheatset_resources/Open_Sans.woff
177
177
  - lib/cheatset/templates/style.css
178
178
  - lib/cheatset/templates/style.scss
179
179
  - lib/cheatset/templates/template.haml