morpheus-heroku 0.1.0 → 0.2.3

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
  SHA1:
3
- metadata.gz: dbd167532237ddbed5b8a0c707a49202c858fe3b
4
- data.tar.gz: 2a4812332e2b925baad0e2c9dbdd693f63030883
3
+ metadata.gz: 01f6ba8ecf58eaa88efa2d9bdb64e9f84fd95690
4
+ data.tar.gz: b402a83f4ac34fc77974eaf7c83aeac724f2bdbc
5
5
  SHA512:
6
- metadata.gz: 7dc1614c01ad020014cb1a3eb819c2ba8389b944aac12154e0776d635182c9668706f2acb05c917e13b52fa264fcbfd7aa650258ebf03010009fe2bf65dfc560
7
- data.tar.gz: 00ceab0393dbc2bb10706387ca951dcd1fc6f95d06312cd0384ea7b3504e04eee94808dd2ef98aacee9a9fbd0aca07adffbe0804b7a45124546b7dae07119fbb
6
+ metadata.gz: 133b86c4fe3c33854800ceac824874e9fd34fa51fb87a85e886675918c5e5f4f93b14933e02323cc36d0ef14f5f7129a53c80ed7ab4cbc5d75611ad5c5378384
7
+ data.tar.gz: dfd8729a0aa0f9eafb800ba4a18801b0b87c9b63cf692293e6c7d09749ed40009d9c1741e6a4521c8ab7c56076f512eab14c5ead9dfa037db8d50818443d2121
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
1
  /*.gem
2
2
  .DS_Store
3
+ pkg
@@ -0,0 +1,15 @@
1
+ # Change Log
2
+
3
+ ## Unreleased
4
+
5
+ - Email Scrambler
6
+
7
+ *Fixes*
8
+
9
+ - Perform a git fetch before trying to update the remote
10
+
11
+ ## 0.1.0
12
+
13
+ - Fetch and Load Postgres Backup DB from Heroku.
14
+ - Deploy to Heroku production.
15
+ - Config through the initializer.
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Gem Version](https://badge.fury.io/rb/morpheus-heroku.svg)](https://badge.fury.io/rb/morpheus-heroku)
2
+
1
3
  # MorpheusHeroku
2
4
 
3
5
  A set of rake tasks to automate interacting with Heroku.
@@ -7,17 +9,21 @@ A set of rake tasks to automate interacting with Heroku.
7
9
  This gem relies heavily on bash for interacting with Heroku. It's assuming you have the `Heroku CLI`
8
10
  installed and `curl`. Your session must be authenticated with heroku (i.e. running `heroku logs` works).
9
11
  You must have a Heroku remote set up (`heroku git:remote -a my-app-name`).
10
- *Warning* We use `--force` when deploying to Heroku.
12
+ **Warning** We use `--force` when deploying to Heroku.
13
+
14
+ ## Change Log
15
+
16
+ [Change Log](./CHANGELOG.md)
11
17
 
12
18
  ## Install
13
19
 
14
20
  Add this to your gemfile
15
21
 
16
- `gem 'morpheus-heroku'`
22
+ `gem 'morpheus-heroku', '0.1.0'`
17
23
 
18
24
  Generate an initializer for `config/morpheus-heroku.rb` with
19
25
 
20
- `bundle exec rails generate morpheus-heroku`
26
+ `bundle exec rails generate morpheus_heroku`
21
27
 
22
28
  ## Automate deploying to Heroku
23
29
 
@@ -30,7 +36,7 @@ the release in git.
30
36
 
31
37
  MorpheusHeroku will fetch the latest PG backup. If there is no backup, then it will create one. It is
32
38
  strongly recommended to set a recurring Heroku backup to avoid loading stale data.
33
- https://devcenter.heroku.com/articles/heroku-postgres-backups#scheduling-backups
39
+ [https://devcenter.heroku.com/articles/heroku-postgres-backups#scheduling-backups]()
34
40
 
35
41
  `bundle exec rake db:fetch`
36
42
 
@@ -40,6 +46,13 @@ MorpheusHeroku will fetch the latest database backup and then load it using the
40
46
 
41
47
  `bundle exec rake db:load`
42
48
 
49
+ ## Scramblers
50
+
51
+ ### Email
52
+
53
+ An email will be scrambled if it doesn't contain the substring in `config.dev_email`. Say your dev email is *dev@example.com*.
54
+ An email like *john@company.com* will be scrambled as *dev+234235@example.com*. Email *doe@example.com* will be unchanged.
55
+
43
56
  ## Rails 5 Tips
44
57
 
45
58
  If you see `ActiveRecord::ProtectedEnvironmentError: You are attempting to run a destructive action against your 'production' database.`
@@ -0,0 +1,12 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
7
+
8
+ Rake::Task["release"].enhance do
9
+ spec = Gem::Specification::load(Dir.glob("*.gemspec").first)
10
+ sh "gem build pkg/#{spec.name}-#{spec.version}.gem"
11
+ sh "gem push pkg/#{spec.name}-#{spec.version}.gem"
12
+ end
@@ -8,4 +8,7 @@ MorpheusHeroku.configure do |config|
8
8
 
9
9
  # Show debugging events
10
10
  # config.log_events = false
11
+
12
+ # Your development email. Will not scramble emails containing this string
13
+ # config.dev_email = "dev@blah.com"
11
14
  end
@@ -5,6 +5,8 @@ require 'morpheus-heroku/deploy'
5
5
  require 'morpheus-heroku/helper'
6
6
  require 'morpheus-heroku/config'
7
7
 
8
+ require 'morpheus-heroku/scramblers/email'
9
+
8
10
  require 'morpheus-heroku/railtie'
9
11
 
10
12
  module MorpheusHeroku
@@ -1,6 +1,6 @@
1
1
  module MorpheusHeroku
2
2
  class Config
3
- attr_accessor :database_name, :backup_location, :app_name, :log_events
3
+ attr_accessor :database_name, :backup_location, :app_name, :log_events, :dev_email
4
4
 
5
5
  def initialize
6
6
  @database_name = ActiveRecord::Base.connection_config[:database]
@@ -1,8 +1,11 @@
1
1
  module MorpheusHeroku
2
2
  module Deploy
3
+ DEPLOY_ENV = "production"
4
+
3
5
  extend self
4
6
 
5
7
  def production
8
+ fetch_active_remotes!
6
9
  ensure_local_remote_is_up_to_date!
7
10
  deploy_to_heroku!
8
11
  run_database_migrations!
@@ -13,6 +16,10 @@ module MorpheusHeroku
13
16
 
14
17
  private
15
18
 
19
+ def fetch_active_remotes!
20
+ Helper.bash_run(command: "git fetch")
21
+ end
22
+
16
23
  def git_branch
17
24
  @branch ||= `git branch | grep -e "^*"`.strip.gsub("* ", "")
18
25
  end
@@ -34,7 +41,7 @@ module MorpheusHeroku
34
41
  end
35
42
 
36
43
  def tag_name
37
- "heroku_deploy_#{Time.now.to_s(:db).gsub(/[- :]/, "_")}"
44
+ "heroku_#{DEPLOY_ENV}_#{Time.now.to_s(:db).gsub(/[- :]/, "_")}"
38
45
  end
39
46
 
40
47
  def update_git!
@@ -3,27 +3,16 @@ module MorpheusHeroku
3
3
  extend self
4
4
 
5
5
  def run
6
- unless backup_available?
7
- Rails.logger.info "No backup available. Generating one"
8
- generate_backup!
9
- end
6
+ generate_backup!
10
7
  download_backup!
11
8
  end
12
9
 
13
10
  private
14
11
 
15
- def backup_available?
16
- Helper.heroku_run(command: "heroku pg:backups public-url")
17
- end
18
-
19
12
  def generate_backup!
20
13
  Helper.heroku_run(command: "heroku pg:backups capture")
21
14
  end
22
15
 
23
- def backup_url
24
- Helper.heroku_run(command: "heroku pg:backups public-url")
25
- end
26
-
27
16
  def download_backup!
28
17
  Helper.bash_run(command: "curl -o #{MorpheusHeroku.configuration.backup_location} `heroku pg:backups public-url`")
29
18
  end
@@ -0,0 +1,45 @@
1
+ module MorpheusHeroku
2
+ module Scramblers
3
+ module Load
4
+ extend self
5
+
6
+ def scrambled_email
7
+ if dev_namespace.present? && dev_domain.present?
8
+ "#{dev_namespace}+#{random_string}@#{dev_domain}"
9
+ else
10
+ "dev+#{random_string}@example.com"
11
+ end
12
+ end
13
+
14
+ def should_scramble_email?(email)
15
+ if dev_domain.present?
16
+ email.include?(dev_domain)
17
+ else
18
+ false
19
+ end
20
+ end
21
+
22
+ def dev_domain
23
+ @dev_domain ||= if MorpheusHeroku.configuration.dev_email
24
+ "@" + MorpheusHeroku.configuration.dev_email.match(/(.*)@(.*)/)[2]
25
+ else
26
+ ""
27
+ end
28
+ end
29
+
30
+ def dev_namespace
31
+ @dev_namespace ||= if MorpheusHeroku.configuration.dev_email
32
+ MorpheusHeroku.configuration.dev_email.match(/(.*)@(.*)/)[1]
33
+ else
34
+ ""
35
+ end
36
+ end
37
+
38
+ private
39
+
40
+ def random_string
41
+ SecureRandom.hex.first(6)
42
+ end
43
+ end
44
+ end
45
+ end
@@ -1,3 +1,3 @@
1
1
  module MorpheusHeroku
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.3"
3
3
  end
@@ -13,6 +13,12 @@ Gem::Specification.new do |spec|
13
13
  spec.homepage = "https://github.com/cionescu/morpheus-heroku"
14
14
  spec.license = "MIT"
15
15
 
16
+ if spec.respond_to?(:metadata)
17
+ spec.metadata['allowed_push_host'] = "https://rubygems.org"
18
+ else
19
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
20
+ end
21
+
16
22
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
23
  spec.bindir = "exe"
18
24
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: morpheus-heroku
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Catalin Ionescu
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-06-01 00:00:00.000000000 Z
11
+ date: 2016-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -74,8 +74,10 @@ extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
76
  - ".gitignore"
77
+ - CHANGELOG.md
77
78
  - LICENSE
78
79
  - README.md
80
+ - Rakefile
79
81
  - config/morpheus-heroku-initializer.rb
80
82
  - lib/generators/morpheus_heroku_generator.rb
81
83
  - lib/morpheus-heroku.rb
@@ -85,6 +87,7 @@ files:
85
87
  - lib/morpheus-heroku/helper.rb
86
88
  - lib/morpheus-heroku/load.rb
87
89
  - lib/morpheus-heroku/railtie.rb
90
+ - lib/morpheus-heroku/scramblers/email.rb
88
91
  - lib/morpheus-heroku/version.rb
89
92
  - lib/tasks/db.rake
90
93
  - lib/tasks/deploy.rake
@@ -92,7 +95,8 @@ files:
92
95
  homepage: https://github.com/cionescu/morpheus-heroku
93
96
  licenses:
94
97
  - MIT
95
- metadata: {}
98
+ metadata:
99
+ allowed_push_host: https://rubygems.org
96
100
  post_install_message:
97
101
  rdoc_options: []
98
102
  require_paths: