git-newline-at-eof 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/git-newline-at-eof.gemspec +2 -0
- data/lib/git-newline-at-eof.rb +34 -19
- data/lib/git-newline-at-eof/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d2fe432548d95d15b23a35c313a5d24fff2067bc
|
4
|
+
data.tar.gz: a31cb2e1bea2cd767c0b4c2ffd2e422bc6c86477
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d53162265a23e6d9e87910e8136f58e2eec1bbf629262b452fa86ae2ff9bdc47e3ebede0f587af850dd64512bb9cf85786f8e1db8408fc68aa632a4902529ed
|
7
|
+
data.tar.gz: 110cea051d5fc90cf88cf8d241152bc7acf586a79a177abf071c2d84cf9a70b995c06685a6a3561015b1889e21103725d035048a3be5b26865538153921e78a2
|
data/git-newline-at-eof.gemspec
CHANGED
@@ -19,6 +19,8 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
20
|
spec.require_paths = ['lib']
|
21
21
|
|
22
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.3.3')
|
23
|
+
|
22
24
|
spec.add_development_dependency 'bundler'
|
23
25
|
spec.add_development_dependency 'rake'
|
24
26
|
spec.add_development_dependency 'test-unit'
|
data/lib/git-newline-at-eof.rb
CHANGED
@@ -1,15 +1,18 @@
|
|
1
1
|
require 'git-newline-at-eof/version'
|
2
2
|
require 'optparse'
|
3
3
|
require 'shellwords'
|
4
|
+
require 'open3'
|
4
5
|
|
5
6
|
module GitNewlineAtEof
|
6
7
|
class Application
|
7
8
|
def initialize(argv)
|
9
|
+
@in_git_dir = nil
|
8
10
|
@options = {}
|
9
11
|
@options[:feed_last_line] = false
|
10
12
|
@options[:discard_last_newline] = false
|
11
13
|
@options[:treat_all] = false
|
12
14
|
@options[:check_all] = false
|
15
|
+
@options[:help] = false
|
13
16
|
@options[:opted] = false
|
14
17
|
|
15
18
|
@opt = OptionParser.new
|
@@ -54,7 +57,7 @@ module GitNewlineAtEof
|
|
54
57
|
'--help',
|
55
58
|
'Show this message.',
|
56
59
|
proc { |v|
|
57
|
-
|
60
|
+
@options[:help] = true
|
58
61
|
@options[:opted] = true
|
59
62
|
}
|
60
63
|
],
|
@@ -76,30 +79,42 @@ module GitNewlineAtEof
|
|
76
79
|
@opt.parse!(argv)
|
77
80
|
end
|
78
81
|
|
79
|
-
def run
|
80
|
-
|
82
|
+
def run # return value is used for exit status
|
83
|
+
if !@options[:opted] || @options[:help]
|
81
84
|
puts @opt.help
|
82
85
|
0
|
83
|
-
|
84
|
-
IO.popen('git rev-parse', :err => [:child, :out])
|
85
|
-
if $? != 0
|
86
|
+
elsif !in_git_dir?
|
86
87
|
puts 'Here is not Git dir.'
|
87
|
-
|
88
|
-
end
|
89
|
-
@files = files
|
90
|
-
if @options[:check_all]
|
91
|
-
check_all
|
92
|
-
elsif @options[:treat_all]
|
93
|
-
treat_all
|
94
|
-
0
|
88
|
+
128
|
95
89
|
else
|
96
|
-
|
97
|
-
|
90
|
+
@files = files
|
91
|
+
if @options[:check_all]
|
92
|
+
check_all
|
93
|
+
elsif @options[:treat_all]
|
94
|
+
treat_all
|
95
|
+
0
|
96
|
+
else
|
97
|
+
if @options[:feed_last_line]
|
98
|
+
feed_last_line_all
|
99
|
+
end
|
100
|
+
if @options[:discard_last_newline]
|
101
|
+
discard_last_newline_all
|
102
|
+
end
|
103
|
+
0
|
98
104
|
end
|
99
|
-
|
100
|
-
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def in_git_dir?
|
109
|
+
if !@in_git_dir.nil?
|
110
|
+
@in_git_dir
|
111
|
+
else
|
112
|
+
o, e, exit_status = Open3.capture3('git rev-parse')
|
113
|
+
if exit_status == 0
|
114
|
+
@in_git_dir = true
|
115
|
+
else
|
116
|
+
@in_git_dir = false
|
101
117
|
end
|
102
|
-
0
|
103
118
|
end
|
104
119
|
end
|
105
120
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: git-newline-at-eof
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code Ass
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -87,7 +87,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
87
87
|
requirements:
|
88
88
|
- - ">="
|
89
89
|
- !ruby/object:Gem::Version
|
90
|
-
version:
|
90
|
+
version: 2.3.3
|
91
91
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
92
92
|
requirements:
|
93
93
|
- - ">="
|