downcer 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.markdown +64 -0
- data/Rakefile +2 -0
- data/bin/downcer +13 -0
- data/config/.downcerrc +12 -0
- data/downcer.gemspec +18 -0
- data/lib/downcer.rb +4 -0
- data/lib/downcer/cli.rb +37 -0
- data/lib/downcer/version.rb +3 -0
- metadata +58 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Tomohiro, TAIRA
|
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.markdown
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
Downcer
|
2
|
+
================================================================================
|
3
|
+
|
4
|
+
Command line download tool helper
|
5
|
+
|
6
|
+
|
7
|
+
Requirements
|
8
|
+
-------------------------------------------------------------------------------
|
9
|
+
|
10
|
+
- Ruby 1.9.X
|
11
|
+
- curl / wget
|
12
|
+
|
13
|
+
|
14
|
+
Installation
|
15
|
+
-------------------------------------------------------------------------------
|
16
|
+
|
17
|
+
[RubyGems](http://rubygems.org)
|
18
|
+
|
19
|
+
gem install downcer
|
20
|
+
|
21
|
+
|
22
|
+
[Bundlizer](http://tomohiro.github.com/bundlizer)
|
23
|
+
|
24
|
+
$ bundlizer install Tomohiro/downcer
|
25
|
+
|
26
|
+
|
27
|
+
Usage
|
28
|
+
-------------------------------------------------------------------------------
|
29
|
+
|
30
|
+
1. Configuretion (Format is YAML)
|
31
|
+
|
32
|
+
Edit `.downcerrc`, and put your home direcotry.
|
33
|
+
|
34
|
+
$ vi ~/.downcerrc
|
35
|
+
---
|
36
|
+
youtube.com:
|
37
|
+
command: youtube-dl
|
38
|
+
option: -t
|
39
|
+
raw.github.com
|
40
|
+
command wget
|
41
|
+
github.com:
|
42
|
+
command: hub
|
43
|
+
option: clone
|
44
|
+
default:
|
45
|
+
command: curl
|
46
|
+
option: -LO
|
47
|
+
|
48
|
+
2. Run `downcer`
|
49
|
+
|
50
|
+
$ downcer https://github.com/sinatra/sinatra
|
51
|
+
Cloning into 'sinatra'...
|
52
|
+
remote: Counting objects: 11686, done.
|
53
|
+
remote: Compressing objects: 100% (4890/4890), done.
|
54
|
+
remote: Total 11686 (delta 7202), reused 11030 (delta 6617)
|
55
|
+
Receiving objects: 100% (11686/11686), 2.07 MiB | 348 KiB/s, done.
|
56
|
+
Resolving deltas: 100% (7202/7202), done.
|
57
|
+
|
58
|
+
|
59
|
+
LICENSE
|
60
|
+
--------------------------------------------------------------------------------
|
61
|
+
|
62
|
+
© 2012 Tomohiro, TAIRA.
|
63
|
+
This project is licensed under the MIT license.
|
64
|
+
See LICENSE for details.
|
data/Rakefile
ADDED
data/bin/downcer
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
|
4
|
+
# resolve bin path, ignoring symlinks
|
5
|
+
require 'pathname'
|
6
|
+
bin_file = Pathname.new(__FILE__).realpath
|
7
|
+
|
8
|
+
# add self to libpath
|
9
|
+
$:.unshift File.expand_path("../../lib", bin_file)
|
10
|
+
|
11
|
+
# start up the CLI
|
12
|
+
require 'downcer'
|
13
|
+
Downcer::CLI.start(*ARGV)
|
data/config/.downcerrc
ADDED
data/downcer.gemspec
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path('../lib/downcer/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ['Tomohiro, TAIRA']
|
6
|
+
gem.email = ['tomohiro.t@gmail.com']
|
7
|
+
gem.description = %q{Command line download tool helper}
|
8
|
+
gem.summary = %q{Command line download tool helper}
|
9
|
+
gem.homepage = 'http://github.com/Tomohiro/downcer'
|
10
|
+
gem.license = 'MIT'
|
11
|
+
|
12
|
+
gem.files = `git ls-files`.split($\)
|
13
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
14
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
15
|
+
gem.name = 'downcer'
|
16
|
+
gem.require_paths = ['lib']
|
17
|
+
gem.version = Downcer::VERSION
|
18
|
+
end
|
data/lib/downcer.rb
ADDED
data/lib/downcer/cli.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'yaml'
|
2
|
+
require 'uri'
|
3
|
+
|
4
|
+
module Downcer
|
5
|
+
CONFIG = "#{ENV['HOME']}/.downcerrc"
|
6
|
+
|
7
|
+
class CLI
|
8
|
+
def self.start(*args)
|
9
|
+
self.new(args.first).download
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(url)
|
13
|
+
@url = URI.parse(url)
|
14
|
+
@config = get_config(@url)
|
15
|
+
rescue URI::InvalidURIError => e
|
16
|
+
abort 'Usage: downcer <url>'
|
17
|
+
rescue SystemCallError => e
|
18
|
+
abort e.to_s
|
19
|
+
end
|
20
|
+
|
21
|
+
def download
|
22
|
+
puts "Use `#{@config['command']}`"
|
23
|
+
puts '--'
|
24
|
+
exec "#{@config['command']} #{@config['option']} '#{@url}'"
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
def get_config(url)
|
29
|
+
domain = url.host
|
30
|
+
yaml = YAML.load_file(CONFIG)
|
31
|
+
config = yaml.select { |host, v| domain.match(/#{host}/) }.values.first
|
32
|
+
config || yaml['default'] || { 'command' => 'curl', 'option' => '-LO' }
|
33
|
+
rescue Exception => e
|
34
|
+
abort e.to_s
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
metadata
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: downcer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Tomohiro, TAIRA
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-09-11 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Command line download tool helper
|
15
|
+
email:
|
16
|
+
- tomohiro.t@gmail.com
|
17
|
+
executables:
|
18
|
+
- downcer
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- .gitignore
|
23
|
+
- Gemfile
|
24
|
+
- LICENSE
|
25
|
+
- README.markdown
|
26
|
+
- Rakefile
|
27
|
+
- bin/downcer
|
28
|
+
- config/.downcerrc
|
29
|
+
- downcer.gemspec
|
30
|
+
- lib/downcer.rb
|
31
|
+
- lib/downcer/cli.rb
|
32
|
+
- lib/downcer/version.rb
|
33
|
+
homepage: http://github.com/Tomohiro/downcer
|
34
|
+
licenses:
|
35
|
+
- MIT
|
36
|
+
post_install_message:
|
37
|
+
rdoc_options: []
|
38
|
+
require_paths:
|
39
|
+
- lib
|
40
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
47
|
+
none: false
|
48
|
+
requirements:
|
49
|
+
- - ! '>='
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
52
|
+
requirements: []
|
53
|
+
rubyforge_project:
|
54
|
+
rubygems_version: 1.8.23
|
55
|
+
signing_key:
|
56
|
+
specification_version: 3
|
57
|
+
summary: Command line download tool helper
|
58
|
+
test_files: []
|