docker-clone 0.1.0

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.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/bin/docker-clone +4 -0
  3. data/lib/docker_clone.rb +83 -0
  4. metadata +45 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6994ab4fdcd04d6eee936de0a7c914b799908dd237bc1103a9246f72f98bbb9f
4
+ data.tar.gz: 66159307c9e198608c07f2cfdf64e2d3e1f29dbc471cc55a9b01a549dd631b70
5
+ SHA512:
6
+ metadata.gz: bbabdda72d504772cfb0da648daf4c84b784e7bd71fa544be6807251c3792fe2480287ca55ade94d8992da56da1603d94afcd72d7e5a61bfcda6710d8bd180a0
7
+ data.tar.gz: 8b74f4893bb8a3ce5867da6af38c435c23cac98b502821b185c85c55a35f100a0be5ad13a6ac29a9318f5016cb8632a4a82668b1efd6257e3794deece39abbd2
@@ -0,0 +1,4 @@
1
+ #! /usr/bin/env ruby
2
+ require "docker_clone"
3
+
4
+ DockerClone.new.clone_repos
@@ -0,0 +1,83 @@
1
+ require "yaml"
2
+ require "optparse"
3
+ require "pathname"
4
+
5
+ CONFIG_DESCRIPTION = "Path to your docker pull config file"
6
+ HELP_DESCRIPTION = "Show this help message"
7
+
8
+ HELP_BANNER = "Usage: docker-pull [options]"
9
+
10
+ DEFAULT_WORKING_DIR = "./"
11
+
12
+ class NoRepoException < Exception
13
+ end
14
+
15
+ class DockerClone
16
+ def initialize
17
+ get_config
18
+ end
19
+
20
+ def clone_repos
21
+ working_dir = @@options[:working_dir] || DEFAULT_WORKING_DIR
22
+ Dir.chdir(working_dir) do
23
+ @@docker_pull["repos"].each do |repo|
24
+ clone_repo(repo)
25
+ end
26
+ end
27
+ end
28
+
29
+ private
30
+
31
+ def parse_options
32
+ options = { config_path: "docker-pull.yml" }
33
+ options.tap do |options|
34
+ OptionParser.new do |parser|
35
+ parser.banner = HELP_BANNER
36
+ parser.separator ""
37
+ parser.on("-h", "--help", HELP_DESCRIPTION) do
38
+ puts parser
39
+ exit(true)
40
+ end
41
+ parser.on("-c", "--config config_file_path", CONFIG_DESCRIPTION) do |config_path|
42
+ options[:config_path] = config_path
43
+ end
44
+ end.parse!
45
+ end
46
+ end
47
+
48
+ def full_path(pathname)
49
+ path = Pathname.new(pathname)
50
+ path.expand_path
51
+ end
52
+
53
+ def read_docker_file(pathname)
54
+ path = full_path(pathname)
55
+ file = File.read(path)
56
+ YAML.load(file)
57
+ end
58
+
59
+ def print_docker_pull_error(path)
60
+ puts "No corresponding config file, looking for #{path}"
61
+ end
62
+
63
+ def print_docker_pull_error_and_exit
64
+ config_path = @@options[:config_path]
65
+ full_config_path = full_path(config_path)
66
+
67
+ print_docker_pull_error(full_config_path)
68
+ exit(false)
69
+ end
70
+
71
+ def get_config
72
+ @@options ||= parse_options
73
+ @@docker_pull ||= read_docker_file(@@options[:config_path])
74
+ rescue
75
+ print_docker_pull_error_and_exit
76
+ end
77
+
78
+ def clone_repo(repo)
79
+ url, name = repo["url"], repo["name"]
80
+ puts "No URL or name given for your repo. #{url} #{name}" if !url || !name
81
+ `git clone #{url} #{name}`
82
+ end
83
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: docker-clone
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Guillaume Hivert
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2019-03-24 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Get all your dockers repos
14
+ email: hivert.is.coming@gmail.com
15
+ executables:
16
+ - docker-clone
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - bin/docker-clone
21
+ - lib/docker_clone.rb
22
+ homepage:
23
+ licenses:
24
+ - MIT
25
+ metadata: {}
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubygems_version: 3.0.3
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: Get all your dockers repos
45
+ test_files: []