engage 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- engage (0.0.3)
4
+ engage (0.0.4)
5
5
  thor (~> 0.14)
6
6
 
7
7
  GEM
data/README.markdown CHANGED
@@ -1,6 +1,6 @@
1
1
  # engage
2
2
 
3
- engage is a helper command to setup an already existent ruby(or rails) app on your current environment. It expects that you use [rvm](http://rvm.beginrescueend.com/) and [git](http://git-scm.com/) - [bundler](http://gembundler.com/) is supported but not required.
3
+ engage is a tiny gem to setup an already existent ruby(or rails) app on your current environment. It expects that you use [rvm](http://rvm.beginrescueend.com/) and [git](http://git-scm.com/) - [bundler](http://gembundler.com/) is supported but not required.
4
4
 
5
5
  ### What?
6
6
 
@@ -14,15 +14,16 @@ Engage aims to provide a single command to run all those tasks. All you need to
14
14
 
15
15
  ### Usage
16
16
  First, you can set your common git servers - the default list include only `git@github.com`.
17
+
17
18
  engage --sources git@git.acme.com
18
19
 
19
- After that you can engage on a project by just running:
20
+ After that you can start a project by just running:
20
21
 
21
22
  engage some_project
22
23
 
23
24
  Behind the curtains, engage will:
24
25
 
25
26
  * Prompt the git server to use - either "github.com" or "acme.com";
26
- * Clone the some_project repository form the chosen server - `git@git.acme.com/some_project.git`;
27
- * Creates a gemset name `some_project` and a .rvmrc file;
28
- * Install gems based on project's `Gemfile`, if needed.
27
+ * Clone the some_project repository form the selected server - `git@git.acme.com/some_project.git`;
28
+ * Create a gemset name `some_project` and a .rvmrc file;
29
+ * Run bundler to install all the dependencies.
@@ -0,0 +1,50 @@
1
+ # https://github.com/rails/rails/blob/87ae85d5360ac8965f24/activesupport/lib/active_support/core_ext/object/blank.rb
2
+ class Object #:nodoc:
3
+ def blank?
4
+ respond_to?(:empty?) ? empty? : !self
5
+ end
6
+ def present?
7
+ !blank?
8
+ end
9
+ def presence
10
+ self if present?
11
+ end
12
+ end
13
+
14
+ class NilClass #:nodoc:
15
+ def blank?
16
+ true
17
+ end
18
+ end
19
+
20
+ class FalseClass #:nodoc:
21
+ def blank?
22
+ true
23
+ end
24
+ end
25
+
26
+ class TrueClass #:nodoc:
27
+ def blank?
28
+ false
29
+ end
30
+ end
31
+
32
+ class Array #:nodoc:
33
+ alias_method :blank?, :empty?
34
+ end
35
+
36
+ class Hash #:nodoc:
37
+ alias_method :blank?, :empty?
38
+ end
39
+
40
+ class String #:nodoc:
41
+ def blank?
42
+ self !~ /\S/
43
+ end
44
+ end
45
+
46
+ class Numeric #:nodoc:
47
+ def blank?
48
+ false
49
+ end
50
+ end
data/lib/engage/runner.rb CHANGED
@@ -4,6 +4,18 @@ module Engage
4
4
 
5
5
  argument :name, :optional => true, :desc => "The targeted project name"
6
6
  class_option :source, :type => :string, :desc => "Adds the given source to the user list."
7
+
8
+ def self.banner
9
+ "USAGE: engage [project] [options]"
10
+ end
11
+
12
+ def check_parameters
13
+ if name.blank? && options.source.blank?
14
+ say self.class.banner
15
+ say_status 'quitting...', 'no arguments given.', :red
16
+ raise SystemExit
17
+ end
18
+ end
7
19
 
8
20
  def clone_repo
9
21
  return if adding_source?
@@ -60,11 +72,11 @@ module Engage
60
72
  end
61
73
 
62
74
  def adding_source?
63
- !options.source.nil?
75
+ options.source.present?
64
76
  end
65
77
 
66
78
  def rubyversion
67
- `#{ENV["HOME"]}/.rvm/bin/rvm-prompt v`
79
+ `#{ENV["HOME"]}/.rvm/bin/rvm-prompt v`.strip
68
80
  end
69
81
 
70
82
  end
@@ -1,3 +1,3 @@
1
1
  module Engage
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/engage.rb CHANGED
@@ -2,4 +2,5 @@ require 'yaml'
2
2
  require 'thor'
3
3
  require 'thor/group'
4
4
 
5
+ require 'engage/core_ext/blank'
5
6
  require 'engage/runner'
data/spec/runner_spec.rb CHANGED
@@ -3,6 +3,17 @@ require 'spec_helper'
3
3
  describe Engage::Runner do
4
4
  subject { Engage::Runner.new(["lucasmazza/engage"]) }
5
5
  before { stub_commands }
6
+
7
+ context "without parameters" do
8
+ subject { Engage::Runner.new([""]) }
9
+
10
+ it "outputs the script banner and quits" do
11
+ subject.should_receive(:say).with(Engage::Runner.banner)
12
+ subject.should_receive(:say_status).with('quitting...', 'no arguments given.', :red)
13
+ lambda { run }.should raise_error SystemExit
14
+ end
15
+ end
16
+
6
17
  context "Starting projects" do
7
18
 
8
19
  context "a full featured project" do
@@ -65,17 +76,29 @@ describe Engage::Runner do
65
76
  end
66
77
  end
67
78
  end
68
-
69
- context "Writing sources" do
70
- subject { Engage::Runner.new(["wrong"], :source => "git@acme.com") }
71
-
72
- it "doesn't trigger any system call" do
73
- subject.should_not_receive(:system)
74
- run
79
+ context "with the --source option" do
80
+
81
+ context "when passing a new source" do
82
+ subject { Engage::Runner.new(["wrong"], :source => "git@acme.com") }
83
+
84
+ it "doesn't trigger any system call" do
85
+ subject.should_not_receive(:system)
86
+ run
87
+ end
88
+ it "adds the given source to the list" do
89
+ run
90
+ subject.sources.should include("git@acme.com")
91
+ end
75
92
  end
76
- it "adds the given source to the list" do
77
- run
78
- subject.sources.should include("git@acme.com")
93
+
94
+ context "when passing an already existent source" do
95
+ subject { Engage::Runner.new([], :source => "git@github.com") }
96
+
97
+ it "doesn't duplicate the sources" do
98
+ run
99
+ subject.should have(1).sources
100
+ end
79
101
  end
102
+
80
103
  end
81
104
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: engage
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Lucas Mazza
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-12-20 00:00:00 -02:00
18
+ date: 2010-12-21 00:00:00 -02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -95,6 +95,7 @@ files:
95
95
  - bin/engage
96
96
  - engage.gemspec
97
97
  - lib/engage.rb
98
+ - lib/engage/core_ext/blank.rb
98
99
  - lib/engage/runner.rb
99
100
  - lib/engage/version.rb
100
101
  - spec/helpers.rb