effective_developer 0.4.15 → 0.4.16
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 +4 -4
- data/lib/effective_developer/version.rb +1 -1
- data/lib/tasks/hatchbox.rake +2 -0
- data/lib/tasks/heroku.rake +3 -4
- data/lib/tasks/pg_pull.rake +15 -22
- metadata +1 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 7d56abcd9d4964e1ef609e137ee2e5cf0af65fef0b94420b75ece42f5dea60a9
         | 
| 4 | 
            +
              data.tar.gz: 626969c07fd04d4886b2b6044111ec3651c8f682dbb316318106f2528dca7dd1
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 046a257cd7af7e70f2973f3d6082758a66c54982e8ee4b34f32ee91146ef43dd66c4c1b04dc7eb9d2503a5321d83d64f159d715d17f19bcf4b41d64f6427a555
         | 
| 7 | 
            +
              data.tar.gz: 904fe1dea98e96c21e87c7a74c6c2b7364025edc208719e6d657915566d3de47851892de84811b7e14ab6601edb65dcfecfd543aace4ec6f1bfa3edc5f47c15c
         | 
    
        data/lib/tasks/hatchbox.rake
    CHANGED
    
    
    
        data/lib/tasks/heroku.rake
    CHANGED
    
    | @@ -12,14 +12,13 @@ namespace :heroku do | |
| 12 12 |  | 
| 13 13 | 
             
                  Bundler.with_clean_env do
         | 
| 14 14 | 
             
                    unless system("heroku pg:backups:capture --remote #{args.remote}")
         | 
| 15 | 
            -
                       | 
| 16 | 
            -
                      exit
         | 
| 15 | 
            +
                      abort("Error capturing heroku backup")
         | 
| 17 16 | 
             
                    end
         | 
| 18 17 |  | 
| 19 18 | 
             
                    if system("curl -o latest.dump `heroku pg:backups:public-url --remote #{args.remote}`")
         | 
| 20 | 
            -
                      puts | 
| 19 | 
            +
                      puts("Downloading database completed")
         | 
| 21 20 | 
             
                    else
         | 
| 22 | 
            -
                       | 
| 21 | 
            +
                      abort("Error downloading database")
         | 
| 23 22 | 
             
                    end
         | 
| 24 23 | 
             
                  end
         | 
| 25 24 | 
             
                end
         | 
    
        data/lib/tasks/pg_pull.rake
    CHANGED
    
    | @@ -13,7 +13,7 @@ namespace :pg do | |
| 13 13 | 
             
                else
         | 
| 14 14 | 
             
                  puts "Unable to find pg:pull provider."
         | 
| 15 15 | 
             
                  puts "Please add a heroku git remote or a HATCHBOX_IP environment variable and try again"
         | 
| 16 | 
            -
                   | 
| 16 | 
            +
                  abort
         | 
| 17 17 | 
             
                end
         | 
| 18 18 |  | 
| 19 19 | 
             
                Rake::Task['pg:load'].invoke
         | 
| @@ -43,7 +43,7 @@ namespace :pg do | |
| 43 43 | 
             
                if system("export PGPASSWORD=#{db[:password]}; pg_restore --no-acl --no-owner --clean --if-exists -h #{db[:host]} -U #{db[:username]} -d #{db[:database]} #{args.file_name}")
         | 
| 44 44 | 
             
                  puts "Loading database completed"
         | 
| 45 45 | 
             
                else
         | 
| 46 | 
            -
                   | 
| 46 | 
            +
                  abort "Error loading database"
         | 
| 47 47 | 
             
                end
         | 
| 48 48 | 
             
              end
         | 
| 49 49 |  | 
| @@ -54,14 +54,10 @@ namespace :pg do | |
| 54 54 | 
             
                args.with_defaults(:file_name => 'latest.dump')
         | 
| 55 55 |  | 
| 56 56 | 
             
                db = if ENV['DATABASE_URL'].to_s.length > 0
         | 
| 57 | 
            -
                   | 
| 58 | 
            -
                   | 
| 57 | 
            +
                  uri = URI.parse(ENV['DATABASE_URL']) rescue nil
         | 
| 58 | 
            +
                  abort("Invalid DATABASE_URL") unless uri.present?
         | 
| 59 59 |  | 
| 60 | 
            -
                   | 
| 61 | 
            -
                    puts("Invalid DATABASE_URL") and exit
         | 
| 62 | 
            -
                  end
         | 
| 63 | 
            -
             | 
| 64 | 
            -
                  { username: info[1], password: info[2], host: info[3], port: info[4], database: info[5] }
         | 
| 60 | 
            +
                  { username: uri.user, password: uri.password, host: uri.host, port: (uri.port || 5432), database: uri.path.sub('/', '') }
         | 
| 65 61 | 
             
                else
         | 
| 66 62 | 
             
                  config = ActiveRecord::Base.configurations[Rails.env]
         | 
| 67 63 | 
             
                  { username: (config['username'] || `whoami`), password: config['password'], host: config['host'], port: (config['port'] || 5432), database: config['database'] }
         | 
| @@ -72,7 +68,7 @@ namespace :pg do | |
| 72 68 | 
             
                if system("export PGPASSWORD=#{db[:password]}; pg_dump -Fc --no-acl --no-owner -h #{db[:host]} -p #{db[:port]} -U #{db[:username]} #{db[:database]} > #{args.file_name}")
         | 
| 73 69 | 
             
                  puts "Saving database completed"
         | 
| 74 70 | 
             
                else
         | 
| 75 | 
            -
                   | 
| 71 | 
            +
                  abort "Error saving database"
         | 
| 76 72 | 
             
                end
         | 
| 77 73 | 
             
              end
         | 
| 78 74 |  | 
| @@ -85,20 +81,17 @@ namespace :pg do | |
| 85 81 |  | 
| 86 82 | 
             
                Bundler.with_clean_env do
         | 
| 87 83 | 
             
                  unless system("heroku pg:backups:capture --remote #{args.source_remote}")
         | 
| 88 | 
            -
                     | 
| 89 | 
            -
                    exit
         | 
| 84 | 
            +
                    abort "Error capturing heroku backup"
         | 
| 90 85 | 
             
                  end
         | 
| 91 86 |  | 
| 92 87 | 
             
                  url = (`heroku pg:backups:public-url --remote #{args.source_remote}`).chomp
         | 
| 93 88 |  | 
| 94 89 | 
             
                  unless (url || '').length > 0
         | 
| 95 | 
            -
                     | 
| 96 | 
            -
                    exit
         | 
| 90 | 
            +
                    abort "Error reading public-url from remote #{args.source_remote}"
         | 
| 97 91 | 
             
                  end
         | 
| 98 92 |  | 
| 99 93 | 
             
                  unless system("heroku pg:backups:restore '#{url}' DATABASE_URL --remote #{args.target_remote}")
         | 
| 100 | 
            -
                     | 
| 101 | 
            -
                    exit
         | 
| 94 | 
            +
                    abort "Error cloning heroku backup"
         | 
| 102 95 | 
             
                  end
         | 
| 103 96 | 
             
                end
         | 
| 104 97 |  | 
| @@ -110,7 +103,7 @@ namespace :pg do | |
| 110 103 | 
             
                args.with_defaults(:remote => 'heroku')
         | 
| 111 104 |  | 
| 112 105 | 
             
                if args.table.blank?
         | 
| 113 | 
            -
                   | 
| 106 | 
            +
                  abort "Error, no table name specified. Expected usage: rake pg:push_table[prices]"
         | 
| 114 107 | 
             
                end
         | 
| 115 108 |  | 
| 116 109 | 
             
                # Find and parse my heroku database info
         | 
| @@ -121,14 +114,14 @@ namespace :pg do | |
| 121 114 | 
             
                if info.blank? || info.length != 6
         | 
| 122 115 | 
             
                  puts "Unable to find heroku DATABASE_URL"
         | 
| 123 116 | 
             
                  puts "Expected \"heroku config --remote #{args.remote} | grep DATABASE_URL\" to be present"
         | 
| 124 | 
            -
                   | 
| 117 | 
            +
                  abort
         | 
| 125 118 | 
             
                end
         | 
| 126 119 |  | 
| 127 120 | 
             
                heroku = { username: info[1], password: info[2], host: info[3], port: info[4], database: info[5] }
         | 
| 128 121 |  | 
| 129 122 | 
             
                # Confirm destructive operation
         | 
| 130 123 | 
             
                puts "WARNING: this task will overwrite the #{args.table} database table on #{args.remote}. Proceed? (y/n)"
         | 
| 131 | 
            -
                ( | 
| 124 | 
            +
                abort('Aborted') unless STDIN.gets.chomp.downcase == 'y'
         | 
| 132 125 |  | 
| 133 126 | 
             
                puts "=== Cloning local table '#{args.table}' to remote #{args.remote} database"
         | 
| 134 127 |  | 
| @@ -137,7 +130,7 @@ namespace :pg do | |
| 137 130 | 
             
                tmpfile = "tmp/#{args.table}.sql"
         | 
| 138 131 |  | 
| 139 132 | 
             
                unless system("pg_dump --data-only --table=#{args.table} -h localhost -U '#{db['username']}' '#{db['database']}' > #{tmpfile}")
         | 
| 140 | 
            -
                   | 
| 133 | 
            +
                  abort "Error dumping local database table"
         | 
| 141 134 | 
             
                end
         | 
| 142 135 |  | 
| 143 136 | 
             
                # Now restore it to heroku
         | 
| @@ -145,11 +138,11 @@ namespace :pg do | |
| 145 138 | 
             
                delete = args.table.split(',').map { |table| "DELETE FROM #{table}" }.join(';')
         | 
| 146 139 |  | 
| 147 140 | 
             
                unless system("#{psql} -c \"#{delete}\"")
         | 
| 148 | 
            -
                   | 
| 141 | 
            +
                  abort "Error deleting remote table data"
         | 
| 149 142 | 
             
                end
         | 
| 150 143 |  | 
| 151 144 | 
             
                unless system("#{psql} < #{tmpfile}")
         | 
| 152 | 
            -
                   | 
| 145 | 
            +
                  abort "Error pushing table to remote database"
         | 
| 153 146 | 
             
                end
         | 
| 154 147 |  | 
| 155 148 | 
             
                # Delete tmpfile
         |