Ruby bindings to read and parse the OpenStax ABL and the content archive
Add this gem to your Gemfile and then add the following configuration to your boot (for example, in a Rails initializer):
OpenStax::Content.configure do |config|
config.abl_url = ENV['OPENSTAX_CONTENT_ABL_URL']
config.archive_path = ENV['OPENSTAX_CONTENT_ARCHIVE_PATH']
config.bucket_name = ENV['OPENSTAX_CONTENT_BUCKET_NAME']
config.domain = ENV['OPENSTAX_CONTENT_DOMAIN']
config.exercises_search_api_url = ENV['OPENSTAX_CONTENT_EXERCISES_SEARCH_API_URL']
config.logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
config.s3_region = ENV['OPENSTAX_CONTENT_S3_REGION']
config.s3_access_key_id = ENV['OPENSTAX_CONTENT_S3_ACCESS_KEY_ID']
config.s3_secret_access_key = ENV['OPENSTAX_CONTENT_S3_SECRET_ACCESS_KEY']
end
It's probably a good idea to read these values from environment variables s3_access_key_id and s3_secret_access_key are optional (you can use AWS instance roles instead)
abl = OpenStax::Content::Abl.new
books = abl.books
slugs = abl.slugs_by_page_uuid
fragment_splitter = OpenStax::Content::FragmentSplitter.new(
book.reading_processing_instructions, reference_view_url
)
fragment_splitter.split_into_fragments page.root
To run all existing tests for this gem, simply execute the following from the main folder:
$ rake
- Fork the openstax/content-ruby repo on Github
- Create a feature or bugfix branch (
git checkout -b my-new-feature
) - Write tests for the feature/bugfix
- Implement the new feature/bugfix
- Make sure both new and old tests pass (
rake
) - Commit your changes (
git commit -am 'Added some feature'
) - Push the branch (
git push origin my-new-feature
) - Create a new Pull Request to openstax/content-ruby on Github
This gem is distributed under the terms of the AGPLv3 license. See the LICENSE file for details.