database_yml 0.0.3 → 0.0.4
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 +7 -0
- data/lib/database_yml.rb +5 -18
- metadata +7 -9
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c55e70521dbc8ec7e4dacefccff34b221e8b4820
|
4
|
+
data.tar.gz: 4202a7dc572b1ff5765852a8102a484924f25b86
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b5b9f466b200e17c433310e66fdc4800cf2935c746522069bc42b4a1f17ffb35c3e62acc4174b61fcd127278f38f5386f3a1593f30f36f42c507b2f912f370ac
|
7
|
+
data.tar.gz: 372cd04de04353bc335a06cb392c0069ae942384f5cbd55057dfb8dc4540381fbf95d6830a72bf8843a198cc129b9c9691d926892d16eb04ddf69b7e184d8514
|
data/lib/database_yml.rb
CHANGED
@@ -1,6 +1,3 @@
|
|
1
|
-
# Obtained from rails source code
|
2
|
-
# https://github.com/rails/rails/blob/3-2-stable/railties/lib/rails/script_rails_loader.rb
|
3
|
-
|
4
1
|
require 'pathname'
|
5
2
|
require 'fileutils'
|
6
3
|
require 'etc'
|
@@ -9,7 +6,6 @@ class DatabaseYML
|
|
9
6
|
SCRIPT_RAILS = File.join('script', 'rails')
|
10
7
|
DRIVERS = %W(mysql postgresql sqlite3)
|
11
8
|
TEMPLATES_DIR = File.join(File.expand_path(File.dirname(__FILE__)), "templates")
|
12
|
-
|
13
9
|
|
14
10
|
def initialize(database)
|
15
11
|
@database = database || 'sqlite3'
|
@@ -19,29 +15,20 @@ class DatabaseYML
|
|
19
15
|
|
20
16
|
return unless DRIVERS.include? @database
|
21
17
|
|
22
|
-
cwd = Dir.pwd
|
23
|
-
return unless self.class.in_rails_application? || self.class.in_rails_application_subdirectory?
|
24
|
-
|
25
18
|
if self.class.in_rails_application?
|
26
19
|
generate_database_yml!
|
27
20
|
return
|
21
|
+
else
|
22
|
+
puts "Must be executed in a rails directory"
|
28
23
|
end
|
29
24
|
|
30
|
-
Dir.chdir("..") do
|
31
|
-
# Recurse in a chdir block: if the search fails we want to be sure
|
32
|
-
# the application is generated in the original working directory.
|
33
|
-
create! unless cwd == Dir.pwd
|
34
|
-
end
|
35
|
-
rescue SystemCallError
|
36
|
-
# could not chdir, no problem just return
|
37
25
|
end
|
38
26
|
|
39
27
|
def self.in_rails_application?
|
40
|
-
File.
|
41
|
-
|
28
|
+
file_exist = File.exist?('Gemfile')
|
29
|
+
return false unless file_exist
|
42
30
|
|
43
|
-
|
44
|
-
File.exists?(File.join(path, SCRIPT_RAILS)) || !path.root? && in_rails_application_subdirectory?(path.parent)
|
31
|
+
open('Gemfile') { |f| !f.grep(/rails/).empty? }
|
45
32
|
end
|
46
33
|
|
47
34
|
def generate_database_yml!
|
metadata
CHANGED
@@ -1,15 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: database_yml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.4
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Adrián González
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-12-26 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
13
|
description: Generate database yml for rails projects
|
15
14
|
email: adrian@icalialabs.com
|
@@ -25,26 +24,25 @@ files:
|
|
25
24
|
- bin/database_yml
|
26
25
|
homepage: https://github.com/Adrian2112/database_yml
|
27
26
|
licenses: []
|
27
|
+
metadata: {}
|
28
28
|
post_install_message:
|
29
29
|
rdoc_options: []
|
30
30
|
require_paths:
|
31
31
|
- lib
|
32
32
|
required_ruby_version: !ruby/object:Gem::Requirement
|
33
|
-
none: false
|
34
33
|
requirements:
|
35
|
-
- -
|
34
|
+
- - '>='
|
36
35
|
- !ruby/object:Gem::Version
|
37
36
|
version: '0'
|
38
37
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
39
|
-
none: false
|
40
38
|
requirements:
|
41
|
-
- -
|
39
|
+
- - '>='
|
42
40
|
- !ruby/object:Gem::Version
|
43
41
|
version: '0'
|
44
42
|
requirements: []
|
45
43
|
rubyforge_project:
|
46
|
-
rubygems_version: 1.
|
44
|
+
rubygems_version: 2.1.11
|
47
45
|
signing_key:
|
48
|
-
specification_version:
|
46
|
+
specification_version: 4
|
49
47
|
summary: Generate database yml for rails projects
|
50
48
|
test_files: []
|