I received feedback from some of you, saying that it would be cool if RailsCron was even easier to manage. So I implemented a graceful start/restart inside of the plugin''s init.rb. If you don''t like it, comment it out and send me the feedback. Also, I finished an update to RailsCron that allows you to attach asynchronous processing methods to your ActiveRecord models. i.e.: class EmailQueue < ActiveRecord::Base background :deliver, :every => 10 #seconds, or 1.minute, etc def self.deliver #process the queue end end If your deliver method takes a minute to process (like some of my async methods do), then RailsCron will NOT load up multiple threads of the same command every 10 seconds. Rather RailsCron checks to see if the command is currently running, and doesn''t start a new one. You can overrride this with: RailsCron.options[:overlap] = true Is there a better name to use than overlap? Anyhow, have fun, and feedback is always welcome and encouraged! Repository: http://svn.kylemaxwell.com/rails_cron/ Bug Tracker: http://dev.kylemaxwell.com -- Kyle Maxwell Chief Technologist E Factor Media // FN Interactive kyle@efactormedia.com 1-866-263-3261
Kyle- This is totally sweet. I am using it to implement some new features on http://yakimaherald.com. i will give you feedback and maybe a patch or two once I get it worked out. Thanks -Ezra On Jan 25, 2006, at 12:26 PM, Kyle Maxwell wrote:> I received feedback from some of you, saying that it would be cool if > RailsCron was even easier to manage. So I implemented a graceful > start/restart inside of the plugin''s init.rb. If you don''t like it, > comment it out and send me the feedback. > > Also, I finished an update to RailsCron that allows you to attach > asynchronous processing methods to your ActiveRecord models. i.e.: > > class EmailQueue < ActiveRecord::Base > background :deliver, :every => 10 #seconds, or 1.minute, etc > > def self.deliver > #process the queue > end > end > > If your deliver method takes a minute to process (like some of my > async methods do), then RailsCron will NOT load up multiple threads of > the same command every 10 seconds. Rather RailsCron checks to see if > the command is currently running, and doesn''t start a new one. You > can overrride this with: > > RailsCron.options[:overlap] = true > > Is there a better name to use than overlap? Anyhow, have fun, and > feedback is always welcome and encouraged! > > Repository: > http://svn.kylemaxwell.com/rails_cron/ > > Bug Tracker: > http://dev.kylemaxwell.com > > -- > Kyle Maxwell > Chief Technologist > E Factor Media // FN Interactive > kyle@efactormedia.com > 1-866-263-3261 > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-Ezra Zygmuntowicz Yakima Herald-Republic WebMaster http://yakimaherald.com 509-577-7732 ezra@yakima-herald.com
Hi Kyle ~ This looks like it might solve several items that I need to automate. I will be sure to check it out and send you some feedback. I usually would set up a cron job on a linux box to execute the action I needed. Thx! ~ Ben On 1/25/06, Kyle Maxwell <kyle@kylemaxwell.com> wrote:> > I received feedback from some of you, saying that it would be cool if > RailsCron was even easier to manage. So I implemented a graceful > start/restart inside of the plugin''s init.rb. If you don''t like it, > comment it out and send me the feedback. > > Also, I finished an update to RailsCron that allows you to attach > asynchronous processing methods to your ActiveRecord models. i.e.: > > class EmailQueue < ActiveRecord::Base > background :deliver, :every => 10 #seconds, or 1.minute, etc > > def self.deliver > #process the queue > end > end > > If your deliver method takes a minute to process (like some of my > async methods do), then RailsCron will NOT load up multiple threads of > the same command every 10 seconds. Rather RailsCron checks to see if > the command is currently running, and doesn''t start a new one. You > can overrride this with: > > RailsCron.options[:overlap] = true > > Is there a better name to use than overlap? Anyhow, have fun, and > feedback is always welcome and encouraged! > > Repository: > http://svn.kylemaxwell.com/rails_cron/ > > Bug Tracker: > http://dev.kylemaxwell.com > > -- > Kyle Maxwell > Chief Technologist > E Factor Media // FN Interactive > kyle@efactormedia.com > 1-866-263-3261 > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-- Ben Reubenstein http://www.benr75.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060125/4a8e1128/attachment-0001.html
Hello Kyle, I know this is the plugin I need. Can you maybe give me a simple example of what I might need in the model and controller? What I''m trying to do is process then purge emails recorded in a table. Thank You, jeff On 1/25/06, Kyle Maxwell <kyle@kylemaxwell.com> wrote:> I received feedback from some of you, saying that it would be cool if > RailsCron was even easier to manage. So I implemented a graceful > start/restart inside of the plugin''s init.rb. If you don''t like it, > comment it out and send me the feedback. > > Also, I finished an update to RailsCron that allows you to attach > asynchronous processing methods to your ActiveRecord models. i.e.: > > class EmailQueue < ActiveRecord::Base > background :deliver, :every => 10 #seconds, or 1.minute, etc > > def self.deliver > #process the queue > end > end > > If your deliver method takes a minute to process (like some of my > async methods do), then RailsCron will NOT load up multiple threads of > the same command every 10 seconds. Rather RailsCron checks to see if > the command is currently running, and doesn''t start a new one. You > can overrride this with: > > RailsCron.options[:overlap] = true > > Is there a better name to use than overlap? Anyhow, have fun, and > feedback is always welcome and encouraged! > > Repository: > http://svn.kylemaxwell.com/rails_cron/ > > Bug Tracker: > http://dev.kylemaxwell.com > > -- > Kyle Maxwell > Chief Technologist > E Factor Media // FN Interactive > kyle@efactormedia.com > 1-866-263-3261 > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
Awesome awesome work Kyle! On 26/01/2006, at 7:26 AM, Kyle Maxwell wrote:> RailsCron.options[:overlap] = true > > Is there a better name to use than overlap? Anyhow, have fun, and > feedback is always welcome and encouraged!maybe it would make more sense to have this as an option to the "background" method. i.e. class EmailQueue < ActiveRecord::Base background :deliver, :every => 10, :concurrent => true end (would be good if we had a ''seconds'' method for fixnum which just returned itself, so you would write 10.seconds) -- tim
HTTP URL Validation is a Rails plugin that allows you to validate a URL entered in a form. It validates if the URL exists by hitting it with a HEAD request. There''s the option to also check that the URL returns content of a specified type. Here???s how you can use it your model: Class Article < ActiveRecord::Base validates_http_url :url, :content_type => "text/html" validates_http_utl :photo, :content_type => "image" end This example will make sure the value entered for the URL field points to a publicly accessible HTML page, and the photo field points to an image. You can get the plugin at http://www.ccjr.name/blog/2006/01/25/http-url-validator/ Cheers, Cloves Carneiro Jr http://www.ccjr.name/blog __________________________________________________________ Find your next car at http://autos.yahoo.ca
One useful addition worth considering is adding this RegEX as a define or even as a helper to AR in the format of "validates_format_of_url :url" to be a shorthand for the REGEX. Source: http://www.nshb.net/node/252 class Company < ActiveRecord::Base validates_format_of :url, :with => /^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/ix end -Nb ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Nathaniel S. H. Brown http://nshb.net ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~> -----Original Message----- > From: rails-bounces@lists.rubyonrails.org > [mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of > Cloves Carneiro Junior > Sent: January 25, 2006 9:00 PM > To: rails@lists.rubyonrails.org > Subject: [Rails] [ANN] HTTP URL validation plugin > > HTTP URL Validation is a Rails plugin that allows you to > validate a URL entered in a form. It validates if the URL > exists by hitting it with a HEAD request. There''s the option > to also check that the URL returns content of a specified > type. Here???s how you can use it your > model: > > Class Article < ActiveRecord::Base > validates_http_url :url, :content_type => "text/html" > validates_http_utl :photo, :content_type => "image" > end > > This example will make sure the value entered for the URL > field points to a publicly accessible HTML page, and the > photo field points to an image. > > You can get the plugin at > http://www.ccjr.name/blog/2006/01/25/http-url-validator/ > > Cheers, > > Cloves Carneiro Jr > http://www.ccjr.name/blog > > > > > > > __________________________________________________________ > Find your next car at http://autos.yahoo.ca > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Nathaniel S. H. Brown wrote:> One useful addition worth considering is adding this RegEX as a define or even as a helper to AR in the format of "validates_format_of_url :url" to be a shorthand for the REGEX. > > Source: http://www.nshb.net/node/252 > > class Company < ActiveRecord::Base > validates_format_of :url, :with => /^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/ix > end >Technically a URL can also start with ftp:// smb:// etc Does this also allow stuff like: http://username:password@www.example.com/?q=r&me=you#some_id Sorry, my REGEX skills are quite poor.. Jeroen
It only allows for URL''s without the HTTP AUTH syntax you mentioned. /^(http|https|ftp|smb):\/\/(a-z0-9]+:[a-z0-9]+@)?[a-z0-9]+([\-\.]{1}[a-z0-9] +)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/ix Without testing, the above should work in such a case. -Nb ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Nathaniel S. H. Brown http://nshb.net ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~> -----Original Message----- > From: rails-bounces@lists.rubyonrails.org > [mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of > Jeroen Houben > Sent: January 26, 2006 3:04 AM > To: rails@lists.rubyonrails.org > Subject: Re: [Rails] [ANN] HTTP URL validation plugin > > Nathaniel S. H. Brown wrote: > > One useful addition worth considering is adding this RegEX > as a define or even as a helper to AR in the format of > "validates_format_of_url :url" to be a shorthand for the REGEX. > > > > Source: http://www.nshb.net/node/252 > > > > class Company < ActiveRecord::Base > > validates_format_of :url, :with => > > > /^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1 > > ,5})?\/.*)?$/ix > > end > > > > > Technically a URL can also start with ftp:// smb:// etc > > Does this also allow stuff like: > http://username:password@www.example.com/?q=r&me=you#some_id > > Sorry, my REGEX skills are quite poor.. > > Jeroen > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
Nathaniel S. H. Brown wrote:> It only allows for URL''s without the HTTP AUTH syntax you mentioned. > > /^(http|https|ftp|smb):\/\/(a-z0-9]+:[a-z0-9]+@)?[a-z0-9]+([\-\.]{1}[a-z0-9] > +)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/ixDepending on how complete you want it to be, you might want to get rid of explicit scheme matching completely. RFC 1738 indicates that [A-Za-z.+-]+ should work instead of (http|https|ftp|smb). -- Alex
El 26/01/2006, a las 06:04 AM, Jeroen Houben escribi?:> Technically a URL can also start with ftp:// smb:// etcMost of the time you require a user to enter an URL only HTTP (and sometimes FTP and mailto) is allowed. At least in my applications. Patrice
Alex Young wrote:> Nathaniel S. H. Brown wrote: >> It only allows for URL''s without the HTTP AUTH syntax you mentioned. >> >> /^(http|https|ftp|smb):\/\/(a-z0-9]+:[a-z0-9]+@)?[a-z0-9]+([\-\.]{1}[a-z0-9] >> >> +)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/ix > > Depending on how complete you want it to be, you might want to get rid > of explicit scheme matching completely. RFC 1738 indicates that > [A-Za-z.+-]+ should work instead of (http|https|ftp|smb).I agree. It should be up to the user though if they want to allow more exotic protocols. I personally would never include this in a plugin, I would just copy and paste the regex from Nathan''s homepage and modify it to fit my needs. Jeroen
Jeroen Houben wrote:> Alex Young wrote: >> Nathaniel S. H. Brown wrote: >>> It only allows for URL''s without the HTTP AUTH syntax you mentioned. >>> >>> /^(http|https|ftp|smb):\/\/(a-z0-9]+:[a-z0-9]+@)?[a-z0-9]+([\-\.]{1}[a-z0-9] >>> >>> +)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/ix >> >> Depending on how complete you want it to be, you might want to get rid >> of explicit scheme matching completely. RFC 1738 indicates that >> [A-Za-z.+-]+ should work instead of (http|https|ftp|smb). > > I agree. It should be up to the user though if they want to allow more > exotic protocols. I personally would never include this in a plugin, I > would just copy and paste the regex from Nathan''s homepage and modify it > to fit my needs.You could use a scheme whitelist that the first bracket group gets compared against, couldn''t you? Something like: class UriMatcher < Regexp def initialize(whitelist) super(###uri_regex_here###) @whitelist = Set.new(whitelist) end def =~(str) return @whitelist.include? self.match(str)[1] end end class Company < ActiveRecord::Base schemes = [''http'', ''https'', ''ftp''] validates_format_of :url, :with => UriMatcher.new(schemes) end I guess the overriding principle here is to Do The Simplest Thing That Can Possibly Work :-) -- Alex
At 1/26/2006 06:38 AM, you wrote:>Nathaniel S. H. Brown wrote: >>It only allows for URL''s without the HTTP AUTH syntax you mentioned. >>/^(http|https|ftp|smb):\/\/(a-z0-9]+:[a-z0-9]+@)?[a-z0-9]+([\-\.]{1}[a-z0-9] >>+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/ix > >Depending on how complete you want it to be, you might want to get >rid of explicit scheme matching completely. RFC 1738 indicates that >[A-Za-z.+-]+ should work instead of (http|https|ftp|smb). > >-- >AlexOr go all the way with the regexp from RFC 2396 <http://www.ietf.org/rfc/rfc2396.txt>Uniform Resource Identifiers (URI): Generic Syntax on page 29. (the remainder is best viewed in a monospaced font or just visit the RFC on the web. -Rob RFC 2396 URI Generic Syntax August 1998 B. Parsing a URI Reference with a Regular Expression As described in Section 4.3, the generic URI syntax is not sufficient to disambiguate the components of some forms of URI. Since the "greedy algorithm" described in that section is identical to the disambiguation method used by POSIX regular expressions, it is natural and commonplace to use a regular expression for parsing the potential four components and fragment identifier of a URI reference. The following line is the regular expression for breaking-down a URI reference into its components. ^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))? 12 3 4 5 6 7 8 9 The numbers in the second line above are only to assist readability; they indicate the reference points for each subexpression (i.e., each paired parenthesis). We refer to the value matched for subexpression <n> as $<n>. For example, matching the above expression to http://www.ics.uci.edu/pub/ietf/uri/#Related results in the following subexpression matches: $1 = http: $2 = http $3 = //www.ics.uci.edu $4 = www.ics.uci.edu $5 = /pub/ietf/uri/ $6 = <undefined> $7 = <undefined> $8 = #Related $9 = Related where <undefined> indicates that the component is not present, as is the case for the query component in the above example. Therefore, we can determine the value of the four components and fragment as scheme = $2 authority = $4 path = $5 query = $7 fragment = $9 and, going in the opposite direction, we can recreate a URI reference from its components using the algorithm in step 7 of Section 5.2. Berners-Lee, et. al. Standards Track [Page 29] -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060126/960edac0/attachment.html
Hi Kyle, looks great. There''s a small bug in RailsCron#task_list: @@last_db_update is not updated, so the DB is always queried. Changing @@task_list = find(:all) to @@last_db_update = Time.now.to_i @@task_list = find(:all) solves it. I agree to Tim, that :overlap should be settable on a per-task basis (and that :concurrent would make a nice option-name for it). Thanks for the nice plugin. Timo Am 25.01.2006 um 21:26 schrieb Kyle Maxwell:> I received feedback from some of you, saying that it would be cool if > RailsCron was even easier to manage. So I implemented a graceful > start/restart inside of the plugin''s init.rb. If you don''t like it, > comment it out and send me the feedback. > > Also, I finished an update to RailsCron that allows you to attach > asynchronous processing methods to your ActiveRecord models. i.e.: > > class EmailQueue < ActiveRecord::Base > background :deliver, :every => 10 #seconds, or 1.minute, etc > > def self.deliver > #process the queue > end > end > > If your deliver method takes a minute to process (like some of my > async methods do), then RailsCron will NOT load up multiple threads of > the same command every 10 seconds. Rather RailsCron checks to see if > the command is currently running, and doesn''t start a new one. You > can overrride this with: > > RailsCron.options[:overlap] = true > > Is there a better name to use than overlap? Anyhow, have fun, and > feedback is always welcome and encouraged! > > Repository: > http://svn.kylemaxwell.com/rails_cron/ > > Bug Tracker: > http://dev.kylemaxwell.com > > -- > Kyle Maxwell > Chief Technologist > E Factor Media // FN Interactive > kyle@efactormedia.com > 1-866-263-3261 > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
On 1/25/06, Jeff Blasius <jeff.blasius@gmail.com> wrote:> Hello Kyle, > I know this is the plugin I need. Can you maybe give me a simple > example of what I might need in the model and controller? What I''m > trying to do is process then purge emails recorded in a table. > Thank You, > jeff > > > On 1/25/06, Kyle Maxwell <kyle@kylemaxwell.com> wrote: > > I received feedback from some of you, saying that it would be cool if > > RailsCron was even easier to manage. So I implemented a graceful > > start/restart inside of the plugin''s init.rb. If you don''t like it, > > comment it out and send me the feedback. > > > > Also, I finished an update to RailsCron that allows you to attach > > asynchronous processing methods to your ActiveRecord models. i.e.: > > > > class EmailQueue < ActiveRecord::Base > > background :deliver, :every => 10 #seconds, or 1.minute, etc > > > > def self.deliver > > #process the queue > > end > > end > > > > If your deliver method takes a minute to process (like some of my > > async methods do), then RailsCron will NOT load up multiple threads of > > the same command every 10 seconds. Rather RailsCron checks to see if > > the command is currently running, and doesn''t start a new one. You > > can overrride this with: > > > > RailsCron.options[:overlap] = true > > > > Is there a better name to use than overlap? Anyhow, have fun, and > > feedback is always welcome and encouraged! > > > > Repository: > > http://svn.kylemaxwell.com/rails_cron/ > > > > Bug Tracker: > > http://dev.kylemaxwell.com > > > > -- > > Kyle Maxwell > > Chief Technologist > > E Factor Media // FN Interactive > > kyle@efactormedia.com > > 1-866-263-3261 > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >I just posted an example on my blog: http://www.kylemaxwell.com/articles/2006/01/26/simple-emailqueue-for-rails -- Kyle Maxwell Chief Technologist E Factor Media // FN Interactive kyle@efactormedia.com 1-866-263-3261
On 1/26/06, Timo Hoepfner <th-dev@onlinehome.de> wrote:> Hi Kyle, > > looks great. > > There''s a small bug in RailsCron#task_list: @@last_db_update is not > updated, so the DB is always queried. Changing > > @@task_list = find(:all) > > to > > @@last_db_update = Time.now.to_i > @@task_list = find(:all) > > solves it.Yeah, I feel a little sheepish... It''s fixed in the trunk, and I''ll probably tag up 0.2.1 with this, and the :concurrent option sometime today or tomorrow. -- Kyle Maxwell Chief Technologist E Factor Media // FN Interactive kyle@efactormedia.com 1-866-263-3261
That regex seems broken. It says that a URI can start with everything other than any of the following items ":/?#". Meaning that a URI can start with a "@" or a "%" or any of the other million keys that aren''t those four? Alex Young''s mention of RFC 1738 looks much closer to what a URI should start with [a-z.+-]+ /^([a-z.+-]+):\/\/(a-z0-9]+:[a-z0-9]+@)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z ]{2,5}(([0-9]{1,5})?\/.*)?$/ix The "I" flag negates the second case of A-Z. I really like the concept of the URI Matcher, but it would be far simpler to have a helper method for AR with usage like so: validates_format_of_uri :link, :schemes => [ ''mailto'', ''http'', ''https'' ] That is what I was suggesting go into the Plugin. Or even simply mapping the above Regex into a define like so: REGEX_URI /^([a-z.+-]+):\/\/(a-z0-9]+:[a-z0-9]+@)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z ]{2,5}(([0-9]{1,5})?\/.*)?$/ix So you can use it within the original code: validates_format_of :uri, :with => REGEX_URI This would be a simple method of implementation, and would stick to the DRY principle as I am sure if you have one URI column in your database, you are likely to have another. -Nb ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Nathaniel S. H. Brown http://nshb.net ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~> -----Original Message----- > From: rails-bounces@lists.rubyonrails.org > [mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of Rob > Biedenharn > Sent: January 26, 2006 6:24 AM > To: rails@lists.rubyonrails.org > Subject: Re: [Rails] [ANN] HTTP URL validation plugin > > At 1/26/2006 06:38 AM, you wrote: > > > Nathaniel S. H. Brown wrote: > > > It only allows for URL''s without the HTTP AUTH > syntax you mentioned. > > /^(http|https|ftp|smb):\/\/(a-z0-9]+:[a-z0-9]+@)?[a-z0-9]+([\- > \.]{1}[a-z0-9] > +)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/ix > > > Depending on how complete you want it to be, you might > want to get rid of explicit scheme matching completely. RFC > 1738 indicates that [A-Za-z.+-]+ should work instead of > (http|https|ftp|smb). > > -- > Alex > > > > Or go all the way with the regexp from RFC 2396 Uniform > Resource Identifiers (URI): Generic Syntax > <http://www.ietf.org/rfc/rfc2396.txt> on page 29. (the > remainder is best viewed in a monospaced font or just visit > the RFC on the web. > -Rob > > > > > RFC > 2396 > URI Generic > Syntax > August 1998 > > > B. Parsing a URI Reference with a Regular Expression > > As described in Section 4.3, the generic URI syntax is not > sufficient > to disambiguate the components of some forms of URI. > Since the > "greedy algorithm" described in that section is identical to the > disambiguation method used by POSIX regular expressions, it is > natural and commonplace to use a regular expression for parsing the > potential four components and fragment identifier of a URI > reference. > > The following line is the regular expression for > breaking-down a URI > reference into its components. > > > ^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))? > > 12 > 3 4 > 5 6 > 7 8 9 > > The numbers in the second line above are only to assist > readability; > they indicate the reference points for each subexpression > (i.e., each > paired parenthesis). We refer to the value matched for > subexpression > <n> as $<n>. For example, matching the above expression to > > > > http://www.ics.uci.edu/pub/ietf/uri/#Related > > <http://www.ics.uci.edu/pub/ietf/uri/#Related> results in > the following subexpression matches: > > $1 = http: > $2 = http > $3 > //www.ics.uci.edu > <http://www.ics.uci.edu/> $4 > www.ics.uci.edu > <http://www.ics.uci.edu/> $5 = /pub/ietf/uri/ > $6 = <undefined> > $7 = <undefined> > $8 = #Related > $9 = Related > > where <undefined> indicates that the component is not > present, as is > the case for the query component in the above example. > Therefore, we > can determine the value of the four components and fragment as > > scheme = $2 > authority = $4 > path = $5 > query = $7 > fragment = $9 > > and, going in the opposite direction, we can recreate a > URI reference > from its components using the algorithm in step 7 of Section 5.2. > > > > > > Berners-Lee, et. al. Standards > Track > [Page 29] >
I''m a newbie, and having trouble installing the plugin. I did "ruby script/plugin source http://svn.kylemaxwell.com/rails_cron/tags/0.2/", and it is added ok. When I do "ruby script/plugin list", I see the following for the new source: lib http://svn.kylemaxwell.com/rails_cron/tags/0.2/lib/ tasks http://svn.kylemaxwell.com/rails_cron/tags/0.2/tasks/ This doesn''t seem correct. There are other plugins listed (i.e. account_location, acts_as_taggable, etc), so I was thinking there would be something like "rails_cron" instead of "lib" and "tasks". What am I doing wrong? Thanks in advance! Nate -- Posted via http://www.ruby-forum.com/.
Nathaniel S. H. Brown wrote:> That regex seems broken. > > It says that a URI can start with everything other than any of the following > items ":/?#". Meaning that a URI can start with a "@" or a "%" or any of the > other million keys that aren''t those four? >Yup. It''s a superset. The regex from the RFC only serves to separate the constituent parts of a URI, not to validate them. From page 12, though: Scheme names consist of a sequence of characters beginning with a lower case letter and followed by any combination of lower case letters, digits, plus ("+"), period ("."), or hyphen ("-"). For resiliency, programs interpreting URI should treat upper case letters as equivalent to lower case in scheme names (e.g., allow "HTTP" as well as "http"). scheme = alpha *( alpha | digit | "+" | "-" | "." ) -- Alex
On 1/25/06, Kyle Maxwell <kyle@kylemaxwell.com> wrote:> I received feedback from some of you, saying that it would be cool if > RailsCron was even easier to manage. So I implemented a graceful > start/restart inside of the plugin''s init.rb. If you don''t like it, > comment it out and send me the feedback. > > Also, I finished an update to RailsCron that allows you to attach > asynchronous processing methods to your ActiveRecord models. i.e.: > > class EmailQueue < ActiveRecord::Base > background :deliver, :every => 10 #seconds, or 1.minute, etc > > def self.deliver > #process the queue > end > end > > If your deliver method takes a minute to process (like some of my > async methods do), then RailsCron will NOT load up multiple threads of > the same command every 10 seconds. Rather RailsCron checks to see if > the command is currently running, and doesn''t start a new one. You > can overrride this with: > > RailsCron.options[:overlap] = true > > Is there a better name to use than overlap? Anyhow, have fun, and > feedback is always welcome and encouraged! > > Repository: > http://svn.kylemaxwell.com/rails_cron/ > > Bug Tracker: > http://dev.kylemaxwell.com > > -- > Kyle Maxwell > Chief Technologist > E Factor Media // FN Interactive > kyle@efactormedia.com > 1-866-263-3261 >I just tagged 0.2.1 which fixes several minor issues, and adds the :concurrent option suggested by the list. background :method, :concurrent => true STUFF HAS BEEN REMOVED!! - The overlap option has been superceded by concurrent. - RailsCron DOES NOT start automatically. Please use the rake tasks. This was a problematic feature, but if you can code it without side efffects, the patch is welcome. -- Kyle Maxwell Chief Technologist E Factor Media // FN Interactive kyle@efactormedia.com 1-866-263-3261
Are there any plans to support distributed jobs? For example, when jobs grows too big to be accomplished between the cron intervals. I have been thinking of something like, acts_as_queue or acts_as_queue_job. Something to allow multiple threads and/or separate physical servers to check out jobs for processing, without stomping on each other. Using servers as an example: Server 1 checks out a batch of jobs, processes the jobs and clears them from the queue as they are finished. Server 2 grabs the next batch, and so on. Is Server 1 fails, the next machine grabs the unfinished jobs based on a maximum checkout time value set during check out. If a server exceeds the maximum checkout time value during processing, it drops the remaining jobs and grabs a new batch. Certainly there are many nuances I am missing. But this is my first pass at a solution. Any comments or code would be greatly appreciated. ;-) -- Posted via http://www.ruby-forum.com/.
On 2/14/06, Lon Baker <lon@speedymac.com> wrote:> Are there any plans to support distributed jobs? > > For example, when jobs grows too big to be accomplished between the cron > intervals. > > I have been thinking of something like, acts_as_queue or > acts_as_queue_job. > > Something to allow multiple threads and/or separate physical servers to > check out jobs for processing, without stomping on each other. > > Using servers as an example: > > Server 1 checks out a batch of jobs, processes the jobs and clears them > from the queue as they are finished. > > Server 2 grabs the next batch, and so on. > > Is Server 1 fails, the next machine grabs the unfinished jobs based on a > maximum checkout time value set during check out. > > If a server exceeds the maximum checkout time value during processing, > it drops the remaining jobs and grabs a new batch. > > Certainly there are many nuances I am missing. But this is my first pass > at a solution. > > Any comments or code would be greatly appreciated. ;-) > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >I currently don''t have any plans to support distributed jobs, because my current apps don''t require it. RailsCron currently is multithreaded. If I was going to do simple distributed jobs, I would put: return unless ENV["HOSTNAME"] == "specific_server" at the top of each action to let each server run a subset of the task list. If you wanted multiple servers to run the same action on a queue, then it isn''t too bad to implement that queue with an exclusive checkout flag. This type of thing is separate logic from the idea of RailsCron, and is suitable for the type of acts_as_queue plugin you are talking about. I do something similar for sending bulk email, but haven''t been able to extract a generalized plugin from it. -- Kyle Maxwell Chief Technologist E Factor Media // FN Interactive kyle@efactormedia.com 1-866-263-3261
very very useful plugin. But if someone is using migration, your plugin is not useable. Instead of generating a tabel for the cronjob, it would be better to generate a migration-script. This is now a standard in rails. Hussein Morsy -- Posted via http://www.ruby-forum.com/.
On 2/14/06, Hussein Morsy <hussein@morsy.de> wrote:> very very useful plugin. > But if someone is using migration, your plugin is not useable. Instead > of generating a tabel for the cronjob, it would be better to generate a > migration-script. > This is now a standard in rails. > > > Hussein Morsy > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >A migration would be better, but this works fine, and doesn''t interfere with your migrations. Maybe in the future. -- Kyle Maxwell Chief Technologist E Factor Media // FN Interactive kyle@efactormedia.com 1-866-263-3261