ovirt_metrics 3.0.0 → 3.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. checksums.yaml +4 -4
  2. data/lib/active_record/connection_adapters/ovirt_postgresql_adapter.rb +30 -0
  3. data/lib/ovirt_metrics.rb +4 -1
  4. data/lib/ovirt_metrics/version.rb +1 -1
  5. metadata +3 -35
  6. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/column.rb +0 -15
  7. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/database_statements.rb +0 -170
  8. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/explain_pretty_printer.rb +0 -42
  9. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid.rb +0 -31
  10. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/array.rb +0 -70
  11. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/bit.rb +0 -52
  12. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/bit_varying.rb +0 -13
  13. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/bytea.rb +0 -15
  14. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/cidr.rb +0 -48
  15. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/date_time.rb +0 -21
  16. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/decimal.rb +0 -13
  17. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/enum.rb +0 -19
  18. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/hstore.rb +0 -59
  19. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/inet.rb +0 -13
  20. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/json.rb +0 -10
  21. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/jsonb.rb +0 -23
  22. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/money.rb +0 -39
  23. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/point.rb +0 -43
  24. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/rails_5_1_point.rb +0 -50
  25. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/range.rb +0 -93
  26. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/specialized_string.rb +0 -15
  27. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/type_map_initializer.rb +0 -109
  28. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/uuid.rb +0 -21
  29. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/vector.rb +0 -26
  30. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/oid/xml.rb +0 -28
  31. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/quoting.rb +0 -116
  32. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/referential_integrity.rb +0 -49
  33. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/schema_definitions.rb +0 -180
  34. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/schema_dumper.rb +0 -47
  35. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/schema_statements.rb +0 -682
  36. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/type_metadata.rb +0 -35
  37. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql/utils.rb +0 -77
  38. data/lib/active_record/connection_adapters/ovirt_legacy_postgresql_adapter.rb +0 -856
@@ -1,52 +0,0 @@
1
- module ActiveRecord
2
- module ConnectionAdapters
3
- module OvirtLegacyPostgreSQL
4
- module OID # :nodoc:
5
- class Bit < Type::Value # :nodoc:
6
- def type
7
- :bit
8
- end
9
-
10
- def cast(value)
11
- if ::String === value
12
- case value
13
- when /^0x/i
14
- value[2..-1].hex.to_s(2) # Hexadecimal notation
15
- else
16
- value # Bit-string notation
17
- end
18
- else
19
- value
20
- end
21
- end
22
-
23
- def serialize(value)
24
- Data.new(super) if value
25
- end
26
-
27
- class Data
28
- def initialize(value)
29
- @value = value
30
- end
31
-
32
- def to_s
33
- value
34
- end
35
-
36
- def binary?
37
- /\A[01]*\Z/ === value
38
- end
39
-
40
- def hex?
41
- /\A[0-9A-F]*\Z/i === value
42
- end
43
-
44
- protected
45
-
46
- attr_reader :value
47
- end
48
- end
49
- end
50
- end
51
- end
52
- end
@@ -1,13 +0,0 @@
1
- module ActiveRecord
2
- module ConnectionAdapters
3
- module OvirtLegacyPostgreSQL
4
- module OID # :nodoc:
5
- class BitVarying < OID::Bit # :nodoc:
6
- def type
7
- :bit_varying
8
- end
9
- end
10
- end
11
- end
12
- end
13
- end
@@ -1,15 +0,0 @@
1
- module ActiveRecord
2
- module ConnectionAdapters
3
- module OvirtLegacyPostgreSQL
4
- module OID # :nodoc:
5
- class Bytea < Type::Binary # :nodoc:
6
- def deserialize(value)
7
- return if value.nil?
8
- return value.to_s if value.is_a?(Type::Binary::Data)
9
- PGconn.unescape_bytea(super)
10
- end
11
- end
12
- end
13
- end
14
- end
15
- end
@@ -1,48 +0,0 @@
1
- require 'ipaddr'
2
-
3
- module ActiveRecord
4
- module ConnectionAdapters
5
- module OvirtLegacyPostgreSQL
6
- module OID # :nodoc:
7
- class Cidr < Type::Value # :nodoc:
8
- def type
9
- :cidr
10
- end
11
-
12
- def type_cast_for_schema(value)
13
- subnet_mask = value.instance_variable_get(:@mask_addr)
14
-
15
- # If the subnet mask is equal to /32, don't output it
16
- if subnet_mask == (2**32 - 1)
17
- "\"#{value}\""
18
- else
19
- "\"#{value}/#{subnet_mask.to_s(2).count('1')}\""
20
- end
21
- end
22
-
23
- def serialize(value)
24
- if IPAddr === value
25
- "#{value}/#{value.instance_variable_get(:@mask_addr).to_s(2).count('1')}"
26
- else
27
- value
28
- end
29
- end
30
-
31
- def cast_value(value)
32
- if value.nil?
33
- nil
34
- elsif String === value
35
- begin
36
- IPAddr.new(value)
37
- rescue ArgumentError
38
- nil
39
- end
40
- else
41
- value
42
- end
43
- end
44
- end
45
- end
46
- end
47
- end
48
- end
@@ -1,21 +0,0 @@
1
- module ActiveRecord
2
- module ConnectionAdapters
3
- module OvirtLegacyPostgreSQL
4
- module OID # :nodoc:
5
- class DateTime < Type::DateTime # :nodoc:
6
- def cast_value(value)
7
- case value
8
- when 'infinity' then ::Float::INFINITY
9
- when '-infinity' then -::Float::INFINITY
10
- when / BC$/
11
- astronomical_year = format("%04d", -value[/^\d+/].to_i + 1)
12
- super(value.sub(/ BC$/, "").sub(/^\d+/, astronomical_year))
13
- else
14
- super
15
- end
16
- end
17
- end
18
- end
19
- end
20
- end
21
- end
@@ -1,13 +0,0 @@
1
- module ActiveRecord
2
- module ConnectionAdapters
3
- module OvirtLegacyPostgreSQL
4
- module OID # :nodoc:
5
- class Decimal < Type::Decimal # :nodoc:
6
- def infinity(options = {})
7
- BigDecimal.new("Infinity") * (options[:negative] ? -1 : 1)
8
- end
9
- end
10
- end
11
- end
12
- end
13
- end
@@ -1,19 +0,0 @@
1
- module ActiveRecord
2
- module ConnectionAdapters
3
- module OvirtLegacyPostgreSQL
4
- module OID # :nodoc:
5
- class Enum < Type::Value # :nodoc:
6
- def type
7
- :enum
8
- end
9
-
10
- private
11
-
12
- def cast_value(value)
13
- value.to_s
14
- end
15
- end
16
- end
17
- end
18
- end
19
- end
@@ -1,59 +0,0 @@
1
- module ActiveRecord
2
- module ConnectionAdapters
3
- module OvirtLegacyPostgreSQL
4
- module OID # :nodoc:
5
- class Hstore < Type::Value # :nodoc:
6
- include Type::Helpers::Mutable
7
-
8
- def type
9
- :hstore
10
- end
11
-
12
- def deserialize(value)
13
- if value.is_a?(::String)
14
- ::Hash[value.scan(HstorePair).map { |k, v|
15
- v = v.upcase == 'NULL' ? nil : v.gsub(/\A"(.*)"\Z/m,'\1').gsub(/\\(.)/, '\1')
16
- k = k.gsub(/\A"(.*)"\Z/m,'\1').gsub(/\\(.)/, '\1')
17
- [k, v]
18
- }]
19
- else
20
- value
21
- end
22
- end
23
-
24
- def serialize(value)
25
- if value.is_a?(::Hash)
26
- value.map { |k, v| "#{escape_hstore(k)}=>#{escape_hstore(v)}" }.join(', ')
27
- else
28
- value
29
- end
30
- end
31
-
32
- def accessor
33
- ActiveRecord::Store::StringKeyedHashAccessor
34
- end
35
-
36
- private
37
-
38
- HstorePair = begin
39
- quoted_string = /"[^"\\]*(?:\\.[^"\\]*)*"/
40
- unquoted_string = /(?:\\.|[^\s,])[^\s=,\\]*(?:\\.[^\s=,\\]*|=[^,>])*/
41
- /(#{quoted_string}|#{unquoted_string})\s*=>\s*(#{quoted_string}|#{unquoted_string})/
42
- end
43
-
44
- def escape_hstore(value)
45
- if value.nil?
46
- 'NULL'
47
- else
48
- if value == ""
49
- '""'
50
- else
51
- '"%s"' % value.to_s.gsub(/(["\\])/, '\\\\\1')
52
- end
53
- end
54
- end
55
- end
56
- end
57
- end
58
- end
59
- end
@@ -1,13 +0,0 @@
1
- module ActiveRecord
2
- module ConnectionAdapters
3
- module OvirtLegacyPostgreSQL
4
- module OID # :nodoc:
5
- class Inet < Cidr # :nodoc:
6
- def type
7
- :inet
8
- end
9
- end
10
- end
11
- end
12
- end
13
- end
@@ -1,10 +0,0 @@
1
- module ActiveRecord
2
- module ConnectionAdapters
3
- module OvirtLegacyPostgreSQL
4
- module OID # :nodoc:
5
- class Json < Type::Internal::AbstractJson
6
- end
7
- end
8
- end
9
- end
10
- end
@@ -1,23 +0,0 @@
1
- module ActiveRecord
2
- module ConnectionAdapters
3
- module OvirtLegacyPostgreSQL
4
- module OID # :nodoc:
5
- class Jsonb < Json # :nodoc:
6
- def type
7
- :jsonb
8
- end
9
-
10
- def changed_in_place?(raw_old_value, new_value)
11
- # Postgres does not preserve insignificant whitespaces when
12
- # round-tripping jsonb columns. This causes some false positives for
13
- # the comparison here. Therefore, we need to parse and re-dump the
14
- # raw value here to ensure the insignificant whitespaces are
15
- # consistent with our encoder's output.
16
- raw_old_value = serialize(deserialize(raw_old_value))
17
- super(raw_old_value, new_value)
18
- end
19
- end
20
- end
21
- end
22
- end
23
- end
@@ -1,39 +0,0 @@
1
- module ActiveRecord
2
- module ConnectionAdapters
3
- module OvirtLegacyPostgreSQL
4
- module OID # :nodoc:
5
- class Money < Type::Decimal # :nodoc:
6
- def type
7
- :money
8
- end
9
-
10
- def scale
11
- 2
12
- end
13
-
14
- def cast_value(value)
15
- return value unless ::String === value
16
-
17
- # Because money output is formatted according to the locale, there are two
18
- # cases to consider (note the decimal separators):
19
- # (1) $12,345,678.12
20
- # (2) $12.345.678,12
21
- # Negative values are represented as follows:
22
- # (3) -$2.55
23
- # (4) ($2.55)
24
-
25
- value.sub!(/^\((.+)\)$/, '-\1') # (4)
26
- case value
27
- when /^-?\D+[\d,]+\.\d{2}$/ # (1)
28
- value.gsub!(/[^-\d.]/, '')
29
- when /^-?\D+[\d.]+,\d{2}$/ # (2)
30
- value.gsub!(/[^-\d,]/, '').sub!(/,/, '.')
31
- end
32
-
33
- super(value)
34
- end
35
- end
36
- end
37
- end
38
- end
39
- end
@@ -1,43 +0,0 @@
1
- module ActiveRecord
2
- module ConnectionAdapters
3
- module OvirtLegacyPostgreSQL
4
- module OID # :nodoc:
5
- class Point < Type::Value # :nodoc:
6
- include Type::Helpers::Mutable
7
-
8
- def type
9
- :point
10
- end
11
-
12
- def cast(value)
13
- case value
14
- when ::String
15
- if value[0] == '(' && value[-1] == ')'
16
- value = value[1...-1]
17
- end
18
- cast(value.split(','))
19
- when ::Array
20
- value.map { |v| Float(v) }
21
- else
22
- value
23
- end
24
- end
25
-
26
- def serialize(value)
27
- if value.is_a?(::Array)
28
- "(#{number_for_point(value[0])},#{number_for_point(value[1])})"
29
- else
30
- super
31
- end
32
- end
33
-
34
- private
35
-
36
- def number_for_point(number)
37
- number.to_s.gsub(/\.0$/, '')
38
- end
39
- end
40
- end
41
- end
42
- end
43
- end
@@ -1,50 +0,0 @@
1
- module ActiveRecord
2
- Point = Struct.new(:x, :y)
3
-
4
- module ConnectionAdapters
5
- module OvirtLegacyPostgreSQL
6
- module OID # :nodoc:
7
- class Rails51Point < Type::Value # :nodoc:
8
- include Type::Helpers::Mutable
9
-
10
- def type
11
- :point
12
- end
13
-
14
- def cast(value)
15
- case value
16
- when ::String
17
- if value[0] == '(' && value[-1] == ')'
18
- value = value[1...-1]
19
- end
20
- x, y = value.split(",")
21
- build_point(x, y)
22
- when ::Array
23
- build_point(*value)
24
- else
25
- value
26
- end
27
- end
28
-
29
- def serialize(value)
30
- if value.is_a?(ActiveRecord::Point)
31
- "(#{number_for_point(value.x)},#{number_for_point(value.y)})"
32
- else
33
- super
34
- end
35
- end
36
-
37
- private
38
-
39
- def number_for_point(number)
40
- number.to_s.gsub(/\.0$/, '')
41
- end
42
-
43
- def build_point(x, y)
44
- ActiveRecord::Point.new(Float(x), Float(y))
45
- end
46
- end
47
- end
48
- end
49
- end
50
- end
@@ -1,93 +0,0 @@
1
- require 'active_support/core_ext/string/filters'
2
-
3
- module ActiveRecord
4
- module ConnectionAdapters
5
- module OvirtLegacyPostgreSQL
6
- module OID # :nodoc:
7
- class Range < Type::Value # :nodoc:
8
- attr_reader :subtype, :type
9
- delegate :user_input_in_time_zone, to: :subtype
10
-
11
- def initialize(subtype, type = :range)
12
- @subtype = subtype
13
- @type = type
14
- end
15
-
16
- def type_cast_for_schema(value)
17
- value.inspect.gsub('Infinity', '::Float::INFINITY')
18
- end
19
-
20
- def cast_value(value)
21
- return if value == 'empty'
22
- return value unless value.is_a?(::String)
23
-
24
- extracted = extract_bounds(value)
25
- from = type_cast_single extracted[:from]
26
- to = type_cast_single extracted[:to]
27
-
28
- if !infinity?(from) && extracted[:exclude_start]
29
- raise ArgumentError, "The Ruby Range object does not support excluding the beginning of a Range. (unsupported value: '#{value}')"
30
- end
31
- ::Range.new(from, to, extracted[:exclude_end])
32
- end
33
-
34
- def serialize(value)
35
- if value.is_a?(::Range)
36
- from = type_cast_single_for_database(value.begin)
37
- to = type_cast_single_for_database(value.end)
38
- "[#{from},#{to}#{value.exclude_end? ? ')' : ']'}"
39
- else
40
- super
41
- end
42
- end
43
-
44
- def ==(other)
45
- other.is_a?(Range) &&
46
- other.subtype == subtype &&
47
- other.type == type
48
- end
49
-
50
- def map(value) # :nodoc:
51
- new_begin = yield(value.begin)
52
- new_end = yield(value.end)
53
- ::Range.new(new_begin, new_end, value.exclude_end?)
54
- end
55
-
56
- private
57
-
58
- def type_cast_single(value)
59
- infinity?(value) ? value : @subtype.deserialize(value)
60
- end
61
-
62
- def type_cast_single_for_database(value)
63
- infinity?(value) ? '' : @subtype.serialize(value)
64
- end
65
-
66
- def extract_bounds(value)
67
- from, to = value[1..-2].split(',')
68
- {
69
- from: (value[1] == ',' || from == '-infinity') ? infinity(negative: true) : from,
70
- to: (value[-2] == ',' || to == 'infinity') ? infinity : to,
71
- exclude_start: (value[0] == '('),
72
- exclude_end: (value[-1] == ')')
73
- }
74
- end
75
-
76
- def infinity(negative: false)
77
- if subtype.respond_to?(:infinity)
78
- subtype.infinity(negative: negative)
79
- elsif negative
80
- -::Float::INFINITY
81
- else
82
- ::Float::INFINITY
83
- end
84
- end
85
-
86
- def infinity?(value)
87
- value.respond_to?(:infinite?) && value.infinite?
88
- end
89
- end
90
- end
91
- end
92
- end
93
- end