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
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
spec/mxnet/gluon/block_spec.rb
Ruby
mit
48
master
11,622
require 'spec_helper' require 'mxnet/gluon' require 'tempfile' RSpec.describe MXNet::Gluon::Block do describe 'attri[ute assignment' do let(:block) do MXNet::Gluon::Block.new end it 'automagically creates a block accessor' do a = block[:a] = MXNet::Gluon::Block.new expect(block[:a]).to...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
spec/mxnet/gluon/parameter_spec.rb
Ruby
mit
48
master
17,448
require 'spec_helper' require 'mxnet/gluon' RSpec.describe MXNet::Gluon::Parameter do specify do param = MXNet::Gluon::Parameter.new(:param) expect(param.name).to eq(:param) expect(param.dtype).to eq(:float32) expect(param.lr_mult).to eq(1.0) expect(param.wd_mult).to eq(1.0) expect(param.init...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
spec/mxnet/gluon/block_scope_spec.rb
Ruby
mit
48
master
3,605
require 'spec_helper' require 'mxnet/gluon' RSpec.describe MXNet::Gluon::BlockScope do describe '.make_prefix_and_params' do context 'when BlockScope.current is nil' do specify do prefix, params = MXNet::Gluon::BlockScope.make_prefix_and_params(nil, nil, 'foo') expect(prefix).to eq('foo0_')...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
spec/mxnet/gluon/trainer_spec.rb
Ruby
mit
48
master
797
require 'spec_helper' require 'mxnet/gluon' RSpec.describe MXNet::Gluon::Trainer do describe '#update' do let(:parameter) do MXNet::Gluon::Parameter.new('p', shape: [1]).tap do |param| param.init end end let(:optimizer) do instance_double(MXNet::Optimizer::Base).tap do |opt| ...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
spec/mxnet/gluon/nn/layers_spec.rb
Ruby
mit
48
master
10,039
require 'spec_helper' require 'mxnet/gluon' RSpec.describe MXNet::Gluon::NN::Sequential do describe '#add' do let(:layer) do MXNet::Gluon::NN::Sequential.new end it 'should register block as a child' do layer.add(MXNet::Gluon::NN::Dense.new(1)) expect(layer.collect_params.keys).to cont...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
spec/mxnet/gluon/nn/activations_spec.rb
Ruby
mit
48
master
519
require 'spec_helper' require 'mxnet/gluon' RSpec.describe MXNet::Gluon::NN::Activation do describe '.new' do it 'accepts a string' do act = MXNet::Gluon::NN::Activation.new('relu') expect(act.forward(MXNet::NDArray.array([-1, 0, 1]))) .to eq(MXNet::NDArray.array([0, 0, 1])) end it '...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
spec/mxnet/gluon/nn/sequential_spec.rb
Ruby
mit
48
master
339
require 'spec_helper' require 'mxnet/gluon' ::RSpec.describe MXNet::Gluon::NN::Sequential do specify do nn = MXNet::Gluon::NN net = nn::Sequential.new net.with_name_scope do net << nn::Dense.new(128, activation: :relu) net << nn::Dense.new(64, activation: :relu) net << nn::Dense.new(10)...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
spec/mxnet/gluon/data/data_loader_spec.rb
Ruby
mit
48
master
2,488
require 'spec_helper' require 'mxnet/gluon' RSpec.describe MXNet::Gluon::Data::DataLoader do let(:dataset) do (0..99).to_a end let(:shuffle) do false end let(:batch_size) do 3 end let(:last_batch) do :keep end let(:loader) do described_class.new(dataset, shuffle: shuffle, batc...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
spec/mxnet/gluon/data/dataset_spec.rb
Ruby
mit
48
master
1,656
require 'spec_helper' require 'mxnet/gluon' RSpec.describe MXNet::Gluon::Data::SimpleDataset do let(:dataset) do MXNet::Gluon::Data::SimpleDataset.new([1, 2, 3, 4]) end describe '#length' do specify do expect(MXNet::Gluon::Data::SimpleDataset.new([1, 2, 3]).length).to eq(3) expect(MXNet::Glu...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
spec/mxnet/gluon/data/sampler_spec.rb
Ruby
mit
48
master
2,366
require 'spec_helper' require 'mxnet/gluon/data/sampler' RSpec.describe MXNet::Gluon::Data::SequentialSampler do let(:sampler) do described_class.new(100) end describe '#length' do it 'is 100' do expect(sampler.length).to eq(100) end end describe '#each' do it 'results in an array fro...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
spec/mxnet/gluon/data/vision/mnist_spec.rb
Ruby
mit
48
master
1,465
require 'spec_helper' require 'mxnet/gluon' RSpec.describe MXNet::Gluon::Data::Vision::MNIST do context 'the default settings' do subject(:dataset) do MXNet::Gluon::Data::Vision::MNIST.new end specify do expect(dataset.root).to eq(File.expand_path("~/.mxnet/datasets/mnist")) expect(dat...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
spec/mxnet/io/image_record_iter_spec.rb
Ruby
mit
48
master
1,816
require 'spec_helper' RSpec.describe MXNet::IO::ImageRecordIter do # TODO: should be refactord with the same things in mnist_iter_spec.rb let(:fixture_dir_path) do Pathname(File.expand_path('../../../fixture' , __FILE__)) end before do cifar10_dir = fixture_dir_path.join('cifar10') cifar10_dir.mkd...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
spec/mxnet/io/mnist_iter_spec.rb
Ruby
mit
48
master
1,791
require 'spec_helper' require 'fileutils' require 'open-uri' require 'pathname' require 'zlib' ::RSpec.describe MXNet::IO::MNISTIter do def download(url, dirname: Dir.pwd) url = String(url) FileUtils.mkdir_p(dirname) basename = File.basename(url) fullname = File.join(dirname, basename) URI.parse...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
spec/support/tmpdir.rb
Ruby
mit
48
master
206
require "tmpdir" RSpec.shared_context 'within tmpdir', :within_tmpdir do around do |this_example| Dir.mktmpdir do |path| Dir.chdir(path) do this_example.run end end end end
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
lib/mxnet.rb
Ruby
mit
48
master
779
require "mxnet/version" module MXNet module HandleWrapper end None = Object.new def None.to_s 'None' end def None.inspect 'None' end require 'mxnet/libmxnet' require 'mxnet/attribute' require 'mxnet/autograd' require 'mxnet/context' require 'mxnet/name/name_manager' require 'mxnet/e...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
lib/mxnet/ndarray.rb
Ruby
mit
48
master
23,677
module MXNet class NDArray include Enumerable def self.ones(shape, ctx=nil, dtype=:float32, **kwargs) ctx ||= Context.default dtype = Utils.dtype_id(dtype) Internal._ones(shape: shape, ctx: ctx, dtype: dtype, **kwargs) end def self.zeros(shape, ctx=nil, dtype=:float32, **kwargs) ...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
lib/mxnet/libmxnet.rb
Ruby
mit
48
master
293
require 'fiddle' module MXNet module LibMXNet def self.load_lib require 'mxnet/libmxnet/finder' lib_path = Finder.find_libmxnet return Fiddle::Handle.new(lib_path[0], Fiddle::Handle::RTLD_LAZY) end def self.handle @handle ||= load_lib end end end
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
lib/mxnet/symbol.rb
Ruby
mit
48
master
11,429
module MXNet class Symbol include HandleWrapper private_class_method :new # NATIVE: self.load # NATIVE: self.load_json # Returns a new symbol of given shape and type, filled with zeros. # # @param shape # @param dtype # @return [MXNet::Symbol] The created symbol. def self.ze...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
lib/mxnet/autograd.rb
Ruby
mit
48
master
1,034
module MXNet module Autograd def self.with_recording_state(is_record, train_mode) unless is_record.nil? prev_is_record = self.set_recording(is_record) end unless train_mode.nil? prev_train_mode = self.set_training(train_mode) end yield ensure if !is_record....
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
lib/mxnet/context.rb
Ruby
mit
48
master
1,914
module MXNet class Context DEVICE_TYPE_NAME_FROM_ID = { 1 => :cpu, 2 => :gpu, 3 => :cpu_pinned }.freeze DEVICE_TYPE_ID_FROM_NAME = { cpu: 1, gpu: 2, cpu_pinned: 3 }.freeze def self.device_type_id_from_name(device_name) device_name = device_name.to_sym if device_name.kind_of? String DEVICE_TY...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
lib/mxnet/executor.rb
Ruby
mit
48
master
515
module MXNet class Executor include HandleWrapper def initialize(handle, symbol, ctx, grad_req, group2ctx) super(handle) @arg_arrays = [] @grad_arrays = [] @aux_arrays = [] @outputs = get_outputs @symbol = symbol.dup @arg_dict = nil @grad_dict = nil @aux_...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
lib/mxnet/metric.rb
Ruby
mit
48
master
6,706
require 'mxnet/registry' module MXNet module Metric # Base class for all evaluation metrics. class EvalMetric def initialize(name, output_names: nil, label_names: nil, **kwargs) @name = case name when Symbol, String name.to_sym else ...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
lib/mxnet/utils.rb
Ruby
mit
48
master
2,715
require 'digest/sha1' require 'open-uri' module MXNet module Utils module_function def dtype_id(name_or_id) case name_or_id when String, ::Symbol MXNet::DType.name2id(name_or_id) when Integer name_or_id else raise TypeError, "wrong type of dtype: #{name_or_id....
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
lib/mxnet/registry.rb
Ruby
mit
48
master
2,824
require 'json' module MXNet module Registry @registries = {} class Manager def initialize(base_class, nickname) @registry = registry_for(base_class) @base_class = base_class @nickname = nickname end private def registry_for(klass) registries = MXNet::Regist...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
lib/mxnet/module.rb
Ruby
mit
48
master
802
module MXNet # The base class of a module. # # ... class BaseModule def initialize(logger: nil) # TODO: logger @logger = logger @binded = false @for_training = false @inputs_need_grad = false @params_initialized = false @optimizer_initialized = false @symbol = nil ...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
lib/mxnet/narray_helper.rb
Ruby
mit
48
master
844
require 'numo/narray' require 'mxnet/narray_helper.so' module MXNet module NArrayHelper module_function MXNET_DTYPE_TO_NUMO = { float32: Numo::SFloat, float64: Numo::DFloat, float16: nil, # TODO uint8: Numo::UInt8, int32: Numo::Int32, int8: Numo::Int8, int64: Numo:...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
lib/mxnet/attribute.rb
Ruby
mit
48
master
745
module MXNet class AttrScope @current = nil def self.current @current end def initialize(**kwargs) @old_scope = nil kwargs.each_value do |v| raise ArgumentError, "attributes need to be string" unless v.kind_of?(String) or v.kind_of?(Symbol) end @attr = kwargs ...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
lib/mxnet/gluon.rb
Ruby
mit
48
master
226
require 'mxnet' module MXNet module Gluon end end require 'mxnet/gluon/block' require 'mxnet/gluon/data' require 'mxnet/gluon/nn' require 'mxnet/gluon/parameter' require 'mxnet/gluon/trainer' require 'mxnet/gluon/utils'
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
lib/mxnet/lr_scheduler.rb
Ruby
mit
48
master
3,091
module MXNet module LRScheduler class Base def initialize(base_lr: 0.01) @base_lr = base_lr end attr_accessor :base_lr # Return a new learning rate. # # The `num_update` is the upper bound of the number of updates applied # to every weight. # # Assum...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
lib/mxnet/optimizer.rb
Ruby
mit
48
master
14,086
module MXNet module Optimizer def self.registry_manager @registry_manager ||= MXNet::Registry::Manager.new(Base, :optimizer) end private_class_method :registry_manager def self.create(*args, **kwargs) registry_manager.create(*args, **kwargs) end module Registry @opt_registr...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
lib/mxnet/io.rb
Ruby
mit
48
master
3,449
module MXNet module IO # DataDesc is used to store name, shape, type and layout information # of the data or the label. class DataDesc < Struct.new(:name, :shape) def initialize(name, shape, dtype: :float32, layout: 'NCHW') super(name, shape) @dtype = dtype @layout = layout ...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
lib/mxnet/op_info.rb
Ruby
mit
48
master
912
module MXNet OpInfo = Struct.new(:name, :real_name, :description, :args, :key_var_num_args, :return_type) OpArgInfo = Struct.new(:name, :type_info, :description) class OpInfo NAME_PREFIX_LIST = %w[ _contrib_ _linalg_ _sparse_ ].freeze def name_prefix NAME_PREFIX_LIST.each do ...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
lib/mxnet/initializer.rb
Ruby
mit
48
master
9,762
require 'mxnet/registry' require 'json' module MXNet module Init def self.registry_manager @registry_manager ||= MXNet::Registry::Manager.new(Initializer, :initializer) end private_class_method :registry_manager def self.create(*args, **kwargs) registry_manager.create(*args, **kwargs) ...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
lib/mxnet/ndarray/random.rb
Ruby
mit
48
master
3,737
require 'mxnet/ndarray' module MXNet class NDArray module Random module_function # Draw random samples from a uniform distribution # # Samples are uniformly distributed over the half-open interval *[low, high)* # (includes *low*, but excludes *high*). def uniform(low=0, high=...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
lib/mxnet/ndarray/operation_delegator.rb
Ruby
mit
48
master
3,158
module MXNet class NDArray module OperationDelegator def self.define_delegator(mod, handle, op_info) dtype_name = nil ary_name = nil signature = [] ndsignature = [] ndarg_names = [] kwarg_names = [] op_info.args.each do |arg| name = arg.name ...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
lib/mxnet/gluon/parameter.rb
Ruby
mit
48
master
24,283
require 'set' module MXNet module Gluon # Error for unfinished deferred initializations. class DeferredInitializationError < MXNet::Error end # A container holding parameters (weights) of blocks. # # Parameter holds a copy of the parameter on each Context after it # is initialized with #...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
lib/mxnet/gluon/nn.rb
Ruby
mit
48
master
200
require 'mxnet/gluon' module MXNet module Gluon module NN class HybridSequential < HybridBlock end end end end require_relative 'nn/activations' require_relative 'nn/layers'
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
lib/mxnet/gluon/block.rb
Ruby
mit
48
master
24,680
require 'mxnet/gluon' module MXNet module Gluon # Scope for collecting child Blocks. class BlockScope TLS_KEY = :"#{self.name}.current" private_constant :TLS_KEY def self.current Thread.current[TLS_KEY] end def self.current=(block_scope) Thread.current[TLS_KEY]...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
lib/mxnet/gluon/loss.rb
Ruby
mit
48
master
6,759
require 'mxnet/gluon' module MXNet module Gluon module Loss ## # Base class for loss. # class Base < MXNet::Gluon::HybridBlock ## # Creates a new instance. # # ====Parameters # # +weight+:: (float or +nil+) # Globa...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
lib/mxnet/gluon/utils.rb
Ruby
mit
48
master
2,492
require 'mxnet/gluon' module MXNet module Gluon module Utils # Splits an NDArray into `num_slice` slices along `batch_axis`. # Usually used for data parallelism where each slices is sent # to one device (i.e. GPU). # # Parameters # ---------- # data : NDArray # ...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
lib/mxnet/gluon/trainer.rb
Ruby
mit
48
master
8,752
module MXNet module Gluon # Applies an `Optimizer` on a set of Parameters. # Trainer should be used together with `Autograd`. class Trainer # Creates a new instance. # # ====Parameters # # +params+:: (ParameterDict) # The set of parameters...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
lib/mxnet/gluon/data/data_loader.rb
Ruby
mit
48
master
4,691
require_relative 'sampler' module MXNet module Gluon module Data # Loads data from a dataset and returns mini-batches of data. class DataLoader include Enumerable # Creates a new instance. # # ====Parameters # # +dataset+:: (Dataset, NDArray or arra...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
lib/mxnet/gluon/data/sampler.rb
Ruby
mit
48
master
3,894
module MXNet module Gluon module Data # Base class for samplers. # # All samplers should subclass Sampler and define #length and # #each methods. # class Sampler include Enumerable def length raise NotImplementedError end def each ...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
lib/mxnet/gluon/data/dataset.rb
Ruby
mit
48
master
1,841
require 'mxnet/gluon/data' module MXNet::Gluon::Data class Dataset include Enumerable def length raise NotImplementedError end def [](idx) raise NotImplementedError end def each return enum_for unless block_given? i = 0 while i < length yield self[i] ...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
lib/mxnet/gluon/data/vision/mnist.rb
Ruby
mit
48
master
2,333
require 'mxnet/gluon/data' require 'mxnet/narray_helper' require 'zlib' require 'numo/narray' module MXNet::Gluon::Data module Vision class MNIST < DownloadedDataset def initialize(root: File.join('~', '.mxnet', 'datasets', 'mnist'), train: true, transform: nil) @train = train...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
lib/mxnet/gluon/nn/layers.rb
Ruby
mit
48
master
18,191
require 'mxnet/gluon/block' require 'mxnet/gluon/nn' module MXNet module Gluon module NN # Stacks blocks sequentially. # # net = MXNet::Gluon::NN.Sequential # net.with_name_scope do # net.add(MXNet::Gluon::NN.Dense(10, activation: :relu)) # net.add(MXNet::G...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
lib/mxnet/gluon/nn/activations.rb
Ruby
mit
48
master
723
require 'mxnet/gluon/block' require 'mxnet/gluon/nn' module MXNet module Gluon module NN ## # Applies an activation function. # class Activation < MXNet::Gluon::HybridBlock ## # Creates a new instance. # # ====Parameters # # +activation+:: (...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
lib/mxnet/symbol/operation_delegator.rb
Ruby
mit
48
master
4,204
module MXNet class Symbol module OperationDelegator def self.define_delegator(mod, handle, op_info) dtype_name = nil ary_name = nil signature = [] ndsignature = [] ndarg_names = [] kwarg_names = [] op_info.args.each do |arg| name = arg.name ...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
lib/mxnet/libmxnet/finder.rb
Ruby
mit
48
master
1,900
module MXNet module LibMXNet module Finder case RUBY_PLATFORM when /cygwin/ libprefix = 'cyg' libsuffix = 'dll' when /mingw/, /mswin/ libprefix = '' libsuffix = 'dll' when /darwin/ libsuffix = 'dylib' end LIBPREFIX = libprefix || 'lib' ...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
lib/mxnet/name/name_manager.rb
Ruby
mit
48
master
1,886
module MXNet module Name # NameManager to do automatic naming. # # Developers can also inherit from this class to change naming behavior. class NameManager @current = nil class << self attr_accessor :current end def initialize @counter = {} @old_manage...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
lib/mxnet/io/resize_iter.rb
Ruby
mit
48
master
1,400
module MXNet module IO # Resize a data iterator to a given number of batches. class ResizeIter < DataIter def initialize(data_iter, size, reset_internal: true) super() @data_iter = data_iter @size = size @reset_internal = reset_internal @cur = 0 @current_b...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
lib/mxnet/io/prefetching_iter.rb
Ruby
mit
48
master
3,941
require 'mxnet/io/data_iter' require 'sync' module MXNet module IO # Performs pre-fetch for other data iterators. # # This iterator will create another thread to perform +iter_next+ and then # store the data in memory. It potentially accelerates the data read, at the # cost of more memory usage...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
lib/mxnet/io/mxdata_iter.rb
Ruby
mit
48
master
1,819
module MXNet module IO # A ruby wrapper of a C++ data iterator. class MXDataIter < DataIter def initialize(data_name: 'data', label_name: 'softmax_label', **) @debug_skip_load = false # load the first batch to get shape information @first_batch = next_batch data = @first...
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
notebooks/Gemfile
Ruby
mit
48
master
210
source 'https://rubygems.org' git_source(:github) {|repo_name| "https://github.com/#{repo_name}" } gem 'mxnet', path: '..' gem 'pry' gem 'cztop' gem 'iruby' gem 'numo-narray' gem 'rbplotly' gem 'chunky_png'
github
mrkn/mxnet.rb
https://github.com/mrkn/mxnet.rb
docker/Rakefile
Ruby
mit
48
master
2,238
namespace :docker do def make_tag(ruby_version, python_version, mxnet_version) name = 'mrkn/mxnet-rb-ci' return [name, [ruby_version, python_version, mxnet_version].join('-')].join(':') end def make_build_args(ruby_version, python_version, mxnet_version) ba = '--build-arg' return [ ba, "RUB...
github
rememberlenny/robinhood-ruby__2016
https://github.com/rememberlenny/robinhood-ruby__2016
Gemfile
Ruby
mit
48
master
210
source 'https://rubygems.org' # Specify your gem's dependencies in robinhood.gemspec gemspec group :test do gem 'rake', '~> 10.1' gem 'rspec', '~> 3.0' gem 'fakeweb', '~> 1.3' gem 'rack', '~> 1.3' end
github
rememberlenny/robinhood-ruby__2016
https://github.com/rememberlenny/robinhood-ruby__2016
robinhood-ruby.gemspec
Ruby
mit
48
master
2,204
# coding: utf-8 lib = File.expand_path("../lib", __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require "robinhood-ruby/version" Gem::Specification.new do |spec| spec.name = "robinhood-ruby" spec.version = Robinhood::VERSION spec.authors = ["Leonard Bogdonoff"] spec.emai...
github
rememberlenny/robinhood-ruby__2016
https://github.com/rememberlenny/robinhood-ruby__2016
spec/robinhood_spec.rb
Ruby
mit
48
master
502
require "spec_helper" describe Robinhood do it "has a version number" do expect(Robinhood::VERSION).not_to be nil end after(:each) do Robinhood.instance_variable_set('@configuration', nil) end it 'should set the username and password with a config block' do Robinhood.configure do |config| ...
github
rememberlenny/robinhood-ruby__2016
https://github.com/rememberlenny/robinhood-ruby__2016
spec/util/configuration_spec.rb
Ruby
mit
48
master
430
require 'spec_helper' describe Robinhood::Util::Configuration do it 'should have an account sid attribute' do config = Robinhood::Util::Configuration.new config.username = 'someSid' expect(config.username).to eq('someSid') end it 'should have an auth token attribute' do config = Robinhood::Util:...
github
rememberlenny/robinhood-ruby__2016
https://github.com/rememberlenny/robinhood-ruby__2016
spec/rest/client_spec.rb
Ruby
mit
48
master
521
require 'spec_helper' describe Robinhood::REST::Client do describe 'config at class level' do after(:each) do Robinhood.instance_variable_set('@configuration', nil) end it 'should throw an argument error if the sid and token isn\'t set' do expect { Robinhood::REST::Client.new }.to raise_erro...
github
rememberlenny/robinhood-ruby__2016
https://github.com/rememberlenny/robinhood-ruby__2016
example/robinhood-sample/Gemfile
Ruby
mit
48
master
334
source 'https://rubygems.org' gem 'rails', '4.2.7.1' gem 'sqlite3' gem 'sass-rails', '~> 5.0' gem 'uglifier', '>= 1.3.0' gem 'coffee-rails', '~> 4.1.0' gem 'jquery-rails' gem 'turbolinks' gem "dotenv-rails", require: "dotenv/rails-now" gem "robinhood-ruby", path: "../.." group :development, :test do gem 'pry' gem...
github
rememberlenny/robinhood-ruby__2016
https://github.com/rememberlenny/robinhood-ruby__2016
example/robinhood-sample/config/application.rb
Ruby
mit
48
master
1,122
require File.expand_path('../boot', __FILE__) require 'rails/all' # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) module RobinhoodSample class Application < Rails::Application # Settings in config/environments/* ta...
github
rememberlenny/robinhood-ruby__2016
https://github.com/rememberlenny/robinhood-ruby__2016
lib/robinhood-ruby.rb
Ruby
mit
48
master
991
require "net/http" require "net/https" require "builder" require "multi_json" require "cgi" require "openssl" require "base64" require "forwardable" require "singleton" require "httparty" require "robinhood-ruby/version" unless defined?(Robinhood::VERSION) require "robinhood-ruby" require "robinhood-ruby/util" require...
github
rememberlenny/robinhood-ruby__2016
https://github.com/rememberlenny/robinhood-ruby__2016
lib/robinhood-ruby/rest/api.rb
Ruby
mit
48
master
6,614
module Robinhood module REST class API def account raw_response = HTTParty.get(endpoints[:accounts], headers: headers) JSON.parse(raw_response.body) end def investment_profile raw_response = HTTParty.get(endpoints[:investment_profile], headers: headers) JSO...
github
rememberlenny/robinhood-ruby__2016
https://github.com/rememberlenny/robinhood-ruby__2016
lib/robinhood-ruby/rest/client.rb
Ruby
mit
48
master
2,723
module Robinhood module REST class Client < API attr_accessor :token, :options, :private, :headers def initialize(*args) @options = args.last.is_a?(Hash) ? args.pop : {} @options[:username] = args[0] || Robinhood.username @options[:password] = args[1] || Robinhood.password ...
github
rememberlenny/robinhood-ruby__2016
https://github.com/rememberlenny/robinhood-ruby__2016
lib/robinhood-ruby/rest/endpoints.rb
Ruby
mit
48
master
2,282
module Robinhood module REST class Endpoints attr_accessor :endpoints def initialize end def self.endpoints api_url = "https://api.robinhood.com/" { login: api_url + "api-token-auth/", investment_profile: api_url + "user/...
github
pat/ts-datetime-delta
https://github.com/pat/ts-datetime-delta
ts-datetime-delta.gemspec
Ruby
mit
48
master
2,295
# Generated by jeweler # DO NOT EDIT THIS FILE DIRECTLY # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec' # -*- encoding: utf-8 -*- # stub: ts-datetime-delta 2.0.2 ruby lib Gem::Specification.new do |s| s.name = "ts-datetime-delta" s.version = "2.0.2" s.required_rubygems_version = Gem::Requirem...
github
pat/ts-datetime-delta
https://github.com/pat/ts-datetime-delta
tasks/testing.rb
Ruby
mit
48
master
357
require 'rspec/core/rake_task' require 'cucumber/rake/task' RSpec::Core::RakeTask.new(:spec) do |spec| spec.pattern = 'spec/**/*_spec.rb' end RSpec::Core::RakeTask.new(:rcov) do |spec| spec.pattern = 'spec/**/*_spec.rb' spec.rcov = true end Cucumber::Rake::Task.new task :spec => :check_dependencies ta...
github
pat/ts-datetime-delta
https://github.com/pat/ts-datetime-delta
tasks/distribution.rb
Ruby
mit
48
master
928
require 'jeweler' require 'yard' YARD::Rake::YardocTask.new Jeweler::Tasks.new do |gem| gem.name = 'ts-datetime-delta' gem.summary = 'Thinking Sphinx - Datetime Deltas' gem.description = 'Manage delta indexes via datetime columns for Thinking Sphinx' gem.email = "pat@freelancing-gods.com" g...
github
pat/ts-datetime-delta
https://github.com/pat/ts-datetime-delta
spec/spec_helper.rb
Ruby
mit
48
master
269
$LOAD_PATH.unshift File.join(File.dirname(__FILE__), '..', 'lib') require 'rubygems' require 'rspec' require 'active_support' require 'active_support/time' require 'thinking_sphinx' require 'thinking_sphinx/deltas/datetime_delta' RSpec.configure do |config| # end
github
pat/ts-datetime-delta
https://github.com/pat/ts-datetime-delta
spec/thinking_sphinx/deltas/datetime_delta_spec.rb
Ruby
mit
48
master
5,653
require './spec/spec_helper' describe ThinkingSphinx::Deltas::DatetimeDelta do before :each do @sphinx_version = (ThinkingSphinx.constants.include?(:Version) ? ThinkingSphinx::Version : '3.0.0').to_f if @sphinx_version < 3 @datetime_delta = ThinkingSphinx::Deltas::DatetimeDelta.new(double('index'), {}...
github
pat/ts-datetime-delta
https://github.com/pat/ts-datetime-delta
lib/thinking_sphinx/deltas/datetime_delta.rb
Ruby
mit
48
master
7,018
# Datetime Deltas for Thinking Sphinx # # This documentation is aimed at those reading the code. If you're looking for # a guide to Thinking Sphinx and/or deltas, I recommend you start with the # Thinking Sphinx site instead - or the README for this library at the very # least. # # @author Patrick Allan # @see http://t...
github
pat/ts-datetime-delta
https://github.com/pat/ts-datetime-delta
lib/thinking_sphinx/deltas/datetime_delta/tasks.rb
Ruby
mit
48
master
651
namespace :thinking_sphinx do namespace :index do desc "Index Thinking Sphinx datetime delta indices" # task :delta => :app_env do task :delta => ( (ThinkingSphinx.constants.include?(:Version) and ThinkingSphinx::Version.to_f < 3) \ ? :app_env : :environment) do ThinkingSphinx::...
github
pat/ts-datetime-delta
https://github.com/pat/ts-datetime-delta
features/support/env.rb
Ruby
mit
48
master
377
require 'rubygems' require 'cucumber' require 'spec/expectations' require 'fileutils' require 'active_record' $:.unshift File.dirname(__FILE__) + '/../../lib' require 'cucumber/thinking_sphinx/internal_world' world = Cucumber::ThinkingSphinx::InternalWorld.new world.configure_database require "thinking_sphinx" requ...
github
pat/ts-datetime-delta
https://github.com/pat/ts-datetime-delta
features/support/db/migrations/create_thetas.rb
Ruby
mit
48
master
231
ActiveRecord::Base.connection.create_table :thetas, :force => true do |t| t.column :name, :string, :null => false t.column :created_at, :datetime, :null => false t.column :updated_at, :datetime, :null => false end
github
pat/ts-datetime-delta
https://github.com/pat/ts-datetime-delta
features/step_definitions/datetime_delta_steps.rb
Ruby
mit
48
master
441
When /^I index the theta datetime delta$/ do Theta.sphinx_indexes.first.delta_object.delayed_index(Theta) end When /^I change the name of theta (\w+) to (\w+)$/ do |current, replacement| Theta.find_by_name(current).update_attributes(:name => replacement) end When /^I create a new theta named (\w+)$/ do |name| T...
github
pat/ts-datetime-delta
https://github.com/pat/ts-datetime-delta
features/step_definitions/common_steps.rb
Ruby
mit
48
master
1,342
Before do $queries_executed = [] @model = nil @method = :search @query = "" @conditions = {} @with = {} @without = {} @with_all = {} @options = {} @results = nil end Given "Sphinx is running" do ThinkingSphinx::Configuration.instance.controller.should be_running ...
github
mirego/killswitch
https://github.com/mirego/killswitch
Rakefile
Ruby
bsd-3-clause
48
main
372
# frozen_string_literal: true # 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__) Killswitch::Application.load_tasks # Load tasks in app/tasks Rails.r...
github
mirego/killswitch
https://github.com/mirego/killswitch
Gemfile
Ruby
bsd-3-clause
48
main
1,212
source 'https://rubygems.org' ruby '3.2.2' gem 'activerecord_json_validator', '~> 3.1.0' gem 'autoprefixer-rails', '6.4.0.1' gem 'bootsnap' gem 'bourgeois' gem 'camaraderie' gem 'cancancan' gem 'devise', '~> 4.9' gem 'devise-security', github: 'devise-security/devise-security' gem 'friendly_id' gem 'gaffe', '1.2.0' g...
github
mirego/killswitch
https://github.com/mirego/killswitch
app/validators/email_validator.rb
Ruby
bsd-3-clause
48
main
394
class EmailValidator < ActiveModel::EachValidator def initialize(options) options.reverse_merge!(message: :invalid_email) options.reverse_merge!(regex: /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i) super end def validate_each(record, attribute, value) return if value =~ options.fetch(:regex) ...
github
mirego/killswitch
https://github.com/mirego/killswitch
app/validators/version_validator.rb
Ruby
bsd-3-clause
48
main
552
class VersionValidator < ActiveModel::EachValidator def initialize(options) options.reverse_merge!(message: :invalid_version) super end def validate_each(record, attribute, value) if value.blank? add_error(record, attribute, value) else begin Versionomy.parse(value) resc...
github
mirego/killswitch
https://github.com/mirego/killswitch
app/controllers/api/behaviors_controller.rb
Ruby
bsd-3-clause
48
main
312
class API::BehaviorsController < API::ApplicationController # Constants VARY_HEADER = 'Accept-Language'.freeze # GET /killswitch def show dispatcher = BehaviorDispatcher.new dispatcher.dispatch!(request) headers['Vary'] = VARY_HEADER render json: dispatcher.matching_behavior end end
github
mirego/killswitch
https://github.com/mirego/killswitch
app/controllers/web/applications_controller.rb
Ruby
bsd-3-clause
48
main
1,612
class Web::ApplicationsController < Web::ApplicationController before_action :fetch_organization before_action :fetch_application, only: [:show, :update, :edit, :destroy] # GET / # GET /applications def index @applications = @organization.applications.includes(:projects) end # GET /applications/:id ...
github
mirego/killswitch
https://github.com/mirego/killswitch
app/controllers/web/projects_controller.rb
Ruby
bsd-3-clause
48
main
1,795
class Web::ProjectsController < Web::ApplicationController before_action :fetch_organization before_action :fetch_application before_action :fetch_project, only: [:show, :update, :edit, :destroy] # GET /applications/:application_id/projects/:id def show; end # GET /applications/:application_id/projects/ne...
github
mirego/killswitch
https://github.com/mirego/killswitch
app/controllers/web/users_controller.rb
Ruby
bsd-3-clause
48
main
616
class Web::UsersController < Web::ApplicationController before_action :fetch_user, only: [:update, :edit] # GET /users/:id/edit def edit; end # PUT /users/:id # PATCH /users/:id def update if @user.update(user_params) redirect_to root_path, notice: t('.notice') else render :edit en...
github
mirego/killswitch
https://github.com/mirego/killswitch
app/controllers/web/sessions_controller.rb
Ruby
bsd-3-clause
48
main
292
class Web::SessionsController < Devise::SessionsController before_action :configure_permitted_parameters protected # White-list parameters for Devise def configure_permitted_parameters devise_parameter_sanitizer.permit(:sign_in, keys: [:email, :password, :remember_me]) end end
github
mirego/killswitch
https://github.com/mirego/killswitch
app/controllers/web/home_controller.rb
Ruby
bsd-3-clause
48
main
322
class Web::HomeController < Web::ApplicationController skip_before_action :authenticate_user! def show return if current_user.blank? organization = current_user.organizations.first return if organization.blank? redirect_to web_organization_applications_path(organization_id: organization) end en...
github
mirego/killswitch
https://github.com/mirego/killswitch
app/controllers/web/errors_controller.rb
Ruby
bsd-3-clause
48
main
391
class Web::ErrorsController < Web::ApplicationController include Gaffe::Errors # Layout layout 'application' # Allow all users to view error pages skip_before_action :authenticate_user! def show render "web/errors/#{@rescue_response}", status: @status_code rescue ActionView::MissingTemplate ren...
github
mirego/killswitch
https://github.com/mirego/killswitch
app/controllers/web/application_controller.rb
Ruby
bsd-3-clause
48
main
1,129
class Web::ApplicationController < ApplicationController # CSRF Protection protect_from_forgery with: :exception # Users must be authenticated everywhere before_action :authenticate_user! before_action :set_paper_trail_whodunnit # Expose some methods to views helper_method :current_organization skip_b...
github
mirego/killswitch
https://github.com/mirego/killswitch
app/controllers/web/organizations_controller.rb
Ruby
bsd-3-clause
48
main
1,492
class Web::OrganizationsController < Web::ApplicationController before_action :fetch_organizations, only: [:index] before_action :fetch_organization, only: [:edit, :update, :destroy] # GET /organizations def index; end # GET /organizations/new def new @organization = Organization.new authorize! :c...
github
mirego/killswitch
https://github.com/mirego/killswitch
app/controllers/web/behaviors_controller.rb
Ruby
bsd-3-clause
48
main
2,382
class Web::BehaviorsController < Web::ApplicationController before_action :fetch_organization before_action :fetch_application before_action :fetch_project before_action :fetch_behavior, only: [:update, :edit, :destroy] # GET /applications/:application_id/projects/:project_id/behaviors/new def new @beh...
github
mirego/killswitch
https://github.com/mirego/killswitch
app/controllers/web/memberships_controller.rb
Ruby
bsd-3-clause
48
main
1,778
class Web::MembershipsController < Web::ApplicationController before_action :fetch_organization before_action :fetch_membership, only: [:update, :edit, :destroy] # GET /memberships def index @memberships = @organization.memberships.oldest end # GET /memberships/new def new @membership = @organiz...
github
mirego/killswitch
https://github.com/mirego/killswitch
app/services/behavior_sorter.rb
Ruby
bsd-3-clause
48
main
936
class BehaviorSorter def initialize(project) @project = project end # rubocop:disable Naming/PredicateMethod def reorder!(behavior_ids) @behavior_ids = behavior_ids sanitize_behaviors reset_all_orders reorder_each_behavior true end # rubocop:enable Naming/PredicateMethod protecte...
github
mirego/killswitch
https://github.com/mirego/killswitch
app/services/behavior_dispatcher.rb
Ruby
bsd-3-clause
48
main
2,206
class BehaviorDispatcher attr_reader :matching_behavior class MissingParameter < StandardError end def dispatch!(request) @request = request fetch_version fetch_key fetch_project fetch_language @matching_behavior = @project.behaviors.find { |b| matches?(b) } @matching_behavior ||...
github
mirego/killswitch
https://github.com/mirego/killswitch
app/services/ability.rb
Ruby
bsd-3-clause
48
main
717
class Ability include CanCan::Ability def initialize(user) @user = user || User.new if @user.super_powers? # We can do everything! can :manage, :all # Prevent from destroying super-admin organizations cannot :destroy, Organization, &:super_admin? else organization_permis...
github
mirego/killswitch
https://github.com/mirego/killswitch
app/models/behavior.rb
Ruby
bsd-3-clause
48
main
1,825
class Behavior < ApplicationRecord # Constants VERSION_OPERATORS = { 'lt' => :<, 'lte' => :<=, 'eq' => :==, 'gte' => :>=, 'gt' => :> }.freeze TIME_OPERATORS = { 'lt' => :<, 'gt' => :> }.freeze LANGUAGES = %w(fr en de es it pt).freeze DATA_JSON_SCHEMA = Rails.root.join('config/schemas/behavior_data.jsonschema'...
github
mirego/killswitch
https://github.com/mirego/killswitch
app/models/project.rb
Ruby
bsd-3-clause
48
main
489
class Project < ApplicationRecord # Associations belongs_to :application has_many :behaviors, -> { ascendingly }, dependent: :destroy, inverse_of: :project # Validations validates :name, presence: true, uniqueness: { scope: [:application_id, :deleted_at] } # Concerns include Keyable # FriendlyId ex...
github
mirego/killswitch
https://github.com/mirego/killswitch
app/models/user.rb
Ruby
bsd-3-clause
48
main
1,575
class User < ApplicationRecord # Validations validates :name, presence: true validates :email, presence: true, email: true, uniqueness: { scope: [:deleted_at] } validates :password, length: { within: 8..128, allow_blank: true }, presence: { if: :password_required? } # Devise devise :database_authenticatabl...
github
mirego/killswitch
https://github.com/mirego/killswitch
app/models/membership.rb
Ruby
bsd-3-clause
48
main
1,227
class Membership < ApplicationRecord # Camaraderie acts_as_membership # NOTE: This association is defined by the `acts_as_membership` method above. # However, we need to redefine it because we add `counter_cache`. # rubocop:disable Rails/ReflectionClassName belongs_to :organization, class_name: Camaraderie....
github
mirego/killswitch
https://github.com/mirego/killswitch
app/models/application.rb
Ruby
bsd-3-clause
48
main
449
class Application < ApplicationRecord # Associations has_many :projects, -> { ascendingly }, dependent: :destroy, inverse_of: :application belongs_to :organization, counter_cache: true # Validations validates :name, presence: true, uniqueness: { scope: [:deleted_at] } # FriendlyId extend FriendlyId fr...