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 CHANGED
@@ -7,4 +7,3 @@ group :development, :test do
7
7
  end
8
8
 
9
9
  gem 'curb'
10
- gem 'subcommand'
data/bin/coldshoulder CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  require 'coldshoulder'
4
4
 
5
- Coldshoulder::Commander.new({:command => ARGV[0], :language => ARGV[1]}).generate!
5
+ Coldshoulder::Commander.new({:command => ARGV[0], :language => ARGV[1]})
@@ -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# Generating using coldshoulder - github.com/bryanmikaelian/coldshoulder\n#\n\n#{r.body_str}")
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
@@ -1,3 +1,3 @@
1
1
  module Coldshoulder
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -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"}).generate!
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: coldshoulder
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: