Displaying 18 results from an estimated 18 matches for "openstruct".
2010 Nov 28
2
converting xml to a OpenStruct
Hi just wondering if there is a easy way to turn an xml entity into a
object like of type OpenStruct where i can access everything like a
property?
It''s kind of like parsing xml, I already know about nokogiri, but I want
to work is a OpenStruct and not a DOM object, does that make sense? =P
--
Kind Regards,
Rajinder Yadav | DevMentor.org | Do Good! ~ Share Freely
GNU/Linux: 2.6.35-2...
2007 Sep 25
16
putting away HashWithIndifferentAccess
...to_s and m.respond_to?:layout;s;end
And, well, as for ActiveSupport, Camping only uses the supra-
flexi-careless-hash, so we need a replacement.
I''m not too hot on [symbol] and [string] equivalence. But I do like
to call the query string vars like methods. What do you think about
using OpenStruct instead?
I''ve been testing with this:
class H < OpenStruct
def u h;for k,v in h;@table[k.to_sym]=v;new_ostruct_member(k);end
def self.[] *a;new *a;end
en
Or, you know, just Hash is okay, right folks?
_why
2007 Sep 27
2
Problem getting "extract" from RDig
.../config/rdig_config.rb
1. RDig.configuration do |cfg|
2. cfg.crawler.start_urls = [ ''http://localhost:3000/login/index'' ]
3. cfg.index.path =
"C:/rails/managedsupport/index/development/rdig-index"
4. cfg.verbose = true
5. cfg.content_extraction = OpenStruct.new(
6. :hpricot => OpenStruct.new(
7. :title_tag_selector => ''title'',
8. :content_tag_selector => ''body''
9. )
10. )
11.
12. end
I have created the index file using the code
1. rdig -c config/rdig_config.r...
2007 Jan 23
3
Someone getting RDig work for Linux?
...;/home/myaccount/index''
##################################################################
# options you might want to set, the given values are the defaults
# set to true to get stack traces on errors
cfg.verbose = true
# content extraction options
cfg.content_extraction = OpenStruct.new(
# HPRICOT configuration
# this is the html parser used by default from RDig 0.3.3 upwards.
# Hpricot by far outperforms Rubyful Soup, and is at least as flexible
when
# it comes to selection of portions of the html documents.
:hpricot => OpenStruct.new(
# css selecto...
2007 Sep 18
4
basic rdig setup
...o nothing
in them.
Both rdig_config.rb files look like:
cfg.crawler.start_urls = [ ''http://domain.tpl/'' ]
cfg.crawler.include_hosts = [ ''domain.tpl/'' ]
cfg.index.path = ''./rdig_index''
cfg.verbose = true
cfg.content_extraction = OpenStruct.new(
:hpricot => OpenStruct.new(
:title_tag_selector => ''title'',
:content_tag_selector => ''body''
)
Both enviroment.rb files have:
require ''acts_as_ferret''
require ''rdig''
require ''rdi...
2007 Oct 26
3
Selecting a database from the application itself?
Hi everybody,
I just started thinking about a project and am seeking some help
regarding its design.
The idea would be to create labels (i.e. address labels).I could let
users type the text manually, but I dont think they would appreciate
that when they''ll want to print 5000 addresses.
I can also probably let them import csv files, that should not be a
problem, but playing with those
2010 Oct 06
16
Dealing with an EAV database
I''ve inherited an EAV database and there''s really no option to remodel
it. Data is stored as key_name, key_value pairs
Trying to return a meaningful, unified recordset is far too complex to
be efficient.
I''ve decided to make use of the MySQL GROUP_CONCAT, and CONCAT_WS
functions to return a fast query result, with the consolidated fields
as one string.
The final data is
2007 Nov 28
0
OpenHash class I thought I would share...
I love OpenStruct, but it has no ability to iterate over the members.
I had extended it, but recently I use this little class. Anyone see
any issues with it ?
class OpenHash < Hash
def method_missing(name, value=nil)
key = name.to_s.sub(/[=?!]$/,'''').to_sym
self[key] = value if name.t...
2007 Dec 21
0
pretty neat Mash class (Magic Hash)
class Mash < Hash
def method_missing(name, value=nil)
key = name.to_s.sub(/[=?!]$/,'''').to_sym
self[key] = value if name.to_s[-1,1] == "="
self[key] = Mash.new unless self[key] || value
return self[key]
end
end
Its like OpenStruct...so what can you do?
require ''pp''
m = Mash.new
m.first_name = "john"
m.last_name = "doe"
m.address.street = "somewhere drive"
m.address.city = "somecity"
m.address.state = "somestate"
m.address.zip = 12334
pp m
{:address=>...
2009 Mar 16
0
Version of Struct for initializing via Hash
is there any equivalent to this
class A
attr_accessor :foo, :bar
def initialize(options={})
options.each{|k,v| send("#{k}=", v)}
end
end
I know that OpenStruct is very similar, but you don''t get to define
specific attributes.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to th...
2008 Jan 28
6
client first, top down, outside in, etc with rails
I''m starting a new project and I want to try writing the client first. I.e. I want to write my ''views'' first and I would like to mock out all the models in such a way that I can run the site and browse it with the mocked out models. Is it easy to use rspec''s mocking for this sort of thing and has anyone done it before? Does anyone know of a tutorial out there
2020 Feb 19
2
Poor write performance with golang binding
...f.size
raise "short write at offset #{off} (wanted #{buf.size}, done #{siz})"
end
off += buf.size
end
end
end
module Ls
include BaseOp
@readonly = 1
def perform gu, opts
puts gu.list_devices
end
end
end
def main
opts = OpenStruct.new offset: 0, bs: 1<<20
optp = OptionParser.new
optp.banner << " [op] [diskimage]
op = [#{OPS.names.join ?|}]
options:"
optp.on("-d", "--guestdevice DEV", "guest device") { |c| opts.dev = c }
optp.on("--blocksize BS", Int...
2007 Jul 21
3
manging rescues
What''s the recommended way to catch errors like this:
NoMethodError in Register#confirm
Showing app/views/register/confirm.rhtml where line #4 raised:
undefined method `namen'' for nil:NilClass
I get this error when someone does somethinh like:
http://.........../register/confirm?email=jkdsfadslkjflksd
If I make:
remail = params[:email]
@user = Request.find(:first,
2006 Jul 02
7
Generic SingleTable inheritance
Hi all,
I would like to discuss a design idea I have in mind with you, in order
to get critical feedback.
ActiveRecord supports single table inheritance(STI) "per se", BUT you
must add all possible instance variables(properties) of all subclasses
to the "base table"(as columns). I would like to circumvent this
restriction.
Say we have a
class AbstractGenericThing <
2020 Feb 19
0
Re: Poor write performance with golang binding
...t; end
> off += buf.size
> end
> end
> end
>
> module Ls
> include BaseOp
>
> @readonly = 1
>
> def perform gu, opts
> puts gu.list_devices
> end
> end
>
> end
>
> def main
> opts = OpenStruct.new offset: 0, bs: 1<<20
> optp = OptionParser.new
> optp.banner << " [op] [diskimage]
>
> op = [#{OPS.names.join ?|}]
>
> options:"
>
> optp.on("-d", "--guestdevice DEV", "guest device") { |c| opts.dev = c }
&...
2006 Nov 04
0
traits-0.9.2 - better living through metaprogramming
...quot;ls" => %w[4 2]
p c.li
p c.ls
~ > ruby sample/p.rb
[4, 2]
["4", "2"]
<========< sample/q.rb >========>
~ > cat sample/q.rb
require ''traits''
#
# the OpenTraits class is similar to an OpenStruct but, imho, easier to
use.
# the otraits shorthand can be used to contruct one
#
#
# options passed as args dynamically create and init traits
#
config = otraits :port => 42
p config.port
#
# any passed block does the same but, via a method miss...
2006 Nov 04
0
traits-0.10.0
...quot;ls" => %w[4 2]
p c.li
p c.ls
~ > ruby sample/p.rb
[4, 2]
["4", "2"]
<========< sample/q.rb >========>
~ > cat sample/q.rb
require ''traits''
#
# the OpenTraits class is similar to an OpenStruct but, imho, easier to use.
# the otraits shorthand can be used to contruct one
#
#
# options passed as args dynamically create and init traits
#
config = otraits :port => 42
p config.port
#
# any passed block does the same but, via a method missi...
2007 Dec 29
15
Do you think it would look cleaner?
I was looking over some of my specs.
I was thinking that the following:
@game.should_receive(:name).and_return(''The Battle for Blaze'')
@game.should_receive(:people).and_return(5000000)
@game.should_receive(:activated).and_return(true)
Would it look cleaner if I could do this instead?
@game.should_recieve_and_return(
:name => ''The Battle for Blaze''