handy 0.0.28 → 0.0.29

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
  SHA1:
3
- metadata.gz: 0b033fc8c059b880793277ad5ac18228acd29d5c
4
- data.tar.gz: ffa5da5c39742ac341a5a740b08b9d86db4edca7
3
+ metadata.gz: dd372766b424ef623504c187c3628f3f0b1ae725
4
+ data.tar.gz: 1794c1f1f19fbd8bcc684b896870d2ec60575afb
5
5
  SHA512:
6
- metadata.gz: 123eee508942d41d59a0e55d5ac6aca19c0e54770f0667c9b99be0e71cf11816a123ee53215a65e2fb09df997d689415332f25a33fe25fa8207529013ec44165
7
- data.tar.gz: c51ed6aaf6f22c808c809aa563f402074690ca69184df914c6427f214e61e10d212837fd879b3b9b20b99b97e78c969da1d7fd7160aa6262487333ca031b1f90
6
+ metadata.gz: 4892ef1631b4c63fb9368acd0411bebbc689d2ca6584c1ea8e81cad9434becd3e7157eca49c6a7e7b2e47e3ad6108df1700dbf7f3f5fed19cbde2dd4bfffe005
7
+ data.tar.gz: a73d3119208931698a29b35c26c484cdd54c1da8e776e33f60036e5521b7ecc1e5605f019d241f1dfb63559b9525422fcacaec59b1fdd5249d21485c1443cc87
@@ -1,3 +1,6 @@
1
+ #This file is needed copy production db to localhost. This file
2
+ #is used to get database name.
3
+
1
4
  require "hashr"
2
5
 
3
6
  module Handy
@@ -1,10 +1,6 @@
1
1
  module Handy
2
2
  class Engine < ::Rails::Engine
3
3
 
4
- initializer :load_application_yml, before: :load_environment_config do
5
- ::Settings = ConfigLoader.new('settings.yml').load
6
- end
7
-
8
4
  rake_tasks do
9
5
  load 'handy/trailing_whitespaces.rb'
10
6
  load 'handy/delete_merged_branches.rb'
@@ -5,9 +5,15 @@ end
5
5
 
6
6
  namespace :handy do
7
7
 
8
- desc "delete merged branches"
9
- task :delete_merged_branches do
8
+ desc "delete merged branches from github"
9
+ task :delete_merged_branches_from_github do
10
+
11
+ puts "This command deletes branches from github."
12
+ puts "This command would never delete master, staging or production branch."
13
+ puts "This command only deletes branches which are already merged."
10
14
  cmd = "git branch -r --merged | grep -v master | grep -v staging | grep -v production | sed -e 's/origin\//:/' | xargs git push origin"
15
+ puts cmd
16
+
11
17
  `#{cmd}`
12
18
  end
13
19
 
@@ -18,17 +24,17 @@ namespace :handy do
18
24
  take_current_snapshot "#{heroku_app_name(t, args)}-production"
19
25
  end
20
26
 
21
- desc "Takes snapshot of production db and copies production data to development"
27
+ desc "Take snapshot of production db and copy production data to development"
22
28
  task :prod2development, :app do |t, args|
23
29
  export2local "#{heroku_app_name(t, args)}-production"
24
30
  end
25
31
 
26
- desc "Takes snapshot of staging db and copies staging data to development"
32
+ desc "Take snapshot of staging db and copy staging data to development"
27
33
  task :staging2development, :app do |t, args|
28
34
  export2local "#{heroku_app_name(t, args)}-staging"
29
35
  end
30
36
 
31
- desc "Takes snapshot of production db and copies production data to staging"
37
+ desc "Take snapshot of production db and copy production data to staging"
32
38
  task :prod2staging, :app do |t, args|
33
39
  take_current_snapshot "#{heroku_app_name(t, args)}-production"
34
40
 
@@ -40,7 +46,7 @@ namespace :handy do
40
46
  execute "heroku pgbackups:restore DATABASE #{get_src_db_url_cmd} --app #{dst_app_name} --confirm #{dst_app_name}"
41
47
  end
42
48
 
43
- desc "Takes snapshot of branch A and pushes to branch B"
49
+ desc "Take snapshot of branch A and copy data to branch B"
44
50
  task :a2b, :app do |t, args|
45
51
  a = ENV['A'] || ENV['a']
46
52
  b = ENV['B'] || ENV['b']
@@ -71,8 +77,8 @@ namespace :handy do
71
77
 
72
78
  def export2local(app_name)
73
79
  take_current_snapshot(app_name)
74
- execute "curl -o latest.dump `heroku pgbackups:url --app #{app_name}`"
75
- execute restore_command + "; rm latest.dump"
80
+ execute "curl -o latest.dump `heroku pg:backups public-url --app #{app_name}`"
81
+ execute restore_command + "; rm latest.dump"
76
82
  end
77
83
 
78
84
  def take_current_snapshot(app_name)
@@ -91,17 +97,20 @@ ERROR_MSG
91
97
  database_config && database_config[:database] ||
92
98
  abort('Error: Please check your database.yml since no database was found.')
93
99
  end
94
-
100
+
95
101
  def database_config
96
102
  @database_config ||= Handy::ConfigLoader.new('database.yml').load
97
103
  end
98
-
104
+
99
105
  def restore_command
106
+ host = database_config[:host]
107
+
108
+ #Posgresql.app sets user as machine user. In mac command "id -un" gets user name
109
+ username = `id -un`.chomp
110
+
100
111
  result = "pg_restore --verbose --clean --no-acl --no-owner"
101
- result += " -h#{database_config[:host]}" if database_config[:host].present?
102
- result += " -U#{database_config[:username]}" if database_config[:username].present?
103
- result = "PGPASSWORD=#{database_config[:password]} #{result}" if database_config[:password].present?
104
-
112
+ result += " -h#{host}"
113
+ result += " -U#{username}"
105
114
  result + " -d #{local_database} latest.dump"
106
115
  end
107
116
  end
@@ -1,3 +1,3 @@
1
1
  module Handy
2
- VERSION = "0.0.28"
2
+ VERSION = "0.0.29"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: handy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.28
4
+ version: 0.0.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - Neeraj Singh
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-08 00:00:00.000000000 Z
11
+ date: 2015-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashr
@@ -39,7 +39,6 @@ files:
39
39
  - handy.gemspec
40
40
  - lib/handy.rb
41
41
  - lib/handy/add_database_yml.rb
42
- - lib/handy/additional_test_directories.rb
43
42
  - lib/handy/config_loader.rb
44
43
  - lib/handy/delete_heroku_apps.rb
45
44
  - lib/handy/delete_merged_branches.rb
@@ -66,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
65
  version: '0'
67
66
  requirements: []
68
67
  rubyforge_project:
69
- rubygems_version: 2.2.2
68
+ rubygems_version: 2.4.5
70
69
  signing_key:
71
70
  specification_version: 4
72
71
  summary: Collection of handy tools
@@ -1,25 +0,0 @@
1
- # Adding test/services directory to the rake test.
2
- namespace :test do
3
- desc "Test services code"
4
- Rails::TestTask.new(services: 'test:prepare') do |t|
5
- t.pattern = 'test/services/**/*_test.rb'
6
- end
7
- end
8
-
9
- # Adding test/workers directory to the rake test.
10
- namespace :test do
11
- desc "Test workers code"
12
- Rails::TestTask.new(workers: 'test:prepare') do |t|
13
- t.pattern = 'test/workers/**/*_test.rb'
14
- end
15
- end
16
-
17
- # Adding test/carriers directory to the rake test.
18
- namespace :test do
19
- desc "Test carriers code"
20
- Rails::TestTask.new(carriers: 'test:prepare') do |t|
21
- t.pattern = 'test/carriers/**/*_test.rb'
22
- end
23
- end
24
-
25
- Rake::Task['test:run'].enhance ["test:services", "test:carriers", "test:workers"]