yaml

Hash inside YAML file?

I want to include a hash and list inside a YAML file that I'm parsing with the following command: APP_CONFIG = YAML.load_file("#{RAILS_ROOT}/config/config.yml") My YAML file looks like this: feeds: [{:url => 'http://www.google.com', :label => 'default'}] But this doesn't seem to work. How would I go about achieving such a thing? T...

Storing information inside YAML

I looked through the YAML for ruby documentation and couldn't find an answer. I have a list of several employees. Each has a name, phone, and email as such: Employees: Name | Phone | Email john 111 [email protected] joe 123 [email protected] joan 321 [email protected] How would I write the above information in YAML to end up wit...

Can YAML have inheritance?

This question involves a lot of symfony but it should be easy enough for someone to follow who only knows YAML and not symfony. My symfony models come from a three-step process: First, I create the tables in MySQL. Second, I run a symfony command (symfony doctrine:build-schema) to convert my table structure into a YAML file. Third, I ru...

How to dump the database to yaml file with content '<% abc do %>ddd<% end %>'?

In my database, there are some text content, one of them is: <% abc do %> ddd <% end %> When I dumped it to yaml with to_yaml(), it is like: content: |- <% abc do %> ddd <% end %> And then, when I use rake db:fixtures:load, such error occurs: The exact error was: NoMethodError: undefined method 'abc' for main:Object...

index.yaml is not updating

I expect the index.yaml file to update with the necessary indices when I run queries in my development environment. It claims that it is updating this file in the dev server log, but the file doesn't actually change. Any idea what might be going on? Here is the entire index.yaml file: indexes: # AUTOGENERATED # This index.yaml is aut...

Can we force rendering a text as binary when 'to_yaml'?

requrie 'yaml' hash = {:title=>'abc'} hash.to_yaml will output: --- title: abc Is there any method to force the title to be a binary, like: --- title: !binary| 5Lit5pa UPDATE I'm asking this because I want to dump the data from database to yml files. But the text in the database, contains English and non-English text, and bot...

Is there any gem can dump the data from and to yml files?

I'm find such a gem a whole day, but not find a good one. I want to write one, but I'm not able to do it. The data in my database may be English text, which will be dump to a yml file with plain text. And some are non-English text, which will be binary type. And both of them may have such code: <% xxx %> When I use rake db:fixtures:...

Python Google App Engine: Call specific method from yaml file?

I am new to database programming with Google App Engine and am programming in Python. I was wondering if I am allowed to have one Python file with several request handler classes, each of which has get and post methods. I know that the yaml file allows me to specify which scripts are run with specific urls, like the example below: hand...

Can one YAML object refer to another?

I'd like to have one yaml object refer to another, like so: intro: "Hello, dear user." registration: $intro Thanks for registering! new_message: $intro You have a new message! The above syntax is just an example of how it might work (it's also how it seems to work in this cpan module.) I'm using the standard ruby yaml parser. Is t...

Doctrine yaml for a One-To-Many And One-To-One Relationship

I have two objects: File and FileDetail. A File can have many FileDetails, but a FileDetail can only have one File. I can get this to work, but I can't delete anything from the database because of key constraints (I can't delete the File row because FileDetail depends on it, and vice versa). I have the following yaml: File: columns: ...

How can I go about translating Doctrines YAML models into json-schema

Basically I am looking to be able to reuse model definitions to target both Doctrine models and JSON-Schema. I don't care if it means defining it in a 3rd model language and having the ability to convert that to both yml and json-schema or if it is from json-schema -> yml as long as I have 1 place to update both of them. ...

Is there any limitation on YAML indentation level?

I am developing a Ruby on Rails application with I18n support. I created a YAML file. But Rails report there is syntax error in the YAML file. I found that if I decrease the level of indentation for that error line, no error message come out again. Is there any limitation on YAML indentation level (in Ruby on Rails)? Here is YAML bloc...

What's the correct way to read some data from a yaml file and use it in an erb page?

I'm using rails to build a website. I have a yaml file contails some colors, which is config/colors.yml --- - white - red - blue - yellow - ... And, there is an erb file app/views/users/setting.html.erb, which will need the data in config/colors.yml, and put them in a tag. I don't know what's the correct way to read the yaml file. ...

How can I fold YAML items in VIM?

I have a YAML formatted text file, and would like to define custom folding for VIM, but I'm not sure how to go about it (despite reading the VIM documentation for folding). The file consists of YAML "documents", like so: --- title: My Title attr1: value1 attr2: value2 --- title: Next Item attr1: value3 --- title: One More Item ... I ...

List of Language Codes in YAML or JSON?

Is there a list of language codes in YAML or JSON somewhere out there? Another format is fine, I can convert it if necessary. ...

[Ruby] Sequel example won't run

Hi, I've just installed "sequel" gem for Ruby. I wanted to try example from Sequel website and it won't work :( test.rb: require 'rubygems' require 'sequel' DB = Sequel.sqlite # memory database DB.create_table :items do primary_key :id String :name Float :price end items = DB[:items] # Create a dataset # Populate the tab...

Validating a yaml document in python

One of the benefits of XML is being able to validate a document against an XSD. YAML doesn't have this feature, so how can I validate that the YAML document I open is in the format expected by my application? ...

Editing a YAML file inside a Rails App

I'm trying to use a yaml config file as a very simple flat file db for a small rails app. The app has a single user, so I just need a way to store a username and password. The only thing is that I'd like to be able to edit the username and password while still inside the app and not require an app restart (so I can't load the YAML file...

Import a YAML (fixtures) file from another

Hello, for better organization (for eg: seed and test data), is it possible to split the yaml file and import the first one from second. Of course, the variables in file1 should be available to use in the second. I use Snakeyaml based parser i java, if that matters. thanks. Update 1: (example) Seed file: seed.yaml Priority(L1E1...

Relations with multiple keys in Doctrine 1.2

I have two tables, which can be thought of one being a list of parts in a product, and another being the internationalisation table for the full name of those parts. I'm trying to specify a relationship in either Doctrine class code or YAML, but I can't see how to do so on more than one key. For example, from Product to Part is easy, as...