coldshoulder 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +0 -1
- data/bin/coldshoulder +1 -1
- data/lib/coldshoulder/commander.rb +31 -1
- data/lib/coldshoulder/generator.rb +1 -1
- data/lib/coldshoulder/version.rb +1 -1
- data/spec/commander_spec.rb +8 -2
- metadata +1 -1
data/Gemfile
CHANGED
data/bin/coldshoulder
CHANGED
@@ -5,10 +5,40 @@ module Coldshoulder
|
|
5
5
|
attr_accessor :command, :language
|
6
6
|
|
7
7
|
def initialize(arg_hash)
|
8
|
-
self.command = arg_hash[:command]
|
9
8
|
self.language = arg_hash[:language]
|
9
|
+
self.command = arg_hash[:command]
|
10
|
+
if self.command == "generate"
|
11
|
+
generate!
|
12
|
+
else
|
13
|
+
parse!([self.command])
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def parse!(commands)
|
18
|
+
options = {}
|
19
|
+
begin
|
20
|
+
opts = OptionParser.new do |opts|
|
21
|
+
opts.banner = "Usage: coldshoulder [options] [template name]"
|
22
|
+
opts.separator ""
|
23
|
+
opts.separator "Commands: "
|
24
|
+
|
25
|
+
opts.on_tail("-v", "--version", "Display the version") do
|
26
|
+
puts "Current version: #{Coldshoulder::VERSION}"
|
27
|
+
end
|
28
|
+
|
29
|
+
opts.on_tail("-h", "--help", "Displays this message") do
|
30
|
+
puts opts
|
31
|
+
end
|
32
|
+
end
|
33
|
+
opts.parse!(commands)
|
34
|
+
rescue OptionParser::ParseError => e
|
35
|
+
puts "Error: #{e.message}"
|
36
|
+
end
|
10
37
|
end
|
11
38
|
|
39
|
+
|
40
|
+
protected
|
41
|
+
|
12
42
|
def generate!
|
13
43
|
Coldshoulder::Generator.new.build(self.language)
|
14
44
|
end
|
@@ -12,7 +12,7 @@ module Coldshoulder
|
|
12
12
|
r = request_url("https://raw.github.com/github/gitignore/master/#{language}.gitignore")
|
13
13
|
if r.response_code == 200
|
14
14
|
File.open('.gitignore', 'w') do |f|
|
15
|
-
f.write("#\n#
|
15
|
+
f.write("#\n# Generated using coldshoulder - github.com/bryanmikaelian/coldshoulder\n#\n\n#{r.body_str}")
|
16
16
|
end
|
17
17
|
puts "Ignore file generated for language #{language}"
|
18
18
|
else
|
data/lib/coldshoulder/version.rb
CHANGED
data/spec/commander_spec.rb
CHANGED
@@ -14,7 +14,13 @@ describe Coldshoulder::Commander do
|
|
14
14
|
file = mock('file')
|
15
15
|
File.should_receive(:open).with(".gitignore", "w").and_yield(file)
|
16
16
|
file.should_receive(:write)
|
17
|
-
Coldshoulder::Commander.new({:command => "generate", :language => "Ruby"})
|
17
|
+
Coldshoulder::Commander.new({:command => "generate", :language => "Ruby"})
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
|
+
it 'it will not generate a gitingore file if generate is not specified' do
|
21
|
+
Coldshoulder::Commander.should_not_receive(:generate!)
|
22
|
+
Coldshoulder::Commander.new({:command => "generate", :language => "Ruby"})
|
23
|
+
end
|
24
|
+
|
25
|
+
|
20
26
|
end
|