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 | guard/guard-jasmine | https://github.com/guard/guard-jasmine | lib/guard/jasmine.rb | Ruby | mit | 302 | master | 7,898 | require 'net/http'
# Don't require "guard/plugin" here or in any other plugin's files
require 'guard/compat/plugin'
module Guard
# The Jasmine guard that gets notifications about the following
# Guard events: `start`, `stop`, `reload`, `run_all` and `run_on_modifications`.
#
class Jasmine < Plugin
require... |
github | guard/guard-jasmine | https://github.com/guard/guard-jasmine | lib/guard/jasmine/cli.rb | Ruby | mit | 302 | master | 9,743 | require 'thor'
require 'guard/jasmine/version'
require 'guard/jasmine/runner'
require 'guard/jasmine/formatter'
require 'guard/jasmine/server'
require 'guard/jasmine/util'
require 'guard/jasmine/server'
module Guard
class Jasmine < Plugin
# Small helper class to run the Jasmine runner_options once from the
#... |
github | guard/guard-jasmine | https://github.com/guard/guard-jasmine | lib/guard/jasmine/util.rb | Ruby | mit | 302 | master | 3,838 | require 'net/http'
require 'timeout'
require 'guard/compat/plugin'
require 'guard/jasmine/formatter'
module Guard
class Jasmine < Plugin
# Provider of some shared utility methods.
#
module Util
# Verifies if the Jasmine test runner is available.
# If the runner is not available within 15 seco... |
github | guard/guard-jasmine | https://github.com/guard/guard-jasmine | lib/guard/jasmine/task.rb | Ruby | mit | 302 | master | 1,077 | #!/usr/bin/env ruby
require 'rake'
require 'rake/tasklib'
require 'guard/jasmine/cli'
module Guard
# Provides a method to define a Rake task that
# runs the Jasmine specs.
#
class JasmineTask < ::Rake::TaskLib
# Name of the main, top level task
attr_accessor :name
# CLI options
attr_accessor... |
github | guard/guard-jasmine | https://github.com/guard/guard-jasmine | lib/guard/jasmine/formatter.rb | Ruby | mit | 302 | master | 3,387 | require 'guard/compat/plugin'
module Guard
class Jasmine < Plugin
# The Guard::Jasmine formatter collects console and
# system notification methods and enhances them with
# some color information.
#
module Formatter
class << self
# Print an info message to the console.
#
... |
github | guard/guard-jasmine | https://github.com/guard/guard-jasmine | lib/guard/jasmine/inspector.rb | Ruby | mit | 302 | master | 1,348 | require 'guard/compat/plugin'
module Guard
class Jasmine < Plugin
# The inspector verifies if the changed paths are valid
# for Guard::Jasmine. Please note that request to {.clean}
# paths keeps the current valid files cached until {.clear} is
# called.
#
module Inspector
class << self
... |
github | guard/guard-jasmine | https://github.com/guard/guard-jasmine | lib/guard/jasmine/coverage.rb | Ruby | mit | 302 | master | 1,809 | # coding: utf-8
require 'tilt'
require 'childprocess'
require 'guard/jasmine'
require 'guard/jasmine/util'
# Tilt template to generate coverage instrumented
# Jasmine specs files.
#
class JasmineCoverage < Tilt::Template
extend ::Guard::Jasmine::Util
def prepare
end
# Returns a coverage instrumented JavaScri... |
github | guard/guard-jasmine | https://github.com/guard/guard-jasmine | lib/guard/jasmine/server.rb | Ruby | mit | 302 | master | 7,086 | # coding: utf-8
require 'socket'
require 'timeout'
require 'childprocess'
require 'jasmine'
require 'guard/compat/plugin'
module Guard
class Jasmine < Plugin
# Start and stop a Jasmine test server for requesting the specs
# from PhantomJS.
#
module Server
class << self
attr_accessor :... |
github | guard/guard-jasmine | https://github.com/guard/guard-jasmine | lib/guard/jasmine/runner.rb | Ruby | mit | 302 | master | 23,193 | # coding: utf-8
require 'multi_json'
require 'fileutils'
require 'guard/compat/plugin'
require 'guard/jasmine'
require 'guard/jasmine/util'
module Guard
class Jasmine < Plugin
# The Jasmine runner handles the execution of the spec through the PhantomJS binary,
# evaluates the JSON response from the Phantom... |
github | guard/guard-jasmine | https://github.com/guard/guard-jasmine | lib/guard/jasmine/templates/Guardfile | Ruby | mit | 302 | master | 336 | guard :jasmine do
watch(%r{spec/javascripts/spec\.(js\.coffee|js|coffee)$}) { 'spec/javascripts' }
watch(%r{spec/javascripts/.+_spec\.(js\.coffee|js|coffee)$})
watch(%r{spec/javascripts/fixtures/.+$})
watch(%r{app/assets/javascripts/(.+?)\.(js\.coffee|js|coffee)(?:\.\w+)*$}) { |m| "spec/javascripts/#{m[1]}_spec... |
github | guard/guard-jasmine | https://github.com/guard/guard-jasmine | spec/spec_helper.rb | Ruby | mit | 302 | master | 668 | require 'rspec'
require 'pathname'
RSpec.configure do |config|
config.expect_with :rspec do |expectations|
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
end
config.mock_with :rspec do |mocks|
mocks.verify_partial_doubles = true
end
config.color = true
config.filter_run ... |
github | guard/guard-jasmine | https://github.com/guard/guard-jasmine | spec/guard/jasmine_spec.rb | Ruby | mit | 302 | master | 23,215 | require 'guard/compat/test/helper'
require 'guard/jasmine'
RSpec.describe Guard::Jasmine do
let(:guard) { Guard::Jasmine.new }
let(:runner) { Guard::Jasmine::Runner }
let(:inspector) { Guard::Jasmine::Inspector }
let(:formatter) { Guard::Jasmine::Formatter }
let(:server) { Guard::Jasmine::Server }
let(:d... |
github | guard/guard-jasmine | https://github.com/guard/guard-jasmine | spec/guard/jasmine/inspector_spec.rb | Ruby | mit | 302 | master | 1,358 | require 'guard/jasmine/inspector'
RSpec.describe Guard::Jasmine::Inspector do
before do
allow(File).to receive(:exist?) do |file|
['spec/javascripts/a_spec.js.coffee', 'spec/javascripts/b_spec.js', 'c_spec.coffee'].include?(file)
end
end
subject { Guard::Jasmine::Inspector }
let(:options) { { s... |
github | guard/guard-jasmine | https://github.com/guard/guard-jasmine | spec/guard/jasmine/cli_spec.rb | Ruby | mit | 302 | master | 15,945 | require 'guard/jasmine/cli'
RSpec.describe Guard::Jasmine::CLI do
let(:cli) { ::Guard::Jasmine::CLI }
let(:runner) { ::Guard::Jasmine::Runner }
let(:server) { ::Guard::Jasmine::Server }
before do
allow(Process).to receive(:exit)
new_method = runner.method(:new)
allow(runner).to receive(:new) { |*a... |
github | guard/guard-jasmine | https://github.com/guard/guard-jasmine | spec/guard/jasmine/util_spec.rb | Ruby | mit | 302 | master | 4,620 | require 'guard/jasmine'
RSpec.describe Guard::Jasmine::Util do
let(:util) { Class.new { extend Guard::Jasmine::Util } }
before do
allow(Guard::Compat::UI).to receive(:info)
end
describe '.runner_available?' do
let(:http) do
double('http').tap do |http|
allow(http).to receive(:start).and... |
github | guard/guard-jasmine | https://github.com/guard/guard-jasmine | spec/guard/jasmine/runner_spec.rb | Ruby | mit | 302 | master | 36,568 | # coding: utf-8
require 'pathname'
def read_fixture(name)
Pathname.new(__FILE__).dirname.join('fixtures', name + '.json').read
end
require 'guard/jasmine/runner'
RSpec.describe Guard::Jasmine::Runner do
let(:formatter) { Guard::Jasmine::Formatter }
let(:defaults) do
Guard::Jasmine::DEFAULT_OPTIONS.merge(... |
github | guard/guard-jasmine | https://github.com/guard/guard-jasmine | spec/guard/jasmine/version_spec.rb | Ruby | mit | 302 | master | 218 | require 'guard/jasmine/version'
RSpec.describe Guard::JasmineVersion do
describe 'VERSION' do
it 'defines the version' do
expect(Guard::JasmineVersion::VERSION).to match(/\d+\.\d+\.\d+/)
end
end
end |
github | guard/guard-jasmine | https://github.com/guard/guard-jasmine | spec/guard/jasmine/formatter_spec.rb | Ruby | mit | 302 | master | 1,658 | require 'guard/jasmine/formatter'
RSpec.describe Guard::Jasmine::Formatter do
let(:formatter) { Guard::Jasmine::Formatter }
let(:ui) { Guard::Compat::UI }
before do
allow(ui).to receive(:info)
allow(ui).to receive(:debug)
allow(ui).to receive(:error)
allow(ui).to receive(:warning)
allow(ui).... |
github | guard/guard-jasmine | https://github.com/guard/guard-jasmine | spec/guard/jasmine/server_spec.rb | Ruby | mit | 302 | master | 8,040 | # coding: utf-8
require 'guard/jasmine/server'
RSpec.describe Guard::Jasmine::Server do
let(:server) { Guard::Jasmine::Server }
let(:defaults) do
{
server: :auto,
port: 8888,
server_env: 'test',
spec_dir: 'spec/javascripts'
}
end
before do
allow(server).to rec... |
github | yhirose/maxminddb | https://github.com/yhirose/maxminddb | Rakefile | Ruby | mit | 302 | master | 1,932 | require "bundler/gem_tasks"
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
desc "Downloads maxmind free DBs if required"
task :ensure_maxmind_files do
unless File.exist?('spec/cache/GeoLite2-City.mmdb')
os = %x{uname}.strip
options = os == 'Linux' ? '--wildcards' : ''
sh "curl 'https://... |
github | yhirose/maxminddb | https://github.com/yhirose/maxminddb | maxminddb.gemspec | Ruby | mit | 302 | master | 832 | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'maxminddb/version'
Gem::Specification.new do |spec|
spec.name = "maxminddb"
spec.version = MaxMindDB::VERSION
spec.authors = ["yhirose"]
spec.email = ["yuji.h... |
github | yhirose/maxminddb | https://github.com/yhirose/maxminddb | spec/maxminddb_spec.rb | Ruby | mit | 302 | master | 7,153 | require 'maxminddb'
describe MaxMindDB do
[
['default file reader', MaxMindDB::DEFAULT_FILE_READER],
['low memory file reader', MaxMindDB::LOW_MEMORY_FILE_READER],
].each do |file_reader|
description, reader = file_reader
describe description do
let(:city_db) { MaxMindDB.new('spec/cache/GeoL... |
github | yhirose/maxminddb | https://github.com/yhirose/maxminddb | spec/maxminddb/result_spec.rb | Ruby | mit | 302 | master | 9,027 | # -*- encoding: utf-8 -*-
require 'maxminddb'
describe MaxMindDB::Result do
subject(:result) { described_class.new(raw_result) }
let(:raw_result) { {
"city"=>{
"geoname_id"=>5375480,
"names"=>{"de"=>"Mountain View", "en"=>"Mountain View", "fr"=>"Mountain View", "ru"=>"Маунтин-Вью", "zh-CN"=>"芒廷维尤"}... |
github | yhirose/maxminddb | https://github.com/yhirose/maxminddb | spec/maxminddb/result/subdivisions_spec.rb | Ruby | mit | 302 | master | 1,962 | # -*- encoding: utf-8 -*-
require 'maxminddb'
describe MaxMindDB::Result::Subdivisions do
subject(:subdivisions) { described_class.new(raw_subdivisions) }
context "with multiple subdivisions" do
let(:raw_subdivisions) { [{
"geoname_id"=>5037779,
"iso_code"=>"MN",
"names"=>{"en"=>"Minnesota"}... |
github | yhirose/maxminddb | https://github.com/yhirose/maxminddb | spec/maxminddb/result/location_spec.rb | Ruby | mit | 302 | master | 885 | require 'maxminddb'
require 'rspec/its'
describe MaxMindDB::Result::Location do
subject(:result) { described_class.new(raw_result) }
context "with a result" do
let(:raw_result) { {
"latitude"=>37.419200000000004,
"longitude"=>-122.0574,
"metro_code"=>"807",
"time_zone"=>"America/Los_An... |
github | yhirose/maxminddb | https://github.com/yhirose/maxminddb | spec/maxminddb/result/trait_spec.rb | Ruby | mit | 302 | master | 991 | require 'maxminddb'
describe MaxMindDB::Result::Traits do
subject(:result) { described_class.new(raw_result) }
context "with an is_anonymous_proxy result" do
let(:raw_result) { {
"is_anonymous_proxy"=>true
} }
its(:is_anonymous_proxy) { should eq(true) }
its(:is_satellite_provider) { should... |
github | yhirose/maxminddb | https://github.com/yhirose/maxminddb | spec/maxminddb/result/named_location_spec.rb | Ruby | mit | 302 | master | 1,032 | # -*- encoding: utf-8 -*-
require 'maxminddb'
describe MaxMindDB::Result::NamedLocation do
subject(:result) { described_class.new(raw_result) }
context "with a result" do
let(:raw_result) { {
"geoname_id"=>6252001,
"iso_code"=>"US",
"names"=>{"de"=>"USA", "en"=>"United States", "es"=>"Estado... |
github | yhirose/maxminddb | https://github.com/yhirose/maxminddb | spec/maxminddb/result/postal_spec.rb | Ruby | mit | 302 | master | 350 | require 'maxminddb'
describe MaxMindDB::Result::Postal do
subject(:result) { described_class.new(raw_result) }
context "with a result" do
let(:raw_result) { {
"code"=>"94043"
} }
its(:code) { should eq("94043") }
end
context "without a result" do
let(:raw_result) { nil }
its(:code... |
github | yhirose/maxminddb | https://github.com/yhirose/maxminddb | lib/maxminddb.rb | Ruby | mit | 302 | master | 6,375 | require_relative "maxminddb/version"
require_relative 'maxminddb/result'
require_relative 'maxminddb/reader'
require 'ipaddr'
module MaxMindDB
# The default reader for MaxMindDB files. Reads the database into memory.
# This creates a higher memory overhead, but faster lookup times.
DEFAULT_FILE_READER = proc { ... |
github | yhirose/maxminddb | https://github.com/yhirose/maxminddb | lib/maxminddb/reader.rb | Ruby | mit | 302 | master | 831 | require 'thread'
module MaxMindDB
class LowMemoryReader
METADATA_MAX_SIZE = 128 * 1024
def initialize(path)
@mutex = Mutex.new
@file = File.open(path, 'rb')
end
def [](pos, length=1)
atomic_read(length, pos)
end
def rindex(search)
base = [0, @file.size - METADATA_MA... |
github | yhirose/maxminddb | https://github.com/yhirose/maxminddb | lib/maxminddb/result.rb | Ruby | mit | 302 | master | 1,370 | require_relative 'result/location'
require_relative 'result/named_location'
require_relative 'result/postal'
require_relative 'result/subdivisions'
require_relative 'result/traits'
module MaxMindDB
class Result
def initialize(raw)
@raw = raw || {}
end
def [](attr)
raw[attr]
end
def ... |
github | yhirose/maxminddb | https://github.com/yhirose/maxminddb | lib/maxminddb/result/postal.rb | Ruby | mit | 302 | master | 213 | module MaxMindDB
class Result
class Postal
def initialize(raw)
@raw = raw || {}
end
def code
raw['code']
end
private
attr_reader :raw
end
end
end |
github | yhirose/maxminddb | https://github.com/yhirose/maxminddb | lib/maxminddb/result/subdivisions.rb | Ruby | mit | 302 | master | 340 | module MaxMindDB
class Result
class Subdivisions < Array
def initialize(raw)
super((raw || []).map { |hash| NamedLocation.new(hash) })
end
def most_specific
last || NamedLocation.new({})
end
def inspect
"#<MaxMindDB::Result::Subdivisions: #{super}>"
en... |
github | yhirose/maxminddb | https://github.com/yhirose/maxminddb | lib/maxminddb/result/location.rb | Ruby | mit | 302 | master | 461 | module MaxMindDB
class Result
class Location
def initialize(raw)
@raw = raw || {}
end
def latitude
raw['latitude']
end
def longitude
raw['longitude']
end
def metro_code
raw['metro_code']
end
def time_zone
raw['time_z... |
github | yhirose/maxminddb | https://github.com/yhirose/maxminddb | lib/maxminddb/result/traits.rb | Ruby | mit | 302 | master | 321 | module MaxMindDB
class Result
class Traits
def initialize(raw)
@raw = raw || {}
end
def is_anonymous_proxy
raw['is_anonymous_proxy']
end
def is_satellite_provider
raw['is_satellite_provider']
end
private
attr_reader :raw
end
end
end |
github | yhirose/maxminddb | https://github.com/yhirose/maxminddb | lib/maxminddb/result/named_location.rb | Ruby | mit | 302 | master | 500 | module MaxMindDB
class Result
class NamedLocation
def initialize(raw)
@raw = raw || {}
end
def code
raw['code']
end
def geoname_id
raw['geoname_id']
end
def is_in_european_union
raw['is_in_european_union']
end
def iso_code
... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | Gemfile | Ruby | mit | 301 | master | 1,257 | # frozen_string_literal: true
source "https://rubygems.org"
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
# Declare your gem's dependencies in role_core.gemspec.
# Bundler will treat runtime dependencies like base dependencies, and
# development dependencies will be added by default to the :developm... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | role_core.gemspec | Ruby | mit | 301 | master | 871 | # frozen_string_literal: true
$LOAD_PATH.push File.expand_path("lib", __dir__)
# Maintain your gem's version:
require "role_core/version"
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "role_core"
s.version = RoleCore::VERSION
s.authors = ["jasl"]
s.em... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | Rakefile | Ruby | mit | 301 | master | 708 | # frozen_string_literal: true
begin
require "bundler/setup"
rescue LoadError
puts "You must `gem install bundler` and `bundle install` to run rake tasks"
end
require "rdoc/task"
RDoc::Task.new(:rdoc) do |rdoc|
rdoc.rdoc_dir = "rdoc"
rdoc.title = "RoleCore"
rdoc.options << "--line-numbers"
rdoc.rdoc_fi... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | db/migrate/20170705174003_create_roles.rb | Ruby | mit | 301 | master | 257 | # frozen_string_literal: true
class CreateRoles < ActiveRecord::Migration[5.1]
def change
create_table :roles do |t|
t.string :name, null: false
t.text :permissions
t.string :type, null: false
t.timestamps
end
end
end |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | lib/role_core.rb | Ruby | mit | 301 | master | 876 | # frozen_string_literal: true
require "role_core/engine"
require "options_model"
require "role_core/permission"
require "role_core/mapper"
require "role_core/permission_set"
require "role_core/computed_permissions"
require "role_core/concerns/models/role"
module RoleCore
class << self
def permission_set_class... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | lib/role_core/computed_permissions.rb | Ruby | mit | 301 | master | 608 | # frozen_string_literal: true
module RoleCore
class ComputedPermissions
delegate :each, :map, :to_a, :to_ary, to: :@permissions
def initialize(permissions = [])
@permissions = [].concat permissions.to_a
regroup!
end
def concat(permissions)
@permissions.concat permissions
reg... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | lib/role_core/permission_set.rb | Ruby | mit | 301 | master | 1,694 | # frozen_string_literal: true
module RoleCore
class PermissionSet < OptionsModel::Base
def permitted_permission_names
attributes.select { |_, v| v }.keys
end
def computed_permissions(include_nesting: true)
permissions = self.class.registered_permissions.slice(*permitted_permission_names).val... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | lib/role_core/mapper.rb | Ruby | mit | 301 | master | 1,116 | # frozen_string_literal: true
module RoleCore
class Mapper
def initialize(set, constraints = {}) # :nodoc:
@constraints = constraints
@constraints[:_namespace] ||= []
@set = set
end
def permission(name, default: false, **options, &block)
@set.register_permission name, default, @c... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | lib/role_core/permission.rb | Ruby | mit | 301 | master | 602 | # frozen_string_literal: true
module RoleCore
class Permission
attr_reader :name, :namespace, :priority, :callable
def initialize(name, _namespace: [], _priority: 0, _callable: false, **_options, &_block)
@name = name
@namespace = _namespace
@priority = _priority
@callable = _callabl... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | lib/role_core/contrib/can_can_can_permission.rb | Ruby | mit | 301 | master | 1,079 | # frozen_string_literal: true
module RoleCore
class CanCanCanPermission < RoleCore::Permission
attr_reader :action, :options
def initialize(name, _namespace: [], _priority: 0, _callable: true, **options, &block)
super
return unless _callable
@model_name = options[:model_name]
@subje... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | lib/role_core/concerns/models/role.rb | Ruby | mit | 301 | master | 451 | # frozen_string_literal: true
module RoleCore::Concerns
module Models
module Role
extend ActiveSupport::Concern
included do
validates :name,
presence: true
delegate :computed_permissions, to: :permissions
serialize :permissions, coder: RoleCore.permission_... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | lib/generators/role_core/model/model_generator.rb | Ruby | mit | 301 | master | 279 | # frozen_string_literal: true
module RoleCore
module Generators
class ModelGenerator < Rails::Generators::Base
source_root File.expand_path("templates", __dir__)
def generate_model
copy_file "role.rb", "app/models/role.rb"
end
end
end
end |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | lib/generators/role_core/config/config_generator.rb | Ruby | mit | 301 | master | 372 | # frozen_string_literal: true
module RoleCore
module Generators
class ConfigGenerator < Rails::Generators::Base
source_root File.expand_path("templates", __dir__)
def generate_config
copy_file "role_core.rb", "config/initializers/role_core.rb"
copy_file "role_core.en.yml", "config/lo... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | lib/generators/role_core/config/templates/role_core.rb | Ruby | mit | 301 | master | 2,676 | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# For I18n, see `config/locales/role_core.en.yml` for details which followed the rule of ActiveRecord's I18n,
# See <http://guides.rubyonrails.org/i18n.html#translations-for-active-record-models>.
# Uncomment below if you want ... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | test/test_helper.rb | Ruby | mit | 301 | master | 857 | # frozen_string_literal: true
require File.expand_path("../test/dummy/config/environment.rb", __dir__)
ActiveRecord::Migrator.migrations_paths = [File.expand_path("../test/dummy/db/migrate", __dir__)]
ActiveRecord::Migrator.migrations_paths << File.expand_path("../db/migrate", __dir__)
require "rails/test_help"
# Fil... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | test/dummy/test/system/projects_test.rb | Ruby | mit | 301 | master | 236 | # frozen_string_literal: true
require "application_system_test_case"
class ProjectsTest < ApplicationSystemTestCase
# test "visiting the index" do
# visit projects_url
#
# assert_selector "h1", text: "Project"
# end
end |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | test/dummy/test/system/users_test.rb | Ruby | mit | 301 | master | 227 | # frozen_string_literal: true
require "application_system_test_case"
class UsersTest < ApplicationSystemTestCase
# test "visiting the index" do
# visit users_url
#
# assert_selector "h1", text: "User"
# end
end |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | test/dummy/test/system/roles_test.rb | Ruby | mit | 301 | master | 227 | # frozen_string_literal: true
require "application_system_test_case"
class RolesTest < ApplicationSystemTestCase
# test "visiting the index" do
# visit roles_url
#
# assert_selector "h1", text: "Role"
# end
end |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | test/dummy/test/system/dynamic_permissions_test.rb | Ruby | mit | 301 | master | 1,402 | # frozen_string_literal: true
require "application_system_test_case"
class DynamicPermissionsTest < ApplicationSystemTestCase
setup do
@dynamic_permission = dynamic_permissions(:one)
end
test "visiting the index" do
visit dynamic_permissions_url
assert_selector "h1", text: "Dynamic permissions"
e... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | test/dummy/test/system/teams_test.rb | Ruby | mit | 301 | master | 983 | # frozen_string_literal: true
require "application_system_test_case"
class TeamsTest < ApplicationSystemTestCase
setup do
@team = teams(:one)
end
test "visiting the index" do
visit teams_url
assert_selector "h1", text: "Teams"
end
test "should create team" do
visit teams_url
click_on "... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | test/dummy/test/system/tasks_test.rb | Ruby | mit | 301 | master | 227 | # frozen_string_literal: true
require "application_system_test_case"
class TasksTest < ApplicationSystemTestCase
# test "visiting the index" do
# visit tasks_url
#
# assert_selector "h1", text: "Task"
# end
end |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | test/dummy/test/controllers/users_controller_test.rb | Ruby | mit | 301 | master | 1,000 | # frozen_string_literal: true
require "test_helper"
class UsersControllerTest < ActionDispatch::IntegrationTest
setup do
@user = users(:one)
end
test "should get index" do
get users_url
assert_response :success
end
test "should get new" do
get new_user_url
assert_response :success
en... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | test/dummy/test/controllers/teams_controller_test.rb | Ruby | mit | 301 | master | 1,064 | # frozen_string_literal: true
require "test_helper"
class TeamsControllerTest < ActionDispatch::IntegrationTest
setup do
@team = teams(:one)
end
test "should get index" do
get teams_url
assert_response :success
end
test "should get new" do
get new_team_url
assert_response :success
en... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | test/dummy/test/controllers/roles_controller_test.rb | Ruby | mit | 301 | master | 1,000 | # frozen_string_literal: true
require "test_helper"
class RolesControllerTest < ActionDispatch::IntegrationTest
setup do
@role = roles(:one)
end
test "should get index" do
get roles_url
assert_response :success
end
test "should get new" do
get new_role_url
assert_response :success
en... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | test/dummy/test/controllers/projects_controller_test.rb | Ruby | mit | 301 | master | 1,145 | # frozen_string_literal: true
require "test_helper"
class ProjectsControllerTest < ActionDispatch::IntegrationTest
setup do
@project = projects(:one)
end
test "should get index" do
get projects_url
assert_response :success
end
test "should get new" do
get new_project_url
assert_respons... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | test/dummy/test/controllers/dynamic_permissions_controller_test.rb | Ruby | mit | 301 | master | 1,538 | # frozen_string_literal: true
require "test_helper"
class DynamicPermissionsControllerTest < ActionDispatch::IntegrationTest
setup do
@dynamic_permission = dynamic_permissions(:one)
end
test "should get index" do
get dynamic_permissions_url
assert_response :success
end
test "should get new" do... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | test/dummy/test/controllers/session_controller_test.rb | Ruby | mit | 301 | master | 220 | # frozen_string_literal: true
require "test_helper"
class SessionControllerTest < ActionDispatch::IntegrationTest
test "should get sign_in_as" do
get session_sign_in_as_url
assert_response :success
end
end |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | test/dummy/test/controllers/tasks_controller_test.rb | Ruby | mit | 301 | master | 1,112 | # frozen_string_literal: true
require "test_helper"
class TasksControllerTest < ActionDispatch::IntegrationTest
setup do
@task = tasks(:one)
end
test "should get index" do
get tasks_url
assert_response :success
end
test "should get new" do
get new_task_url
assert_response :success
en... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | test/dummy/config/puma.rb | Ruby | mit | 301 | master | 1,428 | # frozen_string_literal: true
# Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers: a minimum and maximum.
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for mini... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | test/dummy/config/application.rb | Ruby | mit | 301 | master | 879 | # frozen_string_literal: true
require_relative "boot"
require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
# require "active_job/railtie"
require "active_record/railtie"
# require "active_storage/engine"
require "action_controller/railtie"
# require "action_mailer/railtie"
require "action_vi... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | test/dummy/config/routes.rb | Ruby | mit | 301 | master | 465 | # frozen_string_literal: true
Rails.application.routes.draw do
resources :teams, except: %i[show]
resources :dynamic_permissions, except: %i[show]
resources :roles, except: %i[show]
resources :users, except: %i[show]
resources :projects, except: %i[show] do
resources :tasks, except: %i[show]
end
get... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | test/dummy/config/environments/test.rb | Ruby | mit | 301 | master | 1,646 | # frozen_string_literal: true
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "s... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | test/dummy/config/environments/production.rb | Ruby | mit | 301 | master | 3,441 | # frozen_string_literal: true
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, a... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | test/dummy/config/environments/development.rb | Ruby | mit | 301 | master | 2,029 | # frozen_string_literal: true
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
# since you don... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | test/dummy/config/initializers/assets.rb | Ruby | mit | 301 | master | 600 | # frozen_string_literal: true
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = "1.0"
# Add additional assets to the asset load path.
# Rails.application.config.assets.paths << Emoji.images_path
# Add Yarn node_modules folder to the asset load path.... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | test/dummy/config/initializers/inflections.rb | Ruby | mit | 301 | master | 678 | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Add new inflection rules using the following format. Inflections
# are locale specific, and you may define rules for as many different
# locales as you wish. All of these examples are active by default:
# ActiveSupport::Inflec... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | test/dummy/config/initializers/content_security_policy.rb | Ruby | mit | 301 | master | 1,123 | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# Define an application-wide content security policy
# For further information see the following documentation
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
# Rails.application.config.conte... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | test/dummy/config/initializers/role_core.rb | Ruby | mit | 301 | master | 1,408 | # frozen_string_literal: true
# Be sure to restart your server when you modify this file.
# For I18n, see `config/locales/role_core.en.yml` for details which followed the rule of ActiveRecord's I18n,
# See <http://guides.rubyonrails.org/i18n.html#translations-for-active-record-models>.
require "role_core/contrib/can... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | test/dummy/app/controllers/users_controller.rb | Ruby | mit | 301 | master | 1,093 | # frozen_string_literal: true
class UsersController < ApplicationController
before_action :set_user, only: %i[show edit update destroy]
# GET /users
def index
@users = User.all
end
# GET /users/new
def new
@user = User.new
end
# GET /users/1/edit
def edit; end
# POST /users
def create... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | test/dummy/app/controllers/dynamic_permissions_controller.rb | Ruby | mit | 301 | master | 1,563 | # frozen_string_literal: true
class DynamicPermissionsController < ApplicationController
before_action :set_dynamic_permission, only: %i[edit update destroy]
# GET /dynamic_permissions
def index
@dynamic_permissions = DynamicPermission.all
end
# GET /dynamic_permissions/new
def new
@dynamic_permi... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | test/dummy/app/controllers/projects_controller.rb | Ruby | mit | 301 | master | 1,431 | # frozen_string_literal: true
class ProjectsController < ApplicationController
before_action :require_signed_in
before_action :set_project, only: %i[show edit update destroy]
# GET /projects
def index
@projects = Project.all
end
# GET /projects/new
def new
@project = Project.new
authorize! ... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | test/dummy/app/controllers/tasks_controller.rb | Ruby | mit | 301 | master | 1,546 | # frozen_string_literal: true
class TasksController < ApplicationController
before_action :require_signed_in
before_action :set_project
before_action :set_task, only: %i[show edit update destroy]
# GET /tasks
def index
authorize! :read, @project
@tasks = @project.tasks.all
end
# GET /tasks/new
... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | test/dummy/app/controllers/application_controller.rb | Ruby | mit | 301 | master | 381 | # frozen_string_literal: true
class ApplicationController < ActionController::Base
helper_method :current_user
private
def current_user
if session[:current_user_id].present?
@_current_user ||=
User.where(id: session[:current_user_id]).first
end
end
def require_signed_in... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | test/dummy/app/controllers/session_controller.rb | Ruby | mit | 301 | master | 263 | # frozen_string_literal: true
class SessionController < ApplicationController
def sign_in_as
session[:current_user_id] = params[:id]
redirect_to projects_url
end
def sign_out
session[:current_user_id] = nil
redirect_to users_url
end
end |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | test/dummy/app/controllers/teams_controller.rb | Ruby | mit | 301 | master | 1,160 | # frozen_string_literal: true
class TeamsController < ApplicationController
before_action :set_team, only: %i[edit update destroy]
# GET /teams
def index
@teams = Team.all
end
# GET /teams/new
def new
@team = Team.new
end
# GET /teams/1/edit
def edit
end
# POST /teams
def create
... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | test/dummy/app/controllers/roles_controller.rb | Ruby | mit | 301 | master | 1,106 | # frozen_string_literal: true
class RolesController < ApplicationController
before_action :set_role, only: %i[show edit update destroy]
# GET /roles
def index
@roles = Role.all
end
# GET /roles/new
def new
@role = Role.new
end
# GET /roles/1/edit
def edit; end
# POST /roles
def create... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | test/dummy/app/models/user.rb | Ruby | mit | 301 | master | 403 | # frozen_string_literal: true
class User < ApplicationRecord
has_many :projects, dependent: :destroy
has_many :tasks, dependent: :destroy
has_many :role_assignments, dependent: :destroy
has_many :roles, through: :role_assignments
validates :name, presence: true
def computed_permissions
roles.map(&:c... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | test/dummy/app/models/ability.rb | Ruby | mit | 301 | master | 260 | # frozen_string_literal: true
class Ability
include CanCan::Ability
def initialize(user)
# See the wiki for details:
# https://github.com/CanCanCommunity/cancancan/wiki/Defining-Abilities
user.computed_permissions.call(self, user)
end
end |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | test/dummy/app/models/dynamic_permission.rb | Ruby | mit | 301 | master | 231 | # frozen_string_literal: true
class DynamicPermission < ApplicationRecord
validates :name,
presence: true,
uniqueness: true
validates :key,
presence: true,
uniqueness: true
end |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | test/dummy/app/models/team.rb | Ruby | mit | 301 | master | 1,214 | # frozen_string_literal: true
class Team < ApplicationRecord
validates :name,
presence: true,
uniqueness: true
before_save :write_permissions
before_validation :validate_permissions
def permissions
@permissions ||= permission_set_class.load self[:permissions]
end
def permissi... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | test/dummy/db/schema.rb | Ruby | mit | 301 | master | 3,015 | # This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `bin/rai... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | test/dummy/db/migrate/20220122193725_create_dynamic_permissions.rb | Ruby | mit | 301 | master | 335 | # frozen_string_literal: true
class CreateDynamicPermissions < ActiveRecord::Migration[7.0]
def change
create_table :dynamic_permissions do |t|
t.string :name, null: false
t.string :key, null: false, index: { unique: true }
t.boolean :default, null: false, default: false
t.timestamps
... |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | test/dummy/db/migrate/20170705175121_create_role_assignments.rb | Ruby | mit | 301 | master | 277 | # frozen_string_literal: true
class CreateRoleAssignments < ActiveRecord::Migration[5.2]
def change
create_table :role_assignments do |t|
t.references :user, foreign_key: true, null: false
t.references :role, foreign_key: true, null: false
end
end
end |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | test/dummy/db/migrate/20170703193631_create_tasks.rb | Ruby | mit | 301 | master | 275 | # frozen_string_literal: true
class CreateTasks < ActiveRecord::Migration[5.2]
def change
create_table :tasks do |t|
t.string :title
t.references :user, foreign_key: true
t.references :project, foreign_key: true
t.timestamps
end
end
end |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | test/dummy/db/migrate/20170703051239_create_projects.rb | Ruby | mit | 301 | master | 302 | # frozen_string_literal: true
class CreateProjects < ActiveRecord::Migration[5.2]
def change
create_table :projects do |t|
t.string :title
t.boolean :is_public, null: false, index: true, default: true
t.references :user, foreign_key: true
t.timestamps
end
end
end |
github | rails-engine/role_core | https://github.com/rails-engine/role_core | test/dummy/db/migrate/20220122193822_create_teams.rb | Ruby | mit | 301 | master | 248 | # frozen_string_literal: true
class CreateTeams < ActiveRecord::Migration[7.0]
def change
create_table :teams do |t|
t.string :name, null: false
t.text :permissions, null: false, default: ""
t.timestamps
end
end
end |
github | franckverrot/activevalidators | https://github.com/franckverrot/activevalidators | activevalidators.gemspec | Ruby | mit | 301 | master | 1,193 | # -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = 'activevalidators'
s.version = '6.0.0'
s.platform = Gem::Platform::RUBY
s.authors = ['Franck Verrot']
s.email = ['franck@verrot.fr']
s.homepage = 'http://github.com/franckverrot/activevalidators'
s.summary = %q... |
github | franckverrot/activevalidators | https://github.com/franckverrot/activevalidators | Rakefile | Ruby | mit | 301 | master | 1,333 | require 'rubygems'
require 'rubygems/specification'
require 'bundler'
Bundler::GemHelper.install_tasks
require 'rake/testtask'
Rake::TestTask.new do |t|
t.libs << "test"
t.pattern = "test/**/*_test.rb"
t.verbose = true
t.warning = true
end
def gemspec
@gemspec ||= begin
file = File.expand_... |
github | franckverrot/activevalidators | https://github.com/franckverrot/activevalidators | lib/activevalidators.rb | Ruby | mit | 301 | master | 1,059 | require 'active_model'
require 'active_validators/one_nine_shims/one_nine_string'
module ActiveValidators
def self.activevalidators
%w(email url respond_to phone slug ip credit_card date password twitter postal_code tracking_number siren ssn sin nino barcode date hex_color regexp)
end
# Require each validat... |
github | franckverrot/activevalidators | https://github.com/franckverrot/activevalidators | lib/active_validators/active_model/validations/credit_card_validator.rb | Ruby | mit | 301 | master | 1,629 | require 'credit_card_validations'
module ActiveModel
module Validations
class CreditCardValidator < EachValidator
def validate_each(record, attribute, value)
brand = options.fetch(:type, :any)
brands = (brand == :any ? [] : Array.wrap(brand))
record.errors.add(attribute) if value.bl... |
github | franckverrot/activevalidators | https://github.com/franckverrot/activevalidators | lib/active_validators/active_model/validations/tracking_number_validator.rb | Ruby | mit | 301 | master | 2,627 | module ActiveModel
module Validations
class TrackingNumberValidator < EachValidator
def validate_each(record, attribute, value)
carrier = options[:carrier] || (options[:carrier_field] && record.send(options[:carrier_field]))
raise "Carrier option required" unless carrier
method = "va... |
github | franckverrot/activevalidators | https://github.com/franckverrot/activevalidators | lib/active_validators/active_model/validations/hex_color_validator.rb | Ruby | mit | 301 | master | 255 | module ActiveModel
module Validations
class HexColorValidator < EachValidator
def validate_each(record, attribute, value)
unless value =~ /\A(\h{3}){,2}\z/
record.errors.add(attribute)
end
end
end
end
end |
github | franckverrot/activevalidators | https://github.com/franckverrot/activevalidators | lib/active_validators/active_model/validations/barcode_validator.rb | Ruby | mit | 301 | master | 1,376 | module ActiveModel
module Validations
class BarcodeValidator < EachValidator
# We check the validity of :format option
# More at https://github.com/rails/rails/blob/aa7fdfb859d8a73f58460a7aba7174a47b5101d5/activemodel/lib/active_model/validator.rb#L180
def check_validity!
format = option... |
github | franckverrot/activevalidators | https://github.com/franckverrot/activevalidators | lib/active_validators/active_model/validations/ip_validator.rb | Ruby | mit | 301 | master | 1,018 | module ActiveModel
module Validations
class IpValidator < EachValidator
def validate_each(record, attribute, value)
value_str = value.to_s # might be an IPAddr
record.errors.add(attribute) if value_str.blank? || !regex.match(value_str)
end
def check_validity!
raise Argum... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.