has_counter_on 0.1.3 → 0.1.4

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: 83ec47115331450a8723d6c616e734fca47b7facdc8957261b950c15d9983a6b
4
- data.tar.gz: 38d3b4b6116da5f6d9278d738ba528e3f0c8895a54576dda4591283c07d23a91
3
+ metadata.gz: c17c30b8d709a1b860f2c522fa34519529272f17e49787cb1417119d9cab1685
4
+ data.tar.gz: ac458a5a08940019b06a72106fd5e296cc2562dab461d248d3d7e7cb84b2d293
5
5
  SHA512:
6
- metadata.gz: ff45ee2f1c15ffe51e8ebda494f0362424e772e12bb746055a948327e72d1f2e185ff245ef5c60343b076c0a139b5cbeb2b9531cd02a28f254e8cedb95e65d98
7
- data.tar.gz: 7bde2f45f41efaed18c354e578629939c56b7503cbd2ef411046cdb132a6f739e8f1f9f15221f8b7e0d71d9a761877a2b3430468c70a6979bdde6fa9cb8bd4bc
6
+ metadata.gz: 4092192d2b3bf5a10e976201c2a378399188733811a7872a1ffd057db9e859a637535128aa0f212f25d79f9c99891e4476a7ed14163e2ca4236eaf7921c82ad1
7
+ data.tar.gz: c8fbed7fda3f5ba9098e322e240f3a1664bd65cf00f9e4a37a0549edbe090f6b2c0163335a1750764ccb1f7c9b89f3c55316f3a6bcbed4b3bb4f153e63991c98
@@ -1,8 +1,27 @@
1
1
  namespace :has_counter_on do
2
- desc 'Install has_counter_on dependencies'
3
- task :install do
4
- ActiveRecord::Base.establish_connection
5
- ActiveRecord::Migrator.migrate('db/migrate/')
6
- Rake::Task['db:schema'].invoke
2
+ desc 'Setup has_counter_on environment'
3
+ task :setup do
4
+ timestamp = Time.now.strftime('%Y%m%d%H%M%S')
5
+ ar_migration_path = ActiveRecord::Schema.migrations_paths.first
6
+ migration_path = "#{ar_migration_path}/#{timestamp}_create_counters.rb"
7
+
8
+ ar_version = "#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}"
9
+ migration_content = %Q{
10
+ class CreateCounters < ActiveRecord::Migration[#{ar_version}]
11
+ def change
12
+ create_table :counters do |t|
13
+ t.string :countable_type, limit: 64
14
+ t.integer :countable_id, unsigned: true
15
+ t.string :countable_name
16
+ t.integer :value
17
+ end
18
+
19
+ add_index :counters, [:countable_id, :countable_type, :countable_name], name: :index_counters_on_countable_id_type_name
20
+ end
21
+ end
22
+ }.strip
23
+
24
+ system("touch #{migration_path}")
25
+ system("echo #{migration_content} >> #{migration_path}")
7
26
  end
8
27
  end
@@ -1,3 +1,3 @@
1
1
  module HasCounterOn
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_counter_on
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Injung Chung
@@ -36,7 +36,6 @@ files:
36
36
  - LICENSE
37
37
  - README.md
38
38
  - Rakefile
39
- - db/migrate/create_counters_migration.rb
40
39
  - has_counter_on.gemspec
41
40
  - lib/has_counter_on.rb
42
41
  - lib/has_counter_on/countable.rb
@@ -1,14 +0,0 @@
1
- AR_VERSION = ActiveRecord.gem_version.version.to_f
2
-
3
- class CreateCounters < ActiveRecord::Migration[AR_VERSION]
4
- def change
5
- create_table :counters do |t|
6
- t.string :countable_type, limit: 64
7
- t.integer :countable_id, unsigned: true
8
- t.string :countable_name
9
- t.integer :value
10
- end
11
-
12
- add_index :counters, [:countable_id, :countable_type, :countable_name], name: :index_counters_on_countable_id_type_name
13
- end
14
- end