hubignore 1.0.2 → 1.0.3
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 +4 -4
- data/lib/hubignore.rb +22 -23
- data/lib/hubignore/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 16875e0b4f2c73aa48d667b33a6aa4189505b190
|
|
4
|
+
data.tar.gz: e3302b448235cdb7a08ab1189529c015c4961ed9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 747d6faa487115641998f09c401903d766a0e1936bf664840851a91ea82f94c6600dd31fa8618507274cd657f793772a42343640226d40a3cb5d49547c941d18
|
|
7
|
+
data.tar.gz: 27aea072b89e206982580b1d46f8f9343488262b855f0014adb1cca10554feeb2001d2692878664535dfbc3ad10f301191a9ec27a1d681e1eff8407853f1b542
|
data/lib/hubignore.rb
CHANGED
|
@@ -2,6 +2,7 @@ require 'colored'
|
|
|
2
2
|
require 'hubignore/version'
|
|
3
3
|
require 'net/http'
|
|
4
4
|
require 'uri'
|
|
5
|
+
require 'open-uri'
|
|
5
6
|
|
|
6
7
|
# The main class of HubIgnore
|
|
7
8
|
class HubIgnore
|
|
@@ -15,10 +16,10 @@ class HubIgnore
|
|
|
15
16
|
|
|
16
17
|
def parse_argv(argv)
|
|
17
18
|
help = <<EOS
|
|
18
|
-
$ hubignore -v --version # show version
|
|
19
|
-
$ hubignore -l --list # list git ignores in current .gitignore
|
|
20
|
-
$ hubignore -u --update # update git ignores in current .gitignore to upstream
|
|
21
|
-
$ hubignore -h --help # show this help message
|
|
19
|
+
$ hubignore -v --version # show version
|
|
20
|
+
$ hubignore -l --list # list git ignores in current .gitignore
|
|
21
|
+
$ hubignore -u --update # update git ignores in current .gitignore to upstream
|
|
22
|
+
$ hubignore -h --help # show this help message
|
|
22
23
|
EOS
|
|
23
24
|
|
|
24
25
|
case argv
|
|
@@ -43,7 +44,7 @@ EOS
|
|
|
43
44
|
def items
|
|
44
45
|
items = []
|
|
45
46
|
file = IO.read('.gitignore')
|
|
46
|
-
file.scan(
|
|
47
|
+
file.scan(/^\#\#\s*HubIgnore Begins?:.*^\#\#\s*HubIgnore End.?$/mi).each do |block|
|
|
47
48
|
first_line = block.lines.first
|
|
48
49
|
items << first_line.split(':')[1].split(',').map(&:strip)
|
|
49
50
|
end
|
|
@@ -56,27 +57,25 @@ EOS
|
|
|
56
57
|
end
|
|
57
58
|
|
|
58
59
|
def update
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
content = IO.read('.gitignore')
|
|
61
|
+
new_content = content.gsub(/^\#\#\s*HubIgnore Begins?:.*^\#\#\s*HubIgnore End.?$/mi) do |block|
|
|
62
|
+
first_line = block.lines.first
|
|
63
|
+
result = first_line
|
|
64
|
+
first_line.split(':')[1].split(',').map(&:strip).each do |file|
|
|
62
65
|
next if file.empty?
|
|
63
66
|
puts "Downloading #{file}"
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
item.map! do |name|
|
|
72
|
-
Regexp.escape(name)
|
|
67
|
+
result += "\#\# #{file} Begins:\n"
|
|
68
|
+
uri = URI.parse(
|
|
69
|
+
'https://raw.githubusercontent.com/github/'\
|
|
70
|
+
"gitignore/master/#{file}.gitignore"
|
|
71
|
+
)
|
|
72
|
+
result += uri.read
|
|
73
|
+
result += "\n"
|
|
73
74
|
end
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
file = file.gsub(
|
|
77
|
-
/\#\# HubIgnore Begin: *#{item.join(' *, *')} *.*?\#\# HubIgnore End./m,
|
|
78
|
-
content)
|
|
79
|
-
IO.write('.gitignore', file)
|
|
75
|
+
result += block.lines.last
|
|
76
|
+
result
|
|
80
77
|
end
|
|
78
|
+
|
|
79
|
+
IO.write('.gitignore', new_content)
|
|
81
80
|
end
|
|
82
81
|
end
|
data/lib/hubignore/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hubignore
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0.
|
|
4
|
+
version: 1.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jiege Chen
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2017-07-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description:
|
|
14
14
|
email:
|
|
@@ -43,9 +43,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
43
43
|
version: '0'
|
|
44
44
|
requirements: []
|
|
45
45
|
rubyforge_project:
|
|
46
|
-
rubygems_version: 2.
|
|
46
|
+
rubygems_version: 2.6.11
|
|
47
47
|
signing_key:
|
|
48
48
|
specification_version: 4
|
|
49
49
|
summary: Download and manage git ignores from github/gitignore.
|
|
50
50
|
test_files: []
|
|
51
|
-
has_rdoc:
|