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.



76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/jeweler/version_helper.rb', line 76

def initialize(base_dir)
  self.base_dir = base_dir

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

Instance Attribute Details

#base_dirObject

Returns the value of attribute base_dir.



5
6
7
# File 'lib/jeweler/version_helper.rb', line 5

def base_dir
  @base_dir
end

#majorObject (readonly)

Returns the value of attribute major.



6
7
8
# File 'lib/jeweler/version_helper.rb', line 6

def major
  @major
end

#minorObject (readonly)

Returns the value of attribute minor.



6
7
8
# File 'lib/jeweler/version_helper.rb', line 6

def minor
  @minor
end

#patchObject (readonly)

Returns the value of attribute patch.



6
7
8
# File 'lib/jeweler/version_helper.rb', line 6

def patch
  @patch
end

Instance Method Details

#bump_majorObject



90
91
92
93
94
# File 'lib/jeweler/version_helper.rb', line 90

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

#bump_minorObject



96
97
98
99
# File 'lib/jeweler/version_helper.rb', line 96

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

#bump_patchObject



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

def bump_patch
  @patch += 1
end

#plaintext_pathObject



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

def plaintext_path
  denormalized_path = File.join(@base_dir, 'VERSION')
  absolute_path = File.expand_path(denormalized_path)
  absolute_path.gsub(Dir.getwd + File::SEPARATOR, '')
end

#to_sObject



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

def to_s
  "#{major}.#{minor}.#{patch}"
end

#update_to(major, minor, patch) ⇒ Object



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

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

#yaml_pathObject



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

def yaml_path
  denormalized_path = File.join(@base_dir, 'VERSION.yml')
  absolute_path = File.expand_path(denormalized_path)
  absolute_path.gsub(Dir.getwd + File::SEPARATOR, '')
end