bookingsync_application 0.1.7 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +114 -9
- data/lib/bookingsync_application/spec_helper.rb +0 -14
- data/lib/bookingsync_application/version.rb +1 -1
- metadata +15 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 61e8a69312085fb8b68d4533325f0656fa769d5e
|
4
|
+
data.tar.gz: d10d3a9f892a954f4ea0e6fe7ab25dd1ba184896
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd3797798f43a4b9183602412ce75e13e3772d4b9ff97416cb4103f5be73850415d837d180ca36e7ebb11803aac3fa9f1cc383e9a63cd44c141b78caf075ca42
|
7
|
+
data.tar.gz: 62c31222f9e7c1fd6cf37152b73d56d31e979649214be57d50f31c24e6add0aa12de4fb911d9a8405b43b79ea085499b5fb4f69bccbac75acb00f96c52629725
|
data/README.md
CHANGED
@@ -1,26 +1,88 @@
|
|
1
1
|
[![Code Climate](https://codeclimate.com/github/BookingSync/bookingsync_application/badges/gpa.svg)](https://codeclimate.com/github/BookingSync/bookingsync_application)
|
2
|
-
[![Build Status](https://travis-ci.org/BookingSync/bookingsync_application.svg?branch=master)](https://travis-ci.org/BookingSync/
|
2
|
+
[![Build Status](https://travis-ci.org/BookingSync/bookingsync_application.svg?branch=master)](https://travis-ci.org/BookingSync/bookingsync_application)
|
3
3
|
|
4
4
|
# BookingsyncApplication
|
5
5
|
|
6
6
|
A Rails engine to simplify building BookingSync Applications.
|
7
7
|
|
8
|
-
|
8
|
+
## Requirements
|
9
9
|
|
10
|
-
|
11
|
-
|
10
|
+
This engine requires Rails `>= 4.0.0` and Ruby `>= 2.0.0`.
|
11
|
+
|
12
|
+
## Documentation
|
13
|
+
|
14
|
+
[API documentation is available at rdoc.info](http://rdoc.info/github/BookingSync/bookingsync_application/master/frames).
|
15
|
+
|
16
|
+
## Installation
|
17
|
+
|
18
|
+
BookingSync Application works with Rails 4.0 onwards and Ruby 2.0 onwards. To get started, add it to your Gemfile with:
|
19
|
+
|
20
|
+
```ruby
|
12
21
|
gem 'bookingsync_application'
|
13
22
|
```
|
14
|
-
|
23
|
+
|
24
|
+
Then bundle install:
|
25
|
+
|
26
|
+
```ruby
|
27
|
+
bundle install
|
15
28
|
```
|
16
|
-
|
29
|
+
|
30
|
+
### Add authorization routes
|
31
|
+
|
32
|
+
Then BookingSync Authorization routes need to be mounted inside you apps routes.rb:
|
33
|
+
```ruby
|
34
|
+
mount BookingSync::Engine => '/'
|
35
|
+
```
|
36
|
+
|
37
|
+
This will add the following routes:
|
38
|
+
|
39
|
+
* `/auth/bookingsync/callback`
|
40
|
+
* `/auth/failure`
|
41
|
+
* `/signout`
|
42
|
+
|
43
|
+
### Add a model to link with BookingSync accounts
|
44
|
+
|
45
|
+
BookingSync Application uses the `Account` model to authenticate each BookingSync Account, if you do not have an `Account` model yet, create one:
|
46
|
+
|
47
|
+
```console
|
48
|
+
rails g model Account
|
49
|
+
```
|
50
|
+
|
51
|
+
Then, generate a migration to add OAuth fields for the `Account` class:
|
52
|
+
|
53
|
+
```console
|
54
|
+
rails g migration AddOAuthFieldsToAccounts provider:string uid:integer:index \
|
55
|
+
name:string oauth_access_token:string oauth_refresh_token:string \
|
56
|
+
oauth_expires_at:string
|
57
|
+
```
|
58
|
+
|
59
|
+
and migrate:
|
60
|
+
|
61
|
+
```console
|
62
|
+
rake db:migrate
|
63
|
+
```
|
64
|
+
|
65
|
+
Also include `BookingSync::Engine::Account` in your `Account` model:
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
class Account < ActiveRecord::Base
|
69
|
+
include BookingSync::Engine::Model
|
70
|
+
end
|
17
71
|
```
|
18
|
-
|
72
|
+
|
73
|
+
### Secure controllers to require a BookingSync authorized account
|
74
|
+
|
75
|
+
We now want to provide secured controllers, this controllers will be accessible only to BookingSync identified accounts.
|
76
|
+
|
77
|
+
You have 2 options pre built for this:
|
78
|
+
|
79
|
+
1) Create base admin controller (it will be `json` based):
|
19
80
|
```
|
20
81
|
class Admin::BaseController < BookingsyncApplication::Admin::BaseController
|
21
82
|
end
|
22
83
|
```
|
23
|
-
|
84
|
+
|
85
|
+
2) Optionally if you want to have `html` based controller:
|
24
86
|
```
|
25
87
|
class Admin::BaseHTMLController < ApplicationController
|
26
88
|
respond_to :html
|
@@ -28,4 +90,47 @@ class Admin::BaseHTMLController < ApplicationController
|
|
28
90
|
include BookingsyncApplication::CommonBaseController
|
29
91
|
end
|
30
92
|
```
|
31
|
-
|
93
|
+
|
94
|
+
|
95
|
+
_Note: When saving new token, this gem uses a separate thread with new db connection to ensure token save (in case of a rollback in the main transaction). To make room for the new connections, it is recommended to increase db `pool` size by 2-3._
|
96
|
+
|
97
|
+
## Configuration
|
98
|
+
|
99
|
+
The engine is configured by the following ENV variables:
|
100
|
+
|
101
|
+
* `BOOKINGSYNC_URL` - the url of the website, should be
|
102
|
+
* `BOOKINGSYNC_APP_ID` - BookingSync Application's Client ID
|
103
|
+
* `BOOKINGSYNC_APP_SECRET` - BookingSync Application's Client Secret
|
104
|
+
* `BOOKINGSYNC_VERIFY_SSL` - Verify SSL (available only in development or test). Default to false
|
105
|
+
* `BOOKINGSYNC_SCOPE` - Space separated list of required scopes. Defaults to nil, which means the public scope.
|
106
|
+
|
107
|
+
You might want to use [dotenv-rails](https://github.com/bkeepers/dotenv)
|
108
|
+
to make ENV variables management easy.
|
109
|
+
|
110
|
+
## Testing
|
111
|
+
|
112
|
+
### RSpec
|
113
|
+
|
114
|
+
We do provide some helper for RSpec users, you can include them in your `spec/rails_helper.rb` (before `spec/support` inclusion):
|
115
|
+
```
|
116
|
+
require 'bookingsync_application/spec_helper'
|
117
|
+
```
|
118
|
+
|
119
|
+
### VCR
|
120
|
+
|
121
|
+
We recommend a VCR setup inspired from the following configuration. It will mask authorization tokens from your fixtures:
|
122
|
+
|
123
|
+
```ruby
|
124
|
+
require 'vcr'
|
125
|
+
|
126
|
+
VCR.configure do |config|
|
127
|
+
config.cassette_library_dir = 'spec/fixtures/cassettes'
|
128
|
+
config.hook_into :webmock
|
129
|
+
config.configure_rspec_metadata!
|
130
|
+
config.filter_sensitive_data('BOOKINGSYNC_OAUTH_ACCESS_TOKEN') do
|
131
|
+
ENV['BOOKINGSYNC_OAUTH_ACCESS_TOKEN']
|
132
|
+
end
|
133
|
+
# Uncomment if using codeclimate
|
134
|
+
# config.ignore_hosts 'codeclimate.com'
|
135
|
+
end
|
136
|
+
```
|
@@ -5,17 +5,3 @@ shared_examples_for :synced_model do
|
|
5
5
|
it { is_expected.to include Synced::HasSyncedData }
|
6
6
|
end
|
7
7
|
end
|
8
|
-
|
9
|
-
require 'vcr'
|
10
|
-
|
11
|
-
VCR.configure do |config|
|
12
|
-
config.cassette_library_dir = 'spec/fixtures/cassettes'
|
13
|
-
config.hook_into :webmock
|
14
|
-
config.configure_rspec_metadata!
|
15
|
-
config.filter_sensitive_data('Bearer <OAUTH_TOKEN>') do |interaction|
|
16
|
-
if interaction.request.headers['Authorization']
|
17
|
-
interaction.request.headers['Authorization'].first
|
18
|
-
end
|
19
|
-
end
|
20
|
-
config.ignore_hosts 'codeclimate.com'
|
21
|
-
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bookingsync_application
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcin Nowicki
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2015-05-
|
13
|
+
date: 2015-05-21 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -46,30 +46,30 @@ dependencies:
|
|
46
46
|
requirements:
|
47
47
|
- - "~>"
|
48
48
|
- !ruby/object:Gem::Version
|
49
|
-
version: 0.
|
49
|
+
version: 0.1.1
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
54
|
- - "~>"
|
55
55
|
- !ruby/object:Gem::Version
|
56
|
-
version: 0.
|
56
|
+
version: 0.1.1
|
57
57
|
- !ruby/object:Gem::Dependency
|
58
|
-
name:
|
58
|
+
name: synced
|
59
59
|
requirement: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
|
-
- - "
|
61
|
+
- - "~>"
|
62
62
|
- !ruby/object:Gem::Version
|
63
|
-
version:
|
63
|
+
version: 1.0.0
|
64
64
|
type: :runtime
|
65
65
|
prerelease: false
|
66
66
|
version_requirements: !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
|
-
- - "
|
68
|
+
- - "~>"
|
69
69
|
- !ruby/object:Gem::Version
|
70
|
-
version:
|
70
|
+
version: 1.0.0
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
|
-
name:
|
72
|
+
name: dotenv-rails
|
73
73
|
requirement: !ruby/object:Gem::Requirement
|
74
74
|
requirements:
|
75
75
|
- - ">="
|
@@ -83,13 +83,13 @@ dependencies:
|
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: '0'
|
85
85
|
- !ruby/object:Gem::Dependency
|
86
|
-
name:
|
86
|
+
name: appraisal
|
87
87
|
requirement: !ruby/object:Gem::Requirement
|
88
88
|
requirements:
|
89
89
|
- - ">="
|
90
90
|
- !ruby/object:Gem::Version
|
91
91
|
version: '0'
|
92
|
-
type: :
|
92
|
+
type: :development
|
93
93
|
prerelease: false
|
94
94
|
version_requirements: !ruby/object:Gem::Requirement
|
95
95
|
requirements:
|
@@ -97,13 +97,13 @@ dependencies:
|
|
97
97
|
- !ruby/object:Gem::Version
|
98
98
|
version: '0'
|
99
99
|
- !ruby/object:Gem::Dependency
|
100
|
-
name:
|
100
|
+
name: rspec-rails
|
101
101
|
requirement: !ruby/object:Gem::Requirement
|
102
102
|
requirements:
|
103
103
|
- - ">="
|
104
104
|
- !ruby/object:Gem::Version
|
105
105
|
version: '0'
|
106
|
-
type: :
|
106
|
+
type: :development
|
107
107
|
prerelease: false
|
108
108
|
version_requirements: !ruby/object:Gem::Requirement
|
109
109
|
requirements:
|
@@ -111,7 +111,7 @@ dependencies:
|
|
111
111
|
- !ruby/object:Gem::Version
|
112
112
|
version: '0'
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
|
-
name:
|
114
|
+
name: factory_girl_rails
|
115
115
|
requirement: !ruby/object:Gem::Requirement
|
116
116
|
requirements:
|
117
117
|
- - ">="
|