velcro 0.0.1
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.
- data/.gitignore +17 -0
- data/.rspec +1 -0
- data/.travis.yml +8 -0
- data/Gemfile +2 -0
- data/LICENSE.txt +22 -0
- data/README.md +59 -0
- data/Rakefile +6 -0
- data/lib/velcro.rb +27 -0
- data/lib/velcro/brewfile.rb +35 -0
- data/lib/velcro/homebrew.rb +43 -0
- data/lib/velcro/lockfile.rb +55 -0
- data/lib/velcro/version.rb +3 -0
- data/spec/velcro/brewfile_spec.rb +32 -0
- data/spec/velcro/homebrew_spec.rb +41 -0
- data/spec/velcro/lockfile_spec.rb +38 -0
- data/spec/velcro_spec.rb +30 -0
- data/velcro.gemspec +21 -0
- metadata +122 -0
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 vanstee
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
# Velcro
|
2
|
+
|
3
|
+
[](http://travis-ci.org/vanstee/velcro)
|
4
|
+
|
5
|
+
Manage your dependencies with homebrew like you manage your gems with
|
6
|
+
bundler.
|
7
|
+
|
8
|
+
## Getting Started
|
9
|
+
|
10
|
+
1. Install the gem
|
11
|
+
|
12
|
+
```bash
|
13
|
+
gem install velcro
|
14
|
+
```
|
15
|
+
|
16
|
+
2. Open up a project and install dependencies
|
17
|
+
|
18
|
+
```bash
|
19
|
+
velcro install
|
20
|
+
```
|
21
|
+
|
22
|
+
If this is the first time you are installing the project a `Brewfile`
|
23
|
+
and `Brewfile.lock` will be generated.
|
24
|
+
|
25
|
+
3. Update a dependency to the most recent version
|
26
|
+
|
27
|
+
```bash
|
28
|
+
velcro update redis
|
29
|
+
```
|
30
|
+
|
31
|
+
This will update the version in the `Brewfile.lock`.
|
32
|
+
|
33
|
+
## Give Back
|
34
|
+
|
35
|
+
1. Fork it:
|
36
|
+
|
37
|
+
https://help.github.com/articles/fork-a-repo
|
38
|
+
|
39
|
+
2. Create your feature branch:
|
40
|
+
|
41
|
+
```bash
|
42
|
+
git checkout -b fixes_horrible_spelling_errors
|
43
|
+
```
|
44
|
+
|
45
|
+
3. Commit your changes:
|
46
|
+
|
47
|
+
```bash
|
48
|
+
git commit -am 'Really? You spelled application as "applickachon"?'
|
49
|
+
```
|
50
|
+
|
51
|
+
4. Push the branch:
|
52
|
+
|
53
|
+
```bash
|
54
|
+
git push origin fixes_horrible_spelling_errors
|
55
|
+
```
|
56
|
+
|
57
|
+
5. Create a pull request:
|
58
|
+
|
59
|
+
https://help.github.com/articles/using-pull-requests
|
data/Rakefile
ADDED
data/lib/velcro.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'velcro/version'
|
2
|
+
require 'velcro/homebrew'
|
3
|
+
require 'velcro/brewfile'
|
4
|
+
require 'velcro/lockfile'
|
5
|
+
|
6
|
+
class Velcro
|
7
|
+
attr_accessor :homebrew, :brewfile, :lockfile
|
8
|
+
|
9
|
+
def initialize(path)
|
10
|
+
self.homebrew = Homebrew.new
|
11
|
+
self.brewfile = Brewfile.new(path)
|
12
|
+
self.lockfile = Lockfile.new(path)
|
13
|
+
end
|
14
|
+
|
15
|
+
def install
|
16
|
+
install_dependencies
|
17
|
+
generate_lockfile
|
18
|
+
end
|
19
|
+
|
20
|
+
def install_dependencies
|
21
|
+
homebrew.install_dependencies(brewfile.dependencies)
|
22
|
+
end
|
23
|
+
|
24
|
+
def generate_lockfile
|
25
|
+
lockfile.generate(brewfile.dependencies)
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
class Velcro
|
4
|
+
class Brewfile
|
5
|
+
DEPENDENCY_FORMAT = %r{^brew '(?<name>\S*)'(, '(?<version>\S*)')?$}
|
6
|
+
|
7
|
+
attr_accessor :path
|
8
|
+
|
9
|
+
def initialize(path)
|
10
|
+
self.path = path
|
11
|
+
end
|
12
|
+
|
13
|
+
def dependencies
|
14
|
+
parse_dependencies(content)
|
15
|
+
end
|
16
|
+
|
17
|
+
def parse_dependencies(content)
|
18
|
+
content.split("\n").map do |line|
|
19
|
+
parse_line(line)
|
20
|
+
end.flatten.compact
|
21
|
+
end
|
22
|
+
|
23
|
+
def parse_line(line)
|
24
|
+
if line.match(/^brew/)
|
25
|
+
line.scan(DEPENDENCY_FORMAT).map do |name, version|
|
26
|
+
OpenStruct.new(name: name, version: version)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def content
|
32
|
+
File.read(self.path)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
|
3
|
+
class Velcro
|
4
|
+
class Homebrew
|
5
|
+
HOMEBREW_COMMAND = 'brew'
|
6
|
+
|
7
|
+
def install_dependencies(dependencies)
|
8
|
+
dependencies.each do |dependency|
|
9
|
+
install(dependency)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def install(dependency)
|
14
|
+
command = "#{HOMEBREW_COMMAND} install #{dependency.name}"
|
15
|
+
command << " -v #{dependency.version}" if dependency.version
|
16
|
+
shellout(command)
|
17
|
+
end
|
18
|
+
|
19
|
+
def child_dependencies(dependency)
|
20
|
+
deps(dependency).split.map do |child|
|
21
|
+
child = OpenStruct.new(name: child)
|
22
|
+
child.version = versions(child).split.first
|
23
|
+
child
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def deps(dependency)
|
28
|
+
command = "#{HOMEBREW_COMMAND} deps #{dependency.name}"
|
29
|
+
shellout(command, true)
|
30
|
+
end
|
31
|
+
|
32
|
+
def versions(dependency)
|
33
|
+
command = "#{HOMEBREW_COMMAND} versions --compact #{dependency.name}"
|
34
|
+
shellout(command, true)
|
35
|
+
end
|
36
|
+
|
37
|
+
def shellout(command, quiet = false)
|
38
|
+
output = `#{command}`
|
39
|
+
puts output unless quiet
|
40
|
+
output
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'velcro/homebrew'
|
2
|
+
|
3
|
+
class Velcro
|
4
|
+
class Lockfile
|
5
|
+
attr_accessor :path, :homebrew
|
6
|
+
|
7
|
+
def initialize(path)
|
8
|
+
self.path = path
|
9
|
+
self.homebrew = Homebrew.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def generate(dependencies)
|
13
|
+
[
|
14
|
+
'FORMULA',
|
15
|
+
indent(generate_formula(dependencies)),
|
16
|
+
'',
|
17
|
+
'DEPENDENCIES',
|
18
|
+
indent(generate_dependencies(dependencies))
|
19
|
+
].flatten.join("\n")
|
20
|
+
end
|
21
|
+
|
22
|
+
def generate_formula(dependencies)
|
23
|
+
dependencies.map do |dependency|
|
24
|
+
[
|
25
|
+
"#{dependency.name} (#{specified_or_most_recent_version(dependency)})",
|
26
|
+
indent(generate_child_dependencies(dependency))
|
27
|
+
]
|
28
|
+
end.flatten
|
29
|
+
end
|
30
|
+
|
31
|
+
def generate_child_dependencies(dependency)
|
32
|
+
self.homebrew.child_dependencies(dependency).map do |child|
|
33
|
+
"#{child.name} (#{child.version})"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def generate_dependencies(dependencies)
|
38
|
+
dependencies.map do |dependency|
|
39
|
+
line = "#{dependency.name}"
|
40
|
+
line << " (#{dependency.version})" if dependency.version
|
41
|
+
line
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def specified_or_most_recent_version(dependency)
|
46
|
+
dependency.version || self.homebrew.versions(dependency).split.first
|
47
|
+
end
|
48
|
+
|
49
|
+
def indent(lines)
|
50
|
+
Array(lines).map do |line|
|
51
|
+
" #{line}"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'velcro/brewfile'
|
2
|
+
require 'tempfile'
|
3
|
+
|
4
|
+
describe Velcro::Brewfile do
|
5
|
+
let(:content) {
|
6
|
+
<<-END.gsub(/^\s{6}/, '')
|
7
|
+
brew 'postgresql'
|
8
|
+
brew 'redis', '2.4.16'
|
9
|
+
END
|
10
|
+
}
|
11
|
+
|
12
|
+
let(:file) {
|
13
|
+
Tempfile.new('brewfile') do |f|
|
14
|
+
f.write(content)
|
15
|
+
end
|
16
|
+
}
|
17
|
+
|
18
|
+
let(:parsed_content) {
|
19
|
+
[
|
20
|
+
OpenStruct.new(name: 'postgresql', version: nil),
|
21
|
+
OpenStruct.new(name: 'redis', version: '2.4.16')
|
22
|
+
]
|
23
|
+
}
|
24
|
+
|
25
|
+
subject { described_class.new(file.path) }
|
26
|
+
|
27
|
+
describe '#parse' do
|
28
|
+
it 'parses the Brewfile' do
|
29
|
+
subject.parse_dependencies(content).should == parsed_content
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require 'velcro/homebrew'
|
2
|
+
require 'ostruct'
|
3
|
+
|
4
|
+
describe Velcro::Homebrew do
|
5
|
+
subject { described_class.new }
|
6
|
+
|
7
|
+
let(:postgresql) { OpenStruct.new(name: 'postgresql') }
|
8
|
+
let(:redis) { OpenStruct.new(name: 'redis') }
|
9
|
+
let(:dependencies) { [postgresql, redis] }
|
10
|
+
|
11
|
+
before do
|
12
|
+
subject.stub(:shellout) { nil }
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'installing dependencies' do
|
16
|
+
describe '#install_dependencies' do
|
17
|
+
it 'installs the dependencies' do
|
18
|
+
subject.should_receive(:install).with(postgresql)
|
19
|
+
subject.should_receive(:install).with(redis)
|
20
|
+
|
21
|
+
subject.install_dependencies(dependencies)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#install' do
|
26
|
+
it 'installs a dependecy' do
|
27
|
+
subject.should_receive(:shellout).with('brew install redis')
|
28
|
+
|
29
|
+
subject.install(redis)
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'installs the correct version of a dependency' do
|
33
|
+
redis.version = '2.4.16'
|
34
|
+
|
35
|
+
subject.should_receive(:shellout).with('brew install redis -v 2.4.16')
|
36
|
+
|
37
|
+
subject.install(redis)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'velcro/lockfile'
|
2
|
+
|
3
|
+
describe Velcro::Lockfile do
|
4
|
+
subject { described_class.new(stub) }
|
5
|
+
|
6
|
+
let(:postgresql) { OpenStruct.new(name: 'postgresql', version: nil) }
|
7
|
+
let(:redis) { OpenStruct.new(name: 'redis', version: '2.4.16') }
|
8
|
+
let(:dependencies) { [postgresql, redis] }
|
9
|
+
|
10
|
+
before do
|
11
|
+
subject.homebrew.stub(:shellout) { nil }
|
12
|
+
subject.homebrew.stub(:child_dependencies).with(postgresql) {
|
13
|
+
[
|
14
|
+
OpenStruct.new(name: 'ossp-uuid', version: '1.6.2'),
|
15
|
+
OpenStruct.new(name: 'readline', version: '6.2.4')
|
16
|
+
]
|
17
|
+
}
|
18
|
+
subject.homebrew.stub(:child_dependencies).with(redis) { [] }
|
19
|
+
subject.homebrew.stub(:versions).with(postgresql) { '9.1.4' }
|
20
|
+
subject.homebrew.stub(:versions).with(redis) { '2.4.16' }
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#generate' do
|
24
|
+
it 'creates a Brewfile.lock for the installed dependencies' do
|
25
|
+
subject.generate(dependencies).should == <<-END.gsub(/^ {8}/, '').rstrip
|
26
|
+
FORMULA
|
27
|
+
postgresql (9.1.4)
|
28
|
+
ossp-uuid (1.6.2)
|
29
|
+
readline (6.2.4)
|
30
|
+
redis (2.4.16)
|
31
|
+
|
32
|
+
DEPENDENCIES
|
33
|
+
postgresql
|
34
|
+
redis (2.4.16)
|
35
|
+
END
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
data/spec/velcro_spec.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'velcro'
|
2
|
+
|
3
|
+
describe Velcro do
|
4
|
+
subject { described_class.new(stub) }
|
5
|
+
|
6
|
+
context '#install' do
|
7
|
+
let(:homebrew) { stub(install_dependencies: nil) }
|
8
|
+
let(:dependencies) { stub }
|
9
|
+
let(:brewfile) { stub(dependencies: dependencies) }
|
10
|
+
let(:lockfile) { stub(generate: nil) }
|
11
|
+
|
12
|
+
before do
|
13
|
+
subject.stub(:homebrew) { homebrew }
|
14
|
+
subject.stub(:brewfile) { brewfile }
|
15
|
+
subject.stub(:lockfile) { lockfile }
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'installs the necessary dependencies' do
|
19
|
+
homebrew.should_receive(:install_dependencies).with(dependencies)
|
20
|
+
|
21
|
+
subject.install
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'generates a Brewfile.lock if not yet created' do
|
25
|
+
lockfile.should_receive(:generate).with(dependencies)
|
26
|
+
|
27
|
+
subject.install
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/velcro.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require File.expand_path('../lib/velcro/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.name = 'velcro'
|
6
|
+
gem.version = Velcro::VERSION
|
7
|
+
gem.authors = ['vanstee', 'tomelm']
|
8
|
+
gem.email = ['vanstee@highgroove.com']
|
9
|
+
gem.description = %q{Manage your dependencies with homebrew like you manage your gems with bundler}
|
10
|
+
gem.summary = %q{Manage your dependencies with homebrew like you manage your gems with bundler}
|
11
|
+
gem.homepage = 'http://github.com/vanstee/velcro'
|
12
|
+
|
13
|
+
gem.files = `git ls-files`.split
|
14
|
+
gem.executables = `git ls-files -- bin/*`.split.map { |f| File.basename(f) }
|
15
|
+
gem.test_files = `git ls-files -- spec/*`.split
|
16
|
+
gem.require_paths = ['lib']
|
17
|
+
|
18
|
+
gem.add_development_dependency 'rspec', '~> 2.11.0'
|
19
|
+
gem.add_development_dependency 'pry'
|
20
|
+
gem.add_development_dependency 'rake'
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: velcro
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- vanstee
|
9
|
+
- tomelm
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2012-08-20 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ~>
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 2.11.0
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ~>
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 2.11.0
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: pry
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
type: :development
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rake
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
description: Manage your dependencies with homebrew like you manage your gems with
|
64
|
+
bundler
|
65
|
+
email:
|
66
|
+
- vanstee@highgroove.com
|
67
|
+
executables: []
|
68
|
+
extensions: []
|
69
|
+
extra_rdoc_files: []
|
70
|
+
files:
|
71
|
+
- .gitignore
|
72
|
+
- .rspec
|
73
|
+
- .travis.yml
|
74
|
+
- Gemfile
|
75
|
+
- LICENSE.txt
|
76
|
+
- README.md
|
77
|
+
- Rakefile
|
78
|
+
- lib/velcro.rb
|
79
|
+
- lib/velcro/brewfile.rb
|
80
|
+
- lib/velcro/homebrew.rb
|
81
|
+
- lib/velcro/lockfile.rb
|
82
|
+
- lib/velcro/version.rb
|
83
|
+
- spec/velcro/brewfile_spec.rb
|
84
|
+
- spec/velcro/homebrew_spec.rb
|
85
|
+
- spec/velcro/lockfile_spec.rb
|
86
|
+
- spec/velcro_spec.rb
|
87
|
+
- velcro.gemspec
|
88
|
+
homepage: http://github.com/vanstee/velcro
|
89
|
+
licenses: []
|
90
|
+
post_install_message:
|
91
|
+
rdoc_options: []
|
92
|
+
require_paths:
|
93
|
+
- lib
|
94
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
95
|
+
none: false
|
96
|
+
requirements:
|
97
|
+
- - ! '>='
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
segments:
|
101
|
+
- 0
|
102
|
+
hash: -1769184219394736127
|
103
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
none: false
|
105
|
+
requirements:
|
106
|
+
- - ! '>='
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '0'
|
109
|
+
segments:
|
110
|
+
- 0
|
111
|
+
hash: -1769184219394736127
|
112
|
+
requirements: []
|
113
|
+
rubyforge_project:
|
114
|
+
rubygems_version: 1.8.23
|
115
|
+
signing_key:
|
116
|
+
specification_version: 3
|
117
|
+
summary: Manage your dependencies with homebrew like you manage your gems with bundler
|
118
|
+
test_files:
|
119
|
+
- spec/velcro/brewfile_spec.rb
|
120
|
+
- spec/velcro/homebrew_spec.rb
|
121
|
+
- spec/velcro/lockfile_spec.rb
|
122
|
+
- spec/velcro_spec.rb
|