devup 0.4.2 → 0.5.3

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: e5744f3c2fd5d14feaa071eb77144c66180cc1788fc072823150e3817bcb13c6
4
- data.tar.gz: 4f0c24dc63a0e375bcc740828989e2d3f524444253440945481367c7c781fd2d
3
+ metadata.gz: f63ff0ee5ffd8b69739caec5f9feee5c9f881e34f866de04a3f1e379ae1cb792
4
+ data.tar.gz: 51d840a02ce6e6469dc056d1992c87c450020bad0eeeb3cfe7e465f61508cd20
5
5
  SHA512:
6
- metadata.gz: 78b162b5135a393e6647a302cba4748b3f9110e100a5be2ffecc904cc08ffacdd767f0bb6070368d724faa6d0651b5226f629711e62a54a377d14a9e1c4d3981
7
- data.tar.gz: cb57eea0871d5740bbdd91d19600ba42fc34399fae4c3ccb4da8fd98b898fe64c0cf7fb2b45f33bb200c8c7a04f246ebc963d6b3892098d89efed9cbd8ae6ac1
6
+ metadata.gz: 887ddd31283c4a6220c2a28ce119f0f22a6b22cfbd812c73baf9957af1d21fe3dc46c3799abbcdf647572c6ee41fce197093489e96d51c9f97891f5aa52dbfa2
7
+ data.tar.gz: db5711a5e2a3c5a47532693908f67514b3c69214ab0e30c29fa52b3836fec9980c4e372df15c89de7d26fb142e39b9ab4d633da7daf29b53a6962ad563ad431f
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.7.1
1
+ ruby-2.5.8
data/.travis.yml CHANGED
@@ -12,15 +12,6 @@ services:
12
12
  before_install:
13
13
  - gem install bundler -v $BUNDLER_VERSION
14
14
  bundler_args: "--jobs=3 --retry=3"
15
- deploy:
16
- provider: rubygems
17
- api_key:
18
- secure: sMr+AT3gK44uTM6PHPrPAN8zxFf4njsqp65tC7l69dnzzYCuz9xBpUlYW18XFTTkJaFsr9s4A5ptdQ4gi7D12LdjFbRUkLkrCcAedALQ4PoQVkAQoNPaEPI40F7GUxElyBqbbHlUzgsxf6YPmVPykl+sbaD+WLZM26P9rxFpjwwlVsG4aaQ1TKHXQ4PZUch0LZDjuA3Z6cs9Tb22Ep0kur+Lb8EYyvgB+p50gidsBuFy2fb7/PYApqq2NhZn7bgS0vd5tTfuPzhq8B0PJzBrio52Ymn8Ry7n3WVJRXtoG2ZuynL+nxkLtUHuC4HGt336d/kx+8hLGHDRbBQurF2B+UQowD6+EZVb1d5zqYGJAvMXVBZ73+aa99tCU4hUVK8TWmwfaRgrZyLbOpOfkMEO905nsqRVFduI0HRI3MhD8ZzzwPiXmmtx4/dxzx+UX1tQiBRMmBKUaeXB8iCry7C5IcKPuTFMs1qVYmFfDrcnpL8H4FWtZ2diCgop8ocqtRRqLF7ZgdGticNlYkI6jISn7ToDCH/V+brVI9B/QQWq9xUVCUw10kGBllWFd9TJ7eZ7coQ+tOFfTibFd92xyRyR0QLUXE0ECyXMLI2kW31VN3yWMYYm4k+rXXXOsdQ3CJI7ozSVGDAO/7V6BLlaOeNqe9dgW/nD2NMr8RuSJr2akUA=
19
- gem: devup
20
- on:
21
- tags: true
22
- repo: sergio-fry/devup
23
- skip_cleanup: 'true'
24
15
 
25
16
  jobs:
26
17
  include:
data/Gemfile CHANGED
@@ -8,4 +8,3 @@ gem "rspec", "~> 3.0"
8
8
  gem "standard"
9
9
  gem "simplecov", require: false
10
10
  gem "byebug"
11
- gem "lefthook"
data/Gemfile.lock CHANGED
@@ -1,30 +1,28 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- devup (0.4.2)
4
+ devup (0.5.3)
5
5
  dotenv
6
6
  dry-cli
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- ast (2.4.0)
11
+ ast (2.4.1)
12
12
  byebug (11.1.3)
13
- concurrent-ruby (1.1.6)
14
- diff-lcs (1.3)
13
+ concurrent-ruby (1.1.7)
14
+ diff-lcs (1.4.4)
15
15
  docile (1.3.2)
16
- dotenv (2.7.5)
16
+ dotenv (2.7.6)
17
17
  dry-cli (0.6.0)
18
18
  concurrent-ruby (~> 1.0)
19
- jaro_winkler (1.5.4)
20
- json (2.3.0)
21
- lefthook (0.7.2)
22
- parallel (1.19.1)
23
- parser (2.7.1.0)
24
- ast (~> 2.4.0)
19
+ parallel (1.19.2)
20
+ parser (2.7.1.4)
21
+ ast (~> 2.4.1)
25
22
  rainbow (3.0.0)
26
23
  rake (12.3.3)
27
- rexml (3.1.9)
24
+ regexp_parser (1.7.1)
25
+ rexml (3.2.4)
28
26
  rspec (3.9.0)
29
27
  rspec-core (~> 3.9.0)
30
28
  rspec-expectations (~> 3.9.0)
@@ -38,26 +36,28 @@ GEM
38
36
  diff-lcs (>= 1.2.0, < 2.0)
39
37
  rspec-support (~> 3.9.0)
40
38
  rspec-support (3.9.3)
41
- rubocop (0.80.1)
42
- jaro_winkler (~> 1.5.1)
39
+ rubocop (0.85.1)
43
40
  parallel (~> 1.10)
44
41
  parser (>= 2.7.0.1)
45
42
  rainbow (>= 2.2.2, < 4.0)
43
+ regexp_parser (>= 1.7)
46
44
  rexml
45
+ rubocop-ast (>= 0.0.3)
47
46
  ruby-progressbar (~> 1.7)
48
- unicode-display_width (>= 1.4.0, < 1.7)
49
- rubocop-performance (1.5.2)
47
+ unicode-display_width (>= 1.4.0, < 2.0)
48
+ rubocop-ast (0.1.0)
49
+ parser (>= 2.7.0.1)
50
+ rubocop-performance (1.6.1)
50
51
  rubocop (>= 0.71.0)
51
52
  ruby-progressbar (1.10.1)
52
- simplecov (0.16.1)
53
+ simplecov (0.18.5)
53
54
  docile (~> 1.1)
54
- json (>= 1.8, < 3)
55
- simplecov-html (~> 0.10.0)
56
- simplecov-html (0.10.2)
57
- standard (0.2.4)
58
- rubocop (~> 0.80.1)
59
- rubocop-performance (~> 1.5.2)
60
- unicode-display_width (1.6.1)
55
+ simplecov-html (~> 0.11)
56
+ simplecov-html (0.12.2)
57
+ standard (0.4.7)
58
+ rubocop (~> 0.85.0)
59
+ rubocop-performance (~> 1.6.0)
60
+ unicode-display_width (1.7.0)
61
61
 
62
62
  PLATFORMS
63
63
  ruby
@@ -65,11 +65,10 @@ PLATFORMS
65
65
  DEPENDENCIES
66
66
  byebug
67
67
  devup!
68
- lefthook
69
68
  rake (~> 12.0)
70
69
  rspec (~> 3.0)
71
70
  simplecov
72
71
  standard
73
72
 
74
73
  BUNDLED WITH
75
- 2.1.4
74
+ 1.17.3
data/README.md CHANGED
@@ -38,12 +38,21 @@ and
38
38
  Update your database.yml to use ENV:
39
39
 
40
40
  ```yaml
41
- test:
42
- url: <%= ENV.fetch("DATABASE_URL") %>
41
+ default: &default
42
+ adapter: postgresql
43
+ encoding: unicode
44
+ host: <%= ENV.fetch("POSTGRES_HOST") %>
45
+ port: <%= ENV.fetch("POSTGRES_PORT") %>
46
+ username: postgres
47
+ password:
43
48
 
44
49
  development:
45
- url: <%= ENV.fetch("DATABASE_URL") %>
50
+ <<: *default
51
+ database: development
46
52
 
53
+ test:
54
+ <<: *default
55
+ database: test
47
56
  ```
48
57
 
49
58
 
@@ -53,7 +62,7 @@ You are ready to use rails with PostgreSQL configured
53
62
  DevUp! INFO starting up...
54
63
  DevUp! INFO up
55
64
 
56
- $ Created database 'dummy_rails_test'
65
+ $ Created database 'test'
57
66
 
58
67
 
59
68
  ## Without Rails
@@ -65,7 +74,7 @@ ENV vars from .env.services are loaded with dotenv automatically.
65
74
  require "devup"
66
75
  require "sequel"
67
76
 
68
- DB = Sequel.connect(ENV.fetch("DATABASE_URL"))
77
+ DB = Sequel.connect(adapter: "postgres", host: ENV.fetch("POSTGRES_HOST"), port: ENV.fetch("POSTGRES_PORT"), database: "blog", user: 'postgres')
69
78
  ```
70
79
 
71
80
 
@@ -101,7 +110,27 @@ Now you can run app
101
110
 
102
111
  ### Disable **DevUp!**
103
112
 
104
- If you don't want devup to setup your dev services, you can disable it by using `DEVUP_ENABLED=false`. Just add it to .env.local file.
113
+ If you don't want devup to setup your dev services, you can disable it by using `DEVUP_ENABLED=false`. Just add it to .env.test.local file.
114
+
115
+ ### Override some service
116
+
117
+ If you want to switch some service from DevUp! to another, you can override ENV in a local dotenv configs:
118
+
119
+ * .env.local
120
+ * .env.development.local
121
+ * .env.test.local
122
+
123
+ Just put to your .env.local:
124
+
125
+ export POSTGRES_HOST=0.0.0.0
126
+ export POSTGRES_PORT=5432
127
+
128
+ ### Get some DATABASE_URL working
129
+
130
+
131
+ Just put to your .env.test or .env.development something like:
132
+
133
+ DATABASE_URL=postgres://postgres@$POSTGRES_HOST:$POSTGRES_PORT/test_db
105
134
 
106
135
  ### Debug
107
136
 
data/devup.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.authors = ["Sergei O. Udalov"]
11
11
  spec.email = ["sergei@udalovs.ru"]
12
12
 
13
- spec.summary = "A tool to manage docker-compose for developmnet"
13
+ spec.summary = "A tool to manage docker-compose for development"
14
14
  # spec.description = %q{TODO: Write a longer description or delete this line.}
15
15
  spec.homepage = "https://github.com/sergio-fry/devup"
16
16
  spec.license = "MIT"
data/lib/devup.rb CHANGED
@@ -1,9 +1,10 @@
1
1
  require "devup/version"
2
2
  require "devup/environment"
3
+ require "devup/application"
3
4
 
4
5
  module Devup
5
6
  class Error < StandardError; end
6
7
  end
7
8
 
8
- require "devup/boot"
9
- require "devup/dotenv"
9
+ app = Devup::Application.new
10
+ app.run
@@ -0,0 +1,64 @@
1
+ require "devup/dotenv_load_list"
2
+ require "devup/environment"
3
+ require "devup/logger"
4
+ require "dotenv"
5
+
6
+ module Devup
7
+ class Application
8
+ def run
9
+ boot unless devup_disabled?
10
+ load_env
11
+ end
12
+
13
+ def boot
14
+ devup.up
15
+
16
+ begin
17
+ require "spring/commands"
18
+
19
+ Spring.watch devup.root.join("docker-compose.yml")
20
+ rescue LoadError, ArgumentError, NameError
21
+ # Spring is not available
22
+ end
23
+ end
24
+
25
+ def devup
26
+ @devup ||= Devup::Environment.new(
27
+ pwd: `pwd`,
28
+ logger: Devup::Logger.build(log_level)
29
+ )
30
+ end
31
+
32
+ def load_env
33
+ if defined? ActiveSupport::Notifications
34
+ Dotenv.instrumenter = ActiveSupport::Notifications
35
+ ActiveSupport::Notifications.subscribe(/^dotenv/) do |*args|
36
+ event = ActiveSupport::Notifications::Event.new(*args)
37
+ Spring.watch event.payload[:env].filename if defined? Spring
38
+ end
39
+ end
40
+
41
+ Dotenv.load(*dotenv_list.to_a)
42
+ end
43
+
44
+ def app_env
45
+ (ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development").to_sym
46
+ end
47
+
48
+ def dotenv_list
49
+ Devup::DotenvLoadList.new(env: app_env)
50
+ end
51
+
52
+ def dotenv_vars
53
+ Dotenv.parse(*dotenv_list.to_a)
54
+ end
55
+
56
+ def log_level
57
+ ENV.fetch("DEVUP_LOG_LEVEL", dotenv_vars["DEVUP_LOG_LEVEL"] || "info")
58
+ end
59
+
60
+ def devup_disabled?
61
+ ENV.fetch("DEVUP_ENABLED", dotenv_vars["DEVUP_ENABLED"] || "true") != "true"
62
+ end
63
+ end
64
+ end
data/lib/devup/cli.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "dry/cli"
2
2
 
3
+ require "devup/version"
3
4
  require "devup/cli/commands/up"
4
5
  require "devup/cli/commands/down"
5
6
 
@@ -0,0 +1,39 @@
1
+ module Devup
2
+ class DotenvLoadList
3
+ def initialize(env: nil)
4
+ @env = env.to_sym unless env.nil?
5
+ end
6
+
7
+ def to_a
8
+ list = []
9
+
10
+ list << ".env.#{@env}.local" if env_defined?
11
+
12
+ # .env.local is ignored by dotenv-rails too. So behaviour is the same.
13
+ # https://github.com/bkeepers/dotenv/blob/08f22148fb14019dce1e9b1d8ac1a74788e49e1b/lib/dotenv/rails.rb#L69
14
+ list << ".env.local" unless test?
15
+
16
+ list << ".env.services"
17
+ list << ".env.#{@env}" if env_defined?
18
+ list << ".env"
19
+
20
+ list
21
+ end
22
+
23
+ def include?(val)
24
+ to_a.include? val
25
+ end
26
+
27
+ def index(val)
28
+ to_a.index val
29
+ end
30
+
31
+ def test?
32
+ @env == :test
33
+ end
34
+
35
+ def env_defined?
36
+ !@env.nil?
37
+ end
38
+ end
39
+ end
data/lib/devup/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Devup
2
- VERSION = "0.4.2"
2
+ VERSION = "0.5.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergei O. Udalov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-06-24 00:00:00.000000000 Z
11
+ date: 2021-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv
@@ -63,16 +63,15 @@ files:
63
63
  - devup.gemspec
64
64
  - docker-compose.devup.yml
65
65
  - exe/devup
66
- - lefthook.yml
67
66
  - lib/devup.rb
68
- - lib/devup/boot.rb
67
+ - lib/devup/application.rb
69
68
  - lib/devup/cli.rb
70
69
  - lib/devup/cli/commands/command.rb
71
70
  - lib/devup/cli/commands/down.rb
72
71
  - lib/devup/cli/commands/up.rb
73
72
  - lib/devup/compose.rb
74
73
  - lib/devup/compose/ps.rb
75
- - lib/devup/dotenv.rb
74
+ - lib/devup/dotenv_load_list.rb
76
75
  - lib/devup/environment.rb
77
76
  - lib/devup/logger.rb
78
77
  - lib/devup/port_checker.rb
@@ -101,8 +100,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
100
  - !ruby/object:Gem::Version
102
101
  version: '0'
103
102
  requirements: []
104
- rubygems_version: 3.1.2
103
+ rubygems_version: 3.0.8
105
104
  signing_key:
106
105
  specification_version: 4
107
- summary: A tool to manage docker-compose for developmnet
106
+ summary: A tool to manage docker-compose for development
108
107
  test_files: []
data/lefthook.yml DELETED
@@ -1,7 +0,0 @@
1
- pre-commit:
2
- parallel: true
3
- commands:
4
- lint:
5
- files: git diff --name-only --staged
6
- glob: "*.rb"
7
- run: standardrb --force-exclusion {files}
data/lib/devup/boot.rb DELETED
@@ -1,20 +0,0 @@
1
- if ENV.fetch("DEVUP_ENABLED", "true") == "true"
2
- devup = Devup::Environment.new(
3
- pwd: `pwd`,
4
- logger: Devup::Logger.build(ENV.fetch("DEVUP_LOG_LEVEL", "info"))
5
- )
6
-
7
- begin
8
- require "spring/commands"
9
-
10
- Spring.after_fork do
11
- devup.up
12
- end
13
-
14
- Spring.watch devup.root.join("docker-compose.devup.yml")
15
- rescue LoadError, ArgumentError
16
- # Spring is not available
17
-
18
- devup.up
19
- end
20
- end
data/lib/devup/dotenv.rb DELETED
@@ -1,2 +0,0 @@
1
- require "dotenv"
2
- Dotenv.load ".env.services"