Class: Jeweler::VersionHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/jeweler/version_helper.rb

Defined Under Namespace

Modules: PlaintextExtension, YamlExtension

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_dir) ⇒ VersionHelper

Returns a new instance of VersionHelper.



86
87
88
89
90
91
92
93
94
95
96
# File 'lib/jeweler/version_helper.rb', line 86

def initialize(base_dir)
  self.base_dir = base_dir

  if File.exist?(yaml_path)
    extend YamlExtension
    parse_yaml
  else
    extend PlaintextExtension
    parse_plaintext if File.exist?(plaintext_path)
  end
end

Instance Attribute Details

#base_dirObject

Returns the value of attribute base_dir.



10
11
12
# File 'lib/jeweler/version_helper.rb', line 10

def base_dir
  @base_dir
end

#buildObject (readonly)

Returns the value of attribute build.



11
12
13
# File 'lib/jeweler/version_helper.rb', line 11

def build
  @build
end

#majorObject (readonly)

Returns the value of attribute major.



11
12
13
# File 'lib/jeweler/version_helper.rb', line 11

def major
  @major
end

#minorObject (readonly)

Returns the value of attribute minor.



11
12
13
# File 'lib/jeweler/version_helper.rb', line 11

def minor
  @minor
end

#patchObject (readonly)

Returns the value of attribute patch.



11
12
13
# File 'lib/jeweler/version_helper.rb', line 11

def patch
  @patch
end

Instance Method Details

#bump_majorObject



98
99
100
101
102
103
# File 'lib/jeweler/version_helper.rb', line 98

def bump_major
  @major += 1
  @minor = 0
  @patch = 0
  @build = nil
end

#bump_minorObject



105
106
107
108
109
# File 'lib/jeweler/version_helper.rb', line 105

def bump_minor
  @minor += 1
  @patch = 0
  @build = nil
end

#bump_patchObject



111
112
113
114
# File 'lib/jeweler/version_helper.rb', line 111

def bump_patch
  @patch += 1
  @build = nil
end

#plaintext_pathObject



131
132
133
# File 'lib/jeweler/version_helper.rb', line 131

def plaintext_path
  path_to_version_file('VERSION')
end

#to_sObject



123
124
125
# File 'lib/jeweler/version_helper.rb', line 123

def to_s
  [major, minor, patch, build].compact.join('.')
end

#update_to(major, minor, patch, build = nil) ⇒ Object



116
117
118
119
120
121
# File 'lib/jeweler/version_helper.rb', line 116

def update_to(major, minor, patch, build = nil)
  @major = major
  @minor = minor
  @patch = patch
  @build = build
end

#yaml_pathObject



127
128
129
# File 'lib/jeweler/version_helper.rb', line 127

def yaml_path
  path_to_version_file('VERSION.yml')
end