uuids 0.0.1
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 +7 -0
- data/.rubocop.yml +58 -0
- data/LICENSE.rdoc +21 -0
- data/README.rdoc +154 -0
- data/Rakefile +41 -0
- data/app/models/uuids/uuid.rb +53 -0
- data/config/locales/en.yml +10 -0
- data/config/locales/ru.yml +10 -0
- data/db/migrate/20141016112506_create_uuids_uuids.rb +9 -0
- data/lib/tasks/uuids_tasks.rake +41 -0
- data/lib/uuids/engine.rb +12 -0
- data/lib/uuids/version.rb +4 -0
- data/lib/uuids.rb +7 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/models/record.rb +3 -0
- data/spec/dummy/app/views/layouts/application.html.erb +13 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config/application.rb +29 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +78 -0
- data/spec/dummy/config/environments/test.rb +39 -0
- data/spec/dummy/config/initializers/assets.rb +8 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/migrate/20141016113016_create_records.rb +8 -0
- data/spec/dummy/db/schema.rb +30 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +0 -0
- data/spec/dummy/log/test.log +2152 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/spec/factories/records.rb +4 -0
- data/spec/factories/uuids.rb +6 -0
- data/spec/models/uuids/uuid_spec.rb +58 -0
- data/spec/spec_helper.rb +11 -0
- data/spec/support/initializers/coveralls.rb +4 -0
- data/spec/support/initializers/database_cleaner.rb +24 -0
- data/spec/support/initializers/factory_girl_rails.rb +5 -0
- data/spec/support/initializers/focus.rb +5 -0
- data/spec/support/initializers/garbage_collection.rb +11 -0
- data/spec/support/initializers/i18n.rb +1 -0
- data/spec/support/initializers/migrations.rb +3 -0
- data/spec/support/initializers/rails.rb +6 -0
- data/spec/support/initializers/random_order.rb +4 -0
- data/spec/support/initializers/rspec.rb +10 -0
- metadata +279 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 6fa4c647a7c49ca3c8dc977ef4eecdb8c98d8c65
|
|
4
|
+
data.tar.gz: 5ef6df5ecc81765ed887afb31ee8c9c76f065930
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: e5a8eb30e3fb60615ad8ed955a9978519e73c3aefbb5db98413228fdcdc64f40d6d74d33ed7c35fb7e8c51854fdf38bdd39929dbc942bc3094816b153c0b1ebe
|
|
7
|
+
data.tar.gz: 581d68f4bc69eb48b28050f746cc744d89493b6cb156706cbf536767269ec1a16965ffcf37e665ffef58de4a55f73393cd6e43618e74b1aeb08e43f3b0cccbc1
|
data/.rubocop.yml
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
AllCops:
|
|
2
|
+
Exclude:
|
|
3
|
+
- 'spec/dummy/**/*'
|
|
4
|
+
- 'Rakefile'
|
|
5
|
+
|
|
6
|
+
Lint/HandleExceptions:
|
|
7
|
+
Exclude:
|
|
8
|
+
- 'spec/**/*'
|
|
9
|
+
|
|
10
|
+
Lint/RescueException:
|
|
11
|
+
Exclude:
|
|
12
|
+
- 'spec/**/*'
|
|
13
|
+
|
|
14
|
+
Style/AccessorMethodName:
|
|
15
|
+
Exclude:
|
|
16
|
+
- 'spec/**/*'
|
|
17
|
+
|
|
18
|
+
Style/ClassAndModuleChildren:
|
|
19
|
+
Exclude:
|
|
20
|
+
- 'spec/**/*'
|
|
21
|
+
|
|
22
|
+
Style/Documentation:
|
|
23
|
+
Exclude:
|
|
24
|
+
- 'spec/**/*'
|
|
25
|
+
- 'db/**/*'
|
|
26
|
+
|
|
27
|
+
Style/EmptyLinesAroundBody:
|
|
28
|
+
Enabled: false
|
|
29
|
+
|
|
30
|
+
Style/EmptyLineBetweenDefs:
|
|
31
|
+
Exclude:
|
|
32
|
+
- 'spec/**/*'
|
|
33
|
+
|
|
34
|
+
Metrics/MethodLength:
|
|
35
|
+
Exclude:
|
|
36
|
+
- 'db/**/*'
|
|
37
|
+
|
|
38
|
+
Style/RaiseArgs:
|
|
39
|
+
EnforcedStyle: compact
|
|
40
|
+
|
|
41
|
+
Style/SingleLineMethods:
|
|
42
|
+
Exclude:
|
|
43
|
+
- 'spec/**/*'
|
|
44
|
+
|
|
45
|
+
Style/SpecialGlobalVars:
|
|
46
|
+
Exclude:
|
|
47
|
+
- 'Gemfile'
|
|
48
|
+
- '*.gemspec'
|
|
49
|
+
|
|
50
|
+
Style/StringLiterals:
|
|
51
|
+
EnforcedStyle: double_quotes
|
|
52
|
+
|
|
53
|
+
Style/SingleSpaceBeforeFirstArg:
|
|
54
|
+
Enabled: false
|
|
55
|
+
|
|
56
|
+
Style/TrivialAccessors:
|
|
57
|
+
Exclude:
|
|
58
|
+
- 'spec/**/*'
|
data/LICENSE.rdoc
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
= The MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2014 Andrew Kozin, https://github.com/nepalez
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.rdoc
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
= UUIDs
|
|
2
|
+
|
|
3
|
+
{<img src="http://img.shields.io/gem/v/uuids.svg?style=flat" alt="Gem Version" />}[https://rubygems.org/gems/uuids]
|
|
4
|
+
{<img src="http://img.shields.io/travis/nepalez/uuids.svg?style=flat" alt="Bild Status" />}[https://travis-ci.org/nepalez/uuids]
|
|
5
|
+
{<img src="http://img.shields.io/codeclimate/github/nepalez/uuids.svg?style=flat" alt="Code Metrics" />}[https://codeclimate.com/github/nepalez/uuids]
|
|
6
|
+
{<img src="http://img.shields.io/gemnasium/nepalez/uuids.svg?style=flat" alt="Dependency Status" />}[https://gemnasium.com/nepalez/uuids]
|
|
7
|
+
{<img src="http://img.shields.io/coveralls/nepalez/uuids.svg?style=flat" alt="Coverage Status" />}[https://coveralls.io/r/nepalez/uuids]
|
|
8
|
+
{<img src="http://img.shields.io/badge/license-MIT-blue.svg?style=flat" alt="License" />}[https://github.com/nepalez/uuids/blob/master/LICENSE.rdoc]
|
|
9
|
+
|
|
10
|
+
== About
|
|
11
|
+
|
|
12
|
+
Defines a model +Uuid+ to store {UUIDs}[http://en.wikipedia.org/wiki/Universally_Unique_Identifier] assigned to various AR records.
|
|
13
|
+
|
|
14
|
+
It is expected any uuid is assigned to one record, but a record can be
|
|
15
|
+
identified by many uuids.
|
|
16
|
+
|
|
17
|
+
The gem is a {mountable Rails engine}[http://guides.rubyonrails.org/engines.html#generating-an-engine].
|
|
18
|
+
|
|
19
|
+
=== Pattern
|
|
20
|
+
|
|
21
|
+
This model allows refering records by some uuid (not the id).
|
|
22
|
+
|
|
23
|
+
If necessary any referred record can be merged with another one.
|
|
24
|
+
If you reassign all their uuids to merged record then any references remains
|
|
25
|
+
valid without tracking and changing them before merge.
|
|
26
|
+
|
|
27
|
+
A uuid should be neither deleted, no changed. It can only be reassigned to
|
|
28
|
+
another resource. The records can be deleted
|
|
29
|
+
|
|
30
|
+
* by merging to another ones;
|
|
31
|
+
* by explicitly marking as deleted without physical removal.
|
|
32
|
+
|
|
33
|
+
=== Example
|
|
34
|
+
|
|
35
|
+
Suppose you have models referred to cities. One day you discover
|
|
36
|
+
a duplication among cities: the "New York" and the "NEW YORK".
|
|
37
|
+
|
|
38
|
+
You should:
|
|
39
|
+
|
|
40
|
+
* reassign both uuids to "New York";
|
|
41
|
+
* safely remove the "NEW YORK" record.
|
|
42
|
+
|
|
43
|
+
You needn't track all records that refer to "NEW YORK". All those references
|
|
44
|
+
will authomatically lead to merged record via old uuid.
|
|
45
|
+
|
|
46
|
+
=== Standards
|
|
47
|
+
|
|
48
|
+
The Uuid is generated authomatically following the
|
|
49
|
+
{RFC4122}[http://www.ietf.org/rfc/rfc4122.txt] standard. The generation uses the
|
|
50
|
+
+sequrerandom+ Ruby library.
|
|
51
|
+
|
|
52
|
+
This allows keeping all uuids in one model and referring to any record whatever
|
|
53
|
+
type it has.
|
|
54
|
+
|
|
55
|
+
=== Models
|
|
56
|
+
|
|
57
|
+
A model <tt>Uuids::Uuid</tt> has two attributes: +value+ and +record+.
|
|
58
|
+
Only the +record+ can (and must) be set and changed.
|
|
59
|
+
The readonly +value+ (the uuid itself) is assigned by default.
|
|
60
|
+
|
|
61
|
+
=== Translations
|
|
62
|
+
|
|
63
|
+
Error messages are translated to English and Russian (see `config/locales`).
|
|
64
|
+
Translations to other languages are welcome.
|
|
65
|
+
|
|
66
|
+
== Installation
|
|
67
|
+
|
|
68
|
+
Add this line to your application's Gemfile:
|
|
69
|
+
|
|
70
|
+
gem "uuids"
|
|
71
|
+
|
|
72
|
+
And then execute:
|
|
73
|
+
|
|
74
|
+
$ bundle
|
|
75
|
+
|
|
76
|
+
Or install it yourself as:
|
|
77
|
+
|
|
78
|
+
$ gem install uuids
|
|
79
|
+
|
|
80
|
+
Then run from a command line in application root:
|
|
81
|
+
|
|
82
|
+
$ rake uuids:install
|
|
83
|
+
|
|
84
|
+
== Usage
|
|
85
|
+
|
|
86
|
+
Add the assotiation to your AR model:
|
|
87
|
+
|
|
88
|
+
class YourModel < ActiveRecord::Base
|
|
89
|
+
has_many :uuids, class_name: "Uuids::Uuid", as: :record, dependent: :destroy
|
|
90
|
+
...
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
Note the <tt>dependent: :destroy</tt> condition! It prevents a record from
|
|
94
|
+
destruction before a corresponding uuids reassigned to another record.
|
|
95
|
+
|
|
96
|
+
Then add a callback for uuid creation:
|
|
97
|
+
|
|
98
|
+
class YourModel < ActiveRecord::Base
|
|
99
|
+
...
|
|
100
|
+
# create the uuid by default
|
|
101
|
+
before_create -> { uuids.new }
|
|
102
|
+
...
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
Now you can add reference to your model via uuid:
|
|
106
|
+
|
|
107
|
+
class CreateAnotherModelTable < ActiveRecord::Migration
|
|
108
|
+
def change
|
|
109
|
+
create_table :another_models do |t|
|
|
110
|
+
t.string :your_model_uuid, limit: 36
|
|
111
|
+
end
|
|
112
|
+
add_index :another_models, :your_model_uuid
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
class AnotherModel < ActiveRecord::Base
|
|
117
|
+
|
|
118
|
+
def your_model
|
|
119
|
+
@your_model ||= YourModel.join(:uuids).where(uuids: { value: your_model_uuid }).first
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
def your_model=(value)
|
|
123
|
+
@your_model_uuid ||= Uuids::Uuid.find_by_record(value)
|
|
124
|
+
end
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
== Uninstallation
|
|
128
|
+
|
|
129
|
+
Run from a command line in application root:
|
|
130
|
+
|
|
131
|
+
$ rake uuids:uninstall
|
|
132
|
+
|
|
133
|
+
== Contributing
|
|
134
|
+
|
|
135
|
+
1. Fork it ( https://github.com/nepalez/uuids/fork )
|
|
136
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
137
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
138
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
139
|
+
5. Create a new Pull Request
|
|
140
|
+
|
|
141
|
+
== TODO
|
|
142
|
+
|
|
143
|
+
Redefine AR::Base class methods +has_one+ and +has_many+ to allow reference
|
|
144
|
+
by uuid:
|
|
145
|
+
|
|
146
|
+
class MyModel < ActiveRecord::Base
|
|
147
|
+
extend Uuids
|
|
148
|
+
|
|
149
|
+
has_one :another_model, uuid: true
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
== License
|
|
153
|
+
|
|
154
|
+
The plugin is distributed under {MIT license}[https://github.com/nepalez/uuids/blob/master/LICENSE.rdoc]
|
data/Rakefile
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
begin
|
|
2
|
+
require "bundler/setup"
|
|
3
|
+
rescue LoadError
|
|
4
|
+
puts "You must `gem install bundler` and `bundle install` to run rake tasks"
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
begin
|
|
8
|
+
require "rdoc/task"
|
|
9
|
+
rescue LoadError
|
|
10
|
+
require "rdoc/rdoc"
|
|
11
|
+
require "rake/rdoctask"
|
|
12
|
+
RDoc::Task = Rake::RDocTask
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
|
16
|
+
rdoc.rdoc_dir = "rdoc"
|
|
17
|
+
rdoc.title = "Uuids"
|
|
18
|
+
rdoc.options << "--line-numbers"
|
|
19
|
+
rdoc.rdoc_files.include "README.rdoc"
|
|
20
|
+
rdoc.rdoc_files.include "lib/**/*.rb"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
Bundler::GemHelper.install_tasks
|
|
24
|
+
|
|
25
|
+
APP_RAKEFILE = File.expand_path "../spec/dummy/Rakefile", __FILE__
|
|
26
|
+
load "rails/tasks/engine.rake"
|
|
27
|
+
|
|
28
|
+
require "bundler/gem_tasks"
|
|
29
|
+
require "rspec/core/rake_task"
|
|
30
|
+
|
|
31
|
+
RSpec::Core::RakeTask.new :spec
|
|
32
|
+
task :default do
|
|
33
|
+
sh "bundle exec rake db:migrate RAILS_ENV=test"
|
|
34
|
+
sh "bundle exec rspec spec"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
task full: [:default] do
|
|
38
|
+
sh "rubocop"
|
|
39
|
+
sh "metric_fu"
|
|
40
|
+
sh "inch"
|
|
41
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
module Uuids
|
|
2
|
+
|
|
3
|
+
# Stores uuids assigned to corresponding records.
|
|
4
|
+
#
|
|
5
|
+
# == Attributes:
|
|
6
|
+
#
|
|
7
|
+
# +value+:: A value of uuid as defined in
|
|
8
|
+
# {RFC4122}[http://www.ietf.org/rfc/rfc4122.txt].
|
|
9
|
+
# Assigned by default on creation. Cannot be set or edited manually.
|
|
10
|
+
# +record+:: An AR record the uuid is assigned to.
|
|
11
|
+
# Required attribute. Can be changed.
|
|
12
|
+
#
|
|
13
|
+
# == Examples:
|
|
14
|
+
#
|
|
15
|
+
# # Create the uuid
|
|
16
|
+
# uuid = Uuids::Uuid.create! record: some_record
|
|
17
|
+
#
|
|
18
|
+
# # Find a record by uuid
|
|
19
|
+
# Uuid.find_by_value(uuid.value).record # => some_record
|
|
20
|
+
#
|
|
21
|
+
# # Reassigns a uuid to another record
|
|
22
|
+
# uuid.update_attributes! record: another_record
|
|
23
|
+
#
|
|
24
|
+
class Uuid < ActiveRecord::Base
|
|
25
|
+
|
|
26
|
+
belongs_to :record, polymorphic: true
|
|
27
|
+
validate :record_present?
|
|
28
|
+
before_destroy :forbid_destruction
|
|
29
|
+
|
|
30
|
+
# Assigns a #value by default.
|
|
31
|
+
def initialize(*)
|
|
32
|
+
super
|
|
33
|
+
write_attribute :value, SecureRandom.uuid
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
private
|
|
37
|
+
|
|
38
|
+
# Disables value assignment.
|
|
39
|
+
attr_writer :value
|
|
40
|
+
|
|
41
|
+
# Validates record presence with a custom error message.
|
|
42
|
+
def record_present?
|
|
43
|
+
return if record
|
|
44
|
+
errors.add :record, :blank, uuid: value
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Forbids destruction of the record.
|
|
48
|
+
def forbid_destruction
|
|
49
|
+
errors.add :base, :destruction_forbidden
|
|
50
|
+
false
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
en:
|
|
2
|
+
activerecord:
|
|
3
|
+
errors:
|
|
4
|
+
models:
|
|
5
|
+
uuids/uuid:
|
|
6
|
+
attributes:
|
|
7
|
+
base:
|
|
8
|
+
destruction_forbidden: "Destruction of UUID is forbidden. Instead of destruction reassign the UUID to another record!"
|
|
9
|
+
record:
|
|
10
|
+
blank: "Define a record the UUID: %{uuid} is assigned to!"
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
class CreateUuidsUuids < ActiveRecord::Migration
|
|
2
|
+
def change
|
|
3
|
+
create_table :uuids_uuids do |t|
|
|
4
|
+
t.string :value, limit: 36, null: false
|
|
5
|
+
t.references :record, polymorphic: true, null: false, index: true
|
|
6
|
+
end
|
|
7
|
+
add_index :uuids_uuids, :value, unique: true
|
|
8
|
+
end
|
|
9
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
namespace :uuids do
|
|
2
|
+
|
|
3
|
+
desc "Installs the uuids gem inside a Rails application"
|
|
4
|
+
task install: %w(install:migrations) do
|
|
5
|
+
sh "rake db:migrate SCOPE=uuids"
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
desc "Uninstalls and removes the uuids gem from a Rails application"
|
|
9
|
+
task :uninstall do
|
|
10
|
+
sh "rake db:rollback SCOPE=uuids"
|
|
11
|
+
say do
|
|
12
|
+
remove_from_file "Gemfile", /gem\s+["|']uuids["|']/
|
|
13
|
+
Dir["*.gemspec"].each do |gemspec|
|
|
14
|
+
remove_from_file gemspec, /_dependency\s+["|']uuids["|']/
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
sh "bundle"
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def remove_from_file(name, regex)
|
|
21
|
+
say_with_time name do
|
|
22
|
+
temp = File.read(name).split("\n")
|
|
23
|
+
.reject { |line| line[regex] }.join("\n")
|
|
24
|
+
File.write(name, temp)
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def say
|
|
29
|
+
print "== Removing the 'uuids' gem" \
|
|
30
|
+
" ===================================================\n"
|
|
31
|
+
yield
|
|
32
|
+
print "\n"
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def say_with_time(name)
|
|
36
|
+
start = Time.now.to_f
|
|
37
|
+
print "-- remove from #{ name }\n"
|
|
38
|
+
yield
|
|
39
|
+
print " -> #{ (Time.now.to_f - start).round(4) }s\n"
|
|
40
|
+
end
|
|
41
|
+
end
|
data/lib/uuids/engine.rb
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
module Uuids
|
|
2
|
+
|
|
3
|
+
# Rails Engine settings
|
|
4
|
+
class Engine < ::Rails::Engine
|
|
5
|
+
isolate_namespace Uuids
|
|
6
|
+
|
|
7
|
+
config.generators do |generator|
|
|
8
|
+
generator.test_framework :rspec, fixture: true, view_specs: true
|
|
9
|
+
generator.fixture_replacement :factory_girl, dir: "spec/factories"
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
data/lib/uuids.rb
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
== README
|
|
2
|
+
|
|
3
|
+
This README would normally document whatever steps are necessary to get the
|
|
4
|
+
application up and running.
|
|
5
|
+
|
|
6
|
+
Things you may want to cover:
|
|
7
|
+
|
|
8
|
+
* Ruby version
|
|
9
|
+
|
|
10
|
+
* System dependencies
|
|
11
|
+
|
|
12
|
+
* Configuration
|
|
13
|
+
|
|
14
|
+
* Database creation
|
|
15
|
+
|
|
16
|
+
* Database initialization
|
|
17
|
+
|
|
18
|
+
* How to run the test suite
|
|
19
|
+
|
|
20
|
+
* Services (job queues, cache servers, search engines, etc.)
|
|
21
|
+
|
|
22
|
+
* Deployment instructions
|
|
23
|
+
|
|
24
|
+
* ...
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
Please feel free to use a different markup language if you do not plan to run
|
|
28
|
+
<tt>rake doc:app</tt>.
|
data/spec/dummy/Rakefile
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
|
2
|
+
// listed below.
|
|
3
|
+
//
|
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
|
6
|
+
//
|
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
|
8
|
+
// compiled file.
|
|
9
|
+
//
|
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
|
11
|
+
// about supported directives.
|
|
12
|
+
//
|
|
13
|
+
//= require_tree .
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
|
3
|
+
* listed below.
|
|
4
|
+
*
|
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
|
7
|
+
*
|
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
|
11
|
+
* file per style scope.
|
|
12
|
+
*
|
|
13
|
+
*= require_tree .
|
|
14
|
+
*= require_self
|
|
15
|
+
*/
|
data/spec/dummy/bin/rake
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require File.expand_path('../boot', __FILE__)
|
|
2
|
+
|
|
3
|
+
# Pick the frameworks you want:
|
|
4
|
+
require "active_record/railtie"
|
|
5
|
+
require "action_controller/railtie"
|
|
6
|
+
require "action_mailer/railtie"
|
|
7
|
+
require "action_view/railtie"
|
|
8
|
+
# require "sprockets/railtie"
|
|
9
|
+
# require "rails/test_unit/railtie"
|
|
10
|
+
|
|
11
|
+
Bundler.require(*Rails.groups)
|
|
12
|
+
require "uuids"
|
|
13
|
+
|
|
14
|
+
module Dummy
|
|
15
|
+
class Application < Rails::Application
|
|
16
|
+
# Settings in config/environments/* take precedence over those specified here.
|
|
17
|
+
# Application configuration should go into files in config/initializers
|
|
18
|
+
# -- all .rb files in that directory are automatically loaded.
|
|
19
|
+
|
|
20
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
|
21
|
+
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
|
|
22
|
+
# config.time_zone = 'Central Time (US & Canada)'
|
|
23
|
+
|
|
24
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
|
25
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
|
26
|
+
# config.i18n.default_locale = :de
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# SQLite version 3.x
|
|
2
|
+
# gem install sqlite3
|
|
3
|
+
#
|
|
4
|
+
# Ensure the SQLite 3 gem is defined in your Gemfile
|
|
5
|
+
# gem 'sqlite3'
|
|
6
|
+
#
|
|
7
|
+
default: &default
|
|
8
|
+
adapter: sqlite3
|
|
9
|
+
pool: 5
|
|
10
|
+
timeout: 5000
|
|
11
|
+
|
|
12
|
+
development:
|
|
13
|
+
<<: *default
|
|
14
|
+
database: db/development.sqlite3
|
|
15
|
+
|
|
16
|
+
# Warning: The database defined as "test" will be erased and
|
|
17
|
+
# re-generated from your development database when you run "rake".
|
|
18
|
+
# Do not set this db to the same as development or production.
|
|
19
|
+
test:
|
|
20
|
+
<<: *default
|
|
21
|
+
database: db/test.sqlite3
|
|
22
|
+
|
|
23
|
+
production:
|
|
24
|
+
<<: *default
|
|
25
|
+
database: db/production.sqlite3
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
Rails.application.configure do
|
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
|
3
|
+
|
|
4
|
+
# In the development environment your application's code is reloaded on
|
|
5
|
+
# every request. This slows down response time but is perfect for development
|
|
6
|
+
# since you don't have to restart the web server when you make code changes.
|
|
7
|
+
config.cache_classes = false
|
|
8
|
+
|
|
9
|
+
# Do not eager load code on boot.
|
|
10
|
+
config.eager_load = false
|
|
11
|
+
|
|
12
|
+
# Show full error reports and disable caching.
|
|
13
|
+
config.consider_all_requests_local = true
|
|
14
|
+
config.action_controller.perform_caching = false
|
|
15
|
+
|
|
16
|
+
# Don't care if the mailer can't send.
|
|
17
|
+
config.action_mailer.raise_delivery_errors = false
|
|
18
|
+
|
|
19
|
+
# Print deprecation notices to the Rails logger.
|
|
20
|
+
config.active_support.deprecation = :log
|
|
21
|
+
|
|
22
|
+
# Raise an error on page load if there are pending migrations.
|
|
23
|
+
config.active_record.migration_error = :page_load
|
|
24
|
+
|
|
25
|
+
# Debug mode disables concatenation and preprocessing of assets.
|
|
26
|
+
# This option may cause significant delays in view rendering with a large
|
|
27
|
+
# number of complex assets.
|
|
28
|
+
config.assets.debug = true
|
|
29
|
+
|
|
30
|
+
# Adds additional error checking when serving assets at runtime.
|
|
31
|
+
# Checks for improperly declared sprockets dependencies.
|
|
32
|
+
# Raises helpful error messages.
|
|
33
|
+
config.assets.raise_runtime_errors = true
|
|
34
|
+
|
|
35
|
+
# Raises error for missing translations
|
|
36
|
+
# config.action_view.raise_on_missing_translations = true
|
|
37
|
+
end
|