gsrd 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.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/README.md +66 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/gsrd.gemspec +24 -0
- data/images/logo.png +0 -0
- data/images/option.png +0 -0
- data/lib/gsrd.rb +76 -0
- data/lib/gsrd/version.rb +3 -0
- metadata +99 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 6c701566c860517e52ded3b5dbb421e0656ec082
|
4
|
+
data.tar.gz: 9b937006dc6533a0ac432066ed071bff6d7d02d0
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 0d95dfa1548add82438349612abd58f254007e914be800aa973bfbc02b164d1403ff5f495377cd2e6bfa52d6f4b059a7d9edd35fc124e138f0ec1fcc452d01a1
|
7
|
+
data.tar.gz: c1d6e0718aa8263a19e80fea1c69bd902a79910df95ca8bc5ee6ac47da6d239237ff7ad29ad6bc608d29a3fc250357283922efe84774a88219848b6f1482c97e
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Leonardo Cardoso
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
<p align="center">
|
2
|
+
|
3
|
+

|
4
|
+
|
5
|
+
<p align="center">
|
6
|
+
**gsrd** downloads your public starred repos.<br />Just in case you want to keep a backup of them from time to time.
|
7
|
+
<p>
|
8
|
+
|
9
|
+
<p>
|
10
|
+
|
11
|
+
<hr />
|
12
|
+
|
13
|
+
## Configuration
|
14
|
+
|
15
|
+
### Getting your credential
|
16
|
+
In order to keep your privacy, create your [personal token on Github](https://github.com/settings/tokens). You just need to select the option `public_repo` as shown below:
|
17
|
+
|
18
|
+

|
19
|
+
|
20
|
+
## Installation
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
$ gem install gsrd
|
24
|
+
```
|
25
|
+
|
26
|
+
## Run
|
27
|
+
Run the code passing your access token as argument
|
28
|
+
|
29
|
+
<pre>
|
30
|
+
$ gsrd "<b>put</b>your<b>forty</b>character<b>generated</b>string<b>here</b>"
|
31
|
+
</pre>
|
32
|
+
|
33
|
+
|
34
|
+
## Requirement
|
35
|
+
|
36
|
+
* [wget](https://www.gnu.org/software/wget/)
|
37
|
+
|
38
|
+
## Information and Contact
|
39
|
+
|
40
|
+
Developed by [@LeonardoCardoso](https://github.com/LeonardoCardoso).
|
41
|
+
|
42
|
+
Contact me either by Twitter [@leocardz](https://twitter.com/leocardz) or emailing me to [contact@leocardz.com](mailto:contact@leocardz.com).
|
43
|
+
|
44
|
+
## License
|
45
|
+
|
46
|
+
The MIT License (MIT)
|
47
|
+
|
48
|
+
Copyright (c) 2016 Leonardo Cardoso
|
49
|
+
|
50
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
51
|
+
of this software and associated documentation files (the "Software"), to deal
|
52
|
+
in the Software without restriction, including without limitation the rights
|
53
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
54
|
+
copies of the Software, and to permit persons to whom the Software is
|
55
|
+
furnished to do so, subject to the following conditions:
|
56
|
+
|
57
|
+
The above copyright notice and this permission notice shall be included in all
|
58
|
+
copies or substantial portions of the Software.
|
59
|
+
|
60
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
61
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
62
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
63
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
64
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
65
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
66
|
+
SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "gsrd"
|
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
|
data/bin/setup
ADDED
data/gsrd.gemspec
ADDED
@@ -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
|
+
require 'gsrd/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "gsrd"
|
8
|
+
spec.version = Gsrd::VERSION
|
9
|
+
spec.authors = ["Leonardo Cardoso"]
|
10
|
+
spec.email = ["leo@leocardz.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{GitHub Starred Repos Downloader}
|
13
|
+
spec.description = %q{This gem downloads your public starred repos. Just in case you want to keep a backup of them from time to time}
|
14
|
+
spec.homepage = "https://github.com/LeonardoCardoso/gsrd"
|
15
|
+
spec.license = "MIT"
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_dependency 'httparty', '~> 0.13.7'
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.10"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
end
|
data/images/logo.png
ADDED
Binary file
|
data/images/option.png
ADDED
Binary file
|
data/lib/gsrd.rb
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
require "./gsrd/version"
|
2
|
+
|
3
|
+
module Gsrd
|
4
|
+
|
5
|
+
if ARGV.empty?
|
6
|
+
|
7
|
+
begin
|
8
|
+
raise ArgumentError
|
9
|
+
rescue Exception => ex
|
10
|
+
puts "\nERROR: You must provide your access_token.\nCheck it out @ https://github.com/LeonardoCardoso/gsrd#getting-your-credential\n\n"
|
11
|
+
end
|
12
|
+
|
13
|
+
exit
|
14
|
+
|
15
|
+
end
|
16
|
+
|
17
|
+
class Download
|
18
|
+
|
19
|
+
require "httparty"
|
20
|
+
|
21
|
+
$base_uri = "https://api.github.com"
|
22
|
+
$repos_uri = $base_uri + "/user/starred?per_page=100&access_token="
|
23
|
+
$archive = "/archive/"
|
24
|
+
$extension = ".zip"
|
25
|
+
$page = "&page="
|
26
|
+
|
27
|
+
def initialize(token)
|
28
|
+
@token = token
|
29
|
+
end
|
30
|
+
|
31
|
+
def go()
|
32
|
+
|
33
|
+
@directory_name = File.join(File.dirname(__FILE__), "../") + "gsrd-downloads"
|
34
|
+
Dir.mkdir(@directory_name) unless File.exists?(@directory_name)
|
35
|
+
|
36
|
+
@pagination = 1
|
37
|
+
|
38
|
+
loop do
|
39
|
+
|
40
|
+
response = HTTParty.get($repos_uri + @token + $page + "#{@pagination}")
|
41
|
+
|
42
|
+
for repo in response.parsed_response
|
43
|
+
|
44
|
+
@uri = repo["html_url"]
|
45
|
+
@download_uri = @uri + $archive + repo["default_branch"] + $extension
|
46
|
+
@file_name = repo["owner"]["login"] + "-" + repo["name"] + "-" + repo["default_branch"] + $extension
|
47
|
+
|
48
|
+
puts "\n\n======= DOWNLOADING " + repo["name"] + " ======= "
|
49
|
+
puts "URL: " + @uri
|
50
|
+
puts "Download URL: " + @download_uri
|
51
|
+
puts "started: " + Time.now.strftime("%d/%m/%Y %H:%M:%S")
|
52
|
+
|
53
|
+
@wget = "wget -O " + @directory_name + "/" + @file_name + " " + @download_uri
|
54
|
+
|
55
|
+
`#{@wget}`
|
56
|
+
|
57
|
+
puts "finished: " + Time.now.strftime("%d/%m/%Y %H:%M:%S")
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
@pagination += 1
|
62
|
+
|
63
|
+
break if response.parsed_response.count == 0
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
puts "\n\n======= Repos downloaded to gsrd-downloads directory =======\n\n"
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
gsrd = Download.new(ARGV[0])
|
74
|
+
gsrd.go()
|
75
|
+
|
76
|
+
end
|
data/lib/gsrd/version.rb
ADDED
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gsrd
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Leonardo Cardoso
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-07-14 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: httparty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.13.7
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.13.7
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.10'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.10'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description: This gem downloads your public starred repos. Just in case you want to
|
56
|
+
keep a backup of them from time to time
|
57
|
+
email:
|
58
|
+
- leo@leocardz.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- Gemfile
|
65
|
+
- LICENSE
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- bin/console
|
69
|
+
- bin/setup
|
70
|
+
- gsrd.gemspec
|
71
|
+
- images/logo.png
|
72
|
+
- images/option.png
|
73
|
+
- lib/gsrd.rb
|
74
|
+
- lib/gsrd/version.rb
|
75
|
+
homepage: https://github.com/LeonardoCardoso/gsrd
|
76
|
+
licenses:
|
77
|
+
- MIT
|
78
|
+
metadata: {}
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options: []
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '0'
|
88
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
requirements: []
|
94
|
+
rubyforge_project:
|
95
|
+
rubygems_version: 2.4.8
|
96
|
+
signing_key:
|
97
|
+
specification_version: 4
|
98
|
+
summary: GitHub Starred Repos Downloader
|
99
|
+
test_files: []
|