depends-client 0.2.0.beta3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +34 -15
- data/bin/depends +17 -0
- data/lib/depends.rb +15 -3
- data/lib/depends/command_factory.rb +31 -0
- data/lib/depends/commands/base.rb +87 -0
- data/lib/depends/commands/install.rb +27 -25
- data/lib/depends/commands/list.rb +64 -11
- data/lib/depends/commands/upload.rb +70 -33
- data/lib/depends/config.rb +3 -13
- data/lib/depends/definition.rb +4 -1
- data/lib/depends/dsl/depend.rb +10 -6
- data/lib/depends/log.rb +6 -0
- data/lib/depends/log/formatter.rb +41 -0
- data/lib/depends/rest_client.rb +27 -14
- data/lib/depends/server.rb +0 -0
- data/lib/depends/util.rb +4 -6
- metadata +40 -37
- data/bin/depend +0 -6
- data/lib/depends/cli.rb +0 -83
- data/lib/depends/commands/versions.rb +0 -19
data/README.md
CHANGED
@@ -15,37 +15,56 @@ Depends is quite simple.
|
|
15
15
|
```bash
|
16
16
|
gem install depends-client
|
17
17
|
```
|
18
|
-
2. Setup ~/.depends/config.rb
|
19
18
|
|
20
|
-
|
21
|
-
depend config --key <your key here>
|
22
|
-
```
|
23
|
-
|
24
|
-
3. Define a Depends file at the root of your source repository. The format is as follows:
|
25
|
-
As of this release <code>source</code> is not longer necessary. The default location is always used.
|
19
|
+
2. Define a Depends file at the root of your source repository. The format is as follows:
|
26
20
|
|
27
21
|
```ruby
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
depend '
|
32
|
-
depend '
|
22
|
+
|
23
|
+
source :depends
|
24
|
+
|
25
|
+
depend 'Qt', :version => '4', :destination => 'External/Qt'
|
26
|
+
depend 'SevenZipSharp', :version => '4', :destination => 'External/SevenZipSharp'
|
27
|
+
depend 'Sqlite', :version => '4', :destination => 'External/Sqlite'
|
28
|
+
depend 'Xerces', :version => '4', :destination => 'External/Xerces'
|
29
|
+
depend 'Xsd', :version => '4', :destination => 'External/Xsd'
|
33
30
|
|
34
31
|
```
|
35
32
|
|
33
|
+
_source_ defines that location of the depends server. Currently :local, :depends, or a string to some other depends
|
34
|
+
server, i.e. http://example.com.
|
35
|
+
|
36
36
|
_depend_ defines what the dependency is, the version to install and the path to unpack it to
|
37
37
|
|
38
|
-
|
38
|
+
3. Execute Depends
|
39
39
|
```bash
|
40
40
|
depend
|
41
41
|
```
|
42
42
|
|
43
|
-
|
43
|
+
4. Add your Depends file to source control
|
44
44
|
|
45
45
|
_We also recomend that you add depends destinations to your gitignore and hgignore files._
|
46
46
|
|
47
|
-
|
47
|
+
Your done, packages are download, extracted and installed per the instructions in your gem file
|
48
|
+
|
49
|
+
|
50
|
+
Uploading A Dependency
|
51
|
+
----------------------
|
52
|
+
This tutorial does not cover installing a depends server, but asuming that you have a depends server setup, adding a new
|
53
|
+
dependency is simple.
|
54
|
+
|
55
|
+
1. Install Depends
|
56
|
+
|
57
|
+
```bash
|
58
|
+
gem install depends
|
59
|
+
````
|
60
|
+
2. Setup a directory that models what you want to upload. I.e. Create /tmp/openssl and add some files to it.
|
61
|
+
3. Package and upload
|
62
|
+
|
63
|
+
```bash
|
64
|
+
depend upload -s /tmp/openssl -d 'depends' -n "OpenSSL" -v '1.2.3b'
|
65
|
+
```
|
48
66
|
|
67
|
+
That's it, your package is created and uploaded to the depends server.
|
49
68
|
|
50
69
|
The Future
|
51
70
|
==========
|
data/bin/depends
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'depends'
|
4
|
+
time = Benchmark.realtime do
|
5
|
+
begin
|
6
|
+
a = Depends::CommandFactory.build.new
|
7
|
+
a.run
|
8
|
+
rescue Depends::Exceptions::SubCommandMissing => e
|
9
|
+
Depends::Log.debug ("Exception: #{e.inspect}")
|
10
|
+
Depends::Log.fatal ("SubCommand is not defined #{e.message}")
|
11
|
+
Process.exit 1
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
Depends::Log.debug ":total_runtime => #{time*1000} milliseconds"
|
16
|
+
|
17
|
+
|
data/lib/depends.rb
CHANGED
@@ -4,9 +4,19 @@ require 'net/http'
|
|
4
4
|
require 'json'
|
5
5
|
require 'fileutils'
|
6
6
|
require 'logger'
|
7
|
+
require 'mixlib/log'
|
8
|
+
require 'mixlib/config'
|
9
|
+
require 'mixlib/cli'
|
7
10
|
require 'digest/sha1'
|
8
11
|
require 'multi_json'
|
9
|
-
|
12
|
+
|
13
|
+
if RUBY_PLATFORM =~ /mingw32|mswin32/
|
14
|
+
unless Gem.available?('win32-dir')
|
15
|
+
`gem install win32-dir`
|
16
|
+
Gem.clear_paths
|
17
|
+
end
|
18
|
+
require 'win32/dir'
|
19
|
+
end
|
10
20
|
|
11
21
|
require 'depends/exceptions'
|
12
22
|
require 'depends/config'
|
@@ -14,9 +24,11 @@ require 'depends/util'
|
|
14
24
|
require 'depends/rest_client'
|
15
25
|
require 'depends/dsl/depend'
|
16
26
|
require 'depends/definition'
|
17
|
-
require '
|
27
|
+
require 'depends/log/formatter'
|
28
|
+
require 'depends/log'
|
29
|
+
require 'depends/command_factory'
|
18
30
|
|
31
|
+
require 'depends/commands/base'
|
19
32
|
require 'depends/commands/install'
|
20
33
|
require 'depends/commands/list'
|
21
|
-
require 'depends/commands/versions'
|
22
34
|
require 'depends/commands/upload'
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module Depends
|
2
|
+
module CommandFactory
|
3
|
+
class << self
|
4
|
+
def build
|
5
|
+
subcommand_class
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
def subcommand_class
|
10
|
+
command_words = ARGV.select {|arg| arg =~ /^(([[:alnum:]])[[:alnum:]\_\-]+)$/ }
|
11
|
+
if command_words.empty?
|
12
|
+
return Depends::Commands::Install
|
13
|
+
end
|
14
|
+
command_words.collect! {|word| word.titleize }
|
15
|
+
command_options = []
|
16
|
+
subcommand_class = nil
|
17
|
+
|
18
|
+
while ( !subcommand_class ) && ( !command_words.empty? )
|
19
|
+
constant_case_name = command_words.join('')
|
20
|
+
command_options << constant_case_name
|
21
|
+
command_constant = Depends::Commands.constants.select { |i| i.eql? constant_case_name.to_sym}
|
22
|
+
unless command_constant.empty?
|
23
|
+
return "Depends::Commands::#{constant_case_name}".constantize
|
24
|
+
end
|
25
|
+
command_words.pop
|
26
|
+
end
|
27
|
+
raise Depends::Exceptions::SubCommandMissing, "Possible SubCommands: #{command_options} "
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,87 @@
|
|
1
|
+
module Depends
|
2
|
+
module Commands
|
3
|
+
class Base
|
4
|
+
|
5
|
+
include Mixlib::CLI
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
super
|
9
|
+
|
10
|
+
trap("TERM") do
|
11
|
+
Depends::Commands::Base.fatal!("SIGTERM received, stopping", 1)
|
12
|
+
end
|
13
|
+
|
14
|
+
trap("INT") do
|
15
|
+
Depends::Commands::Base.fatal!("SIGINT received, stopping", 2)
|
16
|
+
end
|
17
|
+
|
18
|
+
processor, platform, *rest = RUBY_PLATFORM.split("-")
|
19
|
+
|
20
|
+
unless RUBY_PLATFORM =~ /mingw32|mswin32/
|
21
|
+
trap("QUIT") do
|
22
|
+
Depends::Log.info("SIGQUIT received, call stack:\n " + caller.join("\n "))
|
23
|
+
end
|
24
|
+
|
25
|
+
trap("HUP") do
|
26
|
+
Depends::Log.info("SIGHUP received, reconfiguring")
|
27
|
+
reconfigure
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
def reconfigure
|
34
|
+
parse_options
|
35
|
+
configure_depends
|
36
|
+
configure_logging
|
37
|
+
end
|
38
|
+
|
39
|
+
def run
|
40
|
+
reconfigure
|
41
|
+
setup_application
|
42
|
+
run_application
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
private
|
47
|
+
def configure_depends
|
48
|
+
|
49
|
+
if File.exist?('~/.depends')
|
50
|
+
Depends::Log.info "Loading config file from '~/.depends'"
|
51
|
+
Depends::Config.from_file('~/.depends')
|
52
|
+
end
|
53
|
+
|
54
|
+
FileUtils.mkdir_p Depends::Config.cache
|
55
|
+
end
|
56
|
+
|
57
|
+
def configure_logging
|
58
|
+
Depends::Log.formatter = Depends::Log::Formatter.new
|
59
|
+
Depends::Log.level = config[:log_level] || Logger::INFO
|
60
|
+
end
|
61
|
+
|
62
|
+
# Called prior to starting the application, by the run method
|
63
|
+
def setup_application
|
64
|
+
raise Depends::Exceptions::Application, "#{self.to_s}: you must override setup_application"
|
65
|
+
end
|
66
|
+
|
67
|
+
# Actually run the application
|
68
|
+
def run_application
|
69
|
+
raise Depends::Exceptions::Application, "#{self.to_s}: you must override run_application"
|
70
|
+
end
|
71
|
+
|
72
|
+
class << self
|
73
|
+
|
74
|
+
# Log a fatal error message to both STDERR and the Logger, exit the application
|
75
|
+
def fatal!(msg, err = -1)
|
76
|
+
Depends::Log.fatal(msg)
|
77
|
+
Process.exit err
|
78
|
+
end
|
79
|
+
|
80
|
+
def exit!(msg, err = -1)
|
81
|
+
Depends::Log.debug(msg)
|
82
|
+
Process.exit err
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
@@ -1,20 +1,21 @@
|
|
1
|
+
require 'benchmark'
|
1
2
|
module Depends
|
2
3
|
module Commands
|
3
|
-
class Install
|
4
|
+
class Install < Depends::Commands::Base
|
4
5
|
|
5
|
-
|
6
|
+
banner "Install dependencies"
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
exit(1)
|
13
|
-
end
|
14
|
-
end
|
8
|
+
option :log_level,
|
9
|
+
:short => "-l LEVEL",
|
10
|
+
:long => "--log_level LEVEL",
|
11
|
+
:description => "Set the log level (debug, info, warn, error, fatal)",
|
12
|
+
:proc => Proc.new { |l| l.downcase.to_sym }
|
15
13
|
|
16
|
-
|
17
|
-
|
14
|
+
def setup_application
|
15
|
+
Log.info "Installing dependencies..."
|
16
|
+
end
|
17
|
+
|
18
|
+
def run_application
|
18
19
|
check_for_file
|
19
20
|
load_depends_file
|
20
21
|
download_extract
|
@@ -25,7 +26,7 @@ module Depends
|
|
25
26
|
private
|
26
27
|
def check_for_file
|
27
28
|
unless Dir.entries(Dir.pwd).include?('Depends')
|
28
|
-
|
29
|
+
Depends::Log.error "Missing Depends file"
|
29
30
|
exit 1
|
30
31
|
end
|
31
32
|
end
|
@@ -39,7 +40,7 @@ module Depends
|
|
39
40
|
file = nil
|
40
41
|
end
|
41
42
|
|
42
|
-
|
43
|
+
Depends::Log.info "Updating #{file} with external dependencies..." if file
|
43
44
|
unless file.nil?
|
44
45
|
FileUtils.touch(file) unless File.exist? file
|
45
46
|
ignore_file = File.read(file)
|
@@ -49,12 +50,13 @@ module Depends
|
|
49
50
|
ignore.delete(line.chomp)
|
50
51
|
end
|
51
52
|
end
|
52
|
-
File.open(file, 'a')
|
53
|
+
File.open(file, 'a') { |f|
|
53
54
|
ignore.each do |i|
|
55
|
+
Depends::Log.debug "Adding #{i} to #{file}"
|
54
56
|
f.puts ""
|
55
57
|
f.puts i
|
56
58
|
end
|
57
|
-
|
59
|
+
}
|
58
60
|
end
|
59
61
|
end
|
60
62
|
|
@@ -64,31 +66,31 @@ module Depends
|
|
64
66
|
|
65
67
|
|
66
68
|
def load_depends_file
|
67
|
-
|
69
|
+
Depends::Log.info "Loading Dependencies..."
|
68
70
|
@def = Depends::DSL::Depend.evaluate('Depends')
|
69
71
|
unless @def.unmet_dependencies.empty?
|
70
|
-
|
72
|
+
Depends::Log.fatal "You have unmet dependencies in your sources, #{@def.unmet_dependencies.inspect}"
|
71
73
|
Process.exit 1
|
72
74
|
end
|
73
75
|
end
|
74
76
|
|
75
77
|
|
76
78
|
def download_extract
|
77
|
-
|
79
|
+
Depends::Log.info "Downloading and extracting missing dependencies..."
|
78
80
|
@def.dependencies.each do |dep|
|
79
|
-
file_name = "#{
|
81
|
+
file_name = "#{dep[:name]}-#{dep['number']}.zip"
|
80
82
|
cache_file = File.join(Depends::Config.cache,file_name)
|
81
83
|
cache_directory = File.join(Depends::Config.cache,File.basename(file_name,'.zip'))
|
82
84
|
|
83
85
|
unless File.exist?(cache_file) # and Digest::SHA1.file(cache_file).to_s.eql? dep["sha1"]
|
84
|
-
|
86
|
+
Depends::Log.info "Downloading #{dep[:name]}..."
|
85
87
|
just_downloaded = true
|
86
88
|
dep[:source].download_depend_version(dep[:name],dep["number"])
|
87
89
|
end
|
88
90
|
|
89
91
|
if just_downloaded or not File.exist? cache_directory
|
90
|
-
|
91
|
-
Util.un_zip(cache_file,cache_directory)
|
92
|
+
Depends::Log.info "Extracting #{cache_file}"
|
93
|
+
Util.un_zip(cache_file,cache_directory) unless config[:dry_run]
|
92
94
|
end
|
93
95
|
|
94
96
|
end
|
@@ -96,10 +98,10 @@ module Depends
|
|
96
98
|
|
97
99
|
def link
|
98
100
|
@def.dependencies.each do |dep|
|
99
|
-
source = File.join(Depends::Config.cache,File.basename(
|
101
|
+
source = File.join(Depends::Config.cache,File.basename("#{dep[:name]}-#{dep['number']}",'.zip'))
|
100
102
|
base_dir = File.dirname(dep[:destination])
|
101
103
|
FileUtils.mkdir_p(base_dir) unless File.exist? base_dir
|
102
|
-
|
104
|
+
Depends::Log.info "Linking #{source} to #{dep[:destination]}"
|
103
105
|
|
104
106
|
if RUBY_PLATFORM =~ /mingw32|mswin32/
|
105
107
|
Dir.delete dep[:destination] if File.exist? dep[:destination]
|
@@ -1,19 +1,72 @@
|
|
1
|
-
|
1
|
+
require 'benchmark'
|
2
2
|
module Depends
|
3
3
|
module Commands
|
4
|
-
class List
|
4
|
+
class List < Depends::Commands::Base
|
5
|
+
|
6
|
+
banner "List dependencies"
|
7
|
+
|
8
|
+
option :log_level,
|
9
|
+
:short => "-l LEVEL",
|
10
|
+
:long => "--log_level LEVEL",
|
11
|
+
:description => "Set the log level (debug, info, warn, error, fatal)",
|
12
|
+
:proc => Proc.new { |l| l.downcase.to_sym }
|
13
|
+
option :versions,
|
14
|
+
:short => "-d depend",
|
15
|
+
:long => "--depend d",
|
16
|
+
:description => "List the versions for a depend"
|
5
17
|
|
6
|
-
def
|
7
|
-
Depends
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
18
|
+
def setup_application
|
19
|
+
Log.info "Getting Depends from sources..."
|
20
|
+
end
|
21
|
+
|
22
|
+
def run_application
|
23
|
+
check_for_file
|
24
|
+
load_depends_file
|
25
|
+
if config[:versions]
|
26
|
+
results = []
|
27
|
+
@def.sources.each do |source|
|
28
|
+
source_index = results.count
|
29
|
+
results[source_index] = {:source => source.source_url, :versions => []}
|
30
|
+
begin
|
31
|
+
dep = source.get_depend(config[:versions])
|
14
32
|
|
33
|
+
dep['versions'].each do |version|
|
34
|
+
results[source_index][:versions] << version.keep_if { |key| ['number','notes','publisher','sha1'].include?(key) }
|
35
|
+
end
|
36
|
+
rescue Nestful::ResourceNotFound
|
37
|
+
puts " Depend not found on source"
|
38
|
+
end
|
39
|
+
puts results.to_yaml
|
40
|
+
end
|
41
|
+
else
|
42
|
+
results = []
|
43
|
+
@def.sources.each do |source|
|
44
|
+
source_index = results.count
|
45
|
+
results[source_index] = {:source => source.source_url, :depends => []}
|
46
|
+
source.list.each do |d|
|
47
|
+
results[source_index][:depends] << d.keep_if { |key| ['name','description'].include?(key) }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
results.each do |r|
|
51
|
+
r[:depends].sort_by! { |h| h['name']}
|
52
|
+
end
|
53
|
+
puts results.to_yaml
|
54
|
+
end
|
15
55
|
end
|
16
|
-
|
56
|
+
|
57
|
+
private
|
58
|
+
def check_for_file
|
59
|
+
unless Dir.entries(Dir.pwd).include?('Depends')
|
60
|
+
Depends::Log.error "Missing Depends file"
|
61
|
+
exit 1
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
|
66
|
+
def load_depends_file
|
67
|
+
@def = Depends::DSL::Depend.evaluate('Depends')
|
68
|
+
end
|
69
|
+
|
17
70
|
end
|
18
71
|
end
|
19
72
|
end
|
@@ -1,51 +1,88 @@
|
|
1
1
|
module Depends
|
2
2
|
module Commands
|
3
|
-
class Upload
|
3
|
+
class Upload < Depends::Commands::Base
|
4
4
|
|
5
|
+
class UploadConfig
|
6
|
+
extend(Mixlib::Config)
|
7
|
+
end
|
5
8
|
|
6
|
-
|
7
|
-
Depends::Config.load
|
8
|
-
client = Depends::RestClient.new
|
9
|
-
puts "CREATE: #{options.create}"
|
9
|
+
banner "Upload a dependency to a depends server"
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
option :source,
|
12
|
+
:short => "-s source",
|
13
|
+
:long => "--source source",
|
14
|
+
:description => "Source directory for dependency",
|
15
|
+
:required => true
|
16
|
+
option :key,
|
17
|
+
:short => "-k key",
|
18
|
+
:long => "--key key",
|
19
|
+
:description => "The API Key to use for upload",
|
20
|
+
:required => true
|
17
21
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
end
|
22
|
+
option :description,
|
23
|
+
:short => "-e description",
|
24
|
+
:long => "--description description",
|
25
|
+
:required => false
|
23
26
|
|
24
|
-
|
25
|
-
|
27
|
+
option :name,
|
28
|
+
:short => "-n name",
|
29
|
+
:long => "--name name",
|
30
|
+
:description => "Dependency Name",
|
31
|
+
:required => true
|
32
|
+
|
33
|
+
option :version,
|
34
|
+
:short => "-v version",
|
35
|
+
:long => "--version version",
|
36
|
+
:description => "Version to publish",
|
37
|
+
:required => true
|
38
|
+
|
39
|
+
option :destination,
|
40
|
+
:short => "-d destination",
|
41
|
+
:long => "--destination destination",
|
42
|
+
:description => "Destination to publish depend to",
|
43
|
+
:default => 'https://depends.io',
|
44
|
+
:proc => Proc.new { |o|
|
45
|
+
Depends::Util.depends_source o
|
46
|
+
}
|
26
47
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
48
|
+
option :log_level,
|
49
|
+
:short => "-l LEVEL",
|
50
|
+
:long => "--log_level LEVEL",
|
51
|
+
:description => "Set the log level (debug, info, warn, error, fatal)",
|
52
|
+
:proc => Proc.new { |l| l.downcase.to_sym }
|
53
|
+
|
54
|
+
def setup_application
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
def run_application
|
59
|
+
client = Depends::RestClient.new(config[:destination])
|
60
|
+
client.api_key = config[:key]
|
61
|
+
|
62
|
+
begin
|
63
|
+
Log.info "Getting Depend"
|
64
|
+
@dep = client.get_depend(config[:name])
|
65
|
+
rescue Nestful::ResourceNotFound => e
|
66
|
+
if config[:description].nil?
|
67
|
+
Log.fatal("Depends does not exist, you must specify a description")
|
68
|
+
exit(1)
|
35
69
|
end
|
36
|
-
|
37
|
-
|
70
|
+
Log.info "Creating Depends"
|
71
|
+
@dep = client.create_depend(config[:name],config[:description])
|
38
72
|
end
|
73
|
+
file = build_package
|
74
|
+
sha1 = Digest::SHA1.file(file).to_s
|
75
|
+
client.create_version(config[:name], :file => file, :sha1 => sha1, :number => config[:version])
|
39
76
|
end
|
40
77
|
|
41
78
|
private
|
42
79
|
|
43
|
-
def build_package
|
80
|
+
def build_package
|
44
81
|
upload_dir = File.join(Depends::Config.cache,'upload')
|
45
|
-
FileUtils.mkdir_p upload_dir
|
46
|
-
dest_file = File.join(upload_dir, "#{
|
47
|
-
FileUtils.
|
48
|
-
source_path = File.expand_path(
|
82
|
+
FileUtils.mkdir_p upload_dir unless File.exist? upload_dir
|
83
|
+
dest_file = File.join(upload_dir, "#{config[:name]}-#{config[:version]}.zip")
|
84
|
+
FileUtils.rm dest_file if File.exist? dest_file
|
85
|
+
source_path = File.expand_path(config[:source])
|
49
86
|
Zip::ZipFile.open(dest_file, Zip::ZipFile::CREATE) { |zipfile|
|
50
87
|
Dir["#{source_path}/**/*"].each do |file|
|
51
88
|
relative_path = file.to_s.gsub(source_path, '')
|
data/lib/depends/config.rb
CHANGED
@@ -2,16 +2,6 @@ module Depends
|
|
2
2
|
class Config
|
3
3
|
extend(Mixlib::Config)
|
4
4
|
|
5
|
-
cache File.expand_path('~/.
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
def self.load(file = '~/.depends/config.rb')
|
10
|
-
config_file = File.expand_path(file)
|
11
|
-
Depends::Config.from_file(config_file)
|
12
|
-
rescue
|
13
|
-
color("Failed to load config file, please run 'depend config'", :red)
|
14
|
-
exit(1)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
5
|
+
cache File.expand_path('~/.depends_cache')
|
6
|
+
end
|
7
|
+
end
|
data/lib/depends/definition.rb
CHANGED
@@ -5,6 +5,7 @@ module Depends
|
|
5
5
|
attr_reader :sources
|
6
6
|
attr_reader :dependencies
|
7
7
|
attr_reader :unmet_dependencies
|
8
|
+
attr_reader :default_source
|
8
9
|
|
9
10
|
def initialize(sources,dependencies, options ={})
|
10
11
|
@sources = sources
|
@@ -14,6 +15,7 @@ module Depends
|
|
14
15
|
def map(deps)
|
15
16
|
@dependencies = []
|
16
17
|
@unmet_dependencies = []
|
18
|
+
Log.debug " :definition => #{@def.inspect}"
|
17
19
|
deps.each do |dep|
|
18
20
|
dependency_met = false
|
19
21
|
sources.each do |source|
|
@@ -22,10 +24,11 @@ module Depends
|
|
22
24
|
server_dep[:source] = source
|
23
25
|
server_dep[:destination] = dep[:destination]
|
24
26
|
server_dep[:name] = dep[:name]
|
27
|
+
Log.debug ":server_dep => #{server_dep}"
|
25
28
|
@dependencies << server_dep
|
26
29
|
dependency_met = true
|
27
30
|
rescue Nestful::ResourceNotFound => e
|
28
|
-
|
31
|
+
Log.debug ":resource_not_found => #{e.inspect}"
|
29
32
|
end
|
30
33
|
end
|
31
34
|
|
data/lib/depends/dsl/depend.rb
CHANGED
@@ -13,7 +13,7 @@ module Depends
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def initialize
|
16
|
-
@sources = [
|
16
|
+
@sources = []
|
17
17
|
@dependencies = []
|
18
18
|
end
|
19
19
|
|
@@ -33,22 +33,26 @@ module Depends
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def source(source, options = {})
|
36
|
-
|
36
|
+
depends_source Depends::Util.depends_source(source)
|
37
37
|
end
|
38
38
|
|
39
|
-
def
|
40
|
-
|
39
|
+
def default
|
40
|
+
@default ||= @sources.last
|
41
|
+
end
|
42
|
+
|
43
|
+
def key(api_key)
|
44
|
+
@sources.last.api_key = api_key
|
41
45
|
end
|
42
46
|
|
43
47
|
def to_definition
|
44
48
|
@sources.uniq!
|
45
|
-
raise DslError, "No source specified! Try source :
|
49
|
+
raise DslError, "No source specified! Try source :depends" unless @sources.length > 0
|
46
50
|
Depends::Definition.new(@sources, @dependencies)
|
47
51
|
end
|
48
52
|
|
49
53
|
private
|
50
54
|
def depends_source(source)
|
51
|
-
|
55
|
+
@sources << Depends::RestClient.new(source)
|
52
56
|
end
|
53
57
|
|
54
58
|
end
|
data/lib/depends/log.rb
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'logger'
|
2
|
+
require 'time'
|
3
|
+
|
4
|
+
module Depends
|
5
|
+
class Log
|
6
|
+
class Formatter < Logger::Formatter
|
7
|
+
@@show_time = false
|
8
|
+
|
9
|
+
COLOR_MAP = {'DEBUG' =>'0;37', 'INFO'=>'32', 'WARN'=>'33', 'ERROR'=>'31', 'FATAL'=>'31', 'UNKNOWN'=>'37'}
|
10
|
+
|
11
|
+
def self.show_time=(show=false)
|
12
|
+
@@show_time = show
|
13
|
+
end
|
14
|
+
|
15
|
+
def call(severity, time, progname, msg)
|
16
|
+
color = COLOR_MAP[severity]
|
17
|
+
|
18
|
+
if @@show_time
|
19
|
+
sprintf("\033[0;37m%s \033[0m[\033[#{color}m%s\033[0m]: \033[0m%s\n", time.rfc2822(), severity, msg2str(msg))
|
20
|
+
else
|
21
|
+
sprintf("\033[#{color}m%s\033[0;37m: \033[0m%s\n", severity, msg2str(msg))
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# Converts some argument to a Logger.severity() call to a string. Regular strings pass through like
|
26
|
+
# normal, Exceptions get formatted as "message (class)\nbacktrace", and other random stuff gets
|
27
|
+
# put through "object.inspect"
|
28
|
+
def msg2str(msg)
|
29
|
+
case msg
|
30
|
+
when ::String
|
31
|
+
msg
|
32
|
+
when ::Exception
|
33
|
+
"#{ msg.message } (#{ msg.class })\n" <<
|
34
|
+
(msg.backtrace || []).join("\n")
|
35
|
+
else
|
36
|
+
msg.inspect
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
data/lib/depends/rest_client.rb
CHANGED
@@ -5,16 +5,18 @@ module Depends
|
|
5
5
|
class RestClient
|
6
6
|
|
7
7
|
attr_accessor :source_url
|
8
|
+
attr_accessor :api_key
|
8
9
|
attr_reader :cache
|
9
10
|
|
10
|
-
def initialize
|
11
|
-
@source_url =
|
12
|
-
cache_path = File.join(Depends::Config.cache,'rest',URI.parse(
|
11
|
+
def initialize(source)
|
12
|
+
@source_url = source
|
13
|
+
cache_path = File.join(Depends::Config.cache,'rest',URI.parse(source.to_s).host )
|
14
|
+
Depends::Log.debug ":cache_path => #{cache_path}"
|
13
15
|
@cache = ActiveSupport::Cache::FileStore.new(cache_path, :expires_in => 1.day)
|
14
16
|
end
|
15
17
|
|
16
18
|
def headers
|
17
|
-
{'key' =>
|
19
|
+
{'key' => api_key}
|
18
20
|
end
|
19
21
|
|
20
22
|
def create_version(name,options = {})
|
@@ -28,13 +30,22 @@ module Depends
|
|
28
30
|
|
29
31
|
def get_depend(name)
|
30
32
|
uri = "#{source_url}/depends/#{name}"
|
31
|
-
depend =
|
33
|
+
#depend = cache.read(uri)
|
34
|
+
#if depend.nil?
|
35
|
+
depend = Nestful.get uri, :format => :json, :headers => headers
|
36
|
+
#cache.write(uri,depend.to_json)
|
37
|
+
#else
|
38
|
+
# depend = ::MultiJson.load(depend)
|
39
|
+
#end
|
32
40
|
depend
|
33
41
|
end
|
34
42
|
|
35
43
|
def download_depend_version(name,version)
|
36
44
|
dest_file = File.join(Depends::Config.cache, "#{name}-#{version}.zip")
|
37
|
-
|
45
|
+
Log.info "#{source_url}/depends/#{name}/version/#{version}/download"
|
46
|
+
|
47
|
+
request = Nestful.get "#{source_url}/depends/#{name}/version/#{version}/download.url", :headers => headers
|
48
|
+
uri = URI.parse(request)
|
38
49
|
http = Net::HTTP.new(uri.host, uri.port)
|
39
50
|
http.use_ssl = true
|
40
51
|
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
@@ -51,13 +62,13 @@ module Depends
|
|
51
62
|
size += chunk.size
|
52
63
|
new_progress = (size * 100) / total
|
53
64
|
unless new_progress == progress
|
54
|
-
|
65
|
+
Log.info "\rDownloading %s (%3d%%) " % [name, new_progress]
|
55
66
|
end
|
56
67
|
progress = new_progress
|
57
68
|
end
|
58
69
|
|
59
70
|
temp_file.close
|
60
|
-
|
71
|
+
File.unlink dest_file if File.exists?(dest_file)
|
61
72
|
FileUtils.mkdir_p File.dirname(dest_file)
|
62
73
|
FileUtils.mv temp_file.path, dest_file, :force => true
|
63
74
|
end
|
@@ -82,16 +93,18 @@ module Depends
|
|
82
93
|
|
83
94
|
|
84
95
|
def get_dep_version(name,version)
|
96
|
+
Depends::Log.debug "[get] :ver => #{version}"
|
85
97
|
uri = "#{source_url}/depends/#{name}/version/#{version}"
|
86
|
-
depend =
|
98
|
+
#depend = cache.read(uri)
|
99
|
+
#if depend.nil?
|
100
|
+
depend = Nestful.get uri, :format => :json, :headers => headers
|
101
|
+
#cache.write(uri,depend.to_json)
|
102
|
+
#else
|
103
|
+
# depend = ::MultiJson.load(depend)
|
104
|
+
#end
|
87
105
|
depend
|
88
106
|
end
|
89
107
|
|
90
|
-
private
|
91
|
-
def get_downlad_uri(name,version)
|
92
|
-
request = Nestful.get "#{source_url}/depends/#{name}/version/#{version}/download.url", :headers => headers
|
93
|
-
uri = URI.parse(request)
|
94
|
-
end
|
95
108
|
|
96
109
|
end
|
97
110
|
end
|
File without changes
|
data/lib/depends/util.rb
CHANGED
@@ -5,12 +5,14 @@ module Depends
|
|
5
5
|
|
6
6
|
def self.un_zip(source,destination, options = {})
|
7
7
|
options.reverse_merge!({:overwrite => true})
|
8
|
-
|
8
|
+
Log.debug "Opening #{source}"
|
9
9
|
Zip::ZipFile.open(source) do |zip|
|
10
10
|
zip.each do |entry|
|
11
|
+
Log.debug (":entry => #{entry.name}")
|
11
12
|
path = ::File.join(destination, entry.name)
|
12
13
|
FileUtils.mkdir_p(::File.dirname(path))
|
13
14
|
if options[:overwrite] && ::File.exists?(path) && !::File.directory?(path)
|
15
|
+
Log.debug("Removing #{path}")
|
14
16
|
FileUtils.rm(path)
|
15
17
|
end
|
16
18
|
zip.extract(entry, path)
|
@@ -25,14 +27,10 @@ module Depends
|
|
25
27
|
when :local
|
26
28
|
"http://localhost:8080"
|
27
29
|
when :depends
|
28
|
-
"
|
30
|
+
"https://depends.cloudfoundry.com/"
|
29
31
|
else
|
30
32
|
source
|
31
33
|
end
|
32
34
|
end
|
33
|
-
|
34
|
-
def self.depend_name_with_version(dep)
|
35
|
-
"#{dep[:name]}-#{dep['number']}"
|
36
|
-
end
|
37
35
|
end
|
38
36
|
end
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: depends-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.0
|
5
|
-
prerelease:
|
4
|
+
version: 0.2.0
|
5
|
+
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Chris Roby
|
@@ -10,16 +10,16 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2012-07-19 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
16
|
+
name: mixlib-log
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ~>
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
22
|
+
version: 1.3.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -27,15 +27,15 @@ dependencies:
|
|
27
27
|
requirements:
|
28
28
|
- - ~>
|
29
29
|
- !ruby/object:Gem::Version
|
30
|
-
version:
|
30
|
+
version: 1.3.0
|
31
31
|
- !ruby/object:Gem::Dependency
|
32
|
-
name:
|
32
|
+
name: nestful
|
33
33
|
requirement: !ruby/object:Gem::Requirement
|
34
34
|
none: false
|
35
35
|
requirements:
|
36
36
|
- - ~>
|
37
37
|
- !ruby/object:Gem::Version
|
38
|
-
version: 0.
|
38
|
+
version: 0.0.8
|
39
39
|
type: :runtime
|
40
40
|
prerelease: false
|
41
41
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -43,15 +43,15 @@ dependencies:
|
|
43
43
|
requirements:
|
44
44
|
- - ~>
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 0.
|
46
|
+
version: 0.0.8
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
48
|
+
name: mixlib-config
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version:
|
54
|
+
version: 1.1.2
|
55
55
|
type: :runtime
|
56
56
|
prerelease: false
|
57
57
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -59,15 +59,15 @@ dependencies:
|
|
59
59
|
requirements:
|
60
60
|
- - ~>
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version:
|
62
|
+
version: 1.1.2
|
63
63
|
- !ruby/object:Gem::Dependency
|
64
|
-
name:
|
64
|
+
name: rubyzip
|
65
65
|
requirement: !ruby/object:Gem::Requirement
|
66
66
|
none: false
|
67
67
|
requirements:
|
68
68
|
- - ~>
|
69
69
|
- !ruby/object:Gem::Version
|
70
|
-
version:
|
70
|
+
version: 0.9.7
|
71
71
|
type: :runtime
|
72
72
|
prerelease: false
|
73
73
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -75,15 +75,15 @@ dependencies:
|
|
75
75
|
requirements:
|
76
76
|
- - ~>
|
77
77
|
- !ruby/object:Gem::Version
|
78
|
-
version:
|
78
|
+
version: 0.9.7
|
79
79
|
- !ruby/object:Gem::Dependency
|
80
|
-
name:
|
80
|
+
name: mixlib-cli
|
81
81
|
requirement: !ruby/object:Gem::Requirement
|
82
82
|
none: false
|
83
83
|
requirements:
|
84
84
|
- - ~>
|
85
85
|
- !ruby/object:Gem::Version
|
86
|
-
version: 1.
|
86
|
+
version: 1.2.2
|
87
87
|
type: :runtime
|
88
88
|
prerelease: false
|
89
89
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -91,15 +91,15 @@ dependencies:
|
|
91
91
|
requirements:
|
92
92
|
- - ~>
|
93
93
|
- !ruby/object:Gem::Version
|
94
|
-
version: 1.
|
94
|
+
version: 1.2.2
|
95
95
|
- !ruby/object:Gem::Dependency
|
96
|
-
name:
|
96
|
+
name: activesupport
|
97
97
|
requirement: !ruby/object:Gem::Requirement
|
98
98
|
none: false
|
99
99
|
requirements:
|
100
100
|
- - ~>
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version:
|
102
|
+
version: 3.2.3
|
103
103
|
type: :runtime
|
104
104
|
prerelease: false
|
105
105
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -107,59 +107,62 @@ dependencies:
|
|
107
107
|
requirements:
|
108
108
|
- - ~>
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version:
|
110
|
+
version: 3.2.3
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: rack-cache
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
none: false
|
115
115
|
requirements:
|
116
|
-
- -
|
116
|
+
- - ~>
|
117
117
|
- !ruby/object:Gem::Version
|
118
|
-
version: '
|
118
|
+
version: '1.2'
|
119
119
|
type: :runtime
|
120
120
|
prerelease: false
|
121
121
|
version_requirements: !ruby/object:Gem::Requirement
|
122
122
|
none: false
|
123
123
|
requirements:
|
124
|
-
- -
|
124
|
+
- - ~>
|
125
125
|
- !ruby/object:Gem::Version
|
126
|
-
version: '
|
126
|
+
version: '1.2'
|
127
127
|
- !ruby/object:Gem::Dependency
|
128
|
-
name:
|
128
|
+
name: multi_json
|
129
129
|
requirement: !ruby/object:Gem::Requirement
|
130
130
|
none: false
|
131
131
|
requirements:
|
132
|
-
- -
|
132
|
+
- - ~>
|
133
133
|
- !ruby/object:Gem::Version
|
134
|
-
version:
|
134
|
+
version: 1.3.2
|
135
135
|
type: :runtime
|
136
136
|
prerelease: false
|
137
137
|
version_requirements: !ruby/object:Gem::Requirement
|
138
138
|
none: false
|
139
139
|
requirements:
|
140
|
-
- -
|
140
|
+
- - ~>
|
141
141
|
- !ruby/object:Gem::Version
|
142
|
-
version:
|
142
|
+
version: 1.3.2
|
143
143
|
description:
|
144
144
|
email:
|
145
145
|
- croby@biaprotect.com
|
146
146
|
- pmorton@biaprotect.com
|
147
147
|
executables:
|
148
|
-
-
|
148
|
+
- depends
|
149
149
|
extensions: []
|
150
150
|
extra_rdoc_files: []
|
151
151
|
files:
|
152
|
-
- bin/
|
153
|
-
- lib/depends/
|
152
|
+
- bin/depends
|
153
|
+
- lib/depends/command_factory.rb
|
154
|
+
- lib/depends/commands/base.rb
|
154
155
|
- lib/depends/commands/install.rb
|
155
156
|
- lib/depends/commands/list.rb
|
156
157
|
- lib/depends/commands/upload.rb
|
157
|
-
- lib/depends/commands/versions.rb
|
158
158
|
- lib/depends/config.rb
|
159
159
|
- lib/depends/definition.rb
|
160
160
|
- lib/depends/dsl/depend.rb
|
161
161
|
- lib/depends/exceptions.rb
|
162
|
+
- lib/depends/log/formatter.rb
|
163
|
+
- lib/depends/log.rb
|
162
164
|
- lib/depends/rest_client.rb
|
165
|
+
- lib/depends/server.rb
|
163
166
|
- lib/depends/util.rb
|
164
167
|
- lib/depends.rb
|
165
168
|
- LICENSE
|
@@ -179,9 +182,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
179
182
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
180
183
|
none: false
|
181
184
|
requirements:
|
182
|
-
- - ! '
|
185
|
+
- - ! '>='
|
183
186
|
- !ruby/object:Gem::Version
|
184
|
-
version:
|
187
|
+
version: '0'
|
185
188
|
requirements: []
|
186
189
|
rubyforge_project:
|
187
190
|
rubygems_version: 1.8.24
|
data/bin/depend
DELETED
data/lib/depends/cli.rb
DELETED
@@ -1,83 +0,0 @@
|
|
1
|
-
require 'commander/import'
|
2
|
-
|
3
|
-
# :name is optional, otherwise uses the basename of this executable
|
4
|
-
program :name, 'depends'
|
5
|
-
program :version, '0.2.0'
|
6
|
-
program :description, 'Simple binary dependency management '
|
7
|
-
|
8
|
-
command :install do |c|
|
9
|
-
c.syntax = 'install'
|
10
|
-
c.description = 'Install application dependencies'
|
11
|
-
c.action do |args,options|
|
12
|
-
Depends::Commands::Install.new.run
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
|
17
|
-
command :list do |c|
|
18
|
-
c.syntax = 'list'
|
19
|
-
c.description = 'List application dependencies'
|
20
|
-
c.action do |args,options|
|
21
|
-
Depends::Commands::List.new.run
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
command :versions do |c|
|
26
|
-
c.syntax = 'versions'
|
27
|
-
c.description = 'List version if an application'
|
28
|
-
c.action do |args,options|
|
29
|
-
Depends::Commands::Versions.new.run(args)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
command :upload do |c|
|
35
|
-
c.syntax = 'upload'
|
36
|
-
c.description = 'Upload a dependency to the server'
|
37
|
-
c.option '--source DIR', String, 'Directory to be uploaded'
|
38
|
-
c.option '--name NAME', String, 'Name of the dependency'
|
39
|
-
c.option '--num VERSION', String, 'Version String'
|
40
|
-
c.option '--create','Create if does not exist'
|
41
|
-
c.option '--description', String, 'Description of the dependency'
|
42
|
-
c.action do |args,options|
|
43
|
-
|
44
|
-
options.source = ask("Source Directory: ") unless options.source
|
45
|
-
options.name = ask("Dependency Name: ") unless options.dep
|
46
|
-
options.num = ask("Version Number: ") unless options.num
|
47
|
-
options.description = ask("Description:") if not options.description and options.create
|
48
|
-
|
49
|
-
Depends::Commands::Upload.new.run(options)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
command :config do |c|
|
54
|
-
c.syntax = 'config'
|
55
|
-
c.description = 'Configure the depends client'
|
56
|
-
c.option '--key KEY', String, 'The key to use to access the depends server'
|
57
|
-
c.option '--server SERVER', String, 'The URL of the depends server'
|
58
|
-
c.option '--cache CACHE', String, 'The path to the folder to use for caching dependencies'
|
59
|
-
c.option '--overwrite','Overwrite an existing config file'
|
60
|
-
|
61
|
-
c.action do |args,options|
|
62
|
-
config_file = File.expand_path( '~/.depends/config.rb' )
|
63
|
-
config_dir = File.dirname(config_file)
|
64
|
-
|
65
|
-
if File.exists? config_file and not options.overwrite
|
66
|
-
say("Your configuration already exists, please specify --overwrite if you wish to overwrite the existing config")
|
67
|
-
exit(1)
|
68
|
-
end
|
69
|
-
|
70
|
-
options.key = ask("Depends server key ") unless options.key
|
71
|
-
|
72
|
-
config_content = ''
|
73
|
-
config_content << "api_key '#{options.key}'"
|
74
|
-
config_content << "server '#{options.server}" if options.server
|
75
|
-
config_content << "cache '#{options.cache}'" if options.cache
|
76
|
-
|
77
|
-
Dir.mkdir config_dir unless File.directory? config_dir
|
78
|
-
|
79
|
-
file = File.new(config_file,'w+')
|
80
|
-
file.write(config_content)
|
81
|
-
|
82
|
-
end
|
83
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
|
2
|
-
module Depends
|
3
|
-
module Commands
|
4
|
-
class Versions
|
5
|
-
|
6
|
-
def run(depend)
|
7
|
-
Depends::Config.load
|
8
|
-
client = Depends::RestClient.new()
|
9
|
-
dep = client.get_depend(depend[0])
|
10
|
-
|
11
|
-
headers = ['Version Number','SHA1', 'Publisher Address']
|
12
|
-
rows = dep['versions'].collect{ |i| [i['number'] ,i['sha1'],i['publisher']] }
|
13
|
-
table = Terminal::Table.new :title => "Versions for #{depend[0]}", :headings => headers, :rows => rows
|
14
|
-
puts table
|
15
|
-
end
|
16
|
-
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|