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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7416aa6f1bb92c2310a5bf78538f2b2b2f174527
4
- data.tar.gz: 76f35e8e1e202652ff0261fc27c25c3b3b110eb4
3
+ metadata.gz: 7bf78c5ac751ef29855d0ef4d566c9960926173b
4
+ data.tar.gz: de2da7fbe495d37d12dc79582c2a703084d42e6b
5
5
  SHA512:
6
- metadata.gz: 416b970fe9e5c57460750db621f13047387acd43d5666fa45210321ae7888382aeb71bda2d783c9d23acfb67f7b320613a83897e9037b9a5197f48bd14c43cc5
7
- data.tar.gz: c3dd70a67e708707bc458abbafc9efdf51fc5f2e07edf0a85b5a93528acf1c4009d9e432b4f0f8ae81a14245769a05aac0841d0a0866ab715681f9e4e7c0cc0e
6
+ metadata.gz: 2259350145f6eeb723038aa9eae4e0505fc737c275024951c9f249190e3dc666aea229d26bbbea391b36f46656988081ec4fa84bb009c0168b07f0ab42b76cee
7
+ data.tar.gz: a8b3d02c97d42ff7e3f0e610c60a7d7693f653fc2cf013ab5e71d1044d064c4dcffddda1a9409f80ad1eaac5f2ccc81792dbf88434435a673b009b51f5b6fef0
@@ -17,9 +17,9 @@ module RuboCopFMT
17
17
  end
18
18
 
19
19
  def run
20
- runner = Formatter.new(options)
21
- runner.run
22
- @sources = runner.sources
20
+ formatter = Formatter.new(options)
21
+ formatter.run
22
+ @sources = formatter.sources
23
23
 
24
24
  if @options.list
25
25
  print_corrected_list
@@ -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 :stdin_file, 'Optionally provide file path when using STDIN.',
43
- short: 'F', type: :string
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 ''
@@ -32,10 +32,6 @@ module RuboCopFMT
32
32
 
33
33
  private
34
34
 
35
- def rcs?(format)
36
- diff_opts(format) == FORMATS[:rcs]
37
- end
38
-
39
35
  def diff_opts(format = nil)
40
36
  format ? FORMATS[format.downcase.to_sym] : DEFAULT_FORMAT
41
37
  end
@@ -27,7 +27,7 @@ module RuboCopFMT
27
27
 
28
28
  def build_sources
29
29
  if options.paths.empty?
30
- [new_source_from_stdin(options.stdin_file)]
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(path = nil)
39
- Source.new($stdin.binmode.read, path)
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
@@ -1,6 +1,6 @@
1
1
  module RuboCopFMT
2
2
  class Options
3
- attr_accessor :stdin_file
3
+ attr_accessor :src_dir
4
4
  attr_accessor :diff_format
5
5
 
6
6
  def paths
@@ -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, path)
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
@@ -1,3 +1,3 @@
1
1
  module RuboCopFMT
2
- VERSION = '0.1.0.beta6'.freeze
2
+ VERSION = '0.1.0.beta7'.freeze
3
3
  end
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.beta6
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-19 00:00:00.000000000 Z
11
+ date: 2017-01-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler