Skip to content
Browse files

Gem simplification

* Add a few Ruby version manager files to .gitignore. Remove Gemfile.lock.
* Use random test running for RSpec. Remove extraneous puts.
* Use secure RubyGems URL
* Update copyright year in LICENSE
* Add version file
* Cleanup authy.gemspec
* Simplify Rakefile
* Use double instead of mock as mock is deprecated in newer RSpec
  • Loading branch information...
1 parent 63b6bbc commit 6ee9f352e1b002eb0f9f28860e49f076db0d3dbe @czarneckid czarneckid committed Aug 7, 2013
Showing with 43 additions and 170 deletions.
  1. +6 −1 .gitignore
  2. +1 −0 .rspec
  3. +1 −1 Gemfile
  4. +0 −59 Gemfile.lock
  5. +1 −1 LICENSE.txt
  6. +4 −29 Rakefile
  7. +24 −75 authy.gemspec
  8. +1 −1 lib/authy.rb
  9. +1 −2 lib/authy/url_helpers.rb
  10. +3 −0 lib/authy/version.rb
  11. +1 −1 spec/authy/api_spec.rb
View
7 .gitignore
@@ -15,7 +15,7 @@ doc
# jeweler generated
pkg
-# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
+# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
#
# * Create a file at ~/.gitignore
# * Include files you want ignored
@@ -51,3 +51,8 @@ tmtags
*.kdev4
examples/db
+.ruby-version
+.ruby-gemset
+.rvmrc
+Gemfile.lock
+
View
1 .rspec
@@ -1 +1,2 @@
--color
+--order random
View
2 Gemfile
@@ -1,4 +1,4 @@
-source "http://rubygems.org"
+source "https://rubygems.org"
gem 'httpclient', ">= 2.2.6"
View
59 Gemfile.lock
@@ -1,59 +0,0 @@
-GEM
- remote: http://rubygems.org/
- specs:
- coderay (1.0.9)
- diff-lcs (1.2.4)
- git (1.2.5)
- httpclient (2.3.3)
- jeweler (1.8.4)
- bundler (~> 1.0)
- git (>= 1.2.5)
- rake
- rdoc
- json (1.8.0)
- method_source (0.8.1)
- multi_json (1.7.5)
- pry (0.9.12.2)
- coderay (~> 1.0.5)
- method_source (~> 0.8)
- slop (~> 3.4)
- rake (10.0.4)
- rdoc (4.0.1)
- json (~> 1.4)
- reek (1.3.1)
- ruby2ruby (~> 2.0.2)
- ruby_parser (~> 3.1.1)
- sexp_processor
- rspec (2.13.0)
- rspec-core (~> 2.13.0)
- rspec-expectations (~> 2.13.0)
- rspec-mocks (~> 2.13.0)
- rspec-core (2.13.1)
- rspec-expectations (2.13.0)
- diff-lcs (>= 1.1.3, < 2.0)
- rspec-mocks (2.13.1)
- ruby2ruby (2.0.5)
- ruby_parser (~> 3.1)
- sexp_processor (~> 4.0)
- ruby_parser (3.1.3)
- sexp_processor (~> 4.1)
- sexp_processor (4.2.1)
- simplecov (0.7.1)
- multi_json (~> 1.0)
- simplecov-html (~> 0.7.1)
- simplecov-html (0.7.1)
- slop (3.4.5)
- yard (0.8.6.1)
-
-PLATFORMS
- ruby
-
-DEPENDENCIES
- httpclient (>= 2.2.6)
- jeweler
- pry
- rdoc
- reek
- rspec
- simplecov
- yard
View
2 LICENSE.txt
@@ -1,4 +1,4 @@
-Copyright (c) 2012 David A. Cuadrado
+Copyright (c) 2012-2013 David A. Cuadrado
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
View
33 Rakefile
@@ -1,36 +1,14 @@
-# encoding: utf-8
-
-require 'rubygems'
-require 'bundler'
-begin
- Bundler.setup(:default, :development)
-rescue Bundler::BundlerError => e
- $stderr.puts e.message
- $stderr.puts "Run `bundle install` to install missing gems"
- exit e.status_code
-end
+require 'bundler/gem_tasks'
require 'rake'
-
-require 'jeweler'
-Jeweler::Tasks.new do |gem|
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
- gem.name = "authy"
- gem.homepage = "http://github.com/authy/authy"
- gem.license = "MIT"
- gem.summary = %Q{Ruby library to access Authy services}
- gem.description = %Q{Ruby library to access Authy services}
- gem.email = "krawek@gmail.com"
- gem.authors = ["Authy", "David A. Cuadrado"]
- # dependencies defined in Gemfile
-end
-Jeweler::RubygemsDotOrgTasks.new
-
require 'rspec/core'
require 'rspec/core/rake_task'
+
RSpec::Core::RakeTask.new(:spec) do |spec|
spec.pattern = FileList['spec/**/*_spec.rb']
end
+task :default => :spec
+
RSpec::Core::RakeTask.new(:rcov) do |spec|
spec.pattern = 'spec/**/*_spec.rb'
spec.rcov = true
@@ -43,8 +21,6 @@ Reek::Rake::Task.new do |t|
t.source_files = 'lib/**/*.rb'
end
-task :default => :spec
-
require 'yard'
YARD::Rake::YardocTask.new
@@ -53,4 +29,3 @@ task :simplecov do
ENV['COVERAGE'] = "true"
Rake::Task['spec'].execute
end
-
View
99 authy.gemspec
@@ -1,83 +1,32 @@
-# Generated by jeweler
-# DO NOT EDIT THIS FILE DIRECTLY
-# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-
+$:.push File.expand_path("../lib", __FILE__)
+
+require 'authy/version'
Gem::Specification.new do |s|
- s.name = "authy"
- s.version = "2.2.0"
+ s.name = "authy"
+ s.version = Authy::VERSION
+ s.authors = ["Authy", "David A. Cuadrado"]
+ s.email = ["krawek@gmail.com"]
+ s.homepage = "https://github.com/authy/authy"
+ s.summary = %q{Ruby library to access Authy services}
+ s.description = %q{Ruby library to access Authy services}
+ s.license = 'MIT'
+
+ s.rubyforge_project = "authy"
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
- s.authors = ["Authy", "David A. Cuadrado"]
- s.date = "2013-06-17"
- s.description = "Ruby library to access Authy services"
- s.email = "krawek@gmail.com"
- s.executables = ["authy-api-console"]
- s.extra_rdoc_files = [
- "LICENSE.txt",
- "README.md"
- ]
- s.files = [
- ".document",
- ".rspec",
- "Gemfile",
- "Gemfile.lock",
- "LICENSE.txt",
- "README.md",
- "Rakefile",
- "VERSION",
- "authy.gemspec",
- "bin/authy-api-console",
- "examples/demo.rb",
- "lib/authy.rb",
- "lib/authy/api.rb",
- "lib/authy/config.rb",
- "lib/authy/core_ext.rb",
- "lib/authy/models/user.rb",
- "lib/authy/response.rb",
- "lib/authy/url_helpers.rb",
- "spec/authy/api_spec.rb",
- "spec/authy/response_spec.rb",
- "spec/authy/url_helpers_spec.rb",
- "spec/spec_helper.rb"
- ]
- s.homepage = "http://github.com/authy/authy"
- s.licenses = ["MIT"]
+ 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"]
- s.rubygems_version = "1.8.24"
- s.summary = "Ruby library to access Authy services"
- if s.respond_to? :specification_version then
- s.specification_version = 3
+ s.add_dependency('httpclient', '>= 2.26')
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
- s.add_runtime_dependency(%q<httpclient>, [">= 2.2.6"])
- s.add_development_dependency(%q<rspec>, [">= 0"])
- s.add_development_dependency(%q<pry>, [">= 0"])
- s.add_development_dependency(%q<yard>, [">= 0"])
- s.add_development_dependency(%q<rdoc>, [">= 0"])
- s.add_development_dependency(%q<jeweler>, [">= 0"])
- s.add_development_dependency(%q<simplecov>, [">= 0"])
- s.add_development_dependency(%q<reek>, [">= 0"])
- else
- s.add_dependency(%q<httpclient>, [">= 2.2.6"])
- s.add_dependency(%q<rspec>, [">= 0"])
- s.add_dependency(%q<pry>, [">= 0"])
- s.add_dependency(%q<yard>, [">= 0"])
- s.add_dependency(%q<rdoc>, [">= 0"])
- s.add_dependency(%q<jeweler>, [">= 0"])
- s.add_dependency(%q<simplecov>, [">= 0"])
- s.add_dependency(%q<reek>, [">= 0"])
- end
- else
- s.add_dependency(%q<httpclient>, [">= 2.2.6"])
- s.add_dependency(%q<rspec>, [">= 0"])
- s.add_dependency(%q<pry>, [">= 0"])
- s.add_dependency(%q<yard>, [">= 0"])
- s.add_dependency(%q<rdoc>, [">= 0"])
- s.add_dependency(%q<jeweler>, [">= 0"])
- s.add_dependency(%q<simplecov>, [">= 0"])
- s.add_dependency(%q<reek>, [">= 0"])
- end
+ s.add_development_dependency('rake')
+ s.add_development_dependency('rspec')
+ s.add_development_dependency('pry')
+ s.add_development_dependency('yard')
+ s.add_development_dependency('rdoc')
+ s.add_development_dependency('simplecov')
+ s.add_development_dependency('reek')
end
-
View
2 lib/authy.rb
@@ -10,4 +10,4 @@
require 'authy/models/user'
require 'authy/config'
require 'authy/api'
-
+require 'authy/version'
View
3 lib/authy/url_helpers.rb
@@ -21,13 +21,12 @@ def validate_for_url(names, to_validate = {})
names.each do |name|
value = to_validate[name]
if value.nil? or value.to_s.empty? or value.to_s.split(" ").size == 0
- puts "#{name} param is blank."
return [ false, "#{name} is blank." ]
end
end
[ true, ""]
end
-
+
def escape_for_url(field)
URI.escape(field.to_s.strip, Regexp.new("[^#{URI::PATTERN::UNRESERVED}]"))
end
View
3 lib/authy/version.rb
@@ -0,0 +1,3 @@
+module Authy
+ VERSION = "2.2.0"
+end
View
2 spec/authy/api_spec.rb
@@ -71,7 +71,7 @@
it "should request a #{title} token" do
uri_param = kind == "phone_call" ? "call" : kind
url = "#{Authy.api_uri}/protected/json/#{uri_param}/#{Authy::API.escape_for_url(@user.id)}"
- HTTPClient.any_instance.should_receive(:request).with(:get, url, {:query=>{:api_key=> Authy.api_key}, :header=>nil, :follow_redirect=>nil}) { mock(:ok? => true, :body => "", :status => 200) }
+ HTTPClient.any_instance.should_receive(:request).with(:get, url, {:query=>{:api_key=> Authy.api_key}, :header=>nil, :follow_redirect=>nil}) { double(:ok? => true, :body => "", :status => 200) }
response = Authy::API.send("request_#{kind}", :id => @user.id)
response.should be_ok
end

0 comments on commit 6ee9f35

Please sign in to comment.
Something went wrong with that request. Please try again.