database_yml 0.0.2 → 0.0.3

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.
data/lib/database_yml.rb CHANGED
@@ -3,6 +3,7 @@
3
3
 
4
4
  require 'pathname'
5
5
  require 'fileutils'
6
+ require 'etc'
6
7
 
7
8
  class DatabaseYML
8
9
  SCRIPT_RAILS = File.join('script', 'rails')
@@ -44,7 +45,17 @@ class DatabaseYML
44
45
  end
45
46
 
46
47
  def generate_database_yml!
47
- FileUtils.cp(File.join(TEMPLATES_DIR, @database), File.join(Dir.pwd, "config", "database.yml"))
48
+ template = File.open(File.join(TEMPLATES_DIR, @database)).read
49
+ output_file = File.new(File.join(Dir.pwd, "config", "database.yml"), "w")
50
+
51
+ username = Etc.getlogin
52
+ application_name = File.basename(Dir.getwd)
53
+
54
+ template.gsub!("USERNAME", username)
55
+ template.gsub!("APPLICATION_NAME", application_name)
56
+
57
+ output_file.write(template)
58
+
48
59
  puts "database.yml created for #{@database}"
49
60
  end
50
61
 
data/lib/templates/mysql CHANGED
@@ -1,30 +1,20 @@
1
- # MySQL. Versions 4.1 and 5.0 are recommended.
2
- #
3
- # Install the MySQL driver:
4
- # gem install mysql2
5
- #
6
- # And be sure to use new-style password hashing:
7
- # http://dev.mysql.com/doc/refman/5.0/en/old-client.html
8
1
  development:
9
2
  adapter: mysql2
10
3
  encoding: utf8
11
4
  reconnect: false
12
- database: test-mysql2_development
5
+ database: APPLICATION_NAME_development
13
6
  pool: 5
14
- username: root
7
+ username: USERNAME
15
8
  password:
16
9
  socket: /tmp/mysql.sock
17
10
 
18
- # Warning: The database defined as "test" will be erased and
19
- # re-generated from your development database when you run "rake".
20
- # Do not set this db to the same as development or production.
21
11
  test:
22
12
  adapter: mysql2
23
13
  encoding: utf8
24
14
  reconnect: false
25
- database: test-mysql2_test
15
+ database: APPLICATION_NAME_test
26
16
  pool: 5
27
- username: root
17
+ username: USERNAME
28
18
  password:
29
19
  socket: /tmp/mysql.sock
30
20
 
@@ -32,8 +22,8 @@ production:
32
22
  adapter: mysql2
33
23
  encoding: utf8
34
24
  reconnect: false
35
- database: test-mysql2_production
25
+ database: APPLICATION_NAME_production
36
26
  pool: 5
37
- username: root
27
+ username: USERNAME
38
28
  password:
39
29
  socket: /tmp/mysql.sock
@@ -1,51 +1,23 @@
1
- # PostgreSQL. Versions 7.4 and 8.x are supported.
2
- #
3
- # Install the pg driver:
4
- # gem install pg
5
- # On Mac OS X with macports:
6
- # gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
7
- # On Windows:
8
- # gem install pg
9
- # Choose the win32 build.
10
- # Install PostgreSQL and put its /bin directory on your path.
11
1
  development:
12
2
  adapter: postgresql
13
3
  encoding: unicode
14
- database: test-postgres_development
4
+ database: APPLICATION_NAME_development
15
5
  pool: 5
16
- username: test-postgres (or your username if PostgreSQL installed by Homebrew)
6
+ username: USERNAME
17
7
  password:
18
8
 
19
- # Connect on a TCP socket. Omitted by default since the client uses a
20
- # domain socket that doesn't need configuration. Windows does not have
21
- # domain sockets, so uncomment these lines.
22
- #host: localhost
23
- #port: 5432
24
-
25
- # Schema search path. The server defaults to $user,public
26
- #schema_search_path: myapp,sharedapp,public
27
-
28
- # Minimum log levels, in increasing order:
29
- # debug5, debug4, debug3, debug2, debug1,
30
- # log, notice, warning, error, fatal, and panic
31
- # The server defaults to notice.
32
- #min_messages: warning
33
-
34
- # Warning: The database defined as "test" will be erased and
35
- # re-generated from your development database when you run "rake".
36
- # Do not set this db to the same as development or production.
37
9
  test:
38
10
  adapter: postgresql
39
11
  encoding: unicode
40
- database: test-postgres_test
12
+ database: APPLICATION_NAME_test
41
13
  pool: 5
42
- username: test-postgres (or your username if PostgreSQL installed by Homebrew)
14
+ username: USERNAME
43
15
  password:
44
16
 
45
17
  production:
46
18
  adapter: postgresql
47
19
  encoding: unicode
48
- database: test-postgres_production
20
+ database: APPLICATION_NAME_production
49
21
  pool: 5
50
- username: test-postgres
22
+ username: USERNAME
51
23
  password:
@@ -1,14 +1,9 @@
1
- # SQLite version 3.x
2
- # gem install sqlite3
3
1
  development:
4
2
  adapter: sqlite3
5
3
  database: db/development.sqlite3
6
4
  pool: 5
7
5
  timeout: 5000
8
6
 
9
- # Warning: The database defined as "test" will be erased and
10
- # re-generated from your development database when you run "rake".
11
- # Do not set this db to the same as development or production.
12
7
  test:
13
8
  adapter: sqlite3
14
9
  database: db/test.sqlite3
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: database_yml
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
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-06-03 00:00:00.000000000 Z
12
+ date: 2013-06-10 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Generate database yml for rails projects
15
15
  email: adrian@icalialabs.com