leap-cli 1.0.0
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 +7 -0
- data/.gitignore +2 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +41 -0
- data/LICENSE +21 -0
- data/README.md +54 -0
- data/bin/leap +3 -0
- data/leap.gemspec +30 -0
- data/lib/leap.rb +9 -0
- data/lib/leap/cli.rb +63 -0
- data/lib/leap/config.rb +6 -0
- data/lib/leap/support/brew.rb +44 -0
- data/lib/leap/support/remotes.rb +37 -0
- data/lib/leap/version.rb +3 -0
- data/spec/lib/leap/cli_spec.rb +115 -0
- data/spec/lib/leap/support/brew_spec.rb +109 -0
- data/spec/lib/leap/support/remotes_spec.rb +84 -0
- data/spec/spec_helper.rb +2 -0
- metadata +139 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8787a01442a6f05a729b42403a0d3fe1f4d5e5d1
|
4
|
+
data.tar.gz: 2341e315764f8954674438a6f38d1bfa3249bf3f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5a5d3b63026eaa8d8e3ea6052cbf6dc5cdac5b09afc044bb23491b93b97d90efcd2a68f58010ae877b9f6742a876e23cedbf4b51b09bf2006016edc5685f92e4
|
7
|
+
data.tar.gz: 571097b889476c3170f1616b836408f7cef6f5485c40e0ea9608611f2323141e90181e8678c1f8fc9442de5733c5834f6d2af50dd36ab6b8f95688f588d1dd50
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
leap-cli (1.0.0)
|
5
|
+
thor (= 0.19.1)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
coderay (1.1.0)
|
11
|
+
diff-lcs (1.2.5)
|
12
|
+
method_source (0.8.2)
|
13
|
+
pry (0.10.0)
|
14
|
+
coderay (~> 1.1.0)
|
15
|
+
method_source (~> 0.8.1)
|
16
|
+
slop (~> 3.4)
|
17
|
+
rake (10.3.2)
|
18
|
+
rspec (3.1.0)
|
19
|
+
rspec-core (~> 3.1.0)
|
20
|
+
rspec-expectations (~> 3.1.0)
|
21
|
+
rspec-mocks (~> 3.1.0)
|
22
|
+
rspec-core (3.1.6)
|
23
|
+
rspec-support (~> 3.1.0)
|
24
|
+
rspec-expectations (3.1.2)
|
25
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
26
|
+
rspec-support (~> 3.1.0)
|
27
|
+
rspec-mocks (3.1.3)
|
28
|
+
rspec-support (~> 3.1.0)
|
29
|
+
rspec-support (3.1.2)
|
30
|
+
slop (3.6.0)
|
31
|
+
thor (0.19.1)
|
32
|
+
|
33
|
+
PLATFORMS
|
34
|
+
ruby
|
35
|
+
|
36
|
+
DEPENDENCIES
|
37
|
+
bundler (~> 1.3)
|
38
|
+
leap-cli!
|
39
|
+
pry (= 0.10.0)
|
40
|
+
rake (= 10.3.2)
|
41
|
+
rspec (= 3.1.0)
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 General Assembly
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# Leap
|
2
|
+
|
3
|
+
Leap is a CLI to make working on projects inside a service oriented architecture easier.
|
4
|
+
|
5
|
+
## Dependencies
|
6
|
+
|
7
|
+
Leap is built upon Ruby 2.1.2.
|
8
|
+
|
9
|
+
While not a strict dependency, leap has not been tested on Linux or Windows. Don’t expect the latter to work.
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
To install leap and take advantage of its full command, you’ll want to install it globally.
|
14
|
+
|
15
|
+
`sudo gem install leap-cli`
|
16
|
+
|
17
|
+
## Adding leap to a project
|
18
|
+
|
19
|
+
Leap uses convention through configuration. What that means is individual teams enforce their conventions through configuration in leap.
|
20
|
+
|
21
|
+
To do this, in each project create a `.leap` directory, inside of which you’ll create a `config` file. This is ultimately a YAML file.
|
22
|
+
|
23
|
+
#### Example `config` file
|
24
|
+
|
25
|
+
```YAML
|
26
|
+
dependencies:
|
27
|
+
- postgresql
|
28
|
+
- redis
|
29
|
+
|
30
|
+
remotes:
|
31
|
+
- origin:
|
32
|
+
- git@github.com:generalassembly/turbo-octo-happiness.git
|
33
|
+
```
|
34
|
+
|
35
|
+
#### Adding leap start
|
36
|
+
|
37
|
+
The start script is just a shell script that starts your server. This could be as simple as:
|
38
|
+
|
39
|
+
```shell
|
40
|
+
rails s
|
41
|
+
```
|
42
|
+
|
43
|
+
Or as complex as you like. This simply gives a clear way for any dev new to a project start the server without having to ask, “Is this a foreman project or do I use 'rails s' or some other way?”
|
44
|
+
|
45
|
+
## Using leap
|
46
|
+
|
47
|
+
Leap is now part of your CLI. Using it is simple!
|
48
|
+
|
49
|
+
`$ leap`
|
50
|
+
|
51
|
+
## Contributing to leap
|
52
|
+
|
53
|
+
We’d love to have all contributions that are sent our way that match the mission of the project. To that end, opening an issue before submitting a pull request is the best way to kick off the discussion as to whether your vision and our vision matches.
|
54
|
+
|
data/bin/leap
ADDED
data/leap.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
lib = File.expand_path('../lib', __FILE__)
|
4
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
+
require 'leap/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |spec|
|
8
|
+
spec.name = 'leap-cli'
|
9
|
+
spec.version = Leap::VERSION
|
10
|
+
spec.authors = ['General Assembly', 'Dustin Coates']
|
11
|
+
spec.email = ['tech@generalassemb.ly', 'dustin@dcoates.com']
|
12
|
+
spec.description = %q{Tools for projects inside a SOA.}
|
13
|
+
spec.summary = %q{A CLI for setting up, running, and making changes to project inside a SOA.}
|
14
|
+
spec.homepage = 'http://github.com/generalassembly/leap'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.files = `git ls-files`.split($/)
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
20
|
+
spec.require_paths = ['lib']
|
21
|
+
|
22
|
+
spec.required_ruby_version = '>= 2.1.2'
|
23
|
+
|
24
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
25
|
+
spec.add_development_dependency 'pry', '0.10.0'
|
26
|
+
spec.add_development_dependency 'rake', '10.3.2'
|
27
|
+
spec.add_development_dependency 'rspec', '3.1.0'
|
28
|
+
|
29
|
+
spec.add_dependency 'thor', '0.19.1'
|
30
|
+
end
|
data/lib/leap.rb
ADDED
data/lib/leap/cli.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'thor'
|
2
|
+
require 'mkmf'
|
3
|
+
require 'leap'
|
4
|
+
require 'pry'
|
5
|
+
|
6
|
+
require_relative 'config'
|
7
|
+
require_relative 'support/brew'
|
8
|
+
require_relative 'support/remotes'
|
9
|
+
|
10
|
+
class Leap::CLI < Thor
|
11
|
+
|
12
|
+
desc 'setup USERNAME/PROJECT', 'Clone and install dependencies of a project'
|
13
|
+
def setup(username_project)
|
14
|
+
username, project_name = split_source(username_project)
|
15
|
+
invoke :clone, [username_project]
|
16
|
+
invoke :remotes, [project_name]
|
17
|
+
invoke :dependencies, [project_name]
|
18
|
+
end
|
19
|
+
|
20
|
+
desc 'clone USERNAME/PROJECT', 'Clone project into current directory'
|
21
|
+
def clone(username_project)
|
22
|
+
username, project_name = split_source(username_project)
|
23
|
+
if Dir.exists?(project_name)
|
24
|
+
say "Project appears to already exist. Skipping clone.", :green
|
25
|
+
else
|
26
|
+
say "Cloning #{project_name}.", :green
|
27
|
+
`git clone git@github.com:#{username}/#{project_name}.git`
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
desc 'remotes', 'Sets up all relevant remotes for a project'
|
32
|
+
def remotes(project_name = nil)
|
33
|
+
# setup above invokes dependencies with an argument so we allow for a single
|
34
|
+
# unused argument when called inside a project
|
35
|
+
Remotes.new(self, Leap::CONFIG, project_name).add_specified_remotes
|
36
|
+
end
|
37
|
+
|
38
|
+
desc 'dependencies', 'Guided installation of dependencies for project'
|
39
|
+
# setup above invokes dependencies with an argument so we allow for a single
|
40
|
+
# unused argument when called inside a project
|
41
|
+
def dependencies(project_name = nil)
|
42
|
+
brew = Brew.new(self, Leap::CONFIG, project_name)
|
43
|
+
|
44
|
+
brew.install unless brew.present?
|
45
|
+
brew.install_dependencies
|
46
|
+
end
|
47
|
+
|
48
|
+
desc 'start', 'Starts a local server'
|
49
|
+
def start
|
50
|
+
remotes_file = '.leap/start'
|
51
|
+
if File.exists?(remotes_file)
|
52
|
+
exec(remotes_file)
|
53
|
+
else
|
54
|
+
say 'No start script', :red
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
no_commands do
|
59
|
+
def split_source(username_project)
|
60
|
+
username_project.downcase.split("/")
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
data/lib/leap/config.rb
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
class Brew
|
2
|
+
attr_reader :dependencies
|
3
|
+
|
4
|
+
def initialize(thor, config, project_name)
|
5
|
+
@dependencies = extract_dependencies(config, project_name)
|
6
|
+
@thor = thor
|
7
|
+
end
|
8
|
+
|
9
|
+
def eligible?
|
10
|
+
!RbConfig::CONFIG['host_os'].match(/darwin|mac os/).nil?
|
11
|
+
end
|
12
|
+
|
13
|
+
def install
|
14
|
+
@thor.say 'Installing brew', :green
|
15
|
+
exec('ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"')
|
16
|
+
end
|
17
|
+
|
18
|
+
def install_dependencies
|
19
|
+
@dependencies.each do |dependency|
|
20
|
+
local_package = `brew list | grep #{dependency}`
|
21
|
+
if local_package.empty?
|
22
|
+
@thor.say "Installing #{dependency}", :green
|
23
|
+
exec("brew install #{dependency}")
|
24
|
+
end
|
25
|
+
end.empty? and begin
|
26
|
+
@thor.say "No dependencies found in leap config", :red
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def present?
|
31
|
+
!(find_executable 'brew').nil?
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
def extract_dependencies(config, project_name)
|
36
|
+
config.fetch('dependencies') do
|
37
|
+
if File.exists? "./#{project_name}/.leap/config"
|
38
|
+
YAML.load_file("./#{project_name}/.leap/config")['dependencies']
|
39
|
+
else
|
40
|
+
[]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
class Remotes
|
2
|
+
attr_reader :remotes
|
3
|
+
|
4
|
+
def initialize(thor, config, project_name = nil)
|
5
|
+
@thor = thor
|
6
|
+
@remotes = extract_remotes(config, project_name)
|
7
|
+
@project_name = project_name
|
8
|
+
end
|
9
|
+
|
10
|
+
def add_specified_remotes
|
11
|
+
if @remotes.nil?
|
12
|
+
@thor.say 'No remotes specified', :red
|
13
|
+
else
|
14
|
+
@remotes.each do |name, remote_url|
|
15
|
+
add_remote(name, remote_url, @project_name)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def add_remote(name, remote_url, project_name = nil)
|
21
|
+
@thor.say "Adding #{name} remote"
|
22
|
+
if project_name.nil?
|
23
|
+
`git remote add #{name} #{remote_url}`
|
24
|
+
else
|
25
|
+
`cd #{project_name} && git remote add #{name} #{remote_url}`
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
def extract_remotes(config, project_name)
|
31
|
+
config.fetch('remotes') do
|
32
|
+
if File.exists? "./#{project_name}/.leap/config"
|
33
|
+
YAML.load_file("./#{project_name}/.leap/config")['remotes']
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/leap/version.rb
ADDED
@@ -0,0 +1,115 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'pry'
|
3
|
+
|
4
|
+
describe Leap::CLI do
|
5
|
+
let(:cli) { Leap::CLI.new }
|
6
|
+
|
7
|
+
describe 'setup' do
|
8
|
+
it 'invokes clone, remotes, dependencies' do
|
9
|
+
expect(cli).to receive(:invoke).exactly(:thrice)
|
10
|
+
|
11
|
+
cli.setup('username/project')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe 'clone' do
|
16
|
+
context 'when directory with same name already exists' do
|
17
|
+
before do
|
18
|
+
allow(Dir).to receive(:exists?).and_return(true)
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'does not clone project' do
|
22
|
+
expect(cli).to_not receive(:`)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'warns user' do
|
26
|
+
expect(cli).to receive(:say)
|
27
|
+
.exactly(:once)
|
28
|
+
.with('Project appears to already exist. Skipping clone.', :green)
|
29
|
+
|
30
|
+
cli.clone('username/project')
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'when directory with same name does not exist' do
|
35
|
+
before do
|
36
|
+
allow(Dir).to receive(:exists?).and_return(false)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'clones project' do
|
40
|
+
expect(cli).to receive(:`).with("git clone git@github.com:username/project.git")
|
41
|
+
|
42
|
+
cli.clone('username/project')
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'notifies user' do
|
46
|
+
expect(cli).to receive(:say)
|
47
|
+
.exactly(:once)
|
48
|
+
.with("Cloning project.", :green)
|
49
|
+
|
50
|
+
cli.clone('username/project')
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe 'dependencies' do
|
56
|
+
context 'when brew is not present' do
|
57
|
+
it 'installs brew' do
|
58
|
+
allow_any_instance_of(Brew).to receive(:present?).and_return(false)
|
59
|
+
|
60
|
+
expect_any_instance_of(Brew).to receive(:install_brew).exactly(:once)
|
61
|
+
|
62
|
+
cli.dependencies
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context 'when brew is present' do
|
67
|
+
it 'does not install brew' do
|
68
|
+
allow_any_instance_of(Brew).to receive(:present?).and_return(true)
|
69
|
+
|
70
|
+
expect_any_instance_of(Brew).to_not receive(:install_brew)
|
71
|
+
|
72
|
+
cli.dependencies
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'installs dependencies' do
|
77
|
+
expect_any_instance_of(Brew).to receive(:install_dependencies)
|
78
|
+
|
79
|
+
cli.dependencies
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
describe 'start' do
|
84
|
+
context 'when start script exists' do
|
85
|
+
before do
|
86
|
+
allow(File).to receive(:exists?).and_return(false)
|
87
|
+
end
|
88
|
+
|
89
|
+
it 'alerts user of no start script' do
|
90
|
+
expect(cli)
|
91
|
+
.to receive(:say)
|
92
|
+
.with('No start script', :red)
|
93
|
+
.exactly(:once)
|
94
|
+
|
95
|
+
cli.start
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
context 'when start script does not exist' do
|
100
|
+
before do
|
101
|
+
allow(File).to receive(:exists?).and_return(true)
|
102
|
+
allow_any_instance_of(Object).to receive(:exec).and_return(double)
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'executes that script' do
|
106
|
+
expect_any_instance_of(Object)
|
107
|
+
.to receive(:exec)
|
108
|
+
.with('.leap/start')
|
109
|
+
.exactly(:once)
|
110
|
+
|
111
|
+
cli.start
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
@@ -0,0 +1,109 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Brew do
|
4
|
+
let(:brew) { Brew.new(Leap::CLI.new, {}, 'project') }
|
5
|
+
|
6
|
+
describe '#eligible?' do
|
7
|
+
it 'returns true for mac os' do
|
8
|
+
RbConfig::CONFIG['host_os'] = 'mac os'
|
9
|
+
expect(brew).to be_eligible
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'returns true for darwin' do
|
13
|
+
RbConfig::CONFIG['host_os'] = 'darwin'
|
14
|
+
expect(brew).to be_eligible
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'returns false for anything else' do
|
18
|
+
RbConfig::CONFIG['host_os'] = 'mswin'
|
19
|
+
expect(brew).to_not be_eligible
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#install' do
|
24
|
+
it 'notifies user' do
|
25
|
+
expect_any_instance_of(Leap::CLI)
|
26
|
+
.to receive('say')
|
27
|
+
.exactly(:once)
|
28
|
+
.with('Installing brew', :green)
|
29
|
+
|
30
|
+
allow_any_instance_of(Object).to receive(:exec).and_return(double)
|
31
|
+
|
32
|
+
brew.install
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'installs brew' do
|
36
|
+
expect_any_instance_of(Object)
|
37
|
+
.to receive(:exec)
|
38
|
+
.with('ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"')
|
39
|
+
.exactly(:once)
|
40
|
+
|
41
|
+
brew.install
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#install_dependencies' do
|
46
|
+
before do
|
47
|
+
allow_any_instance_of(Object).to receive(:exec).and_return(double)
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'when no dependencies are present' do
|
51
|
+
it 'alerts user' do
|
52
|
+
brew = Brew.new(Leap::CLI.new, {}, 'project')
|
53
|
+
|
54
|
+
expect_any_instance_of(Leap::CLI)
|
55
|
+
.to receive('say')
|
56
|
+
.exactly(:once)
|
57
|
+
.with('No dependencies found in leap config', :red)
|
58
|
+
|
59
|
+
brew.install_dependencies
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
context 'when dependencies are present' do
|
64
|
+
context 'when local_package is not present' do
|
65
|
+
before { allow_any_instance_of(Object).to receive(:`).and_return('') }
|
66
|
+
|
67
|
+
it 'notifies user for every dependency' do
|
68
|
+
brew = Brew.new(Leap::CLI.new, { 'dependencies' => ['redis', 'awk'] }, 'project')
|
69
|
+
|
70
|
+
expect_any_instance_of(Leap::CLI)
|
71
|
+
.to receive('say')
|
72
|
+
.exactly(:twice)
|
73
|
+
|
74
|
+
brew.install_dependencies
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'installs dependencies via brew' do
|
78
|
+
brew = Brew.new(Leap::CLI.new, { 'dependencies' => ['redis'] }, 'project')
|
79
|
+
|
80
|
+
expect_any_instance_of(Object)
|
81
|
+
.to receive(:exec)
|
82
|
+
.with("brew install redis")
|
83
|
+
|
84
|
+
brew.install_dependencies
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe '#present?' do
|
91
|
+
it 'returns false if brew executable is not found' do
|
92
|
+
allow_any_instance_of(Object)
|
93
|
+
.to receive(:find_executable)
|
94
|
+
.with('brew')
|
95
|
+
.and_return(nil)
|
96
|
+
|
97
|
+
expect(brew).to_not be_present
|
98
|
+
end
|
99
|
+
|
100
|
+
it 'returns true if brew executable is found' do
|
101
|
+
allow_any_instance_of(Object)
|
102
|
+
.to receive(:find_executable)
|
103
|
+
.with('brew')
|
104
|
+
.and_return('/usr/local/bin/brew')
|
105
|
+
|
106
|
+
expect(brew).to be_present
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Remotes do
|
4
|
+
|
5
|
+
describe '#add_specified_remotes' do
|
6
|
+
context 'when no remotes are present' do
|
7
|
+
let(:remotes) { Remotes.new(Leap::CLI.new, {}) }
|
8
|
+
|
9
|
+
it 'alerts the user' do
|
10
|
+
expect{
|
11
|
+
remotes.add_specified_remotes
|
12
|
+
}.to output("No remotes specified\n").to_stdout
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'does not add remotes' do
|
16
|
+
expect(remotes).to_not receive(:add_remote)
|
17
|
+
|
18
|
+
remotes.add_specified_remotes
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'when remotes are present' do
|
23
|
+
let(:remotes) do
|
24
|
+
Remotes.new(
|
25
|
+
Leap::CLI.new,
|
26
|
+
{ "remotes" => {
|
27
|
+
"origin" => 'git@github.com:generalassembly/leap.git'
|
28
|
+
}
|
29
|
+
}
|
30
|
+
)
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'adds remotes' do
|
34
|
+
expect(remotes).to receive(:add_remote).exactly(:once)
|
35
|
+
|
36
|
+
remotes.add_specified_remotes
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#add_remote' do
|
42
|
+
let(:remotes) do
|
43
|
+
Remotes.new(
|
44
|
+
Leap::CLI.new,
|
45
|
+
{ "remotes" => {
|
46
|
+
"origin" => 'git@github.com:generalassembly/leap.git'
|
47
|
+
}
|
48
|
+
},
|
49
|
+
'project'
|
50
|
+
)
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'notifies user' do
|
54
|
+
expect_any_instance_of(Leap::CLI)
|
55
|
+
.to receive('say')
|
56
|
+
.exactly(:once)
|
57
|
+
.with('Adding origin remote')
|
58
|
+
|
59
|
+
remotes.add_remote(remotes.remotes.keys.first, remotes.remotes.values.first)
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'when project name is present' do
|
63
|
+
it 'cds into project and adds remote' do
|
64
|
+
expect(remotes)
|
65
|
+
.to receive(:`)
|
66
|
+
.exactly(:once)
|
67
|
+
.with("cd project && git remote add origin git@github.com:generalassembly/leap.git")
|
68
|
+
|
69
|
+
remotes.add_remote(remotes.remotes.keys.first, remotes.remotes.values.first, "project")
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
context 'when project name is not present' do
|
74
|
+
it 'does not cd into project, then adds remote' do
|
75
|
+
expect(remotes)
|
76
|
+
.to receive(:`)
|
77
|
+
.exactly(:once)
|
78
|
+
.with("git remote add origin git@github.com:generalassembly/leap.git")
|
79
|
+
|
80
|
+
remotes.add_remote(remotes.remotes.keys.first, remotes.remotes.values.first, nil)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,139 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: leap-cli
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- General Assembly
|
8
|
+
- Dustin Coates
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2015-04-03 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.3'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.3'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: pry
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - '='
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 0.10.0
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - '='
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 0.10.0
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rake
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - '='
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: 10.3.2
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - '='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: 10.3.2
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: rspec
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - '='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 3.1.0
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - '='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 3.1.0
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: thor
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - '='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: 0.19.1
|
77
|
+
type: :runtime
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - '='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: 0.19.1
|
84
|
+
description: Tools for projects inside a SOA.
|
85
|
+
email:
|
86
|
+
- tech@generalassemb.ly
|
87
|
+
- dustin@dcoates.com
|
88
|
+
executables:
|
89
|
+
- leap
|
90
|
+
extensions: []
|
91
|
+
extra_rdoc_files: []
|
92
|
+
files:
|
93
|
+
- ".gitignore"
|
94
|
+
- Gemfile
|
95
|
+
- Gemfile.lock
|
96
|
+
- LICENSE
|
97
|
+
- README.md
|
98
|
+
- bin/leap
|
99
|
+
- leap.gemspec
|
100
|
+
- lib/leap.rb
|
101
|
+
- lib/leap/cli.rb
|
102
|
+
- lib/leap/config.rb
|
103
|
+
- lib/leap/support/brew.rb
|
104
|
+
- lib/leap/support/remotes.rb
|
105
|
+
- lib/leap/version.rb
|
106
|
+
- spec/lib/leap/cli_spec.rb
|
107
|
+
- spec/lib/leap/support/brew_spec.rb
|
108
|
+
- spec/lib/leap/support/remotes_spec.rb
|
109
|
+
- spec/spec_helper.rb
|
110
|
+
homepage: http://github.com/generalassembly/leap
|
111
|
+
licenses:
|
112
|
+
- MIT
|
113
|
+
metadata: {}
|
114
|
+
post_install_message:
|
115
|
+
rdoc_options: []
|
116
|
+
require_paths:
|
117
|
+
- lib
|
118
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: 2.1.2
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
requirements: []
|
129
|
+
rubyforge_project:
|
130
|
+
rubygems_version: 2.2.2
|
131
|
+
signing_key:
|
132
|
+
specification_version: 4
|
133
|
+
summary: A CLI for setting up, running, and making changes to project inside a SOA.
|
134
|
+
test_files:
|
135
|
+
- spec/lib/leap/cli_spec.rb
|
136
|
+
- spec/lib/leap/support/brew_spec.rb
|
137
|
+
- spec/lib/leap/support/remotes_spec.rb
|
138
|
+
- spec/spec_helper.rb
|
139
|
+
has_rdoc:
|