uuiddqd 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/.travis.yml +7 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +31 -0
- data/Rakefile +16 -0
- data/ext/uuiddqd/extconf.rb +19 -0
- data/ext/uuiddqd/uuid.c +23 -0
- data/lib/uuiddqd/version.rb +3 -0
- data/test/helper.rb +5 -0
- data/test/uuiddqd_test.rb +21 -0
- data/uuiddqd.gemspec +20 -0
- metadata +76 -0
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Josef Šimánek
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Uuiddqd
|
2
|
+
|
3
|
+
Simple libuuid ruby c binding
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'uuiddqd'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install uuiddqd
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
Uuiddqd.generate #=> "c3523d95-ecb5-4f86-9f75-aa7ac230e8f0"
|
23
|
+
```
|
24
|
+
|
25
|
+
## Contributing
|
26
|
+
|
27
|
+
1. Fork it
|
28
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
29
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
30
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
31
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'bundler'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/clean'
|
4
|
+
require 'rake/extensiontask'
|
5
|
+
|
6
|
+
Bundler::GemHelper.install_tasks
|
7
|
+
Rake::ExtensionTask.new('uuiddqd')
|
8
|
+
|
9
|
+
desc "Build eventmachine, then run tests."
|
10
|
+
task :default => [:clean,:compile, :test]
|
11
|
+
|
12
|
+
Rake::TestTask.new(:test) do |t|
|
13
|
+
t.libs << 'test'
|
14
|
+
t.pattern = 'test/**/*_test.rb'
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# Loads mkmf which is used to make makefiles for Ruby extensions
|
2
|
+
require 'mkmf'
|
3
|
+
|
4
|
+
$CFLAGS = "-Wall -Wno-multichar -luuid"
|
5
|
+
|
6
|
+
# Give it a name
|
7
|
+
extension_name = 'uuiddqd'
|
8
|
+
|
9
|
+
unless find_library("uuid", 'uuid_generate')
|
10
|
+
abort "Install libuuid!\n"
|
11
|
+
end
|
12
|
+
|
13
|
+
pkg_config('uuid')
|
14
|
+
|
15
|
+
# The destination
|
16
|
+
dir_config(extension_name)
|
17
|
+
|
18
|
+
# Do the work
|
19
|
+
create_makefile(extension_name)
|
data/ext/uuiddqd/uuid.c
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
#include <stdio.h>
|
2
|
+
#include <uuid/uuid.h>
|
3
|
+
#include "ruby.h"
|
4
|
+
|
5
|
+
VALUE Uuiddqd = Qnil;
|
6
|
+
|
7
|
+
void Init_uuiddqd();
|
8
|
+
|
9
|
+
VALUE method_generate(VALUE self);
|
10
|
+
|
11
|
+
void Init_uuiddqd() {
|
12
|
+
Uuiddqd = rb_define_module("Uuiddqd");
|
13
|
+
rb_define_singleton_method(Uuiddqd, "generate", method_generate, 0);
|
14
|
+
}
|
15
|
+
|
16
|
+
VALUE method_generate(VALUE self) {
|
17
|
+
uuid_t my_uuid;
|
18
|
+
uuid_generate(my_uuid);
|
19
|
+
|
20
|
+
char stringy[36];
|
21
|
+
uuid_unparse(my_uuid, stringy);
|
22
|
+
return rb_str_new2(stringy);
|
23
|
+
}
|
data/test/helper.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'helper'
|
2
|
+
|
3
|
+
class TestUuiddqd < MiniTest::Unit::TestCase
|
4
|
+
def setup
|
5
|
+
@uuid = Uuiddqd.generate
|
6
|
+
end
|
7
|
+
|
8
|
+
def test_return_string
|
9
|
+
assert_kind_of String, @uuid
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_return_proper_length
|
13
|
+
assert_equal 36, @uuid.length
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_not_same
|
17
|
+
another_uuid = Uuiddqd.generate
|
18
|
+
refute_equal another_uuid, @uuid
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
data/uuiddqd.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/uuiddqd/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Josef Šimánek"]
|
6
|
+
gem.email = ["retro@ballgag.cz"]
|
7
|
+
gem.description = %q{Ruby libuuid}
|
8
|
+
gem.summary = %q{Little Ruby experiment}
|
9
|
+
gem.homepage = "https://github.com/simi/uuiddqd"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test)/})
|
14
|
+
gem.name = "uuiddqd"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Uuiddqd::VERSION
|
17
|
+
|
18
|
+
# specify any dependencies here; for example:
|
19
|
+
gem.add_development_dependency "rake-compiler"
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: uuiddqd
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Josef Šimánek
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-09-28 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rake-compiler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
description: Ruby libuuid
|
31
|
+
email:
|
32
|
+
- retro@ballgag.cz
|
33
|
+
executables: []
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- .gitignore
|
38
|
+
- .travis.yml
|
39
|
+
- Gemfile
|
40
|
+
- LICENSE
|
41
|
+
- README.md
|
42
|
+
- Rakefile
|
43
|
+
- ext/uuiddqd/extconf.rb
|
44
|
+
- ext/uuiddqd/uuid.c
|
45
|
+
- lib/uuiddqd/version.rb
|
46
|
+
- test/helper.rb
|
47
|
+
- test/uuiddqd_test.rb
|
48
|
+
- uuiddqd.gemspec
|
49
|
+
homepage: https://github.com/simi/uuiddqd
|
50
|
+
licenses: []
|
51
|
+
post_install_message:
|
52
|
+
rdoc_options: []
|
53
|
+
require_paths:
|
54
|
+
- lib
|
55
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
57
|
+
requirements:
|
58
|
+
- - ! '>='
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '0'
|
61
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ! '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
requirements: []
|
68
|
+
rubyforge_project:
|
69
|
+
rubygems_version: 1.8.24
|
70
|
+
signing_key:
|
71
|
+
specification_version: 3
|
72
|
+
summary: Little Ruby experiment
|
73
|
+
test_files:
|
74
|
+
- test/helper.rb
|
75
|
+
- test/uuiddqd_test.rb
|
76
|
+
has_rdoc:
|