acts_as_activitable 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,9 @@
1
+ class Activity < ActiveRecord::Base
2
+ belongs_to :activitable, :polymorphic => true
3
+ belongs_to :user
4
+
5
+ serialize :data, Hash
6
+
7
+ validates :user_id, :presence => true
8
+ validates :data, :presence => true
9
+ end
@@ -1,3 +1,3 @@
1
1
  module ActsAsActivitable
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1,8 @@
1
+ Description:
2
+ This will set up a Gunner Technology Rails Project
3
+
4
+ Example:
5
+ rails generate project Thing
6
+
7
+ This will create:
8
+ a/lot/of/stuff
@@ -0,0 +1,25 @@
1
+ module ActsAsActivitable
2
+ module Generators
3
+ class InstallGenerator < ::Rails::Generators::Base
4
+ include ::Rails::Generators::Migration
5
+
6
+ source_root File.expand_path('../templates', __FILE__)
7
+
8
+ def self.next_migration_number(dirname)
9
+ if ActiveRecord::Base.timestamped_migrations
10
+ Time.now.utc.strftime("%Y%m%d%H%M%S%L")
11
+ else
12
+ "%.3d" % (current_migration_number(dirname) + 1)
13
+ end
14
+ end
15
+
16
+ def generate_migrations
17
+ migration_template "db/migrate/create_activities.rb", "db/migrate/create_activities.rb" rescue true
18
+ end
19
+
20
+ def generate_routes
21
+ route("resources :activities")
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,17 @@
1
+ class CreateActivities < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :activities do |t|
4
+ t.references :activitiable, :polymorphic => true
5
+ t.references :user
6
+ t.text :data
7
+ t.timestamps
8
+ end
9
+
10
+ add_index :activities, [:activitable_id, :activitable_type]
11
+ add_index :activities, :user_id
12
+ end
13
+
14
+ def self.down
15
+ drop_table :activities
16
+ end
17
+ end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: acts_as_activitable
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.1
5
+ version: 0.0.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Gunner Technology, Cody Swann
@@ -28,8 +28,12 @@ files:
28
28
  - Gemfile
29
29
  - Rakefile
30
30
  - acts_as_activitable.gemspec
31
+ - app/models/activity.rb
31
32
  - lib/acts_as_activitable.rb
32
33
  - lib/acts_as_activitable/version.rb
34
+ - lib/generators/acts_as_activitable/USAGE
35
+ - lib/generators/acts_as_activitable/install/install_generator.rb
36
+ - lib/generators/acts_as_activitable/install/templates/db/migrate/create_activities.rb
33
37
  has_rdoc: true
34
38
  homepage: ""
35
39
  licenses: []