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
brandur/json_schema
https://github.com/brandur/json_schema
lib/json_reference.rb
Ruby
mit
231
master
1,193
require "uri" require_relative "json_pointer" module JsonReference def self.reference(ref) Reference.new(ref) end class Reference include Comparable attr_accessor :pointer attr_accessor :uri def initialize(ref) # Note that the #to_s of `nil` is an empty string. @uri = nil ...
github
brandur/json_schema
https://github.com/brandur/json_schema
lib/json_pointer/evaluator.rb
Ruby
mit
231
master
2,202
module JsonPointer # Evaluates a JSON pointer within a JSON document. # # Note that this class is designed to evaluate references across a plain JSON # data object _or_ an instance of `JsonSchema::Schema`, so the constructor's # `data` argument can be of either type. class Evaluator def initialize(data)...
github
brandur/json_schema
https://github.com/brandur/json_schema
lib/commands/validate_schema.rb
Ruby
mit
231
master
3,215
require "json" require "yaml" require_relative "../json_schema" module Commands class ValidateSchema attr_accessor :detect attr_accessor :fail_fast attr_accessor :extra_schemas attr_accessor :errors attr_accessor :messages def initialize @detect = false @fail_fast = false ...
github
brandur/json_schema
https://github.com/brandur/json_schema
lib/json_schema/schema.rb
Ruby
mit
231
master
8,932
require "json" module JsonSchema class Schema TYPE_MAP = { "array" => Array, "boolean" => [FalseClass, TrueClass], "integer" => Integer, "number" => [Integer, Float], "null" => NilClass, "object" => Hash, "string" => String, } include Attributes def...
github
brandur/json_schema
https://github.com/brandur/json_schema
lib/json_schema/reference_expander.rb
Ruby
mit
231
master
11,428
require "set" module JsonSchema class ReferenceExpander attr_accessor :errors attr_accessor :store def expand(schema, options = {}) @errors = [] @local_store = DocumentStore.new @schema = schema @schema_paths = {} @store = options[:store] || DocumentStor...
github
brandur/json_schema
https://github.com/brandur/json_schema
lib/json_schema/document_store.rb
Ruby
mit
231
master
777
module JsonSchema # The document store helps resolve URI-based JSON pointers by storing IDs # that we've seen in the schema. # # Each URI tuple also contains a pointer map that helps speed up expansions # that have already happened and handles cyclic dependencies. Store a # reference to the top-level schema...
github
brandur/json_schema
https://github.com/brandur/json_schema
lib/json_schema/parser.rb
Ruby
mit
231
master
13,556
require_relative "../json_reference" require_relative "validator" module JsonSchema class Parser ALLOWED_TYPES = %w{any array boolean integer number null object string} BOOLEAN = [FalseClass, TrueClass] FORMATS = JsonSchema::Validator::DEFAULT_FORMAT_VALIDATORS.keys FRIENDLY_TYPES = { Array ...
github
brandur/json_schema
https://github.com/brandur/json_schema
lib/json_schema/attributes.rb
Ruby
mit
231
master
4,109
module JsonSchema # Attributes mixes in some useful attribute-related methods for use in # defining schema classes in a spirit similar to Ruby's attr_accessor and # friends. module Attributes # Provides class-level methods for the Attributes module. module ClassMethods # Attributes that should be ...
github
brandur/json_schema
https://github.com/brandur/json_schema
lib/json_schema/validator.rb
Ruby
mit
231
master
22,126
require "uri" module JsonSchema class Validator attr_accessor :errors def initialize(schema) @schema = schema end def validate(data, fail_fast: false) @errors = [] @visits = {} @fail_fast = fail_fast # This dynamically creates the "strict_or_fast_and" method which is ...
github
brandur/json_schema
https://github.com/brandur/json_schema
lib/json_schema/error.rb
Ruby
mit
231
master
1,792
module JsonSchema class Error < RuntimeError end class AggregateError < Error attr_accessor :errors def initialize(errors) @errors = errors end def to_s @errors.join(" ") end end class SchemaError < Error attr_accessor :message, :schema, :type def self.aggregate(er...
github
brandur/json_schema
https://github.com/brandur/json_schema
lib/json_schema/configuration.rb
Ruby
mit
231
master
539
module JsonSchema class Configuration attr_accessor :all_of_sub_errors attr_reader :custom_formats attr_reader :validate_regex_with def validate_regex_with=(validator) @validate_regex_with = validator end def register_format(name, validator_proc) @custom_formats[name] = validator...
github
brandur/json_schema
https://github.com/brandur/json_schema
test/data_scaffold.rb
Ruby
mit
231
master
7,593
module DataScaffold def self.data_sample { "name" => "cloudnasium" } end def self.schema_sample { "$schema" => "http://json-schema.org/draft-04/hyper-schema", "title" => "Example API", "description" => "An example API.", "type" => [ "object" ], "defin...
github
brandur/json_schema
https://github.com/brandur/json_schema
test/json_schema_test.rb
Ruby
mit
231
master
1,050
require "test_helper" require "json_schema" describe JsonSchema do describe ".parse" do it "succeeds" do schema, errors = JsonSchema.parse(schema_sample) assert schema assert_nil errors end it "returns errors on a parsing problem" do pointer("#/properties").merge!( "app"...
github
brandur/json_schema
https://github.com/brandur/json_schema
test/test_helper.rb
Ruby
mit
231
master
480
if RUBY_VERSION >= '2.0.0' require 'simplecov' SimpleCov.start do # We do our utmost to test our executables by modularizing them into # testable pieces, but testing them to completion is nearly impossible as # far as I can tell, so include them in our tests but don't calculate # coverage. add_f...
github
brandur/json_schema
https://github.com/brandur/json_schema
test/bin_test.rb
Ruby
mit
231
master
599
require "test_helper" # # The purpose of this sets of tests is just to test our Ruby executables # where possible so that we can get very basic sanity checks on their syntax. # # We can do this without actually executing them with a "ruby -c" call. # describe "executables in bin/" do before do @bin_dir = File.e...
github
brandur/json_schema
https://github.com/brandur/json_schema
test/json_pointer/evaluator_test.rb
Ruby
mit
231
master
2,243
require "test_helper" require "json_pointer" require "json_schema" describe JsonPointer::Evaluator do before do @evaluator = JsonPointer::Evaluator.new(data) end it "evaluates pointers according to spec" do assert_equal data, @evaluator.evaluate("") assert_equal ["bar", "baz"], @evaluator...
github
brandur/json_schema
https://github.com/brandur/json_schema
test/commands/validate_schema_test.rb
Ruby
mit
231
master
3,132
require "test_helper" require "commands/validate_schema" require "tempfile" describe Commands::ValidateSchema do before do @command = Commands::ValidateSchema.new end it "shows usage with no arguments" do success = @command.run([]) assert_equal [], @command.errors assert_equal [], @command.mess...
github
brandur/json_schema
https://github.com/brandur/json_schema
test/json_schema/document_store_test.rb
Ruby
mit
231
master
1,078
require "test_helper" require "json_schema" describe JsonSchema::DocumentStore do before do @store = JsonSchema::DocumentStore.new end it "adds and looks up a schema" do schema = schema_sample("http://example.com/schema") @store.add_schema(schema) assert_equal schema, @store.lookup_schema(schem...
github
brandur/json_schema
https://github.com/brandur/json_schema
test/json_schema/reference_expander_test.rb
Ruby
mit
231
master
18,788
require "test_helper" require "json_schema" describe JsonSchema::ReferenceExpander do it "expands references" do expand assert_equal [], error_messages # this was always a fully-defined property referenced = @schema.definitions["app"] # this used to be a $ref reference = @schema.properties[...
github
brandur/json_schema
https://github.com/brandur/json_schema
test/json_schema/schema_test.rb
Ruby
mit
231
master
1,296
require "test_helper" require "json_schema" describe JsonSchema::Schema do it "allows schema attribute access with #[]" do schema = JsonSchema::Schema.new schema.properties = { "foo" => nil } assert_equal({ "foo" => nil }, schema[:properties]) end it "allows schema attribute access with #[] and ove...
github
brandur/json_schema
https://github.com/brandur/json_schema
test/json_schema/parser_test.rb
Ruby
mit
231
master
11,443
require "test_helper" require "json_schema" describe JsonSchema::Parser do after do JsonSchema.configuration.reset! end it "parses the basic attributes of a schema" do schema = parse assert_nil schema.id assert_equal "Example API", schema.title assert_equal "An example API.", schema.descrip...
github
brandur/json_schema
https://github.com/brandur/json_schema
test/json_schema/error_test.rb
Ruby
mit
231
master
445
require "test_helper" require "json_schema" describe JsonSchema::SchemaError do it "can print a message with a pointer" do schema = JsonSchema::Schema.new schema.fragment = "#" e = JsonSchema::SchemaError.new(schema, "problem", nil) assert_equal "#: problem", e.to_s end it "can print a message...
github
brandur/json_schema
https://github.com/brandur/json_schema
test/json_schema/attribute_test.rb
Ruby
mit
231
master
3,058
require "test_helper" require "json_schema" describe JsonSchema::Attributes do it "defines copyable attributes" do obj = TestAttributes.new obj.copyable = "foo" assert_equal "foo", obj.copyable assert_includes obj.class.copyable_attrs, :@copyable end it "defines schema attributes" do obj = ...
github
brandur/json_schema
https://github.com/brandur/json_schema
test/json_schema/validator_test.rb
Ruby
mit
231
master
34,062
require "test_helper" require "json_schema" describe JsonSchema::Validator do after do JsonSchema.configuration.reset! end it "can find data valid" do assert_valid end it "validates enum successfully" do pointer("#/definitions/app/definitions/visibility").merge!( "enum" => ["private", "p...
github
brandur/json_schema
https://github.com/brandur/json_schema
test/json_reference/reference_test.rb
Ruby
mit
231
master
1,176
require "test_helper" require "json_reference" describe JsonReference::Reference do it "expands a reference without a URI" do ref = reference("#/definitions") assert_nil ref.uri assert_equal "#/definitions", ref.pointer end it "expands a reference with a URI" do ref = reference("http://example....
github
rails/protected_attributes
https://github.com/rails/protected_attributes
protected_attributes.gemspec
Ruby
mit
231
master
1,096
# -*- encoding: utf-8 -*- lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'protected_attributes/version' Gem::Specification.new do |gem| gem.name = "protected_attributes" gem.version = ProtectedAttributes::VERSION gem.authors = ["Dav...
github
rails/protected_attributes
https://github.com/rails/protected_attributes
test/mass_assignment_security_test.rb
Ruby
mit
231
master
4,939
require 'test_helper' require 'active_model/mass_assignment_security' require 'models/mass_assignment_specific' class CustomSanitizer < ActiveModel::MassAssignmentSecurity::Sanitizer def process_removed_attributes(klass, attrs) raise StandardError end end class MassAssignmentSecurityTest < ActiveModel::Test...
github
rails/protected_attributes
https://github.com/rails/protected_attributes
test/accessible_params_wrapper_test.rb
Ruby
mit
231
master
2,557
require 'test_helper' require 'abstract_unit' require 'action_controller/accessible_params_wrapper' module ParamsWrapperTestHelp def with_default_wrapper_options(&block) @controller.class._set_wrapper_options({:format => [:json]}) @controller.class.inherited(@controller.class) yield end def assert_p...
github
rails/protected_attributes
https://github.com/rails/protected_attributes
test/abstract_unit.rb
Ruby
mit
231
master
4,382
require 'action_dispatch' require 'action_controller' require 'active_support/dependencies' def active_support_4_0? ActiveSupport::VERSION::MAJOR == 4 && ActiveSupport::VERSION::MINOR == 0 end if active_support_4_0? require 'active_support/core_ext/class/attribute_accessors' else require 'active_support/core_ex...
github
rails/protected_attributes
https://github.com/rails/protected_attributes
test/ar_helper.rb
Ruby
mit
231
master
2,048
require 'active_record' ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:') ActiveRecord::Schema.verbose = false ActiveRecord::Schema.define do create_table :accounts, :force => true do |t| t.integer :firm_id t.string :firm_name t.integer :credit_limit end create_tabl...
github
rails/protected_attributes
https://github.com/rails/protected_attributes
test/attribute_sanitization_test.rb
Ruby
mit
231
master
43,143
require 'test_helper' require 'ar_helper' require 'active_record/mass_assignment_security' require 'models/battle' require 'models/company' require 'models/group' require 'models/keyboard' require 'models/membership' require 'models/person' require 'models/pirate' require 'models/subscriber' require 'models/task' requi...
github
rails/protected_attributes
https://github.com/rails/protected_attributes
test/models/team.rb
Ruby
mit
231
master
369
class Team < ActiveRecord::Base has_many :battles has_many :wolf_battles, :through => :battles, :class_name => 'Wolf', :source => :battle, :source_type => 'Wolf' has_many :vampire_battles, :through => :battles, :class_name => 'Vampire', :source => :battle, :source_type => 'Vampire' has_many :nested_battles a...
github
rails/protected_attributes
https://github.com/rails/protected_attributes
test/models/person.rb
Ruby
mit
231
master
1,941
class LoosePerson < ActiveRecord::Base self.table_name = 'people' attr_protected :comments, :best_friend_id, :best_friend_of_id attr_protected :as => :admin has_one :best_friend, :class_name => 'LoosePerson', :foreign_key => :best_friend_id belongs_to :best_friend_of, :class_name => 'LoosePerson', :fo...
github
rails/protected_attributes
https://github.com/rails/protected_attributes
test/models/company.rb
Ruby
mit
231
master
286
class AbstractCompany < ActiveRecord::Base self.abstract_class = true end class Company < AbstractCompany attr_protected :rating end class Firm < Company end class Corporation < Company attr_accessible :type, :name, :description end class SpecialCorporation < Corporation end
github
rails/protected_attributes
https://github.com/rails/protected_attributes
test/models/mass_assignment_specific.rb
Ruby
mit
231
master
1,697
class User include ActiveModel::MassAssignmentSecurity attr_protected :admin public :sanitize_for_mass_assignment end class SpecialUser include ActiveModel::MassAssignmentSecurity attr_accessible :name, :email, :as => :moderator public :sanitize_for_mass_assignment end class Person include ActiveModel...
github
rails/protected_attributes
https://github.com/rails/protected_attributes
test/models/battle.rb
Ruby
mit
231
master
298
class Battle < ActiveRecord::Base attr_accessible [] belongs_to :team belongs_to :battle, :polymorphic => true end class NestedBattle < ActiveRecord::Base self.table_name = "battles" belongs_to :team belongs_to :battle, :polymorphic => true accepts_nested_attributes_for :team end
github
rails/protected_attributes
https://github.com/rails/protected_attributes
test/mass_assignment_security/black_list_test.rb
Ruby
mit
231
master
498
require 'test_helper' require 'active_model/mass_assignment_security' class BlackListTest < ActiveModel::TestCase def setup @black_list = ActiveModel::MassAssignmentSecurity::BlackList.new @included_key = 'admin' @black_list += [ @included_key ] end test "deny? is true for included items" do ...
github
rails/protected_attributes
https://github.com/rails/protected_attributes
test/mass_assignment_security/sanitizer_test.rb
Ruby
mit
231
master
1,822
require 'test_helper' require 'active_model/mass_assignment_security' require 'active_support/logger' class SanitizerTest < ActiveModel::TestCase attr_accessor :logger class Authorizer < ActiveModel::MassAssignmentSecurity::PermissionSet def deny?(key) ['admin', 'id'].include?(key) end end def ...
github
rails/protected_attributes
https://github.com/rails/protected_attributes
test/mass_assignment_security/permission_set_test.rb
Ruby
mit
231
master
1,167
require 'test_helper' require 'active_model/mass_assignment_security' class PermissionSetTest < ActiveModel::TestCase def setup @permission_list = ActiveModel::MassAssignmentSecurity::PermissionSet.new end test "+ stringifies added collection values" do symbol_collection = [ :admin ] new_list = @pe...
github
rails/protected_attributes
https://github.com/rails/protected_attributes
test/mass_assignment_security/strong_parameters_fallback_test.rb
Ruby
mit
231
master
3,099
require 'test_helper' require 'ar_helper' require 'rack/test' require 'action_controller/metal/strong_parameters' require 'active_record/mass_assignment_security' require 'active_model/mass_assignment_security' require 'models/book' require 'models/person' class StrongParametersFallbackTest < ActiveModel::TestCase ...
github
rails/protected_attributes
https://github.com/rails/protected_attributes
test/mass_assignment_security/white_list_test.rb
Ruby
mit
231
master
497
require 'test_helper' require 'active_model/mass_assignment_security' class WhiteListTest < ActiveModel::TestCase def setup @white_list = ActiveModel::MassAssignmentSecurity::WhiteList.new @included_key = 'first_name' @white_list += [ @included_key ] end test "deny? is false for included items" ...
github
rails/protected_attributes
https://github.com/rails/protected_attributes
lib/protected_attributes.rb
Ruby
mit
231
master
386
require "active_model/mass_assignment_security" require "protected_attributes/railtie" if defined? Rails::Railtie require "protected_attributes/version" ActiveSupport.on_load :active_record do require "active_record/mass_assignment_security" end ActiveSupport.on_load :action_controller do require "action_controll...
github
rails/protected_attributes
https://github.com/rails/protected_attributes
lib/active_record/mass_assignment_security.rb
Ruby
mit
231
master
1,126
require "active_record" require "active_record/mass_assignment_security/associations" require "active_record/mass_assignment_security/attribute_assignment" require "active_record/mass_assignment_security/core" require "active_record/mass_assignment_security/nested_attributes" require "active_record/mass_assignment_sec...
github
rails/protected_attributes
https://github.com/rails/protected_attributes
lib/active_record/mass_assignment_security/reflection.rb
Ruby
mit
231
master
452
module ActiveRecord module Reflection if defined?(AbstractReflection) class AbstractReflection undef :build_association def build_association(*options, &block) klass.new(*options, &block) end end else class AssociationReflection undef :build_associa...
github
rails/protected_attributes
https://github.com/rails/protected_attributes
lib/active_record/mass_assignment_security/core.rb
Ruby
mit
231
master
295
module ActiveRecord module MassAssignmentSecurity module Core private def init_attributes(attributes, options) assign_attributes(attributes, options) end def init_internals super @mass_assignment_options = nil end end end end
github
rails/protected_attributes
https://github.com/rails/protected_attributes
lib/active_record/mass_assignment_security/nested_attributes.rb
Ruby
mit
231
master
7,061
module ActiveRecord module MassAssignmentSecurity module NestedAttributes extend ActiveSupport::Concern module ClassMethods REJECT_ALL_BLANK_PROC = proc { |attributes| attributes.all? { |key, value| key == '_destroy' || value.blank? } } def accepts_nested_attributes_for(*attr_names)...
github
rails/protected_attributes
https://github.com/rails/protected_attributes
lib/active_record/mass_assignment_security/relation.rb
Ruby
mit
231
master
2,921
module ActiveRecord class Relation undef :first_or_create undef :first_or_create! undef :first_or_initialize undef :find_or_initialize_by undef :find_or_create_by undef :find_or_create_by! # Tries to load the first record; if it fails, then <tt>create</tt> is called with the same argument...
github
rails/protected_attributes
https://github.com/rails/protected_attributes
lib/active_record/mass_assignment_security/persistence.rb
Ruby
mit
231
master
3,629
require 'active_support/concern' module ActiveRecord module MassAssignmentSecurity # = Active Record Persistence module Persistence extend ActiveSupport::Concern module ClassMethods # Creates an object (or multiple objects) and saves it to the database, if validations pass. # The...
github
rails/protected_attributes
https://github.com/rails/protected_attributes
lib/active_record/mass_assignment_security/attribute_assignment.rb
Ruby
mit
231
master
3,119
require 'active_model/mass_assignment_security' require 'active_record' module ActiveRecord module MassAssignmentSecurity module AttributeAssignment extend ActiveSupport::Concern include ActiveModel::MassAssignmentSecurity module ClassMethods private # The primary key and inhe...
github
rails/protected_attributes
https://github.com/rails/protected_attributes
lib/active_record/mass_assignment_security/validations.rb
Ruby
mit
231
master
698
require 'active_support/concern' module ActiveRecord module MassAssignmentSecurity module Validations extend ActiveSupport::Concern module ClassMethods # Creates an object just like Base.create but calls <tt>save!</tt> instead of +save+ # so an exception is raised if the record is in...
github
rails/protected_attributes
https://github.com/rails/protected_attributes
lib/active_record/mass_assignment_security/inheritance.rb
Ruby
mit
231
master
867
module ActiveRecord module MassAssignmentSecurity module Inheritance extend ActiveSupport::Concern module ClassMethods private # Detect the subclass from the inheritance column of attrs. If the inheritance column value # is not self or a valid subclass, raises ActiveRecord::Subc...
github
rails/protected_attributes
https://github.com/rails/protected_attributes
lib/active_record/mass_assignment_security/associations.rb
Ruby
mit
231
master
4,319
module ActiveRecord module Associations class Association undef :build_record def build_record(attributes, options) reflection.build_association(attributes, options) do |record| attributes = create_scope.except(*(record.changed - [reflection.foreign_key])) record.assign_at...
github
rails/protected_attributes
https://github.com/rails/protected_attributes
lib/action_controller/accessible_params_wrapper.rb
Ruby
mit
231
master
771
require 'active_support/concern' require 'action_controller' require 'action_controller/metal/params_wrapper' module ActionController module ParamsWrapper class Options # :nodoc: undef :include def include return super if @include_set m = model synchronize do retur...
github
rails/protected_attributes
https://github.com/rails/protected_attributes
lib/active_model/mass_assignment_security.rb
Ruby
mit
231
master
13,689
require 'active_support/concern' require 'active_support/core_ext/class/attribute' require 'active_support/core_ext/string/inflections' require 'active_model' require 'active_model/mass_assignment_security/permission_set' require 'active_model/mass_assignment_security/sanitizer' module ActiveModel # == Active Model ...
github
rails/protected_attributes
https://github.com/rails/protected_attributes
lib/active_model/mass_assignment_security/sanitizer.rb
Ruby
mit
231
master
1,984
module ActiveModel module MassAssignmentSecurity class Sanitizer #:nodoc: # Returns all attributes not denied by the authorizer. def sanitize(klass, attributes, authorizer) rejected = [] sanitized_attributes = attributes.reject do |key, value| rejected << key if authorizer.de...
github
rails/protected_attributes
https://github.com/rails/protected_attributes
lib/active_model/mass_assignment_security/permission_set.rb
Ruby
mit
231
master
701
require 'set' module ActiveModel module MassAssignmentSecurity class PermissionSet < Set #:nodoc: def +(values) super(values.compact.map(&:to_s)) end def include?(key) super(remove_multiparameter_id(key)) end def deny?(key) raise NotImplementedError, "#den...
github
rails/protected_attributes
https://github.com/rails/protected_attributes
lib/protected_attributes/railtie.rb
Ruby
mit
231
master
456
module ProtectedAttributes class Railtie < ::Rails::Railtie initializer "protected_attributes.active_record", :before => "active_record.set_configs" do |app| if app.config.respond_to?(:active_record) && app.config.active_record.delete(:whitelist_attributes) ActiveSupport::Deprecation.warn "config.ac...
github
Kimtaro/ve
https://github.com/Kimtaro/ve
Gemfile
Ruby
mit
231
main
297
source 'https://rubygems.org' gem 'json', '~> 2.3' group :server do gem 'rack', '>= 2.1.4' gem 'sinatra', '~> 2.2.3' gem 'rack-cors', '~> 1.0.5' end group :test do gem 'rake', '~> 12.3.3' gem 'minitest', '~> 5.8.3' gem 'minitest-focus' gem 'mocha', '~> 1.1.0', require: false end
github
Kimtaro/ve
https://github.com/Kimtaro/ve
ve.gemspec
Ruby
mit
231
main
773
# -*- coding: utf-8 -*- Gem::Specification.new do |s| s.name = 've' s.version = '0.0.4' s.platform = Gem::Platform::RUBY s.authors = ['Kim Ahlström'] s.email = ['kim.ahlstrom@gmail.com'] s.license = 'MIT' s.homepage = 'http://github.com/kimtaro/ve' s.summary = 'Ve is a...
github
Kimtaro/ve
https://github.com/Kimtaro/ve
tests/test_helper.rb
Ruby
mit
231
main
733
require 'rubygems' require 'bundler/setup' require File.expand_path(File.dirname(__FILE__) + "/../lib/ve") require 'minitest/autorun' require "minitest/focus" require 'mocha' class MiniTest::Unit::TestCase private def assert_parses_into_words(parse_klass, expected, text, raw) parse = parse_klass.new(text, ra...
github
Kimtaro/ve
https://github.com/Kimtaro/ve
tests/ve_test.rb
Ruby
mit
231
main
588
# Encoding: UTF-8 require_relative 'test_helper' class VeTest < MiniTest::Unit::TestCase # TODO: Set these up to run properly def test_get skip assert_equal ['日本語', 'です'], Ve.get('日本語です', :ja, :words).collect(&:word) end def test_in skip assert_equal ['日本語', 'です'], Ve.in(:ja).words('日本語です')....
github
Kimtaro/ve
https://github.com/Kimtaro/ve
tests/mecab_ipadic_provider_test.rb
Ruby
mit
231
main
437
# Encoding: UTF-8 require_relative 'test_helper' class MecabIpadicProviderTest < MiniTest::Unit::TestCase # TODO: make these run without running mecab def test_should_be_able_to_start skip mecab = Ve::Provider::MecabIpadic.new assert mecab.works? end def test_can_parse skip mecab = Ve::P...
github
Kimtaro/ve
https://github.com/Kimtaro/ve
tests/freeling_en_parse_test.rb
Ruby
mit
231
main
5,977
# Encoding: UTF-8 require_relative 'test_helper' class FreelingEnParseTest < MiniTest::Unit::TestCase def test_all_literals_should_equal_the_input_text text = <<-EOS There once was a man from X Who took it upon himself to Y Z EOS raw = ["There there EX 0.857656", "once once RB 0.809237", "...
github
Kimtaro/ve
https://github.com/Kimtaro/ve
tests/mecab_ipadic_parse_test.rb
Ruby
mit
231
main
41,543
# Encoding: UTF-8 require_relative 'test_helper' class MecabIpadicParseTest < MiniTest::Unit::TestCase def test_all_literals_should_equal_the_input_text text = <<-EOS 古池や 蛙飛び込む 水の音 EOS raw = <<-EOR.split("\n") 古池 名詞,固有名詞,一般,*,*,*,古池,フルイケ,フルイケ や 助動詞,*,*,*,特殊・ヤ,基本形,や,ヤ,ヤ EOS 蛙 名詞,一般,*,*,*,*,...
github
Kimtaro/ve
https://github.com/Kimtaro/ve
tests/japanese_transliterators_test.rb
Ruby
mit
231
main
4,881
# Encoding: UTF-8 require_relative 'test_helper' class JapaneseTransliteratorsTest < MiniTest::Unit::TestCase KATAKANA = "ァアィイゥウェエォオカガキギクグケゲコゴサザシジスズセゼソゾタダチヂッツヅテデトドナニヌネノハバパヒビピフブプヘベペホボポマミムメモャヤュユョヨラリルレロヮワヰヱヲンヴヵヶ" HIRAGANA = "ぁあぃいぅうぇえぉおかがきぎくぐけげこごさざしじすずせぜそぞただちぢっつづてでとどなにぬねのはばぱひびぴふぶぷへべぺほぼぽまみむめもゃやゅゆょよらりるれろゎわゐゑをんゔゕゖ" H...
github
Kimtaro/ve
https://github.com/Kimtaro/ve
tests/freeling_en_provider_test.rb
Ruby
mit
231
main
1,073
# Encoding: UTF-8 require_relative 'test_helper' class FreelingEnProviderTest < MiniTest::Unit::TestCase # TODO: Make these tests not require running freeling def test_should_be_able_to_start skip Ve::Provider::FreelingEn.any_instance.expects(:start!).returns({}) Ve::Provider::FreelingEn.any_instance...
github
Kimtaro/ve
https://github.com/Kimtaro/ve
lib/word.rb
Ruby
mit
231
main
958
class Ve class Word attr_accessor :word, :lemma, :part_of_speech, :tokens, :extra, :info # TODO: More elegance def initialize(word, lemma, part_of_speech, tokens, extra = {}, info = {}) @word = word.dup @lemma = lemma.dup @part_of_speech = part_of_speech @tokens = tokens #...
github
Kimtaro/ve
https://github.com/Kimtaro/ve
lib/ve.rb
Ruby
mit
231
main
3,516
$: << File.expand_path(File.dirname(__FILE__)) require 'misc' require 'word' require 'part_of_speech' require 'languages/english' require 'languages/japanese' require 'pp' class Ve class Manager @@config_for = {} def self.set_default_config_for(klass, config = {}) @@config_for[klass] = config end...
github
Kimtaro/ve
https://github.com/Kimtaro/ve
lib/part_of_speech.rb
Ruby
mit
231
main
1,065
class Ve class PartOfSpeech def self.name self.to_s.split('::').last.gsub(/(?<=[A-Za-z])(?=[A-Z])/, ' ').downcase # RegEx adds spaces before uppercase letters. Ex: Ve::PartOfSpeech::ProperNoun.name => "proper noun" end class Noun < PartOfSpeech; end class ProperNoun < PartOfSpeech; end...
github
Kimtaro/ve
https://github.com/Kimtaro/ve
lib/provider.rb
Ruby
mit
231
main
272
class Ve class Provider # Interface, to be implemented by providers def provides end def start! end def works? end def parse end end end class Ve class Parse # TODO def as_json end end end
github
Kimtaro/ve
https://github.com/Kimtaro/ve
lib/providers/freeling_en.rb
Ruby
mit
231
main
7,885
# Encoding: UTF-8 # TODO: Retain capitalization in lemmas? # TODO: Memoize require 'open3' class Ve class Provider class FreelingEn < Ve::Provider # FIX: This class isn't tested BIT_STOP = 'VeEnd' # TODO: Automatically set FREELINGSHARE if it's not set? def initialize(config = {}) ...
github
Kimtaro/ve
https://github.com/Kimtaro/ve
lib/providers/mecab_ipadic.rb
Ruby
mit
231
main
13,236
# Encoding: UTF-8 require 'open3' class Ve class Provider class MecabIpadic < Ve::Provider BIT_STOP = 'VeEnd' def initialize(config = {}) # TODO: Make config handling better @config = {:app => 'mecab', :path => '', :flags => ''}.merge(config) ...
github
Kimtaro/ve
https://github.com/Kimtaro/ve
lib/providers/japanese_transliterators.rb
Ruby
mit
231
main
13,888
# Encoding: UTF-8 class Ve class Provider class JapaneseTransliterators < Ve::Provider def initialize(config = {}) end def works? true end def parse(text, options = {}) Ve::Parse::JapaneseTransliterators.new(text) end end end end class Ve class Par...
github
Kimtaro/ve
https://github.com/Kimtaro/ve
sinatra/server.rb
Ruby
mit
231
main
1,782
# Encoding: UTF-8 require 'rubygems' require 'bundler/setup' require 'sinatra' require 'json' require 'rack/cors' require File.expand_path(File.dirname(__FILE__) + "/../lib/ve") use Rack::Cors do allow do origins '*' end end get '/' do content_type 'application/json', :charset => 'utf-8' howto = { ...
github
archonic/limestone
https://github.com/archonic/limestone
Gemfile
Ruby
mit
231
master
2,565
# frozen_string_literal: true source "https://rubygems.org" git_source(:github) { |repo| "https://github.com/#{repo}.git" } ruby "2.7.2" # Pretty admin dashboards gem "administrate" # Upload to S3 directly gem "aws-sdk-s3", "~> 1" # Reduces boot times through caching; required in config/boot.rb gem "bootsnap", ">=...
github
archonic/limestone
https://github.com/archonic/limestone
app/controllers/subscriptions_controller.rb
Ruby
mit
231
master
1,134
# frozen_string_literal: true class SubscriptionsController < ApplicationController before_action :authenticate_user! skip_before_action :check_access, only: :show # NOTE This isn't a controller for a typical model. Subscriptions live in Stripe. # GET '/billing' def show redirect_to subscribe_path unle...
github
archonic/limestone
https://github.com/archonic/limestone
app/controllers/pages_controller.rb
Ruby
mit
231
master
292
# frozen_string_literal: true class PagesController < ApplicationController def pro unless current_user.product.pro? redirect_to(billing_path, flash: { warning: "Upgrade to the Pro plan to get access to that page." } ) && return end end end
github
archonic/limestone
https://github.com/archonic/limestone
app/controllers/application_controller.rb
Ruby
mit
231
master
1,455
# frozen_string_literal: true require "application_helper" class ApplicationController < ActionController::Base include Pundit include ActionView::Helpers::DateHelper protect_from_forgery with: :exception impersonates :user before_action :configure_permitted_parameters, if: :devise_controller? before_acti...
github
archonic/limestone
https://github.com/archonic/limestone
app/controllers/avatars_controller.rb
Ruby
mit
231
master
961
# frozen_string_literal: true class AvatarsController < ApplicationController before_action :set_user, only: %i(update destroy) before_action :set_avatar, only: %i(update destroy) respond_to :json layout false def update if params.try(:[], :user).try(:[], :avatar).present? avatar_uploaded = params...
github
archonic/limestone
https://github.com/archonic/limestone
app/controllers/admin/application_controller.rb
Ruby
mit
231
master
774
# frozen_string_literal: true # All Administrate controllers inherit from this `Admin::ApplicationController`, # making it the ideal place to put authentication logic or other # before_filters. # # If you want to add pagination or other controller-level concerns, # you're free to overwrite the RESTful controller actio...
github
archonic/limestone
https://github.com/archonic/limestone
app/controllers/admin/users_controller.rb
Ruby
mit
231
master
336
# frozen_string_literal: true module Admin class UsersController < Admin::ApplicationController def impersonate user = User.find(params[:id]) impersonate_user(user) redirect_to dashboard_path end def stop_impersonating stop_impersonating_user redirect_to admin_users_path ...
github
archonic/limestone
https://github.com/archonic/limestone
app/controllers/users/registrations_controller.rb
Ruby
mit
231
master
2,283
# frozen_string_literal: true module Users class RegistrationsController < Devise::RegistrationsController before_action :check_public_registration, only: %i(new create) before_action :set_plan, only: %i(create) # POST /resource def create build_resource( sign_up_params.merge( ...
github
archonic/limestone
https://github.com/archonic/limestone
app/models/plan.rb
Ruby
mit
231
master
483
# frozen_string_literal: true # NOTE This model is not meant to sync with Stripe - # just to hold the unique stripe_id as a convenience for retrieval. class Plan < ApplicationRecord include CurrencyHelper belongs_to :product validates :name, presence: true validates :amount, presence: true validates :curren...
github
archonic/limestone
https://github.com/archonic/limestone
app/models/user.rb
Ruby
mit
231
master
1,285
# frozen_string_literal: true class User < ApplicationRecord include Pay::Billable include Discard::Model # Include default devise modules. Others available are: # :lockable, :timeoutable and :omniauthable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validat...
github
archonic/limestone
https://github.com/archonic/limestone
app/models/product.rb
Ruby
mit
231
master
456
# frozen_string_literal: true # NOTE This model is not meant to sync with Stripe - # just to hold the unique stripe_id as a convenience for retrieval. class Product < ApplicationRecord validates :name, presence: true has_many :users, dependent: :nullify has_many :plans, dependent: :nullify scope :active, -> {...
github
archonic/limestone
https://github.com/archonic/limestone
app/mailers/user_mailer.rb
Ruby
mit
231
master
835
# frozen_string_literal: true class UserMailer < ApplicationMailer include Rails.application.routes.url_helpers def welcome_email(user) @user = user mail( to: email_with_name(user), subject: "[Limestone] Welcome!" ) end def billing_updated(user) @user = user mail( to: em...
github
archonic/limestone
https://github.com/archonic/limestone
app/services/stripe_plan_service.rb
Ruby
mit
231
master
860
# frozen_string_literal: true class StripePlanService def initialize(plan_model) @plan_model = plan_model end def create # Don't contact Stripe if we already have a stripe_id return false if @plan_model.product.stripe_id.blank? || @plan_model.stripe_id.present? stripe_plan = nil stripe_plan...
github
archonic/limestone
https://github.com/archonic/limestone
app/services/create_admin_service.rb
Ruby
mit
231
master
652
# frozen_string_literal: true class CreateAdminService # NOTE This user will be on a trial upon creation # enter a test card when prompted: https://stripe.com/docs/testing#cards def self.call admin = User.find_or_create_by!(email: ENV["ADMIN_EMAIL"]) do |u| u.password = ENV["ADMIN_PASSWORD"] u.pa...
github
archonic/limestone
https://github.com/archonic/limestone
app/services/subscription_service.rb
Ruby
mit
231
master
1,637
# frozen_string_literal: true # Manages all calls to Stripe pertaining to subscriptions class SubscriptionService def initialize(user, plan = nil) @user = user @user.processor = "stripe" @plan = plan end def swap_plan! stripe_plan_id = @plan.try(:stripe_id) success = stripe_call do @us...
github
archonic/limestone
https://github.com/archonic/limestone
app/services/stripe_product_service.rb
Ruby
mit
231
master
703
# frozen_string_literal: true class StripeProductService def initialize(product_model) @product_model = product_model end def create # Don't contact Stripe if we already have a stripe_id return false if @product_model.stripe_id.present? stripe_product = nil stripe_product_attrs = { na...
github
archonic/limestone
https://github.com/archonic/limestone
app/dashboards/dashboard_manifest.rb
Ruby
mit
231
master
814
# frozen_string_literal: true # DashboardManifest tells Administrate which dashboards to display class DashboardManifest # `DASHBOARDS` # a list of dashboards to display in the side navigation menu # # These are all of the rails models that we found in your database # at the time you installed Administrate. ...
github
archonic/limestone
https://github.com/archonic/limestone
app/dashboards/user_dashboard.rb
Ruby
mit
231
master
2,004
# frozen_string_literal: true require "administrate/base_dashboard" class UserDashboard < Administrate::BaseDashboard # ATTRIBUTE_TYPES # a hash that describes the type of each of the model's fields. # # Each different type represents an Administrate::Field object, # which determines how the attribute is di...
github
archonic/limestone
https://github.com/archonic/limestone
app/helpers/currency_helper.rb
Ruby
mit
231
master
405
# frozen_string_literal: true module CurrencyHelper include ActionView::Helpers::NumberHelper def formatted_amount(amount, currency = nil) [ number_to_currency(amount / 100), currency.try(:upcase) ].join(" ").strip end def invoice_pdf_link(invoice) link_to( icon("file-pdf-o", :s...
github
archonic/limestone
https://github.com/archonic/limestone
app/helpers/application_helper.rb
Ruby
mit
231
master
512
# frozen_string_literal: true module ApplicationHelper # Appends to body tag if content_for :no_turbolink present def turbolinks? if content_for(:no_turbolink) { data: { no_turbolink: true } } else { data: nil } end end # For Devise custom sign in form # helper_method :resource_name,...
github
archonic/limestone
https://github.com/archonic/limestone
app/helpers/devise_helper.rb
Ruby
mit
231
master
707
# frozen_string_literal: true module DeviseHelper def devise_error_messages! return "" unless devise_error_messages? messages = resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join sentence = I18n.t("errors.messages.not_saved", count: resource.errors.count, resource: resour...
github
archonic/limestone
https://github.com/archonic/limestone
app/helpers/icon_helper.rb
Ruby
mit
231
master
1,109
# frozen_string_literal: true module IconHelper AVATAR_SIZES = { xs: 16, sm: 32, md: 64, lg: 128, xl: 256 }.freeze def avatar(user, size = :sm) width = AVATAR_SIZES[size] resize_str = "#{width}x#{width}" img_or_text = user.avatar.attached? ? "img" : "text" image_tag = if user.avatar.attached? ...
github
archonic/limestone
https://github.com/archonic/limestone
bin/aws-v3.rb
Ruby
mit
231
master
815
#!/usr/bin/env ruby # frozen_string_literal: true # # This file was generated by Bundler. # # The application 'aws-v3.rb' is installed as part of a gem, and # this file is here to facilitate running it. # require "pathname" ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", Pathname.new(__FILE__).realpath)...
github
archonic/limestone
https://github.com/archonic/limestone
lib/core_ext/hash.rb
Ruby
mit
231
master
544
# frozen_string_literal: true class Hash # Returns a hash with non +nil+ values. # hash = { a: true, b: false, c: nil} # hash.compact # => { a: true, b: false} # hash # => { a: true, b: false, c: nil} # { c: nil }.compact # => {} def compact reject { |_, value| value.nil? } end # Replaces ...
github
archonic/limestone
https://github.com/archonic/limestone
db/seeds.rb
Ruby
mit
231
master
1,777
# frozen_string_literal: false # This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup). # # Examples: # # movies = Movie.create([{ name: 'Star Wars' }, { name...
github
archonic/limestone
https://github.com/archonic/limestone
db/schema.rb
Ruby
mit
231
master
5,067
# frozen_string_literal: true # 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 yo...