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 +4 -4
- data/lib/has_counter_on/tasks.rb +24 -5
- data/lib/has_counter_on/version.rb +1 -1
- metadata +1 -2
- data/db/migrate/create_counters_migration.rb +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c17c30b8d709a1b860f2c522fa34519529272f17e49787cb1417119d9cab1685
|
4
|
+
data.tar.gz: ac458a5a08940019b06a72106fd5e296cc2562dab461d248d3d7e7cb84b2d293
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4092192d2b3bf5a10e976201c2a378399188733811a7872a1ffd057db9e859a637535128aa0f212f25d79f9c99891e4476a7ed14163e2ca4236eaf7921c82ad1
|
7
|
+
data.tar.gz: c8fbed7fda3f5ba9098e322e240f3a1664bd65cf00f9e4a37a0549edbe090f6b2c0163335a1750764ccb1f7c9b89f3c55316f3a6bcbed4b3bb4f153e63991c98
|
data/lib/has_counter_on/tasks.rb
CHANGED
@@ -1,8 +1,27 @@
|
|
1
1
|
namespace :has_counter_on do
|
2
|
-
desc '
|
3
|
-
task :
|
4
|
-
|
5
|
-
ActiveRecord::
|
6
|
-
|
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
|
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.
|
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
|