This repository was archived by the owner on Oct 22, 2020. It is now read-only.
File tree 4 files changed +56
-36
lines changed
4 files changed +56
-36
lines changed Original file line number Diff line number Diff line change 1
1
development :
2
2
adapter : sqlite
3
- database : db/development.db
3
+ database :
4
4
max_connections : 5
5
5
pool_timeout : 5000
6
6
7
7
production :
8
8
adapter : sqlite
9
- database : db/production.db
9
+ database :
10
10
max_connections : 5
11
11
pool_timeout : 5000
12
12
13
13
test : &test
14
14
adapter : sqlite
15
- database : db/test.db
15
+ database :
16
16
max_connections : 5
17
17
pool_timeout : 5000
Original file line number Diff line number Diff line change 1
1
# frozen_string_literal: true
2
2
3
- require 'sequel'
4
- require 'yaml'
5
-
6
3
ENV [ 'WPXF_ENV' ] = 'development' unless ENV [ 'WPXF_ENV' ]
7
4
8
5
db_config_path = File . join ( __dir__ , 'config.yml' )
9
6
db_config = YAML . load_file ( db_config_path ) [ ENV [ 'WPXF_ENV' ] ]
10
7
8
+ if db_config [ 'database' ] . nil?
9
+ db_config [ 'database' ] = File . join ( Wpxf . databases_path , "#{ ENV [ 'WPXF_ENV' ] } .db" )
10
+ end
11
+
11
12
Sequel ::Model . plugin :timestamps
12
13
Sequel ::Model . db = Sequel . connect ( db_config )
14
+
15
+ Sequel . extension :migration
16
+ Sequel ::Migrator . run ( Sequel ::Model . db , File . join ( __dir__ , 'migrations' ) )
Original file line number Diff line number Diff line change
1
+ # frozen_string_literal: true
2
+
3
+ require 'date'
4
+ require 'fileutils'
5
+ require 'json'
6
+ require 'time'
7
+ require 'yaml'
8
+ require 'zip'
9
+
10
+ Gem . loaded_specs [ 'wpxf' ] . dependencies . each do |d |
11
+ require d . name unless d . type == :development || d . name == 'rubyzip'
12
+ end
13
+
14
+ # The root namespace.
15
+ module Wpxf
16
+ def self . data_directory
17
+ File . join ( app_path , 'data' )
18
+ end
19
+
20
+ def self . app_path
21
+ File . expand_path ( File . dirname ( __dir__ ) )
22
+ end
23
+
24
+ def self . version
25
+ Gem . loaded_specs [ 'wpxf' ] . version
26
+ end
27
+
28
+ def self . home_directory
29
+ File . join ( Dir . home , '.wpxf' )
30
+ end
31
+
32
+ def self . databases_path
33
+ path = File . join ( home_directory , 'db' )
34
+ FileUtils . mkdir_p ( path ) unless File . directory? ( path )
35
+ path
36
+ end
37
+
38
+ def self . change_stdout_sync ( enabled )
39
+ original_setting = STDOUT . sync
40
+ STDOUT . sync = true
41
+ yield ( enabled )
42
+ STDOUT . sync = original_setting
43
+ end
44
+ end
45
+
46
+ require_relative '../db/env'
Original file line number Diff line number Diff line change 1
1
# frozen_string_literal: true
2
2
3
- # The root namespace.
4
- module Wpxf
5
- def self . data_directory = ( val )
6
- @@data_directory = val
7
- end
8
-
9
- def self . data_directory
10
- @@data_directory
11
- end
12
-
13
- def self . app_path = ( val )
14
- @@app_path = val
15
- end
16
-
17
- def self . app_path
18
- @@app_path
19
- end
20
-
21
- def self . version
22
- File . read ( File . join ( Wpxf . app_path , 'VERSION' ) ) . strip
23
- end
24
-
25
- def self . change_stdout_sync ( enabled )
26
- original_setting = STDOUT . sync
27
- STDOUT . sync = true
28
- yield ( enabled )
29
- STDOUT . sync = original_setting
30
- end
31
- end
32
-
33
3
require 'wpxf/db'
34
4
require 'wpxf/utility'
35
5
You can’t perform that action at this time.
0 commit comments