fastlane-plugin-get_version_code 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d24c1039b5cc18c0e7ce312327c8de63ff1635e5
4
- data.tar.gz: cde91ae7176e3023951496ce2764024ab551eaec
3
+ metadata.gz: 9da0361fa95dde4ffc14be481ef6661a83e8a974
4
+ data.tar.gz: 3864980ae24b4051094b36c6cd0e2c52c15bb86e
5
5
  SHA512:
6
- metadata.gz: 77a5af14fbe207a7f8f4b7226f9425f587cb4237e4393b22a9f9f53be8938143239a60b2170e4297f8c4dce694fa4f746f758c892216aee1418091984e0c6c48
7
- data.tar.gz: a81f7c8ca3a1900252788e74d46f0e79633ebd5fb556b740ed2b1240214983bbf35000e1a0dd83b16095a8d4f1711d4b83fe4ba47028b926e8719963fd3b9fa1
6
+ metadata.gz: 264f1e52ff9031591073f053f2e3297646ff54cfea894917734346489e7d27f6c7954bca511a8f98b3ea44b87b4126f748fcba2bbb67ef041202a23c0f1f2219
7
+ data.tar.gz: 3e18ef36164dc2f7216a51564749a44cfe0f020123790b14ab93a0a1e7aa40dbea4270ef0abda575444b2cdba018b2d1d2133b015b5ebc31d33d3a5bc7cca6a2
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2016 Jérémy TOUDIC <jeremy.toudic@aufeminin.com>
3
+ Copyright (c) 2016 Jérémy TOUDIC <jeremy.toudic@gmail.com>
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -2,25 +2,22 @@ module Fastlane
2
2
  module Actions
3
3
  class GetVersionCodeAction < Action
4
4
  def self.run(params)
5
- app_folder_name ||= params[:app_folder_name]
6
- UI.message("The get_version_code plugin is looking inside your project folder (#{app_folder_name})!")
7
-
8
5
  version_code = "0"
9
6
 
10
- Dir.glob("**/#{app_folder_name}/build.gradle") do |path|
11
- begin
12
- file = File.new(path, "r")
13
- while (line = file.gets)
14
- if line.include? "versionCode"
15
- versionComponents = line.strip.split(' ')
16
- version_code = versionComponents[1].tr("\"","")
17
- break
18
- end
19
- end
20
- file.close
21
- rescue => err
22
- UI.error("An exception occured while reading gradle file: #{err}")
23
- err
7
+ constant_name ||= params[:ext_constant_name]
8
+ gradle_file_path ||= params[:gradle_file_path]
9
+ if gradle_file_path != nil
10
+ UI.message("The get_version_code plugin will use gradle file at (#{gradle_file_path})!")
11
+ version_code = getVersionCode(gradle_file_path, constant_name)
12
+ else
13
+ app_folder_name ||= params[:app_folder_name]
14
+ UI.message("The get_version_code plugin is looking inside your project folder (#{app_folder_name})!")
15
+
16
+ #temp_file = Tempfile.new('fastlaneIncrementVersionCode')
17
+ #foundVersionCode = "false"
18
+ Dir.glob("**/#{app_folder_name}/build.gradle") do |path|
19
+ UI.message(" -> Found a build.gradle file at path: (#{path})!")
20
+ version_code = getVersionCode(path, constant_name)
24
21
  end
25
22
  end
26
23
 
@@ -35,12 +32,35 @@ module Fastlane
35
32
  return version_code
36
33
  end
37
34
 
35
+ def self.getVersionCode(path, constant_name)
36
+ version_code = "0"
37
+ if !File.file?(path)
38
+ UI.message(" -> No file exist at path: (#{path})!")
39
+ return version_code
40
+ end
41
+ begin
42
+ file = File.new(path, "r")
43
+ while (line = file.gets)
44
+ if line.include? constant_name
45
+ versionComponents = line.strip.split(' ')
46
+ version_code = versionComponents[versionComponents.length - 1].tr("\"","")
47
+ break
48
+ end
49
+ end
50
+ file.close
51
+ rescue => err
52
+ UI.error("An exception occured while readinf gradle file: #{err}")
53
+ err
54
+ end
55
+ return version_code
56
+ end
57
+
38
58
  def self.description
39
59
  "Get the version code of an Android project. This action will return the version code of your project according to the one set in your build.gradle file"
40
60
  end
41
61
 
42
62
  def self.authors
43
- ["Jérémy TOUDIC"]
63
+ ["Jems"]
44
64
  end
45
65
 
46
66
  def self.available_options
@@ -50,7 +70,19 @@ module Fastlane
50
70
  description: "The name of the application source folder in the Android project (default: app)",
51
71
  optional: true,
52
72
  type: String,
53
- default_value:"app")
73
+ default_value:"app"),
74
+ FastlaneCore::ConfigItem.new(key: :gradle_file_path,
75
+ env_name: "GETVERSIONCODE_GRADLE_FILE_PATH",
76
+ description: "The relative path to the gradle file containing the version code parameter (default:app/build.gradle)",
77
+ optional: true,
78
+ type: String,
79
+ default_value: nil),
80
+ FastlaneCore::ConfigItem.new(key: :ext_constant_name,
81
+ env_name: "GETVERSIONCODE_EXT_CONSTANT_NAME",
82
+ description: "If the version code is set in an ext constant, specify the constant name (optional)",
83
+ optional: true,
84
+ type: String,
85
+ default_value: "versionCode")
54
86
  ]
55
87
  end
56
88
 
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module GetVersionCode
3
- VERSION = "0.1.2"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-get_version_code
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
- - Jérémy TOUDIC
7
+ - Jems
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-02 00:00:00.000000000 Z
11
+ date: 2017-05-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry