mysql_framework 0.0.1 → 0.0.2
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/mysql_framework/connector.rb +3 -3
 - data/lib/mysql_framework/version.rb +3 -1
 - data/spec/lib/mysql_framework/connector_spec.rb +6 -1
 - data/spec/spec_helper.rb +27 -20
 - metadata +3 -3
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 1464cd256c24c61d853fbcfe1fdb4d784fe4ec4ee4453c327502aceed7912f83
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 9e4d0f30d3aba04788c8d12eeffb81cd3d8973f7dcffc38ea1abb6fd683e0be7
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: e5ed2afe2631ff18469da0665dad07bb2e94ca7154548940297870c50a726de8261dfc66a0e6be65fb2411b00246a087d300d65af4bceff78094effe0a5cc840
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 4e3f86db50a7a555b273776da36d1de80bd6872df1181a889e007c4e0364d981b1f68f6d636e44bd3c0068a89f30bc728eaf9d080b9ddf9e11bb90f4ad186f2c
         
     | 
| 
         @@ -24,11 +24,11 @@ module MysqlFramework 
     | 
|
| 
       24 
24 
     | 
    
         
             
                end
         
     | 
| 
       25 
25 
     | 
    
         | 
| 
       26 
26 
     | 
    
         
             
                # This method is called to use a client from the connection pool.
         
     | 
| 
       27 
     | 
    
         
            -
                def with_client
         
     | 
| 
       28 
     | 
    
         
            -
                  client = check_out
         
     | 
| 
      
 27 
     | 
    
         
            +
                def with_client(provided = nil)
         
     | 
| 
      
 28 
     | 
    
         
            +
                  client = provided || check_out
         
     | 
| 
       29 
29 
     | 
    
         
             
                  yield client
         
     | 
| 
       30 
30 
     | 
    
         
             
                ensure
         
     | 
| 
       31 
     | 
    
         
            -
                  check_in(client) unless  
     | 
| 
      
 31 
     | 
    
         
            +
                  check_in(client) unless provided
         
     | 
| 
       32 
32 
     | 
    
         
             
                end
         
     | 
| 
       33 
33 
     | 
    
         | 
| 
       34 
34 
     | 
    
         
             
                # This method is called to execute a prepared statement
         
     | 
| 
         @@ -66,7 +66,12 @@ describe MysqlFramework::Connector do 
     | 
|
| 
       66 
66 
     | 
    
         
             
              end
         
     | 
| 
       67 
67 
     | 
    
         | 
| 
       68 
68 
     | 
    
         
             
              describe '#with_client' do
         
     | 
| 
       69 
     | 
    
         
            -
                it ' 
     | 
| 
      
 69 
     | 
    
         
            +
                it 'uses the client that is provided, if passed one' do
         
     | 
| 
      
 70 
     | 
    
         
            +
                  expect(subject).not_to receive(:check_out)
         
     | 
| 
      
 71 
     | 
    
         
            +
                  expect { |b| subject.with_client(client, &b) }.to yield_with_args(client)
         
     | 
| 
      
 72 
     | 
    
         
            +
                end
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
                it 'obtains a client from the pool to use, if no client is provided' do
         
     | 
| 
       70 
75 
     | 
    
         
             
                  allow(subject).to receive(:check_out).and_return(client)
         
     | 
| 
       71 
76 
     | 
    
         
             
                  expect { |b| subject.with_client(&b) }.to yield_with_args(client)
         
     | 
| 
       72 
77 
     | 
    
         
             
                end
         
     | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    | 
         @@ -1,15 +1,18 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
       1 
3 
     | 
    
         
             
            require 'simplecov'
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
       2 
5 
     | 
    
         
             
            SimpleCov.start do
         
     | 
| 
       3 
6 
     | 
    
         
             
              add_filter 'spec/'
         
     | 
| 
       4 
7 
     | 
    
         
             
            end
         
     | 
| 
       5 
8 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
            ENV['MYSQL_DATABASE'] 
     | 
| 
       7 
     | 
    
         
            -
            ENV['MYSQL_HOST'] 
     | 
| 
      
 9 
     | 
    
         
            +
            ENV['MYSQL_DATABASE'] ||= 'test_database'
         
     | 
| 
      
 10 
     | 
    
         
            +
            ENV['MYSQL_HOST'] ||= '127.0.0.1'
         
     | 
| 
       8 
11 
     | 
    
         
             
            ENV['MYSQL_PARTITIONS'] ||= '5'
         
     | 
| 
       9 
     | 
    
         
            -
            ENV['MYSQL_PASSWORD'] 
     | 
| 
       10 
     | 
    
         
            -
            ENV['MYSQL_PORT'] 
     | 
| 
       11 
     | 
    
         
            -
            ENV['MYSQL_USERNAME'] 
     | 
| 
       12 
     | 
    
         
            -
            ENV['REDIS_URL'] 
     | 
| 
      
 12 
     | 
    
         
            +
            ENV['MYSQL_PASSWORD'] ||= ''
         
     | 
| 
      
 13 
     | 
    
         
            +
            ENV['MYSQL_PORT'] ||= '3306'
         
     | 
| 
      
 14 
     | 
    
         
            +
            ENV['MYSQL_USERNAME'] ||= 'root'
         
     | 
| 
      
 15 
     | 
    
         
            +
            ENV['REDIS_URL'] ||= 'redis://127.0.0.1:6379'
         
     | 
| 
       13 
16 
     | 
    
         | 
| 
       14 
17 
     | 
    
         
             
            require 'bundler'
         
     | 
| 
       15 
18 
     | 
    
         
             
            require 'mysql_framework'
         
     | 
| 
         @@ -22,6 +25,8 @@ require_relative 'support/tables/test' 
     | 
|
| 
       22 
25 
     | 
    
         
             
            require_relative 'support/tables/demo'
         
     | 
| 
       23 
26 
     | 
    
         | 
| 
       24 
27 
     | 
    
         
             
            RSpec.configure do |config|
         
     | 
| 
      
 28 
     | 
    
         
            +
              config.before(:each) { MysqlFramework.logger.level = Logger::ERROR }
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
       25 
30 
     | 
    
         
             
              config.expect_with :rspec do |expectations|
         
     | 
| 
       26 
31 
     | 
    
         
             
                expectations.include_chain_clauses_in_custom_matcher_descriptions = true
         
     | 
| 
       27 
32 
     | 
    
         
             
              end
         
     | 
| 
         @@ -31,22 +36,24 @@ RSpec.configure do |config| 
     | 
|
| 
       31 
36 
     | 
    
         
             
              end
         
     | 
| 
       32 
37 
     | 
    
         
             
            end
         
     | 
| 
       33 
38 
     | 
    
         | 
| 
       34 
     | 
    
         
            -
            client = Mysql2::Client.new( 
     | 
| 
       35 
     | 
    
         
            -
              host: 
     | 
| 
       36 
     | 
    
         
            -
              port: 
     | 
| 
       37 
     | 
    
         
            -
              username: 
     | 
| 
       38 
     | 
    
         
            -
              password: 
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
      
 39 
     | 
    
         
            +
            client = Mysql2::Client.new(
         
     | 
| 
      
 40 
     | 
    
         
            +
              host: ENV.fetch('MYSQL_HOST'),
         
     | 
| 
      
 41 
     | 
    
         
            +
              port: ENV.fetch('MYSQL_PORT'),
         
     | 
| 
      
 42 
     | 
    
         
            +
              username: ENV.fetch('MYSQL_USERNAME'),
         
     | 
| 
      
 43 
     | 
    
         
            +
              password: ENV.fetch('MYSQL_PASSWORD')
         
     | 
| 
      
 44 
     | 
    
         
            +
            )
         
     | 
| 
       40 
45 
     | 
    
         
             
            client.query("DROP DATABASE IF EXISTS `#{ENV.fetch('MYSQL_DATABASE')}`;")
         
     | 
| 
       41 
46 
     | 
    
         
             
            client.query("CREATE DATABASE `#{ENV.fetch('MYSQL_DATABASE')}`;")
         
     | 
| 
       42 
47 
     | 
    
         | 
| 
       43 
48 
     | 
    
         
             
            connector = MysqlFramework::Connector.new
         
     | 
| 
       44 
49 
     | 
    
         
             
            connector.query("DROP TABLE IF EXISTS `#{ENV.fetch('MYSQL_DATABASE')}`.`gems`")
         
     | 
| 
       45 
     | 
    
         
            -
            connector.query( 
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
      
 50 
     | 
    
         
            +
            connector.query(<<~SQL)
         
     | 
| 
      
 51 
     | 
    
         
            +
              CREATE TABLE `#{ENV.fetch('MYSQL_DATABASE')}`.`gems` (
         
     | 
| 
      
 52 
     | 
    
         
            +
                `id` CHAR(36) NOT NULL,
         
     | 
| 
      
 53 
     | 
    
         
            +
                `name` VARCHAR(255) NULL,
         
     | 
| 
      
 54 
     | 
    
         
            +
                `author` VARCHAR(255) NULL,
         
     | 
| 
      
 55 
     | 
    
         
            +
                `created_at` DATETIME,
         
     | 
| 
      
 56 
     | 
    
         
            +
                `updated_at` DATETIME,
         
     | 
| 
      
 57 
     | 
    
         
            +
                PRIMARY KEY (`id`)
         
     | 
| 
      
 58 
     | 
    
         
            +
              )
         
     | 
| 
      
 59 
     | 
    
         
            +
            SQL
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: mysql_framework
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.0.2
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Sage
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: exe
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2018-07- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2018-07-12 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: bundler
         
     | 
| 
         @@ -150,7 +150,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       150 
150 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       151 
151 
     | 
    
         
             
            requirements: []
         
     | 
| 
       152 
152 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       153 
     | 
    
         
            -
            rubygems_version: 2.7. 
     | 
| 
      
 153 
     | 
    
         
            +
            rubygems_version: 2.7.7
         
     | 
| 
       154 
154 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       155 
155 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       156 
156 
     | 
    
         
             
            summary: A lightweight framework to provide managers for working with MySQL.
         
     |