Skip to content

Commit

Permalink
Added Rubocop conformity
Browse files Browse the repository at this point in the history
  • Loading branch information
samdunne committed May 11, 2014
1 parent 3accda9 commit a3fb58f
Show file tree
Hide file tree
Showing 12 changed files with 229 additions and 94 deletions.
82 changes: 82 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
AllCops:
Includes:
- 'Gemfile'
- 'Rakefile'
- 'omniauth-gplus.gemspec'

# Avoid long parameter lists
ParameterLists:
Max: 5
CountKeywordArgs: true

MethodLength:
CountComments: false
Max: 18

# Avoid more than `Max` levels of nesting.
BlockNesting:
Max: 2

# Align with the style guide.
CollectionMethods:
PreferredMethods:
map: 'collect'
reduce: 'inject'
find: 'detect'
find_all: 'select'

# Do not force public/protected/private keyword to be indented at the same
# level as the def keyword. My personal preference is to outdent these keywords
# because I think when scanning code it makes it easier to identify the
# sections of code and visually separate them. When the keyword is at the same
# level I think it sort of blends in with the def keywords and makes it harder
# to scan the code and see where the sections are.
AccessModifierIndentation:
Enabled: false

# Limit line length
LineLength:
Enabled: false

# Disable documentation checking until a class needs to be documented once
Documentation:
Enabled: false

# Enforce Ruby 1.8-compatible hash syntax
HashSyntax:
EnforcedStyle: hash_rockets

# No spaces inside hash literals
SpaceInsideHashLiteralBraces:
EnforcedStyle: no_space

# Allow dots at the end of lines
DotPosition:
Enabled: false

# Don't require magic comment at the top of every file
Encoding:
Enabled: false

# Enforce outdenting of access modifiers (i.e. public, private, protected)
AccessModifierIndentation:
EnforcedStyle: outdent

EmptyLinesAroundAccessModifier:
Enabled: true

# Align ends correctly
EndAlignment:
AlignWith: variable

# Indentation of when/else
CaseIndentation:
IndentWhenRelativeTo: end
IndentOneStep: false

Lambda:
Enabled: false

FileName:
Exclude:
- 'lib/omniauth-gplus.rb'
16 changes: 15 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,26 @@ before_install:
- bundle --version
- gem update --system 2.1.11
- gem --version
language: ruby
rvm:
- 1.9.2
- 1.9.3
- 2.0.0
- 2.1
- jruby
- rbx
- rbx-2
- ruby-head
matrix:
include:
- rvm: jruby-18mode
env: JRUBY_OPTS="$JRUBY_OPTS --debug"
- rvm: jruby-19mode
env: JRUBY_OPTS="$JRUBY_OPTS --debug"
- rvm: jruby-head
env: JRUBY_OPTS="$JRUBY_OPTS --debug"
allow_failures:
- rvm: rbx
- rvm: jruby-head
- rvm: ruby-head
- rvm: rbx
fast_finish: true
85 changes: 35 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,27 @@ omniauth-gplus
It allows you to easily interact with the Google+ OAuth2 endpoint.


Installing
----------

**Requirements**:
A GPlus API key/secret

You can either install manually:

``` bash
$ gem install omniauth-gplus
```

Or put it in your `Gemfile`:

``` ruby
source 'https://rubygems.org'

gem 'omniauth-gplus', '~> 2.0'
```


Examples
--------

Expand Down Expand Up @@ -55,6 +76,11 @@ provider :gplus, ENV['GPLUS_KEY'], ENV['GPLUS_SECRET'], scope: 'plus.login', req

To see and learn about all of the available App Activity types, visit: https://developers.google.com/+/api/moment-types/

To get a refresh token please pass the following:

```ruby
provider :gplus, ENV['GPLUS_KEY'], ENV['GPLUS_SECRET'], scope: 'plus.login', request_visible_actions: 'AddActivity,BuyActivity', access_type: 'offline'
```

The information schema looks like this:

Expand Down Expand Up @@ -82,56 +108,15 @@ extra do
end
```


Installing
----------

**Requirements**:

1. Ruby 2.1, 2.0, 1.9 OR Rubinius 1.9 OR JRuby 1.9
2. A GPlus API key/secret

You can either install manually:

``` bash
$ gem install omniauth-gplus
```

Or put it in your `Gemfile`:

``` ruby
source 'https://rubygems.org'

gem 'omniauth-gplus', '~> 2.0'
```


Issues & Documentation
----------------------

* [Documentation](https://github.com/samdunne/omniauth-gplus/wiki)
* [Issues](https://github.com/samdunne/omniauth-gplus/issues)

Absolutely feel free to contribute, please!


Contributing
------------

* **Fork** the repository
* **Clone the repository** locally, or **edit via Github**
* Create a **new branch** using the [Git Flow Standard](http://yakiloo.com/getting-started-git-flow/) conventions
* Commit **often** and **when important**
* **DO NOT CHANGE** ANY OF THESE (without making a new branch for *that* change):
* `*.gemspec`
* `Rakefile`
* `.ruby-version`
* `.ruby-gemset`
* `.gitignore`
* Any part of the git history
* **Write tests** specifically for the changes you've made, if no test exist
* **Push** your feature or hotfix branch to Github.
* Make a **Pull Request**
Supported Rubies
----------------
Actively tested with the following Ruby versions:
- MRI 2.1.0
- MRI 2.0.0
- MRI 1.9.3
- MRI 1.9.2
- JRuby 1.7.9
- Rubinius (latest stable)


License
Expand Down
19 changes: 13 additions & 6 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,31 @@ begin
Bundler.setup :default, :development
rescue Bundler::BundlerError => error
$stderr.puts error.message
$stderr.puts "Run `bundle install` to install missing gems"
$stderr.puts 'Run `bundle install` to install missing gems.'
exit error.status_code
end

Bundler::GemHelper.install_tasks

desc "Run all of the tests"
desc 'Run all of the tests'
Rake::TestTask.new do |config|
config.libs << 'test'
config.pattern = 'test/**/*_test*'
# config.verbose = true
# config.warning = true
end

desc "Generate all of the docs"
desc 'Generate all of the docs'
YARD::Rake::YardocTask.new do |config|
config.files = Dir['lib/**/*.rb']
end

begin
require 'rubocop/rake_task'
Rubocop::RakeTask.new
rescue LoadError
task :rubocop do
$stderr.puts 'Rubocop is disabled'
end
end

desc 'Default: run tests, and generate docs'
task :default => [ :test, :yard ]
task default: [:test, :yard, :rubocop]
7 changes: 2 additions & 5 deletions lib/omniauth-gplus.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
require "omniauth-oauth2"
require_relative "omniauth/strategies/gplus"
require_relative "omniauth/gplus/version"

OmniAuth.config.add_camelization("gplus", "GPlus")
require 'omniauth/gplus'
OmniAuth.config.add_camelization('gplus', 'GPlus')
2 changes: 2 additions & 0 deletions lib/omniauth/gplus.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require 'omniauth/gplus/version'
require 'omniauth/strategies/gplus'
2 changes: 1 addition & 1 deletion lib/omniauth/gplus/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module OmniAuth
module GPlus
VERSION = "2.0.0.beta1"
VERSION = '2.0.0.beta1'
end
end
9 changes: 7 additions & 2 deletions lib/omniauth/strategies/gplus.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
require 'omniauth/strategies/oauth2'

module OmniAuth
module Strategies
class GPlus < OAuth2
class GPlus < OmniAuth::Strategies::OAuth2
class NoAuthorizationCodeError < StandardError; end
class UnknownSignatureAlgorithmError < NotImplementedError; end

option :client_options, {
site: 'https://www.googleapis.com/oauth2/v1',
authorize_url: 'https://www.google.com/accounts/o8/oauth2/authorization',
Expand Down Expand Up @@ -70,7 +75,7 @@ def format_scope(scope)
end

def custom_parameters(params)
["scope", "client_options", "request_visible_actions"].each { |k| add_key_to_params(params, k) }
["scope", "client_options", "request_visible_actions", "access_type"].each { |k| add_key_to_params(params, k) }
end

def add_key_to_params(params, key)
Expand Down
54 changes: 28 additions & 26 deletions omniauth-gplus.gemspec
Original file line number Diff line number Diff line change
@@ -1,34 +1,36 @@
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
# -*- encoding: utf-8 -*-
$:.push File.expand_path('../lib', __FILE__)
require 'omniauth/gplus/version'

Gem::Specification.new do |spec|
spec.name = "omniauth-gplus"
spec.version = OmniAuth::GPlus::VERSION
spec.authors = ["Kurtis Rainbolt-Greene", "Sam Dunne"]
spec.email = ["me@kurtisrainboltgreene.name", "sam@sam-dunne.com"]
spec.summary = %q{A Google+ OAuth2 solution for Omniauth}
spec.description = spec.summary
spec.homepage = "http://samdunne.github.com/omniauth-gplus"
spec.license = "MIT"
Gem::Specification.new do |s|
s.name = 'omniauth-gplus'
s.version = OmniAuth::GPlus::VERSION
s.authors = %w(Kurtis Rainbolt-Greene Sam Dunne)
s.email = %w(me@kurtisrainboltgreene.name sam@sam-dunne.com)
s.summary = 'A Google+ OAuth2 solution for Omniauth'
s.description = s.summary
s.homepage = 'http://samdunne.github.com/omniauth-gplus'
s.license = 'MIT'

spec.files = `git ls-files`.split($/)
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
s.require_paths = ['lib']

spec.add_runtime_dependency "omniauth-oauth2", '~> 1.1'
spec.add_development_dependency "bundler"
spec.add_development_dependency "rake"
spec.add_development_dependency "mocha"
spec.add_development_dependency 'yard'
spec.add_development_dependency 'kramdown'
spec.add_development_dependency 'pry'
spec.add_development_dependency 'coveralls'
s.add_runtime_dependency 'omniauth-oauth2', '~> 1.1'

s.add_development_dependency 'bundler'
s.add_development_dependency 'rake'
s.add_development_dependency 'mocha'
s.add_development_dependency 'yard'
s.add_development_dependency 'kramdown'
s.add_development_dependency 'pry'
s.add_development_dependency 'coveralls'
s.add_development_dependency 'rubocop'

if RUBY_PLATFORM == 'rbx'
spec.add_development_dependency 'racc'
spec.add_development_dependency 'rubinius-coverage', github: 'rubinius/rubinius-coverage'
spec.add_development_dependency 'rubysl'
s.add_development_dependency 'racc'
s.add_development_dependency 'rubinius-coverage', github: 'rubinius/rubinius-coverage'
s.add_development_dependency 'rubysl'
end
end
Loading

0 comments on commit a3fb58f

Please sign in to comment.