yaml

Rails i18n and yml structure for form labels

According to the ActionView documentation. Quote: The text of label will default to the attribute name unless a translation is found in the current I18n locale (through views.labels.<modelname>.<attribute>) or you specify it explicitly. I have a "user" model and a registration form. Here's a snippet of the relevant part: <% form_f...

Ruby CLI app configuration / argument management

I'm currently working on a CLI app in Ruby, I'm using Trollop (http://trollop.rubyforge.org/) for dealing with cli arguments. I'd also like to implement the possibility of storing the required options in ~/.mycfg as well as cwd/.mycfg, the latter taking precedence. The behaviour I'm trying to implement is: If .mycfg exists in the curr...

Markdown within yaml / yaml multi-line escape sequence?

Is it possible to store unescaped markdown documents in yaml? I've tested key:|+ markdown text block that could have any combination of line breaks, >, -, :, ', " etc etc. This does not work. I need something like CDATA or python style triple-quotes for yamal. Any ideas? ...

Using Doctrine with views - dud 'id' field generated

I have a DB (yes, that one) which is proving far easier to access via views than raw tables. In general this plays quite nicely with Doctrine, but there's one issue. Doctrine can't identify a primary key in a view table when generating the YAML from the database schema, so it invents one called 'id'. Generating classes from this means th...

Can YAML entries be used a subsets of entries in same file?

I am using a YAML file for configuration in my rails app and a few entries in the file are subsets of future entries, eg - domain: domain.com name: jack email: [email protected] To make this more efficient, is something like this possible in YAML ? domain: domain.com name: jack email: jack@${domain} ...

Can I only generate base classes when calling Doctrine::generateModelsFromYaml()?

I am using Doctrine::generateModelsFromYaml(). It creates a directory filled with base classes. Cool. I'm guessing the point of separating the base classes is to store only column definitions and relationships (in other words, only things that can be gleamed from the DB. The extension models, on the other hand, will be edited with behavi...

When using Doctrine::generateYamlFromDb(), can I specify a prefix to use?

When using Doctrine::generateYamlFromDb(), can I specify a prefix to use? For example, if the table name is "user", by default, the generated class name would be "User". Can I make sure the class name (and filename) is "PrefixUser"? ...

Symfony 1.4.6 loading factories.yml configuration from task

I have the following configuration set in my factories.yml file... all: mailer: param: transport: class: Swift_SendmailTransport param: command: /usr/sbin/sendmail -oi -t ...to overcome the 'double dot' issue as described here. When I run the following code... $mailer = $this->getMailer(); $mess...

Active Record serialized attr losing string encodings (probably YAML issue), workarounds?

I'm using Rails 2.3.8 with Ruby 1.9.1 and I'm having a problem with serialized attributes in active record not preserving string encodings. The underlying problem is probably yaml, but I'm wondering if anyone has any good ideas on how to handle this. The app I'm working on has numerous serialized fields some of which contain deep struct...

In Perl, how to traverse an array of hashes loaded by YAML?

I load the following YAML stream into a Perl's array and I want to traverse the array associated with Field2. use YAML; my @arr = Load(<<'...'); --- Field1: F1 Field2: - {Key: v1, Val: v2} - {Key: v3, Val: v4} --- Field1: F2 Field2: - {Key: v5, Val: v6} - {Key: v7, Val: v8} ... foreach (@arr) { @tmp = $_->{'Field2'}; pr...

Working around unexpected behavior in yaml for Ruby -- interned unicode strings

(1.9 on Windows) Reproducing: require 'yaml' s = YAML::load("\xEC\x86\x8C\xEB\x85\x80\xEC\x8B\x9C\xEB\x8C\x80") # => "∞åîδàÇ∞ï£δîÇ" or "소녀시대", depending on your terminal's unicode support s_interned = s.intern s_interned.class # => Symbol s_yamld = s_interned.to_yaml # => "--- \":\\xEC\\x86\\x8C\\xEB\\x85\\x80\\xEC\\x8B\\x9...

Special character in database.yml for password.

Hi All, I have my database password starting with a '*'. When i put this on my production server i get following error: - syntax error on line 17, col 25: ` password: *---------'.Exception class:ArgumentError. Thanks, Anubhaw ...

Ruby Code Critique

I'm a Ruby newbie (started 4 days ago and hey it rhymes!) and decided to code a simple little tool for fun/learning. The following code was the result. It works fine, but I would really appreciate critique from some more experienced Ruby developers. I'm looking for comments on style, verbosity, and any misc. tips/tricks. By the way, I'm...

YML files in Symfony - can you get associative arrays more than 1 level down?

Hi, I have a load of data I want to store here: /apps/frontend/modules/builder/config/module.yml I have it looking something like: all: series_options: compact: name: Compact description: Something small. enabled: 1 large: name: Large description: Bit bigger. enabled: 0 In the actions.c...

Ruby YAML::load

I'm trying to modify the default deserialization of the built-in timestamp format, to affect Ruby's Time. I do this (successfully) with Hash: YAML::add_domain_type('yaml.org,2002', 'map') { |t, v| nil } YAML::add_domain_type('ruby.yaml.org,2002', 'hash') { |t, v| nil } hash = { :hello => :world } puts YAML::load(hash.to_yaml) # nil B...

Preserve new lines in YAML

How do I format a YAML document like this so that pyYAML can parse it properly? Data: Some data, here and a special character like ':' Another line of data on a separate line I know that the ':' character is special so I have to surround the whole thing in quotations like so: Data: "Some data, here and a special character like ...

Assign class methods from YAML file.

In short,I've written an application that parses text files in specified formats from different email feeds. Currently, there are two formats allowed by users in order to correctly upload information. I've also included a simple YAML file that allows people with non-programming backgrounds (ie sysadmins) to define the basics parsing pa...

use of YAML blocks in rails i18n locale files

So I'd like to be able to add a longer block of text to a YAML locale file in Rails. However, the YAML parser gives syntax errors for blocks that appear to be fine! I've read through the Ruby YAML cookbook and it seems like these examples below should all work, but they don't. config/locales/tx.yml This one works fine: tx: states: ...

In YAML, how do I break a string over multiple lines?

In YAML, I have a string that's very long. I want to keep this within the 80-column (or so) view of my editor, so I'd like to break the string. What's the syntax for this? In other words, I have this: Key: 'this is my very very very very very very long string' and I'd like to have this (or something to this effect): Key: 'this is my...

How can I store a YAML object in Memcached ? Without a serializations problems.

I'm using gem 'dalli' but the same problem happen with gem memcached-client development.rb config.cache_store = :dalli_store My app controller Rails.cache.write('presidentes', Candidato.by_cargo(:key => "Presidente")) @presidentes = Rails.cache.read('presidentes') If I debug the @presidentes var it returns --- !binary | BAhvOi...