webnames 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 431989b46773f8aca9bacdd12d322c6c0366b6e8
4
- data.tar.gz: c6b62052a5261b11c20b63ef803aca1b14150615
3
+ metadata.gz: 98ec6cda206cde9482e4238259bd4ea94a16ef43
4
+ data.tar.gz: 3dad2eae8bbe2a18909250ef0cbce528b04964c5
5
5
  SHA512:
6
- metadata.gz: c18bdb74168118bcfca1568bd2709905e2ebe139275ac37d94593d0e6c8b49a0b37269a38905f59243fd6e5fc1b32ebe908b17d8a4ef6f2108966708542b3cf6
7
- data.tar.gz: 28059e39ebb0392da62cf44882a61519bd61cbd9c2f3e2cf21b5fe1130d9bc1b7852950973924f4ecc74252d102dcc9cef5d3b2c5133cad3242fd81470022bcf
6
+ metadata.gz: 6aa2155c28e61e29f264ceb8d14e7a76204ffbcc3d261839eb41360f19579fe57d43a4573f2c8389f505a7ce5a8d9dd69d3d50fe4e7b4d4599289e0338980642
7
+ data.tar.gz: d5e9a03802be5831ce0353f3d180bcd0a4d30fe297d20aa0772fb28d76d7d5a0886bd56e56776588449fb705fa24d50162c8c513c8301503af4fed76d268cfc3
@@ -1,8 +1,8 @@
1
1
  Description:
2
- Generates a model and a migration file for the webnames
2
+ Generates a initializer file with configuration for webnames.
3
3
 
4
4
  Example:
5
5
  rails generate webnames:install
6
6
 
7
7
  This will create:
8
- app/models/webname.rb
8
+ config/initializers/webnames.rb
@@ -1,24 +1,7 @@
1
- require 'rails/generators/active_record'
2
- require 'active_support/core_ext'
3
-
4
- class Webnames::InstallGenerator < ActiveRecord::Generators::Base
1
+ class Webnames::InstallGenerator < Rails::Generators::Base
5
2
  source_root File.expand_path('../templates', __FILE__)
6
3
 
7
- argument :name, :type => :string, :default => "Webname", :banner => "Webname"
8
-
9
4
  def copy_initialize_file
10
5
  copy_file "webnames_initializer.rb", "config/initializers/webnames.rb"
11
6
  end
12
-
13
- def generate_model
14
- copy_file "webnames-active_record.rb", model_path
15
- end
16
-
17
- def copy_webnames_migration
18
- migration_template "migration.rb", "db/migrate/webnames_create_#{table_name}"
19
- end
20
-
21
- def model_path
22
- File.join("app", "models", "#{file_path}.rb")
23
- end
24
7
  end
@@ -1,6 +1,6 @@
1
1
  require "webnames/engine"
2
2
  require "webnames/rails/routes"
3
- require "webnames/rails/active_record"
3
+ require "webnames/model"
4
4
 
5
5
  module Webnames
6
6
 
@@ -11,5 +11,3 @@ module Webnames
11
11
  yield self
12
12
  end
13
13
  end
14
-
15
- ActiveRecord::Base.send(:extend, Webnames::ClassMacros)
@@ -0,0 +1,19 @@
1
+ require 'active_support/concern'
2
+
3
+ module Webnames
4
+ module Model
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ def to_param
9
+ self.webname
10
+ end
11
+ end
12
+
13
+ module ClassMethods
14
+ def find(input, *args)
15
+ input.to_i == 0 ? where(webname: input).first : super
16
+ end
17
+ end
18
+ end
19
+ end
@@ -1,3 +1,3 @@
1
1
  module Webnames
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webnames
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sadjow Medeiros Leão
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-24 00:00:00.000000000 Z
11
+ date: 2014-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -30,35 +30,7 @@ dependencies:
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '5'
33
- - !ruby/object:Gem::Dependency
34
- name: rspec-rails
35
- requirement: !ruby/object:Gem::Requirement
36
- requirements:
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- version: '0'
40
- type: :development
41
- prerelease: false
42
- version_requirements: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: '0'
47
- - !ruby/object:Gem::Dependency
48
- name: pry
49
- requirement: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
53
- version: '0'
54
- type: :development
55
- prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- version: '0'
61
- description: webname(nickname, username) solution for Rails applications
33
+ description: webnames(nicknames, usernames) solution for Rails applications
62
34
  email:
63
35
  - sadjow@gmail.com
64
36
  executables: []
@@ -69,13 +41,11 @@ files:
69
41
  - Rakefile
70
42
  - lib/generators/webnames/install/USAGE
71
43
  - lib/generators/webnames/install/install_generator.rb
72
- - lib/generators/webnames/install/templates/migration.rb
73
- - lib/generators/webnames/install/templates/webnames-active_record.rb
74
44
  - lib/generators/webnames/install/templates/webnames_initializer.rb
75
45
  - lib/tasks/webnames_tasks.rake
76
46
  - lib/webnames.rb
77
47
  - lib/webnames/engine.rb
78
- - lib/webnames/rails/active_record.rb
48
+ - lib/webnames/model.rb
79
49
  - lib/webnames/rails/routes.rb
80
50
  - lib/webnames/version.rb
81
51
  homepage: https://github.com/sadjow/webnames
@@ -101,5 +71,5 @@ rubyforge_project:
101
71
  rubygems_version: 2.2.2
102
72
  signing_key:
103
73
  specification_version: 4
104
- summary: webname(nickname, username) solution for Rails
74
+ summary: webnames(nicknames, usernames) solution for Rails
105
75
  test_files: []
@@ -1,13 +0,0 @@
1
- class WebnamesCreate<%= table_name.camelize %> < ActiveRecord::Migration
2
- def change
3
- create_table(:<%= table_name %>) do |t|
4
- t.string :webname
5
- t.references :resource, :polymorphic => true
6
-
7
- t.timestamps
8
- end
9
-
10
- add_index(:<%= table_name %>, :webname)
11
- add_index(:<%= table_name %>, [ :webname, :resource_type, :resource_id ])
12
- end
13
- end
@@ -1,8 +0,0 @@
1
- class Webname < ActiveRecord::Base
2
- belongs_to :resource, :polymorphic => true
3
- validates_uniqueness_of :webname
4
-
5
- def to_s
6
- self.webname
7
- end
8
- end
@@ -1,30 +0,0 @@
1
- require 'active_support/concern'
2
-
3
- module Webnames
4
- module ClassMacros
5
- def webnameable
6
- include Webnames::Webnameable
7
- end
8
- end
9
-
10
- module Webnameable
11
- extend ActiveSupport::Concern
12
-
13
- included do
14
- has_one :webname_model, class_name: 'Webname', as: :resource
15
- default_scope -> { includes(:webname_model) }
16
-
17
- delegate :webname, to: :webname_model
18
-
19
- def to_param
20
- self.webname
21
- end
22
- end
23
-
24
- module ClassMethods
25
- def find(input, *args)
26
- input.to_i == 0 ? where(webnames: {webname: input}).first : super
27
- end
28
- end
29
- end
30
- end