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 | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20240330115757_create_solid_queue_tables.solid_queue.rb | Ruby | mit | 84 | main | 4,123 | # frozen_string_literal: true
# This migration comes from solid_queue (originally 20231211200639)
class CreateSolidQueueTables < ActiveRecord::Migration[7.0]
# rubocop:disable Metrics/MethodLength
def change
create_table(:solid_queue_jobs) do |t|
t.string(:queue_name, null: false)
t.string(:class_n... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20231125195134_update_project_members.rb | Ruby | mit | 84 | main | 548 | # frozen_string_literal: true
class UpdateProjectMembers < ActiveRecord::Migration[6.1]
def up
Project.find_each do |proj|
proj.admin_group.users.find_each do |user|
check_project_member(proj, user, true)
end
end
end
def down; end
def check_project_member(project, user, trusted)
... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20100326000000_vote_anonymity.rb | Ruby | mit | 84 | main | 428 | # encoding: utf-8
class VoteAnonymity < ActiveRecord::Migration
def self.up
# Make default "no" (always public), except grandfather in existing users
# as "old" (public going forward).
add_column :users, :votes_anonymous, :enum, limit: [:no, :yes, :old], default: :no
User.connection.update "UPDATE use... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20240914174211_add_importables_and_imported_count_to_inat_import.rb | Ruby | mit | 84 | main | 212 | class AddImportablesAndImportedCountToInatImport < ActiveRecord::Migration[7.1]
def change
add_column :inat_imports, :importables, :integer
add_column :inat_imports, :imported_count, :integer
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20100402000000_image_ok_for_export.rb | Ruby | mit | 84 | main | 233 | # encoding: utf-8
class ImageOkForExport < ActiveRecord::Migration
def self.up
add_column :images, :ok_for_export, :boolean, default: true, null: false
end
def self.down
remove_column :images, :ok_for_export
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20100910195247_expand_location_names.rb | Ruby | mit | 84 | main | 1,501 | # encoding: utf-8
class ExpandLocationNames < ActiveRecord::Migration
def self.up
add_column :observations, :where_tmp, :string, limit: 1024
Name.connection.update("update observations set where_tmp=`where`")
remove_column :observations, :where
add_column :observations, :where, :string, limit: 1024
... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20240131201441_add_observation_index_to_votes.rb | Ruby | mit | 84 | main | 232 | class AddObservationIndexToVotes < ActiveRecord::Migration[7.1]
def up
add_index :votes, :observation_id, name: :observation_index
end
def down
remove_index :votes, :observation_id, name: :observation_index
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20260101095531_drop_queued_email_tables.rb | Ruby | mit | 84 | main | 643 | # frozen_string_literal: true
# Drop legacy QueuedEmail tables. All email functionality has been migrated
# to ActionMailer + ActiveJob (deliver_later with SolidQueue).
class DropQueuedEmailTables < ActiveRecord::Migration[7.2]
def up
# Drop child tables first due to foreign key relationships
drop_table(:que... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20120425174100_convert_observations_alt_to_integer.rb | Ruby | mit | 84 | main | 273 | class ConvertObservationsAltToInteger < ActiveRecord::Migration
def self.up
# Not used yet in production, so no harm in just deleting and reinserting.
remove_column :observations, :alt
add_column :observations, :alt, :integer
end
def self.down
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20241226192904_create_project_aliases.rb | Ruby | mit | 84 | main | 430 | # frozen_string_literal: true
class CreateProjectAliases < ActiveRecord::Migration[7.1]
def change
create_table(:project_aliases) do |t|
t.integer(:project_id, null: false)
t.integer(:target_id, null: false)
t.string(:target_type, null: false)
t.string(:name)
t.timestamps
t.... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20171210164400_fix_locales.rb | Ruby | mit | 84 | main | 963 | class FixLocales < ActiveRecord::Migration
def up
User.connection.execute(%(
UPDATE users
SET locale = LEFT(locale, 2)
WHERE locale LIKE "%-%"
))
User.connection.execute(%(
UPDATE name_descriptions
SET locale = LEFT(locale, 2)
WHERE locale LIKE "%-%"
))
User.con... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20240906052016_make_name_not_null.solid_queue.rb | Ruby | mit | 84 | main | 616 | # This migration comes from solid_queue (originally 20240813160053)
class MakeNameNotNull < ActiveRecord::Migration[7.1]
def up
SolidQueue::Process.where(name: nil).find_each do |process|
process.name ||= [ process.kind.downcase, SecureRandom.hex(10) ].join("-")
process.save!
end
change_colum... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20130921220548_cleanup_copyright_holder.rb | Ruby | mit | 84 | main | 783 | class CleanupCopyrightHolder < ActiveRecord::Migration
def self.up
for current, preferred in Image.connection.select_rows %(
SELECT DISTINCT i.copyright_holder, u.name
FROM images i, users u
WHERE i.user_id = u.id
AND i.copyright_holder COLLATE utf8_bin != u.name
AND u.name != ""
... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20230903144229_add_accepting_observations_to_projects.rb | Ruby | mit | 84 | main | 230 | # frozen_string_literal: true
class AddAcceptingObservationsToProjects < ActiveRecord::Migration[6.1]
def change
add_column(:projects, :accepting_observations, :boolean,
default: true, null: false)
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20100104000000_synchronization.rb | Ruby | mit | 84 | main | 8,587 | # encoding: utf-8
class Synchronization < ActiveRecord::Migration
#=================================================
# Migrate up.
#=================================================
def self.up
# ------------------------------------------
# Add sync_id and modified to everything.
# --------------... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/201201302113_save_original_image_filenames.rb | Ruby | mit | 84 | main | 223 | class SaveOriginalImageFilenames < ActiveRecord::Migration
def self.up
add_column(:images, :original_name, :string, limit: 120, default: "")
end
def self.down
remove_column(:images, :original_name)
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20171208203600_make_sure_public_descriptions_are_public.rb | Ruby | mit | 84 | main | 383 | class MakeSurePublicDescriptionsArePublic < ActiveRecord::Migration
def up
Name.connection.execute(%(
UPDATE name_descriptions SET public = TRUE
WHERE source_type = 1 AND public IS FALSE
))
Location.connection.execute(%(
UPDATE location_descriptions SET public = TRUE
WHERE source_t... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20120606110100_make_thumbnail_map_optional.rb | Ruby | mit | 84 | main | 242 | # encoding: utf-8
class MakeThumbnailMapOptional < ActiveRecord::Migration
def self.up
add_column :users, :thumbnail_maps, :boolean, null: false, default: true
end
def self.down
remove_column :users, :thumbnail_maps
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20120626122800_add_scientific_name_to_locations.rb | Ruby | mit | 84 | main | 860 | # encoding: utf-8
class AddScientificNameToLocations < ActiveRecord::Migration
def self.up
add_column(:locations, :scientific_name, :string, limit: 1024)
add_column(:locations_versions, :scientific_name, :string, limit: 1024)
fill_in_scientific_names("locations")
fill_in_scientific_names("locations_v... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20120713171100_add_index_to_image_votes.rb | Ruby | mit | 84 | main | 706 | # encoding: utf-8
class AddIndexToImageVotes < ActiveRecord::Migration
def self.up
# This improves the following query by orders of magnitude:
# Query.lookup(:Observation, :by_user, :user => 252, :by => owners_thumbnail_quality):
# SELECT DISTINCT observations.id
# FROM `observations`
#... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20260305000000_reverse_field_slip_observation_relationship.rb | Ruby | mit | 84 | main | 1,073 | # frozen_string_literal: true
# Reverse the FieldSlip-Observation relationship from
# field_slips.observation_id to observations.field_slip_id.
# This enables one FieldSlip to have many Observations (needed for
# the Occurrences feature).
class ReverseFieldSlipObservationRelationship < ActiveRecord::Migration[7.2]
d... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20171207130700_add_lifeform_to_names.rb | Ruby | mit | 84 | main | 1,602 | class AddLifeformToNames < ActiveRecord::Migration
def up
add_column :names, :lifeform, :string, limit: 1024, null: false, default: " "
add_column :names_versions, :lifeform, :string, limit: 1024, null: false, default: " "
Name.connection.execute("UPDATE names SET lifeform = ' '")
Name.connection.exec... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20171209004800_add_content_filter_caches.rb | Ruby | mit | 84 | main | 768 | class AddContentFilterCaches < ActiveRecord::Migration
def up
add_column :observations, :lifeform, :string, limit: 1024
add_column :observations, :text_name, :string, limit: 100
add_column :observations, :classification, :text
Name.connection.execute(%(
UPDATE observations o, names n
SET ... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20160731145100_refactor_query.rb | Ruby | mit | 84 | main | 759 | class RefactorQuery < ActiveRecord::Migration
def self.up
drop_table :queries
create_table :query_records, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: true do |t|
t.datetime "updated_at"
t.integer "access_count", limit: 4
t.text "description", limit: 65535
t.integer "o... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20231001132458_add_dates_to_products.rb | Ruby | mit | 84 | main | 219 | class AddDatesToProducts < ActiveRecord::Migration[6.1]
def change
add_column :projects, :start_date, :date, null: true, default: nil
add_column :projects, :end_date, :date, null: true, default: nil
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20170423010922_create_articles.rb | Ruby | mit | 84 | main | 242 | class CreateArticles < ActiveRecord::Migration
def change
create_table :articles do |t|
t.string :title
t.text :body
t.integer :user_id
t.integer :rss_log_id
t.timestamps null: false
end
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20100403000000_add_rss_log_to_project.rb | Ruby | mit | 84 | main | 294 | # encoding: utf-8
class AddRssLogToProject < ActiveRecord::Migration
def self.up
add_column :rss_logs, :project_id, :integer
add_column :projects, :rss_log_id, :integer
end
def self.down
remove_column :rss_logs, :project_id
remove_column :projects, :rss_log_id
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20171124004900_split_herbarium_label.rb | Ruby | mit | 84 | main | 1,820 | class SplitHerbariumLabel < ActiveRecord::Migration
def up
add_column :herbarium_records, :initial_det, :string, null: false, limit: 221
add_column :herbarium_records, :accession_number, :string, null: false, limit: 80
Name.connection.execute(%(
UPDATE herbarium_records
SET accession_number = ... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20240504122906_add_one_per_page_to_field_slip_job_tracker.rb | Ruby | mit | 84 | main | 236 | # frozen_string_literal: true
class AddOnePerPageToFieldSlipJobTracker < ActiveRecord::Migration[7.1]
def change
add_column(:field_slip_job_trackers, :one_per_page, :boolean,
null: false, default: false)
end
end |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | db/migrate/20241001233907_add_box_area_to_locations.rb | Ruby | mit | 84 | main | 1,146 | class AddBoxAreaToLocations < ActiveRecord::Migration[7.1]
require "extensions"
def up
add_column :locations, :box_area, :decimal, precision: 21, scale: 10
add_column :location_versions, :box_area, :decimal, precision: 21, scale: 10
add_column :locations, :center_lat, :decimal, precision: 15, scale: 10... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | cable/config.ru | Ruby | mit | 84 | main | 278 | # frozen_string_literal: true
# This file is used to start a Rack-based standalone server for ActionCable
# Start our cable server with `bundle exec puma -p 28080 cable/config.ru`
require_relative("../config/environment")
Rails.application.eager_load!
run ActionCable.server |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | script/purge_original_image_cache.rb | Ruby | mit | 84 | main | 606 | #!/usr/bin/env ruby
# frozen_string_literal: true
# USAGE::
#
# script/purge_original_image_cache.rb
#
# DESCRIPTION::
#
# This just clears out old images from the local original image cache.
#
################################################################################
require_relative("../config/boot")
re... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | script/check_links.rb | Ruby | mit | 84 | main | 909 | #!/usr/bin/env ruby
# frozen_string_literal: true
require_relative("../config/boot")
require_relative("../config/environment")
require_relative("../config/initializers/extensions")
abort(<<HELP) if ARGV.length != 2
USAGE::
script/check_links.rb <table> <column>
DESCRIPTION::
Loads all the nonempty val... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | script/update_query_records.rb | Ruby | mit | 84 | main | 1,821 | #!/usr/bin/env ruby
# frozen_string_literal: true
# This is a one-time script, can be modified and reused in the future if Query
# params change and we need to purge existing QueryRecords of the old params.
#
# call with `script/update_query_records.rb "true"`
require_relative("../config/boot")
require_relative("../c... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | script/parse_classification.rb | Ruby | mit | 84 | main | 670 | #!/usr/bin/env ruby
# frozen_string_literal: true
NAME_REGEXP = /_([^_]*)_/
DOMAIN_REGEXP = /Domain: #{NAME_REGEXP}/
KINGDOM_REGEXP = /Kingdom: #{NAME_REGEXP}/
PHYLUM_REGEXP = /Phylum: #{NAME_REGEXP}/
CLASS_REGEXP = /Class: #{NAME_REGEXP}/
ORDER_REGEXP = /Order: #{NAME_REGEXP}/
FAMILY_REGEXP = /Family: #{NAM... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | script/fix_names.rb | Ruby | mit | 84 | main | 1,796 | #!/usr/bin/env ruby
# frozen_string_literal: true
# Ensure that name.sort_name is consistent with
# Name.parse(name.search_name).sort_name
NAME_METHODS = %w[
text_name
search_name
display_name
sort_name
].freeze
def update(controller)
last_id = controller.start
Name.where(id: controller.start..).
ord... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | script/classification_audit.rb | Ruby | mit | 84 | main | 15,899 | #!/usr/bin/env ruby
# frozen_string_literal: true
# USAGE::
#
# script/classification_audit.rb [-n|--dry-run] [-v|--verbose]
#
# DESCRIPTION::
#
# Audits and backfills `names.classification`:
#
# Phase 1 – Propagate each genus's classification to its subtaxa
# and to deprecated synonyms of ... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | script/update_user_content_filter.rb | Ruby | mit | 84 | main | 1,545 | #!/usr/bin/env ruby
# frozen_string_literal: true
# This is a one-time script, i'm just making it nice for practice
# call with `script/update_user_content_filter.rb "true"`
require_relative("../config/boot")
require_relative("../config/environment")
require_relative("../config/initializers/extensions")
abort(<<HELP... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | script/download_symbiota.rb | Ruby | mit | 84 | main | 600 | #!/usr/bin/env ruby
# frozen_string_literal: true
require_relative("../config/boot")
require_relative("../config/environment")
require_relative("../config/initializers/extensions")
def do_report(year, do_labels = false)
warn("Doing #{year.inspect}...")
query = Query.lookup(:Observation, date: year)
report = Rep... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | script/repair_observation_vote_cache.rb | Ruby | mit | 84 | main | 6,919 | #!/usr/bin/env ruby
# frozen_string_literal: true
# USAGE::
#
# bin/rails runner script/repair_observation_vote_cache.rb \
# [-n|--dry-run] [--no-email] [-v|--verbose]
#
# DESCRIPTION::
#
# Find + fix + alert for #4171: observations whose `vote_cache`
# is stuck near 0 even though their consensus-name ... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | script/check_running_jobs.rb | Ruby | mit | 84 | main | 2,044 | # frozen_string_literal: true
# Called by deploy.sh to check for running background jobs.
# Exit codes:
# 0 - no jobs running
# 2 - jobs are running (details printed to stdout)
# 1 - error (rails runner default for unhandled exceptions)
#
# Usage: bundle exec rails runner script/check_running_jobs.rb
claimed = ... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | script/validate_themes.rb | Ruby | mit | 84 | main | 5,813 | #!/usr/bin/env ruby
# frozen_string_literal: true
# Theme Validation Script
# Ensures all themes define all required variables and identifies
# orphaned variables
#
# Usage:
# script/validate_themes.rb # Validate all themes
# script/validate_themes.rb --strict # Exit with error if issues found
#
# Exit ... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | script/mushroom_mapper.rb | Ruby | mit | 84 | main | 6,589 | #!/usr/bin/env ruby
# frozen_string_literal: true
#
# USAGE::
#
# script/mushroom_mapper.rb
#
# DESCRIPTION::
#
# Creates JSON data file for Fungal Diversity Survey's
# Mushroom Mapper app.
#
# It writes output to:
#
# RAILS_ROOT/public/mushroom_mapper.json
# RAILS_ROOT/public/taxonomy.csv
#
# Structure... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | script/reset_user_original_image_quotas.rb | Ruby | mit | 84 | main | 411 | #!/usr/bin/env ruby
# frozen_string_literal: true
# USAGE::
#
# script/reset_user_original_image_quotas.rb
#
# DESCRIPTION::
#
# This just resets all of the user original image quotas to zero.
#
################################################################################
require_relative("../config/boot")
r... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | script/analyze_consensus_change.rb | Ruby | mit | 84 | main | 9,990 | # frozen_string_literal: true
# USAGE::
#
# rails runner script/analyze_consensus_change.rb [options]
#
# DESCRIPTION::
#
# Analyzes or applies the consensus algorithm change (Issue #3815).
#
# Without --update, compares old vs new consensus for candidate
# observations (those with multiple namings and sub-max... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | script/backfill_gps_dubious.rb | Ruby | mit | 84 | main | 1,603 | #!/usr/bin/env ruby
# frozen_string_literal: true
# Backfill Observation#gps_dubious for every obs with a recorded GPS
# and a location. Run once after the add_gps_dubious_to_observations
# migration ships. Idempotent — safe to re-run (only writes rows
# whose computed value differs from the stored one).
#
# bin/rai... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | script/update_ip_stats.rb | Ruby | mit | 84 | main | 3,403 | #!/usr/bin/env ruby
# frozen_string_literal: true
# Kludge to allow us to include consts.rb without loading entire Rails app.
class Configuration
def method_missing(method, *args)
@data ||= {}
if method.to_s.end_with?("=")
@data[method.to_s.chop.to_sym] = args[0]
else
@data[method]
end
... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | script/fix_quotes.rb | Ruby | mit | 84 | main | 1,827 | #!/usr/bin/env ruby
# frozen_string_literal: true
# Ensure that name.sort_name is consistent with
# Name.parse(name.search_name).sort_name
NAME_METHODS = %w[
text_name
search_name
display_name
sort_name
].freeze
def update(controller)
last_id = controller.start
Name.where("id >= ? and text_name LIKE '%\"... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | script/update_googlebots.rb | Ruby | mit | 84 | main | 1,978 | #!/usr/bin/env ruby
# frozen_string_literal: true
# Kludge to allow us to include consts.rb without loading entire Rails app.
class Configuration
def method_missing(method, *args)
@data ||= {}
if method.to_s.end_with?("=")
@data[method.to_s.chop.to_sym] = args[0]
else
@data[method]
end
... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | script/verify_theme_changes.rb | Ruby | mit | 84 | main | 7,793 | #!/usr/bin/env ruby
# frozen_string_literal: true
# Verification script for theme system changes
# Run this BEFORE and AFTER Phase 1 changes to detect unintended side effects
require "fileutils"
require "json"
THEMES = %w[
agaricus
amanita
cantharellaceae
hygrocybe
admin
sudo
black_on_white
defaults
... |
github | MushroomObserver/mushroom-observer | https://github.com/MushroomObserver/mushroom-observer | script/config.rb | Ruby | mit | 84 | main | 3,101 | #!/usr/bin/env ruby
# frozen_string_literal: true
require("yaml")
class ImageConfigData
def initialize
@env = ENV.fetch("RAILS_ENV", "development")
@config = YAML.load_file("#{root}/config/image_config.yml")[@env]
end
def root
File.expand_path("..", __dir__)
end
def local_image_files
# Use... |
github | ankane/lightgbm-ruby | https://github.com/ankane/lightgbm-ruby | lightgbm.gemspec | Ruby | mit | 84 | master | 559 | require_relative "lib/lightgbm/version"
Gem::Specification.new do |spec|
spec.name = "lightgbm"
spec.version = LightGBM::VERSION
spec.summary = "High performance gradient boosting for Ruby"
spec.homepage = "https://github.com/ankane/lightgbm-ruby"
spec.license = "MIT"
spec.... |
github | ankane/lightgbm-ruby | https://github.com/ankane/lightgbm-ruby | Rakefile | Ruby | mit | 84 | master | 2,246 | require "bundler/gem_tasks"
require "rake/testtask"
require "ruby_memcheck"
test_config = lambda do |t|
t.pattern = "test/**/*_test.rb"
end
Rake::TestTask.new(&test_config)
namespace :test do
RubyMemcheck::TestTask.new(:valgrind, &test_config)
end
task default: :test
shared_libraries = %w(lib_lightgbm.dll lib_l... |
github | ankane/lightgbm-ruby | https://github.com/ankane/lightgbm-ruby | Gemfile | Ruby | mit | 84 | master | 202 | source "https://rubygems.org"
gemspec
gem "rake"
gem "minitest"
gem "matrix"
gem "numo-narray-alt", platform: [:mri, :windows]
gem "rover-df", platform: [:mri, :windows]
gem "csv"
gem "ruby_memcheck" |
github | ankane/lightgbm-ruby | https://github.com/ankane/lightgbm-ruby | test/cv_test.rb | Ruby | mit | 84 | master | 2,458 | require_relative "test_helper"
class CvTest < Minitest::Test
def test_regression
# need to set stratified=False in Python
eval_hist = LightGBM.cv(regression_params, regression_train, shuffle: false)
assert_in_delta 0.2597565400783163, eval_hist["l2-mean"].first
assert_in_delta 0.10267769399880997, ev... |
github | ankane/lightgbm-ruby | https://github.com/ankane/lightgbm-ruby | test/booster_test.rb | Ruby | mit | 84 | master | 6,622 | require_relative "test_helper"
class BoosterTest < Minitest::Test
def test_model_file
x_test = [[3.7, 1.2, 7.2, 9.0], [7.5, 0.5, 7.9, 0.0]]
booster = LightGBM::Booster.new(model_file: "test/support/model.txt")
y_pred = booster.predict(x_test)
assert_elements_in_delta [0.9823112229173586, 0.9583143724... |
github | ankane/lightgbm-ruby | https://github.com/ankane/lightgbm-ruby | test/dataset_test.rb | Ruby | mit | 84 | master | 3,362 | require_relative "test_helper"
class DatasetTest < Minitest::Test
def test_data_string
dataset = LightGBM::Dataset.new(data_path, params: {header: true, label_column: "name:y"})
assert_equal 500, dataset.num_data
assert_equal 4, dataset.num_feature
assert_equal 500, dataset.label.size
assert_equa... |
github | ankane/lightgbm-ruby | https://github.com/ankane/lightgbm-ruby | test/ranker_test.rb | Ruby | mit | 84 | master | 698 | require_relative "test_helper"
class RankerTest < Minitest::Test
def test_works
x_train, y_train, x_test, _ = ranker_data
group = [100, 200]
model = LightGBM::Ranker.new
model.fit(x_train, y_train, group: group)
y_pred = model.predict(x_test)
expected = [4.32677558843951, 1.5663855381974388,... |
github | ankane/lightgbm-ruby | https://github.com/ankane/lightgbm-ruby | test/train_test.rb | Ruby | mit | 84 | master | 4,430 | require_relative "test_helper"
class TrainTest < Minitest::Test
def test_regression
model = LightGBM.train(regression_params, regression_train, valid_sets: [regression_train, regression_test], verbose_eval: false)
y_pred = model.predict(regression_test.data)
assert_in_delta 0.2900400590132747, rsme(regre... |
github | ankane/lightgbm-ruby | https://github.com/ankane/lightgbm-ruby | test/test_helper.rb | Ruby | mit | 84 | master | 2,360 | require "bundler/setup"
Bundler.require(:default)
require "minitest/autorun"
require "json"
class Minitest::Test
def setup
if stress?
# autoload before GC.stress
LightGBM::FFI.ffi_libraries
load_data
GC.stress = true
end
end
def teardown
GC.stress = false if stress?
@temp... |
github | ankane/lightgbm-ruby | https://github.com/ankane/lightgbm-ruby | test/regressor_test.rb | Ruby | mit | 84 | master | 1,628 | require_relative "test_helper"
class RegressorTest < Minitest::Test
def test_works
x_train, y_train, x_test, _ = regression_data
model = LightGBM::Regressor.new
model.fit(x_train, y_train)
y_pred = model.predict(x_test)
expected = [1.3687029666659025, 1.7352643821271516, 1.4988839660914637, 0.87... |
github | ankane/lightgbm-ruby | https://github.com/ankane/lightgbm-ruby | test/classifier_test.rb | Ruby | mit | 84 | master | 3,961 | require_relative "test_helper"
class ClassifierTest < Minitest::Test
def test_binary
x_train, y_train, x_test, _ = binary_data
model = LightGBM::Classifier.new
model.fit(x_train, y_train)
y_pred = model.predict(x_test)
expected = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,... |
github | ankane/lightgbm-ruby | https://github.com/ankane/lightgbm-ruby | lib/lightgbm.rb | Ruby | mit | 84 | master | 6,453 | # dependencies
require "ffi"
# stdlib
require "json"
# modules
require_relative "lightgbm/utils"
require_relative "lightgbm/booster"
require_relative "lightgbm/dataset"
require_relative "lightgbm/inner_predictor"
require_relative "lightgbm/version"
# scikit-learn API
require_relative "lightgbm/model"
require_relativ... |
github | ankane/lightgbm-ruby | https://github.com/ankane/lightgbm-ruby | lib/lightgbm/booster.rb | Ruby | mit | 84 | master | 10,444 | module LightGBM
class Booster
include Utils
attr_accessor :best_iteration, :train_data_name, :params
def initialize(params: nil, train_set: nil, model_file: nil, model_str: nil)
@refs = []
if model_str
model_from_string(model_str)
elsif model_file
out_num_iterations = ... |
github | ankane/lightgbm-ruby | https://github.com/ankane/lightgbm-ruby | lib/lightgbm/model.rb | Ruby | mit | 84 | master | 655 | module LightGBM
class Model
attr_reader :booster
def initialize(num_leaves: 31, learning_rate: 0.1, n_estimators: 100, objective: nil, **options)
@params = {
num_leaves: num_leaves,
learning_rate: learning_rate
}.merge(options)
@params[:objective] = objective if objective
... |
github | ankane/lightgbm-ruby | https://github.com/ankane/lightgbm-ruby | lib/lightgbm/dataset.rb | Ruby | mit | 84 | master | 7,010 | module LightGBM
class Dataset
include Utils
attr_reader :data, :params
def initialize(data, label: nil, weight: nil, group: nil, params: nil, reference: nil, used_indices: nil, categorical_feature: "auto", feature_name: nil, feature_names: nil)
@data = data
@label = label
@weight = wei... |
github | ankane/lightgbm-ruby | https://github.com/ankane/lightgbm-ruby | lib/lightgbm/ranker.rb | Ruby | mit | 84 | master | 689 | module LightGBM
class Ranker < Model
def initialize(num_leaves: 31, learning_rate: 0.1, n_estimators: 100, objective: "lambdarank", **options)
super
end
def fit(x, y, group:, categorical_feature: "auto", early_stopping_rounds: nil, verbose: true)
train_set = Dataset.new(x, label: y, group: gr... |
github | ankane/lightgbm-ruby | https://github.com/ankane/lightgbm-ruby | lib/lightgbm/inner_predictor.rb | Ruby | mit | 84 | master | 4,726 | module LightGBM
class InnerPredictor
include Utils
MAX_INT32 = (1 << 31) - 1
def initialize(booster, pred_parameter)
@handle = booster.instance_variable_get(:@handle)
@pandas_categorical = booster.instance_variable_get(:@pandas_categorical)
@pred_parameter = params_str(pred_parameter)
... |
github | ankane/lightgbm-ruby | https://github.com/ankane/lightgbm-ruby | lib/lightgbm/ffi.rb | Ruby | mit | 84 | master | 3,801 | module LightGBM
module FFI
extend ::FFI::Library
begin
ffi_lib LightGBM.ffi_lib
rescue LoadError => e
if ["/usr/local", "/opt/homebrew"].any? { |v| e.message.include?("Library not loaded: #{v}/opt/libomp/lib/libomp.dylib") } && e.message.include?("Reason: image not found")
raise LoadE... |
github | ankane/lightgbm-ruby | https://github.com/ankane/lightgbm-ruby | lib/lightgbm/classifier.rb | Ruby | mit | 84 | master | 1,606 | module LightGBM
class Classifier < Model
def initialize(num_leaves: 31, learning_rate: 0.1, n_estimators: 100, objective: nil, **options)
super
end
def fit(x, y, eval_set: nil, eval_names: [], categorical_feature: "auto", early_stopping_rounds: nil, verbose: true)
n_classes = y.uniq.size
... |
github | ankane/lightgbm-ruby | https://github.com/ankane/lightgbm-ruby | lib/lightgbm/regressor.rb | Ruby | mit | 84 | master | 901 | module LightGBM
class Regressor < Model
def initialize(num_leaves: 31, learning_rate: 0.1, n_estimators: 100, objective: "regression", **options)
super
end
def fit(x, y, categorical_feature: "auto", eval_set: nil, eval_names: [], early_stopping_rounds: nil, verbose: true)
train_set = Dataset.... |
github | ankane/lightgbm-ruby | https://github.com/ankane/lightgbm-ruby | lib/lightgbm/utils.rb | Ruby | mit | 84 | master | 1,245 | module LightGBM
module Utils
private
def safe_call(err)
raise Error, FFI.LGBM_GetLastError if err != 0
end
# remove spaces in keys and values to prevent injection
def params_str(params)
params.map { |k, v| [check_param(k.to_s), check_param(Array(v).join(",").to_s)].join("=") }.join("... |
github | luan/carrierwave-ftp | https://github.com/luan/carrierwave-ftp | carrierwave-ftp.gemspec | Ruby | mit | 84 | master | 1,123 | $LOAD_PATH.push File.expand_path('../lib', __FILE__)
require 'carrierwave/storage/ftp/version'
Gem::Specification.new do |s|
s.name = 'carrierwave-ftp'
s.version = Carrierwave::Storage::FTP::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ['Luan Santos']
s.email = ['luan@luansant... |
github | luan/carrierwave-ftp | https://github.com/luan/carrierwave-ftp | Rakefile | Ruby | mit | 84 | master | 329 | require 'bundler/setup'
require 'rspec/core/rake_task'
require 'rubocop/rake_task'
Bundler::GemHelper.install_tasks
desc 'Run all examples'
RSpec::Core::RakeTask.new(:spec) do |t|
t.rspec_opts = %w[--color]
end
RuboCop::RakeTask.new(:rubocop) do |t|
t.options = ['--display-cop-names']
end
task default: %i[ruboc... |
github | luan/carrierwave-ftp | https://github.com/luan/carrierwave-ftp | spec/ftp_spec.rb | Ruby | mit | 84 | master | 4,550 | require 'spec_helper'
require 'carrierwave/storage/ftp'
class FtpUploader < CarrierWave::Uploader::Base
storage :ftp
end
describe CarrierWave::Storage::FTP do
before do
FtpUploader.configure do |config|
config.reset_config
config.ftp_host = 'ftp.testcarrierwave.dev'
config.ftp_user = 'test_u... |
github | luan/carrierwave-ftp | https://github.com/luan/carrierwave-ftp | spec/sftp_file_spec.rb | Ruby | mit | 84 | master | 1,050 | require 'spec_helper'
require 'carrierwave/storage/sftp'
describe CarrierWave::Storage::SFTP::File do
let(:uploader) do
uploader = Class.new(CarrierWave::Uploader::Base) do
storage :sftp
end
allow(uploader).to receive(:store_path).and_return('uploads/test.jpg')
uploader
end
let(:base) { Ca... |
github | luan/carrierwave-ftp | https://github.com/luan/carrierwave-ftp | spec/sftp_spec.rb | Ruby | mit | 84 | master | 3,448 | require 'spec_helper'
require 'carrierwave/storage/sftp'
class SftpUploader < CarrierWave::Uploader::Base
storage :sftp
end
describe CarrierWave::Storage::SFTP do
before do
CarrierWave.configure do |config|
config.reset_config
config.sftp_host = 'testcarrierwave.dev'
config.sftp_user = 'test... |
github | luan/carrierwave-ftp | https://github.com/luan/carrierwave-ftp | spec/spec_helper.rb | Ruby | mit | 84 | master | 1,443 | require 'rubygems'
require 'bundler/setup'
require 'rspec'
require 'tempfile'
require 'carrierwave'
def file_path(*paths)
File.expand_path(File.join(File.dirname(__FILE__), 'fixtures', *paths))
end
def public_path(*paths)
File.expand_path(File.join(File.dirname(__FILE__), 'public', *paths))
end
CarrierWave.root... |
github | luan/carrierwave-ftp | https://github.com/luan/carrierwave-ftp | spec/ftp_file_spec.rb | Ruby | mit | 84 | master | 1,045 | require 'spec_helper'
require 'carrierwave/storage/ftp'
describe CarrierWave::Storage::FTP::File do
let(:uploader) do
uploader = Class.new(CarrierWave::Uploader::Base) do
storage :ftp
end
allow(uploader).to receive(:store_path).and_return('uploads/test.jpg')
uploader
end
let(:base) { Carri... |
github | luan/carrierwave-ftp | https://github.com/luan/carrierwave-ftp | spec/ftp_tls_spec.rb | Ruby | mit | 84 | master | 2,313 | require 'spec_helper'
require 'carrierwave/storage/ftp'
class FtpTlsUploader < CarrierWave::Uploader::Base
storage :ftp
end
describe CarrierWave::Storage::FTP do
before do
FtpTlsUploader.configure do |config|
config.reset_config
config.ftp_host = 'ftp.testcarrierwave.dev'
config.ftp_user = '... |
github | napazone/haml_assets | https://github.com/napazone/haml_assets | haml_assets.gemspec | Ruby | mit | 84 | master | 1,113 | # -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "haml_assets/version"
Gem::Specification.new do |s|
s.name = "haml_assets"
s.version = HamlAssets::VERSION
s.authors = ["Les Hill", "Wes Gibbs"]
s.email = ["leshill@gmail.com", "wes@infbio.com"]
s.homepage ... |
github | napazone/haml_assets | https://github.com/napazone/haml_assets | spec/render_spec.rb | Ruby | mit | 84 | master | 3,320 | require 'spec_helper'
describe HamlAssets do
it "should have the proper format" do
expect(RailsApp::Application.assets['link_to.jst.ejs.haml'].to_s).to eq("(function() { this.JST || (this.JST = {}); this.JST[\"link_to\"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__... |
github | napazone/haml_assets | https://github.com/napazone/haml_assets | spec/rails_app/config/application.rb | Ruby | mit | 84 | master | 1,009 | require_relative 'boot'
require "rails"
# Pick the frameworks you want:
require "active_model/railtie"
require "active_job/railtie"
# require "active_record/railtie"
# require "active_storage/engine"
require "action_controller/railtie"
# require "action_mailer/railtie"
require "action_view/railtie"
# require "action_c... |
github | napazone/haml_assets | https://github.com/napazone/haml_assets | spec/rails_app/config/environments/test.rb | Ruby | mit | 84 | master | 1,497 | 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 | napazone/haml_assets | https://github.com/napazone/haml_assets | spec/rails_app/config/environments/production.rb | Ruby | mit | 84 | master | 3,184 | 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 | napazone/haml_assets | https://github.com/napazone/haml_assets | spec/rails_app/config/environments/development.rb | Ruby | mit | 84 | master | 1,675 | 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 | napazone/haml_assets | https://github.com/napazone/haml_assets | lib/haml_assets.rb | Ruby | mit | 84 | master | 256 | require "haml_assets/version"
if defined? Rails
if Rails.version.to_f >= 3.1
require "haml_assets/engine"
end
end
module HamlAssets
autoload :Config, "haml_assets/config"
autoload :HamlSprocketsEngine, "haml_assets/haml_sprockets_engine"
end |
github | napazone/haml_assets | https://github.com/napazone/haml_assets | lib/haml_assets/engine.rb | Ruby | mit | 84 | master | 925 | module HamlAssets
class Engine < ::Rails::Engine
initializer "haml_assets.assets.register", :group => :all do |app|
app.config.assets.configure do |sprockets_env|
if sprockets_env.respond_to?(:register_transformer)
sprockets_env.register_mime_type 'application/vnd.carezone.haml+text', exte... |
github | napazone/haml_assets | https://github.com/napazone/haml_assets | lib/haml_assets/haml_sprockets_engine.rb | Ruby | mit | 84 | master | 2,657 | require 'haml'
require 'tilt'
module HamlAssets
class HamlSprocketsEngine < Tilt::HamlTemplate
self.default_mime_type = 'application/javascript'
class LookupContext < ActionView::LookupContext
def initialize(haml_context, path)
super(path)
@view_context = haml_context
end
... |
github | bglusman/debt_ceiling | https://github.com/bglusman/debt_ceiling | debt_ceiling.gemspec | Ruby | mit | 84 | master | 1,034 | # -*- encoding: utf-8 -*-
lib = File.expand_path('../lib/', __FILE__)
$LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib)
require 'debt_ceiling/version'
Gem::Specification.new do |s|
s.name = 'debt_ceiling'
s.version = DebtCeiling::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ['Bri... |
github | bglusman/debt_ceiling | https://github.com/bglusman/debt_ceiling | Gemfile | Ruby | mit | 84 | master | 310 | source "https://rubygems.org"
gemspec
# To support older versions, keep back some gems
if RUBY_VERSION < '2.0.0'
gem 'tins', '< 1.7.0'
gem 'term-ansicolor', '< 1.4.0'
end
group :development, :test do
gem 'pry', '~> 0.10'
gem 'rake', '~> 10.3'
gem 'rspec', '~> 3.1'
gem 'coveralls', '~> 0.7'
end |
github | bglusman/debt_ceiling | https://github.com/bglusman/debt_ceiling | lib/debt_ceiling.rb | Ruby | mit | 84 | master | 3,574 | require 'configurations'
require 'chronic'
require 'sparkr'
require 'rubycritic'
require 'rubycritic/cli/application'
require 'ostruct'
require 'forwardable'
require_relative 'debt_ceiling/common_methods'
require_relative 'debt_ceiling/audit'
require_relative 'debt_ceiling/accounting'
require_relative 'debt_ceiling/tod... |
github | bglusman/debt_ceiling | https://github.com/bglusman/debt_ceiling | lib/debt_ceiling/audit.rb | Ruby | mit | 84 | master | 2,386 | module DebtCeiling
class Audit
extend Forwardable
include CommonMethods
undef :+
FAILURE_MESSAGE = "DEBT CEILING FAILURE: "
TOTAL_LIMIT = "EXCEEDED TOTAL DEBT CEILING "
PER_MODULE_MESSAGE = "MAX DEBT PER MODULE EXCEEDED IN AT LEAST ONE LOCATION"
MISSED_TARGET_MESSAGE = ... |
github | bglusman/debt_ceiling | https://github.com/bglusman/debt_ceiling | lib/debt_ceiling/accounting.rb | Ruby | mit | 84 | master | 1,678 | module DebtCeiling
class Accounting
DebtCeilingExceeded = Class.new(StandardError)
TargetDeadlineMissed = Class.new(StandardError)
extend Forwardable
attr_reader :result, :path, :debts, :total_debt, :max_debt
def_delegator :max_debt, :analysed_module
alias_method :max_module, :analysed_modul... |
github | bglusman/debt_ceiling | https://github.com/bglusman/debt_ceiling | lib/debt_ceiling/todo.rb | Ruby | mit | 84 | master | 673 | module DebtCeiling
class Todo
def self.json_debts(debts)
debts.map(&:custom_debt).compact.map(&:todo_report).compact.reduce(&:merge)
end
def self.output(debts)
hash_debts = self.json_debts(debts)
puts JSON.pretty_generate(hash_debts)
.gsub("{", "")
.gsub("}", "")
... |
github | bglusman/debt_ceiling | https://github.com/bglusman/debt_ceiling | lib/debt_ceiling/static_analysis_debt.rb | Ruby | mit | 84 | master | 1,726 | module DebtCeiling
class StaticAnalysisDebt
extend Forwardable
include CommonMethods
def_delegators :configuration,
:complexity_multiplier, :duplication_multiplier, :smells_multiplier,
:grade_points, :method_count_multiplier, :ideal_max_line_count,
... |
github | bglusman/debt_ceiling | https://github.com/bglusman/debt_ceiling | lib/debt_ceiling/file_attributes.rb | Ruby | mit | 84 | master | 246 | class FileAttributes
attr_reader :linecount, :path, :source_code
def initialize(file_path)
@linecount = `wc -l #{file_path}`.match(/\d+/)[0].to_i
@path = file_path
@source_code = File.read(file_path)
end
end |
github | bglusman/debt_ceiling | https://github.com/bglusman/debt_ceiling | lib/debt_ceiling/archeological_dig.rb | Ruby | mit | 84 | master | 2,054 | require_relative "source_control_systems/base"
require_relative "analysis_caches/analysis_cache"
require 'digest/sha1'
require 'json'
module DebtCeiling
class ArcheologicalDig
ARCHEOLOGY_RECORD_VERSION_NUMBER = "v0" #increment for backward incompatible changes in record format
attr_reader :source_control, :re... |
github | bglusman/debt_ceiling | https://github.com/bglusman/debt_ceiling | lib/debt_ceiling/debt.rb | Ruby | mit | 84 | master | 1,831 | module DebtCeiling
class Debt
extend Forwardable
include CommonMethods
DoNotWhitelistAndBlacklistSimulateneously = Class.new(StandardError)
def_delegators :file_attributes,
:path, :module_name, :linecount, :source_code
def_delegators :configuration,
:whitelist... |
github | bglusman/debt_ceiling | https://github.com/bglusman/debt_ceiling | lib/debt_ceiling/custom_debt.rb | Ruby | mit | 84 | master | 2,999 | module DebtCeiling
class CustomDebt
extend Forwardable
include CommonMethods
DEFAULT_TODO_TEXT = 'TODO'
def_delegators :configuration,
:deprecated_reference_pairs, :manual_callouts, :cost_per_todo
def_delegators :file_attributes, :source_code, :path
def_delegator :debt_amo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.