coldshoulder 0.0.5 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -15
- data/bin/coldshoulder +1 -1
- data/lib/coldshoulder/commander.rb +26 -0
- data/lib/coldshoulder/generator.rb +5 -16
- data/lib/coldshoulder/version.rb +1 -1
- data/lib/coldshoulder.rb +1 -1
- data/spec/commander_spec.rb +20 -0
- data/spec/generator_spec.rb +2 -7
- metadata +5 -2
data/README.md
CHANGED
@@ -4,28 +4,16 @@ Generate those gitignore files with ease.
|
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
-
Add this line to your application's Gemfile:
|
8
|
-
|
9
|
-
gem 'coldshoulder'
|
10
|
-
|
11
|
-
And then execute:
|
12
|
-
|
13
|
-
$ bundle
|
14
|
-
|
15
|
-
Or install it yourself as:
|
16
|
-
|
17
7
|
$ gem install coldshoulder
|
18
8
|
|
19
9
|
## Usage
|
20
10
|
|
21
|
-
coldshoulder [Language name]
|
11
|
+
coldshoulder generate [Language name]
|
22
12
|
|
23
13
|
Note: You have to specify the exact name of the file in the following repo https://github.com/github/gitignore . This will be fixed in a future release.
|
24
14
|
|
25
15
|
## Contributing
|
26
16
|
|
27
17
|
1. Fork it
|
28
|
-
2. Create
|
29
|
-
3.
|
30
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
-
5. Create new Pull Request
|
18
|
+
2. Create a branch
|
19
|
+
3. Submit a pull requests. Make sure you write tests.
|
data/bin/coldshoulder
CHANGED
@@ -0,0 +1,26 @@
|
|
1
|
+
module Coldshoulder
|
2
|
+
|
3
|
+
class Commander
|
4
|
+
|
5
|
+
attr_accessor :command, :language
|
6
|
+
|
7
|
+
def initialize(*args)
|
8
|
+
self.command = args.shift
|
9
|
+
self.language = args.shift
|
10
|
+
generate!
|
11
|
+
end
|
12
|
+
|
13
|
+
def generate!
|
14
|
+
process
|
15
|
+
end
|
16
|
+
|
17
|
+
protected
|
18
|
+
|
19
|
+
def process
|
20
|
+
if self.command == "generate"
|
21
|
+
Coldshoulder::Generator.new.build(self.language)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -2,32 +2,21 @@ module Coldshoulder
|
|
2
2
|
|
3
3
|
class Generator
|
4
4
|
|
5
|
-
attr_reader :target_language
|
6
|
-
|
7
|
-
def initialize(*args)
|
8
|
-
@target_language = args.shift
|
9
|
-
end
|
10
|
-
|
11
5
|
def request_url(url)
|
12
6
|
Curl::Easy.perform(url)
|
13
7
|
end
|
14
8
|
|
15
|
-
def generate
|
16
|
-
build_ignore_file
|
17
|
-
end
|
18
|
-
|
19
|
-
protected
|
20
9
|
|
21
|
-
def
|
10
|
+
def build(language)
|
22
11
|
puts 'Generating gitignore file...'
|
23
|
-
r = request_url("https://raw.github.com/github/gitignore/master/#{
|
24
|
-
if r.response_code == 200
|
12
|
+
r = request_url("https://raw.github.com/github/gitignore/master/#{language}.gitignore")
|
13
|
+
if r.response_code == 200
|
25
14
|
File.open('.gitignore', 'w') do |f|
|
26
15
|
f.write("#\n# Generating using coldshoulder - github.com/bryanmikaelian/coldshoulder\n#\n\n#{r.body_str}")
|
27
16
|
end
|
28
|
-
puts "Ignore file generated for language #{
|
17
|
+
puts "Ignore file generated for language #{language}"
|
29
18
|
else
|
30
|
-
puts "The gitignore file could not be generated. Ignore file for the language #{
|
19
|
+
puts "The gitignore file could not be generated. Ignore file for the language #{language} not found"
|
31
20
|
end
|
32
21
|
end
|
33
22
|
|
data/lib/coldshoulder/version.rb
CHANGED
data/lib/coldshoulder.rb
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Coldshoulder::Commander do
|
4
|
+
|
5
|
+
it 'takes in a command' do
|
6
|
+
Coldshoulder::Commander.new("generate", "Python").command.should == "generate"
|
7
|
+
end
|
8
|
+
|
9
|
+
it 'takes in a language' do
|
10
|
+
Coldshoulder::Commander.new("generate", "Ruby").language.should == "Ruby"
|
11
|
+
end
|
12
|
+
|
13
|
+
it 'drives the generation of a gitignore file' do
|
14
|
+
file = mock('file')
|
15
|
+
File.should_receive(:open).with(".gitignore", "w").and_yield(file)
|
16
|
+
file.should_receive(:write)
|
17
|
+
Coldshoulder::Commander.new("generate",'Ruby')
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
data/spec/generator_spec.rb
CHANGED
@@ -6,22 +6,17 @@ describe Coldshoulder::Generator do
|
|
6
6
|
Coldshoulder::Generator.new.request_url('http://www.google.com').response_code.should == 200
|
7
7
|
end
|
8
8
|
|
9
|
-
it 'sets the target language' do
|
10
|
-
c = Coldshoulder::Generator.new('Ruby')
|
11
|
-
c.target_language.should == 'Ruby'
|
12
|
-
end
|
13
|
-
|
14
9
|
it 'generates a gitignore file' do
|
15
10
|
file = mock('file')
|
16
11
|
File.should_receive(:open).with(".gitignore", "w").and_yield(file)
|
17
12
|
file.should_receive(:write)
|
18
|
-
Coldshoulder::Generator.new('Ruby')
|
13
|
+
Coldshoulder::Generator.new.build('Ruby')
|
19
14
|
end
|
20
15
|
|
21
16
|
it 'does not generate a gitignore file when a bad language is provided' do
|
22
17
|
file = mock('file')
|
23
18
|
File.should_not_receive(:open)
|
24
|
-
Coldshoulder::Generator.new('
|
19
|
+
Coldshoulder::Generator.new.build('RubySharp')
|
25
20
|
end
|
26
21
|
|
27
22
|
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: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-13 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Ignore those files.
|
15
15
|
email:
|
@@ -27,8 +27,10 @@ files:
|
|
27
27
|
- bin/coldshoulder
|
28
28
|
- coldshoulder.gemspec
|
29
29
|
- lib/coldshoulder.rb
|
30
|
+
- lib/coldshoulder/commander.rb
|
30
31
|
- lib/coldshoulder/generator.rb
|
31
32
|
- lib/coldshoulder/version.rb
|
33
|
+
- spec/commander_spec.rb
|
32
34
|
- spec/generator_spec.rb
|
33
35
|
- spec/spec_helper.rb
|
34
36
|
homepage: ''
|
@@ -57,5 +59,6 @@ specification_version: 3
|
|
57
59
|
summary: Written in Ruby, coldshoulder is a command line tool that will let you easily
|
58
60
|
generate a gitignore file.
|
59
61
|
test_files:
|
62
|
+
- spec/commander_spec.rb
|
60
63
|
- spec/generator_spec.rb
|
61
64
|
- spec/spec_helper.rb
|