devup 0.1.1 → 0.2.0

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: af85549b1c01b89de550c6c7857c23d1b80cc06997e3fd6ceee8709e8587f85c
4
- data.tar.gz: 8523baac5e3d05d235feb677a66857622a97cf3432f62f9726144d86b8fa01f6
3
+ metadata.gz: 16b7a8648ef05f7206cc02900450f8f303fc948a0976ac959472451eeef1988f
4
+ data.tar.gz: a58834288dcd48d1cde4e353f1a77fb40b15419751896bdd7680b71be64a7266
5
5
  SHA512:
6
- metadata.gz: f3c80f5bbbed5b595e58eeb2b7089c2e5743f62fa629b850c98f559be401a5c77767b3485a3140b69ffb9158473f6dc2993919cdc2e416711433772811a4553d
7
- data.tar.gz: 15e5cc91441dc2eb5b251d25fd72d4dad66c2fa6ce43744c66ec30a518c7e5791504c70c91f059fd9211cc98dd198e0c69f88d94452b5037e77f6af8b3c0945d
6
+ metadata.gz: 340f23ba29e0cd7e9c187f3ddb20d5e7c825503c5095fd4e3acd244ae2f714f89c2cfe636533207391292685244f4459b70af87a09ad82e7e8b3d9e70639aead
7
+ data.tar.gz: d596434a6a8450bf01b433a2f2e4c3abbed3f465046463954595badb82468fabd0f3fc6479d0fe9935dc1bbd48b246e11aabd723251b81b2d288ff7d103b822c
@@ -1,11 +1,12 @@
1
+ env:
2
+ matrix:
3
+ - BUNDLER_VERSION=2.1.4
1
4
  language: ruby
2
5
  cache: bundler
3
6
  rvm:
4
7
  - 2.7.1
5
8
  services:
6
9
  - docker
7
- env:
8
- - BUNDLER_VERSION=2.1.4
9
10
  before_install:
10
11
  - gem install bundler -v $BUNDLER_VERSION
11
12
  bundler_args: "--jobs=3 --retry=3"
@@ -18,3 +19,21 @@ deploy:
18
19
  tags: true
19
20
  repo: sergio-fry/devup
20
21
  skip_cleanup: 'true'
22
+
23
+ jobs:
24
+ include:
25
+ - stage: test
26
+ name: RSpec
27
+ before_script:
28
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64
29
+ > ./cc-test-reporter
30
+ - chmod +x ./cc-test-reporter
31
+ - "./cc-test-reporter before-build"
32
+ script:
33
+ - bundle exec rake spec
34
+ after_script:
35
+ - "./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT"
36
+ - stage: test
37
+ name: Lint
38
+ script:
39
+ - bundle exec standardrb
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- devup (0.1.1)
4
+ devup (0.2.0)
5
+ dotenv
5
6
 
6
7
  GEM
7
8
  remote: https://rubygems.org/
@@ -10,6 +11,7 @@ GEM
10
11
  byebug (11.1.3)
11
12
  diff-lcs (1.3)
12
13
  docile (1.3.2)
14
+ dotenv (2.7.5)
13
15
  jaro_winkler (1.5.4)
14
16
  json (2.3.0)
15
17
  parallel (1.19.1)
@@ -42,7 +44,7 @@ GEM
42
44
  rubocop-performance (1.5.2)
43
45
  rubocop (>= 0.71.0)
44
46
  ruby-progressbar (1.10.1)
45
- simplecov (0.17.1)
47
+ simplecov (0.16.1)
46
48
  docile (~> 1.1)
47
49
  json (>= 1.8, < 3)
48
50
  simplecov-html (~> 0.10.0)
data/README.md CHANGED
@@ -1,28 +1,96 @@
1
- # Devup
1
+ # DevUp!
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/devup`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ [![Travis (.com) branch](https://img.shields.io/travis/com/sergio-fry/devup/master)](https://travis-ci.com/github/sergio-fry/devup)
4
+ [![Gem](https://img.shields.io/gem/v/devup)](https://rubygems.org/gems/devup)
5
+ [![Code Climate coverage](https://img.shields.io/codeclimate/coverage/sergio-fry/devup)](https://codeclimate.com/github/sergio-fry/devup)
6
+ [![Code Climate maintainability](https://img.shields.io/codeclimate/maintainability/sergio-fry/devup)](https://codeclimate.com/github/sergio-fry/devup)
7
+ [![Gem](https://img.shields.io/gem/dt/devup)](https://rubygems.org/gems/devup)
4
8
 
5
- TODO: Delete this and the text above, and describe your gem
9
+ **DevUp!** is a tool to run dev dependencies. It builds ENV vars with dynamic exposed ports for services defined in a docker-compose.yml to access from application.
10
+
11
+ ![demo](demo.gif)
6
12
 
7
13
  ## Installation
8
14
 
9
- Add this line to your application's Gemfile:
15
+ $ gem install devup
16
+
17
+ ## Usage
18
+
19
+
20
+ Create a docker-compose.yml with app dependencies like:
21
+
22
+ ```yaml
23
+ version: '3'
24
+
25
+ services:
26
+ postgres:
27
+ image: postgres
28
+ ports:
29
+ - "5432"
30
+ ```
31
+
32
+ Add devup/dotenv to your Gemfile:
33
+
34
+ gem "devup"
35
+
36
+ For each service from docker-compose.yml **DevUp!** will export ENV variable like
37
+
38
+ POSTGRES_HOST=0.0.0.0
39
+ POSTGRES_PORT=5432
40
+
41
+ ### Rails
42
+
43
+
44
+ Update your database.yml to use ENV:
45
+
46
+ ```yaml
47
+ default: &default
48
+ adapter: postgresql
49
+ encoding: unicode
50
+ host: <%= ENV.fetch("POSTGRES_HOST") %>
51
+ port: <%= ENV.fetch("POSTGRES_PORT") %>
52
+ username: postgres
53
+ password:
54
+
55
+ development:
56
+ <<: *default
57
+ database: development
58
+
59
+ test:
60
+ <<: *default
61
+ database: test
62
+ ```
63
+
64
+
65
+ You are ready to start rails
66
+
67
+ $ bundle exec rake db:create db:migrate
68
+ $ bundle exec rails server
69
+
70
+
71
+ ### Without Rails
72
+
10
73
 
11
74
  ```ruby
12
- gem 'devup'
75
+ require "devup"
76
+ require "sequel"
77
+
78
+ DB = Sequel.connect("postgres://postgres@#{ENV.fetch( "POSTGRES_HOST" )}:#{ENV.fetch("POSTGRES_PORT")}/database_name")
13
79
  ```
14
80
 
15
- And then execute:
16
81
 
17
- $ bundle install
82
+ ### Without Ruby (PHP, nodejs, Java, ...)
18
83
 
19
- Or install it yourself as:
84
+ Start up services
20
85
 
21
- $ gem install devup
86
+ $ devup
22
87
 
23
- ## Usage
88
+ Load ENV vars from generated .env.services
89
+
90
+ $ source .env.services
91
+
92
+ Now you can run app
24
93
 
25
- TODO: Write usage instructions here
26
94
 
27
95
  ## Development
28
96
 
Binary file
@@ -30,4 +30,6 @@ Gem::Specification.new do |spec|
30
30
  spec.bindir = "exe"
31
31
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
32
32
  spec.require_paths = ["lib"]
33
+
34
+ spec.add_dependency "dotenv"
33
35
  end
data/exe/devup CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "devup"
3
+ require "devup/environment"
4
4
 
5
5
  devup = Devup::Environment.new pwd: `pwd`
6
6
 
@@ -3,9 +3,7 @@ require "devup/environment"
3
3
 
4
4
  module Devup
5
5
  class Error < StandardError; end
6
- # Your code goes here...
7
-
8
- def self.root
9
- Pathname.new File.dirname(__dir__)
10
- end
11
6
  end
7
+
8
+ require "devup/boot"
9
+ require "devup/dotenv"
@@ -0,0 +1,2 @@
1
+ devup = Devup::Environment.new pwd: `pwd`
2
+ devup.up
@@ -0,0 +1,2 @@
1
+ require "dotenv"
2
+ Dotenv.load ".env.services"
@@ -34,6 +34,10 @@ module Devup
34
34
  }.flatten
35
35
  end
36
36
 
37
+ def env
38
+ vars.reduce({}, :merge).map { |k, v| "export #{k}=#{v}" }.join("\n")
39
+ end
40
+
37
41
  def up
38
42
  compose.up
39
43
  write_dotenv
@@ -61,11 +65,12 @@ module Devup
61
65
 
62
66
  def dotenv
63
67
  <<~DOTENV
64
- ############################################
65
- # This file is generated by devup command. #
66
- ############################################
68
+ ####################################################
69
+ # This file is generated by devup command. #
70
+ # Home: https://github.com/sergio-fry/devup #
71
+ ####################################################
67
72
  # START
68
- #{vars.reduce({}, :merge).map { |k, v| "#{k}=#{v}" }.join("\n")}
73
+ #{env}
69
74
  # END
70
75
 
71
76
  DOTENV
@@ -1,3 +1,3 @@
1
1
  module Devup
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: devup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
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-03 00:00:00.000000000 Z
12
- dependencies: []
11
+ date: 2020-06-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: dotenv
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  description:
14
28
  email:
15
29
  - sergei@udalovs.ru
@@ -31,10 +45,13 @@ files:
31
45
  - Rakefile
32
46
  - bin/console
33
47
  - bin/setup
48
+ - demo.gif
34
49
  - devup.gemspec
35
50
  - exe/devup
36
51
  - lib/devup.rb
52
+ - lib/devup/boot.rb
37
53
  - lib/devup/compose.rb
54
+ - lib/devup/dotenv.rb
38
55
  - lib/devup/environment.rb
39
56
  - lib/devup/service.rb
40
57
  - lib/devup/version.rb