webnames 0.0.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +8 -0
- data/lib/generators/webnames/install/USAGE +8 -0
- data/lib/generators/webnames/install/install_generator.rb +20 -0
- data/lib/generators/{active_record → webnames/install}/templates/migration.rb +1 -1
- data/lib/generators/{webname/templates/webname-active_record.rb → webnames/install/templates/webnames-active_record.rb} +5 -0
- data/lib/tasks/{webname_tasks.rake → webnames_tasks.rake} +1 -1
- data/lib/{webname → webnames}/engine.rb +1 -1
- data/lib/webnames/rails/active_record.rb +28 -0
- data/lib/webnames/rails/routes.rb +15 -0
- data/lib/webnames/version.rb +3 -0
- data/lib/webnames.rb +8 -0
- metadata +25 -27
- data/config/routes.rb +0 -2
- data/lib/generators/active_record/USAGE +0 -8
- data/lib/generators/active_record/active_record_generator.rb +0 -3
- data/lib/generators/active_record/webname_generator.rb +0 -26
- data/lib/generators/webname/USAGE +0 -8
- data/lib/generators/webname/webname_generator.rb +0 -20
- data/lib/webname/version.rb +0 -3
- data/lib/webname.rb +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b6b3236ac3fd31f21655a63483ab84a657e34e1
|
4
|
+
data.tar.gz: 9fafe45b9e62ba6faeab35e3267b2abf16005383
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa3ec000dff1c7d34bcb1df882efbb1d834b6554b8d247643d6e6c303da48ba8fc0e24ca2a7848340af4eff86411cce0fb5dff74ac2d37f14611cce67e78a22c
|
7
|
+
data.tar.gz: fb2d1bc82e454c071efc2dd54cc5339606fc75bf66a37873e87f1bb6142ad720c78a19b793a9b62db5d0843ac93f838121074d93b2b10611ee7eda69daaab623
|
data/Rakefile
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rails/generators/active_record'
|
2
|
+
require 'active_support/core_ext'
|
3
|
+
|
4
|
+
class Webnames::InstallGenerator < ActiveRecord::Generators::Base
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
|
7
|
+
argument :name, :type => :string, :default => "Webname", :banner => "Webname"
|
8
|
+
|
9
|
+
def generate_model
|
10
|
+
copy_file "webnames-active_record.rb", model_path
|
11
|
+
end
|
12
|
+
|
13
|
+
def copy_webnames_migration
|
14
|
+
migration_template "migration.rb", "db/migrate/webnames_create_#{table_name}"
|
15
|
+
end
|
16
|
+
|
17
|
+
def model_path
|
18
|
+
File.join("app", "models", "#{file_path}.rb")
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,28 @@
|
|
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, as: :resource
|
15
|
+
default_scope -> { includes(:webname) }
|
16
|
+
|
17
|
+
def to_param
|
18
|
+
self.webname
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
module ClassMethods
|
23
|
+
def find(input, *args)
|
24
|
+
input.to_i == 0 ? where(webnames: {webname: input}).first : super
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module ActionDispatch::Routing
|
2
|
+
class Mapper
|
3
|
+
def webnames_for(resources_name, *args, &block)
|
4
|
+
options = args.extract_options!
|
5
|
+
|
6
|
+
options.reverse_merge! param: :webname
|
7
|
+
|
8
|
+
options_with_blank_path = options.reverse_merge path: '', except: [:new, :create, :index]
|
9
|
+
options_with_path = options.reverse_merge except: [:show, :edit, :update, :destroy]
|
10
|
+
|
11
|
+
resources resources_name, options_with_blank_path, &block
|
12
|
+
resources resources_name, options_with_path, &block
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/webnames.rb
ADDED
metadata
CHANGED
@@ -1,61 +1,61 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webnames
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.2.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:
|
11
|
+
date: 2014-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '3.2'
|
20
|
-
- - <
|
20
|
+
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '5'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - ">"
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '3.2'
|
30
|
-
- - <
|
30
|
+
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '5'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
|
-
name:
|
34
|
+
name: rspec-rails
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
36
36
|
requirements:
|
37
|
-
- -
|
37
|
+
- - ">="
|
38
38
|
- !ruby/object:Gem::Version
|
39
39
|
version: '0'
|
40
40
|
type: :development
|
41
41
|
prerelease: false
|
42
42
|
version_requirements: !ruby/object:Gem::Requirement
|
43
43
|
requirements:
|
44
|
-
- -
|
44
|
+
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '0'
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
|
-
name:
|
48
|
+
name: pry
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
50
50
|
requirements:
|
51
|
-
- -
|
51
|
+
- - ">="
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: '0'
|
54
54
|
type: :development
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
57
|
requirements:
|
58
|
-
- -
|
58
|
+
- - ">="
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: '0'
|
61
61
|
description: webname(nickname, username) solution for Rails applications
|
@@ -65,20 +65,18 @@ executables: []
|
|
65
65
|
extensions: []
|
66
66
|
extra_rdoc_files: []
|
67
67
|
files:
|
68
|
-
- config/routes.rb
|
69
|
-
- lib/generators/active_record/active_record_generator.rb
|
70
|
-
- lib/generators/active_record/templates/migration.rb
|
71
|
-
- lib/generators/active_record/USAGE
|
72
|
-
- lib/generators/active_record/webname_generator.rb
|
73
|
-
- lib/generators/webname/templates/webname-active_record.rb
|
74
|
-
- lib/generators/webname/USAGE
|
75
|
-
- lib/generators/webname/webname_generator.rb
|
76
|
-
- lib/tasks/webname_tasks.rake
|
77
|
-
- lib/webname/engine.rb
|
78
|
-
- lib/webname/version.rb
|
79
|
-
- lib/webname.rb
|
80
68
|
- MIT-LICENSE
|
81
69
|
- Rakefile
|
70
|
+
- lib/generators/webnames/install/USAGE
|
71
|
+
- 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
|
+
- lib/tasks/webnames_tasks.rake
|
75
|
+
- lib/webnames.rb
|
76
|
+
- lib/webnames/engine.rb
|
77
|
+
- lib/webnames/rails/active_record.rb
|
78
|
+
- lib/webnames/rails/routes.rb
|
79
|
+
- lib/webnames/version.rb
|
82
80
|
homepage: https://github.com/sadjow/webnames
|
83
81
|
licenses: []
|
84
82
|
metadata: {}
|
@@ -88,17 +86,17 @@ require_paths:
|
|
88
86
|
- lib
|
89
87
|
required_ruby_version: !ruby/object:Gem::Requirement
|
90
88
|
requirements:
|
91
|
-
- -
|
89
|
+
- - ">="
|
92
90
|
- !ruby/object:Gem::Version
|
93
91
|
version: '0'
|
94
92
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
95
93
|
requirements:
|
96
|
-
- -
|
94
|
+
- - ">="
|
97
95
|
- !ruby/object:Gem::Version
|
98
96
|
version: '0'
|
99
97
|
requirements: []
|
100
98
|
rubyforge_project:
|
101
|
-
rubygems_version: 2.
|
99
|
+
rubygems_version: 2.2.2
|
102
100
|
signing_key:
|
103
101
|
specification_version: 4
|
104
102
|
summary: webname(nickname, username) solution for Rails
|
data/config/routes.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'rails/generators/active_record'
|
2
|
-
require 'active_support/core_ext'
|
3
|
-
|
4
|
-
module ActiveRecord
|
5
|
-
module Generators
|
6
|
-
class WebnameGenerator < ActiveRecord::Generators::Base
|
7
|
-
source_root File.expand_path('../templates', __FILE__)
|
8
|
-
|
9
|
-
def generate_model
|
10
|
-
invoke "active_record:model", [ name ], :migration => false
|
11
|
-
end
|
12
|
-
|
13
|
-
def copy_webname_migration
|
14
|
-
migration_template "migration.rb", "db/migrate/webname_create_#{table_name}"
|
15
|
-
end
|
16
|
-
|
17
|
-
def model_path
|
18
|
-
File.join("app", "models", "#{file_path}.rb")
|
19
|
-
end
|
20
|
-
|
21
|
-
def model_content
|
22
|
-
"belongs_to :resource, :polymorphic => true"
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module Webname
|
2
|
-
module Generators
|
3
|
-
class WebnameGenerator < Rails::Generators::NamedBase
|
4
|
-
class_option :orm, :type => :string, :default => "active_record"
|
5
|
-
argument :klass_name, :type => :string, :default => "Webname"
|
6
|
-
|
7
|
-
source_root File.expand_path('../templates', __FILE__)
|
8
|
-
|
9
|
-
hook_for :orm, :required => true
|
10
|
-
|
11
|
-
desc "Generates a model and a migration file for the webnames"
|
12
|
-
|
13
|
-
def self.start(args, config)
|
14
|
-
klass_name = args.size > 1 ? args[1] : "Webname"
|
15
|
-
args.insert(1, klass_name) # 0 being the view name
|
16
|
-
super
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
data/lib/webname/version.rb
DELETED
data/lib/webname.rb
DELETED