mry 0.48.1.0 → 0.48.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d544dfdefd04a24b0f94fe178dc31c29b81e12ac
4
- data.tar.gz: 369e43c41ed43a63442bee1e5aa09059fd2dad48
3
+ metadata.gz: 291cc5401e23fa34ddb2c23101b0f6515f42a334
4
+ data.tar.gz: e29f4ae20a421e26df677a757c8e583f149ca295
5
5
  SHA512:
6
- metadata.gz: 81d8f739324ccc13a7145c1bc6edb072a61262c7c67c269655ed1bad6f729b9f821b2eb7137916ee675b6bf79040f638ba668fd22737329ae503b7299bff1b6e
7
- data.tar.gz: 461f6e7f95fb942a5cd463e284a4e6b4b84309151ec2343e343403f2c54928332a06672f0bfd3edefe54decb619e52e7337787757c7ec674c2269e4732ba2b32
6
+ metadata.gz: 9c5028bb9a6dc27867ea83bf7ef6dc33590749bf0cfba658834d2a30afb7614d86550a139b95c2906eb03ebc2bb7ef333a3996595431486ff9f4959be356dc8a
7
+ data.tar.gz: 975a700bef34934dc856653fd54d52901d691c7996687cc489fc101b6adfdaec2c77aac294a595ca40d3c97b5ac4391c8f76fabc95c50643009f7aa8b1770312
data/README.md CHANGED
@@ -5,7 +5,7 @@ Mry Migrates .Rubocop.Yml :muscle:
5
5
 
6
6
  RuboCop has many many breaking changes, because it is before version 1.0.
7
7
  So, if you update RuboCop version, in many cases .rubocop.yml breaks...
8
- This tool supports migrating `.rubocop.yml`. With this tool, you do not have to be afraid of updating RuboCop anymore.
8
+ This tool supports migrating `.rubocop.yml`. It automatically rename the configuration in your `.rubocop.yml` that is renamed by updating RuboCop. So, with this tool, you do not have to be afraid of updating RuboCop anymore!
9
9
 
10
10
  ## Installation
11
11
 
@@ -37,6 +37,11 @@ Update `.rubocop.yml` to version 0.48.0:
37
37
  $ mry --target=0.48.0 .rubocop.yml
38
38
  ```
39
39
 
40
+ ### Example
41
+
42
+
43
+ ![Example Animation](https://cloud.githubusercontent.com/assets/4361134/25322816/8188f21a-28f5-11e7-9915-93f72034e3ea.gif)
44
+
40
45
  ## Development
41
46
 
42
47
  After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
data/lib/mry/cli.rb CHANGED
@@ -4,8 +4,12 @@ module Mry
4
4
  # @param argv [Array<String>]
5
5
  # @return [Integer] exit code
6
6
  def run(argv)
7
- target = parse_option(argv)
8
- Runner.run(argv, target)
7
+ parse_option(argv)
8
+ if argv.empty?
9
+ puts option.help
10
+ return 1
11
+ end
12
+ Runner.run(argv, @target)
9
13
  return 0
10
14
  end
11
15
 
@@ -13,14 +17,21 @@ module Mry
13
17
  private
14
18
 
15
19
  def parse_option(argv)
16
- target = Gem::Version.new('10000000000000000000')
20
+ @target = nil
21
+ option.parse!(argv)
22
+ end
23
+
24
+ def option
17
25
  opt = OptionParser.new
26
+ opt.banner = 'Usage: mry [options] [.rubocop.yml]'
18
27
  opt.on('-t=TARGET_VERSION', '--target=TARGET_VERSION') do |t|
19
- target = Gem::Version.new(t)
28
+ @target =
29
+ if t == 'master'
30
+ :master
31
+ else
32
+ Gem::Version.new(t)
33
+ end
20
34
  end
21
- opt.parse!(argv)
22
-
23
- return target
24
35
  end
25
36
  end
26
37
  end
@@ -0,0 +1,80 @@
1
+ module Mry
2
+ class Rewriter_Master < YAMLRewriter::Rewriter
3
+ layout_cops = %w[
4
+ Layout/AccessModifierIndentation
5
+ Layout/AlignArray
6
+ Layout/AlignHash
7
+ Layout/AlignParameters
8
+ Layout/BlockEndNewline
9
+ Layout/CaseIndentation
10
+ Layout/ClosingParenthesisIndentation
11
+ Layout/CommentIndentation
12
+ Layout/DotPosition
13
+ Layout/ElseAlignment
14
+ Layout/EmptyLineAfterMagicComment
15
+ Layout/EmptyLineBetweenDefs
16
+ Layout/EmptyLinesAroundAccessModifier
17
+ Layout/EmptyLinesAroundBeginBody
18
+ Layout/EmptyLinesAroundBlockBody
19
+ Layout/EmptyLinesAroundClassBody
20
+ Layout/EmptyLinesAroundExceptionHandlingKeywords
21
+ Layout/EmptyLinesAroundMethodBody
22
+ Layout/EmptyLinesAroundModuleBody
23
+ Layout/EmptyLines
24
+ Layout/EndOfLine
25
+ Layout/ExtraSpacing
26
+ Layout/FirstArrayElementLineBreak
27
+ Layout/FirstHashElementLineBreak
28
+ Layout/FirstMethodArgumentLineBreak
29
+ Layout/FirstMethodParameterLineBreak
30
+ Layout/FirstParameterIndentation
31
+ Layout/IndentArray
32
+ Layout/IndentAssignment
33
+ Layout/IndentationConsistency
34
+ Layout/IndentationWidth
35
+ Layout/IndentHash
36
+ Layout/IndentHeredoc
37
+ Layout/InitialIndentation
38
+ Layout/LeadingCommentSpace
39
+ Layout/MultilineArrayBraceLayout
40
+ Layout/MultilineAssignmentLayout
41
+ Layout/MultilineBlockLayout
42
+ Layout/MultilineHashBraceLayout
43
+ Layout/MultilineMethodCallBraceLayout
44
+ Layout/MultilineMethodCallIndentation
45
+ Layout/MultilineMethodDefinitionBraceLayout
46
+ Layout/MultilineOperationIndentation
47
+ Layout/RescueEnsureAlignment
48
+ Layout/SpaceAfterColon
49
+ Layout/SpaceAfterComma
50
+ Layout/SpaceAfterMethodName
51
+ Layout/SpaceAfterNot
52
+ Layout/SpaceAfterSemicolon
53
+ Layout/SpaceAroundBlockParameters
54
+ Layout/SpaceAroundEqualsInParameterDefault
55
+ Layout/SpaceAroundKeyword
56
+ Layout/SpaceAroundOperators
57
+ Layout/SpaceBeforeBlockBraces
58
+ Layout/SpaceBeforeComma
59
+ Layout/SpaceBeforeComment
60
+ Layout/SpaceBeforeFirstArg
61
+ Layout/SpaceBeforeSemicolon
62
+ Layout/SpaceInLambdaLiteral
63
+ Layout/SpaceInsideArrayPercentLiteral
64
+ Layout/SpaceInsideBlockBraces
65
+ Layout/SpaceInsideBrackets
66
+ Layout/SpaceInsideHashLiteralBraces
67
+ Layout/SpaceInsideParens
68
+ Layout/SpaceInsidePercentLiteralDelimiters
69
+ Layout/SpaceInsideRangeLiteral
70
+ Layout/SpaceInsideStringInterpolation
71
+ Layout/Tab
72
+ Layout/TrailingBlankLines
73
+ Layout/TrailingWhitespace
74
+ ]
75
+
76
+ layout_cops.each do |cop|
77
+ define_rule [cop.sub('Layout', 'Style') => cop]
78
+ end
79
+ end
80
+ end
data/lib/mry/runner.rb CHANGED
@@ -8,9 +8,14 @@ module Mry
8
8
 
9
9
  class << self
10
10
  def run(files, target)
11
- rewriters = Rewriters
12
- .select{|key, _value| target >= key}
13
- .values.reverse
11
+ rewriters =
12
+ if target == :master
13
+ (Rewriters.values + [Rewriter_Master]).reverse
14
+ else
15
+ Rewriters
16
+ .select{|key, _value| target >= key}
17
+ .values.reverse
18
+ end
14
19
 
15
20
  files.each do |file|
16
21
  yaml = File.read(file)
data/lib/mry/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Mry
2
- VERSION = "0.48.1.0"
2
+ VERSION = "0.48.1.1"
3
3
  end
data/lib/mry.rb CHANGED
@@ -2,6 +2,7 @@ require 'yaml_rewriter'
2
2
  require 'optparse'
3
3
 
4
4
  require "mry/version"
5
+ require 'mry/rewriter_master'
5
6
  require 'mry/rewriter_0_47_0'
6
7
  require 'mry/rewriter_0_46_0'
7
8
  require 'mry/rewriter_0'
@@ -8,8 +8,9 @@ module YAMLRewriter
8
8
  end
9
9
 
10
10
  def scalar(value, anchor, tag, plain, quoted, style)
11
+ mark = @parser.mark
11
12
  super.tap do |scalar|
12
- scalar.mark = @parser.mark
13
+ scalar.mark = mark
13
14
  end
14
15
  end
15
16
  end
@@ -47,7 +47,8 @@ module YAMLRewriter
47
47
  index = key.mark.index + @offset
48
48
  prev = key.value
49
49
  new = rule.last[prev]
50
- @yaml[(index-prev.size-1)..index-2] = new
50
+ start_index = @yaml.rindex(prev, index)
51
+ @yaml[start_index..(start_index+prev.size-1)] = new
51
52
  @offset += new.size-prev.size
52
53
  end
53
54
  end
data/lib/yaml_rewriter.rb CHANGED
@@ -1,4 +1,4 @@
1
- require 'yaml'
1
+ require 'psych'
2
2
  require 'yaml_rewriter/scalar_with_mark'
3
3
  require 'yaml_rewriter/mark_handler'
4
4
  require 'yaml_rewriter/parser'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mry
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.48.1.0
4
+ version: 0.48.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masataka Kuwabara
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-04-22 00:00:00.000000000 Z
11
+ date: 2017-04-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -131,6 +131,7 @@ files:
131
131
  - lib/mry/rewriter_0.rb
132
132
  - lib/mry/rewriter_0_46_0.rb
133
133
  - lib/mry/rewriter_0_47_0.rb
134
+ - lib/mry/rewriter_master.rb
134
135
  - lib/mry/runner.rb
135
136
  - lib/mry/version.rb
136
137
  - lib/yaml_rewriter.rb