repo_name stringlengths 6 97 | path stringlengths 3 341 | text stringlengths 8 1.02M |
|---|---|---|
ryanlntn/medic | lib/medic/units.rb | module Medic
module Units
def sample_unit(u)
return unless u
camelized = u.to_s.gsub(/_([a-z]*)/){ "#{$1.capitalize}" }
if HKUnit.respond_to?(:"#{camelized}Unit")
HKUnit.send(:"#{camelized}Unit")
else
HKUnit.unitFromString(u.to_s)
end
end
end
end
|
ryanlntn/medic | lib/medic/observer_query_builder.rb | module Medic
class ObserverQueryBuilder
attr_reader :params
attr_reader :query
include Medic::Types
include Medic::Predicate
def initialize(args={}, block=Proc.new)
@params = args
@query = HKObserverQuery.alloc.initWithSampleType(object_type(args[:type]),
predicate: predicate... |
ryanlntn/medic | lib/medic/statistics_collection_query_builder.rb | module Medic
class StatisticsCollectionQueryBuilder
attr_reader :params
attr_reader :query
include Medic::Types
include Medic::Predicate
include Medic::StatisticsOptions
include Medic::Anchor
include Medic::Interval
def initialize(args={})
@params = args
@query = HKStatis... |
ryanlntn/medic | lib/medic/correlation_query_builder.rb | <reponame>ryanlntn/medic
module Medic
class CorrelationQueryBuilder
attr_reader :params
attr_reader :query
include Medic::Types
include Medic::Predicate
def initialize(args={}, block=Proc.new)
@params = args
@query = HKCorrelationQuery.alloc.initWithType(object_type(args[:type]),
... |
ryanlntn/medic | lib/medic/finders.rb | <gh_stars>10-100
module Medic
module Finders
def observe(type, options={}, block=Proc.new)
query_params = options.merge(type: type)
query = Medic::ObserverQueryBuilder.new query_params do |query, completion, error|
block.call(completion, error)
end.query
Medic.execute(query)
e... |
ryanlntn/medic | spec/medic/sample_query_builder_spec.rb | describe Medic::SampleQueryBuilder do
before do
@subject = Medic::SampleQueryBuilder.new type: :dietary_protein, limit: 7 do |query, results, error|
end
end
it "has a query getter that returns an HKSampleQuery" do
@subject.query.should.be.kind_of? HKSampleQuery
end
end
|
ryanlntn/medic | spec/medic/hk_constants_spec.rb | describe Medic::HKConstants do
before do
@subject = Object.new
@subject.extend(Medic::HKConstants)
end
describe "#error_code" do
it "returns the correct error code for symbol" do
@subject.error_code(:no_error).should == HKNoError
@subject.error_code(:health_data_unavailable).should == HK... |
ryanlntn/medic | spec/medic/interval_spec.rb | <filename>spec/medic/interval_spec.rb
describe Medic::Interval do
before do
@subject = Object.new
@subject.extend(Medic::Interval)
end
describe "#interval" do
it "returns the correct NSDateComponents object for symbol" do
@subject.interval(:nine_hundred_ninety_nine_days).should.be.kind_of? NSD... |
ryanlntn/medic | lib/medic/anchor.rb | module Medic
module Anchor
NUMBER_WORDS = {
'zero' => 0, 'one' => 1, 'two' => 2, 'three' => 3, 'four' => 4, 'five' => 5,
'six' => 6, 'seven' => 7, 'eight' => 8, 'nine' => 9, 'ten' => 10, 'eleven' => 11,
'twelve' => 12, 'thirteen' => 13, 'fourteen' => 14, 'fifteen' => 15, 'sixteen' => 16,
... |
ryanlntn/medic | lib/medic/store.rb | module Medic
class Store
include Medic::Types
include Medic::Units
include Medic::HKConstants
def self.shared
Dispatch.once { @@hk_store ||= HKHealthStore.new }
Dispatch.once { @medic_store ||= new }
@medic_store
end
def self.hk_store
@@hk_store
end
def self.... |
ryanlntn/medic | spec/medic/correlation_query_builder_spec.rb | describe Medic::CorrelationQueryBuilder do
before do
high_cal = HKQuantity.quantityWithUnit(HKUnit.kilocalorieUnit, doubleValue: 800.0)
greater_than_high_cal = HKQuery.predicateForQuantitySamplesWithOperatorType(NSGreaterThanOrEqualToPredicateOperatorType, quantity: high_cal)
energy_consumed = HKObjectTy... |
ryanlntn/medic | spec/medic/statistics_query_builder_spec.rb | describe Medic::StatisticsQueryBuilder do
before do
@subject = Medic::StatisticsQueryBuilder.new type: :step_count, options: :sum do |query, results, error|
end
end
it "has a query getter that returns an HKStatisticsQuery" do
@subject.query.should.be.kind_of? HKStatisticsQuery
end
end
|
ryanlntn/medic | lib/medic/source_query_builder.rb | module Medic
class SourceQueryBuilder
attr_reader :params
attr_reader :query
include Medic::Types
include Medic::Predicate
def initialize(args={}, block=Proc.new)
@params = args
@query = HKSourceQuery.alloc.initWithSampleType(object_type(args[:type]),
samplePredicate: predica... |
ryanlntn/medic | spec/medic/anchored_object_query_builder_spec.rb | <filename>spec/medic/anchored_object_query_builder_spec.rb
describe Medic::AnchoredObjectQueryBuilder do
before do
@subject = Medic::AnchoredObjectQueryBuilder.new type: :step_count do |query, results, new_anchor, error|
end
end
it "has a query getter that returns an HKAnchoredObjectQuery" do
@subje... |
ryanlntn/medic | lib/medic/statistics_query_builder.rb | module Medic
class StatisticsQueryBuilder
attr_reader :params
attr_reader :query
include Medic::Types
include Medic::Predicate
include Medic::StatisticsOptions
def initialize(args={}, block=Proc.new)
@params = args
@query = HKStatisticsQuery.alloc.initWithQuantityType(object_type... |
ryanlntn/medic | spec/medic/observer_query_builder_spec.rb | describe Medic::ObserverQueryBuilder do
before do
@subject = Medic::ObserverQueryBuilder.new type: :step_count do |query, completion, error|
end
end
it "has a query getter that returns an HKObserverQuery" do
@subject.query.should.be.kind_of? HKObserverQuery
end
end
|
ryanlntn/medic | lib/medic/anchored_object_query_builder.rb | module Medic
class AnchoredObjectQueryBuilder
attr_reader :params
attr_reader :query
include Medic::Types
include Medic::Predicate
include Medic::Anchor
def initialize(args={}, block=Proc.new)
@params = args
@query = HKAnchoredObjectQuery.alloc.initWithType(object_type(args[:type... |
whiteleaf7/enumerize | lib/enumerize/version.rb | <filename>lib/enumerize/version.rb
# frozen_string_literal: true
module Enumerize
VERSION = '2.3.1'
end
|
whiteleaf7/enumerize | lib/enumerize/value.rb | <filename>lib/enumerize/value.rb
# frozen_string_literal: true
require 'i18n'
module Enumerize
class Value < String
include Predicatable
attr_reader :value
def initialize(attr, name, value=nil)
if self.class.method_defined?("#{name}?")
warn("It's not recommended to use `#{name}` as a fie... |
hhvm/homebrew-hhvm | Formula/hhvm-4.101.rb | #
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
class Hhvm4101 < Formula
desc "JIT compiler and runtime for the Hack language"
homepage "http://hhvm.com/"
head "h... |
bnadlerjr/gitscore | app/adapters/github.rb | <reponame>bnadlerjr/gitscore<filename>app/adapters/github.rb
module Gitscore
module Adapters
class Github
def fetch_profile(username)
response = HTTParty.get("http://github.com/#{username}.json")
data = JSON.parse(response.body)
profile = UserProfile.new(
username: data[0][... |
bnadlerjr/gitscore | test/unit/user_profile_test.rb | require_relative "../test_helper"
require_relative "../../app/user_profile"
require_relative "../../app/event"
module Gitscore
class UserProfileTest < Test::Unit::TestCase
test "has events" do
profile = UserProfile.new
event = Event.new(type: "WatchEvent")
profile.events << event
assert_e... |
bnadlerjr/gitscore | test/unit/event_test.rb | <filename>test/unit/event_test.rb
require_relative "../test_helper"
require_relative "../../app/event"
module Gitscore
class EventTest < Test::Unit::TestCase
test "assigns a score" do
event = Event.new(type: "WatchEvent")
assert_equal(1, event.score)
end
test "assign a score of zero for unkn... |
bnadlerjr/gitscore | app/user_profile.rb | <filename>app/user_profile.rb
module Gitscore
UserProfile = Struct.new(:username, :name, :events) do
def initialize(**attrs)
attrs.each { |k, v| self[k] = v }
self[:events] = []
end
def score
self.events.reduce(0) { |sum, e| sum + e.score }
end
end
end
|
bnadlerjr/gitscore | test/integration/github_test.rb | require_relative "../test_helper"
require_relative "../../app/adapters/github"
require_relative "../../app/user_profile"
require_relative "../../app/event"
require "httparty"
module Gitscore
module Adapters
class GithubTest < Test::Unit::TestCase
test "fetch profile" do
github = Github.new
... |
bnadlerjr/gitscore | app.rb | require "sinatra/base"
require "rack/csrf"
require_relative "app/adapters/github"
require_relative "app/user_profile"
require_relative "app/event"
require "httparty"
Dir.glob(File.join("helpers", "**", "*.rb")).each do |helper|
require_relative helper
end
module Gitscore
class App < Sinatra::Base
set :root, F... |
bnadlerjr/gitscore | test/unit/app_test.rb | require_relative "../test_helper"
require_relative "../../app/user_profile"
require_relative "../../app/event"
class FakeGithub
def fetch_profile(username)
profile = Gitscore::UserProfile.new(
username: "bnadlerjr",
name: "<NAME>"
)
profile.events << Gitscore::Event.new(type: "WatchEvent")
... |
bnadlerjr/gitscore | config.ru | <reponame>bnadlerjr/gitscore<gh_stars>1-10
require "bundler/setup"
require "dotenv"
Dotenv.load
require File.expand_path("../app", __FILE__)
app = Gitscore::App
app.set :github, Gitscore::Adapters::Github.new
run app
|
bnadlerjr/gitscore | app/event.rb | module Gitscore
SCORES = {
"CommitCommentEvent" => 2,
"IssueCommentEvent" => 2,
"IssueEvent" => 3,
"WatchEvent" => 1,
"PullRequestEvent" => 5
}
Event = Struct.new(:type) do
def initialize(**attrs)
attrs.each { |k, v| self[k] = v }
end
def score
SCOR... |
Eyewritecode/igihe | igihe.rb | <gh_stars>1-10
require 'open-uri'
require 'nokogiri'
category = ARGV.first
base_url = "http://igihe.com/"
articles =[]
article_num =0
trash = Nokogiri::HTML(open("http://igihe.com/#{category}"))
puts "\nHi! i found these articles for you:"
puts "\n############################################\n"
trash.css(".homenews-... |
ManuelAF/click-to-deploy | vm/chef/cookbooks/erpnext/recipes/default.rb | # Copyright 2020 Google LLC
#
# 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 agreed to in writing, ... |
cpb/sexp_cli_tools | lib/sexp_cli_tools.rb | # frozen_string_literal: true
require 'ruby_parser'
require_relative 'sexp_cli_tools/version'
require_relative 'sexp_cli_tools/matchers/super_caller'
require_relative 'sexp_cli_tools/matchers/method_implementation'
module SexpCliTools
class Error < StandardError; end
MATCHERS = Hash
.new { |hash, k... |
cpb/sexp_cli_tools | lib/sexp_cli_tools/matchers/method_implementation.rb | # frozen_string_literal: true
module SexpCliTools
module Matchers
# A matcher that's satisfied by an s-expression containing a method definition.
class MethodImplementation
def self.satisfy?(sexp, target_method)
new(target_method).satisfy?(sexp)
end
def initialize(target_method)
... |
cpb/sexp_cli_tools | test/fixtures/generic_empty_class.rb | <filename>test/fixtures/generic_empty_class.rb
# frozen_string_literal: true
class Bicycle
# foo
end
|
cpb/sexp_cli_tools | test/sexp_cli_tools/matchers/method_implementation_test.rb | # frozen_string_literal: true
require 'test_helper'
module SexpExamples
def self.included(base)
base.let(:sexp_with_initialize) { parse_file('road_bike.rb') }
base.let(:sexp_without_initialize) do
RubyParser.new.parse(<<~EMPTY_CLASS_DEFINITION)
class Scooter
end
EMPTY_CLASS_DEFIN... |
cpb/sexp_cli_tools | test/test_helper.rb | <filename>test/test_helper.rb
# frozen_string_literal: true
$LOAD_PATH.unshift File.expand_path('../lib', __dir__)
require 'sexp_cli_tools'
require 'minitest/autorun'
require 'pry'
def fixture_path(basename, relative_path = Pathname.new('test/fixtures/coupling_between_superclasses_and_subclasses'))
relative_path... |
cpb/sexp_cli_tools | test/sexp_cli_tools/matchers/super_caller_test.rb | <reponame>cpb/sexp_cli_tools
# frozen_string_literal: true
require 'test_helper'
module SuperCallerExamples
def self.included(base)
base.let(:without_super_caller) { parse_file('bicycle.rb') }
base.let(:with_super_caller) { parse_file('road_bike.rb') }
base.let(:with_super_caller_no_args) { parse_file('... |
cpb/sexp_cli_tools | lib/sexp_cli_tools/cli.rb | # frozen_string_literal: true
require 'thor'
require 'sexp_cli_tools'
module SexpCliTools
# Top-level command-line interface defining public shell interface.
class Cli < Thor
desc 'version', 'Prints version'
default_command def version
puts format('SexpCliTools version: %p', SexpCliTools::VERSION)
... |
cpb/sexp_cli_tools | test/fixtures/coupling_between_superclasses_and_subclasses/mountain_bike.rb | <filename>test/fixtures/coupling_between_superclasses_and_subclasses/mountain_bike.rb
# frozen_string_literal: true
class MountainBike < Bicycle
attr_reader :front_shock, :rear_shock
def initialize(args)
@front_shock = args[:front_shock]
@rear_shock = args[:rear_shock]
super(args)
end
def spares... |
cpb/sexp_cli_tools | lib/sexp_cli_tools/version.rb | <gh_stars>1-10
# frozen_string_literal: true
module SexpCliTools
VERSION = '1.0.0'
end
|
cpb/sexp_cli_tools | test/fixtures/no_initialize.rb | # frozen_string_literal: true
# Test fixture for `sexp find method-implementation initialize`
class NoInitialize
def some_other_method; end
end
|
cpb/sexp_cli_tools | test/fixtures/coupling_between_superclasses_and_subclasses/bicycle.rb | # frozen_string_literal: true
class Bicycle
attr_reader :size, :chain, :tire_size
def initialize(args)
@size = args[:size]
@chain = args[:chain] || default_chain
@tire_size = args[:tire_size] || default_tire_size
end
def default_chain
'10-speed'
end
def default_tire_size
rais... |
cpb/sexp_cli_tools | test/fixtures/coupling_between_superclasses_and_subclasses/road_bike.rb | <reponame>cpb/sexp_cli_tools<filename>test/fixtures/coupling_between_superclasses_and_subclasses/road_bike.rb
# frozen_string_literal: true
class RoadBike < Bicycle
attr_reader :tape_color
def initialize(args)
@tape_color = args[:tape_color]
super(args)
end
def spares
super.merge({ tape_color: ta... |
cpb/sexp_cli_tools | lib/sexp_cli_tools/matchers/super_caller.rb | <reponame>cpb/sexp_cli_tools<filename>lib/sexp_cli_tools/matchers/super_caller.rb
# frozen_string_literal: true
require 'sexp_processor'
require 'json'
module SexpCliTools
module Matchers
# Matches a call to `super` and captures the method name of calling `super`
class SuperCaller < MethodBasedSexpProcessor... |
cpb/sexp_cli_tools | test/sexp_cli_tools/cli_test.rb | <filename>test/sexp_cli_tools/cli_test.rb
# frozen_string_literal: true
require 'test_helper'
describe 'sexp' do
include CliTestHelpers
it { _(subject).must_match(/SexpCliTools version: "\d+\.\d+\.\d+"/) }
end
describe 'sexp find child-class' do
include CliTestHelpers
it "doesn't match our parent class" do... |
cpb/sexp_cli_tools | test/sexp_cli_tools_test.rb | # frozen_string_literal: true
require 'test_helper'
describe SexpCliTools do
it 'has a version number' do
refute_nil SexpCliTools::VERSION
end
describe "MATCHERS['(class ___)']" do
subject { SexpCliTools::MATCHERS['(class ___)'] }
let(:a_class_sexp) { RubyParser.new.parse('class Foobar; end') }
... |
mathieujobin/weak_parameters | lib/weak_parameters.rb | require "active_support/hash_with_indifferent_access"
require "active_support"
require 'active_support/core_ext/object/blank'
require "weak_parameters/base_validator"
require "weak_parameters/any_validator"
require "weak_parameters/array_validator"
require "weak_parameters/boolean_validator"
require "weak_parameters/f... |
mathieujobin/weak_parameters | spec/requests/strong_spec.rb | require "spec_helper"
describe "Strong", type: :request do
let(:params) do
{
object: [1],
strong_object: [1],
name: "name",
strong_name: "name",
number: 0,
strong_number: 0,
type: 1,
strong_type: 1,
flag: true,
strong_flag: true,
config: { a: 1 },... |
uuttff8/DeclarativeLayoutKit | DeclarativeLayoutKit.podspec | Pod::Spec.new do |spec|
spec.name = "DeclarativeLayoutKit"
spec.version = "3.0.3"
spec.summary = "UIKit declarative layout like SwiftUI."
spec.homepage = "https://github.com/Ernest0-Production/DeclarativeLayoutKit"
spec.license = { :type => "MIT", :file => "LICENSE.md" }
spec.aut... |
ruddfawcett/hoot | lib/hoot/client.rb | require 'json'
require 'net/https'
require 'uri'
module Hoot
unless ENV['DEV']
HEDWING_ENDPOINT = 'https://hedwig.herokuapp.com'
else
HEDWING_ENDPOINT = 'http://localhost:5000'
end
class Client
attr_accessor :hedwig
attr_accessor :credentials
def initialize
@hedwig = ENV['HEDWING_ENDPOINT'] || HEDW... |
ruddfawcett/hoot | lib/hoot/metadata.rb | <reponame>ruddfawcett/hoot
require 'yaml'
module Hoot
module Metadata
@path = "#{ENV['HOME']}/.hoot/metadata.yml"
public
def self.set(key, value)
return if value.nil?
return unless keys.include?(key)
create unless File.exist?(@path)
if File.exist?(@path)
@m = YAML::load... |
ruddfawcett/hoot | hoot.gemspec | # coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'hoot/version'
Gem::Specification.new do |s|
s.name = "hoot"
s.version = Hoot::VERSION
s.authors = ["<NAME>"]
s.email = ["<EMAIL>"]
s.summary = "Send ... |
ruddfawcett/hoot | lib/hoot.rb | <gh_stars>1-10
require 'hoot/client'
require 'hoot/keychain'
require 'hoot/metadata'
require 'hoot/user'
require 'hoot/version'
|
ruddfawcett/hoot | lib/hoot/user.rb | <gh_stars>1-10
require 'commander/import'
module Hoot
module User
@client = Hoot::Client.new
def self.login
puts 'Enter your Hoot credentials.'
email = ask 'Email: '
password = Digest::SHA1.hexdigest(password 'Password: ', '*')
credentials = [email, password]
@client.authenticate(credentials)
... |
ruddfawcett/hoot | lib/hoot/keychain.rb | <gh_stars>1-10
require 'netrc'
require 'digest/sha1'
module Hoot
module Keychain
@n = Netrc.read
public
def self.authenticated?
login, password = @n['hedwig.herokuapp.com']
if (login.nil? || login == 0) || (password.nil? || password == 0)
return false
end
return true
... |
fossabot/binance-api-ruby | spec/spec_helper.rb | require "bundler/setup"
require "binance_api"
RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
config.example_status_persistence_file_path = ".rspec_status"
# Disable RSpec exposing methods globally on `Module` and `main`
config.disable_monkey_patching!
config.expect_with ... |
fossabot/binance-api-ruby | lib/binance_api/base.rb | <filename>lib/binance_api/base.rb
require 'rest-client'
require 'date'
require 'uri'
require 'json'
require 'binance_api/result'
module BinanceAPI
class Base
BASE_URL = 'https://api.binance.com'.freeze
protected
def params_with_signature(params, secret)
params = params.reject { |_k, v| v.nil? }
... |
fossabot/binance-api-ruby | lib/binance_api/rest.rb | require 'rest-client'
require 'date'
require 'uri'
require 'json'
require 'binance_api/base'
require 'binance_api/result'
module BinanceAPI
class REST < BinanceAPI::Base
def ping
response = safe { RestClient.get("#{BASE_URL}/api/v1/ping") }
build_result response
end
def server_time
res... |
fossabot/binance-api-ruby | lib/binance_api.rb | <reponame>fossabot/binance-api-ruby
require 'binance_api/version'
require 'binance_api/rest'
require 'binance_api/wapi'
require 'binance_api/stream'
require 'yaml'
module BinanceAPI
class << self
def rest
@rest ||= BinanceAPI::REST.new
end
def wapi
@wapi ||= BinanceAPI::WAPI.new
end
... |
Nerian/effective_resources | app/models/effective/resource_exec.rb | # Makes sure resource in any instance_execs is the correct resource
module Effective
class ResourceExec
def initialize(instance, resource)
@instance = instance
@resource = resource
end
def resource
@resource
end
def method_missing(method, *args, &block)
@instance.send(me... |
Nerian/effective_resources | app/models/effective/model_reader.rb | <reponame>Nerian/effective_resources
module Effective
class ModelReader
DATATYPES = [:binary, :boolean, :date, :datetime, :decimal, :float, :hstore, :inet, :integer, :string, :text, :permitted_param]
attr_reader :attributes
def initialize(&block)
@attributes = {}
end
def read(&block)
... |
Nerian/effective_resources | app/controllers/concerns/effective/crud_controller/respond.rb | <reponame>Nerian/effective_resources<filename>app/controllers/concerns/effective/crud_controller/respond.rb
module Effective
module CrudController
module Respond
def respond_with_success(format, resource, action)
if specific_redirect_path?(action)
format.html do
flash[:success]... |
Nerian/effective_resources | app/models/effective/resources/paths.rb | module Effective
module Resources
module Paths
def model_file
File.join('app/models', class_path.to_s, "#{name}.rb")
end
def controller_file
File.join('app/controllers', namespace.to_s, "#{plural_name}_controller.rb")
end
def datatable_file
File.join('app/d... |
Nerian/effective_resources | app/controllers/concerns/effective/crud_controller/permitted_params.rb | module Effective
module CrudController
module PermittedParams
BLACKLIST = [:created_at, :updated_at, :logged_change_ids]
# This is only available to models that use the effective_resource do ... end attributes block
# It will be called last, and only for those resources
# params.require(e... |
Nerian/effective_resources | app/models/effective/resources/naming.rb | <reponame>Nerian/effective_resources<filename>app/models/effective/resources/naming.rb<gh_stars>0
module Effective
module Resources
module Naming
SPLIT = /\/|::/ # / or ::
def name # 'post'
@name ||= ((klass.present? ? klass.name : initialized_name).to_s.split(SPLIT).last || '').singularize.... |
Nerian/effective_resources | app/controllers/concerns/effective/crud_controller/submits.rb | module Effective
module CrudController
module Submits
extend ActiveSupport::Concern
module ClassMethods
# { 'Save' => { action: save, ...}}
def submits
@_effective_submits ||= effective_resource.submits
end
# { 'Approve' => { action: approve, ...}}
d... |
Nerian/effective_resources | app/models/concerns/acts_as_archived.rb | # ActsAsArchived
#
# Implements the dumb archived pattern
# An archived object should not be displayed on index screens, or any related resource's #new pages
# effective_select (from the effective_bootstrap gem) is aware of this concern, and calls .unarchived and .archived appropriately when passed an ActiveRecord rela... |
Nerian/effective_resources | app/models/effective/resources/forms.rb | <reponame>Nerian/effective_resources
module Effective
module Resources
module Forms
# Used by datatables
def search_form_field(name, type = nil)
case (type || sql_type(name))
when :belongs_to
{ as: :select }.merge(search_form_field_collection(belongs_to(name)))
when ... |
Nerian/effective_resources | app/models/effective/action_failed.rb | module Effective
class ActionFailed < StandardError
attr_reader :action, :subject
def initialize(message = nil, action = nil, subject = nil)
@message = message
@action = action
@subject = subject
end
def to_s
@message || I18n.t(:'unauthorized.default', :default => 'Action Fai... |
Nerian/effective_resources | app/models/concerns/effective_resource.rb | # EffectiveResource
#
# Mark your model with 'effective_resource'
module EffectiveResource
extend ActiveSupport::Concern
module ActiveRecord
def effective_resource(options = nil, &block)
return @_effective_resource unless block_given?
include ::EffectiveResource
@_effective_resource = Effec... |
Nerian/effective_resources | app/models/effective/resources/relation.rb | <filename>app/models/effective/resources/relation.rb
module Effective
module Resources
module Relation
def relation
@relation ||= klass.where(nil)
end
# When Effective::Resource is initialized with an ActiveRecord relation, the following
# methods will be available to operate on ... |
Nerian/effective_resources | app/models/effective/resources/instance.rb | module Effective
module Resources
module Instance
attr_accessor :instance
# This is written for use by effective_logging and effective_trash
BLACKLIST = [:logged_changes, :trash]
def instance
@instance || klass.new
end
# called by effective_trash and effective_loggin... |
Nerian/effective_resources | app/models/concerns/acts_as_slugged.rb | # ActsAsSlugged
#
# This module automatically generates slugs based on the :to_s field using a before_validation filter
#
# Mark your model with 'acts_as_sluggable' make sure you have a string field :slug
module ActsAsSlugged
extend ActiveSupport::Concern
module ActiveRecord
def acts_as_slugged(options = nil)... |
Nerian/effective_resources | app/models/effective/code_reader.rb | <reponame>Nerian/effective_resources
module Effective
class CodeReader
attr_reader :lines
def initialize(filename, &block)
@lines = File.open(filename).readlines
block.call(self) if block_given?
end
# Iterate over the lines with a depth, and passed the stripped line to the passed block
... |
Nerian/effective_resources | app/models/effective/resources/init.rb | module Effective
module Resources
module Init
private
def _initialize_input(input, namespace: nil)
@initialized_name = input
@model_klass = case input
when String, Symbol
_klass_by_name(input)
when Class
input
when ActiveRecord::Relation
... |
Nerian/effective_resources | app/models/effective/resources/actions.rb | <filename>app/models/effective/resources/actions.rb
module Effective
module Resources
module Actions
# This was written for the Edit actions fallback templates and Datatables
# Effective::Resource.new('admin/posts').routes[:index]
def routes
@routes ||= (
matches = [[namespace... |
Nerian/effective_resources | app/controllers/concerns/effective/flash_messages.rb | <filename>app/controllers/concerns/effective/flash_messages.rb
module Effective
module FlashMessages
extend ActiveSupport::Concern
# flash[:success] = flash_success(@post)
def flash_success(resource, action = nil, name: nil)
raise 'expected an ActiveRecord resource' unless (name || resource.class.r... |
Nerian/effective_resources | app/models/effective/resources/sql.rb | module Effective
module Resources
module Sql
def column(name)
name = name.to_s
columns.find { |col| col.name == name || (belongs_to(name) && col.name == belongs_to(name).foreign_key) }
end
def columns
klass.columns
end
def column_names
@column_names... |
Nerian/effective_resources | lib/generators/effective_resources/install_generator.rb | <filename>lib/generators/effective_resources/install_generator.rb
module EffectiveResources
module Generators
class InstallGenerator < Rails::Generators::Base
desc 'Creates an EffectiveResources initializer in your application.'
source_root File.expand_path('../../templates', __FILE__)
def cop... |
Nerian/effective_resources | app/controllers/concerns/effective/crud_controller.rb | <reponame>Nerian/effective_resources
module Effective
module CrudController
extend ActiveSupport::Concern
include Effective::CrudController::Actions
include Effective::CrudController::Paths
include Effective::CrudController::PermittedParams
include Effective::CrudController::Respond
include E... |
Nerian/effective_resources | app/models/effective/attribute.rb | <filename>app/models/effective/attribute.rb<gh_stars>0
module Effective
class Attribute
attr_accessor :name, :type, :klass
# This parses the written attributes
def self.parse_written(input)
input = input.to_s
if (scanned = input.scan(/^\W*(\w+)\W*:(\w+)/).first).present?
new(*scanned... |
Nerian/effective_resources | app/models/effective/resource.rb | <gh_stars>0
module Effective
class Resource
include Effective::Resources::Actions
include Effective::Resources::Associations
include Effective::Resources::Attributes
include Effective::Resources::Controller
include Effective::Resources::Init
include Effective::Resources::Instance
include E... |
Nerian/effective_resources | lib/effective_resources/engine.rb | module EffectiveResources
class Engine < ::Rails::Engine
engine_name 'effective_resources'
config.autoload_paths += Dir["#{config.root}/lib/", "#{config.root}/app/controllers/concerns/effective/"]
# Set up our default configuration options.
initializer 'effective_resources.defaults', before: :load_c... |
lhursh/YLogging | YLogging.podspec | Pod::Spec.new do |s|
s.name = "YLogging"
s.version = "1.0.0"
s.summary = "Short description of 'YLogging' framework"
s.homepage = "http://www.listrak.com"
s.license = "MIT"
s.author = "<NAME>"
s.platform = :ios, "10.0"
s.source = {:git=>"https://github.com/lhursh/YLogging.git", :tag => "1.0.0"}
s.source_files = "YLoggi... |
lhursh/YLogging | YLogging-Pod-Folder/YLogging.podspec | <filename>YLogging-Pod-Folder/YLogging.podspec<gh_stars>0
Pod::Spec.new do |s|
s.name = "YLogging"
s.version = "1.0.0"
s.summary = "Short description of 'YLogging' framework"
s.homepage = "http://www.listrak.com"
s.license = "MIT"
s.author = "<NAME>"
s.platform = :ios, "10.0"
s.source = {:http => 'https://github.com/lh... |
ricardotk002/machina | lib/machina/dependencies.rb | <reponame>ricardotk002/machina<filename>lib/machina/dependencies.rb
class Object
def self.const_missing(c)
require Machina.to_underscore(c.to_s)
Object.const_get(c)
end
end
|
ricardotk002/machina | lib/machina.rb | require "machina/version"
require "machina/routing"
require "machina/util"
require "machina/dependencies"
require "machina/controller"
require "machina/file_model"
module Machina
class Application
def call(env)
if env['PATH_INFO'] == '/favicon.ico'
return [404, { 'Content-Type' => 'text/html' }, []... |
ricardotk002/machina | lib/machina/controller.rb | require 'erubis'
require 'machina/file_model'
module Machina
class Controller
include Machina::Model
attr_reader :env
def initialize(env)
@env = env
end
def render(view_name, locals = {})
filename = File.join("app", "views", controller_name, "#{view_name}.html.erb")
template =... |
mlj/rss2pocket | lib/app.rb | <reponame>mlj/rss2pocket
require_relative 'feed_db'
require 'pocket-ruby'
module PocketFetcher
def self.run(&block)
cache = Cache.new('config/feeds.yml')
cache.each_url do |url|
Feed.new(url, cache).fetch do |entry, tags|
yield entry.url, tags
end
cache.save
end
end
end
con... |
mlj/rss2pocket | lib/feed_db.rb | <filename>lib/feed_db.rb
require 'feedjira'
require 'httparty'
require 'yaml'
class Cache
def initialize(cache_file = 'feeds.yml')
if File.exists?(cache_file)
@data = YAML::load_file(cache_file)
@data = {} unless @data
else
@data = {}
end
@cache_file = cache_file
end
def save... |
lxl125z/LxlTest | LxlTest.podspec | Pod::Spec.new do |s|
s.name = "LxlTest"
s.version = "1.0.2"
s.summary = "LxlTest is a test code by LXL."
s.description = <<-DESC
It is a marquee view used on iOS, which implement by Objective-C.
DESC
s.homepage = "https://github.com/lxl125z/LxlTest"
s.license = 'MIT'... |
vasinov/paper_trail | lib/paper_trail.rb | require "request_store"
require "paper_trail/cleaner"
require "paper_trail/config"
require "paper_trail/has_paper_trail"
require "paper_trail/record_history"
require "paper_trail/reifier"
require "paper_trail/version_association_concern"
require "paper_trail/version_concern"
require "paper_trail/version_number"
require... |
vasinov/paper_trail | test/test_helper.rb | <reponame>vasinov/paper_trail<filename>test/test_helper.rb
require "pry-nav"
ENV["RAILS_ENV"] = "test"
ENV["DB"] ||= "sqlite"
unless File.exist?(File.expand_path("../../test/dummy/config/database.yml", __FILE__))
warn "WARNING: No database.yml detected for the dummy app, please run `rake prepare` first"
end
def us... |
vasinov/paper_trail | spec/models/post_with_status_spec.rb | <reponame>vasinov/paper_trail
require "rails_helper"
# This model is in the test suite soley for the purpose of testing ActiveRecord::Enum,
# which is available in ActiveRecord4+ only
describe PostWithStatus, type: :model do
if defined?(ActiveRecord::Enum)
with_versioning do
let(:post) { PostWithStatus.cre... |
vasinov/paper_trail | lib/paper_trail/attribute_serializers/cast_attribute_serializer.rb | <reponame>vasinov/paper_trail<gh_stars>0
module PaperTrail
# :nodoc:
module AttributeSerializers
# The `CastAttributeSerializer` (de)serializes model attribute values. For
# example, the string "1.99" serializes into the integer `1` when assigned
# to an attribute of type `ActiveRecord::Type::Integer`.
... |
vasinov/paper_trail | test/paper_trail_test.rb | <gh_stars>0
require "test_helper"
class PaperTrailTest < ActiveSupport::TestCase
test "Sanity test" do
assert_kind_of Module, PaperTrail::Version
end
test "Version Number" do
assert PaperTrail.const_defined?(:VERSION)
end
context "setting enabled" do
should "affect all threads" do
Thread.... |
nsingh/apm-agent-ruby | lib/elastic_apm/transport/connection.rb | <filename>lib/elastic_apm/transport/connection.rb<gh_stars>0
# Licensed to Elasticsearch B.V. under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch B.V. licenses this file to you under
# the Apache L... |
nsingh/apm-agent-ruby | spec/elastic_apm/sql_summarizer_spec.rb | # Licensed to Elasticsearch B.V. under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch B.V. licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this f... |
nsingh/apm-agent-ruby | lib/elastic_apm/metadata/service_info.rb | <reponame>nsingh/apm-agent-ruby
# Licensed to Elasticsearch B.V. under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch B.V. licenses this file to you under
# the Apache License, Version 2.0 (the "Lic... |
nsingh/apm-agent-ruby | spec/elastic_apm/spies/mongo_spec.rb | <filename>spec/elastic_apm/spies/mongo_spec.rb
# Licensed to Elasticsearch B.V. under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Elasticsearch B.V. licenses this file to you under
# the Apache License, Versio... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.