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
PecanProject/bety
https://github.com/PecanProject/bety
app/validators/mediatype_validator.rb
Ruby
bsd-3-clause
19
develop
927
class MediatypeValidator < ActiveModel::EachValidator def validate_each(record, attribute, value) if !is_recognized_mediatype?(value) record.errors.add attribute, "-- the type portion of \"#{value}\" doesn't correspond to any recognized media type." end end def is_recognized_mediatype?(str) str...
github
PecanProject/bety
https://github.com/PecanProject/bety
app/validators/host_validator.rb
Ruby
bsd-3-clause
19
develop
317
class HostValidator < ActiveModel::EachValidator include ValidationConstants def validate_each(record, attribute, value) if !is_host_address?(value) record.errors.add attribute, 'is not a valid host name' end end def is_host_address?(str) str =~ Regexp.new('\A' + HOST + '\z') end end
github
PecanProject/bety
https://github.com/PecanProject/bety
app/validators/validation_constants.rb
Ruby
bsd-3-clause
19
develop
503
module ValidationConstants XALPHAS = %q{([-\w$@.&+!*"'(),]|%[0-9a-f]{2})+} #" IALPHA = '[a-z]' + XALPHAS HOSTNAME = IALPHA + '(\.' + IALPHA + ')*' HOSTNUMBER = '\d+\.\d+\.\d+\.\d+' HOST = '(' + HOSTNAME + '|' + HOSTNUMBER + ')' SCHEME = '(https?|ftp)' OPTIONAL_PORT = '(:\d+)?' PATH = '(/' + XALPHAS + '...
github
PecanProject/bety
https://github.com/PecanProject/bety
app/validators/url_validator.rb
Ruby
bsd-3-clause
19
develop
470
require 'validation_constants' class UrlValidator < ActiveModel::EachValidator include ValidationConstants def validate_each(record, attribute, value) if !is_url_or_parenthesized_or_empty?(value) record.errors.add attribute, 'is not a valid URL. Use a schema-qualified URL. To use arbitrary strings, en...
github
PecanProject/bety
https://github.com/PecanProject/bety
app/mailers/contact_mailer.rb
Ruby
bsd-3-clause
19
develop
2,197
class ContactMailer < ActionMailer::Base helper :mailer def contact_email(email_params) @email_body = email_params[:body] @sender_name = email_params[:name] mail(:to => CONFIG[:admin_email], :subject => email_params[:subject], :from => email_params[:name] + " <" + email_params[:addres...
github
PecanProject/bety
https://github.com/PecanProject/bety
config/environment.rb
Ruby
bsd-3-clause
19
develop
610
# Load the Rails application. require_relative 'application' # Initialize the Rails application. Rails.application.initialize! # config/initializers/bigint_primary_keys.rb ActiveRecord::Base.establish_connection if defined? ActiveRecord::ConnectionAdapters::PostgreSQLAdapter ActiveRecord::ConnectionAdapters::Postgr...
github
PecanProject/bety
https://github.com/PecanProject/bety
config/unicorn.rb
Ruby
bsd-3-clause
19
develop
4,099
# Sample verbose configuration file for Unicorn (not Rack) # # This configuration file documents many features of Unicorn # that may not be needed for some applications. See # http://unicorn.bogomips.org/examples/unicorn.conf.minimal.rb # for a much simpler configuration file. # # See http://unicorn.bogomips.org/Unicor...
github
PecanProject/bety
https://github.com/PecanProject/bety
config/application.rb
Ruby
bsd-3-clause
19
develop
3,843
require_relative 'boot' require 'rails/all' # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) module BetyRails5 class Application < Rails::Application # Enable Hash#deep_symbolize_keys method defined in lib/symboliz...
github
PecanProject/bety
https://github.com/PecanProject/bety
config/routes.rb
Ruby
bsd-3-clause
19
develop
8,932
Rails.application.routes.draw do # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html apipie # The priority is based upon order of creation: first created -> highest priority. # See how all your routes lay out with "rake routes". # You can have the root of your ...
github
PecanProject/bety
https://github.com/PecanProject/bety
config/environments/test.rb
Ruby
bsd-3-clause
19
develop
1,846
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
PecanProject/bety
https://github.com/PecanProject/bety
config/environments/production.rb
Ruby
bsd-3-clause
19
develop
3,850
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
PecanProject/bety
https://github.com/PecanProject/bety
config/environments/development.rb
Ruby
bsd-3-clause
19
develop
2,274
Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the web serv...
github
PecanProject/bety
https://github.com/PecanProject/bety
config/initializers/will_paginate.rb
Ruby
bsd-3-clause
19
develop
477
# Set default per page WillPaginate.per_page = 25 #https://gist.github.com/3142686 # RAILS3 Moved class from app/helpers/remote_link_renderer to this initializer so it gets loaded properly # Changed to extend WillPaginate::ActionView::LinkRenderer instead of WillPaginate::LinkRenderer module WillPaginate::ActionView...
github
PecanProject/bety
https://github.com/PecanProject/bety
config/initializers/apipie.rb
Ruby
bsd-3-clause
19
develop
393
Apipie.configure do |config| config.app_name = "BETYdb" config.default_version = "v1" config.api_base_url = "" config.doc_base_url = "/api/docs" # where is your API defined? config.api_controllers_matcher = "#{Rails.root}/app/controllers/api/v1/*.rb" config.tr...
github
PecanProject/bety
https://github.com/PecanProject/bety
config/initializers/session_store.rb
Ruby
bsd-3-clause
19
develop
459
# Be sure to restart your server when you modify this file. # Rails.application.config.session_store :cookie_store, key: '_bety_rails3_session' # Use the database for sessions instead of the cookie-based default, # which shouldn't be used to store highly confidential information # (create the session table with "rail...
github
PecanProject/bety
https://github.com/PecanProject/bety
config/initializers/rabl_config.rb
Ruby
bsd-3-clause
19
develop
1,298
require 'rabl' Rabl.configure do |config| # Commented as these are defaults # config.cache_all_output = false # config.cache_sources = Rails.env != 'development' # Defaults to false # config.cache_engine = Rabl::CacheEngine.new # Defaults to Rails cache # config.perform_caching = false # config.escape_all_o...
github
PecanProject/bety
https://github.com/PecanProject/bety
config/initializers/assets.rb
Ruby
bsd-3-clause
19
develop
794
# Be sure to restart your server when you modify this file. # Version of your assets, change this if you want to expire all your assets. Rails.application.config.assets.version = '1.0' # Add additional assets to the asset load path # Rails.application.config.assets.paths << Emoji.images_path # Precompile additional ...
github
PecanProject/bety
https://github.com/PecanProject/bety
config/initializers/bety.rb
Ruby
bsd-3-clause
19
develop
377
# If set, this variable will login the system automatically as this user. # This is primarily intended for use with the VM's #BETY_USER=1 # workaround for rspec to silence regex issues: # https://github.com/jnicklas/capybara/issues/87 module Rack module Utils def escape(s) CGI.escape(s.to_s) end ...
github
PecanProject/bety
https://github.com/PecanProject/bety
config/initializers/extend_column_type_support.rb
Ruby
bsd-3-clause
19
develop
719
# Redefine ActiveRecord::ConnectionAdapters::Column#simplified_type. # # Reference: Paolo Perrotta, Metaprogramming Ruby 2, Chapter 11, "The # Fall of alias_method_chain". # module ActiveRecord module ConnectionAdapters module DomainSupport # Deprecation Warning: The ActiveRecord::ConnectionAdapters::Column...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20160930213737_add_experiments_table.rb
Ruby
bsd-3-clause
19
develop
2,851
class AddExperimentsTable < ActiveRecord::Migration def up create_table :experiments do |t| t.string :name, null: false t.date :start_date t.date :end_date t.text :description, null: false, default: '' t.text :design, null: false, default: '' t.integer :user_id, :limit => 8, :n...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20140915153555_restore_default_values.rb
Ruby
bsd-3-clause
19
develop
807
class RestoreDefaultValues < ActiveRecord::Migration # This migration restores some default column values that were lost during the # migration form MySQL to PostgreSQL. Although these defaults ARE set in the # file 001_create_database_objects.rb, it is currently impossible to run the # complete migration sequ...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20150213162341_add_value_constraints_batch_1.rb
Ruby
bsd-3-clause
19
develop
56,588
class AddValueConstraintsBatch1 < ActiveRecord::Migration def self.up # Use "%q" so that backspashes are taken literally (except when doubled). execute %q{ /* Need to drop and later re-create views that depend on columns whose type we are changing. */ DROP VIEW IF EXISTS traits_and_yields_view; DROP VIEW IF...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20130830184559_add_access_level_to_views.rb
Ruby
bsd-3-clause
19
develop
8,923
class AddAccessLevelToViews < ActiveRecord::Migration def self.up begin execute "DROP VIEW IF EXISTS traits_and_yields_view" execute "DROP VIEW IF EXISTS yieldsview" execute "DROP VIEW IF EXISTS traitsview" execute %{ CREATE VIEW traitsview AS SELECT ...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20130813212131_modify_traits_and_yields_view.rb
Ruby
bsd-3-clause
19
develop
8,697
class ModifyTraitsAndYieldsView < ActiveRecord::Migration def self.up begin execute "DROP VIEW IF EXISTS traits_and_yields_view" execute "DROP VIEW IF EXISTS yieldsview" execute "DROP VIEW IF EXISTS traitsview" execute %{ CREATE VIEW traitsview AS SELECT ...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20140621060009_add_model_type_to_pfts.rb
Ruby
bsd-3-clause
19
develop
627
class AddModelTypeToPfts < ActiveRecord::Migration class Pfts < ActiveRecord::Base; end def self.up add_column :pfts, :model_type, :string Pfts.update_all("model_type = 'SIPNET', name=substring(name, 8)", "name like 'sipnet.%'") Pfts.update_all("model_type = 'BIOCRO', name=substring(name, 8)", "name ...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20130829162053_limit_traits_and_yields_view_to_checked_data.rb
Ruby
bsd-3-clause
19
develop
8,948
class LimitTraitsAndYieldsViewToCheckedData < ActiveRecord::Migration def self.up begin execute "DROP VIEW IF EXISTS traits_and_yields_view" execute "DROP VIEW IF EXISTS yieldsview" execute "DROP VIEW IF EXISTS traitsview" execute %{ CREATE VIEW traitsview AS S...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20150904184512_modify_formats_runs_yields.rb
Ruby
bsd-3-clause
19
develop
2,777
class ModifyFormatsRunsYields < ActiveRecord::Migration def self.up add_column :formats, :mimetype_id, :integer, :limit => 8 execute('UPDATE formats SET mimetype_id = (SELECT id FROM mimetypes WHERE type_string = mime_type);') remove_column :formats, :mime_type add_column :yields, :entity_id, :intege...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20150202220519_add_uniqueness_constraints.rb
Ruby
bsd-3-clause
19
develop
8,946
class AddUniquenessConstraints < ActiveRecord::Migration def self.up remove_column :posteriors, :format_id # Use "%q" so that backspashes are taken literally (except when doubled). execute %q{ -- Some convenience functions CREATE OR REPLACE FUNCTION normalize_whitespace( string text ) RETURNS text AS...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20161129192658_database_change_requests.rb
Ruby
bsd-3-clause
19
develop
896
class DatabaseChangeRequests < ActiveRecord::Migration def up change_column :likelihoods, :loglikelihood, :float change_column :likelihoods, :n_eff, :float change_column :likelihoods, :weight, :float change_column :likelihoods, :residual, :float execute %q{ ALTER TABLE likelihoods ...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20150521211114_revise_variable_value_checks.rb
Ruby
bsd-3-clause
19
develop
4,835
class ReviseVariableValueChecks < ActiveRecord::Migration def up execute %{ /* Trigger function to ensure that updates to the min or max values in the variables table do not cause any existing trait or covariate values to be out of range. */ CREATE OR REPLACE FUNCTION prevent_conflicting_range_changes() RE...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20200329233137_fix_functions_pgrestore.rb
Ruby
bsd-3-clause
19
develop
3,608
class FixFunctionsPgrestore < ActiveRecord::Migration[5.1] def change reversible do |dir| dir.up do execute %{ CREATE OR REPLACE FUNCTION is_whitespace_normalized( string text ) RETURNS boolean AS $$ BEGIN RETURN string = public.normalize_whitespace(string); END; $$ LANGUAGE plpgsql; CREATE OR ...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20160711231257_create_benchmarks_tables.rb
Ruby
bsd-3-clause
19
develop
8,068
class CreateBenchmarksTables < ActiveRecord::Migration def self.up this_hostid = Machine.new.hostid # Create the table as normal, then change id to bigint, so all # pieces are created, like index and auto increment. Also all # id's will be set to auto-increment based on the host. create_table :b...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20161005181021_add_score_benchmarks_ensembles_scores.rb
Ruby
bsd-3-clause
19
develop
234
class AddScoreBenchmarksEnsemblesScores < ActiveRecord::Migration def up add_column :benchmarks_ensembles_scores, :score, :text, :null => false end def down remove_column :benchmarks_ensembles_scores, :score end end
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20130222222929_rename_file_to_container_id.rb
Ruby
bsd-3-clause
19
develop
207
class RenameFileToContainerId < ActiveRecord::Migration def self.up rename_column :dbfiles, :file_id, :container_id end def self.down rename_column :dbfiles, :container_id, :file_id end end
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20141009160121_add_geometry_constraint.rb
Ruby
bsd-3-clause
19
develop
319
class AddGeometryConstraint < ActiveRecord::Migration def self.up execute %{ ALTER TABLE public.sites ADD CONSTRAINT enforce_valid_geom CHECK (st_isvalid(geometry)) } end def self.down execute %{ ALTER TABLE public.sites DROP CONSTRAINT enforce_valid_geom } end end
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20160617133217_add_id_to_table.rb
Ruby
bsd-3-clause
19
develop
571
class AddIdToTable < ActiveRecord::Migration def up this_hostid = Machine.new.hostid execute %{ ALTER TABLE "cultivars_pfts" ADD "id" bigserial; SELECT setval('cultivars_pfts_id_seq', 1 + CAST(1e9 * #{this_hostid}::int AS bigint), FALSE); ALTER TABLE "trait_covariate_associations" ADD "id" ...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20140610210928_change_int_to_decimal_in_site.rb
Ruby
bsd-3-clause
19
develop
214
class ChangeIntToDecimalInSite < ActiveRecord::Migration def self.up change_column :sites, :mat, :decimal, :precision => 4, :scale => 2 end def self.down change_column :sites, :mat, :integer end end
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20150624220952_add_sync_id.rb
Ruby
bsd-3-clause
19
develop
1,729
class AddSyncId < ActiveRecord::Migration class Machines < ActiveRecord::Base; end def self.up add_column :machines, :sync_host_id, :integer, :limit => 8 add_column :machines, :sync_url, :string add_column :machines, :sync_contact, :string add_column :machines, :sync_start, :integer, :limit => 8 ...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20140904221818_use_center_point_for_lat_lon.rb
Ruby
bsd-3-clause
19
develop
12,807
class UseCenterPointForLatLon < ActiveRecord::Migration def self.up execute "DROP VIEW IF EXISTS traits_and_yields_view" execute "DROP VIEW IF EXISTS traits_and_yields_view_private" execute "DROP VIEW IF EXISTS yieldsview_private" execute "DROP VIEW IF EXISTS traitsview_private" execute...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20170712171513_sites_cultivars_uniqueness.rb
Ruby
bsd-3-clause
19
develop
439
class SitesCultivarsUniqueness < ActiveRecord::Migration def up this_hostid = Machine.new.hostid execute %{ SELECT setval('sites_cultivars_id_seq', GREATEST(1, 1 + CAST(1e9 * #{this_hostid}::int AS bigint)), FALSE); ALTER TABLE sites_cultivars ADD CONSTRAINT unique_site_id UNIQUE (site_id); ...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20140623004229_add_posteriors_ensembles.rb
Ruby
bsd-3-clause
19
develop
250
class AddPosteriorsEnsembles < ActiveRecord::Migration def self.up create_table :posteriors_ensembles do |t| t.integer :posterior_id t.integer :ensemble_id t.timestamps end end def self.down drop_table :posteriors_ensembles end end
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20140604192901_add_fields_to_variables.rb
Ruby
bsd-3-clause
19
develop
453
class AddFieldsToVariables < ActiveRecord::Migration def self.up add_column :variables, :standard_name, :string add_column :variables, :standard_units, :string add_column :variables, :label, :string add_column :variables, :type, :string end def self.down remove_column :variables, :type r...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20150202215147_add_id_many_to_many.rb
Ruby
bsd-3-clause
19
develop
898
class AddIdManyToMany < ActiveRecord::Migration def self.up execute %{ ALTER TABLE "citations_sites" ADD "id" bigserial; ALTER TABLE "citations_treatments" ADD "id" bigserial; ALTER TABLE "inputs_runs" ADD "id" bigserial; ALTER TABLE "inputs_variables" ADD "id" bigserial; ALTER TABLE...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20140729045640_add_model_type_table.rb
Ruby
bsd-3-clause
19
develop
2,128
class AddModelTypeTable < ActiveRecord::Migration def self.up create_table :modeltypes do |t| t.string :name, :unique => true, :null => false t.integer :user_id t.datetime :created_at t.datetime :updated_at end add_index :modeltypes, [:name], :unique => true execute("insert in...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20140624185610_fix_posteriors_ensembles.rb
Ruby
bsd-3-clause
19
develop
520
class FixPosteriorsEnsembles < ActiveRecord::Migration def self.up remove_column :posteriors_ensembles, :id change_column :posteriors_ensembles, :posterior_id, :integer, :limit => 8 change_column :posteriors_ensembles, :ensemble_id, :integer, :limit => 8 end def self.down add_column :posteriors_ens...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20140506210037_add_and_refactor_views.rb
Ruby
bsd-3-clause
19
develop
11,060
class AddAndRefactorViews < ActiveRecord::Migration def self.up begin execute "DROP VIEW IF EXISTS traits_and_yields_view" execute "DROP VIEW IF EXISTS yieldsview" execute "DROP VIEW IF EXISTS traitsview" rescue ActiveRecord::StatementInvalid => e down # Revert this migration...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20140617163304_add_db_files_to_model.rb
Ruby
bsd-3-clause
19
develop
290
class AddDbFilesToModel < ActiveRecord::Migration def self.up remove_column :models, :model_path execute "DELETE FROM models WHERE id NOT IN (SELECT MIN(id) FROM models GROUP BY model_name, revision)" end def self.down add_column :models, :model_path, :string end end
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20170118205944_set_experiment_table_id_seq_vals.rb
Ruby
bsd-3-clause
19
develop
1,267
class SetExperimentTableIdSeqVals < ActiveRecord::Migration def up this_hostid = Machine.new.hostid range_minimum = 10 ** 9 * this_hostid + 1 range_maximum = 10 ** 9 * (this_hostid + 1) - 1 execute %{ SELECT setval('experiments_id_seq', GREATEST(#{range_minimum}, (SELECT max(id) + 1 FROM exper...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20140909212759_add_trait_covariates_table.rb
Ruby
bsd-3-clause
19
develop
539
class AddTraitCovariatesTable < ActiveRecord::Migration def self.up create_table :trait_covariate_associations, :id => false do |t| t.integer :trait_variable_id, :limit => 8, :null => false t.integer :covariate_variable_id, :limit => 8, :null => false t.boolean :required end add_index :t...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20160523165531_replace_local_time_with_time_zone.rb
Ruby
bsd-3-clause
19
develop
259
class ReplaceLocalTimeWithTimeZone < ActiveRecord::Migration def up add_column :sites, :time_zone, :text remove_column :sites, :local_time end def down add_column :sites, :local_time, :integer remove_column :sites, :time_zone end end
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20141211220550_add_foreign_key_constraints.rb
Ruby
bsd-3-clause
19
develop
16,643
class AddForeignKeyConstraints < ActiveRecord::Migration def self.up execute %{ -- Commented-out constraints are ones being put off for future migrations pending database cleanup. ALTER TABLE "citations" ADD CONSTRAINT "fk_citations_users_1" FOREIGN KEY ("user_id") REFERENCES "users" ("id"); ALTER TABLE "citations...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20161003180105_extend_views.rb
Ruby
bsd-3-clause
19
develop
11,528
class ExtendViews < ActiveRecord::Migration def up execute "DROP VIEW IF EXISTS traits_and_yields_view" execute "DROP VIEW IF EXISTS traits_and_yields_view_private" execute "DROP VIEW IF EXISTS yieldsview_private" execute "DROP VIEW IF EXISTS traitsview_private" execute %q{ CREATE VIEW traitsvie...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20150313165132_dbfiles_reference_constraints.rb
Ruby
bsd-3-clause
19
develop
5,347
class DbfilesReferenceConstraints < ActiveRecord::Migration def self.up execute %q{ /* dbfiles */ CREATE OR REPLACE FUNCTION get_input_ids( ) RETURNS int[] AS $$ DECLARE id_array int[]; BEGIN SELECT ARRAY_AGG(id) FROM inputs INTO id_array; RETURN id_array; END; $$ LA...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20180510184222_update_foreign_key_constraints.rb
Ruby
bsd-3-clause
19
develop
19,504
class UpdateForeignKeyConstraints < ActiveRecord::Migration def self.up execute %q{ /* These constraints are being updated to use the "ON UPDATE CASCADE" clause so that rows having misallocated id numbers can be updated to use ids in the correct range without violating foreign key constraints. A few constraints ar...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20130717162614_update_posteriors.rb
Ruby
bsd-3-clause
19
develop
366
class UpdatePosteriors < ActiveRecord::Migration def self.up add_column :posteriors, :format_id, :integer remove_column :posteriors, :filename remove_column :posteriors, :parent_id end def self.down remove_column :posteriors, :format_id add_column :posteriors, :filename, :string add_colum...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20160412030352_add_sitegroups.rb
Ruby
bsd-3-clause
19
develop
2,400
class AddSitegroups < ActiveRecord::Migration def up this_hostid = Machine.new.hostid # The table we want to add: create_table :sitegroups do |t| t.string :name, null: false t.boolean :public_access, null: false, :default => false t.integer :user_id, :limit => 8, null: false t.ti...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20130707190720_add_yields_and_traits_views.rb
Ruby
bsd-3-clause
19
develop
4,711
class AddYieldsAndTraitsViews < ActiveRecord::Migration def self.up begin execute "DROP VIEW IF EXISTS traits_and_yields_view" execute "DROP VIEW IF EXISTS yieldsview" execute "DROP VIEW IF EXISTS traitsview" execute %{ CREATE VIEW traitsview AS SELECT ...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20151007174432_add_checked_to_traits_and_yields_view.rb
Ruby
bsd-3-clause
19
develop
3,467
class AddCheckedToTraitsAndYieldsView < ActiveRecord::Migration def self.up begin execute "DROP VIEW IF EXISTS traits_and_yields_view" rescue ActiveRecord::StatementInvalid => e down # Revert this migration and ... raise # ... cancel any later ones. end begin execute %{ ...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20150624222656_time_constraints.rb
Ruby
bsd-3-clause
19
develop
20,397
class TimeConstraints < ActiveRecord::Migration def self.up execute %q{ /* On insertion, if created_at or updated_at isn't set explicitly, default to the current UTC time: */ ALTER TABLE citations ALTER COLUMN created_at SET DEFAULT utc_now(); ALTER TABLE citations_sites ALTER COLUMN created_at SET DEFAULT utc_...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20160303221049_change_numerics_to_floats.rb
Ruby
bsd-3-clause
19
develop
11,665
class ChangeNumericsToFloats < ActiveRecord::Migration def self.up begin execute "DROP VIEW IF EXISTS traits_and_yields_view" execute "DROP VIEW IF EXISTS traits_and_yields_view_private" execute "DROP VIEW IF EXISTS yieldsview_private" execute "DROP VIEW IF EXISTS traitsview_private" r...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20130109205535_rename_user_field_field.rb
Ruby
bsd-3-clause
19
develop
237
# RAILS3 Fields named "field" are not allowed in Rails 3 class RenameUserFieldField < ActiveRecord::Migration def self.up rename_column :users, :field, :area end def self.down rename_column :users, :area, :field end end
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20140515205254_add_triggers_to_check_variable_ranges.rb
Ruby
bsd-3-clause
19
develop
6,812
class AddTriggersToCheckVariableRanges < ActiveRecord::Migration def self.up execute %{ /* Trigger function to ensure values of mean in the traits table are within the range specified by min and max in the variables table. A NULL in the min or max column means "no limit". */ CREATE OR REPLACE FUNCTION rest...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20170415183619_add_sites_cultivars.rb
Ruby
bsd-3-clause
19
develop
4,032
class AddSitesCultivars < ActiveRecord::Migration def up execute %q{ CREATE TABLE sites_cultivars ( id serial8 NOT NULL, site_id bigint NOT NULL CONSTRAINT site_exists REFERENCES sites ON UPDATE CASCADE, cultivar_id bigint NOT NULL CONSTRAINT cultivar_exists REFERENCES cultivars ON UPDATE CASCADE, ...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20181129000515_create_attributes_table.rb
Ruby
bsd-3-clause
19
develop
857
class CreateAttributesTable < ActiveRecord::Migration[5.1] def change this_hostid = Machine.new.hostid create_table :attributes, id: :bigint do |t| t.string :container_type, null: false t.integer :container_id, limit: 8, null: false t.jsonb :value, null: false, default: '{}' t.timesta...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20140708232320_add_geometry_to_site.rb
Ruby
bsd-3-clause
19
develop
14,231
# 4326 is WGS84 which is common standard format, for more information # see http://spatialreference.org/ref/epsg/4326/ as well as # http://en.wikipedia.org/wiki/World_Geodetic_System class AddGeometryToSite < ActiveRecord::Migration def self.up begin execute "DROP VIEW IF EXISTS traits_and_yields_view" ...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20140904220035_change_user_id_to_big_int.rb
Ruby
bsd-3-clause
19
develop
368
class ChangeUserIdToBigInt < ActiveRecord::Migration def self.up change_column :modeltypes, :user_id, :integer, :limit => 8 change_column :modeltypes_formats, :user_id, :integer, :limit => 8 end def self.down change_column :modeltypes, :user_id, :integer, :limit => 4 change_column :modeltypes_for...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20130104211946_update_workflows.rb
Ruby
bsd-3-clause
19
develop
867
class UpdateWorkflows < ActiveRecord::Migration def self.up add_column :workflows, :site_id, :integer add_column :workflows, :model_id, :integer, :null => false add_column :workflows, :hostname, :string add_column :workflows, :params, :string add_column :workflows, :advanced_edit, :boolean, :defau...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20141208165401_add_cultivars_pfts.rb
Ruby
bsd-3-clause
19
develop
4,758
# Adds cultivars_pfts table, adds constraints and comments on it and on # pfts_species, and adds uniqueness constraints to pfts table. class AddCultivarsPfts < ActiveRecord::Migration def self.up # The table we want to add: create_table :cultivars_pfts, id: false do |t| t.integer :pft_id, :limit => 8, ...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20140423220457_change_id_to_big_int.rb
Ruby
bsd-3-clause
19
develop
21,451
class ChangeIdToBigInt < ActiveRecord::Migration def self.up begin execute "DROP VIEW IF EXISTS traits_and_yields_view" execute "DROP VIEW IF EXISTS yieldsview" execute "DROP VIEW IF EXISTS traitsview" rescue ActiveRecord::StatementInvalid => e down # Revert this migration an...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20130624001504_change_data_type_for_variable_id.rb
Ruby
bsd-3-clause
19
develop
262
class ChangeDataTypeForVariableId < ActiveRecord::Migration def self.up change_table :priors do |t| t.change :variable_id, :integer end end def self.down change_table :priors do |t| t.change :variable_id, :string end end end
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20151011190026_add_notes_user_to_workflow.rb
Ruby
bsd-3-clause
19
develop
396
class AddNotesUserToWorkflow < ActiveRecord::Migration def up add_column :workflows, :notes, :text add_column :workflows, :user_id, :integer, :limit => 8 execute %{ ALTER TABLE "workflows" ADD CONSTRAINT "fk_workflows_users_1" FOREIGN KEY ("user_id") REFERENCES "users" ("id"); } end def down remove...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20160720182233_add_trait_and_yield_date_and_time_functions.rb
Ruby
bsd-3-clause
19
develop
6,911
class AddTraitAndYieldDateAndTimeFunctions < ActiveRecord::Migration def up # Use "%q" so that backspashes are taken literally (except when doubled). execute %q{ CREATE OR REPLACE FUNCTION effective_time_zone( site_id bigint ) RETURNS text AS $body$ DECLARE SITE_OR_UTC_TIMEZONE text; BEGIN SELEC...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/001_create_database_objects.rb
Ruby
bsd-3-clause
19
develop
26,575
class CreateDatabaseObjects < ActiveRecord::Migration def self.up create_table "citations", :force => true do |t| t.string "author" t.integer "year" t.string "title" t.string "journal" t.integer "vol" t.string "pg" t.string "url", :limit => 512 t.string ...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20140521180349_posteriors_tables_cleanup.rb
Ruby
bsd-3-clause
19
develop
1,317
class PosteriorsTablesCleanup < ActiveRecord::Migration def self.up drop_table :posteriors_runs add_column :pfts, :pft_type, :string, default: "plant" Pft.update_all pft_type: "plant" create_table :posterior_samples do |t| t.integer :posterior_id, :limit => 8 t.integer :variable_id, :limi...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20151014182146_remove_dataformat_from_formats.rb
Ruby
bsd-3-clause
19
develop
206
class RemoveDataformatFromFormats < ActiveRecord::Migration def up remove_column :formats, :dataformat end def down add_column :formats, :dataformat, :text, default: "", null: false end end
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20150625184958_fix_id_getters.rb
Ruby
bsd-3-clause
19
develop
2,763
class FixIdGetters < ActiveRecord::Migration def up execute %q{ /* CASCADE drops the associated CHECK constraints: */ DROP FUNCTION get_input_ids() CASCADE; DROP FUNCTION get_model_ids() CASCADE; DROP FUNCTION get_posterior_ids() CASCADE; /* dbfiles */ CREATE FUNCTION get_input_ids( ) RETURNS bigint[] AS $$ D...
github
PecanProject/bety
https://github.com/PecanProject/bety
db/migrate/20130104211901_add_model_type_to_models.rb
Ruby
bsd-3-clause
19
develop
453
class AddModelTypeToModels < ActiveRecord::Migration class Models < ActiveRecord::Base; end def self.up add_column :models, :model_type, :string Models.update_all("model_type = 'ED2'", "model_name like 'ed%'") Models.update_all("model_type = 'SIPNET'", "model_name like 'sipnet%'") Models.update_a...
github
PecanProject/bety
https://github.com/PecanProject/bety
local/woody_data_import.rb
Ruby
bsd-3-clause
19
develop
2,617
RAILS_ENV='production' require '../config/environment' f = File.new "woody_data_import.traits" Woody = Struct.new(:tmpid,:site_id,:specie_id,:citation_id,:cultivar_id, :treatment_id,:date,:dateloc,:time,:timeloc,:mean,:n, :statname,:stat,:notes,:created_at,:updated_at,:variable_i...
github
PecanProject/bety
https://github.com/PecanProject/bety
local/search_controller.rb
Ruby
bsd-3-clause
19
develop
4,076
# From http://snippets.dzone.com/posts/show/4146 class NestedHash < Hash def initialize blk = lambda {|h,k| h[k] = NestedHash.new(&blk)} super(&blk) end end class Hash def Hash.new_nested_hash Hash.new{|h,k| h[k]=Hash.new(&h.default_proc) } end def nested_hash(array) node = self a...
github
PecanProject/bety
https://github.com/PecanProject/bety
local/make_tile_cache.rb
Ruby
bsd-3-clause
19
develop
16,252
# FIXME: RAILS_ENV should be specified by the deploy scripts # FIXME: We can test the RAILS_ENV and specify options to make this script more portable RAILS_ENV='production' require '../config/environment' # Mercator used for lattitude / longitude projections onto XY coordinate plane require "#{Rails.root}/lib/mercator...
github
PecanProject/bety
https://github.com/PecanProject/bety
local/make_tile_cache-CSV.rb
Ruby
bsd-3-clause
19
develop
16,123
# FIXME: RAILS_ENV should be specified by the deploy scripts # FIXME: We can test the RAILS_ENV and specify options to make this script more portable RAILS_ENV='production' require '../config/environment' # Mercator used for lattitude / longitude projections onto XY coordinate plane require "#{Rails.root}/lib/mercator...
github
PecanProject/bety
https://github.com/PecanProject/bety
local/import_location_yield_data.rb
Ruby
bsd-3-clause
19
develop
4,542
#!/usr/bin/ruby RAILS_ENV='production' require '/rails/ebi/config/environment' file = ARGV[0] file = "/home/dlebauer/dev/multimodel/maps/mapdata.csv" if file.blank? f = File.open file data = Struct.new(:id,:other,:state_fips,:county_fips,:miscanthus,:switchgrass,:poplar,:miscanthus_poplar,:miscanthus_switchgrass,:...
github
PecanProject/bety
https://github.com/PecanProject/bety
local/add_paths_to_counties.rb
Ruby
bsd-3-clause
19
develop
997
RAILS_ENV='production' require '/rails/ebi/config/environment' require 'rvg/rvg' include Magick county = ARGV[0].to_i 0.upto(11) do |zoom| if zoom == 0 conditions = "county_boundaries.zoom0skip = 0" elsif zoom == 1 conditions = "county_boundaries.zoom1skip = 0" else conditions = "1 = 1" end p...
github
PecanProject/bety
https://github.com/PecanProject/bety
local/rawk1.2.rb
Ruby
bsd-3-clause
19
develop
9,723
#!/usr/bin/env ruby ##Rail's Analyzer With Klass #run the following to view help: #ruby rawk.rb -? require 'date' class Stat def initialize(key) @key=key @min = nil @max = nil @sum = 0 @sum_squares = 0 @count = 0 @values = [] end def add(value) @new_log_format = !value.is_a?(Float)...
github
PecanProject/bety
https://github.com/PecanProject/bety
local/remove_county_center_points.rb
Ruby
bsd-3-clause
19
develop
261
RAILS_ENV='production' require '/rails/ebi/config/environment' counties = County.all(:include => "county_boundaries") counties.each do |county| p county county.county_boundaries(:order => "id asc").first.delete if county.county_boundaries.length > 1 end
github
PecanProject/bety
https://github.com/PecanProject/bety
local/queries.rb
Ruby
bsd-3-clause
19
develop
465
require 'mysql' begin con = Mysql.new 'localhost','root','password' ##make a new mysql connection using root as your user password as password rs= con.query 'INSERT INTO yields(id,site_id,citation_id,cultivar_id,treatment_id) Values( %{id} , %{site_id} , %{citation_id} , %{cultivar_id}, %{treatment_id})' # an ...
github
PecanProject/bety
https://github.com/PecanProject/bety
local/add_zoom.rb
Ruby
bsd-3-clause
19
develop
1,094
RAILS_ENV='production' require '/rails/ebi/config/environment' #zoom = ARGV[0].to_i #county = ARGV[0].to_i 0.upto(11) do |zoom| cb_last = CountyBoundary.last(:conditions => "zoom#{zoom}x is null").id cb_first = CountyBoundary.first(:conditions => "zoom#{zoom}x is null").id #cb_last = County.find(county).county...
github
PecanProject/bety
https://github.com/PecanProject/bety
local/update_county_countyboundary.rb
Ruby
bsd-3-clause
19
develop
313
RAILS_ENV='production' require '/rails/ebi/config/environment' c = County.last.id - County.first.id cc = 0 counties = County.all counties.each do |county| p "#{c-cc}" c += 1 CountyBoundary.find_all_by_censusid(county.censusid).each do |cb| p " #{cb.id}" cb.county = county cb.save end end
github
PecanProject/bety
https://github.com/PecanProject/bety
local/sgyield_import-20120227.rb
Ruby
bsd-3-clause
19
develop
777
#Should be run from rails console... require 'csv' county = Struct.new :objectid,:join_count,:target_fid,:name,:state_name,:state_fips,:county_fips,:fips,:loc,:lat,:lon,:sgyield counties = [] CSV.open('/rails/ebi/local/pavi02212012.csv','r') do |row| counties << county.new(*row) end counties.delete_at(0) # Remo...
github
PecanProject/bety
https://github.com/PecanProject/bety
local/pisek_upload/upload_traits.rb
Ruby
bsd-3-clause
19
develop
5,351
# Inserts rows into the traits table corresponding to data in the given CSV. # # The input file name, database host, database credentials (username # and password), and database name are gotten interactively with # suitable defaults. # # The script checks that the header row of the input file has the # expected column ...
github
PecanProject/bety
https://github.com/PecanProject/bety
local/uploadsugarcane/uploadsites.rb
Ruby
bsd-3-clause
19
develop
3,566
require './utilities.rb' # MAIN PROGRAM begin # First get open the csv file and check the header: csv = CSV.open(get_input_file("sugarcanesites.csv")) # Check that the header row is what we expect EXPECTED_HEADER = %w(id usgsmuid city state country lat lon gdd firstkillingfrost mat m...
github
PecanProject/bety
https://github.com/PecanProject/bety
local/uploadsugarcane/uploadyields.rb
Ruby
bsd-3-clause
19
develop
4,951
require './utilities.rb' # MAIN PROGRAM begin # First get open the csv file and check the header: csv = CSV.open(get_input_file("sugarcaneyields.csv")) # Check that the header row is what we expect EXPECTED_HEADER = %w(id citation_id site_id specie_id treatment_id cultivar_id date d...
github
PecanProject/bety
https://github.com/PecanProject/bety
local/uploadsugarcane/uploadcultivars.rb
Ruby
bsd-3-clause
19
develop
2,850
require './utilities.rb' # MAIN PROGRAM begin # First get open the csv file and check the header: csv = CSV.open(get_input_file('sugarcanecultivars.csv')) # Check that the header row is what we expect EXPECTED_HEADER = %w(id specie_id name ecotype notes created_at updated_at previous...
github
PecanProject/bety
https://github.com/PecanProject/bety
local/uploadsugarcane/utilities.rb
Ruby
bsd-3-clause
19
develop
2,381
require 'csv' require 'mysql' # This is the ruby-mysql gem, which allows prepared statements. # Converts a date string of the form 14/2/09 or 14/2/2009 to a form # that can be used in a MySQL insert statement def convert_date(str) begin date_re = %r{^(\d\d?)/(\d\d?)/(\d\d(\d\d)?)$} match_data = date_re.match(st...
github
openstack/puppet-barbican
https://github.com/openstack/puppet-barbican
lib/puppet/provider/barbican_api_paste_ini/ini_setting.rb
Ruby
apache-2.0
19
master
868
# # Copyright (C) 2016 Red Hat Inc. <licensing@redhat.com> # # Author: Ade Lee <alee@redhat.com> # # 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/LICENS...
github
openstack/puppet-barbican
https://github.com/openstack/puppet-barbican
lib/puppet/provider/barbican_config/openstackconfig.rb
Ruby
apache-2.0
19
master
849
# # Copyright (C) 2016 Red Hat Inc. <licensing@redhat.com> # # Author: Ade Lee <alee@redhat.com> # # 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/LICENS...
github
openstack/puppet-barbican
https://github.com/openstack/puppet-barbican
lib/puppet/provider/barbican_api_uwsgi_config/ini_setting.rb
Ruby
apache-2.0
19
master
223
Puppet::Type.type(:barbican_api_uwsgi_config).provide( :ini_setting, :parent => Puppet::Type.type(:openstack_config).provider(:ini_setting) ) do def self.file_path '/etc/barbican/barbican-api-uwsgi.ini' end end
github
openstack/puppet-barbican
https://github.com/openstack/puppet-barbican
lib/puppet/type/barbican_api_paste_ini.rb
Ruby
apache-2.0
19
master
1,929
# # Copyright (C) 2016 Red Hat Inc. <licensing@redhat.com> # # Author: Ade Lee <alee@redhat.com> # # 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/LICENS...
github
openstack/puppet-barbican
https://github.com/openstack/puppet-barbican
lib/puppet/type/barbican_api_uwsgi_config.rb
Ruby
apache-2.0
19
master
709
Puppet::Type.newtype(:barbican_api_uwsgi_config) do ensurable newparam(:name, :namevar => true) do desc 'Section/setting name to manage from /etc/barbican/barbican-api-uwsgi.ini' newvalues(/\S+\/\S+/) end newproperty(:value) do desc 'The value of the setting to be defined.' munge do |value| ...
github
openstack/puppet-barbican
https://github.com/openstack/puppet-barbican
lib/puppet/type/barbican_config.rb
Ruby
apache-2.0
19
master
2,184
# # Copyright (C) 2016 Red Hat Inc. <licensing@redhat.com> # # Author: Ade Lee <alee@redhat.com> # # 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/LICENS...