menagerie 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 947a489a82cedc5005f4c5a99505c0a5f84feaa8
4
+ data.tar.gz: a9a09a817f1887be19666b9513e1cc99d11aa288
5
+ SHA512:
6
+ metadata.gz: 0132db19c6d99efb2e7e642785f025ff4302464bd88ab00cb331b43354343fd1675728302b5572dca5f25001d7298d27d6f7e2bbea56788a28f7d60238d63522
7
+ data.tar.gz: 0db5b60ead4c1ee71ef513a4dc7f5e256a43c3e7cf4dc577c9a0958ab18ac507c9327d7a95e72c01fcf007550c6ef3983a28434515f5e18d2785e20af6a34bc8
@@ -0,0 +1,5 @@
1
+ pkg/*.gem
2
+ coverage/
3
+ .coveralls.yml
4
+ .bundle
5
+ Gemfile.lock
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format Fuubar
2
+ --color
@@ -0,0 +1,2 @@
1
+ Encoding:
2
+ Enabled: false
@@ -0,0 +1,11 @@
1
+ language: ruby
2
+ cache: bundler
3
+ rvm:
4
+ - 2.1.0
5
+ - 2.0.0
6
+ - 1.9.3
7
+ notifications:
8
+ email: false
9
+ irc:
10
+ template:
11
+ - '%{repository}/%{branch}/%{build_number}: %{message} -- %{build_url}'
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Les Aker
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+
@@ -0,0 +1,22 @@
1
+ menagerie
2
+ =========
3
+
4
+ [![Gem Version](https://img.shields.io/gem/v/menagerie.svg)](https://rubygems.org/gems/menagerie)
5
+ [![Dependency Status](https://img.shields.io/gemnasium/akerl/menagerie.svg)](https://gemnasium.com/akerl/menagerie)
6
+ [![Code Climate](https://img.shields.io/codeclimate/github/akerl/menagerie.svg)](https://codeclimate.com/github/akerl/menagerie)
7
+ [![Coverage Status](https://img.shields.io/coveralls/akerl/menagerie.svg)](https://coveralls.io/r/akerl/menagerie)
8
+ [![Build Status](https://img.shields.io/travis/akerl/menagerie.svg)](https://travis-ci.org/akerl/menagerie)
9
+ [![MIT Licensed](https://img.shields.io/badge/license-MIT-green.svg)](https://tldrlegal.com/license/mit-license)
10
+
11
+ Simple release management tool for controlling versioned artifacts on an instance.
12
+
13
+ ## Usage
14
+
15
+ ## Installation
16
+
17
+ gem install menagerie
18
+
19
+ ## License
20
+
21
+ menagerie is released under the MIT License. See the bundled LICENSE file for details.
22
+
@@ -0,0 +1,14 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ require 'rubocop/rake_task'
4
+
5
+ desc 'Run tests'
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ desc 'Run Rubocop on the gem'
9
+ RuboCop::RakeTask.new(:rubocop) do |task|
10
+ task.patterns = ['lib/**/*.rb', 'spec/**/*.rb']
11
+ task.fail_on_error = true
12
+ end
13
+
14
+ task default: [:spec, :rubocop, :build, :install]
@@ -0,0 +1,16 @@
1
+ ##
2
+ # This module provides release collection management
3
+ module Menagerie
4
+ class << self
5
+ ##
6
+ # Insert a helper .new() method for creating a new Collection object
7
+
8
+ def new(*args)
9
+ self::Collection.new(*args)
10
+ end
11
+ end
12
+ end
13
+
14
+ require 'menagerie/artifact'
15
+ require 'menagerie/release'
16
+ require 'menagerie/collection'
@@ -0,0 +1,34 @@
1
+ require 'pathname'
2
+ require 'open-uri'
3
+
4
+ module Menagerie
5
+ ##
6
+ # Artifacts are a stored file for a particular version of a project
7
+ class Artifact
8
+ attr_reader :version, :name, :base, :path
9
+
10
+ def initialize(params = {})
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)
15
+ end
16
+
17
+ def create
18
+ name, version, url = @config[:artifact].values_at :name, :version, :url
19
+ path = "#{@config[:paths][:artifacts]}/#{name}/#{version}"
20
+ download url, path unless File.exist? path
21
+ File.chmod(@config[:artifact][:mode], path) if @config[:artifact][:mode]
22
+ path
23
+ end
24
+
25
+ private
26
+
27
+ def download(url, path)
28
+ FileUtils.mkdir_p File.dirname(path)
29
+ File.open(path, 'wb') do |fh|
30
+ open(url, 'rb') { |request| fh.write request.read }
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,56 @@
1
+ require 'cymbal'
2
+
3
+ module Menagerie
4
+ ##
5
+ # Connection object that contains releases
6
+ class Collection
7
+ def initialize(params = {})
8
+ params = Cymbal.symbolize params
9
+ @paths = default_paths.merge(params[:paths] || {})
10
+ @options = default_options.merge(params[:options] || {})
11
+ end
12
+
13
+ def releases
14
+ Dir.glob("#{@paths[:releases]}/*").map do |x|
15
+ Release.new path: x
16
+ end
17
+ end
18
+
19
+ def create(artifacts)
20
+ rotate
21
+ Release.new artifacts: artifacts, paths: @paths
22
+ reap if @options[:reap]
23
+ link_latest
24
+ end
25
+
26
+ private
27
+
28
+ def rotate
29
+ existing = releases.reverse.sort
30
+ existing.pop(existing.size - @options[:retention]).each(&:delete)
31
+ existing.each(&:rotate)
32
+ end
33
+
34
+ def reap
35
+ end
36
+
37
+ def link_latest
38
+ FileUtils.ln_sf releases.sort.first.path, "#{@paths[:latest]}"
39
+ end
40
+
41
+ def default_paths
42
+ {
43
+ artifacts: 'artifacts',
44
+ releases: 'releases',
45
+ latest: 'latest'
46
+ }
47
+ end
48
+
49
+ def default_options
50
+ {
51
+ retention: 5,
52
+ reap: true
53
+ }
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,49 @@
1
+ require 'pathname'
2
+ require 'fileutils'
3
+
4
+ module Menagerie
5
+ ##
6
+ # Release object containing artifacts
7
+ class Release
8
+ attr_reader :id, :base, :path
9
+
10
+ def initialize(params = {})
11
+ @config = params
12
+ @path = @config[:path] || create
13
+ @base, @id = Pathname.new(@path).split.map(&:to_s)
14
+ end
15
+
16
+ def artifacts
17
+ Dir.glob("#{@path}/*").map { |x| Artifact.new(path: x) }
18
+ end
19
+
20
+ def <=>(other)
21
+ return nil unless other.is_a? Release
22
+ @id.to_i <=> other.id.to_i
23
+ end
24
+
25
+ def create
26
+ path = "#{@config[:paths][:releases]}/0"
27
+ FileUtils.mkdir path
28
+ @config[:artifacts].each do |x|
29
+ artifact = Artifact.new artifact: x, paths: @paths
30
+ link artifact.path, "#{path}/#{x[:name]}"
31
+ end
32
+ path
33
+ end
34
+
35
+ def link(source, target)
36
+ target_dir = Pathname.new(target).dirname
37
+ relative_source = Pathname.new(source).relative_path_from(target_dir)
38
+ FileUtil.ln_s relative_source, target
39
+ end
40
+
41
+ def rotate
42
+ FileUtils.mv @path, "#{@base}/#{@id.to_i + 1}"
43
+ end
44
+
45
+ def delete
46
+ FileUtils.rm_r @path
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,23 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'menagerie'
3
+ s.version = '0.0.1'
4
+ s.date = Time.now.strftime("%Y-%m-%d")
5
+
6
+ s.summary = ''
7
+ s.description = ""
8
+ s.authors = ['Les Aker']
9
+ s.email = 'me@lesaker.org'
10
+ s.homepage = 'https://github.com/akerl/menagerie'
11
+ s.license = 'MIT'
12
+
13
+ s.files = `git ls-files`.split
14
+ s.test_files = `git ls-files spec/*`.split
15
+
16
+ s.add_dependency 'cymbal', '~> 0.0.1'
17
+
18
+ s.add_development_dependency 'rubocop', '~> 0.26.0'
19
+ s.add_development_dependency 'rake', '~> 10.3.2'
20
+ s.add_development_dependency 'coveralls', '~> 0.7.1'
21
+ s.add_development_dependency 'rspec', '~> 3.1.0'
22
+ s.add_development_dependency 'fuubar', '~> 2.0.0'
23
+ end
@@ -0,0 +1 @@
1
+ require 'spec_helper'
@@ -0,0 +1,10 @@
1
+ require 'simplecov'
2
+ require 'coveralls'
3
+
4
+ SimpleCov.formatter = Coveralls::SimpleCov::Formatter
5
+ SimpleCov.start do
6
+ add_filter '/spec/'
7
+ end
8
+
9
+ require 'rspec'
10
+ require 'menagerie'
metadata ADDED
@@ -0,0 +1,144 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: menagerie
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Les Aker
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-12-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: cymbal
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.0.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.0.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: rubocop
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.26.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.26.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 10.3.2
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 10.3.2
55
+ - !ruby/object:Gem::Dependency
56
+ name: coveralls
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.7.1
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.7.1
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 3.1.0
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 3.1.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: fuubar
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 2.0.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 2.0.0
97
+ description: ''
98
+ email: me@lesaker.org
99
+ executables: []
100
+ extensions: []
101
+ extra_rdoc_files: []
102
+ files:
103
+ - ".gitignore"
104
+ - ".rspec"
105
+ - ".rubocop.yml"
106
+ - ".travis.yml"
107
+ - Gemfile
108
+ - LICENSE
109
+ - README.md
110
+ - Rakefile
111
+ - lib/menagerie.rb
112
+ - lib/menagerie/artifact.rb
113
+ - lib/menagerie/collection.rb
114
+ - lib/menagerie/release.rb
115
+ - menagerie.gemspec
116
+ - spec/menagerie_spec.rb
117
+ - spec/spec_helper.rb
118
+ homepage: https://github.com/akerl/menagerie
119
+ licenses:
120
+ - MIT
121
+ metadata: {}
122
+ post_install_message:
123
+ rdoc_options: []
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ requirements: []
137
+ rubyforge_project:
138
+ rubygems_version: 2.2.2
139
+ signing_key:
140
+ specification_version: 4
141
+ summary: ''
142
+ test_files:
143
+ - spec/menagerie_spec.rb
144
+ - spec/spec_helper.rb