konjac 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
data/lib/konjac/cli.rb CHANGED
@@ -23,7 +23,7 @@ module Konjac
23
23
 
24
24
  #{Color.bold I18n.t :usage}
25
25
  konjac %s [#{Color.underscore I18n.t :options}] %s
26
- #{I18n.t(:where_options) % Color.underscore(I18n.t(:options))}
26
+ #{I18n.t(:where_options) % Color.underscore(I18n.t(:options))}%s
27
27
  eos
28
28
 
29
29
  # Starts the command line, parsing arguments passed via <tt>ARGV</tt> and
data/lib/konjac/utils.rb CHANGED
@@ -28,12 +28,18 @@ module Konjac
28
28
  end
29
29
 
30
30
  # Parses a list of files
31
- def parse_files(files, ext = nil)
31
+ def parse_files(files, opts = {})
32
+ opts = { :extension => nil, :directory => nil }.merge opts
32
33
  files = [files] unless files.is_a?(Array)
33
34
  parsed_files = []
34
35
  while !files.empty?
35
36
  file = files.shift
36
- file = file.sub(/\.[^\\\/]*$/, "") + ext unless ext.nil?
37
+ unless opts[:directory].nil?
38
+ file = opts[:directory] + "/" + file
39
+ end
40
+ unless opts[:extension].nil?
41
+ file = file.sub(/\.[^\\\/]*$/, "") + opts[:extension].to_s.tr(".", "")
42
+ end
37
43
  parsed_files += Dir.glob(File.expand_path(file))
38
44
  end
39
45
  parsed_files.uniq
@@ -1,4 +1,4 @@
1
1
  module Konjac
2
2
  # The current version number of Konjac
3
- VERSION = "0.2.1"
3
+ VERSION = "0.2.2"
4
4
  end
data/spec/utils_spec.rb CHANGED
@@ -21,12 +21,12 @@ describe Utils do
21
21
  end
22
22
 
23
23
  it "should work when the user does not specify an extension" do
24
- files_found = Utils.parse_files("#{Dir.tmpdir}/*", ".konjac")
24
+ files_found = Utils.parse_files("#{Dir.tmpdir}/*", :extension => ".konjac")
25
25
  files_found.should include @konjac.path
26
26
  files_found.should include @kon2.path
27
27
  files_found.should_not include @docx.path
28
28
  files_found.should_not include @doc2.path
29
- files_found = Utils.parse_files("#{Dir.tmpdir}/*", ".docx")
29
+ files_found = Utils.parse_files("#{Dir.tmpdir}/*", :extension => ".docx")
30
30
  files_found.should include @docx.path
31
31
  files_found.should include @doc2.path
32
32
  files_found.should_not include @konjac.path
@@ -34,12 +34,12 @@ describe Utils do
34
34
  end
35
35
 
36
36
  it "should work when the user does specify an extension" do
37
- files_found = Utils.parse_files("#{Dir.tmpdir}/*.docx", ".konjac")
37
+ files_found = Utils.parse_files("#{Dir.tmpdir}/*.docx", :extension => ".konjac")
38
38
  files_found.should include @konjac.path
39
39
  files_found.should include @kon2.path
40
40
  files_found.should_not include @docx.path
41
41
  files_found.should_not include @doc2.path
42
- files_found = Utils.parse_files("#{Dir.tmpdir}/*.docx", ".docx")
42
+ files_found = Utils.parse_files("#{Dir.tmpdir}/*.docx", :extension => ".docx")
43
43
  files_found.should include @docx.path
44
44
  files_found.should include @doc2.path
45
45
  files_found.should_not include @konjac.path
@@ -47,12 +47,12 @@ describe Utils do
47
47
  end
48
48
 
49
49
  it "should work when the user supplies wildcards" do
50
- files_found = Utils.parse_files("#{Dir.tmpdir}/*.*", ".konjac")
50
+ files_found = Utils.parse_files("#{Dir.tmpdir}/*.*", :extension => ".konjac")
51
51
  files_found.should include @konjac.path
52
52
  files_found.should include @kon2.path
53
53
  files_found.should_not include @docx.path
54
54
  files_found.should_not include @doc2.path
55
- files_found = Utils.parse_files("#{Dir.tmpdir}/*.*", ".docx")
55
+ files_found = Utils.parse_files("#{Dir.tmpdir}/*.*", :extension => ".docx")
56
56
  files_found.should include @docx.path
57
57
  files_found.should include @doc2.path
58
58
  files_found.should_not include @konjac.path
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: konjac
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-17 00:00:00.000000000 Z
12
+ date: 2012-01-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: amatch
16
- requirement: &70178194102620 !ruby/object:Gem::Requirement
16
+ requirement: &70292727602840 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70178194102620
24
+ version_requirements: *70292727602840
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: i18n
27
- requirement: &70178194101940 !ruby/object:Gem::Requirement
27
+ requirement: &70292727602280 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70178194101940
35
+ version_requirements: *70292727602280
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: nokogiri
38
- requirement: &70178194122460 !ruby/object:Gem::Requirement
38
+ requirement: &70292727601660 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70178194122460
46
+ version_requirements: *70292727601660
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: sdoc
49
- requirement: &70178194122000 !ruby/object:Gem::Requirement
49
+ requirement: &70292727601020 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70178194122000
57
+ version_requirements: *70292727601020
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: term-ansicolor
60
- requirement: &70178194121580 !ruby/object:Gem::Requirement
60
+ requirement: &70292727600580 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70178194121580
68
+ version_requirements: *70292727600580
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: trollop
71
- requirement: &70178194121160 !ruby/object:Gem::Requirement
71
+ requirement: &70292727600160 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *70178194121160
79
+ version_requirements: *70292727600160
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: autotest
82
- requirement: &70178194120740 !ruby/object:Gem::Requirement
82
+ requirement: &70292727599560 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70178194120740
90
+ version_requirements: *70292727599560
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: autotest-fsevent
93
- requirement: &70178194120280 !ruby/object:Gem::Requirement
93
+ requirement: &70292727598960 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70178194120280
101
+ version_requirements: *70292727598960
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: autotest-growl
104
- requirement: &70178194119800 !ruby/object:Gem::Requirement
104
+ requirement: &70292727598300 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *70178194119800
112
+ version_requirements: *70292727598300
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: bundler
115
- requirement: &70178194119300 !ruby/object:Gem::Requirement
115
+ requirement: &70292727597880 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: '0'
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *70178194119300
123
+ version_requirements: *70292727597880
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: rspec
126
- requirement: &70178194118740 !ruby/object:Gem::Requirement
126
+ requirement: &70292727597460 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ! '>='
@@ -131,7 +131,7 @@ dependencies:
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
- version_requirements: *70178194118740
134
+ version_requirements: *70292727597460
135
135
  description: A Ruby command-line utility for translating files using a YAML wordlist
136
136
  email:
137
137
  - bryan.mckelvey@gmail.com