gem install rosette-active-record
Then, somewhere in your project:
require 'rosette/data_stores/active_record_data_store'
This library is generally meant to be used with the Rosette internationalization platform that extracts translatable phrases from git repositories. rosette-active-record provides an ActiveRecord-based data store to Rosette responsible for storage and retrieval of all Rosette data.
Let's assume you're configuring an instance of Rosette::Server
. Adding rosette-active-record as your data store would cause your configuration to look something like this:
# config.ru
require 'rosette/core'
require 'rosette/data_stores/active_record_data_store'
rosette_config = Rosette.build_config do |config|
config.use_datastore(
'active-record', { adapter: 'mysql2', host: '127.0.0.1', port: '3306', ... }
)
end
server = Rosette::Server::ApiV1.new(rosette_config)
run server
-
Phrase
. Phrases represent a single unit of translatable content and consist of akey
(the source text), ameta_key
(a unique identifier), and a few other properties likefile
andline_number
. -
CommitLog
. Rosette identifies translatable content at the git commit level. EachCommitLog
entry represents the current state of a single commit, and contains thecommit_id
of the commit, the currentstatus
of the commit (see Rosette::DataStores::PhraseStatus), and the commit'sbranch_name
. -
CommitLogLocale
. As translations become available,CommitLogLocale
entries are created and updated to track translation progress. Progress is stored in thetranslated_count
field.
As this project matures, new migrations will be added to the migrations/
folder. In true activerecord fashion, migrations are additive and run via a rake task. In your project, add this to your Rakefile:
require 'rosette/data_stores/active_record/tasks'
You should then be able to run bundle exec rake rosette:ar:migrate
.
In addition to migrations, you should also now be able to run rake rosette:ar:rollback
to roll back a migration, and rake rosette:ar:setup
to create the schema_migrations
table and run all migrations (when you're bootstrapping a new database, for example).
This project must be run under jRuby. It uses expert to manage java dependencies via Maven. Run bundle exec expert install
in the project root to download and install java dependencies.
rosette-active-record also reqires a JDBC-friendly database adapter. See this github repo for the right adapter for your database. You'll need to include the adapter gem in your gemfile, require it, and make sure you pass the correct adapter
option to #use_datastore
(see above).
bundle exec rake
or bundle exec rspec
should do the trick.
- Cameron C. Dutro: http://github.com/camertron