quokka 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bd9aa8d1139f22330ee6b422e9e9b48bd3f0f977
4
+ data.tar.gz: 7943be07a23d26ff4b368433918fb48bd1a24035
5
+ SHA512:
6
+ metadata.gz: 58a14e256b889eb5d18ef8bd8765e02dde05ecae5a7c9ae18b897022e2fa1af8a22352f1034ffd947645413df7c064b3db0001fb1d3a4daf711d59fc383b1f2d
7
+ data.tar.gz: 53b1ad917a95fa331f29c79430e97c9b41fca2e776a59a15fc7fbfde216b994953e619142c48ed60a5d28743ed48132dd4427b1ce4929547285e24d40b733fd0
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,5 @@
1
+ require: rubocop-rspec
2
+
3
+ Style/StringLiterals:
4
+ EnforcedStyle: double_quotes
5
+ Enabled: true
@@ -0,0 +1,8 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.3.1
5
+ before_install: gem install bundler -v 1.12.5
6
+ script:
7
+ - bundle exec rubocop
8
+ - bundle exec rspec
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at tom@tomkruijsen.nl. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in quokka.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Tom Kruijsen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,52 @@
1
+ # Quokka [![Build Status](https://travis-ci.org/tomkr/quokka.svg?branch=master)](https://travis-ci.org/tomkr/quokka)
2
+
3
+ Quokka provides tools to make logging in with Facebook from your server a breeze.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'quokka'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install quokka
20
+
21
+ ## Usage
22
+
23
+ The Facebook login flow has a couple of steps that Quokka can help you out with.
24
+
25
+ First you need to setup your app id and secret by specifying them in the env variables `FACEBOOK_APP_ID` and `FACEBOOK_SECRET`.
26
+
27
+ Next your web application will need to redirect to a dialog url created by:
28
+
29
+ Quokka.login_dialog_url(redirect_uri)
30
+
31
+ Facebook will redirect to your redirect uri with a `code` parameter. Pass this to `access_token` to get the required token.
32
+
33
+ access_token = Quokka.access_token(redirect_uri, code)
34
+
35
+ Now you can use the `access_token` you received to get user data from Facebook.
36
+
37
+ Quokka.user_data(access_token)
38
+
39
+ ## Development
40
+
41
+ After 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.
42
+
43
+ To 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).
44
+
45
+ ## Contributing
46
+
47
+ Bug reports and pull requests are welcome on GitHub at https://github.com/tomkr/quokka. 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.
48
+
49
+
50
+ ## License
51
+
52
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "quokka"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,80 @@
1
+ require "open-uri"
2
+ require "addressable/template"
3
+ require "quokka/version"
4
+
5
+ # Tools for logging in with Facebook
6
+ module Quokka
7
+ GRAPH_URI = Addressable::URI.parse(
8
+ "https://graph.facebook.com/v2.6/"
9
+ )
10
+ LOGIN_URI = Addressable::Template.new(
11
+ "https://www.facebook.com/dialog/oauth{?q*}"
12
+ )
13
+
14
+ module_function
15
+
16
+ # Constructs a url that will open a login dialog on Facebook that requests
17
+ # permission for your app.
18
+ #
19
+ # @param redirect_uri URI which Facebook will redirect to after login
20
+ #
21
+ # @return [String] URL to Facebook login dialog
22
+ def login_dialog_url(redirect_uri)
23
+ LOGIN_URI.expand(
24
+ q: {
25
+ client_id: ENV.fetch("FACEBOOK_APP_ID"),
26
+ redirect_uri: redirect_uri
27
+ }
28
+ ).to_s
29
+ end
30
+
31
+ # Gets the hash with access token data from Facebook, based on the
32
+ # redirect_uri used in the login dialog and the code that was returned from
33
+ # it.
34
+ #
35
+ # @param redirect_uri URI which Facebook redirected to after login
36
+ # @param code The code provided by Facebook
37
+ #
38
+ # @return [Hash] Hash with access token data from Facebook
39
+ def access_token_data(redirect_uri, code)
40
+ read_json_from_url(graph_url("oauth/access_token",
41
+ client_id: ENV.fetch("FACEBOOK_APP_ID"),
42
+ client_secret: ENV.fetch("FACEBOOK_SECRET"),
43
+ code: code,
44
+ redirect_uri: redirect_uri))
45
+ end
46
+
47
+ # Gets the hash with access token data from Facebook, based on the
48
+ # redirect_uri used in the login dialog and the code that was returned from
49
+ # it and returns only the access token itself.
50
+ #
51
+ # @param redirect_uri URI which Facebook redirected to after login
52
+ # @param code The code provided by Facebook
53
+ #
54
+ # @return [String] The access token data from Facebook
55
+ def access_token(redirect_uri, code)
56
+ access_token_data(redirect_uri, code)["access_token"]
57
+ end
58
+
59
+ # Gets a hash of data for the user logged in with the access token. This
60
+ # allows you to get the details of the logged in user for further usage.
61
+ #
62
+ # @param access_token The token provided by Facebook
63
+ #
64
+ # @return [Hash] The data for the logged in user
65
+ def user_data(access_token)
66
+ read_json_from_url(graph_url("me", access_token: access_token))
67
+ end
68
+
69
+ def graph_url(path, query)
70
+ uri = GRAPH_URI.join(path)
71
+ uri.query_values = query
72
+ uri.to_s
73
+ end
74
+ private_class_method :graph_url
75
+
76
+ def read_json_from_url(url)
77
+ JSON.parse(open(url).read)
78
+ end
79
+ private_class_method :read_json_from_url
80
+ end
@@ -0,0 +1,3 @@
1
+ module Quokka
2
+ VERSION = "0.1.0".freeze
3
+ end
@@ -0,0 +1,36 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "quokka/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "quokka"
8
+ spec.version = Quokka::VERSION
9
+ spec.authors = ["Tom Kruijsen"]
10
+ spec.email = ["tom@tomkruijsen.nl"]
11
+
12
+ spec.summary = "Tools for logging in with Facebook."
13
+ spec.description = <<-EOF
14
+ Quokka provides tools to make logging in with Facebook from your server a
15
+ breeze.
16
+ EOF
17
+ spec.homepage = "http://github.com/tomkr/quokka"
18
+ spec.license = "MIT"
19
+
20
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
21
+ f.match(%r{^(test|spec|features)/})
22
+ end
23
+ spec.bindir = "exe"
24
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
+ spec.require_paths = ["lib"]
26
+
27
+ spec.add_dependency "addressable", "~> 2.4"
28
+
29
+ spec.add_development_dependency "bundler", "~> 1.12"
30
+ spec.add_development_dependency "rake", "~> 10.0"
31
+ spec.add_development_dependency "rspec", "~> 3.0"
32
+ spec.add_development_dependency "rubocop-rspec", "~> 1.5"
33
+ spec.add_development_dependency "rubocop", "~> 0.40"
34
+ spec.add_development_dependency "simplecov", "~> 0.11"
35
+ spec.add_development_dependency "webmock", "~> 2.1"
36
+ end
metadata ADDED
@@ -0,0 +1,172 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: quokka
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Tom Kruijsen
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-06-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: addressable
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.4'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.4'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.12'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.12'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop-rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.5'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.5'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rubocop
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.40'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.40'
97
+ - !ruby/object:Gem::Dependency
98
+ name: simplecov
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.11'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '0.11'
111
+ - !ruby/object:Gem::Dependency
112
+ name: webmock
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '2.1'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '2.1'
125
+ description: |2
126
+ Quokka provides tools to make logging in with Facebook from your server a
127
+ breeze.
128
+ email:
129
+ - tom@tomkruijsen.nl
130
+ executables: []
131
+ extensions: []
132
+ extra_rdoc_files: []
133
+ files:
134
+ - ".gitignore"
135
+ - ".rspec"
136
+ - ".rubocop.yml"
137
+ - ".travis.yml"
138
+ - CODE_OF_CONDUCT.md
139
+ - Gemfile
140
+ - LICENSE.txt
141
+ - README.md
142
+ - Rakefile
143
+ - bin/console
144
+ - bin/setup
145
+ - lib/quokka.rb
146
+ - lib/quokka/version.rb
147
+ - quokka.gemspec
148
+ homepage: http://github.com/tomkr/quokka
149
+ licenses:
150
+ - MIT
151
+ metadata: {}
152
+ post_install_message:
153
+ rdoc_options: []
154
+ require_paths:
155
+ - lib
156
+ required_ruby_version: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ required_rubygems_version: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ requirements: []
167
+ rubyforge_project:
168
+ rubygems_version: 2.5.1
169
+ signing_key:
170
+ specification_version: 4
171
+ summary: Tools for logging in with Facebook.
172
+ test_files: []