xcflatter 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: df6129a9e946ffeaf73450dab5b4c5beab676649cba003be2b613ed8cdbcb5c4
4
+ data.tar.gz: 3f245ca20007d029c85756c6c097381a53d1cec7f45f90371bbf3fa23dd6826c
5
+ SHA512:
6
+ metadata.gz: 50f64afa6a3c8c787e92f519a961722dcf00b37325b78fb54ccd0d142f4a5fe68be581e4cc05ee152ec57968f1cac188b9853837481012cfc2ba635e7ac57f55
7
+ data.tar.gz: 31e1d269973b5b50f305b94e0ad5d459184a026bddd2d2feed6d030ea13fe6322987a3580028e76b0fbf1ffc40690cb398cdd4654cae9c4569feed638c680666
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in xcflatter.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 Gregory Berngardt
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,47 @@
1
+ # flatter
2
+
3
+ Faced with similar problem?
4
+
5
+ > 🚨 `error: unable to spawn process (Argument list too long)`
6
+
7
+ Until [Apple not fix it](http://www.openradar.me/35879960) I made some solution for workaround this problem - flatter!
8
+
9
+ Flatter is a gem which move all swift files in xCode project to root group. That's all :)
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ ```ruby
16
+ gem 'xcflatter'
17
+ ```
18
+
19
+ And then execute:
20
+
21
+ $ bundle
22
+
23
+ Or install it yourself as:
24
+
25
+ $ gem install xcflatter
26
+
27
+ ## Usage
28
+
29
+ Simple
30
+
31
+ $ flatter "/path/to/your/project.xcodeproj"
32
+
33
+ Specific group
34
+
35
+ $ flatter "/path/to/your/project.xcodeproj" -g "SpecificGroup"
36
+
37
+ Advanced
38
+
39
+ $ flatter "/path/to/your/project.xcodeproj" -g "SpecificGroup" -e ".xib"
40
+
41
+ ## Contributing
42
+
43
+ Bug reports and pull requests are welcome on GitHub at https://github.com/gregoryvit/flatter.
44
+
45
+ ## License
46
+
47
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "xcflatter"
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(__FILE__)
data/bin/flatter ADDED
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'xcflatter/cli'
4
+ Flatter::CLI.new.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,34 @@
1
+ require 'optparse'
2
+ require 'xcflatter'
3
+
4
+ module Flatter
5
+ class CLI
6
+
7
+ def start
8
+ options = {}
9
+ OptionParser.new do |opts|
10
+ opts.banner = "Usage: flatter PATH_TO_XCODEPROJ [options]"
11
+
12
+ opts.on("-g String", String, "Path to root group") do |group_path|
13
+ options[:group_path] = group_path
14
+ end
15
+
16
+ options[:files_ext] = ".swift"
17
+ opts.on("-e String", String, "File extension. Default: .swift") do |files_ext|
18
+ prefix = files_ext.start_with?(".") ? "" : "."
19
+ options[:files_ext] = prefix + files_ext
20
+ end
21
+ end.parse!
22
+
23
+ if ARGV.any?
24
+ project_path = ARGV.first
25
+ dest_file_ext = options[:files_ext]
26
+ root_group_path = options[:group_path]
27
+ Flatter::FileMover.new.move_all_files_with_ext_to_root_group(project_path, dest_file_ext, root_group_path)
28
+ else
29
+ puts "🛑 Error: Not arguments passed"
30
+ end
31
+ end
32
+
33
+ end
34
+ end
@@ -0,0 +1,3 @@
1
+ module Flatter
2
+ VERSION = "1.0.0"
3
+ end
data/lib/xcflatter.rb ADDED
@@ -0,0 +1,46 @@
1
+ require "xcflatter/version"
2
+ require 'xcodeproj'
3
+ require 'fileutils'
4
+
5
+ module Flatter
6
+ class Error < StandardError; end
7
+
8
+ class FileMover
9
+
10
+ # Move all files with specific extenstion from subfolders to root group
11
+ def move_all_files_with_ext_to_root_group(project_path, dest_file_ext, root_group_path)
12
+ project = Xcodeproj::Project.open(project_path)
13
+
14
+ # Get root group
15
+ if root_group_path.nil?
16
+ root_group = project.main_group
17
+ else
18
+ root_group = project[root_group_path]
19
+ end
20
+
21
+ # Move files in FS
22
+ base_dir_path = root_group.real_path.to_s
23
+
24
+ # For each project file move to root group
25
+ project.files.each do |file|
26
+ file_ext = File.extname(file.path)
27
+ if dest_file_ext == file_ext
28
+ # Move files in FS hierarchy
29
+ initial_path = file.real_path
30
+ result_path = base_dir_path + '/' + File.basename(file.path)
31
+ if result_path != initial_path
32
+ FileUtils.mv(initial_path, result_path)
33
+ end
34
+
35
+ # Fix and move files in Xcode hierarchy
36
+ file.set_source_tree("<group>")
37
+ file.set_path(File.basename(file.path))
38
+ file.move(root_group)
39
+ end
40
+ end
41
+
42
+ project.save()
43
+ end
44
+
45
+ end
46
+ end
data/xcflatter.gemspec ADDED
@@ -0,0 +1,30 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "xcflatter/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "xcflatter"
8
+ spec.version = Flatter::VERSION
9
+ spec.authors = ["Gregory Berngardt"]
10
+ spec.email = ["gregoryvit@gmail.com"]
11
+
12
+ spec.summary = %q{Flatter is a gem which move all files with specific extension in xCode project to root group.}
13
+ spec.description = %q{Flatter is a gem which move all files with specific extension in xCode project to root group.}
14
+ spec.homepage = "https://github.com/gregoryvit/flatter"
15
+ spec.license = "MIT"
16
+
17
+ # Specify which files should be added to the gem when it is released.
18
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
19
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
20
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ end
22
+ spec.bindir = "bin"
23
+ spec.executables = ["flatter"]
24
+ spec.require_paths = ["lib"]
25
+
26
+ spec.add_development_dependency "bundler", "~> 1.17"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ spec.add_dependency "xcodeproj", "~> 1.0"
29
+
30
+ end
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: xcflatter
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Gregory Berngardt
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-08-22 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.17'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.17'
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: xcodeproj
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.0'
55
+ description: Flatter is a gem which move all files with specific extension in xCode
56
+ project to root group.
57
+ email:
58
+ - gregoryvit@gmail.com
59
+ executables:
60
+ - flatter
61
+ extensions: []
62
+ extra_rdoc_files: []
63
+ files:
64
+ - ".gitignore"
65
+ - Gemfile
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - bin/console
70
+ - bin/flatter
71
+ - bin/setup
72
+ - lib/xcflatter.rb
73
+ - lib/xcflatter/cli.rb
74
+ - lib/xcflatter/version.rb
75
+ - xcflatter.gemspec
76
+ homepage: https://github.com/gregoryvit/flatter
77
+ licenses:
78
+ - MIT
79
+ metadata: {}
80
+ post_install_message:
81
+ rdoc_options: []
82
+ require_paths:
83
+ - lib
84
+ required_ruby_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ required_rubygems_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ requirements: []
95
+ rubyforge_project:
96
+ rubygems_version: 2.7.8
97
+ signing_key:
98
+ specification_version: 4
99
+ summary: Flatter is a gem which move all files with specific extension in xCode project
100
+ to root group.
101
+ test_files: []