monorm 0.1.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/monorm.rb +6 -10
- data/lib/monorm/adapters/pg_connection.rb +6 -6
- data/lib/monorm/adapters/sqlite_connection.rb +2 -2
- data/lib/monorm/version.rb +1 -1
- data/monorm.gemspec +2 -1
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b323a8b45af457e2866229139b7c3e371f966845
|
4
|
+
data.tar.gz: f14b7bc66a797590accd3720e1b426f0d05f2108
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ce6f690d4412c354ea0608adbbc755c7fb5a91ab8cff3becc5fd09bb2b4d416f114c74dd5272280914c98ecf2f10609ed821a4123d8e1641c0c572f3c42128c
|
7
|
+
data.tar.gz: cb57f8ae43ad841b6e65984744551bbcae45c738ba0ff27d51651b858a44862a0f47792a2ddfb4329738ed572a156d9bf87da5e2c3f375aa8d358de77da40a04
|
data/lib/monorm.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'yaml'
|
2
2
|
require 'erb'
|
3
|
+
require 'uri'
|
3
4
|
|
4
5
|
require "monorm/version"
|
5
6
|
|
@@ -23,11 +24,7 @@ module MonoRM
|
|
23
24
|
def self.db_config
|
24
25
|
File.join config, 'database.yml'
|
25
26
|
end
|
26
|
-
|
27
|
-
# def self.bin
|
28
|
-
# File.join root, 'bin'
|
29
|
-
# end
|
30
|
-
#
|
27
|
+
|
31
28
|
def self.lib
|
32
29
|
File.join root, 'lib'
|
33
30
|
end
|
@@ -35,18 +32,17 @@ module MonoRM
|
|
35
32
|
def self.monorm
|
36
33
|
File.join lib, 'monorm'
|
37
34
|
end
|
38
|
-
DB_CONFIG = YAML.load ERB.new(IO.read("#{self.db_config}")).result
|
39
|
-
# DB_CONFIG = YAML.load(File.open("#{self.db_config}"))
|
40
35
|
|
41
36
|
class MonoRM::DBInitializer
|
42
37
|
def self.load_db_adapter
|
43
38
|
|
44
|
-
adapter =
|
39
|
+
adapter = URI.parse(ENV['DATABASE_URL']).scheme
|
40
|
+
|
45
41
|
case adapter
|
46
|
-
when '
|
42
|
+
when 'postgres'
|
47
43
|
adapter_path = File.join('monorm', 'adapters', 'pg_connection')
|
48
44
|
require adapter_path
|
49
|
-
when '
|
45
|
+
when 'sqlite'
|
50
46
|
adapter_path = File.join('monorm', 'adapters', 'sqlite_connection')
|
51
47
|
require adapter_path
|
52
48
|
else
|
@@ -3,13 +3,13 @@ require 'pg'
|
|
3
3
|
class MonoRM::DBConnection
|
4
4
|
|
5
5
|
def self.open
|
6
|
-
|
6
|
+
uri = URI.parse(ENV['DATABASE_URL'])
|
7
7
|
@conn = PG::Connection.new(
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
user: uri.user,
|
9
|
+
password: uri.password,
|
10
|
+
host: uri.host,
|
11
|
+
port: uri.port,
|
12
|
+
dbname: uri.path[1..-1]
|
13
13
|
)
|
14
14
|
|
15
15
|
@conn
|
@@ -47,8 +47,8 @@ class MonoRM::DBConnection
|
|
47
47
|
|
48
48
|
def self.load_db_path
|
49
49
|
dir = File.dirname(__FILE__)
|
50
|
-
db_name =
|
51
|
-
@db_path = File.join(MonoRM::PROJECT_ROOT_DIR, "db", "sqlite_db", "#{db_name}")
|
50
|
+
db_name = URI.parse(ENV['DATABASE_URL']).path[1..-1]
|
51
|
+
@db_path = File.join(MonoRM::PROJECT_ROOT_DIR, "db", "sqlite_db", "#{db_name}.db")
|
52
52
|
end
|
53
53
|
|
54
54
|
private
|
data/lib/monorm/version.rb
CHANGED
data/monorm.gemspec
CHANGED
@@ -36,9 +36,10 @@ Gem::Specification.new do |spec|
|
|
36
36
|
spec.add_development_dependency "rspec", "~> 3.0"
|
37
37
|
spec.add_development_dependency 'byebug', '~> 9.0'
|
38
38
|
spec.add_development_dependency 'pry', '~> 0.10.4'
|
39
|
+
spec.add_development_dependency 'dotenv', '~> 2.2'
|
39
40
|
|
40
41
|
spec.add_runtime_dependency 'activesupport', '~> 5.0'
|
41
42
|
|
42
|
-
|
43
|
+
spec.required_ruby_version = '~> 2.0'
|
43
44
|
|
44
45
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: monorm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Chilton
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 0.10.4
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: dotenv
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '2.2'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '2.2'
|
83
97
|
- !ruby/object:Gem::Dependency
|
84
98
|
name: activesupport
|
85
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -132,9 +146,9 @@ require_paths:
|
|
132
146
|
- lib
|
133
147
|
required_ruby_version: !ruby/object:Gem::Requirement
|
134
148
|
requirements:
|
135
|
-
- - "
|
149
|
+
- - "~>"
|
136
150
|
- !ruby/object:Gem::Version
|
137
|
-
version: '0'
|
151
|
+
version: '2.0'
|
138
152
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
153
|
requirements:
|
140
154
|
- - ">="
|