evoker 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/evoker/fullstack.rb +106 -0
- data/lib/evoker/version.rb +1 -1
- metadata +11 -5
@@ -0,0 +1,106 @@
|
|
1
|
+
require 'evoker'
|
2
|
+
require 'evoker/local_cache'
|
3
|
+
|
4
|
+
module Evoker
|
5
|
+
module FullStack
|
6
|
+
Context = Struct.new( :tarball_filename, :tarball_path, :tarball_extension,
|
7
|
+
:source_dir_basename, :source_dir,
|
8
|
+
:download, :unpack ) do
|
9
|
+
include Rake::DSL
|
10
|
+
def source_file(subpath)
|
11
|
+
File.join(self.source_dir, subpath)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
smart_const(:build_path, 'build')
|
17
|
+
smart_const(:download_path, 'download')
|
18
|
+
|
19
|
+
module_function
|
20
|
+
|
21
|
+
# Download tarball from given URL and unpack it for build.
|
22
|
+
#
|
23
|
+
# A file from address `tarball_url` is downloaded (via
|
24
|
+
# {#cached_wget}) to directory specified in the `:download_path`
|
25
|
+
# smart constant, and then unpacked in directory specified in the
|
26
|
+
# `:build_path` smart constant.
|
27
|
+
#
|
28
|
+
# The block is called in context that defines following methods:
|
29
|
+
# - `tarball_filename`
|
30
|
+
# - `tarball_path`
|
31
|
+
# - `tarball_extension` (e.g. `".tar.gz"`)
|
32
|
+
# - `source_dir_basename`
|
33
|
+
# - `source_dir`
|
34
|
+
# - `download` (a Rake task that downloads the tarball)
|
35
|
+
# - `unpack` (a Rake task that unpacks the tarball).
|
36
|
+
#
|
37
|
+
# Block should define a task or chain of tasks, that compile (and
|
38
|
+
# possibly install, depending on needs) module contained in the
|
39
|
+
# tarball. First of the tasks should depend on `unpack`, and last
|
40
|
+
# should be returned from the block.
|
41
|
+
#
|
42
|
+
# Task named `task_name` that depends on the task returned from the
|
43
|
+
# block will be created.
|
44
|
+
#
|
45
|
+
# @example
|
46
|
+
# from_tarball :carbon, CARBON_URL do
|
47
|
+
# file installed('bin/carbon-aggregator.py') => [ PIP, :py2cairo ] do
|
48
|
+
# rm_f source_file('setup.cfg')
|
49
|
+
# pip_install source_dir
|
50
|
+
# end
|
51
|
+
# end
|
52
|
+
def from_tarball(task_name, tarball_url, args={}, &block)
|
53
|
+
task task_name
|
54
|
+
|
55
|
+
build_path = File.expand_path(smart_const_get(:build_path))
|
56
|
+
download_path = File.expand_path(smart_const_get(:download_path))
|
57
|
+
|
58
|
+
mkdir_p build_path unless Dir.exists?(build_path)
|
59
|
+
mkdir_p download_path unless Dir.exists?(download_path)
|
60
|
+
|
61
|
+
tarball_filename = args[:filename] || File.basename(tarball_url)
|
62
|
+
tarball_path = File.join(download_path, tarball_filename)
|
63
|
+
tarball_extension = args[:extension] ||
|
64
|
+
( tarball_filename =~ /\.(tar(\.(Z|gz|bz2))?|zip)$/ ? $& : nil )
|
65
|
+
source_dir_basename = args[:directory] ||
|
66
|
+
File.basename(tarball_filename, tarball_extension)
|
67
|
+
source_dir = File.join(build_path, source_dir_basename)
|
68
|
+
unpack_command = args[:unpack] || {
|
69
|
+
'.tar.gz' => 'tar -xzf',
|
70
|
+
'.tar.bz2' => 'tar -xjf',
|
71
|
+
'.tar.Z' => 'tar -xzf',
|
72
|
+
'.tar' => 'tar -xf',
|
73
|
+
'.zip' => 'unzip' }[tarball_extension.downcase]
|
74
|
+
|
75
|
+
download = cached_wget(
|
76
|
+
tarball_url, args.merge(:output_file => tarball_path))
|
77
|
+
|
78
|
+
unpack = file source_dir => download do
|
79
|
+
chdir smart_const_get(:build_path) do
|
80
|
+
rm_rf source_dir_basename
|
81
|
+
sh "#{unpack_command} #{tarball_path}"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
ctx = FullStack::Context.new(
|
86
|
+
tarball_filename, tarball_path, tarball_extension,
|
87
|
+
source_dir_basename, source_dir,
|
88
|
+
download, unpack)
|
89
|
+
|
90
|
+
final_file = ctx.instance_eval(&block)
|
91
|
+
|
92
|
+
task final_file => unpack
|
93
|
+
task task_name => final_file
|
94
|
+
end
|
95
|
+
|
96
|
+
def download(url, args={})
|
97
|
+
args[:output_file] ||= File.expand_path(File.join(
|
98
|
+
smart_const_get(:download_path),
|
99
|
+
args[:filename] || File.basename(url)))
|
100
|
+
cached_wget(url, args)
|
101
|
+
end
|
102
|
+
|
103
|
+
def dl(filename)
|
104
|
+
File.join(smart_const_get(:download_path), filename)
|
105
|
+
end
|
106
|
+
end
|
data/lib/evoker/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evoker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-07-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,7 +21,12 @@ dependencies:
|
|
21
21
|
version: 0.9.2
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 0.9.2
|
25
30
|
description: ! 'Evoker is an add-on to Rake to download and manage project''s external
|
26
31
|
|
27
32
|
dependencied, update them as needed, cache them, etc.
|
@@ -32,6 +37,7 @@ executables: []
|
|
32
37
|
extensions: []
|
33
38
|
extra_rdoc_files: []
|
34
39
|
files:
|
40
|
+
- lib/evoker/fullstack.rb
|
35
41
|
- lib/evoker/local_cache.rb
|
36
42
|
- lib/evoker/python.rb
|
37
43
|
- lib/evoker/s3cache.rb
|
@@ -59,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
59
65
|
version: 1.3.6
|
60
66
|
requirements: []
|
61
67
|
rubyforge_project:
|
62
|
-
rubygems_version: 1.8.
|
68
|
+
rubygems_version: 1.8.24
|
63
69
|
signing_key:
|
64
70
|
specification_version: 3
|
65
71
|
summary: Rake add-on to download and manage project's external dependencies
|