ruslan_first_gem 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.
- data/Manifest +4 -0
- data/README.rdoc +5 -0
- data/Rakefile +14 -0
- data/lib/ruslan_first_gem.rb +34 -0
- data/ruslan_first_gem.gemspec +30 -0
- metadata +78 -0
data/Manifest
ADDED
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'echoe'
|
4
|
+
|
5
|
+
Echoe.new('ruslan_first_gem', '0.1.0') do |p|
|
6
|
+
p.description = "Generate a ruslan token with ActiveRecord"
|
7
|
+
p.url = "https://github.com/RuslanHamidullin/ruslan_first_gem"
|
8
|
+
p.author = "Ruslan Hamidullin"
|
9
|
+
p.email = "ruslan.hamidullin@flatsoft.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 }
|
@@ -0,0 +1,34 @@
|
|
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
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
class ActiveRecord::Base
|
33
|
+
include Uniquify
|
34
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{ruslan_first_gem}
|
5
|
+
s.version = "0.1.0"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Ruslan Hamidullin"]
|
9
|
+
s.date = %q{2010-12-03}
|
10
|
+
s.description = %q{Generate a ruslan token with ActiveRecord}
|
11
|
+
s.email = %q{ruslan.hamidullin@flatsoft.com}
|
12
|
+
s.extra_rdoc_files = ["README.rdoc", "lib/ruslan_first_gem.rb"]
|
13
|
+
s.files = ["README.rdoc", "Rakefile", "lib/ruslan_first_gem.rb", "Manifest", "ruslan_first_gem.gemspec"]
|
14
|
+
s.homepage = %q{https://github.com/RuslanHamidullin/ruslan_first_gem}
|
15
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Ruslan_first_gem", "--main", "README.rdoc"]
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
s.rubyforge_project = %q{ruslan_first_gem}
|
18
|
+
s.rubygems_version = %q{1.3.7}
|
19
|
+
s.summary = %q{Generate a ruslan token with ActiveRecord}
|
20
|
+
|
21
|
+
if s.respond_to? :specification_version then
|
22
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
23
|
+
s.specification_version = 3
|
24
|
+
|
25
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
26
|
+
else
|
27
|
+
end
|
28
|
+
else
|
29
|
+
end
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruslan_first_gem
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 0
|
10
|
+
version: 0.1.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Ruslan Hamidullin
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-12-03 00:00:00 +03:00
|
19
|
+
default_executable:
|
20
|
+
dependencies: []
|
21
|
+
|
22
|
+
description: Generate a ruslan token with ActiveRecord
|
23
|
+
email: ruslan.hamidullin@flatsoft.com
|
24
|
+
executables: []
|
25
|
+
|
26
|
+
extensions: []
|
27
|
+
|
28
|
+
extra_rdoc_files:
|
29
|
+
- README.rdoc
|
30
|
+
- lib/ruslan_first_gem.rb
|
31
|
+
files:
|
32
|
+
- README.rdoc
|
33
|
+
- Rakefile
|
34
|
+
- lib/ruslan_first_gem.rb
|
35
|
+
- Manifest
|
36
|
+
- ruslan_first_gem.gemspec
|
37
|
+
has_rdoc: true
|
38
|
+
homepage: https://github.com/RuslanHamidullin/ruslan_first_gem
|
39
|
+
licenses: []
|
40
|
+
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options:
|
43
|
+
- --line-numbers
|
44
|
+
- --inline-source
|
45
|
+
- --title
|
46
|
+
- Ruslan_first_gem
|
47
|
+
- --main
|
48
|
+
- README.rdoc
|
49
|
+
require_paths:
|
50
|
+
- lib
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
hash: 3
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
version: "0"
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
hash: 11
|
66
|
+
segments:
|
67
|
+
- 1
|
68
|
+
- 2
|
69
|
+
version: "1.2"
|
70
|
+
requirements: []
|
71
|
+
|
72
|
+
rubyforge_project: ruslan_first_gem
|
73
|
+
rubygems_version: 1.3.7
|
74
|
+
signing_key:
|
75
|
+
specification_version: 3
|
76
|
+
summary: Generate a ruslan token with ActiveRecord
|
77
|
+
test_files: []
|
78
|
+
|