infrataster-plugin-mysql 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/infrataster-plugin-mysql.gemspec +1 -1
- data/lib/infrataster/contexts/mysql_query_context.rb +9 -6
- data/spec/mysql_query_spec.rb +9 -0
- data/spec/spec_helper.rb +7 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 112ae7613fec3a4d9e4a20d0f50fd2da8ce2664c
|
4
|
+
data.tar.gz: f6cf21d0bf9311a9ebc05ff4b880df054e688bce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13db7b39805a7c4ee747799bb9ad9d440d1950c172fa2bc6d35d5d84b755e92e34ca9678b848a86325606e7983e95faa58bcde830e2eb93f075ed87a4348b4e3
|
7
|
+
data.tar.gz: 28ed99ff2ac6789c1044507024b60beb73cb168d2881ece194d5c510d8d56912c87caeb7a63f265926d1a508ae088572428a8f4b9a7ed69131775bdae4fb53d3
|
data/README.md
CHANGED
@@ -29,12 +29,12 @@ describe server(:db) do
|
|
29
29
|
end
|
30
30
|
```
|
31
31
|
|
32
|
-
You can specify username and
|
32
|
+
You can specify username, password and database by options passed to `Infrataster::Server.define`:
|
33
33
|
|
34
34
|
```ruby
|
35
35
|
Infrataster::Server.define(
|
36
36
|
# ...
|
37
|
-
mysql: {user: 'app', password: 'app'}
|
37
|
+
mysql: {user: 'app', password: 'app', database: 'myapp'}
|
38
38
|
)
|
39
39
|
```
|
40
40
|
|
@@ -11,12 +11,15 @@ module Infrataster
|
|
11
11
|
end
|
12
12
|
|
13
13
|
server.forward_port(options[:port]) do |address, new_port|
|
14
|
-
|
15
|
-
host: address,
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
14
|
+
mysql_options = {
|
15
|
+
host: address, port: new_port,
|
16
|
+
username: options[:user], password: options[:password]
|
17
|
+
}
|
18
|
+
if options.key?(:database)
|
19
|
+
mysql_options[:database] = options[:database]
|
20
|
+
end
|
21
|
+
client = Mysql2::Client.new(mysql_options)
|
22
|
+
|
20
23
|
client.xquery(resource.query, *resource.params)
|
21
24
|
end
|
22
25
|
end
|
data/spec/mysql_query_spec.rb
CHANGED
@@ -17,3 +17,12 @@ describe server(:db) do
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
+
describe server(:db_database_name) do
|
21
|
+
describe mysql_query('SELECT User, Host FROM user WHERE User=? AND Host=?', 'app', '%') do
|
22
|
+
it 'binds arguments to query' do
|
23
|
+
row = results.first
|
24
|
+
expect(row['User']).to eq 'app'
|
25
|
+
expect(row['Host']).to eq '%'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -8,6 +8,13 @@ Infrataster::Server.define(
|
|
8
8
|
mysql: {user: 'app', password: 'app'},
|
9
9
|
)
|
10
10
|
|
11
|
+
Infrataster::Server.define(
|
12
|
+
:db_database_name,
|
13
|
+
'192.168.44.20',
|
14
|
+
vagrant: true,
|
15
|
+
mysql: {user: 'app', password: 'app', database: 'mysql'},
|
16
|
+
)
|
17
|
+
|
11
18
|
RSpec.configure do |config|
|
12
19
|
config.treat_symbols_as_metadata_keys_with_true_values = true
|
13
20
|
config.run_all_when_everything_filtered = true
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: infrataster-plugin-mysql
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryota Arai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: infrataster
|
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
125
|
version: '0'
|
126
126
|
requirements: []
|
127
127
|
rubyforge_project:
|
128
|
-
rubygems_version: 2.
|
128
|
+
rubygems_version: 2.6.8
|
129
129
|
signing_key:
|
130
130
|
specification_version: 4
|
131
131
|
summary: MySQL plugin for Infrataster
|