snaptoken 0.19.0 → 0.20.0

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/snaptoken/commands/doc.rb +23 -17
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 545140027c981fe0ffe37f26e2624c217d2f24b1
4
- data.tar.gz: 1cd114bc8a2d9da435a0d5e0bdcd4d1fec731ad1
3
+ metadata.gz: 1fe965284492ad49b9d3bebd2b91e34c2c8500ab
4
+ data.tar.gz: d437d4a1291efa2e02012fec122f0a7c4bb3a923
5
5
  SHA512:
6
- metadata.gz: 565f94f26a32f86b785943a7df713e3f9a3cfa20cb0d110f4d5c71ea5fbb3ad5b1d86c201235e7448b0ad5aa028b56626bf846a7e0e968c05177d1cdc596e6dc
7
- data.tar.gz: a901bc63c54d19227134d9ce2e267ce88207f89e23c0df5201237fa9f9ddf035a0c0baf47ae4a5deabb65f4f80d62ebbb4a698c2401bb4cb41c15c9b7560dd09
6
+ metadata.gz: 0b8628f7ec5d77ec35c810cb27b0361da74bf4d007ba38f9e6ea0011bb562492c82e5c993965f07ea55d131fb5ee0ab9294cec866e37200185031bf7250f507b
7
+ data.tar.gz: df1904475d297fb6ee708a2a173a30e0738a497f17b3c9c6ee30fdc94f08ef2a153472826b0f1f78b75f0027d2e9984d4c1c694d65809c87bb4e023e67b2fe7e
@@ -12,11 +12,14 @@ class Snaptoken::Commands::Doc < Snaptoken::Commands::BaseCommand
12
12
 
13
13
  FileUtils.cd(File.join(@config[:path], "doc")) do
14
14
  FileUtils.rm_rf("html_out")
15
+ FileUtils.rm_rf("html_offline")
15
16
  FileUtils.mkdir("html_out")
17
+ FileUtils.mkdir("html_offline")
16
18
 
17
19
  copy_static_files
18
20
  write_css
19
21
  write_html_files(prerender_diffs)
22
+ create_archive if @args.include? "-z"
20
23
  end
21
24
  end
22
25
 
@@ -25,8 +28,9 @@ class Snaptoken::Commands::Doc < Snaptoken::Commands::BaseCommand
25
28
  def copy_static_files
26
29
  Dir["html_in/*"].each do |f|
27
30
  name = File.basename(f)
28
- unless %w(template.html template_index.html style.css).include? name
29
- FileUtils.cp_r(f, "html_out/#{name}")
31
+ unless %w(template.html template_index.html style.css fonts.css).include? name
32
+ FileUtils.cp_r(f, "html_out/#{name}") unless name == "fonts"
33
+ FileUtils.cp_r(f, "html_offline/#{name}")
30
34
  end
31
35
  end
32
36
  end
@@ -49,7 +53,10 @@ class Snaptoken::Commands::Doc < Snaptoken::Commands::BaseCommand
49
53
  css = File.read("html_in/style.css")
50
54
  css << theme_css
51
55
 
56
+ offline_css = css.sub(/^@import .+$/, File.read("html_in/fonts.css"))
57
+
52
58
  File.write("html_out/style.css", css)
59
+ File.write("html_offline/style.css", offline_css)
53
60
  end
54
61
 
55
62
  def prerender_diffs
@@ -80,17 +87,6 @@ class Snaptoken::Commands::Doc < Snaptoken::Commands::BaseCommand
80
87
  def write_html_files(diffs)
81
88
  html_template = File.read("html_in/template.html")
82
89
 
83
- commit_hash = nil
84
- FileUtils.cd(@config[:path]) do
85
- commit_hash = `git rev-parse --short HEAD`.chomp
86
- end
87
-
88
- if @config[:version]
89
- version = "#{@config[:version]}-#{commit_hash}"
90
- else
91
- version = commit_hash
92
- end
93
-
94
90
  index = ""
95
91
  markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML.new(with_toc_data: true))
96
92
  pages = Dir["*.md"].sort.map { |f| f.sub(/\.md$/, '') }
@@ -122,11 +118,11 @@ class Snaptoken::Commands::Doc < Snaptoken::Commands::BaseCommand
122
118
  html.gsub!("{{title}}") { "#{idx+1}. #{title} | #{@config[:title]}" }
123
119
  html.gsub!("{{prev_link}}") { prev_link }
124
120
  html.gsub!("{{next_link}}") { next_link }
125
- html.gsub!("{{version}}") { version }
126
- html.gsub!("{{commit}}") { commit_hash }
121
+ html.gsub!("{{version}}") { @config[:version] }
127
122
  html.gsub!("{{content}}") { content }
128
123
 
129
124
  File.write(File.join("html_out", "#{page}.html"), html)
125
+ File.write(File.join("html_offline", "#{page}.html"), html)
130
126
  end
131
127
 
132
128
  content = markdown.render(File.read("00.index.md"))
@@ -142,11 +138,21 @@ class Snaptoken::Commands::Doc < Snaptoken::Commands::BaseCommand
142
138
  html.gsub!("{{title}}") { "Table of contents | #{@config[:title]}" }
143
139
  html.gsub!("{{prev_link}}") { "<a href='#'></a>" }
144
140
  html.gsub!("{{next_link}}") { "<a href='#{pages.first}.html'>next &rarr;</a>" }
145
- html.gsub!("{{version}}") { version }
146
- html.gsub!("{{commit}}") { commit_hash }
141
+ html.gsub!("{{version}}") { @config[:version] }
147
142
  html.gsub!("{{content}}") { content }
148
143
 
149
144
  File.write("html_out/index.html", html)
145
+ File.write("html_offline/index.html", html)
146
+ end
147
+
148
+ def create_archive
149
+ name = "kilo-tutorial-#{@config[:version]}"
150
+
151
+ FileUtils.mv("html_offline", name)
152
+
153
+ `zip -r #{name}.zip #{name}`
154
+
155
+ FileUtils.mv(name, "html_offline")
150
156
  end
151
157
  end
152
158
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: snaptoken
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.19.0
4
+ version: 0.20.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Ruten
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-05 00:00:00.000000000 Z
11
+ date: 2017-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rugged