hpp 0.1.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.
- data/bin/hpp +5 -0
- data/lib/hpp.rb +28 -0
- metadata +67 -0
data/bin/hpp
ADDED
data/lib/hpp.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require "thor"
|
2
|
+
|
3
|
+
class Hpp < Thor
|
4
|
+
desc "process SRC TARGET", "process HTML files under SRC folder to TARGET folder"
|
5
|
+
def process(src='src', target='target')
|
6
|
+
raise RuntimeError.new("There is NO '#{src}' folder in current working directory") unless Dir.exists?(src)
|
7
|
+
Dir.mkdir(target) unless Dir.exists?(target)
|
8
|
+
|
9
|
+
Dir.glob(File.expand_path('*.html', src)) do |src_path|
|
10
|
+
next if src_path.include? '_include_'
|
11
|
+
File.open(src_path.sub(src, target), 'w') do |output_html|
|
12
|
+
File.open(src_path, 'r') do |source_html|
|
13
|
+
while line = source_html.gets
|
14
|
+
r = /<!--#include src=['"](?<file>.*)['"]-->/.match line
|
15
|
+
if r.nil?
|
16
|
+
output_html.puts line
|
17
|
+
else
|
18
|
+
include_html = File.open(File.expand_path(r[:file], src), 'r').read
|
19
|
+
output_html.puts "<!--include file '#{r[:file]}' Begin-->"
|
20
|
+
output_html.puts include_html
|
21
|
+
output_html.puts "<!--include file '#{r[:file]}' End-->"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
metadata
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hpp
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ming Jin
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-09-21 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: thor
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 0.16.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.16.0
|
30
|
+
description:
|
31
|
+
email:
|
32
|
+
- skyairmj@gmail.com
|
33
|
+
executables:
|
34
|
+
- hpp
|
35
|
+
extensions: []
|
36
|
+
extra_rdoc_files: []
|
37
|
+
files:
|
38
|
+
- lib/hpp.rb
|
39
|
+
- bin/hpp
|
40
|
+
homepage: https://github.com/mingjin/hpp
|
41
|
+
licenses: []
|
42
|
+
post_install_message:
|
43
|
+
rdoc_options: []
|
44
|
+
require_paths:
|
45
|
+
- lib
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
none: false
|
48
|
+
requirements:
|
49
|
+
- - ! '>='
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
segments:
|
53
|
+
- 0
|
54
|
+
hash: -163396053615665011
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ! '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
requirements: []
|
62
|
+
rubyforge_project:
|
63
|
+
rubygems_version: 1.8.24
|
64
|
+
signing_key:
|
65
|
+
specification_version: 3
|
66
|
+
summary: A Command Line tool for HTML Pre-Processing
|
67
|
+
test_files: []
|