Search Results

Search found 7 results on 1 pages for 'artemave'.

Page 1/1 | 1 

  • Haskell: 'No instance for' arising from a trivial usage of Regex library

    - by artemave
    Following the (accepted) answer from this question, I am expecting the following to work: Prelude Text.Regex.Posix Text.Regex.Base.RegexLike Text.Regex.Posix.String> makeRegex ".*" (makeRegex is a shortcut for makeRegexOpts with predefined options) However, it doesn't: <interactive>:1:0: No instance for (RegexMaker regex compOpt execOpt [Char]) arising from a use of `makeRegex' at <interactive>:1:0-13 Possible fix: add an instance declaration for (RegexMaker regex compOpt execOpt [Char]) In the expression: makeRegex ".*" In the definition of `it': it = makeRegex ".*" Prelude Text.Regex.Posix Text.Regex.Base.RegexLike Text.Regex.Posix.String> make Regex ".*"::Regex <interactive>:1:0: No instance for (RegexMaker Regex compOpt execOpt [Char]) arising from a use of `makeRegex' at <interactive>:1:0-13 Possible fix: add an instance declaration for (RegexMaker Regex compOpt execOpt [Char]) In the expression: makeRegex ".*" :: Regex In the definition of `it': it = makeRegex ".*" :: Regex And I really don't understand why. EDIT Haskell Platform 2009.02.02 (GHC 6.10.4) on Windows EDIT2 Prelude Text.Regex.Base.RegexLike Text.Regex.Posix.String> :i RegexMaker class (RegexOptions regex compOpt execOpt) => RegexMaker regex compOpt execOpt source | regex -> compOpt execOpt, compOpt -> regex execOpt, execOpt -> regex compOpt where makeRegex :: source -> regex makeRegexOpts :: compOpt -> execOpt -> source -> regex makeRegexM :: (Monad m) => source -> m regex makeRegexOptsM :: (Monad m) => compOpt -> execOpt -> source -> m regex -- Defined in Text.Regex.Base.RegexLike

    Read the article

  • Cucumber can't find installed gems

    - by artemave
    environment/cucumber.rb: ... # gem dependencies config.gem 'cucumber-rails', :lib => false, :version => '>=0.3.0' unless File.directory?(File.join(Rails.root, 'vend config.gem 'database_cleaner', :lib => false, :version => '>=0.5.0' unless File.directory?(File.join(Rails.root, 'vend config.gem 'webrat', :lib => false, :version => '>=0.7.0' unless File.directory?(File.join(Rails.root, 'vend config.gem 'spork', :lib => false, :version => '>=0.7.5' unless File.directory?(File.join(Rails.root, 'vend config.gem 'factory_girl', :source => 'http://gemcutter.org' config.gem 'selenium-client', :lib => false config.gem 'Selenium', :lib => false config.gem 'rspec', :lib => 'spec' config.gem 'rspec-rails', :lib => 'spec/rails' config.gem 'test-unit', :lib => false Running cucumber gives missing gems error: artem:~/projects/food4feed (master)$ cucumber ... no such file to load -- test-unit /home/artem/.rvm/gems/ruby-1.9.1-p378/gems/polyglot-0.3.0/lib/polyglot.rb:65:in `require' /home/artem/.rvm/gems/ruby-1.9.1-p378/gems/polyglot-0.3.0/lib/polyglot.rb:65:in `require' /home/artem/.rvm/gems/ruby-1.9.1-p378/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:158:in `require' /home/artem/.rvm/gems/ruby-1.9.1-p378/gems/rails-2.3.5/lib/rails/gem_dependency.rb:208:in `load' /home/artem/.rvm/gems/ruby-1.9.1-p378/gems/rails-2.3.5/lib/initializer.rb:307:in `block in load_gems' /home/artem/.rvm/gems/ruby-1.9.1-p378/gems/rails-2.3.5/lib/initializer.rb:307:in `each' /home/artem/.rvm/gems/ruby-1.9.1-p378/gems/rails-2.3.5/lib/initializer.rb:307:in `load_gems' /home/artem/.rvm/gems/ruby-1.9.1-p378/gems/rails-2.3.5/lib/initializer.rb:169:in `process' /home/artem/.rvm/gems/ruby-1.9.1-p378/gems/rails-2.3.5/lib/initializer.rb:113:in `run' /home/artem/projects/food4feed/config/environment.rb:9:in `<top (required)>' /home/artem/.rvm/gems/ruby-1.9.1-p378/gems/polyglot-0.3.0/lib/polyglot.rb:65:in `require' /home/artem/.rvm/gems/ruby-1.9.1-p378/gems/polyglot-0.3.0/lib/polyglot.rb:65:in `require' /home/artem/projects/food4feed/features/support/env.rb:12:in `block in <top (required)>' /home/artem/.rvm/gems/ruby-1.9.1-p378/gems/spork-0.8.1/lib/spork.rb:23:in `prefork' /home/artem/projects/food4feed/features/support/env.rb:10:in `<top (required)>' /home/artem/.rvm/gems/ruby-1.9.1-p378/gems/polyglot-0.3.0/lib/polyglot.rb:65:in `require' /home/artem/.rvm/gems/ruby-1.9.1-p378/gems/polyglot-0.3.0/lib/polyglot.rb:65:in `require' /home/artem/.rvm/gems/ruby-1.9.1-p378/gems/cucumber-0.6.3/lib/cucumber/rb_support/rb_language.rb:124:in `load_code_file' /home/artem/.rvm/gems/ruby-1.9.1-p378/gems/cucumber-0.6.3/lib/cucumber/step_mother.rb:85:in `load_code_file' /home/artem/.rvm/gems/ruby-1.9.1-p378/gems/cucumber-0.6.3/lib/cucumber/step_mother.rb:77:in `block in load_code_files' /home/artem/.rvm/gems/ruby-1.9.1-p378/gems/cucumber-0.6.3/lib/cucumber/step_mother.rb:76:in `each' /home/artem/.rvm/gems/ruby-1.9.1-p378/gems/cucumber-0.6.3/lib/cucumber/step_mother.rb:76:in `load_code_files' /home/artem/.rvm/gems/ruby-1.9.1-p378/gems/cucumber-0.6.3/lib/cucumber/cli/main.rb:48:in `execute!' /home/artem/.rvm/gems/ruby-1.9.1-p378/gems/cucumber-0.6.3/lib/cucumber/cli/main.rb:20:in `execute' /home/artem/.rvm/gems/ruby-1.9.1-p378/gems/cucumber-0.6.3/bin/cucumber:8:in `<top (required)>' /home/artem/.rvm/gems/ruby-1.9.1-p378/bin/cucumber:19:in `load' /home/artem/.rvm/gems/ruby-1.9.1-p378/bin/cucumber:19:in `<main>' Missing these required gems: selenium-client Selenium rspec-rails test-unit You're running: ruby 1.9.1.378 at /home/artem/.rvm/rubies/ruby-1.9.1-p378/bin/ruby rubygems 1.3.5 at /home/artem/.rvm/gems/ruby-1.9.1-p378, /home/artem/.rvm/gems/ruby-1.9.1-p378%global All gems are obviously there: artem:~/projects/food4feed (master)$ gem list | egrep "elenium|rspec|test-unit" rspec (1.3.0) rspec-rails (1.3.2) Selenium (1.1.14) selenium-client (1.2.18) test-unit (2.0.7) The even more confusing part is that it only complains about certain gems. factory_girl and rspec don't cause problems. Any idea what is going on? My environment: Rails 2.3.5 cucumber (0.6.3) cucumber-rails (0.3.0)

    Read the article

  • Strange error coming from ActiveRecord (probably)

    - by artemave
    My development environment: Ubuntu 9 Ruby 1.9.1/1.8.7 (rvm) Rails 2.3.5 Mysql 5.0 Apache Passenger Below is the part of the program flow to represent the issue. Request comes: #action def create begin @report = Report.new(params[:report]) ... rescue LocationNotFound => e ... end end Report constructor: class Report attr_accessor :locations def initialize(params = {}) @locations = params[:locations] ? fetch_locations(params[:locations]) : [] end ... end fetch_locations: def fetch_locations(loc_names) Rails.logger.debug "LOC_NAMES: " + loc_names.inspect ls = Location.find(:all, :conditions => [ # line 57 "locations.name in (#{loc_names.map{'?'}.join(',')})", *loc_names ], :include => [:sample_summaries, :samples]) # loc_names will never be empty ... end Location model: class Location < ActiveRecord::Base has_many :sample_summaries has_many :samples, :through => :sample_summaries ... end Now, the first time (after passenger restart) this runs fine and does the job. Most of the consequent times I get the error: Mar-11 11:01:00 #15098 DEBUG: LOC_NAMES: ["Moscow, RF", "London, UK"] Mar-11 11:01:00 #15098 DEBUG: Location Load (0.0ms) SELECT * FROM `locations` WHERE (locations.name in ('Moscow, RF','London, UK')) Mar-11 11:01:00 #15098 DEBUG: SampleSummary Load (0.0ms) SELECT `sample_summaries`.* FROM `sample_summaries` WHERE (`sample_summaries`.location_id IN (1,3)) Mar-11 11:01:00 #15098 DEBUG: SampleSummary Columns (0.0ms) SHOW FIELDS FROM `sample_summaries` Mar-11 11:01:00 #15098 FATAL: NoMethodError (You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.include?): app/models/report.rb:57:in `fetch_locations' app/models/report.rb:9:in `initialize' app/controllers/report_controller.rb:11:in `new' app/controllers/report_controller.rb:11:in `create' Looks quite random to me. Any ideas? P.S. I also tried to wrap the query in uncached block, but that didn't change anything. EDIT Here is what SampleSummary model looks like: class SampleSummary < ActiveRecord::Base has_many :samples belongs_to :location ... #validations default_scope :include => :samples, :order => 'rss_ts desc' ... end

    Read the article

  • Haskell: how to get through 'no instance for' ?

    - by artemave
    I am learning Haskell. I am on the 8th chapter of this book. The main thing I've learned so far is that Haskell is very unfriendly to me and it bites my ass where possible. Moreover... Heck! Enough mourning, to business. Here is the code: module GlobRegex ( globToRegex, matchesGlob ) where import Text.Regex.Posix import Text.Regex.Posix.String import Text.Regex.Base.RegexLike data CaseOpt = Case | NoCase deriving (Eq) matchesGlob :: String -> String -> CaseOpt -> Bool matchesGlob name pat caseopt = match regex name where regex = case caseopt of NoCase -> makeRegexOpts (defaultCompOpt + compIgnoreCase) defaultExecOpt (globToRegex pat) Case -> makeRegex (globToRegex pat) globToRegex :: String -> String ... And here is how it fails to compile: Prelude Text.Regex.Posix Text.Regex.Base.RegexLike> :load globtoregex\GlobRegex. hs [1 of 1] Compiling GlobRegex ( globtoregex\GlobRegex.hs, interpreted ) globtoregex\GlobRegex.hs:14:31: No instance for (RegexLike regex [Char]) arising from a use of `match' at globtoregex\GlobRegex.hs:14:31-46 Possible fix: add an instance declaration for (RegexLike regex [Char]) In the expression: match regex name In the definition of `matchesGlob': matchesGlob name pat caseopt = match regex name where regex = case caseopt of { NoCase -> makeRegexOpts (defaultCompOpt + compIgnoreCase) defaultExecOpt (globToRegex pat) Case -> makeRegex (globToRegex pat) } globtoregex\GlobRegex.hs:17:23: No instance for (RegexMaker regex CompOption execOpt String) arising from a use of `makeRegex' at globtoregex\GlobRegex.hs:17:23-49 Possible fix: add an instance declaration for (RegexMaker regex CompOption execOpt String) In the expression: makeRegex (globToRegex pat) In a case alternative: Case -> makeRegex (globToRegex pat) In the expression: case caseopt of { NoCase -> makeRegexOpts (defaultCompOpt + compIgnoreCase) defaultExecOpt (globToRegex p at) Case -> makeRegex (globToRegex pat) } Failed, modules loaded: none. To my best understanding, Text.Regex.Posix.String provides instances for RegexLike Regex String and RegexMaker Regex CompOption ExecOption String, so it should work. On the other hand, I can see that regex in the error message is type variable, not a concrete type, so, perhaps not... Anyway, this is where I am stuck. May be there is a common pattern for resolving no instance for type of problems? Or, in Haskell terms, instance of SmartGuess typeclass for no instance for?

    Read the article

  • read/write_attribure on associations

    - by artemave
    read/write_attribute is a great way to enhance default accessors generated by ActiveRecord. Like this for example: def price read_attribute(:price) or "This item is priceless and you are by the way #{User.current.login}" end The same however does not seem to be working with associations. Demonstration: class Product < ActiveRecord::Base has_and_belongs_to_many :stores end Then >> a = Product.first => #<Product id: 1, name: "awesome product", created_at: "2010-05-07 12:11:00", updated_at: "2010-05-07 12:11:00"> >> a.stores => [#<Store id: 1, name: "ikea", created_at: "2010-05-07 12:11:28", updated_at: "2010-05-07 12:11:28">] >> a.read_attribute(:stores) => nil >> So, is there some sort of read/write_association? Or, if not, is there a reason not to have one?

    Read the article

1