xsort 1.0.0
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 +11 -0
- data/.rspec +3 -0
- data/.travis.yml +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +21 -0
- data/README.md +135 -0
- data/Rakefile +10 -0
- data/bin/xsort +5 -0
- data/lib/xsort.rb +42 -0
- data/lib/xsort/Emurate.rb +22 -0
- data/lib/xsort/option.rb +57 -0
- data/lib/xsort/version.rb +3 -0
- data/lib/xsort/xcodeproj/pbxproj/pbxobject/PbxSort.rb +77 -0
- data/lib/xsort/xcodeproj/pbxproj/pbxobject/PbxWrite.rb +67 -0
- data/lib/xsort/xcodeproj/pbxproj/pbxobject/Pbxproj.rb +198 -0
- data/xsort.gemspec +27 -0
- metadata +104 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 47a0f232dedfe9550256647514d43e14901211cf787c269469cb3649f745db25
|
|
4
|
+
data.tar.gz: b1f666c504e5845a698c597bff661747409e4a20454107a976a183dcb1ce752d
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: ae1d2ef5caf86be2df99a69aa7157cdd34bf5140bcf035f2bd9b8514621e05cb60b9c1f47d44e1e91916cd2a6dff49419dcabbe4cb525d9854b85e17a4085ebe
|
|
7
|
+
data.tar.gz: aeb2b1b2247d499523c8d9564afe9548037a76ddb66ff5e7e457b47bd2f4830f540949fa1cfd58b2f785dfa3fdfb5a05239e30e49abf3f15ce33b44a3a265caa
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
|
10
|
+
orientation.
|
|
11
|
+
|
|
12
|
+
## Our Standards
|
|
13
|
+
|
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
|
15
|
+
include:
|
|
16
|
+
|
|
17
|
+
* Using welcoming and inclusive language
|
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
|
19
|
+
* Gracefully accepting constructive criticism
|
|
20
|
+
* Focusing on what is best for the community
|
|
21
|
+
* Showing empathy towards other community members
|
|
22
|
+
|
|
23
|
+
Examples of unacceptable behavior by participants include:
|
|
24
|
+
|
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
|
26
|
+
advances
|
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
|
28
|
+
* Public or private harassment
|
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
|
30
|
+
address, without explicit permission
|
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
32
|
+
professional setting
|
|
33
|
+
|
|
34
|
+
## Our Responsibilities
|
|
35
|
+
|
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
|
38
|
+
response to any instances of unacceptable behavior.
|
|
39
|
+
|
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
|
44
|
+
threatening, offensive, or harmful.
|
|
45
|
+
|
|
46
|
+
## Scope
|
|
47
|
+
|
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
|
49
|
+
when an individual is representing the project or its community. Examples of
|
|
50
|
+
representing a project or community include using an official project e-mail
|
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
|
53
|
+
further defined and clarified by project maintainers.
|
|
54
|
+
|
|
55
|
+
## Enforcement
|
|
56
|
+
|
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
58
|
+
reported by contacting the project team at jam330157@gmail.com. All
|
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
|
63
|
+
|
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
|
66
|
+
members of the project's leadership.
|
|
67
|
+
|
|
68
|
+
## Attribution
|
|
69
|
+
|
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
|
71
|
+
available at [http://contributor-covenant.org/version/1/4][version]
|
|
72
|
+
|
|
73
|
+
[homepage]: http://contributor-covenant.org
|
|
74
|
+
[version]: http://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 keisuke
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
# xsort
|
|
2
|
+
|
|
3
|
+
[](https://twitter.com/O_Linker_Error)
|
|
4
|
+
[](https://www.ruby-lang.org/ja/)
|
|
5
|
+
[](https://github.com/keisukeYamagishi/xsort/blob/master/LICENSE)
|
|
6
|
+
|
|
7
|
+
# Build
|
|
8
|
+
|OS |Result |
|
|
9
|
+
|:---------------|:----------------|
|
|
10
|
+
| ***Linux*** |[](https://travis-ci.org/keisukeYamagishi/xsort)
|
|
11
|
+
|
|
12
|
+
## Overview
|
|
13
|
+
|
|
14
|
+
Sort the file tree next to Xcode by file name.
|
|
15
|
+
|
|
16
|
+
## git clone
|
|
17
|
+
|
|
18
|
+
***Via SSH***: For those who plan on regularly making direct commits, cloning over SSH may provide a better experience (which requires uploading SSH keys to GitHub):
|
|
19
|
+
|
|
20
|
+
```
|
|
21
|
+
$ mkdir gitrepo
|
|
22
|
+
|
|
23
|
+
$ cd gitrepo
|
|
24
|
+
|
|
25
|
+
$ git clone git@github.com:keisukeYamagishi/xsort.git
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
***Via https***: For those checking out sources as read-only, HTTPS works best:
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
$ mkdir gitrepo
|
|
33
|
+
|
|
34
|
+
$ cd gitrepo
|
|
35
|
+
|
|
36
|
+
$ git clone https://github.com/keisukeYamagishi/xsort.git
|
|
37
|
+
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Usage
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Usage: xsort [-v] [<path>] [-o]
|
|
45
|
+
These are common detect commands used in various situations:
|
|
46
|
+
xsort version: 1.1.1
|
|
47
|
+
option:
|
|
48
|
+
-v: display xsort version number
|
|
49
|
+
-o: output result
|
|
50
|
+
-r: Just extracting output.pbxproj will not write to pbxproj of Xcode project
|
|
51
|
+
|
|
52
|
+
Regars !
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Run
|
|
57
|
+
|
|
58
|
+
⚠️Please do version control and back up before doing.⚠️
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
xsort ./xsort ./project.pbxproj
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
this will sort files in the Xcode directory
|
|
65
|
+
|
|
66
|
+
Output.pbxproj file will be output so copy and paste it.
|
|
67
|
+
|
|
68
|
+
## Use it
|
|
69
|
+
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
./xsort path_to_project.pbxproj
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## option
|
|
77
|
+
|
|
78
|
+
***Display result log***
|
|
79
|
+
|
|
80
|
+
if you want to display result log
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
./xsort ./path/to/project.pbxproj -o
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
result
|
|
87
|
+
```
|
|
88
|
+
// !$*UTF8*$!
|
|
89
|
+
{
|
|
90
|
+
archiveVersion = 1;
|
|
91
|
+
classes = {
|
|
92
|
+
};
|
|
93
|
+
objectVersion = 46;
|
|
94
|
+
objects = {
|
|
95
|
+
|
|
96
|
+
/* Begin PBXBuildFile section */
|
|
97
|
+
BA218946A1F8E64C27B613CD /* Pods_Breris.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F0B2DD76AFE7C2922950BB5D /* Pods_Breris.framework */; };
|
|
98
|
+
C704FFE71FB0A67D0043E7BD /* bggfg.jpg in Resources */ = {isa = PBXBuildFile; fileRef = C704FFE61FB0A67D0043E7BD /* bggfg.jpg */; };
|
|
99
|
+
C704FFE91FB0A68C0043E7BD /* world.jpg in Resources */ = {isa = PBXBuildFile; fileRef = C704FFE81FB0A68C0043E7BD /* world.jpg */; };
|
|
100
|
+
C7080F921FFC317F0077A4AD /* TwitterAuth.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7080F911FFC317F0077A4AD /* TwitterAuth.swift */; };
|
|
101
|
+
C7080FB21FFC97F60077A4AD /* Capture.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7080FB11FFC97F60077A4AD /* Capture.swift */; };
|
|
102
|
+
C7080FC81FFE49A30077A4AD /* checkmark-flat.png in Resources */ = {isa = PBXBuildFile; fileRef = C7080FC71FFE49A30077A4AD /* checkmark-flat.png */; };
|
|
103
|
+
C7080FCA1FFE4A0B0077A4AD /* TwtterStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7080FC91FFE4A0B0077A4AD /* TwtterStatus.swift */; };
|
|
104
|
+
C7080FCC1FFE4A200077A4AD /* TwitterStatus.xib in Resources */ = {isa = PBXBuildFile; fileRef = C7080FCB1FFE4A200077A4AD /* TwitterStatus.xib */; };
|
|
105
|
+
C7080FCE1
|
|
106
|
+
....... any
|
|
107
|
+
..... any
|
|
108
|
+
... any
|
|
109
|
+
.. any
|
|
110
|
+
any
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
**Looking at Xcode**
|
|
114
|
+
|
|
115
|
+

|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
***Use -r options***
|
|
119
|
+
|
|
120
|
+
Do not overwrite pbxproj of Xcode project and output.pbxproj.
|
|
121
|
+
You can test the output pbxproj file.
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
./xsort ../App/App.xcodeproj -r
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
***Display version number***
|
|
130
|
+
|
|
131
|
+
```
|
|
132
|
+
->> ./xsort -v
|
|
133
|
+
|
|
134
|
+
Version: 1.0.1
|
|
135
|
+
```
|
data/Rakefile
ADDED
data/bin/xsort
ADDED
data/lib/xsort.rb
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
require 'bundler/setup'
|
|
2
|
+
require "xsort/xcodeproj/pbxproj/pbxobject/Pbxproj"
|
|
3
|
+
require "xsort/xcodeproj/pbxproj/pbxobject/PbxSort"
|
|
4
|
+
require "xsort/xcodeproj/pbxproj/pbxobject/PbxWrite"
|
|
5
|
+
require "xsort/version"
|
|
6
|
+
require "xsort/option"
|
|
7
|
+
|
|
8
|
+
module Xsort
|
|
9
|
+
class XsortMain
|
|
10
|
+
def initialize (argv)
|
|
11
|
+
@option = Option.new(argv)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def execute
|
|
15
|
+
if @option.options.length == 0 && @option.path.length == 0
|
|
16
|
+
puts "Usage: xsort [-v] [<path>] [-o] "
|
|
17
|
+
puts "These are common detect commands used in various situations:"
|
|
18
|
+
puts "xsort version: #{Xsort::VERSION}"
|
|
19
|
+
puts "option:"
|
|
20
|
+
puts "-v: display xsort version number"
|
|
21
|
+
puts "-o: output result"
|
|
22
|
+
puts "-r: Just extracting output.pbxproj will not write to pbxproj of Xcode project"
|
|
23
|
+
puts "\n"
|
|
24
|
+
puts "Regars !"
|
|
25
|
+
elsif @option.options.length == 1 && @option.options[0] == "-v"
|
|
26
|
+
puts "Version: #{Xsort::VERSION}"
|
|
27
|
+
elsif @option.path.index("project.pbxproj")
|
|
28
|
+
|
|
29
|
+
pbx = Xcodeproj::Pbxproj::PbxObject::Pbxproj.new(@option.path,@option.isOut)
|
|
30
|
+
pbx.parse()
|
|
31
|
+
sort = Xcodeproj::Pbxproj::PbxObject::PbxSort.new(pbx.pbxGroups)
|
|
32
|
+
s = sort.psort
|
|
33
|
+
write = Xcodeproj::Pbxproj::PbxObject::PbxWrite.new(@option.path,s,@option.isOut, @option.notOverWrite)
|
|
34
|
+
write.overWrite
|
|
35
|
+
else
|
|
36
|
+
puts "(*_*).oO not pbxproj file"
|
|
37
|
+
puts "must select pbxproj file"
|
|
38
|
+
puts "($_$).oO omg"
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
class Emurate
|
|
2
|
+
|
|
3
|
+
def self.emurates(chars)
|
|
4
|
+
splits = chars.split(" ")
|
|
5
|
+
isName = false
|
|
6
|
+
splits.each { |char|
|
|
7
|
+
if char == "*/"
|
|
8
|
+
isName = false
|
|
9
|
+
end
|
|
10
|
+
if isName == true
|
|
11
|
+
return char
|
|
12
|
+
end
|
|
13
|
+
if char == "/*"
|
|
14
|
+
isName = true
|
|
15
|
+
end
|
|
16
|
+
}
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.emurateUUID(char)
|
|
20
|
+
return char.split(" ").first
|
|
21
|
+
end
|
|
22
|
+
end
|
data/lib/xsort/option.rb
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
class Option
|
|
2
|
+
|
|
3
|
+
def initialize(argv)
|
|
4
|
+
@isOut = false
|
|
5
|
+
argvs = Array.new
|
|
6
|
+
@notOverWrite = false
|
|
7
|
+
|
|
8
|
+
argv.each_with_index do |arg, i|
|
|
9
|
+
argvs.push(arg)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
@options = Array.new
|
|
13
|
+
@path = ""
|
|
14
|
+
argvs.each{|argv|
|
|
15
|
+
if argv.index("-")
|
|
16
|
+
|
|
17
|
+
if argv == "-o"
|
|
18
|
+
@isOut = true
|
|
19
|
+
elsif argv == "-r"
|
|
20
|
+
@notOverWrite = true
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
@options.push(argv)
|
|
24
|
+
else
|
|
25
|
+
@path = createPath(argv)
|
|
26
|
+
end
|
|
27
|
+
}
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def createPath(path)
|
|
31
|
+
if path.index(".pbxproj")
|
|
32
|
+
return path
|
|
33
|
+
else
|
|
34
|
+
pbxproj = path.dup
|
|
35
|
+
pbxproj << "/project.pbxproj"
|
|
36
|
+
return pbxproj
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def options
|
|
42
|
+
@options
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def path
|
|
46
|
+
@path
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def isOut
|
|
50
|
+
@isOut
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def notOverWrite
|
|
54
|
+
@notOverWrite
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
end
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
module Xcodeproj
|
|
2
|
+
module Pbxproj
|
|
3
|
+
module PbxObject
|
|
4
|
+
class PbxSort
|
|
5
|
+
|
|
6
|
+
def initialize(pbxs)
|
|
7
|
+
@pbxs = pbxs
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def psort
|
|
11
|
+
|
|
12
|
+
sorteds = Array.new
|
|
13
|
+
@pbxs.each{ |pbx|
|
|
14
|
+
# puts "parent PBX"
|
|
15
|
+
# puts pbx.parentName
|
|
16
|
+
# puts pbx.parentUUID
|
|
17
|
+
# puts pbx.parentPbx
|
|
18
|
+
# puts pbx.parentPbx
|
|
19
|
+
# puts pbx.parentName
|
|
20
|
+
# puts pbx.parentUUID
|
|
21
|
+
# ->> puts pbx.pbxBase
|
|
22
|
+
# puts "children"
|
|
23
|
+
|
|
24
|
+
sort = pbx.children.sort{|pbx1, pbx2|
|
|
25
|
+
pbx1.name <=> pbx2.name
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
child = Array.new
|
|
29
|
+
sort.each {|pbx|
|
|
30
|
+
|
|
31
|
+
child.push(pbx.childPbx)
|
|
32
|
+
# puts pbx.uuid
|
|
33
|
+
# puts pbx.name
|
|
34
|
+
# ->> puts pbx.childPbx
|
|
35
|
+
}
|
|
36
|
+
sorteds.push(childrenSort(pbx.pbxBase,child))
|
|
37
|
+
# pbx.children.each {|pbx|
|
|
38
|
+
#
|
|
39
|
+
#
|
|
40
|
+
# # puts pbx.uuid
|
|
41
|
+
# # puts pbx.name
|
|
42
|
+
# puts pbx.childPbx
|
|
43
|
+
# }
|
|
44
|
+
}
|
|
45
|
+
return sorteds
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def childrenSort (children, sort)
|
|
49
|
+
pbx = ""
|
|
50
|
+
pbxSplit = children.split("\n")
|
|
51
|
+
isPbxChild = false
|
|
52
|
+
num = 0
|
|
53
|
+
pbxSplit.each{|pbx_line|
|
|
54
|
+
|
|
55
|
+
if pbx_line.index(");")
|
|
56
|
+
isPbxChild = false
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
if isPbxChild == true
|
|
60
|
+
pbx_line = sort[num]
|
|
61
|
+
num += 1
|
|
62
|
+
else
|
|
63
|
+
pbx_line << "\n"
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# Children
|
|
67
|
+
if pbx_line.index("children = (")
|
|
68
|
+
isPbxChild = true
|
|
69
|
+
end
|
|
70
|
+
pbx << pbx_line
|
|
71
|
+
}
|
|
72
|
+
return pbx
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
module Xcodeproj
|
|
2
|
+
module Pbxproj
|
|
3
|
+
module PbxObject
|
|
4
|
+
|
|
5
|
+
class PbxWrite
|
|
6
|
+
|
|
7
|
+
def initialize(path,pbx, out,write)
|
|
8
|
+
@pbx = pbx
|
|
9
|
+
@isOut = out
|
|
10
|
+
@path = path
|
|
11
|
+
@write = write
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def overWrite
|
|
15
|
+
isPbxGroup = false
|
|
16
|
+
pbxValue = ""
|
|
17
|
+
num = 0
|
|
18
|
+
|
|
19
|
+
begin
|
|
20
|
+
File.open(@path, "r") do |pbx|
|
|
21
|
+
pbx.each_line do |pbx_line|
|
|
22
|
+
|
|
23
|
+
if pbx_line.index("/* End PBXGroup section */")
|
|
24
|
+
sorted = @pbx.join
|
|
25
|
+
sorted << pbx_line
|
|
26
|
+
pbx_line = sorted
|
|
27
|
+
isPbxGroup = false
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
if isPbxGroup == true
|
|
31
|
+
pbx_line = ""
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
if pbx_line.index("/* Begin PBXGroup section */")
|
|
35
|
+
isPbxGroup = true
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
pbxValue << pbx_line
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
if @isOut == true
|
|
43
|
+
puts pbxValue
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
writeFile(pbxValue)
|
|
47
|
+
|
|
48
|
+
rescue IOError => ioerr
|
|
49
|
+
puts "Error #{ioerr.message}"
|
|
50
|
+
rescue SystemCallError => sysCallErr
|
|
51
|
+
puts "Failuer: reason #{sysCallErr.message}"
|
|
52
|
+
puts "The entered path is invalid."
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def writeFile(value)
|
|
57
|
+
if @write == true
|
|
58
|
+
@path = "./output.pbxproj"
|
|
59
|
+
end
|
|
60
|
+
File.open(@path,"w") do |write|
|
|
61
|
+
write.puts(value)
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
module Xcodeproj
|
|
2
|
+
module Pbxproj
|
|
3
|
+
module PbxObject
|
|
4
|
+
class PbxGroup
|
|
5
|
+
|
|
6
|
+
def initialize
|
|
7
|
+
@parentPbx = ""
|
|
8
|
+
@parentName = ""
|
|
9
|
+
@parentUUID = ""
|
|
10
|
+
@pbxBase = ""
|
|
11
|
+
@children = Array.new
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def parentPbx
|
|
15
|
+
@parentPbx
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def parentName
|
|
19
|
+
@parentName
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def parentUUID
|
|
23
|
+
@parentUUID
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def pbxBase
|
|
27
|
+
@pbxBase
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def setParentName(name)
|
|
31
|
+
@parentName = name
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def setParentUUID(uuid)
|
|
35
|
+
@parentUUID = uuid
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def setParentPbx(pbx)
|
|
39
|
+
@parentPbx = pbx
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def setPbxBase(base)
|
|
43
|
+
@pbxBase = base
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def setChildren(pbx)
|
|
47
|
+
@children.push(pbx)
|
|
48
|
+
end
|
|
49
|
+
def children
|
|
50
|
+
@children
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
module Xcodeproj
|
|
58
|
+
module Pbxproj
|
|
59
|
+
module PbxObject
|
|
60
|
+
class PbxChild
|
|
61
|
+
|
|
62
|
+
def initialize(uuid, name, childPbx)
|
|
63
|
+
@uuid = uuid
|
|
64
|
+
@name = name
|
|
65
|
+
@childPbx = childPbx
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def uuid
|
|
69
|
+
@uuid
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def name
|
|
73
|
+
@name
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def childPbx
|
|
77
|
+
@childPbx
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
end
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
module Xcodeproj
|
|
86
|
+
module Pbxproj
|
|
87
|
+
module PbxObject
|
|
88
|
+
class Pbxproj
|
|
89
|
+
|
|
90
|
+
def initialize(path, out)
|
|
91
|
+
@path = path
|
|
92
|
+
@isOut = out
|
|
93
|
+
@pbxGroups = Array.new
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def parse ()
|
|
97
|
+
|
|
98
|
+
isPbxGroup = false
|
|
99
|
+
isPbxOneValue = false
|
|
100
|
+
isPbxChild = false
|
|
101
|
+
pbxValue = ""
|
|
102
|
+
|
|
103
|
+
begin
|
|
104
|
+
File.open(@path, "r") do |pbx|
|
|
105
|
+
pbx.each_line do |pbx_line|
|
|
106
|
+
|
|
107
|
+
if @isOut == true
|
|
108
|
+
puts pbx_line
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
if pbx_line.index("/* End PBXGroup section */")
|
|
112
|
+
isPbxGroup = false
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
# In PBX Group
|
|
116
|
+
if isPbxGroup == true
|
|
117
|
+
|
|
118
|
+
if pbx_line.index(");")
|
|
119
|
+
isPbxChild = false
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
if isPbxChild == true
|
|
123
|
+
name = Emurate.emurates(pbx_line)
|
|
124
|
+
uuid = Emurate.emurateUUID(pbx_line)
|
|
125
|
+
@child = Xcodeproj::Pbxproj::PbxObject::PbxChild.new(uuid,name,pbx_line)
|
|
126
|
+
@group.setChildren(@child)
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
# Children
|
|
130
|
+
if pbx_line.index("children = (")
|
|
131
|
+
isPbxChild = true
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
if pbx_line.index(" = {")
|
|
135
|
+
isPbxOneValue = true
|
|
136
|
+
name = Emurate.emurates(pbx_line)
|
|
137
|
+
uuid = Emurate.emurateUUID(pbx_line)
|
|
138
|
+
@group = Xcodeproj::Pbxproj::PbxObject::PbxGroup.new
|
|
139
|
+
@group.setParentName(name)
|
|
140
|
+
@group.setParentUUID(uuid)
|
|
141
|
+
@group.setParentPbx(pbx_line)
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
if isPbxOneValue == true
|
|
145
|
+
pbxValue << pbx_line
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
if pbx_line.index("};")
|
|
149
|
+
isPbxOneValue = false
|
|
150
|
+
@group.setPbxBase(pbxValue)
|
|
151
|
+
@pbxGroups.push(@group)
|
|
152
|
+
pbxValue = ""
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
if pbx_line.index("/* Begin PBXGroup section */")
|
|
157
|
+
isPbxGroup = true
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
rescue IOError => ioerr
|
|
162
|
+
puts "Error #{ioerr.message}"
|
|
163
|
+
rescue SystemCallError => sysCallErr
|
|
164
|
+
puts "Failuer: reason #{sysCallErr.message}"
|
|
165
|
+
puts "The entered path is invalid."
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
def pbxGroups
|
|
170
|
+
@pbxGroups
|
|
171
|
+
end
|
|
172
|
+
end
|
|
173
|
+
end
|
|
174
|
+
end
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
class Emurate
|
|
178
|
+
|
|
179
|
+
def self.emurates(chars)
|
|
180
|
+
splits = chars.split(" ")
|
|
181
|
+
isName = false
|
|
182
|
+
splits.each { |char|
|
|
183
|
+
if char == "*/"
|
|
184
|
+
isName = false
|
|
185
|
+
end
|
|
186
|
+
if isName == true
|
|
187
|
+
return char
|
|
188
|
+
end
|
|
189
|
+
if char == "/*"
|
|
190
|
+
isName = true
|
|
191
|
+
end
|
|
192
|
+
}
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
def self.emurateUUID(char)
|
|
196
|
+
return char.split(" ").first
|
|
197
|
+
end
|
|
198
|
+
end
|
data/xsort.gemspec
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
3
|
+
require "xsort/version"
|
|
4
|
+
|
|
5
|
+
Gem::Specification.new do |spec|
|
|
6
|
+
spec.name = "xsort"
|
|
7
|
+
spec.version = Xsort::VERSION
|
|
8
|
+
spec.authors = ["keisuke"]
|
|
9
|
+
spec.email = ["jam330157@gmail.com"]
|
|
10
|
+
|
|
11
|
+
spec.summary = %q{Sort by file.}
|
|
12
|
+
spec.description = %q{Sort the file tree next to Xcode by file name.}
|
|
13
|
+
spec.homepage = "https://github.com/keisukeYamagishi/xsort"
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
17
|
+
f.match(%r{^(test|spec|features|bin/console|bin/setup|exe/xsort)/})
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
spec.bindir = "bin"
|
|
21
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
22
|
+
spec.require_paths = ["lib"]
|
|
23
|
+
|
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
26
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
|
27
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: xsort
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- keisuke
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2018-02-03 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.16'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.16'
|
|
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: Sort the file tree next to Xcode by file name.
|
|
56
|
+
email:
|
|
57
|
+
- jam330157@gmail.com
|
|
58
|
+
executables:
|
|
59
|
+
- xsort
|
|
60
|
+
extensions: []
|
|
61
|
+
extra_rdoc_files: []
|
|
62
|
+
files:
|
|
63
|
+
- ".gitignore"
|
|
64
|
+
- ".rspec"
|
|
65
|
+
- ".travis.yml"
|
|
66
|
+
- CODE_OF_CONDUCT.md
|
|
67
|
+
- Gemfile
|
|
68
|
+
- LICENSE.txt
|
|
69
|
+
- README.md
|
|
70
|
+
- Rakefile
|
|
71
|
+
- bin/xsort
|
|
72
|
+
- lib/xsort.rb
|
|
73
|
+
- lib/xsort/Emurate.rb
|
|
74
|
+
- lib/xsort/option.rb
|
|
75
|
+
- lib/xsort/version.rb
|
|
76
|
+
- lib/xsort/xcodeproj/pbxproj/pbxobject/PbxSort.rb
|
|
77
|
+
- lib/xsort/xcodeproj/pbxproj/pbxobject/PbxWrite.rb
|
|
78
|
+
- lib/xsort/xcodeproj/pbxproj/pbxobject/Pbxproj.rb
|
|
79
|
+
- xsort.gemspec
|
|
80
|
+
homepage: https://github.com/keisukeYamagishi/xsort
|
|
81
|
+
licenses:
|
|
82
|
+
- MIT
|
|
83
|
+
metadata: {}
|
|
84
|
+
post_install_message:
|
|
85
|
+
rdoc_options: []
|
|
86
|
+
require_paths:
|
|
87
|
+
- lib
|
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
89
|
+
requirements:
|
|
90
|
+
- - ">="
|
|
91
|
+
- !ruby/object:Gem::Version
|
|
92
|
+
version: '0'
|
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
|
+
requirements:
|
|
95
|
+
- - ">="
|
|
96
|
+
- !ruby/object:Gem::Version
|
|
97
|
+
version: '0'
|
|
98
|
+
requirements: []
|
|
99
|
+
rubyforge_project:
|
|
100
|
+
rubygems_version: 2.7.4
|
|
101
|
+
signing_key:
|
|
102
|
+
specification_version: 4
|
|
103
|
+
summary: Sort by file.
|
|
104
|
+
test_files: []
|