streamit 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,10 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "rails", "3.0.3"
4
+ gem "capybara", ">= 0.4.0"
5
+ gem "sqlite3-ruby", :require => "sqlite3"
6
+
7
+ gem "mocha", ">= 0.9.10"
8
+ gem "shoulda-context", "1.0.0.beta1"
9
+ gem "launchy", ">= 0.3.7"
10
+ gem "timecop", ">= 0.3.5"
data/TODO ADDED
@@ -0,0 +1,35 @@
1
+ TODO:
2
+ - use background job like tool to process creating of streams
3
+ - customizable views
4
+ - cleanup old streams
5
+ - add more detailed documentation
6
+
7
+ class Streamit::Stream < ActiveRecord::Base
8
+ belongs_to :actor, :polymorphic => true
9
+ belongs_to :subject, :polymorphic => true
10
+ belongs_to :receiver, :polymorphic => true
11
+ end
12
+
13
+ # "he9lin started watching auction ipad 001 a minute ago"
14
+ #
15
+ # en:
16
+ # streamit:
17
+ # watching:
18
+ # create: "started watching"
19
+
20
+ class Watching < ActiveRecord::Base
21
+ belongs_to :watcher, :class_name => "User", :foreign_key => "user_id"
22
+ belongs_to :watched_item, :class_name => "Item", :foreign_key => "item_id"
23
+
24
+ stream :create, :actor => :watcher,
25
+ :receiver => :watched_item
26
+ end
27
+
28
+ # "he9lin just edited profile image just now"
29
+ #
30
+ # stream:
31
+ # stream_type: 'user.update.image_url'
32
+ #
33
+ class User < ActiveRecord::Base
34
+ stream :update, :attributes => :image_url
35
+ end
@@ -0,0 +1,26 @@
1
+ class Streamit::StreamsController < ApplicationController
2
+ delegate :store, :to => Streamit
3
+
4
+ before_filter :process_params, :only => :fetch
5
+
6
+ def fetch
7
+ respond_to do |format|
8
+ format.html
9
+ format.js { render :text => render_streams_to_string }
10
+ end
11
+ end
12
+
13
+ private
14
+
15
+ def process_params
16
+ @streams = [:ago, :after, :limit].inject(store.scoped) do |scp, sym|
17
+ scp = scp.send(sym, params[sym]) if params[sym]
18
+ scp
19
+ end
20
+ end
21
+
22
+ def render_streams_to_string
23
+ render_to_string(:partial => "streamit/stream", :collection => @streams)
24
+ end
25
+
26
+ end
@@ -0,0 +1,3 @@
1
+ <div id="recent_streams">
2
+ <%= render @streams %>
3
+ </div>
data/config/routes.rb ADDED
@@ -0,0 +1,5 @@
1
+ Rails.application.routes.draw do
2
+ namespace :streamit do
3
+ get "fetch" => "streams#fetch", :as => :fetch
4
+ end
5
+ end
@@ -1,5 +1,5 @@
1
1
  module Streamit
2
- class Engine < Rails::Engine
2
+ class Engine < ::Rails::Engine
3
3
  config.streamit = ActiveSupport::OrderedOptions.new
4
4
 
5
5
  initializer "streamit.active_record" do
@@ -13,5 +13,6 @@ module Streamit
13
13
  Streamit.set_store(&app.config.streamit.set_store)
14
14
  end
15
15
  end
16
- end
17
- end
16
+
17
+ end # Engine
18
+ end # Streamit
@@ -1,12 +1,8 @@
1
1
  Dummy::Application.routes.draw do
2
2
  root :to => "users#new"
3
3
 
4
- resources :watchings
5
-
6
4
  resources :users
7
5
 
8
- resources :items
9
-
10
6
  # The priority is based upon order of creation:
11
7
  # first created -> highest priority.
12
8
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 3
9
+ version: 0.0.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Lin He
@@ -27,17 +27,22 @@ extensions: []
27
27
  extra_rdoc_files: []
28
28
 
29
29
  files:
30
+ - Gemfile
31
+ - README.rdoc
32
+ - MIT-LICENSE
33
+ - Rakefile
34
+ - TODO
35
+ - app/controllers/streamit/streams_controller.rb
36
+ - app/views/streamit/streams/fetch.html.erb
37
+ - config/routes.rb
38
+ - lib/streamit.rb
30
39
  - lib/generators/streamit_generator.rb
31
40
  - lib/generators/templates/_stream.html.erb
32
41
  - lib/streamit/dsl.rb
33
42
  - lib/streamit/engine.rb
43
+ - lib/streamit/store.rb
34
44
  - lib/streamit/locales/en.yml
35
45
  - lib/streamit/orm/active_record.rb
36
- - lib/streamit/store.rb
37
- - lib/streamit.rb
38
- - MIT-LICENSE
39
- - Rakefile
40
- - README.rdoc
41
46
  - test/dummy/app/controllers/application_controller.rb
42
47
  - test/dummy/app/controllers/users_controller.rb
43
48
  - test/dummy/app/models/stream.rb