{"id":22025183,"url":"https://github.com/drexed/lite-report","last_synced_at":"2026-05-16T08:35:50.174Z","repository":{"id":35005349,"uuid":"195255839","full_name":"drexed/lite-report","owner":"drexed","description":"Import and export Ruby and Rails objects to flat files and vice versa","archived":false,"fork":false,"pushed_at":"2023-03-08T20:12:27.000Z","size":141,"stargazers_count":1,"open_issues_count":8,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-28T01:46:04.736Z","etag":null,"topics":["activerecord","csv","export","import","rails","ruby"],"latest_commit_sha":null,"homepage":"https://drexed.github.io/lite-report","language":"Ruby","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/drexed.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-07-04T14:24:13.000Z","updated_at":"2022-08-20T22:08:32.000Z","dependencies_parsed_at":"2024-08-05T18:35:18.533Z","dependency_job_id":null,"html_url":"https://github.com/drexed/lite-report","commit_stats":{"total_commits":61,"total_committers":2,"mean_commits":30.5,"dds":"0.016393442622950838","last_synced_commit":"0e3789158b96ffc8618adafad4f8b9ffbf52d414"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/drexed/lite-report","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drexed%2Flite-report","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drexed%2Flite-report/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drexed%2Flite-report/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drexed%2Flite-report/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/drexed","download_url":"https://codeload.github.com/drexed/lite-report/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/drexed%2Flite-report/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269065613,"owners_count":24354235,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-06T02:00:09.910Z","response_time":99,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["activerecord","csv","export","import","rails","ruby"],"created_at":"2024-11-30T07:14:51.961Z","updated_at":"2025-11-11T18:33:16.041Z","avatar_url":"https://github.com/drexed.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lite::Report\n\n[![Gem Version](https://badge.fury.io/rb/lite-report.svg)](http://badge.fury.io/rb/lite-report)\n[![Build Status](https://travis-ci.org/drexed/lite-report.svg?branch=master)](https://travis-ci.org/drexed/lite-report)\n\nLite::Report is a library for importing and exporting Ruby and Rails objects to flat files and\nvice versa. Usage of the report module has many options so it is best if you check out the specs\nto see everything the library can do.\n\n**NOTE:** If you are coming from `ActiveReport`, please read the [port](#port) section.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'lite-report'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install lite-report\n\n## Table of Contents\n\n* [Configurations](#configurations)\n* [Array](#array)\n* [Hash](#hash)\n* [Record](#record)\n* [Exporter](#exporter)\n* [Stream](#stream)\n* [Port](#port)\n\n## Configurations\n\n`rails g lite:report:install` will generate the following file:\n`../config/initalizers/lite_report.rb`\n\nPlace your default configs in this file.\n\n```ruby\nLite::Report.configure do |config|\n  config.csv_options = {}\n  config.data_options = {}\n  config.import_options = {}\nend\n```\n\n## Array\n\n```ruby\ndata = [\n  ['James Jones', 39, 'male', ...],\n  ['Pamela Anderson', 52, 'female', ...],\n  ['Dwayne Wade', 21, 'male', ...]\n]\n\n# Convert array of arrays to CSV file\nLite::Report::Array.export(\n  data,\n  data_options: {\n    only: ['Age', 'Sex']\n  },\n  csv_options: {\n    write_headers: true,\n    headers: ['Name', 'Age', 'Sex', ...]\n  }\n)\n\n# Convert CSV file to an array of arrays\nLite::Report::Array.import(\n  'path/to/file.csv',\n  data_options: {\n    except: ['Age', 'Sex']\n  },\n  csv_options: {\n    return_headers: true,\n    headers: ['Name', 'Age', 'Sex', ...]\n  }\n)\n```\n\n## Hash\n\n```ruby\ndata = [\n  { 'Name' =\u003e 'James Jones', 'Age' =\u003e 39, 'Sex' =\u003e 'male', ...],\n  { 'Name' =\u003e 'Pamela Anderson', 'Age' =\u003e 52, 'Sex' =\u003e 'female', ...],\n  { 'Name' =\u003e 'Dwayne Wade', 'Age' =\u003e 21, 'Sex' =\u003e 'male', ...]\n]\n\n# Convert array of hashes to CSV file\nLite::Report::Hash.export(\n  data,\n  data_options: {\n    only: ['Age', 'Sex']\n  },\n  csv_options: {\n    write_headers: true,\n    headers: ['Name', 'Age', 'Sex', ...]\n  }\n)\n\n# Convert CSV file to an array of hashes\nLite::Report::Hash.import(\n  'path/to/file.csv',\n  data_options: {\n    except: ['Age', 'Sex']\n  },\n  csv_options: {\n    return_headers: true,\n    headers: ['Name', 'Age', 'Sex', ...]\n  }\n)\n```\n\n## Record\n\n```ruby\ndata = User.where(age: 20..29)\n\n# Convert array/relation/ransack of records to CSV file\nLite::Report::Record.export(\n  data,\n  data_options: {\n    only: [:age, :sex]\n  },\n  csv_options: {\n    write_headers: true,\n    headers: ['Name', 'Age', 'Sex', ...]\n  }\n)\n\n# Convert CSV file to an array of records (import options are from Rails `insert_all`)\nLite::Report::Record.import(\n  'path/to/file.csv',\n  data_options: {\n    klass: User,\n    except: [:age, :sex]\n  },\n  import_options: {\n    unique_by: %w[Name Age]\n  }\n)\n```\n\n## Exporter\n\nUse exporters to filter, manipulate, and prepare data before final exportation.\nThese are very helpful when working with complex datasets.\n\n```ruby\nclass LimitedExporter \u003c Lite::Report::Exporter\n\n  private\n\n  def serialize(record)\n    {\n      'Id' =\u003e record.id,\n      'Name' =\u003e \"#{record.first_name} #{record.last_name}\",\n      'Speed' =\u003e record.speed.ceil,\n      'Date' =\u003e record.to_s(:short)\n    }\n\n    # - or -\n\n    serializer = RecordSerializer.new(record)\n    serializer.serializable_hash\n  end\n\nend\n\nraw_data = User.where(age: 20..29)\nlimited_data = LimitedExporter.call(raw_data)\nLite::Report::Hash.export(limited_data)\n```\n\n## Stream\n\nStream is great option for preventing browser timeouts of downloading large CSV files by chunking\nthe results via an enumerator.\n\n```ruby\nclass StreamingController \u003c ApplicationController\n\n  def download\n    headers.delete(\"Content-Length\")      # Tell Rack to stream the content\n    headers[\"Cache-Control\"] = \"no-cache\" # Don't cache anything from this generated endpoint\n    headers[\"Content-Type\"] = \"text/csv\"  # Tell the browser this is a CSV file\n    headers[\"X-Accel-Buffering\"] = \"no\"   # Don't buffer when going through proxy servers\n\n    # Make the file download with a specific filename\n    headers[\"Content-Disposition\"] = \"attachment; filename=\\\"example.csv\\\"\"\n\n    self.response_body = report_body      # Set an Enumerator as the body\n    response.status = 200                 # Set the status to success\n  end\n\n  private\n\n  def report_body\n    Lite::Report::Hash.export(\n      data,\n      csv_options: { stream: true }\n    )\n  end\n\nend\n```\n\n## Port\n\n`Lite::Report` is NOT a compatible port of [ActiveReport](https://github.com/drexed/active_report).\n\nPlease read the docs and go through the specs to view many examples.\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/lite-report. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the Lite::Report project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/lite-report/blob/master/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrexed%2Flite-report","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdrexed%2Flite-report","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdrexed%2Flite-report/lists"}