cuuid 0.5.0-java

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source :rubygems
2
+
3
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,29 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cuuid (0.5.0-java)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.1.3)
10
+ rake (0.9.2.2)
11
+ rake-compiler (0.8.1)
12
+ rake
13
+ rspec (2.11.0)
14
+ rspec-core (~> 2.11.0)
15
+ rspec-expectations (~> 2.11.0)
16
+ rspec-mocks (~> 2.11.0)
17
+ rspec-core (2.11.1)
18
+ rspec-expectations (2.11.2)
19
+ diff-lcs (~> 1.1.3)
20
+ rspec-mocks (2.11.2)
21
+
22
+ PLATFORMS
23
+ java
24
+ ruby
25
+
26
+ DEPENDENCIES
27
+ cuuid!
28
+ rake-compiler
29
+ rspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 EmberAds Ltd <team@emberads.com>
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/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ spec = Gem::Specification.load("cuuid.gemspec")
2
+
3
+ require "rubygems/package_task"
4
+ Gem::PackageTask.new(spec) {}
5
+
6
+ if RUBY_PLATFORM["java"]
7
+ require "rake/javaextensiontask"
8
+ Rake::JavaExtensionTask.new("cuuid_generator", spec)
9
+ else
10
+ require "rake/extensiontask"
11
+ Rake::ExtensionTask.new("cuuid_generator", spec)
12
+ end
data/Readme.md ADDED
@@ -0,0 +1,36 @@
1
+ # CUUID
2
+
3
+ This gem is a thin C => Ruby wrapper around the `<uuid/uuid.h>` library that should come with your OS. It's been tested on OS X (10.7+) and Ubuntu (10.04 LTS). It provides one method for you.
4
+
5
+ ## Usage
6
+
7
+ CUUID.generate # => "08146761-57BF-46C9-A55B-1B49103AA08B"
8
+
9
+ Or if you've required `"cuuid/uuid"` then you can just do
10
+
11
+ UUID.generate # => "08146761-57BF-46C9-A55B-1B49103AA08B"
12
+
13
+ ## Installation
14
+
15
+ It'll work out the box on OS X. Ubuntu requires `uuid-dev` apt package installing.
16
+
17
+ Rubygem install:
18
+
19
+ gem install cuuid
20
+
21
+ Gemfile:
22
+
23
+ gem "cuuid"
24
+
25
+ There's an optional file for compatibility with the [uuid gem](http://rubygems.org/gems/uuid):
26
+
27
+ require "cuuid/uuid"
28
+
29
+ or in your Gemfile:
30
+
31
+ gem "cuuid", require: "cuuid/uuid"
32
+
33
+
34
+ ## License
35
+
36
+ See LICENSE
@@ -0,0 +1,11 @@
1
+ package com.emberads.cuuid;
2
+
3
+ import java.util.UUID;
4
+
5
+ public class Generator {
6
+
7
+ private static String generate() {
8
+ return UUID.randomUUID().toString();
9
+ }
10
+
11
+ }
@@ -0,0 +1,31 @@
1
+ #include <ruby.h>
2
+ #include <uuid/uuid.h>
3
+
4
+ // CUUID::Generator.generate
5
+
6
+ // Define our module & class constants
7
+ VALUE CUUID = Qnil;
8
+ VALUE CUUIDGenerator = Qnil;
9
+
10
+ void Init_cuuid_generator();
11
+ static VALUE method_cuuid_generator_generate(VALUE self);
12
+
13
+ // Define CUUID, CUUID::Generator and the class method
14
+ void Init_cuuid_generator() {
15
+ CUUID = rb_define_module("CUUID");
16
+ CUUIDGenerator = rb_define_module_under(CUUID, "Generator");
17
+ rb_define_module_function(CUUIDGenerator, "generate", method_cuuid_generator_generate, 0);
18
+ }
19
+
20
+ // Implement CUUID.generate
21
+ static VALUE method_cuuid_generator_generate(VALUE self) {
22
+ uuid_t uuid_id;
23
+ char uuid_str[128];
24
+
25
+ // Generate UUID and grab string version of it
26
+ uuid_generate(uuid_id);
27
+ uuid_unparse(uuid_id, uuid_str);
28
+
29
+ // Cast it into a ruby string and return it
30
+ return rb_str_new2(uuid_str);
31
+ }
@@ -0,0 +1,5 @@
1
+ require 'mkmf'
2
+
3
+ dir_config("cuuid_generator")
4
+ have_library("uuid") if RUBY_PLATFORM[/linux/i]
5
+ create_makefile("cuuid_generator")
data/lib/cuuid/uuid.rb ADDED
@@ -0,0 +1,8 @@
1
+ require "cuuid"
2
+
3
+ # For compatibility with the UUID gem
4
+ module UUID
5
+ def self.generate
6
+ CUUID.generate.downcase
7
+ end
8
+ end
@@ -0,0 +1,3 @@
1
+ module CUUID
2
+ VERSION = "0.5.0"
3
+ end
data/lib/cuuid.rb ADDED
@@ -0,0 +1,16 @@
1
+ require File.expand_path("cuuid_generator", File.dirname(__FILE__))
2
+
3
+ module CUUID
4
+
5
+ if RUBY_PLATFORM["java"]
6
+ require "jruby"
7
+ include_package 'com.emberads.cuuid'
8
+ Generator = Java::ComEmberadsCuuid::Generator
9
+ end
10
+
11
+ # backwards compatible (& lazy)
12
+ def self.generate
13
+ Generator.generate
14
+ end
15
+
16
+ end
Binary file
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cuuid
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.5.0
6
+ platform: java
7
+ authors:
8
+ - Caius Durling
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2012-08-14 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rake-compiler
17
+ version_requirements: &id001 !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: "0"
23
+ requirement: *id001
24
+ prerelease: false
25
+ type: :development
26
+ - !ruby/object:Gem::Dependency
27
+ name: rspec
28
+ version_requirements: &id002 !ruby/object:Gem::Requirement
29
+ none: false
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ requirement: *id002
35
+ prerelease: false
36
+ type: :development
37
+ description:
38
+ email: caius@emberads.com
39
+ executables: []
40
+
41
+ extensions: []
42
+
43
+ extra_rdoc_files: []
44
+
45
+ files:
46
+ - ext/cuuid_generator/cuuid_generator.c
47
+ - ext/cuuid_generator/extconf.rb
48
+ - ext/cuuid_generator/Generator.java
49
+ - lib/cuuid.rb
50
+ - lib/cuuid/uuid.rb
51
+ - lib/cuuid/version.rb
52
+ - Gemfile
53
+ - Gemfile.lock
54
+ - LICENSE
55
+ - Rakefile
56
+ - Readme.md
57
+ - lib/cuuid_generator.jar
58
+ homepage: http://github.com/EmberAds/cuuid
59
+ licenses: []
60
+
61
+ post_install_message:
62
+ rdoc_options: []
63
+
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ hash: 2
72
+ segments:
73
+ - 0
74
+ version: "0"
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ hash: 2
81
+ segments:
82
+ - 0
83
+ version: "0"
84
+ requirements: []
85
+
86
+ rubyforge_project:
87
+ rubygems_version: 1.8.24
88
+ signing_key:
89
+ specification_version: 3
90
+ summary: Ruby wrapper for the uuid library in your OS.
91
+ test_files: []
92
+