chopin 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/chopin +4 -70
- data/lib/chopin/pygments_renderer.rb +8 -0
- data/lib/chopin.rb +94 -0
- metadata +19 -4
- data/lib/pygments_renderer.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c1269a1d0dc69cedad15746b003d7333355f194
|
4
|
+
data.tar.gz: 698038bd392e864aeff404d6f15f10d1500aabb1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 40dd5b4057f7afafa0a2745fd8f013c712bc0aedd4a8b185ee06b9259809674b233a40a1859bffc3067594b051f87ef2c7155052b54e23fe8948a88ae3dfd63b
|
7
|
+
data.tar.gz: 81190674aed6a263fa0f79808bf71581dacb57df677b6fa2057906714b6138d64ee04aa4520fb8c59342ee4408953a626ef4dd16c03641c3178ae9a89a412b50
|
data/bin/chopin
CHANGED
@@ -1,73 +1,7 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
lib_path = File.expand_path('../../lib', __FILE__)
|
3
|
+
$:.unshift(lib_path)
|
2
4
|
|
3
|
-
require
|
4
|
-
require "fileutils"
|
5
|
-
require "pygments"
|
6
|
-
require "redcarpet"
|
7
|
-
require "./lib/pygments_renderer.rb"
|
5
|
+
require 'chopin'
|
8
6
|
|
9
|
-
|
10
|
-
GREEN = "\033[0;32m"
|
11
|
-
PURPLE = "\033[0;35m"
|
12
|
-
RED = "\033[0;31m"
|
13
|
-
WHITE = "\033[0m"
|
14
|
-
|
15
|
-
MARKDOWN = Redcarpet::Markdown.new(PygmentsRenderer,
|
16
|
-
disable_indented_code_blocks: true,
|
17
|
-
fenced_code_blocks: true,
|
18
|
-
footnotes: true,
|
19
|
-
no_intra_emphasis: true,
|
20
|
-
prettify: true,
|
21
|
-
quote: true,
|
22
|
-
tables: true
|
23
|
-
)
|
24
|
-
|
25
|
-
def copy(source, destination, layout = nil)
|
26
|
-
if File.directory?(source)
|
27
|
-
unless Dir.exists?(destination)
|
28
|
-
Dir.mkdir(destination)
|
29
|
-
puts " #{GREEN}Create#{WHITE} #{destination}"
|
30
|
-
end
|
31
|
-
|
32
|
-
source_directory = Dir.new(source)
|
33
|
-
destination_directory = Dir.new(destination)
|
34
|
-
|
35
|
-
layout = "#{source}/layout.erb" if File.exist?("#{source}/layout.erb")
|
36
|
-
|
37
|
-
source_directory.each do |file|
|
38
|
-
next if file == "." || file == ".."
|
39
|
-
|
40
|
-
if file[0] == "."
|
41
|
-
puts " #{RED}Ignore#{WHITE} #{source}/#{file}"
|
42
|
-
next
|
43
|
-
end
|
44
|
-
|
45
|
-
copy("#{source}/#{file}", "#{destination}/#{file}", layout)
|
46
|
-
end
|
47
|
-
else
|
48
|
-
case File.extname(source)
|
49
|
-
when ".erb"
|
50
|
-
unless File.basename(source) == "layout.erb"
|
51
|
-
destination_html = destination.sub(".erb", ".html")
|
52
|
-
puts " #{PURPLE}Parse#{WHITE} #{source} (into #{layout}) -> #{destination_html}"
|
53
|
-
render = Proc.new { ERB.new(File.read(source)).result }
|
54
|
-
output = ERB.new(File.read(layout)).result(nil, &render)
|
55
|
-
File.new(destination_html, "w").write(output)
|
56
|
-
end
|
57
|
-
|
58
|
-
when ".md"
|
59
|
-
destination_html = destination.sub(".md", ".html")
|
60
|
-
puts " #{PURPLE}Parse#{WHITE} #{source} (into #{layout}) -> #{destination_html}"
|
61
|
-
#render = Proc.new { GitHub::Markup.render(source) }
|
62
|
-
render = Proc.new { MARKDOWN.render(File.new(source).read) }
|
63
|
-
output = ERB.new(File.read(layout)).result(nil, &render)
|
64
|
-
File.new(destination_html, "w").write(output)
|
65
|
-
|
66
|
-
else
|
67
|
-
puts " #{BLUE}Copy#{WHITE} #{source} -> #{destination}"
|
68
|
-
FileUtils.cp(source, destination)
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
copy(ARGV[0], ARGV[1])
|
7
|
+
Chopin.copy(ARGV[0], ARGV[1])
|
data/lib/chopin.rb
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
require 'chopin/pygments_renderer'
|
2
|
+
require 'erb'
|
3
|
+
require 'fileutils'
|
4
|
+
require 'redcarpet'
|
5
|
+
require 'sass'
|
6
|
+
|
7
|
+
module Chopin
|
8
|
+
def self.convert_sass(source, type)
|
9
|
+
Sass::Engine.new(File.new(source).read,
|
10
|
+
load_paths: [File.dirname(source)],
|
11
|
+
syntax: type
|
12
|
+
).render
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.copy(source, destination, layout = nil)
|
16
|
+
if File.directory?(source)
|
17
|
+
unless Dir.exists?(destination)
|
18
|
+
Dir.mkdir(destination)
|
19
|
+
puts " #{GREEN}Create#{WHITE} #{destination}"
|
20
|
+
end
|
21
|
+
|
22
|
+
source_directory = Dir.new(source)
|
23
|
+
destination_directory = Dir.new(destination)
|
24
|
+
|
25
|
+
layout = "#{source}/layout.erb" if File.exist?("#{source}/layout.erb")
|
26
|
+
|
27
|
+
source_directory.each do |file|
|
28
|
+
next if file == '.' || file == '..'
|
29
|
+
|
30
|
+
if file[0] == '.'
|
31
|
+
puts " #{RED}Ignore#{WHITE} #{source}/#{file}"
|
32
|
+
next
|
33
|
+
end
|
34
|
+
|
35
|
+
copy("#{source}/#{file}", "#{destination}/#{file}", layout)
|
36
|
+
end
|
37
|
+
else
|
38
|
+
case File.extname(source)
|
39
|
+
when '.erb'
|
40
|
+
unless File.basename(source) == 'layout.erb'
|
41
|
+
destination_html = destination.sub('.erb', '.html')
|
42
|
+
puts " #{PURPLE}Parse#{WHITE} #{source} (into #{layout}) -> #{destination_html}"
|
43
|
+
render = Proc.new { ERB.new(File.read(source)).result }
|
44
|
+
output = ERB.new(File.read(layout)).result(nil, &render)
|
45
|
+
File.new(destination_html, 'w').write(output)
|
46
|
+
end
|
47
|
+
|
48
|
+
when '.md'
|
49
|
+
destination_html = destination.sub('.md', '.html')
|
50
|
+
puts " #{PURPLE}Parse#{WHITE} #{source} (into #{layout}) -> #{destination_html}"
|
51
|
+
render = Proc.new { MARKDOWN.render(File.new(source).read) }
|
52
|
+
output = ERB.new(File.read(layout)).result(nil, &render)
|
53
|
+
File.new(destination_html, 'w').write(output)
|
54
|
+
|
55
|
+
when '.sass'
|
56
|
+
unless File.basename(source)[0] == '_'
|
57
|
+
destination_css = destination.sub('.sass', '.css')
|
58
|
+
puts " #{CYAN}Convert#{WHITE} #{source} -> #{destination_css}"
|
59
|
+
File.new(destination_css, 'w').write(convert_sass(source, :sass))
|
60
|
+
end
|
61
|
+
|
62
|
+
when '.scss'
|
63
|
+
unless File.basename(source)[0] == '_'
|
64
|
+
destination_css = destination.sub('.scss', '.css')
|
65
|
+
puts " #{CYAN}Convert#{WHITE} #{source} -> #{destination_css}"
|
66
|
+
File.new(destination_css, 'w').write(convert_sass(source, :scss))
|
67
|
+
end
|
68
|
+
|
69
|
+
else
|
70
|
+
puts " #{BLUE}Copy#{WHITE} #{source} -> #{destination}"
|
71
|
+
FileUtils.cp(source, destination)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
private
|
77
|
+
|
78
|
+
BLUE = "\033[0;34m"
|
79
|
+
GREEN = "\033[0;32m"
|
80
|
+
PURPLE = "\033[0;35m"
|
81
|
+
RED = "\033[0;31m"
|
82
|
+
CYAN = "\033[0;36m"
|
83
|
+
WHITE = "\033[0m"
|
84
|
+
|
85
|
+
MARKDOWN = Redcarpet::Markdown.new(PygmentsRenderer,
|
86
|
+
disable_indented_code_blocks: true,
|
87
|
+
fenced_code_blocks: true,
|
88
|
+
footnotes: true,
|
89
|
+
no_intra_emphasis: true,
|
90
|
+
prettify: true,
|
91
|
+
quote: true,
|
92
|
+
tables: true
|
93
|
+
)
|
94
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chopin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Josh Forisha
|
@@ -30,14 +30,28 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 3.3.
|
33
|
+
version: 3.3.4
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 3.3.
|
40
|
+
version: 3.3.4
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: sass
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.4.21
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.4.21
|
41
55
|
description: An elegant, simple static site generator
|
42
56
|
email: josh@forisha.com
|
43
57
|
executables:
|
@@ -45,7 +59,8 @@ executables:
|
|
45
59
|
extensions: []
|
46
60
|
extra_rdoc_files: []
|
47
61
|
files:
|
48
|
-
- lib/
|
62
|
+
- lib/chopin.rb
|
63
|
+
- lib/chopin/pygments_renderer.rb
|
49
64
|
- bin/chopin
|
50
65
|
homepage: https://github.com/joshforisha/chopin
|
51
66
|
licenses:
|