-
Notifications
You must be signed in to change notification settings - Fork 2
/
test.rb
48 lines (39 loc) · 1.48 KB
/
test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
require File.expand_path('../lib/cutting_edge/workers/dependency.rb', __FILE__)
require File.expand_path('../lib/cutting_edge/repo.rb', __FILE__)
require 'moneta'
require 'pp'
require 'sinatra/logger'
# Mock Sinatra app which defines a store for us to use.
module CuttingEdge
class App
def self.store
@store ||= Moneta.new(:Memory)
end
def self.enable_logging
true
end
end
end
def print_gems(gems)
gems.each do |gem|
puts "#{gem.identifier}:"
pp ::CuttingEdge::App.store[gem.identifier]
end
end
::SemanticLogger.add_appender(file_name: 'development.log')
# Define some gems to fetch the dependencies of
gollum = CuttingEdge::GithubRepository.new('gollum', 'gollum')
lib = CuttingEdge::GithubRepository.new('gollum', 'gollum-lib', 'ruby', ['gemspec.rb', 'Gemfile'])
rjgit = CuttingEdge::GithubRepository.new('repotag', 'rjgit')
rails = CuttingEdge::GithubRepository.new('rails', 'rails')
flask_dance = CuttingEdge::GithubRepository.new('singingwolfboy', 'flask-dance', 'python')
gems = [gollum, lib, rjgit, rails, flask_dance]
# For illustration, print the output of the Moneta store for each gem -- they are all empty!
print_gems(gems)
# Now actually fetch the data via some workers
gems.each do |gem|
DependencyWorker.perform_async(gem.identifier, gem.lang, gem.locations, gem.dependency_types)
end
sleep 10 # Wait a bit for the workers to finish
# When we now print the contents of the moneta store for each gem, we will actually have data!
print_gems(gems)