Class: GemChanges::Change

Inherits:
Struct
  • Object
show all
Defined in:
lib/gem_changes/change.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(gem:, from:, to:) ⇒ Change

Returns a new instance of Change.



5
6
7
# File 'lib/gem_changes/change.rb', line 5

def initialize(gem:, from:, to:)
  super(gem:, from: Version(from), to: Version(to))
end

Instance Attribute Details

#fromObject

Returns the value of attribute from

Returns:

  • (Object)

    the current value of from



4
5
6
# File 'lib/gem_changes/change.rb', line 4

def from
  @from
end

#gemObject

Returns the value of attribute gem

Returns:

  • (Object)

    the current value of gem



4
5
6
# File 'lib/gem_changes/change.rb', line 4

def gem
  @gem
end

#toObject

Returns the value of attribute to

Returns:

  • (Object)

    the current value of to



4
5
6
# File 'lib/gem_changes/change.rb', line 4

def to
  @to
end

Instance Method Details

#addition?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/gem_changes/change.rb', line 13

def addition?
  from.nil?
end

#change?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/gem_changes/change.rb', line 9

def change?
  to and from
end

#downgrade?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/gem_changes/change.rb', line 25

def downgrade?
  change? and to < from
end

#major?Boolean

Returns:

  • (Boolean)


29
30
31
32
33
# File 'lib/gem_changes/change.rb', line 29

def major?
  change? &&
    from.segments[0] && to.segments[0] &&
    from.segments[0] != to.segments[0]
end

#minor?Boolean

Returns:

  • (Boolean)


35
36
37
38
39
# File 'lib/gem_changes/change.rb', line 35

def minor?
  change? && !major? &&
    from.segments[1] && to.segments[1] &&
    from.segments[1] != to.segments[1]
end

#patch?Boolean

Returns:

  • (Boolean)


41
42
43
44
45
# File 'lib/gem_changes/change.rb', line 41

def patch?
  change? && !major? && !minor? &&
    from.segments[2] && to.segments[2] &&
    from.segments[2] != to.segments[2]
end

#removal?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/gem_changes/change.rb', line 17

def removal?
  to.nil?
end

#upgrade?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/gem_changes/change.rb', line 21

def upgrade?
  change? and to > from
end