puppet-forge-mirror 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cc1e37ea1c172f05e43a6330616d5fb334135b05
4
- data.tar.gz: 6e3e28361feb561f72b126af1cbb1666f810e97e
3
+ metadata.gz: 95ad37a72fd077978a6c8df5b4cfe729437c299e
4
+ data.tar.gz: e868c054f128679306ca5a50d58eb8b25d78e225
5
5
  SHA512:
6
- metadata.gz: b8321c3692c06f251db3d4c0c4a4e8ac0c31ec78038d31bee9ea9b3926a8b9cb30476db6b4b073f8fec371ce4168fd9a0e518fabe95676766b62c051ca1d100d
7
- data.tar.gz: 0ca262fbe7301c8f676cedaabdc5fe4e0927fbd2d0536889c0688d7487080efdf461e836a269ae57c12d3361dc82d26efd56d48148596e0ea8de91d8d74c5a06
6
+ metadata.gz: e8f6dcbdee362b072db3e8a627fc17d54e78d0cf06b2f720f800fb8338e1438f3bb9c213208ff823f58f94f527e62a2a28457541aa8c4d2f0e3633c4e71bf97e
7
+ data.tar.gz: 9585294c9c55e5fb17e50b897c316f96fba4a708931f3312e0c76544db2a2328220432a81589f8ce19eaeb33a9702ce8b90addef6bd068239a9466d4b5f731cc
data/.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  Gem::Specification.new do |s|
3
3
  s.name = 'puppet-forge-mirror'
4
- s.version = '0.0.2'
4
+ s.version = '0.0.3'
5
5
  s.author = 'Johan Haals'
6
6
  s.email = ['johan.haals@gmail.com']
7
7
  s.homepage = 'https://github.com/jhaals/puppet-forge-mirror'
@@ -1,12 +1,25 @@
1
1
  #!/usr/bin/env ruby
2
2
  require 'puppet-forge-mirror'
3
+ require 'optparse'
3
4
 
4
- if ARGV[0].nil?
5
- puts "puppet-forge-mirror [module path]"
6
- exit
7
- end
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
- ARGV[0])
23
+ options[:modulepath],
24
+ options[:max_size])
12
25
  fm.download_modules
@@ -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 * 1
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.2
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-09 00:00:00.000000000 Z
11
+ date: 2014-09-12 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: