hulihanapplications / fletcher

A cross-website product information fetcher for ruby.
http://www.hulihanapplications.com
MIT License
53 stars 12 forks source link

Additional Model Information #9

Closed dhulihan closed 11 years ago

dhulihan commented 11 years ago

I'd like to be able to retrieve useful information about each model. This information should at least include the company's title and url. We may not be able to dynamically render the company title based on the model's class name since the properly formatted title can't always be derived correctly. In this case we could use I18n with each model's hash keyed with [Model].name.underscore.

Here's what the translation file could look like:

en:
  fletcher:
    models:
      amazon:
        title: "Amazon"
        url: "http://www.amazon.com"
      gamecouk:
        title: "Game.co.uk"
        url: "http://www.game.co.uk"

Here's an API example:

I18n.locale = "en-US"
Fletcher.models.first.title # => "Amazon"
Fletcher.models.first.url # => "http://www.amazon.com"

I18n.locale = "en-GB"
Fletcher.models.first.url # => "http://www.amazon.co.uk"
davidcollom commented 11 years ago

Good idea, not too sure on the implementation of this tho.. could become quite complicated? not too sure what performance impact there is with large yaml files too..

dhulihan commented 11 years ago

True, this is probably outside of the scope of fletcher. So far i've been storing this information at the app level when I need it, and it seems to be working well. Closing.