eda-code-downloader 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1474335bb8e7e914a109c9a07772b1add61f6126
4
+ data.tar.gz: 03f2cc69689850d0de7f49c60ef66051e0b1c515
5
+ SHA512:
6
+ metadata.gz: ed3ce28af3d0fa5545f97d7434c526617e4f7bac94883f30e7228f10a9193e57e2c4011a09b9ee284b5d1e9156dad8044b6a6b407cad43258a73d3ebc31f41dc
7
+ data.tar.gz: 8299c47817a6cfce08c291f3ebb068b5ef56ad3bdf3288f019b9fcad5f3288041cf74bb612b66af8aae8de494b4a40f3525c235503f5efcd85975e3898bd3fb2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ gem 'octokit'
4
+ gem 'highline'
data/Gemfile.lock ADDED
@@ -0,0 +1,23 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ addressable (2.3.8)
5
+ faraday (0.9.1)
6
+ multipart-post (>= 1.2, < 3)
7
+ highline (1.7.2)
8
+ multipart-post (2.0.0)
9
+ octokit (4.0.1)
10
+ sawyer (~> 0.6.0, >= 0.5.3)
11
+ sawyer (0.6.0)
12
+ addressable (~> 2.3.5)
13
+ faraday (~> 0.8, < 0.10)
14
+
15
+ PLATFORMS
16
+ ruby
17
+
18
+ DEPENDENCIES
19
+ highline
20
+ octokit
21
+
22
+ BUNDLED WITH
23
+ 1.10.6
data/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # EDA Code Downloader
2
+
3
+ `eda-code-downloader` is a command line tool that clones down all of your Dev Academy code for you. It handles pairing and solo branch names, and can also be used to download all the challenges for a cohort.
4
+
5
+ ## Installation
6
+
7
+ ```
8
+ $ gem install eda-code-downloader
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```
14
+ $ eda-code-downloader
15
+ ```
16
+
17
+ You will be prompted to enter your cohort's Github organization, your Github credentials, your name and the location to clone.
18
+
19
+ Github organization is expected to be formatted as `great-spotted-kiwis-2014`. It's in the url of your cohort's github organization.
20
+
21
+ Your Github credentials are required to access your cohort's repositories. I recommend you choose to use a personal access token instead of your password, but either way nothing is stored.
22
+
23
+ You can issue a personal access token by visiting [this page](https://github.com/settings/tokens/new). You can then use it in place of a password. See this [Github help page](https://help.github.com/articles/creating-an-access-token-for-command-line-use/) for more information.
24
+
25
+ Your name is used to determine the branches to clone down. `eda-code-downloader` simply finds the first branch that contains the name you provide (case insensitive), so it finds branches like 'nick' or 'Nick_and_Hannah' alike. Bonus functionality: If you you provide 'master' as your name, the tool will download all of the repos from the cohort.
26
+
27
+ The location to clone defaults to `~/eda-code/<cohort>` if left blank.
28
+
29
+ Example usage for me:
30
+
31
+ ```
32
+ $ eda-code-downloader
33
+ Github Organization to download from (e.g: kakapo-2015): great-spotted-kiwis-2014
34
+ Github Username: Widdershin
35
+ Github Password/Personal Access Token (not stored): ****************
36
+ What's your name? All branches containing this string will be cloned.
37
+ nick
38
+ Where should I clone the repos to? |~/eda-repos/great-spotted-kiwis-2014|
39
+
40
+ Cloning repos from great-spotted-kiwis-2014...
41
+
42
+ ...
43
+ ```
44
+
45
+
46
+ ## Contributing
47
+
48
+ Bug reports and pull requests are welcome.
49
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "eda/code/downloader"
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
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'eda-code-downloader'
4
+
5
+ organization = ask("Github Organization to download from (e.g: kakapo-2015): ")
6
+ username = ask("Github Username: ")
7
+ password = ask("Github Password/Personal Access Token (not stored): ") { |q| q.echo = '*' }
8
+ branch_name_includes = ask("What's your name? All branches containing this string will be cloned.").downcase
9
+
10
+ default_location_to_clone = "~/eda-repos/#{organization}"
11
+ location_to_clone = File.expand_path(ask("Where should I clone the repos to?") { |q| q.default = default_location_to_clone })
12
+
13
+ Octokit.configure do |c|
14
+ c.login = username
15
+ c.password = password
16
+ end
17
+
18
+ puts "Cloning repos from #{organization}...\n"
19
+
20
+ EdaCodeDownloader.new(organization, branch_name_includes, location_to_clone).clone_repos
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "eda-code-downloader"
7
+ spec.version = "0.0.1"
8
+ spec.authors = ["Nick Johnstone"]
9
+ spec.email = ["ncwjohnstone@gmail.com"]
10
+
11
+ spec.summary = %q{A tool to clone all of your Dev Academy work for you.}
12
+ spec.description = %q{eda-code-downloader is a command line tool that will clone all of the work that you did at Dev Academy. It handles cloning from branches with names like Nick_and_Hannah so you will have both your solo and pairing work. You can also specify master as the branch to download all the challenges for a cohort.}
13
+ spec.homepage = "https://github.com/Widdershin/eda-code-downloader"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
16
+ spec.bindir = "bin"
17
+ spec.executables = 'eda-code-downloader'
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.10"
21
+ spec.add_development_dependency "rake", "~> 10.0"
22
+ spec.add_development_dependency "rspec", '~> 3.2', ">= 3.2.0"
23
+ spec.license = "MIT"
24
+ end
@@ -0,0 +1,49 @@
1
+ require 'octokit'
2
+ require 'highline/import'
3
+
4
+ class EdaCodeDownloader < Struct.new(:organization, :branch_name_includes, :clone_location)
5
+ def clone_repos
6
+ FileUtils::mkdir_p(clone_location) unless File.directory? clone_location
7
+
8
+ repos.each do |repo|
9
+ puts repo.name
10
+
11
+ branch_to_clone = repo.rels[:branches].get.data.find { |branch| branch[:name].downcase.include? branch_name_includes }
12
+
13
+ if branch_to_clone
14
+ puts "Found branch: #{branch_to_clone[:name]}, cloning..."
15
+ clone_repo(repo, branch_to_clone[:name], clone_location)
16
+ end
17
+ end
18
+ end
19
+
20
+ private
21
+
22
+ def repos
23
+ @repos ||= fetch_paginated_repos
24
+ end
25
+
26
+ def fetch_paginated_repos
27
+ next_repo_request = Octokit.org(organization).rels[:repos].get
28
+ repos = next_repo_request.data
29
+
30
+ until next_repo_request.rels[:next].nil?
31
+ next_repo_request = next_repo_request.rels[:next].get
32
+ repos.concat(next_repo_request.data)
33
+ end
34
+
35
+ repos
36
+ end
37
+
38
+ def clone_url(repo)
39
+ repo.rels.to_hash[:ssh_url]
40
+ end
41
+
42
+ def clone_repo(repo, branch, clone_location)
43
+ clone_job = fork do
44
+ exec "cd #{clone_location} && git clone -b #{branch} --single-branch #{clone_url(repo)} &>/dev/null"
45
+ end
46
+
47
+ Process.detach(clone_job)
48
+ end
49
+ end
metadata ADDED
@@ -0,0 +1,105 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: eda-code-downloader
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Nick Johnstone
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-07-29 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: '3.2'
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: 3.2.0
51
+ type: :development
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - "~>"
56
+ - !ruby/object:Gem::Version
57
+ version: '3.2'
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: 3.2.0
61
+ description: eda-code-downloader is a command line tool that will clone all of the
62
+ work that you did at Dev Academy. It handles cloning from branches with names like
63
+ Nick_and_Hannah so you will have both your solo and pairing work. You can also specify
64
+ master as the branch to download all the challenges for a cohort.
65
+ email:
66
+ - ncwjohnstone@gmail.com
67
+ executables:
68
+ - eda-code-downloader
69
+ extensions: []
70
+ extra_rdoc_files: []
71
+ files:
72
+ - Gemfile
73
+ - Gemfile.lock
74
+ - README.md
75
+ - Rakefile
76
+ - bin/console
77
+ - bin/eda-code-downloader
78
+ - bin/setup
79
+ - eda-code-downloader.gemspec
80
+ - lib/eda-code-downloader.rb
81
+ homepage: https://github.com/Widdershin/eda-code-downloader
82
+ licenses:
83
+ - MIT
84
+ metadata: {}
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ requirements: []
100
+ rubyforge_project:
101
+ rubygems_version: 2.2.2
102
+ signing_key:
103
+ specification_version: 4
104
+ summary: A tool to clone all of your Dev Academy work for you.
105
+ test_files: []