xcodeproj-sort 1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: d587209ce990e19a7cb9322e0911ccef4b66e154
4
+ data.tar.gz: 9317a56395c8ebca2e78ca2604bee1f2beb2142a
5
+ SHA512:
6
+ metadata.gz: 85ca14af77148247b829661e7c646d288e1173ba26052560efe88d130d333a24005050334e6f447443e5c2ddc7ddfc5e4e984f20341289e9384ad11f0966bf85
7
+ data.tar.gz: eb4556e3e96db47e3f958bb182516ab10ba898786476dc76ac61f72a15298277442418792c1df49ec13bf484d45b358b4b4fbcfa7e2fed372197715d7c09427e
data/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # xcodeproj-sort-pre-commit-hook
2
+ A pre-commit hook that sorts your xcodeproj file.
3
+
4
+ ## What is it?
5
+ This repo provides a ready to use [pre-commit](https://pre-commit.com/) hook for automatically sorting your Xcode project. The hook looks for files ending in .pbxproj that have been modified and sorts their project group hierarchy automatically using the [Xcodeproj](https://github.com/CocoaPods/Xcodeproj/) gem. The effect is that the sort leaves your project file modified if it's not sorted, so that pre-commit won't allow the unsorted file to go through.
6
+
7
+ ## Usage
8
+ If you haven't set up pre-commit, check out [pre-commit's installation docs](https://pre-commit.com/#install) first.
9
+
10
+ Add the following to your `.pre-commit-config.yaml`:
11
+
12
+ ```
13
+ - repo: git://github.com/noahsark769/xcodeproj-sort-pre-commit-hook
14
+ sha: v1.0.0
15
+ hooks:
16
+ - id: xcodeproj-sort
17
+ ```
18
+
19
+ Then, run:
20
+
21
+ ```
22
+ pre-commit install
23
+ ```
24
+
25
+ ## Contributing
26
+ I use this in the development of [Trestle](https://appstore.com/trestle), but your mileage might vary. If you notice a bug or have a feature request, please open a github issue or submit a pull request. It's best to open issues first so that work isn't duplicated.
@@ -0,0 +1,31 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'optparse'
4
+ require 'xcodeproj-sort'
5
+
6
+ if $PROGRAM_NAME == __FILE__
7
+ ENV['BUNDLE_GEMFILE'] = File.expand_path('../../Gemfile', __FILE__)
8
+ require 'bundler/setup'
9
+ end
10
+
11
+ xcodeproj_sort_options = nil
12
+ OptionParser.new do |opts|
13
+ opts.banner = "Usage: xcodeproj-sort [path/to/Project.xcodeproj]"
14
+
15
+ opts.on(
16
+ "-p",
17
+ "--groups-position [above|below]",
18
+ "Whether to position groups before files (above) or after files (below). Default is to interleave."
19
+ ) do |p|
20
+ if p
21
+ xcodeproj_sort_options = { :groups_position => p.to_sym }
22
+ end
23
+ end
24
+ end.parse!
25
+
26
+ filename = ARGV.pop
27
+ if filename
28
+ XcodeprojSort.sort(filename.gsub('project.pbxproj', ''), xcodeproj_sort_options)
29
+ else
30
+ puts "An xcodeproj filename is required."
31
+ end
@@ -0,0 +1,10 @@
1
+ require 'xcodeproj'
2
+
3
+ module XcodeprojSort
4
+ def sort(project_name, xcodeproj_sort_options)
5
+ project = Xcodeproj::Project.open(project_name)
6
+ project.sort xcodeproj_sort_options
7
+ project.save
8
+ end
9
+ module_function :sort
10
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: xcodeproj-sort
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Noah Gilmore
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-02-12 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: xcodeproj
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: claide
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ description: Xcodeproj-sort provides a simple script to sort the objects in your .xcodeproj
42
+ file. The script modifies the file and prints a message only if the file is modified,
43
+ which makes it good for use in a pre-commit hook.
44
+ email: noah.w.gilmore@gmail.com
45
+ executables:
46
+ - xcodeproj-sort
47
+ extensions: []
48
+ extra_rdoc_files: []
49
+ files:
50
+ - README.md
51
+ - bin/xcodeproj-sort
52
+ - lib/xcodeproj-sort.rb
53
+ homepage: https://github.com/noahsark769/xcodeproj-sort-pre-commit-hook
54
+ licenses:
55
+ - MIT
56
+ metadata:
57
+ source_code_uri: https://github.com/noahsark769/xcodeproj-sort
58
+ post_install_message:
59
+ rdoc_options: []
60
+ require_paths:
61
+ - lib
62
+ required_ruby_version: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 2.0.0
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ requirements: []
73
+ rubyforge_project:
74
+ rubygems_version: 2.6.12
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: Sort your xcodeproj file in a pre-commit hook.
78
+ test_files: []