feedreader 0.2.3

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.
data/README ADDED
@@ -0,0 +1,190 @@
1
+ == Welcome to Rails
2
+
3
+ Rails is a web-application and persistance framework that includes everything
4
+ needed to create database-backed web-applications according to the
5
+ Model-View-Control pattern of separation. This pattern splits the view (also
6
+ called the presentation) into "dumb" templates that are primarily responsible
7
+ for inserting pre-build data in between HTML tags. The model contains the
8
+ "smart" domain objects (such as Account, Product, Person, Post) that holds all
9
+ the business logic and knows how to persist themselves to a database. The
10
+ controller handles the incoming requests (such as Save New Account, Update
11
+ Product, Show Post) by manipulating the model and directing data to the view.
12
+
13
+ In Rails, the model is handled by what's called a object-relational mapping
14
+ layer entitled Active Record. This layer allows you to present the data from
15
+ database rows as objects and embellish these data objects with business logic
16
+ methods. You can read more about Active Record in
17
+ link:files/vendor/rails/activerecord/README.html.
18
+
19
+ The controller and view is handled by the Action Pack, which handles both
20
+ layers by its two parts: Action View and Action Controller. These two layers
21
+ are bundled in a single package due to their heavy interdependence. This is
22
+ unlike the relationship between the Active Record and Action Pack that is much
23
+ more separate. Each of these packages can be used independently outside of
24
+ Rails. You can read more about Action Pack in
25
+ link:files/vendor/rails/actionpack/README.html.
26
+
27
+
28
+ == Requirements
29
+
30
+ * Database and driver (MySQL, PostgreSQL, or SQLite)
31
+ * Rake[http://rake.rubyforge.org] for running tests and the generating documentation
32
+
33
+ == Optionals
34
+
35
+ * Apache 1.3.x or 2.x or lighttpd 1.3.11+ (or any FastCGI-capable webserver with a
36
+ mod_rewrite-like module)
37
+ * FastCGI (or mod_ruby) for better performance on Apache
38
+
39
+ == Getting started
40
+
41
+ 1. Run the WEBrick servlet: <tt>ruby script/server</tt>
42
+ (run with --help for options)
43
+ 2. Go to http://localhost:3000/ and get "Congratulations, you've put Ruby on Rails!"
44
+ 3. Follow the guidelines on the "Congratulations, you've put Ruby on Rails!" screen
45
+
46
+
47
+ == Example for Apache conf
48
+
49
+ <VirtualHost *:80>
50
+ ServerName rails
51
+ DocumentRoot /path/application/public/
52
+ ErrorLog /path/application/log/server.log
53
+
54
+ <Directory /path/application/public/>
55
+ Options ExecCGI FollowSymLinks
56
+ AllowOverride all
57
+ Allow from all
58
+ Order allow,deny
59
+ </Directory>
60
+ </VirtualHost>
61
+
62
+ NOTE: Be sure that CGIs can be executed in that directory as well. So ExecCGI
63
+ should be on and ".cgi" should respond. All requests from 127.0.0.1 goes
64
+ through CGI, so no Apache restart is necessary for changes. All other requests
65
+ goes through FCGI (or mod_ruby) that requires restart to show changes.
66
+
67
+
68
+ == Example for lighttpd conf (with FastCGI)
69
+
70
+ server.port = 8080
71
+ server.bind = "127.0.0.1"
72
+ # server.event-handler = "freebsd-kqueue" # needed on OS X
73
+
74
+ server.modules = ( "mod_rewrite", "mod_fastcgi" )
75
+
76
+ url.rewrite = ( "^/$" => "index.html", "^([^.]+)$" => "$1.html" )
77
+ server.error-handler-404 = "/dispatch.fcgi"
78
+
79
+ server.document-root = "/path/application/public"
80
+ server.errorlog = "/path/application/log/server.log"
81
+
82
+ fastcgi.server = ( ".fcgi" =>
83
+ ( "localhost" =>
84
+ (
85
+ "min-procs" => 1,
86
+ "max-procs" => 5,
87
+ "socket" => "/tmp/application.fcgi.socket",
88
+ "bin-path" => "/path/application/public/dispatch.fcgi",
89
+ "bin-environment" => ( "RAILS_ENV" => "development" )
90
+ )
91
+ )
92
+ )
93
+
94
+
95
+ == Debugging Rails
96
+
97
+ Have "tail -f" commands running on both the server.log, production.log, and
98
+ test.log files. Rails will automatically display debugging and runtime
99
+ information to these files. Debugging info will also be shown in the browser
100
+ on requests from 127.0.0.1.
101
+
102
+
103
+ == Breakpoints
104
+
105
+ Breakpoint support is available through the script/breakpointer client. This
106
+ means that you can break out of execution at any point in the code, investigate
107
+ and change the model, AND then resume execution! Example:
108
+
109
+ class WeblogController < ActionController::Base
110
+ def index
111
+ @posts = Post.find_all
112
+ breakpoint "Breaking out from the list"
113
+ end
114
+ end
115
+
116
+ So the controller will accept the action, run the first line, then present you
117
+ with a IRB prompt in the breakpointer window. Here you can do things like:
118
+
119
+ Executing breakpoint "Breaking out from the list" at .../webrick_server.rb:16 in 'breakpoint'
120
+
121
+ >> @posts.inspect
122
+ => "[#<Post:0x14a6be8 @attributes={\"title\"=>nil, \"body\"=>nil, \"id\"=>\"1\"}>,
123
+ #<Post:0x14a6620 @attributes={\"title\"=>\"Rails you know!\", \"body\"=>\"Only ten..\", \"id\"=>\"2\"}>]"
124
+ >> @posts.first.title = "hello from a breakpoint"
125
+ => "hello from a breakpoint"
126
+
127
+ ...and even better is that you can examine how your runtime objects actually work:
128
+
129
+ >> f = @posts.first
130
+ => #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
131
+ >> f.
132
+ Display all 152 possibilities? (y or n)
133
+
134
+ Finally, when you're ready to resume execution, you press CTRL-D
135
+
136
+
137
+ == Console
138
+
139
+ You can interact with the domain model by starting the console through script/console.
140
+ Here you'll have all parts of the application configured, just like it is when the
141
+ application is running. You can inspect domain models, change values, and save to the
142
+ database. Start the script without arguments will launch it in the development environment.
143
+ Passing an argument will specify a different environment, like <tt>console production</tt>.
144
+
145
+
146
+ == Description of contents
147
+
148
+ app
149
+ Holds all the code that's specific to this particular application.
150
+
151
+ app/controllers
152
+ Holds controllers that should be named like weblog_controller.rb for
153
+ automated URL mapping. All controllers should descend from
154
+ ActionController::Base.
155
+
156
+ app/models
157
+ Holds models that should be named like post.rb.
158
+ Most models will descent from ActiveRecord::Base.
159
+
160
+ app/views
161
+ Holds the template files for the view that should be named like
162
+ weblog/index.rhtml for the WeblogController#index action. All views uses eRuby
163
+ syntax. This directory can also be used to keep stylesheets, images, and so on
164
+ that can be symlinked to public.
165
+
166
+ app/helpers
167
+ Holds view helpers that should be named like weblog_helper.rb.
168
+
169
+ config
170
+ Configuration files for the Rails environment, the routing map, the database, and other dependencies.
171
+
172
+ components
173
+ Self-contained mini-applications that can bundle controllers, models, and views together.
174
+
175
+ lib
176
+ Application specific libraries. Basically, any kind of custom code that doesn't
177
+ belong controllers, models, or helpers. This directory is in the load path.
178
+
179
+ public
180
+ The directory available for the web server. Contains sub-directories for images, stylesheets,
181
+ and javascripts. Also contains the dispatchers and the default HTML files.
182
+
183
+ script
184
+ Helper scripts for automation and generation.
185
+
186
+ test
187
+ Unit and functional tests along with fixtures.
188
+
189
+ vendor
190
+ External libraries that the application depend on. This directory is in the load path.
data/Rakefile ADDED
@@ -0,0 +1,227 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+ require 'rake/packagetask'
5
+ require 'rake/gempackagetask'
6
+
7
+ PKG_VERSION = "0.2.3"
8
+ PKG_NAME = "feedreader"
9
+ PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
10
+
11
+ $VERBOSE = nil
12
+ TEST_CHANGES_SINCE = Time.now - 600
13
+
14
+ desc "Run all the tests on a fresh test database"
15
+ task :default => [ :test_units, :test_functional ]
16
+
17
+
18
+ desc 'Require application environment.'
19
+ task :environment do
20
+ unless defined? RAILS_ROOT
21
+ require File.dirname(__FILE__) + '/config/environment'
22
+ end
23
+ end
24
+
25
+ desc "Generate API documentation, show coding stats"
26
+ task :doc => [ :appdoc, :stats ]
27
+
28
+
29
+ # Look up tests for recently modified sources.
30
+ def recent_tests(source_pattern, test_path, touched_since = 10.minutes.ago)
31
+ FileList[source_pattern].map do |path|
32
+ if File.mtime(path) > touched_since
33
+ test = "#{test_path}/#{File.basename(path, '.rb')}_test.rb"
34
+ test if File.exists?(test)
35
+ end
36
+ end.compact
37
+ end
38
+
39
+ desc 'Test recent changes.'
40
+ Rake::TestTask.new(:recent => [ :clone_structure_to_test ]) do |t|
41
+ since = TEST_CHANGES_SINCE
42
+ touched = FileList['test/**/*_test.rb'].select { |path| File.mtime(path) > since } +
43
+ recent_tests('app/models/*.rb', 'test/unit', since) +
44
+ recent_tests('app/controllers/*.rb', 'test/functional', since)
45
+
46
+ t.libs << 'test'
47
+ t.verbose = true
48
+ t.test_files = touched.uniq
49
+ end
50
+ task :test_recent => [ :clone_structure_to_test ]
51
+
52
+ desc "Run the unit tests in test/unit"
53
+ Rake::TestTask.new("test_units") { |t|
54
+ t.libs << "test"
55
+ t.pattern = 'test/unit/**/*_test.rb'
56
+ t.verbose = true
57
+ }
58
+ task :test_units => [ :clone_structure_to_test ]
59
+
60
+ desc "Run the functional tests in test/functional"
61
+ Rake::TestTask.new("test_functional") { |t|
62
+ t.libs << "test"
63
+ t.pattern = 'test/functional/**/*_test.rb'
64
+ t.verbose = true
65
+ }
66
+ task :test_functional => [ :clone_structure_to_test ]
67
+
68
+ desc "Generate documentation for the application"
69
+ Rake::RDocTask.new("appdoc") { |rdoc|
70
+ rdoc.rdoc_dir = 'doc/app'
71
+ rdoc.title = "Rails Application Documentation"
72
+ rdoc.options << '--line-numbers --inline-source'
73
+ rdoc.rdoc_files.include('doc/README_FOR_APP')
74
+ rdoc.rdoc_files.include('app/**/*.rb')
75
+ }
76
+
77
+ desc "Generate documentation for the Rails framework"
78
+ Rake::RDocTask.new("apidoc") { |rdoc|
79
+ rdoc.rdoc_dir = 'doc/api'
80
+ rdoc.template = "#{ENV['template']}.rb" if ENV['template']
81
+ rdoc.title = "Rails Framework Documentation"
82
+ rdoc.options << '--line-numbers --inline-source'
83
+ rdoc.rdoc_files.include('README')
84
+ rdoc.rdoc_files.include('CHANGELOG')
85
+ rdoc.rdoc_files.include('vendor/rails/railties/CHANGELOG')
86
+ rdoc.rdoc_files.include('vendor/rails/railties/MIT-LICENSE')
87
+ rdoc.rdoc_files.include('vendor/rails/activerecord/README')
88
+ rdoc.rdoc_files.include('vendor/rails/activerecord/CHANGELOG')
89
+ rdoc.rdoc_files.include('vendor/rails/activerecord/lib/active_record/**/*.rb')
90
+ rdoc.rdoc_files.exclude('vendor/rails/activerecord/lib/active_record/vendor/*')
91
+ rdoc.rdoc_files.include('vendor/rails/actionpack/README')
92
+ rdoc.rdoc_files.include('vendor/rails/actionpack/CHANGELOG')
93
+ rdoc.rdoc_files.include('vendor/rails/actionpack/lib/action_controller/**/*.rb')
94
+ rdoc.rdoc_files.include('vendor/rails/actionpack/lib/action_view/**/*.rb')
95
+ rdoc.rdoc_files.include('vendor/rails/actionmailer/README')
96
+ rdoc.rdoc_files.include('vendor/rails/actionmailer/CHANGELOG')
97
+ rdoc.rdoc_files.include('vendor/rails/actionmailer/lib/action_mailer/base.rb')
98
+ rdoc.rdoc_files.include('vendor/rails/actionwebservice/README')
99
+ rdoc.rdoc_files.include('vendor/rails/actionwebservice/CHANGELOG')
100
+ rdoc.rdoc_files.include('vendor/rails/actionwebservice/lib/action_web_service.rb')
101
+ rdoc.rdoc_files.include('vendor/rails/actionwebservice/lib/action_web_service/*.rb')
102
+ rdoc.rdoc_files.include('vendor/rails/actionwebservice/lib/action_web_service/api/*.rb')
103
+ rdoc.rdoc_files.include('vendor/rails/actionwebservice/lib/action_web_service/client/*.rb')
104
+ rdoc.rdoc_files.include('vendor/rails/actionwebservice/lib/action_web_service/container/*.rb')
105
+ rdoc.rdoc_files.include('vendor/rails/actionwebservice/lib/action_web_service/dispatcher/*.rb')
106
+ rdoc.rdoc_files.include('vendor/rails/actionwebservice/lib/action_web_service/protocol/*.rb')
107
+ rdoc.rdoc_files.include('vendor/rails/actionwebservice/lib/action_web_service/support/*.rb')
108
+ rdoc.rdoc_files.include('vendor/rails/activesupport/README')
109
+ rdoc.rdoc_files.include('vendor/rails/activesupport/CHANGELOG')
110
+ rdoc.rdoc_files.include('vendor/rails/activesupport/lib/active_support/**/*.rb')
111
+ }
112
+
113
+ desc "Report code statistics (KLOCs, etc) from the application"
114
+ task :stats => [ :environment ] do
115
+ require 'code_statistics'
116
+ CodeStatistics.new(
117
+ ["Helpers", "app/helpers"],
118
+ ["Controllers", "app/controllers"],
119
+ ["APIs", "app/apis"],
120
+ ["Components", "components"],
121
+ ["Functionals", "test/functional"],
122
+ ["Models", "app/models"],
123
+ ["Units", "test/unit"]
124
+ ).to_s
125
+ end
126
+
127
+ desc "Recreate the test databases from the development structure"
128
+ task :clone_structure_to_test => [ :db_structure_dump, :purge_test_database ] do
129
+ abcs = ActiveRecord::Base.configurations
130
+ case abcs["test"]["adapter"]
131
+ when "mysql"
132
+ ActiveRecord::Base.establish_connection(:test)
133
+ ActiveRecord::Base.connection.execute('SET foreign_key_checks = 0')
134
+ IO.readlines("db/#{RAILS_ENV}_structure.sql").join.split("\n\n").each do |table|
135
+ ActiveRecord::Base.connection.execute(table)
136
+ end
137
+ when "postgresql"
138
+ ENV['PGHOST'] = abcs["test"]["host"] if abcs["test"]["host"]
139
+ ENV['PGPORT'] = abcs["test"]["port"].to_s if abcs["test"]["port"]
140
+ ENV['PGPASSWORD'] = abcs["test"]["password"].to_s if abcs["test"]["password"]
141
+ `psql -U "#{abcs["test"]["username"]}" -f db/#{RAILS_ENV}_structure.sql #{abcs["test"]["database"]}`
142
+ when "sqlite", "sqlite3"
143
+ `#{abcs[RAILS_ENV]["adapter"]} #{abcs["test"]["dbfile"]} < db/#{RAILS_ENV}_structure.sql`
144
+ when "sqlserver"
145
+ `osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{RAILS_ENV}_structure.sql`
146
+ else
147
+ raise "Unknown database adapter '#{abcs["test"]["adapter"]}'"
148
+ end
149
+ end
150
+
151
+ desc "Dump the database structure to a SQL file"
152
+ task :db_structure_dump => :environment do
153
+ abcs = ActiveRecord::Base.configurations
154
+ case abcs[RAILS_ENV]["adapter"]
155
+ when "mysql"
156
+ ActiveRecord::Base.establish_connection(abcs[RAILS_ENV])
157
+ File.open("db/#{RAILS_ENV}_structure.sql", "w+") { |f| f << ActiveRecord::Base.connection.structure_dump }
158
+ when "postgresql"
159
+ ENV['PGHOST'] = abcs[RAILS_ENV]["host"] if abcs[RAILS_ENV]["host"]
160
+ ENV['PGPORT'] = abcs[RAILS_ENV]["port"].to_s if abcs[RAILS_ENV]["port"]
161
+ ENV['PGPASSWORD'] = abcs[RAILS_ENV]["password"].to_s if abcs[RAILS_ENV]["password"]
162
+ `pg_dump -U "#{abcs[RAILS_ENV]["username"]}" -s -x -O -f db/#{RAILS_ENV}_structure.sql #{abcs[RAILS_ENV]["database"]}`
163
+ when "sqlite", "sqlite3"
164
+ `#{abcs[RAILS_ENV]["adapter"]} #{abcs[RAILS_ENV]["dbfile"]} .schema > db/#{RAILS_ENV}_structure.sql`
165
+ when "sqlserver"
166
+ `scptxfr /s #{abcs[RAILS_ENV]["host"]} /d #{abcs[RAILS_ENV]["database"]} /I /f db\\#{RAILS_ENV}_structure.sql /q /A /r`
167
+ `scptxfr /s #{abcs[RAILS_ENV]["host"]} /d #{abcs[RAILS_ENV]["database"]} /I /F db\ /q /A /r`
168
+ else
169
+ raise "Unknown database adapter '#{abcs["test"]["adapter"]}'"
170
+ end
171
+ end
172
+
173
+ desc "Empty the test database"
174
+ task :purge_test_database => :environment do
175
+ abcs = ActiveRecord::Base.configurations
176
+ case abcs["test"]["adapter"]
177
+ when "mysql"
178
+ ActiveRecord::Base.establish_connection(:test)
179
+ ActiveRecord::Base.connection.recreate_database(abcs["test"]["database"])
180
+ when "postgresql"
181
+ ENV['PGHOST'] = abcs["test"]["host"] if abcs["test"]["host"]
182
+ ENV['PGPORT'] = abcs["test"]["port"].to_s if abcs["test"]["port"]
183
+ ENV['PGPASSWORD'] = abcs["test"]["password"].to_s if abcs["test"]["password"]
184
+ `dropdb -U "#{abcs["test"]["username"]}" #{abcs["test"]["database"]}`
185
+ `createdb -T template0 -U "#{abcs["test"]["username"]}" #{abcs["test"]["database"]}`
186
+ when "sqlite","sqlite3"
187
+ File.delete(abcs["test"]["dbfile"]) if File.exist?(abcs["test"]["dbfile"])
188
+ when "sqlserver"
189
+ dropfkscript = "#{abcs["test"]["host"]}.#{abcs["test"]["database"]}.DP1".gsub(/\\/,'-')
190
+ `osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{dropfkscript}`
191
+ `osql -E -S #{abcs["test"]["host"]} -d #{abcs["test"]["database"]} -i db\\#{RAILS_ENV}_structure.sql`
192
+ else
193
+ raise "Unknown database adapter '#{abcs["test"]["adapter"]}'"
194
+ end
195
+ end
196
+
197
+ desc "Clears all *.log files in log/"
198
+ task :clear_logs => :environment do
199
+ FileList["log/*.log"].each do |log_file|
200
+ f = File.open(log_file, "w")
201
+ f.close
202
+ end
203
+ end
204
+
205
+ desc "Migrate the database according to the migrate scripts in db/migrate (only supported on PG/MySQL). A specific version can be targetted with VERSION=x"
206
+ task :migrate => :environment do
207
+ ActiveRecord::Migrator.migrate(File.dirname(__FILE__) + '/db/migrate/', ENV["VERSION"] ? ENV["VERSION"].to_i : nil)
208
+ end
209
+
210
+ spec = Gem::Specification.new do |s|
211
+ s.name = PKG_NAME
212
+ s.version = PKG_VERSION
213
+ s.summary = "Example rails project for use with the FeedTools library."
214
+ s.has_rdoc = false
215
+ s.files = Dir['**/*'].delete_if{ |f| f =~ /sqlite$/ || f =~ /\.log$/ || f =~ /^pkg/ || f =~ /\.svn/ } << "public/.htaccess"
216
+ s.require_path = '.'
217
+ s.author = "Bob Aman"
218
+ s.email = "bob@sporkmonger.com"
219
+ s.homepage = "http://sporkmonger.com/projects/feedtools"
220
+ s.rubyforge_project = "feedreader"
221
+ end
222
+
223
+ Rake::GemPackageTask.new(spec) do |p|
224
+ p.gem_spec = spec
225
+ p.need_tar = true
226
+ p.need_zip = true
227
+ end
@@ -0,0 +1,4 @@
1
+ # The filters added to this controller will be run for all controllers in the application.
2
+ # Likewise will all the methods added be available for all controllers.
3
+ class ApplicationController < ActionController::Base
4
+ end
@@ -0,0 +1,21 @@
1
+ require 'rubygems'
2
+ require 'feed_tools'
3
+
4
+ FeedTools.feed_cache = nil
5
+
6
+ class FeedController < ApplicationController
7
+ layout "common", :except => :xml
8
+
9
+ def index
10
+ @params['feed_url'] = 'http://redhanded.hobix.com/index.xml'
11
+ end
12
+
13
+ def view
14
+ @feed = FeedTools::Feed.open(@params['feed_url'])
15
+ end
16
+
17
+ def xml
18
+ @feed_type = @params['id']
19
+ @feed = FeedTools::Feed.open(@params['feed_url'])
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ # The methods added to this helper will be available to all templates in the application.
2
+ module ApplicationHelper
3
+ end