push_me 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Manifest +4 -0
- data/README.rdoc +0 -0
- data/Rakefile +14 -0
- data/lib/push.rb +35 -0
- data/push_me.gemspec +21 -0
- metadata +54 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a46e1af334d99b90a02c1ca603e557579f924688
|
4
|
+
data.tar.gz: 8b8387cc5247470d8a9e1f9e9797f307ace145f9
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c7efd848fe0c247395c0d55311e6a91644f6b21b10baa6dc77afba5201307a410a948bbacb04a0ad73a52e488d8087104ee102e592733c1797aa0c39b69eadd5
|
7
|
+
data.tar.gz: 093d02319ad14165117bf905fda4a047a77480d33e7a288fb07ffa2d250112d017ee15e22715c456012dad86a23cfc30418c2594147683490d3521ed50dea383
|
data/Manifest
ADDED
data/README.rdoc
ADDED
File without changes
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'echoe'
|
4
|
+
|
5
|
+
Echoe.new('push_me', '0.1.0') do |p|
|
6
|
+
p.description = "Generate a unique token with ActiveRecord"
|
7
|
+
p.url = "http://github.com/eifion/uniquify"
|
8
|
+
p.author = "Eifion Bedford"
|
9
|
+
p.email = "eifion@asciicasts.com"
|
10
|
+
p.ignore_pattern = ["tmp/*", "script/*"]
|
11
|
+
p.development_dependencies = []
|
12
|
+
end
|
13
|
+
|
14
|
+
Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
|
data/lib/push.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
module Uniquify
|
2
|
+
def self.included(base)
|
3
|
+
base.extend ClassMethods
|
4
|
+
end
|
5
|
+
|
6
|
+
def ensure_unique(name)
|
7
|
+
begin
|
8
|
+
self[name] = yield
|
9
|
+
end while self.class.exists?(name => self[name])
|
10
|
+
end
|
11
|
+
|
12
|
+
module ClassMethods
|
13
|
+
|
14
|
+
def uniquify(*args, &block)
|
15
|
+
options = { :length => 8, :chars => ('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a }
|
16
|
+
options.merge!(args.pop) if args.last.kind_of? Hash
|
17
|
+
args.each do |name|
|
18
|
+
before_create do |record|
|
19
|
+
if block
|
20
|
+
record.ensure_unique(name, &block)
|
21
|
+
else
|
22
|
+
record.ensure_unique(name) do
|
23
|
+
Array.new(options[:length]) { options[:chars].to_a[rand(options[:chars].to_a.size)] }.join
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class ActiveRecord::Base
|
34
|
+
include Uniquify
|
35
|
+
end
|
data/push_me.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# stub: push_me 0.1.0 ruby lib
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "push_me"
|
6
|
+
s.version = "0.1.0"
|
7
|
+
|
8
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
9
|
+
s.authors = ["Eifion Bedford"]
|
10
|
+
s.date = "2013-12-11"
|
11
|
+
s.description = "Generate a unique token with ActiveRecord"
|
12
|
+
s.email = "eifion@asciicasts.com"
|
13
|
+
s.extra_rdoc_files = ["README.rdoc", "lib/push.rb"]
|
14
|
+
s.files = ["README.rdoc", "Rakefile", "lib/push.rb", "Manifest", "push_me.gemspec"]
|
15
|
+
s.homepage = "http://github.com/eifion/uniquify"
|
16
|
+
s.rdoc_options = ["--line-numbers", "--title", "Push_me", "--main", "README.rdoc"]
|
17
|
+
s.require_paths = ["lib"]
|
18
|
+
s.rubyforge_project = "push_me"
|
19
|
+
s.rubygems_version = "2.1.10"
|
20
|
+
s.summary = "Generate a unique token with ActiveRecord"
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: push_me
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Eifion Bedford
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-12-11 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Generate a unique token with ActiveRecord
|
14
|
+
email: eifion@asciicasts.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files:
|
18
|
+
- README.rdoc
|
19
|
+
- lib/push.rb
|
20
|
+
files:
|
21
|
+
- README.rdoc
|
22
|
+
- Rakefile
|
23
|
+
- lib/push.rb
|
24
|
+
- Manifest
|
25
|
+
- push_me.gemspec
|
26
|
+
homepage: http://github.com/eifion/uniquify
|
27
|
+
licenses: []
|
28
|
+
metadata: {}
|
29
|
+
post_install_message:
|
30
|
+
rdoc_options:
|
31
|
+
- --line-numbers
|
32
|
+
- --title
|
33
|
+
- Push_me
|
34
|
+
- --main
|
35
|
+
- README.rdoc
|
36
|
+
require_paths:
|
37
|
+
- lib
|
38
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - '>='
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.2'
|
48
|
+
requirements: []
|
49
|
+
rubyforge_project: push_me
|
50
|
+
rubygems_version: 2.1.10
|
51
|
+
signing_key:
|
52
|
+
specification_version: 4
|
53
|
+
summary: Generate a unique token with ActiveRecord
|
54
|
+
test_files: []
|