source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | BattleBrisket/finishing_moves | https://github.com/BattleBrisket/finishing_moves | Vagrantfile | Ruby | mit | 206 | master | 1,323 | # -*- mode: ruby -*-
# vi: set ft=ruby :
NAME = "finishing-moves"
FQDN = "#{NAME}.example.com"
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/jammy64"
# Use the normal insecure key
# https://github.com/mitchellh/vagrant/issues/2608
config.ssh.insert_key = false
config.vm.provider :virtualbox d... |
github | BattleBrisket/finishing_moves | https://github.com/BattleBrisket/finishing_moves | Rakefile | Ruby | mit | 206 | master | 735 | desc "Open an irb session preloaded with this library"
task :console do
sh "irb -I lib -r finishing_moves.rb"
end
task :c => :console
namespace :gem do
desc "Connect to RubyGems.org account"
task :auth do
sh "mkdir ~/.gem"
sh "curl -u battlebrisket https://rubygems.org/api/v1/api_key.yaml > ~/.gem/creden... |
github | BattleBrisket/finishing_moves | https://github.com/BattleBrisket/finishing_moves | finishing_moves.gemspec | Ruby | mit | 206 | master | 1,212 | $:.push File.expand_path("../lib", __FILE__)
require "finishing_moves/version"
Gem::Specification.new do |s|
s.name = "finishing_moves"
s.version = FinishingMoves::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Frank Koehl"]
s.email = ["battlebrisket@outlook.com"]
s.summar... |
github | BattleBrisket/finishing_moves | https://github.com/BattleBrisket/finishing_moves | spec/object_spec.rb | Ruby | mit | 206 | master | 4,723 | require 'spec_helper'
describe Object do
it "#not_nil?" do
var = nil
expect(var.not_nil?).to eq false
var = 'foobar'
expect(var.not_nil?).to eq true
end
it "#same_as" do
expect(:symbol.same_as 'symbol').to eq true
expect('symbol'.same_as :symbol).to eq true
expect('1'.same_as 1).to ... |
github | BattleBrisket/finishing_moves | https://github.com/BattleBrisket/finishing_moves | spec/enumerable_spec.rb | Ruby | mit | 206 | master | 1,075 | require 'spec_helper'
describe Enumerable do
let :test_array do
[
{:foo => 1, :bar => 5, :baz => 9},
{:foo => 2, :bar => 6, :baz => 10},
{:foo => 3, :bar => 7, :baz => 11},
{:foo => 4, :bar => 8, :baz => 12},
]
end
it "#key_map" do
expect(test_array.key_map :foo).to eq([1, ... |
github | BattleBrisket/finishing_moves | https://github.com/BattleBrisket/finishing_moves | spec/hash_spec.rb | Ruby | mit | 206 | master | 2,590 | require 'spec_helper'
describe Hash do
let :test_hash do
{ :foo => :bar, :baz => :bin, :flo => :bie }
end
it "#delete!" do
expect(test_hash.delete!(:bogus)).to eq({ :foo => :bar, :baz => :bin, :flo => :bie })
expect(test_hash.delete!(:baz)).to eq({ :foo => :bar, :flo => :bie })
end
it "#delete... |
github | BattleBrisket/finishing_moves | https://github.com/BattleBrisket/finishing_moves | spec/string_spec.rb | Ruby | mit | 206 | master | 9,549 | require 'spec_helper'
describe String do
it '#dedupe' do
expect('___foo___'.dedupe('_')).to eq '_foo_'
expect('---foo---'.dedupe('-')).to eq '-foo-'
expect('___foo---'.dedupe('_-')).to eq '_foo-'
expect('___foo__bar_baz--bing'.dedupe('_')).to eq '_foo_bar_baz--bing'
expect('foo'.dedupe('o')).to ... |
github | BattleBrisket/finishing_moves | https://github.com/BattleBrisket/finishing_moves | spec/numeric_spec.rb | Ruby | mit | 206 | master | 3,217 | require 'spec_helper'
describe "Numeric methods" do
it "Integer#length" do
expect(1.length).to eq 1
expect(5.length).to eq 1
expect(9.length).to eq 1
expect(90.length).to eq 2
expect(900.length).to eq 3
expect(9000.length).to eq 4
expect(-9000.length).to eq 4
expect(12356469787881584... |
github | BattleBrisket/finishing_moves | https://github.com/BattleBrisket/finishing_moves | spec/fiscal_logic_spec.rb | Ruby | mit | 206 | master | 11,307 | require 'spec_helper'
describe FinishingMovesFiscalLogic do
let(:default_quarters) { [[1,2,3], [4,5,6], [7,8,9], [10,11,12]] }
before(:example) do
@jan01 = Time.new(2015, 1)
end
it "is included into Time, Date, and DateTime" do
expect(Time.method_defined? :fiscal_start).to be true
expect(Date.me... |
github | BattleBrisket/finishing_moves | https://github.com/BattleBrisket/finishing_moves | spec/spec_helper.rb | Ruby | mit | 206 | master | 4,451 | require 'rubygems'
require 'bundler/setup'
Bundler.setup
require 'coveralls'
Coveralls.wear!
require 'finishing_moves'
# This file was generated by the `rspec --init` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# The generated `.rspec` file contains `--r... |
github | BattleBrisket/finishing_moves | https://github.com/BattleBrisket/finishing_moves | spec/kernel_spec.rb | Ruby | mit | 206 | master | 4,459 | require 'spec_helper'
describe Kernel do
it "#nil_chain" do
expect(nil_chain{bogus_variable}).to eq nil
expect(nil_chain{bogus_hash[:foo]}).to eq nil
params = { :foo => 'bar' }
expect(nil_chain{ params[:bogus_key] }).to eq nil
expect(nil_chain{ params[:foo] }).to eq 'bar'
var = 'a simple str... |
github | BattleBrisket/finishing_moves | https://github.com/BattleBrisket/finishing_moves | spec/to_bool_spec.rb | Ruby | mit | 206 | master | 1,728 | require 'spec_helper'
describe "Boolean typecasting" do
it "String#to_bool" do
data = {
true => %w(1 true t yes y on TRUE T YES Y ON tRUe),
false => %w(0 false f no n off FALSE F NO N OFF fALsE),
}
data.each do |truth, strings|
strings.each { |str| expect(str.to_bool).to eq truth }
... |
github | BattleBrisket/finishing_moves | https://github.com/BattleBrisket/finishing_moves | spec/array_spec.rb | Ruby | mit | 206 | master | 3,695 | require 'spec_helper'
describe Array do
let :sages do
['Rauru', 'Saria', 'Darunia', 'Princess Ruto', 'Impa', 'Nabooru', 'Zelda']
end
it '#to_indexed_hash' do
expect { sages.to_indexed_hash("e") }.to raise_error(ArgumentError)
sages_hash = sages.to_indexed_hash
i = 0
sages.each do |sage|
... |
github | BattleBrisket/finishing_moves | https://github.com/BattleBrisket/finishing_moves | lib/finishing_moves/kernel.rb | Ruby | mit | 206 | master | 746 | module Kernel
def nil_chain(ret_val = nil, &block)
begin
result = yield
return ret_val if result.nil?
result
rescue NoMethodError, NameError
return ret_val
end
end
alias_method :method_chain, :nil_chain
def bool_chain(&block)
result = nil_chain(&block)
return false ... |
github | BattleBrisket/finishing_moves | https://github.com/BattleBrisket/finishing_moves | lib/finishing_moves/array.rb | Ruby | mit | 206 | master | 1,116 | class Array
def to_hash_values(starting_key = 0, &block)
key = starting_key
block = proc { |key| key + 1 } unless block_given?
t = {}
each do |entry|
t[key] = entry
key = block.call key
end
t
end
alias_method :to_hash_as_values, :to_hash_values
def to_indexed_hash(starting_... |
github | BattleBrisket/finishing_moves | https://github.com/BattleBrisket/finishing_moves | lib/finishing_moves/hash.rb | Ruby | mit | 206 | master | 1,257 | class Hash
# When deleting a value from a hash, return the remaining hash, instead of the deleted value
def delete!(key)
self.delete(key)
return self
end
# Delete all records according to the keys passed in as an array, and return a hash of deleted
# entries. Silently ignores any keys which are not ... |
github | BattleBrisket/finishing_moves | https://github.com/BattleBrisket/finishing_moves | lib/finishing_moves/numeric.rb | Ruby | mit | 206 | master | 470 | class Numeric
def length
raise ArgumentError.new("Cannot get length: \"#{self}\" is not an integer")
end
def subtract_percent(percent)
self.to_f * ( ( 100.0 - percent.to_f ) / 100.0 )
end
alias_method :percentage_off, :subtract_percent
def add_percent(percent)
self.to_f + ( self.to_f * ( perce... |
github | BattleBrisket/finishing_moves | https://github.com/BattleBrisket/finishing_moves | lib/finishing_moves/to_bool.rb | Ruby | mit | 206 | master | 734 | class String
def to_bool
return true if self == true || self =~ (/^(1|t(rue)?|y(es)?|on)$/i)
return false if self == false || self == "" || self =~ /\A[[:space:]]*\z/ || self =~ (/^(0|f(alse)?|no?|off)$/i)
raise ArgumentError.new("invalid value for Boolean: \"#{self}\"")
end
end
class Integer
def to_... |
github | BattleBrisket/finishing_moves | https://github.com/BattleBrisket/finishing_moves | lib/finishing_moves/fiscal_logic.rb | Ruby | mit | 206 | master | 3,045 | require 'date'
module FinishingMovesFiscalLogic
def fiscal_start
@fiscal_start = 1 if @fiscal_start.nil?
@fiscal_start
end
def fiscal_start=(month)
@fiscal_start = Integer(month)
end
def fiscal_quarter
((( self.month + ( 12 - fiscal_start ) ) / 3 ) % 4 ) + 1
end
def all_quarter_months... |
github | BattleBrisket/finishing_moves | https://github.com/BattleBrisket/finishing_moves | lib/finishing_moves/string.rb | Ruby | mit | 206 | master | 4,367 | class String
def nl2br
gsub _nl_gsub_regex, "<br />\n"
end
def newline_to(rep = ' ')
gsub _nl_gsub_regex, rep.to_s
end
def newline_to!(rep = ' ')
gsub! _nl_gsub_regex, rep.to_s
end
def keyify
_prep_key_or_slug(true)
end
def keyify!
result = _prep_key_or_slug(true)
raise Ar... |
github | BattleBrisket/finishing_moves | https://github.com/BattleBrisket/finishing_moves | lib/finishing_moves/object.rb | Ruby | mit | 206 | master | 1,450 | class Object
def not_nil?
!self.nil?
end
alias_method :is_an?, :is_a?
def is_not_a?(compare)
!is_a? compare
end
alias_method :is_not_an?, :is_not_a?
def same_as(compare)
self.to_s == compare.to_s
end
alias_method :same_as?, :same_as
# Allows us to call keyify directly on a class nam... |
github | BattleBrisket/finishing_moves | https://github.com/BattleBrisket/finishing_moves | lib/finishing_moves/enumerable.rb | Ruby | mit | 206 | master | 385 | module Enumerable
def key_map(key)
map { |h| h[key] }
end
def key_map_reduce(key, arg = :+, &block)
if block_given?
# arg is the initial value of memo
key_map(key).reduce(arg, &block)
else
# arg is a named method
raise ArgumentError.new "arg must be a method symbol" unless ar... |
github | gdotdesign/elm-github-install | https://github.com/gdotdesign/elm-github-install | Gemfile | Ruby | mit | 207 | master | 245 | source 'https://rubygems.org'
gemspec
gem 'codeclimate-test-reporter', '~> 1.0.0'
gem 'inch', '~> 0.7.1'
gem 'rake', '~> 12.0'
gem 'rspec', '~> 3.5'
gem 'rubocop', '~> 0.46.0'
gem 'rubycritic', '~> 3.1', '>= 3.1.3'
gem 'simplecov', '~> 0.12.0' |
github | gdotdesign/elm-github-install | https://github.com/gdotdesign/elm-github-install | elm_install.gemspec | Ruby | mit | 207 | master | 1,078 | require File.expand_path('../lib/elm_install/version', __FILE__)
Gem::Specification.new do |s|
s.name = 'elm_install'
s.version = ElmInstall::VERSION
s.authors = ['Gusztáv Szikszai']
s.email = 'gusztav.szikszai@digitalnatives.hu'
s.homepage = 'https://github.com/gdotdesign/e... |
github | gdotdesign/elm-github-install | https://github.com/gdotdesign/elm-github-install | packaging/Rakefile | Ruby | mit | 207 | master | 3,288 | # For Bundler.with_clean_env
require 'bundler/setup'
require_relative '../lib/elm_install'
PACKAGE_NAME = 'elm-install'.freeze
VERSION = ElmInstall::VERSION
TRAVELING_RUBY_VERSION = '20150715-2.2.2'.freeze
desc 'Package your app'
task package: ['package:linux:x86', 'package:linux:x86_64', 'package:osx', 'package:win3... |
github | gdotdesign/elm-github-install | https://github.com/gdotdesign/elm-github-install | spec/spec_helper.rb | Ruby | mit | 207 | master | 506 | require 'simplecov'
CACHE_DIRECTORY = 'spec/cache'.freeze
RSpec.configure do |config|
config.before do
allow(Process).to receive(:abort)
allow(ElmInstall::Logger).to receive(:puts)
ElmInstall::Repository.class_variable_set('@@fetched', {})
FileUtils.mkdir_p CACHE_DIRECTORY
end
config.after do
... |
github | gdotdesign/elm-github-install | https://github.com/gdotdesign/elm-github-install | spec/git_source_spec.rb | Ruby | mit | 207 | master | 3,507 | describe ElmInstall::GitSource do
subject { described_class.new uri, branch }
let(:uri) do
ElmInstall::Uri::Ssh(GitCloneUrl.parse('git@github.com:test/repo'))
end
let(:branch) do
ElmInstall::Branch::Nothing()
end
before do
subject.options = { cache_directory: CACHE_DIRECTORY }
allow(repos... |
github | gdotdesign/elm-github-install | https://github.com/gdotdesign/elm-github-install | spec/utils_spec.rb | Ruby | mit | 207 | master | 737 | describe ElmInstall::Utils do
subject { described_class }
let(:package_variations) do
[
'https://github.com/test/repo',
'git://github.com/test/repo',
'git@github.com:test/repo'
]
end
describe '.transform_constraint' do
it 'should convert basic constraint' do
expect(subject.... |
github | gdotdesign/elm-github-install | https://github.com/gdotdesign/elm-github-install | spec/directory_source_spec.rb | Ruby | mit | 207 | master | 872 | describe ElmInstall::DirectorySource do
let(:dir) { Pathname.new('.') }
subject { described_class.new dir }
describe '#fetch' do
it 'returns the directory' do
expect(subject.fetch('').path).to eq dir.expand_path.to_s
end
end
describe '#copy_to' do
it 'symlinks the directory' do
allo... |
github | gdotdesign/elm-github-install | https://github.com/gdotdesign/elm-github-install | spec/elm_install_spec.rb | Ruby | mit | 207 | master | 257 | describe ElmInstall do
it 'should install packages' do
allow(ElmInstall::Logger)
.to receive(:arrow)
expect_any_instance_of(ElmInstall::Installer)
.to receive(:install)
subject.install(cache_directory: CACHE_DIRECTORY)
end
end |
github | gdotdesign/elm-github-install | https://github.com/gdotdesign/elm-github-install | spec/repository_spec.rb | Ruby | mit | 207 | master | 994 | describe ElmInstall::Repository do
subject { described_class.new '', '.' }
describe '#clone' do
it 'clones the repository' do
expect(FileUtils)
.to receive(:mkdir_p)
expect(Git)
.to receive(:clone)
.with('', '.')
.and_return(Git::Base.new)
subject.clone
e... |
github | gdotdesign/elm-github-install | https://github.com/gdotdesign/elm-github-install | spec/installer_spec.rb | Ruby | mit | 207 | master | 2,462 | describe ElmInstall::Installer do
subject { described_class.new cache_directory: CACHE_DIRECTORY }
let(:main_package) do
{
dependencies:
{
'base/core' => '1.0.0 <= v < 2.0.0',
'base/uri' => '1.0.0 <= v < 2.0.0',
'base/ssh' => '1.0.0 <= v < 2.0.0'
},
'de... |
github | gdotdesign/elm-github-install | https://github.com/gdotdesign/elm-github-install | spec/identifer_spec.rb | Ruby | mit | 207 | master | 1,084 | describe ElmInstall::Identifier do
subject { described_class.new Dir.new('.') }
let(:package_json) do
{
'dependencies' =>
{
'test/test' => '1.0.0 <= v < 2.0.0',
'test/ref' => '1.0.0 <= v < 2.0.0',
'test/dir' => '1.0.0 <= v < 2.0.0'
},
'dependency-sources' =>
... |
github | gdotdesign/elm-github-install | https://github.com/gdotdesign/elm-github-install | lib/elm_install.rb | Ruby | mit | 207 | master | 1,130 | require 'smart_colored/extend'
require 'git_clone_url'
require 'forwardable'
require 'indentation'
require 'fileutils'
require 'contracts'
require 'json'
require 'adts'
require 'git'
require 'solve/constraint'
require 'solve'
require_relative './elm_install/version'
require_relative './elm_install/utils'
require_rela... |
github | gdotdesign/elm-github-install | https://github.com/gdotdesign/elm-github-install | lib/elm_install/git_source.rb | Ruby | mit | 207 | master | 5,064 | module ElmInstall
# Git Source
class GitSource < Source
# @return [Uri] The uri
attr_reader :uri
# @return [Branch] The branch
attr_reader :branch
Contract Uri, Branch => GitSource
# Initializes a git source by URI and branch
#
# @param uri [Uri] The uri
# @param branch [Branch... |
github | gdotdesign/elm-github-install | https://github.com/gdotdesign/elm-github-install | lib/elm_install/utils.rb | Ruby | mit | 207 | master | 896 | module ElmInstall
# This module contains utility functions.
module Utils
include Contracts::Core
include Contracts::Builtin
module_function
# Regexes for converting constraints.
CONVERTERS = {
/v<(?!=)(.*)/ => '<',
/(.*)<=v/ => '>=',
/v<=(.*)/ => '<=',
/(.*)<v/ => '>'
... |
github | gdotdesign/elm-github-install | https://github.com/gdotdesign/elm-github-install | lib/elm_install/directory_source.rb | Ruby | mit | 207 | master | 1,714 | module ElmInstall
# This clas handles sources that point to a local directory.
class DirectorySource < Source
# @return [Dir] The directory
attr_reader :dir
Contract Pathname => DirectorySource
# Initializes a directory source with the given directory.
#
# @param dir [Dir] The directory
... |
github | gdotdesign/elm-github-install | https://github.com/gdotdesign/elm-github-install | lib/elm_install/installer.rb | Ruby | mit | 207 | master | 1,793 | module ElmInstall
# Installer class
class Installer < Base
Contract KeywordArgs[cache_directory: Or[String, NilClass],
skip_update: Or[Bool, NilClass],
only_update: Or[String, NilClass],
verbose: Or[Bool, NilClass]] => Installer
# In... |
github | gdotdesign/elm-github-install | https://github.com/gdotdesign/elm-github-install | lib/elm_install/resolver.rb | Ruby | mit | 207 | master | 2,092 | module ElmInstall
# Resolves dependencies
class Resolver < Base
# @return [Array<Dependency>] The dependencies
attr_reader :dependencies
Contract Identifier, Hash => Resolver
# Initializes a resolver
#
# @param identifier [Identifier] The identifier
# @param options [Hash] The options
... |
github | gdotdesign/elm-github-install | https://github.com/gdotdesign/elm-github-install | lib/elm_install/logger.rb | Ruby | mit | 207 | master | 513 | module ElmInstall
# This is a helper module for logging.
module Logger
# :nocov:
# Logs the given message prefixed a green dot.
#
# @param message [String] The message to log
#
# @return [void]
def self.dot(message)
puts ' ● '.green + message
end
# Logs the given message ... |
github | gdotdesign/elm-github-install | https://github.com/gdotdesign/elm-github-install | lib/elm_install/source.rb | Ruby | mit | 207 | master | 467 | module ElmInstall
# Abstract class for a source
class Source < Base
# @overload identifier
# @return [Identifier] The identifier
# @overload identifier=(value)
# Sets the identifier
# @param [Identifier] The identifier
attr_accessor :identifier
# @overload options
# @return ... |
github | gdotdesign/elm-github-install | https://github.com/gdotdesign/elm-github-install | lib/elm_install/identifier.rb | Ruby | mit | 207 | master | 4,220 | module ElmInstall
# Identifies dependencies
class Identifier < Base
# @return [Array<Dependency>] The initial dependencies
attr_reader :initial_dependencies
# @return [Hash] The options
attr_reader :options
# @return [String] The initial Elm version
attr_reader :initial_elm_version
Co... |
github | gdotdesign/elm-github-install | https://github.com/gdotdesign/elm-github-install | lib/elm_install/dependency.rb | Ruby | mit | 207 | master | 1,019 | module ElmInstall
# Represents a dependency
class Dependency < Base
extend Forwardable
# @return [Array] The constraints for the dependency
attr_reader :constraints
# @overload version
# @return [Semverse::Version] The version
# @overload version=(value)
# Sets the version
# ... |
github | gdotdesign/elm-github-install | https://github.com/gdotdesign/elm-github-install | lib/elm_install/populator.rb | Ruby | mit | 207 | master | 2,055 | module ElmInstall
# Populator for 'elm-stuff' directory
class Populator < Base
Contract ArrayOf[Dependency] => Populator
# Initializes a new populator
#
# @param dependencies [Array] The dependencies to populate
#
# @return Populator The populator instance
def initialize(dependencies)
... |
github | gdotdesign/elm-github-install | https://github.com/gdotdesign/elm-github-install | lib/elm_install/repository.rb | Ruby | mit | 207 | master | 2,701 | module ElmInstall
# Handles git repositories.
class Repository < Base
extend Forwardable
# The url of the git repository
# @return [String]
attr_reader :url
# The path to the directory where the repository lives
# @return [String]
attr_reader :path
# Whether or not the repository ... |
github | gdotdesign/elm-github-install | https://github.com/gdotdesign/elm-github-install | lib/elm_install/ext.rb | Ruby | mit | 207 | master | 493 | # Extensions for the semvese module
module Semverse
# Added utility functions
class Version
# Returns the simple string representation of a version
#
# @return [String]
def to_simple
"#{major}.#{minor}.#{patch}"
end
# Tries to parse a version, falling back to nil if fails.
#
#... |
github | gdotdesign/elm-github-install | https://github.com/gdotdesign/elm-github-install | lib/elm_install/types.rb | Ruby | mit | 207 | master | 740 | module ElmInstall
# Represents a branch
Branch = ADT do
Just(ref: String) |
Nothing()
end
# Represents an uri
Uri = ADT do
Ssh(uri: URI::SshGit::Generic) do
def to_s
uri.to_s
end
end |
Http(uri: URI::HTTP) do
def to_s
uri.to_s
end
e... |
github | demandforce/rack-oauth2-server | https://github.com/demandforce/rack-oauth2-server | config.ru | Ruby | mit | 206 | master | 1,304 | $: << File.dirname(__FILE__) + "/lib"
require "rack/oauth2/server"
Rack::OAuth2::Server.database = Mongo::Connection.new["test"]
class Authorize < Sinatra::Base
register Rack::OAuth2::Sinatra
get "/oauth/authorize" do
content_type "text/html"
<<-HTML
<h1>#{oauth.client.display_name} wants to access you... |
github | demandforce/rack-oauth2-server | https://github.com/demandforce/rack-oauth2-server | rack-oauth2-server.gemspec | Ruby | mit | 206 | master | 1,220 | $: << File.dirname(__FILE__) + "/lib"
Gem::Specification.new do |spec|
spec.name = "rack-oauth2-server"
spec.version = IO.read("VERSION")
spec.author = "Assaf Arkin"
spec.email = "assaf@labnotes.org"
spec.homepage = "http://github.com/flowtown/#{spec.name}"
spec.summ... |
github | demandforce/rack-oauth2-server | https://github.com/demandforce/rack-oauth2-server | Rakefile | Ruby | mit | 206 | master | 2,487 | require "rake/testtask"
spec = Gem::Specification.load(Dir["*.gemspec"].first)
desc "Install dependencies"
task :setup do
puts "Installing gems for testing with Sinatra ..."
sh "bundle install"
puts "Installing gems for testing with Rails 2.3 ..."
sh "env BUNDLE_GEMFILE=Rails2 bundle install"
puts "Installi... |
github | demandforce/rack-oauth2-server | https://github.com/demandforce/rack-oauth2-server | test/setup.rb | Ruby | mit | 206 | master | 2,646 | require "bundler"
Bundler.setup
require "test/unit"
require "rack/test"
require "shoulda"
require "timecop"
require "ap"
require "json"
require "logger"
$: << File.dirname(__FILE__) + "/../lib"
$: << File.expand_path(File.dirname(__FILE__) + "/..")
require "rack/oauth2/server"
require "rack/oauth2/server/admin"
ENV["... |
github | demandforce/rack-oauth2-server | https://github.com/demandforce/rack-oauth2-server | test/rails3/config/routes.rb | Ruby | mit | 206 | master | 302 | MyApp::Application.routes.draw do
# Authorization flow.
match "oauth/authorize" => "oauth#authorize"
match "oauth/grant" => "oauth#grant"
match "oauth/deny" => "oauth#deny"
# Resources we want to protect
match ":action"=>"api"
mount Rack::OAuth2::Server::Admin, :at=>"oauth/admin"
end |
github | demandforce/rack-oauth2-server | https://github.com/demandforce/rack-oauth2-server | test/rails3/config/application.rb | Ruby | mit | 206 | master | 703 | require "action_controller/railtie"
module MyApp
class Application < Rails::Application
config.session_store :cookie_store, :key=>"_my_app_session"
config.secret_token = "Stay hungry. Stay foolish. -- Steve Jobs"
config.active_support.deprecation = :stderr
config.after_initialize do
config.oau... |
github | demandforce/rack-oauth2-server | https://github.com/demandforce/rack-oauth2-server | test/rails3/app/controllers/api_controller.rb | Ruby | mit | 206 | master | 675 | class ApiController < ApplicationController
oauth_required :only=>[:private, :change]
oauth_required :only=>[:calc], :scope=>"math"
def public
if oauth.authenticated?
render :text=>"HAI from #{oauth.identity}"
else
render :text=>"HAI"
end
end
def private
render :text=>"Shhhh"
... |
github | demandforce/rack-oauth2-server | https://github.com/demandforce/rack-oauth2-server | test/rails3/app/controllers/oauth_controller.rb | Ruby | mit | 206 | master | 473 | class OauthController < ApplicationController
before_filter do |c|
c.send :head, c.oauth.deny! if c.oauth.scope.include?("time-travel") # Only Superman can do that
end
def authorize
render :text=>"client: #{oauth.client.display_name}\nscope: #{oauth.scope.join(", ")}\nauthorization: #{oauth.authorization... |
github | demandforce/rack-oauth2-server | https://github.com/demandforce/rack-oauth2-server | test/admin/api_test.rb | Ruby | mit | 206 | master | 6,540 | require "test/setup"
class AdminApiTest < Test::Unit::TestCase
module Helpers
def should_fail_authentication
should "respond with status 401 (Unauthorized)" do
assert_equal 401, last_response.status
end
end
def should_forbid_access
should "respond with status 403 (Forbidden)" d... |
github | demandforce/rack-oauth2-server | https://github.com/demandforce/rack-oauth2-server | test/admin/ui_test.rb | Ruby | mit | 206 | master | 900 | require "test/setup"
class AdminUiTest < Test::Unit::TestCase
context "/" do
setup { get "/oauth/admin" }
should "return OK" do
assert_equal 200, last_response.status
end
should "return HTML page" do
assert_match "<html>", last_response.body
end
end
context "force SSL" do
set... |
github | demandforce/rack-oauth2-server | https://github.com/demandforce/rack-oauth2-server | test/oauth/authorization_test.rb | Ruby | mit | 206 | master | 8,665 | require "test/setup"
# 3. Obtaining End-User Authorization
class AuthorizationTest < Test::Unit::TestCase
module Helpers
def should_redirect_with_error(error)
should "respond with status code 302 (Found)" do
assert_equal 302, last_response.status
end
should "redirect back to redirect... |
github | demandforce/rack-oauth2-server | https://github.com/demandforce/rack-oauth2-server | test/oauth/access_grant_test.rb | Ruby | mit | 206 | master | 8,483 | require "test/setup"
# 4. Obtaining an Access Token
class AccessGrantTest < Test::Unit::TestCase
module Helpers
def should_return_error(error)
should "respond with status 400 (Bad Request)" do
assert_equal 400, last_response.status
end
should "respond with JSON document" do
a... |
github | demandforce/rack-oauth2-server | https://github.com/demandforce/rack-oauth2-server | test/oauth/access_token_test.rb | Ruby | mit | 206 | master | 8,528 | require "test/setup"
# 5. Accessing a Protected Resource
class AccessTokenTest < Test::Unit::TestCase
module Helpers
def should_return_resource(content)
should "respond with status 200" do
assert_equal 200, last_response.status
end
should "respond with resource name" do
asser... |
github | demandforce/rack-oauth2-server | https://github.com/demandforce/rack-oauth2-server | test/oauth/server_methods_test.rb | Ruby | mit | 206 | master | 9,382 | require "test/setup"
# Tests the Server API
class ServerTest < Test::Unit::TestCase
def setup
super
end
context "configuration" do
should "set oauth.database" do
assert_equal DATABASE, Server.database
end
should "set oauth.host" do
assert_equal "example.org", Server.options.host
... |
github | demandforce/rack-oauth2-server | https://github.com/demandforce/rack-oauth2-server | test/rails2/config/environment.rb | Ruby | mit | 206 | master | 710 | class << Rails
def vendor_rails?
false
end
end
require "yaml"
YAML::ENGINE.yamler= "syck" if defined?(YAML::ENGINE) # see http://stackoverflow.com/questions/4980877/rails-error-couldnt-parse-yaml
Rails::Initializer.run do |config|
config.frameworks = [ :action_controller ]
config.action_controller.session... |
github | demandforce/rack-oauth2-server | https://github.com/demandforce/rack-oauth2-server | test/rails2/config/routes.rb | Ruby | mit | 206 | master | 405 | ActionController::Routing::Routes.draw do |map|
# Authorization flow.
map.with_options :controller=>"oauth" do |oauth|
oauth.connect "oauth/authorize", :action=>"authorize"
oauth.connect "oauth/grant", :action=>"grant"
oauth.connect "oauth/deny", :action=>"deny"
end
# Resources we want to protect
... |
github | demandforce/rack-oauth2-server | https://github.com/demandforce/rack-oauth2-server | test/sinatra/my_app.rb | Ruby | mit | 206 | master | 1,300 | require "rack/oauth2/sinatra"
class MyApp < Sinatra::Base
use Rack::Logger
set :sessions, true
set :show_exceptions, false
register Rack::OAuth2::Sinatra
oauth.authenticator = lambda do |username, password|
"Batman" if username == "cowbell" && password == "more"
end
oauth.host = "example.org"
oaut... |
github | demandforce/rack-oauth2-server | https://github.com/demandforce/rack-oauth2-server | lib/rack/oauth2/sinatra.rb | Ruby | mit | 206 | master | 2,032 | require "rack/oauth2/server"
module Rack
module OAuth2
# Sinatra support.
#
# Adds oauth instance method that returns Rack::OAuth2::Helper, see there for
# more details.
#
# Adds oauth_required class method. Use this filter with paths that require
# authentication, and with paths that re... |
github | demandforce/rack-oauth2-server | https://github.com/demandforce/rack-oauth2-server | lib/rack/oauth2/server.rb | Ruby | mit | 206 | master | 22,436 | require "rack"
require "rack/oauth2/models"
require "rack/oauth2/server/errors"
require "rack/oauth2/server/utils"
require "rack/oauth2/server/helper"
module Rack
module OAuth2
# Implements an OAuth 2 Authorization Server, based on http://tools.ietf.org/html/draft-ietf-oauth-v2-10
class Server
# Sam... |
github | demandforce/rack-oauth2-server | https://github.com/demandforce/rack-oauth2-server | lib/rack/oauth2/models.rb | Ruby | mit | 206 | master | 1,559 | require "mongo"
require "openssl"
require "rack/oauth2/server/errors"
require "rack/oauth2/server/utils"
module Rack
module OAuth2
class Server
class << self
# Create new instance of the klass and populate its attributes.
def new_instance(klass, fields)
return unless fields
... |
github | demandforce/rack-oauth2-server | https://github.com/demandforce/rack-oauth2-server | lib/rack/oauth2/rails.rb | Ruby | mit | 206 | master | 3,168 | require "rack/oauth2/server"
module Rack
module OAuth2
# Rails support.
#
# Adds oauth instance method that returns Rack::OAuth2::Helper, see there for
# more details.
#
# Adds oauth_required filter method. Use this filter with actions that require
# authentication, and with actions that... |
github | demandforce/rack-oauth2-server | https://github.com/demandforce/rack-oauth2-server | lib/rack/oauth2/server/errors.rb | Ruby | mit | 206 | master | 3,624 | module Rack
module OAuth2
class Server
# Base class for all OAuth errors. These map to error codes in the spec.
class OAuthError < StandardError
def initialize(code, message)
super message
@code = code.to_sym
end
# The OAuth error code.
attr_reade... |
github | demandforce/rack-oauth2-server | https://github.com/demandforce/rack-oauth2-server | lib/rack/oauth2/server/practice.rb | Ruby | mit | 206 | master | 2,299 | require "rack/oauth2/server/admin"
module Rack
module OAuth2
class Server
class Practice < ::Sinatra::Base
register Rack::OAuth2::Sinatra
get "/" do
<<-HTML
<html>
<head>
<title>OAuth 2.0 Practice Server</title>
</head>
<body>
<h1>Welcome to OAuth 2.0 Practic... |
github | demandforce/rack-oauth2-server | https://github.com/demandforce/rack-oauth2-server | lib/rack/oauth2/server/railtie.rb | Ruby | mit | 206 | master | 653 | require "rack/oauth2/server"
require "rack/oauth2/rails"
require "rails"
module Rack
module OAuth2
class Server
# Rails 3.x integration.
class Railtie < ::Rails::Railtie # :nodoc:
config.oauth = Server.options
initializer "rack-oauth2-server" do |app|
app.middleware.use ::R... |
github | demandforce/rack-oauth2-server | https://github.com/demandforce/rack-oauth2-server | lib/rack/oauth2/server/utils.rb | Ruby | mit | 206 | master | 917 | module Rack
module OAuth2
class Server
module Utils
module_function
# Parses the redirect URL, normalizes it and returns a URI object.
#
# Raises InvalidRequestError if not an absolute HTTP/S URL.
def parse_redirect_uri(redirect_uri)
raise InvalidRequestEr... |
github | demandforce/rack-oauth2-server | https://github.com/demandforce/rack-oauth2-server | lib/rack/oauth2/server/helper.rb | Ruby | mit | 206 | master | 5,298 | module Rack
module OAuth2
class Server
# Helper methods that provide access to the OAuth state during the
# authorization flow, and from authenticated requests. For example:
#
# def show
# logger.info "#{oauth.client.display_name} accessing #{oauth.scope}"
# end
... |
github | demandforce/rack-oauth2-server | https://github.com/demandforce/rack-oauth2-server | lib/rack/oauth2/server/admin.rb | Ruby | mit | 206 | master | 10,232 | require "sinatra/base"
require "json"
require "rack/oauth2/server"
require "rack/oauth2/sinatra"
module Rack
module OAuth2
class Server
class Admin < ::Sinatra::Base
class << self
# Rack module that mounts the specified class on the specified path,
# and passes all other reque... |
github | demandforce/rack-oauth2-server | https://github.com/demandforce/rack-oauth2-server | lib/rack/oauth2/models/auth_request.rb | Ruby | mit | 206 | master | 3,755 | module Rack
module OAuth2
class Server
# Authorization request. Represents request on behalf of client to access
# particular scope. Use this to keep state from incoming authorization
# request to grant/deny redirect.
class AuthRequest
class << self
# Find AuthRequest fr... |
github | demandforce/rack-oauth2-server | https://github.com/demandforce/rack-oauth2-server | lib/rack/oauth2/models/access_grant.rb | Ruby | mit | 206 | master | 3,700 | module Rack
module OAuth2
class Server
# The access grant is a nonce, new grant created each time we need it and
# good for redeeming one access token.
class AccessGrant
class << self
# Find AccessGrant from authentication code.
def from_code(code)
Server... |
github | demandforce/rack-oauth2-server | https://github.com/demandforce/rack-oauth2-server | lib/rack/oauth2/models/access_token.rb | Ruby | mit | 206 | master | 5,766 | module Rack
module OAuth2
class Server
# Access token. This is what clients use to access resources.
#
# An access token is a unique code, associated with a client, an identity
# and scope. It may be revoked, or expire after a certain period.
class AccessToken
class << self
... |
github | demandforce/rack-oauth2-server | https://github.com/demandforce/rack-oauth2-server | lib/rack/oauth2/models/client.rb | Ruby | mit | 206 | master | 5,451 | module Rack
module OAuth2
class Server
class Client
class << self
# Authenticate a client request. This method takes three arguments,
# Find Client from client identifier.
def find(client_id)
id = BSON::ObjectId(client_id.to_s)
Server.new_insta... |
github | demandforce/rack-oauth2-server | https://github.com/demandforce/rack-oauth2-server | rails/init.rb | Ruby | mit | 206 | master | 358 | # Rails 2.x initialization.
require "rack/oauth2/rails"
config.extend ::Rack::OAuth2::Rails::Configuration
config.oauth.logger ||= Rails.logger
config.middleware.use ::Rack::OAuth2::Server, config.oauth
class ActionController::Base
helper ::Rack::OAuth2::Rails::Helpers
include ::Rack::OAuth2::Rails::Helpers
exte... |
github | pcreux/rspec-set | https://github.com/pcreux/rspec-set | rspec-set.gemspec | Ruby | mit | 206 | master | 1,213 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'version'
Gem::Specification.new do |spec|
spec.name = "rspec-set"
spec.version = Rspec::RSpecSet::VERSION
spec.authors = ["Philippe Creux"]
spec.email = ["pcr... |
github | pcreux/rspec-set | https://github.com/pcreux/rspec-set | spec/rspec_set_spec.rb | Ruby | mit | 206 | master | 3,929 | require 'spec_helper'
describe 'including Set' do
it 'adds the ::set method to RSpec::Core::ExampleGroup' do
expect(RSpec::Core::ExampleGroup).to respond_to(:set)
end
end
describe 'without an ActiveRecord model' do
setup_for_error_checking(NonActiveRecordClass)
it "warns the user that Set only works with... |
github | pcreux/rspec-set | https://github.com/pcreux/rspec-set | spec/spec_helper.rb | Ruby | mit | 206 | master | 1,490 | require 'rspec-set'
require 'database_cleaner'
require 'active_record'
require_relative './fixtures/non_active_record_class'
require_relative './fixtures/active_record_class_example'
RSpec.configure do |config|
config.treat_symbols_as_metadata_keys_with_true_values = true
config.run_all_when_everything_filtered =... |
github | pcreux/rspec-set | https://github.com/pcreux/rspec-set | lib/rspec-set.rb | Ruby | mit | 206 | master | 1,603 | require "version"
module RSpec
module Core
module RSpecSet
module ClassMethods
# Set @variable_name in a before(:all) block and give access to it
# via let(:variable_name)
#
# Example:
#
# set(:transaction) { Factory(:address) }
#
# it "sh... |
github | janlelis/pws | https://github.com/janlelis/pws | Rakefile | Ruby | mit | 206 | main | 719 | require 'fileutils'
NAME = Dir['*.gemspec'].first
def gemspec
@gemspec ||= eval(File.read(NAME), binding, NAME)
end
desc "Build the gem"
task :gem => :gemspec do
sh "gem build #{NAME}"
FileUtils.mkdir_p 'pkg'
FileUtils.mv "#{gemspec.name}-#{gemspec.version}.gem", 'pkg'
end
desc "Install the gem locally"
tas... |
github | janlelis/pws | https://github.com/janlelis/pws | pws.gemspec | Ruby | mit | 206 | main | 1,552 | # -*- encoding: utf-8 -*-
name = 'pws'
require File.dirname(__FILE__) + "/lib/#{name}/version"
Gem::Specification.new do |s|
s.required_ruby_version = '>= 1.9.3'
s.name = name
s.version = PWS::VERSION
s.authors = ["Jan Lelis"]
s.email = ["hi@ruby.consulting"]
s.homepage = 'https://... |
github | janlelis/pws | https://github.com/janlelis/pws | spec/pws_format_spec.rb | Ruby | mit | 206 | main | 5,652 | require_relative '../lib/pws/format'
describe PWS::Format do
describe '.read' do
before(:all) do
@correct = "12345678\x01\x00\x00data"
@unknown_format = "12345678\xfd\x00\x00data"
@wrong_identifier = "012345678\x01\x00\x00data"
@too_short1 = "12345678\x01"
@too_shor... |
github | janlelis/pws | https://github.com/janlelis/pws | spec/pws_runner_spec.rb | Ruby | mit | 206 | main | 3,944 | require_relative '../lib/pws/runner'
require 'fileutils'
describe PWS::Runner do
describe '.run' do
before(:each){ @restore, $stdout = $stdout, StringIO.new }
after(:each){ $stdout = @restore }
it 'creates a pws instance, passing the options (except for special options)' do
options = { some: 'opti... |
github | janlelis/pws | https://github.com/janlelis/pws | spec/pws_format_0_9_spec.rb | Ruby | mit | 206 | main | 2,147 | require_relative '../lib/pws/format/0.9'
require_relative '../lib/pws/format/1.0'
describe PWS::Format::V0_9 do
describe '.read' do
before(:all) do
@password = 'password'
@correct = File.read('spec/fixtures/0.9/correct')
@v1_0 = File.read('spec/fixtures/1.0/correct')
@invali... |
github | janlelis/pws | https://github.com/janlelis/pws | spec/pws_format_1_0_spec.rb | Ruby | mit | 206 | main | 6,843 | # coding: utf-8
require_relative '../lib/pws/format/0.9'
require_relative '../lib/pws/format/1.0'
describe PWS::Format::V1_0 do
describe '.read' do
before(:all) do
@password = 'password'
@correct = File.read('spec/fixtures/1.0/correct')
@correct_1000000_iterations = File.re... |
github | janlelis/pws | https://github.com/janlelis/pws | features/step_definitions/pws_steps.rb | Ruby | mit | 206 | main | 2,756 | require 'fileutils'
def create_safe(master, key_hash = {}, timestamp = nil)
ENV["PWS_CHARPOOL"] = ENV["PWS_LENGTH"] = ENV["PWS_SECONDS"] = nil
restore, $stdout = $stdout, StringIO.new # tmp silence $stdout
pws = PWS.new(password: master, iterations: 5)
key_hash.each{ |key, password|
pws.add key, password
... |
github | janlelis/pws | https://github.com/janlelis/pws | features/support/env.rb | Ruby | mit | 206 | main | 835 | require "bundler/setup"
require 'aruba/cucumber'
require 'clipboard'
require 'securerandom'
require 'fileutils'
require_relative '../../lib/pws'
# Make sure bin is available
ENV['PATH'] = "#{File.expand_path(File.dirname(__FILE__) + '/../../bin')}#{File::PATH_SEPARATOR}#{ENV['PATH']}"
# Hooks
BEGIN{
$original_pws... |
github | janlelis/pws | https://github.com/janlelis/pws | lib/pws.rb | Ruby | mit | 206 | main | 10,623 | # encoding: ascii
require_relative 'pws/version'
require_relative 'pws/class_support'
require_relative 'pws/encryptor'
require_relative 'pws/format'
require 'fileutils'
require 'securerandom'
require 'abbrev'
require 'clipboard'
require 'paint/pa'
class PWS
extend PWS::ClassSupport
class NoAccess < StandardErro... |
github | janlelis/pws | https://github.com/janlelis/pws | lib/pws/runner.rb | Ruby | mit | 206 | main | 6,591 | require_relative '../pws'
module PWS::Runner
SINGLE_OPTIONS = Regexp.union *%w[
cwd
].freeze
class << self
# some simple option parsing
# returns action, arguments, options
# only accepts options with value as next arg, except breaking special cases
def parse_cli_arguments(argv = $*.dup)
... |
github | janlelis/pws | https://github.com/janlelis/pws | lib/pws/encryptor.rb | Ruby | mit | 206 | main | 998 | require 'openssl'
# This encryptor class wraps around openssl to simplify
# en/decryption using AES 256 CBC
# Please note: Failed en/decryptions will raise errors
module PWS::Encryptor
class << self
CIPHER = 'aes-256-cbc'
def decrypt(encrypted_data, options = {})
crypt(
:decrypt,
e... |
github | janlelis/pws | https://github.com/janlelis/pws | lib/pws/format.rb | Ruby | mit | 206 | main | 3,390 | # encoding: ascii
require_relative '../pws'
class PWS
# The purpose of this module is redirecting to the proper format version module
# It also reads and writes the generic header (identifier + pws version)
# Format module can be specified by two integers, support for symbols may be
# added sometime to support... |
github | janlelis/pws | https://github.com/janlelis/pws | lib/pws/format/0.9.rb | Ruby | mit | 206 | main | 1,220 | # encoding: ascii
require_relative '../format'
require 'openssl'
class PWS
module Format
# PWS file format reader for versions before 1.0.0
module V0_9
class << self
def write(_,_={})
raise NotImplementedError, 'Writing the legacy 0.9 format is not supported'
end
def ... |
github | janlelis/pws | https://github.com/janlelis/pws | lib/pws/format/1.0.rb | Ruby | mit | 206 | main | 5,966 | # encoding: ascii
require_relative '../format'
require 'securerandom'
require 'openssl'
require 'pbkdf2'
class PWS
module Format
# PWS file format for versions ~> 1.0.0
# see at bottom block for a short format description
module V1_0
TEMPLATE = 'a64 a16 N a64 a*'.freeze
DEFAULT_ITERATIONS = ... |
github | benbalter/word_diff | https://github.com/benbalter/word_diff | Gemfile | Ruby | mit | 206 | master | 242 | source "https://rubygems.org"
gem "sinatra"
gem "octokit"
gem "word-to-markdown"
gem "dotenv"
gem "rack", "1.5.2"
# Bundle these in prod to prevent a heroku error
gem "rake"
gem "rspec"
group :test do
gem "webmock"
gem "rack-test"
end |
github | benbalter/word_diff | https://github.com/benbalter/word_diff | spec/word_diff_document_spec.rb | Ruby | mit | 206 | master | 5,950 | require "spec_helper"
describe "WordDiff::Document" do
before do
@document = WordDiff::Document.new(
:repo => "benbalter/test-repo-ignore-me",
:path => "/file.docx",
:ref => "aae67a7e9c7097c1af8c7fcbf56c2a736f9e69ff",
:tmpdir => Dir.mktmpdir,
:branch => "master",
... |
github | benbalter/word_diff | https://github.com/benbalter/word_diff | spec/spec_helper.rb | Ruby | mit | 206 | master | 351 | require "bundler/setup"
ENV['RACK_ENV'] = 'test'
$:.push File.join(File.dirname(__FILE__), '..', 'lib')
require 'rack/test'
require 'webmock/rspec'
require_relative "../lib/word_diff"
WebMock.disable_net_connect!
def fixture_dir
File.expand_path "fixtures", File.dirname(__FILE__)
end
def fixture(name)
File.exp... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.