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
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/tasks/export.rake
Ruby
mit
19
develop
1,008
namespace :export do desc 'Export all updated instruments' task instruments: :environment do Instrument.find_each do |i| begin next if i.last_edited_time.nil? if i.export_time.nil? || Date.parse(i.export_time.to_s) < Date.parse(i.last_edited_time.to_s) exp = Exporters::XML::DDI:...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/tasks/start.rake
Ruby
mit
19
develop
474
namespace :start do desc 'Start dev server' task :development do system 'cd react && npm install --legacy-peer-deps && npm audit fix --legacy-peer-deps' exec 'bundle exec foreman start -f Procfile.dev' end desc 'Start production server' task :production do exec 'npm install --legacy-peer-deps && ...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
lib/tasks/mapping.rake
Ruby
mit
19
develop
483
namespace :mapping do desc 'Clear and build all strands' task compile_strands: :environment do Strand.delete_all CcQuestion.find_each do |qc| s = Strand.new [qc] s.save end Variable.find_each do |var| s = Strand.new [var] s.save end Map.where(source_type: CcQuestio...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/jobs/import_job.rb
Ruby
mit
19
develop
1,830
# frozen_string_literal: true module ImportJob class Basic include Sidekiq::Worker sidekiq_options queue: 'in_and_out' def run(importer, options = {}) begin trap 'TERM' do importer.cancel self.class.perform_async(importer.object.id, options) exit 0 ...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/jobs/export_job.rb
Ruby
mit
19
develop
3,270
# frozen_string_literal: true module ExportJob; end class ExportJob::Base include Sidekiq::Worker include Exporters::Loggable sidekiq_options queue: 'in_and_out' def perform(id, options = {}) export_id = options["export_id"] setup_export(export_id) begin set_export_to_running proces...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/jobs/delete_job.rb
Ruby
mit
19
develop
2,859
# frozen_string_literal: true module DeleteJob; end class DeleteJob::Instrument include Sidekiq::Worker sidekiq_options queue: 'in_and_out' def perform (instrument_id) begin instrument = ::Instrument.find instrument_id instrument.destroy ::Instrument.last.touch(:updated_at) rescue =>...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/jobs/copy_job.rb
Ruby
mit
19
develop
317
# frozen_string_literal: true class CopyJob include Sidekiq::Worker sidekiq_options queue: 'in_and_out' def perform (instrument_id, new_prefix, other_vals) begin orig = Instrument.find instrument_id orig.copy new_prefix, other_vals rescue => e Rails.logger.fatal e end end end
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/services/instruments/seed_defaults.rb
Ruby
mit
19
develop
2,477
module Instruments # Seeds a freshly-created Instrument with the common response domains and # the Yes/No code list that every new instrument should start with — see # GH issue #87. # # The defaults are hard-coded constants. They are duplicated per-instrument # at create time (each Instrument owns its own R...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/services/instruments/mappings_tsv_data_service.rb
Ruby
mit
19
develop
4,069
class Instruments::MappingsTsvDataService def initialize(object, unmapped_variables) @object = object @unmapped_variables = unmapped_variables @tsv_data = [] end def generate_tsv_data generate_question_items generate_unmapped_variables @tsv_data end private def generate_question_i...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/services/instruments/control_construct_updater.rb
Ruby
mit
19
develop
3,040
# frozen_string_literal: true module Instruments class ControlConstructUpdater include ActiveRecord::Sanitization::ClassMethods def initialize(instrument, updates=[]) @instrument = instrument @updates = updates.map{|u| u.to_hash.deep_symbolize_keys! }.select{|u| u[:type].present? && u[:parent][:...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/services/instruments/serializer.rb
Ruby
mit
19
develop
3,598
class Instruments::Serializer include Pundit attr_accessor :datasets, :instrument, :current_user, :auth_token def initialize(instrument=nil, user=nil, auth_token=nil) self.current_user = user self.instrument = instrument self.datasets = get_datasets self.auth_token = auth_token end def cal...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/services/variables/serializer.rb
Ruby
mit
19
develop
5,087
class Variables::Serializer attr_accessor :dataset def initialize(dataset=nil) self.dataset = dataset end def call all end private def all connection = ActiveRecord::Base.connection sql = %| SELECT variables.id, variables.name, variables.label, variables.var_type, variable...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/models/instrument.rb
Ruby
mit
19
develop
13,687
# frozen_string_literal: true # The Instrument is based on the Instrument model from DDI3.X and is one of the # champion models that pulls together Archivist. # # # Please visit http://www.ddialliance.org/Specification/DDI-Lifecycle/3.2/XMLSchema/FieldLevelDocumentation/schemas/datacollection_xsd/elements/Instrument.h...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/models/response_domain_text.rb
Ruby
mit
19
develop
603
# frozen_string_literal: true # The ResponseDomainText is based on the TextDomain model from DDI3.X # # Please visit http://www.ddialliance.org/Specification/DDI-Lifecycle/3.2/XMLSchema/FieldLevelDocumentation/schemas/datacollection_xsd/elements/TextDomain.html # # === Properties # * Label # * Maxlen class ResponseDom...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/models/cc_loop.rb
Ruby
mit
19
develop
1,437
# frozen_string_literal: true # The CcLoop model directly relates to the DDI3.X LoopConstruct model # # Loops are one of the five control constructs used in the questionnaire profile # and used in Archivist. This control construct provides a single repeatable branch for the # instrument logic to progress. They typical...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/models/qv_mapping.rb
Ruby
mit
19
develop
875
# frozen_string_literal: true # A representation of the database view for Q-V Mapping # # This cannot be used for creating, updating or deleting, but provides # a quick way to view question-variable mapping. # # === Properties # * id # * source # * variable class QvMapping < ReadOnlyRecord # Use id as a primary key ...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/models/export.rb
Ruby
mit
19
develop
673
# frozen_string_literal: true class Export < ApplicationRecord belongs_to :document belongs_to :dataset belongs_to :instrument delegate :filename, to: :document, allow_nil: true # Cleanup old documents when export completes successfully after_update :cleanup_old_documents, if: :saved_change_to_state? ...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/models/identifier.rb
Ruby
mit
19
develop
2,244
# frozen_string_literal: true # Any exportable item can have an unlimited number of Identifiers # # Identifiers are to ensure persistent identifiers can be created during # import and export. They can be used as URNs or any other form of string # based of unique identification. Each ID string must be unqiue within a #...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/models/item_group.rb
Ruby
mit
19
develop
924
# frozen_string_literal: true # A generic model to represent an DDI 3.X support item group # e.g. VariableGroup # # An ItemGroup can also be purposed to represent groups with # a root item. # # === Properties # * Label # * Group type # * Item type class ItemGroup < ApplicationRecord # Groupings are the junction mode...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/models/import.rb
Ruby
mit
19
develop
672
# frozen_string_literal: true class Import < ApplicationRecord belongs_to :document, optional: true belongs_to :dataset belongs_to :instrument before_create :set_filename after_update :cleanup_old_documents, if: :saved_change_to_state? def parsed_log JSON.parse(log,symbolize_names: true) rescue [] ...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/models/user.rb
Ruby
mit
19
develop
2,922
# frozen_string_literal: true # The User class representers a user account, controlling # authentication and authorization class User < ApplicationRecord # All Users must belong to a {UserGroup} belongs_to :group, class_name: 'UserGroup' # Users do not have their own label, so it is delegated to the {UserGroup}...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/models/question_item.rb
Ruby
mit
19
develop
1,033
# frozen_string_literal: true # The QuestionItem model directly relates to the DDI3.X QuestionItem model # # Please visit http://www.ddialliance.org/Specification/DDI-Lifecycle/3.2/XMLSchema/FieldLevelDocumentation/schemas/datacollection_xsd/elements/QuestionItem.html # # === Properties # * Label # * Literal class Que...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/models/children.rb
Ruby
mit
19
develop
1,165
# frozen_string_literal: true class Children include Enumerable extend Forwardable def_delegators :to_ary, :last def initialize(assocs) @cc_conditions = assocs[:cc_conditions] @cc_loops = assocs[:cc_loops] @cc_questions = assocs[:cc_questions] @cc_sequences = assocs[:cc_sequences] ...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/models/instruction.rb
Ruby
mit
19
develop
1,226
# frozen_string_literal: true # The Instruction is based on the InterviewerInstruction model from DDI3.X # # A Instruction has a label and represents instructive text the is delivered # with either a {QuestionGrid} or a {QuestionItem}. # # Please visit http://www.ddialliance.org/Specification/DDI-Lifecycle/3.2/XMLSche...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/models/dv_mapping.rb
Ruby
mit
19
develop
494
# frozen_string_literal: true # A representation of the database view for DV Mapping # # This cannot be used for creating, updating or deleting, but provides # a quick way to view derived variable mapping. # # === Properties # * id # * source # * variable class DvMapping < ReadOnlyRecord # Use id as a primary key ...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/models/response_domain_datetime.rb
Ruby
mit
19
develop
726
# frozen_string_literal: true # The ResponseDomainDatetime is based on the DateTimeDomain model from DDI3.X # # Please visit http://www.ddialliance.org/Specification/DDI-Lifecycle/3.2/XMLSchema/FieldLevelDocumentation/schemas/datacollection_xsd/elements/DateTimeDomain.html # # === Properties # * Datetime Type # * Labe...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/models/topic.rb
Ruby
mit
19
develop
2,291
# frozen_string_literal: true # Topic represents a single entry from a controlled vocabulary of # terms that can be applied to {CcQuestion questions} and # {Variable variables}. # # Each item can only have one Topic. # # === Properties # * Name # * Code # * Description class Topic < ApplicationRecord # Each Topic ca...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/models/code.rb
Ruby
mit
19
develop
1,573
# frozen_string_literal: true # The Code is based on the Code model from DDI3.X and serves as the join between # Categories and CodeLists # # A Code will have a value and use a Category to form a parallel to a DDI3.X Code # which belongs to a single Code List. # # Please visit http://www.ddialliance.org/Specification/...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/models/user_group.rb
Ruby
mit
19
develop
853
# frozen_string_literal: true # UserGroup represents a set of {User Users} that are interested in particular # studies # # === Properties # * group_type # * label # * study class UserGroup < ApplicationRecord # Each UserGroup can have multiple {User Users} has_many :users, inverse_of: :group, foreign_key: :group_i...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/models/document.rb
Ruby
mit
19
develop
11,970
# frozen_string_literal: true # Stores documents into the database # # Instead of a shared file store between web server nodes, Archivist # makes use of the database as files are not accessed frequently # enough to cause performance issues. # # === Properties # * filename # * content_type # * file_contents # * md5_has...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/models/grouping.rb
Ruby
mit
19
develop
395
# frozen_string_literal: true # Forms a connection between a groupable item and a group # # This is a junction model to form a many-to-many between items # and {ItemGroup groups} class Grouping < ApplicationRecord # Each grouping much belong to an {ItemGroup} belongs_to :item_group # Each grouping belongs to on...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/models/control_construct.rb
Ruby
mit
19
develop
6,057
# frozen_string_literal: true # The ControlConstruct model is used to hold the positional information # for all five of the construct models. Every construct must have one # ControlConstruct and vice-versa. # # This is the abstract class that all five of the control constructs are # eventually derived from. # # === Pr...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/models/parental_construct.rb
Ruby
mit
19
develop
2,732
# frozen_string_literal: true # The ParentalConstruct model is an abstract class that provides # the relationships for models that can have children to be able # to access them. class ParentalConstruct < ControlConstruct include LinkableParent self.abstract_class = true # All {CcCondition} children has_many :...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/models/dataset.rb
Ruby
mit
19
develop
3,653
# frozen_string_literal: true # The Dataset is based on the DataSet model from DDI3.X and is one of the # champion models that pulls together Archivist. # # # Please visit http://www.ddialliance.org/Specification/DDI-Lifecycle/3.2/XMLSchema/FieldLevelDocumentation/schemas/dataset_xsd/elements/DataSet.html # # === Prop...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/models/application_record.rb
Ruby
mit
19
develop
4,397
# frozen_string_literal: true # ApplicationRecord should not be used direct, but rather serves as the base model for # all other Archivist models. # # This model contains all the functionality that should apply to models that use a SQL # database table to store data. # # This is an abstract class. class ApplicationRec...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/models/cc_condition.rb
Ruby
mit
19
develop
1,530
# frozen_string_literal: true # The CcCondition model directly relates to the DDI3.X IfThenElse model # # Conditions are one of the five control constructs used in the questionnaire profile # and used in Archivist. This control construct provides two branches for the # instrument logic to progress. They typically repr...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/models/cc_statement.rb
Ruby
mit
19
develop
1,978
# frozen_string_literal: true # The CcStatement model directly relates to the DDI3.X Statement model # # Statements are one of the five control constructs used in the questionnaire profile # and used in Archivist. This control construct allows a one-off text string to be # placed into the structure of a questionnaire....
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/models/link.rb
Ruby
mit
19
develop
271
# frozen_string_literal: true # A junction model to join {Topic Topics} to a linkable items class Link < ApplicationRecord # The linkable item # targets can be a Variable or a CcQuestion belongs_to :target, polymorphic: true # The topic belongs_to :topic end
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/models/map.rb
Ruby
mit
19
develop
1,077
# frozen_string_literal: true # A junction model to create mappings # # Performs either Q-V mapping for DV mapping by joining # a {Variable} to either a {CcQuestion} or another # Variable. # # === Properties # * x # * y class Map < ApplicationRecord # Each mapping needs a source {CcQuestion} or {Variable} belongs_...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/models/instruments_datasets.rb
Ruby
mit
19
develop
408
# frozen_string_literal: true # This serves as a junction model to allow many-to-many # relations between {Instrument Instruments} and {Dataset Datasets} # # These connections only serve to scope Mapping work and do *not* # represent a logical link. class InstrumentsDatasets < ApplicationRecord # Joining {Instrument...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/models/category.rb
Ruby
mit
19
develop
911
# frozen_string_literal: true # The Category model directly relates to the DDI3.X Category model # # Typically multiple categories are used to create {CodeList CodeLists}. # # Please visit https://www.ddialliance.org/Specification/DDI-Lifecycle/3.2/XMLSchema/FieldLevelDocumentation/schemas/logicalproduct_xsd/elements/...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/models/cc_question.rb
Ruby
mit
19
develop
4,657
# frozen_string_literal: true # The CcQuestion model directly relates to the DDI3.X QuestionConstruct model # # Questions are one of the five control constructs used in the questionnaire profile # and used in Archivist. This control construct provides a join between a question # and the construct layer. They typically...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/models/response_domain_numeric.rb
Ruby
mit
19
develop
1,246
# frozen_string_literal: true # The ResponseDomainNumeric is based on the NumericDomain model from DDI3.X # # Please visit http://www.ddialliance.org/Specification/DDI-Lifecycle/3.2/XMLSchema/FieldLevelDocumentation/schemas/datacollection_xsd/elements/NumericDomain.html # # === Properties # * Numeric Type # * Label # ...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/models/code_list.rb
Ruby
mit
19
develop
3,804
# frozen_string_literal: true # The CodeList is based on the CodeList model from DDI3.X # # A CodeList has a label and typically pulls together multiple {Code Codes} to # create either a {QuestionGrid} axis or a {ResponseDomain}. # # Please visit http://www.ddialliance.org/Specification/DDI-Lifecycle/3.2/XMLSchema/Fie...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/models/response_unit.rb
Ruby
mit
19
develop
552
# frozen_string_literal: true # The ResponseUnit is based on the ResponseUnit model from DDI3.X # # Please visit http://www.ddialliance.org/Specification/DDI-Lifecycle/3.2/XMLSchema/FieldLevelDocumentation/schemas/datacollection_xsd/elements/ResponseUnit.html # # === Properties # * Label class ResponseUnit < Applicati...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/models/redis_record.rb
Ruby
mit
19
develop
1,093
# frozen_string_literal: true # An abstract class for all Redis-backed models to # derive from class RedisRecord class SCOPE; end # Returns a list of all items from Redis # # @return [Array] def self.all all_keys = RedisRecord.all_keys all_ids = all_keys.map { |x| x.split(':').last.to_i } all_k...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/models/response_domain_code.rb
Ruby
mit
19
develop
1,426
# frozen_string_literal: true # The ResponseDomainCode is based on the CodeDomain model from DDI3.X and serves as creates a # response domain for a {CodeList} # # Using the min_responses and max_responses properties cardinality can be recorded. # # Please visit http://www.ddialliance.org/Specification/DDI-Lifecycle/3....
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/models/read_only_record.rb
Ruby
mit
19
develop
915
# frozen_string_literal: true # An abstract class to represent a read only connection to the database # # Typically this abstract model should be used with a read only database view. class ReadOnlyRecord < ActiveRecord::Base self.abstract_class = true #attr_readonly *column_names # Returns whether the record i...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/models/cc_sequence.rb
Ruby
mit
19
develop
1,350
# frozen_string_literal: true # The CcSequence model directly relates to the DDI3.X Sequence model # # Sequences are one of the five control constructs used in the questionnaire profile # and used in Archivist. This control construct provides a single branch as a grouping # method. They typically represent a section ...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/models/rds_qs.rb
Ruby
mit
19
develop
1,174
# frozen_string_literal: true # A junction model to join response domains and questions # # Allows many-to-many connections between an instruments # {Question::Model questions} and its # {ResponseDomain response domains}. The junction also holds the order of the # response domains when a question has multiple response...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/models/question_grid.rb
Ruby
mit
19
develop
2,440
# frozen_string_literal: true # The QuestionGrid model directly relates to the DDI3.X QuestionGrid model # # Please visit http://www.ddialliance.org/Specification/DDI-Lifecycle/3.2/XMLSchema/FieldLevelDocumentation/schemas/datacollection_xsd/elements/QuestionGrid.html # # === Properties # * Label # * Literal # * Roste...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/models/variable.rb
Ruby
mit
19
develop
4,866
# frozen_string_literal: true # The Variable is based on the Variable model from DDI3.X # # Please visit http://www.ddialliance.org/Specification/DDI-Lifecycle/3.2/XMLSchema/FieldLevelDocumentation/schemas/logicalproduct_xsd/elements/Variable.html # # === Properties # * Name # * Label # * Var_type class Variable < App...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/mailers/user_mailer.rb
Ruby
mit
19
develop
225
# frozen_string_literal: true class UserMailer < ApplicationMailer default from: (ENV["FROM_ADDRESS"] || '') def welcome(user) @user = user mail(to: @user.email, subject: 'Welcome to My Awesome Site') end end
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/helpers/devise_helper.rb
Ruby
mit
19
develop
655
# frozen_string_literal: true module DeviseHelper def devise_error_messages! return '' unless devise_error_messages? messages = resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join sentence = I18n.t('errors.messages.not_saved', :count => resource.errors.count, ...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/helpers/application_helper.rb
Ruby
mit
19
develop
227
# frozen_string_literal: true module ApplicationHelper # A helper method to display text which is html_safe and has newlines removed def d(string) return unless string string.gsub(/[\r\n]/, ' ').html_safe end end
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/policies/application_policy.rb
Ruby
mit
19
develop
809
# frozen_string_literal: true class ApplicationPolicy attr_reader :user, :record def initialize(user, record) raise user.inspect raise Pundit::NotAuthorizedError, "must be logged in" unless user @user = user @record = record end def index? false end def show? scope.where(:id => r...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/policies/dataset_policy.rb
Ruby
mit
19
develop
414
# frozen_string_literal: true class DatasetPolicy < ApplicationPolicy class Scope < Scope def resolve u = user #|| User.where(api_key: params[:api_key]).where('api_key IS NOT NULL').first begin if u.group.study == '*' return scope.all else return scope.where(study:...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/policies/user_group_policy.rb
Ruby
mit
19
develop
236
# frozen_string_literal: true class UserGroupPolicy < ApplicationPolicy class Scope < Scope def resolve if user.group.study == '*' scope.all else scope.where(id: user.group) end end end end
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/policies/instrument_policy.rb
Ruby
mit
19
develop
302
# frozen_string_literal: true class InstrumentPolicy < ApplicationPolicy class Scope < ApplicationPolicy::Scope def resolve return scope.none if user.nil? if user.group.study == '*' scope.all else scope.where(study: user.group.study) end end end end
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/controllers/question_items_controller.rb
Ruby
mit
19
develop
826
# frozen_string_literal: true # A controller for the model {QuestionItem} class QuestionItemsController < QuestionController # Initialise finding object for item based actions only_set_object # Set model for automatic CRUD actions @model_class = QuestionItem # List of params that can be set and edited @p...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/controllers/response_domain_numerics_controller.rb
Ruby
mit
19
develop
539
# frozen_string_literal: true # A controller for the model {ResponseDomainNumeric} class ResponseDomainNumericsController < BasicInstrumentController # The response domain has a subtype include RdSubtypeShim # Initialise finding object for item based actions only_set_object # Specifies the name of the subt...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/controllers/datasets_controller.rb
Ruby
mit
19
develop
2,754
# frozen_string_literal: true class DatasetsController < ImportableController include Importers::Controller only_set_object { %i{ questions dv latest_document mapping_stats } } has_importers({ dv: ImportJob::DV, topicv: ImportJob::TopicV }) #skip_before_action :authenti...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/controllers/cc_sequences_controller.rb
Ruby
mit
19
develop
698
# frozen_string_literal: true # A controller for the model {CcSequence} class CcSequencesController < ConstructController # Allow topic linking include Linkable::Controller # Initialise finding object for item based actions only_set_object { %i{set_topic} } # Set model for automatic CRUD actions @model_c...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/controllers/topics_controller.rb
Ruby
mit
19
develop
1,134
# frozen_string_literal: true # A controller for the model {Topic} class TopicsController < BasicController # Initialise finding object for item based actions only_set_object { %i{ question_statistics variable_statistics } } # Set model for automatic CRUD actions @model_class = Topic # List of params that ...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/controllers/code_lists_controller.rb
Ruby
mit
19
develop
4,116
# frozen_string_literal: true class CodeListsController < BasicInstrumentController # Initialise finding object for item based actions only_set_object # Set model for automatic CRUD actions @model_class = CodeList # List of params that can be set and edited @params_list = [:label, response_domain_code_at...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/controllers/variables_controller.rb
Ruby
mit
19
develop
2,431
# frozen_string_literal: true class VariablesController < BasicController include Linkable::Controller prepend_before_action :set_dataset only_set_object { %i{set_topic add_sources remove_source} } @model_class = Variable @params_list = [:name, :label, :var_type, :dataset_id] def index @variables = ...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/controllers/fallback_controller.rb
Ruby
mit
19
develop
258
# frozen_string_literal: true class FallbackController < ApplicationController skip_before_action :authenticate_user!, :authenticate_user_from_token!, only: [:index], raise: false def index render file: 'public/index.html', layout: false end end
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/controllers/cc_conditions_controller.rb
Ruby
mit
19
develop
498
# frozen_string_literal: true # A controller for the model {CcCondition} class CcConditionsController < ConstructController # Allow topic linking include Linkable::Controller # Initialise finding object for item based actions only_set_object { %i{set_topic} } # Set model for automatic CRUD actions @model...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/controllers/question_controller.rb
Ruby
mit
19
develop
1,596
# frozen_string_literal: true class QuestionController < BasicInstrumentController def show respond_to do |f| f.json { render json: @object} f.xml { render body: @object.to_xml_fragment, content_type: 'application/xml' } end end def create if params[:fragment_xml] fragment_instanc...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/controllers/imports_controller.rb
Ruby
mit
19
develop
674
# frozen_string_literal: true class ImportsController < ApplicationController before_action :set_documents def index @imports = Import.where(import_type: ['ImportJob::Instrument','ImportJob::Dataset']).order('imports.created_at DESC') end def show @import = Import.find(params[:id]) end def docum...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/controllers/response_domain_texts_controller.rb
Ruby
mit
19
develop
392
# frozen_string_literal: true # A vanilla CRUD controller for the {ResponseDomainText} model class ResponseDomainTextsController < BasicInstrumentController # Initialise finding object for item based actions only_set_object # Set model for automatic CRUD actions @model_class = ResponseDomainText # List of ...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/controllers/application_controller.rb
Ruby
mit
19
develop
1,945
# frozen_string_literal: true # Application Controller class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. include Pundit::Authorization protect_from_forgery with: :exception skip_before_action :verify_aut...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/controllers/exports_controller.rb
Ruby
mit
19
develop
707
# frozen_string_literal: true class ExportsController < ApplicationController before_action :set_documents def index @exports = Export.where(export_type: ['ExportJob::Instrument','ExportJob::InstrumentComplete', 'ExportJob::Dataset']).order('exports.created_at DESC') end def show @export = Export.fin...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/controllers/cc_loops_controller.rb
Ruby
mit
19
develop
446
# frozen_string_literal: true # A controller for the model {CcLoop} class CcLoopsController < ConstructController # Allow topic linking include Linkable::Controller # Initialise finding object for item based actions only_set_object { %i{set_topic} } # Set model for automatic CRUD actions @model_class = C...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/controllers/instruments_controller.rb
Ruby
mit
19
develop
6,882
# frozen_string_literal: true class InstrumentsController < ImportableController include Importers::Controller include Exporters has_importers({ qvmapping: ImportJob::Mapping, topicq: ImportJob::TopicQ }) only_set_object { %i{copy clear_cache response_domains response_dom...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/controllers/user_groups_controller.rb
Ruby
mit
19
develop
563
# frozen_string_literal: true # A controller for the model {UserGroup} class UserGroupsController < BasicController # Initialise finding object for item based actions only_set_object # Set model for automatic CRUD actions @model_class = UserGroup # List of params that can be set and edited @params_list =...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/controllers/importable_controller.rb
Ruby
mit
19
develop
982
# frozen_string_literal: true class ImportableController < BasicController class << self attr_accessor :model_importer_class end def import files = params[:files].nil? ? [] : params[:files] options = {} options[:prefix] = params[:instrument_prefix] if params.has_key? :instrument_prefix optio...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/controllers/response_units_controller.rb
Ruby
mit
19
develop
365
# frozen_string_literal: true # A vanilla CRUD controller for the {ResponseUnit} model class ResponseUnitsController < BasicInstrumentController # Initialise finding object for item based actions only_set_object # Set model for automatic CRUD actions @model_class = ResponseUnit # List of params that can be...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/controllers/basic_controller.rb
Ruby
mit
19
develop
3,087
# frozen_string_literal: true # An abstract controller to handle the basic CRUD # operations class BasicController < ApplicationController # List of params that can be set and edited @params_list = [] # Defines class methods class << self # Makes model_class set and get-able attr_accessor :model_class...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/controllers/basic_instrument_controller.rb
Ruby
mit
19
develop
326
# frozen_string_literal: true class BasicInstrumentController < BasicController prepend_before_action :set_instrument private def collection @instrument.send self.class.model_class.name.tableize end def set_instrument @instrument = policy_scope(Instrument).friendly.find(params[:instrument_id]) en...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/controllers/response_domain_datetimes_controller.rb
Ruby
mit
19
develop
541
# frozen_string_literal: true # A controller for the model {ResponseDomainDatetime} class ResponseDomainDatetimesController < BasicInstrumentController # The response domain has a subtype include RdSubtypeShim # Initialise finding object for item based actions only_set_object # Specifies the name of the su...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/controllers/instruments_datasets_controller.rb
Ruby
mit
19
develop
644
# frozen_string_literal: true class InstrumentsDatasetsController < BasicController def create @instrument = Instrument.find(params[:instrument_id]) InstrumentsDatasets.create!(instrument_id: params[:instrument_id], dataset_id: params[:dataset_id]) @instrument.touch render json: Instruments::Serializ...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/controllers/cc_questions_controller.rb
Ruby
mit
19
develop
4,024
# frozen_string_literal: true class CcQuestionsController < ConstructController include Linkable::Controller only_set_object { %i{variables set_topic add_variables remove_variable} } prepend_before_action :create_response_unit, only: [:create, :update, :update_all] @model_class = CcQuestion @params_list =...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/controllers/construct_controller.rb
Ruby
mit
19
develop
2,729
# frozen_string_literal: true class ConstructController < BasicInstrumentController def create begin @object = collection.create(safe_params) if @object.valid? render :show, status: :created else render json: @object.errors.full_messages.to_sentence, status: :unprocessable_enti...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/controllers/instructions_controller.rb
Ruby
mit
19
develop
361
# frozen_string_literal: true # A vanilla CRUD controller for the {Instruction} model class InstructionsController < BasicInstrumentController # Initialise finding object for item based actions only_set_object # Set model for automatic CRUD actions @model_class = Instruction # List of params that can be se...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/controllers/main_controller.rb
Ruby
mit
19
develop
1,009
# frozen_string_literal: true class MainController < ApplicationController def index user_count ||= User.all.size user_group_count ||= UserGroup.all.size unless user_count == 0 && user_group_count == 0 render :index else render :first end end def setup begin if params.h...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/controllers/categories_controller.rb
Ruby
mit
19
develop
355
# frozen_string_literal: true # A vanilla CRUD controller for the {Category} model class CategoriesController < BasicInstrumentController # Initialise finding object for item based actions only_set_object # Set model for automatic CRUD actions @model_class = Category # List of params that can be set and ed...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/controllers/question_grids_controller.rb
Ruby
mit
19
develop
537
# frozen_string_literal: true # A controller for the model {QuestionGrid} class QuestionGridsController < QuestionController # Initialise finding object for item based actions only_set_object # Set model for automatic CRUD actions @model_class = QuestionGrid # List of params that can be set and edited @p...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/controllers/cc_statements_controller.rb
Ruby
mit
19
develop
351
# frozen_string_literal: true # A controller for the model {CcStatement} class CcStatementsController < ConstructController # Initialise finding object for item based actions only_set_object # Set model for automatic CRUD actions @model_class = CcStatement # List of params that can be set and edited @par...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/controllers/users/registrations_controller.rb
Ruby
mit
19
develop
1,686
# frozen_string_literal: true class Users::RegistrationsController < Devise::RegistrationsController clear_respond_to respond_to :json before_action :configure_permitted_parameters, if: :devise_controller? # GET /resource/sign_up # def new # super # end # POST /resource def create super do |u...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/controllers/users/confirmations_controller.rb
Ruby
mit
19
develop
2,342
# frozen_string_literal: true class Users::ConfirmationsController < Devise::ConfirmationsController # GET /resource/confirmation/new # def new # super # end # POST /resource/confirmation # def create # super # end #GET /resource/confirmation?confirmation_token=abcdef #def show # super #...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/controllers/users/admin_controller.rb
Ruby
mit
19
develop
1,633
# frozen_string_literal: true class Users::AdminController < ApplicationController def index @collection = User.all end def whoami @object = current_user render :show end def show @object = User.find safe_params end def create @object = User.new safe_params logger.debug @objec...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/controllers/users/sessions_controller.rb
Ruby
mit
19
develop
1,044
# frozen_string_literal: true class Users::SessionsController < Devise::SessionsController clear_respond_to respond_to :json # before_filter :configure_sign_in_params, only: [:create] # GET /resource/sign_in #def new # super #{UserMailer.welcome(self.resource).deliver_now} #end # POST /resource/sign_i...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/controllers/users/passwords_controller.rb
Ruby
mit
19
develop
1,952
# frozen_string_literal: true class Users::PasswordsController < Devise::PasswordsController # GET /resource/password/new # def new # super # end # POST /resource/password def create self.resource = resource_class.send_reset_password_instructions(resource_params) yield resource if block_given? ...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/controllers/instruments/imports_controller.rb
Ruby
mit
19
develop
730
# frozen_string_literal: true class Instruments::ImportsController < ApplicationController def index instrument = Instrument.friendly.find(params[:instrument_id]) @imports = instrument.imports.order(created_at: 'DESC') end def show instrument = Instrument.friendly.find(params[:instrument_id]) @i...
github
CLOSER-Cohorts/archivist
https://github.com/CLOSER-Cohorts/archivist
app/controllers/datasets/imports_controller.rb
Ruby
mit
19
develop
667
# frozen_string_literal: true class Datasets::ImportsController < ApplicationController def index dataset = Dataset.find(params[:dataset_id]) @imports = dataset.imports.order(created_at: 'DESC') end def show dataset = Dataset.find(params[:dataset_id]) @import = dataset.imports.find(params[:id]) ...
github
byroot/explicit-parameters
https://github.com/byroot/explicit-parameters
Rakefile
Ruby
mit
19
master
364
require 'bundler/gem_tasks' require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) task default: :spec namespace :spec do task :all do %w(4.2 5.0).each do |rails_version| command = %W{ BUNDLE_GEMFILE=gemfiles/Gemfile.rails-#{rails_version} rspec }.join(' ') puts comm...
github
byroot/explicit-parameters
https://github.com/byroot/explicit-parameters
explicit-parameters.gemspec
Ruby
mit
19
master
1,006
# coding: utf-8 lib = File.expand_path('../lib', __FILE__) $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'explicit_parameters/version' Gem::Specification.new do |spec| spec.name = 'explicit-parameters' spec.version = ExplicitParameters::VERSION spec.authors = ['Jean Boussie...
github
byroot/explicit-parameters
https://github.com/byroot/explicit-parameters
spec/controller_spec.rb
Ruby
mit
19
master
2,216
require 'spec_helper' class DummyController < ActionController::Base include ExplicitParameters::Controller params do accepts :page_size, Integer accepts :published, Boolean, default: false end def index render json: {value: params.page_size, type: params.page_size.class.name} end def error ...
github
byroot/explicit-parameters
https://github.com/byroot/explicit-parameters
spec/parameters_spec.rb
Ruby
mit
19
master
4,160
require 'spec_helper' RSpec.describe ExplicitParameters::Parameters do let :definition do ExplicitParameters::Parameters.define(:test) do requires :id, Integer, numericality: {greater_than: 0} accepts :name, String accepts :title, String, default: 'Untitled' end end let :parameters do ...