how_are_we_doing 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in how_are_we_doing.gemspec
4
+ gemspec
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,16 @@
1
+ class PrintsController < ApplicationController
2
+ respond_to :html, :json, :xml, :js
3
+
4
+ def create
5
+ @print = parent.prints.create
6
+
7
+ respond_with @print
8
+ end
9
+
10
+ protected
11
+ def parent
12
+ @parent ||= params[:printable_type].classify.constantize.find(params[:printable_id])
13
+ instance_variable_set("@#{params[:printable_type].underscore}",@parent)
14
+ end
15
+
16
+ end
@@ -0,0 +1,16 @@
1
+ class SharesController < ApplicationController
2
+ respond_to :html, :json, :xml, :js
3
+
4
+ def create
5
+ @share = parent.shares.create
6
+
7
+ respond_with @share
8
+ end
9
+
10
+ protected
11
+ def parent
12
+ @parent ||= params[:shareable_type].classify.constantize.find(params[:shareable_id])
13
+ instance_variable_set("@#{params[:shareable_type].underscore}",@parent)
14
+ end
15
+
16
+ end
@@ -0,0 +1,16 @@
1
+ class ViewsController < ApplicationController
2
+ respond_to :html, :json, :xml, :js
3
+
4
+ def create
5
+ @view = parent.views.create
6
+
7
+ respond_with @view
8
+ end
9
+
10
+ protected
11
+ def parent
12
+ @parent ||= params[:viewable_type].classify.constantize.find(params[:viewable_id])
13
+ instance_variable_set("@#{params[:viewable_type].underscore}",@parent)
14
+ end
15
+
16
+ end
@@ -0,0 +1,3 @@
1
+ class Print < ActiveRecord::Base
2
+ belongs_to :printable, :polymorphic => true
3
+ end
@@ -0,0 +1,3 @@
1
+ class Share < ActiveRecord::Base
2
+ belongs_to :shareable, :polymorphic => true
3
+ end
@@ -0,0 +1,3 @@
1
+ class View < ActiveRecord::Base
2
+ belongs_to :viewable, :polymorphic => true
3
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "how_are_we_doing/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "how_are_we_doing"
7
+ s.version = HowAreWeDoing::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Gunner Technology, Cody Swann"]
10
+ s.email = ["developers@gunnertech.com"]
11
+ s.homepage = ""
12
+ s.summary = %q{A gem to help answer the question "How are we doing?"}
13
+ s.description = %q{This gem will help you track shares (Facebook, Twitter, Email), Prints and Views}
14
+
15
+ s.rubyforge_project = "how_are_we_doing"
16
+
17
+ s.files = `git ls-files`.split("\n")
18
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.require_paths = ["lib"]
21
+ end
@@ -0,0 +1,23 @@
1
+ module HowAreWeDoing
2
+ module ActsAsPrintable #:nodoc:
3
+
4
+ def self.included(base)
5
+ base.extend ClassMethods
6
+ end
7
+
8
+ module ClassMethods
9
+ def acts_as_printable
10
+ has_many :prints, :as => :printable
11
+
12
+ include HowAreWeDoing::ActsAsPrintable::InstanceMethods
13
+ extend HowAreWeDoing::ActsAsPrintable::SingletonMethods
14
+ end
15
+ end
16
+
17
+ module SingletonMethods
18
+ end
19
+
20
+ module InstanceMethods
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ module HowAreWeDoing
2
+ module ActsAsShareable #:nodoc:
3
+
4
+ def self.included(base)
5
+ base.extend ClassMethods
6
+ end
7
+
8
+ module ClassMethods
9
+ def acts_as_shareable
10
+ has_many :shares, :as => :shareable
11
+
12
+ include HowAreWeDoing::ActsAsShareable::InstanceMethods
13
+ extend HowAreWeDoing::ActsAsShareable::SingletonMethods
14
+ end
15
+ end
16
+
17
+ module SingletonMethods
18
+ end
19
+
20
+ module InstanceMethods
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,23 @@
1
+ module HowAreWeDoing
2
+ module ActsAsViewable #:nodoc:
3
+
4
+ def self.included(base)
5
+ base.extend ClassMethods
6
+ end
7
+
8
+ module ClassMethods
9
+ def acts_as_viewable
10
+ has_many :views, :as => :viewable
11
+
12
+ include HowAreWeDoing::ActsAsViewable::InstanceMethods
13
+ extend HowAreWeDoing::ActsAsViewable::SingletonMethods
14
+ end
15
+ end
16
+
17
+ module SingletonMethods
18
+ end
19
+
20
+ module InstanceMethods
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,33 @@
1
+ module HowAreWeDoing
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")
11
+ else
12
+ "%.3d" % (current_migration_number(dirname) + 1)
13
+ end
14
+ end
15
+
16
+ def generate_controllers
17
+ #template "app/controllers/authentications_controller.rb", "app/controllers/authentications_controller.rb"
18
+ end
19
+
20
+ def generate_migrations
21
+ migration_template "db/migrate/create_views.rb", "db/migrate/create_views.rb"
22
+ migration_template "db/migrate/create_shares.rb", "db/migrate/create_shares.rb"
23
+ migration_template "db/migrate/create_prints.rb", "db/migrate/create_prints.rb"
24
+ end
25
+
26
+ def generate_routes
27
+ route("match ':viewable_type/:viewable_id/views' => 'views#create', :via => :post")
28
+ route("match ':printable_type/:printable_id/prints' => 'prints#create', :via => :post")
29
+ route("match ':shareable_type/:shareable_id/shares' => 'shares#create', :via => :post")
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,16 @@
1
+ class CreatePrints < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :prints do |t|
4
+ t.references :printable, :polymorphic => true
5
+ t.references :user
6
+ t.timestamps
7
+ end
8
+
9
+ add_index :prints, [:printable_id, :printable_type]
10
+ add_index :prints, :user_id
11
+ end
12
+
13
+ def self.down
14
+ drop_table :prints
15
+ end
16
+ end
@@ -0,0 +1,20 @@
1
+ class CreateShares < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :shares do |t|
4
+ t.references :shareable, :polymorphic => true
5
+ t.references :user
6
+ t.string :service_ident, :limit => 48
7
+ t.string :url_hash
8
+ t.timestamps
9
+ end
10
+
11
+ add_index :shares, [:shareable_id, :shareable_type]
12
+ add_index :shares, :user_id
13
+ add_index :shares, :server_ident
14
+ add_index :shares, :url_hash
15
+ end
16
+
17
+ def self.down
18
+ drop_table :shares
19
+ end
20
+ end
@@ -0,0 +1,16 @@
1
+ class CreateViews < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :views do |t|
4
+ t.references :viewable, :polymorphic => true
5
+ t.references :user
6
+ t.timestamps
7
+ end
8
+
9
+ add_index :views, [:viewable_id, :viewable_type]
10
+ add_index :views, :user_id
11
+ end
12
+
13
+ def self.down
14
+ drop_table :views
15
+ end
16
+ end
@@ -0,0 +1,3 @@
1
+ module HowAreWeDoing
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,12 @@
1
+ require 'acts_as_printable'
2
+ require 'acts_as_viewable'
3
+ require 'acts_as_shareable'
4
+
5
+ ActiveRecord::Base.send(:include, HowAreWeDoing::ActsAsPrintable)
6
+ ActiveRecord::Base.send(:include, HowAreWeDoing::ActsAsViewable)
7
+ ActiveRecord::Base.send(:include, HowAreWeDoing::ActsAsShareable)
8
+
9
+ module HowAreWeDoing
10
+ class Engine < ::Rails::Engine
11
+ end
12
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: how_are_we_doing
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 1
9
+ version: 0.0.1
10
+ platform: ruby
11
+ authors:
12
+ - Gunner Technology, Cody Swann
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2011-02-28 00:00:00 -08:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: This gem will help you track shares (Facebook, Twitter, Email), Prints and Views
22
+ email:
23
+ - developers@gunnertech.com
24
+ executables: []
25
+
26
+ extensions: []
27
+
28
+ extra_rdoc_files: []
29
+
30
+ files:
31
+ - .gitignore
32
+ - Gemfile
33
+ - Rakefile
34
+ - app/controllers/prints_controller.rb
35
+ - app/controllers/shares_controller.rb
36
+ - app/controllers/views_controller.rb
37
+ - app/models/print.rb
38
+ - app/models/share.rb
39
+ - app/models/view.rb
40
+ - how_are_we_doing.gemspec
41
+ - lib/acts_as_printable.rb
42
+ - lib/acts_as_shareable.rb
43
+ - lib/acts_as_viewable.rb
44
+ - lib/generators/install_generator.rb
45
+ - lib/generators/templates/db/migrate/create_prints.rb
46
+ - lib/generators/templates/db/migrate/create_shares.rb
47
+ - lib/generators/templates/db/migrate/create_views.rb
48
+ - lib/how_are_we_doing.rb
49
+ - lib/how_are_we_doing/version.rb
50
+ has_rdoc: true
51
+ homepage: ""
52
+ licenses: []
53
+
54
+ post_install_message:
55
+ rdoc_options: []
56
+
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ segments:
65
+ - 0
66
+ version: "0"
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ segments:
73
+ - 0
74
+ version: "0"
75
+ requirements: []
76
+
77
+ rubyforge_project: how_are_we_doing
78
+ rubygems_version: 1.3.7
79
+ signing_key:
80
+ specification_version: 3
81
+ summary: A gem to help answer the question "How are we doing?"
82
+ test_files: []
83
+