mysql_max_value 1.0.0
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 +7 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +34 -0
- data/lib/mysql_max_value.rb +35 -0
- data/test/mysql_max_value_test.rb +53 -0
- data/test/test_helper.rb +20 -0
- metadata +79 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 443975f917d790c8497e00196231f5e50c37d552
|
4
|
+
data.tar.gz: ff1c8959cce8df68b55cf1ccd8da866ac03d883b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 51ca1193019be8b584388a1b43675bb1f6a0be0212d160bf7a3fb609c5ab7acf75479f57555aa94392dba84ab75c96ad749024b10447ed6aa84581dda2819cf8
|
7
|
+
data.tar.gz: 2e61dce6155b5f9dfbe44b9b550e7238ef093508919fceb2185b7f6fe96798e230f353b14ec27c91c0dca1245fd549c6adb1b90e08c17d657d93af8412467224
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2015 koshikawa
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'MysqlMaxValue'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
|
21
|
+
|
22
|
+
Bundler::GemHelper.install_tasks
|
23
|
+
|
24
|
+
require 'rake/testtask'
|
25
|
+
|
26
|
+
Rake::TestTask.new(:test) do |t|
|
27
|
+
t.libs << 'lib'
|
28
|
+
t.libs << 'test'
|
29
|
+
t.pattern = 'test/**/*_test.rb'
|
30
|
+
t.verbose = false
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
task default: :test
|
@@ -0,0 +1,35 @@
|
|
1
|
+
class MysqlMaxValue
|
2
|
+
VERSION = "1.0.0"
|
3
|
+
|
4
|
+
TYPES = {
|
5
|
+
bigint_unsigned: 0,
|
6
|
+
int_unsigned: 32,
|
7
|
+
mediumint_unsigned: 40,
|
8
|
+
smallint_unsigned: 48,
|
9
|
+
tinyint_unsigned: 56,
|
10
|
+
bigint_signed: 1,
|
11
|
+
int_signed: 33,
|
12
|
+
mediumint_signed: 41,
|
13
|
+
smallint_signed: 49,
|
14
|
+
tinyint_signed: 57
|
15
|
+
}
|
16
|
+
|
17
|
+
TYPES.keys.map do |type|
|
18
|
+
class_variable_set("@@#{type}", nil)
|
19
|
+
end
|
20
|
+
|
21
|
+
class << self
|
22
|
+
def method_missing(name)
|
23
|
+
if TYPES.keys.include? name
|
24
|
+
class_variable_get("@@#{name}".to_sym) || class_variable_set("@@#{name}".to_sym, max_value(TYPES[name]))
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def max_value(shift_bit)
|
31
|
+
ActiveRecord::Base.connection.execute("SELECT ~0 >> #{shift_bit}").first[0]
|
32
|
+
rescue
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class MysqlMaxValueTest < ActiveSupport::TestCase
|
4
|
+
def test_big_unsigned
|
5
|
+
assert_kind_of Bignum,
|
6
|
+
MysqlMaxValue.bigint_unsigned
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_int_unsigned
|
10
|
+
assert_kind_of Fixnum,
|
11
|
+
MysqlMaxValue.int_unsigned
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_mediumint_unsigned
|
15
|
+
assert_kind_of Fixnum,
|
16
|
+
MysqlMaxValue.mediumint_unsigned
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_smallint_unsigned
|
20
|
+
assert_kind_of Fixnum,
|
21
|
+
MysqlMaxValue.smallint_unsigned
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_tinyint_unsigned
|
25
|
+
assert_kind_of Fixnum,
|
26
|
+
MysqlMaxValue.tinyint_unsigned
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_big_signed
|
30
|
+
assert_kind_of Bignum,
|
31
|
+
MysqlMaxValue.bigint_signed
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_int_signed
|
35
|
+
assert_kind_of Fixnum,
|
36
|
+
MysqlMaxValue.int_signed
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_mediumint_signed
|
40
|
+
assert_kind_of Fixnum,
|
41
|
+
MysqlMaxValue.mediumint_signed
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_smallint_signed
|
45
|
+
assert_kind_of Fixnum,
|
46
|
+
MysqlMaxValue.smallint_signed
|
47
|
+
end
|
48
|
+
|
49
|
+
def test_tinyint_signed
|
50
|
+
assert_kind_of Fixnum,
|
51
|
+
MysqlMaxValue.tinyint_signed
|
52
|
+
end
|
53
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# Configure Rails Environment
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
|
4
|
+
require File.expand_path("../../spec/dummy/config/environment.rb", __FILE__)
|
5
|
+
ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../spec/dummy/db/migrate", __FILE__)]
|
6
|
+
require "rails/test_help"
|
7
|
+
|
8
|
+
# Filter out Minitest backtrace while allowing backtrace from other libraries
|
9
|
+
# to be shown.
|
10
|
+
Minitest.backtrace_filter = Minitest::BacktraceFilter.new
|
11
|
+
|
12
|
+
# Load support files
|
13
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
14
|
+
|
15
|
+
# Load fixtures from the engine
|
16
|
+
if ActiveSupport::TestCase.respond_to?(:fixture_path=)
|
17
|
+
ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
|
18
|
+
ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path
|
19
|
+
ActiveSupport::TestCase.fixtures :all
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: mysql_max_value
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- ppworks
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-08-31 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '4.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '4.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: mysql2
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.3.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.3.0
|
41
|
+
description: Provide MySQL max values like integer max.
|
42
|
+
email:
|
43
|
+
- koshikawa@ppworks.jp
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- MIT-LICENSE
|
49
|
+
- Rakefile
|
50
|
+
- lib/mysql_max_value.rb
|
51
|
+
- test/mysql_max_value_test.rb
|
52
|
+
- test/test_helper.rb
|
53
|
+
homepage: https://github.com/ppworks/mysql_max_value
|
54
|
+
licenses:
|
55
|
+
- MIT
|
56
|
+
metadata: {}
|
57
|
+
post_install_message:
|
58
|
+
rdoc_options: []
|
59
|
+
require_paths:
|
60
|
+
- lib
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
requirements: []
|
72
|
+
rubyforge_project:
|
73
|
+
rubygems_version: 2.4.5.1
|
74
|
+
signing_key:
|
75
|
+
specification_version: 4
|
76
|
+
summary: Provide MySQL max values.
|
77
|
+
test_files:
|
78
|
+
- test/mysql_max_value_test.rb
|
79
|
+
- test/test_helper.rb
|