README.md in adhoq-0.0.2 vs README.md in adhoq-0.0.3
- old
+ new
@@ -1,23 +1,25 @@
-# Adhoq
+Adhoq [![Build Status](https://travis-ci.org/esminc/adhoq.svg)](https://travis-ci.org/esminc/adhoq) [![Code Climate](https://codeclimate.com/github/esminc/adhoq/badges/gpa.svg)](https://codeclimate.com/github/esminc/adhoq)
+====
Rails engine to generate instant reports from adhoc SQL query.
![adhoq](https://cloud.githubusercontent.com/assets/3419/4556639/7f06340a-4ecb-11e4-87c4-b074580e77f5.png)
## Features
-- [x] Rails 4.x support
-- [ ] Rails 3.2 support
+- Export ad-hoc SQL result to .xlsx file
+- Persist generated report as local file or in AWS S3
+- Rails 4.x & 3.2 support
+- Nice administration console with rails engine
+
+### Future planning
+
- Export reports in some formats:
- - [x] .xlsx
- [ ] .csv
- [ ] .json
-- Report storage supports:
- - [x] as local file
- - [ ] S3 (via `Fog::Storage`)
-- [ ] In application export function helper
+- [ ] Label data substitution
## Installation
Add this line to your application's Gemfile:
@@ -56,25 +58,56 @@
Edit initialization file in `config/initializer/adhoq.rb`
```ruby
Adhoq.configure do |config|
- config.storage = [:local_file, Rails.root + '/path/to/store/report/files']
+ config.storage = [:local_file, Rails.root + './path/to/store/report/files']
config.authorization = ->(controller) { controller.signed_in? }
end
```
-See configuration example in [dummy app](https://github.com/esminc/adhoq/commit/63cc31fe209baae7211c10f76e7b1c35f4c699ef).
+See configuration example in [dummy app](https://github.com/esminc/adhoq/blob/master/spec/dummy/config/initializers/adhoq.rb).
Then restart server and try it out.
### As Plain old library (application export helper)
-TODO: Write usage instructions here
+Adhoq also provides report generation from SQL string, not from mounted rails engine.
+```ruby
+execution = Adhoq::AdhocExecution.new(
+ 'xlsx',
+ 'SELECT "hello" AS name ,"English greeting message" AS description'
+)
+
+Adhoq::Reporter.generate(execution) #=> report data
+```
+
+Persistence is also available without engine via `Adhoq::Storage::SomeClass#store`.
+Below is example that generating report and persist to in Rails application report method.
+
+```ruby
+execution = Adhoq::AdhocExecution.new(
+ 'xlsx',
+ 'SELECT "hello" AS name ,"English greeting message" AS description'
+)
+
+storage = Storage::S3.new(
+ 'my-adhoq-bucket',
+ aws_access_key_id: 'key_id',
+ aws_secret_access_key: 'access_key'
+)
+
+# generate report and store it to S3, returns `key` to get report data
+key = storage.store('.xlsx') { Adhoq::Reporter.generate(execution) }
+
+...
+storage.get(key) #=> report data
+```
+
## Contributing
-1. Fork it ( https://github.com/[my-github-username]/adhoq/fork )
+1. Fork it ( https://github.com/esminc/adhoq/fork )
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request