Module: DGet

Included in:
GitHubDoc, GoogleCodeDoc
Defined in:
lib/dget.rb,
lib/dget/utils.rb,
lib/dget/github.rb,
lib/dget/googlecode.rb

Defined Under Namespace

Classes: GitHubDoc, GitHubEngine, GoogleCodeDoc, GoogleCodeEngine

Constant Summary collapse

VERSION =
'0.0.1'
GH =
GitHubEngine.new
GC =
GoogleCodeEngine.new

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.cli(stdin, stdout, args) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/dget.rb', line 30

def self.cli(stdin, stdout, args)
  parsed = parse_args(args)
  if !parsed.empty?
    engine, project_spec, file = *parsed
    case engine
    when "github"
      GH.do(project_spec, file)
    when "googlecode"
      GC.do(project_spec, file)
    end
  else
    stdout.puts <<USAGE 
 Usage: 
 dget [github|googlecode] [user/project|project] [file]
 dget http://github.com/user/project [file]
USAGE
  end
end

.parse_args(args) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/dget.rb', line 17

def self.parse_args args    
  if (args[0] =~ /github.com\/(.*)\/(.*)[\/]{0,1}/)
    return ["github", $1 + "/" + $2, args[1]]
  end
  
  engine, project_spec, file = *args
  if (engine && project_spec)
    [engine, project_spec, file]
  else 
    []
  end
end

Instance Method Details

#N(url) ⇒ Object



2
3
4
5
6
7
# File 'lib/dget/utils.rb', line 2

def N url
  Nokogiri::HTML(open(url))
rescue SocketError => e
  puts "No connection available: #{url}"
  exit 1
end