<commit_before># Glass

This Gem is meant to help you quickly building application for Google Glass thanks to Ruby.

This is totally a beginning. Nothing is done.

This gem is using google/api-client.

If you think google/api-client is b***s*** this gem is what you need.

This gem is using Redis to store clients credentials.

## Installation

Add this line to your application's Gemfile:

    gem 'glass'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install glass

## Usage

Setup Credential

```ruby
require 'glass'
Glass::Mirror.client_id = ENV['GLASS_CLIENT_ID']
Glass::Mirror.client_secret = ENV['GLASS_CLIENT_SECRET']
Glass::Mirror.redirect_uri = ENV['GLASS_REDIRECT_URI']
Glass::Mirror.scopes += [# Add other requested scopes]
    # Default is 'https://www.googleapis.com/auth/drive.file',
    #            'https://www.googleapis.com/auth/userinfo.profile',
```

You are a Glassware Explorer Now !
Get a way to get the authorization code from user app install. I don't know how for now. If you find let me know !
And do the OAuth trick
```ruby
ok_glass = Glass::Mirror.build_with_code(authorization_code)
```

### Token Persistence

As in OAuth2.0, Google API issue a Refresh_Token the first time you Authorize the client, so you can get new token later.
You need to store this token. Out of the box Glass's Gem use Redis to do it.

Glass use a namespace on your redis. So don't bother about this (even if you can specify one too).

By default, Glass use local redis store (localhost:6379).

You can specify the Redis store this way :

For Heroku/RedisToGo users

```ruby
Glass::Mirror.redis = ENV["REDISTOGO_URL"]
```

### Bypassing Redis

You can bypass Redis. I don't want to know why you would, but you can do it easily.

Just do :
```ruby
Glass::Mirror.no_redis = true # Glass are so sad !
```

Now you need to handle the storage yourself !

```ruby
credentials = Glass::Mirror.get_credentials(authorization_code)<commit_msg>added explanation for exploration<commit_after># Glass

This Gem is meant to help you quickly building application for Google Glass thanks to Ruby.

This is totally a beginning. Nothing is done.

This gem is using google/api-client.

If you think google/api-client is b***s*** this gem is what you need.

This gem is using Redis to store clients credentials.

## Installation

Add this line to your application's Gemfile:

    gem 'glass'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install glass

## Usage

Setup Credential

```ruby
require 'glass'
Glass::Mirror.client_id = ENV['GLASS_CLIENT_ID']
Glass::Mirror.client_secret = ENV['GLASS_CLIENT_SECRET']
Glass::Mirror.redirect_uri = ENV['GLASS_REDIRECT_URI']
Glass::Mirror.scopes = [ Add requested scopes]
    # Default is 'https://www.googleapis.com/auth/drive.file',
    #            'https://www.googleapis.com/auth/userinfo.profile',
```

You are a Glassware Explorer Now !
Get a way to get the authorization code from user app install. I don't know how for now. If you find let me know !
And do the OAuth trick
```ruby
ok_glass = Glass::Mirror.build_with_code(authorization_code)
```

For now, other features and helpers are under development.

But as you are a Glassware Explorer you can explore yourself. Access the google/api-client Client this way :
```ruby
ok_glass.client   # Get the discovered Google::API on wich you can make request
```

Have fun ! And please, show me any use. Just send me a tweet : @TheDamFr


### Token Persistence

As in OAuth2.0, Google API issue a Refresh_Token the first time you Authorize the client, so you can get new token later.
You need to store this token. Out of the box Glass's Gem use Redis to do it.

Glass use a namespace on your redis. So don't bother about this (even if you can specify one too).

By default, Glass use local redis store (localhost:6379).

You can specify the Redis store this way :

For Heroku/RedisToGo users

```ruby
Glass::Mirror.redis = ENV["REDISTOGO_URL"]
```

### Bypassing Redis

You can bypass Redis. I don't want to know why you would, but you can do it easily.

Just do :
```ruby
Glass::Mirror.no_redis = true # Glass are so sad !
```

Now you need to handle the storage yourself !

```ruby
credentials = Glass::Mirror.get_credentials(authorization_code)
{'fraction_non_alphanumeric': 0.08806353655687923, 'fraction_numerical': 0.002803083391730904, 'mean_word_length': 4.085510688836105, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3557517', 'n_tokens_mistral': 1367, 'n_tokens_neox': 1284, 'n_words': 563}