I have a Rails project which has a Postgres database for the actual application but which needs to pull a heck of a lot of data out of an Oracle database.
database.yml looks like
development:
adapter: postgresql
database: blah blah
...
oracle_db:
adapter: oracle
database: blah blah
My models which descend from data on th...
I have several static factory patterns in my PHP library. However, memory footprint is getting out of hand and we want to reduce the number of files required during execution time. Here is an example of where we are today:
require_once('Car.php');
require_once('Truck.php');
abstract class Auto
{
// ... some stuff ...
public st...
My question is similar to this one over here about include and extend.
What's the difference between require and include in Ruby? If I just want to use the methods from a module in my class, should I require it or include it?
...
Let's say we have two classes, Foo and Foo Sub, each in a different file, foo.rb and foo_sub.rb respectively.
foo.rb:
require "foo_sub"
class Foo
def foo
FooSub.SOME_CONSTANT
end
end
foo_sub.rb:
require "foo"
class FooSub < Foo
SOME_CONSTANT = 1
end
This isn't going to work due to the circular dependency - we c...
Hi,
I have a Perl program, that needs to use packages (that I also write). Some of those packages are only chosen in Runtime (based on some environment variable). I don't want to put in my code a "use" line for all of those packages, of course, but only one "use" line, based on this variable, something like:
use $ENV{a};
Unfortunatel...
I'm trying to follow this tutorial:
http://cl-cookbook.sourceforge.net/sockets.html
And I cannot get it working because of the port package. First the "(in-package :port)" did not work, it said the package could not be found. So I changed it to "(clc:clc-require :port)" but this causes another error:
"INTERN("STRUCTURE-KCONSTRUCTOR"): ...
What's the best way to require all files from a directory in ruby ?
...
Is there a shorter way to require a file located in the same directory (as the script being executed)?
require File.expand_path(File.dirname(__FILE__) + '/some_other_script')
I read that require "my_script" and require "./my_script" will actually load the script twice (ruby will not recognize that it is actually the same script), and ...
I am very new to Ruby so could you please suggest the best practice to separating files and including them.
What is the preferred design structure of the file layout. When do you decide to separate the algorithm into a new file?
When do you use load to include other files and when do you use require?
And is there a performance hit whe...
If I have this folder structure:
rexml
rexml/document
Is the following syntax not a recursive reference that includes everything below it?
require 'rexml'
Or do I need to write the following if I also want to access what's in 'document'?:
require 'rexml/document'
The reason I'm confused is I see some code where the author writes...
How can you display the hierarchy of 'require's that take place in a Ruby app?
Some files require files which require additional files.
However, by running an application in debug mode you only trigger a subset of required files - only the ones that are used by whatever subset of functionality your application is using at any given poi...
Hello
I'm developing own CMS and i want to implement functionality to dynamically include existing PHP script which are located on the server.
there is variable called $page_content which contains page contents including HTML and JS code, also it contains some text recognised by regex, recognised text is then processed and replaced wit...
Hello,
This is a newbie question as I am attempting to learn Ruby by myself, so apologies if it sounds like a silly question!
I am reading through the examples of why's (poignant) guide to ruby and am in chapter 4. I typed the code_words Hash into a file called wordlist.rb
I opened another file and typed the first line as require 'wo...
Hey,
I'm using Eclipse with RDT to do some Ruby programming. I'm trying to include a file in another, but require fails. Both files are in the same directory.
The folder hierarchy is set up like this:
Project > src > folder > a.rb b.rb
If I try to require b.rb in a.rb I would use this:
require 'b.rb'
But I get the following error ...
Is there a version of require in ruby that either loads the whole file, or nothing at all?
The problem is that require starts loading from the top, and if it faces problems you end up with uncompleted definitions, for example, the following would still load a class A even if module C is not defined:
class B
include C
end
In my part...
So I am toying with some black magic in Perl (eventually we all do :-) and I am a little confused as to exactly how I am supposed to be doing all of this. Here is what I'm starting with:
use strict;
use warnings;
use feature ':5.10';
my $classname = 'Frew';
my $foo = bless({ foo => 'bar' }, $classname);
no strict;
*{"$classname\::INC"}...
What is the difference between doing use My::Module and require My::Module?
...
While cleaning up some old php scripts I've noticed some weird behavior with require/include statements when I try to use variables.
On the live server, the following code works fine..
<?php
$test = "http://localhost/elearning/trunk/mypage.php";
require "$test";
?>
..but on my XAMPP installation ((basic package) version 1.6.7) I rece...
Hi All,
I'm trying to create a script to extract the variables from a file on the same server.
The problem is, I don't know what else is going to be in the file all of the time (the script is for other people to use), so I don't really want to load all of the contents or execute any of the code.
I've thought of using file_get_contents...
Hi people! I haven been all day training to fix this problem but i couldn't.
The question is easy, i don't want to put anymore the require 'rubygems' line everytime i require a gem...
If i put the require 'rubygems' before any other "require" the file runs perfect but if i don't put the require 'rubygems' line the following error occur...