README.md in hypershield-0.1.1 vs README.md in hypershield-0.2.0

- old
+ new

@@ -17,10 +17,43 @@ - `token` - `secret` Give database users access to these views instead of the original tables. +## Installation + +Add this line to your application’s Gemfile: + +```ruby +gem 'hypershield' +``` + +And run: + +```sh +rails generate hypershield:install +``` + +Hypershield is disabled in non-production environments by default. You can do a dry run with: + +```sh +rake hypershield:refresh:dry_run +``` + +Next, set up your production database. + +- [Postgres](#postgres) +- [MySQL](#mysql) + +When that’s done, deploy to production and run: + +```sh +rails db:migrate +``` + +The schema will automatically refresh. + ## Database Setup ### Postgres Create a new schema in your database @@ -67,54 +100,36 @@ ```sql SELECT * FROM mydb.users LIMIT 1; ``` -## Installation - -Add this line to your application’s Gemfile: - -```ruby -gem 'hypershield', group: :production -``` - -Refresh the schema - -```sh -rake hypershield:refresh -``` - -And query away on your shielded views - -```sql -SELECT * FROM users LIMIT 1; -``` - -When you run database migrations, the schema is automatically refreshed. - ## Configuration +Set configuration in `config/initializers/hypershield.rb`. + Specify the schema to use and columns to show and hide ```ruby Hypershield.schemas = { hypershield: { - hide: %w(encrypted password token secret), - show: %w(ahoy_visits.visit_token) + hide: ["encrypted", "password", "token", "secret"], + show: ["ahoy_visits.visitor_token", "ahoy_visits.visit_token"] } } ``` -Log Hypershield SQL statements [master] +Log Hypershield SQL statements ```ruby Hypershield.log_sql = true ``` -## TODO +Enable or disable Hypershield in an environment -- Create CLI +```ruby +Hypershield.enabled = Rails.env.production? +``` ## History View the [changelog](CHANGELOG.md) @@ -124,5 +139,13 @@ - [Report bugs](https://github.com/ankane/hypershield/issues) - Fix bugs and [submit pull requests](https://github.com/ankane/hypershield/pulls) - Write, clarify, or fix documentation - Suggest or add new features + +To get started with development: + +```sh +git clone https://github.com/ankane/hypershield.git +cd hypershield +bundle install +```