puppet-forge-mirror 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gemspec +1 -1
- data/bin/puppet-forge-mirror +18 -5
- data/lib/puppet-forge-mirror.rb +3 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 95ad37a72fd077978a6c8df5b4cfe729437c299e
|
4
|
+
data.tar.gz: e868c054f128679306ca5a50d58eb8b25d78e225
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8f6dcbdee362b072db3e8a627fc17d54e78d0cf06b2f720f800fb8338e1438f3bb9c213208ff823f58f94f527e62a2a28457541aa8c4d2f0e3633c4e71bf97e
|
7
|
+
data.tar.gz: 9585294c9c55e5fb17e50b897c316f96fba4a708931f3312e0c76544db2a2328220432a81589f8ce19eaeb33a9702ce8b90addef6bd068239a9466d4b5f731cc
|
data/.gemspec
CHANGED
data/bin/puppet-forge-mirror
CHANGED
@@ -1,12 +1,25 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'puppet-forge-mirror'
|
3
|
+
require 'optparse'
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
options = {}
|
6
|
+
OptionParser.new do |opts|
|
7
|
+
opts.banner = 'Usage: puppet-forge-mirror [options]'
|
8
|
+
opts.on('-m', '--modulepath PATH', 'Downloaded modules will be stored here') do |path|
|
9
|
+
options[:modulepath] = path
|
10
|
+
end
|
11
|
+
opts.on('--max-size MB', 'Maximum size of module in megabyte, bigger modules will be skipped') do |max_size|
|
12
|
+
options[:max_size] = max_size
|
13
|
+
end
|
14
|
+
end.parse!
|
8
15
|
|
16
|
+
if options[:modulepath].nil?
|
17
|
+
puts 'No modulepath specified'
|
18
|
+
exit 1
|
19
|
+
end
|
20
|
+
options[:max_size] = 2 if options[:max_size].nil?
|
9
21
|
fm = PuppetForgeMirror.new(
|
10
22
|
'https://forgeapi.puppetlabs.com',
|
11
|
-
|
23
|
+
options[:modulepath],
|
24
|
+
options[:max_size])
|
12
25
|
fm.download_modules
|
data/lib/puppet-forge-mirror.rb
CHANGED
@@ -7,9 +7,10 @@ require 'uri'
|
|
7
7
|
|
8
8
|
# Mirror /v3 forges
|
9
9
|
class PuppetForgeMirror
|
10
|
-
def initialize(forge_url, modules_dir)
|
10
|
+
def initialize(forge_url, modules_dir, max_size)
|
11
11
|
@modules_dir = modules_dir
|
12
12
|
@forge_url = forge_url
|
13
|
+
@max_size = max_size
|
13
14
|
end
|
14
15
|
|
15
16
|
# Perform http GET request, return response.body if status code is 200
|
@@ -53,7 +54,7 @@ class PuppetForgeMirror
|
|
53
54
|
|
54
55
|
r = JSON.parse(data)
|
55
56
|
r['results'].each do |m|
|
56
|
-
if m['file_size'] > 1024 * 1024 *
|
57
|
+
if m['file_size'] > 1024 * 1024 * @max_size.to_i
|
57
58
|
puts "#{m['metadata']['name']} is too big, skipping"
|
58
59
|
next
|
59
60
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: puppet-forge-mirror
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Johan Haals
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description:
|
14
14
|
email:
|