mack-data_mapper 0.8.2 → 0.8.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/gems/{addressable-2.0.0 → addressable-2.0.1}/lib/addressable/idna.rb +0 -0
- data/lib/gems/{addressable-2.0.0 → addressable-2.0.1}/lib/addressable/uri.rb +62 -21
- data/lib/gems/{addressable-2.0.0 → addressable-2.0.1}/lib/addressable/version.rb +1 -1
- data/lib/gems/addressable-2.0.1/tasks/clobber.rake +2 -0
- data/lib/gems/addressable-2.0.1/tasks/gem.rake +68 -0
- data/lib/gems/addressable-2.0.1/tasks/git.rake +40 -0
- data/lib/gems/addressable-2.0.1/tasks/metrics.rake +22 -0
- data/lib/gems/addressable-2.0.1/tasks/rdoc.rake +29 -0
- data/lib/gems/addressable-2.0.1/tasks/rubyforge.rake +89 -0
- data/lib/gems/addressable-2.0.1/tasks/spec.rake +64 -0
- data/lib/gems/data_objects-0.9.10.1/lib/data_objects.rb +46 -0
- data/lib/gems/data_objects-0.9.10.1/lib/data_objects/command.rb +30 -0
- data/lib/gems/data_objects-0.9.10.1/lib/data_objects/connection.rb +107 -0
- data/lib/gems/data_objects-0.9.10.1/lib/data_objects/field.rb +19 -0
- data/lib/gems/data_objects-0.9.10.1/lib/data_objects/logger.rb +233 -0
- data/lib/gems/data_objects-0.9.10.1/lib/data_objects/quoting.rb +103 -0
- data/lib/gems/data_objects-0.9.10.1/lib/data_objects/reader.rb +22 -0
- data/lib/gems/data_objects-0.9.10.1/lib/data_objects/result.rb +13 -0
- data/lib/gems/data_objects-0.9.10.1/lib/data_objects/transaction.rb +45 -0
- data/lib/gems/data_objects-0.9.10.1/lib/data_objects/uri.rb +34 -0
- data/lib/gems/data_objects-0.9.10.1/lib/data_objects/version.rb +3 -0
- data/lib/gems/{dm-aggregates-0.9.7 → dm-aggregates-0.9.9}/lib/dm-aggregates.rb +1 -1
- data/lib/gems/{dm-aggregates-0.9.7 → dm-aggregates-0.9.9}/lib/dm-aggregates/adapters/data_objects_adapter.rb +0 -0
- data/lib/gems/{dm-aggregates-0.9.7 → dm-aggregates-0.9.9}/lib/dm-aggregates/aggregate_functions.rb +0 -0
- data/lib/gems/{dm-aggregates-0.9.7 → dm-aggregates-0.9.9}/lib/dm-aggregates/collection.rb +4 -0
- data/lib/gems/{dm-aggregates-0.9.7 → dm-aggregates-0.9.9}/lib/dm-aggregates/model.rb +4 -0
- data/lib/gems/{dm-aggregates-0.9.7 → dm-aggregates-0.9.9}/lib/dm-aggregates/repository.rb +0 -0
- data/lib/gems/{dm-aggregates-0.9.7 → dm-aggregates-0.9.9}/lib/dm-aggregates/support/symbol.rb +0 -0
- data/lib/gems/dm-aggregates-0.9.9/lib/dm-aggregates/version.rb +5 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core.rb +5 -5
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/adapters.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/adapters/abstract_adapter.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/adapters/data_objects_adapter.rb +1 -1
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/adapters/in_memory_adapter.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/adapters/mysql_adapter.rb +1 -1
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/adapters/postgres_adapter.rb +1 -1
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/adapters/sqlite3_adapter.rb +1 -1
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/associations.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/associations/many_to_many.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/associations/many_to_one.rb +1 -1
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/associations/one_to_many.rb +3 -6
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/associations/one_to_one.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/associations/relationship.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/associations/relationship_chain.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/auto_migrations.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/collection.rb +26 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/dependency_queue.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/hook.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/identity_map.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/is.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/logger.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/migrations/destructive_migrations.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/migrator.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/model.rb +29 -3
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/naming_conventions.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/property.rb +13 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/property_set.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/query.rb +51 -3
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/repository.rb +8 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/resource.rb +19 -6
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/scope.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/support.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/support/array.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/support/assertions.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/support/errors.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/support/kernel.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/support/symbol.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/transaction.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/type.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/type_map.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/types.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/types/boolean.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/types/discriminator.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/types/object.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/types/paranoid_boolean.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/types/paranoid_datetime.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/types/serial.rb +0 -0
- data/lib/gems/{dm-core-0.9.7 → dm-core-0.9.9}/lib/dm-core/types/text.rb +0 -0
- data/lib/gems/dm-core-0.9.9/lib/dm-core/version.rb +3 -0
- data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/dm-migrations.rb +0 -0
- data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/dm-migrations/version.rb +1 -1
- data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/migration.rb +5 -3
- data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/migration_runner.rb +0 -0
- data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/spec/example/migration_example_group.rb +0 -0
- data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/spec/matchers/migration_matchers.rb +0 -0
- data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/sql.rb +0 -0
- data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/sql/column.rb +0 -0
- data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/sql/mysql.rb +0 -0
- data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/sql/postgresql.rb +0 -0
- data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/sql/sqlite3.rb +0 -0
- data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/sql/table.rb +0 -0
- data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/sql/table_creator.rb +0 -0
- data/lib/gems/{dm-migrations-0.9.7 → dm-migrations-0.9.9}/lib/sql/table_modifier.rb +0 -0
- data/lib/gems/dm-migrations-0.9.9/tasks/db.rb +22 -0
- data/lib/gems/dm-migrations-0.9.9/tasks/install.rb +13 -0
- data/lib/gems/dm-migrations-0.9.9/tasks/spec.rb +25 -0
- data/lib/gems/{dm-observer-0.9.7 → dm-observer-0.9.9}/lib/dm-observer.rb +1 -1
- data/lib/gems/{dm-observer-0.9.7 → dm-observer-0.9.9}/lib/dm-observer/version.rb +1 -1
- data/lib/gems/dm-observer-0.9.9/tasks/install.rb +13 -0
- data/lib/gems/dm-observer-0.9.9/tasks/spec.rb +25 -0
- data/lib/gems/dm-serializer-0.9.9/lib/dm-serializer.rb +4 -0
- data/lib/gems/dm-serializer-0.9.9/lib/dm-serializer/common.rb +24 -0
- data/lib/gems/dm-serializer-0.9.9/lib/dm-serializer/to_csv.rb +35 -0
- data/lib/gems/dm-serializer-0.9.9/lib/dm-serializer/to_json.rb +73 -0
- data/lib/gems/dm-serializer-0.9.9/lib/dm-serializer/to_xml.rb +61 -0
- data/lib/gems/dm-serializer-0.9.9/lib/dm-serializer/to_yaml.rb +48 -0
- data/lib/gems/{dm-serializer-0.9.7 → dm-serializer-0.9.9}/lib/dm-serializer/version.rb +1 -1
- data/lib/gems/dm-serializer-0.9.9/lib/dm-serializer/xml_serializers.rb +17 -0
- data/lib/gems/dm-serializer-0.9.9/lib/dm-serializer/xml_serializers/libxml.rb +29 -0
- data/lib/gems/dm-serializer-0.9.9/lib/dm-serializer/xml_serializers/nokogiri.rb +28 -0
- data/lib/gems/dm-serializer-0.9.9/lib/dm-serializer/xml_serializers/rexml.rb +23 -0
- data/lib/gems/dm-serializer-0.9.9/tasks/install.rb +13 -0
- data/lib/gems/dm-serializer-0.9.9/tasks/spec.rb +25 -0
- data/lib/gems/dm-timestamps-0.9.9/lib/dm-timestamps.rb +58 -0
- data/lib/gems/{dm-timestamps-0.9.7 → dm-timestamps-0.9.9}/lib/dm-timestamps/version.rb +1 -1
- data/lib/gems/dm-timestamps-0.9.9/tasks/install.rb +13 -0
- data/lib/gems/dm-timestamps-0.9.9/tasks/spec.rb +25 -0
- data/lib/gems/dm-types-0.9.9/lib/dm-types.rb +26 -0
- data/lib/gems/dm-types-0.9.9/lib/dm-types/bcrypt_hash.rb +33 -0
- data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/csv.rb +0 -0
- data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/enum.rb +4 -4
- data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/epoch_time.rb +0 -0
- data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/file_path.rb +0 -0
- data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/flag.rb +0 -0
- data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/ip_address.rb +0 -0
- data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/json.rb +3 -6
- data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/regexp.rb +0 -0
- data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/serial.rb +0 -0
- data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/slug.rb +0 -0
- data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/uri.rb +2 -0
- data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/uuid.rb +3 -0
- data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/version.rb +1 -1
- data/lib/gems/{dm-types-0.9.7 → dm-types-0.9.9}/lib/dm-types/yaml.rb +1 -2
- data/lib/gems/dm-types-0.9.9/tasks/install.rb +13 -0
- data/lib/gems/dm-types-0.9.9/tasks/spec.rb +25 -0
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations.rb +1 -1
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/absent_field_validator.rb +0 -0
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/acceptance_validator.rb +0 -0
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/auto_validate.rb +0 -0
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/block_validator.rb +0 -0
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/confirmation_validator.rb +0 -0
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/contextual_validators.rb +2 -3
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/custom_validator.rb +0 -0
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/format_validator.rb +0 -0
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/formats/email.rb +1 -0
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/formats/url.rb +0 -0
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/generic_validator.rb +0 -0
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/length_validator.rb +0 -0
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/method_validator.rb +0 -0
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/numeric_validator.rb +0 -0
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/primitive_validator.rb +0 -0
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/required_field_validator.rb +0 -0
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/support/object.rb +0 -0
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/uniqueness_validator.rb +1 -1
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/validation_errors.rb +0 -0
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/version.rb +1 -1
- data/lib/gems/{dm-validations-0.9.7 → dm-validations-0.9.9}/lib/dm-validations/within_validator.rb +0 -0
- data/lib/gems/dm-validations-0.9.9/tasks/install.rb +13 -0
- data/lib/gems/dm-validations-0.9.9/tasks/spec.rb +25 -0
- data/lib/gems/json_pure-1.1.3/tools/fuzz.rb +140 -0
- data/lib/gems/json_pure-1.1.3/tools/server.rb +62 -0
- data/lib/mack-data_mapper/dm_patches/migrations.rb +22 -1
- data/lib/mack-data_mapper/migration_generator/templates/db/migrations/%=@migration_name%.rb.template +1 -1
- metadata +216 -172
- data/lib/gems/dm-aggregates-0.9.7/lib/dm-aggregates/version.rb +0 -7
- data/lib/gems/dm-core-0.9.7/lib/dm-core/version.rb +0 -3
- data/lib/gems/dm-core-0.9.7/script/all +0 -5
- data/lib/gems/dm-core-0.9.7/script/performance.rb +0 -284
- data/lib/gems/dm-core-0.9.7/script/profile.rb +0 -87
- data/lib/gems/dm-serializer-0.9.7/lib/dm-serializer.rb +0 -183
- data/lib/gems/dm-timestamps-0.9.7/lib/dm-timestamps.rb +0 -57
- data/lib/gems/dm-types-0.9.7/lib/dm-types.rb +0 -28
- data/lib/gems/dm-types-0.9.7/lib/dm-types/bcrypt_hash.rb +0 -31
- data/lib/gems/json_pure-1.1.3/GPL +0 -340
- data/lib/gems/uuidtools-1.0.3/lib/uuidtools.rb +0 -648
- data/lib/gems/uuidtools-1.0.3/lib/uuidtools/version.rb +0 -32
@@ -1,648 +0,0 @@
|
|
1
|
-
#--
|
2
|
-
# Copyright (c) 2005-2008 Robert Aman
|
3
|
-
#
|
4
|
-
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
-
# a copy of this software and associated documentation files (the
|
6
|
-
# "Software"), to deal in the Software without restriction, including
|
7
|
-
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
-
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
-
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
-
# the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be
|
13
|
-
# included in all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
-
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
-
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
-
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
-
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
-
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
-
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
-
#++
|
23
|
-
|
24
|
-
$:.unshift(File.dirname(__FILE__))
|
25
|
-
|
26
|
-
require 'uri'
|
27
|
-
require 'time'
|
28
|
-
require 'thread'
|
29
|
-
require 'digest/sha1'
|
30
|
-
require 'digest/md5'
|
31
|
-
|
32
|
-
require 'uuidtools/version'
|
33
|
-
|
34
|
-
# Backwards compatibility with old method of versioning.
|
35
|
-
UUID_TOOLS_VERSION = UUID::UUID_TOOLS_VERSION::STRING
|
36
|
-
|
37
|
-
# Because it's impossible to hype a UUID generator on its genuine merits,
|
38
|
-
# I give you... Really bad ASCII art in the comments:
|
39
|
-
#
|
40
|
-
#
|
41
|
-
# \
|
42
|
-
# /
|
43
|
-
# +
|
44
|
-
# ]
|
45
|
-
# ]
|
46
|
-
# |
|
47
|
-
# /
|
48
|
-
# Mp___
|
49
|
-
# `~0NNp,
|
50
|
-
# __ggM'
|
51
|
-
# g0M~"`
|
52
|
-
# ]0M*-
|
53
|
-
#
|
54
|
-
# ___
|
55
|
-
# _g000M00g,
|
56
|
-
# j0M~ ~M&
|
57
|
-
# j0M" ~N,
|
58
|
-
# j0P M&
|
59
|
-
# jM 1
|
60
|
-
# j0 ]1
|
61
|
-
# .0P 0,
|
62
|
-
# 00' M&
|
63
|
-
# 0M ]0L
|
64
|
-
# ]0f ___ M0
|
65
|
-
# M0NN0M00MMM~"'M 0&
|
66
|
-
# `~ ~0 ]0,
|
67
|
-
# ]M ]0&
|
68
|
-
# M& M0,
|
69
|
-
# ____gp_ M& M0_
|
70
|
-
# __p0MPM8MM&_ M/ ^0&_
|
71
|
-
# gN"` M0N_j0, MM&__
|
72
|
-
# _gF `~M0P` __ M00g
|
73
|
-
# g0' gM0&, ~M0&
|
74
|
-
# _pM` 0, ]M1 "00&
|
75
|
-
# _00 /g1MMgj01 ]0MI
|
76
|
-
# _0F t"M,7MMM 00I
|
77
|
-
# g0' _ N&j& 40'
|
78
|
-
# g0' _p0Mq_ ' N0QQNM#g,
|
79
|
-
# 0' _g0000000g__ ~M@MMM000g
|
80
|
-
# f _jM00@` ~M0000Mgppg, "P00&
|
81
|
-
# | g000~ `~M000000&_ ~0&
|
82
|
-
# ]M _M00F "00MM` ~#&
|
83
|
-
# `0L m000F #E "0f
|
84
|
-
# 9r j000M` 40, 00
|
85
|
-
# ]0g_ j00M` ^M0MNggp#gqpg M0&
|
86
|
-
# ~MPM0f ~M000000000g_ ,_ygg&M00f
|
87
|
-
# `~~~M00000000000000
|
88
|
-
# `M0000000000f
|
89
|
-
# ~@@@MF~`
|
90
|
-
#
|
91
|
-
#
|
92
|
-
|
93
|
-
#= uuidtools.rb
|
94
|
-
#
|
95
|
-
# UUIDTools was designed to be a simple library for generating any
|
96
|
-
# of the various types of UUIDs. It conforms to RFC 4122 whenever
|
97
|
-
# possible.
|
98
|
-
#
|
99
|
-
#== Example
|
100
|
-
# UUID.md5_create(UUID_DNS_NAMESPACE, "www.widgets.com")
|
101
|
-
# => #<UUID:0x287576 UUID:3d813cbb-47fb-32ba-91df-831e1593ac29>
|
102
|
-
# UUID.sha1_create(UUID_DNS_NAMESPACE, "www.widgets.com")
|
103
|
-
# => #<UUID:0x2a0116 UUID:21f7f8de-8051-5b89-8680-0195ef798b6a>
|
104
|
-
# UUID.timestamp_create
|
105
|
-
# => #<UUID:0x2adfdc UUID:64a5189c-25b3-11da-a97b-00c04fd430c8>
|
106
|
-
# UUID.random_create
|
107
|
-
# => #<UUID:0x19013a UUID:984265dc-4200-4f02-ae70-fe4f48964159>
|
108
|
-
class UUID
|
109
|
-
@@mac_address = nil
|
110
|
-
@@last_timestamp = nil
|
111
|
-
@@last_node_id = nil
|
112
|
-
@@last_clock_sequence = nil
|
113
|
-
@@state_file = nil
|
114
|
-
@@mutex = Mutex.new
|
115
|
-
|
116
|
-
def initialize(time_low, time_mid, time_hi_and_version,
|
117
|
-
clock_seq_hi_and_reserved, clock_seq_low, nodes)
|
118
|
-
unless time_low >= 0 && time_low < 4294967296
|
119
|
-
raise ArgumentError,
|
120
|
-
"Expected unsigned 32-bit number for time_low, got #{time_low}."
|
121
|
-
end
|
122
|
-
unless time_mid >= 0 && time_mid < 65536
|
123
|
-
raise ArgumentError,
|
124
|
-
"Expected unsigned 16-bit number for time_mid, got #{time_mid}."
|
125
|
-
end
|
126
|
-
unless time_hi_and_version >= 0 && time_hi_and_version < 65536
|
127
|
-
raise ArgumentError,
|
128
|
-
"Expected unsigned 16-bit number for time_hi_and_version, " +
|
129
|
-
"got #{time_hi_and_version}."
|
130
|
-
end
|
131
|
-
unless clock_seq_hi_and_reserved >= 0 && clock_seq_hi_and_reserved < 256
|
132
|
-
raise ArgumentError,
|
133
|
-
"Expected unsigned 8-bit number for clock_seq_hi_and_reserved, " +
|
134
|
-
"got #{clock_seq_hi_and_reserved}."
|
135
|
-
end
|
136
|
-
unless clock_seq_low >= 0 && clock_seq_low < 256
|
137
|
-
raise ArgumentError,
|
138
|
-
"Expected unsigned 8-bit number for clock_seq_low, " +
|
139
|
-
"got #{clock_seq_low}."
|
140
|
-
end
|
141
|
-
unless nodes.respond_to? :size
|
142
|
-
raise ArgumentError,
|
143
|
-
"Expected nodes to respond to :size."
|
144
|
-
end
|
145
|
-
unless nodes.size == 6
|
146
|
-
raise ArgumentError,
|
147
|
-
"Expected nodes to have size of 6."
|
148
|
-
end
|
149
|
-
for node in nodes
|
150
|
-
unless node >= 0 && node < 256
|
151
|
-
raise ArgumentError,
|
152
|
-
"Expected unsigned 8-bit number for each node, " +
|
153
|
-
"got #{node}."
|
154
|
-
end
|
155
|
-
end
|
156
|
-
@time_low = time_low
|
157
|
-
@time_mid = time_mid
|
158
|
-
@time_hi_and_version = time_hi_and_version
|
159
|
-
@clock_seq_hi_and_reserved = clock_seq_hi_and_reserved
|
160
|
-
@clock_seq_low = clock_seq_low
|
161
|
-
@nodes = nodes
|
162
|
-
end
|
163
|
-
|
164
|
-
attr_accessor :time_low
|
165
|
-
attr_accessor :time_mid
|
166
|
-
attr_accessor :time_hi_and_version
|
167
|
-
attr_accessor :clock_seq_hi_and_reserved
|
168
|
-
attr_accessor :clock_seq_low
|
169
|
-
attr_accessor :nodes
|
170
|
-
|
171
|
-
# Parses a UUID from a string.
|
172
|
-
def self.parse(uuid_string)
|
173
|
-
unless uuid_string.kind_of? String
|
174
|
-
raise ArgumentError,
|
175
|
-
"Expected String, got #{uuid_string.class.name} instead."
|
176
|
-
end
|
177
|
-
uuid_components = uuid_string.downcase.scan(
|
178
|
-
Regexp.new("^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-" +
|
179
|
-
"([0-9a-f]{2})([0-9a-f]{2})-([0-9a-f]{12})$")).first
|
180
|
-
raise ArgumentError, "Invalid UUID format." if uuid_components.nil?
|
181
|
-
time_low = uuid_components[0].to_i(16)
|
182
|
-
time_mid = uuid_components[1].to_i(16)
|
183
|
-
time_hi_and_version = uuid_components[2].to_i(16)
|
184
|
-
clock_seq_hi_and_reserved = uuid_components[3].to_i(16)
|
185
|
-
clock_seq_low = uuid_components[4].to_i(16)
|
186
|
-
nodes = []
|
187
|
-
for i in 0..5
|
188
|
-
nodes << uuid_components[5][(i * 2)..(i * 2) + 1].to_i(16)
|
189
|
-
end
|
190
|
-
return self.new(time_low, time_mid, time_hi_and_version,
|
191
|
-
clock_seq_hi_and_reserved, clock_seq_low, nodes)
|
192
|
-
end
|
193
|
-
|
194
|
-
# Parses a UUID from a raw byte string.
|
195
|
-
def self.parse_raw(raw_string)
|
196
|
-
unless raw_string.kind_of? String
|
197
|
-
raise ArgumentError,
|
198
|
-
"Expected String, got #{raw_string.class.name} instead."
|
199
|
-
end
|
200
|
-
integer = self.convert_byte_string_to_int(raw_string)
|
201
|
-
|
202
|
-
time_low = (integer >> 96) & 0xFFFFFFFF
|
203
|
-
time_mid = (integer >> 80) & 0xFFFF
|
204
|
-
time_hi_and_version = (integer >> 64) & 0xFFFF
|
205
|
-
clock_seq_hi_and_reserved = (integer >> 56) & 0xFF
|
206
|
-
clock_seq_low = (integer >> 48) & 0xFF
|
207
|
-
nodes = []
|
208
|
-
for i in 0..5
|
209
|
-
nodes << ((integer >> (40 - (i * 8))) & 0xFF)
|
210
|
-
end
|
211
|
-
return self.new(time_low, time_mid, time_hi_and_version,
|
212
|
-
clock_seq_hi_and_reserved, clock_seq_low, nodes)
|
213
|
-
end
|
214
|
-
|
215
|
-
# Creates a UUID from a random value.
|
216
|
-
def self.random_create()
|
217
|
-
new_uuid = self.parse_raw(self.random_128)
|
218
|
-
new_uuid.time_hi_and_version &= 0x0FFF
|
219
|
-
new_uuid.time_hi_and_version |= (4 << 12)
|
220
|
-
new_uuid.clock_seq_hi_and_reserved &= 0x3F
|
221
|
-
new_uuid.clock_seq_hi_and_reserved |= 0x80
|
222
|
-
return new_uuid
|
223
|
-
end
|
224
|
-
|
225
|
-
# Creates a UUID from a timestamp.
|
226
|
-
def self.timestamp_create(timestamp=nil)
|
227
|
-
# We need a lock here to prevent two threads from ever
|
228
|
-
# getting the same timestamp.
|
229
|
-
@@mutex.synchronize do
|
230
|
-
# Always use GMT to generate UUIDs.
|
231
|
-
if timestamp.nil?
|
232
|
-
gmt_timestamp = Time.now.gmtime
|
233
|
-
else
|
234
|
-
gmt_timestamp = timestamp.gmtime
|
235
|
-
end
|
236
|
-
# Convert to 100 nanosecond blocks
|
237
|
-
gmt_timestamp_100_nanoseconds = (gmt_timestamp.tv_sec * 10000000) +
|
238
|
-
(gmt_timestamp.tv_usec * 10) + 0x01B21DD213814000
|
239
|
-
mac_address = self.get_mac_address
|
240
|
-
if mac_address == nil || mac_address == ""
|
241
|
-
raise StandardError,
|
242
|
-
"MAC address could not be autodetected. " +
|
243
|
-
"Set the MAC address manually."
|
244
|
-
end
|
245
|
-
nodes = mac_address.split(":").collect do |octet|
|
246
|
-
octet.to_i(16)
|
247
|
-
end
|
248
|
-
node_id = 0
|
249
|
-
for i in 0..5
|
250
|
-
node_id += (nodes[i] << (40 - (i * 8)))
|
251
|
-
end
|
252
|
-
clock_sequence = @@last_clock_sequence
|
253
|
-
if clock_sequence.nil?
|
254
|
-
clock_sequence = self.convert_byte_string_to_int(self.random_128)
|
255
|
-
end
|
256
|
-
if @@last_node_id != nil && @@last_node_id != node_id
|
257
|
-
# The node id has changed. Change the clock id.
|
258
|
-
clock_sequence = self.convert_byte_string_to_int(self.random_128)
|
259
|
-
elsif @@last_timestamp != nil &&
|
260
|
-
gmt_timestamp_100_nanoseconds <= @@last_timestamp
|
261
|
-
clock_sequence = clock_sequence + 1
|
262
|
-
end
|
263
|
-
@@last_timestamp = gmt_timestamp_100_nanoseconds
|
264
|
-
@@last_node_id = node_id
|
265
|
-
@@last_clock_sequence = clock_sequence
|
266
|
-
|
267
|
-
time_low = gmt_timestamp_100_nanoseconds & 0xFFFFFFFF
|
268
|
-
time_mid = ((gmt_timestamp_100_nanoseconds >> 32) & 0xFFFF)
|
269
|
-
time_hi_and_version = ((gmt_timestamp_100_nanoseconds >> 48) & 0x0FFF)
|
270
|
-
time_hi_and_version |= (1 << 12)
|
271
|
-
clock_seq_low = clock_sequence & 0xFF;
|
272
|
-
clock_seq_hi_and_reserved = (clock_sequence & 0x3F00) >> 8
|
273
|
-
clock_seq_hi_and_reserved |= 0x80
|
274
|
-
|
275
|
-
return self.new(time_low, time_mid, time_hi_and_version,
|
276
|
-
clock_seq_hi_and_reserved, clock_seq_low, nodes)
|
277
|
-
end
|
278
|
-
end
|
279
|
-
|
280
|
-
# Creates a UUID using the MD5 hash. (Version 3)
|
281
|
-
def self.md5_create(namespace, name)
|
282
|
-
return self.create_from_hash(Digest::MD5, namespace, name)
|
283
|
-
end
|
284
|
-
|
285
|
-
# Creates a UUID using the SHA1 hash. (Version 5)
|
286
|
-
def self.sha1_create(namespace, name)
|
287
|
-
return self.create_from_hash(Digest::SHA1, namespace, name)
|
288
|
-
end
|
289
|
-
|
290
|
-
# This method applies only to version 1 UUIDs.
|
291
|
-
# Checks if the node ID was generated from a random number
|
292
|
-
# or from an IEEE 802 address (MAC address).
|
293
|
-
# Always returns false for UUIDs that aren't version 1.
|
294
|
-
# This should not be confused with version 4 UUIDs where
|
295
|
-
# more than just the node id is random.
|
296
|
-
def random_node_id?
|
297
|
-
return false if self.version != 1
|
298
|
-
return ((self.nodes.first & 0x01) == 1)
|
299
|
-
end
|
300
|
-
|
301
|
-
# Returns true if this UUID is the
|
302
|
-
# nil UUID (00000000-0000-0000-0000-000000000000).
|
303
|
-
def nil_uuid?
|
304
|
-
return false if self.time_low != 0
|
305
|
-
return false if self.time_mid != 0
|
306
|
-
return false if self.time_hi_and_version != 0
|
307
|
-
return false if self.clock_seq_hi_and_reserved != 0
|
308
|
-
return false if self.clock_seq_low != 0
|
309
|
-
self.nodes.each do |node|
|
310
|
-
return false if node != 0
|
311
|
-
end
|
312
|
-
return true
|
313
|
-
end
|
314
|
-
|
315
|
-
# Returns the UUID version type.
|
316
|
-
# Possible values:
|
317
|
-
# 1 - Time-based with unique or random host identifier
|
318
|
-
# 2 - DCE Security version (with POSIX UIDs)
|
319
|
-
# 3 - Name-based (MD5 hash)
|
320
|
-
# 4 - Random
|
321
|
-
# 5 - Name-based (SHA-1 hash)
|
322
|
-
def version
|
323
|
-
return (time_hi_and_version >> 12)
|
324
|
-
end
|
325
|
-
|
326
|
-
# Returns the UUID variant.
|
327
|
-
# Possible values:
|
328
|
-
# 0b000 - Reserved, NCS backward compatibility.
|
329
|
-
# 0b100 - The variant specified in this document.
|
330
|
-
# 0b110 - Reserved, Microsoft Corporation backward compatibility.
|
331
|
-
# 0b111 - Reserved for future definition.
|
332
|
-
def variant
|
333
|
-
variant_raw = (clock_seq_hi_and_reserved >> 5)
|
334
|
-
result = nil
|
335
|
-
if (variant_raw >> 2) == 0
|
336
|
-
result = 0x000
|
337
|
-
elsif (variant_raw >> 1) == 2
|
338
|
-
result = 0x100
|
339
|
-
else
|
340
|
-
result = variant_raw
|
341
|
-
end
|
342
|
-
return (result >> 6)
|
343
|
-
end
|
344
|
-
|
345
|
-
# Returns true if this UUID is valid.
|
346
|
-
def valid?
|
347
|
-
if [0b000, 0b100, 0b110, 0b111].include?(self.variant) &&
|
348
|
-
(1..5).include?(self.version)
|
349
|
-
return true
|
350
|
-
else
|
351
|
-
return false
|
352
|
-
end
|
353
|
-
end
|
354
|
-
|
355
|
-
# Returns the IEEE 802 address used to generate this UUID or
|
356
|
-
# nil if a MAC address was not used.
|
357
|
-
def mac_address
|
358
|
-
return nil if self.version != 1
|
359
|
-
return nil if self.random_node_id?
|
360
|
-
return (self.nodes.collect do |node|
|
361
|
-
sprintf("%2.2x", node)
|
362
|
-
end).join(":")
|
363
|
-
end
|
364
|
-
|
365
|
-
# Returns the timestamp used to generate this UUID
|
366
|
-
def timestamp
|
367
|
-
return nil if self.version != 1
|
368
|
-
gmt_timestamp_100_nanoseconds = 0
|
369
|
-
gmt_timestamp_100_nanoseconds +=
|
370
|
-
((self.time_hi_and_version & 0x0FFF) << 48)
|
371
|
-
gmt_timestamp_100_nanoseconds += (self.time_mid << 32)
|
372
|
-
gmt_timestamp_100_nanoseconds += self.time_low
|
373
|
-
return Time.at(
|
374
|
-
(gmt_timestamp_100_nanoseconds - 0x01B21DD213814000) / 10000000.0)
|
375
|
-
end
|
376
|
-
|
377
|
-
# Compares two UUIDs lexically
|
378
|
-
def <=>(other_uuid)
|
379
|
-
check = self.time_low <=> other_uuid.time_low
|
380
|
-
return check if check != 0
|
381
|
-
check = self.time_mid <=> other_uuid.time_mid
|
382
|
-
return check if check != 0
|
383
|
-
check = self.time_hi_and_version <=> other_uuid.time_hi_and_version
|
384
|
-
return check if check != 0
|
385
|
-
check = self.clock_seq_hi_and_reserved <=>
|
386
|
-
other_uuid.clock_seq_hi_and_reserved
|
387
|
-
return check if check != 0
|
388
|
-
check = self.clock_seq_low <=> other_uuid.clock_seq_low
|
389
|
-
return check if check != 0
|
390
|
-
for i in 0..5
|
391
|
-
if (self.nodes[i] < other_uuid.nodes[i])
|
392
|
-
return -1
|
393
|
-
end
|
394
|
-
if (self.nodes[i] > other_uuid.nodes[i])
|
395
|
-
return 1
|
396
|
-
end
|
397
|
-
end
|
398
|
-
return 0
|
399
|
-
end
|
400
|
-
|
401
|
-
# Returns a representation of the object's state
|
402
|
-
def inspect
|
403
|
-
return "#<UUID:0x#{self.object_id.to_s(16)} UUID:#{self.to_s}>"
|
404
|
-
end
|
405
|
-
|
406
|
-
# Returns the hex digest of the UUID object.
|
407
|
-
def hexdigest
|
408
|
-
return self.to_i.to_s(16)
|
409
|
-
end
|
410
|
-
|
411
|
-
# Returns the raw bytes that represent this UUID.
|
412
|
-
def raw
|
413
|
-
return self.class.convert_int_to_byte_string(self.to_i, 16)
|
414
|
-
end
|
415
|
-
|
416
|
-
# Returns a string representation for this UUID.
|
417
|
-
def to_s
|
418
|
-
result = sprintf("%8.8x-%4.4x-%4.4x-%2.2x%2.2x-", @time_low, @time_mid,
|
419
|
-
@time_hi_and_version, @clock_seq_hi_and_reserved, @clock_seq_low);
|
420
|
-
for i in 0..5
|
421
|
-
result << sprintf("%2.2x", @nodes[i])
|
422
|
-
end
|
423
|
-
return result.downcase
|
424
|
-
end
|
425
|
-
|
426
|
-
# Returns an integer representation for this UUID.
|
427
|
-
def to_i
|
428
|
-
bytes = (time_low << 96) + (time_mid << 80) +
|
429
|
-
(time_hi_and_version << 64) + (clock_seq_hi_and_reserved << 56) +
|
430
|
-
(clock_seq_low << 48)
|
431
|
-
for i in 0..5
|
432
|
-
bytes += (nodes[i] << (40 - (i * 8)))
|
433
|
-
end
|
434
|
-
return bytes
|
435
|
-
end
|
436
|
-
|
437
|
-
# Returns a URI string for this UUID.
|
438
|
-
def to_uri
|
439
|
-
return "urn:uuid:#{self.to_s}"
|
440
|
-
end
|
441
|
-
|
442
|
-
# Returns an integer hash value.
|
443
|
-
def hash
|
444
|
-
return self.to_i
|
445
|
-
end
|
446
|
-
|
447
|
-
# Returns true if this UUID is exactly equal to the other UUID.
|
448
|
-
def eql?(other)
|
449
|
-
return (self <=> other) == 0
|
450
|
-
end
|
451
|
-
|
452
|
-
def self.create_from_hash(hash_class, namespace, name) #:nodoc:
|
453
|
-
if hash_class == Digest::MD5
|
454
|
-
version = 3
|
455
|
-
elsif hash_class == Digest::SHA1
|
456
|
-
version = 5
|
457
|
-
else
|
458
|
-
raise ArgumentError,
|
459
|
-
"Expected Digest::SHA1 or Digest::MD5, got #{hash_class.name}."
|
460
|
-
end
|
461
|
-
hash = hash_class.new
|
462
|
-
hash.update(namespace.raw)
|
463
|
-
hash.update(name)
|
464
|
-
hash_string = hash.to_s[0..31]
|
465
|
-
new_uuid = self.parse("#{hash_string[0..7]}-#{hash_string[8..11]}-" +
|
466
|
-
"#{hash_string[12..15]}-#{hash_string[16..19]}-#{hash_string[20..31]}")
|
467
|
-
|
468
|
-
new_uuid.time_hi_and_version &= 0x0FFF
|
469
|
-
new_uuid.time_hi_and_version |= (version << 12)
|
470
|
-
new_uuid.clock_seq_hi_and_reserved &= 0x3F
|
471
|
-
new_uuid.clock_seq_hi_and_reserved |= 0x80
|
472
|
-
return new_uuid
|
473
|
-
end
|
474
|
-
|
475
|
-
# Returns the MAC address of the current computer's network card.
|
476
|
-
# Returns nil if a MAC address could not be found.
|
477
|
-
def self.mac_address #:nodoc:
|
478
|
-
if @@mac_address.nil?
|
479
|
-
require 'rbconfig'
|
480
|
-
os_platform = Config::CONFIG['target_os']
|
481
|
-
if os_platform =~ /win/ && !(os_platform =~ /darwin/)
|
482
|
-
script_in_path = true
|
483
|
-
else
|
484
|
-
script_in_path = !(`which ifconfig`.strip =~ /no .+ in/)
|
485
|
-
end
|
486
|
-
if os_platform =~ /solaris/
|
487
|
-
begin
|
488
|
-
ifconfig_output =
|
489
|
-
(script_in_path ? `ifconfig -a` : `/sbin/ifconfig -a`)
|
490
|
-
ip_addresses = ifconfig_output.scan(
|
491
|
-
/inet\s?(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/)
|
492
|
-
ip = ip_addresses.find {|addr| addr[0] != '127.0.0.1'}[0]
|
493
|
-
@@mac_address = `/usr/sbin/arp #{ip}`.split(' ')[3]
|
494
|
-
rescue Exception
|
495
|
-
end
|
496
|
-
if @@mac_address == "" || @@mac_address == nil
|
497
|
-
begin
|
498
|
-
ifconfig_output =
|
499
|
-
(script_in_path ?
|
500
|
-
`ifconfig -a` : `/sbin/ifconfig -a`).split(' ')
|
501
|
-
index = ifconfig_output.index("inet") + 1
|
502
|
-
ip = ifconfig_output[index]
|
503
|
-
@@mac_address = `arp #{ip}`.split(' ')[3]
|
504
|
-
rescue Exception
|
505
|
-
end
|
506
|
-
end
|
507
|
-
elsif os_platform =~ /win/ && !(os_platform =~ /darwin/)
|
508
|
-
begin
|
509
|
-
ifconfig_output = `ipconfig /all`
|
510
|
-
mac_addresses = ifconfig_output.scan(
|
511
|
-
Regexp.new("(#{(["[0-9a-fA-F]{2}"] * 6).join("-")})"))
|
512
|
-
if mac_addresses.size > 0
|
513
|
-
@@mac_address = mac_addresses.first.first.downcase.gsub(/-/, ":")
|
514
|
-
end
|
515
|
-
rescue
|
516
|
-
end
|
517
|
-
else
|
518
|
-
begin
|
519
|
-
mac_addresses = []
|
520
|
-
if os_platform =~ /netbsd/
|
521
|
-
ifconfig_output =
|
522
|
-
(script_in_path ? `ifconfig -a 2>&1` : `/sbin/ifconfig -a 2>&1`)
|
523
|
-
mac_addresses = ifconfig_output.scan(
|
524
|
-
Regexp.new("address\: (#{(["[0-9a-fA-F]{2}"] * 6).join(":")})"))
|
525
|
-
elsif os_platform =~ /openbsd/
|
526
|
-
ifconfig_output = `/sbin/ifconfig -a 2>&1`
|
527
|
-
ifconfig_output =
|
528
|
-
(script_in_path ? `ifconfig -a 2>&1` : `/sbin/ifconfig -a 2>&1`)
|
529
|
-
mac_addresses = ifconfig_output.scan(
|
530
|
-
Regexp.new("addr (#{(["[0-9a-fA-F]{2}"] * 6).join(":")})"))
|
531
|
-
elsif File.exists?('/sbin/ifconfig')
|
532
|
-
ifconfig_output =
|
533
|
-
(script_in_path ? `ifconfig 2>&1` : `/sbin/ifconfig 2>&1`)
|
534
|
-
mac_addresses = ifconfig_output.scan(
|
535
|
-
Regexp.new("ether (#{(["[0-9a-fA-F]{2}"] * 6).join(":")})"))
|
536
|
-
if mac_addresses.size == 0
|
537
|
-
ifconfig_output =
|
538
|
-
(script_in_path ?
|
539
|
-
`ifconfig -a 2>&1` : `/sbin/ifconfig -a 2>&1`)
|
540
|
-
mac_addresses = ifconfig_output.scan(
|
541
|
-
Regexp.new("ether (#{(["[0-9a-fA-F]{2}"] * 6).join(":")})"))
|
542
|
-
end
|
543
|
-
if mac_addresses.size == 0
|
544
|
-
ifconfig_output =
|
545
|
-
(script_in_path ?
|
546
|
-
`ifconfig | grep HWaddr | cut -c39- 2>&1` :
|
547
|
-
`/sbin/ifconfig | grep HWaddr | cut -c39- 2>&1`)
|
548
|
-
mac_addresses = ifconfig_output.scan(
|
549
|
-
Regexp.new("(#{(["[0-9a-fA-F]{2}"] * 6).join(":")})"))
|
550
|
-
end
|
551
|
-
else
|
552
|
-
ifconfig_output =
|
553
|
-
(script_in_path ? `ifconfig 2>&1` : `/sbin/ifconfig 2>&1`)
|
554
|
-
mac_addresses = ifconfig_output.scan(
|
555
|
-
Regexp.new("ether (#{(["[0-9a-fA-F]{2}"] * 6).join(":")})"))
|
556
|
-
if mac_addresses.size == 0
|
557
|
-
ifconfig_output =
|
558
|
-
(script_in_path ?
|
559
|
-
`ifconfig -a 2>&1` : `/sbin/ifconfig -a 2>&1`)
|
560
|
-
mac_addresses = ifconfig_output.scan(
|
561
|
-
Regexp.new("ether (#{(["[0-9a-fA-F]{2}"] * 6).join(":")})"))
|
562
|
-
end
|
563
|
-
if mac_addresses.size == 0
|
564
|
-
ifconfig_output =
|
565
|
-
(script_in_path ?
|
566
|
-
`ifconfig | grep HWaddr | cut -c39- 2>&1` :
|
567
|
-
`/sbin/ifconfig | grep HWaddr | cut -c39- 2>&1`)
|
568
|
-
mac_addresses = ifconfig_output.scan(
|
569
|
-
Regexp.new("(#{(["[0-9a-fA-F]{2}"] * 6).join(":")})"))
|
570
|
-
end
|
571
|
-
end
|
572
|
-
if mac_addresses.size > 0
|
573
|
-
@@mac_address = mac_addresses.first.first
|
574
|
-
end
|
575
|
-
rescue
|
576
|
-
end
|
577
|
-
end
|
578
|
-
if @@mac_address != nil
|
579
|
-
if @@mac_address.respond_to?(:to_str)
|
580
|
-
@@mac_address = @@mac_address.to_str
|
581
|
-
else
|
582
|
-
@@mac_address = @@mac_address.to_s
|
583
|
-
end
|
584
|
-
@@mac_address.downcase!
|
585
|
-
@@mac_address.strip!
|
586
|
-
end
|
587
|
-
|
588
|
-
# Verify that the MAC address is in the right format.
|
589
|
-
# Nil it out if it isn't.
|
590
|
-
unless @@mac_address.respond_to?(:scan) &&
|
591
|
-
@@mac_address.scan(/#{(["[0-9a-f]{2}"] * 6).join(":")}/)
|
592
|
-
@@mac_address = nil
|
593
|
-
end
|
594
|
-
end
|
595
|
-
return @@mac_address
|
596
|
-
end
|
597
|
-
class <<self
|
598
|
-
alias_method :get_mac_address, :mac_address
|
599
|
-
end
|
600
|
-
|
601
|
-
# Allows users to set the MAC address manually in cases where the MAC
|
602
|
-
# address cannot be obtained programatically.
|
603
|
-
def self.mac_address=(new_mac_address)
|
604
|
-
@@mac_address = new_mac_address
|
605
|
-
end
|
606
|
-
|
607
|
-
# 128 bits of unpredictable data.
|
608
|
-
def self.random_128 #:nodoc:
|
609
|
-
if !defined?(@random_device) || @random_device == nil
|
610
|
-
begin
|
611
|
-
@random_device = nil
|
612
|
-
if File.exists? "/dev/urandom"
|
613
|
-
@random_device = File.open "/dev/urandom", "r"
|
614
|
-
elsif File.exists? "/dev/random"
|
615
|
-
@random_device = File.open "/dev/random", "r"
|
616
|
-
end
|
617
|
-
rescue Exception
|
618
|
-
end
|
619
|
-
end
|
620
|
-
begin
|
621
|
-
return @random_device.read(16) if @random_device != nil
|
622
|
-
rescue Exception
|
623
|
-
end
|
624
|
-
return (1..8).to_a.map { rand(0x10000) }.pack("n8")
|
625
|
-
end
|
626
|
-
|
627
|
-
def self.convert_int_to_byte_string(integer, size) #:nodoc:
|
628
|
-
byte_string = ""
|
629
|
-
for i in 0..(size - 1)
|
630
|
-
byte_string << ((integer >> (((size - 1) - i) * 8)) & 0xFF)
|
631
|
-
end
|
632
|
-
return byte_string
|
633
|
-
end
|
634
|
-
|
635
|
-
def self.convert_byte_string_to_int(byte_string) #:nodoc:
|
636
|
-
integer = 0
|
637
|
-
size = byte_string.size
|
638
|
-
for i in 0..(size - 1)
|
639
|
-
integer += (byte_string[i] << (((size - 1) - i) * 8))
|
640
|
-
end
|
641
|
-
return integer
|
642
|
-
end
|
643
|
-
end
|
644
|
-
|
645
|
-
UUID_DNS_NAMESPACE = UUID.parse("6ba7b810-9dad-11d1-80b4-00c04fd430c8")
|
646
|
-
UUID_URL_NAMESPACE = UUID.parse("6ba7b811-9dad-11d1-80b4-00c04fd430c8")
|
647
|
-
UUID_OID_NAMESPACE = UUID.parse("6ba7b812-9dad-11d1-80b4-00c04fd430c8")
|
648
|
-
UUID_X500_NAMESPACE = UUID.parse("6ba7b814-9dad-11d1-80b4-00c04fd430c8")
|