gem-sparse-mirror 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +56 -0
- data/Rakefile +1 -0
- data/bin/gem-sparse-mirror +5 -0
- data/gem-sparse-mirror.gemspec +22 -0
- data/lib/gem-sparse-mirror.rb +9 -0
- data/lib/gem-sparse-mirror/command.rb +59 -0
- data/lib/gem-sparse-mirror/mirror.rb +37 -0
- data/lib/gem-sparse-mirror/version.rb +7 -0
- metadata +92 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Florian Gilcher
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
# gem-sparse-mirror - Mirror parts of Rubygems
|
2
|
+
|
3
|
+
A script that extends `rubygems-mirror` to download only parts of Rubygems. It uses the bundler API to resolve all dependencies of the intended gems and completely mirrors those.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Run:
|
8
|
+
|
9
|
+
$ gem install gem-sparse-mirror
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
Like [https://github.com/rubygems/rubygems-mirror](rubygems-mirror), this reads `.gems/mirrorrc`, with 2 additional attributes, `only` and `except`:
|
14
|
+
|
15
|
+
```yaml
|
16
|
+
---
|
17
|
+
- from: http://rubygems.org/
|
18
|
+
to: /path/to/your/sync-directory
|
19
|
+
parallelism: 10
|
20
|
+
except:
|
21
|
+
- mail
|
22
|
+
only:
|
23
|
+
- rake
|
24
|
+
- rails
|
25
|
+
```
|
26
|
+
|
27
|
+
This will resolve all dependencies of `rails` and `rake` and sync all of them, but never sync `mail` (for example, if you ship your own version).
|
28
|
+
|
29
|
+
This script syncs _all_ versions of the found gems.
|
30
|
+
|
31
|
+
`gem-sparse-mirror` does not create or update a gem index. This can be done using rubygems `generate_index` command:
|
32
|
+
|
33
|
+
```
|
34
|
+
$ cd /path/to/your/sync-directory
|
35
|
+
$ gem generate_index --no-legacy --modern --update gems/
|
36
|
+
```
|
37
|
+
|
38
|
+
## Word of warning
|
39
|
+
|
40
|
+
This does not supply a gem server. You will have to manage that server yourself.
|
41
|
+
|
42
|
+
## License
|
43
|
+
|
44
|
+
MIT, see `LICENSE.txt`
|
45
|
+
|
46
|
+
## Thanks
|
47
|
+
|
48
|
+
To the rubygems team for running rubygems and implementing rubygems-mirror in the first place.
|
49
|
+
|
50
|
+
## Contributing
|
51
|
+
|
52
|
+
1. Fork it
|
53
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
54
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
55
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
56
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'gem-sparse-mirror/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "gem-sparse-mirror"
|
8
|
+
gem.version = Gem::Sparse::Mirror::VERSION
|
9
|
+
gem.authors = ["Florian Gilcher"]
|
10
|
+
gem.email = ["florian.gilcher@asquera.de"]
|
11
|
+
gem.description = %q{Builds a sparse rubygems mirror that contains all dependencies of the included gems.}
|
12
|
+
gem.summary = %q{Builds a sparse rubygems mirror that contains all dependencies of the included gems.}
|
13
|
+
gem.homepage = ""
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_dependency "rubygems-mirror"
|
21
|
+
gem.add_dependency "bundler"
|
22
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# copied from rubygems-mirrors command.rb (MIT)
|
2
|
+
|
3
|
+
require 'gem-sparse-mirror/mirror'
|
4
|
+
module Gem
|
5
|
+
module SparseMirror
|
6
|
+
class Command
|
7
|
+
SUPPORTS_INFO_SIGNAL = Signal.list['INFO']
|
8
|
+
def execute
|
9
|
+
config_file = File.join Gem.user_home, '.gem', '.mirrorrc'
|
10
|
+
|
11
|
+
raise "Config file #{config_file} not found" unless File.exist? config_file
|
12
|
+
|
13
|
+
mirrors = YAML.load_file config_file
|
14
|
+
|
15
|
+
raise "Invalid config file #{config_file}" unless mirrors.respond_to? :each
|
16
|
+
|
17
|
+
mirrors.each do |mir|
|
18
|
+
raise "mirror missing 'from' field" unless mir.has_key? 'from'
|
19
|
+
raise "mirror missing 'to' field" unless mir.has_key? 'to'
|
20
|
+
|
21
|
+
get_from = mir['from']
|
22
|
+
save_to = File.expand_path mir['to']
|
23
|
+
|
24
|
+
parallelism = mir['parallelism']
|
25
|
+
|
26
|
+
raise "Directory not found: #{save_to}" unless File.exist? save_to
|
27
|
+
raise "Not a directory: #{save_to}" unless File.directory? save_to
|
28
|
+
|
29
|
+
mirror = Gem::SparseMirror::Mirror.new(get_from, save_to, parallelism)
|
30
|
+
mirror.only = mir["only"]
|
31
|
+
mirror.except = Array(mir["except"])
|
32
|
+
|
33
|
+
puts "Fetching: #{mirror.from(Gem::Mirror::SPECS_FILE_Z)} with #{parallelism} threads"
|
34
|
+
mirror.update_specs
|
35
|
+
|
36
|
+
puts "Total gems: #{mirror.gems.size}"
|
37
|
+
|
38
|
+
num_to_fetch = mirror.gems_to_fetch.size
|
39
|
+
|
40
|
+
#progress = ui.progress_reporter num_to_fetch,
|
41
|
+
# "Fetching #{num_to_fetch} gems"
|
42
|
+
|
43
|
+
trap(:INFO) { puts "Fetched: #{progress.count}/#{num_to_fetch}" } if SUPPORTS_INFO_SIGNAL
|
44
|
+
|
45
|
+
#mirror.update_gems { progress.updated true }
|
46
|
+
|
47
|
+
num_to_delete = mirror.gems_to_delete.size
|
48
|
+
|
49
|
+
#progress = ui.progress_reporter num_to_delete,
|
50
|
+
# "Deleting #{num_to_delete} gems"
|
51
|
+
|
52
|
+
trap(:INFO) { puts "Fetched: #{progress.count}/#{num_to_delete}" } if SUPPORTS_INFO_SIGNAL
|
53
|
+
|
54
|
+
mirror.delete_gems { progress.updated true }
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'rubygems/mirror'
|
2
|
+
require 'yaml'
|
3
|
+
require 'bundler'
|
4
|
+
|
5
|
+
module Gem
|
6
|
+
module SparseMirror
|
7
|
+
class Mirror < Gem::Mirror
|
8
|
+
attr_accessor :only, :except
|
9
|
+
|
10
|
+
def gems
|
11
|
+
update_specs unless File.exists?(to(SPECS_FILE))
|
12
|
+
|
13
|
+
gems = Marshal.load(Gem.read_binary(to(SPECS_FILE)))
|
14
|
+
|
15
|
+
if only
|
16
|
+
only_with_deps = fetch_specs_using_bundler
|
17
|
+
gems = gems.find_all { |name, _, _| only_with_deps.include?(name) }
|
18
|
+
end
|
19
|
+
|
20
|
+
gems.reject! { |name, _, _| except.include?(name) }
|
21
|
+
|
22
|
+
gems.map! do |name, ver, plat|
|
23
|
+
# If the platform is ruby, it is not in the gem name
|
24
|
+
"#{name}-#{ver}#{"-#{plat}" unless plat == RUBY}.gem"
|
25
|
+
end
|
26
|
+
gems
|
27
|
+
end
|
28
|
+
|
29
|
+
def fetch_specs_using_bundler
|
30
|
+
fetcher = Bundler::Fetcher.new(from)
|
31
|
+
|
32
|
+
deps = fetcher.fetch_remote_specs(only)
|
33
|
+
deps.values.first.map(&:first).uniq
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gem-sparse-mirror
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Florian Gilcher
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-01-17 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rubygems-mirror
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: bundler
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: Builds a sparse rubygems mirror that contains all dependencies of the
|
47
|
+
included gems.
|
48
|
+
email:
|
49
|
+
- florian.gilcher@asquera.de
|
50
|
+
executables:
|
51
|
+
- gem-sparse-mirror
|
52
|
+
extensions: []
|
53
|
+
extra_rdoc_files: []
|
54
|
+
files:
|
55
|
+
- .gitignore
|
56
|
+
- Gemfile
|
57
|
+
- LICENSE.txt
|
58
|
+
- README.md
|
59
|
+
- Rakefile
|
60
|
+
- bin/gem-sparse-mirror
|
61
|
+
- gem-sparse-mirror.gemspec
|
62
|
+
- lib/gem-sparse-mirror.rb
|
63
|
+
- lib/gem-sparse-mirror/command.rb
|
64
|
+
- lib/gem-sparse-mirror/mirror.rb
|
65
|
+
- lib/gem-sparse-mirror/version.rb
|
66
|
+
homepage: ''
|
67
|
+
licenses: []
|
68
|
+
post_install_message:
|
69
|
+
rdoc_options: []
|
70
|
+
require_paths:
|
71
|
+
- lib
|
72
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
80
|
+
requirements:
|
81
|
+
- - ! '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
requirements: []
|
85
|
+
rubyforge_project:
|
86
|
+
rubygems_version: 1.8.21
|
87
|
+
signing_key:
|
88
|
+
specification_version: 3
|
89
|
+
summary: Builds a sparse rubygems mirror that contains all dependencies of the included
|
90
|
+
gems.
|
91
|
+
test_files: []
|
92
|
+
has_rdoc:
|