carthage_cache 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.ruby-version +1 -0
- data/.travis.yml +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +63 -0
- data/Rakefile +6 -0
- data/bin/carthage_cache +77 -0
- data/bin/console +11 -0
- data/bin/setup +7 -0
- data/carthage_cache.gemspec +34 -0
- data/lib/carthage_cache.rb +61 -0
- data/lib/carthage_cache/archive_builder.rb +45 -0
- data/lib/carthage_cache/archive_installer.rb +47 -0
- data/lib/carthage_cache/archiver.rb +16 -0
- data/lib/carthage_cache/carthage_resolved_file.rb +23 -0
- data/lib/carthage_cache/configurator.rb +69 -0
- data/lib/carthage_cache/description.rb +3 -0
- data/lib/carthage_cache/project.rb +50 -0
- data/lib/carthage_cache/repository.rb +36 -0
- data/lib/carthage_cache/terminal.rb +21 -0
- data/lib/carthage_cache/version.rb +3 -0
- metadata +155 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 91ccda2edc6f70cb54bac31dfb2728087720ae27
|
4
|
+
data.tar.gz: f319f6f87f5c4c6213045f948acb5a7338bb82f5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 904dadd81279ba6ab5f4fe2cb8ace5c20d1fca31770eb314a18b079fda74a0473e445c8da86151dd85dd8e7e84aeb05efa765d2b1765f48dc229b65ce6eb7ac5
|
7
|
+
data.tar.gz: d96ab1c012190f1bb9d0a1690e21fb27d0a1dee4265346afb90c801235e32e37b781e8224dcada8ff557a3c2237b8aa22b3ee5af13d8ed41d06f4cf741e1c915
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.2.2
|
data/.travis.yml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
os:
|
2
|
+
- osx
|
3
|
+
language: ruby
|
4
|
+
cache: bundler
|
5
|
+
rvm:
|
6
|
+
- head
|
7
|
+
- 2.2.2
|
8
|
+
# OS X 10.9.5-10.10.0 (2.0.0-p481)
|
9
|
+
- system
|
10
|
+
# OS X 10.9.3-10.9.4
|
11
|
+
- 2.0.0-p451
|
12
|
+
|
13
|
+
branches:
|
14
|
+
only:
|
15
|
+
- master
|
16
|
+
|
17
|
+
before_install: gem install bundler -v 1.10.6
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Guido Marucci Blas
|
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,63 @@
|
|
1
|
+
# CarthageCache
|
2
|
+
|
3
|
+
[![Code Climate](https://codeclimate.com/github/guidomb/carthage_cache/badges/gpa.svg)](https://codeclimate.com/github/guidomb/carthage_cache)
|
4
|
+
[![Test Coverage](https://codeclimate.com/github/guidomb/carthage_cache/badges/coverage.svg)](https://codeclimate.com/github/guidomb/carthage_cache/coverage)
|
5
|
+
|
6
|
+
CarthageCache allows Carthage users to have a shared cache of their `Carthage/Build` folder backed by Amazon S3.
|
7
|
+
|
8
|
+
Most libraries don't provide pre-compiled binaries, `.framework` files, in their releases. Even if they do, due to Swift lack of ABI, you might be forced to use `--no-use-binaries` flag and compile all your dependencies. Which, depending on the amount of dependencies and their size it could take significant time.
|
9
|
+
|
10
|
+
When you add slow building environments like Travis CI to the mix, a project bootstrap could take around 25 minutes just to build all your dependencies. Which is a lot for every push or pull request. You want your build and test to run really fast.
|
11
|
+
|
12
|
+
CarthageCache generate a hash key based on the content of your `Cartfile.resolved` and checks if there is a cache archive (a zip file of your `Carthage/Build` directory) associated to that hash. If there is one it will download it and install it in your project avoiding the need to run `carthage bootstrap`.
|
13
|
+
|
14
|
+
## Installation
|
15
|
+
|
16
|
+
Add this line to your application's Gemfile:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem 'carthage_cache'
|
20
|
+
```
|
21
|
+
|
22
|
+
And then execute:
|
23
|
+
|
24
|
+
$ bundle
|
25
|
+
|
26
|
+
Or install it yourself as:
|
27
|
+
|
28
|
+
$ gem install carthage_cache
|
29
|
+
|
30
|
+
## Usage
|
31
|
+
|
32
|
+
If you want to bootstrap a project from cache and if there is none then fallback to Carthage.
|
33
|
+
|
34
|
+
```
|
35
|
+
carthage_cache install || carthage bootstrap
|
36
|
+
```
|
37
|
+
|
38
|
+
If you want to update dependencies and update cache
|
39
|
+
|
40
|
+
```
|
41
|
+
carthage update && carthage_cache publish
|
42
|
+
```
|
43
|
+
|
44
|
+
If you want to check whether a cache exists for the current `Carfile.resolved`
|
45
|
+
|
46
|
+
```
|
47
|
+
carthage_cache exist
|
48
|
+
```
|
49
|
+
|
50
|
+
## Development
|
51
|
+
|
52
|
+
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.
|
53
|
+
|
54
|
+
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).
|
55
|
+
|
56
|
+
## Contributing
|
57
|
+
|
58
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/guidomb/carthage_cache/issues/new.
|
59
|
+
|
60
|
+
|
61
|
+
## License
|
62
|
+
|
63
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/carthage_cache
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "commander/import"
|
5
|
+
require "carthage_cache"
|
6
|
+
|
7
|
+
PROGRAM_NAME = 'carthage_cache'
|
8
|
+
|
9
|
+
program :name, PROGRAM_NAME
|
10
|
+
program :version, CarthageCache::VERSION
|
11
|
+
program :description, CarthageCache::DESCRIPTION
|
12
|
+
|
13
|
+
config = {}
|
14
|
+
verbose = false
|
15
|
+
global_option('-b', '--bucket-name BUCKET_NAME', 'Set Amazon S3 bucket to be used to store cache archives') do |bucket_name|
|
16
|
+
config[:bucket_name] = bucket_name
|
17
|
+
end
|
18
|
+
global_option('--verbose') { verbose = true }
|
19
|
+
|
20
|
+
command :exist do |c|
|
21
|
+
c.syntax = "#{PROGRAM_NAME} exist [PROJECT_PATH]"
|
22
|
+
c.description = 'Checks if a cache archive exists for the current Cartfile.resolved.'
|
23
|
+
c.option '-s', '--script', 'Makes prgram write "true" or "false" to STDOUT instead of more verbose message.'
|
24
|
+
c.action do |args, options|
|
25
|
+
app = CarthageCache::Application.new(args.first || ".", verbose, config)
|
26
|
+
if app.archive_exist?
|
27
|
+
if options.script
|
28
|
+
puts "true"
|
29
|
+
else
|
30
|
+
puts "There is a cached archive for the current Cartfile.resolved file."
|
31
|
+
end
|
32
|
+
else
|
33
|
+
if options.script
|
34
|
+
puts "false"
|
35
|
+
else
|
36
|
+
puts "No cached archive available for the current Cartfile.resolved file."
|
37
|
+
puts "You should probably run 'carthage bootstrap'."
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
command :install do |c|
|
44
|
+
c.syntax = "#{PROGRAM_NAME} install [PROJECT_PATH]"
|
45
|
+
c.description = 'Installs the cache archive for the current Cartfile.resolved.'
|
46
|
+
c.action do |args, options|
|
47
|
+
app = CarthageCache::Application.new(args.first || ".", verbose, config)
|
48
|
+
app.install_archive
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
command :publish do |c|
|
53
|
+
c.syntax = "#{PROGRAM_NAME} publish [PROJECT_PATH]"
|
54
|
+
c.description = 'Generates and uploads the cache archive for the current Cartfile.resolved.'
|
55
|
+
c.option '-f', '--force', 'Forces to create a new archive even if an archive already exist.'
|
56
|
+
c.action do |args, options|
|
57
|
+
options.default force: false
|
58
|
+
app = CarthageCache::Application.new(args.first || ".", verbose, config)
|
59
|
+
app.create_archive(options.force)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
command :config do |c|
|
64
|
+
c.syntax = "#{PROGRAM_NAME} config [PROJECT_PATH]"
|
65
|
+
c.description = "Generates a '#{CarthageCache::Configurator::CONFIG_FILE_NAME}' config file."
|
66
|
+
c.action do |args, options|
|
67
|
+
configurator = CarthageCache::Configurator.new(args.first || ".")
|
68
|
+
config = {}
|
69
|
+
config[:bucket_name] = ask "What is the Amazon S3 bucket name? [#{CarthageCache::Repository::DEFAULT_BUCKET_NAME}]"
|
70
|
+
config[:aws_s3_client_options] = {}
|
71
|
+
config[:aws_s3_client_options][:region] = ask "What is the Amazon S3 region?"
|
72
|
+
config[:aws_s3_client_options][:access_key_id] = password "What is the AWS access key?"
|
73
|
+
config[:aws_s3_client_options][:secret_access_key] = password " What is the AWS secret access key?"
|
74
|
+
config.delete_if { |k,v| k == :bucket_name && v == "" }
|
75
|
+
configurator.save_config(config)
|
76
|
+
end
|
77
|
+
end
|
data/bin/console
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "carthage_cache"
|
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
|
data/bin/setup
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'carthage_cache/version'
|
5
|
+
require 'carthage_cache/description'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = "carthage_cache"
|
9
|
+
spec.version = CarthageCache::VERSION
|
10
|
+
spec.authors = ["Guido Marucci Blas"]
|
11
|
+
spec.email = ["guidomb@gmail.com"]
|
12
|
+
|
13
|
+
spec.summary = CarthageCache::DESCRIPTION
|
14
|
+
spec.description = %q{
|
15
|
+
CarthageCache generate a hash key based on the content of your Cartfile.resolved and checks
|
16
|
+
if there is a cache archive (a zip file of your Carthage/Build directory) associated to that hash.
|
17
|
+
If there is one it will download it and install it in your project avoiding the need to run carthage bootstrap.
|
18
|
+
}
|
19
|
+
spec.homepage = "https://github.com/guidomb/carthage_cache"
|
20
|
+
spec.license = "MIT"
|
21
|
+
|
22
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
23
|
+
spec.bindir = "exe"
|
24
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
|
+
spec.require_paths = ["lib"]
|
26
|
+
|
27
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
28
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
29
|
+
spec.add_development_dependency "rspec"
|
30
|
+
spec.add_development_dependency "pry"
|
31
|
+
|
32
|
+
spec.add_dependency "aws-sdk", "~> 2"
|
33
|
+
spec.add_dependency "commander"
|
34
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require "carthage_cache/version"
|
2
|
+
require "carthage_cache/description"
|
3
|
+
require "carthage_cache/archive_builder"
|
4
|
+
require "carthage_cache/archive_installer"
|
5
|
+
require "carthage_cache/archiver"
|
6
|
+
require "carthage_cache/carthage_resolved_file"
|
7
|
+
require "carthage_cache/project"
|
8
|
+
require "carthage_cache/repository"
|
9
|
+
require "carthage_cache/terminal"
|
10
|
+
require "carthage_cache/configurator"
|
11
|
+
|
12
|
+
module CarthageCache
|
13
|
+
|
14
|
+
class Application
|
15
|
+
|
16
|
+
CACHE_DIR_NAME = "carthage_cache"
|
17
|
+
|
18
|
+
attr_reader :terminal
|
19
|
+
attr_reader :archiver
|
20
|
+
attr_reader :repository
|
21
|
+
attr_reader :project
|
22
|
+
attr_reader :configurator
|
23
|
+
|
24
|
+
def initialize(project_path, verbose, config)
|
25
|
+
@terminal = Terminal.new(verbose)
|
26
|
+
@archiver = Archiver.new
|
27
|
+
@configurator = Configurator.new(project_path)
|
28
|
+
@repository = Repository.new(configurator.config[:bucket_name], configurator.config[:aws_s3_client_options])
|
29
|
+
@project = Project.new(project_path, CACHE_DIR_NAME, terminal)
|
30
|
+
end
|
31
|
+
|
32
|
+
def archive_exist?
|
33
|
+
repository.archive_exist?(project.archive_filename)
|
34
|
+
end
|
35
|
+
|
36
|
+
def install_archive
|
37
|
+
if archive_exist
|
38
|
+
archive_installer.install
|
39
|
+
else
|
40
|
+
terminal.puts "There is no cached archive for the current Cartfile.resolved file."
|
41
|
+
exit 1
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def create_archive(force = false)
|
46
|
+
archive_builder.build if force || !archive_exist?
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def archive_installer
|
52
|
+
@archive_installer ||= ArchiveInstaller.new(terminal, repository, archiver, project)
|
53
|
+
end
|
54
|
+
|
55
|
+
def archive_builder
|
56
|
+
@archive_builder ||= ArchiveBuilder.new(terminal, repository, archiver, project)
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module CarthageCache
|
2
|
+
|
3
|
+
class ArchiveBuilder
|
4
|
+
|
5
|
+
attr_reader :terminal
|
6
|
+
attr_reader :repository
|
7
|
+
attr_reader :archiver
|
8
|
+
attr_reader :project
|
9
|
+
|
10
|
+
def initialize(terminal, repository, archiver, project)
|
11
|
+
@terminal = terminal
|
12
|
+
@repository = repository
|
13
|
+
@archiver = archiver
|
14
|
+
@project = project
|
15
|
+
end
|
16
|
+
|
17
|
+
def build
|
18
|
+
archive_path = archive
|
19
|
+
upload_archive(archive_path)
|
20
|
+
# TODO check if some old archives can be deleted
|
21
|
+
# I would store the last N archives and then delete
|
22
|
+
# the rest
|
23
|
+
end
|
24
|
+
|
25
|
+
private
|
26
|
+
|
27
|
+
def archive
|
28
|
+
# TODO Check() that only dependencies that appear
|
29
|
+
# in Cartfile.resolved file are going to be archived.
|
30
|
+
# This will avoid saving unused dependencies into
|
31
|
+
# the archive.
|
32
|
+
archive_path = File.join(project.tmpdir, project.archive_filename)
|
33
|
+
terminal.puts "Archiving Carthage build directory."
|
34
|
+
archiver.archive(project.carthage_build_directory, archive_path)
|
35
|
+
archive_path
|
36
|
+
end
|
37
|
+
|
38
|
+
def upload_archive(archive_path)
|
39
|
+
terminal.puts "Uploading archive with key '#{project.archive_key}'."
|
40
|
+
repository.upload(project.archive_filename, archive_path)
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
module CarthageCache
|
2
|
+
|
3
|
+
class ArchiveInstaller
|
4
|
+
|
5
|
+
attr_reader :terminal
|
6
|
+
attr_reader :repository
|
7
|
+
attr_reader :archiver
|
8
|
+
attr_reader :project
|
9
|
+
|
10
|
+
def initialize(terminal, repository, archiver, project)
|
11
|
+
@terminal = terminal
|
12
|
+
@repository = repository
|
13
|
+
@archiver = archiver
|
14
|
+
@project = project
|
15
|
+
end
|
16
|
+
|
17
|
+
def install
|
18
|
+
archive_path = download_archive
|
19
|
+
unarchive(archive_path)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def create_carthage_build_directory
|
25
|
+
unless File.exist?(project.carthage_build_directory)
|
26
|
+
terminal.vputs "Creating Carthage build directory '#{project.carthage_build_directory}'."
|
27
|
+
FileUtils.mkdir_p(project.carthage_build_directory)
|
28
|
+
end
|
29
|
+
project.carthage_build_directory
|
30
|
+
end
|
31
|
+
|
32
|
+
def download_archive
|
33
|
+
archive_path = File.join(project.tmpdir, project.archive_filename)
|
34
|
+
terminal.puts "Downloading archive with key '#{archive_path}'."
|
35
|
+
repository.download(project.archive_filename, archive_path)
|
36
|
+
archive_path
|
37
|
+
end
|
38
|
+
|
39
|
+
def unarchive(archive_path)
|
40
|
+
build_directory = create_carthage_build_directory
|
41
|
+
terminal.puts "Unarchiving '#{archive_path}' into '#{build_directory}'."
|
42
|
+
archiver.unarchive(archive_path, build_directory)
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module CarthageCache
|
2
|
+
|
3
|
+
class Archiver
|
4
|
+
|
5
|
+
def archive(archive_path, destination_path)
|
6
|
+
files = Dir.entries(archive_path).select { |x| !x.start_with?(".") }
|
7
|
+
`cd #{archive_path} && zip -r -X #{File.expand_path(destination_path)} #{files.join(' ')} > /dev/null`
|
8
|
+
end
|
9
|
+
|
10
|
+
def unarchive(archive_path, destination_path)
|
11
|
+
`unzip #{archive_path} -d #{destination_path} > /dev/null`
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require "digest"
|
2
|
+
|
3
|
+
module CarthageCache
|
4
|
+
|
5
|
+
class CartfileResolvedFile
|
6
|
+
|
7
|
+
attr_reader :file_path
|
8
|
+
|
9
|
+
def initialize(file_path)
|
10
|
+
@file_path = file_path
|
11
|
+
end
|
12
|
+
|
13
|
+
def digest
|
14
|
+
@digest ||= Digest::SHA256.hexdigest(content)
|
15
|
+
end
|
16
|
+
|
17
|
+
def content
|
18
|
+
@content ||= File.read(file_path)
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require "yaml"
|
2
|
+
|
3
|
+
module CarthageCache
|
4
|
+
|
5
|
+
class Configurator
|
6
|
+
|
7
|
+
CONFIG_FILE_NAME = ".carthage_cache.yml"
|
8
|
+
|
9
|
+
attr_reader :config_file_path
|
10
|
+
attr_reader :base_config
|
11
|
+
|
12
|
+
def initialize(project_path, base_config = {})
|
13
|
+
@config_file_path = File.join(project_path, CONFIG_FILE_NAME)
|
14
|
+
@base_config = default_configuration.merge(base_config)
|
15
|
+
end
|
16
|
+
|
17
|
+
def config
|
18
|
+
@config ||= load_config
|
19
|
+
end
|
20
|
+
|
21
|
+
def save_config(config)
|
22
|
+
if valid?(config)
|
23
|
+
File.open(config_file_path, 'w') { |f| f.write config.to_yaml }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
def config_file_exist?
|
30
|
+
File.exist?(config_file_path)
|
31
|
+
end
|
32
|
+
|
33
|
+
def load_config
|
34
|
+
if config_file_exist?
|
35
|
+
config = YAML.load(File.read(config_file_path))
|
36
|
+
raise "Invalid config file" unless valid?(config)
|
37
|
+
config.merge(base_config)
|
38
|
+
else
|
39
|
+
base_config
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def valid?(config)
|
44
|
+
config.has_key?(:aws_s3_client_options) &&
|
45
|
+
config[:aws_s3_client_options][:region] &&
|
46
|
+
config[:aws_s3_client_options][:access_key_id] &&
|
47
|
+
config[:aws_s3_client_options][:secret_access_key]
|
48
|
+
end
|
49
|
+
|
50
|
+
def deep_symbolize_keys(object)
|
51
|
+
return object.inject({}) { |memo,(k,v)| memo[k.to_sym] = deep_symbolize_keys(v); memo } if object.is_a? Hash
|
52
|
+
return object.inject([]) { |memo,v | memo << deep_symbolize_keys(v); memo } if object.is_a? Array
|
53
|
+
return object
|
54
|
+
end
|
55
|
+
|
56
|
+
def default_configuration
|
57
|
+
config = {
|
58
|
+
bucket_name: nil,
|
59
|
+
aws_s3_client_options: {}
|
60
|
+
}
|
61
|
+
config[:aws_s3_client_options][:region] = ENV['AWS_REGION'] if ENV['AWS_REGION']
|
62
|
+
config[:aws_s3_client_options][:access_key_id] = ENV['AWS_ACCESS_KEY_ID'] if ENV['AWS_ACCESS_KEY_ID']
|
63
|
+
config[:aws_s3_client_options][:secret_access_key] = ENV['AWS_SECRET_ACCESS_KEY'] if ENV['AWS_SECRET_ACCESS_KEY']
|
64
|
+
config.delete_if { |k, v| k == :aws_s3_client_options && v.empty? }
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module CarthageCache
|
2
|
+
|
3
|
+
class Project
|
4
|
+
|
5
|
+
attr_reader :cartfile
|
6
|
+
attr_reader :project_path
|
7
|
+
attr_reader :cache_dir_name
|
8
|
+
attr_reader :terminal
|
9
|
+
|
10
|
+
def initialize(project_path, cache_dir_name, terminal)
|
11
|
+
@project_path = project_path
|
12
|
+
@cache_dir_name = cache_dir_name
|
13
|
+
@terminal = terminal
|
14
|
+
@cartfile = CartfileResolvedFile.new(cartfile_resolved_path)
|
15
|
+
end
|
16
|
+
|
17
|
+
def archive_filename
|
18
|
+
@archive_filename ||= "#{archive_key}.zip"
|
19
|
+
end
|
20
|
+
|
21
|
+
def archive_key
|
22
|
+
cartfile.digest
|
23
|
+
end
|
24
|
+
|
25
|
+
def tmpdir
|
26
|
+
@tmpdir ||= create_tmpdir
|
27
|
+
end
|
28
|
+
|
29
|
+
def carthage_build_directory
|
30
|
+
@carthage_build_directory ||= File.join(project_path, "Carthage", "Build")
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def cartfile_resolved_path
|
36
|
+
@carfile_resolved_path ||= File.join(project_path, "Cartfile.resolved")
|
37
|
+
end
|
38
|
+
|
39
|
+
def create_tmpdir
|
40
|
+
dir = File.join(Dir.tmpdir, cache_dir_name)
|
41
|
+
unless File.exist?(dir)
|
42
|
+
terminal.vputs "Creating carthage cache directory at '#{dir}'."
|
43
|
+
FileUtils.mkdir_p(dir)
|
44
|
+
end
|
45
|
+
dir
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require "aws-sdk"
|
2
|
+
|
3
|
+
module CarthageCache
|
4
|
+
|
5
|
+
class Repository
|
6
|
+
|
7
|
+
DEFAULT_BUCKET_NAME = "carthage-cache"
|
8
|
+
|
9
|
+
attr_reader :client
|
10
|
+
attr_reader :bucket_name
|
11
|
+
|
12
|
+
def initialize(bucket_name, client_options = {})
|
13
|
+
@client = ::Aws::S3::Client.new(client_options)
|
14
|
+
@bucket_name = bucket_name || DEFAULT_BUCKET_NAME
|
15
|
+
end
|
16
|
+
|
17
|
+
def archive_exist?(archive_filename)
|
18
|
+
::Aws::S3::Object.new(bucket_name, archive_filename, client: client).exists?
|
19
|
+
end
|
20
|
+
|
21
|
+
def download(archive_filename, destination_path)
|
22
|
+
resp = client.get_object(
|
23
|
+
response_target: destination_path,
|
24
|
+
bucket: bucket_name,
|
25
|
+
key: archive_filename)
|
26
|
+
end
|
27
|
+
|
28
|
+
def upload(archive_filename, archive_path)
|
29
|
+
File.open(archive_path, 'rb') do |file|
|
30
|
+
client.put_object(bucket: bucket_name, key: archive_filename, body: file)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module CarthageCache
|
2
|
+
|
3
|
+
class Terminal
|
4
|
+
|
5
|
+
attr_reader :verbose
|
6
|
+
|
7
|
+
def initialize(verbose = false)
|
8
|
+
@verbose = verbose
|
9
|
+
end
|
10
|
+
|
11
|
+
def puts(message)
|
12
|
+
Kernel.puts(message)
|
13
|
+
end
|
14
|
+
|
15
|
+
def vputs(message)
|
16
|
+
puts(message) if verbose
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: carthage_cache
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Guido Marucci Blas
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-11-10 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.10'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.10'
|
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: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: aws-sdk
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '2'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '2'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: commander
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
description: "\n CarthageCache generate a hash key based on the content of your
|
98
|
+
Cartfile.resolved and checks\n if there is a cache archive (a zip file of your
|
99
|
+
Carthage/Build directory) associated to that hash.\n If there is one it will
|
100
|
+
download it and install it in your project avoiding the need to run carthage bootstrap.\n
|
101
|
+
\ "
|
102
|
+
email:
|
103
|
+
- guidomb@gmail.com
|
104
|
+
executables: []
|
105
|
+
extensions: []
|
106
|
+
extra_rdoc_files: []
|
107
|
+
files:
|
108
|
+
- ".gitignore"
|
109
|
+
- ".rspec"
|
110
|
+
- ".ruby-version"
|
111
|
+
- ".travis.yml"
|
112
|
+
- Gemfile
|
113
|
+
- LICENSE.txt
|
114
|
+
- README.md
|
115
|
+
- Rakefile
|
116
|
+
- bin/carthage_cache
|
117
|
+
- bin/console
|
118
|
+
- bin/setup
|
119
|
+
- carthage_cache.gemspec
|
120
|
+
- lib/carthage_cache.rb
|
121
|
+
- lib/carthage_cache/archive_builder.rb
|
122
|
+
- lib/carthage_cache/archive_installer.rb
|
123
|
+
- lib/carthage_cache/archiver.rb
|
124
|
+
- lib/carthage_cache/carthage_resolved_file.rb
|
125
|
+
- lib/carthage_cache/configurator.rb
|
126
|
+
- lib/carthage_cache/description.rb
|
127
|
+
- lib/carthage_cache/project.rb
|
128
|
+
- lib/carthage_cache/repository.rb
|
129
|
+
- lib/carthage_cache/terminal.rb
|
130
|
+
- lib/carthage_cache/version.rb
|
131
|
+
homepage: https://github.com/guidomb/carthage_cache
|
132
|
+
licenses:
|
133
|
+
- MIT
|
134
|
+
metadata: {}
|
135
|
+
post_install_message:
|
136
|
+
rdoc_options: []
|
137
|
+
require_paths:
|
138
|
+
- lib
|
139
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - ">="
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
145
|
+
requirements:
|
146
|
+
- - ">="
|
147
|
+
- !ruby/object:Gem::Version
|
148
|
+
version: '0'
|
149
|
+
requirements: []
|
150
|
+
rubyforge_project:
|
151
|
+
rubygems_version: 2.4.5
|
152
|
+
signing_key:
|
153
|
+
specification_version: 4
|
154
|
+
summary: A tool that allows to cache Carthage/Build folder in Amazon S3.
|
155
|
+
test_files: []
|