feedbuilder-rails 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,3 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source "http://rubygems.org"
2
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,58 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ feedbuilder-rails (0.0.1)
5
+ actionpack (~> 3.0)
6
+ activerecord (~> 3.0)
7
+ feedbuilder
8
+
9
+ GEM
10
+ remote: http://rubygems.org/
11
+ specs:
12
+ abstract (1.0.0)
13
+ actionpack (3.0.3)
14
+ activemodel (= 3.0.3)
15
+ activesupport (= 3.0.3)
16
+ builder (~> 2.1.2)
17
+ erubis (~> 2.6.6)
18
+ i18n (~> 0.4)
19
+ rack (~> 1.2.1)
20
+ rack-mount (~> 0.6.13)
21
+ rack-test (~> 0.5.6)
22
+ tzinfo (~> 0.3.23)
23
+ activemodel (3.0.3)
24
+ activesupport (= 3.0.3)
25
+ builder (~> 2.1.2)
26
+ i18n (~> 0.4)
27
+ activerecord (3.0.3)
28
+ activemodel (= 3.0.3)
29
+ activesupport (= 3.0.3)
30
+ arel (~> 2.0.2)
31
+ tzinfo (~> 0.3.23)
32
+ activesupport (3.0.3)
33
+ arel (2.0.6)
34
+ builder (2.1.2)
35
+ erubis (2.6.6)
36
+ abstract (>= 1.0.0)
37
+ feedbuilder (0.0.2)
38
+ activesupport (~> 3.0)
39
+ ratom
40
+ i18n (0.5.0)
41
+ libxml-ruby (1.1.4)
42
+ rack (1.2.1)
43
+ rack-mount (0.6.13)
44
+ rack (>= 1.0.0)
45
+ rack-test (0.5.6)
46
+ rack (>= 1.0)
47
+ ratom (0.6.7)
48
+ libxml-ruby (>= 1.1.2)
49
+ tzinfo (0.3.23)
50
+
51
+ PLATFORMS
52
+ ruby
53
+
54
+ DEPENDENCIES
55
+ actionpack (~> 3.0)
56
+ activerecord (~> 3.0)
57
+ feedbuilder
58
+ feedbuilder-rails!
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2009 Brian Moseley
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
data/README.md ADDED
@@ -0,0 +1,46 @@
1
+ Helpers that integrate [feedbuilder](https://github.com/bcm/feedbuilder) into Rails.
2
+
3
+ ## Usage
4
+
5
+ require 'feedbuilder-rails'
6
+ require 'will_paginate' # to get paging links
7
+
8
+ FeedBuilder.feed_id_domain = 'maz.org'
9
+
10
+ class Nug < ActiveRecord::Base
11
+ acts_as_feed_provider
12
+
13
+ def entry_title
14
+ name # a persistent attribute
15
+ end
16
+
17
+ def entry_summary
18
+ Atom::Content::Text.new("A nug named #{name}")
19
+ end
20
+
21
+ def entry_content
22
+ Atom::Content::Html.new("<p>A nug named #{name}</p>")
23
+ end
24
+ end
25
+
26
+ class NugsController < ApplicationController
27
+ def index
28
+ respond_to do |format|
29
+ format.atom do
30
+ nugs = Nug.paginate(:page => (params[:page] || 1), :page_size => (params[:page_size] || 10))
31
+ send_feed("nugs.atom", :etag => nugs) do
32
+ url_builder = feed_url_builder(root_url, nugs_url)
33
+ options = {:feed_title => "Bucket o' nugs", :feed_id_path => nugs_path}
34
+ Nug.build_feed(nugs, url_builder, options) do |nug, entry|
35
+ entry.id = Nug.feed_tag_uri(nug_path(nug), :date => nug.created_at)
36
+ entry.links << Atom::Link.new(:href => nug_url(nug), :rel => :alternate, :type => 'text/html')
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
42
+ end
43
+
44
+ ## Copyright
45
+
46
+ Copyright (c) 2010 Brian Moseley. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "feedbuilder-rails/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "feedbuilder-rails"
7
+ s.version = FeedBuilder::Rails::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Brian Moseley"]
10
+ s.email = ["bcm@maz.org"]
11
+ s.homepage = ""
12
+ s.summary = %q{Rails helpers for feedbuilder}
13
+ s.description = %q{Rails helpers for feedbuilder}
14
+
15
+ s.rubyforge_project = "feedbuilder-rails"
16
+
17
+ s.add_dependency 'actionpack', '~> 3.0'
18
+ s.add_dependency 'activerecord', '~> 3.0'
19
+ s.add_dependency 'feedbuilder'
20
+
21
+ s.files = `git ls-files`.split("\n")
22
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
23
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
24
+ s.require_paths = ["lib"]
25
+ end
@@ -0,0 +1,20 @@
1
+ module FeedBuilder
2
+ module Rails
3
+ module Controller
4
+ def send_feed(filename, options = {}, &block)
5
+ if Rails.env == 'development' || stale?(options)
6
+ feed ||= yield if block_given?
7
+ send_data(feed.to_xml, :filename => filename, :type => :atom, :disposition => 'inline')
8
+ end
9
+ end
10
+
11
+ def feed_url_builder(*args)
12
+ FeedBuilder::UrlBuilder.new(*args)
13
+ end
14
+ end
15
+ end
16
+ end
17
+
18
+ class ActionController::Base
19
+ include FeedBuilder::Rails::Controller
20
+ end
@@ -0,0 +1,14 @@
1
+ class ActiveRecord::Base
2
+ def self.acts_as_feed_provider(options = {})
3
+ unless (options.include?(:feed_id_domain) && options.include?(:feed_id_path)) || options.include?(:feed_id)
4
+ raise ArgumentError, 'Must include either :feed_id_domain and :feed_id_path or :feed_id'
5
+ end
6
+
7
+ extend FeedBuilder::Provider
8
+
9
+ self.feed_id_domain = options[:feed_id_domain]
10
+ self.feed_id_date = options[:feed_id_date]
11
+ self.feed_id_path = options[:feed_id_path]
12
+ self.feed_id = options[:feed_id]
13
+ end
14
+ end
@@ -0,0 +1,5 @@
1
+ module FeedBuilder
2
+ module Rails
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ require 'feedbuilder'
2
+
3
+ require 'action_controller'
4
+ require 'feedbuilder-rails/controller'
5
+
6
+ require 'active_record'
7
+ require 'feedbuilder-rails/provider'
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: feedbuilder-rails
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Brian Moseley
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-12-21 00:00:00 -05:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: actionpack
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ hash: 7
30
+ segments:
31
+ - 3
32
+ - 0
33
+ version: "3.0"
34
+ type: :runtime
35
+ version_requirements: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ name: activerecord
38
+ prerelease: false
39
+ requirement: &id002 !ruby/object:Gem::Requirement
40
+ none: false
41
+ requirements:
42
+ - - ~>
43
+ - !ruby/object:Gem::Version
44
+ hash: 7
45
+ segments:
46
+ - 3
47
+ - 0
48
+ version: "3.0"
49
+ type: :runtime
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: feedbuilder
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 3
60
+ segments:
61
+ - 0
62
+ version: "0"
63
+ type: :runtime
64
+ version_requirements: *id003
65
+ description: Rails helpers for feedbuilder
66
+ email:
67
+ - bcm@maz.org
68
+ executables: []
69
+
70
+ extensions: []
71
+
72
+ extra_rdoc_files: []
73
+
74
+ files:
75
+ - .gitignore
76
+ - Gemfile
77
+ - Gemfile.lock
78
+ - LICENSE
79
+ - README.md
80
+ - Rakefile
81
+ - feedbuilder-rails.gemspec
82
+ - lib/feedbuilder-rails.rb
83
+ - lib/feedbuilder-rails/controller.rb
84
+ - lib/feedbuilder-rails/provider.rb
85
+ - lib/feedbuilder-rails/version.rb
86
+ has_rdoc: true
87
+ homepage: ""
88
+ licenses: []
89
+
90
+ post_install_message:
91
+ rdoc_options: []
92
+
93
+ require_paths:
94
+ - lib
95
+ required_ruby_version: !ruby/object:Gem::Requirement
96
+ none: false
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ hash: 3
101
+ segments:
102
+ - 0
103
+ version: "0"
104
+ required_rubygems_version: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ hash: 3
110
+ segments:
111
+ - 0
112
+ version: "0"
113
+ requirements: []
114
+
115
+ rubyforge_project: feedbuilder-rails
116
+ rubygems_version: 1.3.7
117
+ signing_key:
118
+ specification_version: 3
119
+ summary: Rails helpers for feedbuilder
120
+ test_files: []
121
+