down_universe 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.
- data/.gitignore +23 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +30 -0
- data/Rakefile +2 -0
- data/bin/down_universe +5 -0
- data/down_universe.gemspec +25 -0
- data/lib/application.rb +45 -0
- data/lib/down_universe.rb +31 -0
- data/lib/down_universe/version.rb +3 -0
- metadata +106 -0
data/.gitignore
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
*.gem
|
|
2
|
+
*.rbc
|
|
3
|
+
.bundle
|
|
4
|
+
.config
|
|
5
|
+
.yardoc
|
|
6
|
+
.DS_Store
|
|
7
|
+
Gemfile.lock
|
|
8
|
+
InstalledFiles
|
|
9
|
+
_yardoc
|
|
10
|
+
coverage
|
|
11
|
+
doc/
|
|
12
|
+
lib/bundler/man
|
|
13
|
+
pkg
|
|
14
|
+
rdoc
|
|
15
|
+
spec/reports
|
|
16
|
+
test/tmp
|
|
17
|
+
test/version_tmp
|
|
18
|
+
tmp
|
|
19
|
+
*.bundle
|
|
20
|
+
*.so
|
|
21
|
+
*.o
|
|
22
|
+
*.a
|
|
23
|
+
mkmf.log
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2014 Aref Aslani
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Down Universe Torrent Manager
|
|
2
|
+
Downloads a file and creates a torrent from it and moves it to the specified directory.
|
|
3
|
+
|
|
4
|
+
## Installation
|
|
5
|
+
|
|
6
|
+
Add this line to your application's Gemfile:
|
|
7
|
+
|
|
8
|
+
gem 'down_universe'
|
|
9
|
+
|
|
10
|
+
And then execute:
|
|
11
|
+
|
|
12
|
+
$ bundle
|
|
13
|
+
|
|
14
|
+
Or install it yourself as:
|
|
15
|
+
|
|
16
|
+
$ gem install down_universe
|
|
17
|
+
|
|
18
|
+
Warning: This gem requires 'mktorrent' and 'wget' to correctly functioning
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
TODO: Write usage instructions here
|
|
23
|
+
|
|
24
|
+
## Contributing
|
|
25
|
+
|
|
26
|
+
1. Fork it ( https://github.com/arefaslani/down_universe/fork )
|
|
27
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
28
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
29
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
30
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/down_universe
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'down_universe/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "down_universe"
|
|
8
|
+
spec.version = DownUniverse::VERSION
|
|
9
|
+
spec.authors = ["Aref Aslani"]
|
|
10
|
+
spec.email = ["arefaslani@gmail.com"]
|
|
11
|
+
spec.summary = %q{Downloads a file and makes a torrent from it}
|
|
12
|
+
spec.description = %q{This program needs wget and mktorrent to work correctly and is a
|
|
13
|
+
dependency for UUT Download Application}
|
|
14
|
+
spec.homepage = ""
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
spec.files = `git ls-files -z`.split("\x0")
|
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
20
|
+
spec.require_paths = ["lib"]
|
|
21
|
+
|
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.6"
|
|
23
|
+
spec.add_development_dependency "rake"
|
|
24
|
+
spec.add_runtime_dependency "safe_shell", "~> 1.0"
|
|
25
|
+
end
|
data/lib/application.rb
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
require "down_universe/version"
|
|
2
|
+
require_relative "./down_universe.rb"
|
|
3
|
+
require "optparse"
|
|
4
|
+
|
|
5
|
+
class Application
|
|
6
|
+
attr_accessor :type, :user, :password, :output, :url
|
|
7
|
+
include DownUniverse::Downloadable
|
|
8
|
+
|
|
9
|
+
def run
|
|
10
|
+
# Parsing command line arguments
|
|
11
|
+
OptionParser.new do |opts|
|
|
12
|
+
opts.banner = "Usage: down_universe [options] url output.It Downloads the given 'url' and saves it in 'output' file"
|
|
13
|
+
|
|
14
|
+
opts.on("--user", "Sets the HTTP or FTP user.") do |user|
|
|
15
|
+
self.user = user
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
opts.on("--password", "Sets the HTTP or FTP password.") do |password|
|
|
19
|
+
self.password = password
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
opts.on("-t", "--type DOWNLOAD_TYPE", "Sets the download type available types are 'torrent', 'http' or 'ftp'. 'http' is the default value.") do |type|
|
|
23
|
+
self.type = type
|
|
24
|
+
end
|
|
25
|
+
end.parse!
|
|
26
|
+
|
|
27
|
+
# Get the output path and url from the ARGV variable
|
|
28
|
+
self.output = ARGV.pop
|
|
29
|
+
self.url = ARGV.pop
|
|
30
|
+
|
|
31
|
+
# Set default download type to http
|
|
32
|
+
self.type = 'http'
|
|
33
|
+
|
|
34
|
+
case self.type.downcase
|
|
35
|
+
when 'http'
|
|
36
|
+
http_download(self.url, self.output, self.user, self.password)
|
|
37
|
+
when 'ftp'
|
|
38
|
+
puts "Not implemented yet."
|
|
39
|
+
when 'torrent'
|
|
40
|
+
puts "Not implemented yet."
|
|
41
|
+
else
|
|
42
|
+
puts "The 'type' option could be one of the 'http', 'ftp' or 'torrent' options."
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require "down_universe/version"
|
|
2
|
+
require "safe_shell"
|
|
3
|
+
|
|
4
|
+
module DownUniverse
|
|
5
|
+
module Downloadable
|
|
6
|
+
|
|
7
|
+
# Public: Downloads a given HTTP url with 'wget'.
|
|
8
|
+
#
|
|
9
|
+
# url - The url to be downloaded. That should respond to to_str.
|
|
10
|
+
# output - Name and path of the output file.
|
|
11
|
+
# user - set both ftp and http user(Optional).
|
|
12
|
+
# password - set both ftp and http password(Optional).
|
|
13
|
+
#
|
|
14
|
+
# Returns boolean
|
|
15
|
+
#
|
|
16
|
+
# Examples
|
|
17
|
+
#
|
|
18
|
+
# http_download('http://test.com/som_file.iso', '/Users/test/file.iso')
|
|
19
|
+
# # => true
|
|
20
|
+
#
|
|
21
|
+
# http_download('http://test.com/som_file.iso', '/Users/test/file.iso')
|
|
22
|
+
# # => false
|
|
23
|
+
def http_download(url, output, user=nil, password=nil)
|
|
24
|
+
command = "wget -O #{output}"
|
|
25
|
+
command += " --user=#{user}" unless user.nil?
|
|
26
|
+
command += " --password=#{password}" unless password.nil?
|
|
27
|
+
command += " #{url.to_str}"
|
|
28
|
+
SafeShell.execute! command
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: down_universe
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
prerelease:
|
|
6
|
+
platform: ruby
|
|
7
|
+
authors:
|
|
8
|
+
- Aref Aslani
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2014-05-08 00:00:00.000000000 Z
|
|
13
|
+
dependencies:
|
|
14
|
+
- !ruby/object:Gem::Dependency
|
|
15
|
+
name: bundler
|
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
|
17
|
+
none: false
|
|
18
|
+
requirements:
|
|
19
|
+
- - ~>
|
|
20
|
+
- !ruby/object:Gem::Version
|
|
21
|
+
version: '1.6'
|
|
22
|
+
type: :development
|
|
23
|
+
prerelease: false
|
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
25
|
+
none: false
|
|
26
|
+
requirements:
|
|
27
|
+
- - ~>
|
|
28
|
+
- !ruby/object:Gem::Version
|
|
29
|
+
version: '1.6'
|
|
30
|
+
- !ruby/object:Gem::Dependency
|
|
31
|
+
name: rake
|
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
|
33
|
+
none: false
|
|
34
|
+
requirements:
|
|
35
|
+
- - ! '>='
|
|
36
|
+
- !ruby/object:Gem::Version
|
|
37
|
+
version: '0'
|
|
38
|
+
type: :development
|
|
39
|
+
prerelease: false
|
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
41
|
+
none: false
|
|
42
|
+
requirements:
|
|
43
|
+
- - ! '>='
|
|
44
|
+
- !ruby/object:Gem::Version
|
|
45
|
+
version: '0'
|
|
46
|
+
- !ruby/object:Gem::Dependency
|
|
47
|
+
name: safe_shell
|
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
|
49
|
+
none: false
|
|
50
|
+
requirements:
|
|
51
|
+
- - ~>
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '1.0'
|
|
54
|
+
type: :runtime
|
|
55
|
+
prerelease: false
|
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
+
none: false
|
|
58
|
+
requirements:
|
|
59
|
+
- - ~>
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '1.0'
|
|
62
|
+
description: ! "This program needs wget and mktorrent to work correctly and is a\n
|
|
63
|
+
\ dependency for UUT Download Application"
|
|
64
|
+
email:
|
|
65
|
+
- arefaslani@gmail.com
|
|
66
|
+
executables:
|
|
67
|
+
- down_universe
|
|
68
|
+
extensions: []
|
|
69
|
+
extra_rdoc_files: []
|
|
70
|
+
files:
|
|
71
|
+
- .gitignore
|
|
72
|
+
- Gemfile
|
|
73
|
+
- LICENSE.txt
|
|
74
|
+
- README.md
|
|
75
|
+
- Rakefile
|
|
76
|
+
- bin/down_universe
|
|
77
|
+
- down_universe.gemspec
|
|
78
|
+
- lib/application.rb
|
|
79
|
+
- lib/down_universe.rb
|
|
80
|
+
- lib/down_universe/version.rb
|
|
81
|
+
homepage: ''
|
|
82
|
+
licenses:
|
|
83
|
+
- MIT
|
|
84
|
+
post_install_message:
|
|
85
|
+
rdoc_options: []
|
|
86
|
+
require_paths:
|
|
87
|
+
- lib
|
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
89
|
+
none: false
|
|
90
|
+
requirements:
|
|
91
|
+
- - ! '>='
|
|
92
|
+
- !ruby/object:Gem::Version
|
|
93
|
+
version: '0'
|
|
94
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
|
+
none: false
|
|
96
|
+
requirements:
|
|
97
|
+
- - ! '>='
|
|
98
|
+
- !ruby/object:Gem::Version
|
|
99
|
+
version: '0'
|
|
100
|
+
requirements: []
|
|
101
|
+
rubyforge_project:
|
|
102
|
+
rubygems_version: 1.8.23.2
|
|
103
|
+
signing_key:
|
|
104
|
+
specification_version: 3
|
|
105
|
+
summary: Downloads a file and makes a torrent from it
|
|
106
|
+
test_files: []
|