pico_api 0.0.1 → 0.0.2

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
  SHA256:
3
- metadata.gz: 42f576489c0e3b0b4cc8ab9d23d3dd273f50f3fcd6cf29689b26a67ee6508c3f
4
- data.tar.gz: 83723e1d3095b13f302d016b8a3f2b166220a7e42842b569ef77cfd86f76648e
3
+ metadata.gz: 14850439f778e937789908411715f6b5ce574ea99a4806fffb00ef649dfd8a80
4
+ data.tar.gz: e7a2151b9decd161b1b427e4980904ba63b2d00f3ca0e90d2d924dc64042574e
5
5
  SHA512:
6
- metadata.gz: 7eb82db803e9e5f78d7c78ecf8a2054dfbd523f200331586e8ac1e9c45c38c837fdae794c4296c593627c97a976382aca69b77a478359d8473e882435dcb936f
7
- data.tar.gz: 43935b1f888497e2dafc4f488d53ecc4b55fdd48efa112ef6ca659b37cc94c4f8bbdef392ef30857ac0c474490a88d4e60cf8c1c2e2fb0186a6e719727fb17cf
6
+ metadata.gz: 730b621fdc6d88fca903262364e0e911c5d941f9ba830d2beb6c1965d19b928531838b11e827b16941ad441a128b9024d1390ebe266973eae1a26de505b7d8ab
7
+ data.tar.gz: 195e3271e7198c9e515b9cb25d9f6d818d18c155e5f164d6fe90b6c0268175be5389c71794f12049da3fd498585935c586cdd15ef1326287610ff72d809c2104
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gemspec
6
+
7
+ group :test do
8
+ gem "rspec", "~> 3"
9
+ gem "pry"
10
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,125 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ pico_api (0.0.1)
5
+ erb (~> 2.2.3)
6
+ jsonapi-serializer (~> 2.2.0)
7
+ rackup (~> 0.2.2)
8
+ rake (~> 13.0.6)
9
+ roda (~> 3.61.0)
10
+ rom (~> 5.2.6)
11
+ rom-sql (~> 3.5.0)
12
+ zeitwerk (~> 2.6.1)
13
+
14
+ GEM
15
+ remote: https://rubygems.org/
16
+ specs:
17
+ activesupport (7.0.4)
18
+ concurrent-ruby (~> 1.0, >= 1.0.2)
19
+ i18n (>= 1.6, < 2)
20
+ minitest (>= 5.1)
21
+ tzinfo (~> 2.0)
22
+ cgi (0.3.3)
23
+ coderay (1.1.3)
24
+ concurrent-ruby (1.1.10)
25
+ diff-lcs (1.5.0)
26
+ dry-container (0.11.0)
27
+ concurrent-ruby (~> 1.0)
28
+ dry-core (0.9.1)
29
+ concurrent-ruby (~> 1.0)
30
+ zeitwerk (~> 2.6)
31
+ dry-equalizer (0.3.0)
32
+ dry-inflector (0.3.0)
33
+ dry-initializer (3.1.1)
34
+ dry-logic (1.3.0)
35
+ concurrent-ruby (~> 1.0)
36
+ dry-core (~> 0.9, >= 0.9)
37
+ zeitwerk (~> 2.6)
38
+ dry-struct (1.5.2)
39
+ dry-core (~> 0.9, >= 0.9)
40
+ dry-types (~> 1.6)
41
+ ice_nine (~> 0.11)
42
+ zeitwerk (~> 2.6)
43
+ dry-types (1.6.1)
44
+ concurrent-ruby (~> 1.0)
45
+ dry-container (~> 0.3)
46
+ dry-core (~> 0.9, >= 0.9)
47
+ dry-inflector (~> 0.1, >= 0.1.2)
48
+ dry-logic (~> 1.3, >= 1.3)
49
+ zeitwerk (~> 2.6)
50
+ erb (2.2.3)
51
+ cgi
52
+ i18n (1.12.0)
53
+ concurrent-ruby (~> 1.0)
54
+ ice_nine (0.11.2)
55
+ jsonapi-serializer (2.2.0)
56
+ activesupport (>= 4.2)
57
+ method_source (1.0.0)
58
+ minitest (5.16.3)
59
+ pry (0.14.1)
60
+ coderay (~> 1.1)
61
+ method_source (~> 1.0)
62
+ rack (3.0.0)
63
+ rackup (0.2.2)
64
+ rack (>= 3.0.0.beta1)
65
+ webrick
66
+ rake (13.0.6)
67
+ roda (3.61.0)
68
+ rack
69
+ rom (5.2.6)
70
+ rom-changeset (~> 5.2, >= 5.2.3)
71
+ rom-core (~> 5.2, >= 5.2.5)
72
+ rom-repository (~> 5.2, >= 5.2.2)
73
+ rom-changeset (5.2.3)
74
+ dry-core (~> 0.4)
75
+ rom-core (~> 5.2)
76
+ transproc (~> 1.0, >= 1.1.0)
77
+ rom-core (5.2.6)
78
+ concurrent-ruby (~> 1.1)
79
+ dry-container (~> 0.7)
80
+ dry-core (~> 0.4)
81
+ dry-equalizer (~> 0.2)
82
+ dry-inflector (~> 0.1)
83
+ dry-initializer (~> 3.0, >= 3.0.1)
84
+ dry-struct (~> 1.0)
85
+ dry-types (~> 1.0)
86
+ transproc (~> 1.0, >= 1.1.0)
87
+ rom-repository (5.2.2)
88
+ dry-core (~> 0.4)
89
+ dry-initializer (~> 3.0, >= 3.0.1)
90
+ rom-core (~> 5.2, >= 5.2.2)
91
+ rom-sql (3.5.0)
92
+ dry-core (~> 0.5, >= 0.5)
93
+ dry-types (~> 1.0)
94
+ rom (~> 5.2, >= 5.2.1)
95
+ sequel (>= 4.49)
96
+ rspec (3.12.0)
97
+ rspec-core (~> 3.12.0)
98
+ rspec-expectations (~> 3.12.0)
99
+ rspec-mocks (~> 3.12.0)
100
+ rspec-core (3.12.0)
101
+ rspec-support (~> 3.12.0)
102
+ rspec-expectations (3.12.0)
103
+ diff-lcs (>= 1.2.0, < 2.0)
104
+ rspec-support (~> 3.12.0)
105
+ rspec-mocks (3.12.0)
106
+ diff-lcs (>= 1.2.0, < 2.0)
107
+ rspec-support (~> 3.12.0)
108
+ rspec-support (3.12.0)
109
+ sequel (5.62.0)
110
+ transproc (1.1.1)
111
+ tzinfo (2.0.5)
112
+ concurrent-ruby (~> 1.0)
113
+ webrick (1.7.0)
114
+ zeitwerk (2.6.4)
115
+
116
+ PLATFORMS
117
+ ruby
118
+
119
+ DEPENDENCIES
120
+ pico_api!
121
+ pry
122
+ rspec (~> 3)
123
+
124
+ BUNDLED WITH
125
+ 2.1.4
data/Readme.md CHANGED
@@ -44,7 +44,7 @@ Migration info: https://rom-rb.org/5.0/learn/sql/migrations/
44
44
  - [x] Handle Errors
45
45
  - [ ] Create a Logger config
46
46
  - [ ] Create a testing environment
47
- - [ ] Allow multiple db gateways in the config
47
+ - [x] Allow multiple db gateways in the config
48
48
  - [ ] Add irb/pry console script
49
49
 
50
50
  ## Contributing
@@ -6,12 +6,7 @@ require 'yaml'
6
6
  module PicoApi
7
7
  class << self
8
8
  def configuration
9
- @configuration ||= Configuration.new(db_config)
10
- end
11
-
12
- def db_config
13
- template = ERB.new(File.new('./config/database.yml').read)
14
- YAML.safe_load(template.result(binding))
9
+ @configuration ||= Configuration.new
15
10
  end
16
11
 
17
12
  def configure
@@ -20,11 +15,20 @@ module PicoApi
20
15
  end
21
16
 
22
17
  class Configuration
23
- attr_reader :db_config
24
- attr_accessor :namespace, :lib_path, :errors_map
18
+ attr_accessor :namespace, :lib_path, :errors_map, :db_yaml_path
19
+
20
+ def db_yaml_path
21
+ @db_yaml_path || "/config/database.yml"
22
+ end
23
+
24
+ def db_config
25
+ YAML.safe_load(read_db_yaml_file.result(binding))
26
+ end
27
+
28
+ private
25
29
 
26
- def initialize(db_config)
27
- @db_config = db_config
30
+ def read_db_yaml_file
31
+ ERB.new(File.new(db_yaml_path).read)
28
32
  end
29
33
  end
30
34
  end
@@ -9,15 +9,21 @@ module PicoApi
9
9
  attr_accessor :container
10
10
 
11
11
  def setup!
12
- database_config = PicoApi.configuration.db_config['default']
13
- adapter = database_config['adapter'].to_sym
14
- options = database_config['options'].symbolize_keys
15
- connection_string = database_config['connection_string']
12
+ database_config = PicoApi.configuration.db_config.symbolize_keys
13
+ gateways = database_config.keys
16
14
 
17
- config = ROM::Configuration.new(adapter, connection_string, options)
18
- yield config if block_given?
15
+ configs = gateways.inject({}) do |memo, gateway|
16
+ adapter = database_config.dig(gateway, :adapter).to_sym
17
+ options = database_config.dig(gateway, :options).symbolize_keys
18
+ connection_string = database_config.dig(gateway, :connection_string)
19
19
 
20
- @container = ROM.container(config)
20
+ memo[gateway] = [adapter, connection_string, options]
21
+ memo
22
+ end
23
+
24
+ @container = ROM.container(**configs) do |config|
25
+ yield config if block_given?
26
+ end
21
27
  end
22
28
  end
23
29
  end
@@ -6,3 +6,9 @@ default:
6
6
  options:
7
7
  encoding:
8
8
 
9
+ # Additional gateways supported
10
+ # legacy:
11
+ # adapter:
12
+ # connection_string:
13
+ # options:
14
+ # encoding:
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module PicoApi
4
- VERSION = '0.0.1'
4
+ VERSION = '0.0.2'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pico_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Avlonitis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-15 00:00:00.000000000 Z
11
+ date: 2022-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: erb
@@ -130,6 +130,9 @@ extensions: []
130
130
  extra_rdoc_files: []
131
131
  files:
132
132
  - ".gitignore"
133
+ - ".rspec"
134
+ - Gemfile
135
+ - Gemfile.lock
133
136
  - LICENSE
134
137
  - Rakefile
135
138
  - Readme.md