engage 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +30 -0
- data/README.markdown +10 -0
- data/Rakefile +10 -0
- data/bin/engage +5 -0
- data/engage.gemspec +26 -0
- data/lib/engage/runner.rb +67 -0
- data/lib/engage/version.rb +3 -0
- data/lib/engage.rb +4 -0
- data/spec/helpers.rb +33 -0
- data/spec/runner_spec.rb +76 -0
- data/spec/spec_helper.rb +11 -0
- metadata +142 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
Engage (0.0.1)
|
5
|
+
thor (~> 0.14)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
diff-lcs (1.1.2)
|
11
|
+
fakefs (0.3.1)
|
12
|
+
rspec (2.3.0)
|
13
|
+
rspec-core (~> 2.3.0)
|
14
|
+
rspec-expectations (~> 2.3.0)
|
15
|
+
rspec-mocks (~> 2.3.0)
|
16
|
+
rspec-core (2.3.1)
|
17
|
+
rspec-expectations (2.3.0)
|
18
|
+
diff-lcs (~> 1.1.2)
|
19
|
+
rspec-mocks (2.3.0)
|
20
|
+
thor (0.14.6)
|
21
|
+
|
22
|
+
PLATFORMS
|
23
|
+
ruby
|
24
|
+
|
25
|
+
DEPENDENCIES
|
26
|
+
Engage!
|
27
|
+
bundler (~> 1.0)
|
28
|
+
fakefs
|
29
|
+
rspec (~> 2.3)
|
30
|
+
thor (~> 0.14)
|
data/README.markdown
ADDED
data/Rakefile
ADDED
data/bin/engage
ADDED
data/engage.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "engage/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "engage"
|
7
|
+
s.version = Engage::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Lucas Mazza"]
|
10
|
+
s.email = ["luc4smazza@gmail.com"]
|
11
|
+
s.homepage = ""
|
12
|
+
s.summary = %q{Quick setup for your ruby apps}
|
13
|
+
s.description = %q{Engage is a CLI for rapid bootstrap for your ruby apps using Git, RVM and Bundler.}
|
14
|
+
|
15
|
+
s.rubyforge_project = "engage"
|
16
|
+
s.required_rubygems_version = ">= 1.3.6"
|
17
|
+
s.add_development_dependency "bundler", "~> 1.0"
|
18
|
+
s.add_development_dependency "rspec", "~> 2.3"
|
19
|
+
s.add_development_dependency "fakefs"
|
20
|
+
s.add_runtime_dependency "thor", "~> 0.14"
|
21
|
+
|
22
|
+
s.files = `git ls-files`.split("\n")
|
23
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
24
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
25
|
+
s.require_paths = ["lib"]
|
26
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module Engage
|
2
|
+
class Runner < Thor::Group
|
3
|
+
include Thor::Actions
|
4
|
+
|
5
|
+
argument :name, :optional => true, :desc => "The targeted project name"
|
6
|
+
class_option :source, :type => :string, :desc => "Adds the given source to the user list."
|
7
|
+
|
8
|
+
def clone_repo
|
9
|
+
return if adding_source?
|
10
|
+
source = ask_for_source
|
11
|
+
run "git clone #{source}:#{name}.git"
|
12
|
+
end
|
13
|
+
|
14
|
+
def generate_gemset
|
15
|
+
return if adding_source?
|
16
|
+
run "rvm gemset create #{project_name}"
|
17
|
+
end
|
18
|
+
|
19
|
+
def run_bundler
|
20
|
+
return if adding_source?
|
21
|
+
run "cd #{project_name} && bundle" if using_bundler?
|
22
|
+
end
|
23
|
+
|
24
|
+
def store
|
25
|
+
return unless adding_source?
|
26
|
+
list = sources
|
27
|
+
list << options.source
|
28
|
+
File.open(file_path, 'w') { |f| f.write(YAML.dump(list.uniq.compact)) }
|
29
|
+
end
|
30
|
+
|
31
|
+
no_tasks do
|
32
|
+
def file_path
|
33
|
+
File.join(ENV["HOME"], ".engage.sources")
|
34
|
+
end
|
35
|
+
|
36
|
+
def ask_for_source
|
37
|
+
return sources.first if sources.size == 1
|
38
|
+
say "Available git servers:"
|
39
|
+
sources.each_with_index do |source, index|
|
40
|
+
say "#{index} => #{source}"
|
41
|
+
end
|
42
|
+
sources[ask("Select the server of '#{project_name}':")]
|
43
|
+
end
|
44
|
+
|
45
|
+
def using_bundler?
|
46
|
+
File.exists?(File.join(project_name, "Gemfile"))
|
47
|
+
end
|
48
|
+
|
49
|
+
def project_name
|
50
|
+
@project_name ||= name.split("/").last
|
51
|
+
end
|
52
|
+
|
53
|
+
def sources
|
54
|
+
File.exists?(file_path) ? YAML.load_file(file_path) : default_sources
|
55
|
+
end
|
56
|
+
|
57
|
+
def default_sources
|
58
|
+
["git@github.com"]
|
59
|
+
end
|
60
|
+
|
61
|
+
def adding_source?
|
62
|
+
!options.source.nil?
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
data/lib/engage.rb
ADDED
data/spec/helpers.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
module Helpers
|
2
|
+
|
3
|
+
def run
|
4
|
+
silenced(:stdout) { subject.invoke_all }
|
5
|
+
end
|
6
|
+
|
7
|
+
def stub_commands
|
8
|
+
subject.stub(:system).and_return(true)
|
9
|
+
end
|
10
|
+
|
11
|
+
def expect(command)
|
12
|
+
subject.should_receive(:system).with(command)
|
13
|
+
end
|
14
|
+
|
15
|
+
def dont_expect(command)
|
16
|
+
subject.should_not_receive(:system).with(command)
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
def silenced(stream)
|
21
|
+
begin
|
22
|
+
stream = stream.to_s
|
23
|
+
eval "$#{stream} = StringIO.new"
|
24
|
+
yield
|
25
|
+
result = eval("$#{stream}").string
|
26
|
+
ensure
|
27
|
+
eval("$#{stream} = #{stream.upcase}")
|
28
|
+
end
|
29
|
+
|
30
|
+
result
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
data/spec/runner_spec.rb
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Engage::Runner do
|
4
|
+
subject { Engage::Runner.new(["lucasmazza/engage"]) }
|
5
|
+
before { stub_commands }
|
6
|
+
context "Starting projects" do
|
7
|
+
|
8
|
+
context "a full featured project" do
|
9
|
+
before do
|
10
|
+
subject.stub(:using_bundler?) { true }
|
11
|
+
end
|
12
|
+
it "clones the given github repository" do
|
13
|
+
expect "git clone git@github.com:lucasmazza/engage.git"
|
14
|
+
run
|
15
|
+
end
|
16
|
+
|
17
|
+
it "creates a gemset based on the project name" do
|
18
|
+
expect "rvm gemset create engage"
|
19
|
+
run
|
20
|
+
end
|
21
|
+
|
22
|
+
it "runs bundler command" do
|
23
|
+
expect "cd engage && bundle"
|
24
|
+
run
|
25
|
+
end
|
26
|
+
|
27
|
+
it "doesn't ask for a git source" do
|
28
|
+
subject.should_not_receive(:ask).with("Select the server of 'rails':")
|
29
|
+
run
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "a project without a gemfile" do
|
34
|
+
before do
|
35
|
+
subject.stub(:using_bundler?) { false }
|
36
|
+
end
|
37
|
+
|
38
|
+
it "doesn't run the bundler command" do
|
39
|
+
dont_expect "cd engage && bundle"
|
40
|
+
run
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
context "a project from another git server" do
|
45
|
+
subject { Engage::Runner.new(["random_company_project"]) }
|
46
|
+
|
47
|
+
before do
|
48
|
+
subject.stub(:sources) { ["foo@bar.com", "git@acme.com"] }
|
49
|
+
subject.stub(:ask) { 1 }
|
50
|
+
end
|
51
|
+
|
52
|
+
it "asks for the selected git source" do
|
53
|
+
subject.should_receive(:ask).with("Select the server of 'random_company_project':")
|
54
|
+
run
|
55
|
+
end
|
56
|
+
|
57
|
+
it "clones the repo from the selected server" do
|
58
|
+
expect "git clone git@acme.com:random_company_project.git"
|
59
|
+
run
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
context "Writing sources" do
|
65
|
+
subject { Engage::Runner.new(["wrong"], :source => "git@acme.com") }
|
66
|
+
|
67
|
+
it "doesn't trigger any system call" do
|
68
|
+
subject.should_not_receive(:system)
|
69
|
+
run
|
70
|
+
end
|
71
|
+
it "adds the given source to the list" do
|
72
|
+
run
|
73
|
+
subject.sources.should include("git@acme.com")
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: engage
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Lucas Mazza
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-12-20 00:00:00 -02:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: bundler
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 15
|
30
|
+
segments:
|
31
|
+
- 1
|
32
|
+
- 0
|
33
|
+
version: "1.0"
|
34
|
+
type: :development
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rspec
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
41
|
+
requirements:
|
42
|
+
- - ~>
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 5
|
45
|
+
segments:
|
46
|
+
- 2
|
47
|
+
- 3
|
48
|
+
version: "2.3"
|
49
|
+
type: :development
|
50
|
+
version_requirements: *id002
|
51
|
+
- !ruby/object:Gem::Dependency
|
52
|
+
name: fakefs
|
53
|
+
prerelease: false
|
54
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
hash: 3
|
60
|
+
segments:
|
61
|
+
- 0
|
62
|
+
version: "0"
|
63
|
+
type: :development
|
64
|
+
version_requirements: *id003
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
name: thor
|
67
|
+
prerelease: false
|
68
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ~>
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
hash: 23
|
74
|
+
segments:
|
75
|
+
- 0
|
76
|
+
- 14
|
77
|
+
version: "0.14"
|
78
|
+
type: :runtime
|
79
|
+
version_requirements: *id004
|
80
|
+
description: Engage is a CLI for rapid bootstrap for your ruby apps using Git, RVM and Bundler.
|
81
|
+
email:
|
82
|
+
- luc4smazza@gmail.com
|
83
|
+
executables:
|
84
|
+
- engage
|
85
|
+
extensions: []
|
86
|
+
|
87
|
+
extra_rdoc_files: []
|
88
|
+
|
89
|
+
files:
|
90
|
+
- .gitignore
|
91
|
+
- Gemfile
|
92
|
+
- Gemfile.lock
|
93
|
+
- README.markdown
|
94
|
+
- Rakefile
|
95
|
+
- bin/engage
|
96
|
+
- engage.gemspec
|
97
|
+
- lib/engage.rb
|
98
|
+
- lib/engage/runner.rb
|
99
|
+
- lib/engage/version.rb
|
100
|
+
- spec/helpers.rb
|
101
|
+
- spec/runner_spec.rb
|
102
|
+
- spec/spec_helper.rb
|
103
|
+
has_rdoc: true
|
104
|
+
homepage: ""
|
105
|
+
licenses: []
|
106
|
+
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options: []
|
109
|
+
|
110
|
+
require_paths:
|
111
|
+
- lib
|
112
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
hash: 3
|
118
|
+
segments:
|
119
|
+
- 0
|
120
|
+
version: "0"
|
121
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
+
none: false
|
123
|
+
requirements:
|
124
|
+
- - ">="
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
hash: 23
|
127
|
+
segments:
|
128
|
+
- 1
|
129
|
+
- 3
|
130
|
+
- 6
|
131
|
+
version: 1.3.6
|
132
|
+
requirements: []
|
133
|
+
|
134
|
+
rubyforge_project: engage
|
135
|
+
rubygems_version: 1.3.7
|
136
|
+
signing_key:
|
137
|
+
specification_version: 3
|
138
|
+
summary: Quick setup for your ruby apps
|
139
|
+
test_files:
|
140
|
+
- spec/helpers.rb
|
141
|
+
- spec/runner_spec.rb
|
142
|
+
- spec/spec_helper.rb
|