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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 70e55e28e97f452652e044fbe3b22b9036b5d370
4
- data.tar.gz: f5928c6292f3b27e2357b9e122402de48919fd0b
3
+ metadata.gz: b323a8b45af457e2866229139b7c3e371f966845
4
+ data.tar.gz: f14b7bc66a797590accd3720e1b426f0d05f2108
5
5
  SHA512:
6
- metadata.gz: de45839dc3f0e8a65a9974eb911c4fe738d8815d9e69ba274df2350d766a8aeb7d5bf5b1e08cac6acff8e8bd01bb37a6375e1c48f82dc3c6dc8420544a212196
7
- data.tar.gz: 52329bbb20d82f1e17301ab88c3f7124566cc60edb707af3a23699b7f74be44371142123779d6d663565f153df39b3aadcb6bc3dc4ed625296dc5d18d49c8368
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 = DB_CONFIG['default']['adapter']
39
+ adapter = URI.parse(ENV['DATABASE_URL']).scheme
40
+
45
41
  case adapter
46
- when 'postgresql'
42
+ when 'postgres'
47
43
  adapter_path = File.join('monorm', 'adapters', 'pg_connection')
48
44
  require adapter_path
49
- when 'sqlite3'
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
- # uri = URI.parse(ENV['DATABASE_URL'])
6
+ uri = URI.parse(ENV['DATABASE_URL'])
7
7
  @conn = PG::Connection.new(
8
- dbname: MonoRM::DB_CONFIG['default']['database']
9
- # user: uri.user,
10
- # password: uri.password,
11
- # host: uri.host,
12
- # port: uri.port,
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 = "#{MonoRM::DB_CONFIG['default']['database']}.db"
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
@@ -1,3 +1,3 @@
1
1
  module MonoRM
2
- VERSION = "0.1.1"
2
+ VERSION = "1.0.0"
3
3
  end
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.1.1
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-28 00:00:00.000000000 Z
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
  - - ">="