repo_name stringlengths 6 97 | path stringlengths 3 341 | text stringlengths 8 1.02M |
|---|---|---|
nuthintrue/AuthEngine | app/api/auth_engine/base.rb | <filename>app/api/auth_engine/base.rb
module AuthEngine
class Base < Grape::API
mount V1::Base
end
end |
nuthintrue/AuthEngine | lib/auth_engine.rb | require "auth_engine/engine"
module AuthEngine
# Your code goes here...
end
|
nuthintrue/AuthEngine | app/api/auth_engine/v1/helpers/authentication.rb | module AuthEngine
module V1
module Helpers
module Authentication
extend Grape::API::Helpers
attr_accessor :current_person
def authenticate_token!
error!('Invalid API token', 401) unless token
@current_person = person_from_token
error!('Invalid API toke... |
nuthintrue/AuthEngine | app/coordinators/auth_engine/api/api_coordinator.rb | <gh_stars>0
module AuthEngine
module Api
class ApiCoordinator < BaseCoordinator
attr_reader :params, :headers, :current_person, :context
def initialize(params: {}, headers: {}, current_person: nil, context: {})
@params = params
@headers = headers
@current_person = current_per... |
nuthintrue/AuthEngine | app/api/auth_engine/v1/user/root.rb | module AuthEngine
module V1
module User
class Root < Grape::API
namespace :user do
mount ::V1::User::Token
mount ::V1::User::Me
end
end
end
end
end |
secyritas/dashing-statuscake | jobs/statuscakestatus.rb | require 'statuscake'
require 'time_diff'
config = YAML::load_file('config/statuscake.yml')
def calculate_difference date1, date2
t = Time.diff(date1, date2)
"#{t[:day]}d #{t[:hour]}h #{t[:minute]}m"
end
client = StatusCake::Client.new(API: config['api_key'], Username: config['api_user'])
# :first_in sets how lo... |
vzvu3k6k/redmine2ch | lib/redmine2ch/redmine_client.rb | require 'datpot/bbs'
require 'redmine2ch/resources'
require 'time'
require 'faraday'
require 'faraday_middleware'
module Redmine2ch
class RedmineClient
attr_reader :api_key, :root_url
def initialize(api_key:, root_url:)
@api_key = api_key
@root_url = root_url
end
def issue(id:)
r... |
vzvu3k6k/redmine2ch | spec/datpot/bbs_spec.rb | <reponame>vzvu3k6k/redmine2ch
# frozen_string_literal: true
require 'datpot/bbs'
require 'datpot/thread'
require 'datpot/response'
require 'rack/test'
RSpec.describe Datpot::Bbs do
include Rack::Test::Methods
class App < Datpot::Bbs
def threads(board_id:)
[
Datpot::Thread.new(
thread_... |
vzvu3k6k/redmine2ch | lib/datpot/response.rb | <gh_stars>0
# frozen_string_literal: true
require 'datpot/refinements/string'
module Datpot
Response = Struct.new(:author, :email, :posted_at, :id, :content, keyword_init: true) do
using Datpot::Refinements::String
def self.format_time(time)
day = 'ๆฅๆ็ซๆฐดๆจ้ๅ'[time.wday]
time.strftime("%Y/%m/%d(#{... |
vzvu3k6k/redmine2ch | lib/redmine2ch/resources.rb | # frozen_string_literal: true
require 'redmine2ch/resources/issue'
require 'redmine2ch/resources/journal'
|
vzvu3k6k/redmine2ch | lib/datpot/board.rb | # frozen_string_literal: true
require 'datpot/thread'
module Datpot
Board = Struct.new(:threads, keyword_init: true) do
def subject_txt
threads.map(&:subject_txt).join
end
end
end
|
vzvu3k6k/redmine2ch | config.ru | # frozen_string_literal: true
$LOAD_PATH << './lib'
require 'redmine2ch/app'
run Redmine2ch::App
|
vzvu3k6k/redmine2ch | spec/datpot/board_spec.rb | <gh_stars>0
# frozen_string_literal: true
require 'ostruct'
require 'datpot/board'
RSpec.describe Datpot::Board do
describe '#subject_txt' do
subject { board.subject_txt }
let(:board) {
Datpot::Board.new(
threads: [
OpenStruct.new(subject_txt: "123.dat<>title (1)\n"),
Open... |
vzvu3k6k/redmine2ch | lib/redmine2ch/resources/journal.rb | <reponame>vzvu3k6k/redmine2ch
# frozen_string_literal: true
require 'datpot/bbs'
require 'redmine2ch/resources/base'
module Redmine2ch
module Resources
class Journal < Base
def author
dig(:user, :name)
end
def created_on
Time.parse(dig(:created_on))
end
def conten... |
vzvu3k6k/redmine2ch | lib/datpot/refinements/string.rb | <reponame>vzvu3k6k/redmine2ch
# frozen_string_literal: true
module Datpot
module Refinements
module String
refine ::String do
def escape_dat
gsub(/<|>/, '<' => '<', '>' => '>')
.gsub("\n", '<br>')
end
end
end
end
end
|
vzvu3k6k/redmine2ch | lib/datpot/bbs.rb | <filename>lib/datpot/bbs.rb
# frozen_string_literal: true
require 'sinatra/base'
require 'datpot/board'
module Datpot
class Bbs < Sinatra::Application
def threads(board_id:)
raise NotImplementedError
end
def responses(board_id:, thread_id:)
raise NotImplementedError
end
get '/:boar... |
vzvu3k6k/redmine2ch | spec/redmine2ch/resources/journal_spec.rb | <reponame>vzvu3k6k/redmine2ch
# frozen_string_literal: true
require 'redmine2ch/resources/journal'
RSpec.describe Redmine2ch::Resources::Journal do
describe '#content' do
subject { journal.content }
context 'With notes' do
let(:journal) { described_class.new(notes: 'Journal notes', details: []) }
... |
vzvu3k6k/redmine2ch | lib/redmine2ch/resources/issue.rb | # frozen_string_literal: true
require 'datpot/bbs'
require 'redmine2ch/resources/base'
module Redmine2ch
module Resources
class Issue < Base
def id
dig(:id)
end
def subject
dig(:subject)
end
def author
dig(:author, :name)
end
def created_on
... |
vzvu3k6k/redmine2ch | lib/redmine2ch.rb | <gh_stars>0
# frozen_string_literal: true
require 'redmine2ch/app'
module Redmine2ch; end
|
vzvu3k6k/redmine2ch | spec/datpot/response_spec.rb | <filename>spec/datpot/response_spec.rb
# frozen_string_literal: true
require 'datpot/response'
RSpec.describe Datpot::Response do
describe '#dat' do
subject { response.dat }
context 'Without id' do
let(:response) {
Datpot::Response.new(
author: 'ๅ็กใใใ',
email: 'sage',
... |
vzvu3k6k/redmine2ch | spec/datpot/thread_spec.rb | <gh_stars>0
# frozen_string_literal: true
require 'datpot/board'
RSpec.describe Datpot::Thread do
describe '#subject_txt' do
subject { thread.subject_txt }
context 'With response_count' do
let(:thread) {
Datpot::Thread.new(
thread_id: 123,
title: 'title',
respons... |
vzvu3k6k/redmine2ch | lib/datpot/thread.rb | <reponame>vzvu3k6k/redmine2ch<gh_stars>0
# frozen_string_literal: true
require 'datpot/response'
module Datpot
Thread = Struct.new(:thread_id, :title, :response_count, :responses, keyword_init: true) do
def subject_txt
"#{thread_id}.dat<>#{title} (#{response_count || responses.size})\n"
end
def d... |
vzvu3k6k/redmine2ch | lib/redmine2ch/app.rb | # frozen_string_literal: true
require 'datpot/bbs'
require 'datpot/thread'
require 'datpot/response'
require 'redmine2ch/redmine_client'
module Redmine2ch
class App < Datpot::Bbs
def threads(board_id:)
redmine_client.issues(project_id: board_id).map { |issue|
detailed_issue = redmine_client.issue(... |
vzvu3k6k/redmine2ch | lib/redmine2ch/resources/base.rb | <gh_stars>0
# frozen_string_literal: true
require 'datpot/bbs'
module Redmine2ch
module Resources
class Base
def initialize(raw)
@raw = raw
end
def dig(*args)
@raw.dig(*args)
end
end
end
end
|
ResultadosDigitais/feature_flagger | lib/feature_flagger/storage/feature_keys_migration.rb | # frozen_string_literal: true
module FeatureFlagger
module Storage
class FeatureKeysMigration
def initialize(from_redis, to_control)
@from_redis = from_redis
@to_control = to_control
end
# call migrates features key from the old fashioned to the new
# for... |
ResultadosDigitais/feature_flagger | lib/feature_flagger/notifier.rb | module FeatureFlagger
class Notifier
attr_reader :notify
RELEASE = 'release'.freeze
UNRELEASE = 'unrelease'.freeze
RELEASE_TO_ALL = 'release_to_all'.freeze
UNRELEASE_TO_ALL = 'unrelease_to_all'.freeze
def initialize(notify = nil)
@notify = valid_notify?(notify) ? notify : nullNotify
... |
ResultadosDigitais/feature_flagger | spec/feature_flagger/control_spec.rb | <reponame>ResultadosDigitais/feature_flagger
require 'spec_helper'
module FeatureFlagger
RSpec.describe Control do
let(:redis) { FakeRedis::Redis.new }
let(:notify) { spy(lambda { |event| }, :is_a? => Proc) }
let(:notifier) { Notifier.new(notify)}
let(:storage) { Storage::Redis.new(redis) }
let(... |
ResultadosDigitais/feature_flagger | lib/feature_flagger/manager.rb | <gh_stars>10-100
module FeatureFlagger
class Manager
def self.detached_feature_keys
persisted_features = FeatureFlagger.control.feature_keys
mapped_feature_keys = FeatureFlagger.config.mapped_feature_keys
persisted_features - mapped_feature_keys
end
def self.cleanup_detached(resource_... |
ResultadosDigitais/feature_flagger | lib/tasks/feature_flagger.rake | namespace :feature_flagger do
desc "cleaning up keys from storage that are no longer in the rollout.yml file"
task :cleanup_removed_rollouts => :environment do
keys = FeatureFlagger::Manager.detached_feature_keys
puts "Found keys to remove: #{keys}"
keys.each do |key|
FeatureFlagger::Manager.clean... |
ResultadosDigitais/feature_flagger | lib/feature_flagger/core_ext.rb | <gh_stars>10-100
begin
require 'active_support/core_ext/string/inflections'
rescue LoadError
unless ''.respond_to?(:constantize)
class String
def constantize
names = split('::')
names.shift if names.empty? || names.first.empty?
constant = Object
names.each do |name|
... |
ResultadosDigitais/feature_flagger | spec/feature_flagger/manager_spec.rb | require 'spec_helper'
module FeatureFlagger
RSpec.describe Manager do
describe 'detached_feature_keys' do
let(:redis) { FakeRedis::Redis.new }
let(:storage) { Storage::Redis.new(redis) }
before do
FeatureFlagger.configure do |config|
config.storage = storage
end
... |
ResultadosDigitais/feature_flagger | lib/feature_flagger/model.rb | module FeatureFlagger
# Model provides convinient methods for Rails Models
# class Account
# include FeatureFlagger::Model
# end
#
# Example:
# Account.first.rollout?([:email_marketing, :new_awesome_feature])
# #=> true
module Model
def self.included(base)
base.extend ClassMethods
end
... |
ResultadosDigitais/feature_flagger | spec/feature_flagger/configuration_spec.rb | require 'spec_helper'
module FeatureFlagger
RSpec.describe Configuration do
describe '.storage' do
let(:configuration) { described_class.new }
context 'no storage set' do
it 'returns a Redis storage by default' do
expect(configuration.storage).to be_a(FeatureFlagger::Storage::Redis... |
ResultadosDigitais/feature_flagger | lib/feature_flagger/control.rb | module FeatureFlagger
class Control
attr_reader :storage
RELEASED_FEATURES = 'released_features'
def initialize(storage, notifier, cache_store = nil)
@storage = storage
@notifier = notifier
@cache_store = cache_store
end
def released?(feature_key, resource_id, options = {})
... |
ResultadosDigitais/feature_flagger | spec/feature_flagger/notifier_spec.rb | <filename>spec/feature_flagger/notifier_spec.rb
require 'spec_helper'
module FeatureFlagger
RSpec.describe Notifier do
let(:feature_key) { 'account:email_marketing:whitelabel' }
let(:legacy_feature_key) { 'account' }
let(:resource_id) { 'resource_id' }
let(:resource_name) { 'account' }
... |
ResultadosDigitais/feature_flagger | lib/feature_flagger.rb | require 'yaml'
require 'feature_flagger/version'
require 'feature_flagger/storage/redis'
require 'feature_flagger/storage/feature_keys_migration'
require 'feature_flagger/control'
require 'feature_flagger/model'
require 'feature_flagger/model_settings'
require 'feature_flagger/feature'
require 'feature_flagger/configu... |
ResultadosDigitais/feature_flagger | lib/feature_flagger/feature.rb | <filename>lib/feature_flagger/feature.rb
module FeatureFlagger
class Feature
def initialize(feature_key, resource_name = nil)
@feature_key = resolve_key(feature_key, resource_name)
@doc = FeatureFlagger.config.info
fetch_data
end
def description
@data['description']
end
d... |
ResultadosDigitais/feature_flagger | spec/feature_flagger_spec.rb | <reponame>ResultadosDigitais/feature_flagger
require 'spec_helper'
RSpec.describe FeatureFlagger do
describe '.configure' do
let(:storage) { double('storage') }
let(:other_storage) { double('other_storage') }
let(:notifier_callback) { lambda {|event| } }
before do
FeatureFlagger.configure do ... |
ResultadosDigitais/feature_flagger | spec/spec_helper.rb | <filename>spec/spec_helper.rb<gh_stars>10-100
# frozen_string_literal: true
require 'fakeredis/rspec'
if ENV['COVERAGE'] == "true"
require 'simplecov'
SimpleCov.start do
load_profile "test_frameworks"
add_filter "/vendor/"
end
end
$LOAD_PATH.unshift File.expand_path('../lib', __dir__)
require 'feature... |
ResultadosDigitais/feature_flagger | lib/feature_flagger/model_settings.rb | module FeatureFlagger
class ModelSettings
def initialize(arguments)
arguments.each do |field, value|
self.public_send("#{field}=", value)
end
end
# Public: identifier_field Refers to which field must represent the unique model
# id.
attr_accessor :identifier_field
# Publi... |
ResultadosDigitais/feature_flagger | spec/feature_flagger/storage/feature_keys_migration_spec.rb | # frozen_string_literal: true
require 'spec_helper'
require 'feature_flagger/storage/feature_keys_migration'
RSpec.describe FeatureFlagger::Storage::FeatureKeysMigration do
subject(:migrator) { described_class.new(redis, control) }
let(:redis) { FakeRedis::Redis.new }
let(:notifier) { FeatureFlagger::Notifier.... |
ResultadosDigitais/feature_flagger | spec/feature_flagger/storage/redis_keys_spec.rb | require 'spec_helper'
RSpec.describe FeatureFlagger::Storage::Keys do
describe '.resource_key' do
it 'generates the resource_key' do
prefix = "my_prefix"
resource_name = "account"
resource_id = "1"
result = FeatureFlagger::Storage::Keys.resource_key(
prefix,
resource_name... |
ResultadosDigitais/feature_flagger | lib/feature_flagger/storage/keys.rb | <reponame>ResultadosDigitais/feature_flagger
module FeatureFlagger
module Storage
module Keys
MINIMUM_VALID_FEATURE_PATH = 2.freeze
def self.resource_key(prefix, resource_name, resource_id)
"#{prefix}:#{resource_name}:#{resource_id}"
end
def self.extract_resource_name_from_featur... |
ResultadosDigitais/feature_flagger | spec/feature_flagger/feature_spec.rb | <gh_stars>10-100
require 'spec_helper'
module FeatureFlagger
RSpec.describe Feature do
subject { Feature.new(key, :feature_flagger_dummy_class) }
before do
filepath = File.expand_path('../../fixtures/rollout_example.yml', __FILE__)
FeatureFlagger.config.yaml_filepath = filepath
end
desc... |
ResultadosDigitais/feature_flagger | lib/feature_flagger/configuration.rb | <reponame>ResultadosDigitais/feature_flagger<gh_stars>10-100
module FeatureFlagger
class Configuration
attr_accessor :storage, :cache_store, :yaml_filepath, :notifier_callback
def initialize
@storage ||= Storage::Redis.default_client
@yaml_filepath ||= default_yaml_filepath
@notifier_... |
ResultadosDigitais/feature_flagger | spec/feature_flagger/storage/redis_spec.rb | <filename>spec/feature_flagger/storage/redis_spec.rb
require 'spec_helper'
RSpec.describe FeatureFlagger::Storage::Redis do
let(:redis) { FakeRedis::Redis.new }
let(:storage) { described_class.new(redis) }
let(:feature_key) { 'account:email_marketing:whitelabel' }
let(:resource_id) { '1' }
let(:resourc... |
ResultadosDigitais/feature_flagger | lib/feature_flagger/storage/redis.rb | <filename>lib/feature_flagger/storage/redis.rb
require 'redis'
require 'redis-namespace'
require_relative './keys'
module FeatureFlagger
module Storage
class Redis
DEFAULT_NAMESPACE = :feature_flagger
RESOURCE_PREFIX = "_r".freeze
SCAN_EACH_BATCH_SIZE = 1000.freeze
def initialize(redis)
... |
ResultadosDigitais/feature_flagger | feature_flagger.gemspec | <reponame>ResultadosDigitais/feature_flagger
# coding: utf-8
lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'feature_flagger/version'
Gem::Specification.new do |spec|
spec.name = "feature_flagger"
spec.version = FeatureFlagger::VERSION
sp... |
ResultadosDigitais/feature_flagger | spec/feature_flagger/model_spec.rb | require 'spec_helper'
module FeatureFlagger
class DummyClass
include FeatureFlagger::Model
def id; 14 end
end
RSpec.describe Model do
subject { DummyClass.new }
let(:key) { [:email_marketing, :whitelabel] }
let(:resolved_key) { 'feature_flagger_dummy_class:email_marke... |
supportleap/beacon | test/controllers/statuses_controller_test.rb | # frozen_string_literal: true
require "test_helper"
class StatusesControllerTest < ActionDispatch::IntegrationTest
setup do
@green_status = create(:status, level: :green)
@yellow_status = create(:status, level: :yellow)
@red_status = create(:status, level: :red)
end
test "#index lists current statu... |
supportleap/beacon | app/controllers/dashboard_controller.rb | <gh_stars>0
# frozen_string_literal: true
class DashboardController < ApplicationController
INDEX_STATUS_LIMIT = 5
def index
all_statuses = Status.order("id DESC").limit(INDEX_STATUS_LIMIT + 1)
latest_status = all_statuses.first
statuses = all_statuses.drop(1)
render "dashboard/index", locals: {
... |
supportleap/beacon | lib/graph.rb | # frozen_string_literal: true
module Graph
def self.execute(query, context: {}, variables: {})
Schema.execute(query, context: context, variables: variables)
end
end
|
supportleap/beacon | app/controllers/application_controller.rb | # frozen_string_literal: true
class ApplicationController < ActionController::Base
def current_page(page_param = :page)
if params[page_param].blank? || !params[page_param].respond_to?(:to_i)
1
else
params[page_param].to_i.abs
end
end
end
|
supportleap/beacon | lib/graph/mutations/create_status.rb | # frozen_string_literal: true
module Graph
module Mutations
class CreateStatus < Graph::Mutations::Base
description "Create a new status event."
argument :level, Enums::StatusLevel, "The level of this status event.", required: true
argument :message, String, "The message for this status event.... |
supportleap/beacon | app/models/statuses/create_status.rb | # frozen_string_literal: true
module Statuses
class CreateStatus
# inputs - A Hash of attributes to create a status.
# inputs[:level] - A String that is a `level` enum value for a Status.
# inputs[:message] - (optional) A String message to use for the status.
def self.call(inputs)
new(inputs).... |
supportleap/beacon | test/models/statuses/create_status_test.rb | <gh_stars>0
# frozen_string_literal: true
require 'test_helper'
class Statuses::CreateStatusTest < ActiveSupport::TestCase
test "creates a status with default message" do
assert_empty Status.all
result = Statuses::CreateStatus.call(level: "green")
assert_predicate result, :success?
assert_empty re... |
supportleap/beacon | app/controllers/chatops_controller.rb | <filename>app/controllers/chatops_controller.rb<gh_stars>0
# frozen_string_literal: true
class ChatopsController < ApplicationController
skip_before_action :verify_authenticity_token
include ::Chatops::Controller
chatops_namespace :beacon
chatops_help <<-EOS
:rotating_light: Beacon โ Leap's status page.
EOS... |
supportleap/beacon | config/routes.rb | <gh_stars>0
Rails.application.routes.draw do
root "dashboard#index"
resources :statuses, only: [:index]
post "/_chatops/:chatop", controller: "chatops", action: :execute_chatop
get "/_chatops", to: "chatops#list"
post "/api/graphql", to: "graphql#execute"
end
|
supportleap/beacon | app/controllers/statuses_controller.rb | # frozen_string_literal: true
class StatusesController < ApplicationController
PER_PAGE = 35
def index
statuses = Status.paginate(
page: current_page,
per_page: PER_PAGE,
).order('id DESC')
render "statuses/index", locals: { statuses: statuses }
end
end
|
datamapper/dm-is-searchable | lib/dm-is-searchable.rb | <reponame>datamapper/dm-is-searchable
require 'dm-core'
require 'dm-is-searchable/is/searchable'
module DataMapper
module Model
include DataMapper::Is::Searchable
end
end
|
p1atdev/Nafuda | Nafuda.podspec | Pod::Spec.new do |spec|
spec.name = "Nafuda"
spec.version = "1.1.0"
spec.summary = "This search web site's title"
spec.description = "TODO: write here"
spec.homepage = "https://github.com/p1atdev/Nafuda"
spec.license = { :type => 'MIT', :file => 'LICENSE' }
spec.author ... |
cloversites/draftsman | lib/draftsman/model.rb | <gh_stars>0
require 'draftsman/attributes_serialization'
module Draftsman
module Model
def self.included(base)
base.send :extend, ClassMethods
end
module ClassMethods
# Declare this in your model to enable the Draftsman API for it. A draft
# of the model is available in the `draft` as... |
cloversites/draftsman | spec/dummy/db/migrate/20150404203627_add_talkatives_table_to_tests.rb | class AddTalkativesTableToTests < ActiveRecord::Migration
def self.up
create_table :talkatives, :force => true do |t|
t.string :before_comment
t.string :around_early_comment
t.string :around_late_comment
t.string :after_comment
t.references :draft
t.datetime :... |
cloversites/draftsman | lib/generators/draftsman/templates/create_drafts_json.rb | class CreateDrafts < ActiveRecord::Migration
def change
create_table :drafts do |t|
t.string :item_type, :null => false
t.integer :item_id, :null => false
t.string :event, :null => false
t.string :whodunnit# :null => false
t.json :object
t.json :previous_draft
... |
cloversites/draftsman | spec/dummy/db/migrate/20150408234937_add_only_children.rb | class AddOnlyChildren < ActiveRecord::Migration
def up
create_table :only_children, :force => true do |t|
t.string :name
t.references :parent
t.references :draft, :foreign_key => true
t.datetime :trashed_at
t.datetime :published_at
t.timestamps
end
end
def down... |
cloversites/draftsman | spec/dummy/db/migrate/20110208155312_set_up_test_tables.rb | <filename>spec/dummy/db/migrate/20110208155312_set_up_test_tables.rb
class SetUpTestTables < ActiveRecord::Migration
def self.up
create_table :drafts, :force => true do |t|
t.string :item_type
t.integer :item_id
t.string :event, :null => false
t.string :whodunnit
t.text :object... |
cloversites/draftsman | lib/draftsman/draft.rb | class Draftsman::Draft < ActiveRecord::Base
# Associations
belongs_to :item, polymorphic: true
# Validations
validates :event, presence: true
# Scopes
# Returns `where` that filters to only `create` drafts.
scope :creates, -> { where(event: :create) }
# Returns `where` that filters to only `destroy` ... |
cloversites/draftsman | lib/generators/draftsman/install_generator.rb | <filename>lib/generators/draftsman/install_generator.rb
require 'rails/generators'
require 'rails/generators/migration'
require 'rails/generators/active_record'
module Draftsman
class InstallGenerator < ::Rails::Generators::Base
include ::Rails::Generators::Migration
desc 'Creates config initializer and gen... |
cloversites/draftsman | lib/generators/draftsman/templates/add_object_changes_column_to_drafts_json.rb | <filename>lib/generators/draftsman/templates/add_object_changes_column_to_drafts_json.rb
class AddObjectChangesColumnToDrafts < ActiveRecord::Migration
def self.up
add_column :drafts, :object_changes, :json
end
def self.down
remove_column :drafts, :object_changes
end
end
|
jinroq/agyoh | agyoh_logger.rb | # coding: utf-8
class AgyohLogger
# agyoh log ใใกใคใซ
AGYOH_LOG_FILE = "./tmp/agyoh.log".freeze
def initialize
# log ใใกใคใซไฝๆ
File.open(AGYOH_LOG_FILE, "a+").close
end
# ใญใฌใผ
def self.log_info(message = '')
AgyohLogger.new.log_info(message)
end
def self.log_error(message = '')
AgyohLogger.n... |
jinroq/agyoh | initializers/sqlite3_seeds.rb | <filename>initializers/sqlite3_seeds.rb
# coding: utf-8
module Initializers
class Sqlite3Seeds
require "sqlite3"
# agyoh sqlite file
AGYOH_SQLITE3_FILE = "./tmp/agyoh.sqlite3".freeze
def initialize
@db = SQLite3::Database.new(AGYOH_SQLITE3_FILE)
ret = is_existed_table?("device_tokens")
... |
jinroq/agyoh | agyoh.rb | <filename>agyoh.rb
# coding: utf-8
class Agyoh
require 'net/http'
require "socket"
require "json"
require "sqlite3"
# agyoh pid ใใกใคใซ
AGYOH_PID_FILE = "./tmp/agyoh.pid".freeze
# agyoh log ใใกใคใซ
AGYOH_LOG_FILE = "./tmp/agyoh.log".freeze
# 3rd party ๅใใใผใ็ชๅท
PORTNUMBER_FOR_3RD_PARTY = 2018
# Client ๅใ... |
jinroq/agyoh | agyoh_tcp_server.rb | # coding: utf-8
class AgyohTcpServer
require "socket"
require "./utils/logger"
include Utils
# agyoh pid file
AGYOH_PID_FILE = "./tmp/agyoh.pid".freeze
# port for client
PORTNUMBER_FOR_CLIENT = 2019
def initialize
# open pid file
File.open(AGYOH_PID_FILE, "w").close
end
def run
execu... |
jinroq/agyoh | agyoh_web.rb | # coding: utf-8
# endpoint ใ็ฝฎใใใใฎ web server
class AgyohWeb
require 'net/http'
require "socket"
# agyoh pid ใใกใคใซ
AGYOH_PID_FILE = "./tmp/agyoh.pid".freeze
# agyoh log ใใกใคใซ
AGYOH_LOG_FILE = "./tmp/agyoh.log".freeze
# 3rd party ๅใ agyoh ใใผใ็ชๅท
AGYOH_3RD_PARTY_PORT = 2018
# Client ๅใ agyoh ใใผใ็ชๅท
AGYOH_... |
jinroq/agyoh | utils/logger.rb | # coding: utf-8
module Utils
class Logger
LOG_FILE = "./tmp/agyoh.log".freeze
def initialize
File.open(LOG_FILE, "a+").close
end
# public class methods
# level: info
def self.log_info(message = '')
Logger.new.log_info(message)
end
# level: error
def self.log_err... |
wordjelly/mailgun-ruby | lib/mailgun/version.rb | <filename>lib/mailgun/version.rb
# It's the version. Yeay!
module Mailgun
VERSION = '1.1.7'
end
|
wordjelly/mailgun-ruby | lib/mailgun/events/events.rb | require 'mailgun/exceptions/exceptions'
module Mailgun
# A Mailgun::Events object makes it really simple to consume
# Mailgun's events from the Events endpoint.
#
# This is not yet comprehensive.
#
# Examples
#
# See the Github documentation for full examples.
class Events
include Enumerabl... |
ClaytonPassmore/rails_param | spec/rails_integration_spec.rb | <filename>spec/rails_integration_spec.rb
require 'spec_helper'
describe FakeController, type: :controller do
# Needed to run tests against Rails 4 AND 5
def prepare_params(params)
return params if Rails.version[0].to_i <= 4
{ params: params }
end
describe "type coercion" do
it "coerces to integer"... |
ClaytonPassmore/rails_param | lib/rails_param/version.rb | <filename>lib/rails_param/version.rb<gh_stars>0
module RailsParam #:nodoc
VERSION = "1.0.1"
end
|
acoulton/mysql | test/cookbooks/mysql_test/recipes/yum_repo.rb | # Set a version for modern distros.
# centos-7 and fedora ship MariaDB out of the box.
node.default['mysql']['version'] = '5.6' if node['platform_family'] == 'rhel' && node['platform_version'].to_i == 7
node.default['mysql']['version'] = '5.6' if node['platform_family'] == 'fedora'
# Before that, we use "native" vers... |
acoulton/mysql | test/cookbooks/mysql_test/metadata.rb | name 'mysql_test'
version '0.0.1'
depends 'mysql'
depends 'yum-mysql-community'
|
acoulton/mysql | test/integration/config51/run_spec.rb | prefix_dir = os[:family] == 'centos' ? '/opt/rh/mysql51/root' : nil
if %w(debian ubuntu centos suse fedora).include? os[:family]
describe directory("#{prefix_dir}/etc/mysql-default") do
its('mode') { should eq 00755 }
its('owner') { should eq 'root' }
its('group') { should eq 'root' }
end
describe d... |
acoulton/mysql | libraries/mysql_base.rb | module MysqlCookbook
class MysqlBase < Chef::Resource
require_relative 'helpers'
# All resources are composites
def whyrun_supported?
true
end
################
# Type Constants
################
Boolean = property_type(
is: [true, false],
default: false
) unless... |
acoulton/mysql | test/integration/service56-multi/run_spec.rb | def mysql_bin
return '/opt/mysql56/bin/mysql' if os[:family] =~ /solaris/
return '/opt/local/bin/mysql' if os[:family] =~ /smartos/
'/usr/bin/mysql'
end
def mysqld_bin
return '/opt/mysql51/bin/mysqld' if os[:family] =~ /solaris/
return '/opt/local/bin/mysqld' if os[:family] =~ /smartos/
'/usr/sbin/mysqld'
... |
acoulton/mysql | test/cookbooks/mysql_test/recipes/config.rb | <filename>test/cookbooks/mysql_test/recipes/config.rb
# an config
mysql_config 'hello' do
instance 'default'
source 'hello.conf.erb'
version node['mysql']['version']
action :create
end
mysql_config 'hello_again' do
instance 'foo'
source 'hello.conf.erb'
version node['mysql']['version']
action :create
... |
acoulton/mysql | test/cookbooks/mysql_test/recipes/service_single.rb | # comments!
mysql_server_installation_package 'default' do
version node['mysql']['version']
action :install
end
mysql_service_manager 'default' do
version node['mysql']['version']
action [:create, :start]
end
|
acoulton/mysql | test/integration/installation_server_package-57/run_spec.rb | def mysqld_bin
return '/opt/mysql51/bin/mysqld' if os[:family] =~ /solaris/
return '/opt/local/bin/mysqld' if os[:family] =~ /smartos/
'/usr/sbin/mysqld'
end
def mysqld_cmd
"#{mysqld_bin} --version"
end
describe command(mysqld_cmd) do
its(:exit_status) { should eq 0 }
its(:stdout) { should match(/Ver 5.7/... |
icebox827/oop-CR-training | example_school_library_decorator/student.rb | require './person'
require './classroom'
class Student < Person
attr_reader :classroom
def initialize(age, classroom, name = 'Unknown', parent_permission: true)
super(age, name)
@classroom = classroom
@name = name
@age = age
@parent_permission = parent_permission
end
def classroom=(classr... |
icebox827/oop-CR-training | example_school_library_decorator/app.rb | <filename>example_school_library_decorator/app.rb
require './student'
require './teacher'
require './book'
require './rental'
class App
def initialize
@books = []
@people = []
@rentals = []
end
def list_books
@books.each do |book|
puts "Title: \"#{book.title}\", Author: #{book.author}"
... |
icebox827/oop-CR-training | example_school_library_decorator/main.rb | # rubocop:disable Metrics/CyclomaticComplexity
require './app'
# rubocop:disable Metrics/MethodLength
def main
app = App.new
response = nil
puts "Welcome to School Library App!\n\n"
while response != '7'
puts 'Please choose an option by enterin a number:'
puts '1 - List all books'
puts '2 - List... |
vayan/hue-indicator | hue.rb | require "rubygems"
require "ruby-libappindicator"
require "hue"
def add_submenu_activate(name:, parent:)
sub_menu = Gtk::MenuItem.new name
sub_menu.signal_connect "activate" do
yield
end
parent.append sub_menu
end
ai = AppIndicator::AppIndicator.new("Hue Lights", "gtk-home", AppIndicator::Category::APPLIC... |
atton-/bind_sdb_with_rails | db/migrate/20151009111328_create_reverse_records.rb | <filename>db/migrate/20151009111328_create_reverse_records.rb<gh_stars>0
class CreateReverseRecords < ActiveRecord::Migration
def change
create_table :reverse_records do |t|
t.references :record, index: true, foreign_key: true
t.string :name, default: '', null:false
t.string :rdata , defau... |
atton-/bind_sdb_with_rails | config/initializers/constants.rb | <filename>config/initializers/constants.rb
NSServerName = 'name-server'
IPv4Prefix = '10.100.200.'
ReverseIPv4 = '200.100.10.in-addr.arpa'
DomainSuffix = 'hoge.com'
|
atton-/bind_sdb_with_rails | db/schema.rb | <filename>db/schema.rb
# encoding: UTF-8
# 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 i... |
atton-/bind_sdb_with_rails | db/migrate/20151009110357_create_records.rb | <gh_stars>0
class CreateRecords < ActiveRecord::Migration
def change
create_table :records do |t|
t.integer :ip, default:1, null:false
t.string :domain, default:'', null:false
t.timestamps null: false
end
end
end
|
atton-/bind_sdb_with_rails | db/seeds.rb | <filename>db/seeds.rb
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
# Mayor... |
atton-/bind_sdb_with_rails | app/models/record.rb | <gh_stars>0
class Record < ActiveRecord::Base
validates_presence_of :ip, :domain
validates_uniqueness_of :ip, :domain
validates_inclusion_of :ip, in: 1..254
has_one :forward_record, dependent: :destroy
has_one :reverse_record, dependent: :destroy
def ipv4
IPAddr.new(IPv4Prefix + ip.to_s)
end
d... |
atton-/bind_sdb_with_rails | config/routes.rb | Rails.application.routes.draw do
resources :records
root 'records#index'
end
|
atton-/bind_sdb_with_rails | app/views/records/show.json.jbuilder | <filename>app/views/records/show.json.jbuilder
json.extract! @record, :id, :ip, :domain, :created_at, :updated_at
|
atton-/bind_sdb_with_rails | app/views/records/index.json.jbuilder | <gh_stars>0
json.array!(@records) do |record|
json.extract! record, :id, :ip, :domain
json.url record_url(record, format: :json)
end
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.