rubocopfmt 0.1.0.beta6 → 0.1.0.beta7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rubocopfmt/cli.rb +3 -3
- data/lib/rubocopfmt/cli_options.rb +7 -7
- data/lib/rubocopfmt/diff.rb +0 -4
- data/lib/rubocopfmt/formatter.rb +4 -4
- data/lib/rubocopfmt/options.rb +1 -1
- data/lib/rubocopfmt/source.rb +16 -2
- data/lib/rubocopfmt/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7bf78c5ac751ef29855d0ef4d566c9960926173b
|
4
|
+
data.tar.gz: de2da7fbe495d37d12dc79582c2a703084d42e6b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2259350145f6eeb723038aa9eae4e0505fc737c275024951c9f249190e3dc666aea229d26bbbea391b36f46656988081ec4fa84bb009c0168b07f0ab42b76cee
|
7
|
+
data.tar.gz: a8b3d02c97d42ff7e3f0e610c60a7d7693f653fc2cf013ab5e71d1044d064c4dcffddda1a9409f80ad1eaac5f2ccc81792dbf88434435a673b009b51f5b6fef0
|
data/lib/rubocopfmt/cli.rb
CHANGED
@@ -33,14 +33,14 @@ module RuboCopFMT
|
|
33
33
|
Options:
|
34
34
|
EOF
|
35
35
|
|
36
|
-
version "rubocopfmt #{RuboCopFMT::VERSION}
|
37
|
-
"(rubocop #{::RuboCop::Version::STRING})"
|
36
|
+
version "rubocopfmt #{RuboCopFMT::VERSION}" \
|
37
|
+
" (rubocop #{::RuboCop::Version::STRING})"
|
38
38
|
|
39
|
-
opt :diff, 'Display diffs instead of rewriting files
|
40
|
-
opt :list, 'List files whose formatting is incorrect
|
41
|
-
opt :write, 'Write result to (source) file instead of STDOUT
|
42
|
-
opt :
|
43
|
-
short: '
|
39
|
+
opt :diff, 'Display diffs instead of rewriting files'
|
40
|
+
opt :list, 'List files whose formatting is incorrect'
|
41
|
+
opt :write, 'Write result to (source) file instead of STDOUT'
|
42
|
+
opt :src_dir, 'Operate as if code resides in specified directory',
|
43
|
+
short: 'S', type: :string
|
44
44
|
opt :diff_format, 'Display diffs using format: unified, rcs, context',
|
45
45
|
short: 'D', type: :string
|
46
46
|
banner ''
|
data/lib/rubocopfmt/diff.rb
CHANGED
data/lib/rubocopfmt/formatter.rb
CHANGED
@@ -27,7 +27,7 @@ module RuboCopFMT
|
|
27
27
|
|
28
28
|
def build_sources
|
29
29
|
if options.paths.empty?
|
30
|
-
[new_source_from_stdin
|
30
|
+
[new_source_from_stdin]
|
31
31
|
else
|
32
32
|
options.paths.map do |path|
|
33
33
|
new_source_from_file(path)
|
@@ -35,15 +35,15 @@ module RuboCopFMT
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
def new_source_from_stdin
|
39
|
-
Source.new($stdin.binmode.read,
|
38
|
+
def new_source_from_stdin
|
39
|
+
Source.new($stdin.binmode.read, nil, options.src_dir)
|
40
40
|
end
|
41
41
|
|
42
42
|
def new_source_from_file(path)
|
43
43
|
raise FileNotFound, "File not found: #{path}" unless File.exist?(path)
|
44
44
|
|
45
45
|
source = File.read(path, mode: 'rb')
|
46
|
-
Source.new(source, path)
|
46
|
+
Source.new(source, path, options.src_dir)
|
47
47
|
end
|
48
48
|
end
|
49
49
|
end
|
data/lib/rubocopfmt/options.rb
CHANGED
data/lib/rubocopfmt/source.rb
CHANGED
@@ -5,16 +5,18 @@ module RuboCopFMT
|
|
5
5
|
attr_reader :path
|
6
6
|
attr_reader :input
|
7
7
|
attr_reader :output
|
8
|
+
attr_reader :src_dir
|
8
9
|
|
9
|
-
def initialize(input, path = nil)
|
10
|
+
def initialize(input, path = nil, src_dir = nil)
|
10
11
|
@input = input
|
11
12
|
@path = path
|
13
|
+
@src_dir = src_dir
|
12
14
|
end
|
13
15
|
|
14
16
|
def auto_correct
|
15
17
|
return unless output.nil?
|
16
18
|
|
17
|
-
@corrector = AutoCorrector.new(input,
|
19
|
+
@corrector = AutoCorrector.new(input, full_path)
|
18
20
|
@output = @corrector.correct
|
19
21
|
end
|
20
22
|
|
@@ -24,5 +26,17 @@ module RuboCopFMT
|
|
24
26
|
|
25
27
|
@corrected = (@input != @output)
|
26
28
|
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def full_path
|
33
|
+
full_path = path || '__fake__.rb'
|
34
|
+
|
35
|
+
if src_dir.nil?
|
36
|
+
full_path
|
37
|
+
else
|
38
|
+
File.join(src_dir, File.basename(full_path))
|
39
|
+
end
|
40
|
+
end
|
27
41
|
end
|
28
42
|
end
|
data/lib/rubocopfmt/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubocopfmt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
4
|
+
version: 0.1.0.beta7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jim Myhrberg
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|