xcode_trash_remover 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +20 -0
- data/README.md +3 -33
- data/bin/xcodert +5 -38
- data/lib/xcode_trash_remover/core.rb +51 -0
- data/lib/xcode_trash_remover/version.rb +1 -1
- data/lib/xcode_trash_remover.rb +2 -1
- data/pkg/xcode_trash_remover-1.0.0.gem +0 -0
- metadata +5 -3
- data/LICENSE +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a5fc323bf1965feb9fed9eec0a033a90b0fea110
|
4
|
+
data.tar.gz: e4ffa738e1679fefea5e007b133b6927509489f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d78a1389d1bf78219e5a732680ab092727fe7a15b33a7c52b910a2860e6821c45e2b3ae7248e6d796a722b805aee08a56d52202ac2f05a6ac3e8cf2f9b63a694
|
7
|
+
data.tar.gz: 2f6b7ba82a3eb14d59df897f7c92858a328704ec219e35a2a8a283ec6ef6e78a36b66d90b4d2e31dd141172b14a087dd55aa61a403c27c5a48049871be096d0b
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
xcode_trash_remover (1.0.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
rake (10.4.2)
|
10
|
+
|
11
|
+
PLATFORMS
|
12
|
+
ruby
|
13
|
+
|
14
|
+
DEPENDENCIES
|
15
|
+
bundler (~> 1.14)
|
16
|
+
rake (~> 10.0)
|
17
|
+
xcode_trash_remover!
|
18
|
+
|
19
|
+
BUNDLED WITH
|
20
|
+
1.14.6
|
data/README.md
CHANGED
@@ -1,41 +1,11 @@
|
|
1
|
-
#
|
1
|
+
# Xcode Trash Remover
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
This is a simple script to remove Xcode's trash files that are generated under development.
|
6
4
|
|
7
5
|
## Installation
|
8
6
|
|
9
|
-
Add this line to your application's Gemfile:
|
10
|
-
|
11
|
-
```ruby
|
12
|
-
gem 'xcode_trash_remover'
|
13
|
-
```
|
14
|
-
|
15
|
-
And then execute:
|
16
|
-
|
17
|
-
$ bundle
|
18
|
-
|
19
|
-
Or install it yourself as:
|
20
|
-
|
21
7
|
$ gem install xcode_trash_remover
|
22
8
|
|
23
9
|
## Usage
|
24
10
|
|
25
|
-
|
26
|
-
|
27
|
-
## Development
|
28
|
-
|
29
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
-
|
31
|
-
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
-
|
33
|
-
## Contributing
|
34
|
-
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/xcode_trash_remover.
|
36
|
-
|
37
|
-
|
38
|
-
## License
|
39
|
-
|
40
|
-
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
-
|
11
|
+
$ xcodert
|
data/bin/xcodert
CHANGED
@@ -1,43 +1,10 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require '
|
3
|
-
require 'find'
|
4
|
-
|
5
|
-
module XcodeDirectories
|
6
|
-
DERIVED_DATA = "#{File.expand_path('~')}/Library/Developer/Xcode/DerivedData/*"
|
7
|
-
ARCHIVES = "#{File.expand_path('~')}/Library/Developer/Xcode/Archives/*"
|
8
|
-
end
|
9
|
-
|
10
|
-
def dir_size(dir_path)
|
11
|
-
total_size = 0
|
12
|
-
Find.find(dir_path) do |path|
|
13
|
-
if FileTest.directory?(path)
|
14
|
-
if File.basename(path)[0] == ?.
|
15
|
-
Find.prune
|
16
|
-
else
|
17
|
-
next
|
18
|
-
end
|
19
|
-
else
|
20
|
-
total_size += FileTest.size(path)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
total_size
|
24
|
-
end
|
25
|
-
|
26
|
-
trash_size = 0
|
27
|
-
XcodeDirectories.constants.each do |dir|
|
28
|
-
files = Dir.glob(XcodeDirectories.const_get(dir))
|
29
|
-
if files.empty?
|
30
|
-
next
|
31
|
-
end
|
32
|
-
files.each do |folder|
|
33
|
-
trash_size += dir_size(folder)
|
34
|
-
FileUtils.rm_rf(folder)
|
35
|
-
end
|
36
|
-
end
|
2
|
+
require 'xcode_trash_remover'
|
37
3
|
|
4
|
+
trash_size = XcodeTrashRemover::Core.get_trash_size
|
38
5
|
if trash_size > 0
|
39
|
-
|
40
|
-
puts "
|
6
|
+
XcodeTrashRemover::Core.remove_trash
|
7
|
+
puts "#{trash_size} bytes deleted"
|
41
8
|
else
|
42
|
-
puts "The directories are empty"
|
9
|
+
puts "The directories are empty. No trash files."
|
43
10
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'find'
|
3
|
+
|
4
|
+
module XcodeTrashRemover
|
5
|
+
|
6
|
+
module Core
|
7
|
+
|
8
|
+
extend self
|
9
|
+
|
10
|
+
@@xcode_directories = [
|
11
|
+
Dir.glob("#{File.expand_path('~')}/Library/Developer/Xcode/DerivedData/*"),
|
12
|
+
Dir.glob("#{File.expand_path('~')}/Library/Developer/Xcode/Archives/*"),
|
13
|
+
]
|
14
|
+
|
15
|
+
def dir_size(dir_path)
|
16
|
+
dir_path << '/' unless dir_path.end_with?('/')
|
17
|
+
raise RuntimeError, "#{dir_path} is not a directory" unless File.directory?(dir_path)
|
18
|
+
|
19
|
+
total_size = 0
|
20
|
+
Dir["#{dir_path}**/*"].each do |f|
|
21
|
+
total_size += File.size(f) if File.file?(f) && File.size?(f)
|
22
|
+
end
|
23
|
+
total_size
|
24
|
+
end
|
25
|
+
|
26
|
+
# TODO: function to return best size (MB or GB)
|
27
|
+
|
28
|
+
def get_trash_size
|
29
|
+
trash_size = 0
|
30
|
+
@@xcode_directories.each do |dir|
|
31
|
+
if dir.empty?
|
32
|
+
next
|
33
|
+
end
|
34
|
+
dir.each do |folder|
|
35
|
+
trash_size += dir_size(folder)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
trash_size
|
39
|
+
end
|
40
|
+
|
41
|
+
def remove_trash
|
42
|
+
@@xcode_directories.each do |dir|
|
43
|
+
dir.each do |folder|
|
44
|
+
FileUtils.rm_rf(folder.gsub(/ /, '\ '))
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
data/lib/xcode_trash_remover.rb
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
require "xcode_trash_remover/version"
|
1
|
+
require "xcode_trash_remover/version"
|
2
|
+
require "xcode_trash_remover/core"
|
Binary file
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xcode_trash_remover
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Frank Kair
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -47,13 +47,15 @@ extensions: []
|
|
47
47
|
extra_rdoc_files: []
|
48
48
|
files:
|
49
49
|
- Gemfile
|
50
|
-
-
|
50
|
+
- Gemfile.lock
|
51
51
|
- LICENSE.txt
|
52
52
|
- README.md
|
53
53
|
- Rakefile
|
54
54
|
- bin/xcodert
|
55
55
|
- lib/xcode_trash_remover.rb
|
56
|
+
- lib/xcode_trash_remover/core.rb
|
56
57
|
- lib/xcode_trash_remover/version.rb
|
58
|
+
- pkg/xcode_trash_remover-1.0.0.gem
|
57
59
|
- xcode_trash_remover.gemspec
|
58
60
|
homepage: https://www.github.com/FrankKair/xcode-trash-remover
|
59
61
|
licenses:
|
data/LICENSE
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
MIT License
|
2
|
-
|
3
|
-
Copyright (c) 2017 FrankKair
|
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 all
|
13
|
-
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 THE
|
21
|
-
SOFTWARE.
|