acts_in_relation 0.2.0 → 0.2.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 +4 -4
- data/.gitignore +2 -5
- data/README.md +14 -0
- data/lib/acts_in_relation/version.rb +1 -1
- data/lib/generators/acts_in_relation/action_generator.rb +36 -0
- data/lib/generators/acts_in_relation/templates/add.rb.erb +6 -0
- data/lib/generators/acts_in_relation/templates/create.rb.erb +10 -0
- data/spec/dummy/application.rb +2 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4fe38daa27d165526d7e9e12500dc6c912a09ecd
|
4
|
+
data.tar.gz: 962ba4832d57d659960ca05cb80035f293c0262e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24b69788f633b82dfd277d4ffe6eee078e2edc42018f6f40698328a2a38d5627c19b429485cfd64d026e10de670787a49263dfd23dc6f80b40ffb6c63bdeec0c
|
7
|
+
data.tar.gz: 26a752c79a045ba6595c36d6387134df630e89dab1a66f24e0ab9b331118b2a6e19cb1be7071e877c5d1ac2d1df256b5918305e2bda50725ddffb8faf4e2c4f0
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -142,6 +142,20 @@ acts_in_relation has three roles: source, target and action.
|
|
142
142
|
| target | The model that receives the action. | User | Post |
|
143
143
|
| action | The action performs between two models. | Follow | Like |
|
144
144
|
|
145
|
+
## Generate migration
|
146
|
+
|
147
|
+
You can generate migration by generator:
|
148
|
+
|
149
|
+
```
|
150
|
+
$ rails generate acts_in_relation:action [action] --source=[source] --target=[target]
|
151
|
+
```
|
152
|
+
|
153
|
+
For example:
|
154
|
+
|
155
|
+
```
|
156
|
+
$ rails generate acts_in_relation:action like --source=user --target=post
|
157
|
+
```
|
158
|
+
|
145
159
|
## Contributing
|
146
160
|
|
147
161
|
1. Fork it ( https://github.com/kami30k/acts_in_relation/fork )
|
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'rails/generators/active_record'
|
2
|
+
|
3
|
+
module ActsInRelation
|
4
|
+
module Generators
|
5
|
+
class ActionGenerator < ActiveRecord::Generators::Base
|
6
|
+
source_root File.expand_path('../templates', __FILE__)
|
7
|
+
|
8
|
+
argument :name, required: true, banner: '[action] --source=[source] --target=[target]'
|
9
|
+
|
10
|
+
class_option :source, required: true, aliases: '-s'
|
11
|
+
class_option :target, required: true, aliases: '-t'
|
12
|
+
|
13
|
+
def copy_migration
|
14
|
+
if migration_exists?
|
15
|
+
migration_template 'add.rb.erb', "db/migrate/add_columns_to_#{table_name}.rb"
|
16
|
+
else
|
17
|
+
migration_template 'create.rb.erb', "db/migrate/create_#{table_name}.rb"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def migration_exists?
|
24
|
+
Dir.glob("#{migration_path}/[0-9]*_*.rb").grep(/\d+_create_#{table_name}.rb$/).present?
|
25
|
+
end
|
26
|
+
|
27
|
+
def migration_path
|
28
|
+
Rails.root.join('db/migrate')
|
29
|
+
end
|
30
|
+
|
31
|
+
def table_name
|
32
|
+
name.downcase.pluralize
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/spec/dummy/application.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_in_relation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kami
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-04-
|
11
|
+
date: 2015-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -102,6 +102,9 @@ files:
|
|
102
102
|
- lib/acts_in_relation/roles/target.rb
|
103
103
|
- lib/acts_in_relation/supports/verb.rb
|
104
104
|
- lib/acts_in_relation/version.rb
|
105
|
+
- lib/generators/acts_in_relation/action_generator.rb
|
106
|
+
- lib/generators/acts_in_relation/templates/add.rb.erb
|
107
|
+
- lib/generators/acts_in_relation/templates/create.rb.erb
|
105
108
|
- spec/dummy/application.rb
|
106
109
|
- spec/dummy/bin/rails
|
107
110
|
- spec/dummy/config.ru
|
@@ -128,7 +131,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
131
|
version: '0'
|
129
132
|
requirements: []
|
130
133
|
rubyforge_project:
|
131
|
-
rubygems_version: 2.4.
|
134
|
+
rubygems_version: 2.4.5
|
132
135
|
signing_key:
|
133
136
|
specification_version: 4
|
134
137
|
summary: Add relational feature to Rails (e.g. follow, block and like).
|