hubignore 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b865ae5ace24385f2d90b19aa8df99245fd3adc4
4
+ data.tar.gz: 53c0b2e5032335f203ddbb5941e344aba17c0f69
5
+ SHA512:
6
+ metadata.gz: 6d761ea9d9bb2df651b84e156bc5f7074fc37b5991821c94b42e19943aeba3f2edbcc9b2a4ce2616f0c96726450a8e02d7dca4093e08b935f55479c324c71e21
7
+ data.tar.gz: 5e4d11f933264c400b7324dc84c9e225ce64ed30598b8c21acec959c7ba36737241d15b51635e46b37d4cd665054a4a302ed6b2ac558a633fa5a7e4267373e14
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Jiajie Chen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
data/README.md ADDED
@@ -0,0 +1,15 @@
1
+ hubignore(1) -- Download and manage git ignores from github/gitignore.
2
+ =================================================================
3
+
4
+ SYNOPSIS
5
+ --------
6
+ GitHub has a great collection of .gitignores in github/gitignore.
7
+ This tool is to help using these gitignores withing your own .gitignore.
8
+
9
+ INSTALL
10
+ -------
11
+ $ gem install hubignore
12
+
13
+ USE
14
+ ---
15
+ $ hubignore
data/bin/hubignore ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'hubignore'
4
+
5
+ HubIgnore.new.run(ARGV)
@@ -0,0 +1,3 @@
1
+ class HubIgnore
2
+ VERSION = "1.0.0"
3
+ end
data/lib/hubignore.rb ADDED
@@ -0,0 +1,76 @@
1
+ require 'colored'
2
+ require 'hubignore/version'
3
+ require 'net/http'
4
+ require 'uri'
5
+
6
+ class HubIgnore
7
+ def run(argv)
8
+ unless File.exist?('.gitignore')
9
+ puts 'No .gitignore file in current directory. Exiting.'
10
+ return
11
+ end
12
+ parse_argv(argv)
13
+ end
14
+
15
+ def parse_argv(argv)
16
+ help = <<EOS
17
+ $ hubignore -v --version # show version
18
+ $ hubignore -l --list # list git ignores in current .gitignore
19
+ $ hubignore -u --update # update git ignores in current .gitignore to upstream
20
+ $ hubignore -h --help # show this help message
21
+ EOS
22
+
23
+ case argv
24
+ when ['-l'], ['--list']
25
+ list
26
+ exit
27
+ when ['-u'], ['--update']
28
+ update
29
+ exit
30
+ when ['-v'], ['--version']
31
+ puts "hubignore #{HubIgnore::VERSION}"
32
+ exit
33
+ when ['-h'], ['--help']
34
+ puts help
35
+ exit
36
+ else
37
+ puts help
38
+ exit 1
39
+ end
40
+ end
41
+
42
+ def items
43
+ items = []
44
+ file = IO.read('.gitignore')
45
+ file.scan(/\#\# HubIgnore Begin:.*?\#\# HubIgnore End./m).each do |block|
46
+ first_line = block.lines.first
47
+ items << first_line.split(':')[1].split(',').map(&:strip)
48
+ end
49
+ items
50
+ end
51
+
52
+ def list
53
+ puts items.flatten
54
+ end
55
+
56
+ def update
57
+ items.each do |item|
58
+ content = "\#\# HubIgnore Begin: #{item.join(' , ')}\n"
59
+ item.each do |file|
60
+ next if file.empty?
61
+ puts "Downloading #{file}"
62
+ content += Net::HTTP.get(
63
+ URI.parse(
64
+ 'https://raw.githubusercontent.com/github/'\
65
+ "gitignore/master/#{file}.gitignore"))
66
+ content += "\n"
67
+ end
68
+ content += '## HubIgnore End.'
69
+ file = IO.read('.gitignore')
70
+ file = file.gsub(
71
+ /\#\# HubIgnore Begin: *#{item.join(' *, *')} *.*?\#\# HubIgnore End./m,
72
+ content)
73
+ IO.write('.gitignore', file)
74
+ end
75
+ end
76
+ end
metadata ADDED
@@ -0,0 +1,65 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: hubignore
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Jiege Chen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-10-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: colored
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ description:
28
+ email:
29
+ - jiegec@qq.com
30
+ executables:
31
+ - hubignore
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - LICENSE
36
+ - README.md
37
+ - bin/hubignore
38
+ - lib/hubignore.rb
39
+ - lib/hubignore/version.rb
40
+ homepage: https://github.com/jiegec/hubignore
41
+ licenses:
42
+ - MIT
43
+ metadata: {}
44
+ post_install_message:
45
+ rdoc_options: []
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0'
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '0'
58
+ requirements: []
59
+ rubyforge_project:
60
+ rubygems_version: 2.4.8
61
+ signing_key:
62
+ specification_version: 4
63
+ summary: Download and manage git ignores from github/gitignore.
64
+ test_files: []
65
+ has_rdoc: