menagerie 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 947a489a82cedc5005f4c5a99505c0a5f84feaa8
4
- data.tar.gz: a9a09a817f1887be19666b9513e1cc99d11aa288
3
+ metadata.gz: 7550ca99813f39e03b386723ccfa404099230f2a
4
+ data.tar.gz: 72fbf28be1428d0077774135b17569a46516dc40
5
5
  SHA512:
6
- metadata.gz: 0132db19c6d99efb2e7e642785f025ff4302464bd88ab00cb331b43354343fd1675728302b5572dca5f25001d7298d27d6f7e2bbea56788a28f7d60238d63522
7
- data.tar.gz: 0db5b60ead4c1ee71ef513a4dc7f5e256a43c3e7cf4dc577c9a0958ab18ac507c9327d7a95e72c01fcf007550c6ef3983a28434515f5e18d2785e20af6a34bc8
6
+ metadata.gz: 4d567d4062f2f80480385d56d4ff0e65a500d6b302482ded9ac7bbd49cbe6253d6b9b9a73d695dde2ca4bef7df0e35f077aadb879e05c1b01064b5bf9119c884
7
+ data.tar.gz: 7e4b2246187a47ca7c1084f72fff9335f55aff8adfcc797be954fad59b65dfa61555833e10ec9d5b49d39b0152b57d550a36bf647cf4cdf5d7c9fbb4433c679c
@@ -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, :base, :path
8
+ attr_reader :version, :name, :path
9
9
 
10
10
  def initialize(params = {})
11
11
  @config = params
12
- @path = @config[:path] || create
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
- private
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)
@@ -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 params
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.pop(existing.size - @options[:retention]).each(&:delete)
31
- existing.each(&:rotate)
30
+ keepers = existing.shift(@options[:retention])
31
+ existing.each(&:delete)
32
+ keepers.each(&:rotate)
32
33
  end
33
34
 
34
35
  def reap
@@ -14,7 +14,9 @@ module Menagerie
14
14
  end
15
15
 
16
16
  def artifacts
17
- Dir.glob("#{@path}/*").map { |x| Artifact.new(path: x) }
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.mkdir path
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
- FileUtil.ln_s relative_source, target
40
+ FileUtils.ln_s relative_source, target
39
41
  end
40
42
 
41
43
  def rotate
data/menagerie.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'menagerie'
3
- s.version = '0.0.1'
3
+ s.version = '0.0.2'
4
4
  s.date = Time.now.strftime("%Y-%m-%d")
5
5
 
6
6
  s.summary = ''
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.1
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-13 00:00:00.000000000 Z
11
+ date: 2014-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cymbal