foreplay 0.0.1 → 0.0.2

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.
@@ -0,0 +1,13 @@
1
+ require 'spec_helper'
2
+ require 'foreplay'
3
+
4
+ describe Foreplay::Setup do
5
+ before :each do
6
+ `rm -f config/foreplay.yml`
7
+ end
8
+
9
+ it "should create a config file" do
10
+ File.should_receive(:open)
11
+ Foreplay::Setup.start
12
+ end
13
+ end
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+ require 'foreplay'
3
+
4
+ describe Foreplay::Utility do
5
+ it "should complain unless two hashes are passed to it" do
6
+ expect { Foreplay::Utility::supermerge('x', 'y') }.to raise_error(RuntimeError)
7
+ end
8
+
9
+ it "should merge two simple hashes" do
10
+ expect(Foreplay::Utility::supermerge({ :a => 'x' }, { :b => 'y' })).to eq({ 'a' => 'x', 'b' => 'y' })
11
+ end
12
+
13
+ it "should merge two hashes both with arrays at the same key" do
14
+ expect(Foreplay::Utility::supermerge({ :a => ['x'] }, { :a => ['y'] })).to eq({ 'a' => ['x', 'y'] })
15
+ end
16
+
17
+ it "should merge an array and a value at the same key" do
18
+ expect(Foreplay::Utility::supermerge({ :a => 'x' }, { :a => ['y'] })).to eq({ 'a' => ['x', 'y'] })
19
+ end
20
+
21
+ it "should replace a value at the same key" do
22
+ expect(Foreplay::Utility::supermerge({ :a => 'x' }, { :a => 'y' })).to eq({ 'a' => 'y' })
23
+ end
24
+
25
+ it "should merge two subhashes at the same key" do
26
+ expect(Foreplay::Utility::supermerge({ :a => { :b => 'x' } }, { :a => { :c => 'y' } })).to eq({ 'a' => { 'b' => 'x', 'c' => 'y' } })
27
+ end
28
+ end
@@ -0,0 +1,16 @@
1
+ # Initialize simplecov for coverage report.
2
+ require 'simplecov'
3
+ SimpleCov.start
4
+
5
+ RSpec.configure do |config|
6
+ # Run specs in random order to surface order dependencies. If you find an
7
+ # order dependency and want to debug it, you can fix the order by providing
8
+ # the seed, which is printed after each run.
9
+ # --seed 1234
10
+ config.order = "random"
11
+
12
+ # Manually-added
13
+ config.color_enabled = true
14
+ config.tty = true
15
+ config.formatter = :documentation
16
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: foreplay
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-09 00:00:00.000000000 Z
12
+ date: 2013-11-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -43,22 +43,6 @@ dependencies:
43
43
  - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
- - !ruby/object:Gem::Dependency
47
- name: hashie
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: '0'
54
- type: :runtime
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
46
  - !ruby/object:Gem::Dependency
63
47
  name: foreman
64
48
  requirement: !ruby/object:Gem::Requirement
@@ -203,6 +187,22 @@ dependencies:
203
187
  - - ! '>='
204
188
  - !ruby/object:Gem::Version
205
189
  version: '0'
190
+ - !ruby/object:Gem::Dependency
191
+ name: simplecov
192
+ requirement: !ruby/object:Gem::Requirement
193
+ none: false
194
+ requirements:
195
+ - - ! '>='
196
+ - !ruby/object:Gem::Version
197
+ version: '0'
198
+ type: :development
199
+ prerelease: false
200
+ version_requirements: !ruby/object:Gem::Requirement
201
+ none: false
202
+ requirements:
203
+ - - ! '>='
204
+ - !ruby/object:Gem::Version
205
+ version: '0'
206
206
  description: Deploying Rails projects to Ubuntu using Foreman
207
207
  email:
208
208
  - developers@xenapto.com
@@ -212,24 +212,30 @@ extensions: []
212
212
  extra_rdoc_files: []
213
213
  files:
214
214
  - .gitignore
215
+ - .rvmrc
215
216
  - Gemfile
216
217
  - LICENSE.txt
217
218
  - README.md
218
219
  - Rakefile
219
220
  - bin/foreplay
220
- - features/config.feature
221
- - features/generator.feature
222
- - features/support/setup.rb
221
+ - features/check.feature
222
+ - features/deploy.feature
223
+ - features/setup.feature
224
+ - features/support/env.rb
223
225
  - foreplay.gemspec
224
226
  - foreplay.rake
225
227
  - foreplay.rb
226
228
  - lib/foreplay.rb
227
229
  - lib/foreplay/cli.rb
228
- - lib/foreplay/config.rb
229
- - lib/foreplay/generators/foreplay.yml
230
- - lib/foreplay/generators/setup.rb
230
+ - lib/foreplay/deploy.rb
231
+ - lib/foreplay/setup.rb
232
+ - lib/foreplay/setup/foreplay.yml
233
+ - lib/foreplay/utility.rb
231
234
  - lib/foreplay/version.rb
232
- - spec/foreplay_spec.rb
235
+ - spec/lib/foreplay/deploy_spec.rb
236
+ - spec/lib/foreplay/setup_spec.rb
237
+ - spec/lib/foreplay/utility_spec.rb
238
+ - spec/spec_helper.rb
233
239
  homepage: https://github.com/Xenapto/foreplay
234
240
  licenses:
235
241
  - MIT
@@ -245,7 +251,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
245
251
  version: '0'
246
252
  segments:
247
253
  - 0
248
- hash: -929256133810576486
254
+ hash: -981112274767649738
249
255
  required_rubygems_version: !ruby/object:Gem::Requirement
250
256
  none: false
251
257
  requirements:
@@ -254,7 +260,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
254
260
  version: '0'
255
261
  segments:
256
262
  - 0
257
- hash: -929256133810576486
263
+ hash: -981112274767649738
258
264
  requirements: []
259
265
  rubyforge_project:
260
266
  rubygems_version: 1.8.25
@@ -262,7 +268,11 @@ signing_key:
262
268
  specification_version: 3
263
269
  summary: ! 'Example: foreplay push to production'
264
270
  test_files:
265
- - features/config.feature
266
- - features/generator.feature
267
- - features/support/setup.rb
268
- - spec/foreplay_spec.rb
271
+ - features/check.feature
272
+ - features/deploy.feature
273
+ - features/setup.feature
274
+ - features/support/env.rb
275
+ - spec/lib/foreplay/deploy_spec.rb
276
+ - spec/lib/foreplay/setup_spec.rb
277
+ - spec/lib/foreplay/utility_spec.rb
278
+ - spec/spec_helper.rb
@@ -1,66 +0,0 @@
1
- Feature: Config
2
- In order to configure Foreplay
3
- As a CLI
4
- I want to be as usable as possible
5
-
6
- Scenario: Check configuration
7
- When I run `foreplay check`
8
- Then the output should contain "OK"
9
-
10
- Scenario: Check configuration parameters - invalid parameter
11
- When I run `foreplay check --invalid xyz`
12
- Then the output should contain:
13
- """
14
- ERROR: foreplay check was called with arguments ["--invalid", "xyz"]
15
- Usage: "foreplay check".
16
- """
17
-
18
- Scenario: Check configuration parameters - short invalid parameter
19
- When I run `foreplay check -x xyz`
20
- Then the output should contain:
21
- """
22
- ERROR: foreplay check was called with arguments ["-x", "xyz"]
23
- Usage: "foreplay check".
24
- """
25
-
26
- Scenario: Check configuration parameters - environment parameter
27
- When I run `foreplay check --environment production`
28
- Then the output should contain "Checking configuration for"
29
- And the output should contain "production environment"
30
- And the output should contain "all roles"
31
- And the output should contain "all servers"
32
-
33
- Scenario: Check configuration parameters - role parameter
34
- When I run `foreplay check --role worker`
35
- Then the output should contain "Checking configuration for"
36
- And the output should contain "all environments"
37
- And the output should contain "worker role"
38
- And the output should contain "all servers"
39
-
40
- Scenario: Check configuration parameters - server parameter
41
- When I run `foreplay check --server worker.example.com`
42
- Then the output should contain "Checking configuration for"
43
- And the output should contain "all environments"
44
- And the output should contain "all roles"
45
- And the output should contain "worker.example.com server"
46
-
47
- Scenario: Check configuration parameters - short environment parameter
48
- When I run `foreplay check -e production`
49
- Then the output should contain "Checking configuration for"
50
- And the output should contain "production environment"
51
- And the output should contain "all roles"
52
- And the output should contain "all servers"
53
-
54
- Scenario: Check configuration parameters - short role parameter
55
- When I run `foreplay check -r worker`
56
- Then the output should contain "Checking configuration for"
57
- And the output should contain "all environments"
58
- And the output should contain "worker role"
59
- And the output should contain "all servers"
60
-
61
- Scenario: Check configuration parameters - short server parameter
62
- When I run `foreplay check -s worker.example.com`
63
- Then the output should contain "Checking configuration for"
64
- And the output should contain "all environments"
65
- And the output should contain "all roles"
66
- And the output should contain "worker.example.com server"
@@ -1,97 +0,0 @@
1
- Feature: Setup
2
- In order to setup Foreplay
3
- As a CLI user
4
- I want to be able to create the config scaffold
5
-
6
- Scenario: Setup
7
- When I run `foreplay setup`
8
- Then the following files should exist:
9
- | config/foreplay.yml |
10
- And the file "config/foreplay.yml" should contain:
11
- """
12
- # Format:
13
- #
14
- # There is a section for each environment that you will deploy to, plus a section that defines global default
15
- # values for all environments, like this:
16
- #
17
- # defaults:
18
- # ...
19
- # production:
20
- # ...
21
- # staging:
22
- # ...
23
- #
24
- # Within each section you can define the server roles for that environment: web, worker, database etc. (the
25
- # names of these roles are up to you). You can also define environment-level defaults that apply to all roles.
26
- # Like this:
27
- #
28
- # production:
29
- # defaults:
30
- # ...
31
- # web:
32
- # ...
33
- # worker:
34
- # ...
35
- # scheduler:
36
- # ...
37
- # database:
38
- # ...
39
- # staging:
40
- # defaults:
41
- # ...
42
- # web:
43
- # ...
44
- # worker:
45
- # ...
46
- # scheduler:
47
- # ...
48
- # database:
49
- # ...
50
- #
51
- # Within each role section you can define how the deployment is configured for the servers in that role.
52
- # Some of these values will normally be defined as a default, some will be specific to a particular role.
53
- # The values you can configure are as follows:
54
- #
55
- # value Normally defined as Notes
56
- # ------------- -------------------- -------------------------------------------------------------------
57
- # name: Global default App name (if omitted then
58
- # Rails.application.class.parent_name.underscore is used)
59
- # user: Global default The username to connect with (must have SSH permissions)
60
- # password: Global default The password to use to connect (not necessary if you've set up SSH
61
- # keys - see below)
62
- # keyfile: Global default A file containing a private key that allows the named user access
63
- # to the server, or...
64
- # key: Global default A private key that allows the named user access to the server
65
- # path: Global default An absolute path to deploy the app on each server. %a will be
66
- # translated to the application name. %u will be translated to the
67
- # login user name
68
- # database: Environment default The database.yml elements to write to the config folder
69
- # key: value
70
- # servers: [server1, server2, server3]
71
- # Role level Which servers to deploy the app on
72
- # env: Role level Contents of the .env file
73
- # key: value Values will go into the .env file as key=value
74
- # foreman: Role level Contents of the .foreman file
75
- # key: value
76
- #
77
- defaults:
78
- name: %q{TODO: Add the app name}
79
- repository: %q{TODO: Add the git repository path}
80
- user: %q{TODO: Add the user to logon to the deployment server}
81
- password: %q{TODO: Add the password for the user on the deployment server}
82
- path: %q{TODO: Add the path to deploy to on the deployment server}
83
- production:
84
- defaults:
85
- database:
86
- adapter: postgresql
87
- encoding: utf8
88
- database: %q{TODO: Add the database name}
89
- pool: 5
90
- host: %q{TODO: Add the database host name}
91
- username: %q{TODO: Add the database user}
92
- password: %q{TODO: Add the database user's password}
93
- web:
94
- servers: [%q{TODO: Add the name of the production web server}]
95
- foreman:
96
- concurrency: 'web=1,worker=0,scheduler=0'
97
- """
@@ -1 +0,0 @@
1
- require 'aruba/cucumber'
@@ -1,25 +0,0 @@
1
- require 'active_support/inflector'
2
- require 'colorize'
3
- require 'hashie/mash'
4
-
5
- module Foreplay
6
- class Config
7
- def self.check *args
8
- options = Hashie::Mash[args.first]
9
-
10
- # Explain what we're going to do
11
- environments = explanatory_text options.environment, 'environment'
12
- roles = explanatory_text options.role, 'role'
13
- servers = explanatory_text options.server, 'server'
14
- puts 'Checking configuration for %s, %s, %s' % [environments, roles, servers]
15
-
16
- 'Not finished'
17
- end
18
-
19
- private
20
-
21
- def self.explanatory_text(value, singular_word)
22
- value.nil? ? "all #{singular_word.pluralize}" : "#{value.dup.yellow} #{singular_word}"
23
- end
24
- end
25
- end
@@ -1,20 +0,0 @@
1
- require 'thor/group'
2
-
3
- module Foreplay
4
- module Generators
5
- class Setup < Thor::Group
6
- include Thor::Actions
7
-
8
- Rails ||= nil
9
-
10
- def self.source_root
11
- File.dirname(__FILE__)
12
- end
13
-
14
- def create_config_file
15
- @name = Rails.nil? ? '%q{TODO: Add the app name}' : Rails.application.class.parent_name.underscore
16
- template('foreplay.yml', 'config/foreplay.yml')
17
- end
18
- end
19
- end
20
- end
@@ -1,7 +0,0 @@
1
- require 'foreplay'
2
-
3
- describe Foreplay::Config do
4
- it "should check the config" do
5
- Foreplay::Config.check.should eql('OK')
6
- end
7
- end