geordi 1.2.3 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZTRmNjIxM2QxMjA3MjdlZTZiNDAzMDUyNzVjNDY0YTkyM2RjNDFkYQ==
4
+ ZTg1YjZmMGRjNzQ1YTY4ZTJmNzE2ZmE4Yzc4YjQzOGU3YThlNTY0ZQ==
5
5
  data.tar.gz: !binary |-
6
- MjZmNjkxNWI4OWQ1ZGM2ZGQyMjhkNjAxOTBmMjU2Y2RlODM1MmQwZQ==
6
+ YTVjMTg5NTA0YmU2NDQzZGU5ZWY1Yjc1NjNmODkyMmVhOGYwNGFiMA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- ODgzN2M4YzgwZDAzOTg0ZWQ0ZmE1ZGYxNzhkYmFlMDE0MjYxZmRmNThjNWNi
10
- ZDIxMTkzOWFjNDUzZmEwOGQ3ZjAzMTg4YTE1NWVkZTZiODVjMDQ1OTliZmM1
11
- ZWM1MmI5YWU5OTZmZTU4NjdjZjc3NjcxZWM2MTg4YzAzODRmZTc=
9
+ YWI3YjAzMDE3ZWVmMmFjNGU3ZWM0NTI1MjljZWRiNzE0N2QwYTU1MTlkMjBh
10
+ ZWEzMzFiMGEyODY1OWNlMmE3ZTBjMTc0MTMwZDU0MDJiYmU2M2IyNWY1NDNk
11
+ ODMyZGJkYjdhNTNjM2NhMDEwZjVmYjYxYjBkNzhlZmRjZjg5MzM=
12
12
  data.tar.gz: !binary |-
13
- Zjk4MGFmNTNhNDBlZWNiZDhlNzM1ZGMwZmM4ZTZjMTEzYzEzOTUxNGVjODE0
14
- ZGNiYWMyODIwMTc4MTgwMjlhOTA5OWJkN2NmOGQyMzQ0N2U0MzRjYjc4OTM5
15
- NzY1MGJlOWY5ODNlOWUyNmMxNzdmZjZiZDMwMjEwMmI0OGFiMmY=
13
+ ODhkNTY5ZmNhOTdkMmM3OWRlNzEzMGJkZjBlYWRhMTQxNjMzZGIyNDIzZmVi
14
+ ZjU0MTFmNDBjYmU4MjYyMzIwMzNhZmFjMTZhYTY3ZGRiYjJkOWE5MjZkMzgz
15
+ YmQ0MjgwMGFkMjg3MjdiMjIwNWYxOGVhMjc2N2UzZjdiMzU5YzA=
data/.gitignore CHANGED
@@ -1,8 +1,7 @@
1
1
  *.gem
2
2
  .bundle
3
3
  .idea
4
- Gemfile.lock
5
4
  pkg/*
6
5
  .DS_Store
7
6
  .pt_project_id
8
-
7
+ tmp
data/Gemfile CHANGED
@@ -2,3 +2,10 @@ source "http://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in geordi.gemspec
4
4
  gemspec
5
+
6
+ gem 'aruba'
7
+ gem 'pry'
8
+ gem 'highline'
9
+
10
+ # Required for running features that test parallel test execution
11
+ gem 'parallel_tests' if ENV['GEORDI_TESTING']
data/Gemfile.lock ADDED
@@ -0,0 +1,61 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ geordi (1.3.0)
5
+ thor (>= 0.18.0)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ aruba (0.13.0)
11
+ childprocess (~> 0.5.6)
12
+ contracts (~> 0.9)
13
+ cucumber (>= 1.3.19)
14
+ ffi (~> 1.9.10)
15
+ rspec-expectations (>= 2.99)
16
+ thor (~> 0.19)
17
+ builder (3.2.2)
18
+ childprocess (0.5.9)
19
+ ffi (~> 1.0, >= 1.0.11)
20
+ coderay (1.1.0)
21
+ contracts (0.13.0)
22
+ cucumber (2.3.2)
23
+ builder (>= 2.1.2)
24
+ cucumber-core (~> 1.4.0)
25
+ cucumber-wire (~> 0.0.1)
26
+ diff-lcs (>= 1.1.3)
27
+ gherkin (~> 3.2.0)
28
+ multi_json (>= 1.7.5, < 2.0)
29
+ multi_test (>= 0.1.2)
30
+ cucumber-core (1.4.0)
31
+ gherkin (~> 3.2.0)
32
+ cucumber-wire (0.0.1)
33
+ diff-lcs (1.2.5)
34
+ ffi (1.9.10)
35
+ gherkin (3.2.0)
36
+ highline (1.7.8)
37
+ method_source (0.8.2)
38
+ multi_json (1.11.2)
39
+ multi_test (0.1.2)
40
+ pry (0.10.3)
41
+ coderay (~> 1.1.0)
42
+ method_source (~> 0.8.1)
43
+ slop (~> 3.4)
44
+ rspec-expectations (3.4.0)
45
+ diff-lcs (>= 1.2.0, < 2.0)
46
+ rspec-support (~> 3.4.0)
47
+ rspec-support (3.4.1)
48
+ slop (3.6.0)
49
+ thor (0.19.1)
50
+
51
+ PLATFORMS
52
+ ruby
53
+
54
+ DEPENDENCIES
55
+ aruba
56
+ geordi!
57
+ highline
58
+ pry
59
+
60
+ BUNDLED WITH
61
+ 1.10.6
data/README.md CHANGED
@@ -32,9 +32,9 @@ Run a capistrano command on all deploy targets.
32
32
  Example: `geordi capistrano deploy`
33
33
 
34
34
 
35
- ### geordi cleanup-directory
35
+ ### geordi clean
36
36
 
37
- Remove unneeded files.
37
+ Remove unneeded files from the current directory.
38
38
 
39
39
 
40
40
  ### geordi commit
@@ -57,13 +57,44 @@ Run Cucumber features.
57
57
 
58
58
  Example: `geordi cucumber features/authentication_feature:3`
59
59
 
60
- Runs Cucumber as you want: with `bundle exec`, `cucumber_spinner` detection,
61
- separate Firefox for Selenium, etc.
60
+ Runs Cucumber as you want: with `bundle exec`, using parallel tests, with
61
+ a VNC session holding Selenium test browsers, support for using a dedicated
62
+ testing firefox and beta support for rerunning failed scenarios.
62
63
 
64
+ - *@solo:* Generally, features are run in parallel. However, scenarios tagged
65
+ with @solo are excluded and will be run sequentially, _after_ the parallel run.
63
66
 
64
- ### geordi deploy
67
+ - *Debugging:* Sometimes, the dot-printing Cucumber formatter does not show
68
+ errors. In case a feature fails without a message, try running it with `--debug`
69
+ or `-d`.
65
70
 
66
- Guided deployment.
71
+ - *Options:* Any unknown option will be passed through to Cucumber,
72
+ e.g. `--format pretty`.
73
+
74
+
75
+ ### geordi deploy [STAGE]
76
+
77
+ Guided deployment across branches.
78
+
79
+ Example: `geordi deploy production`
80
+
81
+ Merge, push and deploy with a single command! There are several scenarios where
82
+ this command comes in handy:
83
+
84
+ 1) *Production deploy:* From the master branch, run `geordi deploy production`.
85
+ This will merge `master` to `production`, push and deploy to production.
86
+
87
+ 2) *Feature branch deploy:* From the feature branch, run `geordi deploy staging`.
88
+ This will merge the feature branch to `master`, push and deploy to staging.
89
+
90
+ 3) *Simple deploy:* If the source branch matches the target branch, merging will
91
+ be skipped.
92
+
93
+ Calling the command without arguments will infer the target stage from the
94
+ current branch and fall back to master/staging.
95
+
96
+ When your project does not have a `deploy:migrations` task, this command will
97
+ run `cap deploy` instead when called with `-M`: `geordi deploy -M staging`.
67
98
 
68
99
 
69
100
  ### geordi devserver
@@ -100,6 +131,20 @@ dump into the development database after downloading it.
100
131
  Open the current Eurest cantina menu.
101
132
 
102
133
 
134
+ ### geordi firefox COMMAND
135
+
136
+ Run a command with VNC set up (and the test firefox, if present).
137
+
138
+ Example: `geordi firefox b cucumber` or `geordi firefox --setup 24.0`
139
+
140
+ Useful when you need Firefox for Selenium or the VNC set up, but can't use the
141
+ `geordi cucumber` command.
142
+
143
+ *Install* a special Firefox by calling with `--setup <version>`.
144
+
145
+ This command is aliased `chrome` for users running Selenium in Chrome.
146
+
147
+
103
148
  ### geordi help [COMMAND]
104
149
 
105
150
  Describe available commands or one specific command.
@@ -116,7 +161,7 @@ environment and `rake parallel:prepare` afterwards. Otherwise, invokes `geordi r
116
161
  with `db:migrate`.
117
162
 
118
163
 
119
- ### geordi png-optimize
164
+ ### geordi png-optimize PATH
120
165
 
121
166
  Optimize .png files.
122
167
 
@@ -199,16 +244,6 @@ After setting up, runs all tests when called with the `--test` option:
199
244
  See `geordi help setup` for details.
200
245
 
201
246
 
202
- ### geordi setup-firefox-for-selenium VERSION
203
-
204
- Install a special firefox for running Selenium tests.
205
-
206
-
207
- ### geordi setup-vnc
208
-
209
- Setup VNC for running Selenium tests there.
210
-
211
-
212
247
  ### geordi shell TARGET
213
248
 
214
249
  Open a shell on a Capistrano deploy target.
@@ -255,19 +290,16 @@ See `geordi help update` for details.
255
290
  Print the current version of geordi.
256
291
 
257
292
 
258
- ### geordi vnc-show
293
+ ### geordi vnc
259
294
 
260
295
  Show the hidden VNC window.
261
296
 
297
+ Example: `geordi vnc` or `geordi vnc --setup`
262
298
 
263
- ### geordi with-firefox-for-selenium COMMAND
264
-
265
- Run a command with firefox for selenium set up.
299
+ Launch a VNC session to the hidden screen where `geordi cucumber` runs Selenium
300
+ tests.
266
301
 
267
- Example: `geordi with-firefox-for-selenium b cucumber`
268
-
269
- Useful when you need Firefox for Selenium, but can't use the `geordi cucumber`
270
- command.
302
+ When called with `--setup`, will guide through the setup of VNC.
271
303
 
272
304
 
273
305
  b
@@ -311,3 +343,11 @@ calling your local geordi like so (adjust paths to your needs):
311
343
 
312
344
  Don't forget to update this README. The whole `geordi` section is auto-generated
313
345
  by `rake update_readme`.
346
+
347
+ Geordi is (partially) tested with Cucumber and Aruba. Run all tests with `rake`.
348
+ Of course you're free to use `geordi tests` ;)
349
+
350
+ **Note** that Geordi still needs to support Ruby 1.8.7, so make sure you only
351
+ use syntax that was valid back then (e.g. the :old => hash syntax).
352
+ Unfortunately, it is really hard to get Geordi's tests running on 1.8.7, so you
353
+ need to make sure it runs on 1.8.7 manually.
data/Rakefile CHANGED
@@ -1,6 +1,13 @@
1
1
  require 'bundler'
2
2
  Bundler::GemHelper.install_tasks
3
3
 
4
+ desc 'Default: Run all tests'
5
+ task :default => :features
6
+
7
+ task :features do
8
+ system 'cucumber'
9
+ end
10
+
4
11
  task :update_readme do
5
12
  require File.expand_path('../lib/geordi/cli', __FILE__)
6
13
 
@@ -39,4 +46,5 @@ For details on commands, e.g. supported options, run `geordi help <command>`.
39
46
 
40
47
  updated_readme = readme.sub(geordi_section_regex, geordi_section)
41
48
  File.open('README.md', 'w') { |f| f.puts updated_readme.strip }
49
+ puts 'README.me updated.'
42
50
  end
data/bin/cap-all CHANGED
File without changes
data/bin/console-for CHANGED
File without changes
data/bin/cuc CHANGED
File without changes
data/bin/cuc-show CHANGED
File without changes
data/bin/cuc-vnc-setup CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  puts 'DEPRECATED: Use `geordi vn[c] --setup` instead'
4
- exec 'geordi', 'setup-vnc'
4
+ exec 'geordi', 'vnc', '--setup'
File without changes
data/bin/dump-for CHANGED
File without changes
data/bin/gitpt CHANGED
File without changes
data/bin/load-dump CHANGED
File without changes
data/bin/migrate-all CHANGED
File without changes
data/bin/rs CHANGED
File without changes
data/bin/run_tests CHANGED
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  puts 'DEPRECATED: Use `geordi f[irefox]` instead'
4
- exec 'geordi', 'with-firefox-for-selenium', *ARGV
4
+ exec 'geordi', 'firefox', *ARGV
data/bin/shell-for CHANGED
File without changes
data/bin/tests CHANGED
File without changes
@@ -0,0 +1,6 @@
1
+ Feature: The console command
2
+
3
+ Scenario: Opening a local Rails console
4
+ When I run `geordi console`
5
+ Then the output should contain "# Opening a local Rails console"
6
+ And the output should contain "Util.system! bundle exec rails console development"
@@ -0,0 +1,129 @@
1
+ Feature: The cucumber command
2
+
3
+ Background:
4
+ Given a file named "config/cucumber.yml" with:
5
+ """
6
+ default: features
7
+ rerun: features
8
+ """
9
+
10
+ Scenario: Run a single feature
11
+ Given a file named "features/single.feature" with:
12
+ """
13
+ Feature: Running a single feature
14
+ Scenario: A single scenario
15
+ """
16
+
17
+ When I run `geordi cucumber features/single.feature`
18
+ Then the output should contain "# Running features"
19
+ And the output should contain "> Only: features/single.feature"
20
+ But the output should not contain "parallel"
21
+
22
+
23
+ Scenario: Multiple features are run in parallel
24
+ Given a file named "features/one.feature" with:
25
+ """
26
+ Feature: One
27
+ Scenario: One
28
+ """
29
+ And a file named "features/two.feature" with:
30
+ """
31
+ Feature: Two
32
+ Scenario: Two
33
+ """
34
+
35
+ When I run `geordi cucumber`
36
+ Then the output should contain "# Running features"
37
+ And the output should contain "> All features in features/"
38
+ And the output should contain "> Using parallel_tests"
39
+
40
+
41
+ Scenario: Rerunning tests until they pass
42
+ Given a file named "features/step_definitions/test_steps.rb" with:
43
+ """
44
+ Given /^this test fails$/ do
45
+ raise
46
+ end
47
+ """
48
+ And a file named "features/failing.feature" with:
49
+ """
50
+ Feature: Failing feature
51
+ Scenario: Failing scenario
52
+ And this test fails
53
+ """
54
+
55
+ When I run `geordi cucumber --rerun=2`
56
+ Then the output should contain "# Running features"
57
+ And the output should contain "# Rerun #1 of 2"
58
+ And the output should contain "# Rerun #2 of 2"
59
+ And the output should contain "Rerunning failed scenarios"
60
+ And the output should contain "Using the rerun profile"
61
+ And the exit status should be 1
62
+
63
+
64
+ Scenario: Running all features in a given subfolder
65
+ Given a file named "features/sub/one.feature" with:
66
+ """
67
+ Feature: Testfeature
68
+ """
69
+ And a file named "features/sub/two.feature" with:
70
+ """
71
+ Feature: Testfeature
72
+ """
73
+
74
+ When I run `geordi cucumber features/sub`
75
+ Then the output should contain "> Only: features/sub/two.feature, features/sub/one.feature"
76
+ And the output should contain "> Using parallel_tests"
77
+
78
+
79
+ Scenario: Using the @solo tag
80
+
81
+ The cucumber command runs all features without the @solo tag. If any of the
82
+ .feature files contains '@solo', it boots Cucumber a second time and runs
83
+ only the features tagged with @solo.
84
+
85
+ Given a file named "features/no_solo.feature" with:
86
+ """
87
+ Feature: Test without solo tag
88
+ Scenario: This scenario can run in parallel
89
+ """
90
+ And a file named "features/solo.feature" with:
91
+ """
92
+ Feature: Solo test
93
+ @solo
94
+ Scenario: This scenario must NOT run in parallel
95
+ """
96
+
97
+ When I run `geordi cucumber --verbose`
98
+ Then the output should contain "# Running features"
99
+ And the output should match /^> .*cucumber .*--tags ~@solo/
100
+ And the output should contain "# Running @solo features"
101
+ And the output should match /^> .*cucumber .*--tags @solo/
102
+
103
+
104
+ Scenario: When there are no scenarios tagged @solo, the extra run is skipped
105
+ Given a file named "features/no_solo.feature" with:
106
+ """
107
+ Feature: Test without solo tag
108
+ Scenario: This scenario can run in parallel
109
+ """
110
+
111
+ When I run `geordi cucumber --verbose`
112
+ Then the output should contain "# Running features"
113
+ And the output should match /^> .*cucumber .*--tags ~@solo/
114
+ But the output should not contain "# Running @solo features"
115
+ And the output should not match /^> .*cucumber .*--tags @solo/
116
+
117
+
118
+ Scenario: Specifying a firefox version to use
119
+ Given a file named "features/sub/one.feature" with:
120
+ """
121
+ Feature: Testfeature
122
+ """
123
+ And a file named ".firefox-version" with:
124
+ """
125
+ 24.0
126
+ """
127
+
128
+ When I run `geordi cucumber --verbose`
129
+ Then the output should match /^> PATH=.*24.0:\$PATH.* cucumber/
@@ -0,0 +1,31 @@
1
+ Feature: The dump command
2
+
3
+ Scenario: Creating a dump of the development database
4
+ When I run `geordi dump`
5
+ Then the output should contain "Util.system! dumple development"
6
+ And the output should contain "Successfully dumped the development database"
7
+
8
+
9
+ Scenario: Creating a dump of a remote database
10
+ Given a file named "Capfile" with "Capfile exists"
11
+ And a file named "config/deploy.rb" with:
12
+ """
13
+ """
14
+ And a file named "config/deploy/staging.rb" with:
15
+ """
16
+ set :rails_env, 'staging'
17
+ set :deploy_to, '/var/www/example.com'
18
+ set :user, 'user'
19
+
20
+ server 'www.example.com'
21
+ """
22
+
23
+ When I run `geordi dump staging`
24
+ Then the output should contain "# Dumping the database of staging"
25
+ And the output should contain "> Connecting to www.example.com"
26
+ And the output should contain "Util.system! ssh user@www.example.com -t cd /var/www/example.com/current && bash --login -c 'dumple staging --for_download'"
27
+ And the output should contain "> Downloading remote dump to tmp/staging.dump"
28
+ # Omitting the absolute path in this regex (.*)
29
+ And the output should match %r<Util.system! scp user@www.example.com:~/dumps/dump_for_download.dump .*/tmp/aruba/tmp/staging.dump>
30
+ And the output should contain "> Dumped the staging database to tmp/staging.dump"
31
+
@@ -0,0 +1,53 @@
1
+ Feature: The firefox/chrome command
2
+
3
+ This command is used internally by the cucumber command.
4
+
5
+ Scenario: Running a command with VNC set up
6
+ Given a file named "testfile" with "testcontent"
7
+
8
+ When I run `geordi firefox cat testfile`
9
+ Then the output should contain "> VNC is ready to hold Selenium test browsers. Use `geordi vnc` to view them."
10
+ And the output should contain "testcontent"
11
+ But the output should not contain "Firefox for Selenium"
12
+
13
+
14
+ Scenario: The command is aliased as "chrome"
15
+ Given a file named "testfile" with "testcontent"
16
+
17
+ When I run `geordi chrome cat testfile`
18
+ Then the output should contain "> VNC is ready to hold Selenium test browsers. Use `geordi vnc` to view them."
19
+ And the output should contain "testcontent"
20
+
21
+
22
+ # Could not get this to work
23
+ # Scenario: Running a command with VNC and Firefox set up
24
+ # Given a mocked home directory
25
+ # Given a file named ".firefox-version" with "1337"
26
+ # And a file named "bin/firefoxes/1337/firefox" with "<fake>"
27
+ # And a file named "testfile" with "testcontent"
28
+ #
29
+ # When I run `geordi firefox cat testfile`
30
+ # Then the output should contain "> VNC is ready"
31
+ # And the output should contain "> Firefox for Selenium set up"
32
+ # And the output should contain "testcontent"
33
+
34
+
35
+ Scenario: Having a .firefox-version that is not installed yet
36
+ Given a file named ".firefox-version" with "1337"
37
+ And a file named "testfile" with "testcontent"
38
+
39
+ When I run `geordi firefox cat testfile` interactively
40
+ And I type "yes"
41
+ Then the output should contain "> Firefox 1337 not found"
42
+ And the output should contain "Run tests anyway?"
43
+ And the output should contain "testcontent"
44
+
45
+
46
+ Scenario: A .firefox-version file with "system" is ignored (legacy support)
47
+ Given a file named ".firefox-version" with "system"
48
+ And a file named "testfile" with "testcontent"
49
+
50
+ When I run `geordi firefox cat testfile`
51
+ Then the output should contain "> VNC is ready"
52
+ And the output should contain "testcontent"
53
+ But the output should not contain "Firefox for Selenium"
@@ -0,0 +1,30 @@
1
+ Feature: The shell command
2
+
3
+ Background:
4
+ Given a file named "Capfile" with "Capfile exists"
5
+
6
+
7
+ Scenario: It opens a remote shell on the primary server
8
+ Given a file named "config/deploy.rb" with "deploy.rb exists"
9
+ And a file named "config/deploy/geordi.rb" with:
10
+ """
11
+ set :user, 'deploy'
12
+ set :deploy_to, '/var/www/example.com'
13
+ server 'first.example.com'
14
+ server 'second.example.com'
15
+ """
16
+
17
+ When I run `geordi shell geordi`
18
+ Then the output should contain "Util.system! ssh deploy@first.example.com -t cd /var/www/example.com/current && bash --login"
19
+
20
+
21
+ Scenario: It understands Capistrano 3 syntax
22
+ Given a file named "config/deploy.rb" with "deploy.rb exists"
23
+ And a file named "config/deploy/geordi.rb" with:
24
+ """
25
+ set :deploy_to, '/var/www/example.com'
26
+ server 'first.example.com', user: 'deploy'
27
+ """
28
+
29
+ When I run `geordi shell geordi`
30
+ Then the output should contain "Util.system! ssh deploy@first.example.com -t cd /var/www/example.com/current && bash --login"
@@ -0,0 +1,5 @@
1
+ require 'aruba/cucumber'
2
+ require 'pry'
3
+
4
+ # Disables execution of Util.system! calls
5
+ ENV['GEORDI_TESTING'] = 'true'
data/geordi.gemspec CHANGED
@@ -21,9 +21,8 @@ Gem::Specification.new do |s|
21
21
  s.require_paths = ["lib"]
22
22
 
23
23
  s.add_runtime_dependency 'thor', '>= 0.18.0'
24
- # s.add_development_dependency 'debugger'
25
24
 
26
25
  s.post_install_message = <<-ATTENTION
27
- Binary `geordi` installed
26
+ Binary `geordi` installed
28
27
  ATTENTION
29
28
  end
@@ -1,60 +1,57 @@
1
- require 'capistrano'
2
-
3
1
  module Geordi
4
2
  class CapistranoConfig
5
3
 
6
4
  attr_accessor :root
7
5
 
8
6
  def initialize(stage)
9
- ENV['BUNDLE_BIN_PATH'] = 'Trick capistrano safeguard in deploy.rb into believing bundler is present by setting this variable.'
10
-
11
- @stage = stage
12
- @root = find_project_root!
13
- load_capistrano_config
7
+ self.stage = stage
8
+ self.root = find_project_root!
9
+ load_deploy_info
14
10
  end
15
11
 
16
- def user
17
- @capistrano_config.fetch(:user)
12
+ def user(server)
13
+ cap2user = deploy_info[ /^set :user, ['"](.*?)['"]/, 1 ]
14
+ cap2user || deploy_info[ /^server ['"]#{ server }['"],.*user.{1,4}['"](.*?)['"]/, 1 ]
18
15
  end
19
16
 
20
17
  def servers
21
- @capistrano_config.find_servers(:roles => [:app])
18
+ deploy_info.scan(/^server ['"](.*?)['"]/).flatten
22
19
  end
23
20
 
24
21
  def primary_server
25
- @capistrano_config.find_servers(:roles => [:app], :only => { :primary => true }).first
22
+ # Actually, servers may have a :primary property. From Capistrano 3, the
23
+ # first listed server is the primary one by default, which is a good-
24
+ # enough default for us.
25
+ servers.first
26
26
  end
27
27
 
28
- def path
29
- @capistrano_config.fetch(:deploy_to) + '/current'
28
+ def remote_root
29
+ File.join deploy_info[ /^set :deploy_to, ['"](.*?)['"]/, 1 ], 'current'
30
30
  end
31
31
 
32
32
  def env
33
- @capistrano_config.fetch(:rails_env, 'production')
33
+ deploy_info[ /^set :rails_env, ['"](.*?)['"]/, 1 ]
34
34
  end
35
35
 
36
36
  def shell
37
- @capistrano_config.fetch(:default_shell, 'bash --login')
37
+ 'bash --login'
38
38
  end
39
39
 
40
-
41
40
  private
42
41
 
43
- def load_capistrano_config
44
- config = ::Capistrano::Configuration.new
45
- config.load('deploy')
46
- config.load('config/deploy')
47
- if @stage and @stage != ''
48
- config[:stage] = @stage
49
- config.find_and_execute_task(@stage)
50
- end
42
+ attr_accessor :deploy_info, :stage
51
43
 
52
- @capistrano_config = config
44
+ def load_deploy_info
45
+ self.deploy_info = File.read(File.join root, 'config/deploy.rb').tap do |info|
46
+ if stage
47
+ info << "\n" << File.read(File.join root, "config/deploy/#{ stage }.rb")
48
+ end
49
+ end
53
50
  end
54
51
 
55
52
  def find_project_root!
56
53
  current = Dir.pwd
57
- until (File.exists? 'Capfile')
54
+ until File.exists?('Capfile')
58
55
  Dir.chdir '..'
59
56
  raise <<-ERROR if current == Dir.pwd
60
57
  Could not locate Capfile.