has_friendship 1.1.2 → 1.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d99d48c395f941bc212f9cb801ce1eddd5d66b38c190df42a49f3e66d6163913
4
- data.tar.gz: 5c2803f46a236f983123fa9a0cc81768366627d941c6d09abff385824e55ca99
3
+ metadata.gz: 227f53cc04f4a9112f9c00c718ef0b5b94d594db9880aabc724a59f19e3ca53d
4
+ data.tar.gz: 2ed9c242a90308842bc1297df5cc868502b5d37713af9f6b89fa6ebba1a5b278
5
5
  SHA512:
6
- metadata.gz: 4eb875859e9137ef81dbe1e6780ff2eb082b5ab3652b51d40b2ab0ebc8eb7f07c93abc99edbe77ccbbfe267b93ae378b7998f7074c203c1c12c0ed6f4ea9964a
7
- data.tar.gz: 848dd43cb64e95279a0f1447f960d780da7f6a61c79a56e19911af2b1acc68d829bf0375e90587c37a37618a0a2db06983c9d26c676c223ac9621d4cb157d91d
6
+ metadata.gz: a9875987ef55fcc4d146b8364ce3009f6df5d3c2f1cf4f4d9f069b845673c1037e75620db5e1064276511d950cf6700ffde5e11efce5b5649d47699a5f3d9904
7
+ data.tar.gz: 0b44c5878aded4760f54bc7903b093baa3bb0eecf189f6d5667bc123306ada2e4ae402be0d9309002b600420f64753876a73bba0236a0025306bf70f2a750050
@@ -1,4 +1,10 @@
1
- class CreateFriendships < ActiveRecord::Migration[4.2]
1
+ if ActiveRecord.gem_version >= Gem::Version.new('5.0')
2
+ class CreateFriendships < ActiveRecord::Migration[4.2]; end
3
+ else
4
+ class CreateFriendships < ActiveRecord::Migration; end
5
+ end
6
+
7
+ CreateFriendships.class_eval do
2
8
  def self.up
3
9
  create_table :friendships do |t|
4
10
  t.references :friendable, polymorphic: true
@@ -0,0 +1,15 @@
1
+ if ActiveRecord.gem_version >= Gem::Version.new('5.0')
2
+ class AddBlockerIdToFriendships < ActiveRecord::Migration[4.2]; end
3
+ else
4
+ class AddBlockerIdToFriendships < ActiveRecord::Migration; end
5
+ end
6
+
7
+ AddBlockerIdToFriendships.class_eval do
8
+ def self.up
9
+ add_column :friendships, :blocker_id, :integer, default: nil
10
+ end
11
+
12
+ def self.down
13
+ remove_column :friendships, :blocker_id
14
+ end
15
+ end
@@ -1,4 +1,10 @@
1
- class UpdateFriendships < ActiveRecord::Migration[4.2]
1
+ if ActiveRecord.gem_version >= Gem::Version.new('5.0')
2
+ class UpdateFriendships < ActiveRecord::Migration[4.2]; end
3
+ else
4
+ class UpdateFriendships < ActiveRecord::Migration; end
5
+ end
6
+
7
+ UpdateFriendships.class_eval do
2
8
  def self.up
3
9
  add_column :friendships, :status_temp, :integer, index: true
4
10
  HasFriendship::Friendship.where(status: 'pending').update_all(status_temp: 0)
@@ -2,6 +2,8 @@ require 'stateful_enum'
2
2
 
3
3
  require 'active_support'
4
4
  require 'active_record'
5
+ require 'rails/engine'
6
+ require 'has_friendship/engine'
5
7
 
6
8
  module HasFriendship
7
9
  extend ActiveSupport::Autoload
@@ -13,4 +15,4 @@ end
13
15
 
14
16
  ActiveSupport.on_load(:active_record) do
15
17
  extend HasFriendship::Friendable
16
- end
18
+ end
@@ -0,0 +1,5 @@
1
+ module HasFriendship
2
+ class Engine < ::Rails::Engine
3
+ # isolate_namespace HasFriendship
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  module HasFriendship
2
- VERSION = "1.1.2"
2
+ VERSION = "1.1.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_friendship
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2
4
+ version: 1.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sung Won Cho
@@ -165,12 +165,11 @@ extra_rdoc_files: []
165
165
  files:
166
166
  - MIT-LICENSE
167
167
  - Rakefile
168
- - lib/generators/has_friendship/has_friendship_generator.rb
169
- - lib/generators/has_friendship/templates/add_blocker_id_to_friendships.rb
170
- - lib/generators/has_friendship/templates/create_friendships.rb
171
- - lib/generators/has_friendship_update/has_friendship_update_generator.rb
172
- - lib/generators/has_friendship_update/templates/update_friendships.rb
168
+ - db/migrate/1_create_friendships.rb
169
+ - db/migrate/2_add_blocker_id_to_friendships.rb
170
+ - db/migrate/3_update_friendships.rb
173
171
  - lib/has_friendship.rb
172
+ - lib/has_friendship/engine.rb
174
173
  - lib/has_friendship/extender.rb
175
174
  - lib/has_friendship/friendable.rb
176
175
  - lib/has_friendship/friendship.rb
@@ -1,26 +0,0 @@
1
- require 'rails/generators'
2
- require 'rails/generators/migration'
3
-
4
- class HasFriendshipGenerator < 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 'create_friendships.rb',
20
- 'db/migrate/create_friendships.rb'
21
- migration_template 'add_blocker_id_to_friendships.rb',
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'
25
- end
26
- end
@@ -1,9 +0,0 @@
1
- class AddBlockerIdToFriendships < ActiveRecord::Migration[4.2]
2
- def self.up
3
- add_column :friendships, :blocker_id, :integer, default: nil
4
- end
5
-
6
- def self.down
7
- remove_column :friendships, :blocker_id
8
- end
9
- end
@@ -1,22 +0,0 @@
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