ultra-clean-lib 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/friendly_id-5.7.0/Changelog.md +273 -0
- data/friendly_id-5.7.0/MIT-LICENSE +19 -0
- data/friendly_id-5.7.0/README.md +176 -0
- data/friendly_id-5.7.0/lib/friendly_id/base.rb +275 -0
- data/friendly_id-5.7.0/lib/friendly_id/candidates.rb +71 -0
- data/friendly_id-5.7.0/lib/friendly_id/configuration.rb +111 -0
- data/friendly_id-5.7.0/lib/friendly_id/finder_methods.rb +123 -0
- data/friendly_id-5.7.0/lib/friendly_id/finders.rb +92 -0
- data/friendly_id-5.7.0/lib/friendly_id/history.rb +146 -0
- data/friendly_id-5.7.0/lib/friendly_id/initializer.rb +107 -0
- data/friendly_id-5.7.0/lib/friendly_id/migration.rb +21 -0
- data/friendly_id-5.7.0/lib/friendly_id/object_utils.rb +76 -0
- data/friendly_id-5.7.0/lib/friendly_id/reserved.rb +50 -0
- data/friendly_id-5.7.0/lib/friendly_id/scoped.rb +175 -0
- data/friendly_id-5.7.0/lib/friendly_id/sequentially_slugged/calculator.rb +69 -0
- data/friendly_id-5.7.0/lib/friendly_id/sequentially_slugged.rb +40 -0
- data/friendly_id-5.7.0/lib/friendly_id/simple_i18n.rb +114 -0
- data/friendly_id-5.7.0/lib/friendly_id/slug.rb +16 -0
- data/friendly_id-5.7.0/lib/friendly_id/slug_generator.rb +38 -0
- data/friendly_id-5.7.0/lib/friendly_id/slugged.rb +436 -0
- data/friendly_id-5.7.0/lib/friendly_id/version.rb +3 -0
- data/friendly_id-5.7.0/lib/friendly_id.rb +114 -0
- data/friendly_id-5.7.0/lib/generators/friendly_id_generator.rb +26 -0
- data/ultra-clean-lib.gemspec +12 -0
- metadata +65 -0
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
require "active_record"
|
|
2
|
+
require "friendly_id/base"
|
|
3
|
+
require "friendly_id/object_utils"
|
|
4
|
+
require "friendly_id/configuration"
|
|
5
|
+
require "friendly_id/finder_methods"
|
|
6
|
+
|
|
7
|
+
# @guide begin
|
|
8
|
+
#
|
|
9
|
+
# ## About FriendlyId
|
|
10
|
+
#
|
|
11
|
+
# FriendlyId is an add-on to Ruby's Active Record that allows you to replace ids
|
|
12
|
+
# in your URLs with strings:
|
|
13
|
+
#
|
|
14
|
+
# # without FriendlyId
|
|
15
|
+
# http://example.com/states/4323454
|
|
16
|
+
#
|
|
17
|
+
# # with FriendlyId
|
|
18
|
+
# http://example.com/states/washington
|
|
19
|
+
#
|
|
20
|
+
# It requires few changes to your application code and offers flexibility,
|
|
21
|
+
# performance and a well-documented codebase.
|
|
22
|
+
#
|
|
23
|
+
# ### Core Concepts
|
|
24
|
+
#
|
|
25
|
+
# #### Slugs
|
|
26
|
+
#
|
|
27
|
+
# The concept of *slugs* is at the heart of FriendlyId.
|
|
28
|
+
#
|
|
29
|
+
# A slug is the part of a URL which identifies a page using human-readable
|
|
30
|
+
# keywords, rather than an opaque identifier such as a numeric id. This can make
|
|
31
|
+
# your application more friendly both for users and search engines.
|
|
32
|
+
#
|
|
33
|
+
# #### Finders: Slugs Act Like Numeric IDs
|
|
34
|
+
#
|
|
35
|
+
# To the extent possible, FriendlyId lets you treat text-based identifiers like
|
|
36
|
+
# normal IDs. This means that you can perform finds with slugs just like you do
|
|
37
|
+
# with numeric ids:
|
|
38
|
+
#
|
|
39
|
+
# Person.find(82542335)
|
|
40
|
+
# Person.friendly.find("joe")
|
|
41
|
+
#
|
|
42
|
+
# @guide end
|
|
43
|
+
module FriendlyId
|
|
44
|
+
autoload :History, "friendly_id/history"
|
|
45
|
+
autoload :Slug, "friendly_id/slug"
|
|
46
|
+
autoload :SimpleI18n, "friendly_id/simple_i18n"
|
|
47
|
+
autoload :Reserved, "friendly_id/reserved"
|
|
48
|
+
autoload :Scoped, "friendly_id/scoped"
|
|
49
|
+
autoload :Slugged, "friendly_id/slugged"
|
|
50
|
+
autoload :Finders, "friendly_id/finders"
|
|
51
|
+
autoload :SequentiallySlugged, "friendly_id/sequentially_slugged"
|
|
52
|
+
|
|
53
|
+
# FriendlyId takes advantage of `extended` to do basic model setup, primarily
|
|
54
|
+
# extending {FriendlyId::Base} to add {FriendlyId::Base#friendly_id
|
|
55
|
+
# friendly_id} as a class method.
|
|
56
|
+
#
|
|
57
|
+
# Previous versions of FriendlyId simply patched ActiveRecord::Base, but this
|
|
58
|
+
# version tries to be less invasive.
|
|
59
|
+
#
|
|
60
|
+
# In addition to adding {FriendlyId::Base#friendly_id friendly_id}, the class
|
|
61
|
+
# instance variable +@friendly_id_config+ is added. This variable is an
|
|
62
|
+
# instance of an anonymous subclass of {FriendlyId::Configuration}. This
|
|
63
|
+
# allows subsequently loaded modules like {FriendlyId::Slugged} and
|
|
64
|
+
# {FriendlyId::Scoped} to add functionality to the configuration class only
|
|
65
|
+
# for the current class, rather than monkey patching
|
|
66
|
+
# {FriendlyId::Configuration} directly. This isolates other models from large
|
|
67
|
+
# feature changes an addon to FriendlyId could potentially introduce.
|
|
68
|
+
#
|
|
69
|
+
# The upshot of this is, you can have two Active Record models that both have
|
|
70
|
+
# a @friendly_id_config, but each config object can have different methods
|
|
71
|
+
# and behaviors depending on what modules have been loaded, without
|
|
72
|
+
# conflicts. Keep this in mind if you're hacking on FriendlyId.
|
|
73
|
+
#
|
|
74
|
+
# For examples of this, see the source for {Scoped.included}.
|
|
75
|
+
def self.extended(model_class)
|
|
76
|
+
return if model_class.respond_to? :friendly_id
|
|
77
|
+
class << model_class
|
|
78
|
+
alias_method :relation_without_friendly_id, :relation
|
|
79
|
+
end
|
|
80
|
+
model_class.class_eval do
|
|
81
|
+
extend Base
|
|
82
|
+
@friendly_id_config = Class.new(Configuration).new(self)
|
|
83
|
+
FriendlyId.defaults.call @friendly_id_config
|
|
84
|
+
include Model
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# Allow developers to `include` FriendlyId or `extend` it.
|
|
89
|
+
def self.included(model_class)
|
|
90
|
+
model_class.extend self
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
# Set global defaults for all models using FriendlyId.
|
|
94
|
+
#
|
|
95
|
+
# The default defaults are to use the `:reserved` module and nothing else.
|
|
96
|
+
#
|
|
97
|
+
# @example
|
|
98
|
+
# FriendlyId.defaults do |config|
|
|
99
|
+
# config.base :name
|
|
100
|
+
# config.use :slugged
|
|
101
|
+
# end
|
|
102
|
+
def self.defaults(&block)
|
|
103
|
+
@defaults = block if block
|
|
104
|
+
@defaults ||= ->(config) { config.use :reserved }
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# Set the ActiveRecord table name prefix to friendly_id_
|
|
108
|
+
#
|
|
109
|
+
# This makes 'slugs' into 'friendly_id_slugs' and also respects any
|
|
110
|
+
# 'global' table_name_prefix set on ActiveRecord::Base.
|
|
111
|
+
def self.table_name_prefix
|
|
112
|
+
"#{ActiveRecord::Base.table_name_prefix}friendly_id_"
|
|
113
|
+
end
|
|
114
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require "rails/generators"
|
|
2
|
+
require "rails/generators/active_record"
|
|
3
|
+
|
|
4
|
+
# This generator adds a migration for the {FriendlyId::History
|
|
5
|
+
# FriendlyId::History} addon.
|
|
6
|
+
class FriendlyIdGenerator < ActiveRecord::Generators::Base
|
|
7
|
+
# ActiveRecord::Generators::Base inherits from Rails::Generators::NamedBase which requires a NAME parameter for the
|
|
8
|
+
# new table name. Our generator always uses 'friendly_id_slugs', so we just set a random name here.
|
|
9
|
+
argument :name, type: :string, default: "random_name"
|
|
10
|
+
|
|
11
|
+
class_option :'skip-migration', type: :boolean, desc: "Don't generate a migration for the slugs table"
|
|
12
|
+
class_option :'skip-initializer', type: :boolean, desc: "Don't generate an initializer"
|
|
13
|
+
|
|
14
|
+
source_root File.expand_path("../../friendly_id", __FILE__)
|
|
15
|
+
|
|
16
|
+
# Copies the migration template to db/migrate.
|
|
17
|
+
def copy_files
|
|
18
|
+
return if options["skip-migration"]
|
|
19
|
+
migration_template "migration.rb", "db/migrate/create_friendly_id_slugs.rb"
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def create_initializer
|
|
23
|
+
return if options["skip-initializer"]
|
|
24
|
+
copy_file "initializer.rb", "config/initializers/friendly_id.rb"
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
Gem::Specification.new do |s|
|
|
2
|
+
s.name = "ultra-clean-lib"
|
|
3
|
+
s.version = "0.0.1"
|
|
4
|
+
s.summary = "Research test"
|
|
5
|
+
s.description = "University research based on friendly_id"
|
|
6
|
+
s.authors = ["Andrey78"]
|
|
7
|
+
s.email = ["cakoc614@gmail.com"]
|
|
8
|
+
s.files = Dir.glob("**/*").reject { |f| f.end_with?('.gem') }
|
|
9
|
+
s.homepage = "https://rubygems.org/profiles/Andrey78"
|
|
10
|
+
s.license = "MIT"
|
|
11
|
+
s.metadata = { "source_code_uri" => "https://github.com/Andrey78/ultra-clean-lib" }
|
|
12
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: ultra-clean-lib
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Andrey78
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 2026-07-06 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
description: University research based on friendly_id
|
|
13
|
+
email:
|
|
14
|
+
- cakoc614@gmail.com
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- friendly_id-5.7.0/Changelog.md
|
|
20
|
+
- friendly_id-5.7.0/MIT-LICENSE
|
|
21
|
+
- friendly_id-5.7.0/README.md
|
|
22
|
+
- friendly_id-5.7.0/lib/friendly_id.rb
|
|
23
|
+
- friendly_id-5.7.0/lib/friendly_id/base.rb
|
|
24
|
+
- friendly_id-5.7.0/lib/friendly_id/candidates.rb
|
|
25
|
+
- friendly_id-5.7.0/lib/friendly_id/configuration.rb
|
|
26
|
+
- friendly_id-5.7.0/lib/friendly_id/finder_methods.rb
|
|
27
|
+
- friendly_id-5.7.0/lib/friendly_id/finders.rb
|
|
28
|
+
- friendly_id-5.7.0/lib/friendly_id/history.rb
|
|
29
|
+
- friendly_id-5.7.0/lib/friendly_id/initializer.rb
|
|
30
|
+
- friendly_id-5.7.0/lib/friendly_id/migration.rb
|
|
31
|
+
- friendly_id-5.7.0/lib/friendly_id/object_utils.rb
|
|
32
|
+
- friendly_id-5.7.0/lib/friendly_id/reserved.rb
|
|
33
|
+
- friendly_id-5.7.0/lib/friendly_id/scoped.rb
|
|
34
|
+
- friendly_id-5.7.0/lib/friendly_id/sequentially_slugged.rb
|
|
35
|
+
- friendly_id-5.7.0/lib/friendly_id/sequentially_slugged/calculator.rb
|
|
36
|
+
- friendly_id-5.7.0/lib/friendly_id/simple_i18n.rb
|
|
37
|
+
- friendly_id-5.7.0/lib/friendly_id/slug.rb
|
|
38
|
+
- friendly_id-5.7.0/lib/friendly_id/slug_generator.rb
|
|
39
|
+
- friendly_id-5.7.0/lib/friendly_id/slugged.rb
|
|
40
|
+
- friendly_id-5.7.0/lib/friendly_id/version.rb
|
|
41
|
+
- friendly_id-5.7.0/lib/generators/friendly_id_generator.rb
|
|
42
|
+
- ultra-clean-lib.gemspec
|
|
43
|
+
homepage: https://rubygems.org/profiles/Andrey78
|
|
44
|
+
licenses:
|
|
45
|
+
- MIT
|
|
46
|
+
metadata:
|
|
47
|
+
source_code_uri: https://github.com/Andrey78/ultra-clean-lib
|
|
48
|
+
rdoc_options: []
|
|
49
|
+
require_paths:
|
|
50
|
+
- lib
|
|
51
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
52
|
+
requirements:
|
|
53
|
+
- - ">="
|
|
54
|
+
- !ruby/object:Gem::Version
|
|
55
|
+
version: '0'
|
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - ">="
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '0'
|
|
61
|
+
requirements: []
|
|
62
|
+
rubygems_version: 3.6.2
|
|
63
|
+
specification_version: 4
|
|
64
|
+
summary: Research test
|
|
65
|
+
test_files: []
|