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
app/views/controllers/occurrences/show.rb
Ruby
mit
84
main
1,575
# frozen_string_literal: true module Views module Controllers module Occurrences # Phlex view for the occurrence show page. # Displays observations in matrix boxes with the primary first. class Show < Views::Base register_output_helper :container_class def initialize(occurrence...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/views/controllers/occurrences/new.rb
Ruby
mit
84
main
1,311
# frozen_string_literal: true module Views module Controllers module Occurrences # Phlex view for the occurrence creation page. # Sets page title and renders the form component. # Optionally overlays a project membership confirmation modal. class New < Views::Base register_output_...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/views/controllers/inat_imports/new.rb
Ruby
mit
84
main
859
# frozen_string_literal: true module Views module Controllers module InatImports # Phlex view for the iNat import new/create page. # Sets page title and context nav, then renders the # form component. class New < Views::Base register_output_helper :add_page_title register_...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/views/controllers/rss_logs/rss.xml.builder
Ruby
mit
84
main
675
# frozen_string_literal: true xml.instruct!(:xml, version: "1.0") xml.rss(version: "2.0") do xml.channel do xml.title(:rss_title.l) xml.link(activity_logs_path) xml.description(:rss_description.l) xml.language(I18n.locale.to_s) @logs.each do |log| xml.item do xml.title(log.unique_te...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/views/controllers/projects/new.rb
Ruby
mit
84
main
942
# frozen_string_literal: true module Views module Controllers module Projects # Phlex view for the new project form page. # Replaces new.html.erb. class New < Views::Base register_output_helper :add_new_title register_output_helper :add_context_nav register_value_helper ...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/views/controllers/projects/show.rb
Ruby
mit
84
main
6,579
# frozen_string_literal: true module Views module Controllers module Projects # Phlex view for the project show page. # Replaces show.html.erb. class Show < Views::Base register_output_helper :add_show_title register_output_helper :add_edit_icons register_output_helper :...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/views/controllers/projects/edit.rb
Ruby
mit
84
main
992
# frozen_string_literal: true module Views module Controllers module Projects # Phlex view for the edit project form page. # Replaces edit.html.erb. class Edit < Views::Base register_output_helper :add_edit_title register_output_helper :add_context_nav register_value_hel...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/views/controllers/projects/aliases/index.rb
Ruby
mit
84
main
1,336
# frozen_string_literal: true module Views module Controllers module Projects module Aliases # Phlex view for the project aliases index page. # Replaces aliases/index.html.erb. class Index < Views::Base register_output_helper :add_project_banner register_output_h...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/views/controllers/projects/aliases/new.rb
Ruby
mit
84
main
1,090
# frozen_string_literal: true module Views module Controllers module Projects module Aliases # Phlex view for the new project alias form page. # Replaces aliases/new.html.erb. class New < Views::Base register_output_helper :add_project_banner register_output_help...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/views/controllers/projects/aliases/edit.rb
Ruby
mit
84
main
1,408
# frozen_string_literal: true module Views module Controllers module Projects module Aliases # Phlex view for the edit project alias form page. # Replaces aliases/edit.html.erb. class Edit < Views::Base register_output_helper :add_project_banner register_output_h...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/views/controllers/projects/aliases/show.rb
Ruby
mit
84
main
1,617
# frozen_string_literal: true module Views module Controllers module Projects module Aliases # Phlex view for the project alias show page. # Replaces aliases/show.html.erb. class Show < Views::Base register_output_helper :add_project_banner register_value_helper ...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/views/controllers/projects/admin_requests/new.rb
Ruby
mit
84
main
754
# frozen_string_literal: true module Views module Controllers module Projects module AdminRequests # Phlex view for the admin request form page. # Replaces admin_requests/new.html.erb. class New < Views::Base register_output_helper :add_page_title def initialize...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/views/controllers/projects/updates/index.rb
Ruby
mit
84
main
3,964
# frozen_string_literal: true module Views module Controllers module Projects module Updates class Index < Views::Base register_output_helper :add_project_banner register_output_helper :add_page_title register_value_helper :container_class def initialize(pro...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/views/controllers/projects/field_slips/new.rb
Ruby
mit
84
main
2,968
# frozen_string_literal: true module Views module Controllers module Projects module FieldSlips # Phlex view for the field slips form page. # Replaces field_slips/new.html.erb. class New < Views::Base register_output_helper :add_page_title register_output_helper ...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/views/controllers/projects/members/edit.rb
Ruby
mit
84
main
1,268
# frozen_string_literal: true module Views module Controllers module Projects module Members # Phlex view for the change member status page. # Replaces members/edit.html.erb. class Edit < Views::Base register_output_helper :add_page_title register_output_helper :...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/views/controllers/projects/members/index.rb
Ruby
mit
84
main
3,208
# frozen_string_literal: true module Views module Controllers module Projects module Members # Phlex view for the project members index page. # Replaces members/index.html.erb. class Index < Views::Base register_output_helper :add_project_banner register_value_he...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/views/controllers/projects/members/new.rb
Ruby
mit
84
main
2,287
# frozen_string_literal: true module Views module Controllers module Projects module Members # Phlex view for the add members page. # Replaces members/new.html.erb. class New < Views::Base register_output_helper :add_page_title register_output_helper :add_context...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/views/controllers/api2/_naming.xml.builder
Ruby
mit
84
main
835
# frozen_string_literal: true xml.tag!( tag, id: object.id, url: object.show_url, type: "naming" ) do xml_confidence_level(xml, :confidence, object.vote_cache) xml_datetime(xml, :created_at, object.created_at) xml_datetime(xml, :updated_at, object.updated_at) xml_detailed_object(xml, :name, object.name...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/views/controllers/api2/_occurrence.xml.builder
Ruby
mit
84
main
948
# frozen_string_literal: true xml.tag!( tag, id: object.id, url: occurrence_url(object.id), type: "occurrence" ) do xml_integer(xml, :primary_observation_id, object.primary_observation_id) xml_boolean(xml, :has_specimen, object.has_specimen) xml_datetime(xml, :created_at, object.created_at) xml_datetim...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/views/controllers/api2/results.xml.builder
Ruby
mit
84
main
1,793
# frozen_string_literal: true xml.instruct!(:xml, version: "1.0") xml.response(xmlns: "#{MO.http_domain}/response.xsd") do xml_string(xml, :version, @api.version) xml_datetime(xml, :run_date, @start_time) xml_minimal_object(xml, :user, :user, @api.user.id) if @api.user unless @api.errors.any?(&:fatal) if ...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/views/controllers/api2/_herbarium_record.xml.builder
Ruby
mit
84
main
930
# frozen_string_literal: true xml.tag!( tag, id: object.id, url: object.show_url, type: "herbarium_record" ) do xml_string(xml, :initial_determination, object.initial_det) xml_string(xml, :accession_number, object.accession_number) xml_html_string(xml, :notes, object.notes.to_s.tl_for_api) xml_datetime...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/views/controllers/api2/_herbarium.xml.builder
Ruby
mit
84
main
758
# frozen_string_literal: true xml.tag!( tag, id: object.id, url: object.show_url, type: "herbarium" ) do xml_string(xml, :code, object.code) xml_string(xml, :name, object.name) xml_string(xml, :email, object.email) xml_string(xml, :address, object.mailing_address) xml_html_string(xml, :description, o...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/views/controllers/api2/_external_site.xml.builder
Ruby
mit
84
main
307
# frozen_string_literal: true xml.tag!( tag, id: object.id, url: object.show_url, type: "external_site" ) do xml_string(xml, :name, object.name) if detail xml_detailed_object(xml, :project, object.project) else xml_minimal_object(xml, :project, :project, object.project_id) end end
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/views/controllers/api2/_name.xml.builder
Ruby
mit
84
main
1,646
# frozen_string_literal: true xml.tag!( tag, id: object.id, url: object.show_url, type: "name" ) do xml_string(xml, :name, object.user_real_text_name(nil)) xml_string(xml, :author, object.author) xml_string(xml, :rank, object.rank.to_s.downcase) xml_boolean(xml, :deprecated, true) if object.deprecated ...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/views/controllers/api2/_location_description.xml.builder
Ruby
mit
84
main
931
# frozen_string_literal: true xml.tag!( tag, id: object.id, url: object.show_url, type: "location_description" ) do xml_integer(xml, :location_id, object.location_id) xml_datetime(xml, :created_at, object.created_at) xml_datetime(xml, :updated_at, object.updated_at) xml_integer(xml, :number_of_views, o...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/views/controllers/api2/_field_slip.xml.builder
Ruby
mit
84
main
780
# frozen_string_literal: true xml.tag!( tag, id: object.id, url: object.show_url, type: "field_slip" ) do xml_string(xml, :code, object.code) xml_datetime(xml, :created_at, object.created_at) xml_datetime(xml, :updated_at, object.updated_at) if object.observations.any? xml.observations(number: obje...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/views/controllers/api2/_name_description.xml.builder
Ruby
mit
84
main
1,286
# frozen_string_literal: true xml.tag!( tag, id: object.id, url: object.show_url, type: "name_description" ) do xml_integer(xml, :name_id, object.name_id) xml_datetime(xml, :created_at, object.created_at) xml_datetime(xml, :updated_at, object.updated_at) xml_integer(xml, :number_of_views, object.num_vi...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/views/controllers/api2/_sequence.xml.builder
Ruby
mit
84
main
761
# frozen_string_literal: true xml.tag!( tag, id: object.id, url: object.show_url, type: "sequence" ) do xml_string(xml, :locus, object.locus.truncate(object.locus_width)) # Treat bases as html to preserve newlines and opening ">" xml_html_string(xml, :bases, object.bases.tp) xml_string(xml, :archive, o...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/views/controllers/api2/_comment.xml.builder
Ruby
mit
84
main
549
# frozen_string_literal: true xml.tag!( tag, id: object.id, url: object.show_url, type: "comment" ) do xml_html_string(xml, :summary, object.summary.to_s.tl) xml_html_string(xml, :content, object.comment.to_s.tl_for_api) xml_datetime(xml, :created_at, object.created_at) xml_datetime(xml, :updated_at, o...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/views/controllers/api2/_image.xml.builder
Ruby
mit
84
main
1,549
# frozen_string_literal: true xml.tag!( tag, id: object.id, url: object.show_url, type: "image" ) do xml_date(xml, :date, object.when) xml_string(xml, :copyright_holder, object.copyright_holder) xml_html_string(xml, :notes, object.notes.to_s.tl_for_api) xml_image_quality(xml, :quality, object.vote_cach...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/views/controllers/api2/_collection_number.xml.builder
Ruby
mit
84
main
699
# frozen_string_literal: true xml.tag!( tag, id: object.id, url: object.show_url, type: "collection_number" ) do xml_string(xml, :collector, object.name) xml_string(xml, :number, object.number) xml_datetime(xml, :created_at, object.created_at) xml_datetime(xml, :updated_at, object.updated_at) if deta...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/views/controllers/api2/_species_list.xml.builder
Ruby
mit
84
main
852
# frozen_string_literal: true xml.tag!( tag, id: object.id, url: object.show_url, type: "species_list" ) do xml_string(xml, :title, object.title) xml_html_string(xml, :notes, object.notes.to_s.tl_for_api) xml_date(xml, :date, object.when) xml_datetime(xml, :created_at, object.created_at) xml_datetime...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/views/controllers/api2/_location.xml.builder
Ruby
mit
84
main
1,008
# frozen_string_literal: true xml.tag!( tag, id: object.id, url: object.show_url, type: "location" ) do xml_string(xml, :name, object.text_name) xml_latitude(xml, :latitude_north, object.north) xml_latitude(xml, :latitude_south, object.south) xml_longitude(xml, :longitude_east, object.east) xml_longi...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/views/controllers/api2/_project.xml.builder
Ruby
mit
84
main
735
# frozen_string_literal: true xml.tag!( tag, id: object.id, url: object.show_url, type: "project" ) do xml_string(xml, :title, object.title) xml_html_string(xml, :summary, object.summary.to_s.tl_for_api) xml_string(xml, :field_slip_prefix, object.field_slip_prefix) xml_datetime(xml, :created_at, object...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/views/controllers/api2/_user.xml.builder
Ruby
mit
84
main
1,445
# frozen_string_literal: true xml.tag!( tag, id: object.id, url: object.show_url, type: "user" ) do xml_string(xml, :login_name, object.login) xml_string(xml, :legal_name, object.legal_name) xml_date(xml, :joined, object.created_at) xml_date(xml, :verified, object.verified) xml_datetime(xml, :last_lo...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/views/controllers/api2/_external_link.xml.builder
Ruby
mit
84
main
648
# frozen_string_literal: true xml.tag!( tag, id: object.id, url: object.show_url, type: "external_link" ) do xml_string(xml, :url, object.url) xml_datetime(xml, :created_at, object.created_at) xml_datetime(xml, :updated_at, object.updated_at) xml_minimal_object(xml, :observation, :observation, object.o...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/views/controllers/api2/_observation.xml.builder
Ruby
mit
84
main
4,191
# frozen_string_literal: true xml.tag!( tag, id: object.id, url: object.show_url, type: "observation" ) do xml_date(xml, :date, object.when) xml_latitude(xml, :latitude, object.public_lat) xml_longitude(xml, :longitude, object.public_lng) xml_altitude(xml, :altitude, object.alt) xml_boolean(xml, :gps...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/views/controllers/api2/_api_key.xml.builder
Ruby
mit
84
main
398
# frozen_string_literal: true xml.tag!( tag, id: object.id, url: object.show_url, type: "api_key" ) do xml_string(xml, :key, object.key) xml_html_string(xml, :notes, object.notes.to_s.tl_for_api) xml_date(xml, :created_at, object.created_at) xml_date(xml, :last_used, object.last_used) xml_date(xml, :...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/jobs/inat_import_recovery_job.rb
Ruby
mit
84
main
824
# frozen_string_literal: true # Finds InatImport records stuck in the Importing state and marks them Done. # Scheduled in config/recurring.yml to run every STUCK_THRESHOLD minutes. # This recovers from worker process crashes (e.g., SIGKILL, OOM) where the # job's ensure block never ran. class InatImportRecoveryJob < A...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/jobs/discard_stale_jobs_job.rb
Ruby
mit
84
main
1,406
# frozen_string_literal: true require "mission_control/jobs" class DiscardStaleJobsJob < ApplicationJob queue_as :default def perform(discard_date = 1.week.ago.in_time_zone("UTC")) discard_stale_failed_jobs(discard_date) discard_stale_finished_jobs end def discard_stale_failed_jobs(discard_date) ...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/jobs/field_slip_job.rb
Ruby
mit
84
main
1,109
# frozen_string_literal: true class FieldSlipJob < ApplicationJob queue_as :default def perform(tracker_id) log("Starting FieldSlipJob.perform(#{tracker_id})") cleanup_old_pdfs(tracker_id) tracker = FieldSlipJobTracker.find(tracker_id) raise(:field_slip_job_no_tracker.t) unless tracker tracke...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/jobs/application_job.rb
Ruby
mit
84
main
775
# frozen_string_literal: true class ApplicationJob < ActiveJob::Base # Automatically retry jobs that encountered a deadlock # retry_on ActiveRecord::Deadlocked # Most jobs are safe to ignore if the underlying records are no # longer available discard_on ActiveJob::DeserializationError def log(str) time...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/jobs/image_loader_job.rb
Ruby
mit
84
main
1,305
# frozen_string_literal: true class ImageLoaderJob < ApplicationJob queue_as :default before_enqueue { write_status(:queued) } before_perform { write_status(:working) } after_perform { write_status(:completed) } def perform(image_id, user_id) file = Image.cached_original_file_path(image_id) return...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/jobs/update_box_area_and_center_columns_job.rb
Ruby
mit
84
main
1,291
# frozen_string_literal: true class UpdateBoxAreaAndCenterColumnsJob < ApplicationJob queue_as :default def perform(**args) args ||= {} log("Starting UpdateBoxAreaAndCenterColumnsJob.perform") # This should be zero, but count just in case. loc_count = Location.where(box_area: nil).count log("F...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/jobs/inat_import_job.rb
Ruby
mit
84
main
7,049
# frozen_string_literal: true require "English" class InatImportJob < ApplicationJob attr_accessor :inat_import include Inat::Constants queue_as :default delegate :canceled?, to: :inat_import delegate :imported_count, to: :inat_import delegate :inat_username, to: :inat_import delegate :response_error...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/eol_data.rb
Ruby
mit
84
main
8,665
# frozen_string_literal: true # # = EOL Data # # name_count # total_image_count # total_description_count # has_images?(id) - id is the id of a Name # images(id) - id is the id of a Name # image_count(id) - id is the id of a Name # has_descriptions?(id) - id is the id of a Name # descriptions(...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/note_field.rb
Ruby
mit
84
main
243
# frozen_string_literal: true # Simple PORO to help with structure notes class NoteField attr_reader :name attr_reader :value def initialize(name:, value:) @name = name @value = value end def label name.to_s end end
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/format_url.rb
Ruby
mit
84
main
4,552
# frozen_string_literal: true # Can simply validate one url as a working url, # or check it conforms to a the format of a provided base_url. # # Main accessors # # valid?:: True if it works, and if it matches any provided base_url # # formatted:: Returns formatted URL: # - will automatically...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/robots.rb
Ruby
mit
84
main
1,093
# frozen_string_literal: true # Permissions for user_agents class Robots class << self # Is the robot authorized to be on the site? def authorized?(user_agent) # Googlebot not followed by a hyphen excludes Googlebot-Image, etc. /Googlebot(?!-)|bingbot/.match?(user_agent) end def action_a...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/project_constraints.rb
Ruby
mit
84
main
803
# frozen_string_literal: true # limitations on Projects class ProjectConstraints attr_reader :params def initialize(params) @params = params end def ends_before_start? return false if allow_any_dates? start_date = parse_date(:start_date) end_date = parse_date(:end_date) start_date.prese...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/internal_link.rb
Ruby
mit
84
main
520
# frozen_string_literal: true class InternalLink attr_reader :url def initialize(title, url, html_options: {}, alt_title: nil) @title = title @alt_title = alt_title @url = url @html_options = html_options @html_options[:class] = [@html_options[:class], html_class]....
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/parallel_test_config_service.rb
Ruby
mit
84
main
3,946
# frozen_string_literal: true # Service for managing parallel test MySQL configuration files class ParallelTestConfigService attr_reader :output_handler, :rails_root def initialize( output_handler: ParallelTestConfigService::StdoutOutputHandler.new, rails_root: Rails.root ) @output_handler = output_...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/observation_labels.rb
Ruby
mit
84
main
591
# frozen_string_literal: true # Main document class for generating PDF labels class ObservationLabels def initialize(user, query) @report = if user.label_format == "rtf" ObservationLabels::RtfLabels.new(query) else ObservationLabels::PdfLabels.new(query) ...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/login_system.rb
Ruby
mit
84
main
2,534
# frozen_string_literal: true # Methods to restrict method access to logged-in users module LoginSystem protected # overwrite this if you want to restrict access to only a few actions # or if you want to check if the user has the correct rights # example: # # # only allow nonbobs # def authorize?(user...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/api2.rb
Ruby
mit
84
main
6,945
# frozen_string_literal: true # = API2 # # == Usage # # api = API2.execute(method: "GET", action: :observation, id: 12345) # unless api.errors.any? # render_api_results(api.results) # else # render_errors(api.errors) # end # # All requests return an array of objects affected, and an array of a...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/country_counter.rb
Ruby
mit
84
main
1,439
# frozen_string_literal: true # # = CountryCounter # # This class counts how many observations are from each country # ################################################################################ class CountryCounter attr_accessor :known_by_count # known countries with observations attr_accessor :unknown_by...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/web_sequence_archive.rb
Ruby
mit
84
main
1,687
# frozen_string_literal: true # class with information about external websites class WebSequenceArchive class << self # on-line primary-source repositories (Archives) for nucleotide sequences # in menu order # name short name, used in drop-down menu # home home page # prefix prefix f...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/visual_group_images.rb
Ruby
mit
84
main
2,364
# frozen_string_literal: true class VisualGroupImages # VOTE_LIMIT = 1.5 attr_accessor :query # status should be one of [:included, :excluded, :any, :reviewed] def initialize(visual_group, name, status, count = nil) self.query = tables[:observation_images] add_joins(status) add_project(status) ...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/query.rb
Ruby
mit
84
main
18,206
# frozen_string_literal: true # == Query Superclass # # This class encapsulates a hash of params that can produce an ActiveRecord # statement for a database query, that looks up one or more objects of a # given type, matching certain conditions in a certain order. # # Queries are specified by a model. The model ...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/ip_stats.rb
Ruby
mit
84
main
6,203
# frozen_string_literal: true # This class is used by a cronjob which is stripped down to the minimum and # apparently doesn't load the exclude? method, therefore we're just disabling # this cop locally to avoid any problems. # rubocop:disable Rails/NegateInclude class IpStats class << self STATS_TIME = 10 # mi...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/pattern_search.rb
Ruby
mit
84
main
2,220
# frozen_string_literal: true # # = PatternSearch # # This is a user-facing interface for Query. It allows users to type a bunch # of parameters into a single text field - potentially search terms, but also # specific params, as key:value pairs. (Search terms are not even required.) # PatternSearch class parses t...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/textile.rb
Ruby
mit
84
main
17,381
# frozen_string_literal: true require("redcloth") # == Textile Parser # # This class -- a subclass of String -- is a wrapper on RedCloth. It provides # some extra proprietary syntax on top of the standard Textile as implemented # by RedCloth, such as turning _Species name_ into a link to # <tt>lookup_name/Speci...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/date_range_parser.rb
Ruby
mit
84
main
3,758
# frozen_string_literal: true # Parses user-input date ranges (or strings) into a range of Ruby dates that # MO's date AR scopes can handle. # # Can parse ranges like "2008-01-05-2008-03-14", "2009-2011", # "02-08" (month range), "09-03" (month range wrapping new year), # and underscored Ruby-style phrases like "last_...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/checklist.rb
Ruby
mit
84
main
10,307
# frozen_string_literal: true # = Checklist # # This class calculates a checklist of species observed by users, # projects, etc. # # == Methods # # num_genera:: Number of genera seen. # num_species:: Number of species seen. # num_taxa:: Number of distinct taxa. # genera:: List of gener...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/search_params.rb
Ruby
mit
84
main
2,430
# frozen_string_literal: true # Give search string for notes google-like syntax: # word1 word2 --> any has both word1 and word2 # word1 OR word2 --> any has either word1 or word2 # "word1 word2" --> any has word1 followed immediately by word2 # -word1 --> none has word1 # # Note, to conform...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/pagination_data.rb
Ruby
mit
84
main
5,761
# frozen_string_literal: true # # = Pagination # # Simple class to hold the minimal info needed to paginate a set of objects by # page number and/or letter. This class knows nothing about how to query the # results (see Query#paginate), nor does it know anything about how to render # the results or pagination co...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/field_slip_view.rb
Ruby
mit
84
main
2,397
# frozen_string_literal: true require("prawn/measurement_extensions") class FieldSlipView include Prawn::View include Prawn::FieldSlipCard # Full page constants SLIPS_PER_PAGE = 6 # Horizontal PAGE_LEFT = -27 PAGE_RIGHT = 567 X_OFFSET = -1.5 PAGE_X_MID = X_OFFSET + PAGE_LEFT + (PAGE_RIGHT - PAGE_L...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/search_field_ui.rb
Ruby
mit
84
main
4,434
# frozen_string_literal: true # Service object to determine which UI component to use for a search field. # Extracts UI selection logic from the Searchable concern. # # @example Usage in controller # SearchFieldUI.for(controller: self, field: :names) # # => :names_fields_for_obs # # @example With instance # Sear...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/autocomplete.rb
Ruby
mit
84
main
1,951
# frozen_string_literal: true # # = Autocomplete base class # # results = AutocompleteName.new(string: 'Agaricus') # ...or... # results = Autocomplete.subclass('name').new(string: 'Agaricus') # render(json: ActiveSupport::JSON.encode(results) # ################################################################...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/normalized_hash.rb
Ruby
mit
84
main
1,217
# frozen_string_literal: true # Used to ensure all keys to the hash use underscores # rather than spaces and that the keys are case insensitive # for setting, but the key used is the first one that gets # assigns. # # See the Observation cache for the primary use case class NormalizedHash extend Forwardable def_d...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/visual_group_names.rb
Ruby
mit
84
main
1,610
# frozen_string_literal: true class VisualGroupNames attr_accessor :query def initialize(visual_group_id, count = nil) self.query = tables[:observation_images] add_joins add_project add_conditions(visual_group_id) add_order_and_limit(count) end def sql_query query.to_sql end priv...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/lookup.rb
Ruby
mit
84
main
3,383
# frozen_string_literal: true # Lookup # # A flexible looker-upper of records. It can handle any identifiers we're likely # to throw at it: a string, ID, instance, or a mixed array of any of those. The # `lookup_method` has to be configured in the Lookup child class, because the # lookup column names are different for...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/tree.rb
Ruby
mit
84
main
3,528
# frozen_string_literal: true class Tree # Searches the screwy ActiveRecord join- and include-style "trees" for a node. # # NOTE: Symbol, Array and Hash classes have been extended with "has_node?" # methods. It might be more readable to use those as entry points. # # BAD: # Tree.has_node?(join, :n...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/field_slip_notes_builder.rb
Ruby
mit
84
main
1,327
# frozen_string_literal: true class FieldSlipNotesBuilder def initialize(params, field_slip) @params = params @field_slip = field_slip end def assemble notes = {} notes[:Collector] = collector notes[:Field_Slip_ID] = field_slip_id notes[:Field_Slip_ID_By] = field_slip_id_by notes[:Ot...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/suggestion.rb
Ruby
mit
84
main
2,042
# frozen_string_literal: true class Suggestion attr_reader :name def self.analyze(data) matches = {} data.each do |image_data| next unless image_data.is_a?(Array) image_data.each do |name, prob| if matches[name] matches[name].add_data(prob) else matches[nam...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/run_level.rb
Ruby
mit
84
main
347
# frozen_string_literal: true # Class used by "rake location" and autologger (in AbstractModel) # to turn event logging and email notifications off. class RunLevel @@runlevel = :normal def self.normal @@runlevel = :normal end def self.silent @@runlevel = :silent end def self.is_normal? @@run...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/project_lat_lngs.rb
Ruby
mit
84
main
2,129
# frozen_string_literal: true # Finds all observations that the current logged in user # can see due to their being a project admin for a project # that another user trusts. class ProjectLatLngs attr_accessor :query, :user def initialize(args) self.query = tables[:observations] self.user = args[:user] || ...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/user_management_service.rb
Ruby
mit
84
main
5,039
# frozen_string_literal: true # app/services/user_management_service.rb class UserManagementService attr_reader :input_handler, :output_handler def initialize(input_handler: StdinInputHandler.new, output_handler: StdoutOutputHandler.new) @input_handler = input_handler @output_handler = o...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/object_change.rb
Ruby
mit
84
main
306
# frozen_string_literal: true # Encapsulates a change in an object class ObjectChange attr_reader :object, :old_clone, :new_clone def initialize(obj, old_version, new_version) @object = obj @old_clone = obj&.revert_clone(old_version) @new_clone = obj&.revert_clone(new_version) end end
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/token.rb
Ruby
mit
84
main
602
# frozen_string_literal: true class Token attr_accessor :hash def initialize(hash = {}) @hash = hash end def encrypt_to_header token_json = JSON.generate(@hash) Token.crypt.encrypt_and_sign(token_json) end def self.decrypt_from_header(auth_header) token = Token.crypt.decrypt_and_verify(a...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/site_data.rb
Ruby
mit
84
main
3,035
# frozen_string_literal: true # # = Site Data # # This class manages user contributions / rankings. # # == Instance Methods # ==== Public # get_site_data:: Returns stats for entire site. # ==== Private # field_count:: Looks up total number of entries in a given table. # class SiteData ##...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/pattern_search/location.rb
Ruby
mit
84
main
1,090
# frozen_string_literal: true module PatternSearch # Search where results returned are Locations class Location < Base PARAMS = { # dates / times created: [:created_at, :parse_date_range], modified: [:updated_at, :parse_date_range], # strings / lists region: [:region, :parse_list...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/pattern_search/base.rb
Ruby
mit
84
main
3,560
# frozen_string_literal: true module PatternSearch # Base class for PatternSearch; handles everything plus build_query class Base attr_accessor :errors, :parser, :query_params, :query def initialize(string) self.errors = [] self.parser = PatternSearch::Parser.new(string) build_query ...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/pattern_search/term.rb
Ruby
mit
84
main
7,169
# frozen_string_literal: true module PatternSearch # Parse PatternSearch parameter terms # Sample use: # elsif term.var == :specimen # query_params[:has_specimen] = term.parse_boolean_string class Term include Dates attr_accessor :var, :vals def initialize(var) self.var = var ...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/pattern_search/parser.rb
Ruby
mit
84
main
1,547
# frozen_string_literal: true module PatternSearch class Parser attr_accessor :incoming_string, :terms VAL_REGEX = / "([^\\"]+|\\.)*" | '([^\\']+|\\.)*' | ([^\s\\,]+|\\.)+ /x TERM_REGEX = / ^(\S+:)? ( #{VAL_REGEX} (, #{VAL_REGEX})* ) (\s+|$) /x def initialize(string) self....
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/pattern_search/name.rb
Ruby
mit
84
main
1,887
# frozen_string_literal: true module PatternSearch # Search where results returned are Names class Name < Base PARAMS = { created: [:created_at, :parse_date_range], modified: [:updated_at, :parse_date_range], deprecated: [:deprecated, :parse_boolean], has_synonyms: [:has_synonyms, :par...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/pattern_search/observation.rb
Ruby
mit
84
main
3,661
# frozen_string_literal: true module PatternSearch # base class for Searches for Observations meeting conditions in a Pattern class Observation < Base PARAMS = { # dates / times when: [:date, :parse_date_range], created: [:created_at, :parse_date_range], modified: [:updated_at, :parse_d...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/pattern_search/term/dates.rb
Ruby
mit
84
main
370
# frozen_string_literal: true module PatternSearch class Term # parse the date variable in pattern searches module Dates def parse_date_range val = make_sure_there_is_one_value!.dup val = ::DateRangeParser.new(val).range raise(BadDateRangeError.new(var: var, val: first_val)) if ...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/pattern_search/error/bad_date_range_error.rb
Ruby
mit
84
main
260
# frozen_string_literal: true module PatternSearch class BadDateRangeError < Error def to_s :pattern_search_bad_date_range_error.t(term: args[:var].inspect, value: args[:val].inspect) end end end
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/pattern_search/error/pattern_must_be_first_error.rb
Ruby
mit
84
main
277
# frozen_string_literal: true module PatternSearch class PatternMustBeFirstError < Error def to_s :pattern_search_pattern_must_be_first_error.t(str: args[:str].inspect, var: args[:var].inspect) end end end
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/pattern_search/error/bad_yes_no_both_error.rb
Ruby
mit
84
main
262
# frozen_string_literal: true module PatternSearch class BadYesNoBothError < Error def to_s :pattern_search_bad_yes_no_both_error.t(term: args[:var].inspect, value: args[:val].inspect) end end end
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/pattern_search/error/bad_float_error.rb
Ruby
mit
84
main
376
# frozen_string_literal: true module PatternSearch class BadFloatError < Error def to_s :pattern_search_bad_float_error.t(term: args[:var].inspect, value: args[:val].inspect, min: args[:min].inspect, ...
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/pattern_search/error/bad_project_error.rb
Ruby
mit
84
main
252
# frozen_string_literal: true module PatternSearch class BadProjectError < Error def to_s :pattern_search_bad_project_error.t(term: args[:var].inspect, value: args[:val].inspect) end end end
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/pattern_search/error/bad_location_error.rb
Ruby
mit
84
main
255
# frozen_string_literal: true module PatternSearch class BadLocationError < Error def to_s :pattern_search_bad_location_error.t(term: args[:var].inspect, value: args[:val].inspect) end end end
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/pattern_search/error/bad_boolean_error.rb
Ruby
mit
84
main
252
# frozen_string_literal: true module PatternSearch class BadBooleanError < Error def to_s :pattern_search_bad_boolean_error.t(term: args[:var].inspect, value: args[:val].inspect) end end end
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/pattern_search/error/bad_confidence_error.rb
Ruby
mit
84
main
261
# frozen_string_literal: true module PatternSearch class BadConfidenceError < Error def to_s :pattern_search_bad_confidence_error.t(term: args[:var].inspect, value: args[:val].inspect) end end end
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/pattern_search/error/bad_rank_range_error.rb
Ruby
mit
84
main
260
# frozen_string_literal: true module PatternSearch class BadRankRangeError < Error def to_s :pattern_search_bad_rank_range_error.t(term: args[:var].inspect, value: args[:val].inspect) end end end
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/pattern_search/error/bad_herbarium_error.rb
Ruby
mit
84
main
258
# frozen_string_literal: true module PatternSearch class BadHerbariumError < Error def to_s :pattern_search_bad_herbarium_error.t(term: args[:var].inspect, value: args[:val].inspect) end end end
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/pattern_search/error/bad_term_error.rb
Ruby
mit
84
main
266
# frozen_string_literal: true module PatternSearch class BadTermError < Error def to_s :pattern_search_bad_term_error.tp(type: args[:type], help: args[:help], term: args[:term].var.to_s.inspect) end end end
github
MushroomObserver/mushroom-observer
https://github.com/MushroomObserver/mushroom-observer
app/classes/pattern_search/error/bad_name_error.rb
Ruby
mit
84
main
243
# frozen_string_literal: true module PatternSearch class BadNameError < Error def to_s :pattern_search_bad_name_error.t(term: args[:var].inspect, value: args[:val].inspect) end end end