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 | rubymonolith/fixturebot | https://github.com/rubymonolith/fixturebot | lib/fixturebot/fixture_set.rb | Ruby | mit | 192 | main | 823 | # frozen_string_literal: true
module FixtureBot
class FixtureSet
attr_reader :tables
def initialize(schema, definition)
@tables = {}
schema.tables.each_key { |name| @tables[name] = {} }
schema.join_tables.each_key { |name| @tables[name] = {} }
keys = KeyRegistry.new(definition.rows... |
github | rubymonolith/fixturebot | https://github.com/rubymonolith/fixturebot | lib/fixturebot/definition.rb | Ruby | mit | 192 | main | 1,165 | # frozen_string_literal: true
module FixtureBot
class Definition
attr_reader :defaults, :rows
def initialize(schema)
@schema = schema
@defaults = {}
@rows = []
schema.tables.each_value do |table|
@defaults[table.name] = {}
define_table_method(table)
end
end... |
github | rubymonolith/fixturebot | https://github.com/rubymonolith/fixturebot | lib/fixturebot/schema.rb | Ruby | mit | 192 | main | 3,357 | # frozen_string_literal: true
module FixtureBot
class Schema
Table = Data.define(:name, :singular_name, :columns, :associations, :key, :primary_key) do
def initialize(name:, singular_name:, columns:, associations: [], key: Key::Integer, primary_key: :id)
super
end
def belongs_to_associ... |
github | rubymonolith/fixturebot | https://github.com/rubymonolith/fixturebot | lib/fixturebot/rails.rb | Ruby | mit | 192 | main | 1,718 | # frozen_string_literal: true
require "fixturebot"
require_relative "rails/schema_loader"
require_relative "rails/cli"
require_relative "rails/railtie" if defined?(::Rails::Railtie)
module FixtureBot
module Rails
def self.compile(fixtures_file: nil, output_dir: nil)
fixtures_file = resolve_fixtures_file(f... |
github | rubymonolith/fixturebot | https://github.com/rubymonolith/fixturebot | lib/fixturebot/key_registry.rb | Ruby | mit | 192 | main | 558 | # frozen_string_literal: true
module FixtureBot
class KeyRegistry
def initialize(rows, schema_tables)
@values = {}
rows.each do |row|
table = schema_tables[row.table_name]
pk_col = table.primary_key
@values[[row.table_name, row.name]] = if row.literal_values.key?(pk_col)
... |
github | rubymonolith/fixturebot | https://github.com/rubymonolith/fixturebot | lib/fixturebot/row.rb | Ruby | mit | 192 | main | 4,498 | # frozen_string_literal: true
module FixtureBot
module Row
TableReference = Data.define(:table_name, :record_name)
TagRef = Data.define(:other_table, :refs)
JoinRow = Data.define(:key, :join_table, :row)
Declaration = Data.define(:table_name, :name, :literal_values, :association_refs, :tag_refs)
... |
github | rubymonolith/fixturebot | https://github.com/rubymonolith/fixturebot | lib/fixturebot/syntax.rb | Ruby | mit | 192 | main | 2,080 | # frozen_string_literal: true
require "active_support/core_ext/string/inflections"
require "active_support/core_ext/hash/keys"
module FixtureBot
module Syntax
module Methods
def build(table_name, fixture_name, **attributes)
record = send(table_name.to_s.pluralize, fixture_name).dup
record.... |
github | rubymonolith/fixturebot | https://github.com/rubymonolith/fixturebot | lib/fixturebot/cli.rb | Ruby | mit | 192 | main | 1,616 | # frozen_string_literal: true
require "thor"
module FixtureBot
class CLI < Thor
def self.exit_on_failure?
true
end
desc "compile DIR", "Compile DIR/schema.rb and DIR/fixtures.rb to YAML fixture files"
def compile(dir)
fixture_set = load_fixture_set(dir)
output_dir = File.join(dir... |
github | rubymonolith/fixturebot | https://github.com/rubymonolith/fixturebot | lib/fixturebot/key.rb | Ruby | mit | 192 | main | 264 | # frozen_string_literal: true
require_relative "key/integer"
require_relative "key/uuid"
module FixtureBot
module Key
# Backward compatibility
def self.generate(table_name, record_name)
Integer.generate(table_name, record_name)
end
end
end |
github | rubymonolith/fixturebot | https://github.com/rubymonolith/fixturebot | lib/fixturebot/compiler.rb | Ruby | mit | 192 | main | 736 | # frozen_string_literal: true
require "yaml"
require "fileutils"
module FixtureBot
class Compiler
def initialize(fixture_set)
@fixture_set = fixture_set
end
def compile(output_dir)
FileUtils.mkdir_p(output_dir)
@fixture_set.tables.each do |table_name, records|
next if records.... |
github | rubymonolith/fixturebot | https://github.com/rubymonolith/fixturebot | lib/fixturebot/rspec.rb | Ruby | mit | 192 | main | 228 | # frozen_string_literal: true
require "fixturebot/rails"
require "fixturebot/syntax"
RSpec.configure do |config|
config.before(:suite) do
FixtureBot::Rails.compile
end
config.include FixtureBot::Syntax::Methods
end |
github | rubymonolith/fixturebot | https://github.com/rubymonolith/fixturebot | lib/fixturebot/key/uuid.rb | Ruby | mit | 192 | main | 632 | # frozen_string_literal: true
require "digest/sha1"
module FixtureBot
module Key
module Uuid
NAMESPACE = "fixturebot"
module_function
def generate(table_name, record_name)
digest = Digest::SHA1.digest("#{NAMESPACE}:#{table_name}:#{record_name}")
# Set version 5 (bits 4-7 of b... |
github | rubymonolith/fixturebot | https://github.com/rubymonolith/fixturebot | lib/fixturebot/key/integer.rb | Ruby | mit | 192 | main | 256 | # frozen_string_literal: true
require "zlib"
module FixtureBot
module Key
module Integer
module_function
def generate(table_name, record_name)
Zlib.crc32("#{table_name}:#{record_name}") & 0x7FFFFFFF
end
end
end
end |
github | rubymonolith/fixturebot | https://github.com/rubymonolith/fixturebot | lib/fixturebot/rails/railtie.rb | Ruby | mit | 192 | main | 409 | # frozen_string_literal: true
module FixtureBot
module Rails
class Railtie < ::Rails::Railtie
config.fixturebot = ActiveSupport::OrderedOptions.new
rake_tasks do
namespace :fixturebot do
desc "Compile FixtureBot DSL to YAML fixture files"
task compile: :environment do
... |
github | rubymonolith/fixturebot | https://github.com/rubymonolith/fixturebot | lib/fixturebot/rails/cli.rb | Ruby | mit | 192 | main | 814 | # frozen_string_literal: true
require "fixturebot/cli"
module FixtureBot
module Rails
class CLI < FixtureBot::CLI
desc "compile FIXTURES_FILE [OUTPUT_DIR]", "Compile FixtureBot DSL to YAML fixture files"
def compile(fixtures_path, output_dir = "test/fixtures")
unless File.exist?(fixtures_pat... |
github | rubymonolith/fixturebot | https://github.com/rubymonolith/fixturebot | lib/fixturebot/rails/schema_loader.rb | Ruby | mit | 192 | main | 3,966 | # frozen_string_literal: true
require "active_record"
module FixtureBot
module Rails
class SchemaLoader
def self.load(connection = ActiveRecord::Base.connection)
new(connection).load
end
def initialize(connection)
@connection = connection
end
def load
bui... |
github | rubymonolith/fixturebot | https://github.com/rubymonolith/fixturebot | spec/fixturebot_spec.rb | Ruby | mit | 192 | main | 6,147 | # frozen_string_literal: true
require "tmpdir"
RSpec.describe FixtureBot do
it "has a version number" do
expect(FixtureBot::VERSION).not_to be nil
end
describe ".define" do
let(:schema) do
FixtureBot::Schema.define do
table :users, singular: :user, columns: [:name, :email]
table :... |
github | rubymonolith/fixturebot | https://github.com/rubymonolith/fixturebot | spec/spec_helper.rb | Ruby | mit | 192 | main | 494 | # frozen_string_literal: true
require "simplecov"
SimpleCov.start do
add_filter "/spec/"
add_filter "/playground/"
enable_coverage :branch
end
require "fixturebot"
RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
config.example_status_persistence_file_path = ".rspec_status... |
github | rubymonolith/fixturebot | https://github.com/rubymonolith/fixturebot | spec/integration/rails_app_spec.rb | Ruby | mit | 192 | main | 7,653 | # frozen_string_literal: true
require "spec_helper"
require "tmpdir"
require "open3"
require "yaml"
require "zlib"
RSpec.describe "Rails integration", :integration do
GEM_ROOT = File.expand_path("../..", __dir__)
def run_cmd!(cmd, chdir:, unbundled: true)
output, status = if unbundled
Bundler.with_unbu... |
github | rubymonolith/fixturebot | https://github.com/rubymonolith/fixturebot | spec/fixturebot/association_spec.rb | Ruby | mit | 192 | main | 1,579 | # frozen_string_literal: true
RSpec.describe "Association resolve" do
let(:keys) do
# Simple stub that generates keys on the fly
Object.new.tap do |obj|
def obj.resolve(table_name, record_name)
FixtureBot::Key::Integer.generate(table_name, record_name)
end
end
end
describe Fixtur... |
github | rubymonolith/fixturebot | https://github.com/rubymonolith/fixturebot | spec/fixturebot/key_spec.rb | Ruby | mit | 192 | main | 1,533 | # frozen_string_literal: true
RSpec.describe FixtureBot::Key do
describe "Key::Integer" do
subject(:strategy) { FixtureBot::Key::Integer }
it "generates deterministic IDs" do
id1 = strategy.generate(:users, :admin)
id2 = strategy.generate(:users, :admin)
expect(id1).to eq(id2)
end
... |
github | rubymonolith/fixturebot | https://github.com/rubymonolith/fixturebot | spec/fixturebot/features_spec.rb | Ruby | mit | 192 | main | 7,694 | # frozen_string_literal: true
RSpec.describe "New features" do
describe "UUID tables" do
let(:schema) do
FixtureBot::Schema.define do
table :projects, singular: :project, columns: [:name], key: FixtureBot::Key::Uuid
end
end
it "generates UUID primary keys" do
result = FixtureBo... |
github | rubymonolith/fixturebot | https://github.com/rubymonolith/fixturebot | spec/fixturebot/compiler_spec.rb | Ruby | mit | 192 | main | 2,231 | # frozen_string_literal: true
require "tmpdir"
require "yaml"
RSpec.describe FixtureBot::Compiler do
let(:schema) do
FixtureBot::Schema.define do
table :users, singular: :user, columns: [:name, :email]
table :posts, singular: :post, columns: [:title, :author_id] do
belongs_to :author, table:... |
github | rubymonolith/fixturebot | https://github.com/rubymonolith/fixturebot | spec/fixturebot/schema_loader_spec.rb | Ruby | mit | 192 | main | 3,602 | # frozen_string_literal: true
require "fixturebot/rails"
RSpec.describe FixtureBot::Rails::SchemaLoader do
before do
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
ActiveRecord::Schema.define(version: 2024_01_01_000000) do
create_table "users", force: :cascade do |t... |
github | rubymonolith/fixturebot | https://github.com/rubymonolith/fixturebot | spec/fixturebot/syntax_spec.rb | Ruby | mit | 192 | main | 4,939 | # frozen_string_literal: true
require "spec_helper"
require "fixturebot/syntax"
RSpec.describe FixtureBot::Syntax::Methods do
let(:test_context) do
Object.new.tap do |ctx|
ctx.extend(FixtureBot::Syntax::Methods)
# Stub fixture accessor: users(:brad), users(:alice)
brad = double("brad",
... |
github | rubymonolith/fixturebot | https://github.com/rubymonolith/fixturebot | spec/fixturebot/rails/compile_spec.rb | Ruby | mit | 192 | main | 2,880 | # frozen_string_literal: true
require "fixturebot/rails"
require "tmpdir"
RSpec.describe FixtureBot::Rails, ".compile" do
before do
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
ActiveRecord::Schema.define(version: 2024_01_01_000000) do
create_table "users", force:... |
github | rubymonolith/fixturebot | https://github.com/rubymonolith/fixturebot | playground/blog/schema.rb | Ruby | mit | 192 | main | 615 | FixtureBot::Schema.define do
table :users, singular: :user, columns: [:name, :email]
table :posts, singular: :post, columns: [:title, :body, :author_id] do
belongs_to :author, table: :users
end
table :comments, singular: :comment, columns: [:body, :post_id, :author_id] do
belongs_to :post, table: :pos... |
github | rubymonolith/fixturebot | https://github.com/rubymonolith/fixturebot | playground/blog/fixtures.rb | Ruby | mit | 192 | main | 1,240 | FixtureBot.define do
user.email { |fixture| "#{fixture.key}@blog.test" }
user :brad do
name "Brad"
email "brad@blog.test"
end
user :alice do
name "Alice"
end
user :charlie do
name "Charlie"
end
tag.name { |fixture| fixture.key.to_s.capitalize }
tag :ruby
tag :rails
tag :testin... |
github | vvchik/vagrant-serverspec | https://github.com/vvchik/vagrant-serverspec | vagrant-serverspec.gemspec | Ruby | mit | 192 | master | 1,438 | lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'vagrant-serverspec/version'
Gem::Specification.new do |gem|
gem.name = 'vagrant-serverspec'
gem.homepage = 'https://github.com/vvchik/vagrant-serverspec'
gem.version = VagrantPlugins::S... |
github | vvchik/vagrant-serverspec | https://github.com/vvchik/vagrant-serverspec | test/Docker/spec_helper.rb | Ruby | mit | 192 | master | 235 | #require 'serverspec'
#require 'net/ssh'
#set :backend, :ssh
# Disable sudo
# set :disable_sudo, true
# Set environment variables
# set :env, :LANG => 'C', :LC_MESSAGES => 'C'
# Set PATH
# set :path, '/sbin:/usr/local/sbin:$PATH' |
github | vvchik/vagrant-serverspec | https://github.com/vvchik/vagrant-serverspec | test/Docker/Vagrantfile | Ruby | mit | 192 | master | 448 | Vagrant.configure('2') do |config|
config.vm.provider "docker" do |d|
d.vagrant_vagrantfile = "./Docker_Vagrantfile"
d.image = "jjhughes57/docker-vagrant-ubuntu"
d.has_ssh = true
end
config.vm.provision :shell, inline: <<-EOF
sudo apt-get install -y vim
touch /tmp/testfile
EOF
config.vm.... |
github | vvchik/vagrant-serverspec | https://github.com/vvchik/vagrant-serverspec | test/windows/sample_spec.rb | Ruby | mit | 192 | master | 901 | require_relative 'spec_helper'
#describe file('C:\\programdata\\chocolatey\\bin\\console.exe') do
# it { should be_file }
#end
describe windows_feature('Web-Server') do
it{ should be_installed.by("powershell") }
end
#describe windows_registry_key(
# 'HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Ex... |
github | vvchik/vagrant-serverspec | https://github.com/vvchik/vagrant-serverspec | test/windows/vagrantfile | Ruby | mit | 192 | master | 1,741 | # -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.require_version ">= 1.6.2"
Vagrant.configure("2") do |config|
config.vm.define "windows"
config.vm.box = "windows"
config.vm.communicator = "winrm"
# Admin user name and password
config.winrm.username = "vagrant"
config.winrm.password = "vagran... |
github | vvchik/vagrant-serverspec | https://github.com/vvchik/vagrant-serverspec | test/windows/spec_helper.rb | Ruby | mit | 192 | master | 465 | #require 'serverspec'
#require 'pathname'
#require 'winrm'
#set :backend, :winrm
#set :os, :family => 'windows'
#user = 'vagrant'
#pass = 'vagrant'
##endpoint = "http://#{ENV['TARGET_HOST']}:5985/wsman"
#endpoint = "http://10.128.139.116:5985/wsman"
#winrm = ::WinRM::WinRMWebService.new(endpoint, :ssl, :user => user, ... |
github | vvchik/vagrant-serverspec | https://github.com/vvchik/vagrant-serverspec | test/ubuntu/Vagrantfile | Ruby | mit | 192 | master | 472 | Vagrant.configure('2') do |config|
config.vm.box = 'precise64'
config.vm.box_url = 'http://cloud-images.ubuntu.com/precise/current/precise-server-cloudimg-vagrant-amd64-disk1.box'
config.vm.provision :shell, inline: <<-EOF
sudo ufw allow 22
yes | sudo ufw enable
EOF
config.vm.provision :serverspec d... |
github | vvchik/vagrant-serverspec | https://github.com/vvchik/vagrant-serverspec | test/ubuntu/sample_spec.rb | Ruby | mit | 192 | master | 233 | require_relative 'spec_helper'
describe package('ufw') do
it { should be_installed }
end
describe service('ufw') do
it { should be_enabled }
it { should be_running }
end
describe port(22) do
it { should be_listening }
end |
github | vvchik/vagrant-serverspec | https://github.com/vvchik/vagrant-serverspec | lib/vagrant-serverspec.rb | Ruby | mit | 192 | master | 356 | require 'vagrant-serverspec/plugin'
require 'vagrant-serverspec/version'
require 'vagrant-serverspec/error'
module VagrantPlugins
module ServerSpec
def self.source_root
@source_root ||= Pathname.new(File.expand_path('../../', __FILE__))
end
I18n.load_path << File.expand_path('locales/en.yml', sour... |
github | vvchik/vagrant-serverspec | https://github.com/vvchik/vagrant-serverspec | lib/vagrant-serverspec/provisioner.rb | Ruby | mit | 192 | master | 5,289 | # This implementation executes rspec in-process. Because rspec effectively
# takes ownership of the global scope, executing rspec within a child process
# may be preferred.
module VagrantPlugins
module ServerSpec
class Provisioner < Vagrant.plugin('2', :provisioner)
def initialize(machine, config)
s... |
github | vvchik/vagrant-serverspec | https://github.com/vvchik/vagrant-serverspec | lib/vagrant-serverspec/plugin.rb | Ruby | mit | 192 | master | 590 | require 'rspec/core'
require 'serverspec'
require 'pathname'
require 'winrm'
require 'net/ssh'
require 'net/ssh/proxy/command'
require 'os'
module VagrantPlugins
module ServerSpec
class Plugin < Vagrant.plugin('2')
name 'serverspec'
description <<-DESC
This plugin executes a serverspec suite ag... |
github | vvchik/vagrant-serverspec | https://github.com/vvchik/vagrant-serverspec | lib/vagrant-serverspec/error.rb | Ruby | mit | 192 | master | 525 | module Vagrant
module Errors
class ServerSpecFailed < VagrantError
error_key(:serverspec_failed)
end
class ServerSpecFailedHtml < VagrantError
error_key(:serverspec_failed_html)
end
class ServerSpecFailedHtmlJunit < VagrantError
error_key(:serverspec_failed_html_junit)
end
... |
github | vvchik/vagrant-serverspec | https://github.com/vvchik/vagrant-serverspec | lib/vagrant-serverspec/config.rb | Ruby | mit | 192 | master | 2,786 | module VagrantPlugins
module ServerSpec
class Config < Vagrant.plugin('2', :config)
attr_accessor :spec_files
attr_accessor :spec_pattern
attr_accessor :spec_excluded_files
attr_accessor :spec_exclude_pattern
attr_accessor :error_no_spec_files_found
attr_accessor :html_output_f... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | comatose.gemspec | Ruby | mit | 192 | master | 4,936 | # Generated on Tue May 20 20:13:12 -0500 2008
Gem::Specification.new do |s|
s.name = "comatose"
s.version = "2.0.5"
s.date = "2008-10-31" # 2008-05-20
s.summary = "Micro CMS designed for being embedded into existing Rails applications"
s.email = "matt@elucidata.net"
s.rubyforge_project = 'comatose'
s.home... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | install.rb | Ruby | mit | 192 | master | 607 | require 'fileutils'
# Copy the images (*.gif) into Rails.root/public/images/comatose
Rails.root = File.expand_path( File.join(File.dirname(__FILE__), '../../../') )
unless FileTest.exist? File.join(Rails.root.to_s, 'public', 'images', 'comatose')
FileUtils.mkdir( File.join(Rails.root.to_s, 'public', 'images', 'coma... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | Rakefile | Ruby | mit | 192 | master | 5,466 | require 'rake'
require 'rake/tasklib'
require 'rake/testtask'
require 'rake/rdoctask'
require 'test/behaviors'
desc 'Default: run unit tests.'
task :default => :test
desc 'Test the Comatose plugin.'
Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.pattern = 'test/**/*_test.rb'
t.verbose = false
end
Behaviors... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | test/behaviors.rb | Ruby | mit | 192 | master | 2,944 | require 'rake'
require 'rake/tasklib'
module Behaviors
include Rake
class ReportTask < TaskLib
attr_accessor :pattern
attr_accessor :html_dir
def initialize(name=:behaviors)
@name = name
@html_dir = 'doc'
yield self if block_given?
define
end
def define
desc "List... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | test/comatose_migration_generator_test.rb | Ruby | mit | 192 | master | 1,619 | require File.dirname(__FILE__) + '/test_helper'
#require 'rails_generator'
#require 'rails_generator/scripts/generate'
class MigrationGeneratorTest < Test::Unit::TestCase
def setup
FileUtils.mkdir_p(fake_Rails.root)
@original_files = file_list
end
def teardown
ActiveRecord::Base.pluralize_table_... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | test/test_helper.rb | Ruby | mit | 192 | master | 1,186 | ENV["Rails.env"] = 'test'
require File.expand_path(File.join(File.dirname(__FILE__), '../../../../config/environment.rb'))
require 'test/unit'
require 'rails/test_help'
class ActiveSupport::TestCase
# self.fixture_path = File.expand_path( File.join(File.dirname(__FILE__), 'fixtures') )
self.use_transactional_fi... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | test/unit/text_filters_test.rb | Ruby | mit | 192 | master | 1,981 | require File.dirname(__FILE__) + '/../test_helper'
require 'erb'
require 'liquid'
require 'text_filters'
# require 'comatose/page'
# require 'comatose/processing_context'
class TextFiltersTest < Test::Unit::TestCase
# fixtures :comatose_pages
# self.use_instantiated_fixtures = true
should "not alter output w... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | test/unit/processing_context_test.rb | Ruby | mit | 192 | master | 4,245 | require File.dirname(__FILE__) + '/../test_helper'
require 'comatose'
class ProcessingContextTest < Test::Unit::TestCase
fixtures :comatose_pages
def setup
@root = comatose_page( :home_page )
@binding = Comatose::ProcessingContext.new(@root)
end
should "process liquid tags with no filters correct... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | test/unit/class_options_test.rb | Ruby | mit | 192 | master | 1,317 | require File.dirname(__FILE__) + '/../test_helper'
require 'support/class_options'
class ClassOptionsTest < Test::Unit::TestCase
class Opts
define_option :nothing, nil
define_option :nada
define_option :name, "Matt"
define_option :age, 30
define_option :mode, :test
define_option :listing, ['... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | test/unit/comatose_page_test.rb | Ruby | mit | 192 | master | 4,327 | require File.dirname(__FILE__) + '/../test_helper'
class ComatosePageTest < Test::Unit::TestCase
fixtures :comatose_pages
should "create page" do
assert_difference ComatosePage, :count do
page = create_page :title=>'New Page Name'
assert !page.new_record?, "#{page.errors.full_messages.to_sentence... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | test/functional/comatose_admin_controller_test.rb | Ruby | mit | 192 | master | 3,720 | require File.dirname(__FILE__) + '/../test_helper'
require 'comatose_admin_controller'
require 'comatose_admin_helper'
require 'text_filters'
# Re-raise errors caught by the controller.
class ComatoseAdminController
def rescue_action(e) raise e end
end
class ComatoseAdminControllerTest < ActiveSupport::TestCase
... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | test/functional/comatose_controller_test.rb | Ruby | mit | 192 | master | 1,357 | require File.dirname(__FILE__) + '/../test_helper'
require 'comatose_controller'
require 'comatose_helper'
# Re-raise errors caught by the controller.
class ComatoseController
def rescue_action(e) raise e end
end
class ComatoseControllerTest < ActiveSupport::TestCase
fixtures :comatose_pages
def setup
@c... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | lib/liquid.rb | Ruby | mit | 192 | master | 2,090 | # Copyright (c) 2005 Tobias Luetke
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# di... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | lib/comatose_page.rb | Ruby | mit | 192 | master | 4,322 | # ComatosePage attributes
# - parent_id
# - title
# - full_path
# - slug
# - keywords
# - body
# - author
# - filter_type
# - position
# - version
# - updated_on
# - created_on
class ComatosePage < ActiveRecord::Base
set_table_name 'comatose_pages'
# Only versions the content... Not all of the met... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | lib/comatose_admin_helper.rb | Ruby | mit | 192 | master | 1,526 | module ComatoseAdminHelper
# Checks the hidden_meta_fields class variable for a specified field name...
def show_field?(key)
!Comatose.config.hidden_meta_fields.include? key
end
# Used in the Page Form to build an indented drop-down list of pages
def tree_select_box(nodes, selected= nil, hide= nil, lab... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | lib/comatose_controller.rb | Ruby | mit | 192 | master | 4,622 | # The controller for serving cms content...
class ComatoseController < ActionController::Base
unloadable
before_filter :handle_authorization, :set_content_type
after_filter :cache_cms_page
helper :application
# Render a specific page
def show
page_name, page_ext = get_page_path
page = Coma... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | lib/acts_as_versioned.rb | Ruby | mit | 192 | master | 20,854 | # Copyright (c) 2005 Rick Olson
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distr... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | lib/redcloth.rb | Ruby | mit | 192 | master | 35,832 | # vim:ts=4:sw=4:
# = RedCloth - Textile and Markdown Hybrid for Ruby
#
# Homepage:: http://whytheluckystiff.net/ruby/redcloth/
# Author:: why the lucky stiff (http://whytheluckystiff.net/)
# Copyright:: (cc) 2004 why the lucky stiff (and his puppet organizations.)
# License:: BSD
#
... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | lib/comatose_admin_controller.rb | Ruby | mit | 192 | master | 12,916 | # The controller for serving cms content...
class ComatoseAdminController < ActionController::Base
unloadable
define_option :original_template_root, nil
define_option :plugin_layout_path, File.join( '..', '..', '..', 'vendor', 'plugins', 'comatose', 'views', 'layouts' )
before_filter :handle_authorization
b... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | lib/text_filters.rb | Ruby | mit | 192 | master | 3,536 | require 'support/class_options'
class TextFilters
define_option :default_processor, :liquid
define_option :default_filter, :textile
define_option :logger, nil
@registered_filters = {}
@registered_titles = {}
attr_reader :name
attr_reader :title
def initialize(name, title)
@nam... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | lib/comatose.rb | Ruby | mit | 192 | master | 916 | module Comatose
# DEPRECATED
# Loads extensions from Rails.root/lib/comatose/*.rb
def self.load_extensions
Dir[File.join(Rails.root.to_s, 'lib', 'comatose', '*.rb')].each do |path|
require "comatose/#{File.basename(path)}"
end
end
end
require 'acts_as_versioned'
require 'redcloth' unless define... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | lib/generators/comatose/comatose_generator.rb | Ruby | mit | 192 | master | 1,071 | # lib/generators/authr/comatose/comatose_generator.rb
require 'rails/generators'
require 'rails/generators/migration'
class ComatoseGenerator < Rails::Generators::Base
include Rails::Generators::Migration
def self.source_root
@source_root ||= File.join(File.dirname(__FILE__), 'templates')
end
def self.n... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | lib/generators/comatose/templates/migration.rb | Ruby | mit | 192 | master | 1,142 | class ComatosePage < ActiveRecord::Base
set_table_name 'comatose_pages'
acts_as_versioned :table_name=>'comatose_page_versions', :if_changed => [:title, :slug, :keywords, :body]
end
class ComatoseMigration < ActiveRecord::Migration
# Schema for Comatose version 0.7+
def self.up
create_table :comatose_pag... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | lib/text_filters/markdown_smartypants.rb | Ruby | mit | 192 | master | 301 | #
# MARKDOWN + SMARTYPANTS
#
TextFilters.define :markdown_smartypants, "Markdown + SmartyPants" do
require 'bluecloth'
require 'rubypants'
def render_text(text)
RubyPants.new( BlueCloth.new(text).to_html ).to_html
end
def create_link(title, url)
"[#{title}](#{url})"
end
end |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | lib/text_filters/markdown.rb | Ruby | mit | 192 | master | 214 | #
# MARKDOWN
#
TextFilters.define :markdown, "Markdown" do
require 'bluecloth'
def render_text(text)
BlueCloth.new(text).to_html
end
def create_link(title, url)
"[#{title}](#{url})"
end
end |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | lib/text_filters/textile.rb | Ruby | mit | 192 | master | 250 | #
# TEXTILE
#
TextFilters.define :textile, "Textile" do
require 'redcloth'
def render_text(text)
RedCloth.new(text).to_html(:refs_markdown, :textile, :markdown)
end
def create_link(title, url)
%Q|"#{title}":#{url}|
end
end |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | lib/text_filters/rdoc.rb | Ruby | mit | 192 | master | 243 | #
# RDOC
#
TextFilters.define :rdoc, "RDoc" do
require 'rdoc/markup/simple_markup'
require 'rdoc/markup/simple_markup/to_html'
def render_text(text)
p = SM::SimpleMarkup.new
h = SM::ToHtml.new
p.convert(text, h)
end
end |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | lib/comatose/page_wrapper.rb | Ruby | mit | 192 | master | 2,840 | # Giving direct access to the AR model is disconcerting, so this wraps the AR
# Model to prevent access to certain, destructive behavior
class Comatose::PageWrapper
@@allowed_methods = %w(id full_path uri slug keywords title to_html filter_type author updated_on created_on)
@@custom_methods = %w(link content par... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | lib/comatose/processing_context.rb | Ruby | mit | 192 | master | 1,588 | # This is the rendering context object you have access to in text processing...
class Comatose::ProcessingContext
@@supported_methods = %w(page include)
def initialize( page, locals={} )
@locals = locals.stringify_keys if locals.respond_to? :stringify_keys
@page = Comatose::PageWrapper.new(page, @locals)
... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | lib/comatose/configuration.rb | Ruby | mit | 192 | master | 2,579 | module Comatose
def self.config
@@config ||= Configuration.new
end
def self.configure(&block)
raise "#configure must be sent a block" unless block_given?
yield config
config.validate!
end
# All of the 'mount' points for Comatose
def self.mount_points
@@mount_points ||= []
end
#... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | lib/comatose/comatose_drop.rb | Ruby | mit | 192 | master | 1,769 | module Comatose
class ComatoseDrop < ::Liquid::Drop
private :initialize
def before_method(method)
self.send(method.to_sym)
rescue
ComatoseController.logger.debug "Error calling #{method}: #{$!}"
raise $!
end
class << self
# Define a new ComatoseDrop by name
... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | lib/comatose/tasks/data.rb | Ruby | mit | 192 | master | 2,443 | require 'rake'
require 'rake/tasklib'
namespace :comatose do
#
# Data Migration Tasks
#
namespace :data do
def page_to_hash(page)
data = page.attributes.clone
# Pull out the specific, or unnecessary fields
%w(id parent_id updated_on author position version created_on full_path).each ... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | lib/comatose/tasks/admin.rb | Ruby | mit | 192 | master | 2,021 | require 'rake'
require 'rake/tasklib'
namespace :comatose do
#
# Customization Tasks
#
namespace :admin do
desc "Create Comatose views, layouts, and public files..."
task :customize do
puts "Copying public files..."
plugin_dir = File.join(File.dirname(__FILE__), '../../..')
FileUtils... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | lib/comatose/tasks/setup.rb | Ruby | mit | 192 | master | 1,640 | require 'rake'
require 'rake/tasklib'
namespace :comatose do
#
# Setup Task...
#
namespace :setup do
desc "If the installation didn't add the images correctly, use this task"
task :copy_images do
plugin_dir = File.join(File.dirname(__FILE__), '..')
unless FileTest.exist? File.join(Rail... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | lib/liquid/file_system.rb | Ruby | mit | 192 | master | 2,389 | module Liquid
# A Liquid file system is way to let your templates retrieve other templates for use with the include tag.
#
# You can implement subclasses that retrieve templates from the database, from the file system using a different
# path structure, you can provide them as hard-coded inline strings, or any... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | lib/liquid/standardtags.rb | Ruby | mit | 192 | master | 10,501 | module Liquid
class Assign < Tag
Syntax = /(\w+)\s*=\s*(#{AllowedVariableCharacters}+)/
def initialize(markup, tokens)
if markup =~ Syntax
@to = $1
@from = $2
else
raise SyntaxError.new("Syntax Error in 'assign' - Valid syntax: assign [var] = [source]")
en... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | lib/liquid/extensions.rb | Ruby | mit | 192 | master | 432 | class String
def to_liquid
self
end
end
class Array
def to_liquid
self
end
end
class Hash
def to_liquid
self
end
end
class Numeric
def to_liquid
self
end
end
class Time
def to_liquid
self
end
end
class DateTime
def to_liquid
self
end
end
class Date
def to_liquid... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | lib/liquid/drop.rb | Ruby | mit | 192 | master | 1,357 | module Liquid
# A drop in liquid is a class which allows you to to export DOM like things to liquid
# Methods of drops are callable.
# The main use for liquid drops is the implement lazy loaded objects.
# If you would like to make data available to the web designers which you don't want loaded unless neede... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | lib/liquid/tag.rb | Ruby | mit | 192 | master | 308 | module Liquid
class Tag
attr_accessor :nodelist
def initialize(markup, tokens)
@markup = markup
parse(tokens)
end
def parse(tokens)
end
def name
self.class.name.downcase
end
def render(context)
''
end
end
end |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | lib/liquid/variable.rb | Ruby | mit | 192 | master | 1,270 | module Liquid
# Hols variables. Variables are only loaded "just in time"
# they are not evaluated as part of the render stage
class Variable
attr_accessor :filters, :name
def initialize(markup)
@markup = markup
@name = markup.match(/\s*(#{QuotedFragment}... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | lib/liquid/block.rb | Ruby | mit | 192 | master | 2,702 | module Liquid
class Block < Tag
def parse(tokens)
@nodelist ||= []
@nodelist.clear
while token = tokens.shift
case token
when /^#{TagStart}/
if token =~ /^#{TagStart}\s*(\w+)\s*(.*)?#{TagEnd}$/
# if we found the proper block delimit... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | lib/liquid/standardfilters.rb | Ruby | mit | 192 | master | 3,161 | module Liquid
module StandardFilters
# Return the size of an array or of an string
def size(input)
input.respond_to?(:size) ? input.size : 0
end
# convert a input string to DOWNCASE
def downcase(input)
input.downcase rescue input
end
# con... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | lib/liquid/htmltags.rb | Ruby | mit | 192 | master | 1,941 | module Liquid
class TableRow < Block
Syntax = /(\w+)\s+in\s+(#{AllowedVariableCharacters}+)/
def initialize(markup, tokens)
super
if markup =~ Syntax
@variable_name = $1
@collection_name = $2
@attributes = {}
mar... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | lib/liquid/strainer.rb | Ruby | mit | 192 | master | 1,207 | module Liquid
# Strainer is the parent class for the filters system.
# New filters are mixed into the strainer class which is then instanciated for each liquid template render run.
#
# One of the strainer's responsibilities is to keep malicious method calls out
class Strainer
@@required_methods = ["__... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | lib/liquid/template.rb | Ruby | mit | 192 | master | 2,885 | module Liquid
# Templates are central to liquid.
# Interpretating templates is a two step process. First you compile the
# source code you got. During compile time some extensive error checking is performed.
# your code should expect to get some SyntaxErrors.
#
# After you have a compiled template you ... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | lib/liquid/context.rb | Ruby | mit | 192 | master | 4,921 | module Liquid
class ContextError < StandardError
end
# Context keeps the variable stack and resolves variables, as well as keywords
#
# context['variable'] = 'testing'
# context['variable'] #=> 'testing'
# context['true'] #=> true
# context['10.2232'] #=> 10.2232
#
# context.... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | lib/liquid/document.rb | Ruby | mit | 192 | master | 500 | module Liquid
class Document < Block
# we don't need markup to open this block
def initialize(tokens)
parse(tokens)
end
# There isn't a real delimter
def... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | lib/support/class_options.rb | Ruby | mit | 192 | master | 834 | class Class
def define_option(name, default=nil)
sym = name.to_sym
cattr_reader(sym)
cattr_writer(sym)
send("#{name.to_s}=", default)
end
def blockable_attr_accessor(sym)
module_eval(<<-EVAL, __FILE__, __LINE__)
def #{sym}(&block)
if block_given?
@#{sym} = block
... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | lib/support/inline_rendering.rb | Ruby | mit | 192 | master | 1,443 | # Extends the view to support rendering inline comatose pages...
ActionView::Base.class_eval do
alias_method :render_otherwise, :render
def render(options = {}, old_local_assigns = {}, &block) #:nodoc:
if options.is_a?(Hash) && page_name = options.delete(:comatose)
render_comatose(page_name, options[:p... |
github | mattmccray/comatose | https://github.com/mattmccray/comatose | lib/support/route_mapper.rb | Ruby | mit | 192 | master | 1,805 | require 'action_dispatch/routing/mapper'
require 'action_dispatch/routing/deprecated_mapper'
require 'rails'
# For use with 'Edge Rails'
ActionDispatch::Routing::Mapper.class_eval do
# For mounting a page to a path
def comatose_root( path, options={} )
opts = {
:index => '',
:layout => 'co... |
github | yohasebe/wp2txt | https://github.com/yohasebe/wp2txt | wp2txt.gemspec | Ruby | mit | 193 | master | 1,370 | # frozen_string_literal: true
require_relative "lib/wp2txt/version"
Gem::Specification.new do |s|
s.name = "wp2txt"
s.version = Wp2txt::VERSION
s.authors = ["Yoichiro Hasebe"]
s.email = ["yohasebe@gmail.com"]
s.homepage = "https://github.com/yohasebe/wp2txt"
s.summary = "A comm... |
github | yohasebe/wp2txt | https://github.com/yohasebe/wp2txt | Rakefile | Ruby | mit | 193 | master | 925 | # frozen_string_literal: true
require "bundler/gem_tasks"
require "rspec/core"
require "rspec/core/rake_task"
require_relative "./lib/wp2txt/version"
class String
def strip_heredoc
gsub(/^#{scan(/^[ \t]*(?=\S)/).min}/, "")
end
end
RSpec::Core::RakeTask.new(:spec) do |spec|
spec.pattern = FileList["spec/**/... |
github | yohasebe/wp2txt | https://github.com/yohasebe/wp2txt | spec/index_cache_spec.rb | Ruby | mit | 193 | master | 6,164 | # frozen_string_literal: true
require_relative "spec_helper"
require "tmpdir"
require "fileutils"
RSpec.describe Wp2txt::IndexCache do
let(:cache_dir) { Dir.mktmpdir("wp2txt_index_cache_test_") }
let(:source_file) { File.join(cache_dir, "test-index.txt") }
let(:cache) { described_class.new(source_file, cache_di... |
github | yohasebe/wp2txt | https://github.com/yohasebe/wp2txt | spec/formatter_sections_spec.rb | Ruby | mit | 193 | master | 9,797 | # frozen_string_literal: true
require "spec_helper"
require "tmpdir"
require "fileutils"
require_relative "../lib/wp2txt/article"
require_relative "../lib/wp2txt/formatter"
RSpec.describe "Formatter section extraction" do
include Wp2txt::Formatter
include Wp2txt
let(:sample_wiki_text) do
<<~WIKI
'''T... |
github | yohasebe/wp2txt | https://github.com/yohasebe/wp2txt | spec/cli_spec.rb | Ruby | mit | 193 | master | 23,188 | # frozen_string_literal: true
require_relative "spec_helper"
require_relative "../lib/wp2txt/cli"
require "tmpdir"
# Load the CLI app class for testing
require_relative "../lib/wp2txt"
require_relative "../lib/wp2txt/utils"
RSpec.describe Wp2txt::CLI do
describe ".parse_options" do
context "with --from-categor... |
github | yohasebe/wp2txt | https://github.com/yohasebe/wp2txt | spec/text_processing_spec.rb | Ruby | mit | 193 | master | 8,674 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe "Wp2txt Text Processing" do
include Wp2txt
describe "convert_characters" do
it "handles valid UTF-8 text" do
result = convert_characters("Hello World")
expect(result).to eq("Hello World")
end
it "handles Unicode text" do
... |
github | yohasebe/wp2txt | https://github.com/yohasebe/wp2txt | spec/ractor_worker_spec.rb | Ruby | mit | 193 | master | 5,736 | # frozen_string_literal: true
require "spec_helper"
require "wp2txt/ractor_worker"
RSpec.describe Wp2txt::RactorWorker do
describe "MINIMUM_RUBY_VERSION" do
it "is set to 4.0" do
expect(described_class::MINIMUM_RUBY_VERSION).to eq("4.0")
end
end
describe "OPERATIONS" do
it "includes expected ... |
github | yohasebe/wp2txt | https://github.com/yohasebe/wp2txt | spec/parser_functions_spec.rb | Ruby | mit | 193 | master | 13,512 | # frozen_string_literal: true
require "spec_helper"
RSpec.describe Wp2txt::ParserFunctions do
let(:parser) { described_class.new }
describe "#if" do
it "returns then-value when condition is non-empty" do
expect(parser.evaluate("{{#if:yes|true|false}}")).to eq("true")
end
it "returns else-value... |
github | yohasebe/wp2txt | https://github.com/yohasebe/wp2txt | spec/article_spec.rb | Ruby | mit | 193 | master | 14,289 | # frozen_string_literal: true
require_relative "spec_helper"
require_relative "fixtures/samples"
RSpec.describe Wp2txt::Article do
# Use let blocks for lazy evaluation to avoid triggering bugs at load time
let(:english_article) { Wp2txt::TestSamples::ENGLISH_ARTICLE }
let(:japanese_article) { Wp2txt::TestSample... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.