webnames 0.2.0 → 0.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6b6b3236ac3fd31f21655a63483ab84a657e34e1
4
- data.tar.gz: 9fafe45b9e62ba6faeab35e3267b2abf16005383
3
+ metadata.gz: 431989b46773f8aca9bacdd12d322c6c0366b6e8
4
+ data.tar.gz: c6b62052a5261b11c20b63ef803aca1b14150615
5
5
  SHA512:
6
- metadata.gz: fa3ec000dff1c7d34bcb1df882efbb1d834b6554b8d247643d6e6c303da48ba8fc0e24ca2a7848340af4eff86411cce0fb5dff74ac2d37f14611cce67e78a22c
7
- data.tar.gz: fb2d1bc82e454c071efc2dd54cc5339606fc75bf66a37873e87f1bb6142ad720c78a19b793a9b62db5d0843ac93f838121074d93b2b10611ee7eda69daaab623
6
+ metadata.gz: c18bdb74168118bcfca1568bd2709905e2ebe139275ac37d94593d0e6c8b49a0b37269a38905f59243fd6e5fc1b32ebe908b17d8a4ef6f2108966708542b3cf6
7
+ data.tar.gz: 28059e39ebb0392da62cf44882a61519bd61cbd9c2f3e2cf21b5fe1130d9bc1b7852950973924f4ecc74252d102dcc9cef5d3b2c5133cad3242fd81470022bcf
@@ -6,6 +6,10 @@ class Webnames::InstallGenerator < ActiveRecord::Generators::Base
6
6
 
7
7
  argument :name, :type => :string, :default => "Webname", :banner => "Webname"
8
8
 
9
+ def copy_initialize_file
10
+ copy_file "webnames_initializer.rb", "config/initializers/webnames.rb"
11
+ end
12
+
9
13
  def generate_model
10
14
  copy_file "webnames-active_record.rb", model_path
11
15
  end
@@ -0,0 +1,5 @@
1
+ Webnames.setup do |config|
2
+ # Webname regex used to validate the webname format. in the model and in the
3
+ # routes constraints.
4
+ #config.regex = /[^\/]+/
5
+ end
@@ -11,8 +11,10 @@ module Webnames
11
11
  extend ActiveSupport::Concern
12
12
 
13
13
  included do
14
- has_one :webname, as: :resource
15
- default_scope -> { includes(:webname) }
14
+ has_one :webname_model, class_name: 'Webname', as: :resource
15
+ default_scope -> { includes(:webname_model) }
16
+
17
+ delegate :webname, to: :webname_model
16
18
 
17
19
  def to_param
18
20
  self.webname
@@ -8,8 +8,10 @@ module ActionDispatch::Routing
8
8
  options_with_blank_path = options.reverse_merge path: '', except: [:new, :create, :index]
9
9
  options_with_path = options.reverse_merge except: [:show, :edit, :update, :destroy]
10
10
 
11
- resources resources_name, options_with_blank_path, &block
12
- resources resources_name, options_with_path, &block
11
+ constraints webname: Webnames.regex do
12
+ resources resources_name, options_with_blank_path, &block
13
+ resources resources_name, options_with_path, &block
14
+ end
13
15
  end
14
16
  end
15
17
  end
@@ -1,3 +1,3 @@
1
1
  module Webnames
2
- VERSION = "0.2.0"
2
+ VERSION = "0.3.0"
3
3
  end
data/lib/webnames.rb CHANGED
@@ -3,6 +3,13 @@ require "webnames/rails/routes"
3
3
  require "webnames/rails/active_record"
4
4
 
5
5
  module Webnames
6
+
7
+ mattr_accessor :regex
8
+ @@regex = /[^\/]+/
9
+
10
+ def self.setup
11
+ yield self
12
+ end
6
13
  end
7
14
 
8
15
  ActiveRecord::Base.send(:extend, Webnames::ClassMacros)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webnames
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sadjow Medeiros Leão
@@ -71,6 +71,7 @@ files:
71
71
  - lib/generators/webnames/install/install_generator.rb
72
72
  - lib/generators/webnames/install/templates/migration.rb
73
73
  - lib/generators/webnames/install/templates/webnames-active_record.rb
74
+ - lib/generators/webnames/install/templates/webnames_initializer.rb
74
75
  - lib/tasks/webnames_tasks.rake
75
76
  - lib/webnames.rb
76
77
  - lib/webnames/engine.rb
@@ -78,7 +79,8 @@ files:
78
79
  - lib/webnames/rails/routes.rb
79
80
  - lib/webnames/version.rb
80
81
  homepage: https://github.com/sadjow/webnames
81
- licenses: []
82
+ licenses:
83
+ - MIT
82
84
  metadata: {}
83
85
  post_install_message:
84
86
  rdoc_options: []