iuid 0.0.4 → 0.1.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 +5 -5
- data/CHANGELOG.md +12 -0
- data/README.md +32 -7
- data/bin/iuid +25 -23
- data/lib/iuid/version.rb +13 -15
- data/lib/iuid.rb +36 -30
- metadata +55 -49
- data/.document +0 -4
- data/.rspec +0 -1
- data/.travis.yml +0 -10
- data/Gemfile +0 -27
- data/Rakefile +0 -53
- data/iuid.gemspec +0 -69
- data/lib/VERSION +0 -4
- data/spec/data/.keep +0 -0
- data/spec/iuid_spec.rb +0 -76
- data/spec/spec_helper.rb +0 -31
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: '08a241e0c2524b734f3e1f6f4e5b9b993bd1fca67be120f14261c25247360bc6'
|
|
4
|
+
data.tar.gz: c9e26cf1e7177bc4ab0e43b96ab8a269c2a7585158f20e578c7cc0809bd6c380
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: cd860ceeb004bb01b63af8ed5c9d1d5ffd8396e3034cdee48091b18a2e4a27e04f83267054daf02b46fe426bdd173902dc24294e3f57b7169fceab6348707c3f
|
|
7
|
+
data.tar.gz: f312fa738008a446e21cca2700100f9bb751d38b334bdc02ea48d06d5b0cf7c7944c061f4789f3d07877f349bdea5894017ed037ce5f67977b9e592ee6fd3634
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## to 0.1.0
|
|
4
|
+
|
|
5
|
+
* Drop support for EOL Ruby versions (< 3.1)
|
|
6
|
+
* Support Ruby 3.1, 3.2, 3.3, 3.4, 4.0, head and JRuby
|
|
7
|
+
* Update dependencies (Moneta ~> 1.6, add explicit pstore dependency)
|
|
8
|
+
* Move from Travis-CI to GitHub Actions
|
|
9
|
+
* Remove Jeweler dependency and use standard gemspec
|
|
10
|
+
* Fix `File.exists?` deprecation for Ruby 3.2+
|
|
11
|
+
* Fix `--version` CLI option
|
|
12
|
+
* Setup Dependabot and release workflow
|
data/README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# iuid
|
|
2
|
-
[](https://github.com/duritong/iuid/actions/workflows/ruby.yml)
|
|
3
3
|
|
|
4
4
|
iuid is a simple username / uid storage that can autogenerate uids.
|
|
5
5
|
|
|
@@ -48,7 +48,7 @@ This will set the uid 1024 for the key user3
|
|
|
48
48
|
|
|
49
49
|
### delete
|
|
50
50
|
|
|
51
|
-
iuid delete user1
|
|
51
|
+
iuid delete user1
|
|
52
52
|
|
|
53
53
|
This will delete the stored uid and return it.
|
|
54
54
|
|
|
@@ -58,11 +58,37 @@ Simply build and install the gem.
|
|
|
58
58
|
|
|
59
59
|
## Update & Changes
|
|
60
60
|
|
|
61
|
-
|
|
61
|
+
See [CHANGELOG.md](CHANGELOG.md).
|
|
62
|
+
|
|
63
|
+
## Releasing
|
|
64
|
+
|
|
65
|
+
Releases are fully automated via GitHub Actions (`.github/workflows/release.yml`). The workflow runs specs, builds the gem, creates a GitHub Release with the `.gem` artifact, and publishes to RubyGems.
|
|
66
|
+
|
|
67
|
+
### Prerequisites
|
|
68
|
+
|
|
69
|
+
1. **GitHub Permissions**: In repository **Settings** → **Actions** → **General**, ensure **Workflow permissions** is set to **Read and write permissions**.
|
|
70
|
+
2. **RubyGems Trusted Publishing**: On [rubygems.org](https://rubygems.org), add a GitHub Actions trusted publisher for `duritong/iuid` and workflow `release.yml`.
|
|
71
|
+
|
|
72
|
+
### Triggering a Release
|
|
73
|
+
|
|
74
|
+
#### Option A: GitHub Actions UI (Manual Trigger)
|
|
75
|
+
|
|
76
|
+
1. Go to the **Actions** tab in the GitHub repository.
|
|
77
|
+
2. Select the **Release** workflow from the left sidebar.
|
|
78
|
+
3. Click **Run workflow**:
|
|
79
|
+
- Leave `version` blank to release the current version in `lib/iuid/version.rb`.
|
|
80
|
+
- Or provide a version (e.g. `0.2.0`) to automatically bump `version.rb`, commit, and tag.
|
|
81
|
+
4. Click **Run workflow**.
|
|
82
|
+
|
|
83
|
+
#### Option B: Push a Git Tag
|
|
84
|
+
|
|
85
|
+
Pushing a version tag (`v*`) automatically runs the workflow and publishes the release:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
git tag v0.1.0
|
|
89
|
+
git push origin v0.1.0
|
|
90
|
+
```
|
|
62
91
|
|
|
63
|
-
1. be sure to update as well the moneta gem, iuid now uses the official moneta releases and supports current avaiable versions.
|
|
64
|
-
1. Options for moneta's backends have changed. For example, if you are using the yaml-backend you will likely need to change the adapter option `:path:` to `:file:` to match moneta's new API.
|
|
65
|
-
1. **IMPORTANT:** If you are using the yaml backend you need to migrate the current data *before* using the new iuid version! You can migrate the datastore by using the following two sed commands `sed -i -e :a -e '$!N;s/\n value: //;ta' -e 'P;D' /PATH/TO/iuid_date.yaml` && `sed -i 's/^ / /' /PATH/TO/iuid_date.yaml`.
|
|
66
92
|
|
|
67
93
|
## Contributing to iuid
|
|
68
94
|
|
|
@@ -78,4 +104,3 @@ Simply build and install the gem.
|
|
|
78
104
|
|
|
79
105
|
Copyright (c) 2011 mh. See LICENSE.txt for
|
|
80
106
|
further details.
|
|
81
|
-
|
data/bin/iuid
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
#!/usr/bin/env ruby
|
|
2
|
-
#
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
# CLI client for iuid.
|
|
3
5
|
#
|
|
4
6
|
require 'rubygems'
|
|
5
7
|
require 'iuid'
|
|
6
8
|
require 'optparse'
|
|
7
9
|
require 'yaml'
|
|
8
10
|
|
|
9
|
-
options = { :
|
|
11
|
+
options = { config_file: nil }
|
|
10
12
|
|
|
11
13
|
OptionParser.new do |opts|
|
|
12
|
-
opts.on(
|
|
13
|
-
puts
|
|
14
|
+
opts.on('--version', '-V', 'Version information') do
|
|
15
|
+
puts Iuid::VERSION::STRING
|
|
14
16
|
exit
|
|
15
17
|
end
|
|
16
18
|
|
|
17
|
-
opts.on(
|
|
19
|
+
opts.on('--config CONFIG', '-c', 'Configuration file') do |v|
|
|
18
20
|
if File.exist?(v)
|
|
19
21
|
options[:config_file] = v
|
|
20
22
|
else
|
|
21
|
-
|
|
23
|
+
warn "Cannot find config file: #{v}"
|
|
22
24
|
exit 1
|
|
23
25
|
end
|
|
24
26
|
end
|
|
@@ -37,11 +39,12 @@ def get(options)
|
|
|
37
39
|
options.delete(:name)
|
|
38
40
|
)
|
|
39
41
|
end
|
|
42
|
+
|
|
40
43
|
def set(options)
|
|
41
|
-
miss('uid') unless options[:category]
|
|
44
|
+
miss('uid') unless options[:category] # this is actually the uid
|
|
42
45
|
Iuid.new(options.delete(:config_file)).set(
|
|
43
46
|
options.delete(:name),
|
|
44
|
-
options.delete(:category)
|
|
47
|
+
options.delete(:category).to_i
|
|
45
48
|
)
|
|
46
49
|
end
|
|
47
50
|
|
|
@@ -52,25 +55,24 @@ def delete(options)
|
|
|
52
55
|
end
|
|
53
56
|
|
|
54
57
|
def miss(what)
|
|
55
|
-
|
|
58
|
+
warn "Missing #{what}, exiting..."
|
|
56
59
|
exit 1
|
|
57
60
|
end
|
|
58
61
|
|
|
59
|
-
actions=[
|
|
62
|
+
actions = %w[create get set delete]
|
|
60
63
|
|
|
61
|
-
if
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
end
|
|
68
|
-
rescue Exception => e
|
|
69
|
-
STDERR.puts "Action failed with the following message: #{e.message}" unless e.message == 'exit'
|
|
70
|
-
exit 1
|
|
64
|
+
if ARGV.length >= 2 && (action = ARGV.shift) && actions.include?(action)
|
|
65
|
+
options[:name] = ARGV.shift
|
|
66
|
+
options[:category] = ARGV.shift
|
|
67
|
+
begin
|
|
68
|
+
if (result = send(action, options))
|
|
69
|
+
puts result.is_a?(String) ? result : result.inspect
|
|
71
70
|
end
|
|
72
|
-
|
|
73
|
-
|
|
71
|
+
rescue StandardError => e
|
|
72
|
+
warn "Action failed with the following message: #{e.message}" unless e.message == 'exit'
|
|
74
73
|
exit 1
|
|
74
|
+
end
|
|
75
|
+
else
|
|
76
|
+
warn "Please supply one of the following actions: #{actions.join(', ')}"
|
|
77
|
+
exit 1
|
|
75
78
|
end
|
|
76
|
-
|
data/lib/iuid/version.rb
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
|
-
#
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
2
3
|
class Iuid
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
MAJOR = version['major']
|
|
12
|
-
MINOR = version['minor']
|
|
13
|
-
PATCH = version['patch']
|
|
14
|
-
BUILD = version['build']
|
|
15
|
-
|
|
4
|
+
module VERSION
|
|
5
|
+
MAJOR = 0
|
|
6
|
+
MINOR = 1
|
|
7
|
+
PATCH = 0
|
|
8
|
+
BUILD = nil
|
|
9
|
+
|
|
16
10
|
STRING = [MAJOR, MINOR, PATCH, BUILD].compact.join('.')
|
|
17
|
-
|
|
11
|
+
|
|
18
12
|
def self.version
|
|
19
13
|
STRING
|
|
20
14
|
end
|
|
15
|
+
|
|
16
|
+
def self.to_s
|
|
17
|
+
STRING
|
|
18
|
+
end
|
|
21
19
|
end
|
|
22
20
|
end
|
data/lib/iuid.rb
CHANGED
|
@@ -1,49 +1,52 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'iuid/version'
|
|
2
4
|
|
|
3
5
|
class Iuid
|
|
4
|
-
|
|
5
|
-
def initialize(config_file=nil)
|
|
6
|
+
def initialize(config_file = nil)
|
|
6
7
|
if config_file
|
|
7
8
|
@config_file = File.expand_path(config_file)
|
|
8
|
-
elsif File.
|
|
9
|
+
elsif File.exist?(def_config_file = File.expand_path('~/.iuid.yaml')) || File.exist?(def_config_file = File.expand_path('/etc/iuid.yaml'))
|
|
9
10
|
@config_file = def_config_file
|
|
10
11
|
end
|
|
11
12
|
end
|
|
12
13
|
|
|
13
|
-
def create(name,category)
|
|
14
|
-
unless (uid=get(name)).nil?
|
|
14
|
+
def create(name, category)
|
|
15
|
+
unless (uid = get(name)).nil?
|
|
15
16
|
return uid
|
|
16
17
|
end
|
|
17
18
|
|
|
18
|
-
set(name,next_uid(category))
|
|
19
|
+
set(name, next_uid(category))
|
|
19
20
|
end
|
|
20
|
-
|
|
21
|
+
|
|
21
22
|
def get(name)
|
|
22
23
|
cache.fetch(name)
|
|
23
24
|
end
|
|
24
|
-
|
|
25
|
+
|
|
25
26
|
def delete(name)
|
|
26
27
|
cache.delete(name)
|
|
27
28
|
end
|
|
28
|
-
|
|
29
|
-
def set(name,uid)
|
|
29
|
+
|
|
30
|
+
def set(name, uid)
|
|
31
|
+
uid = uid.to_i if uid.is_a?(String) && uid =~ /\A\d+\z/
|
|
30
32
|
cache[name] = uid
|
|
31
|
-
cache['_all_uids'] = (alluids | [
|
|
33
|
+
cache['_all_uids'] = (alluids | [uid])
|
|
32
34
|
uid
|
|
33
35
|
end
|
|
34
36
|
|
|
35
37
|
protected
|
|
36
38
|
|
|
37
39
|
def next_uid(category)
|
|
38
|
-
raise "Category #{category} is not configured!" unless max_uid=categories[category]
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
raise "Category #{category} is not configured!" unless (max_uid = categories[category])
|
|
41
|
+
|
|
42
|
+
if (curr_uid = cache["_category_#{category}_curr_uid"]) || (max_uid && alluids.include?(curr_uid = max_uid))
|
|
43
|
+
uid = curr_uid + 1
|
|
44
|
+
while alluids.include?(uid)
|
|
45
|
+
uid += 1
|
|
43
46
|
end
|
|
44
47
|
raise "Max uid is 4294967295" if uid > 4294967295
|
|
45
|
-
if coll_category = categories.keys.find{|c| categories[c] > max_uid && uid >= categories[c] }
|
|
46
|
-
raise "Next available uid
|
|
48
|
+
if (coll_category = categories.keys.find { |c| categories[c] > max_uid && uid >= categories[c] })
|
|
49
|
+
raise "Next available uid #{uid} collides with category #{coll_category}"
|
|
47
50
|
end
|
|
48
51
|
else
|
|
49
52
|
uid = max_uid
|
|
@@ -51,42 +54,45 @@ class Iuid
|
|
|
51
54
|
cache["_category_#{category}_curr_uid"] = uid
|
|
52
55
|
uid
|
|
53
56
|
end
|
|
54
|
-
|
|
57
|
+
|
|
55
58
|
private
|
|
59
|
+
|
|
56
60
|
def cache
|
|
57
61
|
@cache ||= build_cache
|
|
58
62
|
end
|
|
59
63
|
|
|
60
64
|
def alluids
|
|
61
|
-
cache.fetch('_all_uids',[])
|
|
65
|
+
cache.fetch('_all_uids', [])
|
|
62
66
|
end
|
|
63
67
|
|
|
64
68
|
def categories
|
|
65
69
|
config['categories'] || {}
|
|
66
70
|
end
|
|
67
|
-
|
|
71
|
+
|
|
68
72
|
def build_cache
|
|
69
73
|
require 'moneta'
|
|
70
74
|
lconfig = config
|
|
71
|
-
Moneta.new(lconfig['adapter'], lconfig['adapter_options']||{})
|
|
75
|
+
Moneta.new(lconfig['adapter'], lconfig['adapter_options'] || {})
|
|
72
76
|
end
|
|
73
|
-
|
|
77
|
+
|
|
74
78
|
def config
|
|
75
79
|
@config ||= read_config
|
|
76
80
|
end
|
|
77
|
-
|
|
81
|
+
|
|
78
82
|
def read_config
|
|
79
83
|
if @config_file.nil?
|
|
80
84
|
default_config
|
|
81
85
|
else
|
|
82
|
-
raise "Configfile #{@config_file} does not exist!" unless File.
|
|
83
|
-
|
|
86
|
+
raise "Configfile #{@config_file} does not exist!" unless File.exist?(@config_file)
|
|
87
|
+
|
|
88
|
+
config_data = YAML.respond_to?(:unsafe_load) ? YAML.unsafe_load(File.read(@config_file)) : YAML.load(File.read(@config_file))
|
|
89
|
+
default_config.merge(config_data)
|
|
84
90
|
end
|
|
85
91
|
end
|
|
86
|
-
|
|
92
|
+
|
|
87
93
|
def default_config
|
|
88
|
-
|
|
89
|
-
|
|
94
|
+
require 'yaml'
|
|
95
|
+
file = File.expand_path(File.join(File.dirname(__FILE__), 'iuid', 'default_config.yaml'))
|
|
96
|
+
YAML.respond_to?(:unsafe_load) ? YAML.unsafe_load(File.read(file)) : YAML.load(File.read(file))
|
|
90
97
|
end
|
|
91
|
-
|
|
92
98
|
end
|
metadata
CHANGED
|
@@ -1,116 +1,123 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: iuid
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0
|
|
4
|
+
version: 0.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- mh
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-11-05 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: moneta
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
17
|
+
- - "~>"
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
19
|
+
version: '1.6'
|
|
20
20
|
type: :runtime
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
|
-
- - "
|
|
24
|
+
- - "~>"
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
26
|
+
version: '1.6'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
name:
|
|
28
|
+
name: pstore
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
|
-
- - "
|
|
31
|
+
- - "~>"
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '0'
|
|
34
|
-
type: :
|
|
33
|
+
version: '0.2'
|
|
34
|
+
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
|
-
- - "
|
|
38
|
+
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '0'
|
|
40
|
+
version: '0.2'
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name:
|
|
42
|
+
name: rake
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
44
44
|
requirements:
|
|
45
|
-
- - "
|
|
45
|
+
- - "~>"
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '0'
|
|
47
|
+
version: '13.0'
|
|
48
48
|
type: :development
|
|
49
49
|
prerelease: false
|
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
|
52
|
-
- - "
|
|
52
|
+
- - "~>"
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '0'
|
|
54
|
+
version: '13.0'
|
|
55
55
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name:
|
|
56
|
+
name: rspec
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
|
-
- - "
|
|
59
|
+
- - "~>"
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '
|
|
61
|
+
version: '3.13'
|
|
62
62
|
type: :development
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
|
-
- - "
|
|
66
|
+
- - "~>"
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: '
|
|
68
|
+
version: '3.13'
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
70
|
name: rspec-pending_for
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
72
72
|
requirements:
|
|
73
|
-
- - "
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0.1'
|
|
76
|
+
type: :development
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0.1'
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: rdoc
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - "~>"
|
|
74
88
|
- !ruby/object:Gem::Version
|
|
75
|
-
version: '0'
|
|
89
|
+
version: '7.0'
|
|
76
90
|
type: :development
|
|
77
91
|
prerelease: false
|
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
|
79
93
|
requirements:
|
|
80
|
-
- - "
|
|
94
|
+
- - "~>"
|
|
81
95
|
- !ruby/object:Gem::Version
|
|
82
|
-
version: '0'
|
|
96
|
+
version: '7.0'
|
|
83
97
|
description: Iuid generates and keeps uids stored. It generates the next unique uid
|
|
84
98
|
based on a category range
|
|
85
|
-
email:
|
|
99
|
+
email:
|
|
100
|
+
- mh+iuid@immerda.ch
|
|
86
101
|
executables:
|
|
87
102
|
- iuid
|
|
88
103
|
extensions: []
|
|
89
|
-
extra_rdoc_files:
|
|
90
|
-
- LICENSE.txt
|
|
91
|
-
- README.md
|
|
104
|
+
extra_rdoc_files: []
|
|
92
105
|
files:
|
|
93
|
-
-
|
|
94
|
-
- ".rspec"
|
|
95
|
-
- ".travis.yml"
|
|
96
|
-
- Gemfile
|
|
106
|
+
- CHANGELOG.md
|
|
97
107
|
- LICENSE.txt
|
|
98
108
|
- README.md
|
|
99
|
-
- Rakefile
|
|
100
109
|
- bin/iuid
|
|
101
|
-
- iuid.gemspec
|
|
102
|
-
- lib/VERSION
|
|
103
110
|
- lib/iuid.rb
|
|
104
111
|
- lib/iuid/default_config.yaml
|
|
105
112
|
- lib/iuid/version.rb
|
|
106
|
-
|
|
107
|
-
- spec/iuid_spec.rb
|
|
108
|
-
- spec/spec_helper.rb
|
|
109
|
-
homepage: http://www.immerda.ch
|
|
113
|
+
homepage: https://github.com/duritong/iuid
|
|
110
114
|
licenses:
|
|
111
|
-
-
|
|
112
|
-
metadata:
|
|
113
|
-
|
|
115
|
+
- GPL-3.0-or-later
|
|
116
|
+
metadata:
|
|
117
|
+
source_code_uri: https://github.com/duritong/iuid
|
|
118
|
+
bug_tracker_uri: https://github.com/duritong/iuid/issues
|
|
119
|
+
changelog_uri: https://github.com/duritong/iuid/blob/master/CHANGELOG.md
|
|
120
|
+
post_install_message:
|
|
114
121
|
rdoc_options: []
|
|
115
122
|
require_paths:
|
|
116
123
|
- lib
|
|
@@ -118,16 +125,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
118
125
|
requirements:
|
|
119
126
|
- - ">="
|
|
120
127
|
- !ruby/object:Gem::Version
|
|
121
|
-
version:
|
|
128
|
+
version: 3.1.0
|
|
122
129
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
130
|
requirements:
|
|
124
131
|
- - ">="
|
|
125
132
|
- !ruby/object:Gem::Version
|
|
126
133
|
version: '0'
|
|
127
134
|
requirements: []
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
signing_key:
|
|
135
|
+
rubygems_version: 3.5.22
|
|
136
|
+
signing_key:
|
|
131
137
|
specification_version: 4
|
|
132
138
|
summary: Iuid a simple uid generator and storage
|
|
133
139
|
test_files: []
|
data/.document
DELETED
data/.rspec
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
--color
|
data/.travis.yml
DELETED
data/Gemfile
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
source "http://rubygems.org"
|
|
2
|
-
# Add dependencies required to use your gem here.
|
|
3
|
-
# Example:
|
|
4
|
-
# gem "activesupport", ">= 2.3.5"
|
|
5
|
-
|
|
6
|
-
if RUBY_VERSION.to_f > 1.8
|
|
7
|
-
gem "moneta"
|
|
8
|
-
else
|
|
9
|
-
gem "moneta", "~> 0.7.20"
|
|
10
|
-
gem "highline", "~> 1.6.2"
|
|
11
|
-
gem 'rake', '< 11'
|
|
12
|
-
gem 'git', '< 1.3'
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
group :development do
|
|
16
|
-
if RUBY_VERSION.to_f > 1.8
|
|
17
|
-
gem "rspec"
|
|
18
|
-
gem "rdoc"
|
|
19
|
-
gem "jeweler"
|
|
20
|
-
else
|
|
21
|
-
gem "rspec", "~> 2.4"
|
|
22
|
-
gem "rdoc", "~> 3.8"
|
|
23
|
-
gem "jeweler", "~> 1.6"
|
|
24
|
-
gem "addressable", "~> 2.3.8"
|
|
25
|
-
end
|
|
26
|
-
gem 'rspec-pending_for'
|
|
27
|
-
end
|
data/Rakefile
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
require 'rubygems'
|
|
4
|
-
require 'bundler'
|
|
5
|
-
begin
|
|
6
|
-
Bundler.setup(:default, :development)
|
|
7
|
-
rescue Bundler::BundlerError => e
|
|
8
|
-
$stderr.puts e.message
|
|
9
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
|
10
|
-
exit e.status_code
|
|
11
|
-
end
|
|
12
|
-
require 'rake'
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
require 'jeweler'
|
|
16
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'lib'))
|
|
17
|
-
require 'iuid'
|
|
18
|
-
Jeweler::Tasks.new do |gem|
|
|
19
|
-
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
|
20
|
-
gem.name = "iuid"
|
|
21
|
-
gem.homepage = "http://www.immerda.ch"
|
|
22
|
-
gem.license = "GPLv3"
|
|
23
|
-
gem.summary = "Iuid a simple uid generator and storage"
|
|
24
|
-
gem.description = "Iuid generates and keeps uids stored. It generates the next unique uid based on a category range"
|
|
25
|
-
gem.email = "mh+iuid@immerda.ch"
|
|
26
|
-
gem.authors = ["mh"]
|
|
27
|
-
gem.version = Iuid::VERSION::STRING
|
|
28
|
-
# dependencies defined in Gemfile
|
|
29
|
-
end
|
|
30
|
-
Jeweler::RubygemsDotOrgTasks.new
|
|
31
|
-
|
|
32
|
-
require 'rspec/core'
|
|
33
|
-
require 'rspec/core/rake_task'
|
|
34
|
-
RSpec::Core::RakeTask.new(:spec) do |spec|
|
|
35
|
-
spec.pattern = FileList['spec/**/*_spec.rb']
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
RSpec::Core::RakeTask.new(:rcov) do |spec|
|
|
39
|
-
spec.pattern = 'spec/**/*_spec.rb'
|
|
40
|
-
spec.rcov = true
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
task :default => :spec
|
|
44
|
-
|
|
45
|
-
gem 'rdoc'
|
|
46
|
-
require 'rdoc/task'
|
|
47
|
-
RDoc::Task.new do |rdoc|
|
|
48
|
-
version = Iuid::VERSION::STRING
|
|
49
|
-
rdoc.rdoc_dir = 'rdoc'
|
|
50
|
-
rdoc.title = "iuid #{version}"
|
|
51
|
-
rdoc.rdoc_files.include('README*')
|
|
52
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
53
|
-
end
|
data/iuid.gemspec
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
# Generated by jeweler
|
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
|
4
|
-
# -*- encoding: utf-8 -*-
|
|
5
|
-
# stub: iuid 0.0.4 ruby lib
|
|
6
|
-
|
|
7
|
-
Gem::Specification.new do |s|
|
|
8
|
-
s.name = "iuid"
|
|
9
|
-
s.version = "0.0.4"
|
|
10
|
-
|
|
11
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
12
|
-
s.require_paths = ["lib"]
|
|
13
|
-
s.authors = ["mh"]
|
|
14
|
-
s.date = "2016-05-27"
|
|
15
|
-
s.description = "Iuid generates and keeps uids stored. It generates the next unique uid based on a category range"
|
|
16
|
-
s.email = "mh+iuid@immerda.ch"
|
|
17
|
-
s.executables = ["iuid"]
|
|
18
|
-
s.extra_rdoc_files = [
|
|
19
|
-
"LICENSE.txt",
|
|
20
|
-
"README.md"
|
|
21
|
-
]
|
|
22
|
-
s.files = [
|
|
23
|
-
".document",
|
|
24
|
-
".rspec",
|
|
25
|
-
".travis.yml",
|
|
26
|
-
"Gemfile",
|
|
27
|
-
"LICENSE.txt",
|
|
28
|
-
"README.md",
|
|
29
|
-
"Rakefile",
|
|
30
|
-
"bin/iuid",
|
|
31
|
-
"iuid.gemspec",
|
|
32
|
-
"lib/VERSION",
|
|
33
|
-
"lib/iuid.rb",
|
|
34
|
-
"lib/iuid/default_config.yaml",
|
|
35
|
-
"lib/iuid/version.rb",
|
|
36
|
-
"spec/data/.keep",
|
|
37
|
-
"spec/iuid_spec.rb",
|
|
38
|
-
"spec/spec_helper.rb"
|
|
39
|
-
]
|
|
40
|
-
s.homepage = "http://www.immerda.ch"
|
|
41
|
-
s.licenses = ["GPLv3"]
|
|
42
|
-
s.rubygems_version = "2.3.0"
|
|
43
|
-
s.summary = "Iuid a simple uid generator and storage"
|
|
44
|
-
|
|
45
|
-
if s.respond_to? :specification_version then
|
|
46
|
-
s.specification_version = 4
|
|
47
|
-
|
|
48
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
|
49
|
-
s.add_runtime_dependency(%q<moneta>, [">= 0"])
|
|
50
|
-
s.add_development_dependency(%q<rspec>, [">= 0"])
|
|
51
|
-
s.add_development_dependency(%q<rdoc>, [">= 0"])
|
|
52
|
-
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
|
53
|
-
s.add_development_dependency(%q<rspec-pending_for>, [">= 0"])
|
|
54
|
-
else
|
|
55
|
-
s.add_dependency(%q<moneta>, [">= 0"])
|
|
56
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
|
57
|
-
s.add_dependency(%q<rdoc>, [">= 0"])
|
|
58
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
|
59
|
-
s.add_dependency(%q<rspec-pending_for>, [">= 0"])
|
|
60
|
-
end
|
|
61
|
-
else
|
|
62
|
-
s.add_dependency(%q<moneta>, [">= 0"])
|
|
63
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
|
64
|
-
s.add_dependency(%q<rdoc>, [">= 0"])
|
|
65
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
|
66
|
-
s.add_dependency(%q<rspec-pending_for>, [">= 0"])
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
|
data/lib/VERSION
DELETED
data/spec/data/.keep
DELETED
|
File without changes
|
data/spec/iuid_spec.rb
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
|
-
|
|
3
|
-
describe "Iuid" do
|
|
4
|
-
|
|
5
|
-
context 'with config' do
|
|
6
|
-
before(:each) do
|
|
7
|
-
expect_any_instance_of(Iuid).to receive(:read_config).and_return(test_config)
|
|
8
|
-
end
|
|
9
|
-
let!(:iuid) do
|
|
10
|
-
Iuid.new
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
describe "get" do
|
|
14
|
-
it "should return nil as default" do
|
|
15
|
-
expect(iuid.get('get_test')).to be_nil
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
describe "create" do
|
|
20
|
-
it "should create a new uid if not yet present" do
|
|
21
|
-
expect(iuid.get('create_test')).to be_nil
|
|
22
|
-
expect(iuid.create('create_test','global')).to eql(100)
|
|
23
|
-
expect(iuid.get('create_test')).to eql(100)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
it "should increase the next uid by one" do
|
|
27
|
-
expect(iuid.get('create_test2')).to be_nil
|
|
28
|
-
|
|
29
|
-
expect(iuid.create('create_test2','global')).to eql(100)
|
|
30
|
-
expect(iuid.get('create_test2')).to eql(100)
|
|
31
|
-
|
|
32
|
-
expect(iuid.create('create_test3','global')).to eql(101)
|
|
33
|
-
expect(iuid.get('create_test3')).to eql(101)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
it "should raise an exception if the next category is reached" do
|
|
37
|
-
expect(iuid.create('create_test4','global2')).to eql(200)
|
|
38
|
-
expect{ iuid.create('create_test5','global2') }.to raise_error(Exception)
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
it "should not create an existing uid" do
|
|
42
|
-
expect(iuid.set('double_test1',100)).to eql(100)
|
|
43
|
-
expect(iuid.create('double_test2','global')).to eql(101)
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
it "should not create an uid > 4294967295" do
|
|
47
|
-
expect(iuid.create('max_test1','max')).to eql(4294967295)
|
|
48
|
-
expect { iuid.create('max_test2','max') }.to raise_error(Exception)
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
describe "set" do
|
|
53
|
-
it "should set an uid and return it" do
|
|
54
|
-
expect(iuid.get('set_test1')).to be_nil
|
|
55
|
-
expect(iuid.set('set_test1',100)).to eql(100)
|
|
56
|
-
expect(iuid.get('set_test1')).not_to be_nil
|
|
57
|
-
expect(iuid.get('set_test1')).to be(100)
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
describe "delete" do
|
|
62
|
-
it "should delete a given uid" do
|
|
63
|
-
expect(iuid.create('delete_test1','global')).not_to be_nil
|
|
64
|
-
expect(iuid.get('delete_test1')).not_to be_nil
|
|
65
|
-
expect(iuid.delete('delete_test1')).not_to be_nil
|
|
66
|
-
expect(iuid.get('delete_test1')).to be_nil
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
describe "VERSION" do
|
|
72
|
-
it "should return a version" do
|
|
73
|
-
expect(Iuid::VERSION::STRING).not_to be_empty
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
end
|
data/spec/spec_helper.rb
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
2
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
|
3
|
-
require 'rspec'
|
|
4
|
-
require 'yaml'
|
|
5
|
-
require 'iuid'
|
|
6
|
-
|
|
7
|
-
# Requires supporting files with custom matchers and macros, etc,
|
|
8
|
-
# in ./support/ and its subdirectories.
|
|
9
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
|
10
|
-
|
|
11
|
-
def default_config
|
|
12
|
-
@default_config ||= YAML.load(File.read(File.expand_path(base_dir+'/lib/iuid/default_config.yaml')))
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def test_config
|
|
16
|
-
return @config unless @config.nil?
|
|
17
|
-
@config = default_config
|
|
18
|
-
@config['categories'] = {
|
|
19
|
-
'global' => 100,
|
|
20
|
-
'global2' => 200,
|
|
21
|
-
'global3' => 201,
|
|
22
|
-
'max' => 4294967295
|
|
23
|
-
}
|
|
24
|
-
@config['adapter'] = :Memory
|
|
25
|
-
@config.delete('adapter_options')
|
|
26
|
-
@config
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def base_dir
|
|
30
|
-
File.dirname(__FILE__)+'/../'
|
|
31
|
-
end
|