require

bad practice to strip out all require statements into a separate file?

If I have a whole bunch of requires in my main app file: require 'a' require 'b' require 'c' require 'd' require 'e' require 'f' require 'g' require 'h' require 'i' require 'j' would it be bad practice to put strip all of these requires out and put them in a separate file that just does all of the requires - let's call it 'all_require...

How are require, require_dependency and constants reloading related in Rails?

I need to write a plugin for a rails application which uses Engines. Since I have no Rails experience before, I read some documents and tutorial stuff. But Rails' class loading process lost me, feels like so much black magic behind. The basic question I'm having is how require and require_dependency are different? How can require_depe...

Problem with using require inside a function and variable scope

I'm using an MVC setup and I'm trying to inject javascript into my views (.php), yet allow the javascript access to all the variables that the view has access to. My end goal is to be able to access PHP variables from my javascript (for example so I could alert() a product's name). Here's my application flow: start output buffer call ...

Pretty version of Ruby's require statement?

I've always thought this sort of thing ugly: require File.join(File.dirname(__FILE__), 'hirb/config') Is there a prettier alternative, maybe one written for Rails? require_relative 'hirb/config' require_relative '../another/file' ...

Why can't my Perl script see the our() variables I defined in another file?

I have a question relating to Perl and scoping. I have a common file with lots of various variables. I require the common file in my main script, but I cannot access the variables; they seem to be outside of its scope. I assumed that an our declaration would overcome that problem, but it doesn't seem to work. Script 1: common.pl #!/usr...

Ruby require problem

I'm trying to get the sanitize gem up and running. I've installed sanitize and nokogiri 1.3.3 as required, but when I try and use it in my application_helper.rb: require 'rubygems' require 'sanitize' I get the error: MissingSourceFile no such file to load -- sanitize RAILS_ROOT: C:/Ruby/GWS (stack trace) This error occurred while ...

PHP Catch "Empty" Includes

We have a custom framework that we use, that allows us to include code in to other pages. However, the header for this code is always printed, even if the include code doesn't output anything. Is there a way that I can exit, or return something specific, that I can trap and catch via include/require, so that I can do the right thing? ...

FxCop or other util to require inline docs in VB.NET?

I'm starting a new project; trying to be more strict than previous ones. I've set warnings as errors in the build I've added FxCop to PostBuild. The one last thing on my list os require people to add inline docs for all classes/non-private methods/properties. Is there a custom FxCop rule or another exe I can run in the post build to che...

Simple 'require' problem in Ruby

Hello, I'm following along with 'Why's Poignant Guide to Ruby' in order to learn Ruby and I am having some problem when he first introduces the 'require' method(?) in his tutorial. Essentially I make a file called 'wordlist.rb' which contains: code_words = { 'starmonkeys' => 'Phil and Pete, those prickly chancellors of the New Rei...

How to determine where a require request originated?

Is there any way to determine from within a required script, where that require call was made from? So if Script B is required by Script A. How can I determine from within Script B that it is Script A who is making the request? ...

How to include a class

I have index.php and I want to include class.twitter.php inside it, how do I do this? Hopefully then when I put the below code in index.php it will work. $t = new twitter(); $t->username = 'user'; $t->password = 'password'; $data = $t->publicTimeline(); ...

Loading ruby source from a zip archive?

I have a mod_rails server where disk space, oddly enough, is at a premium. Is there a way for me to compress my application's source, like Python's zipimport? There are obvious disadvantages to this, so I should probably just break down and spend a nickel on disk space, but I figured it'd be worth a shot. ...

monitoring disc reads

Hi, i want to use apc in php, to avoid disc reads when including files. But how can i know if files are really coming from shared memory, instead of disc reads? Does anyone know how to measure the number of disc reads for a php script, or in a time interval? (on windows server 2003) Thanks a lot in advance, regards, Charles ...

Can I require class-functions only if the class is instantiated in php?

Trying to improve my code's agility and loading time, I thought of doing this, so that the functions would be required only if the class was instantiated. class User { public function __construct() { require('all_user_fns.php'); } } Inside all_user_fns.php will reside all User class's functions. Is that feasible (...

Why does my Perl CGI program fail when I include a file?

I'm trying to create a base template which then loads data depending on what actions are taken. I included ( required ) some pages which was fine but when I included another file which I got a 500 internal error. pasting the code straight in and it works fine: Here's what I've got; #!/usr/bin/perl use strict; use warnings; use LWP::Sim...

change path for include/require only once

I have a lot of sites - all hosted on my server. I want one of them to access file from /vhost which is a directory above httpdocs where the domain is linked. I know that there is an option to change the path in httpd.conf but that is a lot of work to change all the includes in my sites. ...

Require constant-defining files at once or by utilisation in PHP?

I have about 20 files containing 10-15 times this: define('someConstantName','stringBetween10and200Chars'); those are all critical for the app, but each constants-file is parallel to an app page. For example, index.php will require index_constants.php so on so forth. The question is, should I make one file of all constant-definition...

IronRuby - how to require .NET assemblies without strong name?

This page on the IronRuby help website talks about being able to 'require' some well-known assemblies such as System.Windows.Forms without needing to crank out the entire 'ah-come-on-gimme-a-break-here-you-cannot-be-serious' strong name of the assembly. In the docs it says this: >>> require "System.Windows.Forms" => true But when...

What's better of require(dirname(__FILE__).'/'.'myParent.php') than just require('myParent.php') ?

Lots of famous PHP scripts including WordPress use dirname(_FILE_).'/myParent.php' instead of just 'myParent.php' when including files in the same directory of the currently running script. Aren't they the same thing? Why do you prefer typing more? Thanks. ...

Dynamically requiring in ruby

All, I was wondering if anyone has an intermit enough knowledge of rubys 'require' to tell me if the following is valid ruby or not; class Something def initialize(mode) case mode when :one then require 'some_gem' when :two then require 'other_gem' end end end s = Something.new If so, would the require plac...