lita-ey-tools 0.0.1

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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: efa107c4be4a0809f93c9f890eef5dee2cf2ac35
4
+ data.tar.gz: dd76fad1393e2709b1255f3a8b0940cc6e8cc455
5
+ SHA512:
6
+ metadata.gz: a3743dcfa1b243528deb39b2a97d86f086600abbd84d7fdf13a768f6d0b45077ec8c061f320351116131754e13b3d6be737dae0889a03bd88fa7c1bfb96858b9
7
+ data.tar.gz: a3112c78812ec059e65f8f02274faab3a33b788310e3aa91538573e655a3850167972b6112ccf16f335592056bac17e7dfa043e4ed617e9133da8004b744833a
data/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ *.gem
2
+ .bundle
3
+ .config
4
+ .coveralls.yml
5
+ .ruby-gemset
6
+ .ruby-version
7
+ coverage
8
+ pkg
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ -f documentation --color
data/.travis.yml ADDED
@@ -0,0 +1,13 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ script: bundle exec rake
5
+ before_install:
6
+ - gem update --system
7
+ services:
8
+ - redis-server
9
+ notifications:
10
+ email: false
11
+ webhooks:
12
+ urls:
13
+ - https://lita-freenode.herokuapp.com/travis
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source "https://rubygems.org"
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,108 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ lita-ey-tools (0.0.1)
5
+ engineyard
6
+ lita (>= 3.2.0)
7
+ lita-ey-base
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ addressable (2.3.6)
13
+ coveralls (0.7.0)
14
+ multi_json (~> 1.3)
15
+ rest-client
16
+ simplecov (>= 0.7)
17
+ term-ansicolor
18
+ thor
19
+ diff-lcs (1.2.5)
20
+ docile (1.1.3)
21
+ engineyard (2.3.1)
22
+ engineyard-cloud-client (~> 1.0.14)
23
+ engineyard-serverside-adapter (= 2.2.0)
24
+ escape (~> 0.0.4)
25
+ highline (~> 1.6.1)
26
+ launchy (~> 2.1)
27
+ net-ssh (~> 2.2)
28
+ rest-client (~> 1.6.0)
29
+ engineyard-cloud-client (1.0.15)
30
+ multi_json (~> 1.6)
31
+ rest-client (~> 1.6.1)
32
+ engineyard-serverside-adapter (2.2.0)
33
+ escape (~> 0.0.4)
34
+ multi_json (~> 1.6)
35
+ escape (0.0.4)
36
+ faraday (0.9.0)
37
+ multipart-post (>= 1.2, < 3)
38
+ highline (1.6.21)
39
+ http_router (0.11.1)
40
+ rack (>= 1.0.0)
41
+ url_mount (~> 0.2.1)
42
+ i18n (0.6.9)
43
+ ice_nine (0.11.0)
44
+ launchy (2.4.2)
45
+ addressable (~> 2.3)
46
+ lita (3.3.0)
47
+ bundler (>= 1.3)
48
+ faraday (>= 0.8.7)
49
+ http_router (>= 0.11.1)
50
+ i18n (>= 0.6.9)
51
+ ice_nine (>= 0.11.0)
52
+ multi_json (>= 1.7.7)
53
+ puma (>= 2.7.1)
54
+ rack (>= 1.5.2)
55
+ rb-readline (>= 0.5.1)
56
+ redis-namespace (>= 1.3.0)
57
+ thor (>= 0.18.1)
58
+ lita-ey-base (0.0.2)
59
+ engineyard
60
+ lita (>= 3.2.0)
61
+ mime-types (2.3)
62
+ multi_json (1.10.1)
63
+ multipart-post (2.0.0)
64
+ net-ssh (2.9.1)
65
+ puma (2.8.2)
66
+ rack (>= 1.1, < 2.0)
67
+ rack (1.5.2)
68
+ rake (10.3.2)
69
+ rb-readline (0.5.1)
70
+ redis (3.0.7)
71
+ redis-namespace (1.4.1)
72
+ redis (~> 3.0.4)
73
+ rest-client (1.6.7)
74
+ mime-types (>= 1.16)
75
+ rspec (3.0.0)
76
+ rspec-core (~> 3.0.0)
77
+ rspec-expectations (~> 3.0.0)
78
+ rspec-mocks (~> 3.0.0)
79
+ rspec-core (3.0.2)
80
+ rspec-support (~> 3.0.0)
81
+ rspec-expectations (3.0.2)
82
+ diff-lcs (>= 1.2.0, < 2.0)
83
+ rspec-support (~> 3.0.0)
84
+ rspec-mocks (3.0.2)
85
+ rspec-support (~> 3.0.0)
86
+ rspec-support (3.0.2)
87
+ simplecov (0.8.2)
88
+ docile (~> 1.1.0)
89
+ multi_json
90
+ simplecov-html (~> 0.8.0)
91
+ simplecov-html (0.8.0)
92
+ term-ansicolor (1.3.0)
93
+ tins (~> 1.0)
94
+ thor (0.19.1)
95
+ tins (1.3.0)
96
+ url_mount (0.2.1)
97
+ rack
98
+
99
+ PLATFORMS
100
+ ruby
101
+
102
+ DEPENDENCIES
103
+ bundler
104
+ coveralls
105
+ lita-ey-tools!
106
+ rake
107
+ rspec (>= 3.0.0)
108
+ simplecov
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2014 Carlos Paramio
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,74 @@
1
+ # lita-ey-tools
2
+
3
+ [![Build Status](https://travis-ci.org/carlosparamio/lita-ey-tools.png?branch=master)](https://travis-ci.org/carlosparamio/lita-ey-tools)
4
+ [![Code Climate](https://codeclimate.com/github/carlosparamio/lita-ey-tools.png)](https://codeclimate.com/github/carlosparamio/lita-ey-tools)
5
+ [![Coverage Status](https://coveralls.io/repos/carlosparamio/lita-ey-tools/badge.png)](https://coveralls.io/r/carlosparamio/lita-ey-tools)
6
+
7
+ **lita-ey-tools** is a handler for [Lita](http://lita.io/) that provides some EngineYard tools.
8
+
9
+ ## Installation
10
+
11
+ Add lita-ey-tools to your Lita instance's Gemfile:
12
+
13
+ ``` ruby
14
+ gem "lita-ey-tools"
15
+ ```
16
+
17
+ Don't forget to include your EngineYard API key on the lita_config.rb file:
18
+
19
+ ``` ruby
20
+ config.handlers.ey.api_token = "YOUR_EY_API_TOKEN"
21
+ config.handlers.ey.apps = {
22
+ "my_app_name_for_lita" => {
23
+ "ey_name" => "my_app_name_at_ey",
24
+ "app_dir" => "/data/myapp/current",
25
+ "envs" => {
26
+ "test" => {
27
+ ey_name: "my_app_testing",
28
+ auth_group: "devs",
29
+ default_branch: "develop",
30
+ app_url: "test.myapp.com",
31
+ db_name: "db_name",
32
+ db_host: "db.hostname.com",
33
+ db_user: "db_user",
34
+ db_password: "db_password"
35
+ },
36
+ "stage" => {
37
+ ey_name: "my_app_staging",
38
+ auth_group: "testers",
39
+ default_branch: "stage"
40
+ app_url: "stage.myapp.com",
41
+ db_name: "db_name",
42
+ db_host: "db.hostname.com",
43
+ db_user: "db_user",
44
+ db_password: "db_password"
45
+ },
46
+ "production" => {
47
+ ey_name: "my_app_production",
48
+ auth_group: "devops",
49
+ default_branch: "master"
50
+ app_url: "www.myapp.com",
51
+ db_name: "db_name",
52
+ db_host: "db.hostname.com",
53
+ db_user: "db_user",
54
+ db_password: "db_password"
55
+ }
56
+ }
57
+ }
58
+ }
59
+ ```
60
+
61
+ ## Usage
62
+
63
+ ```
64
+ You: @Lita ey dbdump <app> <env>
65
+ ```
66
+
67
+ ## See also
68
+
69
+ [lita-ey-info](http://github.com/carlosparamio/lita-ey-info)
70
+ [lita-ey-deploy](http://github.com/carlosparamio/lita-ey-deploy)
71
+
72
+ ## License
73
+
74
+ [MIT](http://opensource.org/licenses/MIT)
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,78 @@
1
+ module Lita
2
+ module Handlers
3
+ class EyTools < EyBase
4
+
5
+ route(/ey dbdump (\w*) (\w*)/i, :dump_database, command: true, help: {
6
+ "ey dbdump <app> <env>" => "Dumps database."
7
+ })
8
+
9
+ def dump_database(response)
10
+ app = response.matches[0][0]
11
+ env = response.matches[0][1]
12
+
13
+ do_if_can_access(response, app, env) do
14
+ response.reply "Doing db dump..."
15
+
16
+ dump_filename = "dbdump_#{Time.now.strftime('%d%m%H%M%S')}.sql"
17
+ master_hostname = master_hostname_for(app, env)
18
+ app_dir = app_dir_for(app)
19
+ db_name = db_name_for(app, env)
20
+ db_host = db_host_for(app, env)
21
+ db_user = db_user_for(app, env)
22
+ db_password = db_password_for(app, env)
23
+
24
+ # Dump DB
25
+ `#{ssh_cmd} #{master_hostname} 'mysqldump --opt --host=#{db_host} --user=#{db_user} --password=#{db_password} #{db_name} > #{dump_filename}'`
26
+
27
+ # Encrypt DB dump
28
+ dump_password = rand(36**8).to_s(36)
29
+ `#{ssh_cmd} #{master_hostname} 'tar cvzf - #{dump_filename} | openssl des3 -salt -k #{dump_password} | dd of=#{dump_filename}.crypt'`
30
+
31
+ # Move DB dump
32
+ `#{ssh_cmd} #{master_hostname} 'rm #{dump_filename} && mv #{dump_filename}.crypt #{app_dir_for(app)}/public'`
33
+
34
+ output = "Dump completed. Download URL: #{app_url_for(app, env)}/#{dump_filename}.crypt\n"
35
+ output += "Decrypt it with 'dd if=#{dump_filename}.crypt | openssl des3 -d -k #{dump_password} | tar xvzf - '"
36
+ response.reply output
37
+ end
38
+ end
39
+
40
+ private
41
+
42
+ def ssh_cmd
43
+ "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
44
+ end
45
+
46
+ def app_dir_for(app)
47
+ config.apps[app]["app_dir"]
48
+ end
49
+
50
+ def master_hostname_for(app, env)
51
+ `bundle exec ey servers -uS --environment=#{ey_env(app, env)} --api-token=#{config.api_token}`.split('\n')[0].chop
52
+ end
53
+
54
+ def app_url_for(app, env)
55
+ config.apps[app]["envs"][env]["app_url"]
56
+ end
57
+
58
+ def db_name_for(app, env)
59
+ config.apps[app]["envs"][env]["db_name"]
60
+ end
61
+
62
+ def db_host_for(app, env)
63
+ config.apps[app]["envs"][env]["db_host"]
64
+ end
65
+
66
+ def db_user_for(app, env)
67
+ config.apps[app]["envs"][env]["db_user"]
68
+ end
69
+
70
+ def db_password_for(app, env)
71
+ config.apps[app]["envs"][env]["db_password"]
72
+ end
73
+
74
+ end
75
+
76
+ Lita.register_handler(EyTools)
77
+ end
78
+ end
@@ -0,0 +1,3 @@
1
+ require "lita"
2
+ require "lita-ey-base"
3
+ require "lita/handlers/ey_tools"
@@ -0,0 +1,26 @@
1
+ Gem::Specification.new do |spec|
2
+ spec.name = "lita-ey-tools"
3
+ spec.version = "0.0.1"
4
+ spec.authors = ["Carlos Paramio"]
5
+ spec.email = ["hola@carlosparamio.com"]
6
+ spec.description = %q{A Lita handler with some EY tools.}
7
+ spec.summary = %q{A Lita handler with some EY tools.}
8
+ spec.homepage = "https://github.com/carlosparamio/lita-ey-tools"
9
+ spec.metadata = { "lita_plugin_type" => "handler" }
10
+
11
+ spec.files = `git ls-files`.split($/)
12
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
13
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
14
+ spec.require_paths = ["lib"]
15
+
16
+ spec.add_runtime_dependency "lita", ">= 3.2.0"
17
+
18
+ spec.add_dependency "engineyard"
19
+ spec.add_dependency "lita-ey-base"
20
+
21
+ spec.add_development_dependency "bundler"
22
+ spec.add_development_dependency "coveralls"
23
+ spec.add_development_dependency "rake"
24
+ spec.add_development_dependency "rspec", ">= 3.0.0"
25
+ spec.add_development_dependency "simplecov"
26
+ end
@@ -0,0 +1,5 @@
1
+ require "spec_helper"
2
+
3
+ describe Lita::Handlers::EyTools, lita_handler: true do
4
+ it { routes_command("ey dbdump appname envname").to(:dump_database) }
5
+ end
@@ -0,0 +1,11 @@
1
+ require "coveralls"
2
+ require "simplecov"
3
+
4
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
5
+ SimpleCov::Formatter::HTMLFormatter,
6
+ Coveralls::SimpleCov::Formatter
7
+ ]
8
+ SimpleCov.start { add_filter "/spec/" }
9
+
10
+ require "lita-ey-tools"
11
+ require "lita/rspec"
metadata ADDED
@@ -0,0 +1,171 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: lita-ey-tools
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Carlos Paramio
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-06-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: lita
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 3.2.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 3.2.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: engineyard
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: lita-ey-base
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: coveralls
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rake
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rspec
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '>='
102
+ - !ruby/object:Gem::Version
103
+ version: 3.0.0
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '>='
109
+ - !ruby/object:Gem::Version
110
+ version: 3.0.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: simplecov
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '>='
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: A Lita handler with some EY tools.
126
+ email:
127
+ - hola@carlosparamio.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - .gitignore
133
+ - .rspec
134
+ - .travis.yml
135
+ - Gemfile
136
+ - Gemfile.lock
137
+ - LICENSE
138
+ - README.md
139
+ - Rakefile
140
+ - lib/lita-ey-tools.rb
141
+ - lib/lita/handlers/ey_tools.rb
142
+ - lita-ey-tools.gemspec
143
+ - spec/lita/handlers/ey_tools_spec.rb
144
+ - spec/spec_helper.rb
145
+ homepage: https://github.com/carlosparamio/lita-ey-tools
146
+ licenses: []
147
+ metadata:
148
+ lita_plugin_type: handler
149
+ post_install_message:
150
+ rdoc_options: []
151
+ require_paths:
152
+ - lib
153
+ required_ruby_version: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ required_rubygems_version: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - '>='
161
+ - !ruby/object:Gem::Version
162
+ version: '0'
163
+ requirements: []
164
+ rubyforge_project:
165
+ rubygems_version: 2.1.11
166
+ signing_key:
167
+ specification_version: 4
168
+ summary: A Lita handler with some EY tools.
169
+ test_files:
170
+ - spec/lita/handlers/ey_tools_spec.rb
171
+ - spec/spec_helper.rb