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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 498832a304c1e5234ed5ed576727d2f98a236b50
4
- data.tar.gz: 4cf1a787e0e8034df4351707dd086c5409dde83c
3
+ metadata.gz: af4ffa11c1e7c0dc09dfef52a5d6a62183c2f3e2
4
+ data.tar.gz: 72e4ee5dce6fd4ed5e665a0c6d9ff3637965b9f8
5
5
  SHA512:
6
- metadata.gz: b9319fd2d7592610e5e2c040c84f8083d2526d848ddc2ac84fea1e286e62b13a593922526c676d71963a69b065e4b6d5c089e2415d28c38ffddd4f162f8910fb
7
- data.tar.gz: 889c71eb0c6ae727428041b430c1eb3a61ddc7f3082efc5158587fab5ba1994aa328b0a749c28a47ac9bcf9ef3c57cba8f94f35fa5e1715bb4fc2d390717bb4a
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
@@ -3,7 +3,7 @@ class CreateFriendships < ActiveRecord::Migration
3
3
  create_table :friendships do |t|
4
4
  t.references :friendable, polymorphic: true
5
5
  t.integer :friend_id
6
- t.integer :status, index: true
6
+ t.string :status
7
7
 
8
8
  t.timestamps
9
9
  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
@@ -1,3 +1,3 @@
1
1
  module HasFriendship
2
- VERSION = "0.1.4"
2
+ VERSION = "1.0.0"
3
3
  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.1.4
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-04-17 00:00:00.000000000 Z
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