deep_thought 0.1.1 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c0dfbb4db4fd08ad8def952e00cf106b02862d25
4
- data.tar.gz: dd56ee449838d5ba4bd0c01f5041f32d3105fdc8
3
+ metadata.gz: f19cef213ef16227a7bc898ac65270247f7b1e67
4
+ data.tar.gz: 301d7f61c392fd8c92790dcc1d3df457f7c76d1b
5
5
  SHA512:
6
- metadata.gz: 937786d6394d8d5ca34fcaf3cda570cdff45b394c8bb94c4a7f674c9b859c499f53e3b27858e639f2c794adcc230af02274fbeb0dd059b6dbe06784ff2d0b854
7
- data.tar.gz: f49fc78d7cf859cf928435ab78bdbaddb56b1d67bad870c9405a1f8e0751e95111d1122754925f71fc90fa7b638375e8a7193b9b4e77832a3f344eeac7464777
6
+ metadata.gz: 8132f413fc46c326fb189c9deefdc1334bfadcebbfdef68580591b6e1764ddbaf1602e05d1892c7f01bd786beede6552d7e03ae994ee3dacd9d8a7313de27972
7
+ data.tar.gz: c37efee45ec3c1bc287b7a6f930bfcf202b272b072432c2de6578808e70a8c934f590eefb95ff2928e1953cc431c907c741a8911e5962f0dabc2396166cf4e22
data/README.md CHANGED
@@ -6,7 +6,7 @@ Deploy smart, not hard.
6
6
 
7
7
  Deep Thought takes all of the thought out of deploying.
8
8
 
9
- Want to prevent deployment conflicts? Deep Thought does that. Want to deploy with Hubot? Deep Thought has you covered. Looking to ensure a build is green before it is deployed? Deep Thought yawns at your puny requests. Want a web interface? Got it. An API? Yep. Security? Totally locked down. Deep Thought is master of your deployments.
9
+ Want to prevent deployment conflicts? Deep Thought does that. Want to deploy with Hubot? Deep Thought has you covered. Looking to ensure a build is green before it is deployed? Deep Thought yawns at your puny requests. How about deployment locking? Of course! Want a web interface? Got it. An API? Yep. Security? Totally locked down. Deep Thought is master of your deployments.
10
10
 
11
11
  Deep Thought was inspired by GitHub's own Hubot+Heaven workflow. Check out [Zach Holman's talk](http://zachholman.com/talk/unsucking-your-teams-development-environment/) to see the original inspiration.
12
12
 
@@ -20,7 +20,9 @@ Use [this Gist](https://gist.github.com/redhotvengeance/5746731) to get started:
20
20
 
21
21
  ### Setup
22
22
 
23
- Deep Thought needs an environment with Ruby and Git installed, and also access to a PostgreSQL database. Deep Thought will work fine on any server or VM matching those requirements, though it is largely designed to be deployed to Heroku:
23
+ Deep Thought needs an environment with Ruby and Git installed, and also access to a database. Deep Thought by default expects a PostgreSQL database, but should work with any ActiveRecord-compatible database.
24
+
25
+ Deep Thought will work fine on any server or VM matching those requirements, though it is largely designed to be deployed to Heroku:
24
26
 
25
27
  heroku apps:create [NAME]
26
28
  heroku config:set RACK_ENV=production
@@ -52,6 +54,14 @@ Deep Thought requires the use of a background worker for deployments. Normally,
52
54
  HEROKU_APP=<app-name>
53
55
  HEROKU_API_KEY=<your-heroku-api-key>
54
56
 
57
+ If you'd like to use a database other than PostgreSQL, you'll need to add appropriate gem to your Gemfile and set the `DATABASE_ADAPTER` environment variable. For instance, if you'd like to use MySQL, add the gem to the Gemfile:
58
+
59
+ gem "mysql2"
60
+
61
+ Then set the adapter environment variable:
62
+
63
+ DATABASE_ADAPTER=mysql2
64
+
55
65
  ### Add a project
56
66
 
57
67
  Once logged in, click the `+ add project` button on the `projects` page. Enter a unique project name and the remote Git repository url for the project. Click `create project`, and your project will be set up and ready to deploy.
@@ -154,7 +164,7 @@ Your custom deployer should live in the `DeepThought::Deployer` namespace. Deep
154
164
 
155
165
  The `setup?` method is called before deploys to ensure the project is setup as needed for the deploy to execute properly. For instance, if your deployer deploys by pushing to a Git remote, you can ensure that the Git remotes exist within `setup?`. Your deployer may have no need of `setup?`, in which case just don't bother overwriting the method.
156
166
 
157
- A reference to the project is passed to the `setup?` method, as is the project config (which is the hash generated from the project's `.deepthought.yml` file). You can use access to the config to take advantage of any deployer-specfic data that may have been put into the `.deepthought.yml` file.
167
+ A reference to the project is passed to the `setup?` method, as is the project config (which is the hash generated from the project's `.deepthought.yml` file). You can use access to the config to take advantage of any deployer-specific data that may have been put into the `.deepthought.yml` file.
158
168
 
159
169
  The `setup?` method should return `true` when successful and `false` when not.
160
170
 
@@ -228,10 +238,16 @@ Set it up:
228
238
 
229
239
  script/bootstrap
230
240
 
241
+ The bootstrap script will create an `.env`, install all required gems, set up the databases, and make a user. Of course, you can always do it manually.
242
+
231
243
  Create an `.env`:
232
244
 
233
245
  echo RACK_ENV=development > .env
234
246
 
247
+ Install required gems:
248
+
249
+ bundle install --binstubs
250
+
235
251
  Set up the databases (PostgreSQL):
236
252
 
237
253
  createuser deep_thought
@@ -239,6 +255,9 @@ Set up the databases (PostgreSQL):
239
255
  createdb -O deep_thought -E utf8 deep_thought_test
240
256
  rake db:migrate
241
257
 
258
+ Make a user:
259
+ bundle exec rake create_user[test@test.com,secret]
260
+
242
261
  Start the server:
243
262
 
244
263
  script/server
data/Rakefile CHANGED
@@ -3,8 +3,9 @@ $LOAD_PATH.unshift(File.expand_path("../lib", __FILE__))
3
3
  require "bundler/gem_tasks"
4
4
  require "active_record"
5
5
  require "fileutils"
6
+ require 'dotenv'
6
7
 
7
- ENV["RACK_ENV"] ||= "development"
8
+ Dotenv.load
8
9
 
9
10
  require "deep_thought"
10
11
 
@@ -35,6 +35,7 @@ Gem::Specification.new do |gem|
35
35
  gem.add_development_dependency "shotgun", "~>0.9"
36
36
  gem.add_development_dependency "thin", "~>1.6"
37
37
  gem.add_development_dependency "racksh", "~>1.0.0"
38
+ gem.add_development_dependency "dotenv", "~>0.9"
38
39
 
39
40
  # # testing
40
41
  gem.add_development_dependency "minitest", "~>4.7"
@@ -17,17 +17,18 @@ require 'deep_thought/version'
17
17
 
18
18
  module DeepThought
19
19
  def self.setup(settings)
20
- env = settings['RACK_ENV']
20
+ env = settings['RACK_ENV'] ||= 'development'
21
21
 
22
22
  if env != "production"
23
23
  settings["DATABASE_URL"] ||= "postgres://deep_thought@localhost/deep_thought_#{env}"
24
24
  end
25
25
 
26
26
  database = URI(settings["DATABASE_URL"])
27
+ settings["DATABASE_ADAPTER"] ||= "postgresql"
27
28
 
28
29
  connection = {
29
- :adapter => "postgresql",
30
- :encoding => "unicode",
30
+ :adapter => settings["DATABASE_ADAPTER"],
31
+ :encoding => "utf8",
31
32
  :database => database.path[1..-1],
32
33
  :pool => 5,
33
34
  :username => database.user,
@@ -1,3 +1,3 @@
1
1
  module DeepThought
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.1"
3
3
  end
@@ -1,3 +1,67 @@
1
1
  #!/bin/sh
2
2
 
3
+ echo ''
4
+ echo 'Boostraping Deep Thought...'
5
+
6
+ ruby --version >/dev/null 2>&1 || { echo >&2 "\nIt looks like the Ruby isn't installed. You're going to need it: https://www.ruby-lang.org/en/\n"; exit 1; }
7
+ git --version >/dev/null 2>&1 || { echo >&2 "\nIt looks like the Heroku Toolbelt isn't installed. You're going to need it: http://git-scm.com/\n"; exit 1; }
8
+ psql --version >/dev/null 2>&1 || { echo >&2 "\nIt looks like PostgreSQL isn't installed. You're going to need it: http://www.postgresql.org/\n"; exit 1; }
9
+
10
+ create_env() {
11
+ echo "RACK_ENV=development" > "${PWD}/.env"
12
+ echo "SESSION_SECRET=secret" >> "${PWD}/.env"
13
+ }
14
+
15
+ echo ''
16
+ echo 'Creating .env file...'
17
+
18
+ if [ -f "${PWD}/.env" ]; then
19
+ echo ''
20
+ read -p "File already exists - what would you like to do? [s]kip or [o]verwrite? " action
21
+
22
+ case "$action" in
23
+ o )
24
+ create_env
25
+ esac
26
+ else
27
+ create_env
28
+ fi
29
+
30
+ echo ''
31
+ echo 'Installing required gems...'
32
+
3
33
  bundle install --binstubs
34
+
35
+ create_db() {
36
+ psql -l >/dev/null 2>&1 || { echo >&2 "\nIt looks like PostgreSQL isn't running. Depending on how you installed it, there are any number of ways it could be started. Go get it running and then bootstrap again.\n"; exit 1; }
37
+
38
+ echo ''
39
+ echo 'Creating deep_thought user...'
40
+
41
+ createuser deep_thought >/dev/null 2>&1
42
+
43
+ echo 'Creating deep_thought_development database...'
44
+ createdb -O deep_thought -E utf8 deep_thought_development >/dev/null 2>&1
45
+
46
+ echo 'Creating deep_thought_test database...'
47
+ createdb -O deep_thought -E utf8 deep_thought_test >/dev/null 2>&1
48
+
49
+ echo 'Running migrations...'
50
+ bundle exec rake db:migrate
51
+ bundle exec rake db:migrate RACK_ENV=test
52
+
53
+ echo 'Creating user test@test.com with password "secret"'
54
+ bundle exec rake create_user[test@test.com,secret] >/dev/null 2>&1
55
+ }
56
+
57
+ echo ''
58
+ read -p "Would you like me to create and configure the PostgreSQL database for this project? [y]es or [n]o? " action
59
+
60
+ case "$action" in
61
+ y )
62
+ create_db
63
+ esac
64
+
65
+ echo ''
66
+ echo 'Done!'
67
+ echo ''
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: deep_thought
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ian Lollar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-13 00:00:00.000000000 Z
11
+ date: 2013-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -234,6 +234,20 @@ dependencies:
234
234
  - - ~>
235
235
  - !ruby/object:Gem::Version
236
236
  version: 1.0.0
237
+ - !ruby/object:Gem::Dependency
238
+ name: dotenv
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - ~>
242
+ - !ruby/object:Gem::Version
243
+ version: '0.9'
244
+ type: :development
245
+ prerelease: false
246
+ version_requirements: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - ~>
249
+ - !ruby/object:Gem::Version
250
+ version: '0.9'
237
251
  - !ruby/object:Gem::Dependency
238
252
  name: minitest
239
253
  requirement: !ruby/object:Gem::Requirement