has_friendship 0.1.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/generators/has_friendship/has_friendship_generator.rb +2 -0
- data/lib/generators/has_friendship/templates/create_friendships.rb +1 -1
- data/lib/generators/has_friendship_update/has_friendship_update_generator.rb +22 -0
- data/lib/generators/has_friendship_update/templates/update_friendships.rb +21 -0
- data/lib/has_friendship/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af4ffa11c1e7c0dc09dfef52a5d6a62183c2f3e2
|
4
|
+
data.tar.gz: 72e4ee5dce6fd4ed5e665a0c6d9ff3637965b9f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2011f57fc3335256ff46e3a479ae1b096b3d57b35df768614a7834b3a70363985e55696c8b91348bfff1ba95b4496a84df1c4c8fe99b506ebaadef89cd9b03de
|
7
|
+
data.tar.gz: 1d7009b070873938b4f528eab18fa102df2acd7c4acbcdf0981c35b149ff078da8d16069dc6c8e4e300168b00661cb45817c9b10ddbade05fffc0cfd0e77fded
|
@@ -20,5 +20,7 @@ class HasFriendshipGenerator < Rails::Generators::Base
|
|
20
20
|
'db/migrate/create_friendships.rb'
|
21
21
|
migration_template 'add_blocker_id_to_friendships.rb',
|
22
22
|
'db/migrate/add_blocker_id_to_friendships.rb'
|
23
|
+
migration_template '../../has_friendship_update/templates/update_friendships.rb',
|
24
|
+
'db/migrate/update_friendships.rb'
|
23
25
|
end
|
24
26
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require 'rails/generators/migration'
|
3
|
+
|
4
|
+
class HasFriendshipUpdateGenerator < Rails::Generators::Base
|
5
|
+
include Rails::Generators::Migration
|
6
|
+
|
7
|
+
def self.source_root
|
8
|
+
File.join(File.dirname(__FILE__), 'templates')
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.next_migration_number(path)
|
12
|
+
next_num = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
|
13
|
+
current_num = current_migration_number(path)
|
14
|
+
next_num += (current_num - next_num + 1) if current_num >= next_num
|
15
|
+
next_num.to_s
|
16
|
+
end
|
17
|
+
|
18
|
+
def create_migration_file
|
19
|
+
migration_template 'update_friendships.rb',
|
20
|
+
'db/migrate/update_friendships.rb'
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
class UpdateFriendships < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
add_column :friendships, :status_temp, :integer, index: true
|
4
|
+
HasFriendship::Friendship.where(status: 'pending').update_all(status_temp: 0)
|
5
|
+
HasFriendship::Friendship.where(status: 'requested').update_all(status_temp: 1)
|
6
|
+
HasFriendship::Friendship.where(status: 'accepted').update_all(status_temp: 2)
|
7
|
+
HasFriendship::Friendship.where(status: 'blocked').update_all(status_temp: 3)
|
8
|
+
remove_column :friendships, :status
|
9
|
+
rename_column :friendships, :status_temp, :status
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.down
|
13
|
+
add_column :friendships, :status_temp, :string
|
14
|
+
HasFriendship::Friendship.where(status: 0).update_all(status_temp: 'pending')
|
15
|
+
HasFriendship::Friendship.where(status: 1).update_all(status_temp: 'requested')
|
16
|
+
HasFriendship::Friendship.where(status: 2).update_all(status_temp: 'accepted')
|
17
|
+
HasFriendship::Friendship.where(status: 3).update_all(status_temp: 'blocked')
|
18
|
+
remove_column :friendships, :status
|
19
|
+
rename_column :friendships, :status_temp, :status
|
20
|
+
end
|
21
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: has_friendship
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sung Won Cho
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -162,6 +162,8 @@ files:
|
|
162
162
|
- lib/generators/has_friendship/has_friendship_generator.rb
|
163
163
|
- lib/generators/has_friendship/templates/add_blocker_id_to_friendships.rb
|
164
164
|
- lib/generators/has_friendship/templates/create_friendships.rb
|
165
|
+
- lib/generators/has_friendship_update/has_friendship_update_generator.rb
|
166
|
+
- lib/generators/has_friendship_update/templates/update_friendships.rb
|
165
167
|
- lib/has_friendship.rb
|
166
168
|
- lib/has_friendship/extender.rb
|
167
169
|
- lib/has_friendship/friendable.rb
|