db_meta 0.1.0 → 0.1.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: f1ad2711b25cc76657e0440075e7490aa8d8f4f3
4
- data.tar.gz: 90a8e4656fd99b5c222b322331050bcc9ecd66c0
3
+ metadata.gz: 8887a183a25b6272667070306efb1984a7801a51
4
+ data.tar.gz: 65ff06a084c42b17c3298808543a7309ac83ece8
5
5
  SHA512:
6
- metadata.gz: 8d69a75464f2f27fcca790cd80ca679477e689aaf48b65a676c9d20396f82512b19475ced792cb207b0226244618f6930c54bba38ca93cddcdad8456b3461049
7
- data.tar.gz: 6d6d898ccbcdd0d688ea3c70394faad78396f68c826f93cf8c8bed242a398887a3f807c99522abbafc7ab382aaa6461bda6b2786e134408fb7adaa50a32da11a
6
+ metadata.gz: db74f4213879ce983a1f85a1dc7e0eed34f1005493520ba78714399ec17a80265e8f55374514ddd7d54cbad770f6158eb3f428f2e1d96c6c944186e13663f698
7
+ data.tar.gz: c051dc8ee2b358d3d7953f3dc692233873c1abb8271afadd7dacab65eb26975eb121be68e5c5ec9cdde6f8adbeb4bed45c9f4e71acbf673d7efd3db3e9cbb6fd
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- db_meta (0.1.0)
4
+ db_meta (0.1.1)
5
5
  ruby-oci8 (~> 2.2)
6
6
 
7
7
  GEM
@@ -2,6 +2,41 @@ module DbMeta
2
2
 
3
3
  class Abstract
4
4
 
5
+ TYPES = {}
6
+
7
+ def self.register_type(type)
8
+ TYPES[type] = self
9
+ end
10
+
11
+ def self.from_type(type, args)
12
+ raise "type [#{type}] is unknown" unless TYPES.keys.include?(type)
13
+ TYPES[type].new(args)
14
+ end
15
+
16
+ def initialize(**args)
17
+ @username = args[:username]
18
+ @password = args[:password]
19
+ @instance = args[:instance]
20
+
21
+ raise 'username is mandatory, pass a username argument during initialization' if @username.nil?
22
+ raise 'password is mandatory, pass a password argument during initialization' if @password.nil?
23
+ raise 'instance is mandatory, pass a instance argument during initialization' if @instance.nil?
24
+ end
25
+
26
+ def fetch(**args)
27
+ raise 'Needs to be implemented in derived class'
28
+ end
29
+
30
+ def extract(**args)
31
+ raise 'Needs to be implemented in derived class'
32
+ end
33
+
5
34
  end
6
35
 
7
36
  end
37
+
38
+
39
+
40
+
41
+
42
+
@@ -0,0 +1,7 @@
1
+ module DbMeta
2
+
3
+ class Oracle < DbMeta::Abstract
4
+ register_type(:oracle)
5
+ end
6
+
7
+ end
@@ -1,3 +1,3 @@
1
1
  module DbMeta
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/db_meta.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  require_relative 'db_meta/version'
2
2
  require_relative 'db_meta/abstract'
3
3
 
4
+ require_relative 'db_meta/oracle/oracle'
5
+
4
6
  module DbMeta
5
7
 
6
8
  DATABASE_TYPES = [:oracle]
@@ -8,30 +10,17 @@ module DbMeta
8
10
  class DbMeta
9
11
 
10
12
  def initialize(**args)
11
- @args = args
12
-
13
- @username = args[:username]
14
- @password = args[:password]
15
- @instance = args[:instance]
16
-
17
13
  @database_type = args[:database_type] || DATABASE_TYPES[0]
14
+ raise "allowed database types are [#{DATABASE_TYPES.join(', ')}], but provided was [#{@database_type}]" unless DATABASE_TYPES.include?(@database_type)
15
+ @abstract = Abstract.from_type(@database_type, args)
18
16
  end
19
17
 
20
- def fetch
21
- validate
22
- end
23
-
24
- def extract
25
- validate
18
+ def fetch(**args)
19
+ abstract.fetch(args)
26
20
  end
27
21
 
28
- private
29
-
30
- def validate
31
- raise 'username is mandatory, pass a username argument during initialization' if @username.nil?
32
- raise 'password is mandatory, pass a password argument during initialization' if @password.nil?
33
- raise 'instance is mandatory, pass a instance argument during initialization' if @instance.nil?
34
- raise "allowed database types are [#{DATABASE_TYPES.join(', ')}], but provided was [#{@database_type}]" unless DATABASE_TYPES.include?(@database_type)
22
+ def extract(**args)
23
+ abstract.extract(args)
35
24
  end
36
25
 
37
26
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: db_meta
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomi
@@ -87,6 +87,7 @@ files:
87
87
  - examples/simple.rb
88
88
  - lib/db_meta.rb
89
89
  - lib/db_meta/abstract.rb
90
+ - lib/db_meta/oracle/oracle.rb
90
91
  - lib/db_meta/version.rb
91
92
  homepage: https://github.com/thomis/db_meta
92
93
  licenses: []