flutter_version_tool 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/flutter_version_tool.rb +88 -0
  3. metadata +43 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: fbad9eef2f7d73d4b77b3e7fa7ae33285be8b677c9e81dde913fe69eceaf041a
4
+ data.tar.gz: 64df2ffc684d9115e6672181d2d18fd4b0ce2ccf3790593782b7b5fb8c6cacde
5
+ SHA512:
6
+ metadata.gz: c94f632a80b9787e6cc4596961c68ba48d906a9493f9ae41d59e629a26af2f9febf8490d633bc98e2a6e47acff7d32e43c114145f84ecc889a82e7b08a96cd28
7
+ data.tar.gz: dfdb53d32f0c66ac0da153c02379149d5fdad6cf606e3063ac79696bc282a774bbd1181ab44ecaef7556c33e7cd49b12a52e4c3400a0a3368802e797cd5ba013
@@ -0,0 +1,88 @@
1
+ class FlutterVersionTool
2
+ attr_reader :pubspecPath, :vName, :vCode, :vMajor, :vMinor, :vPatch
3
+
4
+ def vFull
5
+ return "#{@vMajor.to_s}.#{@vMinor.to_s}.#{@vPatch.to_s}+#{@vCode.to_s}"
6
+ end
7
+
8
+ def initialize(path)
9
+ @pubspecPath = path
10
+
11
+ begin
12
+ pubspec = YAML.load_file(@pubspecPath)
13
+ rescue
14
+ raise 'Read pubspec.yaml failed'
15
+ end
16
+
17
+ version = pubspec["version"]
18
+
19
+ begin
20
+ if not version.include? "+"
21
+ raise
22
+ end
23
+ v_sections = version.split("+")
24
+ @vName = v_sections[0].to_s
25
+ @vCode = v_sections[1].to_i
26
+ rescue
27
+ @noCode = true
28
+ @vName = version
29
+ @vCode = 0
30
+ end
31
+
32
+ begin
33
+ if not vName.include? "."
34
+ raise
35
+ end
36
+ vName_sections = @vName.split(".")
37
+ @vMajor = vName_sections[0].to_i
38
+ @vMinor = vName_sections[1].to_i
39
+ if (vName_sections.length() > 2)
40
+ @vPatch = vName_sections[2].to_i
41
+ else
42
+ @vPatch = 0
43
+ end
44
+ rescue
45
+ @vMajor = @vName.to_i
46
+ @vMinor = 0
47
+ @vPatch = 0
48
+ end
49
+
50
+ end
51
+
52
+ private def commitChanges
53
+ fileString = File.read(@pubspecPath)
54
+ newFileString = fileString.gsub(/^version:\s.+/, "version: "+self.vFull)
55
+ File.write(@pubspecPath, newFileString)
56
+ end
57
+
58
+ def changeVersionCode(p_code)
59
+ @vCode=p_code.to_i
60
+ commitChanges
61
+ end
62
+
63
+ def bumpVersionCode(increment = 1)
64
+ @vCode= @vCode+increment
65
+ commitChanges
66
+ end
67
+
68
+ def bumpVersionName(level = "major", increment)
69
+ case level
70
+ when "major"
71
+ @vMajor=@vMajor+increment
72
+ @vMinor=0
73
+ @vPatch=0
74
+ puts "Bumping major"
75
+ when "minor"
76
+ @vMinor=@vMinor+increment
77
+ @vPatch=0
78
+ puts "Bumping minor"
79
+ when "patch"
80
+ @vPatch=@vPatch+increment
81
+ puts "Bumping patch"
82
+ else puts "Nope"
83
+ end
84
+ commitChanges
85
+ end
86
+
87
+ end
88
+
metadata ADDED
@@ -0,0 +1,43 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: flutter_version_tool
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Rim Ganiev
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-01-18 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A tool for maintaning Flutter project versioning
14
+ email: cj_rimix@rambler.ru
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/flutter_version_tool.rb
20
+ homepage: https://rubygems.org/gems/flutter_version_tool
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubygems_version: 3.3.7
40
+ signing_key:
41
+ specification_version: 4
42
+ summary: Flutter Version Tool
43
+ test_files: []