iuid 0.0.3 → 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: '08a241e0c2524b734f3e1f6f4e5b9b993bd1fca67be120f14261c25247360bc6'
4
+ data.tar.gz: c9e26cf1e7177bc4ab0e43b96ab8a269c2a7585158f20e578c7cc0809bd6c380
5
+ SHA512:
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
- [![Build Status](https://travis-ci.org/duritong/iuid.png)](https://travis-ci.org/duritong/iuid)
2
+ [![Ruby](https://github.com/duritong/iuid/actions/workflows/ruby.yml/badge.svg)](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 plain
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
- ### to 0.0.3
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, trocla 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 trocla version! You can migrate the datastore by using the following two sed commands `sed -i 's/^ / /' /PATH/TO/trocla_data.yaml` && `sed -i '/^ value\:/d' /PATH/TO/trocla_data.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
- # CLI client for Trocla.
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 = { :config_file => nil }
11
+ options = { config_file: nil }
10
12
 
11
13
  OptionParser.new do |opts|
12
- opts.on("--version", "-V", "Version information") do
13
- puts Trocla::VERSION::STRING
14
+ opts.on('--version', '-V', 'Version information') do
15
+ puts Iuid::VERSION::STRING
14
16
  exit
15
17
  end
16
18
 
17
- opts.on("--config CONFIG", "-c", "Configuration file") do |v|
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
- STDERR.puts "Cannot find config file: #{v}"
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] # this is actually the uid
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
- STDERR.puts "Missing #{what}, exiting..."
58
+ warn "Missing #{what}, exiting..."
56
59
  exit 1
57
60
  end
58
61
 
59
- actions=['create','get','set','delete']
62
+ actions = %w[create get set delete]
60
63
 
61
- if !(ARGV.length < 2) && (action=ARGV.shift) && actions.include?(action)
62
- options[:name] = ARGV.shift
63
- options[:category] = ARGV.shift
64
- begin
65
- if result = send(action,options)
66
- puts result.is_a?(String) ? result : result.inspect
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
- else
73
- STDERR.puts "Please supply one of the following actions: #{actions.join(', ')}"
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
- # encoding: utf-8
1
+ # frozen_string_literal: true
2
+
2
3
  class Iuid
3
- class VERSION
4
- version = {}
5
- File.read(File.join(File.dirname(__FILE__), '../', 'VERSION')).each_line do |line|
6
- type, value = line.chomp.split(":")
7
- next if type =~ /^\s+$/ || value =~ /^\s+$/
8
- version[type] = value
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.exists?(def_config_file=File.expand_path('~/.iuid.yaml')) || File.exists?(def_config_file=File.expand_path('/etc/iuid.yaml'))
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 | [ uid ])
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
- if (curr_uid = cache["_category_#{category}_curr_uid"]) || max_uid && alluids.include?(curr_uid=max_uid)
40
- uid=curr_uid + 1
41
- while alluids.include?(uid)
42
- uid = curr_uid + 1
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 (uid) collides with category #{coll_category}"
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.exists?(@config_file)
83
- default_config.merge(YAML.load(File.read(@config_file)))
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
- require 'yaml'
89
- YAML.load(File.read(File.expand_path(File.join(File.dirname(__FILE__),'iuid','default_config.yaml'))))
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,190 +1,139 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: iuid
3
- version: !ruby/object:Gem::Version
4
- hash: 25
5
- prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 3
10
- version: 0.0.3
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - mh
14
- autorequire:
8
+ autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2013-01-14 00:00:00 +01:00
19
- default_executable: iuid
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- type: :runtime
11
+ date: 2026-11-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
23
14
  name: moneta
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :runtime
24
21
  prerelease: false
25
- version_requirements: &id001 !ruby/object:Gem::Requirement
26
- none: false
27
- requirements:
28
- - - ~>
29
- - !ruby/object:Gem::Version
30
- hash: 7
31
- segments:
32
- - 0
33
- - 7
34
- - 2
35
- version: 0.7.2
36
- requirement: *id001
37
- - !ruby/object:Gem::Dependency
38
- type: :development
39
- name: rspec
40
- prerelease: false
41
- version_requirements: &id002 !ruby/object:Gem::Requirement
42
- none: false
43
- requirements:
44
- - - ~>
45
- - !ruby/object:Gem::Version
46
- hash: 31
47
- segments:
48
- - 2
49
- - 4
50
- - 0
51
- version: 2.4.0
52
- requirement: *id002
53
- - !ruby/object:Gem::Dependency
54
- type: :development
55
- name: rdoc
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: pstore
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '0.2'
34
+ type: :runtime
56
35
  prerelease: false
57
- version_requirements: &id003 !ruby/object:Gem::Requirement
58
- none: false
59
- requirements:
60
- - - ~>
61
- - !ruby/object:Gem::Version
62
- hash: 23
63
- segments:
64
- - 3
65
- - 8
66
- version: "3.8"
67
- requirement: *id003
68
- - !ruby/object:Gem::Dependency
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '0.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '13.0'
69
48
  type: :development
70
- name: mocha
71
49
  prerelease: false
72
- version_requirements: &id004 !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- hash: 3
78
- segments:
79
- - 0
80
- version: "0"
81
- requirement: *id004
82
- - !ruby/object:Gem::Dependency
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '13.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.13'
83
62
  type: :development
84
- name: bundler
85
63
  prerelease: false
86
- version_requirements: &id005 !ruby/object:Gem::Requirement
87
- none: false
88
- requirements:
89
- - - ~>
90
- - !ruby/object:Gem::Version
91
- hash: 25
92
- segments:
93
- - 1
94
- - 2
95
- - 3
96
- version: 1.2.3
97
- requirement: *id005
98
- - !ruby/object:Gem::Dependency
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.13'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec-pending_for
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.1'
99
76
  type: :development
100
- name: jeweler
101
77
  prerelease: false
102
- version_requirements: &id006 !ruby/object:Gem::Requirement
103
- none: false
104
- requirements:
105
- - - ~>
106
- - !ruby/object:Gem::Version
107
- hash: 7
108
- segments:
109
- - 1
110
- - 6
111
- - 4
112
- version: 1.6.4
113
- requirement: *id006
114
- - !ruby/object:Gem::Dependency
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
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '7.0'
115
90
  type: :development
116
- name: rcov
117
91
  prerelease: false
118
- version_requirements: &id007 !ruby/object:Gem::Requirement
119
- none: false
120
- requirements:
121
- - - ">="
122
- - !ruby/object:Gem::Version
123
- hash: 3
124
- segments:
125
- - 0
126
- version: "0"
127
- requirement: *id007
128
- description: Iuid generates and keeps uids stored. It generates the next unique uid based on a category range
129
- email: mh+iuid@immerda.ch
130
- executables:
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '7.0'
97
+ description: Iuid generates and keeps uids stored. It generates the next unique uid
98
+ based on a category range
99
+ email:
100
+ - mh+iuid@immerda.ch
101
+ executables:
131
102
  - iuid
132
103
  extensions: []
133
-
134
- extra_rdoc_files:
135
- - LICENSE.txt
136
- - README.md
137
- files:
138
- - .document
139
- - .rspec
140
- - .travis.yml
141
- - Gemfile
142
- - Gemfile.lock
104
+ extra_rdoc_files: []
105
+ files:
106
+ - CHANGELOG.md
143
107
  - LICENSE.txt
144
108
  - README.md
145
- - Rakefile
146
109
  - bin/iuid
147
- - iuid.gemspec
148
- - lib/VERSION
149
110
  - lib/iuid.rb
150
111
  - lib/iuid/default_config.yaml
151
112
  - lib/iuid/version.rb
152
- - spec/data/.keep
153
- - spec/iuid_spec.rb
154
- - spec/spec_helper.rb
155
- has_rdoc: true
156
- homepage: http://www.immerda.ch
157
- licenses:
158
- - GPLv3
159
- post_install_message:
113
+ homepage: https://github.com/duritong/iuid
114
+ licenses:
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:
160
121
  rdoc_options: []
161
-
162
- require_paths:
122
+ require_paths:
163
123
  - lib
164
- required_ruby_version: !ruby/object:Gem::Requirement
165
- none: false
166
- requirements:
124
+ required_ruby_version: !ruby/object:Gem::Requirement
125
+ requirements:
167
126
  - - ">="
168
- - !ruby/object:Gem::Version
169
- hash: 3
170
- segments:
171
- - 0
172
- version: "0"
173
- required_rubygems_version: !ruby/object:Gem::Requirement
174
- none: false
175
- requirements:
127
+ - !ruby/object:Gem::Version
128
+ version: 3.1.0
129
+ required_rubygems_version: !ruby/object:Gem::Requirement
130
+ requirements:
176
131
  - - ">="
177
- - !ruby/object:Gem::Version
178
- hash: 3
179
- segments:
180
- - 0
181
- version: "0"
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
182
134
  requirements: []
183
-
184
- rubyforge_project:
185
- rubygems_version: 1.6.2
186
- signing_key:
187
- specification_version: 3
135
+ rubygems_version: 3.5.22
136
+ signing_key:
137
+ specification_version: 4
188
138
  summary: Iuid a simple uid generator and storage
189
139
  test_files: []
190
-
data/.document DELETED
@@ -1,4 +0,0 @@
1
- lib/**/*.rb
2
- bin/*
3
- -
4
- LICENSE.txt
data/.rspec DELETED
@@ -1 +0,0 @@
1
- --color
data/.travis.yml DELETED
@@ -1,4 +0,0 @@
1
- language: ruby
2
- rvm:
3
- - 1.9.3
4
- - 1.8.7
data/Gemfile DELETED
@@ -1,17 +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
- gem "moneta", "~> 0.7.2"
7
-
8
- # Add dependencies to develop your gem here.
9
- # Include everything needed to run rake, tests, features, etc.
10
- group :development do
11
- gem "rspec", "~> 2.4.0"
12
- gem "rdoc", "~> 3.8"
13
- gem "mocha"
14
- gem "bundler", "~> 1.2.3"
15
- gem "jeweler", "~> 1.6.4"
16
- gem "rcov", ">= 0"
17
- end
data/Gemfile.lock DELETED
@@ -1,34 +0,0 @@
1
- GEM
2
- remote: http://rubygems.org/
3
- specs:
4
- diff-lcs (1.1.3)
5
- git (1.2.5)
6
- jeweler (1.6.4)
7
- bundler (~> 1.0)
8
- git (>= 1.2.5)
9
- rake
10
- mocha (0.9.12)
11
- moneta (0.7.2)
12
- rake (0.9.2)
13
- rcov (0.9.9)
14
- rdoc (3.8)
15
- rspec (2.4.0)
16
- rspec-core (~> 2.4.0)
17
- rspec-expectations (~> 2.4.0)
18
- rspec-mocks (~> 2.4.0)
19
- rspec-core (2.4.0)
20
- rspec-expectations (2.4.0)
21
- diff-lcs (~> 1.1.2)
22
- rspec-mocks (2.4.0)
23
-
24
- PLATFORMS
25
- ruby
26
-
27
- DEPENDENCIES
28
- bundler (~> 1.2.3)
29
- jeweler (~> 1.6.4)
30
- mocha
31
- moneta (~> 0.7.2)
32
- rcov
33
- rdoc (~> 3.8)
34
- rspec (~> 2.4.0)
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,76 +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
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{iuid}
8
- s.version = "0.0.3"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["mh"]
12
- s.date = %q{2013-01-14}
13
- s.default_executable = %q{iuid}
14
- s.description = %q{Iuid generates and keeps uids stored. It generates the next unique uid based on a category range}
15
- s.email = %q{mh+iuid@immerda.ch}
16
- s.executables = ["iuid"]
17
- s.extra_rdoc_files = [
18
- "LICENSE.txt",
19
- "README.md"
20
- ]
21
- s.files = [
22
- ".document",
23
- ".rspec",
24
- ".travis.yml",
25
- "Gemfile",
26
- "Gemfile.lock",
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 = %q{http://www.immerda.ch}
41
- s.licenses = ["GPLv3"]
42
- s.require_paths = ["lib"]
43
- s.rubygems_version = %q{1.6.2}
44
- s.summary = %q{Iuid a simple uid generator and storage}
45
-
46
- if s.respond_to? :specification_version then
47
- s.specification_version = 3
48
-
49
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
50
- s.add_runtime_dependency(%q<moneta>, ["~> 0.7.2"])
51
- s.add_development_dependency(%q<rspec>, ["~> 2.4.0"])
52
- s.add_development_dependency(%q<rdoc>, ["~> 3.8"])
53
- s.add_development_dependency(%q<mocha>, [">= 0"])
54
- s.add_development_dependency(%q<bundler>, ["~> 1.2.3"])
55
- s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"])
56
- s.add_development_dependency(%q<rcov>, [">= 0"])
57
- else
58
- s.add_dependency(%q<moneta>, ["~> 0.7.2"])
59
- s.add_dependency(%q<rspec>, ["~> 2.4.0"])
60
- s.add_dependency(%q<rdoc>, ["~> 3.8"])
61
- s.add_dependency(%q<mocha>, [">= 0"])
62
- s.add_dependency(%q<bundler>, ["~> 1.2.3"])
63
- s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
64
- s.add_dependency(%q<rcov>, [">= 0"])
65
- end
66
- else
67
- s.add_dependency(%q<moneta>, ["~> 0.7.2"])
68
- s.add_dependency(%q<rspec>, ["~> 2.4.0"])
69
- s.add_dependency(%q<rdoc>, ["~> 3.8"])
70
- s.add_dependency(%q<mocha>, [">= 0"])
71
- s.add_dependency(%q<bundler>, ["~> 1.2.3"])
72
- s.add_dependency(%q<jeweler>, ["~> 1.6.4"])
73
- s.add_dependency(%q<rcov>, [">= 0"])
74
- end
75
- end
76
-
data/lib/VERSION DELETED
@@ -1,4 +0,0 @@
1
- major:0
2
- minor:0
3
- patch:3
4
- build:
data/spec/data/.keep DELETED
File without changes
data/spec/iuid_spec.rb DELETED
@@ -1,72 +0,0 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe "Iuid" do
4
-
5
- before(:each) do
6
- Iuid.any_instance.expects(:read_config).returns(test_config)
7
- @iuid = Iuid.new
8
- end
9
-
10
- describe "get" do
11
- it "should return nil as default" do
12
- @iuid.get('get_test').should be_nil
13
- end
14
- end
15
-
16
- describe "create" do
17
- it "should create a new uid if not yet present" do
18
- @iuid.get('create_test').should be_nil
19
- @iuid.create('create_test','global').should eql(100)
20
- @iuid.get('create_test').should eql(100)
21
- end
22
-
23
- it "should increase the next uid by one" do
24
- @iuid.get('create_test2').should be_nil
25
-
26
- @iuid.create('create_test2','global').should eql(100)
27
- @iuid.get('create_test2').should eql(100)
28
-
29
- @iuid.create('create_test3','global').should eql(101)
30
- @iuid.get('create_test3').should eql(101)
31
- end
32
-
33
- it "should raise an exception if the next category is reached" do
34
- @iuid.create('create_test4','global2').should eql(200)
35
- lambda { @iuid.create('create_test5','global2') }.should raise_error(Exception)
36
- end
37
-
38
- it "should not create an existing uid" do
39
- @iuid.set('double_test1',100).should eql(100)
40
- @iuid.create('double_test2','global').should eql(101)
41
- end
42
-
43
- it "should not create an uid > 4294967295" do
44
- @iuid.create('max_test1','max').should eql(4294967295)
45
- lambda { @iuid.create('max_test2','max') }.should raise_error(Exception)
46
- end
47
- end
48
-
49
- describe "set" do
50
- it "should set an uid and return it" do
51
- @iuid.get('set_test1').should be_nil
52
- @iuid.set('set_test1',100).should eql(100)
53
- @iuid.get('set_test1').should_not be_nil
54
- @iuid.get('set_test1').should be(100)
55
- end
56
- end
57
-
58
- describe "delete" do
59
- it "should delete a given uid" do
60
- @iuid.create('delete_test1','global').should_not be_nil
61
- @iuid.get('delete_test1').should_not be_nil
62
- @iuid.delete('delete_test1').should_not be_nil
63
- @iuid.get('delete_test1').should be_nil
64
- end
65
- end
66
-
67
- describe "VERSION" do
68
- it "should return a version" do
69
- Iuid::VERSION::STRING.should_not be_empty
70
- end
71
- end
72
- end
data/spec/spec_helper.rb DELETED
@@ -1,35 +0,0 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
- $LOAD_PATH.unshift(File.dirname(__FILE__))
3
- require 'rspec'
4
- require 'mocha'
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
- RSpec.configure do |config|
12
-
13
- end
14
-
15
- def default_config
16
- @default_config ||= YAML.load(File.read(File.expand_path(base_dir+'/lib/iuid/default_config.yaml')))
17
- end
18
-
19
- def test_config
20
- return @config unless @config.nil?
21
- @config = default_config
22
- @config['categories'] = {
23
- 'global' => 100,
24
- 'global2' => 200,
25
- 'global3' => 201,
26
- 'max' => 4294967295
27
- }
28
- @config['adapter'] = :Memory
29
- @config.delete('adapter_options')
30
- @config
31
- end
32
-
33
- def base_dir
34
- File.dirname(__FILE__)+'/../'
35
- end