Class: Ruby::Reforge::MigrationRules
- Inherits:
-
Object
- Object
- Ruby::Reforge::MigrationRules
- Defined in:
- lib/ruby/reforge/migration_rules.rb
Constant Summary collapse
- RULES =
{ "3.0.0" => { deprecated_methods: { "File.exists?" => "File.exist?", "Dir.exists?" => "Dir.exist?", "URI.escape" => "CGI.escape", "URI.unescape" => "CGI.unescape" }, deprecated_patterns: { /File\.exists\?/ => "File.exist?", /Dir\.exists\?/ => "Dir.exist?", /URI\.escape/ => "CGI.escape", /URI\.unescape/ => "CGI.unescape" }, breaking_changes: [ "Keyword arguments are now separated from positional arguments" ] }, "3.1.0" => { deprecated_methods: { "File.exists?" => "File.exist?", "Dir.exists?" => "Dir.exist?" }, deprecated_patterns: { /File\.exists\?/ => "File.exist?", /Dir\.exists\?/ => "Dir.exist?" } }, "3.2.0" => { deprecated_methods: { "File.exists?" => "File.exist?", "Dir.exists?" => "Dir.exist?" }, deprecated_patterns: { /File\.exists\?/ => "File.exist?", /Dir\.exists\?/ => "Dir.exist?" } }, "3.3.0" => { deprecated_methods: { "File.exists?" => "File.exist?", "Dir.exists?" => "Dir.exist?" }, deprecated_patterns: { /File\.exists\?/ => "File.exist?", /Dir\.exists\?/ => "Dir.exist?" } } }.freeze
Instance Attribute Summary collapse
-
#breaking_changes ⇒ Object
readonly
Returns the value of attribute breaking_changes.
-
#deprecated_methods ⇒ Object
readonly
Returns the value of attribute deprecated_methods.
-
#deprecated_patterns ⇒ Object
readonly
Returns the value of attribute deprecated_patterns.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(rules = {}) ⇒ MigrationRules
constructor
A new instance of MigrationRules.
Constructor Details
#initialize(rules = {}) ⇒ MigrationRules
Returns a new instance of MigrationRules.
71 72 73 74 75 |
# File 'lib/ruby/reforge/migration_rules.rb', line 71 def initialize(rules = {}) @deprecated_methods = rules[:deprecated_methods] || {} @deprecated_patterns = rules[:deprecated_patterns] || {} @breaking_changes = rules[:breaking_changes] || [] end |
Instance Attribute Details
#breaking_changes ⇒ Object (readonly)
Returns the value of attribute breaking_changes.
69 70 71 |
# File 'lib/ruby/reforge/migration_rules.rb', line 69 def breaking_changes @breaking_changes end |
#deprecated_methods ⇒ Object (readonly)
Returns the value of attribute deprecated_methods.
69 70 71 |
# File 'lib/ruby/reforge/migration_rules.rb', line 69 def deprecated_methods @deprecated_methods end |
#deprecated_patterns ⇒ Object (readonly)
Returns the value of attribute deprecated_patterns.
69 70 71 |
# File 'lib/ruby/reforge/migration_rules.rb', line 69 def deprecated_patterns @deprecated_patterns end |
Class Method Details
.for_version(version) ⇒ Object
56 57 58 59 60 61 |
# File 'lib/ruby/reforge/migration_rules.rb', line 56 def self.for_version(version) # Find the most appropriate rule set target = normalize_version(version) rule_key = RULES.keys.select { |k| normalize_version(k) <= target }.max || RULES.keys.first new(RULES[rule_key] || {}) end |
.normalize_version(version) ⇒ Object
63 64 65 66 67 |
# File 'lib/ruby/reforge/migration_rules.rb', line 63 def self.normalize_version(version) parts = version.to_s.split(".").map(&:to_i) parts << 0 while parts.size < 3 parts[0..2].join(".") end |