devup 0.4.0 → 0.5.2

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
  SHA256:
3
- metadata.gz: 99a6b3579f7d44d86a42c61b5d5b55dcd32e8d7aac580c49e5bce9a95500ff02
4
- data.tar.gz: 2a73831a4d8d1549d6150050c12d4806ab8cc41089cbb9ce2b81420d09b02c8a
3
+ metadata.gz: 6cac2c49e58ab10b2851c040543e3d0559ba2827ddb65c0194e902ddaedc7b77
4
+ data.tar.gz: 75645b22886ac2e5ed3935797b53ef16a0221bee4b312f0a9cb5617619b7535e
5
5
  SHA512:
6
- metadata.gz: 709e5c38a2786273085eba92ab0fa70f70dd8fbbfe1200b631ab1bd527b072df097fe6b856bab1e57a5790952dd2476665bcca965e302a69fa8ea2d47cb0d2a4
7
- data.tar.gz: 5c81a935db87d41f22be697fcce631d9f80262f155bbc5eac146c2782e8d1ff49a4a805a86ad0b2c14b3d91e118807c80e0f857ba8584927a1743eab3fd7d87a
6
+ metadata.gz: 80c00c1ba35664e0239b66aef478ee585b96b6000d8931ff27bce090448e002e2daa358d1e28f2ecaf896d55235ec21a6dcf69d28a0507f6dbd24009e58b243b
7
+ data.tar.gz: 1a94f305329fc701429203c17412b41406e4f14de59596d52895f68f4d7b1b4f92dca7f9212cbaa947b74949e6697acb7f146a2dfd6c353d487e90feba85c88c
@@ -1 +1 @@
1
- ruby-2.7.1
1
+ ruby-2.5.8
@@ -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"
@@ -1,30 +1,28 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- devup (0.4.0)
4
+ devup (0.5.2)
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
 
@@ -103,6 +112,26 @@ Now you can run app
103
112
 
104
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.local file.
105
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
134
+
106
135
  ### Debug
107
136
 
108
137
  $ export DEVUP_LOG_LEVEL=debug
@@ -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"
@@ -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,68 @@
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
+ return if devup_disabled?
10
+
11
+ boot
12
+ load_env
13
+ end
14
+
15
+ def boot
16
+ devup.up
17
+
18
+ begin
19
+ require "spring/commands"
20
+
21
+ Spring.watch devup.root.join("docker-compose.yml")
22
+ rescue LoadError, ArgumentError, NameError
23
+ # Spring is not available
24
+ end
25
+ end
26
+
27
+ def devup
28
+ @devup ||= Devup::Environment.new(
29
+ pwd: `pwd`,
30
+ logger: Devup::Logger.build(log_level)
31
+ )
32
+ end
33
+
34
+ def load_env
35
+ begin
36
+ Dotenv.instrumenter = ActiveSupport::Notifications
37
+ ActiveSupport::Notifications.subscribe(/^dotenv/) do |*args|
38
+ event = ActiveSupport::Notifications::Event.new(*args)
39
+ Spring.watch event.payload[:env].filename # if Rails.application
40
+ end
41
+ rescue LoadError, ArgumentError, NameError
42
+ # Spring is not available
43
+ end
44
+
45
+ Dotenv.load(*dotenv_list.to_a)
46
+ end
47
+
48
+ def app_env
49
+ (ENV["RAILS_ENV"] || ENV["RACK_ENV"] || "development").to_sym
50
+ end
51
+
52
+ def dotenv_list
53
+ Devup::DotenvLoadList.new(env: app_env)
54
+ end
55
+
56
+ def dotenv_vars
57
+ Dotenv.parse(*dotenv_list.to_a)
58
+ end
59
+
60
+ def log_level
61
+ ENV.fetch("DEVUP_LOG_LEVEL", dotenv_vars["DEVUP_LOG_LEVEL"] || "info")
62
+ end
63
+
64
+ def devup_disabled?
65
+ ENV.fetch("DEVUP_ENABLED", dotenv_vars["DEVUP_ENABLED"] || "true") != "true"
66
+ end
67
+ end
68
+ end
@@ -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
 
@@ -29,8 +29,8 @@ module Devup
29
29
  config["services"][name]["ports"].map { |el| el.to_s.split(":")[-1].to_i }
30
30
  end
31
31
 
32
- def port_mapping(service, port)
33
- exec("port #{service} #{port}").split(":")[-1].strip.to_i
32
+ def port_mapping(port)
33
+ ComposeHelpers::Ps.new(exec_ps_cached).port_mapping(port)
34
34
  end
35
35
 
36
36
  def up
@@ -64,7 +64,15 @@ module Devup
64
64
  end
65
65
 
66
66
  def alive?
67
- ComposeHelpers::Ps.new(exec("ps")).up?
67
+ ComposeHelpers::Ps.new(exec_ps).up?
68
+ end
69
+
70
+ def exec_ps
71
+ @exec_ps_output = exec("ps")
72
+ end
73
+
74
+ def exec_ps_cached
75
+ @exec_ps_output ||= exec("ps")
68
76
  end
69
77
 
70
78
  def exec(cmd)
@@ -0,0 +1,35 @@
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
+ list << ".env.local" unless test?
12
+ list << ".env.services"
13
+ list << ".env.#{@env}" if env_defined?
14
+ list << ".env"
15
+
16
+ list
17
+ end
18
+
19
+ def include?(val)
20
+ to_a.include? val
21
+ end
22
+
23
+ def index(val)
24
+ to_a.index val
25
+ end
26
+
27
+ def test?
28
+ @env == :test
29
+ end
30
+
31
+ def env_defined?
32
+ !@env.nil?
33
+ end
34
+ end
35
+ end
@@ -19,7 +19,7 @@ module Devup
19
19
  compose.service_ports(name).map do |from|
20
20
  OpenStruct.new(
21
21
  from: from,
22
- to: compose.port_mapping(name, from)
22
+ to: compose.port_mapping(from)
23
23
  )
24
24
  end
25
25
  end
@@ -31,7 +31,7 @@ module Devup
31
31
  def ports_env
32
32
  res = []
33
33
 
34
- res << port_env(to: service.ports.first.to) if service.ports.size == 1
34
+ res << port_env(to: service.ports.first.to)
35
35
 
36
36
  service.ports.each do |port|
37
37
  res << port_env(from: port.from, to: port.to)
@@ -1,3 +1,3 @@
1
1
  module Devup
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.2"
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.0
4
+ version: 0.5.2
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-23 00:00:00.000000000 Z
11
+ date: 2020-10-15 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: []
@@ -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}
@@ -1,15 +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
- devup.up
7
-
8
- begin
9
- require "spring/commands"
10
-
11
- Spring.watch devup.root.join("docker-compose.yml")
12
- rescue LoadError, ArgumentError
13
- # Spring is not available
14
- end
15
- end
@@ -1,2 +0,0 @@
1
- require "dotenv"
2
- Dotenv.load ".env.services"