haml2slim 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/haml2slim/command.rb +18 -23
- data/lib/haml2slim/version.rb +1 -1
- metadata +3 -3
data/lib/haml2slim/command.rb
CHANGED
@@ -24,13 +24,7 @@ module Haml2Slim
|
|
24
24
|
protected
|
25
25
|
|
26
26
|
def set_opts(opts)
|
27
|
-
opts.
|
28
|
-
@options[:input] = $stdin
|
29
|
-
end
|
30
|
-
|
31
|
-
opts.on('-o', '--output FILENAME', :NONE, 'Output file destination') do |filename|
|
32
|
-
@options[:output] = filename
|
33
|
-
end
|
27
|
+
opts.banner = "Usage: haml2slim INPUT_FILENAME_OR_DIRECTORY [OUTPUT_FILENAME_OR_DIRECTORY] [options]"
|
34
28
|
|
35
29
|
opts.on('--trace', :NONE, 'Show a full traceback on error') do
|
36
30
|
@options[:trace] = true
|
@@ -48,30 +42,31 @@ module Haml2Slim
|
|
48
42
|
end
|
49
43
|
|
50
44
|
def process!
|
51
|
-
|
45
|
+
args = @args.dup
|
52
46
|
|
53
|
-
|
54
|
-
|
55
|
-
if file
|
56
|
-
@options[:file] = file
|
57
|
-
@options[:input] = file
|
58
|
-
else
|
59
|
-
@options[:file] = 'STDIN'
|
60
|
-
@options[:input] = $stdin
|
61
|
-
end
|
62
|
-
end
|
47
|
+
@options[:input] = file = args.shift
|
48
|
+
@options[:output] = destination = args.shift
|
63
49
|
|
64
|
-
if File.directory?(@options[:
|
65
|
-
Dir
|
50
|
+
if File.directory?(@options[:input])
|
51
|
+
Dir["#{@options[:input]}/**/*.haml"].each { |file| _process(file, destination) }
|
66
52
|
else
|
67
|
-
_process(file)
|
53
|
+
_process(file, destination)
|
68
54
|
end
|
69
55
|
end
|
70
56
|
|
71
57
|
private
|
72
58
|
|
73
|
-
def _process(file)
|
74
|
-
|
59
|
+
def _process(file, destination = nil)
|
60
|
+
require 'fileutils'
|
61
|
+
slim_file = file.sub(/\.haml$/, '.slim')
|
62
|
+
|
63
|
+
if File.directory?(@options[:input]) && destination
|
64
|
+
FileUtils.mkdir_p(File.dirname(slim_file).sub(@options[:input].chomp('/'), destination))
|
65
|
+
slim_file.sub!(@options[:input].chomp('/'), destination)
|
66
|
+
else
|
67
|
+
slim_file = destination || slim_file
|
68
|
+
end
|
69
|
+
|
75
70
|
@options[:output] = file ? File.open(slim_file, 'w') : $stdout
|
76
71
|
@options[:output].puts Haml2Slim.convert!(File.open(file, 'r'))
|
77
72
|
@options[:output].close
|
data/lib/haml2slim/version.rb
CHANGED
metadata
CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
7
|
+
- 4
|
8
8
|
- 0
|
9
|
-
version: 0.
|
9
|
+
version: 0.4.0
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Fred Wu
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-12-
|
17
|
+
date: 2010-12-23 00:00:00 +11:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|