This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "sinatra/base" | |
| require "dm-core" | |
| require "dm-serializer" | |
| Bundler.require(:default, ENV["RACK_ENV"] || :development) if defined?(Bundler) | |
| DataMapper.setup(:default, :adapter => :in_memory) | |
| Dir[File.join(File.dirname(__FILE__), "models/**/*.rb")].each { |f| require f } | |
| DataMapper.finalize |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| context "given a simple model" do | |
| let(:model) do | |
| Class.new do | |
| def self.name | |
| "Customer" | |
| end | |
| include DataMapper::Resource | |
| property :id, DataMapper::Property::Serial |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| context "given a simple model" do | |
| let(:model) do | |
| Class.new do | |
| def self.name | |
| "Customer" | |
| end | |
| include DataMapper::Resource | |
| property :id, DataMapper::Property::Serial |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Failures: | |
| 1) Acquisto::ReflectiveRoutes with a model containing a 1:n relationship generates a route to fetch the child collection | |
| Failure/Error: model.finalize | |
| NameError: | |
| Cannot find the child_model Invoice for Customer in invoices | |
| # ./spec/unit/reflective_routes_spec.rb:11:in `block (2 levels) in <top (required)>' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "parslet" | |
| class MiniP < Parslet::Parser | |
| rule(:wsp) { match("\\s").repeat(1) } | |
| rule(:wsp?) { wsp.maybe } | |
| rule(:t_int) { match("[0-9]").repeat(1).as(:int) } | |
| # this is causing Stack Level Too Deep | |
| rule(:sum) { expr.as(:left) >> wsp? >> str("+") >> wsp? >> expr.as(:right) } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'whittle' | |
| class Parser < Whittle::Parser | |
| rule("class") | |
| rule("(") | |
| rule(")") | |
| rule("{") | |
| rule("}") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'whittle' | |
| class Parser < Whittle::Parser | |
| class StringParser < Whittle::Parser | |
| rule('"') | |
| rule(:esc => /\\./).as { |esc| eval('"' + esc + '"') } | |
| rule(:chars => /[^\\"]+/) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [1] pry(main)> Complex("2.5") | |
| => (2.5+0i) | |
| [2] pry(main)> Rational("2.5") | |
| => (5/2) | |
| [3] pry(main)> Complex("2.5") == Rational("2.5") | |
| => true | |
| [4] pry(main)> Complex("2.5").real? | |
| => false | |
| [5] pry(main)> Rational("2.5").real? | |
| => true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class QueryParser < Whittle::Parser | |
| rule(:wsp => /\s+/).skip! | |
| rule("(") | |
| rule(")") | |
| rule("AND") % :left | |
| rule("OR") % :left | |
| rule(">") % :left ^ 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class QueryParser < Whittle::Parser | |
| rule(:wsp => /\s+/).skip! | |
| rule("(") | |
| rule(")") | |
| rule("AND") % :left ^ 1 | |
| rule("OR") % :left ^ 1 | |
| rule(">") % :left ^ 2 |