handy 0.0.27 → 0.0.28
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/handy/add_database_yml.rb +79 -0
- data/lib/handy/engine.rb +1 -1
- data/lib/handy/heroku_tasks.rb +6 -0
- data/lib/handy/version.rb +1 -1
- metadata +9 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b033fc8c059b880793277ad5ac18228acd29d5c
|
4
|
+
data.tar.gz: ffa5da5c39742ac341a5a740b08b9d86db4edca7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 123eee508942d41d59a0e55d5ac6aca19c0e54770f0667c9b99be0e71cf11816a123ee53215a65e2fb09df997d689415332f25a33fe25fa8207529013ec44165
|
7
|
+
data.tar.gz: c51ed6aaf6f22c808c809aa563f402074690ca69184df914c6427f214e61e10d212837fd879b3b9b20b99b97e78c969da1d7fd7160aa6262487333ca031b1f90
|
@@ -0,0 +1,79 @@
|
|
1
|
+
namespace :handy do
|
2
|
+
|
3
|
+
def git_branch_command
|
4
|
+
"git_branch = `git symbolic-ref HEAD 2>/dev/null`.chomp.sub('refs/heads/', '')"
|
5
|
+
end
|
6
|
+
|
7
|
+
def repository_name_command
|
8
|
+
"repository_name = `git rev-parse --show-toplevel`.split('/').last.strip"
|
9
|
+
end
|
10
|
+
|
11
|
+
def database_name(env)
|
12
|
+
case env
|
13
|
+
when 'development'
|
14
|
+
'<%= "#{repository_name}_development"[0...63] %>'
|
15
|
+
when 'test'
|
16
|
+
'<%= "#{repository_name}_test"[0...63] %>'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def database_yml_path
|
21
|
+
File.join Rails.root, 'config', 'database.yml'
|
22
|
+
end
|
23
|
+
|
24
|
+
def adapter
|
25
|
+
ENV['ADAPTER'] = 'mysql2' if ENV['ADAPTER'] == 'mysql'
|
26
|
+
@_adapter ||= ENV['ADAPTER'] || 'postgresql'
|
27
|
+
end
|
28
|
+
|
29
|
+
def adapter_credentials
|
30
|
+
case adapter
|
31
|
+
when 'postgresql'
|
32
|
+
{ 'username' => 'postgres', 'password' => nil }
|
33
|
+
when 'sqlite3'
|
34
|
+
{}
|
35
|
+
when 'mysql2'
|
36
|
+
{ 'username' => 'root', 'password' => nil }
|
37
|
+
else
|
38
|
+
raise "Adapter #{adapter} is not supported."
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def db_character_set
|
43
|
+
case adapter
|
44
|
+
when 'postgresql'
|
45
|
+
'unicode'
|
46
|
+
when 'sqlite3'
|
47
|
+
nil
|
48
|
+
when 'mysql', 'mysql2'
|
49
|
+
'utf8'
|
50
|
+
else
|
51
|
+
raise "Adapter #{adapter} is not supported."
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def config(env)
|
56
|
+
{ env => { 'adapter' => adapter,
|
57
|
+
'database' => database_name(env),
|
58
|
+
'encoding' => db_character_set,
|
59
|
+
'host' => 'localhost',
|
60
|
+
'pool' => 5
|
61
|
+
}.merge(adapter_credentials)
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
65
|
+
desc 'Creates database.yml. Default adapter is postgresql. Uses repository name and environment for generating database name. Options: (ADAPTER: sqlite3/mysql2/postgresql)'
|
66
|
+
task :add_database_yml do
|
67
|
+
File.open database_yml_path, 'w' do |f|
|
68
|
+
f.write "<% #{git_branch_command} %>\n"
|
69
|
+
f.write "<% #{repository_name_command} %>\n"
|
70
|
+
f.write "\n"
|
71
|
+
f.write "# Database name is restricted to 63 characters.\n"
|
72
|
+
f.write "# Because the default limit on length of identifiers in PostGreSQL is 63.\n"
|
73
|
+
f.write "\n"
|
74
|
+
f.write config('development').to_yaml.gsub(/^---\s+/, '')
|
75
|
+
f.write "\n"
|
76
|
+
f.write config('test').to_yaml.gsub(/^---\s+/, '')
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
data/lib/handy/engine.rb
CHANGED
data/lib/handy/heroku_tasks.rb
CHANGED
@@ -5,6 +5,12 @@ end
|
|
5
5
|
|
6
6
|
namespace :handy do
|
7
7
|
|
8
|
+
desc "delete merged branches"
|
9
|
+
task :delete_merged_branches do
|
10
|
+
cmd = "git branch -r --merged | grep -v master | grep -v staging | grep -v production | sed -e 's/origin\//:/' | xargs git push origin"
|
11
|
+
`#{cmd}`
|
12
|
+
end
|
13
|
+
|
8
14
|
namespace :heroku do
|
9
15
|
|
10
16
|
desc "Backup production database"
|
data/lib/handy/version.rb
CHANGED
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: handy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.28
|
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-
|
11
|
+
date: 2014-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashr
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
description: handy tool
|
@@ -31,13 +31,14 @@ executables: []
|
|
31
31
|
extensions: []
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
|
-
- .gitignore
|
34
|
+
- ".gitignore"
|
35
35
|
- Gemfile
|
36
36
|
- LICENSE
|
37
37
|
- README.md
|
38
38
|
- Rakefile
|
39
39
|
- handy.gemspec
|
40
40
|
- lib/handy.rb
|
41
|
+
- lib/handy/add_database_yml.rb
|
41
42
|
- lib/handy/additional_test_directories.rb
|
42
43
|
- lib/handy/config_loader.rb
|
43
44
|
- lib/handy/delete_heroku_apps.rb
|
@@ -55,17 +56,17 @@ require_paths:
|
|
55
56
|
- lib
|
56
57
|
required_ruby_version: !ruby/object:Gem::Requirement
|
57
58
|
requirements:
|
58
|
-
- -
|
59
|
+
- - ">="
|
59
60
|
- !ruby/object:Gem::Version
|
60
61
|
version: '0'
|
61
62
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
63
|
requirements:
|
63
|
-
- -
|
64
|
+
- - ">="
|
64
65
|
- !ruby/object:Gem::Version
|
65
66
|
version: '0'
|
66
67
|
requirements: []
|
67
68
|
rubyforge_project:
|
68
|
-
rubygems_version: 2.
|
69
|
+
rubygems_version: 2.2.2
|
69
70
|
signing_key:
|
70
71
|
specification_version: 4
|
71
72
|
summary: Collection of handy tools
|