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 | platanus/pincers | https://github.com/platanus/pincers | lib/pincers/chenso/browsing_manager.rb | Ruby | mit | 88 | master | 1,260 | require 'pincers/chenso/browsing_context'
module Pincers::Chenso
class BrowsingManager
extend Forwardable
def_delegators :context, :document, :current_url, :push, :forward, :back, :refresh
def initialize(_client)
@client = _client
@index = 0
@windows = [
[build_root_context]
... |
github | platanus/pincers | https://github.com/platanus/pincers | lib/pincers/chenso/browsing_context.rb | Ruby | mit | 88 | master | 1,557 | module Pincers::Chenso
class BrowsingContext
def initialize(_http_client, _state=nil)
@client = _http_client
@history = []
@pointer = -1
@childs = {}
@state = _state
end
def get_child(_id)
@childs[_id]
end
def load_child(_id)
@childs[_id] = self.class.... |
github | Yuki-Inoue/jupyter_on_rails | https://github.com/Yuki-Inoue/jupyter_on_rails | Gemfile | Ruby | mit | 88 | master | 203 | # frozen_string_literal: true
source 'https://rubygems.org'
git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
# Specify your gem's dependencies in jupyter_on_rails.gemspec
gemspec |
github | Yuki-Inoue/jupyter_on_rails | https://github.com/Yuki-Inoue/jupyter_on_rails | jupyter_on_rails.gemspec | Ruby | mit | 88 | master | 2,018 | # frozen_string_literal: true
lib = File.expand_path('lib', __dir__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'jupyter_on_rails/version'
Gem::Specification.new do |spec|
spec.name = 'jupyter_on_rails'
spec.version = JupyterOnRails::VERSION
spec.authors = ['Yuki INOUE'... |
github | Yuki-Inoue/jupyter_on_rails | https://github.com/Yuki-Inoue/jupyter_on_rails | lib/jupyter_on_rails/initializer.rb | Ruby | mit | 88 | master | 1,901 | # frozen_string_literal: true
module JupyterOnRails
class Initializer
def self.run(**opts)
new(**opts).run
end
def initialize(root:, sandbox:)
@root = root
@sandbox = sandbox
end
attr_reader :root, :sandbox
def run
setup_daru
load_rails_environment
setup... |
github | Yuki-Inoue/jupyter_on_rails | https://github.com/Yuki-Inoue/jupyter_on_rails | lib/jupyter_on_rails/kernel.rb | Ruby | mit | 88 | master | 608 | # frozen_string_literal: true
module JupyterOnRails
class Kernel
def initialize(sandbox: false)
@root = ENV.fetch('RAILS_ROOT')
@sandbox = sandbox
end
def boot
boot_rails
load_extensions
end
private
def boot_rails
boot_file = File.expand_path('config/boot.rb',... |
github | Yuki-Inoue/jupyter_on_rails | https://github.com/Yuki-Inoue/jupyter_on_rails | lib/jupyter_on_rails/railtie.rb | Ruby | mit | 88 | master | 257 | # frozen_string_literal: true
require_relative 'daru/active_record_ext'
require_relative 'daru/data_frame_ext'
module JupyterOnRails
class Railtie < ::Rails::Railtie
rake_tasks do
load 'jupyter_on_rails/railtie/jupyter.rake'
end
end
end |
github | Yuki-Inoue/jupyter_on_rails | https://github.com/Yuki-Inoue/jupyter_on_rails | lib/jupyter_on_rails/railtie/jupyter.rake | Ruby | mit | 88 | master | 2,270 | # frozen_string_literal: true
require 'shellwords'
require 'json'
require 'ostruct'
# rubocop:disable Metrics/BlockLength
namespace :jupyter do
exec_jupyter_command = lambda do |subcomand|
ipython_dir = ENV['IPYTHONDIR'] || Rails.root / '.ipython'
env = { 'JUPYTER_DATA_DIR' => ipython_dir.to_s }
comman... |
github | Yuki-Inoue/jupyter_on_rails | https://github.com/Yuki-Inoue/jupyter_on_rails | lib/jupyter_on_rails/daru/data_frame_ext.rb | Ruby | mit | 88 | master | 758 | # frozen_string_literal: true
module JupyterOnRails
module Daru
module DataFrameExt
def write_model(model)
if ActiveRecord.version >= Gem::Version.new('6.0.0.beta1')
write_model_rails(model)
else
write_model_activerecord_import(model)
end
end
private... |
github | Yuki-Inoue/jupyter_on_rails | https://github.com/Yuki-Inoue/jupyter_on_rails | lib/jupyter_on_rails/daru/active_record_ext.rb | Ruby | mit | 88 | master | 1,616 | # frozen_string_literal: true
require 'active_support/concern'
module JupyterOnRails
module Daru
module ActiveRecordExt
extend ::ActiveSupport::Concern
# Rails 4.0 support
unless respond_to?(:class_methods)
def self.class_methods(&class_methods_module_definition)
mod = const... |
github | tombenner/nested-hstore | https://github.com/tombenner/nested-hstore | nested-hstore.gemspec | Ruby | mit | 88 | master | 743 | require File.expand_path('../lib/nested_hstore/version', __FILE__)
Gem::Specification.new do |s|
s.authors = ['Tom Benner']
s.email = ['tombenner@gmail.com']
s.description = s.summary = %q{Store nested hashes and other types in ActiveRecord hstores}
s.homepage = 'https://github.com/tombenner... |
github | tombenner/nested-hstore | https://github.com/tombenner/nested-hstore | lib/nested_hstore/serializer.rb | Ruby | mit | 88 | master | 3,226 | module NestedHstore
class Serializer
def initialize
@type_key = '__TYPE__'
@types_map = {
array: '__ARRAY__',
boolean: '__BOOLEAN__',
float: '__FLOAT__',
integer: '__INTEGER__',
string: '__STRING__'
}
@types_map_inverted = @types_map.invert
@v... |
github | tombenner/nested-hstore | https://github.com/tombenner/nested-hstore | lib/active_record/coders/nested_hstore.rb | Ruby | mit | 88 | master | 965 | module ActiveRecord
module Coders
if ActiveRecord::VERSION::MAJOR < 4
require 'activerecord-postgres-hstore'
class NestedHstore < Hstore
def initialize(default=nil)
super(default)
@nested_serializer = ::NestedHstore::Serializer.new
end
private
def... |
github | tombenner/nested-hstore | https://github.com/tombenner/nested-hstore | spec/spec_helper.rb | Ruby | mit | 88 | master | 689 | require 'nested-hstore'
RSpec.configure do |config|
# ## Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
#
# config.mock_with :mocha
# config.mock_with :flexmock
# config.mock_with :rr
# Run specs in random order to surface order dependencies. If you find... |
github | tombenner/nested-hstore | https://github.com/tombenner/nested-hstore | spec/db/create_posts.rb | Ruby | mit | 88 | master | 232 | class CreatePosts < ActiveRecord::Migration
def self.up
execute "CREATE EXTENSION IF NOT EXISTS hstore"
create_table :posts do |t|
t.hstore :properties
end
end
def self.down
drop_table :posts
end
end |
github | tombenner/nested-hstore | https://github.com/tombenner/nested-hstore | spec/nested_hstore/serializer_spec.rb | Ruby | mit | 88 | master | 4,748 | require 'spec_helper'
describe NestedHstore::Serializer do
let(:serializer) { NestedHstore::Serializer.new }
def it_serializes
serialized = serializer.serialize(@deserialized)
serialized.should == @serialized
end
def it_deserializes
deserialized = serializer.deserialize(@serialized)
deseriali... |
github | tombenner/nested-hstore | https://github.com/tombenner/nested-hstore | spec/nested_hstore/active_record/coders/nested_hstore_spec.rb | Ruby | mit | 88 | master | 577 | require 'spec_helper'
describe ActiveRecord::Coders::NestedHstore do
class Post < ActiveRecord::Base
serialize :properties, ActiveRecord::Coders::NestedHstore
end
before :all do
CreatePosts.up
end
after :all do
CreatePosts.down
end
describe "dumping and loading" do
context "with a nest... |
github | pitr-ch/algebrick | https://github.com/pitr-ch/algebrick | update_doc.rb | Ruby | apache-2.0 | 88 | master | 735 | #!/usr/bin/env ruby
root = File.expand_path File.dirname(__FILE__)
push_to_github = (ARGV == %w(push))
if push_to_github
puts 'Pushing to github ...'
else
puts 'Just generating the doc, call "update_doc.rb push"'
end
def cmd(cmd)
puts ">> #{cmd}"
system cmd or raise "#{cmd} failed"
end
unless File.exist? "... |
github | pitr-ch/algebrick | https://github.com/pitr-ch/algebrick | algebrick.gemspec | Ruby | apache-2.0 | 88 | master | 1,196 | Gem::Specification.new do |s|
git_files = `git ls-files`.split("\n")
s.name = 'algebrick'
s.version = File.read(File.join(File.dirname(__FILE__), 'VERSION'))
s.date = Time.now.strftime('%Y-%m-%d')
s.summary = 'Algebraic types and pattern matching for Ruby'
s.descr... |
github | pitr-ch/algebrick | https://github.com/pitr-ch/algebrick | lib/algebrick.rb | Ruby | apache-2.0 | 88 | master | 2,075 | # Copyright 2013 Petr Chalupa <git+algebrick@pitr.ch>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable ... |
github | pitr-ch/algebrick | https://github.com/pitr-ch/algebrick | lib/algebrick/type_check.rb | Ruby | apache-2.0 | 88 | master | 1,593 | # Copyright 2013 Petr Chalupa <git+algebrick@pitr.ch>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable ... |
github | pitr-ch/algebrick | https://github.com/pitr-ch/algebrick | lib/algebrick/product_variant.rb | Ruby | apache-2.0 | 88 | master | 5,830 | # Copyright 2013 Petr Chalupa <git+algebrick@pitr.ch>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable ... |
github | pitr-ch/algebrick | https://github.com/pitr-ch/algebrick | lib/algebrick/types.rb | Ruby | apache-2.0 | 88 | master | 1,696 | # Copyright 2013 Petr Chalupa <git+algebrick@pitr.ch>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable ... |
github | pitr-ch/algebrick | https://github.com/pitr-ch/algebrick | lib/algebrick/dsl.rb | Ruby | apache-2.0 | 88 | master | 2,415 | # Copyright 2013 Petr Chalupa <git+algebrick@pitr.ch>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable ... |
github | pitr-ch/algebrick | https://github.com/pitr-ch/algebrick | lib/algebrick/serializers.rb | Ruby | apache-2.0 | 88 | master | 905 | # Copyright 2013 Petr Chalupa <git+algebrick@pitr.ch>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable ... |
github | pitr-ch/algebrick | https://github.com/pitr-ch/algebrick | lib/algebrick/reclude.rb | Ruby | apache-2.0 | 88 | master | 1,230 | # Copyright 2013 Petr Chalupa <git+algebrick@pitr.ch>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable ... |
github | pitr-ch/algebrick | https://github.com/pitr-ch/algebrick | lib/algebrick/serializer.rb | Ruby | apache-2.0 | 88 | master | 3,659 | # Copyright 2013 Petr Chalupa <git+algebrick@pitr.ch>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable ... |
github | pitr-ch/algebrick | https://github.com/pitr-ch/algebrick | lib/algebrick/field_method_readers.rb | Ruby | apache-2.0 | 88 | master | 1,378 | # Copyright 2013 Petr Chalupa <git+algebrick@pitr.ch>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable ... |
github | pitr-ch/algebrick | https://github.com/pitr-ch/algebrick | lib/algebrick/product_constructors.rb | Ruby | apache-2.0 | 88 | master | 879 | # Copyright 2013 Petr Chalupa <git+algebrick@pitr.ch>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable ... |
github | pitr-ch/algebrick | https://github.com/pitr-ch/algebrick | lib/algebrick/parametrized_type.rb | Ruby | apache-2.0 | 88 | master | 3,238 | # Copyright 2013 Petr Chalupa <git+algebrick@pitr.ch>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable ... |
github | pitr-ch/algebrick | https://github.com/pitr-ch/algebrick | lib/algebrick/atom.rb | Ruby | apache-2.0 | 88 | master | 1,085 | # Copyright 2013 Petr Chalupa <git+algebrick@pitr.ch>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable ... |
github | pitr-ch/algebrick | https://github.com/pitr-ch/algebrick | lib/algebrick/value.rb | Ruby | apache-2.0 | 88 | master | 1,011 | # Copyright 2013 Petr Chalupa <git+algebrick@pitr.ch>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable ... |
github | pitr-ch/algebrick | https://github.com/pitr-ch/algebrick | lib/algebrick/matchers.rb | Ruby | apache-2.0 | 88 | master | 1,131 | # Copyright 2013 Petr Chalupa <git+algebrick@pitr.ch>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable ... |
github | pitr-ch/algebrick | https://github.com/pitr-ch/algebrick | lib/algebrick/matcher_delegations.rb | Ruby | apache-2.0 | 88 | master | 960 | # Copyright 2013 Petr Chalupa <git+algebrick@pitr.ch>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable ... |
github | pitr-ch/algebrick | https://github.com/pitr-ch/algebrick | lib/algebrick/matching.rb | Ruby | apache-2.0 | 88 | master | 1,917 | # Copyright 2013 Petr Chalupa <git+algebrick@pitr.ch>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable ... |
github | pitr-ch/algebrick | https://github.com/pitr-ch/algebrick | lib/algebrick/type.rb | Ruby | apache-2.0 | 88 | master | 1,389 | # Copyright 2013 Petr Chalupa <git+algebrick@pitr.ch>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable ... |
github | pitr-ch/algebrick | https://github.com/pitr-ch/algebrick | lib/algebrick/product_constructors/abstract.rb | Ruby | apache-2.0 | 88 | master | 1,736 | # Copyright 2013 Petr Chalupa <git+algebrick@pitr.ch>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable ... |
github | pitr-ch/algebrick | https://github.com/pitr-ch/algebrick | lib/algebrick/product_constructors/basic.rb | Ruby | apache-2.0 | 88 | master | 1,288 | # Copyright 2013 Petr Chalupa <git+algebrick@pitr.ch>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable ... |
github | pitr-ch/algebrick | https://github.com/pitr-ch/algebrick | lib/algebrick/product_constructors/named.rb | Ruby | apache-2.0 | 88 | master | 1,630 | # Copyright 2013 Petr Chalupa <git+algebrick@pitr.ch>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable ... |
github | pitr-ch/algebrick | https://github.com/pitr-ch/algebrick | lib/algebrick/matchers/wrapper.rb | Ruby | apache-2.0 | 88 | master | 1,424 | # Copyright 2013 Petr Chalupa <git+algebrick@pitr.ch>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable ... |
github | pitr-ch/algebrick | https://github.com/pitr-ch/algebrick | lib/algebrick/matchers/many.rb | Ruby | apache-2.0 | 88 | master | 916 | # Copyright 2013 Petr Chalupa <git+algebrick@pitr.ch>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable ... |
github | pitr-ch/algebrick | https://github.com/pitr-ch/algebrick | lib/algebrick/matchers/variant.rb | Ruby | apache-2.0 | 88 | master | 935 | # Copyright 2013 Petr Chalupa <git+algebrick@pitr.ch>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable ... |
github | pitr-ch/algebrick | https://github.com/pitr-ch/algebrick | lib/algebrick/matchers/abstract.rb | Ruby | apache-2.0 | 88 | master | 2,622 | # Copyright 2013 Petr Chalupa <git+algebrick@pitr.ch>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable ... |
github | pitr-ch/algebrick | https://github.com/pitr-ch/algebrick | lib/algebrick/matchers/and.rb | Ruby | apache-2.0 | 88 | master | 842 | # Copyright 2013 Petr Chalupa <git+algebrick@pitr.ch>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable ... |
github | pitr-ch/algebrick | https://github.com/pitr-ch/algebrick | lib/algebrick/matchers/or.rb | Ruby | apache-2.0 | 88 | master | 1,341 | # Copyright 2013 Petr Chalupa <git+algebrick@pitr.ch>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable ... |
github | pitr-ch/algebrick | https://github.com/pitr-ch/algebrick | lib/algebrick/matchers/atom.rb | Ruby | apache-2.0 | 88 | master | 868 | # Copyright 2013 Petr Chalupa <git+algebrick@pitr.ch>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable ... |
github | pitr-ch/algebrick | https://github.com/pitr-ch/algebrick | lib/algebrick/matchers/array.rb | Ruby | apache-2.0 | 88 | master | 1,782 | # Copyright 2013 Petr Chalupa <git+algebrick@pitr.ch>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable ... |
github | pitr-ch/algebrick | https://github.com/pitr-ch/algebrick | lib/algebrick/matchers/product.rb | Ruby | apache-2.0 | 88 | master | 2,716 | # Copyright 2013 Petr Chalupa <git+algebrick@pitr.ch>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable ... |
github | pitr-ch/algebrick | https://github.com/pitr-ch/algebrick | lib/algebrick/matchers/any.rb | Ruby | apache-2.0 | 88 | master | 1,098 | # Copyright 2013 Petr Chalupa <git+algebrick@pitr.ch>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable ... |
github | pitr-ch/algebrick | https://github.com/pitr-ch/algebrick | lib/algebrick/matchers/abstract_logic.rb | Ruby | apache-2.0 | 88 | master | 1,061 | # Copyright 2013 Petr Chalupa <git+algebrick@pitr.ch>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable ... |
github | pitr-ch/algebrick | https://github.com/pitr-ch/algebrick | lib/algebrick/matchers/not.rb | Ruby | apache-2.0 | 88 | master | 1,072 | # Copyright 2013 Petr Chalupa <git+algebrick@pitr.ch>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable ... |
github | pitr-ch/algebrick | https://github.com/pitr-ch/algebrick | test/algebrick_test.rb | Ruby | apache-2.0 | 88 | master | 22,707 | # Copyright 2013 Petr Chalupa <git@pitr.ch>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agr... |
github | ctide/devise_lastseenable | https://github.com/ctide/devise_lastseenable | Rakefile | Ruby | mit | 88 | master | 1,044 | require 'rubygems'
require 'bundler'
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts "Run `bundle install` to install missing gems"
exit e.status_code
end
require 'rake'
require 'jeweler'
Jeweler::Tasks.new do |gem|
# gem is a Gem::Specificati... |
github | ctide/devise_lastseenable | https://github.com/ctide/devise_lastseenable | devise_lastseenable.gemspec | Ruby | mit | 88 | master | 2,417 | # Generated by jeweler
# DO NOT EDIT THIS FILE DIRECTLY
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
# -*- encoding: utf-8 -*-
# stub: devise_lastseenable 0.0.6 ruby lib
Gem::Specification.new do |s|
s.name = "devise_lastseenable"
s.version = "0.0.6"
s.required_rubygems_version = Gem::Requ... |
github | ctide/devise_lastseenable | https://github.com/ctide/devise_lastseenable | test/test_devise_lastseenable.rb | Ruby | mit | 88 | master | 234 | require 'helper'
class TestDeviseLastseenable < Test::Unit::TestCase
should "probably rename this file and start testing for real" do
flunk "hey buddy, you should probably rename this file and start testing for real"
end
end |
github | ctide/devise_lastseenable | https://github.com/ctide/devise_lastseenable | test/helper.rb | Ruby | mit | 88 | master | 440 | require 'rubygems'
require 'bundler'
begin
Bundler.setup(:default, :development)
rescue Bundler::BundlerError => e
$stderr.puts e.message
$stderr.puts "Run `bundle install` to install missing gems"
exit e.status_code
end
require 'test/unit'
require 'shoulda'
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__),... |
github | ctide/devise_lastseenable | https://github.com/ctide/devise_lastseenable | lib/devise_lastseenable.rb | Ruby | mit | 88 | master | 216 | unless defined?(Devise)
require 'devise'
end
require 'devise_lastseenable'
Devise.add_module :lastseenable, :model => 'devise_lastseenable/model'
module DeviseLastseenable
end
require 'devise_lastseenable/rails' |
github | ctide/devise_lastseenable | https://github.com/ctide/devise_lastseenable | lib/devise_lastseenable/model.rb | Ruby | mit | 88 | master | 282 | require 'devise_lastseenable/hooks/lastseenable'
module Devise
module Models
module Lastseenable
def stamp!
if self.last_seen.to_i < (Time.now - 5.minutes).to_i
self.last_seen = DateTime.now
self.save!
end
end
end
end
end |
github | ctide/devise_lastseenable | https://github.com/ctide/devise_lastseenable | lib/generators/devise_lastseenable/devise_lastseenable_generator.rb | Ruby | mit | 88 | master | 803 | require 'rails/generators/migration'
class DeviseLastseenableGenerator < Rails::Generators::NamedBase
include Rails::Generators::Migration
def self.source_root
@_devise_source_root ||= File.expand_path("../templates", __FILE__)
end
def self.orm_has_migration?
Rails::Generators.options[:rails][:orm] =... |
github | ctide/devise_lastseenable | https://github.com/ctide/devise_lastseenable | lib/generators/devise_lastseenable/templates/migration.rb | Ruby | mit | 88 | master | 246 | class DeviseAddLastseenable<%= table_name.camelize.singularize %> < ActiveRecord::Migration
def self.up
add_column :<%= table_name %>, :last_seen, :datetime
end
def self.down
remove_column :<%= table_name %>, :last_seen
end
end |
github | damwhit/harvest_helper | https://github.com/damwhit/harvest_helper | Gemfile | Ruby | mit | 88 | master | 979 | source "https://rubygems.org"
ruby "2.6.3"
gem 'rails', '~> 5.2'
gem 'bootstrap-sass', '~> 3.3.6'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'jquery-rails'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'bcrypt', '~> 3.1.7'
gem 'figaro'
gem 'pg'
gem 'rails_12factor', group: :production
... |
github | damwhit/harvest_helper | https://github.com/damwhit/harvest_helper | config/environment.rb | Ruby | mit | 88 | master | 407 | # Load the Rails application.
require_relative 'application'
# Initialize the Rails application.
Rails.application.initialize!
ActionMailer::Base.smtp_settings = {
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:domain => 'harvesthelper.herokuapp.com',
:address => 'smtp.sendgri... |
github | damwhit/harvest_helper | https://github.com/damwhit/harvest_helper | config/application.rb | Ruby | mit | 88 | master | 1,863 | # require File.expand_path('../boot', __FILE__)
require_relative 'boot'
require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
require "active_record/railtie"
require "active_storage/engine"
require "action_controller/railtie"
require "action_mailer/railtie"
require... |
github | damwhit/harvest_helper | https://github.com/damwhit/harvest_helper | config/routes.rb | Ruby | mit | 88 | master | 808 | Rails.application.routes.draw do
root to: 'plants#index'
devise_for :users, controllers: {
sessions: 'users/sessions'
}
post '/mygarden', to: "gardens#create", as: :gardens
get '/mygarden', to: "gardens#show", as: :garden
delete '/mygarden', to: "gardens#destroy", as: :garden_plants
resources :plan... |
github | damwhit/harvest_helper | https://github.com/damwhit/harvest_helper | config/environments/test.rb | Ruby | mit | 88 | master | 1,904 | Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# The test environment is used exclusively to run your application's
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suit... |
github | damwhit/harvest_helper | https://github.com/damwhit/harvest_helper | config/environments/production.rb | Ruby | mit | 88 | master | 3,780 | Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web serve... |
github | damwhit/harvest_helper | https://github.com/damwhit/harvest_helper | config/initializers/content_security_policy.rb | Ruby | mit | 88 | master | 2,364 | # Be sure to restart your server when you modify this file.
# Define an application-wide content security policy
# For further information see the following documentation
# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy
Rails.application.config.content_security_policy do |policy|
# ... |
github | damwhit/harvest_helper | https://github.com/damwhit/harvest_helper | config/initializers/wrap_parameters.rb | Ruby | mit | 88 | master | 518 | # Be sure to restart your server when you modify this file.
# This file contains settings for ActionController::ParamsWrapper which
# is enabled by default.
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
ActiveSupport.on_load(:action_controller) do
wrap_parameters f... |
github | damwhit/harvest_helper | https://github.com/damwhit/harvest_helper | config/initializers/cloudinary.rb | Ruby | mit | 88 | master | 222 | Cloudinary.config do |config|
config.cloud_name = ENV['CLOUDINARY_NAME']
config.api_key = ENV['CLOUDINARY_KEY']
config.api_secret = ENV['CLOUDINARY_SECRET']
config.secure = true
config.cdn_subdomain = true
end |
github | damwhit/harvest_helper | https://github.com/damwhit/harvest_helper | config/initializers/devise.rb | Ruby | mit | 88 | master | 13,772 | # frozen_string_literal: true
# Use this hook to configure devise mailer, warden hooks and so forth.
# Many of these configuration options can be set straight in your model.
Devise.setup do |config|
# The secret key used by Devise. Devise uses this key to generate
# random tokens. Changing this key will render inv... |
github | damwhit/harvest_helper | https://github.com/damwhit/harvest_helper | db/seeds.rb | Ruby | mit | 88 | master | 489 | require 'csv'
photos = []
Dir.entries(File.join Rails.root, "data/vegetable_photos/").sort.each {
|file_name| photos << file_name
}
plants = File.join Rails.root, "data/garden_vegetables.csv"
count = 2
CSV.foreach(plants, headers: true, header_converters: :symbol) do |row|
data = row.to_h
record = Plant.creat... |
github | damwhit/harvest_helper | https://github.com/damwhit/harvest_helper | db/schema.rb | Ruby | mit | 88 | master | 2,871 | # This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# Note that this schema.rb definition is the authoritative source for your
# dat... |
github | damwhit/harvest_helper | https://github.com/damwhit/harvest_helper | db/migrate/20160425153306_create_locations.rb | Ruby | mit | 88 | master | 224 | class CreateLocations < ActiveRecord::Migration[5.2]
def change
create_table :locations do |t|
t.string :address
t.float :latitude
t.float :longitude
t.timestamps null: false
end
end
end |
github | damwhit/harvest_helper | https://github.com/damwhit/harvest_helper | db/migrate/20160420224413_create_users.rb | Ruby | mit | 88 | master | 256 | class CreateUsers < ActiveRecord::Migration[5.2]
def change
create_table :users do |t|
t.string :uid
t.string :name
t.string :email
t.string :oauth_token
t.string :image
t.timestamps null: false
end
end
end |
github | damwhit/harvest_helper | https://github.com/damwhit/harvest_helper | db/migrate/20160428030614_create_api_keys.rb | Ruby | mit | 88 | master | 230 | class CreateApiKeys < ActiveRecord::Migration[5.0]
def change
create_table :api_keys do |t|
t.string :api_key
t.references :user, index: true, foreign_key: true
t.timestamps null: false
end
end
end |
github | damwhit/harvest_helper | https://github.com/damwhit/harvest_helper | db/migrate/20180412220041_add_devise_to_users.rb | Ruby | mit | 88 | master | 1,685 | # frozen_string_literal: true
class AddDeviseToUsers < ActiveRecord::Migration[5.2]
def self.up
change_table :users do |t|
## Database authenticatable
t.string :encrypted_password, null: false, default: ""
## Recoverable
t.string :reset_password_token
t.datetime :reset_password_s... |
github | damwhit/harvest_helper | https://github.com/damwhit/harvest_helper | db/migrate/20160420163215_create_plants.rb | Ruby | mit | 88 | master | 587 | class CreatePlants < ActiveRecord::Migration[5.2]
def change
create_table :plants do |t|
t.string :name
t.string :description
t.string :optimal_sun
t.string :optimal_soil
t.string :planting_considerations
t.string :when_to_plant
t.string :growing_from_seed
t.string ... |
github | damwhit/harvest_helper | https://github.com/damwhit/harvest_helper | spec/factories.rb | Ruby | mit | 88 | master | 916 | FactoryBot.define do
factory :api_key do
api_key { "0123456789ABCDEF" }
user_id { nil }
end
factory :location do
address { "46250" }
latitude { 1.5 }
longitude { 1.5 }
end
factory :user do
name { "MyString" }
uid { "MyString" }
email { "MyString@example.com" }
password {... |
github | damwhit/harvest_helper | https://github.com/damwhit/harvest_helper | spec/rails_helper.rb | Ruby | mit | 88 | master | 3,534 | # This file is copied to spec/ when you run 'rails generate rspec:install'
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path('../../config/environment', __FILE__)
# Prevent database truncation if the environment is production
abort("The Rails environment is running in production mode!") if Rails.env.production?
requ... |
github | damwhit/harvest_helper | https://github.com/damwhit/harvest_helper | spec/spec_helper.rb | Ruby | mit | 88 | master | 4,543 | require "capybara"
Capybara.server = :webrick
Capybara.register_driver :selenium do |app|
Capybara::Selenium::Driver.new(app, :browser => :chrome)
end
require "simplecov"
SimpleCov.start("rails")
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
# specs live under a `spec` ... |
github | damwhit/harvest_helper | https://github.com/damwhit/harvest_helper | spec/integration/user_can_get_api_key_spec.rb | Ruby | mit | 88 | master | 805 | require "rails_helper"
RSpec.feature "developer can get an api key" do
xcontext "a logged in user is able to get one key" do
before do
user = create(:user)
sign_in user
@api_key = create(:api_key)
end
it "should return a 16 digit key" do
visit '/developers'
click_on 'get ap... |
github | damwhit/harvest_helper | https://github.com/damwhit/harvest_helper | spec/integration/user_can_view_my_garden_page_spec.rb | Ruby | mit | 88 | master | 1,312 | require 'rails_helper'
RSpec.feature "User views their 'my garden' page" do
xcontext "logged in user" do
before do
user = create(:user)
sign_in user
@plant = create(:plant)
end
it "should see the plant that was searched for" do
visit "/plants/#{@plant.id}"
expect(page).to ... |
github | damwhit/harvest_helper | https://github.com/damwhit/harvest_helper | spec/integration/user_can_view_specific_plants_spec.rb | Ruby | mit | 88 | master | 836 | require 'rails_helper'
RSpec.feature "User sees a specific plant" do
xcontext "logged in user, when searching", :js => true do
before do
@user = create(:user)
@plant = create(:plant)
end
it "should see the plant that was searched for" do
visit '/plants'
fill_in 'search', with: ... |
github | damwhit/harvest_helper | https://github.com/damwhit/harvest_helper | spec/requests/api/v1/recipes_spec.rb | Ruby | mit | 88 | master | 571 | require 'rails_helper'
RSpec.describe "GET /api/v1/recipes" do
xit "returns a list of all recipes for a given plant" do
include ApiHelpers
plant1 = create(:plant, name: 'carrot')
create(:plant, name: "test plant numero dos")
api_key = create(:api_key)
get "/api/v1/recipes?plant=#{plant1.name}&ap... |
github | damwhit/harvest_helper | https://github.com/damwhit/harvest_helper | spec/requests/api/v1/plant_spec.rb | Ruby | mit | 88 | master | 960 | require 'rails_helper'
RSpec.describe "GET /api/v1/plants/:id" do
it "returns information for a given plant based on id" do
plant1 = create(:plant)
create(:plant, name: "plant 2")
api_key = create(:api_key)
get "/api/v1/plants/#{plant1.id}?api_key=#{api_key.api_key}"
expect(response.status).to ... |
github | damwhit/harvest_helper | https://github.com/damwhit/harvest_helper | spec/requests/api/v1/update_plant_spec.rb | Ruby | mit | 88 | master | 652 | require "rails_helper"
RSpec.describe "GET api/v1/plants" do
it "returns all plants" do
plant1 = create(:plant)
api_key = create(:api_key)
get "/api/v1/plants/#{plant1.id}?api_key=#{api_key.api_key}"
expect(response.status).to eq(200)
expect(json_body.count).to eq(18)
expect(json_body[:nam... |
github | damwhit/harvest_helper | https://github.com/damwhit/harvest_helper | spec/requests/api/v1/plants_spec.rb | Ruby | mit | 88 | master | 984 | require 'rails_helper'
RSpec.describe "GET /api/v1/plants" do
it "returns a list of all plants" do
include ApiHelpers
plant1 = create(:plant)
create(:plant, name: "test plant numero dos")
api_key = create(:api_key)
get "/api/v1/plants?api_key=#{api_key.api_key}"
expect(response.status).to e... |
github | damwhit/harvest_helper | https://github.com/damwhit/harvest_helper | spec/requests/api/v1/create_plants_spec.rb | Ruby | mit | 88 | master | 697 | require "rails_helper"
RSpec.describe "POST api/v1/plants" do
it "creates a new plant" do
create(:plant)
create(:plant, name: "thing")
api_key = create(:api_key)
post "/api/v1/plants?api_key=#{api_key.api_key}&name=canteloupe&description=guud&optimal_sun=full&optimal_soil=loamy&when_to_plant=now&gro... |
github | damwhit/harvest_helper | https://github.com/damwhit/harvest_helper | spec/requests/api/v1/find_by_spec.rb | Ruby | mit | 88 | master | 980 | require 'rails_helper'
RSpec.describe "GET /api/v1/plants/find?name" do
it "returns information for a given plant based on name" do
plant1 = create(:plant)
create(:plant, name: "plant 2")
api_key = create(:api_key)
get "/api/v1/plants/find?name=#{plant1.name}&api_key=#{api_key.api_key}"
expect(... |
github | damwhit/harvest_helper | https://github.com/damwhit/harvest_helper | spec/models/user_spec.rb | Ruby | mit | 88 | master | 224 | require 'rails_helper'
RSpec.describe User, type: :model do
it { should validate_presence_of(:name) }
it { should validate_presence_of(:email) }
it { should have_many :plants }
it { should have_many :api_keys }
end |
github | damwhit/harvest_helper | https://github.com/damwhit/harvest_helper | spec/models/plant_spec.rb | Ruby | mit | 88 | master | 552 | require 'rails_helper'
RSpec.describe Plant, type: :model do
it { should validate_presence_of(:name) }
it { should validate_uniqueness_of(:name) }
it { should validate_presence_of(:description) }
it { should validate_presence_of(:optimal_sun) }
it { should validate_presence_of(:optimal_soil) }
it { should ... |
github | damwhit/harvest_helper | https://github.com/damwhit/harvest_helper | app/models/plant.rb | Ruby | mit | 88 | master | 1,201 | class Plant < ApplicationRecord
before_create :reset_attributes
belongs_to :user, optional: true
validates :name, presence: true, uniqueness: true
validates :description, presence: true
validates :optimal_sun, presence: true
validates :optimal_soil, presence: true
validates :when_to_plant, presence: true... |
github | damwhit/harvest_helper | https://github.com/damwhit/harvest_helper | app/models/user.rb | Ruby | mit | 88 | master | 774 | class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
has_many :plants
has_many :api_keys
validates :nam... |
github | damwhit/harvest_helper | https://github.com/damwhit/harvest_helper | app/models/frost_date.rb | Ruby | mit | 88 | master | 587 | class FrostDate
attr_reader :spring,
:fall
def initialize(data)
@spring = format_spring(data)
@fall = format_fall(data)
end
def self.service
FarmSenseService.new
end
def self.find(lat, lon)
FrostDate.new(service.get_stations(lat, lon))
end
def format_spring(data)
re... |
github | damwhit/harvest_helper | https://github.com/damwhit/harvest_helper | app/models/api_key.rb | Ruby | mit | 88 | master | 265 | class ApiKey < ApplicationRecord
belongs_to :user, optional: true
before_create :generate_access_token
private
def generate_access_token
begin
self.api_key = SecureRandom.hex
end while self.class.exists?(api_key: api_key)
end
end |
github | damwhit/harvest_helper | https://github.com/damwhit/harvest_helper | app/models/recipe.rb | Ruby | mit | 88 | master | 737 | class Recipe
attr_reader :name,
:image,
:ingredients,
:id,
:servings,
:tags,
:url,
:source,
:sourceIcon
def initialize(data)
@name = data[:label]
@image = data[:image]
@ingredients = data[:in... |
github | damwhit/harvest_helper | https://github.com/damwhit/harvest_helper | app/controllers/plants_controller.rb | Ruby | mit | 88 | master | 741 | class PlantsController < ApplicationController
respond_to :html, :json
def index
term = params[:term].try(:downcase)
plants = Plant.where("LOWER(name) LIKE ?", "%#{term}%").take(7)
respond_with(plants)
end
def show
@plant = Plant.find(params["id"])
location = Location.where(address: param... |
github | damwhit/harvest_helper | https://github.com/damwhit/harvest_helper | app/controllers/application_controller.rb | Ruby | mit | 88 | master | 318 | class ApplicationController < ActionController::Base
before_action :configure_permitted_parameters, if: :devise_controller?
protect_from_forgery with: :exception
respond_to :html, :json
protected
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: [:name])
end
end |
github | damwhit/harvest_helper | https://github.com/damwhit/harvest_helper | app/controllers/gardens_controller.rb | Ruby | mit | 88 | master | 921 | class GardensController < ApplicationController
before_action :authenticate_user!
skip_before_action :authenticate_user!, :only => [:destroy]
skip_before_action :verify_authenticity_token, :only => [:destroy]
def show
@plants = current_user.plants.order(name: :asc)
end
def create
plant = Plant.f... |
github | damwhit/harvest_helper | https://github.com/damwhit/harvest_helper | app/controllers/api_keys_controller.rb | Ruby | mit | 88 | master | 362 | class ApiKeysController < ApplicationController
before_action :authenticate_user!
def show
end
def create
api_key = ApiKey.create
if current_user.api_keys.empty?
current_user.api_keys << api_key
render :show
else
flash.now[:alert] = "Sorry #{current_user.name}, only one key per d... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.