update_plist_build_version 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +4 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/README.md +74 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/bin/update_plist_build_version +49 -0
- data/lib/update_plist_build_version.rb +6 -0
- data/lib/update_plist_build_version/runner.rb +84 -0
- data/lib/update_plist_build_version/version.rb +3 -0
- data/sample/info.plist +40 -0
- data/update_plist_build_version.gemspec +24 -0
- metadata +101 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8f5d399c1846c9d2ce7a9a9609a7d80ece2d86a7
|
4
|
+
data.tar.gz: a0331b1af35ab8ad54ef532511fee51742eb4c4e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2e0f66649549dc8b242bdf32037e0bb3e4e466ee194ffc162c143c0e203a8c31015e5cd8fb04ef0a76b8a8721e1a89643dd188d9eff5a5588015e8ba05699f63
|
7
|
+
data.tar.gz: 631811034f38f58142d45aa4d778d7a3c7280232ad3ab330f5d4d570528ae3e736d79383a2b260e469228cb70f572b0da803e5a6a20201778caa9cfefa0dcda3
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at hiroe.orz@gmail.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# UpdatePlistBuildVersion
|
2
|
+
|
3
|
+
XCodeプロジェクトに含まれる`info.plist`中のバージョン番号をインクリメントするスクリプト。
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
$ cd /path/to/update_plist_build_version
|
8
|
+
$ bundle install (or $ bundle install --path=.bundle)
|
9
|
+
$ bundle exec rake build
|
10
|
+
$ sudo gem install pkg/update_plist_build_version-0.0.1.gem
|
11
|
+
|
12
|
+
## Usage
|
13
|
+
|
14
|
+
入力ファイル、出力ファイルのパスは環境変数とコマンドライン引数の両方から与えられます。
|
15
|
+
出力ファイルパスを指定しなかった場合は入力ファイルを上書きします。
|
16
|
+
|
17
|
+
|
18
|
+
### パスを環境変数で与える場合
|
19
|
+
|
20
|
+
パスを環境変数で与える場合は環境変数 `INFO_PLIST_PATH` にパスを与えた上でスクリプトをコマンドライン引数なしで実行してください。
|
21
|
+
|
22
|
+
$ export INFO_PLIST_PATH=/path/to/info.plist
|
23
|
+
$ bundle exec update_plist_build_version
|
24
|
+
|
25
|
+
### パスをコマンドライン引数で与える場合
|
26
|
+
|
27
|
+
読み込みファイルと書き出しファイルが同じ場合は読み込みファイルのみ指定すれば、そのファイルを上書きします。
|
28
|
+
|
29
|
+
$ bundle exec update_plist_build_version --src_file=/path/to/info.plist
|
30
|
+
|
31
|
+
読み込みファイルと書き出しファイルが別の場合はそれぞれ個別に指定します。
|
32
|
+
|
33
|
+
$ bundle exec update_plist_build_version --src_file=/path/to/info.plist --dst_file=/path/to/new_info.plist
|
34
|
+
|
35
|
+
|
36
|
+
### 既存のスクリプト内にimportしてライブラリとして使用する場合
|
37
|
+
|
38
|
+
既存のスクリプト内で使用する場合は下記のようにしてください。
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
require "update_plist_build_version"
|
42
|
+
|
43
|
+
updater = UpdatePlistBuildVersion::Runner.new(src_file:"/path/to/info.plist")
|
44
|
+
updater.run
|
45
|
+
```
|
46
|
+
|
47
|
+
"/path/to/info.plist" の部分は実際のファイルの相対パスまたは絶対パスを指定してください。
|
48
|
+
インクリメント処理はrunメソッドを実行した時点で行われます。
|
49
|
+
|
50
|
+
もしも読み込みファイルと書き出しファイルが異なる場合は以下のように書き出しファイルを指定してください。
|
51
|
+
最初の例のように書き出しファイルのパスを指定しなかった場合は元のファイルを上書きします。
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
require "update_plist_build_version"
|
55
|
+
|
56
|
+
updater = UpdatePlistBuildVersion::Runner.new(src_file:"/path/to/info.plist", dst_file:"/path/to/info2.plist")
|
57
|
+
updater.run
|
58
|
+
```
|
59
|
+
|
60
|
+
環境変数で指定した上で既存のスクリプト内で使用する場合は、上記のファイルパス指定の部分を環境変数からとってくるようにします。
|
61
|
+
例として環境変数 `INFO_PLIST_PATH` で `info.plist` へのパスを指定する場合は、
|
62
|
+
|
63
|
+
スクリプト実行前に環境変数を設定
|
64
|
+
|
65
|
+
$ export INFO_PLIST_PATH=/path/to/info.plist
|
66
|
+
|
67
|
+
そして、下記のように実装し、実行します。
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
require "update_plist_build_version"
|
71
|
+
|
72
|
+
updater = UpdatePlistBuildVersion::Runner.new(src_file:ENV["INFO_PLIST_PATH"])
|
73
|
+
updater.run
|
74
|
+
```
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "update_plist_build_version"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
require "optparse"
|
5
|
+
require "update_plist_build_version"
|
6
|
+
|
7
|
+
module UpdatePlistBuildVersion
|
8
|
+
class Main
|
9
|
+
|
10
|
+
def start
|
11
|
+
opts = parse_opts(ARGV)
|
12
|
+
runner = Runner.new(opts)
|
13
|
+
runner.run
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
###
|
19
|
+
# コマンドライン引数をパースします。
|
20
|
+
# 入力ファイルと出力ファイルは同じファイルでも別ファイルでも構いません。
|
21
|
+
# 環境変数 INFO_PLIST_PATH を入出力ファイルのデフォルトのパスとして使用します。
|
22
|
+
def parse_opts(argv)
|
23
|
+
opts = {}
|
24
|
+
|
25
|
+
opt = OptionParser.new{|opt|
|
26
|
+
opt.banner = "Usage #{$0} [options]"
|
27
|
+
opt.separator "Options:"
|
28
|
+
|
29
|
+
opts[:src_file] = ENV["INFO_PLIST_PATH"]
|
30
|
+
opt.on("-s", "--src_file STR",
|
31
|
+
"input xml file path"){|s|
|
32
|
+
opts[:src_file] = s
|
33
|
+
}
|
34
|
+
|
35
|
+
opts[:dst_file] = ENV["INFO_PLIST_PATH"]
|
36
|
+
opt.on("-o", "--dst_file STR",
|
37
|
+
"output xml file path"){|s|
|
38
|
+
opts[:dst_file] = s
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
opt.parse(argv)
|
43
|
+
return opts
|
44
|
+
end
|
45
|
+
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
UpdatePlistBuildVersion::Main.new.start
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require "rexml/document"
|
3
|
+
|
4
|
+
module UpdatePlistBuildVersion
|
5
|
+
class Runner
|
6
|
+
|
7
|
+
attr_accessor :src_path, :dst_path, :today
|
8
|
+
|
9
|
+
def initialize(opts)
|
10
|
+
@src_path = opts[:src_file] || (raise ArgumentError.new("Source file path required!"))
|
11
|
+
check_src_file(@src_path)
|
12
|
+
@dst_path = opts[:dst_file] || @src_path
|
13
|
+
@xml = REXML::Document.new(File.open(@src_path))
|
14
|
+
@today = Time.now
|
15
|
+
end
|
16
|
+
|
17
|
+
###
|
18
|
+
# バージョンのインクリメント処理を開始します.
|
19
|
+
def run
|
20
|
+
pos = get_version_position(@xml)
|
21
|
+
version = @xml.elements["plist/dict/string[#{pos}]"].text
|
22
|
+
date,index = version.split(/\./)
|
23
|
+
|
24
|
+
next_version = if today?(date)
|
25
|
+
"#{date}.#{index.to_i + 1}"
|
26
|
+
else
|
27
|
+
"#{today_str}.0"
|
28
|
+
end
|
29
|
+
|
30
|
+
@xml.elements["plist/dict/string[#{pos}]"].text = next_version
|
31
|
+
write(@xml)
|
32
|
+
return next_version, @xml
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
###
|
38
|
+
# XML中でのバージョン番号の位置を返します。
|
39
|
+
# 存在しなければArgumentErrorをraiseします。
|
40
|
+
def get_version_position(xml)
|
41
|
+
pos = 0
|
42
|
+
|
43
|
+
xml.elements["plist/dict"].each do |dict|
|
44
|
+
if dict.class == REXML::Element and dict.name == "key"
|
45
|
+
pos += 1
|
46
|
+
return pos if dict.text == "CFBundleVersion"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
raise ArgumentError.new("CFBundleVersion not found.")
|
51
|
+
end
|
52
|
+
|
53
|
+
###
|
54
|
+
# 本日を示す文字列を返します。
|
55
|
+
def today_str
|
56
|
+
@today.strftime("%Y%m%d")
|
57
|
+
end
|
58
|
+
|
59
|
+
###
|
60
|
+
# info.plist中のバージョンに含まれる日付が本日ならtrueを返します。
|
61
|
+
def today?(date_str)
|
62
|
+
@today.strftime("%Y%m%d") == date_str
|
63
|
+
end
|
64
|
+
|
65
|
+
###
|
66
|
+
# 指定の出力先ファイルへ書き出します。
|
67
|
+
# XMLの正しさには関係ありませんが、<plist 前に改行入れるのと
|
68
|
+
# シングルクォーテーションをダブルクォーテーションに置き換えて、元のファイルに合わせておきます。
|
69
|
+
def write(xml)
|
70
|
+
File.open(@dst_path, "w") do |f|
|
71
|
+
f.write(xml.to_s.sub(/\<plist/, "\n<plist").gsub(/\'/, "\""))
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
###
|
76
|
+
# info.plistが指定の位置に存在しなければArgumentErrorをraiseします。
|
77
|
+
def check_src_file(src_path)
|
78
|
+
unless File.exist?(src_path)
|
79
|
+
raise ArgumentError.new("XML file not exist: #{src_path}")
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
end
|
84
|
+
end
|
data/sample/info.plist
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
+
<plist version="1.0">
|
4
|
+
<dict>
|
5
|
+
<key>CFBundleDevelopmentRegion</key>
|
6
|
+
<string>en</string>
|
7
|
+
<key>CFBundleExecutable</key>
|
8
|
+
<string>$(EXECUTABLE_NAME)</string>
|
9
|
+
<key>CFBundleIdentifier</key>
|
10
|
+
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
11
|
+
<key>CFBundleInfoDictionaryVersion</key>
|
12
|
+
<string>6.0</string>
|
13
|
+
<key>CFBundleName</key>
|
14
|
+
<string>$(PRODUCT_NAME)</string>
|
15
|
+
<key>CFBundlePackageType</key>
|
16
|
+
<string>APPL</string>
|
17
|
+
<key>CFBundleShortVersionString</key>
|
18
|
+
<string>1.0</string>
|
19
|
+
<key>CFBundleSignature</key>
|
20
|
+
<string>????</string>
|
21
|
+
<key>CFBundleVersion</key>
|
22
|
+
<string>20151214.0</string>
|
23
|
+
<key>LSRequiresIPhoneOS</key>
|
24
|
+
<true/>
|
25
|
+
<key>UILaunchStoryboardName</key>
|
26
|
+
<string>LaunchScreen</string>
|
27
|
+
<key>UIMainStoryboardFile</key>
|
28
|
+
<string>Main</string>
|
29
|
+
<key>UIRequiredDeviceCapabilities</key>
|
30
|
+
<array>
|
31
|
+
<string>armv7</string>
|
32
|
+
</array>
|
33
|
+
<key>UISupportedInterfaceOrientations</key>
|
34
|
+
<array>
|
35
|
+
<string>UIInterfaceOrientationPortrait</string>
|
36
|
+
<string>UIInterfaceOrientationLandscapeLeft</string>
|
37
|
+
<string>UIInterfaceOrientationLandscapeRight</string>
|
38
|
+
</array>
|
39
|
+
</dict>
|
40
|
+
</plist>
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'update_plist_build_version/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "update_plist_build_version"
|
8
|
+
spec.version = UpdatePlistBuildVersion::VERSION
|
9
|
+
spec.authors = ["Shin Hiroe"]
|
10
|
+
spec.email = ["hiroe.orz@gmail.com"]
|
11
|
+
|
12
|
+
spec.description = %q{Increment Version of info.plist}
|
13
|
+
spec.summary = %q{Increment Version of info.plist}
|
14
|
+
spec.homepage = ""
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = 'bin'
|
18
|
+
spec.executables = ['update_plist_build_version']
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: update_plist_build_version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Shin Hiroe
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-02-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.11'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.11'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: Increment Version of info.plist
|
56
|
+
email:
|
57
|
+
- hiroe.orz@gmail.com
|
58
|
+
executables:
|
59
|
+
- update_plist_build_version
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- ".rspec"
|
65
|
+
- ".travis.yml"
|
66
|
+
- CODE_OF_CONDUCT.md
|
67
|
+
- Gemfile
|
68
|
+
- README.md
|
69
|
+
- Rakefile
|
70
|
+
- bin/console
|
71
|
+
- bin/setup
|
72
|
+
- bin/update_plist_build_version
|
73
|
+
- lib/update_plist_build_version.rb
|
74
|
+
- lib/update_plist_build_version/runner.rb
|
75
|
+
- lib/update_plist_build_version/version.rb
|
76
|
+
- sample/info.plist
|
77
|
+
- update_plist_build_version.gemspec
|
78
|
+
homepage: ''
|
79
|
+
licenses: []
|
80
|
+
metadata: {}
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options: []
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
requirements: []
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 2.5.1
|
98
|
+
signing_key:
|
99
|
+
specification_version: 4
|
100
|
+
summary: Increment Version of info.plist
|
101
|
+
test_files: []
|