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 | Beagle123/visualruby | https://github.com/Beagle123/visualruby | src/main/VR_Local_Gem_Tree.rb | Ruby | mit | 46 | master | 1,547 | class VR_Local_Gem_Tree < GemTree
include GladeGUI
def initialize(main)
super()
@main = main
load_glade()
parse_signals()
end
def refresh()
self.model.clear
result = `gem list`
result.each_line do |line|
gem, versions = get_name_ver(line)
versions.split(",").each d... |
github | Beagle123/visualruby | https://github.com/Beagle123/visualruby | src/main/RubygemsAPI.rb | Ruby | mit | 46 | master | 4,034 | class RubygemsAPI
# include GladeGUI
CREDENTIALS_FILE = File.join(ENV['HOME'], ".gem", "credentials")
def initialize
uri = URI.parse("https://rubygems.org")
@http = Net::HTTP.new(uri.host, uri.port)
@http.use_ssl = true
@http.verify_mode = OpenSSL::SSL::VERIFY_NONE
# load_glade()
end
... |
github | voxpupuli/puppet-hiera_vault | https://github.com/voxpupuli/puppet-hiera_vault | Gemfile | Ruby | apache-2.0 | 46 | master | 848 | # Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/
source ENV['GEM_SOURCE'] || 'https://rubygems.org'
group :test do
gem 'voxpupuli-test', '~> 13.0', :require => false
gem 'puppet_metadata', '~> 6.0', :require => false
gem 'vault', :... |
github | voxpupuli/puppet-hiera_vault | https://github.com/voxpupuli/puppet-hiera_vault | Rakefile | Ruby | apache-2.0 | 46 | master | 906 | # Managed by modulesync - DO NOT EDIT
# https://voxpupuli.org/docs/updating-files-managed-with-modulesync/
begin
require 'voxpupuli/test/rake'
rescue LoadError
# only available if gem group test is installed
end
begin
require 'voxpupuli/acceptance/rake'
rescue LoadError
# only available if gem group acceptanc... |
github | voxpupuli/puppet-hiera_vault | https://github.com/voxpupuli/puppet-hiera_vault | spec/support/vault_server.rb | Ruby | apache-2.0 | 46 | master | 2,136 | #
# Copied from Hashicorp's Vault ruby gem, source is licensed under MPL2.0
#
# https://github.com/hashicorp/vault-ruby/blob/master/spec/support/vault_server.rb
#
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0
require 'open-uri'
require 'singleton'
require 'timeout'
require 'tempfile'
module RSpec... |
github | voxpupuli/puppet-hiera_vault | https://github.com/voxpupuli/puppet-hiera_vault | spec/functions/hiera_vault_happy_path_spec.rb | Ruby | apache-2.0 | 46 | master | 8,255 | require 'spec_helper'
require 'support/vault_server'
require 'puppet/functions/hiera_vault'
describe FakeFunction do
let :function do
described_class.new
end
let :context do
ctx = instance_double('Puppet::LookupContext')
allow(ctx).to receive(:cache_has_key).and_return(false)
if ENV['DEBUG']
... |
github | voxpupuli/puppet-hiera_vault | https://github.com/voxpupuli/puppet-hiera_vault | spec/functions/hiera_vault_sealed_spec.rb | Ruby | apache-2.0 | 46 | master | 1,640 | require 'spec_helper'
require 'support/vault_server'
require 'puppet/functions/hiera_vault'
describe FakeFunction do
let :function do
described_class.new
end
let :context do
ctx = instance_double('Puppet::LookupContext')
allow(ctx).to receive(:cache_has_key).and_return(false)
if ENV['DEBUG']
... |
github | voxpupuli/puppet-hiera_vault | https://github.com/voxpupuli/puppet-hiera_vault | spec/functions/hiera_vault_sad_path_spec.rb | Ruby | apache-2.0 | 46 | master | 4,385 | require 'spec_helper'
require 'support/vault_server'
require 'puppet/functions/hiera_vault'
describe FakeFunction do
let :function do
described_class.new
end
let :context do
ctx = instance_double('Puppet::LookupContext')
allow(ctx).to receive(:cache_has_key).and_return(false)
if ENV['DEBUG']
... |
github | voxpupuli/puppet-hiera_vault | https://github.com/voxpupuli/puppet-hiera_vault | spec/functions/hiera_vault_happy_path_v2_spec.rb | Ruby | apache-2.0 | 46 | master | 8,534 | require 'spec_helper'
require 'support/vault_server'
require 'puppet/functions/hiera_vault'
describe FakeFunction do
let :function do
described_class.new
end
let :context do
ctx = instance_double('Puppet::LookupContext')
allow(ctx).to receive(:cache_has_key).and_return(false)
if ENV['DEBUG']
... |
github | voxpupuli/puppet-hiera_vault | https://github.com/voxpupuli/puppet-hiera_vault | spec/functions/hiera_vault_strict_mode_spec.rb | Ruby | apache-2.0 | 46 | master | 3,662 | require 'spec_helper'
require 'support/vault_server'
require 'puppet/functions/hiera_vault'
describe FakeFunction do
let :function do
described_class.new
end
let :context do
ctx = instance_double('Puppet::LookupContext')
allow(ctx).to receive(:cache_has_key).and_return(false)
if ENV['DEBUG']
... |
github | voxpupuli/puppet-hiera_vault | https://github.com/voxpupuli/puppet-hiera_vault | spec/functions/hiera_vault_path_interpolation_spec.rb | Ruby | apache-2.0 | 46 | master | 2,932 | require 'spec_helper'
require 'support/vault_server'
require 'puppet/functions/hiera_vault'
VAULT_PATH = 'puppetv2_interpolation'
describe FakeFunction do
let :function do
described_class.new
end
let :context do
ctx = instance_double('Puppet::LookupContext')
allow(ctx).to receive(:cache_has_key).an... |
github | voxpupuli/puppet-hiera_vault | https://github.com/voxpupuli/puppet-hiera_vault | spec/functions/hiera_vault_cache_spec.rb | Ruby | apache-2.0 | 46 | master | 3,833 | require 'spec_helper'
require 'support/vault_server'
require 'puppet/functions/hiera_vault'
describe FakeFunction do
let :function do
described_class.new
end
let :context do
ctx = instance_double('Puppet::LookupContext')
allow(ctx).to receive(:cache_has_key).and_return(false)
if ENV['DEBUG']
... |
github | voxpupuli/puppet-hiera_vault | https://github.com/voxpupuli/puppet-hiera_vault | lib/puppet/functions/hiera_vault.rb | Ruby | apache-2.0 | 46 | master | 12,376 | # Cache will keep track of all the results gotten from the Vault server.
# To avoid leaking secrets both the key looked for and the options are used as
# the key for the cache so that using the same key with different options will
# not risk leaking a secret.
# To keep things fast and not have the pruning method take l... |
github | yasaichi/gakubuchi | https://github.com/yasaichi/gakubuchi | gakubuchi.gemspec | Ruby | mit | 46 | master | 1,443 | $:.push File.expand_path("../lib", __FILE__)
# Maintain your gem's version:
require "gakubuchi/version"
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "gakubuchi"
s.version = Gakubuchi::VERSION
s.authors = ["yasaichi"]
s.email = ["yasaichi@users.n... |
github | yasaichi/gakubuchi | https://github.com/yasaichi/gakubuchi | Gemfile | Ruby | mit | 46 | master | 572 | source "https://rubygems.org"
# Declare your gem's dependencies in gakubuchi.gemspec.
# Bundler will treat runtime dependencies like base dependencies, and
# development dependencies will be added by default to the :development group.
gemspec
# Declare any dependencies that are still in development here instead of in... |
github | yasaichi/gakubuchi | https://github.com/yasaichi/gakubuchi | Rakefile | Ruby | mit | 46 | master | 617 | 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 = "Gakubuchi"
rdoc.options << "--line-numbers"
rdoc.rdoc_files.include("README.rdoc")
r... |
github | yasaichi/gakubuchi | https://github.com/yasaichi/gakubuchi | Appraisals | Ruby | mit | 46 | master | 703 | appraise "sprockets-rails 2 with sprockets 2" do
gem "railties", "~> 4.0"
gem "sprockets-rails", "~> 2.0"
gem "sprockets", "~> 2.0"
# NOTE: nokogiri dropped support for Ruby 2.0.0 on v1.7.0
gem "nokogiri", "< 1.7.0"
end
appraise "sprockets-rails 2 with sprockets 3" do
gem "railties", "~> 4.0"
gem "sproc... |
github | yasaichi/gakubuchi | https://github.com/yasaichi/gakubuchi | spec/spec_helper.rb | Ruby | mit | 46 | master | 4,388 | # This file was generated by the `rails generate rspec:install` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# The generated `.rspec` file contains `--require spec_helper` which will cause
# this file to always be loaded, without a need to explicitly require ... |
github | yasaichi/gakubuchi | https://github.com/yasaichi/gakubuchi | spec/rails_helper.rb | Ruby | mit | 46 | master | 2,716 | # This file is copied to spec/ when you run 'rails generate rspec:install'
ENV['RAILS_ENV'] ||= 'test'
require 'simplecov'
SimpleCov.start do
add_filter '/spec/'
end
require File.expand_path('../dummy/config/environment', __FILE__)
# Prevent database truncation if the environment is production
abort("The Rails en... |
github | yasaichi/gakubuchi | https://github.com/yasaichi/gakubuchi | spec/lib/gakubuchi_spec.rb | Ruby | mit | 46 | master | 798 | require "rails_helper"
RSpec.describe Gakubuchi do
describe ".configuration" do
subject { described_class.configuration }
it { is_expected.to be_an_instance_of Gakubuchi::Configuration }
end
describe ".configure" do
subject { described_class.configuration }
let(:expected_attrs) do
{
... |
github | yasaichi/gakubuchi | https://github.com/yasaichi/gakubuchi | spec/lib/generators/gakubuchi/install/install_generator_spec.rb | Ruby | mit | 46 | master | 1,480 | require "rails_helper"
require "ammeter/init"
require "generators/gakubuchi/install/install_generator"
RSpec.describe Gakubuchi::Generators::InstallGenerator, type: :generator do
destination File.expand_path("../tmp", __FILE__)
before do
prepare_destination
end
describe "generated files" do
before do... |
github | yasaichi/gakubuchi | https://github.com/yasaichi/gakubuchi | spec/lib/gakubuchi/rake_task_spec.rb | Ruby | mit | 46 | master | 3,196 | require "rails_helper"
RSpec.describe Gakubuchi::RakeTask do
let(:rake_task) { described_class.new(application) }
let(:application) { Rake::Application.new }
describe ".enhance" do
subject { proc { |block| described_class.enhance(application, &block) } }
before do
application.define_task(Rake::Ta... |
github | yasaichi/gakubuchi | https://github.com/yasaichi/gakubuchi | spec/lib/gakubuchi/configuration_spec.rb | Ruby | mit | 46 | master | 1,020 | require "rails_helper"
RSpec.describe Gakubuchi::Configuration do
let(:configuration) { described_class.new }
describe "#to_h" do
subject { configuration.to_h }
it { is_expected.to be_an_instance_of Hash }
end
describe "#leave_digest_named_templates" do
subject { configuration.leave_digest_named_... |
github | yasaichi/gakubuchi | https://github.com/yasaichi/gakubuchi | spec/lib/gakubuchi/template_spec.rb | Ruby | mit | 46 | master | 5,428 | require "rails_helper"
RSpec.describe Gakubuchi::Template do
let(:template) { described_class.new(source_path) }
let(:template_root) { described_class.root }
describe ".all" do
subject { described_class.all }
let(:expectation) do
[
described_class.new("foo.html.erb"),
described_cl... |
github | yasaichi/gakubuchi | https://github.com/yasaichi/gakubuchi | spec/lib/gakubuchi/task_spec.rb | Ruby | mit | 46 | master | 3,932 | require "rails_helper"
RSpec.describe Gakubuchi::Task do
let(:task) { described_class.new(Gakubuchi::Configuration.new) }
describe "#publish" do
subject { -> { task.publish(template) } }
let(:destination_path) { template.destination_path }
let(:template) { Gakubuchi::Template.new(source_path) }
... |
github | yasaichi/gakubuchi | https://github.com/yasaichi/gakubuchi | spec/lib/gakubuchi/engine_registrar_spec.rb | Ruby | mit | 46 | master | 3,009 | require "rails_helper"
RSpec.describe Gakubuchi::EngineRegistrar do
let(:engine_registrar) { described_class.new(env) }
let(:env) { Sprockets::Environment.new }
describe "#register" do
let(:described_method) { -> { engine_registrar.register(mime_type, engine) } }
let(:mime_type) { Gakubuchi::MimeType.ne... |
github | yasaichi/gakubuchi | https://github.com/yasaichi/gakubuchi | spec/lib/gakubuchi/railtie_spec.rb | Ruby | mit | 46 | master | 1,055 | require "rails_helper"
RSpec.describe Gakubuchi::Railtie do
describe ".rake_tasks" do
describe 'Rake.application["assets:clobber"]' do
subject { Pathname.glob(Rails.public_path.join("*")) }
before do
Rake.application["assets:precompile"].execute
Rake.application["assets:clobber"].exe... |
github | yasaichi/gakubuchi | https://github.com/yasaichi/gakubuchi | spec/lib/gakubuchi/mime_type_spec.rb | Ruby | mit | 46 | master | 1,542 | require "rails_helper"
RSpec.describe Gakubuchi::MimeType do
describe "#new" do
subject { -> { described_class.new(content_type) } }
context "when an invalid `content_type` is specified" do
let(:content_type) { "foo" }
it { is_expected.to raise_error(Gakubuchi::Error::InvalidMimeType, /#{content... |
github | yasaichi/gakubuchi | https://github.com/yasaichi/gakubuchi | spec/dummy/config/application.rb | Ruby | mit | 46 | master | 1,125 | require File.expand_path('../boot', __FILE__)
# Pick the frameworks you want:
require "sprockets/railtie"
Bundler.require(*Rails.groups)
require "rspec/rails"
require "haml-rails"
require "slim-rails"
require "gakubuchi"
module Dummy
class Application < Rails::Application
# Settings in config/environments/* t... |
github | yasaichi/gakubuchi | https://github.com/yasaichi/gakubuchi | spec/dummy/config/environments/development.rb | Ruby | mit | 46 | master | 1,605 | Dummy::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't have to restart the web ser... |
github | yasaichi/gakubuchi | https://github.com/yasaichi/gakubuchi | spec/dummy/config/environments/production.rb | Ruby | mit | 46 | master | 3,307 | Dummy::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, allowing both threaded web serv... |
github | yasaichi/gakubuchi | https://github.com/yasaichi/gakubuchi | spec/dummy/config/environments/test.rb | Ruby | mit | 46 | master | 2,052 | Dummy::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 "scratch space" for the test sui... |
github | yasaichi/gakubuchi | https://github.com/yasaichi/gakubuchi | lib/generators/gakubuchi/install/install_generator.rb | Ruby | mit | 46 | master | 819 | # frozen_string_literal: true
require "gakubuchi/configuration"
require "pathname"
require "rails/generators/base"
module Gakubuchi
module Generators
class InstallGenerator < ::Rails::Generators::Base
DEFAULT_DIRECTORY = ::Gakubuchi::Configuration.new.template_directory.freeze
desc "Create a Gakubuc... |
github | yasaichi/gakubuchi | https://github.com/yasaichi/gakubuchi | lib/gakubuchi/template.rb | Ruby | mit | 46 | master | 2,374 | # frozen_string_literal: true
require "forwardable"
require "gakubuchi/configuration"
require "gakubuchi/error"
require "pathname"
require "rails"
require "sprockets/railtie"
module Gakubuchi
class Template
extend ::Forwardable
attr_reader :source_path, :extname
def_delegators :source_path, :basename, :... |
github | yasaichi/gakubuchi | https://github.com/yasaichi/gakubuchi | lib/gakubuchi/rake_task.rb | Ruby | mit | 46 | master | 839 | # frozen_string_literal: true
require "gakubuchi/configuration"
require "gakubuchi/task"
module Gakubuchi
class RakeTask
attr_reader :application, :templates
attr_accessor :configuration
def self.enhance(application, &block)
new(application).tap do |rake_task|
yield(rake_task) if block_giv... |
github | yasaichi/gakubuchi | https://github.com/yasaichi/gakubuchi | lib/gakubuchi/configuration.rb | Ruby | mit | 46 | master | 666 | # frozen_string_literal: true
require "active_support/configurable"
require "forwardable"
module Gakubuchi
class << self
attr_writer :configuration
def configuration
@configuration ||= ::Gakubuchi::Configuration.new
end
def configure
yield(configuration) if block_given?
end
def... |
github | yasaichi/gakubuchi | https://github.com/yasaichi/gakubuchi | lib/gakubuchi/railtie.rb | Ruby | mit | 46 | master | 1,136 | # frozen_string_literal: true
require "gakubuchi/configuration"
require "gakubuchi/engine_registrar"
require "gakubuchi/mime_type"
require "gakubuchi/rake_task"
require "gakubuchi/template"
require "rails/railtie"
require "sprockets/railtie"
module Gakubuchi
class Railtie < ::Rails::Railtie
config.assets.configu... |
github | yasaichi/gakubuchi | https://github.com/yasaichi/gakubuchi | lib/gakubuchi/engine_registrar.rb | Ruby | mit | 46 | master | 1,459 | # frozen_string_literal: true
require "active_support/inflector"
require "grease"
require "sprockets"
module Gakubuchi
class EngineRegistrar
EXTENSION_WITH_SIGLE_DOT = /\A\.[^\.]+\z/
def initialize(env)
@env = env
end
def register(mime_type, engine_name_or_class)
engine = constantize(en... |
github | yasaichi/gakubuchi | https://github.com/yasaichi/gakubuchi | lib/gakubuchi/mime_type.rb | Ruby | mit | 46 | master | 537 | # frozen_string_literal: true
require "gakubuchi/error"
require "set"
module Gakubuchi
class MimeType
CONTENT_TYPE_FORMAT = %r(\A[^/]+/[^/]+\z)
attr_reader :content_type, :extensions
def initialize(content_type, extensions: [])
unless content_type =~ CONTENT_TYPE_FORMAT
message = %(`#{con... |
github | yasaichi/gakubuchi | https://github.com/yasaichi/gakubuchi | lib/gakubuchi/task.rb | Ruby | mit | 46 | master | 1,289 | # frozen_string_literal: true
require "fileutils"
require "logger"
require "rails"
module Gakubuchi
class Task
attr_reader :configuration
def initialize(configuration)
@configuration = configuration
end
def publish(templates)
Array(templates).each do |template|
src = template.di... |
github | danielpclark/PolyBelongsTo | https://github.com/danielpclark/PolyBelongsTo | Rakefile | Ruby | mit | 46 | master | 575 | 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 = 'PolyBelongsTo'
rdoc.options << '--line-numbers'
rdoc.rdoc_files.include('README.rdoc')... |
github | danielpclark/PolyBelongsTo | https://github.com/danielpclark/PolyBelongsTo | Gemfile | Ruby | mit | 46 | master | 549 | source 'https://rubygems.org'
gemspec
group :test do
gem 'simplecov'
gem "codeclimate-test-reporter", '~> 1.0.0'
end
group :development, :test do
rails_version = ENV["RAILS_VERSION"] || "default"
# if rails_version =~ /^3\./
# gem 'test-unit', ">= 1.2.3"
# end
rails = case rails_version
whe... |
github | danielpclark/PolyBelongsTo | https://github.com/danielpclark/PolyBelongsTo | poly_belongs_to.gemspec | Ruby | mit | 46 | master | 990 | $LOAD_PATH.push File.expand_path("../lib", __FILE__)
# Maintain your gem's version:
require "poly_belongs_to/version"
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "poly_belongs_to"
s.version = PolyBelongsTo::VERSION
s.authors = ["Daniel P. Clark"]
s.e... |
github | danielpclark/PolyBelongsTo | https://github.com/danielpclark/PolyBelongsTo | test/faked_collection_test.rb | Ruby | mit | 46 | master | 6,095 | require 'test_helper'
require 'minitest/autorun'
class FakedCollectionTest < ActiveSupport::TestCase
fixtures :all
let(:steve_photos) do
steve_prof = users(:steve).profiles.first
PolyBelongsTo::FakedCollection.new(steve_prof, Photo)
end
let(:null_object) do
PolyBelongsTo::FakedCollection.new()
... |
github | danielpclark/PolyBelongsTo | https://github.com/danielpclark/PolyBelongsTo | test/major_version_changes_test.rb | Ruby | mit | 46 | master | 2,230 | require 'test_helper'
require 'minitest/autorun'
class MajorVersionChangesTest < ActiveSupport::TestCase
fixtures :all
describe "Test breaking changes between major versions" do
let(:contact) { contacts(:bob_contact) }
if Gem::Dependency.new('', "< 1.0.0").match?('', PolyBelongsTo::VERSION)
it "pr... |
github | danielpclark/PolyBelongsTo | https://github.com/danielpclark/PolyBelongsTo | test/dup_test.rb | Ruby | mit | 46 | master | 3,582 | require 'test_helper'
require 'minitest/autorun'
class DupTest < ActiveSupport::TestCase
fixtures :all
describe PolyBelongsTo::Dup do
it "has method :pbt_dup_build" do
User.instance_methods.must_include(:pbt_dup_build)
User.methods.must_include(:pbt_dup_build)
end
it "has method :pbt_deep... |
github | danielpclark/PolyBelongsTo | https://github.com/danielpclark/PolyBelongsTo | test/test_helper.rb | Ruby | mit | 46 | master | 950 | ENV["RAILS_ENV"] = "test"
# require "codeclimate-test-reporter"
# CodeClimate::TestReporter.start
require 'simplecov'
SimpleCov.start
require File.expand_path("../../test/dummy/config/environment.rb", __FILE__)
ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../test/dummy/db/migrate", __FILE__)]
requir... |
github | danielpclark/PolyBelongsTo | https://github.com/danielpclark/PolyBelongsTo | test/pbt_test.rb | Ruby | mit | 46 | master | 6,268 | require 'test_helper'
require 'minitest/autorun'
class PbtTest < ActiveSupport::TestCase
fixtures :all
describe PolyBelongsTo::Pbt do
it "AttrSanitizer removes conflicting attributes" do
user = users(:bob)
PolyBelongsTo::Pbt::AttrSanitizer[user].must_equal Hash[id: nil, content: user.content].stri... |
github | danielpclark/PolyBelongsTo | https://github.com/danielpclark/PolyBelongsTo | test/singleton_set_test.rb | Ruby | mit | 46 | master | 1,174 | require 'test_helper'
require 'minitest/autorun'
class DupTest < ActiveSupport::TestCase
fixtures :all
describe PolyBelongsTo::SingletonSet do
let(:example){ users(:bob) }
let(:the_set){ PolyBelongsTo::SingletonSet.new }
it "formats name with #formatted_name" do
the_set.formatted_name(example).... |
github | danielpclark/PolyBelongsTo | https://github.com/danielpclark/PolyBelongsTo | test/core_test.rb | Ruby | mit | 46 | master | 14,034 | require 'test_helper'
require 'minitest/autorun'
class CoreTest < ActiveSupport::TestCase
fixtures :all
describe PolyBelongsTo::Core do
it "is a module" do
PolyBelongsTo::Core.must_be_kind_of Module
end
it "#poly? User as not polymorphic" do
user = users(:bob)
user.wont_be :poly?
... |
github | danielpclark/PolyBelongsTo | https://github.com/danielpclark/PolyBelongsTo | test/dummy/Rakefile | Ruby | mit | 46 | master | 240 | # Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require File.expand_path('../config/application', __FILE__)
DummyApp.load_tasks |
github | danielpclark/PolyBelongsTo | https://github.com/danielpclark/PolyBelongsTo | test/dummy/db/schema.rb | Ruby | mit | 46 | master | 7,729 | # encoding: UTF-8
# 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.
#
# Note that this schema.rb definition is the authoritative sou... |
github | danielpclark/PolyBelongsTo | https://github.com/danielpclark/PolyBelongsTo | test/dummy/db/migrate/20150216092449_create_contacts.rb | Ruby | mit | 46 | master | 215 | class CreateContacts < ActiveRecord::Migration
def change
create_table :contacts do |t|
t.integer :user_id
t.string :content
t.timestamps
end
add_index :contacts, :user_id
end
end |
github | danielpclark/PolyBelongsTo | https://github.com/danielpclark/PolyBelongsTo | test/dummy/db/migrate/20161209115003_create_events.rb | Ruby | mit | 46 | master | 209 | class CreateEvents < ActiveRecord::Migration
def change
create_table :events do |t|
t.integer :work_order_id
t.timestamps null: false
end
add_index :events, :work_order_id
end
end |
github | danielpclark/PolyBelongsTo | https://github.com/danielpclark/PolyBelongsTo | test/dummy/db/migrate/20150216092218_create_addresses.rb | Ruby | mit | 46 | master | 222 | class CreateAddresses < ActiveRecord::Migration
def change
create_table :addresses do |t|
t.references :addressable, polymorphic: true, index: true
t.string :content
t.timestamps
end
end
end |
github | danielpclark/PolyBelongsTo | https://github.com/danielpclark/PolyBelongsTo | test/dummy/db/migrate/20150211224225_create_phones.rb | Ruby | mit | 46 | master | 226 | class CreatePhones < ActiveRecord::Migration
def change
create_table :phones do |t|
t.references :phoneable, polymorphic: true, index: true
t.string :content
t.timestamps null: false
end
end
end |
github | danielpclark/PolyBelongsTo | https://github.com/danielpclark/PolyBelongsTo | test/dummy/db/migrate/20150220230146_create_squishies.rb | Ruby | mit | 46 | master | 221 | class CreateSquishies < ActiveRecord::Migration
def change
create_table :squishies do |t|
t.string :content
t.references :squishable, polymorphic: true, index: true
t.timestamps
end
end
end |
github | danielpclark/PolyBelongsTo | https://github.com/danielpclark/PolyBelongsTo | test/dummy/db/migrate/20150511161648_create_coffees.rb | Ruby | mit | 46 | master | 205 | class CreateCoffees < ActiveRecord::Migration
def change
create_table :coffees do |t|
t.references :coffeeable, polymorphic: true, index: true
t.timestamps null: false
end
end
end |
github | danielpclark/PolyBelongsTo | https://github.com/danielpclark/PolyBelongsTo | test/dummy/db/migrate/20150211224157_create_tags.rb | Ruby | mit | 46 | master | 215 | class CreateTags < ActiveRecord::Migration
def change
create_table :tags do |t|
t.integer :user_id
t.string :content
t.timestamps null: false
end
add_index :tags, :user_id
end
end |
github | danielpclark/PolyBelongsTo | https://github.com/danielpclark/PolyBelongsTo | test/dummy/db/migrate/20150216092411_create_photos.rb | Ruby | mit | 46 | master | 214 | class CreatePhotos < ActiveRecord::Migration
def change
create_table :photos do |t|
t.references :photoable, polymorphic: true, index: true
t.string :content
t.timestamps
end
end
end |
github | danielpclark/PolyBelongsTo | https://github.com/danielpclark/PolyBelongsTo | test/dummy/db/migrate/20161210145757_create_assembly_part_join_table.rb | Ruby | mit | 46 | master | 218 | class CreateAssemblyPartJoinTable < ActiveRecord::Migration
def change
create_join_table :assemblies, :parts do |t|
t.index [:assembly_id, :part_id]
t.index [:part_id, :assembly_id]
end
end
end |
github | danielpclark/PolyBelongsTo | https://github.com/danielpclark/PolyBelongsTo | test/dummy/db/migrate/20150216092519_create_ssns.rb | Ruby | mit | 46 | master | 203 | class CreateSsns < ActiveRecord::Migration
def change
create_table :ssns do |t|
t.integer :user_id
t.string :content
t.timestamps
end
add_index :ssns, :user_id
end
end |
github | danielpclark/PolyBelongsTo | https://github.com/danielpclark/PolyBelongsTo | test/dummy/db/migrate/20150220213422_create_geo_locations.rb | Ruby | mit | 46 | master | 235 | class CreateGeoLocations < ActiveRecord::Migration
def change
create_table :geo_locations do |t|
t.integer :address_id
t.string :content
t.timestamps
end
add_index :geo_locations, :address_id
end
end |
github | danielpclark/PolyBelongsTo | https://github.com/danielpclark/PolyBelongsTo | test/dummy/db/migrate/20150216092338_create_profiles.rb | Ruby | mit | 46 | master | 220 | class CreateProfiles < ActiveRecord::Migration
def change
create_table :profiles do |t|
t.references :profileable, polymorphic: true, index: true
t.string :content
t.timestamps
end
end
end |
github | danielpclark/PolyBelongsTo | https://github.com/danielpclark/PolyBelongsTo | test/dummy/db/migrate/20150301100658_create_tires.rb | Ruby | mit | 46 | master | 225 | class CreateTires < ActiveRecord::Migration
def change
create_table :tires do |t|
t.references :user, index: true
t.references :car, index: true
t.string :content
t.timestamps
end
end
end |
github | danielpclark/PolyBelongsTo | https://github.com/danielpclark/PolyBelongsTo | test/dummy/app/models/user.rb | Ruby | mit | 46 | master | 290 | class User < ActiveRecord::Base
has_one :ssn, dependent: :destroy
has_many :tags, dependent: :destroy
has_many :contacts, dependent: :destroy
has_many :profiles, as: :profileable, dependent: :destroy
has_many :cars, dependent: :destroy
has_many :tires, dependent: :destroy
end |
github | danielpclark/PolyBelongsTo | https://github.com/danielpclark/PolyBelongsTo | test/dummy/app/models/profile.rb | Ruby | mit | 46 | master | 322 | class Profile < ActiveRecord::Base
belongs_to :profileable, polymorphic: true
has_many :phones, as: :phoneable, dependent: :destroy
has_many :addresses, as: :addressable, dependent: :destroy
has_one :photo, as: :photoable, dependent: :destroy
accepts_nested_attributes_for :phones, :addresses, :photo
en... |
github | danielpclark/PolyBelongsTo | https://github.com/danielpclark/PolyBelongsTo | test/dummy/app/models/contact.rb | Ruby | mit | 46 | master | 205 | class Contact < ActiveRecord::Base
belongs_to :user
belongs_to :contactable, polymorphic: true
has_one :profile, as: :profileable, dependent: :destroy
accepts_nested_attributes_for :profile
end |
github | danielpclark/PolyBelongsTo | https://github.com/danielpclark/PolyBelongsTo | test/dummy/config/routes.rb | Ruby | mit | 46 | master | 1,592 | DummyApp.routes.draw do
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
# root 'welcome#index'
# Example of regular route:
# get 'products/:id' => 'catalog#vie... |
github | danielpclark/PolyBelongsTo | https://github.com/danielpclark/PolyBelongsTo | test/dummy/config/application.rb | Ruby | mit | 46 | master | 1,286 | require File.expand_path('../boot', __FILE__)
require 'rails/all'
Bundler.require(*Rails.groups)
require "poly_belongs_to"
module Dummy
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in c... |
github | danielpclark/PolyBelongsTo | https://github.com/danielpclark/PolyBelongsTo | test/dummy/config/environments/production.rb | Ruby | mit | 46 | master | 3,295 | DummyApp.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, allowing both threaded web servers
# an... |
github | danielpclark/PolyBelongsTo | https://github.com/danielpclark/PolyBelongsTo | test/dummy/config/environments/development.rb | Ruby | mit | 46 | master | 1,591 | DummyApp.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't have to restart the web server when y... |
github | danielpclark/PolyBelongsTo | https://github.com/danielpclark/PolyBelongsTo | test/dummy/config/environments/test.rb | Ruby | mit | 46 | master | 1,746 | DummyApp.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 "scratch space" for the test suite and is ... |
github | danielpclark/PolyBelongsTo | https://github.com/danielpclark/PolyBelongsTo | test/dummy/config/initializers/assets.rb | Ruby | mit | 46 | master | 459 | # Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.
DummyApp.config.assets.version = '1.0'
# Add additional assets to the asset load path
# DummyApp.config.assets.paths << Emoji.images_path
# Precompile additional assets.
# applicat... |
github | danielpclark/PolyBelongsTo | https://github.com/danielpclark/PolyBelongsTo | lib/poly_belongs_to.rb | Ruby | mit | 46 | master | 954 | $LOAD_PATH << File.join(File.dirname(__FILE__), "/poly_belongs_to")
require 'active_support/concern'
require 'poly_belongs_to/sorted_reflection_decorator'
ActiveRecord::Reflection::ClassMethods.send(:include, PolyBelongsTo::SortedReflectionDecorator )
require 'poly_belongs_to/version'
require 'poly_belongs_to/core'
req... |
github | danielpclark/PolyBelongsTo | https://github.com/danielpclark/PolyBelongsTo | lib/poly_belongs_to/singleton_set.rb | Ruby | mit | 46 | master | 2,221 | require 'set'
module PolyBelongsTo
##
# PolyBelongsTo::SingletonSet is a modified instance of Set for maintaining singletons of ActiveRecord objects during any recursive flow.
class SingletonSet
# Creates two internal Sets
# @return [self]
def initialize
@set = Set.new
@flagged = Set.new
... |
github | danielpclark/PolyBelongsTo | https://github.com/danielpclark/PolyBelongsTo | lib/poly_belongs_to/faked_collection.rb | Ruby | mit | 46 | master | 2,888 | module PolyBelongsTo
##
# PolyBelongsTo::FakedCollection emulates an ActiveRecord::CollectionProxy of exactly one or zero items
class FakedCollection
# Create the Faked Colllection Proxy
def initialize(obj = nil, child = nil)
@obj = obj
@child = child
if obj.nil? || child.nil?
@i... |
github | danielpclark/PolyBelongsTo | https://github.com/danielpclark/PolyBelongsTo | lib/poly_belongs_to/sorted_reflection_decorator.rb | Ruby | mit | 46 | master | 388 | module PolyBelongsTo
module SortedReflectionDecorator
def self.included(base)
base.module_exec do
original_method = instance_method(:reflect_on_all_associations)
define_method(:reflect_on_all_associations) do |*args, &block|
original_method.bind(self).call(*args, &block).sort_by {|... |
github | danielpclark/PolyBelongsTo | https://github.com/danielpclark/PolyBelongsTo | lib/poly_belongs_to/core.rb | Ruby | mit | 46 | master | 7,130 | module PolyBelongsTo
##
# PolyBelongsTo::Core are the core set of methods included on all ActiveModel & ActiveRecord instances.
module Core
extend ActiveSupport::Concern
included do
# @return [Symbol, nil] first belongs_to relation
def self.pbt
reflect_on_all_associations(:belongs_to)... |
github | danielpclark/PolyBelongsTo | https://github.com/danielpclark/PolyBelongsTo | lib/poly_belongs_to/dup.rb | Ruby | mit | 46 | master | 2,478 | module PolyBelongsTo
##
# PolyBelongsTo::Dup contains duplication methods which is included on all ActiveModel & ActiveRecord instances
module Dup
extend ActiveSupport::Concern
included do
# Build child object by dup'ing its attributes
# @param item_to_build_on [Object] Object on which to bui... |
github | danielpclark/PolyBelongsTo | https://github.com/danielpclark/PolyBelongsTo | lib/poly_belongs_to/pbt.rb | Ruby | mit | 46 | master | 4,678 | module PolyBelongsTo
##
# PolyBelongsTo::Pbt is where internal methods are for implementing core and duplication methods; available on all instances.
# They are available for other use if the need should arise.
module Pbt
# Strips date and id fields dup'd attributes
# @param obj [Object] ActiveRecord in... |
github | kazuhisa/ken_all | https://github.com/kazuhisa/ken_all | Rakefile | Ruby | mit | 46 | master | 520 | #!/usr/bin/env rake
begin
require 'bundler/setup'
rescue LoadError
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
begin
require 'rdoc/task'
rescue LoadError
require 'rdoc/rdoc'
require 'rake/rdoctask'
RDoc::Task = Rake::RDocTask
end
RDoc::Task.new(:rdoc) do |rdoc|
rdoc.r... |
github | kazuhisa/ken_all | https://github.com/kazuhisa/ken_all | ken_all.gemspec | Ruby | mit | 46 | master | 1,112 | lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
# Maintain your gem's version:
require "ken_all/version"
# Describe your gem and declare its dependencies:
Gem::Specification.new do |s|
s.name = "ken_all"
s.version = KenAll::VERSION
s.authors = ["... |
github | kazuhisa/ken_all | https://github.com/kazuhisa/ken_all | db/migrate/20121028092517_create_ken_all_postal_codes.rb | Ruby | mit | 46 | master | 560 | if ActiveRecord.gem_version >= Gem::Version.new('4.2')
class CreateKenAllPostalCodes < ActiveRecord::Migration[4.2]; end
else
class CreateKenAllPostalCodes < ActiveRecord::Migration; end
end
CreateKenAllPostalCodes.class_eval do
def change
create_table :ken_all_postal_codes do |t|
t.string :code
... |
github | kazuhisa/ken_all | https://github.com/kazuhisa/ken_all | db/migrate/20130722102956_column_change_postal_codes.rb | Ruby | mit | 46 | master | 620 | if ActiveRecord.gem_version >= Gem::Version.new('4.2')
class ColumnChangePostalCodes < ActiveRecord::Migration[4.2]; end
else
class ColumnChangePostalCodes < ActiveRecord::Migration; end
end
ColumnChangePostalCodes.class_eval do
def change
change_column :ken_all_postal_codes, :address1, :text
change_colu... |
github | kazuhisa/ken_all | https://github.com/kazuhisa/ken_all | app/models/ken_all/postal_code.rb | Ruby | mit | 46 | master | 255 | module KenAll
class PostalCode < ActiveRecord::Base
validates :code, :presence => true
if Rails.version < "4"
attr_accessible :code, :address1, :address2, :address3,
:address_kana1, :address_kana2, :address_kana3
end
end
end |
github | kazuhisa/ken_all | https://github.com/kazuhisa/ken_all | spec/spec_helper.rb | Ruby | mit | 46 | master | 1,240 | # This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../spec/dummy/config/environment", __FILE__)
require 'rspec/rails'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Ra... |
github | kazuhisa/ken_all | https://github.com/kazuhisa/ken_all | spec/dummy/config/boot.rb | Ruby | mit | 46 | master | 209 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
require 'bundler/setup' # Set up gems listed in the Gemfile.
# require 'bootsnap/setup' # Speed up boot time by caching expensive operations. |
github | kazuhisa/ken_all | https://github.com/kazuhisa/ken_all | spec/dummy/config/application.rb | Ruby | mit | 46 | master | 1,082 | 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_view/railtie"
require "action_cable/eng... |
github | kazuhisa/ken_all | https://github.com/kazuhisa/ken_all | spec/dummy/db/schema.rb | Ruby | mit | 46 | master | 1,079 | # 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.
#
# Note that this schema.rb definition is the authoritative source for your
# dat... |
github | kazuhisa/ken_all | https://github.com/kazuhisa/ken_all | spec/lib/ken_all_spec.rb | Ruby | mit | 46 | master | 5,313 | require 'spec_helper'
require 'rake'
describe KenAll::Import do
before(:all) do
load "#{Rails.root}/Rakefile"
Rake::Task['db:setup'].invoke
end
let(:obj){KenAll::Import.new(:visualize => false)}
describe 'ZIPファイルからのインポート' do
it "正しく取り込まれること" do
ENV['FILE'] = File.join(File.dirname(__FILE__)... |
github | kazuhisa/ken_all | https://github.com/kazuhisa/ken_all | spec/models/ken_all/postal_code_spec.rb | Ruby | mit | 46 | master | 1,054 | # coding: utf-8
require 'spec_helper'
describe KenAll::PostalCode do
context "正常なデータの場合" do
let(:postal_code){KenAll::PostalCode.new(:code => "7000823", :address1 => "岡山県", :address2 => "岡山市",
:address3 => "丸の内", :address_kana1 => "オカヤマケン", :address_kana2 => "オカヤマシキタク",
... |
github | kazuhisa/ken_all | https://github.com/kazuhisa/ken_all | lib/ken_all.rb | Ruby | mit | 46 | master | 262 | require 'rubygems'
require 'open-uri'
require 'tempfile'
require 'zip'
require 'csv'
require 'curses'
require 'activerecord-import'
require 'ken_all/visualizer'
require 'ken_all/engine'
require 'ken_all/import'
require 'ken_all/merge_box'
require 'ken_all/post' |
github | kazuhisa/ken_all | https://github.com/kazuhisa/ken_all | lib/ken_all/import.rb | Ruby | mit | 46 | master | 2,837 | # coding: utf-8
module KenAll
class OldSchemaException < StandardError
end
class Import
URI = "http://www.post.japanpost.jp/zipcode/dl/kogaki/zip/ken_all.zip"
def initialize(opt = { visualize: true })
@visualizer = KenAll::Visualizer.new(opt[:visualize])
return unless old_schema?
err... |
github | kazuhisa/ken_all | https://github.com/kazuhisa/ken_all | lib/ken_all/visualizer.rb | Ruby | mit | 46 | master | 1,813 | # coding: utf-8
module KenAll
class Visualizer
RED = 1
GREEN = 2
def initialize(visualize = true)
@visualize = visualize
end
def screen_init
if @visualize
Curses.init_screen
Curses.start_color
Curses.init_pair RED, Curses::COLOR_RED, Curses::COLOR_BLACK
... |
github | kazuhisa/ken_all | https://github.com/kazuhisa/ken_all | lib/ken_all/post.rb | Ruby | mit | 46 | master | 1,217 | # coding: utf-8
module KenAll
class Post
NOT_FOUND = /^以下に掲載がない場合$/
NEXT_ADDRESS = /^.+の次に番地がくる場合$/
WHOLE_PLACE = /.+一円$/
attr_accessor :code, :address1, :address2, :address3, :address_kana1, :address_kana2, :address_kana3
def initialize(row = nil)
unless row.nil?
self.code = row[2... |
github | kazuhisa/ken_all | https://github.com/kazuhisa/ken_all | lib/ken_all/merge_box.rb | Ruby | mit | 46 | master | 651 | # coding: utf-8
module KenAll
class MergeBox
def initialize
@list = []
end
def add(post)
@list << post
end
def clear
@list = []
end
def to_array
post = Post.new
post.code = @list[0].code
post.address1 = @list[0].address1
post.address2 = @list[0... |
github | kazuhisa/ken_all | https://github.com/kazuhisa/ken_all | lib/tasks/ken_all_tasks.rake | Ruby | mit | 46 | master | 491 | namespace :ken_all do
desc "Download & Import KEN_ALL"
task :import => :environment do
import = KenAll::Import.new
import.from_net
end
namespace :import do
desc "Silent Download & Import KEN_ALL"
task :silent => :environment do
import = KenAll::Import.new(visualize: false)
import.fr... |
github | sonots/haikanko | https://github.com/sonots/haikanko | Guardfile | Ruby | mit | 46 | master | 345 | # A sample Guardfile
# More info at https://github.com/guard/guard#readme
guard 'rspec' do
notifier(%r{^spec/.+_spec\.rb$})
notifier('spec/spec_helper.rb') { "bundle exec spec" }
notifier(%r{^models/(.+)\.rb$}) { |m| "spec/models/#{m[1]}_spec.rb" }
notifier(%r{^controllers/(.+)\.rb$}) { |m| "spec/controllers... |
github | sonots/haikanko | https://github.com/sonots/haikanko | boot.rb | Ruby | mit | 46 | master | 399 | # encoding: utf-8
require 'bundler/setup'
APP_ROOT = File.expand_path(__dir__)
Bundler.require(:default)
Bundler.require(:development) if Bootloader.development?
$logger = Bootloader.logger($stdout, 'info')
$logger = Bootloader.logger($stdout, 'debug') if Bootloader.development?
Bootloader.load_configs
Bootloader.load... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.