menagerie 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/menagerie/artifact.rb +12 -8
- data/lib/menagerie/collection.rb +6 -5
- data/lib/menagerie/release.rb +6 -4
- data/menagerie.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7550ca99813f39e03b386723ccfa404099230f2a
|
4
|
+
data.tar.gz: 72fbf28be1428d0077774135b17569a46516dc40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d567d4062f2f80480385d56d4ff0e65a500d6b302482ded9ac7bbd49cbe6253d6b9b9a73d695dde2ca4bef7df0e35f077aadb879e05c1b01064b5bf9119c884
|
7
|
+
data.tar.gz: 7e4b2246187a47ca7c1084f72fff9335f55aff8adfcc797be954fad59b65dfa61555833e10ec9d5b49d39b0152b57d550a36bf647cf4cdf5d7c9fbb4433c679c
|
data/lib/menagerie/artifact.rb
CHANGED
@@ -5,24 +5,28 @@ module Menagerie
|
|
5
5
|
##
|
6
6
|
# Artifacts are a stored file for a particular version of a project
|
7
7
|
class Artifact
|
8
|
-
attr_reader :version, :name, :
|
8
|
+
attr_reader :version, :name, :path
|
9
9
|
|
10
10
|
def initialize(params = {})
|
11
11
|
@config = params
|
12
|
-
@
|
13
|
-
@base, @name = Pathname.new(path).split.map(&:to_s)
|
14
|
-
@version = File.basename File.readlink(path)
|
12
|
+
@config[:artifact] ? create : parse
|
15
13
|
end
|
16
14
|
|
15
|
+
private
|
16
|
+
|
17
17
|
def create
|
18
|
-
name, version, url = @config[:artifact].values_at :name, :version, :url
|
19
|
-
path = "#{@config[:paths][:artifacts]}/#{name}/#{version}"
|
18
|
+
@name, @version, url = @config[:artifact].values_at :name, :version, :url
|
19
|
+
@path = "#{@config[:paths][:artifacts]}/#{@name}/#{@version}"
|
20
20
|
download url, path unless File.exist? path
|
21
21
|
File.chmod(@config[:artifact][:mode], path) if @config[:artifact][:mode]
|
22
|
-
path
|
23
22
|
end
|
24
23
|
|
25
|
-
|
24
|
+
def parse
|
25
|
+
link_path = @config[:path]
|
26
|
+
@name = Pathname.new(link_path).basename
|
27
|
+
@version = File.basename File.readlink(link_path)
|
28
|
+
@path = "#{@config[:paths][:artifacts]}/#{@name}/#{@version}"
|
29
|
+
end
|
26
30
|
|
27
31
|
def download(url, path)
|
28
32
|
FileUtils.mkdir_p File.dirname(path)
|
data/lib/menagerie/collection.rb
CHANGED
@@ -4,8 +4,8 @@ module Menagerie
|
|
4
4
|
##
|
5
5
|
# Connection object that contains releases
|
6
6
|
class Collection
|
7
|
-
def initialize(params =
|
8
|
-
params = Cymbal.symbolize
|
7
|
+
def initialize(params = nil)
|
8
|
+
params = Cymbal.symbolize(params || {})
|
9
9
|
@paths = default_paths.merge(params[:paths] || {})
|
10
10
|
@options = default_options.merge(params[:options] || {})
|
11
11
|
end
|
@@ -18,7 +18,7 @@ module Menagerie
|
|
18
18
|
|
19
19
|
def create(artifacts)
|
20
20
|
rotate
|
21
|
-
Release.new artifacts: artifacts, paths: @paths
|
21
|
+
Release.new artifacts: Cymbal.symbolize(artifacts), paths: @paths
|
22
22
|
reap if @options[:reap]
|
23
23
|
link_latest
|
24
24
|
end
|
@@ -27,8 +27,9 @@ module Menagerie
|
|
27
27
|
|
28
28
|
def rotate
|
29
29
|
existing = releases.reverse.sort
|
30
|
-
existing.
|
31
|
-
existing.each(&:
|
30
|
+
keepers = existing.shift(@options[:retention])
|
31
|
+
existing.each(&:delete)
|
32
|
+
keepers.each(&:rotate)
|
32
33
|
end
|
33
34
|
|
34
35
|
def reap
|
data/lib/menagerie/release.rb
CHANGED
@@ -14,7 +14,9 @@ module Menagerie
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def artifacts
|
17
|
-
Dir.glob("#{@path}/*").map
|
17
|
+
Dir.glob("#{@path}/*").map do |x|
|
18
|
+
Artifact.new(path: x, paths: @config[:paths])
|
19
|
+
end
|
18
20
|
end
|
19
21
|
|
20
22
|
def <=>(other)
|
@@ -24,9 +26,9 @@ module Menagerie
|
|
24
26
|
|
25
27
|
def create
|
26
28
|
path = "#{@config[:paths][:releases]}/0"
|
27
|
-
FileUtils.
|
29
|
+
FileUtils.mkdir_p path
|
28
30
|
@config[:artifacts].each do |x|
|
29
|
-
artifact = Artifact.new artifact: x, paths: @paths
|
31
|
+
artifact = Artifact.new artifact: x, paths: @config[:paths]
|
30
32
|
link artifact.path, "#{path}/#{x[:name]}"
|
31
33
|
end
|
32
34
|
path
|
@@ -35,7 +37,7 @@ module Menagerie
|
|
35
37
|
def link(source, target)
|
36
38
|
target_dir = Pathname.new(target).dirname
|
37
39
|
relative_source = Pathname.new(source).relative_path_from(target_dir)
|
38
|
-
|
40
|
+
FileUtils.ln_s relative_source, target
|
39
41
|
end
|
40
42
|
|
41
43
|
def rotate
|
data/menagerie.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: menagerie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Les Aker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-12-
|
11
|
+
date: 2014-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cymbal
|