Code Monkey home page Code Monkey logo

runt's People

Contributors

bill avatar bordy avatar bryanstearns avatar dchun avatar deivinsontejeda avatar jwhitmire avatar mlipper avatar reidab avatar rgeerts avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

runt's Issues

REMonth negative range enhancement request

I discovered Runt this week while trying to implement an iCalender type recurring event in a Rails application. I see were the icalendar tests where included, but many test would not work because of lack support for negative mday range.

I'm not very proficient in Ruby, but I attacked the problem by overwriting the REMonth include? method to support negative ranges (which you accept, but don't work)

module Runt    
  class REMonth
    include TExprUtils

    def include?(date)
      if @range.begin < 0 || @range.end < 0
        include_negative(date)
      else
        @range.include? date.mday
      end
    end

    def include_negative(date)
      eom_mday = max_day_of_month(date)
      range = (@range.begin < 0 ? eom_mday + @range.begin + 1 : @range.begin)..(@range.end < 0 ? eom_mday + @range.end + 1 : @range.end)
      range.include? date.mday
    end
  end
end

I couldn't get the tests to run (didn't clone Runt), but this patch seems to work.

# from icalendar test 18

start_date = DateTime.parse("US-Eastern:19970930T090000") #Sep 30, 1997
end_date   = start_date + 365 #Sep 30, 1998
test_date = DateTime.parse("US-Eastern:19971031T090000") #Oct 31
#rrule = RecurrenceRule.new("FREQ=MONTHLY;COUNT=10;BYMONTHDAY=1,-1")
te = REMonth.new(1) | REMonth.new(-1) #first and last days of the month
results = te.dates(DateRange.new(start_date, end_date), 10)

I did notice that if I used Time instead of DateTime and got an error:

results = te.dates(DateRange.new(start_date, end_date), 10)
TypeError: can't iterate from Time

I just have to watch that when I actually try to do something.

Sugar test for monthly passes but does not work

monthly_3rd_to_14th creates a REMonth object:

2.0.0-p247 :127 > m34 = monthly_3rd_to_14th
 => #<Runt::REMonth:0x00000104e4b628 @range="3".."14"> 

and passess the monthly sugar test, since you convert expected and actual to a string. Calling m34.include?(date) will not work. (looking for integer in string range)

I found this trying to add my negative_month offset and testing it. I changed

st_day, end_day = $1, $2
#to
st_day, end_day = $1.to_i, $2.to_i

and all test pass and monthly_3rd_to_14th works.

Rails DateTime functions do not work properly

After adding runt gem to the rails project, some of the functions provided by Rails' DateTime do not work properly.

For eg,
DateTime.now + 1.day #gives some random date in 2035
DateTime.now + 2.hours #gives some random date in 2033

Any idea what might fix these issues?

On Ruby 1.9.3: Runt#method_missing in infinite recursion with Runt#build and #to_str

I ran this:

Bills-MacBook-Air:runt-bill Bill$ rdebug -I lib -I test ./test/icalendartest.rb -n test_example_1

With a break point at icalendartest.rb:23 and stepped a few times and saw this in sugar.rb:

156 def method_missing(name, *args, &block)
=> 157 result = self.build(name, *args, &block)
158 return result unless result.nil?
159 super
160 end
161
(rdb:1) p self

<DateTime: 1997-09-02T09:00:00+00:00 ((2450694j,32400s,0n),+0s,2299161j)>

(rdb:1) p name
:to_str

Here is the stack:

--> #0 Runt.method_missing(name#Symbol)
at line /Users/Bill/Projects/Rails/runt-bill/lib/runt/sugar.rb:157
#1 Runt.method_missing(name#Symbol)
at line /Users/Bill/Projects/Rails/runt-bill/lib/runt/sugar.rb:159
#2 Runt::TExpr.dates(date_range#Runt::DateRange)
at line /Users/Bill/Projects/Rails/runt-bill/lib/runt/temporalexpression.rb:79

I wonder if DateTime#method_missing (probably defined up in Kernel or Object) is causing to_str to be invoked on self which in turn is invoking method_missing (down in the Runt module) again!

On Ruby 2.0.0p195 99% cpu on POW start

I've tried using runt with the following ruby versions:

  • 1.9.3p327
  • 1.9.3p385

In both cases i got a recursion error somewhat hard to debug. I've tried also the Readme example in irb getting the very same error ( irb says also that it could be its own error: maybe irb bug). The Readme example and tutorials work well in ruby 1.8.7.

Reading the issues here i decided to move to ruby 2.0.0p195. I can try the tutorials in irb without any error. However if i bundle runt with my Rails 3.2.13 application the ruby process goes up to 99% of cpu usage and POW become unresponsive.

I'm on OS X Lion 10.7.5. I handle ruby versions with rbenv and ruby-build. runt gem version is updated to 0.9.0.

Rails integration

I wonder if you've integrated runt into a rails app. I'm trying to figure out how I would combine all of my schedule inputs into a serializable hash to store in an hstore field and then deserialize it to make use of the schedule to check for availability.

Since there are multiple layers to a schedule, as in your example with a north and south expression with multiple dates and exclusions, the complexity is leaving me a bit stumped.

Do you think that it would be a better idea to store all of the elements separately in my database and then interact with each individual element once I retrieve a particular schedule's dates and relevant events?

Only Date/Except Date

It is not clear to me from this documentation (without a very convoluted approach) how to create an expression that is "exactly this date, no repeat."

How might I go about saying:
only March 3, 2018

How might I go about saying:
except March 3, 2018

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.