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.



67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/jeweler/version_helper.rb', line 67

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

#versionObject (readonly)

Returns the value of attribute version.



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

def version
  @version
end

Instance Method Details

#bump_majorObject



93
94
95
# File 'lib/jeweler/version_helper.rb', line 93

def bump_major
  @version = "#{major + 1}.0.0"
end

#bump_minorObject



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

def bump_minor
  @version = "#{major}.#{minor+1}.0"
end

#bump_patchObject



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

def bump_patch
  @version = "#{major}.#{minor}.#{patch + 1}"
end

#majorObject



81
82
83
# File 'lib/jeweler/version_helper.rb', line 81

def major
  version_parts[0]
end

#minorObject



85
86
87
# File 'lib/jeweler/version_helper.rb', line 85

def minor
  version_parts[1]
end

#patchObject



89
90
91
# File 'lib/jeweler/version_helper.rb', line 89

def patch
  version_parts[2]
end

#plaintext_pathObject



119
120
121
122
123
# File 'lib/jeweler/version_helper.rb', line 119

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



109
110
111
# File 'lib/jeweler/version_helper.rb', line 109

def to_s
  version
end

#update_to(version) ⇒ Object



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

def update_to(version)
  @version = version
end

#yaml_pathObject



113
114
115
116
117
# File 'lib/jeweler/version_helper.rb', line 113

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