Class: FlutterVersionTool
- Inherits:
-
Object
- Object
- FlutterVersionTool
- Defined in:
- lib/flutter_version_tool.rb
Instance Attribute Summary collapse
-
#pubspecPath ⇒ Object
readonly
Returns the value of attribute pubspecPath.
-
#vCode ⇒ Object
readonly
Returns the value of attribute vCode.
-
#vMajor ⇒ Object
readonly
Returns the value of attribute vMajor.
-
#vMinor ⇒ Object
readonly
Returns the value of attribute vMinor.
-
#vName ⇒ Object
readonly
Returns the value of attribute vName.
-
#vPatch ⇒ Object
readonly
Returns the value of attribute vPatch.
Instance Method Summary collapse
- #bumpVersionCode(increment = 1) ⇒ Object
- #bumpVersionName(level = "major", increment) ⇒ Object
- #changeVersionCode(p_code) ⇒ Object
-
#initialize(path) ⇒ FlutterVersionTool
constructor
A new instance of FlutterVersionTool.
- #vFull ⇒ Object
Constructor Details
#initialize(path) ⇒ FlutterVersionTool
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/flutter_version_tool.rb', line 8 def initialize(path) @pubspecPath = path begin pubspec = YAML.load_file(@pubspecPath) rescue raise 'Read pubspec.yaml failed' end version = pubspec["version"] begin if not version.include? "+" raise end v_sections = version.split("+") @vName = v_sections[0].to_s @vCode = v_sections[1].to_i rescue @noCode = true @vName = version @vCode = 0 end begin if not vName.include? "." raise end vName_sections = @vName.split(".") @vMajor = vName_sections[0].to_i @vMinor = vName_sections[1].to_i if (vName_sections.length() > 2) @vPatch = vName_sections[2].to_i else @vPatch = 0 end rescue @vMajor = @vName.to_i @vMinor = 0 @vPatch = 0 end end |
Instance Attribute Details
#pubspecPath ⇒ Object (readonly)
Returns the value of attribute pubspecPath.
2 3 4 |
# File 'lib/flutter_version_tool.rb', line 2 def pubspecPath @pubspecPath end |
#vCode ⇒ Object (readonly)
Returns the value of attribute vCode.
2 3 4 |
# File 'lib/flutter_version_tool.rb', line 2 def vCode @vCode end |
#vMajor ⇒ Object (readonly)
Returns the value of attribute vMajor.
2 3 4 |
# File 'lib/flutter_version_tool.rb', line 2 def vMajor @vMajor end |
#vMinor ⇒ Object (readonly)
Returns the value of attribute vMinor.
2 3 4 |
# File 'lib/flutter_version_tool.rb', line 2 def vMinor @vMinor end |
#vName ⇒ Object (readonly)
Returns the value of attribute vName.
2 3 4 |
# File 'lib/flutter_version_tool.rb', line 2 def vName @vName end |
#vPatch ⇒ Object (readonly)
Returns the value of attribute vPatch.
2 3 4 |
# File 'lib/flutter_version_tool.rb', line 2 def vPatch @vPatch end |
Instance Method Details
#bumpVersionCode(increment = 1) ⇒ Object
63 64 65 66 |
# File 'lib/flutter_version_tool.rb', line 63 def bumpVersionCode(increment = 1) @vCode= @vCode+increment commitChanges end |
#bumpVersionName(level = "major", increment) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/flutter_version_tool.rb', line 68 def bumpVersionName(level = "major", increment) case level when "major" @vMajor=@vMajor+increment @vMinor=0 @vPatch=0 puts "Bumping major" when "minor" @vMinor=@vMinor+increment @vPatch=0 puts "Bumping minor" when "patch" @vPatch=@vPatch+increment puts "Bumping patch" else puts "Nope" end commitChanges end |
#changeVersionCode(p_code) ⇒ Object
58 59 60 61 |
# File 'lib/flutter_version_tool.rb', line 58 def changeVersionCode(p_code) @vCode=p_code.to_i commitChanges end |
#vFull ⇒ Object
4 5 6 |
# File 'lib/flutter_version_tool.rb', line 4 def vFull return "#{@vMajor.to_s}.#{@vMinor.to_s}.#{@vPatch.to_s}+#{@vCode.to_s}" end |