query
stringlengths 7
9.55k
| document
stringlengths 10
363k
| metadata
dict | negatives
sequencelengths 0
101
| negative_scores
sequencelengths 0
101
| document_score
stringlengths 3
10
| document_rank
stringclasses 102
values |
---|---|---|---|---|---|---|
Does this person currently have access to health coverage or a Health Reimbursement Arrangement that they are not enrolled in (including through another person, like a spouse or parent)? | def eligible_hash
return []
# TODO: refactor as per offered markets
@medicaid_hash[:insuranceCoverage].each do |_eligible_coverage|
next if enrolled_coverage[:insuranceMarketType] == 'NONE'
result << {
kind: Ffe::Types::BenefitsKindMapping[enrolled_coverage[:insuranceMarketType].to_sym],
status: 'is_eligible',
start_on: Date.parse('2021-01-01'), # default value
end_on: nil
}
end
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cant_be_claimed_by_other_and_below_income_requirement?\n dependent.cant_be_claimed_by_other_yes? && dependent.below_qualifying_relative_income_requirement_yes?\n end",
"def resolve_admission_visible?\n if @current_right.employee? || @current_right.external?\n then full_admission?\n elsif @current_right.team_coach? || @current_right.team_master?\n then team_admission?\n elsif @current_right.manager?\n then true\n else\n false\n end\n end",
"def status_restricted?\n (prospect || exstudent || student) &&\n !(prospect && exstudent && student)\n end",
"def person_award?\n !store_award?\n end",
"def claimable?\n # can this invite be confirmed!\n ( pending? or declined? ) and !roster.full?\n end",
"def accomplished_all_enrolled_missions?\n mission_enrollments.select{|m| !m.accomplished? }.empty?\n end",
"def can_view_patient_laboratories?\n has_role?(:public_health) || has_role?(:public_health_enroller)\n end",
"def controls_access_for?(person)\n affected_people.any? { |p| p && (p.id == person.id) } # Checking by object doesn't work for some reason, have to use ID!\n end",
"def advised?\n advisor_company_affiliations.with_access.present?\n end",
"def university_pending?\n university && line_items_pending_any?\n end",
"def can_view_patient_assessments?\n has_role?(:public_health) || has_role?(:public_health_enroller)\n end",
"def senior_member?\n\t\tsenior != true\n\tend",
"def is_owner?(person)\n return person !=nil && person.team_id == self.id && person.role == \"captain\"\n end",
"def has_honors #its gonna return true or false depdening if the object/student has honors\n if @gpa >= 3.5\n return true \n end \n return false \n end",
"def can_activate?\n self.person && self.person_match? && self.has_not_expired?\n end",
"def claimed?\n !claimant.nil?\n end",
"def ensure_is_authorized_to_view\n @is_member_of_company = (@relation == :company_admin_own_site || @relation == :company_employee || @relation == :rentog_admin_own_site)\n\n # ALLOWED\n return if @relation == :rentog_admin ||\n @relation == :rentog_admin_own_site ||\n @relation == :domain_supervisor ||\n @relation == :company_admin_own_site\n\n\n # NOT ALLOWED\n # with error message\n flash[:error] = t(\"listing_events.you_have_to_be_company_member\")\n redirect_to root\n return false\n end",
"def can_make_reserves?\n !undergraduate? && !virginia_borrower?\n end",
"def is_member_of_household?\n self.household.present?\nend",
"def child_or_classroom_assigned?\n current_user.has_child_or_classroom_assigned?\n end",
"def can_edit_patient_laboratories?\n has_role?(:public_health) || has_role?(:public_health_enroller)\n end",
"def can_edit_patient_assessments?\n has_role?(:public_health) || has_role?(:public_health_enroller)\n end",
"def guard_defeated?\n return true if @goal_was_occupied\n guard_mission.squads.each do |squad|\n return false if not squad.annihilated? and not squad.retreated_from_fortress and squad.entried\n end\n return true\n end",
"def can_use_leo?\n faculty?\n end",
"def is_owned\n !!(\n @training &&\n @training.id &&\n (\n @is_admin_logged_in || (@current_user && (@training.user_id == @current_user.id))\n )\n )\n end",
"def legal?\n @age >= LEGAL_AGE\n end",
"def junior?\n\t\tgrade == 11\n\tend",
"def owner_only_offers_reward?\n self.rewards_count == 1 && self.rewards.visible[0].sender == self.person\n end",
"def is_member_of_household_if_required?\n return true unless requires_member_of_household_test?\n\n requires_member_of_household_test? && dependent.residence_lived_with_all_year_yes?\n end",
"def can_view_patient_close_contacts?\n has_role?(:public_health) || has_role?(:public_health_enroller)\n end",
"def unclaimed?\n claimant.nil?\n end",
"def has_access\n if [email protected]_organized_by_or_admin(current_user.sk) && @contestproblem.at_most(:not_started_yet)\n render 'errors/access_refused' and return\n end\n end",
"def awaiting_disbursement?\n financial_aid_approved? && !disbursed?\n end",
"def can_enroll?\n self.self_enrollment_allowed && effective_cutoff_date >= Time.now\n end",
"def can_put_in_foundation?\n (@pile_beneath.empty? && @card_to_drop.rank.ace?) ||\n (@card_beneath && foundation_conditions?(@card_beneath))\n end",
"def can_create_patient_laboratories?\n has_role?(:public_health) || has_role?(:public_health_enroller)\n end",
"def can_create_patient_assessments?\n has_role?(:public_health) || has_role?(:public_health_enroller)\n end",
"def assigned_to_transition_aged_youth?\n volunteer_no_transition_youth_cases = object.casa_cases.pluck(:transition_aged_youth).all? false\n\n volunteer_no_transition_youth_cases ? \"No\" : \"Yes 🐛🦋\"\n end",
"def any_herbivores?\n @carnivores.count < current_occupancy\n end",
"def user_must_own_membership\n # User ID match\n @membership = @user.memberships.find_by(id: params[:id])\n return if @membership && @membership.invite_status != 'left'\n\n alert_and_redirect('Invalid membership or user has left.', login_path, :bad_request)\n end",
"def can_use_ill?\n !virginia_borrower?\n end",
"def check_house\n redirect_to houses_path, alert: \"You do not have access to this house.\" unless current_user.admin or current_user.house_id == @resident.house_id\n end",
"def claimed_for_final_exam?\n claimed_final_application?\n end",
"def is_relevant_for_educator?\n supported_schools.any? {|school| authorized_grade_levels(school.id).size > 0 }\n end",
"def obligatory?\n data[:obligatory] === true\n end",
"def requested?\n !invited?\n end",
"def can_edit_patient_close_contacts?\n has_role?(:public_health) || has_role?(:public_health_enroller)\n end",
"def can_abdicate?\n project = Project.find(self.project_id)\n participants = Participant.where(project_id: self.project_id).where.not(id: self.id)\n other_organizers = participants.any?{|f| f.can_organize? }\n if other_organizers.present?\n true\n end\n end",
"def oversight_admin?\n admin? && agencies.any? { |a| a.oversight? }\n end",
"def check_access\n permission_denied unless can_census?(year)\n end",
"def advising?(other_user)\n advisees.include?(other_user)\n end",
"def allows_clarification_response?(a_person)\n self.alive? && self.pending_clarification_requests?\n end",
"def oversight_staff?\n staff? && agencies.any? { |a| a.oversight? }\n end",
"def occupied?\n !patient.nil?\n end",
"def junior?\n grade <=6\n end",
"def _accessible_through_family? user, edit_or_view\n descendent_access, sibling_access, nephew_access =\n if edit_or_view == :edit\n [user.can_edit_descendents_resources, user.can_edit_siblings_resources || user.manager?, user.can_edit_nephews_resources]\n else\n [user.can_view_descendents_resources, user.can_view_siblings_resources || user.manager?, user.can_view_nephews_resources]\n end\n # check permission to access siblings' stuff\n return true if sibling_access and self.agent.parent_id == user.parent_id\n # check permission to access descendents' stuff\n return true if descendent_access and self.agent.descendent?(user)\n # check permission to access nephews' stuff\n return true if nephew_access and self.agent.parent_id != user.parent_id and self.agent.descendent?(user.parent)\n # default return\n false\n end",
"def announcer?(user_asking)\n employee? user_asking or owner? user_asking\n end",
"def may_interview?(*args)\n\t\t\t(self.role_names & \n\t\t\t\t['superuser','administrator','editor','interviewer']\n\t\t\t).length > 0\n\t\tend",
"def has_contributed_to\n self.contributed_non_profits\n end",
"def participated_entrance?\r\n m = math_performance_entrance && !math_performance_entrance.value.nil? && math_performance_entrance.value != \"Not Tested\"\r\n r = reading_performance_entrance && !reading_performance_entrance.value.nil? && reading_performance_entrance.value != \"Not Tested\"\r\n return (m || r)\r\n end",
"def non_student?\n !self.has_role?('student')\n end",
"def legal?\n age >= LEGAL_DRIVING_AGE\n end",
"def invited_or_captain\n self.captain || invited?\n end",
"def has_been_acquired_by_user?(user)\n current_user_profile = Profile.find_by(user_id: user.id)\n addition = Addition.find_by(profile_id: current_user_profile, story_id: self.id)\n addition != nil\n end",
"def can_create_patient_close_contacts?\n has_role?(:public_health) || has_role?(:public_health_enroller)\n end",
"def CA_only?\n course_assistant? && !instructor?\n end",
"def allows_clarification_request?(a_person=nil)\n self.alive? && \n (a_person ? self.person != a_person : false) && !self.pending_clarification_requests?\n end",
"def describe_their_ownership\n\t\tif self.forsale\n\t\t\treturn \"is selling a\" \n\t\telsif self.wanted \n\t\t\treturn \"wants to buy a\" \n else \n\t \t\treturn \"owns \" \n\t end \n\tend",
"def patient_implicit?\n @authorized_user.patients.size == 1 \n end",
"def in_decision\n return @decision_level > 0\n end",
"def owned_by?(student)\n student.id == self.student_id\n end",
"def ensure_at_williams\n forbidden \"You are not logged in as a current student or faculty/staff member.\" unless at_williams?\n end",
"def can_flag?(person)\n person != self.reviewer && person != self.reviewee\n end",
"def mandatory_supporting_evidence?\n claim.documents.any? || claim.evidence_checklist_ids.any?\n end",
"def is_supervisor?\n not under_supervision_clinics.empty?\n end",
"def disbursed?\n @disbursement_details.valid?\n end",
"def supervisor?(area)\n self.student? and return false\n self.area_ids.include?(area.id) \n end",
"def sampled_ineligible?\n sampled_persons_ineligibilities.count > 0\n end",
"def senior?\n\t\tgrade == 12\n\tend",
"def analyst?\n has_role?(:analyst)\n end",
"def acceptable_by?(acceptor)\n self.can_accept? &&\n !!acceptor && !!self.person && !!self.kase.person && acceptor == self.kase.person &&\n (self.kase.offers_reward? ? acceptor != self.kase.person : true)\n end",
"def deletable_by?(user)\n return false unless self.inviter == user\n !self.is_valid? || (self.is_valid? &&\n accepted_students.size == 1 &&\n self.assignment.group_assignment? &&\n !assignment.past_collection_date?(self.section))\n end",
"def CA_only?\n course_assistant? && (not instructor?)\n end",
"def can_view_patient?\n has_role?(:enroller) || has_role?(:public_health) || has_role?(:public_health_enroller)\n end",
"def can_enroll?(mission)\n (mission_enrollments.empty? && (mission == current_chapter.missions.first_mission)) ||\n ( (current_or_last_accomplished_mission_enrollment && current_or_last_accomplished_mission_enrollment.accomplished?) &&\n (last_accomplished_mission_enrollment.mission.next_mission == mission ) )\n end",
"def allows_clarification_response?(a_person)\n self.active? && a_person == self.person && self.pending_clarification_requests?\n end",
"def adoptant?\n role.name == \"Adoptante\" rescue \"N/A\"\n end",
"def deny\n self.granted = -1\n restaurant = Restaurant.find(self.restaurant_id)\n restaurant.mark_collaborative\n end",
"def responded_with_availability?\n !interview_availabilities.empty?\n end",
"def can_approve_member?\n\t\t[1,2].include? level\n\tend",
"def washington_state_resident?\n resident == 1 || resident == 2\n end",
"def has_access(developer)\r\n current_user.id == developer.id\r\n end",
"def informed_consent?\n consent_activity? && !reconsent? && !withdrawal? && !child_consent?\n end",
"def free?\n self.instructor.nil?\n end",
"def offer_degree?\n institution_of_higher_learning_indicator || non_college_degree_indicator\n end",
"def is_rollcall_nurse?\n has_role?(:nurse, 'rollcall')\n end",
"def claimed?\n ! @claim.nil?\n end",
"def non_quest_attribute\n !!(controller == \"inspirations\" || controller == \"family_members\" || controller == \"subscriptions\" || controller == \"disciplines\" || controller == \"priority_items\")\n end",
"def priv?\n !org?\n end",
"def check_story_ownership_for( user_training_story )\n UserTrainingStoryAccessibility.new( current_user, user_training_story ).is_owned\n end",
"def verify_access\n unless current_user.id == @organization.user_id\n flash[:warning] = \"You do not have authority to access that.\"\n redirect_to user_path(current_user.id)\n end\n end"
] | [
"0.6971547",
"0.68541104",
"0.67984533",
"0.6675985",
"0.6567603",
"0.6537876",
"0.6529181",
"0.65071994",
"0.6498856",
"0.64824724",
"0.6475954",
"0.6474943",
"0.641239",
"0.6404495",
"0.6360805",
"0.63606125",
"0.6359033",
"0.63518614",
"0.6348906",
"0.63443446",
"0.6341368",
"0.631641",
"0.6315933",
"0.63090384",
"0.6292545",
"0.6287671",
"0.62856066",
"0.62844",
"0.62774855",
"0.62689847",
"0.62640727",
"0.6244255",
"0.62397295",
"0.62310797",
"0.6219916",
"0.6214507",
"0.6214015",
"0.6200734",
"0.618681",
"0.61807853",
"0.6170743",
"0.61682725",
"0.61628896",
"0.61603224",
"0.61476266",
"0.61307395",
"0.6129898",
"0.61257625",
"0.6122066",
"0.6115083",
"0.6111465",
"0.6111271",
"0.6104921",
"0.6085351",
"0.60735524",
"0.6073406",
"0.60720277",
"0.6068611",
"0.60617894",
"0.60613847",
"0.6059364",
"0.6055805",
"0.6047164",
"0.60431266",
"0.6027294",
"0.6024024",
"0.6018541",
"0.60123146",
"0.60096425",
"0.60047525",
"0.5994147",
"0.5992618",
"0.5990582",
"0.59894514",
"0.5984438",
"0.5982912",
"0.5979569",
"0.59777874",
"0.5974961",
"0.59738743",
"0.5966807",
"0.59651774",
"0.5965089",
"0.5960477",
"0.59558463",
"0.59526044",
"0.59514177",
"0.59504884",
"0.59481287",
"0.5945984",
"0.5945075",
"0.5935309",
"0.5933759",
"0.59299874",
"0.5929484",
"0.59273976",
"0.5926176",
"0.59070104",
"0.5902549",
"0.59023035",
"0.5901517"
] | 0.0 | -1 |
Is this person currently enrolled in health coverage or getting help paying for health coverage through a Health Reimbursement Arrangement? | def enrolled_hash
result = []
@insurance_coverage_hash[:enrolledCoverages].each do |enrolled_coverage|
next if ['NONE', 'EMPLOYER_SPONSORED'].include?(enrolled_coverage[:insuranceMarketType])
if enrolled_coverage[:insuranceMarketType] == "INDIVIDUAL_INSURANCE" && @medicaid_hash && @medicaid_hash[:insuranceCoverage]
# TODO: what need to be done for EMPLOYER_SPONSORED for medicaid when "INDIVIDUAL_INSURANCE"
@medicaid_hash[:insuranceCoverage].each do |medicaid_coverage|
next unless medicaid_coverage[:insuranceMarketType]
next if ['NONE', 'EMPLOYER_SPONSORED'].include?(medicaid_coverage[:insuranceMarketType])
next unless @medicaid_hash[:enrolledInHealthCoverageIndicator]
result << {
kind: Ffe::Types::BenefitsKindMapping[medicaid_coverage[:insuranceMarketType].to_sym],
status: 'is_enrolled',
start_on: Date.parse('2021-01-01'), # default value
end_on: medicaid_coverage[:medicaidEndIndicator] ? medicaid_coverage[:medicaidEndDate] : nil
}
end
else
next unless enrolled_coverage[:insuranceMarketType]
next unless Ffe::Types::BenefitsKindMapping[enrolled_coverage[:insuranceMarketType].to_sym]
result << {
kind: Ffe::Types::BenefitsKindMapping[enrolled_coverage[:insuranceMarketType].to_sym],
status: 'is_enrolled',
start_on: Date.parse('2021-01-01'), # default value
end_on: nil
}
end
end
result
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_honors #its gonna return true or false depdening if the object/student has honors\n if @gpa >= 3.5\n return true \n end \n return false \n end",
"def is_member_of_household_if_required?\n return true unless requires_member_of_household_test?\n\n requires_member_of_household_test? && dependent.residence_lived_with_all_year_yes?\n end",
"def has_honors\n if @gpa >= 3.5\n return true\n end\n return false\n end",
"def assigned_to_transition_aged_youth?\n volunteer_no_transition_youth_cases = object.casa_cases.pluck(:transition_aged_youth).all? false\n\n volunteer_no_transition_youth_cases ? \"No\" : \"Yes 🐛🦋\"\n end",
"def experienced?(candidate)\n candidate[:years_of_experience] >= 2\nend",
"def experienced?(candidate)\n candidate[:years_of_experience] >= 2 \nend",
"def experience?(candidates)\n candidates[:years_of_experience] >= 2\nend",
"def claimed_for_final_exam?\n claimed_final_application?\n end",
"def can_make_reserves?\n !undergraduate? && !virginia_borrower?\n end",
"def experienced?(candidate)\n candidate[:years_of_experience] >= 2\nend",
"def advised?\n advisor_company_affiliations.with_access.present?\n end",
"def to_be_performed?\n self.research_billing_qty > 0\n end",
"def describe_their_ownership\n\t\tif self.forsale\n\t\t\treturn \"is selling a\" \n\t\telsif self.wanted \n\t\t\treturn \"wants to buy a\" \n else \n\t \t\treturn \"owns \" \n\t end \n\tend",
"def user_meets_criteria?(user)\n user.credits > 0\n end",
"def staff_owned_gate?\n record.check_points.where(registrar: user).map(&:gate?).reduce(:|)\n end",
"def can_afford_insurance\n return 1 if (@bet / 2) <= @bankroll\n return nil\n end",
"def university_pending?\n university && line_items_pending_any?\n end",
"def can_activate?\n self.person && self.person_match? && self.has_not_expired?\n end",
"def company?(candidate)\n info(candidate, :hourly_rate_lbl).include?(SALARY_RANGE)\n end",
"def cant_be_claimed_by_other_and_below_income_requirement?\n dependent.cant_be_claimed_by_other_yes? && dependent.below_qualifying_relative_income_requirement_yes?\n end",
"def can_buy_beer?(person)\nend",
"def awaiting_disbursement?\n financial_aid_approved? && !disbursed?\n end",
"def oversight_staff?\n staff? && agencies.any? { |a| a.oversight? }\n end",
"def experienced?(candidate) \n if((candidate[:years_of_experience] >= 2) === true)\n true\n else\n false\n end\nend",
"def can_enroll?\n self.self_enrollment_allowed && effective_cutoff_date >= Time.now\n end",
"def can_train_siege_engine?\n gold >= 200 && food >= 3 && lumber >= 60\n end",
"def person_award?\n !store_award?\n end",
"def covered?\n coverage.positive?\n end",
"def any_herbivores?\n @carnivores.count < current_occupancy\n end",
"def experienced?(candidate)\n experience = candidate[:years_of_experience]\n if experience >= 2\n true\n else\n false\n end\nend",
"def is_relevant_for_educator?\n supported_schools.any? {|school| authorized_grade_levels(school.id).size > 0 }\n end",
"def claimable?\n # can this invite be confirmed!\n ( pending? or declined? ) and !roster.full?\n end",
"def washington_state_resident?\n resident == 1 || resident == 2\n end",
"def claimed_chore?\n tasks.where(completion_status: \"pending\").count > 0\n end",
"def money_approved?\n true\n end",
"def is_member_of_household?\n self.household.present?\nend",
"def accompaniment?\n self.participant_role == 'accompanist'\n end",
"def flagged_case_responded_to_in_time_for_stats_purposes?\n responding_team_assignment_date = transitions.where(\n event: \"assign_responder\",\n ).last.created_at.to_date\n\n disclosure_approval_date = transitions.where(\n event: \"approve\",\n acting_team_id: default_clearance_team.id,\n ).last.created_at.to_date\n\n internal_deadline = @deadline_calculator.internal_deadline_for_date(\n correspondence_type, responding_team_assignment_date\n )\n\n internal_deadline >= disclosure_approval_date\n end",
"def legal?\n @age >= LEGAL_AGE\n end",
"def can_train_peasant?\n gold >= 90 && food >= 5\n end",
"def can_train_peasant?\n gold >= 90 && food >= 5\n end",
"def has_contributed_to\n self.contributed_non_profits\n end",
"def can_request_purchase?\n true # TODO: Should this be !virginia_borrower? ?\n end",
"def awarded?\n return false if declined?\n case offering.award_basis\n when \"review\" then awarded_by_review_committee?\n when \"interview\" then awarded_by_interview_committee?\n when \"final\" then awarded_by_final_committee?\n else awarded_by_review_committee?\n end\n end",
"def charged?\n compliance_data[:charge].to_f > 0.0\n end",
"def approved?\n closed? && has_met_requirement?\n end",
"def healthy?()\n\t\tif(calories < 200)\n\t\t\treturn TRUE\n\t\tend\n\tend",
"def tenure\n self.years_of_experience > 5\n end",
"def fulfilled?\n user.donations.active.count >= quantity\n end",
"def all_resident?\n lead_type == \"all_resident\"\n end",
"def healthy?\n #its healthy if @calories is less than 200\n @calories < 200\n end",
"def verify_weekend_warrior(badge_user,expected_earned_date,expected_total_warrior_badges,reason)\n warrior = badge_user.badges.reload.detect{|b|b.badge_key==Badge::WeekendWarrior && b.earned_date == expected_earned_date} \n if warrior\n if badge_user.badges.select{|b|b.badge_key==Badge::WeekendWarrior}.size == expected_total_warrior_badges\n # bacon pancaaaaaaaaakes\n return true\n else\n puts \"boo! weekend warrior badge doesn't work! (#{reason}) badges below\"\n puts y(badge_user.badges)\n return false\n end\n else\n puts \"boo! weekend warrior badge doesn't work! (#{reason}, badge not earned for #{expected_earned_date}). badges below\"\n puts y(badge_user.badges)\n return false\n end\nend",
"def eligible?\n\t\tyear = DateTime.now.year\n\t\tself.graduation_year >= year && self.graduation_year <= year + 3\n\tend",
"def donator?\n @badges.key? 'bits'\n end",
"def reg_paid?\n return true if spectator?\n Rails.cache.fetch(\"/registrant/#{id}-#{updated_at}/reg_paid\") do\n registration_cost_items = RegistrationCost.all_registration_expense_items\n paid_expense_items.any? { |item| registration_cost_items.include?(item) }\n end\n end",
"def is_rollcall_health_officer?\n has_role?(:health_officer, 'rollcall')\n end",
"def participated_entrance?\r\n m = math_performance_entrance && !math_performance_entrance.value.nil? && math_performance_entrance.value != \"Not Tested\"\r\n r = reading_performance_entrance && !reading_performance_entrance.value.nil? && reading_performance_entrance.value != \"Not Tested\"\r\n return (m || r)\r\n end",
"def owner_only_offers_reward?\n self.rewards_count == 1 && self.rewards.visible[0].sender == self.person\n end",
"def isResearcher?\n return account_type == 1\n end",
"def sampled_ineligible?\n sampled_persons_ineligibilities.count > 0\n end",
"def legal?\n age >= LEGAL_DRIVING_AGE\n end",
"def can_train_footman?\n gold >= 135 && food >= 2\n end",
"def can_train_footman?\n gold >= 135 && food >= 2\n end",
"def offer_degree?\n institution_of_higher_learning_indicator || non_college_degree_indicator\n end",
"def senior?\n\t\tgrade == 12\n\tend",
"def allows_clarification_response?(a_person)\n self.alive? && self.pending_clarification_requests?\n end",
"def awarded?\n return is_expired && !best_proposal.nil?\n end",
"def can_drink?\n @age >= 21\n end",
"def payable?\n %w(confirmed bookkept).include?(workflow_state)\n end",
"def tenure\n self.years_of_experience > 5 ? true : false\n end",
"def resolve_admission_visible?\n if @current_right.employee? || @current_right.external?\n then full_admission?\n elsif @current_right.team_coach? || @current_right.team_master?\n then team_admission?\n elsif @current_right.manager?\n then true\n else\n false\n end\n end",
"def can_rent_truck?\n !license.expired? && age >= 60 && license.to_drive_truck?\n end",
"def founder?\n @badges.key? 'founder'\n end",
"def check_on_track?\n result = 0\n \n self.accessible_students.each do |student|\n result = student.check_on_track?\n if result == 2\n # Not on-track\n break\n end\n end\n\n return result\n end",
"def is_current?\n self.charge.has_result\n end",
"def can_be_officer?\n self.degree.to_sym == :master_mason\n end",
"def inventoriable?\n inventory?\n end",
"def has_met_requirement?\n yeas >= required_votes\n end",
"def has_been_acquired_by_user?(user)\n current_user_profile = Profile.find_by(user_id: user.id)\n addition = Addition.find_by(profile_id: current_user_profile, story_id: self.id)\n addition != nil\n end",
"def announcer?(user_asking)\n employee? user_asking or owner? user_asking\n end",
"def oversight_admin?\n admin? && agencies.any? { |a| a.oversight? }\n end",
"def can_use_ill?\n !virginia_borrower?\n end",
"def is_enrolled?\n is_enrolled = free? || active? || payment.process!\n is_enrolled && (@recently_enrolled = true)\n end",
"def aquired?\n acquired?\n end",
"def strong?\n self.health >= 100\n end",
"def can_auction?(_company)\n true\n end",
"def fully_paid?\n amount_owed <= 0\n end",
"def accomplished_all_enrolled_missions?\n mission_enrollments.select{|m| !m.accomplished? }.empty?\n end",
"def is_active(effort)\n if effort.deliverable and effort.deliverable.project_phase and effort.deliverable.project_phase.project\n return effort.deliverable.project_phase.project.status == 'Active'\n end\nend",
"def mandatory_case_details?\n claim.court && claim.case_number && claim.external_user\n end",
"def profile_completed?\n return true if self.for_testing?\n !self.skills.blank? and !self.bio.blank?\n end",
"def senior?\n Date.civil(Date.today().year, 8, 1).years_ago(65) > self.naissance \n end",
"def accessioned?\n (6..8).cover?(status)\n end",
"def can_cash?\n self.capture_and_cash\n end",
"def has_related_patient?\n if registrations.count > 0\n return true\n end\n under_supervision_clinics.each do |clinic|\n clinic.registrations.each do |reg|\n return true\n end\n end\n return false\n end",
"def active?\n !self.trial_over? or self.paid?\n end",
"def donatable?\n show_donation_basket? && has_an_approved_account_set? && money_approved?\n end",
"def shortage_of?(commodity)\n shortage_of(commodity) != 0\n end",
"def student?\n return self.eduPersonAffiliation==\"student\"\n end",
"def verifiable_info\n { 'Sponsor attends': (sponsor_attends_home_parish ? Visitor.home_parish : sponsor_church) }\n end",
"def with_doctor?\n status == WITH_DOCTOR\n end"
] | [
"0.6739171",
"0.65589523",
"0.64644766",
"0.6376629",
"0.63613856",
"0.63407296",
"0.6336976",
"0.6336014",
"0.6335779",
"0.6328288",
"0.6304173",
"0.62682116",
"0.6264157",
"0.6262661",
"0.62436634",
"0.62148386",
"0.62048227",
"0.61938846",
"0.6176657",
"0.6175309",
"0.6168877",
"0.61575913",
"0.6154775",
"0.6148824",
"0.6145159",
"0.6138151",
"0.6132949",
"0.61323225",
"0.6125011",
"0.61182445",
"0.60988396",
"0.6098407",
"0.60973406",
"0.6088531",
"0.6082525",
"0.607526",
"0.6072972",
"0.60713804",
"0.6070029",
"0.60642856",
"0.60642856",
"0.60535467",
"0.6034682",
"0.6031842",
"0.6023038",
"0.60225075",
"0.60204977",
"0.60117185",
"0.60101926",
"0.6000395",
"0.59811485",
"0.5978447",
"0.59663486",
"0.59622943",
"0.5962209",
"0.59621114",
"0.596201",
"0.59522724",
"0.594734",
"0.5945118",
"0.5929925",
"0.5925464",
"0.5925464",
"0.5901975",
"0.5898792",
"0.58908564",
"0.5884875",
"0.5881578",
"0.5880762",
"0.58803374",
"0.5876512",
"0.58705187",
"0.58699083",
"0.58686656",
"0.5860114",
"0.58592397",
"0.58526",
"0.58515",
"0.58511055",
"0.58434623",
"0.58368844",
"0.583549",
"0.58327836",
"0.582957",
"0.58233637",
"0.58184016",
"0.581563",
"0.5814021",
"0.58123267",
"0.5800696",
"0.5799281",
"0.57992584",
"0.5794687",
"0.57946783",
"0.57944083",
"0.578968",
"0.5788227",
"0.5784979",
"0.57831",
"0.5782307",
"0.5782252"
] | 0.0 | -1 |
Is this person currently enrolled in health coverage or getting help paying for health coverage through a Health Reimbursement Arrangement? | def enrolled_esc_hash
return [] unless @insurance_coverage_hash[:employerSponsoredCoverageOffers]
# if insuranceMarketType is 'EMPLOYER_SPONSORED' then proceed to next step
enrolled_coverages = @insurance_coverage_hash[:enrolledCoverages].select {|ec| ec[:insuranceMarketType] == 'EMPLOYER_SPONSORED'}
return [] if enrolled_coverages.empty?
@insurance_coverage_hash[:employerSponsoredCoverageOffers].collect do |_k, esc|
next unless esc[:escEnrolledIndicator]
esc_hash = AcaEntities::Ffe::Transformers::Cv::Esc.transform(esc.merge(kind: 'employer_sponsored_insurance', :status => "is_enrolled",
phone: emp_phone(esc)))
esc_hash[:employer].delete(:employer_phone) if esc_hash[:employer] && emp_phone(esc).blank?
esc_hash
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_honors #its gonna return true or false depdening if the object/student has honors\n if @gpa >= 3.5\n return true \n end \n return false \n end",
"def is_member_of_household_if_required?\n return true unless requires_member_of_household_test?\n\n requires_member_of_household_test? && dependent.residence_lived_with_all_year_yes?\n end",
"def has_honors\n if @gpa >= 3.5\n return true\n end\n return false\n end",
"def assigned_to_transition_aged_youth?\n volunteer_no_transition_youth_cases = object.casa_cases.pluck(:transition_aged_youth).all? false\n\n volunteer_no_transition_youth_cases ? \"No\" : \"Yes 🐛🦋\"\n end",
"def experienced?(candidate)\n candidate[:years_of_experience] >= 2\nend",
"def experienced?(candidate)\n candidate[:years_of_experience] >= 2 \nend",
"def claimed_for_final_exam?\n claimed_final_application?\n end",
"def experience?(candidates)\n candidates[:years_of_experience] >= 2\nend",
"def can_make_reserves?\n !undergraduate? && !virginia_borrower?\n end",
"def experienced?(candidate)\n candidate[:years_of_experience] >= 2\nend",
"def advised?\n advisor_company_affiliations.with_access.present?\n end",
"def to_be_performed?\n self.research_billing_qty > 0\n end",
"def describe_their_ownership\n\t\tif self.forsale\n\t\t\treturn \"is selling a\" \n\t\telsif self.wanted \n\t\t\treturn \"wants to buy a\" \n else \n\t \t\treturn \"owns \" \n\t end \n\tend",
"def user_meets_criteria?(user)\n user.credits > 0\n end",
"def staff_owned_gate?\n record.check_points.where(registrar: user).map(&:gate?).reduce(:|)\n end",
"def can_afford_insurance\n return 1 if (@bet / 2) <= @bankroll\n return nil\n end",
"def university_pending?\n university && line_items_pending_any?\n end",
"def can_activate?\n self.person && self.person_match? && self.has_not_expired?\n end",
"def company?(candidate)\n info(candidate, :hourly_rate_lbl).include?(SALARY_RANGE)\n end",
"def cant_be_claimed_by_other_and_below_income_requirement?\n dependent.cant_be_claimed_by_other_yes? && dependent.below_qualifying_relative_income_requirement_yes?\n end",
"def can_buy_beer?(person)\nend",
"def awaiting_disbursement?\n financial_aid_approved? && !disbursed?\n end",
"def oversight_staff?\n staff? && agencies.any? { |a| a.oversight? }\n end",
"def experienced?(candidate) \n if((candidate[:years_of_experience] >= 2) === true)\n true\n else\n false\n end\nend",
"def can_enroll?\n self.self_enrollment_allowed && effective_cutoff_date >= Time.now\n end",
"def can_train_siege_engine?\n gold >= 200 && food >= 3 && lumber >= 60\n end",
"def covered?\n coverage.positive?\n end",
"def person_award?\n !store_award?\n end",
"def any_herbivores?\n @carnivores.count < current_occupancy\n end",
"def experienced?(candidate)\n experience = candidate[:years_of_experience]\n if experience >= 2\n true\n else\n false\n end\nend",
"def is_relevant_for_educator?\n supported_schools.any? {|school| authorized_grade_levels(school.id).size > 0 }\n end",
"def claimable?\n # can this invite be confirmed!\n ( pending? or declined? ) and !roster.full?\n end",
"def washington_state_resident?\n resident == 1 || resident == 2\n end",
"def claimed_chore?\n tasks.where(completion_status: \"pending\").count > 0\n end",
"def money_approved?\n true\n end",
"def is_member_of_household?\n self.household.present?\nend",
"def accompaniment?\n self.participant_role == 'accompanist'\n end",
"def flagged_case_responded_to_in_time_for_stats_purposes?\n responding_team_assignment_date = transitions.where(\n event: \"assign_responder\",\n ).last.created_at.to_date\n\n disclosure_approval_date = transitions.where(\n event: \"approve\",\n acting_team_id: default_clearance_team.id,\n ).last.created_at.to_date\n\n internal_deadline = @deadline_calculator.internal_deadline_for_date(\n correspondence_type, responding_team_assignment_date\n )\n\n internal_deadline >= disclosure_approval_date\n end",
"def legal?\n @age >= LEGAL_AGE\n end",
"def can_train_peasant?\n gold >= 90 && food >= 5\n end",
"def can_train_peasant?\n gold >= 90 && food >= 5\n end",
"def has_contributed_to\n self.contributed_non_profits\n end",
"def can_request_purchase?\n true # TODO: Should this be !virginia_borrower? ?\n end",
"def awarded?\n return false if declined?\n case offering.award_basis\n when \"review\" then awarded_by_review_committee?\n when \"interview\" then awarded_by_interview_committee?\n when \"final\" then awarded_by_final_committee?\n else awarded_by_review_committee?\n end\n end",
"def charged?\n compliance_data[:charge].to_f > 0.0\n end",
"def approved?\n closed? && has_met_requirement?\n end",
"def healthy?()\n\t\tif(calories < 200)\n\t\t\treturn TRUE\n\t\tend\n\tend",
"def tenure\n self.years_of_experience > 5\n end",
"def fulfilled?\n user.donations.active.count >= quantity\n end",
"def all_resident?\n lead_type == \"all_resident\"\n end",
"def healthy?\n #its healthy if @calories is less than 200\n @calories < 200\n end",
"def verify_weekend_warrior(badge_user,expected_earned_date,expected_total_warrior_badges,reason)\n warrior = badge_user.badges.reload.detect{|b|b.badge_key==Badge::WeekendWarrior && b.earned_date == expected_earned_date} \n if warrior\n if badge_user.badges.select{|b|b.badge_key==Badge::WeekendWarrior}.size == expected_total_warrior_badges\n # bacon pancaaaaaaaaakes\n return true\n else\n puts \"boo! weekend warrior badge doesn't work! (#{reason}) badges below\"\n puts y(badge_user.badges)\n return false\n end\n else\n puts \"boo! weekend warrior badge doesn't work! (#{reason}, badge not earned for #{expected_earned_date}). badges below\"\n puts y(badge_user.badges)\n return false\n end\nend",
"def eligible?\n\t\tyear = DateTime.now.year\n\t\tself.graduation_year >= year && self.graduation_year <= year + 3\n\tend",
"def reg_paid?\n return true if spectator?\n Rails.cache.fetch(\"/registrant/#{id}-#{updated_at}/reg_paid\") do\n registration_cost_items = RegistrationCost.all_registration_expense_items\n paid_expense_items.any? { |item| registration_cost_items.include?(item) }\n end\n end",
"def is_rollcall_health_officer?\n has_role?(:health_officer, 'rollcall')\n end",
"def participated_entrance?\r\n m = math_performance_entrance && !math_performance_entrance.value.nil? && math_performance_entrance.value != \"Not Tested\"\r\n r = reading_performance_entrance && !reading_performance_entrance.value.nil? && reading_performance_entrance.value != \"Not Tested\"\r\n return (m || r)\r\n end",
"def donator?\n @badges.key? 'bits'\n end",
"def owner_only_offers_reward?\n self.rewards_count == 1 && self.rewards.visible[0].sender == self.person\n end",
"def isResearcher?\n return account_type == 1\n end",
"def sampled_ineligible?\n sampled_persons_ineligibilities.count > 0\n end",
"def legal?\n age >= LEGAL_DRIVING_AGE\n end",
"def can_train_footman?\n gold >= 135 && food >= 2\n end",
"def can_train_footman?\n gold >= 135 && food >= 2\n end",
"def offer_degree?\n institution_of_higher_learning_indicator || non_college_degree_indicator\n end",
"def senior?\n\t\tgrade == 12\n\tend",
"def allows_clarification_response?(a_person)\n self.alive? && self.pending_clarification_requests?\n end",
"def awarded?\n return is_expired && !best_proposal.nil?\n end",
"def can_drink?\n @age >= 21\n end",
"def payable?\n %w(confirmed bookkept).include?(workflow_state)\n end",
"def tenure\n self.years_of_experience > 5 ? true : false\n end",
"def resolve_admission_visible?\n if @current_right.employee? || @current_right.external?\n then full_admission?\n elsif @current_right.team_coach? || @current_right.team_master?\n then team_admission?\n elsif @current_right.manager?\n then true\n else\n false\n end\n end",
"def can_rent_truck?\n !license.expired? && age >= 60 && license.to_drive_truck?\n end",
"def check_on_track?\n result = 0\n \n self.accessible_students.each do |student|\n result = student.check_on_track?\n if result == 2\n # Not on-track\n break\n end\n end\n\n return result\n end",
"def founder?\n @badges.key? 'founder'\n end",
"def is_current?\n self.charge.has_result\n end",
"def can_be_officer?\n self.degree.to_sym == :master_mason\n end",
"def inventoriable?\n inventory?\n end",
"def has_met_requirement?\n yeas >= required_votes\n end",
"def has_been_acquired_by_user?(user)\n current_user_profile = Profile.find_by(user_id: user.id)\n addition = Addition.find_by(profile_id: current_user_profile, story_id: self.id)\n addition != nil\n end",
"def announcer?(user_asking)\n employee? user_asking or owner? user_asking\n end",
"def oversight_admin?\n admin? && agencies.any? { |a| a.oversight? }\n end",
"def can_use_ill?\n !virginia_borrower?\n end",
"def is_enrolled?\n is_enrolled = free? || active? || payment.process!\n is_enrolled && (@recently_enrolled = true)\n end",
"def aquired?\n acquired?\n end",
"def strong?\n self.health >= 100\n end",
"def can_auction?(_company)\n true\n end",
"def fully_paid?\n amount_owed <= 0\n end",
"def accomplished_all_enrolled_missions?\n mission_enrollments.select{|m| !m.accomplished? }.empty?\n end",
"def is_active(effort)\n if effort.deliverable and effort.deliverable.project_phase and effort.deliverable.project_phase.project\n return effort.deliverable.project_phase.project.status == 'Active'\n end\nend",
"def mandatory_case_details?\n claim.court && claim.case_number && claim.external_user\n end",
"def profile_completed?\n return true if self.for_testing?\n !self.skills.blank? and !self.bio.blank?\n end",
"def senior?\n Date.civil(Date.today().year, 8, 1).years_ago(65) > self.naissance \n end",
"def accessioned?\n (6..8).cover?(status)\n end",
"def can_cash?\n self.capture_and_cash\n end",
"def has_related_patient?\n if registrations.count > 0\n return true\n end\n under_supervision_clinics.each do |clinic|\n clinic.registrations.each do |reg|\n return true\n end\n end\n return false\n end",
"def active?\n !self.trial_over? or self.paid?\n end",
"def donatable?\n show_donation_basket? && has_an_approved_account_set? && money_approved?\n end",
"def shortage_of?(commodity)\n shortage_of(commodity) != 0\n end",
"def student?\n return self.eduPersonAffiliation==\"student\"\n end",
"def with_doctor?\n status == WITH_DOCTOR\n end",
"def verifiable_info\n { 'Sponsor attends': (sponsor_attends_home_parish ? Visitor.home_parish : sponsor_church) }\n end"
] | [
"0.673941",
"0.65596807",
"0.64648944",
"0.63766456",
"0.6361567",
"0.6340877",
"0.6337309",
"0.6337132",
"0.6336302",
"0.63284653",
"0.63038397",
"0.62683326",
"0.6264327",
"0.6263603",
"0.6243463",
"0.6216108",
"0.6205022",
"0.61945325",
"0.61765146",
"0.6176198",
"0.6169035",
"0.6158841",
"0.61557937",
"0.6148736",
"0.61457205",
"0.6139256",
"0.6133273",
"0.6132762",
"0.61255395",
"0.61184967",
"0.60995156",
"0.6099097",
"0.6097428",
"0.6089004",
"0.60824764",
"0.607615",
"0.60722935",
"0.6070731",
"0.607015",
"0.606527",
"0.606527",
"0.6053705",
"0.6035466",
"0.60319334",
"0.6023782",
"0.60235375",
"0.60218436",
"0.60118234",
"0.6011197",
"0.6000212",
"0.5982391",
"0.5978694",
"0.5966999",
"0.59626573",
"0.59625983",
"0.5962428",
"0.5962146",
"0.59522253",
"0.5947146",
"0.59456617",
"0.5930079",
"0.5926712",
"0.5926712",
"0.59026337",
"0.58981913",
"0.58911574",
"0.5885644",
"0.58823246",
"0.588147",
"0.5880351",
"0.5876642",
"0.5871542",
"0.58702976",
"0.58701986",
"0.58616143",
"0.5859925",
"0.58539474",
"0.5852749",
"0.5852189",
"0.5843417",
"0.5838133",
"0.58362997",
"0.58328444",
"0.5830966",
"0.5824484",
"0.581871",
"0.58165234",
"0.58143854",
"0.5812706",
"0.580089",
"0.5799727",
"0.57988226",
"0.57962215",
"0.57961917",
"0.5795193",
"0.57907313",
"0.5788736",
"0.57867485",
"0.5782832",
"0.57825637",
"0.57808185"
] | 0.0 | -1 |
This is from attachment_fu_fixtures. | def attachment_model?(fixture)
# HABTM join tables generate unnamed fixtures; skip them since they
# will not include attachments anyway (you'd use HM:T)
return false if fixture.nil? || fixture.class_name.nil?
klass =
if fixture.respond_to?(:model_class)
fixture.model_class
elsif fixture.class_name.is_a?(Class)
fixture.class_name
else
Object.const_get(fixture.class_name)
#fixture.class_name.camelize.constantize
end
# resolve real class if we have an STI model
if k = fixture[klass.inheritance_column]
klass = k.camelize.constantize
end
fixture_mising_file_for = fixture.to_hash.keys.grep(/file_for_/).empty?
(klass && !fixture_mising_file_for) ? klass : nil
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attachment\n raise NotImplementedError, 'Please implement me. :('\n end",
"def attachment; end",
"def test_attachments_added\n Attachment.storage_path = TestHelper.files_path + '/files'\n issue = Issue.find(1)\n email = HelpdeskMailer.\n email_to_supportclient(\n issue,\n {:recipient => \"[email protected]\",\n :journal => Journal.find(3),\n :text => 'text'\n }).deliver\n assert !ActionMailer::Base.deliveries.empty?\n mail = ActionMailer::Base.deliveries.last\n assert_not_nil mail\n attachments_length = mail.attachments.length\n assert_equal 1, attachments_length\n filename = mail.attachments[0].filename\n assert_equal \"source.rb\", filename\n content = mail.attachments[0].body.to_s\n original_content = File.open(\n Attachment.find(\n Journal.find(3).details.first.prop_key).diskfile).read\n assert_equal original_content, content\n end",
"def test_issue_attachements\n log_user('jsmith', 'jsmith')\n\n post 'issues/edit/1',\n :notes => 'Some notes',\n :attachments => {'1' => {'file' => test_uploaded_file('testfile.txt', 'text/plain'), 'description' => 'This is an attachment'}}\n assert_redirected_to \"issues/show/1\"\n \n # make sure attachment was saved\n attachment = Issue.find(1).attachments.find_by_filename(\"testfile.txt\")\n assert_kind_of Attachment, attachment\n assert_equal Issue.find(1), attachment.container\n assert_equal 'This is an attachment', attachment.description\n # verify the size of the attachment stored in db\n #assert_equal file_data_1.length, attachment.filesize\n # verify that the attachment was written to disk\n assert File.exist?(attachment.diskfile)\n \n # remove the attachments\n Issue.find(1).attachments.each(&:destroy)\n assert_equal 0, Issue.find(1).attachments.length\n end",
"def reflect_on_attachment(attachment); end",
"def insert_fixture_with_attachment(fixture, table_name)\n if klass = attachment_model?(fixture)\n\n fixture = fixture.to_hash\n full_path = fixture.delete('attachment_file')\n mime_type = fixture.delete('content_type') || guess_mime_type(full_path) || 'image/png'\n assert_attachment_exists(full_path)\n\n require 'action_controller/test_process'\n attachment = klass.new\n attachment.uploaded_data = ActionController::TestUploadedFile.new(full_path, mime_type)\n attachment.instance_variable_get(:@attributes)['id'] = fixture['id'] #pwn id\n attachment.valid? #trigger validation for the callbacks\n without_transaction do\n attachment.send(:after_process_attachment) #manually call after_save callback\n end\n\n fixture = Fixture.new(attachment.attributes.update(fixture), klass)\n end\n insert_fixture_without_attachment(fixture, table_name)\n end",
"def attached_file\n=begin # TODO: remove when :json resolved\n file || (file_attacher.load_data(file_data) if file_data.present?)\n=end\n file || file_attacher_load\n end",
"def attachment\n participant.attachment(rubric_item.filename)\n end",
"def load_attachment_fu\n require 'scribd_fu/attachment_fu'\n include ScribdFu::AttachmentFu::InstanceMethods\n end",
"def attachment_file_name\n \"image\"\n end",
"def external_file_attributes; end",
"def attachment(*)\n super\n after :save, :save_attachments\n before :destroy, :destroy_attachments\n end",
"def mock_attachment(opts = {})\n lopts = {id: 27,\n io_stream: nil,\n io_stream_file_name: 'mostly_empty.csv',\n io_stream_content_type: 'Test Content Type',\n io_stream_file_size: 1,\n io_stream_updated_at: DateTime.now,\n revision_number: 1,\n attachable_type: nil, attachable_id: nil, version: 1}\n @attachment = mock_model(ImportableAttachments::Attachment, lopts.merge(opts))\n @attachment.stubs(:io_stream).returns(mock_io_stream(:attach_to => @attachment))\n FileUtils.cp @spec_file, @attachment.io_stream.path\n @attachment\n end",
"def file_uploads; end",
"def test_should_handle_files\n # make reference to four images.\n lightsabers_upload = substruct_fixture_file(\"lightsabers.jpg\")\n lightsaber_blue_upload = substruct_fixture_file(\"lightsaber_blue.jpg\")\n lightsaber_green_upload = substruct_fixture_file(\"lightsaber_green.jpg\")\n lightsaber_red_upload = substruct_fixture_file(\"lightsaber_red.jpg\")\n\n # Load them all and save.\n lightsabers_image = Image.new\n lightsabers_image.upload = lightsabers_upload\n assert lightsabers_image.save\n \n lightsaber_blue_image = Image.new\n lightsaber_blue_image.upload = lightsaber_blue_upload\n assert lightsaber_blue_image.save\n \n lightsaber_green_image = Image.new\n lightsaber_green_image.upload = lightsaber_green_upload\n assert lightsaber_green_image.save\n \n lightsaber_red_image = Image.new\n lightsaber_red_image.upload = lightsaber_red_upload\n assert lightsaber_red_image.save\n \n image_files = []\n # Assert that all those files exists.\n assert File.exist?( (image_files << lightsabers_image.upload.path).last )\n for thumb in lightsabers_image.upload.styles.collect{|x| x[1]}\n assert File.exist?( (image_files << thumb.attachment.path).last )\n end\n \n assert File.exist?(lightsaber_blue_image.upload.path)\n for thumb in lightsaber_blue_image.upload.styles.collect{|x| x[1]}\n assert File.exist?( (image_files << thumb.attachment.path).last )\n end\n\n assert File.exist?(lightsaber_green_image.upload.path)\n for thumb in lightsaber_green_image.upload.styles.collect{|x| x[1]}\n assert File.exist?( (image_files << thumb.attachment.path).last )\n end\n\n assert File.exist?(lightsaber_red_image.upload.path)\n for thumb in lightsaber_red_image.upload.styles.collect{|x| x[1]}\n assert File.exist?( (image_files << thumb.attachment.path).last )\n end\n\n # We must erase the records and its files by hand, just calling destroy.\n assert lightsabers_image.destroy\n assert lightsaber_blue_image.destroy\n assert lightsaber_green_image.destroy\n assert lightsaber_red_image.destroy \n \n # See if the files really were erased. (This test is probably redundant, as file-deletion is handled by Paperclip)\n for image_file in image_files do\n assert !File.exist?(image_file)\n end\n end",
"def file_field; end",
"def fixture_png_upload path=\"rails.png\"\n # creates a mock uploaded file (for testing file upload...),\n # will search for files in the ./test/fixtures directory\n fixture_file_upload(path, \"image/png\")\n end",
"def test_should_create_image_from_uploaded_file\n assert_created Asset do\n attachment = upload_file :filename => '../fixtures/images/rails.png'\n assert !attachment.new_record?, attachment.errors.full_messages.join(\"\\n\")\n assert !attachment.db_file.new_record? if attachment.respond_to?(:db_file)\n assert attachment.image?\n assert !attachment.size.zero?\n assert_equal 50, attachment.width\n assert_equal 64, attachment.height\n end\n end",
"def attachments\n adding_field do |f|\n view_context.render \"questions/attachment_editor\", :f => f, :question => question\n end\n end",
"def attach; end",
"def attachments\n @attachments ||= []\n end",
"def sample_file(filename='sample_file.txt')\n File.new(\"test/fixtures/attachment-files/#{filename}\")\n end",
"def attachment_data\n @attachment_url && @client.get_file(@attachment_url)\n end",
"def internal_file_attributes; end",
"def attachment\n record.public_send(\"#{name}_file\")\n end",
"def attached?(filename); end",
"def attachment(fld, klass, sizes = nil)\r\n self.__send__(:instance_variable_set, \"@#{fld}_sizes\".to_sym, sizes)\r\n \r\n # def photo\r\n define_method(fld) do\r\n return nil unless self.id\r\n klass.first(:attachable_type => self.class.name, :attachable_id => self.id, :field_name => fld, :order => [:position.asc])\r\n end\r\n \r\n # def photos\r\n define_method(fld.to_s.pluralize) do\r\n if self.id\r\n klass.all(:attachable_type => self.class, :attachable_id => self.id, :field_name => fld, :order => [:position.asc])\r\n else\r\n []\r\n end\r\n end\r\n \r\n # def klass.photo_sizes\r\n singleton_class = class << self; self; end\r\n singleton_class.send(:define_method, \"#{fld}_sizes\") do\r\n instance_variable_get(\"@#{fld}_sizes\".to_sym) || DEFAULT_SIZES\r\n end\r\n \r\n # def new_photo=\r\n define_method(\"new_#{fld}=\") do |upload|\r\n photo = klass.create( :attachable_type => self.class,\r\n :attachable_id => self.id,\r\n :filename => upload.original_filename.split(/[\\\\\\/]/)[-1],\r\n :content_type => upload.content_type,\r\n :size => upload.size,\r\n :field_name => fld\r\n )\r\n \r\n if photo.filename[-4..-1].downcase == \".pdf\"\r\n photo.update(:filename => photo.filename[0..-4] + \"png\")\r\n end\r\n \r\n @attachments_needing_id ||= Hash.new{ |hash, key| hash[key] = Array.new }\r\n @attachments_needing_id[fld.to_s] << photo unless self.id\r\n \r\n self.class.__send__(\"#{fld}_sizes\").each do |style|\r\n dir_path = \"public/assets/#{photo.id}/#{style[0]}\"\r\n FileUtils.mkdir_p(dir_path)\r\n img = Magick::Image.read(upload.path)\r\n img[0].\r\n resize_matte(style[1], style[2], style[3]).\r\n write(photo.path(style[0]))\r\n end\r\n end\r\n \r\n # def replace_photo=\r\n # Deletes any current photos and adds a new photo\r\n define_method(\"replace_#{fld}=\") do |upload|\r\n return false if upload.blank?\r\n self.__send__(fld.to_s.pluralize).each {|del_photo| del_photo.destroy}\r\n self.__send__(\"new_#{fld}=\", upload)\r\n end\r\n \r\n # def destroy_photo_attachments=\r\n # \r\n # Delete all attachments of attachment class. Called by before :destroy\r\n define_method(\"destroy_#{fld}_attachments\") do\r\n self.__send__(fld.to_s.pluralize).destroy!\r\n end\r\n \r\n self.before(:destroy, \"destroy_#{fld}_attachments\".to_sym)\r\n end",
"def upload_attachment(safebox, attachment)\n if attachment.guid.nil?\n result = @json_client.upload_file(safebox.upload_url, attachment.file_path || attachment.file, attachment.content_type, attachment.filename)\n attachment.guid = result[\"temporary_document\"][\"document_guid\"]\n end\n attachment\n end",
"def did_attach() end",
"def temporary_attachments\n self.class.read_inheritable_attribute(:temporary_attachments) || []\n end",
"def attachments\n eco_documents = self.eco_documents.reverse\n eco_documents.delete_if { |d| d.specification? }.reverse\n end",
"def file_fixture_path(filename)\n File.expand_path(File.dirname(__FILE__) + \"/../fixtures/Upload/#{ filename }\")\nend",
"def upload_attachment(documentname,locale,fullpath, mime_type,attachmentname)\n thisfile = File.new(\"#{fullpath}\")\n # Create the hash of the file for comparison, since we don't want to update the attachment if it hasn't changed\n this_attachment_hash = Digest::SHA256.file(thisfile).hexdigest\n dupe = Topic.by_topicname_and_locale.key([\"#{documentname}\",\"#{locale}\"]).count > 0\n unless dupe\n then\n# begin\n @thisattachment = Topic.create!({\n :locale => locale,\n :attachment_hash => this_attachment_hash,\n :topicname => documentname})\n @thisattachment.create_attachment(\n :name => attachmentname,\n :file => thisfile,\n :content_type => mime_type)\n # rescue\n # STDERR.puts \"Could not create a new topic with lang/locale: #{locale} and filename #{documentname}\"\n # end\n else\n # Hopefully we don't need the first, but just in case\n @thisattachment = Topic.by_topicname_and_locale.key([\"#{documentname}\",\"#{locale}\"]).first\n begin\n @thisattachment.update_attributes(\n :version_removed => CURRENT_PATCH,\n :api_version_removed => CURRENT_API_VERSION,\n :locale => locale,\n :topicname => documentname)\n rescue\n STDERR.puts \"Could not update attributes on lang/locale: #{locale} and filename #{documentname}\"\n end\n # If there is already an attachment with this filename, check to see if it needs to be updated\n if (@thisattachment.has_attachment?(attachmentname))\n then\n # Only update it if it's changed\n couch_attachment_hash = Digest::SHA256.hexdigest(@thisattachment.read_attachment(attachmentname))\n if (couch_attachment_hash != this_attachment_hash)\n then\n begin\n @thisattachment.update_attributes({:attachment_hash => this_attachment_hash})\n @thisattachment.update_attachment({\n :name => attachmentname,\n :file => thisfile,\n :content_type => mime_type})\n rescue\n STDERR.puts \"Could not update attributes, or the attachment on lang/locale: #{locale} and filename #{documentname}, for #{attachmentname}\"\n end\n end\n else\n begin\n @thisattachment.update_attributes({:attachment_hash => this_attachment_hash})\n @thisattachment.create_attachment({\n :name => attachmentname,\n :file => thisfile,\n :content_type => mime_type})\n rescue\n STDERR.puts \"Could not update attributes on lang/locale: #{locale} and filename #{documentname}\"\n end\n end\n end\n begin\n # This may not be required, but the couchrest::model doc isn't clear if create_attachment saves the document or not.\n @thisattachment.save\n rescue\n STDERR.puts \"Could not save filename #{documentname}\"\n end\n thisfile.close\nend",
"def add_attachments(obj)\n if !email.attachments.nil? && email.attachments.size > 0\n email.attachments.each do |attachment|\n obj.attachments << Attachment.create(:container => obj,\n :file => attachment.decoded,\n :filename => attachment.filename,\n :author => user,\n :content_type => attachment.mime_type)\n end\n end\n end",
"def test_should_associate_images\n a_product = items(:lightsaber)\n assert_equal a_product.images.count, 3\n\n lightsabers_image = substruct_fixture_file(\"lightsabers.jpg\")\n\n an_image = Image.new\n an_image.upload = lightsabers_image\n assert an_image.save\n \n a_product.images << an_image\n assert_equal a_product.images.count, 4\n \n # We must erase the record and its files by hand, just calling destroy.\n assert an_image.destroy\n end",
"def new_attachments_params\n attachments_params(\n [{ title: \"Title 1\" }, { file: file_fixture(\"whitepaper.pdf\") }],\n [{ title: \"Title 2\" }, { file: file_fixture(\"simple.pdf\") }],\n )\n end",
"def test_attach_with_fe\n\n @dashboard.register '.+', Ruote::StorageParticipant\n\n pdef = Ruote.define do\n set 'v:message' => 'hello world'\n bravo\n end\n\n wfid = @dashboard.launch(pdef, 'message' => 'hello planet')\n r = @dashboard.wait_for('dispatched')\n\n adef = Ruote.define do\n echo '${v:message}'\n echo '${f:message}'\n end\n\n fe = @dashboard.ps(wfid).expressions.last\n fei = @dashboard.attach(fe.to_h, adef)\n r = @dashboard.wait_for('ceased')\n\n ps = @dashboard.ps(wfid)\n\n assert_equal '0_1_0', fei.expid\n assert_equal wfid, fei.wfid\n\n assert_equal \"hello world\\nhello planet\", @tracer.to_s\n\n assert_equal 0, ps.errors.size\n assert_equal 2, ps.expressions.size\n assert_equal 1, ps.stored_workitems.size\n end",
"def has_attachments\n preneed_attachments.present?\n end",
"def filename\n find_attachment\n end",
"def attachment_with_upload_method\n if method == \"upload\" && !attachment?\n errors.add(:base, \"Please make sure to upload your prescription.\")\n end\n end",
"def test_should_handle_files\n lightsabers_image = fixture_file_upload(\"/files/lightsabers.jpg\", 'image/jpeg')\n\n an_image = Image.new\n an_image.uploaded_data = lightsabers_image\n assert an_image.save\n \n # Assert that the files exists.\n assert File.exist?(an_image.full_filename)\n for thumb in an_image.thumbnails\n assert File.exist?(thumb.full_filename)\n end\n \n # We must erase the record and its files by hand, just calling destroy.\n assert an_image.destroy\n # See if the files really was erased.\n for thumb in an_image.thumbnails\n assert !File.exist?(thumb.full_filename)\n end\n assert !File.exist?(an_image.full_filename)\n end",
"def attachment\n @attachment\n end",
"def save_attached_files; end",
"def save_attached_files; end",
"def attachment_definitions\n read_inheritable_attribute(:attachment_definitions)\n end",
"def email_with_attachment(recipient_a, subject_a, user_a, org_fname, file_attach)\n @recipients = recipient_a\n @subject = subject_a\n @from = \"[email protected]\"\n @reply_to = \"[email protected]\"\n @body = subject_a \n part :content_type => \"multipart/mixed\" do |p|\n p.attachment :content_type => \"csv/text\", \n# :body => File.open(\"public/whale_batch.csv\", \"rb\") { |f| f.read },\n :body => file_attach,\n :filename => org_fname,\n :transfer_encoding => \"base64\",\n :charset => \"utf-8\"\n end \n end",
"def cloned_attachments(preset)\n attachments = preset.attachments\n\n return if attachments.blank?\n\n attachments.each do |attachment|\n cloned_attachment = ScenarioAttachment.new(\n attachment.attributes.except('id', 'scenario_id')\n )\n\n cloned_attachment.file.attach(attachment.file.blob)\n\n yield cloned_attachment\n end\n end",
"def fullname\n \"#{self.attached_file_identifier}\"\n end",
"def file_fixture(filename)\n filename = File.join(File.dirname(__FILE__), 'fixtures', filename.to_s)\n File.open(filename).read\nend",
"def attachment_field(object_name, method, object:, **options)\n options[:data] ||= {}\n\n definition = object.send(:\"#{method}_attachment_definition\")\n options[:accept] = definition.accept\n\n if options[:direct]\n url = PmacsRefile.attachment_upload_url(object, method, host: options[:host], prefix: options[:prefix])\n options[:data].merge!(direct: true, as: \"file\", url: url)\n end\n\n if options[:presigned] and definition.cache.respond_to?(:presign)\n url = PmacsRefile.attachment_presign_url(object, method, host: options[:host], prefix: options[:prefix])\n options[:data].merge!(direct: true, presigned: true, url: url)\n end\n\n options[:data][:reference] = SecureRandom.hex\n options[:include_hidden] = false\n\n attachment_cache_field(object_name, method, object: object, **options) + file_field(object_name, method, options)\n end",
"def fixture_path\n File.expand_path('../fixtures', __FILE__)\nend",
"def attachment_representation\n parametrized_attachment.tap do |attachment|\n %w(filename target_directory max_file_size).each do |attr|\n attachment.public_send(\"#{attr}=\", public_send(attr))\n end\n attachment.readonly!\n end\n end",
"def build_attachment(key, feature)\n attachment = {}\n attachment[:color] = get_attachment_color(feature)\n attachment[:title] = feature[\"title\"]\n attachment[:title_link] = \"http://caniuse.com/#search=#{key}\"\n attachment[:text] = feature[\"description\"]\n attachment[:fallback] = \"#{feature[\"title\"]} (http://caniuse.com/#feat=#{key}): #{feature[\"description\"]}\"\n attachment[:mrkdwn_in] = [\"text\", \"title\", \"fields\", \"fallback\"]\n fields = []\n fields << build_browser_support_field(feature)\n fields << build_support_field(feature)\n fields << build_spec_field(feature)\n fields << build_resources_field(feature)\n attachment[:fields] = fields\n attachment\nend",
"def attachment( document_id, attachment_id )\n new( :id => document_id ).attachments.get!( attachment_id )\n end",
"def test_should_associate_images\n a_product = items(:lightsaber)\n assert_equal a_product.images.count, 3\n\n lightsabers_image = fixture_file_upload(\"/files/lightsabers.jpg\", 'image/jpeg')\n\n an_image = Image.new\n an_image.uploaded_data = lightsabers_image\n assert an_image.save\n \n a_product.images << an_image\n assert_equal a_product.images.count, 4\n \n # We must erase the record and its files by hand, just calling destroy.\n assert an_image.destroy\n end",
"def test_should_associate_images\n a_product = items(:lightsaber)\n assert_equal a_product.images.count, 3\n\n lightsabers_image = fixture_file_upload(\"/files/lightsabers.jpg\", 'image/jpeg')\n\n an_image = Image.new\n an_image.uploaded_data = lightsabers_image\n assert an_image.save\n \n a_product.images << an_image\n assert_equal a_product.images.count, 4\n \n # We must erase the record and its files by hand, just calling destroy.\n assert an_image.destroy\n end",
"def test_should_handle_files\n # make reference to four images.\n lightsabers_upload = fixture_file_upload(\"/files/lightsabers.jpg\", 'image/jpeg')\n lightsaber_blue_upload = fixture_file_upload(\"/files/lightsaber_blue.jpg\", 'image/jpeg')\n lightsaber_green_upload = fixture_file_upload(\"/files/lightsaber_green.jpg\", 'image/jpeg')\n lightsaber_red_upload = fixture_file_upload(\"/files/lightsaber_red.jpg\", 'image/jpeg')\n\n # Load them all and save.\n lightsabers_image = Image.new\n lightsabers_image.uploaded_data = lightsabers_upload\n assert lightsabers_image.save\n \n lightsaber_blue_image = Image.new\n lightsaber_blue_image.uploaded_data = lightsaber_blue_upload\n assert lightsaber_blue_image.save\n \n lightsaber_green_image = Image.new\n lightsaber_green_image.uploaded_data = lightsaber_green_upload\n assert lightsaber_green_image.save\n \n lightsaber_red_image = Image.new\n lightsaber_red_image.uploaded_data = lightsaber_red_upload\n assert lightsaber_red_image.save\n \n # Assert that all those files exists.\n assert File.exist?(lightsabers_image.full_filename)\n for thumb in lightsabers_image.thumbnails\n assert File.exist?(thumb.full_filename)\n end\n \n assert File.exist?(lightsaber_blue_image.full_filename)\n for thumb in lightsaber_blue_image.thumbnails\n assert File.exist?(thumb.full_filename)\n end\n\n assert File.exist?(lightsaber_green_image.full_filename)\n for thumb in lightsaber_green_image.thumbnails\n assert File.exist?(thumb.full_filename)\n end\n\n assert File.exist?(lightsaber_red_image.full_filename)\n for thumb in lightsaber_red_image.thumbnails\n assert File.exist?(thumb.full_filename)\n end\n\n # We must erase the records and its files by hand, just calling destroy.\n assert lightsabers_image.destroy\n assert lightsaber_blue_image.destroy\n assert lightsaber_green_image.destroy\n assert lightsaber_red_image.destroy\n \n \n # See if the files really was erased.\n for thumb in lightsabers_image.thumbnails\n assert !File.exist?(thumb.full_filename)\n end\n assert !File.exist?(lightsabers_image.full_filename)\n\n for thumb in lightsaber_blue_image.thumbnails\n assert !File.exist?(thumb.full_filename)\n end\n assert !File.exist?(lightsaber_blue_image.full_filename)\n\n for thumb in lightsaber_green_image.thumbnails\n assert !File.exist?(thumb.full_filename)\n end\n assert !File.exist?(lightsaber_green_image.full_filename)\n\n for thumb in lightsaber_red_image.thumbnails\n assert !File.exist?(thumb.full_filename)\n end\n assert !File.exist?(lightsaber_red_image.full_filename)\n end",
"def before_step context\n dropbox_files = context[:media_object].collection.dropbox.all\n context[:dropbox_files] = dropbox_files\n context\n end",
"def test_attach_file\n# post :upload, \"note\"=>{\"title\"=>\"my note\"}, \"courseid\"=>\"806350272748085520\",\n# \"processor\"=>{\"id\"=>\"1000001\"}, \"success\"=>\"/course/806350272748085520/ACMA-320/share_notes\", \n# \"upload_id\"=>\"1169944954\", \n# \"failure\"=>\"/course/806350272748085520/ACMA-320/share_notes\"\n \n post :upload, \"noteid\"=>\"816717565610925385\", \"processor\"=>{\"id\"=>\"1000001\"}\n \n end",
"def create_attachment\n @artifact_answer = ArtifactAnswer.find(params[:id])\n if params[:file]\n params[:file].each do |attachment|\n @artifact_answer.attachments.create(attachment_file: attachment, :company_id => current_company.id)\n @attachment_error = @artifact_answer.attachments.last.errors[:\"file_size_exceeds\"][0] if @artifact_answer.attachments.last.errors.present?\n end\n end\n @attachments = @artifact_answer.attachments\n end",
"def initialize(question, attachment)\n @question = question\n @attachment = attachment\n end",
"def test_listchunk_attributes\n\t\t\n\tend",
"def upload_fixture_file filename, content_type\n ActionDispatch::Http::UploadedFile.new({\n :filename => filename,\n :content_type => content_type,\n :tempfile => File.new(\"#{Rails.root}/test/fixtures/files/\" + filename)\n })\n end",
"def upload_attachment(upload, current_user_guid, stix_id, references = {}, options = {})\n self.init_uploaded_file(upload, 'Attachment', current_user_guid, options)\n XmlSaving.store_original_file(@file_path, self.guid, @input_category, @mime_type, stix_id, 'Indicator')\n\n # Set the reference attributes that were set by the user in the UI if set.\n self.reference_title = references[:ref_title]\n self.reference_number = references[:ref_num]\n self.reference_link = references[:ref_link]\n \n # Save the attribute that it was an attachment\n self.is_attachment = true\n \n self.status = ActionStatus::SUCCEEDED\n self.save\n first_oi = self.original_inputs.active.first\n\n indicator=first_oi.indicator\n audit = Audit.basic\n audit.message = \"File #{self.file_name} attached.\"\n\n # add the reference info into the audits if existant.\n audit.message += \"\\nReference Title: #{self.reference_title}, added.\" unless self.reference_title.nil? || self.reference_title.blank?\n audit.message += \"\\nReference Number: #{self.reference_number}, added.\" unless self.reference_number.nil? || self.reference_number.blank?\n audit.message += \"\\nReference Link: #{self.reference_link}, added.\" unless self.reference_link.nil? || self.reference_link.blank?\n\n audit.item = indicator\n audit.audit_type = :attachment\n indicator.audits << audit\n indicator.updated_at = Time.now\n indicator.save\n IngestUtilities.cleanup(self, @file_path)\n rescue StandardError => e\n IngestUtilities.add_error(self, \"#{e.backtrace.first}: #{e.message} (#{e.class})\")\n ExceptionLogger.debug(\"exception: #{e}, message: #{e.message}, backtrace: #{e.backtrace}\")\n self.save\n IngestUtilities.cleanup(self, @file_path)\n end",
"def multipart; end",
"def attachment?\n !!find_attachment\n end",
"def file_attachment_params\n params.require(:file_attachment).permit(:attachment, :attachment_name)\n end",
"def attachments\n model_documents = self.model_documents.reverse\n end",
"def filename\n attachment.original_filename\n end",
"def revert_fixtures_identify\n def Fixtures.identify(label)\n label.to_s.hash.abs\n end\n end",
"def should_validate_attachment_presence name\n klass = self.name.gsub(/Test$/, '').constantize\n context \"Class #{klass.name} validating presence on #{name}\" do\n context \"when the assignment is nil\" do\n setup do\n @attachment = klass.new.send(name)\n @attachment.assign(nil)\n end\n should \"have a :presence validation error\" do\n assert @attachment.errors[:presence]\n end\n end\n context \"when the assignment is valid\" do\n setup do\n @file = StringIO.new(\".\")\n @attachment = klass.new.send(name)\n @attachment.assign(@file)\n end\n should \"have a :presence validation error\" do\n assert ! @attachment.errors[:presence]\n end\n end\n end\n end",
"def file_attacher_load(data = nil)\n data ||= file_data\n data &&= make_file_record(data)\n file_attacher.load_data(data) if data.present?\n end",
"def attached(attclass)\n attachments[attclass.to_s.classify]\n end",
"def test_file1\n File.new(\"#{TEST_DIR}/fixtures/uploads/test_file1.txt\")\n end",
"def attachment_content_type_for(joint)\n case File.extname(joint).downcase\n when '.txt' then 'text/plain'\n when '.html' then 'plain/html'\n when '.pdf' then 'application/octet-stream' #'application/x-pdf'\n when '.jpg', '.jpeg' then 'image/jpeg'\n when '.png' then 'image/png'\n when '.gif' then 'image/gif'\n when '.doc', '.docx' then 'application/msword'\n else \n 'plain/text' # par défaut\n end\nend",
"def find_upload(post, attachment_id)\n sql = \"SELECT a.attachmentid attachment_id, a.userid user_id, a.filename filename,\n a.filedata filedata, a.extension extension\n FROM #{TABLE_PREFIX}attachment a\n WHERE a.attachmentid = #{attachment_id}\"\n results = mysql_query(sql)\n\n unless row = results.first\n puts \"Couldn't find attachment record for attachment_id = #{attachment_id} post.id = #{post.id}\"\n return\n end\n\n attachment_id = row[0]\n user_id = row[1]\n db_filename = row[2]\n\n filename = File.join(ATTACHMENT_DIR, user_id.to_s.split('').join('/'), \"#{attachment_id}.attach\")\n real_filename = db_filename\n real_filename.prepend SecureRandom.hex if real_filename[0] == '.'\n\n unless File.exists?(filename)\n puts \"Attachment file #{row.inspect} doesn't exist\"\n return nil\n end\n\n upload = create_upload(post.user.id, filename, real_filename)\n\n if upload.nil? || !upload.valid?\n puts \"Upload not valid :(\"\n puts upload.errors.inspect if upload\n return\n end\n\n [upload, real_filename]\n rescue Mysql2::Error => e\n puts \"SQL Error\"\n puts e.message\n puts sql\n end",
"def attachments\n load_object\n load_attachments\n render layout: false\n end",
"def my_file_upload(filename)\n ActionDispatch::Http::UploadedFile.new({\n filename: filename,\n content_type: 'application/octet-stream',\n tempfile: File.new(\"#{Rails.root}/test/fixtures/#{filename}\")\n })\n end",
"def attachments\n @attachments ||= Attachments.new( self )\n end",
"def multipart?; end",
"def upload_shipped\n end",
"def attachment(name, raise_errors: false, destroy: true, **options)\n super(name, raise_errors: raise_errors, **options)\n\n attacher = :\"#{name}_attacher\"\n property :\"#{name}_id\", type: String\n\n validate do\n if send(attacher).present?\n send(attacher).valid?\n send(attacher).errors.each do |error|\n errors.add(name, error)\n end\n end\n end\n\n define_method \"#{name}=\" do |value|\n send(\"#{name}_id_will_change!\")\n super(value)\n end\n\n define_method \"remove_#{name}=\" do |value|\n send(\"#{name}_id_will_change!\")\n super(value)\n end\n\n define_method \"remote_#{name}_url=\" do |value|\n send(\"#{name}_id_will_change!\")\n super(value)\n end\n\n before_save do\n send(attacher).store!\n end\n\n after_destroy do\n send(attacher).delete! if destroy\n end\n end",
"def multipart_upload\n end",
"def attachments\n @attachments ||= ActiveStorage::Attachment.where(record_gid: record.to_gid.to_s, name: name)\n end",
"def files; end",
"def files; end",
"def files; end",
"def files; end",
"def files; end",
"def files; end",
"def validates_attachment_size name, options = {}\n attachment_definitions[name][:validations] << lambda do |attachment, instance|\n unless options[:greater_than].nil?\n options[:in] = (options[:greater_than]..(1/0)) # 1/0 => Infinity\n end\n unless options[:less_than].nil?\n options[:in] = (0..options[:less_than])\n end\n unless attachment.original_filename.blank? || options[:in].include?(instance[:\"#{name}_file_size\"].to_i)\n min = options[:in].first\n max = options[:in].last\n \n if options[:message]\n\n# PB NOT_SAFE sensitive to page deletions\nradiant validates_each radiant/lib/plugins/active_record_extensions/lib/active_record_extensions.rb:6\n configuration = args.extract_options!\n validates_each(args, configuration) do |record, attr_name, value|\n page = Page.find_by_path(value)\n record.errors.add(attr_name, :page_not_found, :default => configuration[:message]) if page.nil? || page.is_a?(FileNotFoundPage)\n end\n end\n \n def self.object_id_attr(symbol, klass)\n module_eval %{\n def #{symbol}\n if @#{symbol}.nil? or (@old_#{symbol}_id != #{symbol}_id)\n @old_#{symbol}_id = #{symbol}_id\n klass = #{klass}.descendants.find { |d| d.#{symbol}_name == #{symbol}_id }\n klass ||= #{klass}\n @#{symbol} = klass.new\n else\n @#{symbol}\n end\n end\n }\n end\n \nend\n\n\n# PB SAFE just does format validation\ncanvas-lms validates_each canvas-lms/lib/custom_validations.rb:24\n def validates_as_url(*fields)\n validates_each(fields, :allow_nil => true) do |record, attr, value|\n begin\n value, uri = CanvasHttp.validate_url(value)\n\n record.send(\"#{attr}=\", value)\n rescue URI::InvalidURIError, ArgumentError\n record.errors.add attr, 'is not a valid URL'\n end\n end\n end\n\n def validates_as_readonly(*fields)\n validates_each(fields) do |record, attr, value|\n if !record.new_record? && record.send(\"#{attr}_changed?\")\n record.errors.add attr, \"cannot be changed\"\n end\n end\n end\n\n # alloweds is a hash of old_value => [new_value]\n # on update, only those transitions will be allowed for the given field\n def validates_allowed_transitions(field, alloweds)\n validates_each(field) do |record, attr, value|\n if !record.new_record? && record.send(\"#{attr}_changed?\")\n\n# PB SAFE just does field validation\ncanvas-lms validates_each canvas-lms/lib/custom_validations.rb:36\n def validates_as_readonly(*fields)\n validates_each(fields) do |record, attr, value|\n if !record.new_record? && record.send(\"#{attr}_changed?\")\n record.errors.add attr, \"cannot be changed\"\n end\n end\n end\n\n # alloweds is a hash of old_value => [new_value]\n # on update, only those transitions will be allowed for the given field\n def validates_allowed_transitions(field, alloweds)\n validates_each(field) do |record, attr, value|\n if !record.new_record? && record.send(\"#{attr}_changed?\")\n old_val = record.send(\"#{attr}_was\")\n unless alloweds.any? { |old,news| old_val == old && Array(news).include?(value) }\n record.errors.add attr, \"cannot be changed to that value\"\n end\n end\n end\n end\n end\n\n def self.included(klass)\n if klass < ActiveRecord::Base\n klass.send :extend, ClassMethods\n\n# PB SAFE just does field validation\ncanvas-lms validates_each canvas-lms/lib/custom_validations.rb:46\n def validates_allowed_transitions(field, alloweds)\n validates_each(field) do |record, attr, value|\n if !record.new_record? && record.send(\"#{attr}_changed?\")\n old_val = record.send(\"#{attr}_was\")\n unless alloweds.any? { |old,news| old_val == old && Array(news).include?(value) }\n record.errors.add attr, \"cannot be changed to that value\"\n end\n end\n end\n end\n end\n\n def self.included(klass)\n if klass < ActiveRecord::Base\n klass.send :extend, ClassMethods\n end\n end\n\nend\n\n\n# PB SAFE \ncanvas-lms validates_each canvas-lms/app/models/pseudonym.rb:42\n # allows us to validate the user and pseudonym together, before saving either\n validates_each :user_id do |record, attr, value|\n record.errors.add(attr, \"blank?\") unless value || record.user\n end\n before_validation :validate_unique_id\n before_destroy :retire_channels\n\n before_save :set_password_changed\n before_validation :infer_defaults, :verify_unique_sis_user_id\n after_save :update_passwords_on_related_pseudonyms\n after_save :update_account_associations_if_account_changed\n has_a_broadcast_policy\n\n alias_method :context, :account\n\n include StickySisFields\n are_sis_sticky :unique_id\n\n validates_each :password, {:if => :require_password?}, &Canvas::PasswordPolicy.method(\"validate\")\n acts_as_authentic do |config|\n config.validates_format_of_login_field_options = {:with => /\\A\\w[\\w\\.\\+\\-_'@ =]*\\z/}\n config.login_field :unique_id\n config.validations_scope = [:account_id, :workflow_state]\n config.perishable_token_valid_for = 30.minutes\n config.validates_length_of_login_field_options = {:within => 1..MAX_UNIQUE_ID_LENGTH}\n\n# PB SAFE just checking format\ncanvas-lms validates_each canvas-lms/app/models/pseudonym.rb:59\n\n validates_each :password, {:if => :require_password?}, &Canvas::PasswordPolicy.method(\"validate\")\n acts_as_authentic do |config|\n config.validates_format_of_login_field_options = {:with => /\\A\\w[\\w\\.\\+\\-_'@ =]*\\z/}\n config.login_field :unique_id\n config.validations_scope = [:account_id, :workflow_state]\n config.perishable_token_valid_for = 30.minutes\n config.validates_length_of_login_field_options = {:within => 1..MAX_UNIQUE_ID_LENGTH}\n config.validates_uniqueness_of_login_field_options = { :case_sensitive => false, :scope => [:account_id, :workflow_state], :if => lambda { |p| (p.unique_id_changed? || p.workflow_state_changed?) && p.active? } }\n end\n\n attr_writer :require_password\n def require_password?\n # Change from auth_logic: don't require a password just because new_record?\n # is true. just check if the pw has changed or crypted_password_field is\n # blank.\n password_changed? || (send(crypted_password_field).blank? && sis_ssha.blank?) || @require_password\n end\n\n acts_as_list :scope => :user\n\n set_broadcast_policy do |p|\n p.dispatch :confirm_registration\n p.to { self.communication_channel || self.user.communication_channel }\n p.whenever { |record|\n\n# PB SAFE just checking format\ncanvas-lms validates_each canvas-lms/app/models/wiki_page.rb:154\n\n validates_each :title do |record, attr, value|\n if value.blank?\n record.errors.add(attr, t('errors.blank_title', \"Title can't be blank\"))\n elsif value.size > maximum_string_length\n record.errors.add(attr, t('errors.title_too_long', \"Title can't exceed %{max_characters} characters\", :max_characters => maximum_string_length))\n elsif value.to_url.blank?\n record.errors.add(attr, t('errors.title_characters', \"Title must contain at least one letter or number\")) # it's a bit more liberal than this, but let's not complicate things\n end\n end\n\n has_a_broadcast_policy\n simply_versioned :exclude => SIMPLY_VERSIONED_EXCLUDE_FIELDS, :when => Proc.new { |wp|\n # :user_id and :updated_at do not merit creating a version, but should be saved\n exclude_fields = [:user_id, :updated_at].concat(SIMPLY_VERSIONED_EXCLUDE_FIELDS).map(&:to_s)\n (wp.changes.keys.map(&:to_s) - exclude_fields).present?\n }\n after_save :remove_changed_flag\n\n\n workflow do\n state :active do\n event :unpublish, :transitions_to => :unpublished\n end\n state :unpublished do\n\n# PB NOT_SAFE race if/when name may already be in use!\ncanvas-lms validates_each canvas-lms/app/models/group_category.rb:41\n\n validates_each :name do |record, attr, value|\n next unless record.name_changed? || value.blank?\n max_len = maximum_string_length\n max_len -= record.create_group_count.to_s.length + 1 if record.create_group_count\n\n if value.blank?\n record.errors.add attr, t(:name_required, \"Name is required\")\n elsif GroupCategory.protected_name_for_context?(value, record.context)\n record.errors.add attr, t(:name_reserved, \"%{name} is a reserved name.\", name: value)\n elsif record.context && record.context.group_categories.other_than(record).where(name: value).exists?\n record.errors.add attr, t(:name_unavailable, \"%{name} is already in use.\", name: value)\n elsif value.length > max_len\n record.errors.add attr, t(:name_too_long, \"Enter a shorter category name\")\n end\n end\n\n validates_each :group_limit do |record, attr, value|\n next if value.nil?\n record.errors.add attr, t(:greater_than_1, \"Must be greater than 1\") unless value.to_i > 1\n end\n\n validates_each :self_signup do |record, attr, value|\n next unless record.self_signup_changed?\n next if value.blank?\n\n\n# PB SAFE value checking\ncanvas-lms validates_each canvas-lms/app/models/group_category.rb:57\n\n validates_each :group_limit do |record, attr, value|\n next if value.nil?\n record.errors.add attr, t(:greater_than_1, \"Must be greater than 1\") unless value.to_i > 1\n end\n\n validates_each :self_signup do |record, attr, value|\n next unless record.self_signup_changed?\n next if value.blank?\n if !record.context.is_a?(Course) && record != communities_for(record.context)\n record.errors.add :enable_self_signup, t(:self_signup_for_courses, \"Self-signup may only be enabled for course groups or communities\")\n elsif value != 'enabled' && value != 'restricted'\n record.errors.add attr, t(:invalid_self_signup, \"Self-signup needs to be one of the following values: %{values}\", values: \"null, 'enabled', 'restricted'\")\n elsif record.restricted_self_signup? && record.has_heterogenous_group?\n record.errors.add :restrict_self_signup, t(:cant_restrict_self_signup, \"Can't restrict self-signup while a mixed-section group exists in the category\")\n end\n end\n\n validates_each :auto_leader do |record, attr, value|\n next unless record.auto_leader_changed?\n next if value.blank?\n unless ['first', 'random'].include?(value)\n record.errors.add attr, t(:invalid_auto_leader, \"AutoLeader type needs to be one of the following values: %{values}\", values: \"null, 'first', 'random'\")\n end\n end\n\n# PB NOT_SAFE conditional evaluation depends on current DB state; e.g., group_categories\ncanvas-lms validates_each canvas-lms/app/models/group_category.rb:62\n\n validates_each :self_signup do |record, attr, value|\n next unless record.self_signup_changed?\n next if value.blank?\n if !record.context.is_a?(Course) && record != communities_for(record.context)\n record.errors.add :enable_self_signup, t(:self_signup_for_courses, \"Self-signup may only be enabled for course groups or communities\")\n elsif value != 'enabled' && value != 'restricted'\n record.errors.add attr, t(:invalid_self_signup, \"Self-signup needs to be one of the following values: %{values}\", values: \"null, 'enabled', 'restricted'\")\n elsif record.restricted_self_signup? && record.has_heterogenous_group?\n record.errors.add :restrict_self_signup, t(:cant_restrict_self_signup, \"Can't restrict self-signup while a mixed-section group exists in the category\")\n end\n end\n\n validates_each :auto_leader do |record, attr, value|\n next unless record.auto_leader_changed?\n next if value.blank?\n unless ['first', 'random'].include?(value)\n record.errors.add attr, t(:invalid_auto_leader, \"AutoLeader type needs to be one of the following values: %{values}\", values: \"null, 'first', 'random'\")\n end\n end\n\n scope :active, -> { where(:deleted_at => nil) }\n\n scope :other_than, lambda { |cat| where(\"group_categories.id<>?\", cat.id || 0) }\n\n\n# PB SAFE -- if we don't hit the 'next's, we just do a local format check\ncanvas-lms validates_each canvas-lms/app/models/group_category.rb:74\n\n validates_each :auto_leader do |record, attr, value|\n next unless record.auto_leader_changed?\n next if value.blank?\n unless ['first', 'random'].include?(value)\n record.errors.add attr, t(:invalid_auto_leader, \"AutoLeader type needs to be one of the following values: %{values}\", values: \"null, 'first', 'random'\")\n end\n end\n\n scope :active, -> { where(:deleted_at => nil) }\n\n scope :other_than, lambda { |cat| where(\"group_categories.id<>?\", cat.id || 0) }\n\n class << self\n def protected_name_for_context?(name, context)\n protected_names_for_context(context).include?(name)\n end\n\n def student_organized_for(context)\n role_category_for_context('student_organized', context)\n end\n\n def imported_for(context)\n role_category_for_context('imported', context)\n end\n\n# PB NOT_SAFE ; may delete the appointment_group.contexts concurrently\ncanvas-lms validates_each canvas-lms/app/models/appointment_group_sub_context.rb:28\n\n validates_each :sub_context do |record, attr, value|\n if record.participant_type == 'User'\n record.errors.add(attr, t('errors.invalid_course_section', 'Invalid course section')) unless value.blank? || value.is_a?(CourseSection) && record.appointment_group.contexts.any? { |c| c == value.course }\n else\n record.errors.add(attr, t('errors.missing_group_category', 'Group appointments must have a group category')) unless value.present? && value.is_a?(GroupCategory)\n record.errors.add(attr, t('errors.invalid_group_category', 'Invalid group category')) unless value && record.appointment_group.contexts.any? { |c| c == value.context }\n end\n end\n\n def participant_type\n sub_context_type == 'GroupCategory' ? 'Group' : 'User'\n end\nend\n\n\n# PB NOT_SAFE e.g., enrollment limit might change depending on concurrent saves!\ncanvas-lms validates_each canvas-lms/app/models/user.rb:279\n validates_acceptance_of :terms_of_use, :if => :require_acceptance_of_terms, :allow_nil => false\n validates_each :self_enrollment_code do |record, attr, value|\n next unless record.require_self_enrollment_code\n if value.blank?\n record.errors.add(attr, \"blank\")\n elsif record.validation_root_account\n course = record.validation_root_account.self_enrollment_course_for(value)\n record.self_enrollment_course = course\n if course && course.self_enrollment_enabled?\n record.errors.add(attr, \"full\") if course.self_enrollment_limit_met?\n record.errors.add(attr, \"already_enrolled\") if course.user_is_student?(record, :include_future => true)\n else\n record.errors.add(attr, \"invalid\")\n end\n else\n record.errors.add(attr, \"account_required\")\n end\n end\n\n before_save :assign_uuid\n before_save :update_avatar_image\n before_save :record_acceptance_of_terms\n after_save :update_account_associations_if_necessary\n after_save :self_enroll_if_necessary\n\n\n# PB NOT_SAFE ; duplicates, etc.\ncanvas-lms validates_each canvas-lms/app/models/calendar_event.rb:70\n\n validates_each :child_event_data do |record, attr, events|\n next unless events || Canvas::Plugin.value_to_boolean(record.remove_child_events)\n events ||= []\n events = events.values if events.is_a?(Hash)\n next record.errors.add(attr, t('errors.no_updating_user', \"Can't update child events unless an updating_user is set\")) if events.present? && !record.updating_user\n context_codes = events.map{ |e| e[:context_code] }\n next record.errors.add(attr, t('errors.duplicate_child_event_contexts', \"Duplicate child event contexts\")) if context_codes != context_codes.uniq\n contexts = find_all_by_asset_string(context_codes).group_by(&:asset_string)\n context_codes.each do |code|\n context = contexts[code] && contexts[code][0]\n next if context && context.grants_right?(record.updating_user, :manage_calendar) && context.try(:parent_event_context) == record.context\n break record.errors.add(attr, t('errors.invalid_child_event_context', \"Invalid child event context\"))\n end\n record.child_event_contexts = contexts\n record.child_event_data = events\n end\n\n def replace_child_events\n return unless @child_event_data\n current_events = child_events.group_by{ |e| e[:context_code] }\n @child_event_data.each do |data|\n if event = current_events.delete(data[:context_code]) and event = event[0]\n event.updating_user = @updating_user\n event.update_attributes(:start_at => data[:start_at], :end_at => data[:end_at])\n\n# PB SAFE ; simple formatting\ncanvas-lms validates_each canvas-lms/app/models/group.rb:87\n\n validates_each :name do |record, attr, value|\n if value.blank?\n record.errors.add attr, t(:name_required, \"Name is required\")\n elsif value.length > maximum_string_length\n record.errors.add attr, t(:name_too_long, \"Enter a shorter group name\")\n end\n end\n\n validates_each :max_membership do |record, attr, value|\n next if value.nil?\n record.errors.add attr, t(:greater_than_1, \"Must be greater than 1\") unless value.to_i > 1\n end\n\n alias_method :participating_users_association, :participating_users\n\n def participating_users(user_ids = nil)\n user_ids ?\n participating_users_association.where(:id =>user_ids) :\n participating_users_association\n end\n\n def wiki_with_create\n Wiki.wiki_for_context(self)\n end\n\n# PB SAFE ; formatting\ncanvas-lms validates_each canvas-lms/app/models/group.rb:95\n\n validates_each :max_membership do |record, attr, value|\n next if value.nil?\n record.errors.add attr, t(:greater_than_1, \"Must be greater than 1\") unless value.to_i > 1\n end\n\n alias_method :participating_users_association, :participating_users\n\n def participating_users(user_ids = nil)\n user_ids ?\n participating_users_association.where(:id =>user_ids) :\n participating_users_association\n end\n\n def wiki_with_create\n Wiki.wiki_for_context(self)\n end\n alias_method_chain :wiki, :create\n\n def auto_accept?\n self.group_category &&\n self.group_category.allows_multiple_memberships? &&\n self.join_level == 'parent_context_auto_join'\n end\n\n\n# PB NOT_SAFE concurrent overlapping appointments\ncanvas-lms validates_each canvas-lms/app/models/appointment_group.rb:65\n validates_inclusion_of :participant_visibility, :in => ['private', 'protected'] # presumably we might add public if we decide to show appointments on the public calendar feed\n validates_each :appointments do |record, attr, value|\n next unless record.new_appointments.present? || record.validation_event_override\n appointments = value\n if record.validation_event_override\n appointments = appointments.select{ |a| a.new_record? || a.id != record.validation_event_override.id} << record.validation_event_override\n end\n appointments.sort_by(&:start_at).inject(nil) do |prev, appointment|\n record.errors.add(attr, t('errors.invalid_end_at', \"Appointment end time precedes start time\")) if appointment.end_at < appointment.start_at\n record.errors.add(attr, t('errors.overlapping_appointments', \"Appointments overlap\")) if prev && appointment.start_at < prev.end_at\n appointment\n end\n end\n\n def validate\n if appointment_group_contexts.empty?\n errors.add :appointment_group_contexts,\n t('errors.needs_contexts', 'Must have at least one context')\n end\n end\n\n attr_accessible :title, :description, :location_name, :location_address, :contexts, :sub_context_codes, :participants_per_appointment, :min_appointments_per_participant, :max_appointments_per_participant, :new_appointments, :participant_visibility, :cancel_reason\n\n # when creating/updating an appointment, you can give it a list of (new)\n # appointment times. these will be added to the existing appointment times\n\n\n# PB SAFE ; Resources set by conf\nrefinerycms FileSizeValidator refinerycms/resources/lib/refinery/resources/validators/file_size_validator.rb:3\n module Validators\n class FileSizeValidator < ActiveModel::Validator\n\n def validate(record)\n file = record.file\n\n if file.respond_to?(:length) && file.length > Resources.max_file_size\n record.errors[:file] << ::I18n.t('too_big',\n :scope => 'activerecord.errors.models.refinery/resource',\n :size => Resources.max_file_size)\n end\n end\n\n end\n end\n end\nend\n\n\n# PB SAFE: changed? => whether this actual image has changed.\nrefinerycms ImageUpdateValidator refinerycms/images/lib/refinery/images/validators/image_update_validator.rb:3\n module Validators\n class ImageUpdateValidator < ActiveModel::Validator\n\n def validate(record)\n if record.image_name_changed?\n record.errors.add :image_name,\n ::I18n.t(\"different_file_name\",\n :scope => \"activerecord.errors.models.refinery/image\")\n end\n end\n\n end\n end\n end\nend\n\n\n# PB SAFE static configuration\nrefinerycms ImageSizeValidator refinerycms/images/lib/refinery/images/validators/image_size_validator.rb:3\n module Validators\n class ImageSizeValidator < ActiveModel::Validator\n\n def validate(record)\n image = record.image\n\n if image.respond_to?(:length) && image.length > Images.max_image_size\n record.errors[:image] << ::I18n.t('too_big',\n :scope => 'activerecord.errors.models.refinery/image',\n :size => Images.max_image_size)\n end\n end\n\n end\n end\n end\nend\n\n\n# PB SAFE formatting only\nskyline validates_each skyline/vendor/weppos/url_validation.rb:57\n\n validates_each(attr_names, configuration) do |record, attr_name, value|\n begin\n uri = URI.parse(value)\n\n if !allowed_schemes.include?(uri.scheme)\n raise(URI::InvalidURIError)\n end\n\n if [:scheme, :host].any? { |i| uri.send(i).blank? }\n raise(URI::InvalidURIError)\n end\n\n rescue URI::InvalidURIError => e\n record.errors.add(attr_name, :invalid, :default => configuration[:message], :value => value)\n next\n end\n end\n end\nend\n\n# PB SAFE formatting\ncommunityengine validates_each communityengine/app/models/invitation.rb:12\n\n validates_each :email_addresses do |record, attr, email_addresses |\n invalid_emails = []\n email_addresses = email_addresses || ''\n emails = email_addresses.split(\",\").collect{|email| email.strip }.uniq\n \n emails.each{ |email|\n unless email =~ /[\\w._%-]+@[\\w.-]+.[a-zA-Z]{2,4}/\n invalid_emails << email\n end \n }\n unless invalid_emails.empty?\n record.errors.add(:email_addresses, \" included invalid addresses: <ul>\"+invalid_emails.collect{|email| '<li>'+email+'</li>' }.join+\"</ul>\")\n record.email_addresses = (emails - invalid_emails).join(', ')\n end\n end\n\n attr_accessible :email_addresses, :message\n\n def send_invite\n emails = self.email_addresses.split(\",\").collect{|email| email.strip }.uniq \n emails.each{|email|\n UserNotifier.signup_invitation(email, self.user, self.message).deliver\n }\n end\n\n# PB SAFE formatting\ncommunityengine validates_each communityengine/app/models/friendship.rb:14\n validate :cannot_request_if_daily_limit_reached\n validates_each :user_id do |record, attr, value|\n record.errors.add attr, 'can not be same as friend' if record.user_id.eql?(record.friend_id)\n end\n \n # named scopes\n scope :accepted, lambda {\n #hack: prevents FriendshipStatus[:accepted] from getting called before the friendship_status records are in the db (only matters in testing ENV)\n {:conditions => [\"friendship_status_id = ?\", FriendshipStatus[:accepted].id] }\n }\n \n def cannot_request_if_daily_limit_reached \n if new_record? && initiator && user.has_reached_daily_friend_request_limit?\n errors.add(:base, \"Sorry, you'll have to wait a little while before requesting any more friendships.\") \n end\n end \n \n before_validation(:on => :create){:set_pending}\n after_save :notify_requester, :if => Proc.new{|fr| fr.accepted? && fr.initiator }\n\n attr_protected :friendship_status_id\n \n def reverse\n Friendship.find(:first, :conditions => ['user_id = ? and friend_id = ?', self.friend_id, self.user_id])\n end\n\n# PB SAFE ; validates against external URLs, but fine from DB \npublify validates_each publify/lib/spam_protection.rb:103\n\n validates_each(attr_names, configuration) do |record, attr_name, value|\n record.errors.add(attr_name, configuration[:message]) if SpamProtection.new(record.blog).is_spam?(value)\n end\n end\n end\n end\nend",
"def test_associations\n\t\tassert check_associations(DocImage)\n\tend",
"def attachments_metadata\n @attachments_metadata || {}\n end",
"def attachment_urls\n @list.when_list do\n result = call(\"Lists\", \"get_attachment_collection\", \"listName\" => @list.id, \"listItemID\" => @id)\n return result.xpath(\"//sp:Attachment\", NS).map { |att| att.text }\n end\n @list.when_document_library { raise TypeError, \"a document library does not support attachments\" }\n @list.raise_on_unknown_type\n end",
"def client_side_multipart_upload\n end",
"def load_attachment!\n if !attachment.present?\n fail \"[UsageReports] All reports should have an attachment.\"\n end\n\n\t\tcontent = load_attachment\n attachment = AttachmentParser.new(content)\n\t\tuuid = attachment.uuid\n\n if uuid.blank?\n fail \"[UsageReports] Report-uid missing from attachment.\"\n end\n if uuid != uid\n fail \"[UsageReports] Report-uid does not match attachment uid.\"\n end\n\n # set report.compressed from the attachment.\n if compressed_report? || resolution_report?\n report_subset = report_subsets.order(\"created_at ASC\").first\n attachment_subset = attachment.search_subsets(checksum: report_subset.checksum)\n fail \"[UsageReports] cannot find gzip for a report-subset\" if attachment_subset.blank?\n\n self.compressed = ::Base64.strict_decode64(attachment.subset_checksum(subset: attachment_subset))\n elsif normal_report?\n Rails.logger.info \"[UsageReports] normal report\"\n else\n fail \"[UsageReports] Unrecognizable report type.\"\n end\n\n # Set report datasets from attachment.\n self.report_datasets = attachment.datasets\n\n # Loop over report_subsets setting report_subset gzip from the attachment.\n self.report_subsets.each do | report_subset |\n attachment_subset = attachment.search_subsets(checksum: report_subset.checksum)\n\n if attachment_subset.blank?\n fail \"[UsageReports] Cannot find report-subset gzip field.\"\n end\n\n report_subset.compressed = ::Base64.strict_decode64(attachment.subset_gzip(subset: attachment_subset))\n end\n\n # Return the same thing as load_attachment, but the report object has been changed.\n content\n end",
"def attachments\n parts.attachments\n end",
"def attachment(name, options = {})\n options.symbolize_keys!\n\n name = name.to_sym\n\n chunk_size = options.fetch(:chunk_size, DEFAULT_CHUNK_SIZE).to_i\n chunk_size = DEFAULT_CHUNK_SIZE if chunk_size.zero?\n\n self.attachment_names = attachment_names.dup.add(name)\n\n after_save :save_attachments\n before_save :nullify_nil_attachments_attributes\n after_save :destroy_nil_attachments\n before_destroy :destroy_all_attachments\n\n key :\"#{name}_id\", ObjectId\n key :\"#{name}_name\", String\n key :\"#{name}_size\", Integer\n key :\"#{name}_type\", String\n\n # Allow for optional, custom chunk size, in bytes.\n # Default size is 255k, set above.\n key :\"#{name}_chunk_size\", Integer, default: chunk_size\n\n validates_presence_of(name) if options[:required]\n\n attachment_accessor_module.module_eval <<-EOC\n def #{name}\n @#{name} ||= AttachmentProxy.new(self, :#{name})\n end\n\n def #{name}?\n !nil_attachments.has_key?(:#{name}) && send(:#{name}_id?)\n end\n\n def #{name}=(file)\n if file.nil?\n nil_attachments[:#{name}] = send(\"#{name}_id\")\n assigned_attachments.delete(:#{name})\n else\n send(\"#{name}_id=\", BSON::ObjectId.new) if send(\"#{name}_id\").nil?\n send(\"#{name}_name=\", Associo::FileHelpers.name(file))\n send(\"#{name}_size=\", Associo::FileHelpers.size(file))\n send(\"#{name}_type=\", Associo::FileHelpers.type(file))\n assigned_attachments[:#{name}] = file\n nil_attachments.delete(:#{name})\n end\n end\n EOC\n end",
"def uploaded_fixture(fname, content_type=\"application/octet-stream\", filename=nil)\n path = File.join(FILE_FIXTURES_PATH, fname)\n filename ||= File.basename(path)\n # simulate small files with StringIO\n if File.stat(path).size < 1024\n # smaller then 1 Ko\n t = StringIO.new(File.read(path))\n else\n t = Tempfile.new(fname)\n FileUtils.copy_file(path, t.path)\n end\n uploaded_file(t, filename, content_type)\n end",
"def test_ListBugAttachments\n\t\tcolName = 'attachments'\n\t\tretClass = LeanTesting::BugAttachment\n\t\tresp = rcol(colName, ['_id', '_owner_id', 'url', 'created_at'])\n\t\[email protected] = {'data'=> JSON.generate(resp), 'status'=> 200}\n\n\t\tcol = LeanTesting::Bug.new(@client, {'id'=> 0}).attachments.all\n\n\t\tassert_equal resp[colName], col.toArray\n\t\tassert_instance_of retClass, col.collection[0]\n\t\tassert_equal resp['meta']['pagination']['total'], col.total\n\t\tassert_equal resp['meta']['pagination']['total_pages'], col.totalPages\n\t\tassert_equal resp['meta']['pagination']['count'], col.count\n\tend"
] | [
"0.6770159",
"0.6696701",
"0.6283699",
"0.6229266",
"0.6154415",
"0.61231565",
"0.5916787",
"0.5889247",
"0.5887766",
"0.58584815",
"0.58106697",
"0.58020484",
"0.57302105",
"0.5708757",
"0.57058",
"0.5654502",
"0.5615778",
"0.55751884",
"0.5571758",
"0.55538285",
"0.5548003",
"0.55132276",
"0.5494616",
"0.54921854",
"0.54881173",
"0.5486807",
"0.54568565",
"0.54554254",
"0.54489774",
"0.54480517",
"0.54391605",
"0.54385203",
"0.54148155",
"0.540776",
"0.54050696",
"0.5402156",
"0.5388833",
"0.53749704",
"0.5367386",
"0.5333689",
"0.5328898",
"0.5315522",
"0.53082305",
"0.53082305",
"0.53004545",
"0.5294498",
"0.52942246",
"0.52910984",
"0.5287874",
"0.5287677",
"0.52838963",
"0.5283746",
"0.5277821",
"0.52724826",
"0.52698565",
"0.52698565",
"0.5269204",
"0.5261804",
"0.5259985",
"0.52530926",
"0.5238725",
"0.52381235",
"0.52317566",
"0.5229848",
"0.5217046",
"0.52114",
"0.52075696",
"0.5206559",
"0.520571",
"0.52013665",
"0.5197553",
"0.5196401",
"0.51946604",
"0.5194404",
"0.5194342",
"0.5190982",
"0.5189271",
"0.51889795",
"0.5187278",
"0.5185633",
"0.5182651",
"0.51818407",
"0.51801646",
"0.51769257",
"0.51731503",
"0.51731503",
"0.51731503",
"0.51731503",
"0.51731503",
"0.51731503",
"0.51654",
"0.5163563",
"0.5163498",
"0.51548266",
"0.5154131",
"0.51526314",
"0.5147858",
"0.51407665",
"0.51324695",
"0.51250404"
] | 0.5714219 | 13 |
Get information regarding the specified Cloud Instance === Required arguments type type of the cloud instance. Possible values are "ec2", "rackspace", "gogrid" instance_id id of the cloud instance in Monitis === Optional arguments timezoneoffset offset relative to GMT, used to show results in the timezone of the user | def info(type, instance_id, options={})
args = {type: type, instanceId: instance_id}.merge(options)
get('cloudInstanceInfo', args)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_instance_of_cloud(cloud_id, instance_of_cloud_id)\n http_get_request(Scalarium.clouds_url+\"/#{cloud_id}/instances/#{instance_of_cloud_id}\") \n end",
"def aws_instance_get(opts)\n AWS::EC2.new.instances[opts[:instance_id]]\n end",
"def get_ec2_details(instance_id)\n ec2 = Aws::EC2::Client.new()\n begin\n res = ec2.describe_instances({instance_ids:[instance_id]})\n rescue\n puts \"Can't found an EC2 instance with given ID: #{instance_id}\"\n exit\n end\n i = res.reservations[0].instances[0]\n instance = make_instance( i )\n\n begin\n res = ec2.describe_image_attribute({image_id: i.image_id, attribute: \"description\"})\n instance[:ami_desc] = res.description.value\n rescue\n instance[:ami_desc] = '-- unavailable as of now --'\n end\n\n if i.vpc_id\n instance[:vpc] = getName( ec2.describe_vpcs({vpc_ids:[i.vpc_id]}).vpcs[0].tags )\n instance[:subnet] = getName( ec2.describe_subnets({subnet_ids:[i.subnet_id]}).subnets[0].tags )\n end\n\n instance\nend",
"def describe_addresses_for_instance(ec2_client, instance_id)\n response = ec2_client.describe_addresses(\n filters: [\n {\n name: \"instance-id\",\n values: [instance_id]\n }\n ]\n )\n addresses = response.addresses\n if addresses.count.zero?\n puts \"No addresses.\"\n else\n addresses.each do |address|\n puts \"-\" * 20\n puts \"Public IP: #{address.public_ip}\"\n puts \"Private IP: #{address.private_ip_address}\"\n end\n end\nrescue StandardError => e\n puts \"Error getting address information for instance: #{e.message}\"\nend",
"def get_pcloud_instance\n get(\"cloud-instances/#{guid}\")\n end",
"def echo_instance(i, is_vpc)\n ip_to_print = is_vpc ? i[:private_ip] : i[:public_ip]\n\n print \"#{echo_state(i[:state])} \"\n print \"#{echo_ip(ip_to_print)} \"\n print \"#{echo_name(i[:name], 40)} #{echo(i[:ec2_class],12)}\" \n\n flags = i[:windows] ? 'W'.bold : ' '\n flags << (i[:spot] ? 'S'.bold : ' ')\n flags << (i[:monitoring] ? 'M'.bold : ' ')\n if is_vpc and i[:state] == 'running' and i[:public_ip].nil?\n flags << 'I'.bold\n else\n flags << ' '\n end\n print \" #{flags} \"\n\n if is_vpc\n print echo_ip(i[:public_ip])\n else\n print echo(i[:arch], 6)\n end\n puts \" #{i[:id]}\"\nend",
"def get_pvm_instance(instance_id)\n get(\"cloud-instances/#{guid}/pvm-instances/#{instance_id}\")\n end",
"def instance_type\n get(\"instance_type\")\n end",
"def index\n\n credentials = Aws::Credentials.new('AKIAJ2JD2EKKFVDSR37A', 'cnZUnzuyYPqUevEPb045VJUnW55VR+rUCQrplzd/')\n ec2 = Aws::EC2::Client.new(\n region: \"us-east-1\",\n credentials: credentials\n )\n #i = ec2.instances.create(:image_id => \"ami-e3106686\")\n resp = ec2.run_instances({\n dry_run: true,\n image_id: \"ami-e3106686\", # required\n min_count: 1, # required\n max_count: 1, # required\n instance_type: \"t1.micro\", # accepts t1.micro, m1.small, m1.medium, m1.large, m1.xlarge, m3.medium, m3.large, m3.xlarge, m3.2xlarge, m4.large, m4.xlarge, m4.2xlarge, m4.4xlarge, m4.10xlarge, t2.micro, t2.small, t2.medium, t2.large, m2.xlarge, m2.2xlarge, m2.4xlarge, cr1.8xlarge, i2.xlarge, i2.2xlarge, i2.4xlarge, i2.8xlarge, hi1.4xlarge, hs1.8xlarge, c1.medium, c1.xlarge, c3.large, c3.xlarge, c3.2xlarge, c3.4xlarge, c3.8xlarge, c4.large, c4.xlarge, c4.2xlarge, c4.4xlarge, c4.8xlarge, cc1.4xlarge, cc2.8xlarge, g2.2xlarge, cg1.4xlarge, r3.large, r3.xlarge, r3.2xlarge, r3.4xlarge, r3.8xlarge, d2.xlarge, d2.2xlarge, d2.4xlarge, d2.8xlarge\n placement: {\n tenancy: \"default\", # accepts default, dedicated\n },\n\n block_device_mappings: [\n {\n virtual_name: \"String\",\n device_name: \"String\",\n ebs: {\n snapshot_id: \"String\",\n volume_size: 1,\n delete_on_termination: true,\n volume_type: \"standard\", # accepts standard, io1, gp2\n iops: 1,\n encrypted: true,\n },\n\n },\n ],\n monitoring: {\n enabled: true, # required\n },\n disable_api_termination: true,\n instance_initiated_shutdown_behavior: \"stop\", # accepts stop, terminate\n network_interfaces: [\n {\n delete_on_termination: true,\n private_ip_addresses: [\n {\n private_ip_address: \"172.31.2.177\", # required\n primary: true,\n },\n ],\n secondary_private_ip_address_count: 1,\n associate_public_ip_address: true,\n },\n ],\n ebs_optimized: true,\n })\n @ec2_instances = Ec2Instance.all\n end",
"def show\n @instance_type = InstanceType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @instance_type }\n end\n end",
"def get_instance instance_id\n instances.get_instance name: instance_path(instance_id)\n end",
"def get_instance instance_id\n execute do\n instances.get_instance(\n instance_path(instance_id)\n )\n end\n end",
"def instance_config project_id:, instance_config_id:\n # [START spanner_get_instance_config]\n # project_id = \"Your Google Cloud project ID\"\n # instance_config_id = \"Spanner instance config ID\"\n\n require \"google/cloud/spanner\"\n require \"google/cloud/spanner/admin/instance\"\n\n instance_admin_client = Google::Cloud::Spanner::Admin::Instance.instance_admin\n\n instance_config_path = instance_admin_client.instance_config_path \\\n project: project_id, instance_config: instance_config_id\n config = instance_admin_client.get_instance_config name: instance_config_path\n\n puts \"Available leader options for instance config #{config.name} : #{config.leader_options}\"\n # [END spanner_get_instance_config]\nend",
"def aws_get_ip (method = :internal, type = :public)\n # allowed methods: :internal (check meta-data inside VM), :aws (ask API)\n # allowed types: :public, :private\n self.aws_describe_instance\n\n if method.equal?(:internal)\n key = type.equal?(:public) ? 'public-ipv4' : 'local-ipv4'\n murl = sprintf('http://169.254.169.254/latest/meta-data/%s', key)\n result = self.aws_get_url(murl)\n else\n key = type.equal?(:public) ? 'ipAddress' : 'privateIpAddress'\n result = @instance_data[key]\n end\n\n result\n end",
"def aws_instance_elastic_ip_get(opts)\n opts[:instance].elastic_ip\n end",
"def ec2_instance_data # rubocop:disable Metrics/MethodLength, Metrics/AbcSize\n i = {\n :placement => {\n :availability_zone => config[:availability_zone]\n },\n :instance_type => config[:instance_type],\n :ebs_optimized => config[:ebs_optimized],\n :image_id => config[:image_id],\n :key_name => config[:aws_ssh_key_id],\n :subnet_id => config[:subnet_id],\n :private_ip_address => config[:private_ip_address]\n }\n i[:block_device_mappings] = block_device_mappings unless block_device_mappings.empty?\n i[:security_group_ids] = config[:security_group_ids] if config[:security_group_ids]\n i[:user_data] = prepared_user_data if prepared_user_data\n if config[:iam_profile_name]\n i[:iam_instance_profile] = { :name => config[:iam_profile_name] }\n end\n if !config.fetch(:associate_public_ip, nil).nil?\n i[:network_interfaces] =\n [{\n :device_index => 0,\n :associate_public_ip_address => config[:associate_public_ip],\n :delete_on_termination => true\n }]\n # If specifying `:network_interfaces` in the request, you must specify\n # network specific configs in the network_interfaces block and not at\n # the top level\n if config[:subnet_id]\n i[:network_interfaces][0][:subnet_id] = i.delete(:subnet_id)\n end\n if config[:private_ip_address]\n i[:network_interfaces][0][:private_ip_address] = i.delete(:private_ip_address)\n end\n if config[:security_group_ids]\n i[:network_interfaces][0][:groups] = i.delete(:security_group_ids)\n end\n end\n i\n end",
"def instanceinfo(compute,name)\n\t\tresp = compute.describe_instances\t\n\t\tif (resp.status == 200)\n\t\t\t# check through the instances looking for one with a matching Name tag\n\t\t\tresp.body['reservationSet'].each { |x|\n\t\t\t\tx['instancesSet'].each { |y| \n\t\t\t\t\tif ( y['tagSet']['Name'] == name)\n\t\t\t\t\t\treturn y\n\t\t\t\t\tend\n\t\t\t\t}\n\t\t\t}\n\t\telse\n\t\t\traise \"ebsvol[aws]->instanceinfo: I couldn't list the instances\"\n\t\tend\n\t\tnil\n\tend",
"def lookup_instance_id\n metadata_endpoint = 'http://169.254.169.254/latest/meta-data/'\n instance_id = Net::HTTP.get( URI.parse( metadata_endpoint + 'instance-id' ) )\n end",
"def get_cloud_sku_instance_type_list_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: CloudApi.get_cloud_sku_instance_type_list ...'\n end\n allowable_values = [\"allpages\", \"none\"]\n if @api_client.config.client_side_validation && opts[:'inlinecount'] && !allowable_values.include?(opts[:'inlinecount'])\n fail ArgumentError, \"invalid value for \\\"inlinecount\\\", must be one of #{allowable_values}\"\n end\n # resource path\n local_var_path = '/api/v1/cloud/SkuInstanceTypes'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'$filter'] = opts[:'filter'] if !opts[:'filter'].nil?\n query_params[:'$orderby'] = opts[:'orderby'] if !opts[:'orderby'].nil?\n query_params[:'$top'] = opts[:'top'] if !opts[:'top'].nil?\n query_params[:'$skip'] = opts[:'skip'] if !opts[:'skip'].nil?\n query_params[:'$select'] = opts[:'select'] if !opts[:'select'].nil?\n query_params[:'$expand'] = opts[:'expand'] if !opts[:'expand'].nil?\n query_params[:'$apply'] = opts[:'apply'] if !opts[:'apply'].nil?\n query_params[:'$count'] = opts[:'count'] if !opts[:'count'].nil?\n query_params[:'$inlinecount'] = opts[:'inlinecount'] if !opts[:'inlinecount'].nil?\n query_params[:'at'] = opts[:'at'] if !opts[:'at'].nil?\n query_params[:'tags'] = opts[:'tags'] if !opts[:'tags'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/csv', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'CloudSkuInstanceTypeResponse'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['cookieAuth', 'http_signature', 'oAuth2', 'oAuth2']\n\n new_options = opts.merge(\n :operation => :\"CloudApi.get_cloud_sku_instance_type_list\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: CloudApi#get_cloud_sku_instance_type_list\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def ec2_instance_data\n # Support for looking up security group id and subnet id using tags.\n vpc_id = nil\n client = ::Aws::EC2::Client.new(region: config[:region])\n if config[:subnet_id].nil? && config[:subnet_filter]\n filters = [config[:subnet_filter]].flatten\n\n r = { filters: [] }\n filters.each do |subnet_filter|\n r[:filters] <<\n {\n name: \"tag:#{subnet_filter[:tag]}\",\n values: [subnet_filter[:value]],\n }\n end\n\n subnets = client.describe_subnets(r).subnets\n raise \"Subnets with tags '#{filters}' not found during security group creation\" if subnets.empty?\n\n # => Select the least-populated subnet if we have multiple matches\n subnet = subnets.max_by { |s| s[:available_ip_address_count] }\n vpc_id = subnet.vpc_id\n config[:subnet_id] = subnet.subnet_id\n end\n\n if config[:security_group_ids].nil? && config[:security_group_filter]\n # => Grab the VPC in the case a Subnet ID rather than Filter was set\n vpc_id ||= client.describe_subnets(subnet_ids: [config[:subnet_id]]).subnets[0].vpc_id\n security_groups = []\n filters = [config[:security_group_filter]].flatten\n filters.each do |sg_filter|\n r = {}\n if sg_filter[:name]\n r[:filters] = [\n {\n name: \"group-name\",\n values: [sg_filter[:name]],\n },\n {\n name: \"vpc-id\",\n values: [vpc_id],\n },\n ]\n end\n\n if sg_filter[:tag]\n r[:filters] = [\n {\n name: \"tag:#{sg_filter[:tag]}\",\n values: [sg_filter[:value]],\n },\n {\n name: \"vpc-id\",\n values: [vpc_id],\n },\n ]\n end\n\n security_group = client.describe_security_groups(r).security_groups\n\n if security_group.any?\n security_group.each { |sg| security_groups.push(sg.group_id) }\n else\n raise \"A Security Group matching the following filter could not be found:\\n#{sg_filter}\"\n end\n end\n config[:security_group_ids] = security_groups\n end\n\n i = {\n instance_type: config[:instance_type],\n ebs_optimized: config[:ebs_optimized],\n image_id: config[:image_id],\n key_name: config[:aws_ssh_key_id],\n subnet_id: config[:subnet_id],\n private_ip_address: config[:private_ip_address],\n min_count: 1,\n max_count: 1,\n }\n\n if config[:tags] && !config[:tags].empty?\n tags = config[:tags].map do |k, v|\n # we convert the value to a string because\n # nils should be passed as an empty String\n # and Integers need to be represented as Strings\n { key: k, value: v.to_s }\n end\n instance_tag_spec = { resource_type: \"instance\", tags: tags }\n volume_tag_spec = { resource_type: \"volume\", tags: tags }\n i[:tag_specifications] = [instance_tag_spec, volume_tag_spec]\n end\n\n availability_zone = config[:availability_zone]\n if availability_zone\n if /^[a-z]$/i.match?(availability_zone)\n availability_zone = \"#{config[:region]}#{availability_zone}\"\n end\n i[:placement] = { availability_zone: availability_zone.downcase }\n end\n tenancy = config[:tenancy]\n if tenancy\n if i.key?(:placement)\n i[:placement][:tenancy] = tenancy\n else\n i[:placement] = { tenancy: tenancy }\n end\n end\n unless config[:block_device_mappings].nil? || config[:block_device_mappings].empty?\n i[:block_device_mappings] = config[:block_device_mappings]\n end\n i[:security_group_ids] = Array(config[:security_group_ids]) if config[:security_group_ids]\n i[:metadata_options] = config[:metadata_options] if config[:metadata_options]\n i[:user_data] = prepared_user_data if prepared_user_data\n if config[:iam_profile_name]\n i[:iam_instance_profile] = { name: config[:iam_profile_name] }\n end\n unless config.fetch(:associate_public_ip, nil).nil?\n i[:network_interfaces] =\n [{\n device_index: 0,\n associate_public_ip_address: config[:associate_public_ip],\n delete_on_termination: true,\n }]\n # If specifying `:network_interfaces` in the request, you must specify\n # network specific configs in the network_interfaces block and not at\n # the top level\n if config[:subnet_id]\n i[:network_interfaces][0][:subnet_id] = i.delete(:subnet_id)\n end\n if config[:private_ip_address]\n i[:network_interfaces][0][:private_ip_address] = i.delete(:private_ip_address)\n end\n if config[:security_group_ids]\n i[:network_interfaces][0][:groups] = i.delete(:security_group_ids)\n end\n end\n availability_zone = config[:availability_zone]\n if availability_zone\n if /^[a-z]$/i.match?(availability_zone)\n availability_zone = \"#{config[:region]}#{availability_zone}\"\n end\n i[:placement] = { availability_zone: availability_zone.downcase }\n end\n tenancy = config[:tenancy]\n if tenancy\n if i.key?(:placement)\n i[:placement][:tenancy] = tenancy\n else\n i[:placement] = { tenancy: tenancy }\n end\n end\n unless config[:instance_initiated_shutdown_behavior].nil? ||\n config[:instance_initiated_shutdown_behavior].empty?\n i[:instance_initiated_shutdown_behavior] = config[:instance_initiated_shutdown_behavior]\n end\n i\n end",
"def ec2_instance_params\n params[:ec2_instance]\n end",
"def aws_find_instance( iprops )\n if iprops[:id]\n @aws_instances.find do |r|\n r[:id] == iprops[:id] && r[:region] == iprops[:region]\n end\n else\n [ :internet_name, :internet_ip, :name ].inject( nil ) do |found, key|\n found || @aws_instances.find { |r| r[key] == iprops[key] }\n end\n end\n end",
"def show\n @instance = Instance.find(params[:id])\n @flavor = Flavor.find_by_flavor_id(@instance.flavor_id)\n @image = Image.find_by_image_id(@instance.image_id)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @instance }\n end\n end",
"def get_cloud\n cloud_href = instance.cloud.href\n cloud_id = cloud_href.split('/').last\n cloud = @api_client.clouds(:id => cloud_id)\n end",
"def get_ec2_list_info(name_regex)\n ec2 = Aws::EC2::Client.new()\n\n # Load VPCs\n vpcs={}\n ec2.describe_vpcs( {filters:[AVAILABLE_STATE_FILTER]} ).vpcs.each do |vpc|\n vpcs[ vpc.vpc_id ] = { name: getName(vpc.tags), cidr: vpc.cidr_block, subnets: {} }\n end\n\n # Load subnets\n ec2.describe_subnets( {filters:[AVAILABLE_STATE_FILTER]} ).subnets.each do |sn|\n vpc = vpcs[ sn.vpc_id ]\n vpc[:subnets][ sn.subnet_id ] = { name: getName(sn.tags), zone: sn.availability_zone, cidr: sn.cidr_block, instances: [] }\n end\n\n ec2_classic = []\n\n # Load instances\n instances = ec2.describe_instances().reservations.map { |r| r.instances } .flatten\n instances.each do |i|\n next if name_regex and not name_regex =~ getName(i.tags)\n instance = make_instance( i )\n if i.vpc_id\n vpc = vpcs[ i.vpc_id ]\n sn = vpc[:subnets][ i.subnet_id ]\n sn[:instances] << instance\n else\n ec2_classic << instance\n end\n end\n\n [vpcs, ec2_classic]\nend",
"def instances(type)\n @instances[type]\n end",
"def right_aws\n cloud_provider.ec2.describe_instances instance_id\n end",
"def get_instance_data\n JSON.parse(Net::HTTP.get(URI.parse('http://169.254.169.254/latest/dynamic/instance-identity/document')))\n end",
"def get(url, instance_id)\n invoke(\"get\", url, :params => {:instance_id => instance_id}, :url_params => :instance_id)\n end",
"def list_instance_ip(compartment_id, instance_id)\n vcnapi = OracleBMC::Core::VirtualNetworkClient.new\n opts = { instance_id: instance_id }\n api = OracleBMC::Core::ComputeClient.new\n vnics = api.list_vnic_attachments(compartment_id, opts)\n network = vcnapi.get_vnic(vnics.data[0].vnic_id)\n return network.data.private_ip, network.data.public_ip\n end",
"def spin_up_instance ami_name, vpc_id, key_name, security_group_id, subnet_id, instance_type = \"t2.micro\"\n resp = client.run_instances({\n dry_run: false,\n image_id: ami_name, # required\n min_count: 1, # required\n max_count: 1, # required\n key_name: key_name,\n instance_type: instance_type, # accepts t1.micro, t2.nano, t2.micro, t2.small, t2.medium, t2.large, m1.small, m1.medium, m1.large, m1.xlarge, m3.medium, m3.large, m3.xlarge, m3.2xlarge, m4.large, m4.xlarge, m4.2xlarge, m4.4xlarge, m4.10xlarge, m4.16xlarge, m2.xlarge, m2.2xlarge, m2.4xlarge, cr1.8xlarge, r3.large, r3.xlarge, r3.2xlarge, r3.4xlarge, r3.8xlarge, x1.16xlarge, x1.32xlarge, i2.xlarge, i2.2xlarge, i2.4xlarge, i2.8xlarge, hi1.4xlarge, hs1.8xlarge, c1.medium, c1.xlarge, c3.large, c3.xlarge, c3.2xlarge, c3.4xlarge, c3.8xlarge, c4.large, c4.xlarge, c4.2xlarge, c4.4xlarge, c4.8xlarge, cc1.4xlarge, cc2.8xlarge, g2.2xlarge, g2.8xlarge, cg1.4xlarge, p2.xlarge, p2.8xlarge, p2.16xlarge, d2.xlarge, d2.2xlarge, d2.4xlarge, d2.8xlarge\n monitoring: {\n enabled: true, # required\n },\n network_interfaces: [\n {\n subnet_id: subnet_id,\n groups: [security_group_id],\n device_index: 0,\n associate_public_ip_address: true\n }\n ],\n\n instance_initiated_shutdown_behavior: \"stop\", # accepts stop, terminate\n })\n\n error \"Error starting EC2 instance #{resp.inspect}\" if resp.instances.nil? || resp.instances.size == 0\n\n return resp.instances[0]\n end",
"def get_instance_id(instance_info)\n # puts \"look up instanceId in #{instance_info.inspect}\"\n instance_info['instancesSet']['item'][0]['instanceId']\n end",
"def instance_region\n aws_ec2_az = `curl --silent http://169.254.169.254/latest/meta-data/placement/availability-zone`.strip\n region = aws_ec2_az[0..-2]\n end",
"def instance instance_id\n ensure_service!\n grpc = service.get_instance instance_id\n Instance.from_grpc grpc, service\n rescue Google::Cloud::NotFoundError\n nil\n end",
"def instance_id\n return ec2_meta_data('instance-id')\n end",
"def get_instances\n instances = [ ]\n get_clouds.each do |cloud|\n instances += cloud.instances.index(:filter => [], :view => 'tiny')\n end\n instances\n end",
"def ec2_instance(instance_id)\n EC2Instance.new(instance_id)\n end",
"def ec2_instance(instance_id)\n EC2Instance.new(instance_id)\n end",
"def list_instances_detail()\n response = dbreq(\"GET\", dbmgmthost, \"#{dbmgmtpath}/instances/detail\", dbmgmtport, dbmgmtscheme)\n CloudDB::Exception.raise_exception(response) unless response.code.to_s.match(/^20.$/)\n instances = CloudDB.symbolize_keys(JSON.parse(response.body)[\"instances\"])\n return instances\n end",
"def instance\n perform_request_with_object(:get, '/api/v1/instance', {}, Mastodon::Instance)\n end",
"def getAWSInfo\n begin\n Timeout::timeout(10) do\n aws_metadata = open('http://169.254.169.254/2014-11-05/dynamic/instance-identity/document'){ |io| data = io.read }\n aws_JSON_Information = JSON.parse(aws_metadata)\n return \"#{aws_JSON_Information['instanceId']}_#{aws_JSON_Information['region']}_#{aws_JSON_Information['accountId']}\"\n end\n rescue\n Chef::Log.warn('Unable to get AWS instance ID, Timeout while reading') \n return ''\n end\nend",
"def get_cluster instance_id, cluster_id\n instances.get_cluster name: cluster_path(instance_id, cluster_id)\n end",
"def get_aws_region\n\n\n begin\n\n url = 'http://169.254.169.254/latest/dynamic/instance-identity/document'\n uri = URI(url)\n response = Net::HTTP.get(uri)\n\n hashOfLookupValues = JSON.parse(response)\n lookupRegion = hashOfLookupValues[\"region\"]\n\n rescue\n logonFailed('Unable to perform region lookup. Is this an EC2 instance? and does it have access to http://169.254.169.254')\n end\n\n return lookupRegion\n\n end",
"def aws_instance_status(opts)\n opts[:instance].status\n end",
"def instance\n perform_request_with_object(:get, '/api/v1/instance', {},\n Mastodon::Instance)\n end",
"def get_cloud_instances(cloud_id)\n http_get_request(Scalarium.clouds_url+\"/#{cloud_id}/instances\") \n end",
"def instance\n node = 'AWS_EC2_INSTANCE'\n q = []\n\n # instance node\n q.push(_upsert({ node: node, id: @name }))\n\n # vpc node and relationship\n if @data.vpc_id\n opts = {\n parent_node: node,\n parent_name: @name,\n child_node: 'AWS_VPC',\n child_name: @data.vpc_id,\n relationship: 'MEMBER_OF_VPC'\n }\n\n q.push(_upsert_and_link(opts))\n end\n\n # network_interfaces and relationship\n @data.network_interfaces.each do |ni|\n opts = {\n parent_node: node,\n parent_name: @name,\n child_node: 'AWS_NETWORK_INTERFACE',\n child_name: ni.network_interface_id,\n relationship: 'ATTACHED_TO_INSTANCE'\n }\n\n q.push(_upsert_and_link(opts))\n end\n\n # security_groups and relationship\n @data.security_groups.each do |sg|\n opts = {\n child_node: 'AWS_SECURITY_GROUP',\n child_name: sg.group_id,\n parent_node: node,\n parent_name: @name,\n relationship: 'IN_SECURITY_GROUP'\n }\n\n q.push(_upsert_and_link(opts))\n end\n\n # subnet and relationship\n if @data.subnet_id\n opts = {\n parent_node: node,\n parent_name: @name,\n child_node: 'AWS_SUBNET',\n # child_name: \"arn:aws:ec2:#{@region}:#{@account}:subnet/#{@data.subnet_id}\",\n child_name: @data.subnet_id,\n relationship: 'IN_SUBNET'\n }\n\n q.push(_upsert_and_link(opts))\n end\n\n if @data.iam_instance_profile\n opts = {\n node: 'AWS_EC2_IAM_PROFILE',\n id: @data.iam_instance_profile.arn\n }\n\n q.push(_merge(opts))\n\n opts = {\n from_node: node,\n from_name: @name,\n to_node: 'AWS_EC2_IAM_PROFILE',\n to_name: @data.iam_instance_profile.arn,\n relationship: 'HAS_IAM_PROFILE'\n }\n\n q.push(_link(opts))\n end\n\n if @data.metadata_options\n metadata_options = \"#{@name}-metadata-options\"\n\n opts = {\n node: 'AWS_EC2_INSTANCE_METADATA_OPTIONS',\n id: metadata_options\n }\n\n q.push(_merge(opts))\n\n opts = {\n from_node: node,\n from_name: @name,\n to_node: 'AWS_EC2_INSTANCE_METADATA_OPTIONS',\n to_name: metadata_options,\n relationship: 'HAS_METADATA_OPTIONS',\n relationship_attributes: @data.metadata_options.to_h\n }\n\n q.push(_link(opts))\n end\n\n q\n end",
"def fetch_instance(shortname = :all, options = {})\n return instances if instances && !options[:force]\n\n fetch_stack\n unless instance_list\n self.instance_list = self.instances =\n aws_client.describe_instances(stack_id: stack[:stack_id])[:instances]\n end\n\n if shortname != :all\n fetch_layer(shortname, force: true)\n self.instances = []\n\n layers.each do |layer|\n instance = aws_client.describe_instances(\n layer_id: layer[:layer_id])\n self.instances << instance[:instances]\n end\n\n self.instances.flatten!\n end\n end",
"def my_instance_id\n Net::HTTP.get(URI('http://169.254.169.254/1.0/meta-data/instance-id'))\n end",
"def instances\n @instances ||= aws_client.instances(filters: instance_filters).map do |instance|\n OpenStruct.new(\n with_tags(instance, private_ip: instance.private_ip_address,\n public_ip: instance.public_ip_address,\n instance: instance.instance_id)\n )\n end\n end",
"def instance_vpc(name, image_id, subnet, security_groups, depends_on: [], properties: {})\n fail \"VPC instance #{name} can not contain non VPC SecurityGroups\" if properties.include?(:SecurityGroups)\n if properties.include?(:NetworkInterfaces)\n fail \"VPC instance #{name} can not contain NetworkInterfaces and subnet or security_groups\"\n end\n properties[:ImageId] = image_id\n properties[:SubnetId] = subnet\n properties[:SecurityGroupIds] = security_groups\n if properties[:Tags] && !properties[:Tags].any? { |x| x[:Key] == 'Name' }\n properties[:Tags] << { Key: 'Name', Value: join('-', aws_stack_name, name) }\n end\n options = {\n Type: 'AWS::EC2::Instance',\n Properties: properties\n }\n\n options[:DependsOn] = depends_on unless depends_on.empty?\n resource name, options\n name\n end",
"def info\n @cloud_core = CloudCore.new(@config, @logger, @volume_manager, @az_selector, API_VERSION)\n @cloud_core.info\n end",
"def instance_ec2\n @@cache[:fedora_image] = ImageService::create_image(nil,\n :broker_image_id => 'fedora',\n :provider_image_id => 'ami-bafcf3ce',\n :provider_id => @@cache[:ec2_provider].id,\n )\n @@cache[:instance_ec2] = LaunchService.launch(Seeding[:pool_ec2].id, 'test instance '+Time.now.to_i.to_s, Seeding[:hwp_1].name, Seeding[:fedora_image].broker_image_id,\n #:flavor => 'm1-small',\n :keyname => 'mpovolny'\n )\n end",
"def all_instances\n Puppet.debug(\"all_instances - cached instances is: #{cached_instances}\")\n Puppet.debug(\"all_instances - cached instances object id: #{cached_instances.object_id}\")\n # return cache if it has been created, this means that this function will only need\n # to be loaded once, returning all instances that exist of this resource in vsphere\n # then, we can lookup our version by name/id/whatever. This saves a TON of processing\n return cached_instances unless cached_instances.nil?\n\n # Want to return an array of instances\n # each hash should have the same properties as the properties\n # of this \"type\"\n # remember the keys should be symbols, aka :ntp_servers not 'ntp_servers'\n # This is a tracking hash which will contain info about each host and NTP server relationships\n cmd = <<-EOF\n $ntp_servers_hash = @{}\n $hosts = #{powercli_get_online_hosts}\n foreach($h in $hosts) {\n $servers = Get-VMHostNtpServer -VMHost $h\n if ($servers) {\n $ntp_servers_hash[$h.Name] = @($servers)\n } else {\n $ntp_servers_hash[$h.Name] = @()\n }\n }\n $ntp_servers_hash | ConvertTo-Json\n EOF\n\n ntpservers_stdout = powercli_connect_exec(cmd)[:stdout]\n # json parse expects a json string, powershell does not stdout with quotes\n # we might be able to remove this line because powershell exits with a viable ruby array already:\n # [\n # \"time1.dev.encore.tech\",\n # \"time2.dev.encore.tech\"\n # ]\n # what happens if this returns null??\n ntpservers_hash = JSON.parse(ntpservers_stdout)\n\n # create instance hash - this contains info about ONE host at a time\n # the values should match the data \"shape\" (ie have the same fields) as our\n # type.\n # the key, should be the title/namevar so we can do a lookup in our\n # read_instance function\n cached_instances_set({})\n ntpservers_hash.each do |esx_host, ntp_servers_array|\n cached_instances[esx_host] = {\n ensure: :present,\n esx_host: esx_host,\n ntp_servers: ntp_servers_array,\n }\n end\n Puppet.debug(\"all_instances - cached instances is at end: #{cached_instances}\")\n Puppet.debug(\"all_instances - cached instances object_id at end: #{cached_instances.object_id}\")\n cached_instances\n end",
"def get_ec2_cpu_usage(instance_id, region, duration)\n cw = AWS::CloudWatch::Client.new(:region=>region)\n @avg_cpu_usage = -1\n\n metrics = cw.get_metric_statistics('metric_name' => 'CPUUtilization', 'period' => 3600, 'start_time' => (Time.now - duration).iso8601,\n 'end_time' => Time.now.iso8601, 'statistics' => \"Average\", 'namespace' => \"AWS/EC2\", :dimensions => [{ :name => 'InstanceId',\n :value => instance_id }])\n if metrics.nil? \n @@logger.info('Cannot get CPU Usage for instance ' + instance_id + ' in ' + 'region')\n else\n metrics.datapoints.each do |datapoint|\n @avg_cpu_usage = datapoint[:average]\n # round to 2 decimal places\n @avg_cpu_usage = Integer(@avg_cpu_usage * 100) / Float(100)\n @@logger.info('Average CPU Usage for instance ' + instance_id + ' in ' + region + ' is ' + @avg_cpu_usage.to_s + '%')\n end\n end\n\n end",
"def show\n @offset_time = OffsetTime.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @offset_time }\n end\n end",
"def instance_path instance_id\n Admin::V2::BigtableInstanceAdminClient.instance_path(\n project_id,\n instance_id\n )\n end",
"def vnc\n requires :instance_uuid\n service.vm_get_vnc(instance_uuid)\n end",
"def show\n @instance = Instance.find_by_id( params[:id] )\n @image = Image.find_by_ami(@instance.image_id)\n end",
"def parameter_ec2_instance_type(instance_name,\n type: InstanceType.ec2_instance_type.current_generation[:general_purpose].first)\n fail(\"Not supported instance type: #{type}\") unless InstanceType.ec2_instance_type.supported?(type)\n warn(\"Using obsolete instance type: #{type}\") if InstanceType.ec2_instance_type.obsolete?(type)\n parameter_instance_type(instance_name, type, allowed_values: InstanceType.ec2_instance_type.allowed_values(type))\n end",
"def list_asgs\n # collect the list of running instances in this zone\n ec2 = AWS::EC2.new\n region = ec2.regions[AMI_REGION]\n instances = region.instances.select { |i| i.tags.to_h[\"server\"] == APP_NAME }\n\n # now find the list of running asgs\n format = \"%-32s %s\"\n puts\n puts format % [\"Instance Groups\", \"Tags\"]\n puts format % [\"-\" * 32, \"-\" * 60]\n auto_scaling = new_auto_scaling\n count = 0\n auto_scaling.groups.each do |group|\n count = count + 1\n puts format % [group.name, tag_value(group.tags, \"env\")]\n\n instances.each do |i|\n if i.tags.to_h[\"env\"] == tag_value(group.tags, \"env\")\n puts \"\\t%s %-13s %s\" % [i.id, i.status, i.dns_name]\n end\n end\n puts\n end\n puts format % [\"-\" * 32, \"-\" * 60]\n puts \"Found #{count} ASGs\"\n puts\nend",
"def get_cluster instance_id, cluster_id\n execute do\n instances.get_cluster(\n cluster_path(instance_id, cluster_id)\n )\n end\n end",
"def status_of(instance)\n description.instances.select{ |e| e.instance_id == instance}\n end",
"def show\n @artists = Artist.all\n @venues = Venue.all\n gon.venue = set_concert.venue\n p ENV['TimeZone']\n gon.tz_key = ENV['TimeZone']\n @keep = Keep.new\n end",
"def get_kubernetes_virtual_machine_instance_type_list_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: KubernetesApi.get_kubernetes_virtual_machine_instance_type_list ...'\n end\n allowable_values = [\"allpages\", \"none\"]\n if @api_client.config.client_side_validation && opts[:'inlinecount'] && !allowable_values.include?(opts[:'inlinecount'])\n fail ArgumentError, \"invalid value for \\\"inlinecount\\\", must be one of #{allowable_values}\"\n end\n # resource path\n local_var_path = '/api/v1/kubernetes/VirtualMachineInstanceTypes'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'$filter'] = opts[:'filter'] if !opts[:'filter'].nil?\n query_params[:'$orderby'] = opts[:'orderby'] if !opts[:'orderby'].nil?\n query_params[:'$top'] = opts[:'top'] if !opts[:'top'].nil?\n query_params[:'$skip'] = opts[:'skip'] if !opts[:'skip'].nil?\n query_params[:'$select'] = opts[:'select'] if !opts[:'select'].nil?\n query_params[:'$expand'] = opts[:'expand'] if !opts[:'expand'].nil?\n query_params[:'$apply'] = opts[:'apply'] if !opts[:'apply'].nil?\n query_params[:'$count'] = opts[:'count'] if !opts[:'count'].nil?\n query_params[:'$inlinecount'] = opts[:'inlinecount'] if !opts[:'inlinecount'].nil?\n query_params[:'at'] = opts[:'at'] if !opts[:'at'].nil?\n query_params[:'tags'] = opts[:'tags'] if !opts[:'tags'].nil?\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/csv', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'KubernetesVirtualMachineInstanceTypeResponse'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['cookieAuth', 'http_signature', 'oAuth2', 'oAuth2']\n\n new_options = opts.merge(\n :operation => :\"KubernetesApi.get_kubernetes_virtual_machine_instance_type_list\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: KubernetesApi#get_kubernetes_virtual_machine_instance_type_list\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n page = params[:page]\n per_page = (params[:per_page] || 10).to_i\n if page\n entities = _all_instances_query.page(page).per(per_page)\n render json: entities, entity: _get_class,\n meta: { total_pages: entities.total_pages, total_count: entities.total_count }\n else\n entities = _all_instances_query\n respond_with entities, entity: '_get_class'\n end\n end",
"def instances_status\n @instances.each do |i_id, meta|\n status = AWS::CLI_Interface.ec2_instance_status(i_id)\n output = \"#{meta['name']} (#{i_id})\".colorize(color: :white, background: :blue) +\n \" : \".colorize(:yellow) +\n \"#{status[:label]}\".colorize(color: :white, background: status[:color])\n\n if meta.has_key? 'timeout'\n output += \" : \".colorize(:yellow)\n output += \"Timeout: #{meta['timeout']}\".colorize(color: :black, background: :light_yellow)\n end\n\n Logging.log output\n end\n end",
"def instance_path instance_id\n Admin::V2::BigtableInstanceAdmin::Paths.instance_path project: project_id, instance: instance_id\n end",
"def instances\n @instances ||= begin\n instances_channel = channel(\n Admin::V2::BigtableInstanceAdminClient::SERVICE_ADDRESS\n )\n Admin::V2::BigtableInstanceAdminClient.new(\n credentials: instances_channel,\n timeout: timeout,\n client_config: client_config,\n lib_name: \"gccl\",\n lib_version: Google::Cloud::Bigtable::VERSION\n )\n end\n end",
"def get_instance request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_get_instance_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Cloud::BareMetalSolution::V2::Instance.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end",
"def instance_id\n `curl --connect-timeout 1 #{aws_url} 2>&1`.chomp\n end",
"def search_salesforce(object_type,obj,instance_url,access_token)\n type = \"search\"\n case\n when object_type == \"Campaign\"\n campaign_id = obj[\"id\"]\n search_string =\n url_encode(\n \"FIND {#{campaign_id}}\" \\\n \" IN ALL FIELDS\" \\\n \" RETURNING #{object_type}(Id)\")\n when object_type == \"Contact\"\n contact_fn = escape_characters(obj[\"profile\"][\"first_name\"])\n contact_ln = escape_characters(obj[\"profile\"][\"last_name\"])\n contact_email = obj[\"profile\"][\"email\"]\n contact_email = obj[\"order\"][\"email\"] if contact_email.nil?\n contact_email = escape_characters(contact_email)\n search_string =\n url_encode(\n \"FIND {#{contact_fn}\" \\\n \" AND #{contact_ln}\" \\\n \" AND #{contact_email}}\" \\\n \" IN ALL FIELDS\" \\\n \" RETURNING #{object_type}(Id)\")\n when object_type == \"CampaignMember\"\n contact_id = obj[\"ContactId\"]\n campaign_id = obj[\"CampaignId\"]\n type = \"query\"\n search_string =\n url_encode(\n \"SELECT Id\" \\\n \" FROM CampaignMember\" \\\n \" WHERE CampaignId='#{campaign_id}'\" \\\n \" AND ContactId='#{contact_id}'\")\n end\n base_uri = \"#{instance_url}/services/data/v29.0/#{type}/?q=#{search_string}\"\n json_payload = nil\n query_response = rest_call(\"get\",base_uri,json_payload,access_token)\n # return query_response\n end",
"def instance_path\n Admin::V2::BigtableTableAdminClient\n .instance_path(\n project_id,\n instance_id\n )\n end",
"def zone_info(zone_name)\n parameters = \"zone=#{zone_name}\"\n request(:get, \"/api/zone?#{parameters}\")\n end",
"def describe_vpc_zone_nos(optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'DescribeVpcZoneNos'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\tif optional.key? :_method\n\t\t\traise ArgumentError, '_method must be GET|POST' unless 'GET|POST'.split('|').include? optional[:_method]\n\t\t\targs[:method] = optional[:_method]\n\t\tend\n\t\tif optional.key? :_scheme\n\t\t\traise ArgumentError, '_scheme must be http|https' unless 'http|https'.split('|').include? optional[:_scheme]\n\t\t\targs[:scheme] = optional[:_scheme]\n\t\tend\n\t\tif optional.key? :client_token\n\t\t\targs[:query]['ClientToken'] = optional[:client_token]\n\t\tend\n\t\tif optional.key? :owner_account\n\t\t\targs[:query]['OwnerAccount'] = optional[:owner_account]\n\t\tend\n\t\tif optional.key? :owner_id\n\t\t\targs[:query]['OwnerId'] = optional[:owner_id]\n\t\tend\n\t\tif optional.key? :region\n\t\t\targs[:query]['Region'] = optional[:region]\n\t\tend\n\t\tif optional.key? :resource_owner_account\n\t\t\targs[:query]['ResourceOwnerAccount'] = optional[:resource_owner_account]\n\t\tend\n\t\tif optional.key? :resource_owner_id\n\t\t\targs[:query]['ResourceOwnerId'] = optional[:resource_owner_id]\n\t\tend\n\t\tif optional.key? :zone_id\n\t\t\targs[:query]['ZoneId'] = optional[:zone_id]\n\t\tend\n\t\tself.run(args)\n\tend",
"def describe_s_q_l_injection_infos(d_b_instance_id, end_time, start_time, optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'DescribeSQLInjectionInfos'\n\t\targs[:query]['DBInstanceId'] = d_b_instance_id\n\t\targs[:query]['EndTime'] = end_time\n\t\targs[:query]['StartTime'] = start_time\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\tif optional.key? :_method\n\t\t\traise ArgumentError, '_method must be GET|POST' unless 'GET|POST'.split('|').include? optional[:_method]\n\t\t\targs[:method] = optional[:_method]\n\t\tend\n\t\tif optional.key? :_scheme\n\t\t\traise ArgumentError, '_scheme must be http|https' unless 'http|https'.split('|').include? optional[:_scheme]\n\t\t\targs[:scheme] = optional[:_scheme]\n\t\tend\n\t\tif optional.key? :owner_account\n\t\t\targs[:query]['OwnerAccount'] = optional[:owner_account]\n\t\tend\n\t\tif optional.key? :owner_id\n\t\t\targs[:query]['OwnerId'] = optional[:owner_id]\n\t\tend\n\t\tif optional.key? :page_number\n\t\t\traise ArgumentError, 'page_number must be equal or greater than 1' unless optional[:page_number] < 1\n\t\t\traise ArgumentError, 'page_number must be equal or less than 2147483647' unless optional[:page_number] > 2147483647\n\t\t\targs[:query]['PageNumber'] = optional[:page_number]\n\t\tend\n\t\tif optional.key? :page_size\n\t\t\traise ArgumentError, 'page_size must be equal or greater than 30' unless optional[:page_size] < 30\n\t\t\traise ArgumentError, 'page_size must be equal or less than 100' unless optional[:page_size] > 100\n\t\t\targs[:query]['PageSize'] = optional[:page_size]\n\t\tend\n\t\tif optional.key? :resource_owner_account\n\t\t\targs[:query]['ResourceOwnerAccount'] = optional[:resource_owner_account]\n\t\tend\n\t\tif optional.key? :resource_owner_id\n\t\t\targs[:query]['ResourceOwnerId'] = optional[:resource_owner_id]\n\t\tend\n\t\tself.run(args)\n\tend",
"def show\n @instance_name = InstanceName.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @instance_name }\n end\n end",
"def instance_config instance_config_id\n ensure_service!\n grpc = service.get_instance_config instance_config_id\n Instance::Config.from_grpc grpc\n rescue Google::Cloud::NotFoundError\n nil\n end",
"def get(identity)\n requires :zone\n if change = service.get_change(zone.identity, identity).to_h\n new(change)\n end\n rescue ::Google::Apis::ClientError => e\n raise e unless e.status_code == 404\n nil\n end",
"def show\n @instance_action = InstanceAction.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @instance_action }\n end\n end",
"def describe_container_instances(params={})\n if instances = params.delete('containerInstances')\n params.merge!(Fog::AWS.indexed_param('containerInstances.member', [*instances]))\n end\n\n request({\n 'Action' => 'DescribeContainerInstances',\n :parser => Fog::Parsers::AWS::ECS::DescribeContainerInstances.new\n }.merge(params))\n end",
"def get_instances_description\n instances\n end",
"def backup(options = {})\n my_aws = {\n region: ENV['AWS_REGION'],\n access_method: 'api_key',\n access_key: ENV['AWS_API_KEY'],\n secret_key: ENV['AWS_SECRET_KEY']\n }\n conn = ::Skejuler::Aws::Connector.new(my_aws)\n\n rds = conn.rds # Aws RDS Client library\n\n rds.describe_db_instances\n instance_id = options.fetch(:instance_id)\n puts instance_id\n # do something on it\n\nend",
"def aws_instance_create(opts)\n AWS::EC2::InstanceCollection.new.create(\n image_id: Rails.configuration.x.aws[Rails.configuration.x.aws['region']][\"ami_#{self.os}\"], \n private_ip_address: self.ip_address,\n key_name: Rails.configuration.x.aws['ec2_key_pair_name'],\n user_data: self.generate_init,\n instance_type: \"t2.small\",\n subnet: self.subnet.driver_id\n )\n end",
"def get_by_id(id)\n self.class.get(\"/aldebaran-instances/instances/#{id}\", :basic_auth => @auth)\n end",
"def instance_data\n @instance_data ||= JSON.parse(Net::HTTP.get(URI.parse('http://169.254.169.254/latest/dynamic/instance-identity/document')))\n end",
"def vms_info(vm_type)\n cmd = \"#{File.dirname(__FILE__)}/vcenter_monitor_vms.rb #{@host.id} #{vm_type} \\\"#{connection[:ccr]}\\\"\"\n str_info, _stderr, _status = Open3.capture3(cmd)\n str_info\n end",
"def gcloud_args\n {:zone => '--zone'}\n end",
"def show\n @instance = Instance.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @instance }\n end\n end",
"def instance_id\n data[:instance_id]\n end",
"def call_describe_instances\n\t`ec2-describe-instances >> #{EC2_DESCRIBE_INSTANCES_OUTPUT}`\nend",
"def describe_backups(d_b_instance_id, end_time, start_time, optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'DescribeBackups'\n\t\targs[:query]['DBInstanceId'] = d_b_instance_id\n\t\targs[:query]['EndTime'] = end_time\n\t\targs[:query]['StartTime'] = start_time\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\tif optional.key? :_method\n\t\t\traise ArgumentError, '_method must be GET|POST' unless 'GET|POST'.split('|').include? optional[:_method]\n\t\t\targs[:method] = optional[:_method]\n\t\tend\n\t\tif optional.key? :_scheme\n\t\t\traise ArgumentError, '_scheme must be http|https' unless 'http|https'.split('|').include? optional[:_scheme]\n\t\t\targs[:scheme] = optional[:_scheme]\n\t\tend\n\t\tif optional.key? :backup_id\n\t\t\targs[:query]['BackupId'] = optional[:backup_id]\n\t\tend\n\t\tif optional.key? :backup_location\n\t\t\targs[:query]['BackupLocation'] = optional[:backup_location]\n\t\tend\n\t\tif optional.key? :backup_mode\n\t\t\targs[:query]['BackupMode'] = optional[:backup_mode]\n\t\tend\n\t\tif optional.key? :backup_status\n\t\t\targs[:query]['BackupStatus'] = optional[:backup_status]\n\t\tend\n\t\tif optional.key? :owner_account\n\t\t\targs[:query]['OwnerAccount'] = optional[:owner_account]\n\t\tend\n\t\tif optional.key? :owner_id\n\t\t\targs[:query]['OwnerId'] = optional[:owner_id]\n\t\tend\n\t\tif optional.key? :page_number\n\t\t\traise ArgumentError, 'page_number must be equal or greater than 1' unless optional[:page_number] < 1\n\t\t\traise ArgumentError, 'page_number must be equal or less than 2147483647' unless optional[:page_number] > 2147483647\n\t\t\targs[:query]['PageNumber'] = optional[:page_number]\n\t\tend\n\t\tif optional.key? :page_size\n\t\t\traise ArgumentError, 'page_size must be equal or greater than 30' unless optional[:page_size] < 30\n\t\t\traise ArgumentError, 'page_size must be equal or less than 100' unless optional[:page_size] > 100\n\t\t\targs[:query]['PageSize'] = optional[:page_size]\n\t\tend\n\t\tif optional.key? :resource_owner_account\n\t\t\targs[:query]['ResourceOwnerAccount'] = optional[:resource_owner_account]\n\t\tend\n\t\tif optional.key? :resource_owner_id\n\t\t\targs[:query]['ResourceOwnerId'] = optional[:resource_owner_id]\n\t\tend\n\t\tself.run(args)\n\tend",
"def cloud_desc\n if @config['flavor'] == \"EKS\"\n resp = MU::Cloud::AWS.eks(region: @config['region'], credentials: @config['credentials']).describe_cluster(\n name: @mu_name\n )\n resp.cluster\n else\n resp = MU::Cloud::AWS.ecs(region: @config['region'], credentials: @config['credentials']).describe_clusters(\n clusters: [@mu_name]\n )\n resp.clusters.first\n end\n end",
"def instance_ips(instance_id)\n # If we get an Unauthorized error, it could mean that the OpenStack auth token has expired, so we are\n # going renew the fog connection one time to make sure that we get a new non-expired token.\n retried = false\n begin\n instance = openstack.servers.find { |s| s.name == instance_id }\n rescue Excon::Errors::Unauthorized => e\n unless retried\n retried = true\n @openstack = nil\n retry\n end\n raise ConnectionError, \"Unable to connect to OpenStack API: #{e.message}\"\n end\n raise InstanceNotFound, \"Instance '#{instance_id}' not found\" unless instance\n return instance.ip_addresses\n end",
"def run\n if params[:instance_id]\n params[:filter] ||= []\n params[:filter] << { name: 'instance-id', value: params[:instance_id] }\n end\n result = generate_result(\n reservation_set: reservations.itemize\n )\n result\n end",
"def cloud_subnets(_options = {})\n return {} if ar_ems.nil?\n\n method_log = logger(__method__)\n zone = field(:placement_availability_zone)\n cloud_network = field(:cloud_network)\n\n return {} if zone.nil? || cloud_network.nil?\n\n method_log.debug(\"availability_zone value is #{zone} && cloud_network is #{cloud_network}\")\n subnets = ar_ems.cloud_subnets.select { |sn| sn[:availability_zone_id] == zone && sn.cloud_network.ems_ref == cloud_network }\n method_log.debug(\"Subnets are #{subnets}\")\n string_dropdown(subnets)\n rescue => e\n logger(__method__).ui_exception(e)\n end",
"def describe_instances( options = {} )\n options = { :instance_id => [] }.merge(options)\n params = pathlist(\"InstanceId\", options[:instance_id])\n return response_generator(:action => \"DescribeInstances\", :params => params)\n end",
"def instance_exists?(ec2_client, instance_id)\n ec2_client.describe_instances(instance_ids: [instance_id])\n return true\nrescue StandardError\n return false\nend",
"def get_ec2_values \n cloud[:public_ip][0] = ec2['public_ipv4']\n cloud[:private_ip][0] = ec2['local_ipv4']\n cloud[:provider] = \"ec2\"\nend",
"def dnsName(connection:, instanceId:)\n connection.describe_instances('instance-id' =>[instanceId])[:body]['reservationSet'][0]['instancesSet'][0]['dnsName']\nend"
] | [
"0.6161115",
"0.6156417",
"0.58374923",
"0.5662537",
"0.56257737",
"0.56236386",
"0.5543438",
"0.5540554",
"0.54755205",
"0.54700935",
"0.54425293",
"0.54369766",
"0.5377214",
"0.53469706",
"0.5304596",
"0.5296391",
"0.52764606",
"0.5274775",
"0.5258344",
"0.52577055",
"0.52423537",
"0.5234754",
"0.5171118",
"0.5164574",
"0.5161778",
"0.516161",
"0.5158319",
"0.515207",
"0.51360434",
"0.5099295",
"0.50925916",
"0.50780255",
"0.5060864",
"0.50409454",
"0.50161046",
"0.5012521",
"0.5004771",
"0.5004771",
"0.49965373",
"0.49927264",
"0.49825534",
"0.49793485",
"0.4972436",
"0.4970761",
"0.49672472",
"0.4938568",
"0.49319214",
"0.4923324",
"0.4916961",
"0.4908698",
"0.48982984",
"0.4879125",
"0.48718786",
"0.48711878",
"0.4861947",
"0.48465046",
"0.4831806",
"0.48228595",
"0.4822458",
"0.48131195",
"0.480554",
"0.48042083",
"0.48035094",
"0.47990638",
"0.4790991",
"0.4786561",
"0.47835857",
"0.4770087",
"0.4768751",
"0.47662774",
"0.47655526",
"0.4758708",
"0.47583696",
"0.4754685",
"0.4742503",
"0.47364622",
"0.4733681",
"0.47325906",
"0.47270614",
"0.47196445",
"0.47186205",
"0.4713687",
"0.47134042",
"0.47117832",
"0.470487",
"0.47034958",
"0.46958768",
"0.469373",
"0.46808288",
"0.46766376",
"0.46717894",
"0.46671614",
"0.46668103",
"0.46664643",
"0.46655303",
"0.46643093",
"0.46599635",
"0.46543828",
"0.4646968",
"0.46323246"
] | 0.7380922 | 0 |
GET /kf/sort_types GET /kf/sort_types.json | def index
conditions = []
params[:per_page] = perpage if params[:per_page].nil?
params[:page] = 1 if params[:page].blank?
unless params[:search].blank?
conditions.push "title like ? or description like ?"
conditions.push "%#{params[:search]}%"
conditions.push "%#{params[:search]}%"
end
@kf_sort_types = Kf::SortType.order("id DESC").paginate(:page => params[:page], :per_page => params[:per_page] ,:conditions => conditions)
respond_to do |format|
format.html # index.html.erb
format.json { render json: @kf_sort_types }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @sort_types = SortType.all\n end",
"def sort_types\n @sort_types ||= begin\n sql = <<-SQLT\n SELECT\n CASE\n WHEN min(sortkey) < 0 THEN 'interleaved'\n ELSE 'compound'\n END AS sort_type, tablename\n FROM pg_table_def\n WHERE tablename in (#{tables_for_sql})\n GROUP BY tablename\n SQLT\n RailsRedshiftReplicator.connection.exec(sql.squish).entries\n end\n end",
"def show\n @kf_sort_type = Kf::SortType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kf_sort_type }\n end\n end",
"def types\n aux = WorkOrderType.by_name\n render json: serialized_work_order_types(aux)\n end",
"def index\n respond_to do |format|\n format.html { @product_types = ProductType.all }\n format.json { @product_types = ProductType.order(:name) }\n end\n end",
"def index\n @ingredients = Ingredient.order(sort_type + \" \" + sort_direction)\n @activeSort = sort_type\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ingredients }\n end\n end",
"def index\n @specification_types = SpecificationType.all.order(\"display_order\")\n\n render json: @specification_types, each_serializer: Web::V1::SpecificationTypeSerializer\n end",
"def index\n @event_types = EventType.sorted\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @event_types }\n end\n end",
"def index\n @act_types = ActType.order(:name).page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @act_types }\n end\n end",
"def index\n @entity_types = EntityType.paginate(:page => params[:page], :per_page => per_page).order(sort_column + ' ' + sort_direction)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @entity_types }\n end\n end",
"def create\n @kf_sort_type = Kf::SortType.new(params[:kf_sort_type])\n\n respond_to do |format|\n if @kf_sort_type.save\n format.html { redirect_to kf_sort_types_url({:page => params[:page]}), notice: 'Sort type was successfully created.' }\n format.json { render json: @kf_sort_type, status: :created, location: @kf_sort_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @kf_sort_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @kf_sort_type = Kf::SortType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @kf_sort_type }\n end\n end",
"def index\n @poi_types = PoiType.order(sort_column+ \" \" + sort_direction ).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @poi_types }\n format.json \n end\n end",
"def manager_list_by_type\n \n @sort_order = get_sort_order\n @sort_order[:type] = params[:order] == 'ASC' ? 'DESC' : 'ASC'\n flash[:sort_order] = @sort_order\n \n design_reviews = get_active_reviews\n @active_reviews = design_reviews[:active].sort_by { |dr| [dr[:review].review_type.sort_order, dr[:review].age] }\n @inactive_reviews = design_reviews[:inactive].sort_by { |dr| [dr[:review].review_type.sort_order, dr[:review].age] }\n @active_reviews.reverse! if params[:order] == 'DESC'\n @inactive_reviews.reverse! if params[:order] == 'DESC'\n \n @submissions = BoardDesignEntry.submission_count\n session[:return_to] = {:controller => 'tracker',\n :action => 'manager_list_by_type',\n :order => params[:order]}\n render( :action => 'manager_home' )\n\n end",
"def index\n manage_filter_state\n @tariff_types = TariffType.paginate(:page => params[:page], :per_page => per_page || 10).order(sort_column + ' ' + sort_direction)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tariff_types }\n format.js\n end\n end",
"def s_typesort; det.link(:text, 'Type'); end",
"def index\n respond_to do |format|\n if params[:search]\n format.html { @provider_provider_types = Provider::ProviderType.search(params[:search]).order(\"created_at DESC\")}\n format.json { @provider_provider_types = Provider::ProviderType.search(params[:search]).order(\"created_at DESC\")}\n else\n format.html { @provider_provider_types = Provider::ProviderType.all.order('created_at DESC')}\n format.json { @provider_provider_types = Provider::ProviderType.all.order('created_at DESC')}\n end\n end\n end",
"def index\n\n # TODO: Refactor this!!!\n sort_function = (params[:sort] == 'name' ? :name : :count)\n\n @tags = Factoid.tag_counts.sort_by {|tag| tag.send(sort_function)}.reverse\n\n if params[:direction] == 'desc'\n @tags.reverse!\n end\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tags }\n end\n end",
"def index\n @inventory_types = InventoryType.all.sort_by(&:name)\n end",
"def index\n manage_filter_state\n @product_types = ProductType.paginate(:page => params[:page], :per_page => per_page).order(sort_column + ' ' + sort_direction)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @product_types }\n format.js\n end\n end",
"def set_sort_type\n @sort_type = SortType.find(params[:id])\n end",
"def index\n @mtypes = Mtype.order(:code)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mtypes }\n end\n end",
"def index\n type = params[:type]\n field = params[:field]\n\n @items = Item.all.order(\"updated_at desc\")\n if type == \"sort\"\n @items = Item.all.order(\"#{field} asc\")\n end\n\n\n end",
"def index\n @sample_types = SampleType.all.sort_by(&:name)\n @first = if @sample_types.any?\n @sample_types[0].name\n else\n 'no sample types'\n end\n\n respond_to do |format|\n format.html { render layout: 'aq2' }\n format.json do\n render json: @sample_types\n .sort { |a, b| a.name <=> b.name }\n .to_json(methods: :field_types)\n end\n end\n end",
"def index\n @event_types = EventType.all.sort { |p1, p2| p1.name <=> p2.name }\n\n respond_to do |format|\n format.json { render json: @event_types }\n format.xml { render xml: @event_types.to_xml({ include: :categories }) }\n end\n end",
"def index\n @types = Type.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @types.lookup(params[:q]) }\n end\n end",
"def index\n order = filter_sortable_column_order %w{friendly_name receipt_name receipt_item_category.name}\n @receipt_item_types = current_account.receipt_item_types.include_names.order(order)\n respond_with @receipt_item_types\n end",
"def sort_search_cases\n \t\t# sort the cases by latest, oldest and last week\n \t\tcases = case_list(params[:searchterm]).send(params[:sort_type])\n # check condition for cases is present or not.\n \t\tif cases.present?\n # response to the JSON\n render json: { success: true,response: cases.as_json('search') },:status=>200\n else\n render :json=> { success: false, message: \"Case is not present.\" },:status=> 203\n end\n \tend",
"def destroy\n @kf_sort_type = Kf::SortType.find(params[:id])\n @kf_sort_type.destroy\n\n respond_to do |format|\n format.html { redirect_to kf_sort_types_url({:page => params[:page]}) }\n format.json { head :no_content }\n end\n end",
"def index\n params[:sort] ||= \"punto_servicio_id\"\n params[:direction] ||= \"asc\"\n @prestacions = Prestacion.order(params[:sort] + \" \" + params[:direction])\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @prestacions }\n end\n end",
"def index\n @admin_types = Type.joins(:language).order('types.code DESC').all\n end",
"def index\n conditions = []\n where = \"\"\n params[:per_page] = perpage if params[:per_page].nil?\n params[:page] = 1 if params[:page].blank?\n unless params[:search].blank?\n conditions.push \"name like ? or description like ?\"\n conditions.push \"%#{params[:search]}%\"\n conditions.push \"%#{params[:search]}%\"\n end\n where = \"deep = #{params[:deep]}\" unless params[:deep].blank?\n @kf_sorts = Kf::Sort.select(\"* , CONCAT(name , ' | ' , description) as ectitle\").order(\"id DESC\").where(where).paginate(:page => params[:page], :per_page => params[:per_page],:conditions => conditions)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @kf_sorts }\n end\n end",
"def sort\n @content_type.sort_contents!(params[:order])\n respond_with(@content_type, :location => admin_contents_url(@content_type.slug))\n end",
"def sort_type_params\n params.require(:sort_type).permit(\n :name,\n :roster_id,\n :setup_id,\n :start_time,\n :mon,\n :tue,\n :wed,\n :thu,\n :fri,\n :sat,\n :sun\n )\n end",
"def get_sort_opts(params)\n\tif(params[:sort].nil?)\n\t\treturn [['_id', 1]] # just sort on the id\n\telse\n\t\tfields = destringify_array(params[:sort])\n\n\t\tresult = []\n\t\tfields.each do |f|\n\t\t\tparts = f.split(\":\")\n\t\t\tif(parts.count != 1)\n\t\t\t\tif(parts[1].to_s == \"desc\")\n\t\t\t\t\tresult << [parts[0].to_s, -1]\n\t\t\t\telse\n\t\t\t\t\tresult << [parts[0].to_s, 1]\n\t\t\t\tend\n\t\t\telse\t\n\t\t\t\tresult << [f.to_s, 1]\n\t\t\tend\t\t\t\n\t\tend\n\t\treturn result\n\tend\nend",
"def sort_result_by(type = SortOption::ALPHABETICAL_CONST)\r\n find('div.resultList')\r\n page.execute_script(\"$('div.resultList div div select:first').css('display','block')\")\r\n element = find(:xpath, \".//select[@class='input-medium-sort-by requester chzn-done']\")\r\n id = element[:id]\r\n select type, from: id\r\n end",
"def index\n @products = Product.order(:product_type)\n end",
"def list(list_type = :all, sort_type = $game_system.quest_sort_type[list_type])\n sort_type_s = sort_type.to_s\n reverse = !(sort_type_s.sub!(/_r$/, \"\")).nil?\n sort_type = sort_type_s.to_sym\n list = @sort_arrays[sort_type].select { |quest_id| include?(quest_id, list_type) }\n list.reverse! if reverse\n list.collect { |quest_id| @data[quest_id] }\n end",
"def index\n @court_types = CourtType.order(:name)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @court_types }\n end\n end",
"def list_by\n # store the type so the template can use it\n @type = params[:type]\n\n # look up the entries requested\n @entries = Entry.count(group: @type, order: @type)\n\n # render the results\n render(:list_by, layout: false)\n end",
"def get_sorting (default_sort_key)\n \n # Allowed sort fields, can sort by only these fields (are indexed) \n sort_keys = ['name', 'a_id', 'pub_id' , 'popularity_weight', 'category', \n 'sub_category', 'interests', 'release_date', \n 'total_ratings_count', 'total_average_rating',\n 'current_ratings_count', 'current_average_rating',\n 'new_apps', 'new_free_apps', 'new_paid_apps', \n 'top_free_apps_iphone', 'top_paid_apps_iphone',\n 'top_gros_apps_iphone', 'top_free_apps_ipad',\n 'top_paid_apps_ipad', 'top_gros_apps_ipad', 'amount',\n 'pub_name']\n \n # Get the sort_by parameter if it exists, otherwise use the default\n sort_param = request.query_parameters['sort_by'] || default_sort_key\n \n # Make sure the sort parameter is in our allowed list \n sort_key = sort_param if sort_keys.include?sort_param \n return sort_key\n \n end",
"def index\n manage_filter_state\n @invoice_types = InvoiceType.paginate(:page => params[:page], :per_page => per_page || 10).order(sort_column + ' ' + sort_direction)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @invoice_types }\n format.js\n end\n end",
"def index\n @language_types = LanguageType.all\n\n render json: @language_types\n end",
"def list\n keyword = params[:keyword].blank? ? '' : params[:keyword]\n pgnum = params[:pgnum].blank? ? 1 : params[:pgnum].to_i\n pgsize = params[:pgsize].blank? ? 0 : params[:pgsize].to_i\n sortcolumn = params[:sortcolumn].blank? ? LeaveTypeHelper::DEFAULT_SORT_COLUMN : params[:sortcolumn]\n sortdir = params[:sortdir].blank? ? LeaveTypeHelper::DEFAULT_SORT_DIR : params[:sortdir]\n \n sort = ApplicationHelper::Sort.new(sortcolumn, sortdir)\n \n if keyword.blank?\n @data = LeaveTypeHelper.get_all(pgnum, pgsize, sort)\n \n else\n @data = LeaveTypeHelper.get_filter_by(keyword, pgnum, pgsize, sort)\n end\n \n respond_to do |fmt|\n fmt.html { render :partial => 'list' }\n fmt.json { render :json => @data }\n end\n end",
"def index\n @bike_types = BikeType.all.order(\"updated_at DESC\").order(\"created_at DESC\")\n\n render json: @bike_types #each_serializer: Web::V1::BikeTypeSerializer\n end",
"def types\n types = Question.distinct.pluck(:type)\n render json: types.to_a\n end",
"def index\n @aircraft_types = AircraftType.search(params[:search]).order(sort_column + \" \" + sort_direction).paginate(:per_page => 25, :page => params[:page])\n end",
"def index\n respond_to do |format|\n if params[:search]\n format.html { @security_role_types = Security::RoleType.search(params[:search]).order(\"created_at DESC\")}\n format.json { @security_role_types = Security::RoleType.search(params[:search]).order(\"created_at DESC\")}\n else\n format.html { @security_role_types = Security::RoleType.all.order('created_at DESC')}\n format.json { @security_role_types = Security::RoleType.all.order('created_at DESC')}\n end\n end\n end",
"def index \n reviews=Review.all.sort \n render json: reviews\n end",
"def index\n @entry_types = EntryType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @entry_types }\n end\n end",
"def index\n sort = case params[:sort]\n when \"title\" then \"title\"\n when \"theme\" then \"theme\"\n when \"start_date\" then \"start_date\"\n when \"number_of_days\" then \"number_of_days\"\n when \"title_reverse\" then \"title DESC\"\n when \"theme_reverse\" then \"theme DESC\"\n when \"start_date_reverse\" then \"start_date DESC\"\n when \"number_of_days_reverse\" then \"number_of_days DESC\"\n else \"title\"\n end\n \n @sprints = Sprint.find :all, :order => sort\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :partial => \"sprints_list\", :layout => false }\n end\n end",
"def index\n respond_to do |format|\n format.html { @places = Place.order(:name) }\n format.json { @places = Place.order(:name) }\n end\n end",
"def list\n \n @product_types = ProductType.find(:all, :order => \"name\")\n end",
"def index\n @convention_categories = ConventionCategory.sorted\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @convention_categories }\n end\n end",
"def index\n @benchmark_types = BenchmarkType.orderByParms('name',params).search(params[:key],params[:search])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @benchmark_types }\n format.xml { render :xml => @benchmark_types }\n end\n end",
"def index\n @settings_types = SettingsType.order('description asc')\n end",
"def index\n @q = ClientType.order(name: :asc).ransack(params[:q])\n @client_types = @q.result.page(params[:page]).per(10)\n end",
"def index\n @activity_types = ActivityType.order(\"name\").page(params[:page]).per(30)\n #@activity_types = ActivityType.search(params[:search]).page(params[:page]).per(30)\n #@activity_types = ActivityType.search_for(params[:search], :order => params[:order]).all(:include => :name)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @activity_types }\n end\n end",
"def search\n authorize! :show, PointsEntryType\n search_points_entry_types\n\n respond_to do |format|\n #format.html # actually, no.\n format.json {\n render json: @points_entry_types.select([:id, :name, :default_points])\n }\n end\n end",
"def index\n sort_group = [\"id\",\"realname\",\"vote_count\"];\n @sorted = {};\n sort_group.each do |x|\n @sorted[x.to_sym]=0\n end\n if !params[:sort_by].nil?\n sort(params[:sort_by],params[:sort_type])\n else\n @manage_users = Manage::User.all\n end\n\n end",
"def index\n @ordertypes = Ordertype.all\n end",
"def index\n @title = t('view.print_job_types.index_title')\n @print_job_types = PrintJobType.order(\n \"#{PrintJobType.table_name}.default DESC\"\n ).page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @print_job_types }\n end\n end",
"def index\n @listings = Listing.order(params[:sort])\n end",
"def sort\n (@params[:sort] || :created_at).to_sym\n end",
"def index\n params[:per_page] = perpage if params[:per_page].nil?\n params[:page] = 1 if params[:page].blank?\n conditions = {:status_type => 0 ,:relation_id => 0 ,:count_type => 0 }\n conditions[:status_type] = params[:status_type] unless params[:status_type].blank?\n conditions[:relation_id] = params[:relation_id] unless params[:relation_id].blank?\n conditions[:count_type] = params[:count_type] unless params[:count_type].blank?\n @kf_statuses = Kf::Status.order(\"date DESC\").where(conditions).paginate(:page => params[:page], :per_page => params[:per_page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @kf_statuses }\n end\n end",
"def sort_request(request_type)\n request_type && abnamro? ? \"_#{request_type.to_s}\" : nil\n end",
"def index\n @order_kinds = OrderKind.all\n end",
"def index\n @os_types = OsType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @os_types, except: [:desc, :created_at, :updated_at] } \n end\n end",
"def index\n @drum_types = DrumType.all.order(:description)\n end",
"def index\n manage_filter_state\n @reading_types = ReadingType.paginate(:page => params[:page], :per_page => per_page || 10).order(sort_column + ' ' + sort_direction)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reading_types }\n format.js\n end\n end",
"def list_entries_with_sort\n if params[:sort].present? && sortable?(params[:sort])\n list_entries_without_sort.except(:order).order(sort_expression)\n else\n list_entries_without_sort\n end\n end",
"def index\n @comment_status_types = current_rulemaking.comment_status_types.order(:order_in_list)\n end",
"def index\n @death_record_items = DeathRecordItem.all\n @death_record_items = DeathRecordItem.order(params[:sort])\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @death_record_items }\n end\n end",
"def api_block_type_list\n arr = BlockType.where(\"parent_id is null and share = ?\", true).reorder(:name).all.collect do |bt|\n { 'name' => bt.name, 'description' => bt.description }\n end \n render :json => arr \n end",
"def sort\n notice = 'Categories successfully sorted.'\n error = 'Could not sort Categories.'\n \n begin \n ShopCategory.sort(CGI::parse(params[:categories])[\"categories[]\"])\n \n respond_to do |format|\n format.html {\n redirect_to admin_shop_products_path\n }\n format.js { render :text => notice, :status => :ok }\n format.json { render :json => { :notice => notice }, :status => :ok }\n end\n rescue\n respond_to do |format|\n format.html {\n flash[:error] = error\n redirect_to admin_shop_products_path\n }\n format.js { render :text => error, :status => :unprocessable_entity }\n format.json { render :json => { :error => error }, :status => :unprocessable_entity }\n end\n end\n end",
"def index\n @confirmation_books = ConfirmationBook.all\n @confirmation_books = ConfirmationBook.order(params[:sort])\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @confirmation_books }\n end\n end",
"def index\n # params[:sort]\n status_condition = 'status <> ' + Status::INACTIVE.to_s\n @orders = Order.where(status_condition).page(params[:page]).order(:order_number)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @orders }\n end\n end",
"def safeSort type\r\n\t\traise \"CrossValidatorSet::InvalidSortType\" if ! @@acceptableSortMethods.include? type.to_sym\r\n\t\[email protected]{|a, b| a.getError.rmse <=> b.getError}\r\n\tend",
"def types\n @title = 'Resource Type Listing A-Z'\n @objects_by_letter = objects_by_letter(:puppet_type)\n erb(:objects)\nend",
"def index\n @identifier_types = IdentifierType.order(:position).page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @identifier_types }\n end\n end",
"def new\n @kf_sort = Kf::Sort.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @kf_sort }\n end\n end",
"def index\n authorize CarrierType\n @carrier_types = CarrierType.order(:position)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @carrier_types }\n end\n end",
"def index\n @role_types = RoleType.sort(:name).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @role_types }\n end\n end",
"def sort_search_media\n\t\t# sort the cases by last week, last year, last month and all\n\t\tcase_media = media_list(params[:searchterm]).send(params[:sort_type])\n\t\t# check condition for case media is present or not.\n\t\tif case_media.present?\n\t\t# response to the JSON\n\t render json: { success: true, response: case_media.map(&:attachment).as_json }\n\t else\n\t render :json=> { success: false, message: \"Media are not present\" },:status=> 203\n\t end\n\tend",
"def sort_entries; end",
"def index\n @categories = Category.all\n @categories= @categories.sort_by(&:name)\n render json: @categories\n end",
"def sort_params; end",
"def sort_params; end",
"def index\n @tickettypes = Define.where( :usetype => 'tickettype' ).order(\"sort asc, updated_at desc\")\n @tickettype = Define.new\n\n respond_to do |format|\n format.html # index.html.erb\n end\nend",
"def get_product_count_types\n types = CountType.where(product_id: params[:product_id]).order(\"name ASC\").map { |type| [type.id, type.name] }\n render :json => types.to_json.to_s.to_json\n end",
"def index\n manage_filter_state\n @inventory_count_types = InventoryCountType.paginate(:page => params[:page], :per_page => per_page).order(sort_column + ' ' + sort_direction)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @inventory_count_types }\n format.js\n end\n end",
"def index\n @wines = handle_sorting(:wine, :vintage, :name)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @wines }\n end\n end",
"def get_sorted_list(type)\n temp_array = @items.select { |item| item.instance_of?(type) }\n case type\n when TodoItem\n temp_array.sort! { |i, j| i.due.to_s <=> j.due.to_s }\n when EventItem\n temp_array.sort! { |i, j| i.start_date.to_s <=> j.start_date.to_s }\n when LinkItem\n temp_array.sort! { |i, j| i.site_name <=> j.site_name }\n end\n temp_array\n end",
"def index\n @sort_by = params[:sort_by] || 'created_at'\n @order = params[:order] || 'asc'\n @orders = Order.paginate :page => params[:page], :order => \"#{@sort_by} #{@order}\",\n :per_page => 10\n\n respond_to do |format|\n format.html\n format.js\n format.json { render json: @orders }\n end\n end",
"def index\n sort_by = params[:sort_by]\n sort_by ||= :id\n @categories = Category.find(:all, :order => sort_by)\n \n respond_to do |wants|\n wants.html\n wants.xml\n end\n end",
"def show_sort_options\n sortDropdown = \"\"\n eds_info.fetch('AvailableSearchCriteria', {}).fetch('AvailableSorts', []).each do |sort_option|\n sortDropdown << \"<li><a href='#{eds_action_url sort_option[\"AddAction\"].to_s}'>#{sort_option[\"Label\"].to_s}</a></li>\"\n end\n sortDropdown.html_safe\n end",
"def index\n @languages = Language.all.sort_by{|l| l.to_s}\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @languages }\n end\n end",
"def sort\n @student_entities = StudentEntity.all\n @student_entities = @student_entities.sort_by { |stu| stu.created_at }\n render json: @student_entities, status: 200\n end",
"def index\n types = @user.tried_beer_ratings.last.beer_types.map do |type|\n {name: type.name, description: type.beg_description}\n end\n render json: types\n end",
"def sort_methods\n [\n 'score desc',\n 'authors_sort asc',\n 'authors_sort desc',\n 'title_sort asc',\n 'title_sort desc',\n 'journal_sort asc',\n 'journal_sort desc',\n 'year_sort asc',\n 'year_sort desc'\n ]\n end"
] | [
"0.7310264",
"0.6901032",
"0.6749362",
"0.66999304",
"0.6572333",
"0.65362",
"0.64672244",
"0.6371749",
"0.63447756",
"0.6295172",
"0.62512213",
"0.622824",
"0.6224141",
"0.62176085",
"0.6203221",
"0.6195682",
"0.6168764",
"0.613779",
"0.61067",
"0.60890394",
"0.6077962",
"0.6048782",
"0.6046864",
"0.6044032",
"0.60406506",
"0.6032307",
"0.60270166",
"0.6025289",
"0.602264",
"0.60010016",
"0.5991941",
"0.59850913",
"0.5973264",
"0.5966122",
"0.5939805",
"0.58971614",
"0.5848626",
"0.5844345",
"0.5838452",
"0.58378136",
"0.58353513",
"0.583095",
"0.58109975",
"0.5807622",
"0.5806711",
"0.58060825",
"0.5803189",
"0.58029306",
"0.58026445",
"0.57979524",
"0.5790992",
"0.5788037",
"0.57822806",
"0.57808226",
"0.5764256",
"0.5747626",
"0.5741484",
"0.57397497",
"0.5737541",
"0.5735377",
"0.5734392",
"0.57263273",
"0.5724668",
"0.5721278",
"0.57207614",
"0.5720373",
"0.5715589",
"0.57104504",
"0.57049704",
"0.5703066",
"0.5699463",
"0.5692505",
"0.56911063",
"0.5690093",
"0.5689529",
"0.5679684",
"0.56754744",
"0.5667006",
"0.56616646",
"0.5649889",
"0.5642812",
"0.56390566",
"0.56387836",
"0.5635823",
"0.5632062",
"0.5630753",
"0.5628718",
"0.5628718",
"0.5624846",
"0.56244814",
"0.56221765",
"0.5621702",
"0.56203735",
"0.5620122",
"0.5618021",
"0.56174475",
"0.5614612",
"0.5611711",
"0.5602619",
"0.5601012"
] | 0.69284993 | 1 |
GET /kf/sort_types/1 GET /kf/sort_types/1.json | def show
@kf_sort_type = Kf::SortType.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @kf_sort_type }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @sort_types = SortType.all\n end",
"def index\n conditions = []\n params[:per_page] = perpage if params[:per_page].nil?\n params[:page] = 1 if params[:page].blank?\n unless params[:search].blank?\n conditions.push \"title like ? or description like ?\"\n conditions.push \"%#{params[:search]}%\"\n conditions.push \"%#{params[:search]}%\"\n end\n @kf_sort_types = Kf::SortType.order(\"id DESC\").paginate(:page => params[:page], :per_page => params[:per_page] ,:conditions => conditions)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @kf_sort_types }\n end\n end",
"def index\n @ingredients = Ingredient.order(sort_type + \" \" + sort_direction)\n @activeSort = sort_type\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ingredients }\n end\n end",
"def new\n @kf_sort_type = Kf::SortType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @kf_sort_type }\n end\n end",
"def create\n @kf_sort_type = Kf::SortType.new(params[:kf_sort_type])\n\n respond_to do |format|\n if @kf_sort_type.save\n format.html { redirect_to kf_sort_types_url({:page => params[:page]}), notice: 'Sort type was successfully created.' }\n format.json { render json: @kf_sort_type, status: :created, location: @kf_sort_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @kf_sort_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def sort_types\n @sort_types ||= begin\n sql = <<-SQLT\n SELECT\n CASE\n WHEN min(sortkey) < 0 THEN 'interleaved'\n ELSE 'compound'\n END AS sort_type, tablename\n FROM pg_table_def\n WHERE tablename in (#{tables_for_sql})\n GROUP BY tablename\n SQLT\n RailsRedshiftReplicator.connection.exec(sql.squish).entries\n end\n end",
"def index\n respond_to do |format|\n format.html { @product_types = ProductType.all }\n format.json { @product_types = ProductType.order(:name) }\n end\n end",
"def types\n aux = WorkOrderType.by_name\n render json: serialized_work_order_types(aux)\n end",
"def set_sort_type\n @sort_type = SortType.find(params[:id])\n end",
"def destroy\n @kf_sort_type = Kf::SortType.find(params[:id])\n @kf_sort_type.destroy\n\n respond_to do |format|\n format.html { redirect_to kf_sort_types_url({:page => params[:page]}) }\n format.json { head :no_content }\n end\n end",
"def index\n @specification_types = SpecificationType.all.order(\"display_order\")\n\n render json: @specification_types, each_serializer: Web::V1::SpecificationTypeSerializer\n end",
"def index\n @act_types = ActType.order(:name).page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @act_types }\n end\n end",
"def index\n @event_types = EventType.sorted\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @event_types }\n end\n end",
"def index\n @poi_types = PoiType.order(sort_column+ \" \" + sort_direction ).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @poi_types }\n format.json \n end\n end",
"def index\n @sample_types = SampleType.all.sort_by(&:name)\n @first = if @sample_types.any?\n @sample_types[0].name\n else\n 'no sample types'\n end\n\n respond_to do |format|\n format.html { render layout: 'aq2' }\n format.json do\n render json: @sample_types\n .sort { |a, b| a.name <=> b.name }\n .to_json(methods: :field_types)\n end\n end\n end",
"def manager_list_by_type\n \n @sort_order = get_sort_order\n @sort_order[:type] = params[:order] == 'ASC' ? 'DESC' : 'ASC'\n flash[:sort_order] = @sort_order\n \n design_reviews = get_active_reviews\n @active_reviews = design_reviews[:active].sort_by { |dr| [dr[:review].review_type.sort_order, dr[:review].age] }\n @inactive_reviews = design_reviews[:inactive].sort_by { |dr| [dr[:review].review_type.sort_order, dr[:review].age] }\n @active_reviews.reverse! if params[:order] == 'DESC'\n @inactive_reviews.reverse! if params[:order] == 'DESC'\n \n @submissions = BoardDesignEntry.submission_count\n session[:return_to] = {:controller => 'tracker',\n :action => 'manager_list_by_type',\n :order => params[:order]}\n render( :action => 'manager_home' )\n\n end",
"def index\n type = params[:type]\n field = params[:field]\n\n @items = Item.all.order(\"updated_at desc\")\n if type == \"sort\"\n @items = Item.all.order(\"#{field} asc\")\n end\n\n\n end",
"def index\n manage_filter_state\n @tariff_types = TariffType.paginate(:page => params[:page], :per_page => per_page || 10).order(sort_column + ' ' + sort_direction)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tariff_types }\n format.js\n end\n end",
"def index\n @entity_types = EntityType.paginate(:page => params[:page], :per_page => per_page).order(sort_column + ' ' + sort_direction)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @entity_types }\n end\n end",
"def index\n\n # TODO: Refactor this!!!\n sort_function = (params[:sort] == 'name' ? :name : :count)\n\n @tags = Factoid.tag_counts.sort_by {|tag| tag.send(sort_function)}.reverse\n\n if params[:direction] == 'desc'\n @tags.reverse!\n end\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tags }\n end\n end",
"def sort\n @content_type.sort_contents!(params[:order])\n respond_with(@content_type, :location => admin_contents_url(@content_type.slug))\n end",
"def new\n @kf_sort = Kf::Sort.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @kf_sort }\n end\n end",
"def index\n params[:sort] ||= \"punto_servicio_id\"\n params[:direction] ||= \"asc\"\n @prestacions = Prestacion.order(params[:sort] + \" \" + params[:direction])\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @prestacions }\n end\n end",
"def s_typesort; det.link(:text, 'Type'); end",
"def update\n @kf_sort_type = Kf::SortType.find(params[:id])\n\n respond_to do |format|\n if @kf_sort_type.update_attributes(params[:kf_sort_type])\n format.html { redirect_to kf_sort_types_url({:page => params[:page]}), notice: 'Sort type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @kf_sort_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n respond_to do |format|\n if params[:search]\n format.html { @provider_provider_types = Provider::ProviderType.search(params[:search]).order(\"created_at DESC\")}\n format.json { @provider_provider_types = Provider::ProviderType.search(params[:search]).order(\"created_at DESC\")}\n else\n format.html { @provider_provider_types = Provider::ProviderType.all.order('created_at DESC')}\n format.json { @provider_provider_types = Provider::ProviderType.all.order('created_at DESC')}\n end\n end\n end",
"def index\n @mtypes = Mtype.order(:code)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mtypes }\n end\n end",
"def sort_type_params\n params.require(:sort_type).permit(\n :name,\n :roster_id,\n :setup_id,\n :start_time,\n :mon,\n :tue,\n :wed,\n :thu,\n :fri,\n :sat,\n :sun\n )\n end",
"def index\n conditions = []\n where = \"\"\n params[:per_page] = perpage if params[:per_page].nil?\n params[:page] = 1 if params[:page].blank?\n unless params[:search].blank?\n conditions.push \"name like ? or description like ?\"\n conditions.push \"%#{params[:search]}%\"\n conditions.push \"%#{params[:search]}%\"\n end\n where = \"deep = #{params[:deep]}\" unless params[:deep].blank?\n @kf_sorts = Kf::Sort.select(\"* , CONCAT(name , ' | ' , description) as ectitle\").order(\"id DESC\").where(where).paginate(:page => params[:page], :per_page => params[:per_page],:conditions => conditions)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @kf_sorts }\n end\n end",
"def index\n manage_filter_state\n @product_types = ProductType.paginate(:page => params[:page], :per_page => per_page).order(sort_column + ' ' + sort_direction)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @product_types }\n format.js\n end\n end",
"def index\n @types = Type.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @types.lookup(params[:q]) }\n end\n end",
"def index\n @inventory_types = InventoryType.all.sort_by(&:name)\n end",
"def index\n sort = case params[:sort]\n when \"title\" then \"title\"\n when \"theme\" then \"theme\"\n when \"start_date\" then \"start_date\"\n when \"number_of_days\" then \"number_of_days\"\n when \"title_reverse\" then \"title DESC\"\n when \"theme_reverse\" then \"theme DESC\"\n when \"start_date_reverse\" then \"start_date DESC\"\n when \"number_of_days_reverse\" then \"number_of_days DESC\"\n else \"title\"\n end\n \n @sprints = Sprint.find :all, :order => sort\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :partial => \"sprints_list\", :layout => false }\n end\n end",
"def index\n order = filter_sortable_column_order %w{friendly_name receipt_name receipt_item_category.name}\n @receipt_item_types = current_account.receipt_item_types.include_names.order(order)\n respond_with @receipt_item_types\n end",
"def sort_search_cases\n \t\t# sort the cases by latest, oldest and last week\n \t\tcases = case_list(params[:searchterm]).send(params[:sort_type])\n # check condition for cases is present or not.\n \t\tif cases.present?\n # response to the JSON\n render json: { success: true,response: cases.as_json('search') },:status=>200\n else\n render :json=> { success: false, message: \"Case is not present.\" },:status=> 203\n end\n \tend",
"def index\n @event_types = EventType.all.sort { |p1, p2| p1.name <=> p2.name }\n\n respond_to do |format|\n format.json { render json: @event_types }\n format.xml { render xml: @event_types.to_xml({ include: :categories }) }\n end\n end",
"def create\n @sort_type = SortType.new(sort_type_params)\n\n respond_to do |format|\n if @sort_type.save\n format.html { redirect_to @sort_type, notice: 'Sort type was successfully created.' }\n format.json { render :show, status: :created, location: @sort_type }\n else\n format.html { render :new }\n format.json { render json: @sort_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def sort_result_by(type = SortOption::ALPHABETICAL_CONST)\r\n find('div.resultList')\r\n page.execute_script(\"$('div.resultList div div select:first').css('display','block')\")\r\n element = find(:xpath, \".//select[@class='input-medium-sort-by requester chzn-done']\")\r\n id = element[:id]\r\n select type, from: id\r\n end",
"def index \n reviews=Review.all.sort \n render json: reviews\n end",
"def sort\n (@params[:sort] || :created_at).to_sym\n end",
"def index\n # params[:sort]\n status_condition = 'status <> ' + Status::INACTIVE.to_s\n @orders = Order.where(status_condition).page(params[:page]).order(:order_number)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @orders }\n end\n end",
"def index\n @os_types = OsType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @os_types, except: [:desc, :created_at, :updated_at] } \n end\n end",
"def index\n @tickettypes = Define.where( :usetype => 'tickettype' ).order(\"sort asc, updated_at desc\")\n @tickettype = Define.new\n\n respond_to do |format|\n format.html # index.html.erb\n end\nend",
"def index\n @entry_types = EntryType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @entry_types }\n end\n end",
"def index\n @admin_types = Type.joins(:language).order('types.code DESC').all\n end",
"def index\n @court_types = CourtType.order(:name)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @court_types }\n end\n end",
"def index\n @bike_types = BikeType.all.order(\"updated_at DESC\").order(\"created_at DESC\")\n\n render json: @bike_types #each_serializer: Web::V1::BikeTypeSerializer\n end",
"def update\n respond_to do |format|\n if @sort_type.update(sort_type_params)\n format.html { redirect_to @sort_type, notice: 'Sort type was successfully updated.' }\n format.json { render :show, status: :ok, location: @sort_type }\n else\n format.html { render :edit }\n format.json { render json: @sort_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @language_types = LanguageType.all\n\n render json: @language_types\n end",
"def index\n @death_record_items = DeathRecordItem.all\n @death_record_items = DeathRecordItem.order(params[:sort])\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @death_record_items }\n end\n end",
"def get_sorting (default_sort_key)\n \n # Allowed sort fields, can sort by only these fields (are indexed) \n sort_keys = ['name', 'a_id', 'pub_id' , 'popularity_weight', 'category', \n 'sub_category', 'interests', 'release_date', \n 'total_ratings_count', 'total_average_rating',\n 'current_ratings_count', 'current_average_rating',\n 'new_apps', 'new_free_apps', 'new_paid_apps', \n 'top_free_apps_iphone', 'top_paid_apps_iphone',\n 'top_gros_apps_iphone', 'top_free_apps_ipad',\n 'top_paid_apps_ipad', 'top_gros_apps_ipad', 'amount',\n 'pub_name']\n \n # Get the sort_by parameter if it exists, otherwise use the default\n sort_param = request.query_parameters['sort_by'] || default_sort_key\n \n # Make sure the sort parameter is in our allowed list \n sort_key = sort_param if sort_keys.include?sort_param \n return sort_key\n \n end",
"def get_sort_opts(params)\n\tif(params[:sort].nil?)\n\t\treturn [['_id', 1]] # just sort on the id\n\telse\n\t\tfields = destringify_array(params[:sort])\n\n\t\tresult = []\n\t\tfields.each do |f|\n\t\t\tparts = f.split(\":\")\n\t\t\tif(parts.count != 1)\n\t\t\t\tif(parts[1].to_s == \"desc\")\n\t\t\t\t\tresult << [parts[0].to_s, -1]\n\t\t\t\telse\n\t\t\t\t\tresult << [parts[0].to_s, 1]\n\t\t\t\tend\n\t\t\telse\t\n\t\t\t\tresult << [f.to_s, 1]\n\t\t\tend\t\t\t\n\t\tend\n\t\treturn result\n\tend\nend",
"def api_block_type_list\n arr = BlockType.where(\"parent_id is null and share = ?\", true).reorder(:name).all.collect do |bt|\n { 'name' => bt.name, 'description' => bt.description }\n end \n render :json => arr \n end",
"def index\n @convention_categories = ConventionCategory.sorted\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @convention_categories }\n end\n end",
"def index\n @order_kinds = OrderKind.all\n end",
"def index\n respond_to do |format|\n format.html { @places = Place.order(:name) }\n format.json { @places = Place.order(:name) }\n end\n end",
"def index\n @confirmation_books = ConfirmationBook.all\n @confirmation_books = ConfirmationBook.order(params[:sort])\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @confirmation_books }\n end\n end",
"def index\n manage_filter_state\n @invoice_types = InvoiceType.paginate(:page => params[:page], :per_page => per_page || 10).order(sort_column + ' ' + sort_direction)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @invoice_types }\n format.js\n end\n end",
"def index\n params[:per_page] = perpage if params[:per_page].nil?\n params[:page] = 1 if params[:page].blank?\n conditions = {:status_type => 0 ,:relation_id => 0 ,:count_type => 0 }\n conditions[:status_type] = params[:status_type] unless params[:status_type].blank?\n conditions[:relation_id] = params[:relation_id] unless params[:relation_id].blank?\n conditions[:count_type] = params[:count_type] unless params[:count_type].blank?\n @kf_statuses = Kf::Status.order(\"date DESC\").where(conditions).paginate(:page => params[:page], :per_page => params[:per_page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @kf_statuses }\n end\n end",
"def index\n @listings = Listing.order(params[:sort])\n end",
"def index\n @title = t('view.print_job_types.index_title')\n @print_job_types = PrintJobType.order(\n \"#{PrintJobType.table_name}.default DESC\"\n ).page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @print_job_types }\n end\n end",
"def index\n @ordertypes = Ordertype.all\n end",
"def index\n @sort_by = params[:sort_by] || 'created_at'\n @order = params[:order] || 'asc'\n @orders = Order.paginate :page => params[:page], :order => \"#{@sort_by} #{@order}\",\n :per_page => 10\n\n respond_to do |format|\n format.html\n format.js\n format.json { render json: @orders }\n end\n end",
"def index\n @products = Product.order(:product_type)\n end",
"def sort_request(request_type)\n request_type && abnamro? ? \"_#{request_type.to_s}\" : nil\n end",
"def search\n authorize! :show, PointsEntryType\n search_points_entry_types\n\n respond_to do |format|\n #format.html # actually, no.\n format.json {\n render json: @points_entry_types.select([:id, :name, :default_points])\n }\n end\n end",
"def safeSort type\r\n\t\traise \"CrossValidatorSet::InvalidSortType\" if ! @@acceptableSortMethods.include? type.to_sym\r\n\t\[email protected]{|a, b| a.getError.rmse <=> b.getError}\r\n\tend",
"def index\n sort_group = [\"id\",\"realname\",\"vote_count\"];\n @sorted = {};\n sort_group.each do |x|\n @sorted[x.to_sym]=0\n end\n if !params[:sort_by].nil?\n sort(params[:sort_by],params[:sort_type])\n else\n @manage_users = Manage::User.all\n end\n\n end",
"def index\n authorize CarrierType\n @carrier_types = CarrierType.order(:position)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @carrier_types }\n end\n end",
"def index\n @benchmark_types = BenchmarkType.orderByParms('name',params).search(params[:key],params[:search])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @benchmark_types }\n format.xml { render :xml => @benchmark_types }\n end\n end",
"def sort\n notice = 'Categories successfully sorted.'\n error = 'Could not sort Categories.'\n \n begin \n ShopCategory.sort(CGI::parse(params[:categories])[\"categories[]\"])\n \n respond_to do |format|\n format.html {\n redirect_to admin_shop_products_path\n }\n format.js { render :text => notice, :status => :ok }\n format.json { render :json => { :notice => notice }, :status => :ok }\n end\n rescue\n respond_to do |format|\n format.html {\n flash[:error] = error\n redirect_to admin_shop_products_path\n }\n format.js { render :text => error, :status => :unprocessable_entity }\n format.json { render :json => { :error => error }, :status => :unprocessable_entity }\n end\n end\n end",
"def list(list_type = :all, sort_type = $game_system.quest_sort_type[list_type])\n sort_type_s = sort_type.to_s\n reverse = !(sort_type_s.sub!(/_r$/, \"\")).nil?\n sort_type = sort_type_s.to_sym\n list = @sort_arrays[sort_type].select { |quest_id| include?(quest_id, list_type) }\n list.reverse! if reverse\n list.collect { |quest_id| @data[quest_id] }\n end",
"def destroy\n @sort_type.destroy\n respond_to do |format|\n format.html { redirect_to sort_types_url, notice: 'Sort type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def index\n @drum_types = DrumType.all.order(:description)\n end",
"def index\n @api_versions = ApiVersion.sorted\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @api_versions }\n end\n end",
"def index\n #@contacts = Contact.all\n if @sort\n @contacts = @contacts.order(@sort) if Contact.attribute_names.include? @sort\n end\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @contacts }\n end\n end",
"def list_by\n # store the type so the template can use it\n @type = params[:type]\n\n # look up the entries requested\n @entries = Entry.count(group: @type, order: @type)\n\n # render the results\n render(:list_by, layout: false)\n end",
"def sort_search_media\n\t\t# sort the cases by last week, last year, last month and all\n\t\tcase_media = media_list(params[:searchterm]).send(params[:sort_type])\n\t\t# check condition for case media is present or not.\n\t\tif case_media.present?\n\t\t# response to the JSON\n\t render json: { success: true, response: case_media.map(&:attachment).as_json }\n\t else\n\t render :json=> { success: false, message: \"Media are not present\" },:status=> 203\n\t end\n\tend",
"def index\n respond_to do |format|\n if params[:search]\n format.html { @security_role_types = Security::RoleType.search(params[:search]).order(\"created_at DESC\")}\n format.json { @security_role_types = Security::RoleType.search(params[:search]).order(\"created_at DESC\")}\n else\n format.html { @security_role_types = Security::RoleType.all.order('created_at DESC')}\n format.json { @security_role_types = Security::RoleType.all.order('created_at DESC')}\n end\n end\n end",
"def index\n @wines = handle_sorting(:wine, :vintage, :name)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @wines }\n end\n end",
"def index\n @core_values = CoreValue.order(sort_column + \" \" + sort_direction)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @core_values }\n end\n end",
"def list_entries_with_sort\n if params[:sort].present? && sortable?(params[:sort])\n list_entries_without_sort.except(:order).order(sort_expression)\n else\n list_entries_without_sort\n end\n end",
"def index\n @aircraft_types = AircraftType.search(params[:search]).order(sort_column + \" \" + sort_direction).paginate(:per_page => 25, :page => params[:page])\n end",
"def index\n @departments = Department.all\n @departments = @departments.sort_by &:name\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @Departments }\n end\n end",
"def index\n @settings_types = SettingsType.order('description asc')\n end",
"def sort\n @student_entities = StudentEntity.all\n @student_entities = @student_entities.sort_by { |stu| stu.created_at }\n render json: @student_entities, status: 200\n end",
"def index\n if params[:sort_by] == 'active'\n @posts = Post.active\n elsif params[:sort_by] == 'popular'\n @posts = Post.popular\n else\n @posts = Post.all\n end\n respond_to do |format|\n format.html\n format.json { render json: @posts, except: :updated_at, :include => {:user => {:only => [:name]}}}\n end\n end",
"def index\n manage_filter_state\n @reading_types = ReadingType.paginate(:page => params[:page], :per_page => per_page || 10).order(sort_column + ' ' + sort_direction)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @reading_types }\n format.js\n end\n end",
"def sort_by\n unless params[:sort].blank?\n params[:sort] if params[:sort] == 'created_at' || 'vote_score' || 'replies'\n else\n 'created_at'\n end\n end",
"def index\n @activity_types = ActivityType.order(\"name\").page(params[:page]).per(30)\n #@activity_types = ActivityType.search(params[:search]).page(params[:page]).per(30)\n #@activity_types = ActivityType.search_for(params[:search], :order => params[:order]).all(:include => :name)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @activity_types }\n end\n end",
"def index\n # I used an if statement because I don't know what value can come in\n # prams[:sort]. \n if(params[:sort] == \"needing_help\")then\n questions = Question.needing_help.questionsLimit\n elsif(params[:sort] == \"pending_first\")then\n questions = Question.pending_first.questionsLimit\n else\n questions = Question.latest.questionsLimit\n end\n render_json serialize_models(questions, fields: {questions:index_fields}), :ok\n end",
"def index\n order = sortable_column_order\n @categoria_productos = CategoriaProducto.order(order)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @categoria_productos }\n end\n end",
"def index\n @run_types = RunType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @run_types }\n end\n end",
"def index\n sort_by = params[:sort_by]\n sort_by ||= :id\n @categories = Category.find(:all, :order => sort_by)\n \n respond_to do |wants|\n wants.html\n wants.xml\n end\n end",
"def list\n keyword = params[:keyword].blank? ? '' : params[:keyword]\n pgnum = params[:pgnum].blank? ? 1 : params[:pgnum].to_i\n pgsize = params[:pgsize].blank? ? 0 : params[:pgsize].to_i\n sortcolumn = params[:sortcolumn].blank? ? LeaveTypeHelper::DEFAULT_SORT_COLUMN : params[:sortcolumn]\n sortdir = params[:sortdir].blank? ? LeaveTypeHelper::DEFAULT_SORT_DIR : params[:sortdir]\n \n sort = ApplicationHelper::Sort.new(sortcolumn, sortdir)\n \n if keyword.blank?\n @data = LeaveTypeHelper.get_all(pgnum, pgsize, sort)\n \n else\n @data = LeaveTypeHelper.get_filter_by(keyword, pgnum, pgsize, sort)\n end\n \n respond_to do |fmt|\n fmt.html { render :partial => 'list' }\n fmt.json { render :json => @data }\n end\n end",
"def index\n \tif params[:sort_type]\n \t@news = News.all(:order => params[:sort_type].to_s)\n else\n \t@news = News.all\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @news }\n end\n end",
"def index\n @gl_types = GlType.where(:gl_report => \"B\").order(\"gl_side DESC\") + GlType.where(:gl_report => \"T\").order(\"gl_side DESC\")\n @gl_typs = Array.new\n # @gl_types = @gl_types + @gl_types2\n respond_to do |format|\n format.html # index.html.erb\n\n format.json {\n @gl_types = @gl_types.select{|gl_type|\n gl_typ = Hash.new\n gl_type.attributes.each do |key, value|\n gl_typ[key] = value\n end\n gl_typ[:links] = CommonActions.object_crud_paths(nil, edit_gl_type_path(gl_type), gl_type_path(gl_type))\n @gl_typs.push(gl_typ)\n }\n render json: {:aaData => @gl_typs}\n }\n end\n end",
"def index\n @pre_print_types = PrePrintType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @pre_print_types }\n end\n end",
"def index\n sort = case params[:sort]\n when \"title\" then \"title\"\n when \"started\" then \"started\"\n when \"done\" then \"done\"\n when \"initial_estimate\" then \"initial_estimate\"\n when \"title_reverse\" then \"title DESC\"\n when \"started_reverse\" then \"started DESC\"\n when \"done_reverse\" then \"done DESC\"\n when \"initial_estimate_reverse\" then \"initial_estimate DESC\"\n else \"title\"\n end\n \n @tasks = Task.all :order => sort\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :partial => \"tasks_list\", :layout => false }\n end\n end",
"def index\n @typegroups = Typegroup.all\n respond_to do |format|\n format.html\n format.json { render json: @typegroups }\n end\n end"
] | [
"0.7407455",
"0.6886707",
"0.6772972",
"0.67474604",
"0.66431576",
"0.6605025",
"0.6537386",
"0.65272313",
"0.6484814",
"0.64376825",
"0.64157367",
"0.63276917",
"0.63265973",
"0.6315456",
"0.6292207",
"0.628211",
"0.6213078",
"0.6190755",
"0.6181705",
"0.61720484",
"0.6158077",
"0.6156721",
"0.614076",
"0.6118209",
"0.6050661",
"0.60499525",
"0.6043605",
"0.60248446",
"0.6019066",
"0.60079706",
"0.6000217",
"0.5984184",
"0.5959694",
"0.59438103",
"0.5942023",
"0.5928737",
"0.5920251",
"0.5911457",
"0.590371",
"0.59018904",
"0.58992803",
"0.58938074",
"0.58866787",
"0.5882644",
"0.5882585",
"0.5874795",
"0.58702517",
"0.58608264",
"0.585703",
"0.58419585",
"0.5839271",
"0.58139133",
"0.5805988",
"0.58039236",
"0.57960165",
"0.57776266",
"0.577334",
"0.5768476",
"0.57665807",
"0.57598406",
"0.5755268",
"0.5754343",
"0.5752766",
"0.5745918",
"0.57455325",
"0.57425684",
"0.5738514",
"0.5731192",
"0.5724908",
"0.57100874",
"0.5706318",
"0.5704377",
"0.5701256",
"0.57003385",
"0.5698195",
"0.56979024",
"0.56954193",
"0.5692157",
"0.5686533",
"0.56845784",
"0.56826985",
"0.5679206",
"0.567844",
"0.56766486",
"0.5671157",
"0.56641877",
"0.5663897",
"0.5662085",
"0.56542456",
"0.5649225",
"0.56481516",
"0.56453437",
"0.56445265",
"0.5641221",
"0.5639363",
"0.5637753",
"0.5636523",
"0.56364197",
"0.5635029",
"0.56319493"
] | 0.72082376 | 1 |
GET /kf/sort_types/new GET /kf/sort_types/new.json | def new
@kf_sort_type = Kf::SortType.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @kf_sort_type }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @kf_sort_type = Kf::SortType.new(params[:kf_sort_type])\n\n respond_to do |format|\n if @kf_sort_type.save\n format.html { redirect_to kf_sort_types_url({:page => params[:page]}), notice: 'Sort type was successfully created.' }\n format.json { render json: @kf_sort_type, status: :created, location: @kf_sort_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @kf_sort_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @sort_type = SortType.new(sort_type_params)\n\n respond_to do |format|\n if @sort_type.save\n format.html { redirect_to @sort_type, notice: 'Sort type was successfully created.' }\n format.json { render :show, status: :created, location: @sort_type }\n else\n format.html { render :new }\n format.json { render json: @sort_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @kf_sort = Kf::Sort.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @kf_sort }\n end\n end",
"def index\n @sort_types = SortType.all\n end",
"def new\n\t\t@sort = Sort.new\n\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.xml { render :xml => @sort }\n\t\tend\n\tend",
"def set_sort_type\n @sort_type = SortType.find(params[:id])\n end",
"def show\n @kf_sort_type = Kf::SortType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kf_sort_type }\n end\n end",
"def index\n @tickettypes = Define.where( :usetype => 'tickettype' ).order(\"sort asc, updated_at desc\")\n @tickettype = Define.new\n\n respond_to do |format|\n format.html # index.html.erb\n end\nend",
"def index\n @ingredients = Ingredient.order(sort_type + \" \" + sort_direction)\n @activeSort = sort_type\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ingredients }\n end\n end",
"def sort_type_params\n params.require(:sort_type).permit(\n :name,\n :roster_id,\n :setup_id,\n :start_time,\n :mon,\n :tue,\n :wed,\n :thu,\n :fri,\n :sat,\n :sun\n )\n end",
"def create\n\t\t@sort = Sort.new(params[:sort])\n\n\t\trespond_to do |format|\n\t\t\tif @sort.save\n\t\t\t\tformat.html { redirect_to(@sort, :notice => 'Sort was successfully created.') }\n\t\t\t\tformat.xml { render :xml => @sort, :status => :created, :location => @sort }\n\t\t\telse\n\t\t\t\tformat.html { render :action => \"new\" }\n\t\t\t\tformat.xml { render :xml => @sort.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def create\n authorize_action_for OrderType, at: current_store\n @order_type = current_store.order_types.build(order_type_params.merge(priority: current_store.order_types.count))\n\n respond_to do |format|\n if @order_type.save\n track @order_type\n format.html { redirect_to edit_admin_order_type_path(@order_type),\n notice: t('.notice', order_type: @order_type) }\n format.json { render :show, status: :created, location: admin_order_type_path(@order_type) }\n else\n format.html { render :new }\n format.json { render json: @order_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n respond_to do |format|\n format.html { @product_types = ProductType.all }\n format.json { @product_types = ProductType.order(:name) }\n end\n end",
"def new\n\t\t@column_sort = current_user.column_sorts.new\n\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.xml { render :xml => @column_sort }\n\t\t\tformat.json { render :json => @column_sort }\n\t\t\tformat.yaml { render :text => @column_sort.to_yaml, :content_type => 'text/yaml' }\n\t\tend\n\tend",
"def destroy\n @kf_sort_type = Kf::SortType.find(params[:id])\n @kf_sort_type.destroy\n\n respond_to do |format|\n format.html { redirect_to kf_sort_types_url({:page => params[:page]}) }\n format.json { head :no_content }\n end\n end",
"def update\n respond_to do |format|\n if @sort_type.update(sort_type_params)\n format.html { redirect_to @sort_type, notice: 'Sort type was successfully updated.' }\n format.json { render :show, status: :ok, location: @sort_type }\n else\n format.html { render :edit }\n format.json { render json: @sort_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def manager_list_by_type\n \n @sort_order = get_sort_order\n @sort_order[:type] = params[:order] == 'ASC' ? 'DESC' : 'ASC'\n flash[:sort_order] = @sort_order\n \n design_reviews = get_active_reviews\n @active_reviews = design_reviews[:active].sort_by { |dr| [dr[:review].review_type.sort_order, dr[:review].age] }\n @inactive_reviews = design_reviews[:inactive].sort_by { |dr| [dr[:review].review_type.sort_order, dr[:review].age] }\n @active_reviews.reverse! if params[:order] == 'DESC'\n @inactive_reviews.reverse! if params[:order] == 'DESC'\n \n @submissions = BoardDesignEntry.submission_count\n session[:return_to] = {:controller => 'tracker',\n :action => 'manager_list_by_type',\n :order => params[:order]}\n render( :action => 'manager_home' )\n\n end",
"def create\n @gtw_sortir = GtwSortir.new(gtw_sortir_params)\n\n respond_to do |format|\n if @gtw_sortir.save\n format.html { redirect_to @gtw_sortir, notice: 'Gtw sortir was successfully created.' }\n format.json { render :show, status: :created, location: @gtw_sortir }\n else\n format.html { render :new }\n format.json { render json: @gtw_sortir.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @type = Type.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @type }\n end\n end",
"def create_types\n\t[]\nend",
"def create_types\n\t[]\nend",
"def create\n @sorteado = Sorteado.new(sorteado_params)\n\n respond_to do |format|\n if @sorteado.save\n format.html { redirect_to @sorteado, notice: 'Sorteado was successfully created.' }\n format.json { render :show, status: :created, location: @sorteado }\n else\n format.html { render :new }\n format.json { render json: @sorteado.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n conditions = []\n params[:per_page] = perpage if params[:per_page].nil?\n params[:page] = 1 if params[:page].blank?\n unless params[:search].blank?\n conditions.push \"title like ? or description like ?\"\n conditions.push \"%#{params[:search]}%\"\n conditions.push \"%#{params[:search]}%\"\n end\n @kf_sort_types = Kf::SortType.order(\"id DESC\").paginate(:page => params[:page], :per_page => params[:per_page] ,:conditions => conditions)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @kf_sort_types }\n end\n end",
"def update\n @kf_sort_type = Kf::SortType.find(params[:id])\n\n respond_to do |format|\n if @kf_sort_type.update_attributes(params[:kf_sort_type])\n format.html { redirect_to kf_sort_types_url({:page => params[:page]}), notice: 'Sort type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @kf_sort_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_types\n\t\t[]\n\tend",
"def create_types\n\t\t[]\n\tend",
"def destroy\n @sort_type.destroy\n respond_to do |format|\n format.html { redirect_to sort_types_url, notice: 'Sort type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def create\n @sorteio = Sorteio.new(sorteio_params)\n\n respond_to do |format|\n if @sorteio.save\n flash[:notice] = 'Salvo com sucesso'\n format.html { redirect_to @sorteio }\n format.json { render :show, status: :created, location: @sorteio }\n else\n format.html { render :new }\n format.json { render json: @sorteio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tickettype = Define.new(params[:define])\n @tickettype.usetype = 'tickettype'\n\n respond_to do |format|\n if @tickettype.save\n format.html { redirect_to admin_ticket_type_path(@tickettype), notice: t(\"helpers.notice.new\") }\n else\n \n \t @tickettypes = Define.where( :usetype => 'tickettype' ).order(\"sort asc, updated_at desc\")\n format.html { render action: \"index\" }\n end\n end\nend",
"def new\n @place = Place.new( :status => Status.active )\n @locals = Local.all\n @ticket_type_groups = TicketTypeGroup.order(:value)\n @statuses = Status.order(:value)\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @place }\n end\n end",
"def new_creatable_selection_list\n Seek::Util.user_creatable_types.collect { |c| [c.name.underscore.humanize, url_for(controller: c.name.underscore.pluralize, action: 'new')] }\n end",
"def new_creatable_selection_list\n Seek::Util.user_creatable_types.collect { |c| [c.name.underscore.humanize, url_for(controller: c.name.underscore.pluralize, action: 'new')] }\n end",
"def new\n @sortie = Sortie.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @sortie }\n end\n end",
"def create_cardsort\n\t\t@cardsort = Cardsort.new(params[:cardsort])\n\t\[email protected]\n\t\trespond_to do |form|\n\t\t\tform.js {}\n\t\tend\n\tend",
"def rec_new\n @beer_types_to_try = BeerType.limit(6).map{|type| [type.id, type.name]}\n render json: @beer_types_to_try\n end",
"def add_to_sort_array(sort_type, quest_id)\n @sort_arrays[sort_type].delete(quest_id) # Make sure always unique\n case sort_type\n when :reveal, :change, :complete, :failed\n @sort_arrays[sort_type].unshift(quest_id)\n when :id\n @sort_arrays[sort_type].maqj_insert_sort(quest_id)\n when :alphabet \n @sort_arrays[sort_type].maqj_insert_sort(quest_id) { |a, b| @data[a].name.downcase <=> @data[b].name.downcase }\n when :level\n @sort_arrays[sort_type].maqj_insert_sort(quest_id) { |a, b| @data[a].level <=> self[b].level }\n end\n end",
"def new\n @fundraiser = Fundraiser.new\n @fundraiser.status = 2;\n @type_array = Fundraiser.select(:division_type).uniq\n @type_array.uniq(true);\n respond_to do |format|\n format.html # new.html.erb\n end\n end",
"def create\n @kf_sort = Kf::Sort.new(params[:kf_sort])\n\n respond_to do |format|\n if @kf_sort.save\n if @kf_sort.father_id != 0\n format.html { redirect_to \"/kf/sorts/#{params[:kf_sort][:father_id]}\" , notice: 'Sort was successfully created.' }\n else\n format.html { redirect_to kf_sorts_url , notice: 'Sort was successfully created.' }\n end\n format.json { render json: @kf_sort, status: :created, location: @kf_sort }\n else\n format.html { render action: \"new\" }\n format.json { render json: @kf_sort.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @entry_type = EntryType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entry_type }\n end\n end",
"def index\n type = params[:type]\n field = params[:field]\n\n @items = Item.all.order(\"updated_at desc\")\n if type == \"sort\"\n @items = Item.all.order(\"#{field} asc\")\n end\n\n\n end",
"def index\n @gl_types = GlType.where(:gl_report => \"B\").order(\"gl_side DESC\") + GlType.where(:gl_report => \"T\").order(\"gl_side DESC\")\n @gl_typs = Array.new\n # @gl_types = @gl_types + @gl_types2\n respond_to do |format|\n format.html # index.html.erb\n\n format.json {\n @gl_types = @gl_types.select{|gl_type|\n gl_typ = Hash.new\n gl_type.attributes.each do |key, value|\n gl_typ[key] = value\n end\n gl_typ[:links] = CommonActions.object_crud_paths(nil, edit_gl_type_path(gl_type), gl_type_path(gl_type))\n @gl_typs.push(gl_typ)\n }\n render json: {:aaData => @gl_typs}\n }\n end\n end",
"def new\n @trtype = Trtype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trtype }\n end\n end",
"def index\n @act_types = ActType.order(:name).page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @act_types }\n end\n end",
"def index\n @court_types = CourtType.order(:name)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @court_types }\n end\n end",
"def new\n @taxonomy = Taxonomy.new(:taxonomy_type => params[:taxonomy_type].presence || 'category')\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @taxonomy }\n end\n end",
"def index\n params[:user_sort] ||= 'updated_at DESC'\n @projects = current_scope.projects.sort(sort_params).page(params[:page])\n @project = current_scope.projects.new\n respond_to do |format|\n format.html\n format.json\n end\n end",
"def create\n @group = Group.new(params[:group])\n new_sort = Configurations.get_sort('group')\n @group.sort = new_sort\n @group.deleted = 0\n\n respond_to do |format|\n if @group.save\n format.html { redirect_to :groups, notice: 'Group was successfully created.' }\n format.json { render json: @group, status: :created, location: @group }\n else\n format.html { render action: \"new\" }\n format.json { render json: @group.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @card_sort = CardSort.new do |csp|\n csp.name = card_sort_params['name']\n csp.description = card_sort_params['description']\n csp.code = card_sort_params['code']\n csp.cards = card_sort_params['cards'].map do |card|\n {label: card}\n end\n end\n\n respond_to do |format|\n if @card_sort.save\n format.html { redirect_to @card_sort, notice: 'Card sort was successfully created.' }\n format.json { render :show, status: :created, location: @card_sort }\n else\n format.html { render :new }\n format.json { render json: @card_sort.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @breadcrumb = 'create'\n @tariff_type = TariffType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tariff_type }\n end\n end",
"def index\n manage_filter_state\n @tariff_types = TariffType.paginate(:page => params[:page], :per_page => per_page || 10).order(sort_column + ' ' + sort_direction)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tariff_types }\n format.js\n end\n end",
"def new\n @ftype = Ftype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ftype }\n end\n end",
"def new\n @title = \"Добавление типа лечения\"\n @treatment_type = TreatmentType.new\n\n respond_to do |format|\n if TreatmentType.all.length < 3\n format.html # new.html.erb\n format.json { render json: @treatment_type }\n end\n end\n end",
"def index\n @event_types = EventType.sorted\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @event_types }\n end\n end",
"def new\n @clinician_order = ClinicianOrder.new\n @clinician_order.visit_id = params[:visit_id]\n\n @order_types = OrderType.all\n @order_type_categories = @order_types.group_by(&:category)\n\n respond_to do |format|\n format.html # new.html.erb\n format.js\n format.json { render json: @clinician_order }\n end\n end",
"def new\n @jetties = Jetty.order(:name)\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @order }\n end\n end",
"def index\n @poi_types = PoiType.order(sort_column+ \" \" + sort_direction ).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @poi_types }\n format.json \n end\n end",
"def index\n @kinds = Kind.create_select_options\n end",
"def create\n @color = Color.new(params[:color])\n new_sort = Configurations.get_sort('color')\n @color.sort = new_sort\n @color.deleted = 0\n\n respond_to do |format|\n if @color.save\n format.html { redirect_to :colors, notice: 'Color was successfully created.' }\n format.json { render json: @color, status: :created, location: @color }\n else\n format.html { render action: \"new\" }\n format.json { render json: @color.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @kind = Kind.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @kind }\n end\n end",
"def new\n @action_type = ActionType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @action_type }\n end\n end",
"def new\n @collection_type = CollectionType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @collection_type }\n end\n end",
"def new\n @resource = Resource.new\n @resource_types=ResourceType.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @resource }\n end\n end",
"def new\n @os_type = OsType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @os_type }\n end\n end",
"def index\n respond_to do |format|\n if params[:search]\n format.html { @provider_provider_types = Provider::ProviderType.search(params[:search]).order(\"created_at DESC\")}\n format.json { @provider_provider_types = Provider::ProviderType.search(params[:search]).order(\"created_at DESC\")}\n else\n format.html { @provider_provider_types = Provider::ProviderType.all.order('created_at DESC')}\n format.json { @provider_provider_types = Provider::ProviderType.all.order('created_at DESC')}\n end\n end\n end",
"def new\n @stock_type = StockType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @stock_type }\n end\n end",
"def index\n @specification_types = SpecificationType.all.order(\"display_order\")\n\n render json: @specification_types, each_serializer: Web::V1::SpecificationTypeSerializer\n end",
"def index\n @creator_types = CreatorType.order(:name)\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @creator_types }\n end\n end",
"def index\n manage_filter_state\n @product_types = ProductType.paginate(:page => params[:page], :per_page => per_page).order(sort_column + ' ' + sort_direction)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @product_types }\n format.js\n end\n end",
"def new\n redirect_to posting_types_path\n end",
"def new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @order_type }\n end\n end",
"def index\n @death_record_items = DeathRecordItem.all\n @death_record_items = DeathRecordItem.order(params[:sort])\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @death_record_items }\n end\n end",
"def new\n @resource_type = ResourceType.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @resource_type }\n end\n end",
"def index\n @os_types = OsType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @os_types, except: [:desc, :created_at, :updated_at] } \n end\n end",
"def new\n @page_type = PageType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @page_type }\n end\n end",
"def new\n @types_of_apprenticeship = TypesOfApprenticeship.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @types_of_apprenticeship }\n end\n end",
"def create\n\t\t@column_sort = current_user.column_sorts.new(params[:column_sort])\n\n\t\trespond_to do |format|\n\t\t\tif @column_sort.save\n\t\t\t\tformat.html { redirect_to(@column_sort, :notice => 'Column sort was successfully created.') }\n\t\t\t\tformat.xml { render :xml => @column_sort, :status => :created, :location => @column_sort }\n\t\t\t\tformat.json { render :json => @column_sort, :status => :created, :location => @column_sort }\n\t\t\t\tformat.yaml { render :text => @column_sort.to_yaml, :content_type => 'text/yaml', :status => :created, :location => @column_sort }\n\t\t\telse\n\t\t\t\tformat.html { render :action => \"new\" }\n\t\t\t\tformat.xml { render :xml => @column_sort.errors, :status => :unprocessable_entity }\n\t\t\t\tformat.json { render :json => @column_sort.errors, :status => :unprocessable_entity }\n\t\t\t\tformat.yaml { render :text => @column_sort.errors.to_yaml, :content_type => 'text/yaml', :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def index\n @language_types = LanguageType.all\n\n render json: @language_types\n end",
"def create\n @comment_status_type = CommentStatusType.new(comment_status_type_params)\n @comment_status_type.rulemaking = current_rulemaking\n\n #set the order_in_list\n cst_max = current_rulemaking.comment_status_types.maximum(:order_in_list)\n @comment_status_type.order_in_list = cst_max.nil? ? 1 : cst_max + 1\n\n respond_to do |format|\n if @comment_status_type.save\n save_change_log(current_user,{object_type: 'comment status type', action_type: 'create', description: \"created comment status type ID ##{@comment_status_type.id} '#{@comment_status_type.status_text}', '#{@comment_status_type.color_name}'\"})\n format.html { redirect_to comment_status_types_path, notice: 'Comment status type was successfully created.' }\n format.json { render :show, status: :created, location: @comment_status_type }\n else\n set_select_options\n format.html { render :new }\n format.json { render json: @comment_status_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @act_type = ActType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @act_type }\n end\n end",
"def new\n @upgrade_type = UpgradeType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @upgrade_type }\n end\n end",
"def index\n @mtypes = Mtype.order(:code)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mtypes }\n end\n end",
"def new\n @category_type = CategoryType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @category_type }\n end\n end",
"def types\n aux = WorkOrderType.by_name\n render json: serialized_work_order_types(aux)\n end",
"def index\n @inventory_types = InventoryType.all.sort_by(&:name)\n end",
"def new\n @all_field_type = AllFieldType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @all_field_type }\n end\n end",
"def new\n @package = Package.new\n @aircraft_types = AircraftType.by_name.collect{|c| [c.name, c.id]}\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @package }\n end\n end",
"def new\n @wicket = Wicket.new( :priority => false, :status => Status.active )\n @place = Place.find(params[:place_id])\n @ticket_type_groups = @place.ticket_type_groups.order( \"value ASC\" )\n @reference_groups = @place.ticket_type_groups.order( \"value ASC\" )\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @wicket }\n end\n end",
"def new\n @tax_type = TaxType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tax_type }\n end\n end",
"def new\n @breadcrumb = 'create'\n @product_type = ProductType.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @product_type }\n end\n end",
"def index\n @entity_types = EntityType.paginate(:page => params[:page], :per_page => per_page).order(sort_column + ' ' + sort_direction)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @entity_types }\n end\n end",
"def index\n @entry_types = EntryType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @entry_types }\n end\n end",
"def update_types\n\t[]\nend",
"def update_types\n\t[]\nend",
"def create\n options = {\n :search => params[:search],\n :sort => params[:sort],\n :page => params[:page],\n :anchor => :vm_os_types,\n }\n redirect_url = send(\"#{ parent_type }_url\", parent, options)\n\n if params[:cancel_button]\n redirect_to redirect_url\n else\n @vm_os_type = parent.vm_os_types.build(params[:vm_os_type])\n\n respond_to do |format|\n if @vm_os_type.save\n flash[:notice] = 'VmOsType was successfully created.'\n format.html { redirect_to redirect_url }\n format.xml { render :xml => @vm_os_type, :status => :created, :location => @vm_os_type }\n format.js\n else\n @error_messages = @vm_os_type.errors.collect{ |e| e[0].humanize+' - '+e[1] }\n format.html { render :action => \"new\" }\n format.xml { render :xml => @vm_os_type.errors, :status => :unprocessable_entity }\n format.js\n end\n end\n end\n end",
"def index\n idea_type\n\n params[:type_id]||=0\n params[:order] ||=\"recent\"\n\n @ideas=Idea.find_categories(params[:type_id],params[:page],params[:order])\n @idea = Idea.new(:type_id => params[:type_id].to_i)\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @ideas }\n end\n end",
"def update_types\n\t\t[]\n\tend",
"def update_types\n\t\t[]\n\tend",
"def new\n @fieldtype = Fieldtype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fieldtype }\n end\n end",
"def new\n @ctype = Ctype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @ctype }\n end\n end",
"def create\n @sortie = Sortie.new(params[:sortie])\n\n respond_to do |format|\n if @sortie.save\n format.html { redirect_to(@sortie, :notice => 'Sortie was successfully created.') }\n format.xml { render :xml => @sortie, :status => :created, :location => @sortie }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @sortie.errors, :status => :unprocessable_entity }\n end\n end\n end"
] | [
"0.7509356",
"0.7160151",
"0.71418476",
"0.6609113",
"0.6438381",
"0.6252697",
"0.61429995",
"0.6070451",
"0.5962859",
"0.5949688",
"0.58969563",
"0.58820546",
"0.58225423",
"0.58022875",
"0.579487",
"0.57849973",
"0.5702127",
"0.56778634",
"0.5669851",
"0.5662975",
"0.5662975",
"0.5613396",
"0.561072",
"0.5602033",
"0.5596037",
"0.5596037",
"0.5592232",
"0.55824393",
"0.55747384",
"0.5570042",
"0.5559907",
"0.5559907",
"0.55568033",
"0.5545657",
"0.55413425",
"0.5537749",
"0.55195093",
"0.5510541",
"0.5510018",
"0.55094504",
"0.54929197",
"0.54851425",
"0.5478541",
"0.5458623",
"0.5450541",
"0.54457974",
"0.5435322",
"0.5434456",
"0.5432642",
"0.542554",
"0.5420933",
"0.5412781",
"0.5403049",
"0.5365437",
"0.53579664",
"0.5356258",
"0.5354542",
"0.5345477",
"0.53238356",
"0.5323297",
"0.53224736",
"0.53212076",
"0.53182197",
"0.531674",
"0.530341",
"0.5300185",
"0.52948856",
"0.52927196",
"0.5292444",
"0.52924204",
"0.5291159",
"0.5290345",
"0.5285709",
"0.5284689",
"0.5282903",
"0.52824587",
"0.5276139",
"0.52636385",
"0.5257202",
"0.5251",
"0.52498436",
"0.5249479",
"0.524743",
"0.5241029",
"0.5240088",
"0.52327275",
"0.52298427",
"0.5209665",
"0.52078724",
"0.520379",
"0.51950806",
"0.519423",
"0.519423",
"0.5194088",
"0.51908576",
"0.5187874",
"0.5187874",
"0.5183531",
"0.51800656",
"0.5179895"
] | 0.778308 | 0 |
POST /kf/sort_types POST /kf/sort_types.json | def create
@kf_sort_type = Kf::SortType.new(params[:kf_sort_type])
respond_to do |format|
if @kf_sort_type.save
format.html { redirect_to kf_sort_types_url({:page => params[:page]}), notice: 'Sort type was successfully created.' }
format.json { render json: @kf_sort_type, status: :created, location: @kf_sort_type }
else
format.html { render action: "new" }
format.json { render json: @kf_sort_type.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n @sort_types = SortType.all\n end",
"def sort_types\n @sort_types ||= begin\n sql = <<-SQLT\n SELECT\n CASE\n WHEN min(sortkey) < 0 THEN 'interleaved'\n ELSE 'compound'\n END AS sort_type, tablename\n FROM pg_table_def\n WHERE tablename in (#{tables_for_sql})\n GROUP BY tablename\n SQLT\n RailsRedshiftReplicator.connection.exec(sql.squish).entries\n end\n end",
"def sort_type_params\n params.require(:sort_type).permit(\n :name,\n :roster_id,\n :setup_id,\n :start_time,\n :mon,\n :tue,\n :wed,\n :thu,\n :fri,\n :sat,\n :sun\n )\n end",
"def create\n @sort_type = SortType.new(sort_type_params)\n\n respond_to do |format|\n if @sort_type.save\n format.html { redirect_to @sort_type, notice: 'Sort type was successfully created.' }\n format.json { render :show, status: :created, location: @sort_type }\n else\n format.html { render :new }\n format.json { render json: @sort_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_sort_type\n @sort_type = SortType.find(params[:id])\n end",
"def types\n aux = WorkOrderType.by_name\n render json: serialized_work_order_types(aux)\n end",
"def s_typesort; det.link(:text, 'Type'); end",
"def new\n @kf_sort_type = Kf::SortType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @kf_sort_type }\n end\n end",
"def index\n conditions = []\n params[:per_page] = perpage if params[:per_page].nil?\n params[:page] = 1 if params[:page].blank?\n unless params[:search].blank?\n conditions.push \"title like ? or description like ?\"\n conditions.push \"%#{params[:search]}%\"\n conditions.push \"%#{params[:search]}%\"\n end\n @kf_sort_types = Kf::SortType.order(\"id DESC\").paginate(:page => params[:page], :per_page => params[:per_page] ,:conditions => conditions)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @kf_sort_types }\n end\n end",
"def index\n @ingredients = Ingredient.order(sort_type + \" \" + sort_direction)\n @activeSort = sort_type\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ingredients }\n end\n end",
"def set_sort_order\n object = params[:imageable_type].constantize.find(params[:imageable_id])\n uploads = object.uploads\n params[:order].each_pair do |key, value|\n uploads.find(value[:id]).update_columns(sort: key, updated_at: Time.now)\n end\n render json: { message: 'success' }, :status => 200\n end",
"def manager_list_by_type\n \n @sort_order = get_sort_order\n @sort_order[:type] = params[:order] == 'ASC' ? 'DESC' : 'ASC'\n flash[:sort_order] = @sort_order\n \n design_reviews = get_active_reviews\n @active_reviews = design_reviews[:active].sort_by { |dr| [dr[:review].review_type.sort_order, dr[:review].age] }\n @inactive_reviews = design_reviews[:inactive].sort_by { |dr| [dr[:review].review_type.sort_order, dr[:review].age] }\n @active_reviews.reverse! if params[:order] == 'DESC'\n @inactive_reviews.reverse! if params[:order] == 'DESC'\n \n @submissions = BoardDesignEntry.submission_count\n session[:return_to] = {:controller => 'tracker',\n :action => 'manager_list_by_type',\n :order => params[:order]}\n render( :action => 'manager_home' )\n\n end",
"def sort_search_cases\n \t\t# sort the cases by latest, oldest and last week\n \t\tcases = case_list(params[:searchterm]).send(params[:sort_type])\n # check condition for cases is present or not.\n \t\tif cases.present?\n # response to the JSON\n render json: { success: true,response: cases.as_json('search') },:status=>200\n else\n render :json=> { success: false, message: \"Case is not present.\" },:status=> 203\n end\n \tend",
"def add_to_sort_array(sort_type, quest_id)\n @sort_arrays[sort_type].delete(quest_id) # Make sure always unique\n case sort_type\n when :reveal, :change, :complete, :failed\n @sort_arrays[sort_type].unshift(quest_id)\n when :id\n @sort_arrays[sort_type].maqj_insert_sort(quest_id)\n when :alphabet \n @sort_arrays[sort_type].maqj_insert_sort(quest_id) { |a, b| @data[a].name.downcase <=> @data[b].name.downcase }\n when :level\n @sort_arrays[sort_type].maqj_insert_sort(quest_id) { |a, b| @data[a].level <=> self[b].level }\n end\n end",
"def index\n respond_to do |format|\n format.html { @product_types = ProductType.all }\n format.json { @product_types = ProductType.order(:name) }\n end\n end",
"def safeSort type\r\n\t\traise \"CrossValidatorSet::InvalidSortType\" if ! @@acceptableSortMethods.include? type.to_sym\r\n\t\[email protected]{|a, b| a.getError.rmse <=> b.getError}\r\n\tend",
"def sort_params; end",
"def sort_params; end",
"def destroy\n @kf_sort_type = Kf::SortType.find(params[:id])\n @kf_sort_type.destroy\n\n respond_to do |format|\n format.html { redirect_to kf_sort_types_url({:page => params[:page]}) }\n format.json { head :no_content }\n end\n end",
"def convert_sort_params\n @sort_params = []\n #convert sort params to database columns\n if params[:sorting] && params[:sorting].is_a?(Array)\n params[:sorting].each do |p|\n\n sort = sort.reject{|k, v| [email protected]_method?(k) || !['asc', 'desc'].include?(v.downcase)}\n\n @sort_params.push(sort)\n end\n end\n @sort_params\n end",
"def index\n type = params[:type]\n field = params[:field]\n\n @items = Item.all.order(\"updated_at desc\")\n if type == \"sort\"\n @items = Item.all.order(\"#{field} asc\")\n end\n\n\n end",
"def sort_types(hash)\n new_hash = {}\n hash.each_pair do |type, array_units|\n\n #TODO\n #data = sort_names array_units\n data = array_units\n \n new_hash[type] = data\n end\n return new_hash\n end",
"def index\n @event_types = EventType.sorted\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @event_types }\n end\n end",
"def recognize_sort(input)\n sort_products = condition_sort(input[:requested])\n\n Success(sort_products)\n rescue StandardError\n Failure(Response::ApiResult.new(status: :internal_error, message: DB_ERR_MSG))\n end",
"def sort\n notice = 'Categories successfully sorted.'\n error = 'Could not sort Categories.'\n \n begin \n ShopCategory.sort(CGI::parse(params[:categories])[\"categories[]\"])\n \n respond_to do |format|\n format.html {\n redirect_to admin_shop_products_path\n }\n format.js { render :text => notice, :status => :ok }\n format.json { render :json => { :notice => notice }, :status => :ok }\n end\n rescue\n respond_to do |format|\n format.html {\n flash[:error] = error\n redirect_to admin_shop_products_path\n }\n format.js { render :text => error, :status => :unprocessable_entity }\n format.json { render :json => { :error => error }, :status => :unprocessable_entity }\n end\n end\n end",
"def index\n @specification_types = SpecificationType.all.order(\"display_order\")\n\n render json: @specification_types, each_serializer: Web::V1::SpecificationTypeSerializer\n end",
"def update\n @kf_sort_type = Kf::SortType.find(params[:id])\n\n respond_to do |format|\n if @kf_sort_type.update_attributes(params[:kf_sort_type])\n format.html { redirect_to kf_sort_types_url({:page => params[:page]}), notice: 'Sort type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @kf_sort_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sort_type.update(sort_type_params)\n format.html { redirect_to @sort_type, notice: 'Sort type was successfully updated.' }\n format.json { render :show, status: :ok, location: @sort_type }\n else\n format.html { render :edit }\n format.json { render json: @sort_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def sort\n @content_type.sort_contents!(params[:order])\n respond_with(@content_type, :location => admin_contents_url(@content_type.slug))\n end",
"def index\n @poi_types = PoiType.order(sort_column+ \" \" + sort_direction ).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @poi_types }\n format.json \n end\n end",
"def sort_request(request_type)\n request_type && abnamro? ? \"_#{request_type.to_s}\" : nil\n end",
"def index\n @event_types = EventType.all.sort { |p1, p2| p1.name <=> p2.name }\n\n respond_to do |format|\n format.json { render json: @event_types }\n format.xml { render xml: @event_types.to_xml({ include: :categories }) }\n end\n end",
"def show\n @kf_sort_type = Kf::SortType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kf_sort_type }\n end\n end",
"def sorting_params\n params.require(:sorting).permit(:house, :marriage, :pregnancy, :babies, :toddlers, :kids, :teens, :balance, :ip, :user_id)\n end",
"def index\n sort_group = [\"id\",\"realname\",\"vote_count\"];\n @sorted = {};\n sort_group.each do |x|\n @sorted[x.to_sym]=0\n end\n if !params[:sort_by].nil?\n sort(params[:sort_by],params[:sort_type])\n else\n @manage_users = Manage::User.all\n end\n\n end",
"def index\n @inventory_types = InventoryType.all.sort_by(&:name)\n end",
"def sort\n (@params[:sort] || :created_at).to_sym\n end",
"def index\n\n # TODO: Refactor this!!!\n sort_function = (params[:sort] == 'name' ? :name : :count)\n\n @tags = Factoid.tag_counts.sort_by {|tag| tag.send(sort_function)}.reverse\n\n if params[:direction] == 'desc'\n @tags.reverse!\n end\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tags }\n end\n end",
"def index\n @entity_types = EntityType.paginate(:page => params[:page], :per_page => per_page).order(sort_column + ' ' + sort_direction)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @entity_types }\n end\n end",
"def sort_page_categories\n params[:pc].each_with_index {|val, index|\n obj = PageCategory.find_by_apikey(val)\n obj.update_attribute(:sort_order, index)\n }\n render :text => \"\"\n end",
"def index\n manage_filter_state\n @tariff_types = TariffType.paginate(:page => params[:page], :per_page => per_page || 10).order(sort_column + ' ' + sort_direction)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tariff_types }\n format.js\n end\n end",
"def get_sort_opts(params)\n\tif(params[:sort].nil?)\n\t\treturn [['_id', 1]] # just sort on the id\n\telse\n\t\tfields = destringify_array(params[:sort])\n\n\t\tresult = []\n\t\tfields.each do |f|\n\t\t\tparts = f.split(\":\")\n\t\t\tif(parts.count != 1)\n\t\t\t\tif(parts[1].to_s == \"desc\")\n\t\t\t\t\tresult << [parts[0].to_s, -1]\n\t\t\t\telse\n\t\t\t\t\tresult << [parts[0].to_s, 1]\n\t\t\t\tend\n\t\t\telse\t\n\t\t\t\tresult << [f.to_s, 1]\n\t\t\tend\t\t\t\n\t\tend\n\t\treturn result\n\tend\nend",
"def tr_type_params\n params.require(:tr_type).permit(:name, :active_status, :sort)\n end",
"def sort_result_by(type = SortOption::ALPHABETICAL_CONST)\r\n find('div.resultList')\r\n page.execute_script(\"$('div.resultList div div select:first').css('display','block')\")\r\n element = find(:xpath, \".//select[@class='input-medium-sort-by requester chzn-done']\")\r\n id = element[:id]\r\n select type, from: id\r\n end",
"def sort_entries; end",
"def index\n manage_filter_state\n @product_types = ProductType.paginate(:page => params[:page], :per_page => per_page).order(sort_column + ' ' + sort_direction)\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @product_types }\n format.js\n end\n end",
"def index\n @act_types = ActType.order(:name).page(params[:page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @act_types }\n end\n end",
"def sort\n params[:dept].each_with_index {|val, index|\n obj = Department.find_by_apikey(val)\n obj.update_attribute(:sort_order, index)\n }\n render :text => \"\"\n end",
"def sort(collection)\n sort = params[:sort]\n return collection unless sort\n\n sort_fields = Jaf::SortFields.deserialize(sort)\n collection.order(sort_fields)\n end",
"def sort(type, in_order)\n @products.sort_by!(&type)\n @products.reverse! if in_order == :down\n @products\n end",
"def set_listing_sort_order(search_object, default_val)\n if params[:sort]\n sort_order = params[:sort].downcase\n case sort_order\n when \"manu\"\n search_object.sort_order = SortOrder::SORT_BY_MANU_ASC\n when \"manud\"\n search_object.sort_order = SortOrder::SORT_BY_MANU_DESC\n when \"size\"\n search_object.sort_order = SortOrder::SORT_BY_SIZE_ASC\n when \"sized\"\n search_object.sort_order = SortOrder::SORT_BY_SIZE_DESC\n when \"upd\"\n search_object.sort_order = SortOrder::SORT_BY_UPDATED_ASC\n when \"updd\"\n search_object.sort_order = SortOrder::SORT_BY_UPDATED_DESC\n when \"qty\"\n search_object.sort_order = SortOrder::SORT_BY_QTY_ASC\n when \"type\"\n search_object.sort_order = SortOrder::SORT_BY_TYPE_ASC\n when \"treadd\"\n search_object.sort_order = SortOrder::SORT_BY_TREADLIFE_DESC\n when \"distance\"\n search_object.sort_order = SortOrder::SORT_BY_DISTANCE_ASC\n when \"cost\"\n search_object.sort_order = SortOrder::SORT_BY_COST_PER_TIRE_ASC\n when \"costd\"\n search_object.sort_order = SortOrder::SORT_BY_COST_PER_TIRE_DESC\n when \"name\"\n search_object.sort_order = SortOrder::SORT_BY_MODEL_NAME_ASC\n when \"named\"\n search_object.sort_order = SortOrder::SORT_BY_MODEL_NAME_DESC\n when \"store\"\n search_object.sort_order = SortOrder::SORT_BY_STORE_NAME_ASC\n when \"stored\"\n search_object.sort_order = SortOrder::SORT_BY_STORE_NAME_DESC\n else\n search_object.sort_order = default_val\n end\n else\n search_object.sort_order = default_val\n end\n end",
"def set_Sort(value)\n set_input(\"Sort\", value)\n end",
"def set_Sort(value)\n set_input(\"Sort\", value)\n end",
"def set_Sort(value)\n set_input(\"Sort\", value)\n end",
"def set_Sort(value)\n set_input(\"Sort\", value)\n end",
"def set_Sort(value)\n set_input(\"Sort\", value)\n end",
"def set_Sort(value)\n set_input(\"Sort\", value)\n end",
"def set_Sort(value)\n set_input(\"Sort\", value)\n end",
"def set_Sort(value)\n set_input(\"Sort\", value)\n end",
"def set_Sort(value)\n set_input(\"Sort\", value)\n end",
"def set_Sort(value)\n set_input(\"Sort\", value)\n end",
"def index\n @sample_types = SampleType.all.sort_by(&:name)\n @first = if @sample_types.any?\n @sample_types[0].name\n else\n 'no sample types'\n end\n\n respond_to do |format|\n format.html { render layout: 'aq2' }\n format.json do\n render json: @sample_types\n .sort { |a, b| a.name <=> b.name }\n .to_json(methods: :field_types)\n end\n end\n end",
"def index\n @tickettypes = Define.where( :usetype => 'tickettype' ).order(\"sort asc, updated_at desc\")\n @tickettype = Define.new\n\n respond_to do |format|\n format.html # index.html.erb\n end\nend",
"def new\n @kf_sort = Kf::Sort.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @kf_sort }\n end\n end",
"def index\n params[:sort] ||= \"punto_servicio_id\"\n params[:direction] ||= \"asc\"\n @prestacions = Prestacion.order(params[:sort] + \" \" + params[:direction])\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @prestacions }\n end\n end",
"def sorting\n @records = Record.all #Get existing records\n @sortType = params[:sortType] #Get parameters from the form on index\n @sortField = params[:sortField]\n\n @limit = params[:sortNum].to_i # params must be converted from string\n\n if @sortType == \"Decending\" # check if sort direction is decending\n case @sortField #check what header to sort by\n when \"id\" # when table header is ID sort by ID descending\n @sortedSet = Record.order(id: :desc).limit(@limit)\n when \"REF_DATE\"\n @sortedSet = Record.order(REF_DATE: :desc).limit(@limit)\n when \"GEO\"\n @sortedSet = Record.order(GEO: :desc).limit(@limit)\n when \"DGUID\"\n @sortedSet = Record.order(DGUID: :desc).limit(@limit)\n when \"Sex\"\n @sortedSet = Record.order(Sex: :desc).limit(@limit)\n when \"Age_group\"\n @sortedSet = Record.order(Age_group: :desc).limit(@limit)\n when \"Student_response\"\n @sortedSet = Record.order(Student_response: :desc).limit(@limit)\n when \"UOM\"\n @sortedSet = Record.order(UOM: :desc).limit(@limit)\n when \"UOM_ID\"\n @sortedSet = Record.order(UOM_ID: :desc).limit(@limit)\n when \"SCALAR_FACTOR\"\n @sortedSet = Record.order(SCALAR_FACTOR: :desc).limit(@limit)\n when \"SCALAR_ID\"\n @sortedSet = Record.order(SCALAR_ID: :desc).limit(@limit)\n when \"VECTOR\"\n @sortedSet = Record.order(VECTOR: :desc).limit(@limit)\n when \"COORDINATE\"\n @sortedSet = Record.order(COORDINATE: :desc).limit(@limit)\n when \"VALUE\"\n @sortedSet = Record.order(VALUE: :desc).limit(@limit)\n when \"STATUS\"\n @sortedSet = Record.order(STATUS: :desc).limit(@limit)\n when \"SYMBOL\"\n @sortedSet = Record.order(SYMBOL: :desc).limit(@limit)\n when \"TERMINATED\"\n @sortedSet = Record.order(TERMINATED: :desc).limit(@limit)\n when \"DECIMALS\"\n @sortedSet = Record.order(DECIMALS: :desc).limit(@limit)\n \n end # end case/when\n else # if not decending its ascending\n case @sortField # check header to sort by\n when \"id\" # when table header is ID sort by ID ascending\n @sortedSet = Record.order(id: :asc).limit(@limit)\n when \"REF_DATE\"\n @sortedSet = Record.order(REF_DATE: :asc).limit(@limit)\n when \"GEO\"\n @sortedSet = Record.order(GEO: :asc).limit(@limit)\n when \"DGUID\"\n @sortedSet = Record.order(DGUID: :asc).limit(@limit)\n when \"Sex\"\n @sortedSet = Record.order(Sex: :asc).limit(@limit)\n when \"Age_group\"\n @sortedSet = Record.order(Age_group: :asc).limit(@limit)\n when \"Student_response\"\n @sortedSet = Record.order(Student_response: :asc).limit(@limit)\n when \"UOM\"\n @sortedSet = Record.order(UOM: :asc).limit(@limit)\n when \"UOM_ID\"\n @sortedSet = Record.order(UOM_ID: :asc).limit(@limit)\n when \"SCALAR_FACTOR\"\n @sortedSet = Record.order(SCALAR_FACTOR: :asc).limit(@limit)\n when \"SCALAR_ID\"\n @sortedSet = Record.order(SCALAR_ID: :asc).limit(@limit)\n when \"VECTOR\"\n @sortedSet = Record.order(VECTOR: :asc).limit(@limit)\n when \"COORDINATE\"\n @sortedSet = Record.order(COORDINATE: :asc).limit(@limit)\n when \"VALUE\"\n @sortedSet = Record.order(VALUE: :asc).limit(@limit)\n when \"STATUS\"\n @sortedSet = Record.order(STATUS: :asc).limit(@limit)\n when \"SYMBOL\"\n @sortedSet = Record.order(SYMBOL: :asc).limit(@limit)\n when \"TERMINATED\"\n @sortedSet = Record.order(TERMINATED: :asc).limit(@limit)\n when \"DECIMALS\"\n @sortedSet = Record.order(DECIMALS: :asc).limit(@limit) \n end\n end\n \n end",
"def sort_order\n sort_string = params[:sort]\n if sort_string\n split = sort_string.split '_'\n sort_field = split[0]\n sort_dir = split[1]\n return {sort_field.to_sym => sort_dir}\n end\n return {text: :asc}\n end",
"def index\n @admin_types = Type.joins(:language).order('types.code DESC').all\n end",
"def destroy\n @sort_type.destroy\n respond_to do |format|\n format.html { redirect_to sort_types_url, notice: 'Sort type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def sorteado_params\n params.require(:sorteado).permit(:name)\n end",
"def sort_by_type!\n children.sort! do |x, y|\n if x.is_a?(PBXGroup) && y.is_a?(PBXFileReference)\n -1\n elsif x.is_a?(PBXFileReference) && y.is_a?(PBXGroup)\n 1\n else\n x.display_name <=> y.display_name\n end\n end\n end",
"def build_selects_from_types(order); end",
"def detail_params\n params.require(:q).permit(:sorts)\n end",
"def order\n\n\t\t\t\ttestimonies = params.require(:testimonies)\n\n\t\t\t\torder = {}\n\t\t\t\ttestimonies.each_with_index do |id,i|\n\n\t\t\t\t\torder.merge! id => {sort: i}\n\n\t\t\t\tend\n\n\t\t\t\tif Testimony.update(order.keys,order.values)\n\n\t\t\t\t\trender json: nil,status: 200\n\n\t\t\t\telse\n\n\t\t\t\t\trender json: nil,status: 422\n\n\t\t\t\tend\n\n\t\t\tend",
"def card_sort_params\n params.require( :card_sort ).permit( :name, :description, :code, :author_id, cards: [] )\n end",
"def get_sorted_list(type)\n temp_array = @items.select { |item| item.instance_of?(type) }\n case type\n when TodoItem\n temp_array.sort! { |i, j| i.due.to_s <=> j.due.to_s }\n when EventItem\n temp_array.sort! { |i, j| i.start_date.to_s <=> j.start_date.to_s }\n when LinkItem\n temp_array.sort! { |i, j| i.site_name <=> j.site_name }\n end\n temp_array\n end",
"def index\n order = filter_sortable_column_order %w{friendly_name receipt_name receipt_item_category.name}\n @receipt_item_types = current_account.receipt_item_types.include_names.order(order)\n respond_with @receipt_item_types\n end",
"def encode_sort_controls(sort_definitions)\n return sort_definitions unless sort_definitions\n\n sort_control_values = sort_definitions.map do |control|\n control = Array(control) # if there is only an attribute name as a string then infer the orderinrule and reverseorder\n control[0] = String(control[0]).to_ber,\n control[1] = String(control[1]).to_ber,\n control[2] = (control[2] == true).to_ber\n control.to_ber_sequence\n end\n sort_control = [\n Net::LDAP::LDAPControls::SORT_REQUEST.to_ber,\n false.to_ber,\n sort_control_values.to_ber_sequence.to_s.to_ber\n ].to_ber_sequence\n end",
"def sort_locations\n if params[:sort].present?\n params[:sort].split(\",\").each {|sort_according_to| add_sorting_for(sort_according_to)}\n end \n end",
"def list(list_type = :all, sort_type = $game_system.quest_sort_type[list_type])\n sort_type_s = sort_type.to_s\n reverse = !(sort_type_s.sub!(/_r$/, \"\")).nil?\n sort_type = sort_type_s.to_sym\n list = @sort_arrays[sort_type].select { |quest_id| include?(quest_id, list_type) }\n list.reverse! if reverse\n list.collect { |quest_id| @data[quest_id] }\n end",
"def create_types\n\t\t[]\n\tend",
"def create_types\n\t\t[]\n\tend",
"def sort_by_type!\n children.sort! do |x, y|\n if x.is_a?(PBXGroup) && y.is_a?(PBXFileReference)\n -1\n elsif x.is_a?(PBXFileReference) && y.is_a?(PBXGroup)\n 1\n else\n x.display_name <=> y.display_name\n end\n end\n end",
"def create_types\n\t[]\nend",
"def create_types\n\t[]\nend",
"def types\n types = Question.distinct.pluck(:type)\n render json: types.to_a\n end",
"def sort_products\n # defaults to \"name\"\n params[:sort] || \"name\"\n end",
"def sort_by\n unless params[:sort].blank?\n params[:sort] if params[:sort] == 'created_at' || 'vote_score' || 'replies'\n else\n 'created_at'\n end\n end",
"def get_sorting (default_sort_key)\n \n # Allowed sort fields, can sort by only these fields (are indexed) \n sort_keys = ['name', 'a_id', 'pub_id' , 'popularity_weight', 'category', \n 'sub_category', 'interests', 'release_date', \n 'total_ratings_count', 'total_average_rating',\n 'current_ratings_count', 'current_average_rating',\n 'new_apps', 'new_free_apps', 'new_paid_apps', \n 'top_free_apps_iphone', 'top_paid_apps_iphone',\n 'top_gros_apps_iphone', 'top_free_apps_ipad',\n 'top_paid_apps_ipad', 'top_gros_apps_ipad', 'amount',\n 'pub_name']\n \n # Get the sort_by parameter if it exists, otherwise use the default\n sort_param = request.query_parameters['sort_by'] || default_sort_key\n \n # Make sure the sort parameter is in our allowed list \n sort_key = sort_param if sort_keys.include?sort_param \n return sort_key\n \n end",
"def sort_search_media\n\t\t# sort the cases by last week, last year, last month and all\n\t\tcase_media = media_list(params[:searchterm]).send(params[:sort_type])\n\t\t# check condition for case media is present or not.\n\t\tif case_media.present?\n\t\t# response to the JSON\n\t render json: { success: true, response: case_media.map(&:attachment).as_json }\n\t else\n\t render :json=> { success: false, message: \"Media are not present\" },:status=> 203\n\t end\n\tend",
"def index\n @products = Product.order(:product_type)\n end",
"def types\n commit('types', nil)\n end",
"def update_types\n\t\t[]\n\tend",
"def update_types\n\t\t[]\n\tend",
"def show_sort_options\n sortDropdown = \"\"\n eds_info.fetch('AvailableSearchCriteria', {}).fetch('AvailableSorts', []).each do |sort_option|\n sortDropdown << \"<li><a href='#{eds_action_url sort_option[\"AddAction\"].to_s}'>#{sort_option[\"Label\"].to_s}</a></li>\"\n end\n sortDropdown.html_safe\n end",
"def types\n [\n { value: 'bus', name: 'Bus' },\n { value: 'coach', name: 'Coach' },\n { value: 'hgv', name: 'Heavy goods vehicle' },\n { value: 'van', name: 'Van' },\n { value: 'minibus', name: 'Minibus' },\n { value: 'private_car', name: 'Car' },\n { value: 'motorcycle', name: 'Motorcycle' }\n ]\n end",
"def index\n @ordertypes = Ordertype.all\n end",
"def evals_types\n call_path = \"evals/types\"\n data = build_post_data(\"\")\n perform_post(build_url(call_path), data)\n end",
"def index\n @settings_types = SettingsType.order('description asc')\n end",
"def index\n @comment_status_types = current_rulemaking.comment_status_types.order(:order_in_list)\n end"
] | [
"0.6817673",
"0.6803999",
"0.66339386",
"0.63523656",
"0.6283269",
"0.6172277",
"0.60445774",
"0.6036694",
"0.60232687",
"0.59714526",
"0.58344734",
"0.58241326",
"0.57855463",
"0.575487",
"0.5754733",
"0.5752283",
"0.574899",
"0.574899",
"0.5747693",
"0.5746359",
"0.5732689",
"0.5709955",
"0.569473",
"0.569087",
"0.5685147",
"0.5650075",
"0.5641341",
"0.5633643",
"0.56314343",
"0.5627217",
"0.56174546",
"0.56008106",
"0.5571786",
"0.5571444",
"0.55710536",
"0.55615795",
"0.55573505",
"0.5535744",
"0.55008036",
"0.54942256",
"0.5491245",
"0.54809767",
"0.5473321",
"0.54684544",
"0.54636276",
"0.5451132",
"0.5443376",
"0.54419327",
"0.5432064",
"0.542846",
"0.54232377",
"0.5413599",
"0.5413599",
"0.5413599",
"0.5413599",
"0.5413599",
"0.5413599",
"0.5413599",
"0.5413599",
"0.5413599",
"0.5393723",
"0.5373818",
"0.5364903",
"0.5353335",
"0.5353014",
"0.53443754",
"0.53347135",
"0.53272974",
"0.53013206",
"0.53012145",
"0.52928245",
"0.5291476",
"0.52871",
"0.5286841",
"0.5283701",
"0.52726895",
"0.5272172",
"0.52694684",
"0.52690077",
"0.5267215",
"0.5263805",
"0.5263805",
"0.5262333",
"0.525743",
"0.525743",
"0.5249968",
"0.52357036",
"0.5234829",
"0.5222531",
"0.52127415",
"0.5210378",
"0.52048147",
"0.5201881",
"0.5201881",
"0.51977336",
"0.51957446",
"0.51849186",
"0.518474",
"0.5176356",
"0.5174616"
] | 0.6941032 | 0 |
PUT /kf/sort_types/1 PUT /kf/sort_types/1.json | def update
@kf_sort_type = Kf::SortType.find(params[:id])
respond_to do |format|
if @kf_sort_type.update_attributes(params[:kf_sort_type])
format.html { redirect_to kf_sort_types_url({:page => params[:page]}), notice: 'Sort type was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @kf_sort_type.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n respond_to do |format|\n if @sort_type.update(sort_type_params)\n format.html { redirect_to @sort_type, notice: 'Sort type was successfully updated.' }\n format.json { render :show, status: :ok, location: @sort_type }\n else\n format.html { render :edit }\n format.json { render json: @sort_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_sort_type\n @sort_type = SortType.find(params[:id])\n end",
"def create\n @kf_sort_type = Kf::SortType.new(params[:kf_sort_type])\n\n respond_to do |format|\n if @kf_sort_type.save\n format.html { redirect_to kf_sort_types_url({:page => params[:page]}), notice: 'Sort type was successfully created.' }\n format.json { render json: @kf_sort_type, status: :created, location: @kf_sort_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @kf_sort_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_sort_order\n object = params[:imageable_type].constantize.find(params[:imageable_id])\n uploads = object.uploads\n params[:order].each_pair do |key, value|\n uploads.find(value[:id]).update_columns(sort: key, updated_at: Time.now)\n end\n render json: { message: 'success' }, :status => 200\n end",
"def index\n @sort_types = SortType.all\n end",
"def sort_type_params\n params.require(:sort_type).permit(\n :name,\n :roster_id,\n :setup_id,\n :start_time,\n :mon,\n :tue,\n :wed,\n :thu,\n :fri,\n :sat,\n :sun\n )\n end",
"def destroy\n @kf_sort_type = Kf::SortType.find(params[:id])\n @kf_sort_type.destroy\n\n respond_to do |format|\n format.html { redirect_to kf_sort_types_url({:page => params[:page]}) }\n format.json { head :no_content }\n end\n end",
"def create\n @sort_type = SortType.new(sort_type_params)\n\n respond_to do |format|\n if @sort_type.save\n format.html { redirect_to @sort_type, notice: 'Sort type was successfully created.' }\n format.json { render :show, status: :created, location: @sort_type }\n else\n format.html { render :new }\n format.json { render json: @sort_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @kf_sort_type = Kf::SortType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @kf_sort_type }\n end\n end",
"def show\n @kf_sort_type = Kf::SortType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kf_sort_type }\n end\n end",
"def index\n type = params[:type]\n field = params[:field]\n\n @items = Item.all.order(\"updated_at desc\")\n if type == \"sort\"\n @items = Item.all.order(\"#{field} asc\")\n end\n\n\n end",
"def index\n @ingredients = Ingredient.order(sort_type + \" \" + sort_direction)\n @activeSort = sort_type\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ingredients }\n end\n end",
"def sort_types\n @sort_types ||= begin\n sql = <<-SQLT\n SELECT\n CASE\n WHEN min(sortkey) < 0 THEN 'interleaved'\n ELSE 'compound'\n END AS sort_type, tablename\n FROM pg_table_def\n WHERE tablename in (#{tables_for_sql})\n GROUP BY tablename\n SQLT\n RailsRedshiftReplicator.connection.exec(sql.squish).entries\n end\n end",
"def add_to_sort_array(sort_type, quest_id)\n @sort_arrays[sort_type].delete(quest_id) # Make sure always unique\n case sort_type\n when :reveal, :change, :complete, :failed\n @sort_arrays[sort_type].unshift(quest_id)\n when :id\n @sort_arrays[sort_type].maqj_insert_sort(quest_id)\n when :alphabet \n @sort_arrays[sort_type].maqj_insert_sort(quest_id) { |a, b| @data[a].name.downcase <=> @data[b].name.downcase }\n when :level\n @sort_arrays[sort_type].maqj_insert_sort(quest_id) { |a, b| @data[a].level <=> self[b].level }\n end\n end",
"def sort\n params[:dept].each_with_index {|val, index|\n obj = Department.find_by_apikey(val)\n obj.update_attribute(:sort_order, index)\n }\n render :text => \"\"\n end",
"def destroy\n @sort_type.destroy\n respond_to do |format|\n format.html { redirect_to sort_types_url, notice: 'Sort type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def set_listing_sort_order(search_object, default_val)\n if params[:sort]\n sort_order = params[:sort].downcase\n case sort_order\n when \"manu\"\n search_object.sort_order = SortOrder::SORT_BY_MANU_ASC\n when \"manud\"\n search_object.sort_order = SortOrder::SORT_BY_MANU_DESC\n when \"size\"\n search_object.sort_order = SortOrder::SORT_BY_SIZE_ASC\n when \"sized\"\n search_object.sort_order = SortOrder::SORT_BY_SIZE_DESC\n when \"upd\"\n search_object.sort_order = SortOrder::SORT_BY_UPDATED_ASC\n when \"updd\"\n search_object.sort_order = SortOrder::SORT_BY_UPDATED_DESC\n when \"qty\"\n search_object.sort_order = SortOrder::SORT_BY_QTY_ASC\n when \"type\"\n search_object.sort_order = SortOrder::SORT_BY_TYPE_ASC\n when \"treadd\"\n search_object.sort_order = SortOrder::SORT_BY_TREADLIFE_DESC\n when \"distance\"\n search_object.sort_order = SortOrder::SORT_BY_DISTANCE_ASC\n when \"cost\"\n search_object.sort_order = SortOrder::SORT_BY_COST_PER_TIRE_ASC\n when \"costd\"\n search_object.sort_order = SortOrder::SORT_BY_COST_PER_TIRE_DESC\n when \"name\"\n search_object.sort_order = SortOrder::SORT_BY_MODEL_NAME_ASC\n when \"named\"\n search_object.sort_order = SortOrder::SORT_BY_MODEL_NAME_DESC\n when \"store\"\n search_object.sort_order = SortOrder::SORT_BY_STORE_NAME_ASC\n when \"stored\"\n search_object.sort_order = SortOrder::SORT_BY_STORE_NAME_DESC\n else\n search_object.sort_order = default_val\n end\n else\n search_object.sort_order = default_val\n end\n end",
"def update_order_of_items\n result = Catalog.do_update_order_of_items(params[:sort_orders])\n \n # return a success message, wouldn't make sense to call this API method as html, but for debugging\n # just return json anyway\n respond_to do |format|\n format.html { render json: result}\n format.json { render json: result}\n end\n end",
"def update\n respond_to do |format|\n if @card_sort.update(\n name: card_sort_params['name'],\n description: card_sort_params['description'],\n cards: card_sort_params['cards'].map{ |card| {label: card} },\n )\n format.html { redirect_to @card_sort, notice: 'Card sort was successfully updated.' }\n format.json { render :show, status: :ok, location: @card_sort }\n else\n format.html { render :edit }\n format.json { render json: @card_sort.errors, status: :unprocessable_entity }\n end\n end\n end",
"def sort\n @content_type.sort_contents!(params[:order])\n respond_with(@content_type, :location => admin_contents_url(@content_type.slug))\n end",
"def index\n conditions = []\n params[:per_page] = perpage if params[:per_page].nil?\n params[:page] = 1 if params[:page].blank?\n unless params[:search].blank?\n conditions.push \"title like ? or description like ?\"\n conditions.push \"%#{params[:search]}%\"\n conditions.push \"%#{params[:search]}%\"\n end\n @kf_sort_types = Kf::SortType.order(\"id DESC\").paginate(:page => params[:page], :per_page => params[:per_page] ,:conditions => conditions)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @kf_sort_types }\n end\n end",
"def safeSort type\r\n\t\traise \"CrossValidatorSet::InvalidSortType\" if ! @@acceptableSortMethods.include? type.to_sym\r\n\t\[email protected]{|a, b| a.getError.rmse <=> b.getError}\r\n\tend",
"def update\n @kf_sort = Kf::Sort.find(params[:id])\n\n respond_to do |format|\n if @kf_sort.update_attributes(params[:kf_sort])\n if @kf_sort.father_id != 0\n format.html { redirect_to \"/kf/sorts/#{params[:kf_sort][:father_id]}\" , notice: 'Sort was successfully updated.' }\n else\n format.html { redirect_to kf_sorts_url , notice: 'Sort was successfully updated.' }\n end\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @kf_sort.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_Sort(value)\n set_input(\"Sort\", value)\n end",
"def set_Sort(value)\n set_input(\"Sort\", value)\n end",
"def set_Sort(value)\n set_input(\"Sort\", value)\n end",
"def set_Sort(value)\n set_input(\"Sort\", value)\n end",
"def set_Sort(value)\n set_input(\"Sort\", value)\n end",
"def set_Sort(value)\n set_input(\"Sort\", value)\n end",
"def set_Sort(value)\n set_input(\"Sort\", value)\n end",
"def set_Sort(value)\n set_input(\"Sort\", value)\n end",
"def set_Sort(value)\n set_input(\"Sort\", value)\n end",
"def add_sorting_to_solr(solr_parameters)\n solr_parameters[:sort] = sort if sort.present?\n end",
"def index\n @tickettypes = Define.where( :usetype => 'tickettype' ).order(\"sort asc, updated_at desc\")\n @tickettype = Define.new\n\n respond_to do |format|\n format.html # index.html.erb\n end\nend",
"def update\n\t\t@sort = Sort.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tif @sort.update_attributes(params[:sort])\n\t\t\t\tformat.html { redirect_to(@sort, :notice => 'Sort was successfully updated.') }\n\t\t\t\tformat.xml { head :ok }\n\t\t\telse\n\t\t\t\tformat.html { render :action => \"edit\" }\n\t\t\t\tformat.xml { render :xml => @sort.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def set_Sort(value)\n set_input(\"Sort\", value)\n end",
"def new\n @kf_sort = Kf::Sort.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @kf_sort }\n end\n end",
"def sort\n (@params[:sort] || :created_at).to_sym\n end",
"def update_types\n\t[]\nend",
"def update_types\n\t[]\nend",
"def card_sort_params\n params.require( :card_sort ).permit( :name, :description, :code, :author_id, cards: [] )\n end",
"def tr_type_params\n params.require(:tr_type).permit(:name, :active_status, :sort)\n end",
"def detail_params\n params.require(:q).permit(:sorts)\n end",
"def update\n respond_to do |format|\n if @sorteio.update(sorteio_params)\n format.html { redirect_to @sorteio, notice: 'Sorteio was successfully updated.' }\n format.json { render :show, status: :ok, location: @sorteio }\n else\n format.html { render :edit }\n format.json { render json: @sorteio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @poi_types = PoiType.order(sort_column+ \" \" + sort_direction ).all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @poi_types }\n format.json \n end\n end",
"def set_SortOrder(value)\n set_input(\"SortOrder\", value)\n end",
"def set_SortOrder(value)\n set_input(\"SortOrder\", value)\n end",
"def set_SortOrder(value)\n set_input(\"SortOrder\", value)\n end",
"def set_SortOrder(value)\n set_input(\"SortOrder\", value)\n end",
"def set_SortOrder(value)\n set_input(\"SortOrder\", value)\n end",
"def set_SortOrder(value)\n set_input(\"SortOrder\", value)\n end",
"def set_SortOrder(value)\n set_input(\"SortOrder\", value)\n end",
"def set_SortOrder(value)\n set_input(\"SortOrder\", value)\n end",
"def set_SortOrder(value)\n set_input(\"SortOrder\", value)\n end",
"def set_SortOrder(value)\n set_input(\"SortOrder\", value)\n end",
"def set_SortOrder(value)\n set_input(\"SortOrder\", value)\n end",
"def set_SortOrder(value)\n set_input(\"SortOrder\", value)\n end",
"def set_SortOrder(value)\n set_input(\"SortOrder\", value)\n end",
"def set_SortOrder(value)\n set_input(\"SortOrder\", value)\n end",
"def set_SortOrder(value)\n set_input(\"SortOrder\", value)\n end",
"def set_SortOrder(value)\n set_input(\"SortOrder\", value)\n end",
"def set_SortOrder(value)\n set_input(\"SortOrder\", value)\n end",
"def update_types\n\t\t[]\n\tend",
"def update_types\n\t\t[]\n\tend",
"def sort_page_categories\n params[:pc].each_with_index {|val, index|\n obj = PageCategory.find_by_apikey(val)\n obj.update_attribute(:sort_order, index)\n }\n render :text => \"\"\n end",
"def s_typesort; det.link(:text, 'Type'); end",
"def index\n sort_group = [\"id\",\"realname\",\"vote_count\"];\n @sorted = {};\n sort_group.each do |x|\n @sorted[x.to_sym]=0\n end\n if !params[:sort_by].nil?\n sort(params[:sort_by],params[:sort_type])\n else\n @manage_users = Manage::User.all\n end\n\n end",
"def add_sort_field(*) super end",
"def sort_params; end",
"def sort_params; end",
"def sort(collection)\n sort = params[:sort]\n return collection unless sort\n\n sort_fields = Jaf::SortFields.deserialize(sort)\n collection.order(sort_fields)\n end",
"def order\n\n\t\t\t\ttestimonies = params.require(:testimonies)\n\n\t\t\t\torder = {}\n\t\t\t\ttestimonies.each_with_index do |id,i|\n\n\t\t\t\t\torder.merge! id => {sort: i}\n\n\t\t\t\tend\n\n\t\t\t\tif Testimony.update(order.keys,order.values)\n\n\t\t\t\t\trender json: nil,status: 200\n\n\t\t\t\telse\n\n\t\t\t\t\trender json: nil,status: 422\n\n\t\t\t\tend\n\n\t\t\tend",
"def sort\n params[:todo].each_with_index do |id, index|\n Todo.where(id: id).update_all(position: index + 1)\n end\n head :ok\n end",
"def sorting_params\n params.require(:sorting).permit(:house, :marriage, :pregnancy, :babies, :toddlers, :kids, :teens, :balance, :ip, :user_id)\n end",
"def manager_list_by_type\n \n @sort_order = get_sort_order\n @sort_order[:type] = params[:order] == 'ASC' ? 'DESC' : 'ASC'\n flash[:sort_order] = @sort_order\n \n design_reviews = get_active_reviews\n @active_reviews = design_reviews[:active].sort_by { |dr| [dr[:review].review_type.sort_order, dr[:review].age] }\n @inactive_reviews = design_reviews[:inactive].sort_by { |dr| [dr[:review].review_type.sort_order, dr[:review].age] }\n @active_reviews.reverse! if params[:order] == 'DESC'\n @inactive_reviews.reverse! if params[:order] == 'DESC'\n \n @submissions = BoardDesignEntry.submission_count\n session[:return_to] = {:controller => 'tracker',\n :action => 'manager_list_by_type',\n :order => params[:order]}\n render( :action => 'manager_home' )\n\n end",
"def create\n @tickettype = Define.new(params[:define])\n @tickettype.usetype = 'tickettype'\n\n respond_to do |format|\n if @tickettype.save\n format.html { redirect_to admin_ticket_type_path(@tickettype), notice: t(\"helpers.notice.new\") }\n else\n \n \t @tickettypes = Define.where( :usetype => 'tickettype' ).order(\"sort asc, updated_at desc\")\n format.html { render action: \"index\" }\n end\n end\nend",
"def order_type\n @order_type = current_store.order_types.find(params[:order_type_id])\n @order.update_columns(order_type_id: @order_type.id)\n @order_types = @order.available_order_types\n end",
"def update\n respond_to do |format|\n if @gtw_sortir.update(gtw_sortir_params)\n format.html { redirect_to @gtw_sortir, notice: 'Gtw sortir was successfully updated.' }\n format.json { render :show, status: :ok, location: @gtw_sortir }\n else\n format.html { render :edit }\n format.json { render json: @gtw_sortir.errors, status: :unprocessable_entity }\n end\n end\n end",
"def providers_sort_save\n params[:sortable_list].each_index do |i|\n item = SmsLcrprovider.find(:first, :conditions => [\"sms_provider_id = ? AND sms_lcr_id = ?\", params[:sortable_list][i], params[:id]])\n item.priority = i\n item.save\n end\n @page_title = _('Change_Order') + \": \" + @lcr.name\n @items = @lcr.sms_providers(\"asc\")\n render :layout => false, :action => :providers_sort\n end",
"def index\n params[:sort] ||= \"punto_servicio_id\"\n params[:direction] ||= \"asc\"\n @prestacions = Prestacion.order(params[:sort] + \" \" + params[:direction])\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @prestacions }\n end\n end",
"def sort_pages\n params[:page].each_with_index {|val, index|\n obj = Page.find_by_apikey(val)\n obj.update_attribute(:sort_order, index)\n }\n render :text => \"\"\n end",
"def update\n\n raw = params[:sample_type]\n st = SampleType.find(raw[:id])\n\n st.name = raw[:name]\n st.description = raw[:description]\n st.save\n st.save_field_types raw[:field_types]\n\n render json: { sample_type: st }\n\n end",
"def sort\n order = params[:asset]\n if order.nil?\n render json: {:kind => 'error', message: 'missing order' } \n end\n\n gid = params[:id]\n \n if gid.nil?\n render json: {:kind => 'error', order: 'missing gid' } unless gid.nil?\n end\n\n\n if Gallery.find(gid).update_attributes(:asset_order => order.join(','))\n render json: {:kind => 'success', :order => order, :gid=>gid} \n else\n render json: {:kind => 'error', :message=>'update order'} \n end\n\n end",
"def types\n aux = WorkOrderType.by_name\n render json: serialized_work_order_types(aux)\n end",
"def index\n sort = case params[:sort]\n when \"title\" then \"title\"\n when \"theme\" then \"theme\"\n when \"start_date\" then \"start_date\"\n when \"number_of_days\" then \"number_of_days\"\n when \"title_reverse\" then \"title DESC\"\n when \"theme_reverse\" then \"theme DESC\"\n when \"start_date_reverse\" then \"start_date DESC\"\n when \"number_of_days_reverse\" then \"number_of_days DESC\"\n else \"title\"\n end\n \n @sprints = Sprint.find :all, :order => sort\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :partial => \"sprints_list\", :layout => false }\n end\n end",
"def update\n\t\t@column_sort = current_user.column_sorts.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tif @column_sort.update_attributes(params[:column_sort])\n\t\t\t\tformat.html { redirect_to(@column_sort, :notice => 'Column sort was successfully updated.') }\n\t\t\t\tformat.xml { head :ok }\n\t\t\t\tformat.json { head :ok }\n\t\t\t\tformat.yaml { render :text => \"\", :content_type => 'text/yaml' }\n\t\t\telse\n\t\t\t\tformat.html { render :action => \"edit\" }\n\t\t\t\tformat.xml { render :xml => @column_sort.errors, :status => :unprocessable_entity }\n\t\t\t\tformat.json { render :json => @column_sort.errors, :status => :unprocessable_entity }\n\t\t\t\tformat.yaml { render :text => @column_sort.errors.to_yaml, :content_type => 'text/yaml', :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def convert_sort_params\n @sort_params = []\n #convert sort params to database columns\n if params[:sorting] && params[:sorting].is_a?(Array)\n params[:sorting].each do |p|\n\n sort = sort.reject{|k, v| [email protected]_method?(k) || !['asc', 'desc'].include?(v.downcase)}\n\n @sort_params.push(sort)\n end\n end\n @sort_params\n end",
"def index\n\n # TODO: Refactor this!!!\n sort_function = (params[:sort] == 'name' ? :name : :count)\n\n @tags = Factoid.tag_counts.sort_by {|tag| tag.send(sort_function)}.reverse\n\n if params[:direction] == 'desc'\n @tags.reverse!\n end\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tags }\n end\n end",
"def set_sortable\n @sortable = Sortable.find(params[:id])\n end",
"def update\n authorize_action_for @order_type, at: current_store\n\n respond_to do |format|\n if @order_type.update(order_type_params)\n track @order_type\n format.html { redirect_to admin_order_type_path(@order_type),\n notice: t('.notice', order_type: @order_type) }\n format.json { render :show, status: :ok, location: admin_order_type_path(@order_type) }\n else\n format.html { render :edit }\n format.json { render json: @order_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @specification_types = SpecificationType.all.order(\"display_order\")\n\n render json: @specification_types, each_serializer: Web::V1::SpecificationTypeSerializer\n end",
"def sort\n @phase = Phase.find(params[:id])\n authorize @phase\n ordering = phase_params[:sort_order] || []\n Section.update_numbers!(ordering, parent: @phase)\n head :ok\n end",
"def index\n respond_to do |format|\n format.html { @product_types = ProductType.all }\n format.json { @product_types = ProductType.order(:name) }\n end\n end",
"def update!(**args)\n @kind = args[:kind] if args.key?(:kind)\n @order = args[:order] if args.key?(:order)\n end",
"def sort_products\n # defaults to \"name\"\n params[:sort] || \"name\"\n end",
"def sort\n @szenes = Szene.where(:id => params[:szene])\n @szenes.each do |szene|\n szene.position = params['szene'].index(szene.id.to_s)+1\n szene.save\n end\n render :nothing => true\n end",
"def index\n @inventory_types = InventoryType.all.sort_by(&:name)\n end",
"def sort\n notice = 'Categories successfully sorted.'\n error = 'Could not sort Categories.'\n \n begin \n ShopCategory.sort(CGI::parse(params[:categories])[\"categories[]\"])\n \n respond_to do |format|\n format.html {\n redirect_to admin_shop_products_path\n }\n format.js { render :text => notice, :status => :ok }\n format.json { render :json => { :notice => notice }, :status => :ok }\n end\n rescue\n respond_to do |format|\n format.html {\n flash[:error] = error\n redirect_to admin_shop_products_path\n }\n format.js { render :text => error, :status => :unprocessable_entity }\n format.json { render :json => { :error => error }, :status => :unprocessable_entity }\n end\n end\n end",
"def set_order\n sort = params[:sort].present? ? params[:sort] : 'id'\n # FIXME cambiar puntos por guiones para tener automagia\n if sort == 'terceros_nombre'\n sort = 'terceros.nombre'\n end\n ord = params[:order].present? ? params[:order].upcase() : 'ASC'\n @order = sort + ' ' + ord\n end",
"def update\n respond_to do |format|\n if @sorteado.update(sorteado_params)\n format.html { redirect_to @sorteado, notice: 'Sorteado was successfully updated.' }\n format.json { render :show, status: :ok, location: @sorteado }\n else\n format.html { render :edit }\n format.json { render json: @sorteado.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.7033368",
"0.67520094",
"0.6654694",
"0.6523376",
"0.6520682",
"0.64555",
"0.6344083",
"0.6135027",
"0.608219",
"0.60049415",
"0.5956442",
"0.5932856",
"0.58494633",
"0.58329576",
"0.5829314",
"0.5772021",
"0.56875914",
"0.5661305",
"0.56543964",
"0.5632907",
"0.5588571",
"0.55807656",
"0.55748385",
"0.5532287",
"0.5532287",
"0.5532287",
"0.5532287",
"0.5532287",
"0.5532287",
"0.5532287",
"0.5532287",
"0.5532287",
"0.55135095",
"0.5511924",
"0.5511376",
"0.5495789",
"0.54856604",
"0.5459008",
"0.5438421",
"0.5438421",
"0.5430887",
"0.5427713",
"0.53900784",
"0.5375933",
"0.5370954",
"0.53694737",
"0.53694737",
"0.53694737",
"0.53694737",
"0.53694737",
"0.53694737",
"0.53694737",
"0.53694737",
"0.53694737",
"0.53694737",
"0.53694737",
"0.53694737",
"0.53694737",
"0.53694737",
"0.53694737",
"0.53694737",
"0.53694737",
"0.5366305",
"0.5366305",
"0.5353837",
"0.53404266",
"0.5338845",
"0.53284425",
"0.53265",
"0.53265",
"0.53136337",
"0.53057015",
"0.5302966",
"0.52928907",
"0.5292125",
"0.5289904",
"0.52808756",
"0.52719563",
"0.5265641",
"0.526313",
"0.525777",
"0.5243606",
"0.5243473",
"0.5240922",
"0.52168345",
"0.5211696",
"0.5207505",
"0.5207192",
"0.5206434",
"0.5200391",
"0.5179854",
"0.51778865",
"0.51670647",
"0.51570535",
"0.51535594",
"0.5146503",
"0.51359206",
"0.5134582",
"0.513333",
"0.513181"
] | 0.72249204 | 0 |
DELETE /kf/sort_types/1 DELETE /kf/sort_types/1.json | def destroy
@kf_sort_type = Kf::SortType.find(params[:id])
@kf_sort_type.destroy
respond_to do |format|
format.html { redirect_to kf_sort_types_url({:page => params[:page]}) }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @sort_type.destroy\n respond_to do |format|\n format.html { redirect_to sort_types_url, notice: 'Sort type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kf_sort = Kf::Sort.find(params[:id])\n @kf_sort.destroy\n\n respond_to do |format|\n if params[:sort_father_id] != 0.to_s\n format.html { redirect_to \"/kf/sorts/#{params[:sort_father_id]}\" }\n else\n format.html { redirect_to kf_sorts_url }\n end\n format.json { head :no_content }\n end\n end",
"def destroy\n @testtype.destroy\n respond_to do |format|\n format.html { redirect_to testtypes_url }\n format.json { head :no_content }\n end\n end",
"def delete_from_entzumena\n headline = Headline.where({:source_item_type => params[:source_item_type], :source_item_id => params[:source_item_id]}).first\n if headline.destroy\n render :json => true, :status => 200\n else\n render :json => false, :status => :error\n end\n end",
"def destroy\n @typegroup.destroy\n respond_to do |format|\n format.html { redirect_to typegroups_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @type = Type.find(params[:id])\n @type.destroy\n\n respond_to do |format|\n format.html { redirect_to types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sortable.destroy\n respond_to do |format|\n format.html { redirect_to sortables_url, notice: 'Sortable was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dishtype.destroy\n respond_to do |format|\n format.html { redirect_to dishtypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @os_type = OsType.find(params[:id])\n @os_type.destroy\n\n respond_to do |format|\n format.html { redirect_to os_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @arc_type.destroy\n respond_to do |format|\n format.html { redirect_to arc_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ordertype.destroy\n respond_to do |format|\n format.html { redirect_to ordertypes_url, notice: 'Ordertype was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @nav_type.destroy\n respond_to do |format|\n format.html { redirect_to nav_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n\n @order_type.destroy\n\n respond_to do |format|\n format.html { redirect_to(order_types_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @entry_type = EntryType.find(params[:id])\n @entry_type.destroy\n\n respond_to do |format|\n format.html { redirect_to entry_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @export_type.destroy\n respond_to do |format|\n format.html { redirect_to export_types_url, notice: 'Export type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dash_type = DashType.find(params[:id])\n @dash_type.destroy\n\n respond_to do |format|\n format.html { redirect_to dash_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item_type.destroy\n respond_to do |format|\n format.html { redirect_to item_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @prune_type.destroy\n respond_to do |format|\n format.html { redirect_to prune_types_url, notice: 'Prune type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gtw_sortir.destroy\n respond_to do |format|\n format.html { redirect_to gtw_sortirs_url, notice: 'Gtw sortir was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tax_type = TaxType.find(params[:id])\n @tax_type.destroy\n\n respond_to do |format|\n format.html { redirect_to tax_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize_action_for @order_type, at: current_store\n track @order_type\n @order_type.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_order_types_path,\n notice: t('.notice', order_type: @order_type) }\n format.json { head :no_content }\n end\n end",
"def destroy\n\t\t@sort = Sort.find(params[:id])\n\t\[email protected]\n\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to(sorts_url) }\n\t\t\tformat.xml { head :ok }\n\t\tend\n\tend",
"def destroy\n @modtype.destroy\n respond_to do |format|\n format.html { redirect_to modtypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gl_type = GlType.find(params[:id])\n @gl_type.destroy\n\n respond_to do |format|\n format.html { redirect_to gl_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @flat_type.destroy\n respond_to do |format|\n format.html { redirect_to flat_types_url, notice: 'Flat type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @type = Type.find(params[:type])\n @type.destroy\n\n respond_to do |format|\n format.html { redirect_to company_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sorteio.destroy\n respond_to do |format|\n format.html { redirect_to sorteios_url, notice: 'Sorteio was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cdist_type = CdistType.find(params[:id])\n @cdist_type.destroy\n\n respond_to do |format|\n format.html { redirect_to cdist_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order_type = OrderType.find(params[:id])\n @order_type.destroy\n\n respond_to do |format|\n format.html { redirect_to(order_types_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @trtype = Trtype.find(params[:id])\n @trtype.destroy\n\n respond_to do |format|\n format.html { redirect_to trtypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @package_type.destroy\n respond_to do |format|\n format.html { redirect_to package_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @data_set_type.destroy\n respond_to do |format|\n format.html { redirect_to data_set_types_url, notice: 'Data set type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @os_type.destroy\n respond_to do |format|\n format.html { redirect_to os_types_url, notice: 'Os type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @affected_type.destroy\n respond_to do |format|\n format.html { redirect_to affected_types_url, notice: 'Affected type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @run_type = RunType.find(params[:id])\n @run_type.destroy\n\n respond_to do |format|\n format.html { redirect_to run_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kf_course_item_type = Kf::CourseItemType.find(params[:id])\n @kf_course_item_type.destroy\n\n respond_to do |format|\n format.html { redirect_to kf_course_item_types_url({:page => params[:page]}) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @all_field_type = AllFieldType.find(params[:id])\n @all_field_type.destroy\n\n respond_to do |format|\n format.html { redirect_to all_field_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kf_status = Kf::Status.find(params[:id])\n @kf_status.destroy\n\n respond_to do |format|\n format.html { redirect_to \"/kf/statuses?page=#{params[:page]}&relation_id=#{params[:relation_id]}&status_type=#{params[:status_type]}&count_type=#{params[:count_type]}\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @step_type = StepType.find(params[:id])\n @step_type.destroy\n\n respond_to do |format|\n format.html { redirect_to step_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cg_table_type = CgTableType.find(params[:id])\n @cg_table_type.destroy\n\n respond_to do |format|\n format.html { redirect_to cg_table_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dish_type.destroy\n respond_to do |format|\n format.html { redirect_to dish_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @run_type.destroy\n respond_to do |format|\n format.html { redirect_to run_types_url, notice: 'Run type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n lookup_label = get_type_label(@lookup.lookup_type)\n @lookup.destroy\n respond_to do |format|\n format.html { redirect_to lookups_path(:lookup_type => lookup_label), notice: \"#{lookup_label} se ha eliminado correctamente\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ref_diagnostic_test_type = Ref::DiagnosticTestType.find(params[:id])\n @ref_diagnostic_test_type.destroy\n\n respond_to do |format|\n format.html { redirect_to ref_diagnostic_test_types_url }\n format.json { head :ok }\n end\n end",
"def destroy\n asset_type = AssetType.find(params[:id])\n asset_type.destroy\n\n respond_to do |format|\n format.html { redirect_to asset_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_v1_admin_type.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_admin_types_url, notice: 'Admin type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @default_task_type.destroy\n respond_to do |format|\n format.html { redirect_to default_task_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @task_type.destroy\n respond_to do |format|\n format.html { redirect_to admin_task_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @segment_type = SegmentType.find(params[:id])\n @segment_type.destroy\n\n respond_to do |format|\n format.html { redirect_to segment_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tariff_type = TariffType.find(params[:id])\n @tariff_type.destroy\n\n respond_to do |format|\n format.html { redirect_to tariff_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @drum_type.destroy\n respond_to do |format|\n format.html { redirect_to drum_types_url, notice: 'Drum type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @coverage_type.destroy\n respond_to do |format|\n format.html { redirect_to coverage_types_url, notice: 'Coverage type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @act_type = ActType.find(params[:id])\n @act_type.destroy\n\n respond_to do |format|\n format.html { redirect_to act_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sortie = Sortie.find(params[:id])\n @sortie.destroy\n\n respond_to do |format|\n format.html { redirect_to(sorties_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @benchmark_type = BenchmarkType.find(params[:id])\n @benchmark_type.destroy\n\n respond_to do |format|\n format.html { redirect_to benchmark_types_url }\n format.json { head :no_content }\n format.xml { head :no_content }\n end\n end",
"def destroy\n @client_type = ClientType.find(params[:id])\n @client_type.destroy\n\n respond_to do |format|\n format.html { redirect_to client_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @crossbowtype.destroy\n respond_to do |format|\n format.html { redirect_to crossbowtypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @stock_type = StockType.find(params[:id])\n @stock_type.destroy\n\n respond_to do |format|\n format.html { redirect_to stock_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ftype = Ftype.find(params[:id])\n @ftype.destroy\n\n respond_to do |format|\n format.html { redirect_to ftypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @vehicle_type.destroy\n respond_to do |format|\n format.html { redirect_to vehicle_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @structure_type = StructureType.find(params[:id])\n @structure_type.destroy\n\n respond_to do |format|\n format.html { redirect_to structure_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @yarn_type.destroy\n respond_to do |format|\n format.html { redirect_to yarn_types_url, notice: 'Yarn type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @entry = Entry.find(params[:id])\n entry_type = @entry.entry_type\n @entry.destroy\n\n respond_to do |format|\n format.html { redirect_to admin_entries_url(:entry_type => entry_type)}\n format.json { head :no_content }\n end\n end",
"def destroy\n @route_type.destroy\n respond_to do |format|\n format.html { redirect_to route_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @addtype.destroy\n respond_to do |format|\n format.html { redirect_to addtypes_url, notice: '变动方式删除成功!.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @vehicletype.destroy\n respond_to do |format|\n format.html { redirect_to vehicletypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @actiontype.destroy\n respond_to do |format|\n format.html { redirect_to actiontypes_url, notice: 'Actiontype was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @acquired_type.destroy\n respond_to do |format|\n format.html { redirect_to acquired_types_url }\n format.json { head :no_content }\n format.js\n end\n end",
"def destroy\n @az_simple_data_type = AzSimpleDataType.find(params[:id])\n @az_simple_data_type.destroy\n\n respond_to do |format|\n format.html { redirect_to(az_simple_data_types_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @shape_type = ShapeType.find(params[:id])\n @shape_type.destroy\n\n\t\tmsg = I18n.t('app.msgs.success_deleted', :obj => I18n.t('app.common.shape_type'))\n\t\tsend_status_update(I18n.t('app.msgs.cache_cleared', :action => msg))\n respond_to do |format|\n format.html { redirect_to admin_shape_types_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @card_sort.destroy\n respond_to do |format|\n format.html { redirect_to card_sorts_url, notice: 'Card sort was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sample_type = SampleType.find(params[:id])\n @sample_type.destroy\n\n respond_to do |format|\n format.html { redirect_to sample_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ad_type = AdType.find(params[:id])\n @ad_type.destroy\n\n respond_to do |format|\n format.html { redirect_to ad_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @collection_type = CollectionType.find(params[:id])\n @collection_type.destroy\n\n respond_to do |format|\n format.html { redirect_to collection_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @diet_type.destroy\n respond_to do |format|\n format.html { redirect_to diet_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @contract_type.destroy\n respond_to do |format|\n format.html { redirect_to contract_types_url, notice: 'Contract type a bien été supprimé.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @block_type.destroy\n respond_to do |format|\n format.html { redirect_to block_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @block_type.destroy\n respond_to do |format|\n format.html { redirect_to block_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tool_type.destroy\n respond_to do |format|\n format.html { redirect_to tool_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @archetype = Archetype.find(params[:id])\n @archetype.destroy\n\n respond_to do |format|\n format.html { redirect_to archetypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @fieldtype = Fieldtype.find(params[:id])\n @fieldtype.destroy\n\n respond_to do |format|\n format.html { redirect_to fieldtypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recipe_type.destroy\n respond_to do |format|\n format.html { redirect_to recipe_types_url, notice: \"Recipe type was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @nametype.destroy\n respond_to do |format|\n format.html { redirect_to nametypes_url, notice: 'Nametype was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tasktype = Tasktype.find(params[:id])\n @tasktype.destroy\n\n respond_to do |format|\n format.html { redirect_to tasktypes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @type_debit.destroy\n respond_to do |format|\n format.html { redirect_to type_debits_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @page_type = PageType.find(params[:id])\n @page_type.destroy\n\n respond_to do |format|\n format.html { redirect_to page_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @manifestation_type = ManifestationType.find(params[:id])\n @manifestation_type.destroy\n\n respond_to do |format|\n format.html { redirect_to manifestation_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bs_type.destroy\n respond_to do |format|\n format.html { redirect_to bs_types_url, notice: 'Bs type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def _delete(type, *args)\n type = type.to_s.camelize\n metadata = args.map { |full_name| {:full_name => full_name} }\n request :delete do |soap|\n soap.body = {\n :metadata => metadata\n }.merge(attributes!(type))\n end\n end",
"def destroy\n @work_item_type.destroy\n respond_to do |format|\n format.html { redirect_to work_item_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @ref_med_diagnostic_test_type = Ref::MedDiagnosticTestType.find(params[:id])\n @ref_med_diagnostic_test_type.destroy\n\n respond_to do |format|\n format.html { redirect_to ref_med_diagnostic_test_types_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @payment_type_status.destroy\n respond_to do |format|\n format.html { redirect_to payment_type_statuses_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n\t\t@column_sort = current_user.column_sorts.find(params[:id])\n\t\t@column_sort.destroy\n\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to(column_sorts_url) }\n\t\t\tformat.xml { head :ok }\n\t\t\tformat.json { head :ok }\n\t\t\tformat.yaml { render :text => \"\", :content_type => 'text/yaml' }\n\t\tend\n\tend",
"def destroy\n @spec_type.destroy\n respond_to do |format|\n format.html { redirect_to spec_types_url, notice: 'Spec type was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @awon_record_type.destroy\n respond_to do |format|\n format.html { redirect_to awon_record_types_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sorteado.destroy\n respond_to do |format|\n format.html { redirect_to sorteados_url, notice: 'Sorteado was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_index\n @customer = Customer.with_deleted.find(params[:id])\n if params[:type]=='normal'\n @customer.delete\n elsif params[:type]=='restore'\n @customer.restore\n @customer.update(deleted_at: nil)\n end\n\n @customer.destroy\n respond_to do |format|\n format.html { redirect_to customers_path, notice: 'Customer was successfully removed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @type_search.destroy\n respond_to do |format|\n format.html { redirect_to type_searches_url, notice: 'Type search was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @order_kind.destroy\n respond_to do |format|\n format.html { redirect_to order_kinds_url, notice: 'Order kind was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n render_json_auto @survey.delete_filter(params[:id].to_i) and return\n end"
] | [
"0.74730843",
"0.6476687",
"0.6438022",
"0.63571686",
"0.63566947",
"0.6345226",
"0.634209",
"0.63361657",
"0.6317694",
"0.63074946",
"0.6300656",
"0.6297253",
"0.62945867",
"0.628615",
"0.62770337",
"0.62645555",
"0.62551594",
"0.6251596",
"0.62496066",
"0.62319815",
"0.6220003",
"0.62154484",
"0.62063324",
"0.62041",
"0.61960024",
"0.61955965",
"0.61880255",
"0.618232",
"0.6167209",
"0.6157788",
"0.615664",
"0.6152508",
"0.6143329",
"0.6140729",
"0.6135813",
"0.61318606",
"0.6128243",
"0.61265665",
"0.6122642",
"0.61171275",
"0.61073756",
"0.6103772",
"0.6103607",
"0.6098019",
"0.6095168",
"0.609469",
"0.60924137",
"0.6091854",
"0.6089543",
"0.6089145",
"0.6087784",
"0.6086893",
"0.60861695",
"0.608536",
"0.6072632",
"0.6071123",
"0.60614663",
"0.60539514",
"0.60497737",
"0.60492855",
"0.60419554",
"0.6037455",
"0.6036473",
"0.6034399",
"0.60329384",
"0.60269535",
"0.6026566",
"0.6024885",
"0.6013845",
"0.60138327",
"0.60113376",
"0.6004072",
"0.6002918",
"0.6002687",
"0.60011095",
"0.60000336",
"0.5997956",
"0.5997956",
"0.59964526",
"0.59963155",
"0.59938353",
"0.5990814",
"0.59897417",
"0.598886",
"0.5986433",
"0.5985049",
"0.59847075",
"0.5983072",
"0.59821063",
"0.5976043",
"0.5974334",
"0.59723926",
"0.5972078",
"0.5970538",
"0.5969527",
"0.596821",
"0.59672415",
"0.59624606",
"0.59613323",
"0.59601164"
] | 0.780744 | 0 |
GET /cabinet/transports GET /cabinet/transports.json | def index
@cabinet_transports = Transport.eager_load(:map_layer)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_transports(level, format, names)\n transport_names = Array(names)\n # rubocop:disable LineLength\n #transports = @transports.select { |t| (t.up_to_level? level) && (t.format == format) }\n transports = @transports\n # rubocop:enable LineLength\n return transports if Array(names).empty?\n\n transports.select { |t| transport_names.include?(t.name) }\n end",
"def new\n @cabinet_transport = current_user.transports.new\n end",
"def get_current_transport\n x = transport_list\n x[:transports][0]\n end",
"def transports(opts=nil)\n @transports = cli.parent.application.transports\n @transports.load_all\n return \"there are no transports.\" unless @transports.size > 0\n response = catch(:quit) do\n transport = prompt_trans\n begin\n puts hr\n puts transport.inspect\n puts hr\n command_names = transport.interface.commands.map{|x| x.name } << :quit\n list = command_names.map{|x| %{[#{x}]}}\n puts \"enter <name> = <value>\"\n puts \"or type the beginning of\"<<(list.size > 1 ? ' one of ' : ' ') <<\n en{np(:the,'command',list.size,:say_count => false)}.say\n puts en{list(list)}.or\n puts hr\n print \": \"\n entered = gets.chomp\n cmd = prompt_enum(command_names.map{|_|_.to_s} << \"\", entered)\n if (cmd)\n case cmd\n when \"\": next\n when \"quit\": throw :quit, \"goodbye, thank you\"\n when String:\n command = transport.interface.command[cmd.to_sym]\n begin\n resp = transport.send(command.method) # we trust that the above only allowed thru publicly accessible cmd names\n puts resp.to_s\n rescue Hipe::SocialSync::TransportRuntimeError => e\n puts e.message\n next\n end\n else raise \"huh?\"\n end\n else\n if (/^[a-z_]+$/i =~ entered)\n puts \"unrecognized or ambiguous command #{entered.inspect}\"\n next\n elsif( tree = parse_assignment(entered) )\n unless(accessor = transport.class.attrs[tree.name])\n puts %|not a writable attribute: #{tree.name.inspect}|\n next\n end\n begin\n transport.send %{#{accessor.name}=}, tree.value\n rescue ArgumentError => e\n puts e.message << \" for #{accessor.name}\"\n next\n end\n next\n else\n puts \"poorly formed request: #{entered.inspect}\"\n next\n end\n end\n end while true\n end\n end",
"def get_cabinets(options={})\n parser.cabinets_parser(get({ path: ROUTES[:get_cabinets].call, headers: authorization_header_for_rest_api }))\n end",
"def create\n @cabinet_transport = current_user.transports.new(cabinet_transport_params)\n respond_to do |format|\n if @cabinet_transport.save\n public_send(params[:transport][:status])\n format.html { redirect_to cabinet_transports_path, notice: I18n.t('created') }\n else\n format.html { render :new }\n format.json { render json: @cabinet_transport.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @transports = Transport.all.includes(:bus,:from,:to)\n end",
"def set_cabinet_transport\n @cabinet_transport = Transport.find(params[:id])\n end",
"def list_transport_zones_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ManagementPlaneApiNetworkTransportTransportZonesApi.list_transport_zones ...'\n end\n if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] > 1000\n fail ArgumentError, 'invalid value for \"opts[:\"page_size\"]\" when calling ManagementPlaneApiNetworkTransportTransportZonesApi.list_transport_zones, must be smaller than or equal to 1000.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] < 0\n fail ArgumentError, 'invalid value for \"opts[:\"page_size\"]\" when calling ManagementPlaneApiNetworkTransportTransportZonesApi.list_transport_zones, must be greater than or equal to 0.'\n end\n\n if @api_client.config.client_side_validation && opts[:'transport_type'] && !['OVERLAY', 'VLAN'].include?(opts[:'transport_type'])\n fail ArgumentError, 'invalid value for \"transport_type\", must be one of OVERLAY, VLAN'\n end\n # resource path\n local_var_path = '/transport-zones'\n\n # query parameters\n query_params = {}\n query_params[:'cursor'] = opts[:'cursor'] if !opts[:'cursor'].nil?\n query_params[:'included_fields'] = opts[:'included_fields'] if !opts[:'included_fields'].nil?\n query_params[:'is_default'] = opts[:'is_default'] if !opts[:'is_default'].nil?\n query_params[:'page_size'] = opts[:'page_size'] if !opts[:'page_size'].nil?\n query_params[:'sort_ascending'] = opts[:'sort_ascending'] if !opts[:'sort_ascending'].nil?\n query_params[:'sort_by'] = opts[:'sort_by'] if !opts[:'sort_by'].nil?\n query_params[:'transport_type'] = opts[:'transport_type'] if !opts[:'transport_type'].nil?\n query_params[:'uplink_teaming_policy_name'] = opts[:'uplink_teaming_policy_name'] if !opts[:'uplink_teaming_policy_name'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'TransportZoneListResult')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ManagementPlaneApiNetworkTransportTransportZonesApi#list_transport_zones\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def get_telephony_providers_edges_timezones_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: TelephonyProvidersEdgeApi.get_telephony_providers_edges_timezones ...\"\n end\n \n \n \n \n \n \n \n \n \n \n \n \n \n # resource path\n local_var_path = \"/api/v2/telephony/providers/edges/timezones\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'pageSize'] = opts[:'page_size'] if opts[:'page_size']\n query_params[:'pageNumber'] = opts[:'page_number'] if opts[:'page_number']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n auth_names = ['PureCloud OAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'TimeZoneEntityListing')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: TelephonyProvidersEdgeApi#get_telephony_providers_edges_timezones\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def getTransport()\n\t\treturn @transport\n\tend",
"def index\n @transports = @player.transports.all\n if @transports.empty?\n flash[:notice] = \"You have no Transports yet.\"\n redirect_to(new_player_transport_path(@player)) and return \n end\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @transports }\n end\n end",
"def list_transport_zones(opts = {})\n data, _status_code, _headers = list_transport_zones_with_http_info(opts)\n data\n end",
"def index\n #@transports = Transport.all\n @transports = Transport.paginate :page => params[:page], :order => 'id DESC'\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @transports }\n end\n end",
"def transport_options\n definition.transport_options\n end",
"def get_carriers\n @transporter = Transporter.find(params[:id])\n\n render json: @transporter.carriers\n end",
"def destroy\n @cabinet_transport.destroy\n respond_to do |format|\n format.html { redirect_to cabinet_transports_path, notice: I18n.t('deleted') }\n format.json { head :no_content }\n end\n end",
"def get_all_tournaments\n\t\ttc = new_sub(@discovery['tournaments']['url'], @discovery['tournaments']['capability'])\n\t\ttc.listen.map {|x| JSON.parse(x) rescue nil}.compact\n\tend",
"def index\n @transport_hours = TransportHour.all\n end",
"def transport; end",
"def transport; end",
"def transport; end",
"def show\n @transport_subsidy = TransportSubsidy.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @transport_subsidy }\n end\n end",
"def show\n @transporter = Transporter.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @transporter }\n end\n end",
"def index\n @torrents = Torrents.new(:url => \"http://newt.local:9091/transmission/rpc\").load\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @torrents }\n end\n end",
"def get_json()\n\n http = Net::HTTP.new(STATUS_URI.host, STATUS_URI.port)\n http.use_ssl = false\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Get.new(\"/api/services.json\")\n\n response = http.request(request)\n JSON.parse(response.body)\nend",
"def tenant_list\n\t\t\n\t\tget_call = Curl::Easy.http_get(\"#{@ip_address}:#{@port_2}/v2.0/tenants\"\n\t\t) do |curl| curl.headers['x-auth-token'] = @token end\n\t\t\n\t\tputs \"invoking tenant-list...\"\n\t\t\n\t\tparsed_json = JSON.parse(get_call.body_str)\n\t\t\n\t\tputs parsed_json\n\t\treturn parsed_json\n\tend",
"def show\n @transport_route = TransportRoute.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @transport_route }\n end\n end",
"def toxics\n request = Net::HTTP::Get.new(\"/proxies/#{name}/toxics\")\n response = http_request(request)\n assert_response(response)\n\n JSON.parse(response.body).map do |attrs|\n Toxic.new(\n type: attrs[\"type\"],\n name: attrs[\"name\"],\n proxy: self,\n stream: attrs[\"stream\"],\n toxicity: attrs[\"toxicity\"],\n attributes: attrs[\"attributes\"],\n )\n end\n end",
"def cabinet_transport_params\n permitted = Transport.globalize_attribute_names + [\n :gis_type_name,\n :status,\n :map_layer_id,\n :transport_type_id,\n geo_json_attributes: %i[id geo_type position]\n ]\n params.require(:transport).permit(permitted)\n end",
"def list_tenants_for_circle(args = {}) \n get(\"/tenantcircles.json/tenants\", args)\nend",
"def index\n @admin_public_transports = City.find(session[:current_city_id]).utility.public_transports.page(params[:page]).per(10)\n end",
"def transport\n instance.transport\n end",
"def newTransport\n\n end",
"def index\n @transportadoras = Transportadora.all\n end",
"def service_list\n uri = URI.parse(@url)\n http = Net::HTTP.new(uri.host, uri.port, @proxy_addr, @proxy_port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n request = Net::HTTP::Get.new(uri.request_uri)\n request.basic_auth user, passwd\n request.add_field 'X-ID-TENANT-NAME', id_domain\n http.request(request)\n end",
"def get_transport_zone_with_http_info(zone_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ManagementPlaneApiNetworkTransportTransportZonesApi.get_transport_zone ...'\n end\n # verify the required parameter 'zone_id' is set\n if @api_client.config.client_side_validation && zone_id.nil?\n fail ArgumentError, \"Missing the required parameter 'zone_id' when calling ManagementPlaneApiNetworkTransportTransportZonesApi.get_transport_zone\"\n end\n # resource path\n local_var_path = '/transport-zones/{zone-id}'.sub('{' + 'zone-id' + '}', zone_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'TransportZone')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ManagementPlaneApiNetworkTransportTransportZonesApi#get_transport_zone\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def get\n appid = ENV['TRIMET_APP_ID']\n response = Unirest.get( \"http://developer.trimet.org/ws/v2/vehicles?appid=#{appid}\" )\n response.body\nend",
"def agent_transport_addresses\n [ @address ]\n end",
"def test_truth\n assert_kind_of Transport, transports(:first)\n end",
"def list_transport_node_collections_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ManagementPlaneApiNetworkTransportTransportNodeCollectionsApi.list_transport_node_collections ...'\n end\n # resource path\n local_var_path = '/transport-node-collections'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'TransportNodeCollectionListResult')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ManagementPlaneApiNetworkTransportTransportNodeCollectionsApi#list_transport_node_collections\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n @transfers = Transfer.all\n render json: @transfers\n end",
"def show\n @transport = @player.transports.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @transport }\n end\n end",
"def get_all_tables\n\t\ttc = new_sub(@discovery['tables']['url'], @discovery['tables']['capability'])\n\t\ttc.listen.map {|x| JSON.parse(x) rescue nil}.compact\n\tend",
"def index\n endpoint(get(services_url).body)\n end",
"def destroy\n authorize! :destroy, @transport\n @transport.destroy\n respond_to do |format|\n format.html { redirect_to transports_url, notice: 'Transport was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @transport.destroy\n respond_to do |format|\n flash[:success] = 'Transport was successfully destroyed.' ;\n format.html { redirect_to transports_url }\n format.json { head :no_content }\n end\n end",
"def update\n respond_to do |format|\n if @cabinet_transport.update(cabinet_transport_params)\n public_send(params[:transport][:status])\n format.html { redirect_to cabinet_transports_path, notice: I18n.t('updated') }\n else\n format.html { render :edit }\n format.json { render json: @cabinet_transport.errors, status: :unprocessable_entity }\n end\n end\n end",
"def get_client_tflows(id)\n conn = @client.get do |req|\n req.url \"/api/v2/client/#{id}/tflows\"\n req.headers[\"Authorization\"] = @token\n end\n conn.body\n end",
"def get_transactions(service)\n\t\treturn @transport.get_path(\"transactions\",service)\n\tend",
"def get_all_tournaments\n\t\ttc = new_sub(@discovery['tournaments'])\n\t\ttc.poll[:messages].map {|x| JSON.parse(x.content) rescue nil}.compact\n\tend",
"def index\n @peticion_servicio_tis = Peticion::ServicioTi.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @peticion_servicio_tis }\n end\n end",
"def transport\n @transport ||= definition.transport_class.new(ui, transport_options)\n end",
"def index\n @days = @trip.days.order(trip_day: :asc)\n render json: @days, include: [:activities]\n end",
"def booking_transportation_codes_get_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: BookingTablesApi.booking_transportation_codes_get ...'\n end\n # resource path\n local_var_path = '/booking-transportation-codes'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'BookingtablesResponse' \n\n # auth_names\n auth_names = opts[:auth_names] || ['auth']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: BookingTablesApi#booking_transportation_codes_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n @transport_lines = TransportLine.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @transport_lines }\n end\n end",
"def show\n @cabinet = Cabinet.find(params[:id])\n \n respond_to do |format|\n format.html do \n @contacts = @cabinet.contacts\n @implantations = @cabinet.implantations\n @testimonials = @cabinet.testimonials\n end\n format.json { render json: @cabinet }\n end\n end",
"def show\n @fabric = Fabric.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @fabric }\n end\n end",
"def show\n @tripJson = []\n @trip.segments.order(:order).each do |segment|\n locations = []\n segment.locations.order(:order).each do |location|\n locations << {:id => location.id, :lat => location.latitude, :lng => location.longitude }\n end\n @tripJson << {:id => segment.id, :transportation => segment.transportation, :locations => locations}\n end\n end",
"def index\n authorize! :read, Transport\n type = params[:type]\n if type.present?\n @category = type == 'private' ? \"Car Riders\" : type == 'shuttle' ? \"Shuttle Cars\" : \"???\"\n end\n @transports = type ? Transport.where('lower(category) = ?', type.downcase) : Transport.all \n if params[:term] =~ /\\A\\d{10}\\Z/ # 10 digits\n @transports = @transports.joins(:smart_cards).where(smart_cards: {code: params[:term]})\n elsif params[:term]\n @transports = @transports.where('name LIKE ?', \"%#{params[:term]}%\")\n end \n @transports = @transports.order(:name).paginate(page: params[:page], per_page: 30) \n end",
"def groupByTransport\n outhash = Hash.new\n @data.each do |country, bridges|\n transporthash = Hash.new\n bridges.each do |ip, measurements|\n transport = measurements[0][\"transport_name\"]\n bridgehash = Hash.new\n bridgehash[ip] = measurements\n\n transporthash[transport] ? transporthash[transport].push(bridgehash) : transporthash[transport] = [bridgehash]\n end\n\n outhash[country] = transporthash\n end\n\n return JSON.pretty_generate(outhash)\n end",
"def champs\n conn = Faraday.new(url, request: {open_timeout: 5, timeout: 5}) do |c|\n c.response :json, :content_type => /\\bjson$/\n c.use Faraday::Response::Logger # log request & response to STDOUT\n c.adapter Faraday.default_adapter\n end\n response = conn.get url\n #@hash = response.body['data']\n response.body['data']\n end",
"def index\n @department = Department.find(params[:department_id])\n @towns = @department.towns\n respond_to do |format|\n format.json { render json: @towns, status: :ok }\n end\n end",
"def set_transportabschnitt\n @transportabschnitt = Transportabschnitt.find(params[:id])\n @transport = @transportabschnitt.transport\n end",
"def get_current_tenant \n get(\"/tenants.json/current\")\nend",
"def get_telephony_providers_edges_trunks_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: TelephonyProvidersEdgeApi.get_telephony_providers_edges_trunks ...\"\n end\n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n \n if opts[:'trunk_type'] && !['EXTERNAL', 'PHONE', 'EDGE'].include?(opts[:'trunk_type'])\n fail ArgumentError, 'invalid value for \"trunk_type\", must be one of EXTERNAL, PHONE, EDGE'\n end\n \n \n \n \n # resource path\n local_var_path = \"/api/v2/telephony/providers/edges/trunks\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'pageNumber'] = opts[:'page_number'] if opts[:'page_number']\n query_params[:'pageSize'] = opts[:'page_size'] if opts[:'page_size']\n query_params[:'sortBy'] = opts[:'sort_by'] if opts[:'sort_by']\n query_params[:'sortOrder'] = opts[:'sort_order'] if opts[:'sort_order']\n query_params[:'edge.id'] = opts[:'edge_id'] if opts[:'edge_id']\n query_params[:'trunkBase.id'] = opts[:'trunk_base_id'] if opts[:'trunk_base_id']\n query_params[:'trunkType'] = opts[:'trunk_type'] if opts[:'trunk_type']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n auth_names = ['PureCloud OAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'TrunkEntityListing')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: TelephonyProvidersEdgeApi#get_telephony_providers_edges_trunks\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def public_transport_options_url\n url(:public_transport_options)\n end",
"def http\n HTTP .headers(accept: \"application/json\")\n # .via(\"127.0.0.1\", 8888)\n end",
"def index\n @transfers = Transfer.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @transfers }\n end\n end",
"def tbu_list\n @client.make_request :get, templates_path('tbu')\n end",
"def get_travellers\n if current_user != nil\n @trip = Trip.find(params[:id])\n render json: @trip.trip_json\n else\n render json: session[:trip].trip_json\n end\n\n end",
"def arrivals\n require 'cobravsmongoose'\n require 'open-uri'\n \n begin\n response = open(\"http://lapi.transitchicago.com/api/1.0/ttarrivals.aspx?key=04dec4048adc48b580220bb154ea0014&mapid=\" + self.cta_id.to_s).read\n arrays_of_hashes = CobraVsMongoose.xml_to_hash(response)\n \n return [arrays_of_hashes['ctatt']['eta']] if arrays_of_hashes['ctatt']['eta'][0].nil?\n \n arrays_of_hashes['ctatt']['eta']\n rescue\n []\n end\n end",
"def create_transports\n @transport = Transport.new(strong_params_transports)\n @transport.value = calculate_transport_emissions\n @transport.user = @user\n @transport.save\n end",
"def list_tenants_for_circles(args = {}) \n get(\"/tenants.json/circles\", args)\nend",
"def list_endpoints\n render json: @endpoints, status: 200\n end",
"def endpoints_list\n get \"endpoints\"\n end",
"def get_transport_guides\n origin= params[:origin]\n destiny=params[:destiny]\n if origin=='' || destiny==''\n @transport_guides=TransportGuide.where(id: 0);\n else\n @@origin=origin\n @@destiny=destiny\n @transport_guides=TransportGuide.where(origin_city_id: origin, destination_city_id: destiny, transport_guide_state_id: 1)\n @@transport_guides=@transport_guides\n end\n respond_to do |format|\n format.js\n end\n end",
"def get_listen_now_situations\n url = 'listennow/situations'\n options = {query: {'alt': 'json', 'tier': 'aa', 'hl': 'en_US'}}\n\n body = {'requestSignals': {'timeZoneOffsetSecs': Time.now.gmt_offset}}.to_json\n\n options[:body] = body\n make_post_request(url, options)['situations']\n end",
"def services\n params = { command: 'account_services' }\n get('/json.php', params)\n end",
"def index\n @traffics = Traffic.find(:all, :order => \"created_at\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @traffics }\n end\n end",
"def get_tenant_by_erp_id(args = {}) \n get(\"/tenants.json/erp-id/#{args[:erpId]}\", args)\nend",
"def index\n @tvcabinets = Tvcabinet.all\n end",
"def trips\n get '/gtfs/trips'\n end",
"def create\n authorize! :manage, Transport\n @transport = Transport.new(transport_params)\n\n respond_to do |format|\n if @transport.save\n format.html { redirect_to @transport, notice: 'Transport was successfully created.' }\n format.json { render :show, status: :created, location: @transport }\n else\n format.html { render :new }\n format.json { render json: @transport.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @transport_batch = TransportBatch.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @transport_batch }\n end\n end",
"def get_client_summary_for_tenant(args = {}) \n get(\"/tenants.json/backoffice/clients/summary/#{args[:tenantId]}\", args)\nend",
"def get_timezones_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: TextMagicApi.get_timezones ...'\n end\n # resource path\n local_var_path = '/api/v2/timezones'\n\n # query parameters\n query_params = {}\n query_params[:'full'] = opts[:'full'] if !opts[:'full'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'GetTimezonesResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: TextMagicApi#get_timezones\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n @tailors = Tailor.all\n respond_to do |format|\n format.html\n format.json { render json: @tailors}\n end\n end",
"def transport\n self.connection.transport\n end",
"def get_thermostat_list\n create_thermostats(HTTParty.get(\"#{NestApi::API_URL}/devices/thermostats\", query: { auth: @token.access_token }))\n end",
"def read_transporte\n @headers = read_headers_from_csv(session[:file_path])\n @headers_with_nil = [\"Nicht vorhanden\"]\n @headers_with_nil.concat(@headers)\n @einstellungen_vorhandene_transporte = {\"Nicht einlesen\" => \"N\", \"Verschmelzen\" => \"J\"}\n end",
"def service_request(params={})\n url = \"#{params[:url]}?type=federation&destination=#{params[:destination]}&domain=#{params[:domain]}\"\n # url = \"#{params[:url]}?type=federation&domain=#{params[:domain]}&destination=#{params[:destination]}&user=#{params[:user]}\"\n\n begin\n response = connection.get url\n rescue Faraday::Error::ConnectionFailed\n raise ConnectionFailed\n rescue Faraday::Error::TimeoutError\n raise Timedout\n end\n\n # Check for error\n if response.body.result == 'error'\n # Error\n raise FederationError, response.body.error_message\n end\n\n response.body.federation_json\n end",
"def list_targets\n # Date is the current date per RFC 2616, section 3.3.1,\n # rfc1123-date format, e.g.: Sun, 22 Apr #2012 08:49:37 GMT.\n date_timestamp = Time.now.httpdate # ruby provides this date format with httpdate method\n signature = build_signature(\"/targets\", nil, \"GET\", date_timestamp)\n raise ArgumentError.new(\"Signature returned nil. Aborting...\") if signature.nil?\n\n authorization_header = \"VWS \" + @accesskey + \":\" + signature\n begin\n RestClient.get(TARGETS_URL, Date: date_timestamp, Authorization: authorization_header)\n rescue => e\n e.response\n end\n end",
"def api_request_url(object)\n api_uri = 'http://timezonedb.wellfounded.ca/api/v1'\n api_request_url = \"#{api_uri}/timezones?\"\n api_request_url << get_filters(object).join('&')\n log \"Making request to #{api_request_url} for timezone.\"\n api_request_url\n end",
"def index\n\n @debtors = Debtor.all\n\n render json: @debtors\n end",
"def index\n trips = Trip.all\n render json: trips\n end",
"def transport(override_region = nil)\n @transports ||= {}\n r = (override_region || region).to_s.upcase\n @transports[r] ||=\n Transport.new(service, r, service_catalog)\n end",
"def index\n @traceroutes = Traceroute.all\n end",
"def index\n @traceroutes = Traceroute.all\n end",
"def new\n @transport_route = TransportRoute.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @transport_route }\n end\n end"
] | [
"0.6007799",
"0.5623272",
"0.5577498",
"0.55764",
"0.5484271",
"0.5446106",
"0.5419598",
"0.5293647",
"0.51976967",
"0.51937914",
"0.51923686",
"0.51599497",
"0.514887",
"0.51383436",
"0.51215374",
"0.5059468",
"0.49962756",
"0.4985491",
"0.48978797",
"0.48749498",
"0.48749498",
"0.48749498",
"0.48496273",
"0.48454967",
"0.48439056",
"0.48398602",
"0.48343682",
"0.48340002",
"0.4826107",
"0.476324",
"0.47215858",
"0.47129568",
"0.4681169",
"0.4674944",
"0.46689996",
"0.46669602",
"0.46438807",
"0.46371576",
"0.46319422",
"0.46250543",
"0.46184623",
"0.46180803",
"0.46025306",
"0.4602332",
"0.45982125",
"0.45947233",
"0.4591625",
"0.45873493",
"0.45783696",
"0.45763105",
"0.45581466",
"0.455691",
"0.45425636",
"0.45398694",
"0.45376888",
"0.45353115",
"0.45306012",
"0.45236722",
"0.4521591",
"0.4520492",
"0.4515541",
"0.4502896",
"0.44999927",
"0.44939604",
"0.44911385",
"0.44850972",
"0.44792208",
"0.44791025",
"0.447747",
"0.44771412",
"0.44729942",
"0.44710281",
"0.44690838",
"0.44686007",
"0.44637394",
"0.44614846",
"0.4457555",
"0.44565064",
"0.4449826",
"0.44464555",
"0.4446254",
"0.44361624",
"0.4428704",
"0.44138435",
"0.44123545",
"0.44111815",
"0.44073594",
"0.44071767",
"0.44003052",
"0.43993935",
"0.43969136",
"0.43940598",
"0.43927923",
"0.4391808",
"0.43902877",
"0.4389079",
"0.43881798",
"0.43880656",
"0.43880656",
"0.43820882"
] | 0.6752842 | 0 |
GET /cabinet/transports/1 GET /cabinet/transports/1.json def show end GET /cabinet/transports/new | def new
@cabinet_transport = current_user.transports.new
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create\n @cabinet_transport = current_user.transports.new(cabinet_transport_params)\n respond_to do |format|\n if @cabinet_transport.save\n public_send(params[:transport][:status])\n format.html { redirect_to cabinet_transports_path, notice: I18n.t('created') }\n else\n format.html { render :new }\n format.json { render json: @cabinet_transport.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @transport_route = TransportRoute.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @transport_route }\n end\n end",
"def new\n @transporter = Transporter.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @transporter }\n end\n end",
"def new\n @transport = Transport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @transport }\n end\n end",
"def new\n @transport = Transport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @transport }\n end\n end",
"def new\n @transport = Transport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @transport }\n end\n end",
"def newTransport\n\n end",
"def new\n @cabinet = Cabinet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @cabinet }\n end\n end",
"def new\n @fabric = Fabric.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fabric }\n end\n end",
"def create\n authorize! :manage, Transport\n @transport = Transport.new(transport_params)\n\n respond_to do |format|\n if @transport.save\n format.html { redirect_to @transport, notice: 'Transport was successfully created.' }\n format.json { render :show, status: :created, location: @transport }\n else\n format.html { render :new }\n format.json { render json: @transport.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @transport_subsidy = TransportSubsidy.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @transport_subsidy }\n end\n end",
"def new\n @trips_connect = TripsConnect.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trips_connect }\n end\n end",
"def create\n @admin_public_transport = City.find(session[:current_city_id]).utility.public_transports.new(admin_public_transport_params)\n\n respond_to do |format|\n if @admin_public_transport.save\n format.html { redirect_to session['previous_url'] || admin_public_transports_url, notice: 'Mezzi pubblici è stato creato con successo.' }\n format.json { render :show, status: :created, location: @admin_public_transport }\n else\n format.html { render :new }\n format.json { render json: @admin_public_transport.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @transport_batch = TransportBatch.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @transport_batch }\n end\n end",
"def create\n @transport = Transport.new(params[:transport])\n\n respond_to do |format|\n if @transport.save\n format.html { redirect_to(@transport, :notice => 'Transport was successfully created.') }\n format.xml { render :xml => @transport, :status => :created, :location => @transport }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @transport.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n raise RuntimeError, \"bad transport type\" unless Transport::Types.include?(params[:transport][:transport])\n @transport = Transport.new(params[:transport].merge( :player => @player ) )\n\n respond_to do |format|\n if @transport.save\n flash[:notice] = 'Transport was successfully created.'\n # url_for(:action => :edit, :player_id => @player.id, :id => @transport.id)\n format.html { redirect_to( player_transport_path(@player, @transport ) ) }\n format.xml { render :xml => @transport, :status => :created, :location => @transport }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @transport.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @transport = Transport.new(params[:transport])\n\n respond_to do |format|\n if @transport.save\n flash[:notice] = 'Transport was successfully created.'\n format.html { redirect_to(@transport) }\n format.xml { render :xml => @transport, :status => :created, :location => @transport }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @transport.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_cabinet_transport\n @cabinet_transport = Transport.find(params[:id])\n end",
"def new\n @traffic = Traffic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @traffic }\n end\n end",
"def new\n @tier = Tier.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @tier }\n end\n end",
"def new\n @host_tpl = HostTpl.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @host_tpl }\n end\n end",
"def new\n @transport_line = TransportLine.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @transport_line }\n end\n end",
"def create\n @tvcabinet = Tvcabinet.new(tvcabinet_params)\n\n respond_to do |format|\n if @tvcabinet.save\n format.html { redirect_to @tvcabinet, notice: 'Tvcabinet was successfully created.' }\n format.json { render :show, status: :created, location: @tvcabinet }\n else\n format.html { render :new }\n format.json { render json: @tvcabinet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @travel_type = TravelType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @travel_type }\n end\n end",
"def new\n @fortune_teller = FortuneTeller.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fortune_teller }\n end\n end",
"def create\n @transporter = Transporter.new(params[:transporter])\n\n respond_to do |format|\n if @transporter.save\n format.html { redirect_to @transporter, notice: 'Transporter was successfully created.' }\n format.json { render json: @transporter, status: :created, location: @transporter }\n else\n format.html { render action: \"new\" }\n format.json { render json: @transporter.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @transport_allowance = TransportAllowance.new(transport_allowance_params)\n\n respond_to do |format|\n if @transport_allowance.save\n format.html { redirect_to transport_allowances_path, notice: 'Transport allowance was successfully created.' }\n format.json { render :show, status: :created, location: @transport_allowance }\n else\n format.html { render :new }\n format.json { render json: transport_allowances_path.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @tipo_tel = TipoTel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_tel }\n end\n end",
"def create\n @transport_hour = TransportHour.new(transport_hour_params)\n\n respond_to do |format|\n if @transport_hour.save\n format.html { redirect_to @transport_hour, notice: 'Transport hour was successfully created.' }\n format.json { render :show, status: :created, location: @transport_hour }\n else\n format.html { render :new }\n format.json { render json: @transport_hour.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n ## Intitializing the temple object\n @temple = Temple.new\n\n if params[:trust_id]\n @trust = Trust.find_by_id(params[:trust_id])\n @temple.trust = @trust\n end\n\n respond_to do |format|\n format.html { get_collections and render :index }\n format.json { render json: @temple }\n format.js {}\n end\n end",
"def create\n @transport_route = TransportRoute.new(params[:transport_route])\n\n respond_to do |format|\n if @transport_route.save\n format.html { redirect_to @transport_route, notice: 'Transport route was successfully created.' }\n format.json { render json: @transport_route, status: :created, location: @transport_route }\n else\n format.html { render action: \"new\" }\n format.json { render json: @transport_route.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @logtransfer = Logtransfer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @logtransfer }\n end\n end",
"def new\n @servicetype = Servicetype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @servicetype }\n end\n end",
"def new\n @servicetype = Servicetype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @servicetype }\n end\n end",
"def new\n @therapist = Therapist.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @therapist }\n end\n end",
"def new\n @zoneamento = Zoneamento.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @zoneamento }\n end\n end",
"def new\n @trtype = Trtype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trtype }\n end\n end",
"def new\n @st_transport_data = StTransportData.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @st_transport_data }\n end\n end",
"def new\n @torso = Torso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @torso }\n end\n end",
"def new\n @peticion_servicio_ti = Peticion::ServicioTi.new\n load_data\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @peticion_servicio_ti }\n end\n end",
"def new\n @item = Item.new\n @transports = Transport.find(:all,:conditions => \"effectiveLoadTime IS NULL and efectiveUnloadTime IS NULL \")\n #@transports = Transport.find(:all)\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item }\n end\n end",
"def new\n @telefononegocio = Telefononegocio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @telefononegocio }\n end\n end",
"def new\n @trip = Trip.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trip }\n end\n end",
"def new\n @trip = Trip.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trip }\n end\n end",
"def new\n @flight = Flight.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @flight }\n end\n end",
"def new\n @trenton = Trenton.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trenton }\n end\n end",
"def new\n @tetramod = Tetramod.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tetramod }\n end\n end",
"def new\n @origin = OriginAddr.new\n \n drop_breadcrumb('新增')\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @origin }\n end\n end",
"def new\n @pc_transport_data = PcTransportData.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pc_transport_data }\n end\n end",
"def new\n @costtype = Costtype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @costtype }\n end\n end",
"def new\n @traffic = Traffic.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @traffic }\n end\n end",
"def create\n @fabric = Fabric.new(params[:fabric])\n\n respond_to do |format|\n if @fabric.save\n format.html { redirect_to @fabric, notice: 'Fabric was successfully created.' }\n format.json { render json: @fabric, status: :created, location: @fabric }\n else\n format.html { render action: \"new\" }\n format.json { render json: @fabric.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @t = T.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @t }\n end\n end",
"def create\n @transportation = Transportation.new(transportation_params)\n\n respond_to do |format|\n if @transportation.save\n format.html { redirect_to transportations_url, notice: 'Transportation was successfully created.' }\n # format.json { render :show, status: :created, location: @transportation }\n else\n format.html { render :new }\n format.json { render json: @transportation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @plantype = Plantype.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @plantype }\n end\n end",
"def new\n @tecnico = Tecnico.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tecnico }\n end\n end",
"def new\n @travel_claims_transport_group = TravelClaimsTransportGroup.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @travel_claims_transport_group }\n end\n end",
"def new\n @territorio = Territorio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @territorio }\n end\n end",
"def new\n @breadcrumb = 'create'\n @tariff_type = TariffType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tariff_type }\n end\n end",
"def new\n @tattoo = Tattoo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tattoo }\n end\n end",
"def new\n @tecnico = Tecnico.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @tecnico }\n end\n end",
"def new\n @settlement = Settlement.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @settlement }\n end\n end",
"def create\n begin\n cabinet = Cabinet.new(params[:cabinet])\n if cabinet.save\n @product_cabinet.cabinet = cabinet\n end\n rescue\n # probably didn't have a form that can provide a new Cabinet\n end\n @called_from = params[:called_from] || \"product\"\n respond_to do |format|\n if @product_cabinet.save\n format.html { redirect_to([:admin, @product_cabinet], notice: 'Product cabinet was successfully created.') }\n format.xml { render xml: @product_cabinet, status: :created, location: @product_cabinet }\n format.js \n website.add_log(user: current_user, action: \"Added cabinet #{@product_cabinet.cabinet.name} to #{@product_cabinet.product.name}\")\n else\n format.html { render action: \"new\" }\n format.xml { render xml: @product_cabinet.errors, status: :unprocessable_entity }\n format.js { render template: \"admin/product_cabinets/create_error\" }\n end\n end\n end",
"def create_transports\n @transport = Transport.new(strong_params_transports)\n @transport.value = calculate_transport_emissions\n @transport.user = @user\n @transport.save\n end",
"def new\n @bp_transport_to_converter_data = BpTransportToConverterData.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @bp_transport_to_converter_data }\n end\n end",
"def create\n p \"Printing \"\n\n @transport = Transport.new(transport_params)\n p \"Printing #{@transport}\"\n\n respond_to do |format|\n if @transport.save\n flash[:success] = 'Transport was successfully created.';\n format.html { redirect_to @transport}\n format.json { render :show, status: :created, location: @transport }\n else\n format.html { render :new }\n format.json { render json: @transport.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @trucking = Trucking.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trucking }\n end\n end",
"def new\n @mt_distribution_transport_data = MtDistributionTransportData.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @mt_distribution_transport_data }\n end\n end",
"def new\n @transport = Transport.find(params[:transport_id].to_i) if params[:transport_id]\n throw ArgumentError.new(\"Must give an transport id which exists}\") unless @transport\n if params[:beobachtung_id]\n @beobachtung_id = params[:beobachtung_id].to_i if params[:beobachtung_id]\n @beobachtung = Beobachtung.find(@beobachtung_id)\n end\n @transportabschnitt = Transportabschnitt.new\n @transportabschnitt.route = Route.find_by(name: \"Unbekannt\")\n # Wenn Abschnitt oder Umschlag davor oder danach schon existiert, \n # dann nimm daher die entsprechenden Anfangs- und Enddaten\n if params[:abschnitt_davor]\n abschnitt_davor = Transportabschnitt.find(params[:abschnitt_davor].to_i)\n @transportabschnitt.start_datum = abschnitt_davor.end_datum\n @transportabschnitt.start_ort = abschnitt_davor.end_ort\n end\n if params[:abschnitt_danach]\n abschnitt_danach = Transportabschnitt.find(params[:abschnitt_danach].to_i)\n @transportabschnitt.end_datum = abschnitt_danach.start_datum\n @transportabschnitt.end_ort = abschnitt_danach.start_ort\n end\n if params[:umschlag_davor]\n umschlag = Umschlag.find(params[:umschlag_davor].to_i)\n @transportabschnitt.start_datum = umschlag.end_datum\n @transportabschnitt.start_ort = umschlag.ort\n end\n if params[:umschlag_danach]\n umschlag = Umschlag.find(params[:umschlag_danach].to_i)\n @transportabschnitt.end_datum = umschlag.start_datum\n @transportabschnitt.end_ort = umschlag.ort\n end \n @redirect_params = new_transportabschnitt_path(transport_id: @transport.id) \n \n respond_to do |format|\n format.html { render 'new'}\n format.js { render 'new' }\n end\n end",
"def new\n @tupian = Tupian.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tupian }\n end\n end",
"def new\n @frozen_tunnel_io = FrozenTunnelIo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @frozen_tunnel_io }\n end\n end",
"def new\n @tiezi = Tiezi.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tiezi }\n end\n end",
"def new\n @fleet = Fleet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fleet }\n end\n end",
"def new\n @translantion = Translantion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @translantion }\n end\n end",
"def new\n @trlocalidad = Trlocalidad.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @trlocalidad }\n end\n end",
"def create\n @transportation = Transportation.new(transportation_params)\n\n respond_to do |format|\n if @transportation.save\n format.html { redirect_to @transportation, notice: \"Transportation was successfully created.\" }\n format.json { render :show, status: :created, location: @transportation }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @transportation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n # @tenant = Tenant.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @tenant }\n end\n end",
"def new\n @fleet = Fleet.find params[:fleet_id]\n @vehicle = @fleet.vehicles.find params[:vehicle_id]\n @tire = @vehicle.tires.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tire }\n end\n end",
"def new\n @breadcrumb = 'create'\n @inventory_transfer = InventoryTransfer.new\n @stores = stores_dropdown\n @products = products_dropdown\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @inventory_transfer }\n end\n end",
"def new\n @tema = Tema.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tema }\n end\n end",
"def new\n @fortune = Fortune.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @fortune }\n end\n end",
"def new\n @hostela = Hostela.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @hostela }\n end\n end",
"def new\n @zutat = Zutat.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @zutat }\n end\n end",
"def new\n @tasktype = Tasktype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tasktype }\n end\n end",
"def new\n @telefone = Telefone.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @telefone }\n end\n end",
"def new\n @teleoperation = Teleoperation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @teleoperation }\n end\n end",
"def new\n @backend_planet = Backend::Planet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @backend_planet }\n end\n end",
"def new\n @etape = Etape.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @etape }\n end\n end",
"def create\n @cet = Cet.new(cet_params)\n\n respond_to do |format|\n if @cet.save\n format.html { redirect_to @cet, notice: 'Cet was successfully created.' }\n format.json { render :show, status: :created, location: @cet }\n else\n format.html { render :new }\n format.json { render json: @cet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @etnia = Etnia.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @etnia }\n end\n end",
"def create\n @transportadora = Transportadora.new(transportadora_params)\n\n respond_to do |format|\n if @transportadora.save\n format.html { redirect_to @transportadora, notice: 'Transportadora was successfully created.' }\n format.json { render :show, status: :created, location: @transportadora }\n else\n format.html { render :new }\n format.json { render json: @transportadora.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @betraege = Betraege.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @betraege }\n end\n end",
"def new\n @taf = Taf.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @taf }\n end\n end",
"def new\n @transaccion = Transaccion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @transaccion }\n end\n end",
"def new\n @tramite = Tramite.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tramite }\n end\n end",
"def new\n @tenure = Tenure.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tenure }\n end\n end",
"def new\n @catch = Catch.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @catch }\n end\n end",
"def new\n @coordinador = Coordinador.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @coordinador }\n end\n end",
"def new\n @tower = Tower.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @tower }\n end\n end",
"def create\n @etatcivil = Etatcivil.new(etatcivil_params)\n\n respond_to do |format|\n if @etatcivil.save\n format.html { redirect_to @etatcivil, notice: 'Etatcivil was successfully created.' }\n format.json { render :show, status: :created, location: @etatcivil }\n else\n format.html { render :new }\n format.json { render json: @etatcivil.errors, status: :unprocessable_entity }\n end\n end\n end"
] | [
"0.7202626",
"0.6888484",
"0.6885551",
"0.66751355",
"0.66751355",
"0.66751355",
"0.66585106",
"0.6653309",
"0.65700626",
"0.65159816",
"0.6502627",
"0.6392964",
"0.6349603",
"0.6330216",
"0.63087165",
"0.62992245",
"0.6293414",
"0.6263963",
"0.62212664",
"0.62099075",
"0.62069553",
"0.62045723",
"0.6192791",
"0.6134564",
"0.61336344",
"0.61211956",
"0.6097312",
"0.60896134",
"0.6082497",
"0.6076174",
"0.6074138",
"0.60330474",
"0.6006366",
"0.60018325",
"0.59945035",
"0.59911096",
"0.5987128",
"0.59828675",
"0.59802717",
"0.59763575",
"0.59744906",
"0.59689474",
"0.5961977",
"0.5961977",
"0.5942085",
"0.59232306",
"0.5923096",
"0.59135914",
"0.5912579",
"0.59082526",
"0.59048504",
"0.5903138",
"0.59022635",
"0.5900904",
"0.5887654",
"0.58874786",
"0.5887176",
"0.5885425",
"0.58825725",
"0.5876605",
"0.5870777",
"0.5868237",
"0.58632445",
"0.58580893",
"0.5856678",
"0.58466834",
"0.58427995",
"0.5831468",
"0.5825394",
"0.58223915",
"0.58207786",
"0.58204687",
"0.5814498",
"0.58087665",
"0.5806577",
"0.5801174",
"0.5795259",
"0.57911515",
"0.5790093",
"0.5789257",
"0.57794094",
"0.57755136",
"0.5774503",
"0.5773443",
"0.57695585",
"0.57645524",
"0.5755349",
"0.57547367",
"0.5748245",
"0.5746667",
"0.5745996",
"0.5741409",
"0.5740522",
"0.57375336",
"0.5736956",
"0.5726135",
"0.5724932",
"0.57239616",
"0.5723689",
"0.571909"
] | 0.80675906 | 0 |
POST /cabinet/transports POST /cabinet/transports.json | def create
@cabinet_transport = current_user.transports.new(cabinet_transport_params)
respond_to do |format|
if @cabinet_transport.save
public_send(params[:transport][:status])
format.html { redirect_to cabinet_transports_path, notice: I18n.t('created') }
else
format.html { render :new }
format.json { render json: @cabinet_transport.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @cabinet_transport = current_user.transports.new\n end",
"def create_transports\n @transport = Transport.new(strong_params_transports)\n @transport.value = calculate_transport_emissions\n @transport.user = @user\n @transport.save\n end",
"def index\n @cabinet_transports = Transport.eager_load(:map_layer)\n end",
"def newTransport\n\n end",
"def transports(opts=nil)\n @transports = cli.parent.application.transports\n @transports.load_all\n return \"there are no transports.\" unless @transports.size > 0\n response = catch(:quit) do\n transport = prompt_trans\n begin\n puts hr\n puts transport.inspect\n puts hr\n command_names = transport.interface.commands.map{|x| x.name } << :quit\n list = command_names.map{|x| %{[#{x}]}}\n puts \"enter <name> = <value>\"\n puts \"or type the beginning of\"<<(list.size > 1 ? ' one of ' : ' ') <<\n en{np(:the,'command',list.size,:say_count => false)}.say\n puts en{list(list)}.or\n puts hr\n print \": \"\n entered = gets.chomp\n cmd = prompt_enum(command_names.map{|_|_.to_s} << \"\", entered)\n if (cmd)\n case cmd\n when \"\": next\n when \"quit\": throw :quit, \"goodbye, thank you\"\n when String:\n command = transport.interface.command[cmd.to_sym]\n begin\n resp = transport.send(command.method) # we trust that the above only allowed thru publicly accessible cmd names\n puts resp.to_s\n rescue Hipe::SocialSync::TransportRuntimeError => e\n puts e.message\n next\n end\n else raise \"huh?\"\n end\n else\n if (/^[a-z_]+$/i =~ entered)\n puts \"unrecognized or ambiguous command #{entered.inspect}\"\n next\n elsif( tree = parse_assignment(entered) )\n unless(accessor = transport.class.attrs[tree.name])\n puts %|not a writable attribute: #{tree.name.inspect}|\n next\n end\n begin\n transport.send %{#{accessor.name}=}, tree.value\n rescue ArgumentError => e\n puts e.message << \" for #{accessor.name}\"\n next\n end\n next\n else\n puts \"poorly formed request: #{entered.inspect}\"\n next\n end\n end\n end while true\n end\n end",
"def cabinet_transport_params\n permitted = Transport.globalize_attribute_names + [\n :gis_type_name,\n :status,\n :map_layer_id,\n :transport_type_id,\n geo_json_attributes: %i[id geo_type position]\n ]\n params.require(:transport).permit(permitted)\n end",
"def set_cabinet_transport\n @cabinet_transport = Transport.find(params[:id])\n end",
"def create\n @admin_public_transport = City.find(session[:current_city_id]).utility.public_transports.new(admin_public_transport_params)\n\n respond_to do |format|\n if @admin_public_transport.save\n format.html { redirect_to session['previous_url'] || admin_public_transports_url, notice: 'Mezzi pubblici è stato creato con successo.' }\n format.json { render :show, status: :created, location: @admin_public_transport }\n else\n format.html { render :new }\n format.json { render json: @admin_public_transport.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n authorize! :manage, Transport\n @transport = Transport.new(transport_params)\n\n respond_to do |format|\n if @transport.save\n format.html { redirect_to @transport, notice: 'Transport was successfully created.' }\n format.json { render :show, status: :created, location: @transport }\n else\n format.html { render :new }\n format.json { render json: @transport.errors, status: :unprocessable_entity }\n end\n end\n end",
"def find_transports(level, format, names)\n transport_names = Array(names)\n # rubocop:disable LineLength\n #transports = @transports.select { |t| (t.up_to_level? level) && (t.format == format) }\n transports = @transports\n # rubocop:enable LineLength\n return transports if Array(names).empty?\n\n transports.select { |t| transport_names.include?(t.name) }\n end",
"def create_transport_zone_with_http_info(transport_zone, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ManagementPlaneApiNetworkTransportTransportZonesApi.create_transport_zone ...'\n end\n # verify the required parameter 'transport_zone' is set\n if @api_client.config.client_side_validation && transport_zone.nil?\n fail ArgumentError, \"Missing the required parameter 'transport_zone' when calling ManagementPlaneApiNetworkTransportTransportZonesApi.create_transport_zone\"\n end\n # resource path\n local_var_path = '/transport-zones'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(transport_zone)\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'TransportZone')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ManagementPlaneApiNetworkTransportTransportZonesApi#create_transport_zone\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def destroy\n @cabinet_transport.destroy\n respond_to do |format|\n format.html { redirect_to cabinet_transports_path, notice: I18n.t('deleted') }\n format.json { head :no_content }\n end\n end",
"def post_as_json(data)\n uri = URI.parse(LISTENER)\n http = Net::HTTP.new(uri.host, uri.port)\n http.read_timeout = 0.5\n begin\n request = Net::HTTP::Post.new(uri.request_uri, {'Content-Type' => 'application/json'})\n request.body = data.to_json\n http.request(request){|res| puts \"Post status: #{res.body}\" }\n rescue StandardError => e\n puts \"Failed sending data: #{e.message}\"\n end\nend",
"def create\n @transport_hour = TransportHour.new(transport_hour_params)\n\n respond_to do |format|\n if @transport_hour.save\n format.html { redirect_to @transport_hour, notice: 'Transport hour was successfully created.' }\n format.json { render :show, status: :created, location: @transport_hour }\n else\n format.html { render :new }\n format.json { render json: @transport_hour.errors, status: :unprocessable_entity }\n end\n end\n end",
"def transport_params\n params.permit(:name, :uid, :transport_type)\n end",
"def create\n @transport_allowance = TransportAllowance.new(transport_allowance_params)\n\n respond_to do |format|\n if @transport_allowance.save\n format.html { redirect_to transport_allowances_path, notice: 'Transport allowance was successfully created.' }\n format.json { render :show, status: :created, location: @transport_allowance }\n else\n format.html { render :new }\n format.json { render json: transport_allowances_path.errors, status: :unprocessable_entity }\n end\n end\n end",
"def transport; end",
"def transport; end",
"def transport; end",
"def update\n respond_to do |format|\n if @cabinet_transport.update(cabinet_transport_params)\n public_send(params[:transport][:status])\n format.html { redirect_to cabinet_transports_path, notice: I18n.t('updated') }\n else\n format.html { render :edit }\n format.json { render json: @cabinet_transport.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @transport_setup = TransportSetup.new(transport_setup_params)\n authorize User\n respond_to do |format|\n if @transport_setup.save\n format.html { redirect_to @transport_setup, notice: 'Transport setup was successfully created.' }\n format.json { render :show, status: :created, location: @transport_setup }\n else\n format.html { render :new }\n format.json { render json: @transport_setup.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tvcabinet = Tvcabinet.new(tvcabinet_params)\n\n respond_to do |format|\n if @tvcabinet.save\n format.html { redirect_to @tvcabinet, notice: 'Tvcabinet was successfully created.' }\n format.json { render :show, status: :created, location: @tvcabinet }\n else\n format.html { render :new }\n format.json { render json: @tvcabinet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @transport = Transport.new(params[:transport])\n\n respond_to do |format|\n if @transport.save\n format.html { redirect_to(@transport, :notice => 'Transport was successfully created.') }\n format.xml { render :xml => @transport, :status => :created, :location => @transport }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @transport.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @transport_route = TransportRoute.new(params[:transport_route])\n\n respond_to do |format|\n if @transport_route.save\n format.html { redirect_to @transport_route, notice: 'Transport route was successfully created.' }\n format.json { render json: @transport_route, status: :created, location: @transport_route }\n else\n format.html { render action: \"new\" }\n format.json { render json: @transport_route.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_tenant_circle(args = {}) \n post(\"/tenantcircles.json/\", args)\nend",
"def transportabschnitt_params\n params.require(:transportabschnitt).permit(:transport, :transport_id, :route_id,\n :start_datum, :end_datum, :firma_id, :verkehrstraeger)\n end",
"def create\n @transporter = Transporter.new(params[:transporter])\n\n respond_to do |format|\n if @transporter.save\n format.html { redirect_to @transporter, notice: 'Transporter was successfully created.' }\n format.json { render json: @transporter, status: :created, location: @transporter }\n else\n format.html { render action: \"new\" }\n format.json { render json: @transporter.errors, status: :unprocessable_entity }\n end\n end\n end",
"def transport_setup_params\n params.require(:transport_setup).permit(:transport_mode, :port_of_loading, :port_of_dischange, :final_destination, :clearing_agent, :container_type)\n end",
"def create\n @transport = Transport.new(params[:transport])\n\n respond_to do |format|\n if @transport.save\n flash[:notice] = 'Transport was successfully created.'\n format.html { redirect_to(@transport) }\n format.xml { render :xml => @transport, :status => :created, :location => @transport }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @transport.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @fabric = Fabric.new(params[:fabric])\n\n respond_to do |format|\n if @fabric.save\n format.html { redirect_to @fabric, notice: 'Fabric was successfully created.' }\n format.json { render json: @fabric, status: :created, location: @fabric }\n else\n format.html { render action: \"new\" }\n format.json { render json: @fabric.errors, status: :unprocessable_entity }\n end\n end\n end",
"def transport_options\n definition.transport_options\n end",
"def write_travels_to_calendar\n @event.write_travels_to_calendar\n render :json => @event.to_json, :status => :ok\n end",
"def create\n raise RuntimeError, \"bad transport type\" unless Transport::Types.include?(params[:transport][:transport])\n @transport = Transport.new(params[:transport].merge( :player => @player ) )\n\n respond_to do |format|\n if @transport.save\n flash[:notice] = 'Transport was successfully created.'\n # url_for(:action => :edit, :player_id => @player.id, :id => @transport.id)\n format.html { redirect_to( player_transport_path(@player, @transport ) ) }\n format.xml { render :xml => @transport, :status => :created, :location => @transport }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @transport.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @transportation = Transportation.new(transportation_params)\n\n respond_to do |format|\n if @transportation.save\n format.html { redirect_to @transportation, notice: \"Transportation was successfully created.\" }\n format.json { render :show, status: :created, location: @transportation }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @transportation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n p \"Printing \"\n\n @transport = Transport.new(transport_params)\n p \"Printing #{@transport}\"\n\n respond_to do |format|\n if @transport.save\n flash[:success] = 'Transport was successfully created.';\n format.html { redirect_to @transport}\n format.json { render :show, status: :created, location: @transport }\n else\n format.html { render :new }\n format.json { render json: @transport.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @transportation = Transportation.new(transportation_params)\n\n respond_to do |format|\n if @transportation.save\n format.html { redirect_to transportations_url, notice: 'Transportation was successfully created.' }\n # format.json { render :show, status: :created, location: @transportation }\n else\n format.html { render :new }\n format.json { render json: @transportation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @transport.destroy\n respond_to do |format|\n flash[:success] = 'Transport was successfully destroyed.' ;\n format.html { redirect_to transports_url }\n format.json { head :no_content }\n end\n end",
"def transport_add(opts={})\n request = transport_prepare_request(COMMAND_ID_CORE_TRANSPORT_ADD, opts)\n\n return false unless request\n\n client.send_request(request)\n\n return true\n end",
"def create\n @transportadora = Transportadora.new(transportadora_params)\n\n respond_to do |format|\n if @transportadora.save\n format.html { redirect_to @transportadora, notice: 'Transportadora was successfully created.' }\n format.json { render :show, status: :created, location: @transportadora }\n else\n format.html { render :new }\n format.json { render json: @transportadora.errors, status: :unprocessable_entity }\n end\n end\n end",
"def test_truth\n assert_kind_of Transport, transports(:first)\n end",
"def transport_params\n params.require(:transport).permit(:name,:bus_id, :from_id, :to_id, :start_date, :end_date, :departure_time, :arrival_time, :recurrence,:cost)\n end",
"def create\n @transport_subsidy = TransportSubsidy.new(params[:transport_subsidy])\n\n respond_to do |format|\n if @transport_subsidy.save\n format.html { redirect_to @transport_subsidy, notice: 'Transport subsidy was successfully created.' }\n format.json { render json: @transport_subsidy, status: :created, location: @transport_subsidy }\n else\n format.html { render action: \"new\" }\n format.json { render json: @transport_subsidy.errors, status: :unprocessable_entity }\n end\n end\n end",
"def list_transport_zones_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ManagementPlaneApiNetworkTransportTransportZonesApi.list_transport_zones ...'\n end\n if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] > 1000\n fail ArgumentError, 'invalid value for \"opts[:\"page_size\"]\" when calling ManagementPlaneApiNetworkTransportTransportZonesApi.list_transport_zones, must be smaller than or equal to 1000.'\n end\n\n if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] < 0\n fail ArgumentError, 'invalid value for \"opts[:\"page_size\"]\" when calling ManagementPlaneApiNetworkTransportTransportZonesApi.list_transport_zones, must be greater than or equal to 0.'\n end\n\n if @api_client.config.client_side_validation && opts[:'transport_type'] && !['OVERLAY', 'VLAN'].include?(opts[:'transport_type'])\n fail ArgumentError, 'invalid value for \"transport_type\", must be one of OVERLAY, VLAN'\n end\n # resource path\n local_var_path = '/transport-zones'\n\n # query parameters\n query_params = {}\n query_params[:'cursor'] = opts[:'cursor'] if !opts[:'cursor'].nil?\n query_params[:'included_fields'] = opts[:'included_fields'] if !opts[:'included_fields'].nil?\n query_params[:'is_default'] = opts[:'is_default'] if !opts[:'is_default'].nil?\n query_params[:'page_size'] = opts[:'page_size'] if !opts[:'page_size'].nil?\n query_params[:'sort_ascending'] = opts[:'sort_ascending'] if !opts[:'sort_ascending'].nil?\n query_params[:'sort_by'] = opts[:'sort_by'] if !opts[:'sort_by'].nil?\n query_params[:'transport_type'] = opts[:'transport_type'] if !opts[:'transport_type'].nil?\n query_params[:'uplink_teaming_policy_name'] = opts[:'uplink_teaming_policy_name'] if !opts[:'uplink_teaming_policy_name'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'TransportZoneListResult')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ManagementPlaneApiNetworkTransportTransportZonesApi#list_transport_zones\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def add_tier\n begin\n with_transaction do\n Tier.create!(\n name: params[:name],\n stage: params[:stage],\n pipeline_id: @pipeline.id\n )\n\n render json: tiers_for_pipeline_view\n end\n rescue Exception => e\n error = \"#{ConfluxErrors::TierCreationFailed} - #{e}\"\n logger.error { error }\n render json: { message: error }, status: 500\n end\n end",
"def transport_change(opts={})\n request = transport_prepare_request(COMMAND_ID_CORE_TRANSPORT_CHANGE, opts)\n\n return false unless request\n\n client.send_request(request)\n\n return true\n end",
"def transportador_params\n params.require(:transportador).permit(:estado, :fecha_cambio_estado, :planificador_cambio_estado, :tipo_identificacion, :numero_identificacion, :primer_nombre, :segundo_nombre, :primer_apellido, :segundo_apellido, :numero_telefonico, :correo_electronico, :direccion, :tipo_vehiculo, :marca_vehiculo, :placa_vehiculo, :id_servicio_actual, :usuario_id)\n end",
"def set_transportabschnitt\n @transportabschnitt = Transportabschnitt.find(params[:id])\n @transport = @transportabschnitt.transport\n end",
"def destroy\n authorize! :destroy, @transport\n @transport.destroy\n respond_to do |format|\n format.html { redirect_to transports_url, notice: 'Transport was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def post_peertransfers_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PeerTransfersApi.post_peertransfers ...'\n end\n # resource path\n local_var_path = '/peertransfers'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'body'])\n\n # return_type\n return_type = opts[:debug_return_type] || 'PeerTransferResponse'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || []\n\n new_options = opts.merge(\n :operation => :\"PeerTransfersApi.post_peertransfers\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PeerTransfersApi#post_peertransfers\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def transport=(_arg0); end",
"def post_create\n response = self.class.post(\"/service/#{$service_id}/version/#{$service_version}/logging/sftp\", \n headers: { \"Fastly-Key\" => $key},\n body: { \"name\" => \"#{$name}\",\n \"address\" => \"#{$address}\",\n \"port\" => \"22\",\n \"format\" => \"#{$log_format}\",\n \"user\" => \"#{$user}\",\n \"secret_key\" => \"#{$secret_key}\",\n \"public_key\" => \"#{$public_key}\" })\n end",
"def transport_hour_params\n params.require(:transport_hour).permit(:transport_id, :hour_id)\n end",
"def addhost(config)\n\n uri = URI.parse(\"#{config[\"addurl\"]}\")\n node = { \"EntityType\" => \"Orion.Nodes\", \"IPAddress\" => \"#{config[\"ipaddr\"]}\",\n \"Caption\"=> \"#{config[\"nodename\"]}\", \"DynamicIP\" => \"False\", \"EngineID\" => \"#{config[\"engineid\"]}\", \n \"Status\" => 1, \"UnManaged\" => \"False\", \"Allow64BitCounters\" => \"True\", \n \"SysObjectID\" => \"\", \"MachineType\" => \"\", \"VendorIcon\" => \"\", \n \"ObjectSubType\" => \"SNMP\", \"SNMPVersion\" => 2, \"Community\" => \"#{config[\"community\"]}\",\n }\n\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Post.new(uri.request_uri, initheader = {'Content-Type' =>'application/json'})\n request.body = node.to_json\n request.basic_auth(\"#{config[\"username\"]}\", \"#{config[\"password\"]}\")\n\n response = http.request(request)\nend",
"def create\n attrs = whitelist(params, :create).merge customer: current_user.becomes(Users::Customer)\n dattrs = attrs.delete(:destinations_attributes)\n\n @travel = Travels::Travel.new(attrs)\n\n dattrs.each_key do |key|\n dattr = dattrs[key]\n iattrs = dattr.delete(:items_attributes)\n\n dest = Travels::Places::Destination.new(dattr)\n\n iattrs.each_key do |key|\n @travel.items.build(iattrs[key]).destination = dest\n end if iattrs\n end\n\n # @travel.customer = current_user.becomes(Users::Customer)\n\n respond_to do |format|\n if @travel.save\n format.html { redirect_to status_travel_path(@travel), notice: \"Gracefully created the travel!\" }\n format.json { render json: @travel, status: :created, location: @travel }\n else\n format.html { redirect_to new_travel_path, alert: \"Failed to create the travel! Errors: #{@travel.errors.full_messages}\" }\n format.json { render json: @travel.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_tenant_to_specified_shard(args = {}) \n post(\"/tenants.json/shard/#{args[:shardId]}\", args)\nend",
"def transmit(path, data)\n http_post (host + path),\n {'Content-Type' => 'application/json'},\n [data.to_json]\n end",
"def upload_facts(host_json, host = '')\n curl = setup_curl(\"#{@foreman_url}/api/hosts/facts\")\n curl.headers['Accept'] = 'application/json,version=2'\n curl.headers['Content-Type'] = 'application/json'\n curl.http_post(host_json)\n result = JSON.parse(curl.body_str)\n raise result['message'] if result['message'] =~ /^ERF51/\n result\n rescue => e\n warn \"Could not push #{host}: #{e}\"\n false\n end",
"def create\n @traceroute = Traceroute.new(traceroute_params)\n\n respond_to do |format|\n if @traceroute.save\n flash[:notice] = 'traceroute was successfully created.'\n format.html { redirect_to @traceroute, notice: 'Traceroute was successfully created.' }\n format.json { render action: 'show', status: :created, location: @traceroute }\n else\n format.html { render action: 'new' }\n format.json { render json: @traceroute.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tenant = keystone.create_tenant({:name=>params[:name],:description=>params[:description],:enabled=>params[:enabled]})\n respond_to do |format|\n \n format.html { redirect_to @tenant, :notice => 'Tenant was successfully created.' }\n format.json { render :json => @tenant, :status => :created, :location => @tenant }\n \n end\n end",
"def create\n response = post_request(URI.parse(\"http://\"+Storage.find(cookies[:donabe_ip]).data+\"/\"+Storage.find(cookies[:current_tenant]).data+\"/containers.json\"), params[:container].to_json, Storage.find(cookies[:current_token]).data)\n json_respond response.body \n\n end",
"def create\n response = post_request(URI.parse(\"http://\"+(sesh :donabe_ip)+\"/\"+(sesh :current_tenant)+\"/containers.json\"), params[:container].to_json, (sesh :current_token))\n json_respond response.body \n\n end",
"def groupByTransport\n outhash = Hash.new\n @data.each do |country, bridges|\n transporthash = Hash.new\n bridges.each do |ip, measurements|\n transport = measurements[0][\"transport_name\"]\n bridgehash = Hash.new\n bridgehash[ip] = measurements\n\n transporthash[transport] ? transporthash[transport].push(bridgehash) : transporthash[transport] = [bridgehash]\n end\n\n outhash[country] = transporthash\n end\n\n return JSON.pretty_generate(outhash)\n end",
"def get_telephony_providers_edges_timezones_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: TelephonyProvidersEdgeApi.get_telephony_providers_edges_timezones ...\"\n end\n \n \n \n \n \n \n \n \n \n \n \n \n \n # resource path\n local_var_path = \"/api/v2/telephony/providers/edges/timezones\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'pageSize'] = opts[:'page_size'] if opts[:'page_size']\n query_params[:'pageNumber'] = opts[:'page_number'] if opts[:'page_number']\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n auth_names = ['PureCloud OAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'TimeZoneEntityListing')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: TelephonyProvidersEdgeApi#get_telephony_providers_edges_timezones\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def create\n @cabinet = Cabinet.new(params[:cabinet])\n \n\n respond_to do |format|\n if @cabinet.save\n current_user.cabinet_id = @cabinet.id\n current_user.save\n format.html { redirect_to @cabinet, notice: 'Cabinet was successfully created.' }\n format.json { render json: @cabinet, status: :created, location: @cabinet }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cabinet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @cabinet_balancer = Balancer.new(create_params)\n\n respond_to do |format|\n if @cabinet_balancer.save\n format.html { redirect_to cabinet_balancers_path, notice: I18n.t('created') }\n format.json { render :show, status: :created, location: @cabinet_balancer }\n else\n format.html { render :new }\n format.json { render json: @cabinet_balancer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def enviar_transaccion(trx,idfactura)\n begin\n logger.debug(\"...Inicio enviar transaccion\")\n info = InfoGrupo.where('id_banco= ?',trx['destino']).first\n url = 'http://integra'+info[:numero].to_s+'.ing.puc.cl/api/pagos/recibir/'+trx[0]['_id'].to_s\n #url = 'http://localhost:3000/api/pagos/recibir/'+trx['_id'].to_s\n request = Typhoeus::Request.new(\n url,\n method: :get,\n params:{\n idfactura: idfactura\n },\n headers: { ContentType: \"application/json\"})\n response = request.run\n logger.debug(\"...Fin enviar transaccion\")\n return {:validado => true, :trx => trx}\n rescue => ex\n Applog.debug(ex.message,'enviar_transaccion')\n return {:validado => false, :trx => trx}\nend\nend",
"def tessen_api_request(data)\n @logger.debug(\"sending data to the tessen call-home service\", {\n :data => data,\n :options => @options\n })\n connection = {}\n connection[:proxy] = @options[:proxy] if @options[:proxy]\n post_options = {:body => Sensu::JSON.dump(data)}\n http = EM::HttpRequest.new(\"https://tessen.sensu.io/v1/data\", connection).post(post_options)\n http.callback do\n @logger.debug(\"tessen call-home service response\", :status => http.response_header.status)\n yield if block_given?\n end\n http.errback do\n @logger.debug(\"tessen call-home service error\", :error => http.error)\n yield if block_given?\n end\n end",
"def create\n @frozen_tunnel_io = FrozenTunnelIo.new(params[:frozen_tunnel_io])\n @frozen_tunnel_io.io_datetime = DateTime.current();\n\n respond_to do |format|\n if @frozen_tunnel_io.save\n @frozen_tunnel_io.order_number = @frozen_tunnel_io.id\n @frozen_tunnel_io.save\n format.html { redirect_to @frozen_tunnel_io, notice: 'El tunel de congelado creado exitosamente.' }\n format.json { render json: @frozen_tunnel_io, status: :created, location: @frozen_tunnel_io }\n else\n format.html { render action: \"new\" }\n format.json { render json: @frozen_tunnel_io.errors, status: :unprocessable_entity }\n end\n end\n end",
"def traceroute_params\n params.require(:traceroute).permit(:server, :stdout, :stderr, :exit_status, :timestamp)\n end",
"def create\n @tarifas_servicio = TarifasServicio.new(tarifas_servicio_params)\n\n respond_to do |format|\n if @tarifas_servicio.save\n format.html { redirect_to tarifas_servicios_url, notice: 'Tarifas servicio Se creó correctamente.' }\n format.json { render :show, status: :created, location: @tarifas_servicio }\n else\n format.html { render :new }\n format.json { render json: @tarifas_servicio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @tb_servicio = TbServicio.new(tb_servicio_params)\n\n respond_to do |format|\n if @tb_servicio.save\n format.html { redirect_to @tb_servicio, notice: 'Tb servicio was successfully created.' }\n format.json { render :show, status: :created, location: @tb_servicio }\n else\n format.html { render :new }\n format.json { render json: @tb_servicio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_transport_timeouts(opts={})\n request = Packet.create_request(COMMAND_ID_CORE_TRANSPORT_SET_TIMEOUTS)\n\n if opts[:session_exp]\n request.add_tlv(TLV_TYPE_TRANS_SESSION_EXP, opts[:session_exp])\n end\n if opts[:comm_timeout]\n request.add_tlv(TLV_TYPE_TRANS_COMM_TIMEOUT, opts[:comm_timeout])\n end\n if opts[:retry_total]\n request.add_tlv(TLV_TYPE_TRANS_RETRY_TOTAL, opts[:retry_total])\n end\n if opts[:retry_wait]\n request.add_tlv(TLV_TYPE_TRANS_RETRY_WAIT, opts[:retry_wait])\n end\n\n response = client.send_request(request)\n\n {\n :session_exp => response.get_tlv_value(TLV_TYPE_TRANS_SESSION_EXP),\n :comm_timeout => response.get_tlv_value(TLV_TYPE_TRANS_COMM_TIMEOUT),\n :retry_total => response.get_tlv_value(TLV_TYPE_TRANS_RETRY_TOTAL),\n :retry_wait => response.get_tlv_value(TLV_TYPE_TRANS_RETRY_WAIT)\n }\n end",
"def transport_params\n params.require(:transport).permit(:category, :name, :status, :active, :notes, :contact_id, :contact_name, :contact_phone, :contact_email,\n {smart_cards_attributes: [:id, :code, :detail, :ref, :_destroy]},\n {passengers_attributes: [:id, :name, :student_id, :family_no, :grade_section_id, :class_name, :active, :_destroy]})\n end",
"def create\n begin\n cabinet = Cabinet.new(params[:cabinet])\n if cabinet.save\n @product_cabinet.cabinet = cabinet\n end\n rescue\n # probably didn't have a form that can provide a new Cabinet\n end\n @called_from = params[:called_from] || \"product\"\n respond_to do |format|\n if @product_cabinet.save\n format.html { redirect_to([:admin, @product_cabinet], notice: 'Product cabinet was successfully created.') }\n format.xml { render xml: @product_cabinet, status: :created, location: @product_cabinet }\n format.js \n website.add_log(user: current_user, action: \"Added cabinet #{@product_cabinet.cabinet.name} to #{@product_cabinet.product.name}\")\n else\n format.html { render action: \"new\" }\n format.xml { render xml: @product_cabinet.errors, status: :unprocessable_entity }\n format.js { render template: \"admin/product_cabinets/create_error\" }\n end\n end\n end",
"def getTransport()\n\t\treturn @transport\n\tend",
"def create(options = {})\n response = request(:post, \"/network_zones.json\", :query => {:pack => options})\n end",
"def create\n @transfer = Transfer.new(transfer_params)\n\n if @transfer.save\n render json: @transfer, status: :created, location: @transfer\n else\n render json: @transfer.errors, status: :unprocessable_entity\n end\n end",
"def add_arrays_to_tenant(args = {}) \n post(\"/tenants.json/#{args[:tenantId]}/arrays\", args)\nend",
"def create\n params[:traceroute].each do |tr|\n Traceroute.create(:server => tr[:server], :local_ip => tr[:local_ip], :stdout => tr[:stdout], :stderr => tr[:stderr], :exit_status => tr[:exit_status], :timestamp => tr[:timestamp])\n end\n\n\n\n #puts \"hello #{params}\"\n #@hello = params\n #@hello.map { |k,v| puts \"#{k} is #{v}\" }\n #traceroute_params.each do |v|\n # traceroute = Traceroute.create(v)\n #end\n\n respond_to do |format|\n format.all { render :nothing => true, :status => 200 }\n end\n #@traceroute = Traceroute.new(params)\n\n #respond_to do |format|\n # if @traceroute.save\n # format.html { redirect_to @traceroute, notice: 'Traceroute was successfully created.' }\n # format.json { render action: 'show', status: :created, location: @traceroute }\n # else\n # format.html { render action: 'new' }\n # format.json { render json: @traceroute.errors, status: :unprocessable_entity }\n # end\n #end\n end",
"def add_user_for_tenant(args = {}) \n post(\"/tenants.json/#{args[:tenantId]}/users\", args)\nend",
"def get_current_transport\n x = transport_list\n x[:transports][0]\n end",
"def create\r\n @fabricante = Fabricante.new(fabricante_params)\r\n\r\n respond_to do |format|\r\n if @fabricante.save\r\n format.html { redirect_to fabricante_path(@fabricante), notice: 'Fabricante criada com sucesso.' }\r\n format.json { render :show, status: :created, location: @fabricante }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @fabricante.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def destroy\n transport = @transportabschnitt.transport\n @transportabschnitt.destroy\n respond_to do |format|\n flash[:success] = \"Transportabschnitt gelöscht.\"\n format.html { redirect_to transport }\n format.json { head :no_content }\n end\n end",
"def transport_send(message)\n case @config[:transport]\n when 'http'\n http_transport(message)\n when 'udp'\n udp_transport(message)\n else\n @logger.debug(\"Failed to flush message due to invalid transport: #{@config[:transport]}\") unless @logger.nil?\n end\n end",
"def create\n @telfornecedor = Telfornecedor.new(telfornecedor_params)\n\n respond_to do |format|\n if @telfornecedor.save\n format.html { redirect_to @telfornecedor, notice: 'Telfornecedor was successfully created.' }\n format.json { render :show, status: :created, location: @telfornecedor }\n else\n format.html { render :new }\n format.json { render json: @telfornecedor.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @guestlist = @event.guestlists.new(guestlist_params)\n @current_host = \"http://\" + request.host.to_s + \":\" + request.port.to_s\n respond_to do |format|\n if @guestlist.save\n format.html { redirect_to event_guestlists_url, notice: 'Guest was successfully created.' }\n format.json { render :show, status: :created, location: @guestlist }\n GuestMailer.with(current_guest: @guestlist, current_event: @event, current_host: @current_host).guestlist_email.deliver_later\n else\n format.html { render :new }\n format.json { render json: @guestlist.errors, status: :unprocessable_entity }\n end\n end\n end",
"def deliver_json(uuid, idents, data)\n self.deliver(uuid, idents, JSON.generate(data))\n end",
"def set_transport\n @transport = Transport.find(params[:id])\n end",
"def set_transport\n @transport = Transport.find(params[:id])\n end",
"def set_transport\n @transport = Transport.find(params[:id])\n end",
"def set_transport_allowance\n @transport_allowance = TransportAllowance.find(params[:id])\n end",
"def create_transport_node_collection_with_http_info(transport_node_collection, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ManagementPlaneApiNetworkTransportTransportNodeCollectionsApi.create_transport_node_collection ...'\n end\n # verify the required parameter 'transport_node_collection' is set\n if @api_client.config.client_side_validation && transport_node_collection.nil?\n fail ArgumentError, \"Missing the required parameter 'transport_node_collection' when calling ManagementPlaneApiNetworkTransportTransportNodeCollectionsApi.create_transport_node_collection\"\n end\n # resource path\n local_var_path = '/transport-node-collections'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(transport_node_collection)\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'TransportNodeCollection')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ManagementPlaneApiNetworkTransportTransportNodeCollectionsApi#create_transport_node_collection\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def create\n @transportabschnitt = Transportabschnitt.new(transportabschnitt_params)\n redirection_path = @transportabschnitt\n if params[:transport_id]\n transport = Transport.find(params[:transport_id].to_i)\n @transportabschnitt.transport = transport\n redirection_path = transport if transport \n end\n if params[:beobachtung_id]\n @beobachtung = Beobachtung.find(params[:beobachtung_id].to_i)\n @beobachtung.transportabschnitt = @transportabschnitt if @beobachtung \n redirection_path = @beobachtung if @beobachtung\n end\n\n # Orte zuordnen (Auswahl über Modalmaske, also id vorhanden, wenn Auswahl getroffen)\n if params[:start_ort_ident] && params[:start_ort_ident].to_i != 0\n @transportabschnitt.start_ort = Ort.find(params[:start_ort_ident].to_i)\n end\n if params[:end_ort_ident] && params[:end_ort_ident].to_i != 0\n @transportabschnitt.end_ort = Ort.find(params[:end_ort_ident].to_i)\n end\n\n respond_to do |format|\n if @transportabschnitt.save\n @beobachtung.save if @beobachtung\n flash[:success] = \"Transportabschnitt angelegt.\"\n format.html { redirect_to redirection_path }\n format.json { render :show, status: :created, location: @transportabschnitt }\n else\n init_ort_and_firma\n firma = @transportabschnitt.firma if @transportabschnitt.firma\n format.html { render :new }\n format.json { render json: @transportabschnitt.errors, status: :unprocessable_entity }\n end\n end\n end",
"def deliver(message)\n Net::HTTP.start(EVENT_BUS_SERVER_URL.host, EVENT_BUS_SERVER_URL.port) do |http|\n request = Net::HTTP::Post.new EVENT_BUS_SERVER_URL\n request.body = message\n request.content_type = \"application/json\"\n request[\"Authorization\"] = authorization\n response = http.request request # Net::HTTPResponse object\n puts response.inspect\n\n # TODO: If the response is not 200 then there needs to be retry logic\n end\nend",
"def eth_accounts\n params = []\n data = {\"jsonrpc\" => \"2.0\", \"method\" => \"eth_accounts\", \"params\" => params, \"id\" => \":1\"}\n @http_client.post(data) do |response|\n NSLog(response.to_s)\n @accounts_result.stringValue = response\n end\nend",
"def post_route(payload)\n with_rescue do\n payload = payload.to_json if payload.is_a?(Hash)\n connection.post do |request|\n request.url routes_path\n request.body = payload\n request.headers['Content-Type'] = 'application/json'\n end\n end\n end",
"def transportation_params\n params.require(:transportation).permit(:name, :hours, :website)\n end",
"def update\n respond_to do |format|\n if @transport.update(transport_params)\n flash[:success] = 'Transport was successfully updated.' ;\n format.html { redirect_to @transport}\n format.json { render :show, status: :ok, location: @transport }\n else\n format.html { render :edit }\n format.json { render json: @transport.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @transport_route = TransportRoute.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @transport_route }\n end\n end",
"def update_transport_zone_with_http_info(zone_id, transport_zone, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: ManagementPlaneApiNetworkTransportTransportZonesApi.update_transport_zone ...'\n end\n # verify the required parameter 'zone_id' is set\n if @api_client.config.client_side_validation && zone_id.nil?\n fail ArgumentError, \"Missing the required parameter 'zone_id' when calling ManagementPlaneApiNetworkTransportTransportZonesApi.update_transport_zone\"\n end\n # verify the required parameter 'transport_zone' is set\n if @api_client.config.client_side_validation && transport_zone.nil?\n fail ArgumentError, \"Missing the required parameter 'transport_zone' when calling ManagementPlaneApiNetworkTransportTransportZonesApi.update_transport_zone\"\n end\n # resource path\n local_var_path = '/transport-zones/{zone-id}'.sub('{' + 'zone-id' + '}', zone_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(transport_zone)\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:PUT, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'TransportZone')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: ManagementPlaneApiNetworkTransportTransportZonesApi#update_transport_zone\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end"
] | [
"0.57502496",
"0.56126213",
"0.5428443",
"0.5370238",
"0.5340381",
"0.5294982",
"0.5267044",
"0.51990455",
"0.5184055",
"0.51214266",
"0.5009426",
"0.4986321",
"0.49860775",
"0.49833617",
"0.4965873",
"0.4890542",
"0.48720932",
"0.48720932",
"0.48720932",
"0.48573115",
"0.4855076",
"0.48483902",
"0.47939467",
"0.47879544",
"0.47668114",
"0.47473598",
"0.4731154",
"0.47310403",
"0.47063264",
"0.464203",
"0.4636158",
"0.46170303",
"0.45855218",
"0.45831633",
"0.45775178",
"0.45590734",
"0.4557603",
"0.45556486",
"0.4536331",
"0.45360062",
"0.45267057",
"0.45248",
"0.45189148",
"0.45175296",
"0.45061636",
"0.44929704",
"0.44910342",
"0.4481214",
"0.4480059",
"0.44774678",
"0.44657978",
"0.443529",
"0.44307125",
"0.44305623",
"0.44219357",
"0.4412491",
"0.44113237",
"0.43975988",
"0.43904302",
"0.43890136",
"0.4380368",
"0.43795058",
"0.43693206",
"0.43526962",
"0.43520224",
"0.435127",
"0.43488047",
"0.43442002",
"0.43436378",
"0.43434212",
"0.43349048",
"0.43338257",
"0.43314418",
"0.432585",
"0.4323301",
"0.43145213",
"0.43113187",
"0.43098247",
"0.430525",
"0.43049625",
"0.4296409",
"0.4288483",
"0.428798",
"0.42852274",
"0.42841357",
"0.42581168",
"0.42486817",
"0.42481807",
"0.42481807",
"0.42481807",
"0.42382938",
"0.4234897",
"0.4230499",
"0.4228946",
"0.42287526",
"0.42169678",
"0.4213201",
"0.42119074",
"0.4200586",
"0.41952488"
] | 0.65239984 | 0 |
PATCH/PUT /cabinet/transports/1 PATCH/PUT /cabinet/transports/1.json | def update
respond_to do |format|
if @cabinet_transport.update(cabinet_transport_params)
public_send(params[:transport][:status])
format.html { redirect_to cabinet_transports_path, notice: I18n.t('updated') }
else
format.html { render :edit }
format.json { render json: @cabinet_transport.errors, status: :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @fabric = Fabric.find(params[:id])\n\n respond_to do |format|\n if @fabric.update_attributes(params[:fabric])\n format.html { redirect_to @fabric, notice: 'Fabric was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @fabric.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @cabinet = Cabinet.find(params[:id])\n\n respond_to do |format|\n if @cabinet.update_attributes(params[:cabinet])\n format.html { redirect_to @cabinet, notice: 'Cabinet was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cabinet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(type, info)\n path, info = type_info(type, :path), force_case(info)\n ida = type == :client ? 'client_id' : 'id'\n raise ArgumentError, \"info must include #{ida}\" unless id = info[ida]\n hdrs = headers\n if info && info['meta'] && (etag = info['meta']['version'])\n hdrs.merge!('if-match' => etag)\n end\n reply = json_parse_reply(@key_style,\n *json_patch(@target, \"#{path}/#{Addressable::URI.encode(id)}\", info, hdrs))\n\n # hide client endpoints that are not quite scim compatible\n type == :client && !reply ? get(type, info['client_id']): reply\n end",
"def update_tenant_circle(args = {}) \n put(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def update\n respond_to do |format|\n if @transport.update(transport_params)\n flash[:success] = 'Transport was successfully updated.' ;\n format.html { redirect_to @transport}\n format.json { render :show, status: :ok, location: @transport }\n else\n format.html { render :edit }\n format.json { render json: @transport.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch\n headers = {\"If-Match\" => @version}\n response = @context.request :patch, \"#{@path}/#{@id}\", @data.to_json, headers\n @version += 1\n response\n # 'X-HTTP-Method-Override' => 'PATCH'\n end",
"def patch!\n request! :patch\n end",
"def update\n @transport_route = TransportRoute.find(params[:id])\n\n respond_to do |format|\n if @transport_route.update_attributes(params[:transport_route])\n format.html { redirect_to @transport_route, notice: 'Transport route was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @transport_route.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @fbt.update(fbt_params)\n format.html { redirect_to @fbt, notice: \"Client was successfully updated.\" }\n format.json { render :show, status: :ok, location: @fbt }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @fbt.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n keystone.update_tenant({:id=>params[:id],:name=>params[:name],:description=>params[:description],:enabled=>params[:enabled]})\n respond_to do |format|\n format.html { redirect_to tenants_path, :notice => 'Tenant was successfully updated.' }\n format.json { head :ok }\n end\n end",
"def update\n @transport = Transport.find(params[:id])\n\n respond_to do |format|\n if @transport.update_attributes(params[:transport])\n format.html { redirect_to(@transport, :notice => 'Transport was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @transport.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tvcabinet.update(tvcabinet_params)\n format.html { redirect_to @tvcabinet, notice: 'Tvcabinet was successfully updated.' }\n format.json { render :show, status: :ok, location: @tvcabinet }\n else\n format.html { render :edit }\n format.json { render json: @tvcabinet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @transport_setup.update(transport_setup_params)\n format.html { redirect_to @transport_setup, notice: 'Transport setup was successfully updated.' }\n format.json { render :show, status: :ok, location: @transport_setup }\n else\n format.html { render :edit }\n format.json { render json: @transport_setup.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_cabinet_transport\n @cabinet_transport = Transport.find(params[:id])\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def update\n respond_to do |format|\n if @traceroute.update(traceroute_params)\n format.html { redirect_to @traceroute, notice: 'Traceroute was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @traceroute.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @traceroute.update(traceroute_params)\n format.html { redirect_to @traceroute, notice: 'Traceroute was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @traceroute.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @transport_subsidy = TransportSubsidy.find(params[:id])\n\n respond_to do |format|\n if @transport_subsidy.update_attributes(params[:transport_subsidy])\n format.html { redirect_to @transport_subsidy, notice: 'Transport subsidy was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @transport_subsidy.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @transport = @player.transports.find(params[:id])\n\n respond_to do |format|\n if @transport.update_attributes(params[:transport])\n flash[:notice] = 'Transport was successfully updated.'\n format.html { redirect_to( player_transport_path(@player, @transport ) ) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @transport.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @frozen_tunnel_io = FrozenTunnelIo.find(params[:id])\n\n respond_to do |format|\n if @frozen_tunnel_io.update_attributes(params[:frozen_tunnel_io])\n format.html { redirect_to @frozen_tunnel_io, notice: 'El tunel de congelado fue editado exitosamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @frozen_tunnel_io.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @transport_allowance.update(transport_allowance_params)\n format.html { redirect_to transport_allowances_path, notice: 'Transport allowance was successfully updated.' }\n format.json { render :show, status: :ok, location: @transport_allowance }\n else\n format.html { render :edit }\n format.json { render json: transport_allowances_path.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @transporter = Transporter.find(params[:id])\n\n respond_to do |format|\n if @transporter.update_attributes(params[:transporter])\n format.html { redirect_to @transporter, notice: 'Transporter was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @transporter.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch options\n rest_request({ method: :patch }.merge(options))\n end",
"def patch options\n rest_request({ method: :patch }.merge(options))\n end",
"def update\n respond_to do |format|\n if @transport_hour.update(transport_hour_params)\n format.html { redirect_to @transport_hour, notice: 'Transport hour was successfully updated.' }\n format.json { render :show, status: :ok, location: @transport_hour }\n else\n format.html { render :edit }\n format.json { render json: @transport_hour.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cta.update(cta_params)\n format.html { redirect_to @cta, notice: 'cta was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @cta.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch_tier1_0_with_http_info(tier_1_id, tier1, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PolicyNetworkingConnectivityTier1GatewaysTier1GatewaysApi.patch_tier1_0 ...'\n end\n # verify the required parameter 'tier_1_id' is set\n if @api_client.config.client_side_validation && tier_1_id.nil?\n fail ArgumentError, \"Missing the required parameter 'tier_1_id' when calling PolicyNetworkingConnectivityTier1GatewaysTier1GatewaysApi.patch_tier1_0\"\n end\n # verify the required parameter 'tier1' is set\n if @api_client.config.client_side_validation && tier1.nil?\n fail ArgumentError, \"Missing the required parameter 'tier1' when calling PolicyNetworkingConnectivityTier1GatewaysTier1GatewaysApi.patch_tier1_0\"\n end\n # resource path\n local_var_path = '/infra/tier-1s/{tier-1-id}'.sub('{' + 'tier-1-id' + '}', tier_1_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(tier1)\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:PATCH, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PolicyNetworkingConnectivityTier1GatewaysTier1GatewaysApi#patch_tier1_0\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def update\n respond_to do |format|\n if @product_cabinet.update_attributes(product_cabinet_params)\n format.html { redirect_to([:admin, @product_cabinet], notice: 'Product cabinet was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render action: \"edit\" }\n format.xml { render xml: @product_cabinet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_tenant_maintenance_window(args = {}) \n id = args['id']\n temp_path = \"/tenants.json/maintenance/{tenantId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"tenantId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def update\r\n respond_to do |format|\r\n if @fabricante.update(fabricante_params)\r\n format.html { redirect_to fabricante_path(@fabricante), notice: 'Fabricante atualizada com sucesso.' }\r\n format.json { render :show, status: :ok, location: @fabricante }\r\n else\r\n format.html { render :edit }\r\n format.json { render json: @fabricante.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def put(id, json)\n with_endpoint do |endpoint|\n url = [endpoint, @resource_name, id].compact.join('/')\n url += \"/\" \n return HTTParty.put(url, :body => json, :timeout => 4, :headers => { 'Content-Type' => 'application/json' })\n end\n end",
"def api_patch(path, data = {})\n api_request(:patch, path, :data => data)\n end",
"def update\n data = tenant_update_params\n tookan = {\"api_key\": \"50646180f541481e4c422b614c5825431be3c2f82fd57936541c03\",\"customer_id\": @tenant.customer_id,\"user_type\": 0,\"name\": data[:name],\"phone\": data[:phone1],\"email\": data[:email],\"address\": data[:address],\"latitude\": data[:latitude],\"longitude\": data[:longitude]}\n response = RestClient.post \"https://api.tookanapp.com/v2/customer/edit\", tookan.to_json, :content_type => \"application/json\"\n response = JSON.parse(response)\n respond_to do |format|\n if response[\"status\"] == 200\n if @tenant.update(tenant_update_params)\n food_category = FoodCategory.find_or_create_by(name: \"Veg\")\n @tenant.tenant_details.update(food_category_id: food_category.id)\n if @tenant.active == true\n end\n end\n @tenant.update(:updated_by=>session[:kitchen_user_id])\n format.html { redirect_to tenants_url, notice: 'Tenant was successfully updated.' }\n format.json { render :show, status: :ok, location: @tenant }\n else\n format.html { redirect_to tenants_url, notice: 'Tenant was not updated.' }\n format.json { render json: @tenant.errors, status: :unprocessable_entity }\n end\n end\nend",
"def update\n respond_to do |format|\n if @rcadmin_cabinet_type.update(rcadmin_cabinet_type_params)\n\tflash[:notice] = 'Cabinet type was successfully updated'\n format.html { redirect_to rcadmin_cabinet_types_url, notice: 'Cabinet type was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @rcadmin_cabinet_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch_tier1_with_http_info(tier_1_id, tier1, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PolicyNetworkingConnectivityTier1GatewaysTier1GatewaysApi.patch_tier1 ...'\n end\n # verify the required parameter 'tier_1_id' is set\n if @api_client.config.client_side_validation && tier_1_id.nil?\n fail ArgumentError, \"Missing the required parameter 'tier_1_id' when calling PolicyNetworkingConnectivityTier1GatewaysTier1GatewaysApi.patch_tier1\"\n end\n # verify the required parameter 'tier1' is set\n if @api_client.config.client_side_validation && tier1.nil?\n fail ArgumentError, \"Missing the required parameter 'tier1' when calling PolicyNetworkingConnectivityTier1GatewaysTier1GatewaysApi.patch_tier1\"\n end\n # resource path\n local_var_path = '/global-infra/tier-1s/{tier-1-id}'.sub('{' + 'tier-1-id' + '}', tier_1_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(tier1)\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:PATCH, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PolicyNetworkingConnectivityTier1GatewaysTier1GatewaysApi#patch_tier1\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def update\n respond_to do |format|\n if @tracing.update(tracing_params)\n format.html { redirect_to @tracing }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tracing.errors, status: :unprocessable_entity }\n end\n end\n end",
"def UpdateTicket params = {}\n \n APICall(path: 'tickets.json',method: 'PUT',payload: params.to_json)\n \n end",
"def patch_tier0_with_http_info(tier_0_id, tier0, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PolicyNetworkingConnectivityTier0GatewaysTier0GatewaysApi.patch_tier0 ...'\n end\n # verify the required parameter 'tier_0_id' is set\n if @api_client.config.client_side_validation && tier_0_id.nil?\n fail ArgumentError, \"Missing the required parameter 'tier_0_id' when calling PolicyNetworkingConnectivityTier0GatewaysTier0GatewaysApi.patch_tier0\"\n end\n # verify the required parameter 'tier0' is set\n if @api_client.config.client_side_validation && tier0.nil?\n fail ArgumentError, \"Missing the required parameter 'tier0' when calling PolicyNetworkingConnectivityTier0GatewaysTier0GatewaysApi.patch_tier0\"\n end\n # resource path\n local_var_path = '/global-infra/tier-0s/{tier-0-id}'.sub('{' + 'tier-0-id' + '}', tier_0_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(tier0)\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:PATCH, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PolicyNetworkingConnectivityTier0GatewaysTier0GatewaysApi#patch_tier0\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def update\n @blocking_client = BlockingClient.find(params[:id])\n\n respond_to do |format|\n if @blocking_client.update_attributes(params[:blocking_client])\n format.html { redirect_to @blocking_client, notice: 'Blocking client was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @blocking_client.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch_tier0_0_with_http_info(tier_0_id, tier0, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PolicyNetworkingConnectivityTier0GatewaysTier0GatewaysApi.patch_tier0_0 ...'\n end\n # verify the required parameter 'tier_0_id' is set\n if @api_client.config.client_side_validation && tier_0_id.nil?\n fail ArgumentError, \"Missing the required parameter 'tier_0_id' when calling PolicyNetworkingConnectivityTier0GatewaysTier0GatewaysApi.patch_tier0_0\"\n end\n # verify the required parameter 'tier0' is set\n if @api_client.config.client_side_validation && tier0.nil?\n fail ArgumentError, \"Missing the required parameter 'tier0' when calling PolicyNetworkingConnectivityTier0GatewaysTier0GatewaysApi.patch_tier0_0\"\n end\n # resource path\n local_var_path = '/infra/tier-0s/{tier-0-id}'.sub('{' + 'tier-0-id' + '}', tier_0_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(tier0)\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:PATCH, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PolicyNetworkingConnectivityTier0GatewaysTier0GatewaysApi#patch_tier0_0\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def update\n respond_to do |format|\n if @cabinet_balancer.update(create_params)\n format.html { redirect_to cabinet_balancers_path, notice: I18n.t('updated') }\n format.json { render :show, status: :ok, location: @cabinet_balancer }\n else\n format.html { render :edit }\n format.json { render json: @cabinet_balancer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put!\n request! :put\n end",
"def update\n respond_to do |format|\n if @tb_servicio.update(tb_servicio_params)\n format.html { redirect_to @tb_servicio, notice: 'Tb servicio was successfully updated.' }\n format.json { render :show, status: :ok, location: @tb_servicio }\n else\n format.html { render :edit }\n format.json { render json: @tb_servicio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_current_tenant_maintenance_window(args = {}) \n id = args['id']\n temp_path = \"/tenants.json/maintenance\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"tenantId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def put(type, info)\n path, info = type_info(type, :path), force_case(info)\n ida = type == :client ? 'client_id' : 'id'\n raise ArgumentError, \"info must include #{ida}\" unless id = info[ida]\n hdrs = headers\n if info && info['meta'] && (etag = info['meta']['version'])\n hdrs.merge!('if-match' => etag)\n end\n reply = json_parse_reply(@key_style,\n *json_put(@target, \"#{path}/#{Addressable::URI.encode(id)}\", info, hdrs))\n\n # hide client endpoints that are not quite scim compatible\n type == :client && !reply ? get(type, info['client_id']): reply\n end",
"def http_put(path, data, content_type = 'application/json')\n http_methods(path, :put, data, content_type)\n end",
"def update\n @servicetype = Servicetype.find(params[:id])\n\n respond_to do |format|\n if @servicetype.update_attributes(params[:servicetype])\n format.html { redirect_to @servicetype, :notice => 'Servicetype was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @servicetype.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def fire_patch(url_or_path, entity, options = {}, &block)\n url = absolute_url(url_or_path)\n headers = {:Accept => MEDIA_TYPE_JSON, :'Content-type' => ENCODED_MEDIA_TYPE_JSON_PATCH}.\n merge(options.fetch(:headers, {}))\n headers = merge_log_weasel_header(headers)\n timeout = options.fetch(:timeout, Ladon.default_request_timeout)\n body = encode_entity(entity)\n response = Typhoeus::Request.run(url, headers: headers, timeout: timeout, body: body, method: :patch)\n handle_response(response, method: :patch, url: url, default_data: options[:default_data],\n raise_on_error: options[:raise_on_error], &block)\n end",
"def update\n respond_to do |format|\n if @chronicle.update(chronicle_params)\n format.html { redirect_to @chronicle, notice: t('flash_message.notice.successfully_updated', model: Chronicle.model_name.human) }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @chronicle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(path, data)\n request 'PATCH', path, body: data.to_json\n end",
"def update_user_for_tenant(args = {}) \n id = args['id']\n temp_path = \"/tenants.json/{tenantId}/users/{userId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"tenantId\")\n args.delete(key)\n path = temp_path.gsub(\"{#{key}}\", id)\n end\nend\n puts \" PATH : #{path}\"\n put(path, args)\nend",
"def rest_patch(base_uri,json_payload,params)\n begin\n @response = RestClient.patch(base_uri,json_payload,params)\n rescue => e\n puts @response.code\n end\n return @response\n end",
"def update\n respond_to do |format|\n if @cta_cte.update(cta_cte_params)\n format.html { redirect_to @cta_cte, notice: 'Cta cte was successfully updated.' }\n format.json { render :show, status: :ok, location: @cta_cte }\n else\n format.html { render :edit }\n format.json { render json: @cta_cte.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(path, **args); end",
"def update\n respond_to do |format|\n if @tenant_fee.update(tenant_fee_params)\n format.html { redirect_to @tenant_fee, notice: 'Tenant fee was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :edit }\n format.json { render json: @tenant_fee.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @fleet.update(fleet_params)\n format.html { redirect_to @fleet, notice: 'Fleet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @fleet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch_tier1_locale_services_0_with_http_info(tier_1_id, locale_services_id, locale_services, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PolicyNetworkingConnectivityTier1GatewaysTier1LocaleServicesApi.patch_tier1_locale_services_0 ...'\n end\n # verify the required parameter 'tier_1_id' is set\n if @api_client.config.client_side_validation && tier_1_id.nil?\n fail ArgumentError, \"Missing the required parameter 'tier_1_id' when calling PolicyNetworkingConnectivityTier1GatewaysTier1LocaleServicesApi.patch_tier1_locale_services_0\"\n end\n # verify the required parameter 'locale_services_id' is set\n if @api_client.config.client_side_validation && locale_services_id.nil?\n fail ArgumentError, \"Missing the required parameter 'locale_services_id' when calling PolicyNetworkingConnectivityTier1GatewaysTier1LocaleServicesApi.patch_tier1_locale_services_0\"\n end\n # verify the required parameter 'locale_services' is set\n if @api_client.config.client_side_validation && locale_services.nil?\n fail ArgumentError, \"Missing the required parameter 'locale_services' when calling PolicyNetworkingConnectivityTier1GatewaysTier1LocaleServicesApi.patch_tier1_locale_services_0\"\n end\n # resource path\n local_var_path = '/infra/tier-1s/{tier-1-id}/locale-services/{locale-services-id}'.sub('{' + 'tier-1-id' + '}', tier_1_id.to_s).sub('{' + 'locale-services-id' + '}', locale_services_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(locale_services)\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:PATCH, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PolicyNetworkingConnectivityTier1GatewaysTier1LocaleServicesApi#patch_tier1_locale_services_0\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def update\n respond_to do |format|\n if @contract.update(update_params)\n format.html { redirect_to_leaf_notice(UPDATE_SUCCESS) }\n format.json { render :show, status: :ok, location: @contract }\n else\n unprocessable_response(format)\n end\n end\n end",
"def update\n respond_to do |format|\n if @trip.update(trip_params)\n last_clip(@trip, trip_params[:clips_attributes].present?)\n format.html { redirect_to @trip.parent || @trip, notice: 'Trip was successfully updated.', change: \"list\" }\n format.json { head :no_content }\n else\n format.html { redirect_to @trip.parent || @trip }\n format.json { render json: @trip.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @servicetype = Servicetype.find(params[:id])\n\n respond_to do |format|\n if @servicetype.update_attributes(params[:servicetype])\n format.html { redirect_to @servicetype, notice: 'Servicetype was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @servicetype.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n resource.update(deposit_contract_params)\n respond_with client, resource\n end",
"def update # PATCH\n raise NotImplementedError\n end",
"def patch(url, payload, headers={})\n RestClient.patch url, payload, headers\n end",
"def update\n respond_to do |format|\n if @clientes_servico.update(clientes_servico_params)\n format.html { redirect_to @clientes_servico, notice: 'Clientes servico was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @clientes_servico.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n contract = Contract.find_by_id(params[:id])\n (head :unauthorized unless contract) and return\n \n # try to update the attributes\n if contract.update_attributes(edit_contract_params)\n render json: contract\n else\n render json: { errors: contract.error.full_messages}\n end\n end",
"def update\n respond_to do |format|\n if @system_contract.update(system_contract_params)\n format.html { redirect_to @system_contract, notice: 'Contract was successfully updated.' }\n format.json { render :show, status: :ok, location: @system_contract }\n else\n format.html { render :edit }\n format.json { render json: @system_contract.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(path, body_params = {})\n debug_log \"PATCH #{@host}#{path} body:#{body_params}\"\n headers = { 'Content-Type' => 'application/json' }\n res = connection.run_request :put, path, body_params.to_json, headers\n debug_log \"Response status:#{res.status}, body:#{res.body}\"\n res\n end",
"def create\n @cabinet_transport = current_user.transports.new(cabinet_transport_params)\n respond_to do |format|\n if @cabinet_transport.save\n public_send(params[:transport][:status])\n format.html { redirect_to cabinet_transports_path, notice: I18n.t('created') }\n else\n format.html { render :new }\n format.json { render json: @cabinet_transport.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(path, opts = {})\n request(:patch, path, opts).body\n end",
"def update\n respond_to do |format|\n if @ct.update(ct_params)\n format.html { redirect_to @ct, notice: 'Ct was successfully updated.' }\n format.json { render :show, status: :ok, location: @ct }\n else\n format.html { render :edit }\n format.json { render json: @ct.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tier = Tier.find(params[:id])\n\n respond_to do |format|\n if @tier.update_attributes(params[:tier])\n format.html { redirect_to @tier, :notice => 'Tier was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @tier.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def patch_tier1_locale_services_with_http_info(tier_1_id, locale_services_id, locale_services, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PolicyNetworkingConnectivityTier1GatewaysTier1LocaleServicesApi.patch_tier1_locale_services ...'\n end\n # verify the required parameter 'tier_1_id' is set\n if @api_client.config.client_side_validation && tier_1_id.nil?\n fail ArgumentError, \"Missing the required parameter 'tier_1_id' when calling PolicyNetworkingConnectivityTier1GatewaysTier1LocaleServicesApi.patch_tier1_locale_services\"\n end\n # verify the required parameter 'locale_services_id' is set\n if @api_client.config.client_side_validation && locale_services_id.nil?\n fail ArgumentError, \"Missing the required parameter 'locale_services_id' when calling PolicyNetworkingConnectivityTier1GatewaysTier1LocaleServicesApi.patch_tier1_locale_services\"\n end\n # verify the required parameter 'locale_services' is set\n if @api_client.config.client_side_validation && locale_services.nil?\n fail ArgumentError, \"Missing the required parameter 'locale_services' when calling PolicyNetworkingConnectivityTier1GatewaysTier1LocaleServicesApi.patch_tier1_locale_services\"\n end\n # resource path\n local_var_path = '/global-infra/tier-1s/{tier-1-id}/locale-services/{locale-services-id}'.sub('{' + 'tier-1-id' + '}', tier_1_id.to_s).sub('{' + 'locale-services-id' + '}', locale_services_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(locale_services)\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:PATCH, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PolicyNetworkingConnectivityTier1GatewaysTier1LocaleServicesApi#patch_tier1_locale_services\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def patch(path, params = {})\n request(:patch, path, params)\n end",
"def patch(path, params = {})\n request(:patch, path, params)\n end",
"def update\n @treq = Treq.find(params[:id])\n\n respond_to do |format|\n unless params[:treq_files].blank?\n params[:treq_files]['file'].each do |a|\n @treq_file = @treq.treq_files.create!(:file => a, :treq_id => @treq.id)\n end\n end\n if @treq.update_attributes(params[:treq])\n format.html { redirect_to @treq, notice: 'Treq was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @treq.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @contract = Contract.find(params[:id])\n @units = Unit.unsold(params[:tower_id])\n respond_to do |format|\n if @contract.update_attributes(params[:contract])\n format.html { redirect_to tower_contract_path(@contract.unit.tower, @contract), notice: 'Contract was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contract.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @marcas = @truck.get_marcas() \n @modelos = @truck.get_modelos()\n @tipo_unidad = @truck.get_tipos()\n @config = @truck.get_config()\n @clase = @truck.get_clase()\n @color = @truck.get_color()\n\n\n respond_to do |format|\n if @truck.update(truck_params)\n format.html { redirect_to @truck, notice: 'Truck was successfully updated.' }\n format.json { render :show, status: :ok, location: @truck }\n else\n format.html { render :edit }\n format.json { render json: @truck.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cto.update(cto_params)\n format.html { redirect_to @cto, notice: 'Cto was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @cto.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @chef.update(chef_params)\n format.html { redirect_to [:admin, @chef], notice: t('messages.updated', model:Chef.model_name.human) }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @chef.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @contractor_feature = ContractorFeature.find(params[:id])\n\n respond_to do |format|\n if @contractor_feature.update_attributes(params[:contractor_feature])\n format.html { redirect_to @contractor_feature, notice: 'Contractor feature was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @contractor_feature.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @tribe.update(tribe_params)\n format.html { redirect_to @tribe, notice: 'Tribe was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @tribe.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update options={}\n client.put(\"/#{id}\", options)\n end",
"def patch(path, params)\n time(\"PATCH #{path}\") { Cloudflarer.new.patch(path, params) }\n end",
"def update\n @st_transport_data = StTransportData.find(params[:id])\n\n respond_to do |format|\n if @st_transport_data.update_attributes(params[:st_transport_data])\n format.html { redirect_to(@st_transport_data) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @st_transport_data.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update!(params)\n res = @client.put(path, nil, params, \"Content-Type\" => \"application/json\")\n @attributes = res.json if res.status == 201\n res\n end",
"def update\n #@service_request = ServiceRequest.find(params[:id])\n\n respond_to do |format|\n if @service_request.update_attributes(service_request_params)\n format.html { redirect_to @service_request, notice: 'Service request was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @service_request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @bookcabinet.update(bookcabinet_params)\n format.html { redirect_to @bookcabinet, notice: 'Bookcabinet was successfully updated.' }\n format.json { render :show, status: :ok, location: @bookcabinet }\n else\n format.html { render :edit }\n format.json { render json: @bookcabinet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n# respond_to do |format|\n# if @req.update(req_params)\n format.json { render :json => {:status => 'success'}}\n# format.html { redirect_to @req, notice: 'Req was successfully updated.' }\n# format.json { render :show, status: :ok, location: @req }\n# else\n format.json { render :json => {:status => 'failed'}}\n# format.html { render :edit }\n# format.json { render json: @req.errors, status: :unprocessable_entity }\n# end\n# end\n end",
"def transport_change(opts={})\n request = transport_prepare_request(COMMAND_ID_CORE_TRANSPORT_CHANGE, opts)\n\n return false unless request\n\n client.send_request(request)\n\n return true\n end",
"def update\n @fleet = Fleet.find(params[:id])\n\n respond_to do |format|\n if @fleet.update_attributes(params[:fleet])\n format.html { redirect_to @fleet, notice: 'Fleet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @fleet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @cabinet_infrastructure_type.update(cabinet_infrastructure_type_params)\n format.html { redirect_to cabinet_infrastructure_types_path, notice: I18n.t('updated') }\n else\n format.html { render :edit }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ticket.update(ticket_params)\n @ticket.update_responsible(:status, 'Waiting for Staff Response')\n format.html { redirect_to @ticket, notice: 'Ticket was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def patch(uri, options = T.unsafe(nil)); end",
"def update\n respond_to do |format|\n if @food_truck.update(food_truck_params)\n format.html { redirect_to @food_truck, notice: 'Food truck was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @food_truck.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tipocliente = Tipocliente.find(params[:id])\n\n respond_to do |format|\n if @tipocliente.update_attributes(params[:tipocliente])\n format.html { redirect_to @tipocliente, :notice => 'Tipocliente was successfully updated.' }\n format.json { render json: @tipocliente }\n else\n format.html { render :action => \"edit\" }\n format.json { render json: @tipocliente.errors }\n end\n end\n end",
"def update\n authorize! :manage, @flock\n\n respond_to do |format|\n if @flock.update(flock_params)\n format.html { redirect_to @flock, notice: \"Flock was successfully updated.\" }\n format.json { render :show, status: :ok, location: @flock }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @flock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @transport_line = TransportLine.find(params[:id])\n\n respond_to do |format|\n if @transport_line.update_attributes(params[:transport_line])\n flash[:notice] = 'TransportLine was successfully updated.'\n format.html { redirect_to(@transport_line) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @transport_line.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @peticion_servicio_ti = Peticion::ServicioTi.find(params[:id])\n\n respond_to do |format|\n if @peticion_servicio_ti.update_attributes(params[:peticion_servicio_ti])\n format.html { redirect_to edit_peticion_servicio_ti_path(@peticion_servicio_ti), notice: 'Actualizado Correctamente.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @peticion_servicio_ti.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @tariff = Tariff.find params[:id]\n\n respond_to do |format|\n if @tariff.update(tariff_params)\n format.html { redirect_to @tariff, notice: 'Tariff was successfully updated.' }\n format.json { respond_with_bip(@tariff) }\n else\n format.html { render :edit }\n format.json { respond_with_bip(@tariff) }\n end\n end\n end",
"def patch_tier0_locale_services_with_http_info(tier_0_id, locale_services_id, locale_services, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: PolicyNetworkingConnectivityTier0GatewaysTier0LocaleServicesApi.patch_tier0_locale_services ...'\n end\n # verify the required parameter 'tier_0_id' is set\n if @api_client.config.client_side_validation && tier_0_id.nil?\n fail ArgumentError, \"Missing the required parameter 'tier_0_id' when calling PolicyNetworkingConnectivityTier0GatewaysTier0LocaleServicesApi.patch_tier0_locale_services\"\n end\n # verify the required parameter 'locale_services_id' is set\n if @api_client.config.client_side_validation && locale_services_id.nil?\n fail ArgumentError, \"Missing the required parameter 'locale_services_id' when calling PolicyNetworkingConnectivityTier0GatewaysTier0LocaleServicesApi.patch_tier0_locale_services\"\n end\n # verify the required parameter 'locale_services' is set\n if @api_client.config.client_side_validation && locale_services.nil?\n fail ArgumentError, \"Missing the required parameter 'locale_services' when calling PolicyNetworkingConnectivityTier0GatewaysTier0LocaleServicesApi.patch_tier0_locale_services\"\n end\n # resource path\n local_var_path = '/global-infra/tier-0s/{tier-0-id}/locale-services/{locale-services-id}'.sub('{' + 'tier-0-id' + '}', tier_0_id.to_s).sub('{' + 'locale-services-id' + '}', locale_services_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(locale_services)\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:PATCH, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: PolicyNetworkingConnectivityTier0GatewaysTier0LocaleServicesApi#patch_tier0_locale_services\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end"
] | [
"0.6032919",
"0.596297",
"0.59566563",
"0.5720547",
"0.5670075",
"0.56541866",
"0.56492096",
"0.5644824",
"0.5632196",
"0.561097",
"0.5578803",
"0.5544935",
"0.55412465",
"0.55397564",
"0.5486192",
"0.54621166",
"0.5461963",
"0.545206",
"0.54416907",
"0.54409003",
"0.5437028",
"0.5434742",
"0.5392051",
"0.5392051",
"0.5388035",
"0.53509897",
"0.5343751",
"0.5337611",
"0.533761",
"0.53313905",
"0.5325649",
"0.5324723",
"0.53221166",
"0.53182834",
"0.5313924",
"0.5312825",
"0.5303776",
"0.5302001",
"0.5294472",
"0.5282093",
"0.5271234",
"0.5256704",
"0.5242664",
"0.52331644",
"0.5232333",
"0.52221596",
"0.5210081",
"0.5209513",
"0.52064246",
"0.5204219",
"0.52009934",
"0.5200525",
"0.51899886",
"0.5183783",
"0.5177966",
"0.51759744",
"0.51701754",
"0.5167246",
"0.51601374",
"0.51555747",
"0.5154599",
"0.51502174",
"0.5146452",
"0.5144861",
"0.51342416",
"0.5133699",
"0.513336",
"0.5125515",
"0.5123281",
"0.511636",
"0.5107398",
"0.5105019",
"0.5104712",
"0.5104712",
"0.5102158",
"0.5099364",
"0.5097413",
"0.50959533",
"0.50929445",
"0.50922114",
"0.5087248",
"0.5084369",
"0.5073934",
"0.5072738",
"0.5070555",
"0.50640965",
"0.5060127",
"0.50571716",
"0.5054534",
"0.50493264",
"0.50484735",
"0.5043605",
"0.50378275",
"0.50357616",
"0.5030298",
"0.5028549",
"0.50278336",
"0.50277025",
"0.5026576",
"0.50240725"
] | 0.67123234 | 0 |
DELETE /cabinet/transports/1 DELETE /cabinet/transports/1.json | def destroy
@cabinet_transport.destroy
respond_to do |format|
format.html { redirect_to cabinet_transports_path, notice: I18n.t('deleted') }
format.json { head :no_content }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n @fabric = Fabric.find(params[:id])\n @fabric.destroy\n\n respond_to do |format|\n format.html { redirect_to fabrics_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cabinet = Cabinet.find(params[:id])\n @cabinet.destroy\n\n respond_to do |format|\n format.html { redirect_to cabinets_url }\n format.json { head :ok }\n end\n end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def deleteFlatpack( flatpack_id)\n params = Hash.new\n params['flatpack_id'] = flatpack_id\n return doCurl(\"delete\",\"/flatpack\",params)\n end",
"def destroy\n @cabinet_balancer.destroy\n respond_to do |format|\n format.html { redirect_to cabinet_balancers_path, notice: I18n.t('deleted') }\n format.json { head :no_content }\n end\n end",
"def destroy\n authorize! :destroy, @transport\n @transport.destroy\n respond_to do |format|\n format.html { redirect_to transports_url, notice: 'Transport was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete endpoint\n do_request :delete, endpoint\n end",
"def destroy\n @loadbalancer = Loadbalancer.find(params[:id])\n checkaccountobject(\"loadbalancers\",@loadbalancer)\n @loadbalancer.send_delete\n\n respond_to do |format|\n format.html { redirect_to loadbalancers_url }\n format.json { head :ok }\n end\n end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def destroy\n @transport.destroy\n respond_to do |format|\n flash[:success] = 'Transport was successfully destroyed.' ;\n format.html { redirect_to transports_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @transport = Transport.find(params[:id])\n @transport.destroy\n\n respond_to do |format|\n format.html { redirect_to(transports_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @transport = Transport.find(params[:id])\n @transport.destroy\n\n respond_to do |format|\n format.html { redirect_to(transports_url) }\n format.xml { head :ok }\n end\n end",
"def delete(type, id)\n http_delete @target, \"#{type_info(type, :path)}/#{Addressable::URI.encode(id)}\", @auth_header, @zone\n end",
"def destroy\n @transport_subsidy = TransportSubsidy.find(params[:id])\n @transport_subsidy.destroy\n\n respond_to do |format|\n format.html { redirect_to transport_subsidies_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @transport_route = TransportRoute.find(params[:id])\n @transport_route.destroy\n\n respond_to do |format|\n format.html { redirect_to transport_routes_url }\n format.json { head :no_content }\n end\n end",
"def tenant_delete(tenant_id)\n\t\n\t\tdelete_call = Curl::Easy.http_delete(\"#{@ip_address}:#{@port_2}/v2.0/tenants/#{tenant_id}\"\n\t\t) do |curl|\n\t\t\tcurl.headers['x-auth-token'] = @token\n\t\t\tcurl.headers['userId'] = tenant_id\n\t\t end\n\t\t\n\t\tputs \"invoked tenant delete\"\n\tend",
"def delete\n res = HTTParty.get URL, headers: HEADERS\n message = JSON.parse res.body, symbolize_names: true\n if res.code == 200\n numSubs = message[:data].count\n if numSubs > 0\n message[:data].each do |sub|\n id = sub[:id]\n delRes = HTTParty.delete \"#{URL}/#{id}\", headers: HEADERS\n #TODO handle status codes\n end\n end\n end\n end",
"def host_delete(host)\n curl = setup_curl(\"#{@foreman_url}/api/hosts/#{host}\", true)\n curl.http_delete\n end",
"def destroy\n @transport_batch = TransportBatch.find(params[:id])\n @transport_batch.destroy\n\n respond_to do |format|\n format.html { redirect_to transport_batches_url }\n format.json { head :no_content }\n end\n end",
"def delete(path)\n RestClient.delete request_base+path\n end",
"def cancelReservation(lease_uuid)\n broker_url = APP_CONFIG['broker_ip'] + ':' + APP_CONFIG['broker_port'].to_s \n cert_path = APP_CONFIG['cert_path']\n \n header = {\"Content-Type\" => \"application/json\"}\n options = {uuid: lease_uuid}\n\n #puts options.to_json \n uri = URI.parse(broker_url+\"/resources/leases\")\n pem = File.read(cert_path)\n http = Net::HTTP.new(uri.host, uri.port)\n http.use_ssl = true\n http.cert = OpenSSL::X509::Certificate.new(pem)\n http.key = OpenSSL::PKey::RSA.new(pem)\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Delete.new(uri.request_uri, header)\n request.body = options.to_json\n\n response = http.request(request)\n puts response\n if response.header.code != '200'\n puts \"Something went wrong\"\n puts response\n end\n end",
"def delete\n start { |connection| connection.request http :Delete }\n end",
"def destroy\n @traffic = Traffic.find(params[:id])\n @traffic.destroy\n\n respond_to do |format|\n format.html { redirect_to traffics_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @traceroute.destroy\n respond_to do |format|\n format.html { redirect_to traceroutes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @traceroute.destroy\n respond_to do |format|\n format.html { redirect_to traceroutes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @fabrica.destroy\n respond_to do |format|\n format.html { redirect_to fabricas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @rcadmin_cabinet_type.destroy\n flash[:notice] = 'Cabinet type was successfully deleted'\n respond_to do |format|\n format.html { redirect_to rcadmin_cabinet_types_url }\n format.json { head :no_content }\n end\n end",
"def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end",
"def destroy\n @client = Client.find(params[:id])\n @client.destroy\n @uuid = params[:uuid]\n respond_to do |format|\n format.html { redirect_to :controller => 'ads', :action => 'admin_dash', :id => 1, :uuid => @uuid }\n format.json { head :no_content }\n end\n end",
"def destroy\n transport = @transportabschnitt.transport\n @transportabschnitt.destroy\n respond_to do |format|\n flash[:success] = \"Transportabschnitt gelöscht.\"\n format.html { redirect_to transport }\n format.json { head :no_content }\n end\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def destroy\n @shutdown_request.destroy\n respond_to do |format|\n format.html { redirect_to shutdown_requests_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @transit_chamber_io = TransitChamberIo.find(params[:id])\n @transit_chamber_io.destroy\n\n respond_to do |format|\n format.html { redirect_to transit_chamber_ios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @blocking_client = BlockingClient.find(params[:id])\n @blocking_client.destroy\n\n respond_to do |format|\n format.html { redirect_to blocking_clients_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @fbt.destroy\n respond_to do |format|\n format.html { redirect_to fbts_url, notice: \"Client was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n client=Client.find_by_id(params[:id])\n if client != nil\n if client.destroy\n head 204\n end\n else\n head 404\n end\n end",
"def destroy\n @traffic.destroy\n respond_to do |format|\n format.html { redirect_to traffics_url, notice: 'Traffic was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n \n keystone.delete_tenant(keystone.get_tenant(params[:id])[:id])\n\n respond_to do |format|\n format.html { redirect_to tenants_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @secubat_client = SecubatClient.find(params[:id])\n @secubat_client.destroy\n\n respond_to do |format|\n format.html { redirect_to secubat_clients_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @host_tpl = HostTpl.find(params[:id])\n @host_tpl.destroy\n\n respond_to do |format|\n format.html { redirect_to host_tpls_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @transport_setup.destroy\n respond_to do |format|\n format.html { redirect_to transport_setups_url, notice: 'Transport setup was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def orchio_delete\n response = client.send_request :delete, inst_args\n orchio_status response, 204\n end",
"def destroy\n chef_rest_v1.delete(\"clients/#{@name}\")\n end",
"def destroy\n @tribe.destroy\n respond_to do |format|\n format.html { redirect_to tribes_url }\n format.json { head :no_content }\n end\n end",
"def delete(id:)\n id_check(:id, id)\n\n cf_delete(path: \"/organizations/#{org_id}/railguns/#{id}\")\n end",
"def destroy\n @traffic = Traffic.find(params[:id])\n @traffic.destroy\n\n respond_to do |format|\n format.html { redirect_to(traffics_url) }\n format.xml { head :ok }\n end\n end",
"def delete_json(path)\n url = [base_url, path].join\n resp = HTTParty.delete(url, headers: standard_headers)\n parse_json(url, resp)\n end",
"def http_delete(opts={})\n ret=http_delete_low(opts)\n if ret.is_a?(Hash) and ret.has_key?('error') and ret['error']=='Invalid Credentials' then\n\tauthdefault\n\tret=http_delete_low(opts)\n\treturn ret\n else\n\treturn ret\n end\n end",
"def delete\n client.delete(url)\n @deleted = true\nend",
"def destroy\n @transport_hour.destroy\n respond_to do |format|\n format.html { redirect_to transport_hours_url, notice: 'Transport hour was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @relay.destroy\n respond_to do |format|\n format.html { redirect_to relays_url }\n format.json { head :no_content }\n end\n end",
"def delete(id)\n request(:delete, \"/network_zones/#{id}.json\")\n end",
"def destroy\n @tvcabinet.destroy\n respond_to do |format|\n format.html { redirect_to tvcabinets_url, notice: 'Tvcabinet was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tcpdump_log.destroy\n respond_to do |format|\n format.html { redirect_to tcpdump_logs_url, notice: 'Tcpdump log was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n url = 'https://casa-core.herokuapp.com/api/units/' + params[:id]\n response = HTTParty.delete(url, :headers => { \"Authorization\" => AUTH, \"Host\" => HOST})\n redirect_to units_url, notice: 'Unit was successfully deleted.'\n end",
"def destroy\n @server = Server.find(params[:id])\n checkaccountobject(\"servers\",@server)\n @server.send_delete\n respond_to do |format|\n format.html { redirect_to servers_url }\n format.json { head :ok }\n end\n end",
"def incident_delete(statuspage_id, incident_id)\n data = {}\n data['statuspage_id'] = statuspage_id\n data['incident_id'] = incident_id\n\n request :method => :post,\n :url => @url + 'incident/delete',\n :payload => data\n end",
"def destroy\n @transport = @player.transports.find(params[:id])\n @transport.destroy\n\n respond_to do |format|\n format.html { redirect_to(player_transports_url(@player)) }\n format.xml { head :ok }\n end\n end",
"def destroy\n# redirect_to activacionclientets_path # ted esto para evitar que borren por la web. ok. Que valla al index. provisional ok.\n \n #@activacionclientet.destroy\n respond_to do |format|\n format.html { redirect_to activacionclientets_url, notice: 'Activacionclientes no se puede eliminar por esta via. Contacte el administrador.' } # ted esto para evitar que borren por la web\n format.json { head :no_content }\n end\n end",
"def destroy\n @trein_consul_comercial.destroy\n respond_to do |format|\n format.html { redirect_to trein_consul_comercials_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @admin_public_transport.destroy\n respond_to do |format|\n format.html { redirect_to session['previous_url'] || admin_public_transports_url, notice: 'Mezzi pubblici cancellata con successo!.' }\n format.json { head :no_content }\n end\n end",
"def cmd_delete argv\n setup argv\n uuid = @hash['uuid']\n response = @api.delete(uuid)\n msg response\n return response\n end",
"def destroy\n @logtransfer = Logtransfer.find(params[:id])\n @logtransfer.destroy\n\n respond_to do |format|\n format.html { redirect_to logtransfers_url }\n format.json { head :no_content }\n end\n end",
"def delete\n request(:delete)\n end",
"def do_delete(uri = \"\")\n @connection.delete do |req|\n req.url uri\n req.headers['Content-Type'] = 'application/json'\n end\n end",
"def destroy\n @treq = Treq.find(params[:id])\n @treq.destroy\n\n respond_to do |format|\n format.html { redirect_to treqs_url }\n format.json { head :no_content }\n end\n end",
"def delete(id)\n with_endpoint do |endpoint|\n url = [endpoint, @resource_name, id].compact.join('/')\n url += \"/\"\n return HTTParty.delete(url, :timeout => 4)\n end\n end",
"def destroy\n @torrent = Torrents.new(:url => \"http://newt.local:9091/transmission/rpc\").find(Integer(params[:id]))\n @torrent.destroy\n\n respond_to do |format|\n format.html { redirect_to torrents_url }\n format.json { head :no_content }\n end\n end",
"def delete(path, params = {})\n debug_log \"DELETE #{@host}#{path} params:#{params}\"\n res = connection.delete path, params\n debug_log \"Response status:#{res.status}, body:#{res.body}\"\n res\n end",
"def http_delete(path, data = nil, content_type = 'application/json')\n http_methods(path, :delete, data, content_type)\n end",
"def destroy\n @tracing.destroy\n respond_to do |format|\n format.html { redirect_to tracings_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @chronicle.destroy\n respond_to do |format|\n format.html { redirect_to chronicles_url }\n format.json { head :no_content }\n end\n end",
"def delete\n super \"/templates/#{template_id}.json\", {}\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def delete\n url = prefix + \"delete\"\n return response(url)\n end",
"def destroy\n @congress.destroy\n respond_to do |format|\n format.html { redirect_to congresses_url, notice: 'Congress was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product_cabinet.destroy\n respond_to do |format|\n format.html { redirect_to(admin_product_cabinets_url) }\n format.xml { head :ok }\n format.js \n end\n website.add_log(user: current_user, action: \"Removed cabinet #{@product_cabinet.cabinet.name} from #{@product_cabinet.product.name}\")\n end",
"def destroy\n @intranet_financeiro_tipos_cobanca.destroy\n respond_to do |format|\n format.html { redirect_to intranet_financeiro_tipos_cobancas_url, notice: \"Financeiro tipos cobanca was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @heartbeat = Heartbeat.find(params[:id])\n @heartbeat.destroy\n\n respond_to do |format|\n format.html { redirect_to heartbeats_url }\n format.json { head :no_content }\n end\n end",
"def deleteExecution(execution_id)\n uri = URI(RUNDECKSERVER + ':' + RUNDECKPORT + '/api/12/execution/' + execution_id)\n http = Net::HTTP.new(uri.host, uri.port)\n headers = {'Content-Type'=> 'application/jsonr','X-RunDeck-Auth-Token'=> API_KEY }\n r = http.delete(uri.path, headers) \n return r\nend",
"def destroy\n begin\n @traffic.destroy\n\n rescue Exception => e\n notice = e.message\n else\n notice = 'Traffic was successfully destroyed.'\n end\n\n respond_to do |format|\n format.html { redirect_to traffics_url, notice: notice }\n format.json { head :no_content }\n end\n end",
"def delete(url, headers = {})\n http :delete, \"#{url}.json\", headers\n end",
"def destroy\n @transport_allowance.destroy\n respond_to do |format|\n format.html { redirect_to transport_allowances_url, notice: 'Transport allowance was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @cta.destroy\n respond_to do |format|\n format.html { redirect_to cta_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @affiliate_ctum = Affiliate::Ctum.find(params[:id])\n @affiliate_ctum.destroy\n\n respond_to do |format|\n format.html { redirect_to affiliate_cta_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @transfer.destroy\n respond_to do |format|\n format.html { redirect_to transfers_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @transport_line = TransportLine.find(params[:id])\n @transport_line.destroy\n\n respond_to do |format|\n format.html { redirect_to(transport_lines_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @cargo_manifest = CargoManifest.find(params[:id])\n num = @cargo_manifest.manifest_num\n attr= TransportGuideState.find_by_name_state('En Proceso').id\n CargoManifest.transaction do\n @cargo_manifest.cargo_manifest_details.each do |detail|\n tg=detail.transport_guide\n tg.update_attribute('transport_guide_state_id', attr)\n detail.delete\n end\n @cargo_manifest.delete\n CustomLogger.info(\"Se borra manifiesto de carga: #{@cargo_manifest.inspect}, usuario: #{current_user.inspect}, #{Time.now}\")\n end\n \n\n respond_to do |format|\n format.html { redirect_to cargo_manifests_url, notice: \"El Manifiesto de cargo #{num} ha sido borrado\"}\n format.json { head :no_content }\n end\n end",
"def destroy\n @dataload_ftp = DataloadFtp.find(params[:id])\n @dataload_ftp.destroy\n\n respond_to do |format|\n format.html { redirect_to dataload_ftps_url }\n format.json { head :no_content }\n end\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def destroy\n #@service_request = ServiceRequest.find(params[:id])\n @service_request.destroy\n\n respond_to do |format|\n format.html { redirect_to service_requests_url }\n format.json { head :no_content }\n end\n end",
"def DeleteTicket id\n \n APICall(path: \"tickets/#{id}.json\",method: 'DELETE')\n \n end",
"def destroy\r\n @fabricante.destroy\r\n respond_to do |format|\r\n format.html { redirect_to fabricantes_url, notice: 'Fabricante excluída com sucesso.' }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @logstash = Logstash.find(params[:id])\n @logstash.destroy\n\n respond_to do |format|\n format.html { redirect_to logstashes_url }\n format.json { head :no_content }\n end\n end",
"def delete(path, params = {})\n Chirpy.request params.merge({:path => path, :method => 'delete'}.merge(authentication))\n end",
"def destroy\n response = get_request(URI.parse(\"http://\"+(sesh :donabe_ip)+\"/\"+(sesh :current_tenant)+\"/deployed_containers/\"+params[:id].to_s+\"/destroy_deployed.json\"), (sesh :current_token))\n json_respond response.body\n\n end",
"def destroy\n authorize @incoming_service_tax\n\n @incoming_service_tax.destroy\n respond_to do |format|\n format.html { redirect_to incoming_service_taxes_url }\n format.json { head :no_content }\n end\n end"
] | [
"0.6586172",
"0.6583339",
"0.65300494",
"0.64225423",
"0.6334508",
"0.62777793",
"0.62728876",
"0.62506986",
"0.62495977",
"0.62020946",
"0.6173425",
"0.6173425",
"0.6161049",
"0.6153423",
"0.61091435",
"0.6107842",
"0.61022156",
"0.61014944",
"0.6100911",
"0.6091735",
"0.608113",
"0.6072506",
"0.60714525",
"0.606766",
"0.606766",
"0.60651255",
"0.6024257",
"0.60155606",
"0.6007947",
"0.6003219",
"0.59991074",
"0.5990343",
"0.59848607",
"0.59810907",
"0.59747326",
"0.59728724",
"0.5969159",
"0.596241",
"0.5961413",
"0.5946887",
"0.5945835",
"0.59421986",
"0.5936252",
"0.59316635",
"0.5917559",
"0.5908914",
"0.5884737",
"0.5877467",
"0.58747554",
"0.5867128",
"0.58574325",
"0.5856642",
"0.58552426",
"0.5849758",
"0.584844",
"0.58469605",
"0.5842307",
"0.5836689",
"0.58363163",
"0.5835934",
"0.5834705",
"0.5830833",
"0.5830675",
"0.58261794",
"0.5824179",
"0.58236116",
"0.58182913",
"0.5814036",
"0.5812578",
"0.58111864",
"0.58084196",
"0.58060426",
"0.5804674",
"0.5802488",
"0.5802488",
"0.5797834",
"0.5797453",
"0.5796074",
"0.5796034",
"0.57944816",
"0.5791979",
"0.579147",
"0.57874477",
"0.5786795",
"0.5781749",
"0.57786655",
"0.57774687",
"0.5773031",
"0.5771181",
"0.57709223",
"0.57709223",
"0.57709223",
"0.57709223",
"0.57692474",
"0.57679224",
"0.5764575",
"0.57633644",
"0.57624745",
"0.5762253",
"0.57582545"
] | 0.7322157 | 0 |
Use callbacks to share common setup or constraints between actions. | def set_cabinet_transport
@cabinet_transport = Transport.find(params[:id])
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def set_actions\n actions :all\n end",
"def define_action_helpers?; end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def workflow\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def setup\n # override and do something appropriate\n end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def setup\n #implement in subclass;\n end",
"def after_set_callback; end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def around_hooks; end",
"def save_action; end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def duas1(action)\n action.call\n action.call\nend",
"def call\n setup_context\n super\n end"
] | [
"0.6165422",
"0.60457647",
"0.5946384",
"0.5916027",
"0.58905005",
"0.583495",
"0.5777223",
"0.56995213",
"0.56995213",
"0.56532377",
"0.5621348",
"0.5422839",
"0.54118705",
"0.54118705",
"0.54118705",
"0.53935355",
"0.5379617",
"0.53577393",
"0.53407264",
"0.53398263",
"0.53316694",
"0.53116405",
"0.52972704",
"0.5296464",
"0.529617",
"0.52609056",
"0.52449894",
"0.52388823",
"0.52388823",
"0.52388823",
"0.52388823",
"0.52388823",
"0.52339035",
"0.52324325",
"0.52277064",
"0.5221976",
"0.5219301",
"0.52134573",
"0.5207571",
"0.52070796",
"0.51770556",
"0.517467",
"0.51727664",
"0.51673347",
"0.51603955",
"0.51581466",
"0.515401",
"0.51533973",
"0.5152852",
"0.5143863",
"0.5140699",
"0.513394",
"0.5113603",
"0.5113603",
"0.51126283",
"0.5110439",
"0.51070756",
"0.50922215",
"0.50881314",
"0.50826275",
"0.50788856",
"0.50678945",
"0.5055518",
"0.5052638",
"0.5049997",
"0.5049997",
"0.50348604",
"0.5026469",
"0.50217324",
"0.50154436",
"0.5013927",
"0.50015604",
"0.50013465",
"0.49973735",
"0.49900484",
"0.49900484",
"0.49862546",
"0.4981161",
"0.49783245",
"0.49772155",
"0.49678212",
"0.49645492",
"0.49579585",
"0.49572104",
"0.49550694",
"0.4954394",
"0.4952923",
"0.49466532",
"0.49427935",
"0.49338013",
"0.4931052",
"0.49276745",
"0.4927467",
"0.4924998",
"0.49223173",
"0.49208498",
"0.49184024",
"0.49167758",
"0.49163175",
"0.4916066",
"0.49157935"
] | 0.0 | -1 |
Never trust parameters from the scary internet, only allow the white list through. | def cabinet_transport_params
permitted = Transport.globalize_attribute_names + [
:gis_type_name,
:status,
:map_layer_id,
:transport_type_id,
geo_json_attributes: %i[id geo_type position]
]
params.require(:transport).permit(permitted)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def filtering_params\n params.permit(:email)\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def url_whitelist; end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end"
] | [
"0.69792545",
"0.6781151",
"0.67419964",
"0.674013",
"0.6734356",
"0.6591046",
"0.6502396",
"0.6496313",
"0.6480641",
"0.6477825",
"0.64565",
"0.6438387",
"0.63791263",
"0.63740575",
"0.6364131",
"0.63192815",
"0.62991166",
"0.62978333",
"0.6292148",
"0.6290449",
"0.6290076",
"0.62894756",
"0.6283177",
"0.6242471",
"0.62382483",
"0.6217549",
"0.6214457",
"0.6209053",
"0.6193042",
"0.6177802",
"0.6174604",
"0.61714715",
"0.6161512",
"0.6151757",
"0.6150663",
"0.61461",
"0.61213595",
"0.611406",
"0.6106206",
"0.6105114",
"0.6089039",
"0.6081015",
"0.6071004",
"0.60620916",
"0.6019971",
"0.601788",
"0.6011056",
"0.6010898",
"0.6005122",
"0.6005122",
"0.6001556",
"0.6001049",
"0.59943926",
"0.5992201",
"0.59909594",
"0.5990628",
"0.5980841",
"0.59669393",
"0.59589154",
"0.5958826",
"0.5957911",
"0.5957385",
"0.5953072",
"0.59526145",
"0.5943361",
"0.59386164",
"0.59375334",
"0.59375334",
"0.5933856",
"0.59292704",
"0.59254247",
"0.5924164",
"0.59167904",
"0.59088355",
"0.5907542",
"0.59064597",
"0.5906243",
"0.5898226",
"0.589687",
"0.5896091",
"0.5894501",
"0.5894289",
"0.5891739",
"0.58860534",
"0.5882406",
"0.587974",
"0.58738774",
"0.5869024",
"0.58679986",
"0.5867561",
"0.5865932",
"0.5864461",
"0.58639693",
"0.58617616",
"0.5861436",
"0.5860451",
"0.58602303",
"0.5854586",
"0.58537364",
"0.5850427",
"0.5850199"
] | 0.0 | -1 |
todo: check why the last number does not transform to int with "to_i". | def int_to_chess(number_list)
# if its just one element return an array inside an array
chess_notation = []
number_list.each do |square|
square_notation = []
letter = num_to_letter(square[0])
number = square[1]
square_notation.push(letter, number)
chess_notation.push(square_notation)
end
# todo: flatten if theres only one element inside!
chess_notation
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_i() end",
"def to_i() end",
"def to_i() end",
"def to_i() end",
"def to_i() end",
"def to_i; end",
"def to_i; end",
"def to_i; end",
"def to_i; end",
"def to_i; end",
"def to_i; end",
"def to_int() end",
"def to_int() end",
"def to_i\n end",
"def to_i\n end",
"def to_i\n end",
"def to_i(*) end",
"def to_i()\n #This is a stub, used for indexing\n end",
"def to_int\n end",
"def to_i\n 9999\n end",
"def to_i(base=10) end",
"def to_i\n to_d.to_i\n end",
"def to_int(*) end",
"def to_i\n to_f.to_i\n end",
"def to_i()\n #This is a stub, used for indexing\n end",
"def to_i\n val.to_i\n end",
"def to_i_with_method\n to_x_with_method.to_i\n end",
"def to_i\n @num\n end",
"def to_i\n self.class.new(@value.to_i)\n end",
"def to_i\n Integer(value)\n end",
"def to_i\n @val.to_i\n end",
"def input_to_index(num)\n return num.to_i - 1\n end",
"def input_to_index(int)\n return int.to_i - 1\nend",
"def to_i\n in_native.to_i\n end",
"def to_i\n @value.to_i\n end",
"def to_integer(input); end",
"def input_to_index(num)\r\n index= num.to_i\r\n index= index - 1\r\nend",
"def input_to_index(inni)\n (inni.to_i - 1)\n \nend",
"def to_i\n n = to_var.to_i\n positive? ? n : -n\n end",
"def convert_to_i(input)\n input.to_i\n end",
"def to_i\n @val\n end",
"def decode_int\n # @index is at the position of the the 'i' so we just need everything between it\n # and the next appearance of 'e'.\n index_of_last_digit = self[@index..self.length - 1].index 'e'\n number_string = self[(@index + 1)..(@index + index_of_last_digit - 1)]\n @index += index_of_last_digit\n number_string.to_i\n end",
"def to_i\n (self.v || self.d).to_i\n end",
"def value; super.to_i; end",
"def input_to_index(num)\n num = num.to_i\n return num - 1\nend",
"def to_int\n @value.to_i\n end",
"def input_to_index(x)\n\n return x.to_i-1\nend",
"def input_to_index(number)\n index = number.to_i\n index = index - 1\nend",
"def to_i\n @object.to_i\n end",
"def to_i\n @object.to_i\n end",
"def to_i\n @object.to_i\n end",
"def to_i\n @object.to_i\n end",
"def to_i\n @to_i ||= @major * 1_000_000 + @minor * 1_000 + @tiny\n end",
"def result\n value.sub(/^integer-/, '').to_i\n end",
"def typecast_value_integer(value)\n value.to_i\n end",
"def input_to_index tato\n tato.to_i - 1\nend",
"def value_as_int(item)\n components = value_as_array(item)\n return nil if components.nil?\n\n (0..(components.length - 1)).collect { |i| components[i].to_s.present? ? components[i] * 10**(10 - 2 * i) : 0 }.sum\n end",
"def interpret\r\n return @number.to_i\r\n end",
"def Integer(p0) end",
"def input_to_index(masuk)\n tes=masuk.to_i\n tes=tes-1\n return tes\nend",
"def to_i4(n)\n head, num, *tail = n\n num.nil?? head : to_i4([head*10+num, *tail])\nend",
"def input_to_index(user_input)\nconverted_input = user_input.to_i - 1\nend",
"def to_i\n @to_i ||= \"#{@low.to_s(16)}\".to_i(16)\n end",
"def handle_integer_conversion(id) \n (Integer(id) rescue nil).nil? || id.to_i.to_s != id.to_s ? id : id.to_i\n end",
"def to_i\n @value\n end",
"def to_i\n @value\n end",
"def to_i\n @value\n end",
"def to_i\n @value\n end",
"def to_i\n @value\n end",
"def to_i\n @value\n end",
"def to_i\n @value\n end",
"def to_i\n @value\n end",
"def to_i\n @value\n end",
"def to_i\n @value\n end",
"def to_i\n @value\n end",
"def to_i\n @value\n end",
"def to_i\n @value\n end",
"def to_i\n @value\n end",
"def to_i\n @value\n end",
"def to_i\n return @val\n end",
"def to_i\n return @val\n end",
"def to_int\n raise ArgumentError, 'Would return an Array' unless returns_one?\n\n roll\n end",
"def input_to_index(input)\n input = input.to_i - 1\nend",
"def post_process_integer( val )\n\t\t\treturn Integer( val.to_s )\n\t\tend",
"def to_index(input)\n input.to_i - 1\n end",
"def return_int(number)\n if number == number.to_i\n number = number.to_i\n else\n number = number\n end\n end",
"def input_to_index(input)\r\n input.to_i - 1 \r\nend",
"def to_integer(i, j)\n if ((i.is_a?(String)) && (i.to_i == 0))\n if ((i_to_integer = @@temp_input_list[\"#{@@current_module}\"][\"#{i}\"]) == NIL)\n i_to_integer = i\n end\n if i == 'R' # hårdkodning\n i_to_integer = 1\n end\n else\n i_to_integer = i\n end\n if ((j.is_a?(String)) && (j.to_i == 0))\n if ((j_to_integer = @@temp_input_list[\"#{@@current_module}\"][\"#{j}\"]) == NIL)\n j_to_integer = j\n end\n if j == 'R' # hårdkodning\n j_to_integer = 1\n end\n else\n j_to_integer = j\n end \n return i_to_integer, j_to_integer\nend",
"def input_to_index(d)\n digit = d.to_i\n digit -= 1\n return digit\nend",
"def number_reverser(integer)\n string = integer.to_s.reverse!\n string.to_i\nend",
"def to_i\n unless @integer\n major, minor, tiny, patch = @version.split \".\"\n if @ceil\n tiny = 99 unless tiny\n patch = 9999 unless patch\n end\n parts = [major, minor, tiny, patch].map { |x| x.to_i }\n @integer = (\"1%02d%02d%02d%04d\" % parts).to_i\n end\n @integer\n end",
"def input_to_index(input)\n input=(input.to_i) - 1;\nend",
"def convert_array_elements_to_i(array)\n for i in 0..array.length-1\n array[i] = array[i].to_i\n end\nend",
"def convert_to_number\n @roman_util.compute_number\n end",
"def reverse(num)\n num.to_s.reverse.to_i\nend",
"def get_integer_value\n\t\tend",
"def input_to_index (input)\n return input.to_i - 1\n\nend",
"def input_to_num\n @input = @input.to_i\n end",
"def to_i\n if @data.respond_to?(:to_i)\n return @data.to_i\n else\n return nil\n end\n end",
"def input_to_index(input)\n input = (input.to_i - 1)\nend",
"def input_to_index(input)\n input.to_i - 1\nend"
] | [
"0.76714593",
"0.76714593",
"0.76714593",
"0.76714593",
"0.76714593",
"0.7634751",
"0.7634751",
"0.7634751",
"0.7634751",
"0.7634751",
"0.7634751",
"0.7515678",
"0.7515678",
"0.7455759",
"0.740994",
"0.740994",
"0.7359315",
"0.72220826",
"0.71838975",
"0.70520437",
"0.7038133",
"0.7038064",
"0.7019699",
"0.6990447",
"0.6971587",
"0.6926996",
"0.6897872",
"0.68325406",
"0.6762335",
"0.67006487",
"0.667908",
"0.66578794",
"0.66324717",
"0.6627139",
"0.66168535",
"0.65939415",
"0.65675163",
"0.6543816",
"0.6539943",
"0.65299594",
"0.6522271",
"0.6516397",
"0.65068895",
"0.6454006",
"0.64508134",
"0.64396673",
"0.64236575",
"0.64198506",
"0.63979965",
"0.63979965",
"0.63979965",
"0.63979965",
"0.63925624",
"0.6387608",
"0.6347892",
"0.63407165",
"0.6310187",
"0.6303027",
"0.6292585",
"0.6281514",
"0.62761915",
"0.6259171",
"0.62428397",
"0.62413883",
"0.62319404",
"0.62319404",
"0.62319404",
"0.62319404",
"0.62319404",
"0.62319404",
"0.62319404",
"0.62319404",
"0.62319404",
"0.62319404",
"0.62319404",
"0.62319404",
"0.62319404",
"0.62319404",
"0.62319404",
"0.6222483",
"0.6222483",
"0.61989355",
"0.61915106",
"0.6190771",
"0.61905706",
"0.6185875",
"0.61837566",
"0.61798304",
"0.6176368",
"0.617292",
"0.6166442",
"0.61614794",
"0.61539054",
"0.6125743",
"0.61231035",
"0.6120928",
"0.6120389",
"0.61166483",
"0.61087996",
"0.609885",
"0.60956204"
] | 0.0 | -1 |
========================================================================================= $ ./cyberdojo update ========================================================================================= | def update
# cyber-dojo.sh does actual [update]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update ; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update() end",
"def update\n #Nothing necessary\n end",
"def update\n \n end",
"def update()\n end",
"def update\n\t\t# Left empty intentionally.\n\tend",
"def update\r\n\r\n end",
"def update\r\n end",
"def update\r\n end",
"def update\r\n end",
"def update\r\n end",
"def update\n \n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n \t\n end",
"def update\n \t\n end",
"def update\n # Not generally used\n end",
"def update\n # Not generally used\n end",
"def update\r\n end",
"def update(...)\n end",
"def update; end",
"def update;end",
"def update\n install\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end"
] | [
"0.7019418",
"0.6942385",
"0.6942385",
"0.6942385",
"0.6942385",
"0.6942385",
"0.6942385",
"0.6942385",
"0.6942385",
"0.68431777",
"0.6765578",
"0.6751971",
"0.66792536",
"0.667858",
"0.6672684",
"0.65905493",
"0.65905493",
"0.65905493",
"0.65905493",
"0.65803975",
"0.6559888",
"0.6559888",
"0.6559888",
"0.6559888",
"0.6559888",
"0.6559888",
"0.6559888",
"0.6559888",
"0.6559888",
"0.6559888",
"0.6559888",
"0.6532789",
"0.6532789",
"0.6526257",
"0.6526257",
"0.6507387",
"0.64713097",
"0.64562535",
"0.64539117",
"0.64318746",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066",
"0.64221066"
] | 0.82577986 | 0 |
========================================================================================= $ ./cyberdojo clean ========================================================================================= | def clean
# TODO: help?
# TODO: check for unknown args
# Can give the following
# Error response from daemon: conflict: unable to delete cfc459985b4b (cannot be forced)
# image is being used by running container a7108a524a4d
command = "docker images -q -f='dangling=true' | xargs docker rmi --force"
run command
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _clean; end",
"def clean_up\n end",
"def clean_up\n end",
"def clean!\n Cleaner.remove_package(package)\n end",
"def clean()\n\t\tSystem::clean target()\n\tend",
"def clean()\n\t\tSystem::clean target()\n\tend",
"def pkg_clean\n sysprint \"#{@name} clean\"\n\n FileUtils::rm_rf(@objdir, :secure => true)\n end",
"def cleaners=(_arg0); end",
"def clean!; end",
"def clean\n end",
"def kernel_clean\n rm_f Dir[\"**/*.rbc\",\n \"**/.*.rbc\",\n \"kernel/**/signature.rb\",\n \"spec/capi/ext/*.{o,sig,#{$dlext}}\",\n \"runtime/**/load_order.txt\",\n \"runtime/platform.conf\"],\n :verbose => $verbose\nend",
"def cleanup; end",
"def cleanup; end",
"def cleanup; end",
"def cleanup; end",
"def clean\n #rm_r(srcdir)\n rm_r(blddir)\n #rm_r(libdir)\n end",
"def setup\n\t\t# Do nothing\n\tend",
"def setup\n\t\t# Do nothing\n\tend",
"def cleanup!; end",
"def cleanup!; end",
"def preclean_project\n # Clean-up non-useful files (if any)\n clean_msg = `make clean 2>&1`\n @log_file.puts \"\\nNettoyage du répertoire :\\n\\n#{clean_msg}\"\n \n # I want to be sure...\n FileUtils::rm_f Dir.glob(\"*.o\")\n FileUtils::rm_f Dir.glob(\"*~\")\n end",
"def clean_up\n puts \"Run the following commands to clean up your test data:\"\n puts \"oc delete pv --all\"\n puts \"oc delete pvc --all\"\n puts \"Deleting temporary test files\"\n `rm -rf #{$templates_path}/*`\nend",
"def clean_up(cmd = nil)\n FileUtils.rm(\n Dir.glob('build/{src,lib}.{rb,c,js}') +\n Dir.glob('build/ruby2d-opal.{rb,js}') +\n Dir.glob('build/app.c')\n )\n if cmd == :all\n puts \"cleaning up...\"\n FileUtils.rm_f 'build/app'\n FileUtils.rm_f 'build/app.js'\n FileUtils.rm_f 'build/app.html'\n FileUtils.rm_rf 'build/ios'\n FileUtils.rm_rf 'build/tvos'\n end\nend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def tidy_up\n return if DEBUG\n\n puts heading(\"Tidying up PWD\")\n\n FileUtils.remove(Dir[\"#{FileUtils.pwd}/bugsnag-*.tgz\"])\nend",
"def clean\n build addl_cmake_bld_args: '--target clean'\n end",
"def clean_whitespace(app)\n git_clean_filesystem\n\n # normalize_whitespace has already cleaned up whitespace if buildr_plus present\n unless File.exist?('vendor/tools/buildr_plus')\n extensions = %w(jsp sass scss xsl sql haml less rake xml html gemspec properties yml yaml css rb java xhtml rdoc txt erb gitattributes gitignore xsd textile md wsdl)\n full_filenames = %w(rakefile Rakefile buildfile Buildfile Gemfile LICENSE)\n\n files_to_dedupe_nl = Dir['etc/checkstyle/*.xml'].flatten + Dir['tasks/*.rake'].flatten + Dir['doc/*.md'].flatten + Dir['*.md'].flatten + Dir['config/*.sh'].flatten + %w(buildfile Gemfile README.md)\n\n files = full_filenames.collect {|file| Dir[\"**/#{file}\"]}.flatten + extensions.collect {|extension| Dir[\"**/*.#{extension}\"] + Dir[\"**/.#{extension}\"]}.flatten\n\n files.each do |f|\n next if /^vendor\\/.*/ =~ f\n next if /^node_modules\\/.*/ =~ f\n\n content = File.read(f)\n original_content = content.dup\n begin\n puts \"Fixing DOS EOL: #{f}\" if content.gsub!(/\\r\\n/, \"\\n\")\n puts \"Fixing Trailing whitespace: #{f}\" if content.gsub!(/[ \\t]+\\n/, \"\\n\")\n puts \"Fixing Double lines: #{f}\" if content.gsub!(/\\n\\n\\n/, \"\\n\\n\") if files_to_dedupe_nl.include?(f)\n content.gsub!(/[ \\r\\t\\n]+\\Z/, '')\n content += \"\\n\"\n rescue\n puts \"Skipping whitespace cleanup: #{f}\"\n end\n if content != original_content\n puts \"Fixing: #{f}\"\n File.open(f, 'wb') do |out|\n out.write content\n end\n end\n end\n end\n\n git_reset_index\n git_add_all_files\n if git_commit('Cleanup whitespace at EOL and EOF.', false)\n puts \"Whitespace cleaned up in #{app}\"\n end\n end",
"def dependencies; end",
"def dependencies; end",
"def dependencies; end",
"def clean(opts = {})\n self.lib.clean(opts)\n end",
"def cleanup\n end",
"def cleanup\n end",
"def cleanup\n end",
"def cleanup\n reshaper_orig_cleanup\n\n # remove some unwanted pages\n pages.delete_if do |page|\n path = page.destination(source)\n path =~ /shared\\/layouts/ or\n path =~ /shared\\/includes/\n end\n\n # remove some unwanted static files\n static_files.delete_if do |file|\n file.path =~ /shared\\/includes/ or\n file.path =~ /\\.styl$/ or # stylus files should be generated into site.css\n file.path =~ /readme\\./ # readme files are for github\n end\n\n end",
"def cleanup\n sh 'rm -rf _site'\n compass('clean')\nend",
"def initialize_clean\n self.clean_globs ||= %w[diff diff.txt TAGS ri deps .source_index\n *.gem **/*~ **/.*~ **/*.rbc]\n end",
"def clean()\n #strip all illegal content here. (scripts, shit that will break layout, etc.)\n end",
"def cleanup\n end",
"def cleanup\n end",
"def cleanup\n end",
"def cleanup\n end",
"def clean\n true\n end",
"def cookbook_clean_start\n end",
"def site_cleaner; end",
"def define_clean_tasks\n require 'rake/clean'\n end",
"def setup\n \n end",
"def setup\n \n end",
"def setup\n \n end",
"def setup\n \n end",
"def setup\n \n end",
"def setup\n \n end",
"def setup\n \n end",
"def setup\r\n end",
"def cleanup\r\n end",
"def generate_all\n copy_template_dir('layouts', 'layouts')\n copy_template_dir('content/bootstrap', 'content/bootstrap')\n copy_template_dir('content/content', 'content/content')\n delete_target_file('lib/default.rb')\n copy_template_dir('lib', 'lib')\n delete_target_file('Rules')\n copy_template_file('Rules', 'Rules')\n copy_template_file('.gitignore', '.gitignore')\n copy_template_file('cg_config.rb', 'cg_config.rb')\n copy_template_file('cg_config.rb_sample', 'cg_config.rb_sample')\n delete_target_file('content/stylesheet.css')\n delete_target_file('content/index.html')\n delete_target_file('layouts/default.html')\n create_empty_dir('content/images')\n end",
"def read_auto_clean_up; end",
"def clean!\n clean_installation if !local?\n end",
"def tear_down; end",
"def prepare\n #let's mark ourselves as dirty if any of our dependents are dirty\n if dependents.values.detect(&:'dirty?')\n mark_dirty\n end\n dependents.values.each {|child| child.prepare}\n\n if dirty?\n delete_clean_dir\n end\n\n #if the directory is there, we don't need to do anything\n if !File.exist?(clean_dir)\n Dir.chdir clean_dir_parent do\n mark_dirty\n if pristine_exists? && !pristine_dirty?\n copy_pristine_here\n else\n build_here\n end\n unmark_dirty\n\n copy_clean_to_pristine\n end\n end\n end",
"def clean_up(*args)\n # Remove all orphan Entries and Products\n SemiStatic::Entry.all{|e| e.destroy if e.tag.nil?}\n SemiStatic::Product.all{|p| p.destroy if p.entry.nil?}\n\n # Get rid of newsletter tags where the actual newsletter has been deleted\n SemiStatic::Tag.select{|t| t.newsletter_id.present? && t.newsletter.nil?}.each{|t| t.destroy}\n\n # There was a bug where some Entry.master_entry_id were not reset to nil, fix these\n SemiStatic::Entry.where.not(:master_entry_id => nil).each{|e| e.master_entry_id = nil; e.save;}\n end",
"def cleanup\n end",
"def cleanup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def cleanup\n jekyll('clean')\nend",
"def setup\n\n end",
"def setup\n\n end",
"def setup\n\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end"
] | [
"0.70924586",
"0.653744",
"0.653744",
"0.63694966",
"0.62678385",
"0.62678385",
"0.62313366",
"0.6133081",
"0.6132408",
"0.6130185",
"0.60131854",
"0.59317344",
"0.59317344",
"0.59317344",
"0.59317344",
"0.59108967",
"0.58496165",
"0.58496165",
"0.58354926",
"0.58354926",
"0.5826076",
"0.57876414",
"0.57826537",
"0.5760272",
"0.5760272",
"0.57492036",
"0.57492036",
"0.57492036",
"0.57492036",
"0.57492036",
"0.57492036",
"0.57492036",
"0.57492036",
"0.57492036",
"0.57492036",
"0.57492036",
"0.57492036",
"0.57492036",
"0.57492036",
"0.57492036",
"0.57492036",
"0.57492036",
"0.57492036",
"0.57492036",
"0.5746779",
"0.5733468",
"0.5728074",
"0.572787",
"0.572787",
"0.572787",
"0.5724757",
"0.572218",
"0.572218",
"0.572218",
"0.57106376",
"0.57104504",
"0.57100016",
"0.57080114",
"0.56813085",
"0.56813085",
"0.56813085",
"0.56813085",
"0.56769264",
"0.5645196",
"0.5642928",
"0.5639197",
"0.5630108",
"0.5630108",
"0.5630108",
"0.5630108",
"0.5630108",
"0.5630108",
"0.5630108",
"0.56252784",
"0.5614995",
"0.5597953",
"0.55936486",
"0.5582397",
"0.55751604",
"0.5570322",
"0.55441976",
"0.55392736",
"0.55392736",
"0.55381155",
"0.55381155",
"0.55381155",
"0.55381155",
"0.55381155",
"0.55381155",
"0.5531239",
"0.5530214",
"0.5530214",
"0.5530214",
"0.5528754",
"0.5528754",
"0.5528754",
"0.5528754",
"0.5528754",
"0.5528754",
"0.5528754",
"0.5528754"
] | 0.0 | -1 |
========================================================================================= $ ./cyberdojo down ========================================================================================= | def down
help = [
'',
"Use: #{me} down",
'',
"Stops and removes docker containers created with 'up'",
]
if ['help','--help'].include? ARGV[1]
show help
exit failed
end
# TODO: check for unknown args
# cyber-dojo.sh does actual [down]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def down; end",
"def down \r\n end",
"def down\n end",
"def down\n end",
"def down\n end",
"def down\n end",
"def down\n end",
"def down\n\n end",
"def down\n end",
"def shut_down\n end",
"def down\n help = [\n '',\n \"Use: #{me} down\",\n '',\n \"Stops and removes docker containers created with 'up'\",\n ]\n\n if ARGV[1] == '--help'\n show help\n exit succeeded\n end\n\n unless ARGV[1].nil?\n STDERR.puts \"FAILED: unknown argument [#{ARGV[1]}]\"\n exit failed\n end\n # cyber-dojo.sh does actual [down]\nend",
"def tear_down; end",
"def down\n send_message('APP_DOWN')\n end",
"def shut_down\n puts\n end",
"def teardown()\n # See 6. Disabling the gadget\n # ~ equiv to: echo \"\" > UDC\n System.write(File.join(path_prefix, \"UDC\"), \"\\n\")\n sleep(0.1)\n\n # See 7. Cleaning up\n System.delete(*Dir.glob(File.join(path_prefix, \"configs/*/*\")))\n System.delete(*Dir.glob(File.join(path_prefix, \"configs/*/strings/*\")))\n System.delete(*Dir.glob(File.join(path_prefix, \"configs/*\")))\n System.delete(*Dir.glob(File.join(path_prefix, \"functions/*\")))\n System.delete(*Dir.glob(File.join(path_prefix, \"strings/*\")))\n System.delete(path_prefix)\n end",
"def down\n Widget.update_all data_table_id: nil\n\n [DataTableDataset, DataRow, DataTable].each do |clazz|\n clazz.delete_all\n end\n end",
"def ls_down\n end",
"def down\n updown_command :detach\n end",
"def shutdown; end",
"def shutdown; end",
"def shutdown; end",
"def shutdown; end",
"def shutdown; end",
"def shutdown; end",
"def shutdown; end",
"def host_down(host)\n end",
"def down\n reverse_method_proxy(:down)\n\n true\n end",
"def debootstrap(options={})\n cmd = \"/usr/sbin/debootstrap\"\n\n options.each do |opt,val|\n unless opt.to_s =~ /dist|dest|mirror/\n cmd << \" --#{opt} #{val}\"\n end\n end\n\n cmd << \" #{options[:dist]}\"\n cmd << \" #{@config.ve_private}\"\n cmd << \" #{options[:mirror]}\"\n\n execute(cmd)\n\n # FIXME - Remove gettys from inititab automatically. We\n # Need a searchandreplace function first... :-)\n #\n # Util.searchandreplace( \"#{@config.ve_private}/etc/inittab\",\n # \"/^(?!#)(.*\\/sbin\\/getty)/\", \n # '#\\1')\n end",
"def shutDown\n\tputs \"[INFO] Shutting Down\"\n\t\n\tif( $webdriver_object )\n\t\tputs \"[INFO] Waiting For Chrome Driver To Quit\"\n\t\tbegin\n\t\t\tsleep( 5 )\n\t\t\t$webdriver_object.quit\n\t\trescue Timeout::Error, Errno::EINVAL, Errno::ECONNREFUSED, Errno::ECONNRESET, EOFError,\n \t Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => e\n \t puts \"[ERROR] Web Driver Error When Trying To Close.\" \n \tend\n\tend\n\n\tif( $jtd_server_pid != 0 ) \n\t\tProcess.kill \"TERM\", $jtd_server_pid\n\tend\n\n\tif( File.exists?( CONFIG_PATH ) )\n\t\tFile.delete( CONFIG_PATH )\n\tend\n\n\tif( File.exists?( PRELUDE_PATH ) )\n\t\tFile.delete( PRELUDE_PATH )\n\tend\nend",
"def down\n update_relative(:-)\n end",
"def shutdown\n return not_enabled unless Vedeu::Configuration.drb?\n\n stop if drb_running?\n\n Vedeu.trigger(:_exit_)\n\n Vedeu::Terminal.restore_screen\n end",
"def tear_down_suite()\n return \"deleted!\"\n end",
"def down\n # un-retext stuff\n @@renames.each do |rename|\n retext_tab(rename[:new_text], rename[:old_text])\n end\n\n task = Task.find_by_name('Update PSD')\n return if task.nil?\n\n # destroy tab\n Tab.find_by_task_id(task.id).destroy\n\n # remove from unlocked lists\n UnlockedTask.where(unlocked_task_id: task.id).destroy_all\n\n # destroy task\n task.destroy\n end",
"def shutdown\n return not_enabled unless Vedeu.config.drb?\n\n stop if drb_running?\n\n Vedeu.trigger(:_exit_)\n\n Vedeu::Terminal.restore_screen\n end",
"def shutdown\n factory.close\n Pacer.open_graphs.delete url\n end",
"def shut_down\n @shutdown_lock.synchronize {\n return if @shutting_down\n @shutting_down = true\n }\n die NO_ERROR\n end",
"def down\n @ui.logger.debug { \"Container Down: #{self.id}\" }\n\n self.node.alive? or return false\n\n please_wait(:ui => @ui, :message => format_object_action(self, 'Down', :red)) do\n\n self.lxc.stop\n\n # If we are in ephemeral mode...\n if self.is_ephemeral?\n\n # IMPORTANT NOTE:\n #\n # If we are using a non-memory backed COW filesystem for the\n # ephemeral clones we should destroy the container.\n #\n # If we are using a memory backed COW filesystem for the ephemeral\n # clones then it will be released when the container is stopped.\n self.persist and self.lxc.destroy(%(-f))\n end\n\n (self.state == :running) and raise ContainerError, \"The container failed to offline!\"\n\n do_provisioner_callbacks(self, :down, @ui)\n end\n\n true\n end",
"def teardown\n # Stopped working with chrome upgrade :(\n # errors = page.driver.browser.manage.logs.get(:browser)\n # if errors.present?\n # errors.each do |error|\n # unless error.to_s.include?(\"Can't perform a React state update on an unmounted component.\")\n # puts \"\\e[31m#{self.method_name} : #{error}\\e[0m\"\n # end\n # end\n # end\n # puts \"Finished #{self.method_name}\\u001b[0K\"\n end",
"def shutdown!; end",
"def shutdown!; end",
"def shutdown!; end",
"def shutdown\n end",
"def shutdown\n end",
"def shutdown\n end",
"def shutdown\n end",
"def step_down\n admin_client.database.command(\n replSetStepDown: 4, secondaryCatchUpPeriodSecs: 2)\n rescue Mongo::Error::OperationFailure => e\n # While waiting for secondaries to catch up before stepping down, this node decided to step down for other reasons (189)\n if e.code == 189\n # success\n else\n raise\n end\n end",
"def run_down(inst, host)\n if do_check(inst, host )\n begin\n do_down(inst, host)\n rescue StandardError => ex\n inst.info \"Got error: #{ex}, rollback #{@name}\"\n # do_down( inst, host )\n raise ex\n end\n else\n inst.info \"#{@name} has already be removed. skip it.\"\n end\n\n @deps.reverse.each do |dep|\n if !COMPONENT_MGR.get(dep).run_down( inst, host )\n return false\n end\n end\n\n !do_check(inst, host)\n end",
"def recycle; teardown; setup; end",
"def check_down; end",
"def shutdown\n yard_shutdown\n YARD::Templates::Engine.template_paths -=\n [File.dirname(__FILE__) + '/../../templates',File.dirname(__FILE__) + '/../../docserver']\n end",
"def down\n DRb.stop_service\n @status = :stopped\n @logger.info(\"slave stopped\")\n @logger.close\n end",
"def shutdown\nend",
"def delelte\n\n end",
"def down!\n @data[:state] = :down\n save!\n end",
"def shutdown\n runcmd 'shutdown'\n end",
"def cleanup\n _send_command(\"hosts -d\")\n _send_command(\"services -d\")\n _send_command(\"creds -d\")\n end",
"def down\n execute <<-SQL\n DROP TABLE event_registrations;\n SQL\n\n execute <<-SQL\n DROP TABLE members;\n SQL\n\n execute <<-SQL\n DROP TABLE events;\n SQL\n\n execute <<-SQL\n DROP TABLE treatment_logs;\n SQL\n\n execute <<-SQL\n DROP TABLE feeding_logs;\n SQL\n\n execute <<-SQL\n DROP TABLE employees;\n SQL\n\n execute <<-SQL\n DROP TABLE animals;\n SQL\n\n execute <<-SQL\n DROP TABLE tanks;\n SQL\n\n execute <<-SQL\n DROP TABLE habitats;\n SQL\n end",
"def down_dirs\n @down_dirs || Dbt::Config.default_down_dirs\n end",
"def test_proxy_down\n setup_plugin(build_proxy_config)\n\n transaction = nil\n toxiproxy.down do\n transaction = trigger_purchase('PLUGIN_FAILURE', 'Connection refused - Connection refused', 'Errno::ECONNREFUSED')\n end\n\n # Check the recovery behavior for the Janitor (no-op by default)\n check_purchase(transaction.payment_id, 'PLUGIN_FAILURE', 'Connection refused - Connection refused', 'Errno::ECONNREFUSED')\n end",
"def CleanUp\n\tallGroups.exec(\"killall ITGRecv >/dev/null 2>&1;\")\n\tallGroups.exec(\"killall ITGManager >/dev/null 2>&1; killall ITGSend >/dev/null 2>&1;\") \n\t#set the interfaces down\n @nodes.each do |node|\n\t\tif node.GetType()==\"R\"\n\t\t node.GetInterfaces().each do |ifn|\n\t\t # self.GetGroupInterface(node, ifn).down\n\t\t end\n\t\tend\n\t\t\n\t\tnode.GetInterfaces().each do |ifn| \n\t\t ifn.GetAddresses().each do |add|\n\t\t #info(\"Deleting address #{add.ip} from interface #{add.interface} on node #{node.id}\")\n\t\t Node(node.id).exec(\"ip addr del #{add.ip}/#{add.netmask} dev #{ifn.GetName()}\")\n\t\t end\n\t\tend\n\tend\n end",
"def shutdown\n @crawler.http.shutdown\n ::EM.stop\n end",
"def clean()\n rels = releases()\n rels.pop()\n\n unless rels.empty?\n rm = ['rm', '-rf'].concat(rels.map {|r| release_dir(r)})\n rm << release_dir('skip-*')\n cmd.ssh(rm)\n end\n end",
"def down(&block)\n disable\n yield\n ensure\n enable\n end",
"def teardown\r\n end",
"def down\n FhirEndpoint.all.each do |fhir_endpoint|\n reg_org = fhir_endpoint.registered_organization\n\n # If registered_organization exists, carry on. If not, then this is an orphaned fhir_endpoint record\n # that should be destroyed.\n if reg_org\n # Can't reset registered_organization_id to nil because then record is invalid.\n fhir_endpoint.update(organization_id: reg_org.organization_id)\n else\n fhir_endpoint.destroy\n end\n end\n end",
"def teardown; end",
"def teardown; end",
"def shutdown\n end",
"def teardown\n #commented this out because it is now unnecessary\n # @api = nil\n #GC.start\n @api.close_api\n # @server.close\n end",
"def teardown\n @fox_driver.quit\n end",
"def teardown\n puts \"tear down\"\n end",
"def teardown\r\n\t\t@vendors = nil\r\n\t\t@vendor = nil\r\n\t\t@model = nil\r\n\t\t@deviceView = nil\r\n\t\t@devicewWhatHas = nil\r\n\t\t@fetchTrees = nil\r\n\t\t@fetchSpecs = nil\r\n\tend",
"def shutdown\n\tend",
"def shutdown\n end",
"def dev() end",
"def stop_app_dashboard()\n Djinn.log_info(\"Shutting down AppDashboard\")\n AppDashboard.stop\n end",
"def down(service)\n find(service, 'DOWN')\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def gcwd; end",
"def update\n # cyber-dojo.sh does actual [update]\nend",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end",
"def teardown\n end"
] | [
"0.73952836",
"0.7173972",
"0.70723206",
"0.70723206",
"0.70723206",
"0.70723206",
"0.70723206",
"0.7046073",
"0.69961923",
"0.6559594",
"0.63943785",
"0.6382332",
"0.6205599",
"0.6124868",
"0.6044264",
"0.5999263",
"0.59576416",
"0.5844776",
"0.5711855",
"0.5711855",
"0.5711855",
"0.5711855",
"0.5711855",
"0.5711855",
"0.5711855",
"0.5678772",
"0.5651591",
"0.56429476",
"0.5641226",
"0.5604938",
"0.55472493",
"0.55421835",
"0.5520014",
"0.5518834",
"0.5517276",
"0.54884374",
"0.5482238",
"0.54713327",
"0.5458114",
"0.5458114",
"0.5458114",
"0.5445971",
"0.5445971",
"0.5445971",
"0.5445971",
"0.54418725",
"0.54211754",
"0.5420759",
"0.5417834",
"0.5378631",
"0.53684497",
"0.5345343",
"0.5341171",
"0.534112",
"0.53275806",
"0.5322839",
"0.53132546",
"0.5303458",
"0.52997774",
"0.52825534",
"0.5262992",
"0.52522033",
"0.5246667",
"0.5242585",
"0.52067393",
"0.5202341",
"0.5202341",
"0.51749045",
"0.5172357",
"0.5171793",
"0.5169288",
"0.5161767",
"0.5160561",
"0.5157005",
"0.51407206",
"0.51397914",
"0.5134971",
"0.51312476",
"0.51312476",
"0.51312476",
"0.51312476",
"0.51312476",
"0.51312476",
"0.51312476",
"0.51312476",
"0.51181686",
"0.5116076",
"0.5113171",
"0.5113171",
"0.5113171",
"0.5113171",
"0.5113171",
"0.5113171",
"0.5113171",
"0.5113171",
"0.5113171",
"0.5113171",
"0.5113171",
"0.5113171",
"0.5113171"
] | 0.66360325 | 9 |
========================================================================================= $ ./cyberdojo sh ========================================================================================= | def sh
help = [
'',
"Use: #{me} sh",
'',
"Shells into the cyber-dojo web server docker container",
]
if ['help','--help'].include? ARGV[1]
show help
exit failed
end
# TODO: check for unknown args
# TODO: check if server is running (as per [logs] command below)
# cyber-dojo.sh does actual [sh]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_result; result['run_cyber_dojo_sh']; end",
"def script; end",
"def script; end",
"def shell_api; end",
"def autorun; end",
"def cmd; end",
"def setup\r\n end",
"def standalone; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def run; end",
"def setup\n\n end",
"def setup\n\n end",
"def setup\n\n end",
"def main\n\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n \n end",
"def setup\n \n end",
"def setup\n \n end",
"def setup\n \n end",
"def setup\n \n end",
"def setup\n \n end",
"def setup\n \n end",
"def run\n end",
"def commands; end",
"def setup\n\n end",
"def setup\n\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def main\n end",
"def main; end",
"def command; end",
"def command; end",
"def command; end",
"def command; end",
"def command; end",
"def command; end",
"def run\n end",
"def update\n # cyber-dojo.sh does actual [update]\nend",
"def exec; end",
"def exec; end",
"def run\n \n end",
"def run\n \n end",
"def setup\n\t\tend",
"def setup\n\t\tend",
"def run\n end",
"def run\n end",
"def run\n end",
"def run\n end",
"def run\n end",
"def run\n end",
"def run\n end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def sh\n help = [\n '',\n \"Use: #{me} sh\",\n '',\n \"Shells into the cyber-dojo web server docker container\",\n ]\n\n if ARGV[1] == '--help'\n show help\n exit succeeded\n end\n\n unless ARGV[1].nil?\n STDERR.puts \"FAILED: unknown argument [#{ARGV[1]}]\"\n exit failed\n end\n\n unless web_server_running\n puts \"FAILED: cannot shell in - the web server is not running\"\n exit failed\n end\n # cyber-dojo.sh does actual [sh]\nend",
"def cli_path; end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def hd\n \n end"
] | [
"0.64778847",
"0.6431991",
"0.6431991",
"0.6363903",
"0.6352241",
"0.6308192",
"0.6244031",
"0.61987036",
"0.6172615",
"0.6172615",
"0.6172615",
"0.6172615",
"0.6172615",
"0.6172615",
"0.6172615",
"0.6172615",
"0.6172615",
"0.6150155",
"0.6150155",
"0.6150155",
"0.614543",
"0.61249834",
"0.61249834",
"0.61249834",
"0.61249834",
"0.61249834",
"0.61249834",
"0.6107236",
"0.6107236",
"0.6107236",
"0.6107236",
"0.6107236",
"0.6107236",
"0.6107236",
"0.6071938",
"0.6065881",
"0.60657287",
"0.60657287",
"0.6063962",
"0.6063962",
"0.6063962",
"0.6063962",
"0.6063962",
"0.6063962",
"0.6063962",
"0.6063962",
"0.6063962",
"0.6063962",
"0.6063962",
"0.6063962",
"0.6039689",
"0.6037959",
"0.5985898",
"0.5985898",
"0.5985898",
"0.5985898",
"0.5985898",
"0.5985898",
"0.5982931",
"0.59755534",
"0.5968191",
"0.5968191",
"0.59548384",
"0.59548384",
"0.59465444",
"0.59465444",
"0.5936744",
"0.5936744",
"0.5936744",
"0.5936744",
"0.5936744",
"0.5936744",
"0.5936744",
"0.593178",
"0.593178",
"0.593178",
"0.593178",
"0.593178",
"0.593178",
"0.593178",
"0.593178",
"0.593178",
"0.593178",
"0.593178",
"0.593178",
"0.593178",
"0.593178",
"0.593178",
"0.593178",
"0.593178",
"0.593178",
"0.593178",
"0.5922731",
"0.5918683",
"0.5850804",
"0.5850804",
"0.5850804",
"0.5850804",
"0.5850804",
"0.5802577"
] | 0.60688305 | 35 |
========================================================================================= $ ./cyberdojo logs ========================================================================================= | def logs
help = [
'',
"Use: #{me} logs",
'',
"Fetches and prints the logs of the web server (if running)",
]
if ['help','--help'].include? ARGV[1]
show help
exit failed
end
# TODO: check for unknown args
if `docker ps --quiet --filter "name=cdf-web"` == ''
puts "FAILED: Cannot show logs - the web server is not running"
exit failed
else
puts `docker logs cdf-web`
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def logs\n end",
"def logs\n\n end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log; end",
"def log\n end",
"def logger_output; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def logger; end",
"def druby_weblog_explain; \"Start the DRuby daemon for weblogs in your config.\"; end",
"def log_startup\n log_environment\n log_dispatcher\n log_app_name\n end",
"def logger ; @log end",
"def autoflush_log; end",
"def autoflush_log; end",
"def error_log\n end",
"def error_log\n end",
"def error_log\n end",
"def log\n Engines.log\n end",
"def log\n Engine.logger\n end",
"def logger; LOGGER; end",
"def logged?; false end",
"def logged?; false end",
"def log_file; end",
"def logs\n @runner.log\n end",
"def smartlog\n assert_in_repo\n SugarJar::Log.info(hub(\n 'log', '--graph', '--oneline', '--decorate', '--boundary',\n '--branches', \"#{most_master}..\"\n ).stdout.chomp)\n end",
"def log_writer; end",
"def log\n @log\n end",
"def logme\n\t\tlogger.debug \"============Main ApplicationController get calls at #{Time.now}\"\n\tend",
"def log()\n @log\n end",
"def log\n Lita.logger\n end",
"def log_file\n end",
"def log(message)\n puts \"[ dev/rails ] #{message}\"\nend",
"def debug_log(msg)\n Chef::Log.info(\"easybib_deploy_manager: #{msg}\")\nend",
"def logging_prefs; end",
"def log\n ::Deployable::Log.log\n end",
"def colorize_logging; end",
"def log\n advanced[:log]\n end",
"def verbose_logging; end",
"def log(msg)\n Serv::Log.info(Time.now.to_s+': '+msg+\"\\n\")\n end",
"def test_logging\n\t$MEMORY_LOG.debug \"Test Memory Log : DEBUG\"\n\t$TIME_LOG.debug \"Test Time Log : DEBUG\"\n\t$MEMORY_LOG.error \"Test Memory Log : ERROR\"\n\t$TIME_LOG.error \"Test Time Log : ERROR\" \nend",
"def devlog\n @@devlog ||= Logger.new(Rails.root.join(\"log/alipay-customers-webhook-#{Time.now.strftime('%Y-%m-%d')}.log\"))\n end",
"def dlog(*args)\n if development?\n $stdout.puts \"\\n================================================\\n\"\n for arg in args\n $stdout.puts arg\n $stdout.puts \"================================================\\n\"\n end\n end\n end",
"def log msg\n puts \"U:Service: #{msg}\"\n end",
"def log\n @deps.log\n end",
"def log_version_and_pid\n ::NewRelic::Agent.logger.debug(\"New Relic Ruby Agent #{NewRelic::VERSION::STRING} Initialized: pid = #{$$}\")\n end",
"def logger\n LOGGER\n end",
"def reopen_logs; end",
"def scraper_logger\n\n @@scraper_logger ||= Logger.new(\"#{Rails.root}/log/scraper.log\")\n\n end",
"def log\n LOGGER\n end",
"def help\n log_tips = \"\\nInitializing a Watirmark Logger:\nlogger = WatirmarkLog::Loger.new('optional_logger_name')\\n\nLogging methods:\nlogger.debug 'debug message' => 'DEBUG: debug message'\nlogger.info 'info message' => 'INFO: info message'\nlogger.warn 'warn message' => 'WARN: warn message'\nlogger.error 'error message' => 'ERROR: error message'\nlogger.turn_off = true => turns off all logging to stdout\\n\nLogging Hierarchy (debug < info < warn < error):\nlog.level = :info\nlogger.debug 'this message will NOT execute'\nlogger.info 'info message'\nlogger.warn 'warn message'\nlogger.error 'this message will AlWAYS execute'\\n\nLog Color Coding:\nlog.colors => {:black => :black, :red => :red,:green => :green, :yellow => :yellow, :blue => :blue, :magenta => :magenta, :cyan => :cyan, :white => :white}\nlog.debug_color = :red\nlog.debug 'debug message with color' => \" + \"DEBUG: debug message with color\".red + \"\n \\nCreating Log File:\nCreate a file where all log information is streamed to.\nThis is not dependent on log.level\nEx.\nlog.create_file\nlog.create_file 'file_name.log'\nlog.create_file 'file_name.log', directory\"\n puts log_tips\n end",
"def do_logging\n Log.debug \"debugging\"\n Log.info \"a piece of info\"\n Log.warn \"Danger, Will Robinson, danger!\"\n Log.error \"I dropped my Wookie! :(\"\n Log.fatal \"kaboom!\"\nend",
"def do_logging\n Log.debug \"debugging\"\n Log.info \"a piece of info\"\n Log.warn \"Danger, Will Robinson, danger!\"\n Log.error \"I dropped my Wookie! :(\"\n Log.fatal \"kaboom!\"\nend",
"def log(msg)\n SystemLog.fact(title: 'live-dynamo-controller', payload: msg)\n end",
"def log=(log); end",
"def setup\r\n $LOG = Logger.new(STDERR)\r\n $LOG.level = Logger::DEBUG\r\n @baseDir = File.dirname(__FILE__)\r\n @dataDir = File.join(@baseDir, \"data\")\r\n \r\n end",
"def request_log(request); end",
"def log(message)\n puts \"[ dev/docker ] #{message}\"\nend",
"def create_weblog_explain; \"Create a brand new weblog.\"; end",
"def log(msg)\n puts msg\n end",
"def initialize\n\t\t@@logger = OMLogger.getLogger(DataHelper.name)\n\tend",
"def logger\n $logger ||= Steno.logger(\"uhuru-repository-manager.runner\")\n end",
"def log_environment\n ::NewRelic::Agent.logger.info(\"Environment: #{NewRelic::Control.instance.env}\")\n end",
"def log_directory\n '/var/log/tokyotyrant'\n end",
"def log(*args); end",
"def log_stuff\r\n log.info(\"TestLogger is here to log stuff.\")\r\n log.warn(\"TestLogger is finishged logging. Be careful.\")\r\n end",
"def post_init\n # puts 'Syslogger initialized'\n end",
"def log\n @log ||= RainbowifyLogger.new\n end",
"def log=(logger); end",
"def setup_logger\n logger = Log4r::Logger.new('drbman')\n logger.outputters = Log4r::StdoutOutputter.new(:console)\n Log4r::Outputter[:console].formatter = Log4r::PatternFormatter.new(:pattern => \"%m\")\n logger.level = Log4r::DEBUG\n logger.level = Log4r::INFO\n logger.level = Log4r::WARN if @user_choices[:quiet]\n logger.level = Log4r::DEBUG if @user_choices[:debug]\n # logger.trace = true\n logger\n end",
"def KLDALog(text)\n $logFile.puts(\"======[KLDA Log] \" + text.to_s + \"======\\n\")\n end",
"def logger\n SpotifyWeb.logger\n end",
"def log\n @log || MPDClient.log\n end",
"def log_tags; end",
"def log_tags; end",
"def log_tags; end",
"def log\r\n false\r\n end",
"def blogs_weblog_explain; \"List your weblogs.\"; end",
"def self_log_file\n return File.join(File.dirname(__FILE__), 'sshsurveyor.log')\n end",
"def result_log\n end"
] | [
"0.74157083",
"0.72932535",
"0.7259012",
"0.7259012",
"0.7259012",
"0.7259012",
"0.7259012",
"0.7259012",
"0.7259012",
"0.7259012",
"0.71576166",
"0.7097548",
"0.70335436",
"0.70335436",
"0.70335436",
"0.70335436",
"0.70335436",
"0.70335436",
"0.70335436",
"0.70335436",
"0.70335436",
"0.70335436",
"0.70335436",
"0.70335436",
"0.70335436",
"0.70335436",
"0.70335436",
"0.70335436",
"0.70335436",
"0.70335436",
"0.70335436",
"0.676769",
"0.6711199",
"0.6673018",
"0.6500643",
"0.6500643",
"0.64688694",
"0.64688694",
"0.64688694",
"0.6451436",
"0.6449435",
"0.641455",
"0.6401613",
"0.6401613",
"0.63859147",
"0.63837296",
"0.6372502",
"0.6356324",
"0.63303745",
"0.631715",
"0.63066983",
"0.6295501",
"0.628501",
"0.62810564",
"0.62593687",
"0.6256865",
"0.62567604",
"0.62344545",
"0.622708",
"0.6225745",
"0.6161137",
"0.6151699",
"0.6144623",
"0.6143186",
"0.6112333",
"0.6064794",
"0.60432357",
"0.60407466",
"0.60360605",
"0.5998987",
"0.59886855",
"0.5973469",
"0.59707457",
"0.59707457",
"0.59688103",
"0.5963067",
"0.59565836",
"0.5925147",
"0.5911659",
"0.5911271",
"0.5910479",
"0.5908974",
"0.59077716",
"0.5904941",
"0.58987033",
"0.5894818",
"0.5888605",
"0.5879155",
"0.5877457",
"0.58683825",
"0.5867183",
"0.5848438",
"0.58468235",
"0.5846698",
"0.5831854",
"0.5831854",
"0.5831854",
"0.58288985",
"0.5828175",
"0.58268404",
"0.5820619"
] | 0.0 | -1 |
========================================================================================= $ ./cyberdojo up ========================================================================================= | def up_arg_ok(help, args, name)
vol = get_arg("--#{name}", args)
if vol.nil? || vol == 'default-' + name # handled in cyber-dojo.sh
return true
end
# TODO: edge case... this is not type checked
# cyber-dojo up --languages=default-exercises
if vol == ''
show help
puts "FAILED: missing argument value --#{name}=[???]"
return false
end
if !volume_exists?(vol)
show help
puts "FAILED: volume #{vol} does not exist"
return false
end
type = cyber_dojo_type(vol)
if type != name
show help
puts "FAILED: #{vol} is not a #{name} volume (it's #{type})"
return false
end
return true
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup\r\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def lybunt_setup\n end",
"def setup\n \n end",
"def setup\n \n end",
"def setup\n \n end",
"def setup\n \n end",
"def setup\n \n end",
"def setup\n \n end",
"def setup\n \n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n\n end",
"def setup\n\n end",
"def setup()\n end",
"def setup\n\n end",
"def setup\n\n end",
"def setup\n\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup; end",
"def setup\n\t\tend",
"def setup\n\t\tend",
"def autorun; end",
"def setup\n switch_dir\n end",
"def prepare\n FileUtils.mkdir_p(veewee_autoyast_dir) unless veewee_autoyast_dir.directory?\n FileUtils.cp(sources_dir.join(\"postinstall.sh\"), veewee_autoyast_dir)\n end",
"def update\n # cyber-dojo.sh does actual [update]\nend",
"def setup\n\t\t# Do nothing\n\tend",
"def setup\n\t\t# Do nothing\n\tend",
"def install_engine\n generate 'hydra:head -f'\n end",
"def setup; end",
"def setup\n # no setup\n\tend",
"def setup\r\n setup_wiki\r\n setup_host_map\r\n setup_host\r\n end",
"def up\n end",
"def setup\n true\n end",
"def setup\n Rails.logger.debug \"Setting up goon\"\n end",
"def do_setup; \"\" end",
"def globalSetup()\n # Build\n run(\"cd '#{Embedding::CODE_PATH}' && make clean && make\")\nend",
"def install\n \n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n # override this if needed\n end",
"def prepare_for_installation; end",
"def up\n send_message('APP_UP')\n end",
"def setup!\n if @options.has_key?(:home)\n @home = Pathname.new(@options[:home])\n elsif not ENV['COMMITSU_HOME'].nil?\n @home = Pathname.new(ENV['COMMITSU_HOME'])\n else\n @home = Environment.default_home\n end\n load_config!\n @gui = @options.has_key?('gui')\n if @options.has_key?('issuetracker')\n begin\n @tracker = Commitsu::Trackers.get(@options['issuetracker'],self)\n rescue LoadError => le\n puts \"Unable to load tracker. Gem not found: #{le}\"\n @tracker = Commitsu::Trackers.none\n end\n else\n @tracker = Commitsu::Trackers.none\n end\n end",
"def setup\n add_standard_properties\n #\n create_banner\n create_standard_options\n create_advanced_options\n create_mode_options\n create_application_options\n create_feature_options\n create_tail_options\n #\n parse_options\n load_config_configuration\n create_result_directory\n load_results_archive\n end",
"def setup!\n return self if @app_is_setup\n puts \"Hatchet setup: #{name.inspect} for #{repo_name.inspect}\"\n create_app\n set_labs!\n # heroku.put_config_vars(name, 'BUILDPACK_URL' => @buildpack)\n buildpack_list = @buildpacks.map {|pack| { buildpack: pack }}\n platform_api.buildpack_installation.update(name, updates: buildpack_list)\n @app_is_setup = true\n self\n end",
"def setup\n\n setup_path\n save_application_details\n add_jvm_args\n rename_server_instance\n\n \"/bin/bash ./#{SETUP_ENV_SCRIPT}\"\n end",
"def setup\n make_config\n make_users_file\n end",
"def setup()\n create_directories\n end",
"def setup\n copy_definitions\n package_agent\n end",
"def setup\n copy_definitions\n package_agent\n end",
"def setup(*args) ; end",
"def bootstrap\n @commands += [\n \"export HOME=`pwd`\" ,\"\\n\",\n \"wget --no-check-certificate https://raw.githubusercontent.com/bcwik9/ScriptsNStuff/master/setup_dev_server.sh && bash setup_dev_server.sh\", \"\\n\"\n ]\n end",
"def setup\n FileUtils.remove_dir(File.expand_path(TEST_DIR), true)\n @wd = WebDump.new :base_dir => TEST_DIR\n end",
"def setup\n\n setup_path\n save_application_details\n add_jvm_args\n rename_server_instance\n\n \"/bin/sh ./#{SETUP_ENV_SCRIPT}\"\n end",
"def setup\n ''\n end",
"def install\n end",
"def install\n end",
"def docker_updb\n rootFolder = Dir.pwd\n\n # execute updb cmds for each endpoints\n @endpoints.each do |ep|\n framework = ep[:frameworkname]\n Dir.chdir(\"#{rootFolder}/#{ep[:path]}\")\n\n # execute framework specific updb\n case framework\n when /Symfony/\n system \"docker pull nextdeploy/#{framework.downcase}console\"\n system \"docker run --net=#{@projectname}_default -v=#{Dir.pwd}:/var/www/html nextdeploy/#{framework.downcase}console doctrine:schema:update --force\"\n when /Drupal/\n system \"docker pull nextdeploy/drush\"\n system \"docker run --net=#{@projectname}_default -v=#{Dir.pwd}:/app nextdeploy/drush -y updb\"\n end\n end\n Dir.chdir(rootFolder)\n\n docker_cc\n end",
"def setup!\n drb_input!\n drb_retrieve_output!\n drb_store_output!\n drb_restart!\n drb_start!\n drb_status!\n drb_stop!\n end",
"def setup\n clear_db\n\n @db = Wgit::Database.new\n end",
"def setup\n # noop\n end",
"def pre_install; end",
"def run!\n $config = @config.dup\n\n require \"configure_db\"\n\n db = Uhuru::RepositoryManager::ConfigureDb.connect logger\n\n require 'main'\n\n # Only load main class after configurations are initialized and we're ready to run.\n webui = Uhuru::RepositoryManager::RepositoryManager.new\n\n # check if tables exists in db and create them if not\n # when problems are encountered stops the app\n table_creator = Uhuru::RepositoryManager::CreateTables.new db\n begin\n unless table_creator.exist_tables?\n table_creator.create_tables\n end\n\n master_mirror = Uhuru::RepositoryManager::Model::Mirrors.get_mirrors(:name => 'Master').first\n\n if master_mirror\n Uhuru::RepositoryManager::Model::Mirrors.update(master_mirror,\n {\n :description => $config[:master_mirror][:description],\n :hostname => $config[:master_mirror][:domain],\n :status => $config[:master_mirror][:status]\n })\n else\n Uhuru::RepositoryManager::Model::Mirrors.create('Master', $config[:master_mirror][:description], $config[:master_mirror][:domain], $config[:master_mirror][:status], \"master\")\n end\n rescue => e\n puts \"ERROR: Database connection problems: #{e.message} - #{e.backtrace}\"\n exit 1\n end\n\n # creates default admin user if doesn't exist\n # generates ssh keys and adds them in db\n # and adds it to password files\n begin\n master_mirror_user_sys = $config[:master_mirror][:blobstore_options][:user]\n administrator_email = $config[:repository_manager][:administrator_email]\n\n if Uhuru::RepositoryManager::Model::Users.get_users(:username => administrator_email).count == 0\n Uhuru::RepositoryManager::HtpasswdHandler.create_password(administrator_email, \"admin\")\n\n home_path = File.join($config[:path_home_user], master_mirror_user_sys)\n\n `test -d \"#{home_path}\" || ( mkdir -p #{home_path} ; chown #{master_mirror_user_sys}.#{master_mirror_user_sys} #{home_path} ; chmod 0700 #{home_path} )`\n\n admin_user = Uhuru::RepositoryManager::Model::Users.create(administrator_email, \"Admin\", \"Account\", \"Uhuru Software\", \"urm administrator\", \"United States\", \"Redmond\", nil, nil, true, master_mirror_user_sys)\n Uhuru::RepositoryManager::Model::Users.update(admin_user, {:active => true})\n end\n\n master_mirror_user_home_path = `cat /etc/passwd|grep -w ^#{master_mirror_user_sys}|cut -f 6 -d \\:`\n\t\t master_mirror_user_home_path = master_mirror_user_home_path.gsub(\"\\n\",'')\n\n public_key = `cat #{master_mirror_user_home_path}/.ssh/id_rsa.pub`\n unless public_key\n `sudo -u #{master_mirror_user_sys} test -e #{master_mirror_user_home_path}/.ssh/id_rsa || ssh-keygen -f #{master_mirror_user_home_path}/.ssh/id_rsa -N ''`\n public_key = `cat #{master_mirror_user_home_path}/.ssh/id_rsa.pub`\n `echo \"#{public_key}\" >>#{master_mirror_user_home_path}/.ssh/authorized_keys ; chmod 0600 #{master_mirror_user_home_path}/.ssh/authorized_keys ; chown #{master_mirror_user_sys}.#{master_mirror_user_sys} #{master_mirror_user_home_path}/.ssh/authorized_keys`\n end\n\n admin_user = Uhuru::RepositoryManager::Model::Users.get_users(:username => administrator_email).first\n if admin_user.access_keys.count == 0\n Uhuru::RepositoryManager::Model::AccessKeys.create(public_key, \"admin local key\", admin_user)\n end\n\n rescue => ex\n puts \"ERROR: Unable to create default admin user. #{ex.message} #{ex.backtrace}\"\n end\n\n # create ucc public and private groups if doesn't exist\n ucc_public = \"#{Uhuru::RepositoryManager::FilesystemHandler.get_ucc_group}_public\"\n ucc_private = \"#{Uhuru::RepositoryManager::FilesystemHandler.get_ucc_group}_private\"\n groups = `getent group #{ucc_public} #{ucc_private}`\n\n if !groups.include?(ucc_public)\n ucc_path = File.join($config[:master_mirror][:blobstore_options][:blobstore_path], ucc_public)\n Uhuru::RepositoryManager::FilesystemHandler.add_group(ucc_public, ucc_path)\n end\n\n if !groups.include?(ucc_private)\n ucc_path = File.join($config[:master_mirror][:blobstore_options][:blobstore_path], ucc_private)\n Uhuru::RepositoryManager::FilesystemHandler.add_group(ucc_private, ucc_path)\n end\n\n app = Rack::Builder.new do\n use Rack::CommonLogger\n\n map \"/\" do\n run webui\n end\n\n end\n\n @thin_server = Thin::Server.new('0.0.0.0', @config[:port], app)\n trap_signals\n\n @thin_server.threaded = true\n @thin_server.start!\n end"
] | [
"0.6569636",
"0.6501257",
"0.6501257",
"0.6501257",
"0.6501257",
"0.6501257",
"0.6501257",
"0.6501257",
"0.6501257",
"0.6501257",
"0.6501257",
"0.6501257",
"0.6501257",
"0.6437355",
"0.64166605",
"0.64166605",
"0.64166605",
"0.64166605",
"0.64166605",
"0.64166605",
"0.64166605",
"0.6380777",
"0.6380777",
"0.6380777",
"0.6380777",
"0.6380777",
"0.6380777",
"0.6373805",
"0.6373805",
"0.6298619",
"0.628876",
"0.628876",
"0.628876",
"0.62839895",
"0.62839895",
"0.62839895",
"0.62839895",
"0.62839895",
"0.6253574",
"0.6253574",
"0.6253574",
"0.6253574",
"0.6253574",
"0.6253574",
"0.6253574",
"0.6253574",
"0.6253574",
"0.6253574",
"0.6253574",
"0.6253574",
"0.6253574",
"0.6253574",
"0.6253574",
"0.6253574",
"0.6253574",
"0.6253574",
"0.6253574",
"0.62412125",
"0.62412125",
"0.6229196",
"0.61462086",
"0.60565925",
"0.603424",
"0.60031915",
"0.60031915",
"0.59956604",
"0.5974177",
"0.59713817",
"0.5957293",
"0.5956975",
"0.59516937",
"0.5949281",
"0.5929778",
"0.59147286",
"0.5875366",
"0.58475333",
"0.58475333",
"0.5835665",
"0.58245075",
"0.57910484",
"0.5789732",
"0.5776555",
"0.57758284",
"0.5771553",
"0.5737617",
"0.5735607",
"0.57341933",
"0.57341933",
"0.5730681",
"0.5717972",
"0.5712835",
"0.57016057",
"0.56929255",
"0.56811607",
"0.56811607",
"0.56749827",
"0.5666994",
"0.5659776",
"0.56597596",
"0.5641488",
"0.5626816"
] | 0.0 | -1 |
========================================================================================= $ ./cyberdojo volume ========================================================================================= | def volume
help = [
'',
"Use: #{me} volume [COMMAND]",
'',
'Manage cyber-dojo setup volumes',
'',
'Commands:',
minitab + 'create Creates a new volume',
minitab + 'rm Removes a volume',
minitab + 'ls Lists the names of all volumes',
minitab + 'inspect Displays details of a volume',
minitab + "pull Pulls the docker images inside a volume's manifest.json files",
'',
"Run '#{me} volume COMMAND --help' for more information on a command",
]
case ARGV[1]
when 'create' then volume_create
when 'rm' then volume_rm
when 'ls' then volume_ls
when 'inspect' then volume_inspect
when 'pull' then volume_pull
else show help
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_volume\n @volume\n end",
"def volume \n puts \"The volume is #{@length * @width * @height}\"\n end",
"def volume; self.class.volume; end",
"def volume; property('volume'); end",
"def volume\n @length * @width * @depth\n end",
"def get_volume()\n return(get_cmd('AG;',0.1,0.5,3).gsub(/^AG/,'').gsub(/;$/,'').to_i)\nend",
"def series_volume\n end",
"def volume (l, w, h)\n\tl * w * h\nend",
"def volume_calc(length,width,height)\n volume = length * width * height\n end",
"def volume\n return @width * @height / @depth\n end",
"def volume\n app.speakers.ID(@id).volume.get\n end",
"def volume _value, _abs=0\n send_cmd(\"volume #{_value} #{_abs}\")\n end",
"def set_bunny_volume vol\n @exch.publish(vol.to_i) \n end",
"def volume(options)\n options[:width] * options[:height] * options[:depth]\nend",
"def do_volume(num)\n\n fail CvlcClientError, \"The 'volume' command requires an integer value between 0 and 300...\" unless num.between?(0, 300)\n do_command(\"requests/status.json?command=volume&val=#{num}\")\n sleep STATUS_PAUSE\n return pretty_status(current_status)\n end",
"def sfx_volume\n return @sfx_volume\n end",
"def volume(x)\n\t\tsynchronized do\n\t\t\[email protected] \"volume #{x}\"\n\t\tend\n\tend",
"def set_volume(volume)\n puts \"Setting volume to #{volume}\" if $verbose\n v='AG'+(('000'+volume.to_s)[-3..-1])+';'\n puts v if $verbose\n ret=send_cmd(v,'AG;',v,0.5,1.5,3)\n if(ret)\n return(ret.gsub(/^AG/,'').gsub(/;$/,'').to_i)\n else\n return(nil)\n end\nend",
"def volume\n @cr[0xe] & 0x0f\n end",
"def volume\n `#{@sound}.volume`\n end",
"def music_volume\n return @music_volume\n end",
"def show_vol()\n\t\tvm = get_vol\n\t\[email protected]=$muted_colors[vm[:mute]]\n\t\[email protected]='Volume'\n\t\[email protected] += ' (Muted)' if vm[:mute]\n\t\[email protected]=vm[:vol]\n\t\[email protected]=5\n\tend",
"def volume\n return (4.0/3.0) * Math::PI * self.radius**3\n end",
"def volume\n player_iface['Volume']\n end",
"def volume\n $redis_pool.with { |redis| redis.get('warble:volume').to_i }\n end",
"def musicVolume \n \"musicVolume\" \n end",
"def volume\n a, b, c, d = @points\n ((a - d) % ((b - d) * (c - d))) / 6\n end",
"def volume\n return nil if dimension_u.nil? || dimension_v.nil? || dimension_w.nil?\n (dimension_u * dimension_v * dimension_w) / 1_000_000_000.0\n end",
"def current_volume(volume)\n\t\t\"The current volume is #{@volume}\"\n\tend",
"def soundVolume \n \"soundVolume\" \n end",
"def get_volume\n\n # get the keyword value of \"SHAPE\"\n shape = get_keyword_value(\"SHAPE\")\n\n # if the shape value returns nil, or is defined as \"NO-SHAPE\", the volume is\n # given directly\n if ( shape == nil || shape == \"NO-SHAPE\")\n volume = get_keyword_value(\"VOLUME\")\n volume = volume.to_f\n return volume\n\n # if the shape is defined as a \"BOX\", the values for height, width, and\n # depth are given, from which you can get the volume\n elsif ( shape == \"BOX\" )\n height = get_keyword_value(\"HEIGHT\")\n width = get_keyword_value(\"WIDTH\")\n depth = get_keyword_value(\"DEPTH\")\n height = height.to_f\n width = width.to_f\n depth = depth.to_f\n return height * width * depth\n\n # if the shape is defined as a \"POLYGON\", the get_area is defined as the area\n # of the polygon, and the height is given by the value of \"HEIGHT\"\n elsif ( shape == \"POLYGON\")\n height = getKeywordvalue(\"HEIGHT\")\n temp = get_keyword_value(\"POLYGON\")\n height = height.to_f\n @polygon.utype = temp\n return @polygon.get_area * height\n else\n raise \"Error: The volume could not be evaluated. Please check inputs\\n \"\n\n end\n\n end",
"def volume(x, y, z)\r\n x * y * z\r\nend",
"def volume(x, y, z)\n x * y * z\nend",
"def sound_volume\n @ole.SoundVolume\n end",
"def vol_decr\n %x[pactl set-sink-input-volume #{self.input_id} -- -5%]\n new_vol = vol_perc - 5\n new_vol = 0 if new_vol < 0\n @args[:props][\"volume\"] = \"0: #{new_vol}% 1: #{new_vol}%\"\n return nil\n end",
"def get_volume\n return get_floor_height.to_f * get_area.to_f\n end",
"def volume(level = nil)\n level.nil? ? Integer(connection.write(\"volume\", false)) : connection.write(\"volume #{Integer(level)}\")\n rescue ArgumentError\n level.nil? ? 0 : nil\n end",
"def set_volume\n @volume = Volume.find(params[:id])\n end",
"def set_volume\n @volume = Volume.find(params[:id])\n end",
"def cVolume r,l,m\n return 0 if r == 0\n z = r-m\n l*(r*r * Math.acos(z/r)-z*(2*r*m - m*m)**0.5)\nend",
"def total_volume\n quantity * Item.find(item_id).volume\n end",
"def volume\n { bid: bid_volume, ask: ask_volume }\n end",
"def volume_increase(button)\n\t\t if @volumes < 10\n\t\t\t@volumes += 1\n\t\t\tputs \"press #{button}! leaves volume bar level at: #{@volumes}.\"\n\t\telse\n\t\t\tputs \"Volume Max!...Pls reduce Volume \"\n\t\tend\n\tend",
"def volume_ft3\n self.volume\n end",
"def volume(level = nil)\n return Integer(connection.write(\"volume\", false)) if level.nil?\n connection.write(\"volume #{Integer(level)}\")\n rescue ArgumentError\n level.nil? ? 0 : nil\n end",
"def volume(level = nil)\n return Integer(connection.write(\"volume\", false)) if level.nil?\n connection.write(\"volume #{Integer(level)}\")\n rescue ArgumentError\n level.nil? ? 0 : nil\n end",
"def traded_volume\n data.fetch('tradedVolume')\n end",
"def volume(amount: T.unsafe(nil)); end",
"def volume_inspect\n help = [\n '',\n \"Use: #{me} volume inspect VOLUME\",\n '',\n 'Displays details of the named cyber-dojo volume',\n ]\n # asked for help?\n vol = ARGV[2]\n if [nil,'help','--help'].include? vol\n show help\n exit failed\n end\n\n # TODO: check for unknown args\n\n exit_unless_is_cyber_dojo_volume(vol, 'inspect')\n\n command =\n [\n 'docker run',\n '--rm',\n \"--user=root\",\n \"--volume=#{vol}:/data:#{read_only}\",\n '--volume=/var/run/docker.sock:/var/run/docker.sock',\n \"#{cyber_dojo_hub}/web:#{docker_version}\",\n \"sh -c 'cd /usr/src/cyber-dojo/cli && ./volume_inspect.rb /data'\"\n ].join(space=' ')\n\n print run(command)\nend",
"def radioVolume \n \"radioVolume\" \n end",
"def volume_type\n return @volume_type\n end",
"def volume_params\n params[:volume]\n end",
"def set_volume(volume)\n %x{#{echo()} volume #{volume} 1 > #{fifo()}} if running?\n end",
"def populate_volume(server)\n server.spot_check_command(\" echo \\\"blah blah blah\\\" > #{@mount_point}/data.txt\")\n end",
"def series_volume(field = nil)\n find_record_value(field, clean: false) if field\n end",
"def set_Volume(value)\n set_input(\"Volume\", value)\n end",
"def sfx_volume=(value)\n value = value.to_i.abs\n @sfx_volume = value < 101 ? value : 100\n end",
"def volume_size\n # If not user-specified, I'm using a fudge factor of 1.5 on the volume size -- arbitrarily chosen\n @volume_size || (`du -x #{volume_to_bundle}`.split(/\\n/)[-1].split[0].to_f * 1.5 / 1024).ceil\n end",
"def db= value\n code = if value > 12.0\n '185VL'\n elsif value < -80.0\n '000VL'\n else\n sprintf(\"%03dVL\", (value/0.5 + 161).to_int)\n end\n\n return decode_volume(@vsx.cmd(code, /^VOL(\\d+)$/).shift)\n end",
"def volume_ls\n help = [\n '',\n \"Use: #{me} volume ls\",\n '',\n 'Lists the names of all cyber-dojo volumes',\n '',\n minitab + '--quiet Only display volume names'\n ]\n\n if ['help','--help'].include? ARGV[2]\n show help\n exit failed\n end\n\n # There is currently no [--filter label=LABEL] option on [docker volume ls]\n # https://github.com/docker/docker/pull/21567\n # So I have to inspect all volumes. Could be slow if lots of volumes.\n\n names = run(\"docker volume ls --quiet\").split\n names = names.select{ |name| cyber_dojo_volume?(name) }\n\n if ARGV[2] == '--quiet'\n names.each { |name| puts name }\n else\n types = names.map { |name| cyber_dojo_type(name) }\n urls = names.map { |name| cyber_dojo_label(name) }\n\n headings = { :name => 'NAME', :type => 'TYPE', :url => 'SRC' }\n\n gap = 3\n max_name = ([headings[:name]] + names).max_by(&:length).length + gap\n max_type = ([headings[:type]] + types).max_by(&:length).length + gap\n max_url = ([headings[:url ]] + urls ).max_by(&:length).length + gap\n\n spaced = lambda { |max,s| s + (space * (max - s.length)) }\n\n name = spaced.call(max_name, headings[:name])\n type = spaced.call(max_type, headings[:type])\n url = spaced.call(max_url , headings[:url ])\n puts name + type + url\n names.length.times do |n|\n name = spaced.call(max_name, names[n])\n type = spaced.call(max_type, types[n])\n url = spaced.call(max_url , urls[n])\n puts name + type + url\n end\n end\nend",
"def get_volume(volume_id)\n get(\"cloud-instances/#{guid}/volumes/#{volume_id}\")\n end",
"def master_volume=(value)\n self.music_volume = value\n self.sfx_volume = value\n end",
"def test_volume_of_sphere()\n result = volume_of_sphere(2)\n assert_equal(33,result)\n end",
"def get_vol\n\t\tIO::popen('amixer sget Master') do |f|\n\t\t\tf.read.scan(/Front Left.*?\\[(\\d+)%\\].*?\\[(on|off)\\]\\n/) do |pc, on_or_off|\n\t\t\t\treturn {\n\t\t\t\t\t:vol => pc.to_i,\n\t\t\t\t\t:mute => 'off' == on_or_off\n\t\t\t\t}\n\t\t\tend\n\t\tend\n\t\treturn { :vol => -1, :mute => false }\n\tend",
"def check_volume(volume) \n # Default warning_limit\n warning_limit=@warning_limit\n # Default critical_limit\n critical_limit=@critical_limit\n # Default nobackup_status\n nobackup_status=@nobackup_status\n\n puts \"Checking volume: #{volume}\" if @verbose\n\n if @objects.has_key?(volume) and not @objects[volume].has_key?(:skip)\n vol=DuplicityVolume.new(volume,@config_values,@objects[volume])\n vol.debug=@debug\n vol.testing=@testing\n vol.run(\"col\")\n\n puts \" Checking vol: #{volume} last backup: #{vol.last_backup}\" if @verbose\n warning_limit=@objects[volume][:warning_limit] if @objects[volume].has_key? :warning_limit\n\t puts \" warning_limit for #{volume} is #{warning_limit}\" if @debug\n critical_limit=@objects[volume][:critical_limit] if @objects[volume].has_key? :critical_limit\n\t puts \" critical_limit for #{volume} is #{critical_limit}\" if @debug\n nobackup_status=@objects[volume][:nobackup_status] if @objects[volume].has_key? :nobackup_status\n\t puts \" nobackup_status for #{volume} is #{nobackup_status}\" if @debug\n # Check backup age\n check_time=Time.now\n if vol.last_backup\n if check_time < vol.last_backup + warning_limit.to_i\n incstatus(\"OK\")\n elsif check_time >= vol.last_backup + warning_limit.to_i and check_time < vol.last_backup + critical_limit.to_i\n @short+=\"#{vol.name} OLD, \"\n @long+=\"#{vol.name} is too OLD\\n\"\n incstatus(\"WARNING\")\n elsif check_time >= vol.last_backup + critical_limit.to_i\n @short+=\"#{vol.name} OLD, \"\n @long+=\"#{vol.name} is too OLD\\n\"\n incstatus(\"CRITICAL\")\n end\n else\n @short+=\"no backups for #{vol.name}, \"\n @long+=\"No backups found for volume #{vol.name}\\n\"\n incstatus(nobackup_status)\n end\n else\n puts \"ERROR: Volume #{volume} is not defined\"\n return false\n end\n end",
"def vd(value=1)\n @music.vd(value.to_i)\n end",
"def set_actual_volume\n @actual_volume = ActualVolume.find(params[:id])\n end",
"def volume=(vol)\n `#{@sound}.volume = #{vol}`\n end",
"def total_volume(order)\n volume = 0\n order.line_items.each do |line_item|\n line_item.variant.volume ? volume += (line_item.quantity * line_item.variant.volume) : 0\n end\n volume\n end",
"def find_volume_of_cube (length, width, height, lwh)\n puts \"The volume is #{length}*#{width}*#{height}= #{lwh}\"\nend",
"def vol_incr\n %x[pactl set-sink-input-volume #{self.input_id} -- +5%]\n new_vol = vol_perc + 5\n new_vol = 100 if new_vol > 100\n @args[:props][\"volume\"] = \"0: #{new_vol}% 1: #{new_vol}%\"\n return nil\n end",
"def volume(result)\n return result['trades']['entries'].collect do |data|\n volume = data[1].to_f\n end\n end",
"def init_ebs_volumes\n @@client.describe_volumes.volumes\n end",
"def calculate_volume(units)\n units.reduce(0) do |sum, unit|\n volume = unit.volume\n raise GameLogicError.new(\"#{unit} does not have volume!\") \\\n if volume.nil?\n\n sum + volume\n end\n end",
"def test_volume_of_cube()\n first_volume = cube_volume(1)\n second_volume = cube_volume(3)\n third_volume = cube_volume(5)\n assert_equal(1, first_volume)\n assert_equal(27, second_volume)\n assert_equal(125, third_volume)\n end",
"def volume_reduce(button)\n\t\tif @volumes > 0\n\t\t\t@volumes -= 1\n\t\t\tputs \"press #{button}! leaves volumes bar level at: #{@volumes}.\"\n\t\telse\n\t\t\tputs \" Volume bar level is at 0\"\n\t\tend\n\tend",
"def get_road_volume\n @volumes_east = RoadVolume.get_road_volume('East')\n @volumes_west = RoadVolume.get_road_volume('West')\n end",
"def index\n @actual_volumes = ActualVolume.all\n end",
"def tankvol(h, d, vt)\n\nend",
"def check_volumes\n \n # ask tech if there is enough volume\n vol_checking = show do \n title \"Checking Volumes\"\n operations.each do |op|\n select [\"Yes\", \"No\"], var: \"#{op.input(INPUT).item.id}_stockvol\", label: \"Does #{op.input(INPUT).item.id} have at least #{op.temporary[:stock_vol].round(2)} uL?\", default: 0\n select [\"Yes\", \"No\"], var: \"#{op.input(INPUT).item.id}_watervol\", label: \"Does #{op.input(INPUT).item.id} have at least #{op.temporary[:water_vol].round(2)} uL?\", default: 0\n end\n end\n \n operations.each do |op|\n if vol_checking[\"#{op.input(INPUT).item.id}_stockvol\".to_sym] == \"No\" || vol_checking[\"#{op.input(INPUT).item.id}_watervol\".to_sym] == \"No\"\n op.error :not_enough_volume, \"Not enough volume for this plasmid\"\n end\n end\n \n end",
"def test_volume_of_cube()\n first_volume = volume_of_a_cube (3) \n assert_equal(27,first_volume)\n end",
"def volume_pull\n help = [\n '',\n \"Use: #{me} volume pull VOLUME\",\n '',\n 'Pulls all the docker images named inside the cyber-dojo volume'\n ]\n vol = ARGV[2]\n if [nil,'help','--help'].include? vol\n show help\n exit failed\n end\n\n exit_unless_is_cyber_dojo_volume(vol, 'pull')\n\n command =\n [\n 'docker run',\n '--rm',\n '--tty',\n \"--user=root\",\n \"--volume=#{vol}:/data:#{read_only}\",\n '--volume=/var/run/docker.sock:/var/run/docker.sock',\n \"#{cyber_dojo_hub}/web:#{docker_version}\",\n \"sh -c 'cd /usr/src/cyber-dojo/cli && ./volume_pull.rb /data'\"\n ].join(space=' ')\n\n system(command)\nend",
"def volume_adjustment\n @ole.VolumeAdjustment\n end",
"def volume_of_sphere(radius)\n return 3.14 * 4 / 3 * (radius ** 3)\n return volume\nend",
"def test_volume_of_cube()\n volume = volume_of_cube(3)\n assert_equal(27, volume)\n end",
"def test_volume_of_cube()\n volume = volume_of_cube(3)\n assert_equal(27, volume)\n end",
"def metric_volume(amount: T.unsafe(nil)); end",
"def peak_volume(type=TagLib::ID3v2::RelativeVolumeFrame::MasterVolume)\n end",
"def volumes\n client = Aws::EC2::Client.new\n client.describe_volumes({\n filters: [{\n name: \"tag:backup\",\n values: [\"true\"]\n }]\n }).volumes\nend",
"def set_volume\n @volume = services.block_storage.get_volume(params[:id])\n end",
"def test_volume_of_cube()\n result = volume_of_cube(5)\n assert_equal(125, result)\n end",
"def name\n self['VolumeName']\n end",
"def test_volume_of_a_sphere()\n # add test code here\n result = volume_of_a_sphere(2)\n assert_equal(33.5103216, result)\n end",
"def volume(volume_id)\n volumes(volume_id)[0]\n end",
"def index\n @volumes = Volume.all\n end",
"def index\n @volumes = Volume.all\n end",
"def sound_volume(value)\n @ole.SoundVolume = value\n nil\n end",
"def volume(volume_name, attrs={}, &block)\n volumes[volume_name] ||= Ironfan::Volume.new(:parent => self, :name => volume_name)\n volumes[volume_name].configure(attrs, &block)\n volumes[volume_name]\n end",
"def music_volume=(value)\n value = value.to_i.abs\n @music_volume = value < 101 ? value : 100\n end",
"def volume_up(increase = 1)\n if (@volume + increase) >= 100\n @volume = 100\n else\n @volume += increase\n end\n end"
] | [
"0.78524226",
"0.76760495",
"0.7618209",
"0.7503193",
"0.739426",
"0.7362389",
"0.73306435",
"0.7118862",
"0.71077865",
"0.7084909",
"0.7019615",
"0.70027536",
"0.69819474",
"0.69792277",
"0.6978118",
"0.6975737",
"0.6973202",
"0.69401526",
"0.68769175",
"0.686562",
"0.68242276",
"0.6728388",
"0.671885",
"0.6695583",
"0.66092944",
"0.65994304",
"0.65876764",
"0.65812343",
"0.65712535",
"0.65525085",
"0.6549431",
"0.6530739",
"0.65214974",
"0.6458254",
"0.6450211",
"0.6447141",
"0.6437403",
"0.64179695",
"0.64179695",
"0.6408623",
"0.6392133",
"0.63715374",
"0.6343363",
"0.6342402",
"0.6332422",
"0.6332422",
"0.6317758",
"0.63058585",
"0.6298886",
"0.6290458",
"0.62736475",
"0.6262456",
"0.62256753",
"0.6219705",
"0.6209837",
"0.6191682",
"0.61644953",
"0.61489755",
"0.6118789",
"0.61114746",
"0.6109936",
"0.6105409",
"0.6092025",
"0.6085078",
"0.6081593",
"0.60658085",
"0.60653615",
"0.6064824",
"0.60613424",
"0.6055679",
"0.6042983",
"0.60386443",
"0.6037938",
"0.6025028",
"0.6010697",
"0.60043114",
"0.6002283",
"0.5996294",
"0.59808815",
"0.5958194",
"0.5948408",
"0.5946511",
"0.59404904",
"0.594015",
"0.5930944",
"0.5930841",
"0.5929683",
"0.59211063",
"0.5919851",
"0.5910647",
"0.59091336",
"0.5904283",
"0.59018254",
"0.5899733",
"0.58955973",
"0.58955973",
"0.58935475",
"0.58876693",
"0.5882617",
"0.5877838"
] | 0.6337684 | 44 |
========================================================================================= $ ./cyberdojo volume create ========================================================================================= | def volume_create
help = [
'',
"Use: #{me} volume create --name=VOLUME --git=URL",
"Use: #{me} volume create --name=VOLUME --dir=PATH",
'',
'Creates a volume named VOLUME from a git clone of URL',
'Creates a volume named VOLUME from a copy of PATH'
]
# asked for help?
if [nil,'help','--help'].include? ARGV[2]
show help
exit failed
end
# unknown arguments?
knowns = ['name','git','dir']
unknown = ARGV[2..-1].select do |argv|
knowns.none? { |known| argv.start_with?('--' + known + '=') }
end
if unknown != []
show help
unknown.each { |arg| puts "FAILED: unknown argument [#{arg.split('=')[0]}]" }
exit failed
end
# required known arguments
args = ARGV[2..-1]
vol = get_arg('--name', args)
url = get_arg('--git', args)
dir = get_arg('--dir', args)
if vol.nil? || (url.nil? && dir.nil?)
show help
exit failed
end
if vol.length == 1
msg = 'volume names must be at least two characters long. See https://github.com/docker/docker/issues/20122'
puts "FAILED: [volume create --name=#{vol}] #{msg}"
exit failed
end
if volume_exists? vol
msg = "#{vol} already exists"
puts "FAILED: [volume create --name=#{vol}] #{msg}"
exit failed
end
# cyber-dojo.sh does actual [volume create]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_volume(options)\n # Creating the volume is part of the server creation\n end",
"def create_volume(options)\n # Creating the volume is part of the server creation\n end",
"def volume_create(name)\n @log.info \"Creating volume #{name} from offering id #{DISK_OFFERING}...\"\n ret = @cloud_stack.create_volume(name, ZONE, DISK_OFFERING)\n id = ret[\"createvolumeresponse\"][\"jobid\"]\n wait_for_job id\n vol_id = ret[\"createvolumeresponse\"][\"id\"]\n @log.info \"Created volume id: #{vol_id}\"\n vol_id\n end",
"def create\n properties = [ resource[:name],\n resource[:user],\n resource[:group],\n resource[:config],\n resource[:mode],\n ]\n\n qmgmt(['volume', 'create'] + properties)\n end",
"def createvolume\n if not checkRequirements([\"thezone\",\"thevolume\"])\n return false\n end\n checkToken(@thezone)\n req = {}\n req[\"name\"] = \"oe-#{@thevolume.name}\"\n req[\"description\"] = @thevolume.description\n req[\"sizeGb\"] = @thevolume.size\n submit = queryGCE(:path => '/compute/v1beta15/projects/#{@thezone.name}/zones/#{@thevolume.azone.name}/disks', :method => 'post', :options => '', :data => req.to_json, :access_token => @thezone.toekn )\n d = checkQuery(:type => 'zone', :token => @thezone.token, :projectname => @thezone.name, :zonename => @thevolume.azone.name, :operationname => submit[\"name\"])\n data = queryGCE(:path => '/compute/v1beta15/projects/#{@thezone.name}/zones/#{@thevolume.azone.name}/disks/#{req[\"name\"]}', :method => 'get', :options => '', :access_token => @thezone.token) if d\n data ? data[\"name\"] : false\n end",
"def create_volume(options={}) \n raise \"Volume nickname required\" unless options[:nickname]\n params = {:nickname => options[:nickname],:size => options[:size], :api_version => 1.0}\n params[:description] = options[:description] if options[:description]\n #STDERR.puts \"HERE IS THE URL: #{@api_url}/create_ebs_volume.js (PARAMS: #{params.inspect})\"\n body = RestClient.post @api_url+\"/create_ebs_volume.js\",params\n json = JSON.load(body)\n STDERR.puts \"CREATED_VOLUME: #{json}\"\n json\n rescue => e\n display_exception(e, \"create_volume: #{options.inspect}\")\n end",
"def create_volume(options = {})\n options[:capacity] = options[:capacity] * GB if options[:capacity] < 100000\n vol = pool.create_volume_xml(Volume.to_xml(options))\n Volume.new vol, self\n end",
"def create_default_volume()\n # Create a default application_volume using the volume attributes from the cookbook\n create_node_volume(:application_volume)\n end",
"def createVolume\n require 'rest_client'\n require 'uri'\n\n if @role.nil? and !current_actor.superadmin\n json_response({ message: \"You don't have permission to view the clusters in this project\" }, :unauthorized)\n return\n end\n\n # Service name in the query\n volumeName = params[\"volume_name\"]\n\n # Env variables for Manager host and port\n serviceManagerHost = Settings.service_manager_host\n serviceManagerPort = Settings.service_manager_port.to_s\n serviceManagerURI = 'http://' + serviceManagerHost + ':' + serviceManagerPort + '/v1/volume'\n\n # Create request for Service Manager\n stack = {\n 'name' => volumeName,\n 'engine-url' => @cluster.endpoint,\n 'ca-cert' => @cluster.ca,\n 'cert' => @cluster.cert,\n 'cert-key' => @cluster.key\n }.to_json\n\n begin\n response = RestClient.post(\n serviceManagerURI,\n stack,\n 'Accept' => 'application/json',\n 'Content-Type' => 'application/json'\n )\n puts \"Deploy Response: \" + response\n json_response(response, :created)\n rescue Exception => e\n # If error, respond with it\n puts e\n json_response({message: e}, :unprocessable_entity)\n end\n end",
"def create body = {}\n @connection.request(method: :post, path: \"/volumes/create\", headers: {\"Content-Type\": \"application/json\"}, body: body.to_json)\n end",
"def create_volume(volume_name, config:, **kwargs)\n object = { name: volume_name }.merge(config).merge(kwargs)\n log.info \"Creating volume: #{object}\"\n volumes << object\n end",
"def addVolume(dev, size, type: \"gp2\")\n if @cloud_id.nil? or @cloud_id.empty?\n MU.log \"#{self} didn't have a cloud id, couldn't determine 'active?' status\", MU::ERR\n return true\n end\n az = nil\n MU::Cloud::AWS.ec2(region: @config['region'], credentials: @config['credentials']).describe_instances(\n instance_ids: [@cloud_id]\n ).reservations.each { |resp|\n if !resp.nil? and !resp.instances.nil?\n resp.instances.each { |instance|\n az = instance.placement.availability_zone\n instance.block_device_mappings.each { |vol|\n if vol.device_name == dev\n MU.log \"A volume #{dev} already attached to #{self}, skipping\", MU::NOTICE\n return\n end\n }\n }\n end\n }\n MU.log \"Creating #{size}GB #{type} volume on #{dev} for #{@cloud_id}\"\n creation = MU::Cloud::AWS.ec2(region: @config['region'], credentials: @config['credentials']).create_volume(\n availability_zone: az,\n size: size,\n volume_type: type\n )\n begin\n sleep 3\n creation = MU::Cloud::AWS.ec2(region: @config['region'], credentials: @config['credentials']).describe_volumes(volume_ids: [creation.volume_id]).volumes.first\n if ![\"creating\", \"available\"].include?(creation.state)\n raise MuError, \"Saw state '#{creation.state}' while creating #{size}GB #{type} volume on #{dev} for #{@cloud_id}\"\n end\n end while creation.state != \"available\"\n\n if @deploy\n MU::MommaCat.listStandardTags.each_pair { |key, value|\n MU::MommaCat.createTag(creation.volume_id, key, value, region: @config['region'], credentials: @config['credentials'])\n }\n MU::MommaCat.createTag(creation.volume_id, \"Name\", \"#{MU.deploy_id}-#{@config[\"name\"].upcase}-#{dev.upcase}\", region: @config['region'], credentials: @config['credentials'])\n end\n\n attachment = MU::Cloud::AWS.ec2(region: @config['region'], credentials: @config['credentials']).attach_volume(\n device: dev,\n instance_id: @cloud_id,\n volume_id: creation.volume_id\n )\n\n begin\n sleep 3\n attachment = MU::Cloud::AWS.ec2(region: @config['region'], credentials: @config['credentials']).describe_volumes(volume_ids: [attachment.volume_id]).volumes.first.attachments.first\n if ![\"attaching\", \"attached\"].include?(attachment.state)\n raise MuError, \"Saw state '#{creation.state}' while creating #{size}GB #{type} volume on #{dev} for #{@cloud_id}\"\n end\n end while attachment.state != \"attached\"\n end",
"def create_storage_volume(create_opts={})\n create_resource :storage_volume, create_opts\n end",
"def create\n @volume = Volume.new(volume_params)\n\n respond_to do |format|\n if @volume.save\n format.html { redirect_to @volume, notice: 'Volume was successfully created.' }\n format.json { render :show, status: :created, location: @volume }\n else\n format.html { render :new }\n format.json { render json: @volume.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_volume( options = {} )\n options = { :availability_zone => '' }.merge(options)\n raise ArgumentError, \"No :availability_zone provided\" if options[:availability_zone].nil? || options[:availability_zone].empty?\n options = { :size => '' }.merge(options)\n options = { :snapshot_id => '' }.merge(options)\n params = {\n \"AvailabilityZone\" => options[:availability_zone],\n \"Size\" => options[:size],\n \"SnapshotId\" => options[:snapshot_id]\n }\n return response_generator(:action => \"CreateVolume\", :params => params)\n end",
"def create\n\t\tregion = resource[:availability_zone].to_s.gsub(/.$/,'') \n\t\tcompute = Fog::Compute.new(:provider => 'aws', :region => \"#{region}\")\n\t\tprint \"ebsvol[aws]->create: Region is #{region}\\n\" if $debug\n\t\tprint \"ebsvol[aws]->create: Availability_zone is #{resource[:availability_zone]}\\n\" if $debug\n\t\t# create the requested volume\n\t\tresponse = compute.create_volume(resource[:availability_zone],resource[:size],resource[:snapshot])\t\n\t\tif (response.status == 200)\n\t\t\tvolumeid = response.body['volumeId']\n\t\t\tprint \"ebsvol[aws]->create: I created volume #{volumeid}.\\n\" if $debug\n\t\t\t# now tag the volume with volumename so we can identify it by name\n\t\t\t# and not the volumeid\n\t\t\tresponse = compute.create_tags(volumeid,{ :Name => resource[:volume_name] })\n\t\t\tif (response.status == 200)\n\t\t\t\tprint \"ebsvol[aws]->create: I tagged #{volumeid} with Name = #{resource[:volume_name]}\\n\" if $debug\n\t\t\tend\n\t\t\t# Check if I need to attach it to an ec2 instance.\n\t\t\tattachto = resource[:attached_to].to_s\n\t\t\tprint \"attachto is #{attachto}\\n\" if $debug\n\t\t\tif ( attachto != '' )\n\t\t\t\tif ( attachto == 'me')\n\t\t\t\t\tinstance = instanceinfo(compute,myname(compute))\n\t\t\t\telse\n\t\t\t\t\tinstance = instanceinfo(compute,attachto)\n\t\t\t\tend\n\t\t\t\tif ( resource[:device] != nil )\n\t\t\t\t\t# try to attach the volume to requested instance\n\t\t\t\t\tprint \"attach the volume\\n\" if $debug\n\t\t\t\t\tvolume = volinfo(compute,resource[:volume_name])\n\t\t\t\t\tattachvol(compute,volume,instance,resource[:device])\n\t\t\t\telse\n\t\t\t\t\traise \"ebsvol[aws]->create: Sorry, I can't attach a volume with out a device to attach to!\"\n\t\t\t\tend\n\t\t\tend\n\t\telse\n\t\t\traise \"ebsvol[aws]->create: I couldn't create the ebs volume, sorry!\"\n\t\tend\n\tend",
"def create_volume(snapshot_id, size, availability_zone, timeout, volume_type, piops)\n availability_zone ||= instance_availability_zone\n\n # Sanity checks so we don't shoot ourselves.\n raise \"Invalid volume type: #{volume_type}\" unless ['standard', 'gp2', 'io1'].include?(volume_type)\n\n # PIOPs requested. Must specify an iops param and probably won't be \"low\".\n if volume_type == 'io1'\n raise 'IOPS value not specified.' unless piops >= 100\n end\n\n # Shouldn't see non-zero piops param without appropriate type.\n if piops > 0\n raise 'IOPS param without piops volume type.' unless volume_type == 'io1'\n end\n\n create_volume_opts = { :volume_type => volume_type }\n # TODO: this may have to be casted to a string. rightaws vs aws doc discrepancy.\n create_volume_opts[:iops] = piops if volume_type == 'io1'\n\n nv = ec2.create_volume(snapshot_id, size, availability_zone, create_volume_opts)\n Chef::Log.debug(\"Created new volume #{nv[:aws_id]}#{snapshot_id ? \" based on #{snapshot_id}\" : \"\"}\")\n\n # block until created\n begin\n Timeout::timeout(timeout) do\n while true\n vol = volume_by_id(nv[:aws_id])\n if vol && vol[:aws_status] != \"deleting\"\n if [\"in-use\", \"available\"].include?(vol[:aws_status])\n Chef::Log.info(\"Volume #{nv[:aws_id]} is available\")\n break\n else\n Chef::Log.debug(\"Volume is #{vol[:aws_status]}\")\n end\n sleep 3\n else\n raise \"Volume #{nv[:aws_id]} no longer exists\"\n end\n end\n end\n rescue Timeout::Error\n raise \"Timed out waiting for volume creation after #{timeout} seconds\"\n end\n\n nv[:aws_id]\n end",
"def create\n @volume = Volume.new(volume_params)\n\n respond_to do |format|\n if @volume.save\n format.html { redirect_to @volume, notice: 'Volume was successfully created.' }\n format.json { render action: 'show', status: :created, location: @volume }\n else\n format.html { render action: 'new' }\n format.json { render json: @volume.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @volume = Volume.new(params[:volume])\n\n respond_to do |format|\n if @volume.save\n format.html { redirect_to(@volume, :notice => 'Volume was successfully created.') }\n format.xml { render :xml => @volume, :status => :created, :location => @volume }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @volume.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def addVolume(dev, size, type: \"gp2\", delete_on_termination: false)\n\n if setDeleteOntermination(dev, delete_on_termination)\n MU.log \"A volume #{dev} already attached to #{self}, skipping\", MU::NOTICE\n return\n end\n\n MU.log \"Creating #{size}GB #{type} volume on #{dev} for #{@cloud_id}\"\n creation = MU::Cloud::AWS.ec2(region: @region, credentials: @credentials).create_volume(\n availability_zone: cloud_desc.placement.availability_zone,\n size: size,\n volume_type: type\n )\n\n MU.retrier(wait: 3, loop_if: Proc.new {\n creation = MU::Cloud::AWS.ec2(region: @region, credentials: @credentials).describe_volumes(volume_ids: [creation.volume_id]).volumes.first\n if ![\"creating\", \"available\"].include?(creation.state)\n raise MuError, \"Saw state '#{creation.state}' while creating #{size}GB #{type} volume on #{dev} for #{@cloud_id}\"\n end\n creation.state != \"available\"\n })\n\n\n if @deploy\n MU::Cloud::AWS.createStandardTags(\n creation.volume_id,\n region: @region,\n credentials: @credentials,\n optional: @config['optional_tags'],\n nametag: @mu_name+\"-\"+dev.upcase,\n othertags: @config['tags']\n )\n end\n\n MU.log \"Attaching #{creation.volume_id} as #{dev} to #{@cloud_id} in #{@region} (credentials #{@credentials})\"\n attachment = nil\n MU.retrier([Aws::EC2::Errors::IncorrectState], wait: 15, max: 4) {\n attachment = MU::Cloud::AWS.ec2(region: @region, credentials: @credentials).attach_volume(\n device: dev,\n instance_id: @cloud_id,\n volume_id: creation.volume_id\n )\n }\n\n begin\n att_resp = MU::Cloud::AWS.ec2(region: @region, credentials: @credentials).describe_volumes(volume_ids: [attachment.volume_id])\n if att_resp and att_resp.volumes and !att_resp.volumes.empty? and\n att_resp.volumes.first.attachments and\n !att_resp.volumes.first.attachments.empty?\n attachment = att_resp.volumes.first.attachments.first\n if !attachment.nil? and ![\"attaching\", \"attached\"].include?(attachment.state)\n raise MuError, \"Saw state '#{creation.state}' while creating #{size}GB #{type} volume on #{dev} for #{@cloud_id}\"\n end\n end\n end while attachment.nil? or attachment.state != \"attached\"\n\n # Set delete_on_termination, which for some reason is an instance\n # attribute and not on the attachment\n setDeleteOntermination(dev, delete_on_termination)\n end",
"def create\n tmp = Puppet::FileSystem::Uniquefile.new('quobyte_volume_config')\n tmp.write(resource[:content])\n tmp.flush()\n\n qmgmt(['volume', 'config', 'import', [resource[:name]], tmp.path])\n end",
"def create_volume(size_or_snapshot_id, options = {})\n options = {:device => '/dev/sdh'}.merge(options)\n if size_or_snapshot_id.is_a?(Numeric)\n volume = @ec2.create_volume availability_zone, :size => size_or_snapshot_id\n else\n volume = @ec2.create_volume availability_zone, :snapshot_id => size_or_snapshot_id\n end\n if options[:tags]\n @ec2.create_tags(volume.id, options[:tags])\n end\n while volume.status != 'available'\n volume.reload\n end\n if options[:device]\n attach volume, options[:device]\n end\n volume\n end",
"def create_volumes(volume_definitions)\n volume_definitions.each { |volume| client.volumes.create(volume) }\n end",
"def volume\n help = [\n '',\n \"Use: #{me} volume [COMMAND]\",\n '',\n 'Manage cyber-dojo setup volumes',\n '',\n 'Commands:',\n minitab + 'create Creates a new volume',\n minitab + 'rm Removes a volume',\n minitab + 'ls Lists the names of all volumes',\n minitab + 'inspect Displays details of a volume',\n minitab + \"pull Pulls the docker images inside a volume's manifest.json files\",\n '',\n \"Run '#{me} volume COMMAND --help' for more information on a command\",\n ]\n case ARGV[1]\n when 'create' then volume_create\n when 'rm' then volume_rm\n when 'ls' then volume_ls\n when 'inspect' then volume_inspect\n when 'pull' then volume_pull\n else show help\n end\nend",
"def volume_client_create\n options = {\n :provider => :openstack,\n :openstack_api_key => @options[:openstack_api_key],\n :openstack_username => @options[:openstack_username],\n :openstack_auth_url => @options[:openstack_auth_url],\n :openstack_tenant => @options[:openstack_tenant],\n :openstack_region => @options[:openstack_region],\n }\n @volume_client ||= Fog::Volume.new(options)\n unless @volume_client\n raise \"Unable to create OpenStack Volume instance\"\\\n \" (api_key: #{@options[:openstack_api_key]},\"\\\n \" username: #{@options[:openstack_username]},\"\\\n \" auth_url: #{@options[:openstack_auth_url]},\"\\\n \" tenant: #{@options[:openstack_tenant]})\"\n end\n end",
"def create\n @actual_volume = ActualVolume.new(actual_volume_params)\n\n respond_to do |format|\n if @actual_volume.save\n format.html { redirect_to @actual_volume, notice: 'Actual volume was successfully created.' }\n format.json { render :show, status: :created, location: @actual_volume }\n else\n format.html { render :new }\n format.json { render json: @actual_volume.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @admissive_volume = AdmissiveVolume.new(params[:admissive_volume])\n\n respond_to do |format|\n if @admissive_volume.save\n format.html { redirect_to @admissive_volume, notice: 'Admissive volume was successfully created.' }\n format.json { render json: @admissive_volume, status: :created, location: @admissive_volume }\n else\n format.html { render action: \"new\" }\n format.json { render json: @admissive_volume.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_volume(availability_zone, options = {})\n raise ArgumentError.new('You must specify a size if not creating a volume from a snapshot') if options[:snapshot_id].blank? && options[:size].blank?\n\n action = 'CreateVolume'\n params = {\n 'Action' => action,\n 'AvailabilityZone' => availability_zone\n }\n params['Size'] = options[:size] unless options[:size].blank?\n params['SnapshotId'] = options[:snapshot_id] unless options[:snapshot_id].blank?\n\n response = send_query_request(params)\n parser = Awsum::Ec2::VolumeParser.new(self)\n volume = parser.parse(response.body)[0]\n if options[:tags] && options[:tags].size > 0\n create_tags volume.id, options[:tags]\n end\n volume\n end",
"def create_vdi(name, sr_ref, size)\n vdi_record = {\n \"name_label\" => \"#{name}\",\n \"name_description\" => \"Root disk for #{name} created by knfie xapi\",\n \"SR\" => sr_ref,\n \"virtual_size\" => input_to_bytes(size).to_s,\n \"type\" => \"system\",\n \"sharable\" => false,\n \"read_only\" => false,\n \"other_config\" => {},\n }\n \n # Async create the VDI\n task = xapi.Async.VDI.create(vdi_record)\n ui.msg \"waiting for VDI Create\"\n vdi_ref = get_task_ref(task)\n end",
"def gen_pv\n pv_name = \"pv-#{gen_uuid}\"\n file = \"#{$templates_path}/#{pv_name}.yaml\"\n File.open(file, 'w') do |f|\n f.puts <<-PV\nkind: PersistentVolume\napiVersion: v1\nmetadata:\n name: #{pv_name}\nspec:\n capacity:\n storage: 1Gi\n accessModes:\n - ReadWriteOnce\n nfs:\n path: \"/\"\n server: \"10.1.1.1\"\n persistentVolumeReclaimPolicy: \"Retain\"\nPV\n end\n\n `oc create -f #{file}`\nend",
"def volume(volume_name, attrs={}, &block)\n volumes[volume_name] ||= Ironfan::Volume.new(:parent => self, :name => volume_name)\n volumes[volume_name].configure(attrs, &block)\n volumes[volume_name]\n end",
"def create_vdi(name, sr_ref, size)\n vdi_record = {\n 'name_label' => \"#{name}\",\n 'name_description' => \"Root disk for #{name} created by #{ENV['USER']} with knfie xapi\",\n 'SR' => sr_ref,\n 'virtual_size' => input_to_bytes(size).to_s,\n 'type' => 'system',\n 'sharable' => false,\n 'read_only' => false,\n 'other_config' => {}\n }\n\n # Async create the VDI\n task = xapi.Async.VDI.create(vdi_record)\n ui.msg 'waiting for VDI Create'\n vdi_ref = get_task_ref(task)\n vdi_ref\n end",
"def create\n @volume_type = VolumeType.new(params[:volume_type])\n\n respond_to do |format|\n if @volume_type.save\n format.html { redirect_to @volume_type, notice: 'Volume type was successfully created.' }\n format.json { render json: @volume_type, status: :created, location: @volume_type }\n else\n format.html { render action: \"new\" }\n format.json { render json: @volume_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_stripe_volume(server)\n options = { \"EBS_MOUNT_POINT\" => \"text:#{@mount_point}\",\n \"EBS_STRIPE_COUNT\" => \"text:#{@stripe_count}\",\n \"EBS_TOTAL_VOLUME_GROUP_SIZE\" => \"text:#{@volume_size}\",\n \"EBS_LINEAGE\" => \"text:#{@lineage}\" }\n audit = server.run_executable(@scripts_to_run['create_stripe'], options)\n audit.wait_for_completed\n end",
"def addVolume(dev, size, type: \"pd-standard\", delete_on_termination: false)\n devname = dev.gsub(/.*?\\/([^\\/]+)$/, '\\1')\n resname = MU::Cloud::Google.nameStr(@mu_name+\"-\"+devname)\n MU.log \"Creating disk #{resname}\"\n\n description = @deploy ? @deploy.deploy_id : @mu_name+\"-\"+devname\n\n newdiskobj = MU::Cloud::Google.compute(:Disk).new(\n size_gb: size,\n description: description,\n zone: @config['availability_zone'],\n# type: \"projects/#{config['project']}/zones/#{config['availability_zone']}/diskTypes/pd-ssd\",\n type: \"projects/#{@project_id}/zones/#{@config['availability_zone']}/diskTypes/#{type}\",\n# Other values include pd-ssd and local-ssd\n name: resname\n )\n\n begin\n newdisk = MU::Cloud::Google.compute(credentials: @config['credentials']).insert_disk(\n @project_id,\n @config['availability_zone'],\n newdiskobj\n )\n rescue ::Google::Apis::ClientError => e\n if e.message.match(/^alreadyExists: /)\n MU.log \"Disk #{resname} already exists, ignoring request to create\", MU::WARN\n return\n else\n raise e\n end\n end\n\n attachobj = MU::Cloud::Google.compute(:AttachedDisk).new(\n device_name: devname,\n source: newdisk.self_link,\n type: \"PERSISTENT\",\n auto_delete: delete_on_termination\n )\n\n MU.log \"Attaching disk #{resname} to #{@cloud_id} at #{devname}\"\n MU::Cloud::Google.compute(credentials: @config['credentials']).attach_disk(\n @project_id,\n @config['availability_zone'],\n @cloud_id,\n attachobj\n )\n\n end",
"def create_vbox_hdd(client_name,vbox_disk_name)\n message = \"Creating:\\tVM hard disk for \"+client_name\n command = \"VBoxManage createhd --filename \\\"#{vbox_disk_name}\\\" --size \\\"#{$default_vm_size}\\\"\"\n execute_command(message,command)\n return\nend",
"def create_gdom_disk(options)\n client_disk = options['q_struct']['gdom_disk'].value\n disk_size = options['q_struct']['gdom_size'].value\n disk_size = disk_size.downcase\n vds_disk = options['name']+\"_vdisk0\"\n if not client_disk.match(/\\/dev/)\n if not File.exist?(client_disk)\n message = \"Information:\\tCreating guest domain disk \"+client_disk+\" for client \"+options['name']\n command = \"mkfile -n #{disk_size} #{client_disk}\"\n output = execute_command(options,message,command)\n end\n end\n message = \"Information:\\tChecking Virtual Disk Server device doesn't already exist\"\n command = \"ldm list-services |grep 'primary-vds0' |grep '#{vds_disk}'\"\n output = execute_command(options,message,command)\n if not output.match(/#{options['name']}/)\n message = \"Information:\\tAdding disk device to Virtual Disk Server\"\n command = \"ldm add-vdsdev #{client_disk} #{vds_disk}@primary-vds0\"\n output = execute_command(options,message,command)\n end\n return\nend",
"def create!\n set_id = generate_set_id\n\n @volume_ids.each do |id|\n snapshot = @fog.snapshots.new\n\n snapshot.description = \"#{@hostname.split(\".\")[0]} #{@mount} (#{self.needed_types.join(\", \")}) (#{set_id})\"\n snapshot.volume_id = id\n\n # Actually do the snapshot\n snapshot.save\n\n # Reload to get snapshot.id so we can add tags\n snapshot.reload\n\n @fog.tags.create(:resource_id => snapshot.id, :key => \"Host\", :value => @hostname)\n @fog.tags.create(:resource_id => snapshot.id, :key => \"Mount\", :value => @mount)\n @fog.tags.create(:resource_id => snapshot.id, :key => \"SetID\", :value => set_id)\n @fog.tags.create(:resource_id => snapshot.id, :key => \"Type\", :value => self.needed_types.join(\",\"))\n end\n end",
"def vsc_create(drive)\n puts \"[\".light_blue + \"*\".white + \"]\".light_blue + \" Creating New Volume Shady Copy from #{drive}\".white\n cmd=\"vssadmin create shadow /for=#{drive}:\"\n begin\n text = \"#{@tmp}\\\\#{Rex::Text.rand_text_alpha(16)}.txt\"\n bat = \"#{@tmp}\\\\#{Rex::Text.rand_text_alpha(16)}.bat\"\n cmdexec = \"%COMSPEC% /C echo #{cmd} ^> #{text} > #{bat} & %COMSPEC% /C start %COMSPEC% /C #{bat}\"\n# cmdexec = \"%COMSPEC% /C #{cmd} > #{text}\"\n smb_psexec(cmdexec, false)\n puts \"[\".light_blue + \"*\".white + \"]\".light_blue + \" taking short 30 second nap to ensure it has enough time....\".white\n sleep(30) # Need to provide sufficient time for this process to complete or your S.O.L.\n output = get_output(text, false)\n files = [ text, bat ]\n cleanup_after(files, false)\n if output =~ /Successfully created shadow copy/i\n if output =~ /Shadow Copy ID: (.+)/i\n id=$1.chomp\n end\n if output =~ /Shadow Copy Volume Name: (.+)/i\n path=$1.chomp\n end\n if not id.nil? and not path.nil?\n puts \"[\".light_green + \"*\".white + \"]\".light_green + \" New Volume Shady Copy ID: #{id}\".white\n puts \"[\".light_green + \"*\".white + \"]\".light_green + \" New Volume Shady Copy Location: #{path}\".white\n return id, path\n else\n return nil, nil\n end\n else\n puts \"[\".light_red + \"*\".white + \"]\".light_red + \" Error creating Volume Shadow Copy!\".white\n puts \"[\".light_red + \"*\".white + \"]\".light_red + \" Make sure you have enough privileges and that this is a Domain Controller.....\".white\n return nil, nil\n end\n rescue Rex::Proto::SMB::Exceptions::InvalidCommand => e\n puts \"[\".light_red + \"*\".white + \"]\".light_red + \" Error creating Volume Shadow Copy!\".white\n puts \"[\".light_red + \"*\".white + \"]\".light_red + \" Make sure you have enough privileges and that this is a Domain Controller.....\".white\n return nil, nil\n end\nend",
"def create_ec2_ebs_volume opts\n Ec2EbsVolume.create opts.merge :account => self\n end",
"def set_volume(volume)\n puts \"Setting volume to #{volume}\" if $verbose\n v='AG'+(('000'+volume.to_s)[-3..-1])+';'\n puts v if $verbose\n ret=send_cmd(v,'AG;',v,0.5,1.5,3)\n if(ret)\n return(ret.gsub(/^AG/,'').gsub(/;$/,'').to_i)\n else\n return(nil)\n end\nend",
"def mount_kvm_volume(name)\n dev = available_dev\n enable_netblockdev(name, dev)\n vol_grp = lvm_volume_group(\n lvm_partition(dev)\n )\n root = lvm_root(vol_grp)\n lvm_enable(vol_grp) unless lvm_enabled?(root)\n mount(name, root)\n dev\nend",
"def setup_volumes\n # managing planned volumes is currently only needed in Windows and only if\n # this is not a reboot scenario.\n if !RightScale::Platform.windows? || RightScale::InstanceState.reboot?\n boot\n else\n RightScale::AuditProxy.create(@agent_identity, 'Planned volume management') do |audit|\n @audit = audit\n manage_planned_volumes do\n @audit = nil\n boot\n end\n end\n end\n true\n end",
"def volume_create_from_snap(source, name, snapshot_id)\n retries = 3\n begin \n @log.info \"Creating volume #{name} from snapshot id #{snapshot_id}...\"\n ret = @cloud_stack.create_volume(name, ZONE, nil, snapshot_id)\n id = ret[\"createvolumeresponse\"][\"jobid\"]\n wait_for_job id\n rescue Exception => e\n retries -= 1\n if retries > 0\n @log.error \"Failed. #{e.message}. Retrying...\"\n retry\n end\n raise e\n end\n vol_id = ret[\"createvolumeresponse\"][\"id\"]\n @log.info \"Created volume id: #{vol_id}\"\n vol_id\n end",
"def create_disk(size, cloud_properties, server_id = nil)\n volume_service_client = @openstack.volume\n with_thread_name(\"create_disk(#{size}, #{cloud_properties}, #{server_id})\") do\n raise ArgumentError, 'Disk size needs to be an integer' unless size.is_a?(Integer)\n cloud_error('Minimum disk size is 1 GiB') if size < 1024\n\n unique_name = generate_unique_name\n volume_params = {\n # cinder v1 requires display_ prefix\n display_name: \"volume-#{unique_name}\",\n display_description: '',\n # cinder v2 does not require prefix\n name: \"volume-#{unique_name}\",\n description: '',\n size: mib_to_gib(size),\n }\n\n if cloud_properties.key?('type')\n volume_params[:volume_type] = cloud_properties['type']\n elsif !@default_volume_type.nil?\n volume_params[:volume_type] = @default_volume_type\n end\n\n if server_id && @az_provider.constrain_to_server_availability_zone?\n server = @openstack.with_openstack { @openstack.compute.servers.get(server_id) }\n volume_params[:availability_zone] = server.availability_zone if server&.availability_zone\n end\n\n @logger.info('Creating new volume...')\n new_volume = @openstack.with_openstack { volume_service_client.volumes.create(volume_params) }\n\n @logger.info(\"Creating new volume `#{new_volume.id}'...\")\n @openstack.wait_resource(new_volume, :available)\n\n new_volume.id.to_s\n end\n end",
"def create\n @sm_volume = SmVolume.new(params[:sm_volume])\n\n respond_to do |format|\n if @sm_volume.save\n format.html { redirect_to @sm_volume, notice: 'Sm volume was successfully created.' }\n format.json { render json: @sm_volume, status: :created, location: @sm_volume }\n else\n format.html { render action: \"new\" }\n format.json { render json: @sm_volume.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_volume(volume)\n %x{#{echo()} volume #{volume} 1 > #{fifo()}} if running?\n end",
"def create_lvm_volumes( opts = {} )\n opts = deep_merge_hashes( @aws_default_instance_options, opts )\n unless exist?( opts[ :lvm_volumes ].first[1] )\n create_lvm_volumes!( opts )\n end\n end",
"def provision_storage host, vm\n if host['volumes']\n # Lazily create the volume client if needed\n volume_client_create\n host['volumes'].keys.each_with_index do |volume, index|\n @logger.debug \"Creating volume #{volume} for OpenStack host #{host.name}\"\n\n # The node defintion file defines volume sizes in MB (due to precedent\n # with the vagrant virtualbox implementation) however OpenStack requires\n # this translating into GB\n openstack_size = host['volumes'][volume]['size'].to_i / 1000\n\n # Create the volume and wait for it to become available\n vol = @volume_client.volumes.create(\n :size => openstack_size,\n :display_name => volume,\n :description => \"Beaker volume: host=#{host.name} volume=#{volume}\",\n )\n vol.wait_for { ready? }\n\n # Fog needs a device name to attach as, so invent one. The guest\n # doesn't pay any attention to this\n device = \"/dev/vd#{('b'.ord + index).chr}\"\n vm.attach_volume(vol.id, device)\n end\n end\n end",
"def populate_volume(server)\n server.spot_check_command(\" echo \\\"blah blah blah\\\" > #{@mount_point}/data.txt\")\n end",
"def attach_blank_volume opts\n device = opts.delete :device\n opts = {:ec2_availability_zone => ec2_availability_zone }.merge opts\n volume = account.create_ec2_ebs_volume opts\n attach_volume volume, device\n end",
"def volume_params\n params.require(:volume).permit(:name, :status, :volume_id)\n end",
"def create_volume request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_create_volume_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Longrunning::Operation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end",
"def set_bunny_volume vol\n @exch.publish(vol.to_i) \n end",
"def volume _value, _abs=0\n send_cmd(\"volume #{_value} #{_abs}\")\n end",
"def create\n begin\n # Set the partition (/dev/sdb1), device (/dev/sdb) and alignment (optimal,minimal,none etc.) variables\n partition= resource[:name]\n device=partition[0,(partition.length-1)]\n alignment= resource[:alignment]\n\n # Now we can create the partition\n partitions = parted('-a', resource[:alignment],'--script',device,'mklabel',resource[:part_label],'mkpart', resource[:part_type],resource[:fs_type],resource[:p_begin],resource[:p_end])\n rescue Puppet::ExecutionFailure => e\n false\n end\n end",
"def create_kvm(kvm_name, template, options)\n ensure_name_availability!(kvm_name)\n clone_kvm(kvm_name, template)\n device = mount_kvm_volume(kvm_name)\n address = update_kvm_ip(kvm_name)\n update_hostname(kvm_name)\n make_console_accessible(kvm_name)\n unmount_kvm_volume(kvm_name, device)\n create_kvm_instance(kvm_name, options)\n puts \"KVM Node #{kvm_name} available at: #{address}\"\nend",
"def add_cdrom_to_vbox_vm(client_name)\n message = \"Attaching:\\tCDROM to VM \"+client_name\n command = \"VBoxManage storagectl \\\"#{client_name}\\\" --name \\\"cdrom\\\" --add \\\"sata\\\" --controller \\\"IntelAHCI\\\"\"\n execute_command(message,command)\n if File.exist?($vbox_additions_iso)\n message = \"Attaching:\\tISO \"+$vbox_additions_iso+\" to VM \"+client_name\n command = \"VBoxManage storageattach \\\"#{client_name}\\\" --storagectl \\\"cdrom\\\" --port 0 --device 0 --type dvddrive --medium \\\"#{$vbox_additions_iso}\\\"\"\n execute_command(message,command)\n end\n return\nend",
"def create_kvm_instance(name, opts={})\n cmd = \"virt-install -n #{name} --ram #{opts[:memory]} --disk \" <<\n \"path=#{File.join(KVM_HOME, 'storage', \"#{name}.qcow2\")},device=disk,bus=virtio,format=qcow2 \" <<\n \"-v --import --noautoconsole --vcpus=#{opts[:vcpus]},maxvcpus=#{opts[:maxvcpus]}\" \n unless(system(cmd))\n raise \"Failed to create KVM instance!\"\n end \nend",
"def create_server(options = {})\n begin\n add_custom_attributes(options[:server_def])\n server = connection.servers.create(options[:server_def])\n\n print \"\\nWaiting For Server\"\n server.wait_for(Integer(options[:server_create_timeout])) do\n print '.'\n !locked?\n end\n\n # attach/or create any volumes.\n options[:server_volumes].each do |voldef|\n Chef::Log.debug(\"Volume definition: #{voldef}\")\n if voldef.key?(:size) || voldef.key?(:size_gb)\n # create a new volume\n result = connection.add_volume(server.id, voldef)\n name = (result / 'disk/name').first.text\n elsif voldef.key? :id\n server.attach_volume(voldef)\n name = voldef[:id]\n else\n raise CloudExceptions::ServerCreateError, \"cannot handle volume definition #{voldef}\"\n end\n\n print \"\\nAttached #{name} volume\"\n end\n\n print \"\\nWaiting For Volumes\"\n server.wait_for(Integer(options[:server_create_timeout])) do\n print '.'\n !locked?\n end\n Chef::Log.debug(\"options: #{options}\")\n server.start_with_cloudinit(user_data: options[:cloud_init])\n rescue Excon::Error::BadRequest => e\n response = Chef::JSONCompat.from_json(e.response.body)\n message = if response['badRequest']['code'] == 400\n \"Bad request (400): #{response['badRequest']['message']}\"\n else\n \"Unknown server error (#{response['badRequest']['code']}): #{response['badRequest']['message']}\"\n end\n ui.fatal(message)\n raise CloudExceptions::ServerCreateError, message\n rescue Fog::Errors::Error => e\n raise CloudExceptions::ServerCreateError, e.message\n end\n\n print \"\\n#{ui.color(\"Waiting for server [wait time = #{options[:server_create_timeout]}]\", :magenta)}\"\n\n # wait for it to be ready to do stuff\n server.wait_for(Integer(options[:server_create_timeout])) do\n print '.'\n ready?\n end\n\n puts(\"\\n\")\n server\n end",
"def volume(options)\n options[:width] * options[:height] * options[:depth]\nend",
"def create_vbd(vm_ref, vdi_ref, position)\n vbd_record = {\n \"VM\" => vm_ref,\n \"VDI\" => vdi_ref,\n \"empty\" => false,\n \"other_config\" => {\"owner\"=>\"\"},\n \"userdevice\" => position.to_s,\n \"bootable\" => true,\n \"mode\" => \"RW\",\n \"qos_algorithm_type\" => \"\",\n \"qos_algorithm_params\" => {},\n \"qos_supported_algorithms\" => [],\n \"type\" => \"Disk\"\n }\n\n task = xapi.Async.VBD.create(vbd_record)\n ui.msg \"Waiting for VBD create\"\n vbd_ref = get_task_ref(task) \n end",
"def createEBSSnapshot(client=nil,description='',volume_id=nil)\n return false if volume_id.nil? || client.nil?\n # Fetch the Volume Name. This will be used in the description of the snapshot\n resp = client.describe_volumes({dry_run: false, volume_ids: [volume_id] })\n resp.volumes[0].tags.each do |t|\n if t.key=='Name'\n description = t.value unless t.value.empty?\n break\n end\n end\n # puts \"Taking snapshot of volume #{volume_id}...\"\n return client.create_snapshot({\n dry_run: false,\n volume_id: volume_id,\n description: description\n })\nend",
"def get_volume\n @volume\n end",
"def create_volume_dir(volume,olddirname)\n\t\tfname= \"#{self.class.name}.#{__method__}\"\n\t\tif !olddirname.blank? && volume.dir_name != olddirname\n\t\t\tret=nil\n\t\t\tself.errors.add :base, \"The directory of database volume can't be moved\"\n\t\telse\n\t\t\tret = vol_table_name(volume)\n\t\t\tVolumeTablesBinary.init_table(ret)\n\t\tend\n\t\tLOG.debug(fname) {\"ret=#{ret}\"}\n\t\tret\n\tend",
"def volume_from(name)\n volumes << VolumeFrom.new(name)\n end",
"def set_volume\n @volume = Volume.find(params[:id])\n end",
"def set_volume\n @volume = Volume.find(params[:id])\n end",
"def volume(level = nil)\n level.nil? ? Integer(connection.write(\"volume\", false)) : connection.write(\"volume #{Integer(level)}\")\n rescue ArgumentError\n level.nil? ? 0 : nil\n end",
"def attach_node_volume (volume_label)\n # XXX should check whether this device name is already allocated,\n # and if so throw an exception\n # Helper method, attach an arbitrary volume using an arbitrary label that must be preconfigured in nodes\n Chef::Log.info(\"In attach_node_volume with volume_label #{volume_label}\")\n mount_device = node.application_attributes[volume_label].mount_device\n volume_id = node.application_attributes[volume_label].volume_id\n\n if mount_device.nil?\n Chef::Log.fatal(\"No mount device for volume label #{volume_label}.\tMust supply a volume label configured in nodes\")\n raise\n end\n\n attach_volume(volume_label, volume_id, mount_device)\n end",
"def create\n @vdisk = Vdisk.new(params[:vdisk])\n\n respond_to do |format|\n if @vdisk.save\n format.html { redirect_to @vdisk, notice: 'Vdisk was successfully created.' }\n format.json { render json: @vdisk, status: :created, location: @vdisk }\n else\n format.html { render action: \"new\" }\n format.json { render json: @vdisk.errors, status: :unprocessable_entity }\n end\n end\n end",
"def attach_volumes!(server, volumes_count, size)\n #create a new block storage connection obj\n volume_service = Fog::Volume::OpenStack.new(\n :openstack_api_key => @os_password,\n :openstack_username => @os_username,\n :openstack_auth_url => @os_auth_url,\n :openstack_tenant => @os_tenant,\n )\n base = 'sdd'\n volumes_count.times do |i|\n base = base.next!\n #create a new volume\n vol = volume_service.volumes.create(\n :size => size,\n :display_name => \"#{server.name}-#{i}\",\n :description => \"Volume attached to #{server.name} - managed by ankus\"\n )\n vol.reload\n vol.wait_for { status == 'available' }\n server.attach_volume(vol.id, \"/dev/#{base}\")\n vol.wait_for { status == 'in-use' }\n end\n end",
"def definition(opts)\n opts = check_params(opts,[:volumes])\n super(opts)\n end",
"def determine_volume\n vol = currently_attached_volume(instance_id, new_resource.device)\n vol_id = new_resource.volume_id || volume_id_in_node_data || ( vol ? vol[:aws_id] : nil )\n raise \"volume_id attribute not set and no volume id is set in the node data for this resource (which is populated by action :create) and no volume is attached at the device\" unless vol_id\n\n # check that volume exists\n vol = volume_by_id(vol_id)\n raise \"No volume with id #{vol_id} exists\" unless vol\n\n vol\n end",
"def init_ebs_volumes\n @@client.describe_volumes.volumes\n end",
"def attach_volume( options = {} )\n options = { :volume_id => '' }.merge(options)\n options = { :instance_id => '' }.merge(options)\n options = { :device => '' }.merge(options)\n raise ArgumentError, \"No :volume_id provided\" if options[:volume_id].nil? || options[:volume_id].empty?\n raise ArgumentError, \"No :instance_id provided\" if options[:instance_id].nil? || options[:instance_id].empty?\n raise ArgumentError, \"No :device provided\" if options[:device].nil? || options[:device].empty?\n\n params = {\n \"VolumeId\" => options[:volume_id],\n \"InstanceId\" => options[:instance_id],\n \"Device\" => options[:device]\n }\n return response_generator(:action => \"AttachVolume\", :params => params)\n end",
"def clone_volume(source, target)\n debug(\"Creating Libvirt volume #{target}\")\n debug(\"Cloning volume from #{source}\")\n\n # Attempt to locate the target or source volume\n source_image = client.volumes.get(source)\n if source_image.name =~ /^fog-\\d+/\n error(\"Could not find target image: #{source}.\")\n end\n\n # Clone the source volume\n source_image.clone_volume(target)\n client.volumes.all.find { |vol| vol.name == target }\n end",
"def volume \n puts \"The volume is #{@length * @width * @height}\"\n end",
"def create\n Dir.mkdir dir\n File.symlink Hoboku.project_dir, File.join(dir, 'src')\n vm.write_vagrantfile\n vm.start\n end",
"def create(size)\n disk_id = uuid\n sh \"zfs create -o reservation=1024 -o quota=1024 #{base}/#{disk_id}\"\n disk_id\n end",
"def create_ebs_stripe(nickname, new_volume_size_in_gb, options = {})\n self.execute_terminate_volumes if options[:force]\n devices = @disk.generate_physical_device_names(options[:stripe])\n each_volume_size = (new_volume_size_in_gb / options[:stripe].to_f).ceil\n devices.each do |d| \n vol = self.create_volume(:nickname => \"#{nickname}-#{d}\", \n :description => \"Created by RS tools to initialize new EBS stripe volume\",\n :size => each_volume_size)\n raise vol unless vol['aws_id']\n \"Attaching new EBS volume: #{vol['aws_id']}\"\n att = self.attach_volume(vol['aws_id'], d)\n end\n devices.each {|d| self.wait_for_attachment(d) }\n\n @disk.initialize_stripe(devices)\n end",
"def create_volume_with_http_info(id, volume, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: VolumesApi.create_volume ...'\n end\n # verify the required parameter 'id' is set\n if @api_client.config.client_side_validation && id.nil?\n fail ArgumentError, \"Missing the required parameter 'id' when calling VolumesApi.create_volume\"\n end\n # verify the required parameter 'volume' is set\n if @api_client.config.client_side_validation && volume.nil?\n fail ArgumentError, \"Missing the required parameter 'volume' when calling VolumesApi.create_volume\"\n end\n # resource path\n local_var_path = '/projects/{id}/storage'.sub('{' + 'id' + '}', CGI.escape(id.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body] || @api_client.object_to_http_body(volume)\n\n # return_type\n return_type = opts[:debug_return_type] || 'Volume'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['x_auth_token']\n\n new_options = opts.merge(\n :operation => :\"VolumesApi.create_volume\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: VolumesApi#create_volume\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def create_vlan_dev(options)\n OpenNebula.log_error(\"create_vlan_dev function not implemented.\")\n\n exit -1\n end",
"def set_volume\n @volume = services.block_storage.get_volume(params[:id])\n end",
"def volume(level = nil)\n return Integer(connection.write(\"volume\", false)) if level.nil?\n connection.write(\"volume #{Integer(level)}\")\n rescue ArgumentError\n level.nil? ? 0 : nil\n end",
"def volume(level = nil)\n return Integer(connection.write(\"volume\", false)) if level.nil?\n connection.write(\"volume #{Integer(level)}\")\n rescue ArgumentError\n level.nil? ? 0 : nil\n end",
"def execute\n log.info 'Creating the Basic VM'\n placement_spec = VMPlacementHelper.get_placementspec_vm(service_manager.vapi_config, datacenter_name, folder_name, datastore_name)\n standard_network = NetworkHelper.get_standard_network_mapping(service_manager.vapi_config, @datacenter_name, standard_portgroup_name)\n boot_disk = VCENTER_HARDWARE_DISK_CLASS::CreateSpec.new('type' => VCENTER_HARDWARE_DISK_CLASS::HostBusAdapterType::SCSI,\n 'scsi' => VCENTER_HARDWARE_MODULE::ScsiAddressSpec.new('bus'=>0,'unit'=>0),\n 'new_vmdk' => VCENTER_HARDWARE_DISK_CLASS::VmdkCreateSpec.new() )\n data_disk = VCENTER_HARDWARE_DISK_CLASS::CreateSpec.new('new_vmdk' => VCENTER_HARDWARE_DISK_CLASS::VmdkCreateSpec.new())\n ethernet_nic_0 = VCENTER_HARDWARE_ETHERNET_CLASS::CreateSpec.new('start_connected' => true,\n 'backing' => VCENTER_HARDWARE_ETHERNET_CLASS::BackingSpec.new(\n 'type' => VCENTER_HARDWARE_ETHERNET_CLASS::BackingType::STANDARD_PORTGROUP,\n 'network' => standard_network))\n boot_device_order = [VCENTER_HARDWARE_BOOT_DEVICE_CLASS::EntryCreateSpec.new('type' => VCENTER_HARDWARE_BOOT_DEVICE_CLASS::Type::ETHERNET),\n VCENTER_HARDWARE_BOOT_DEVICE_CLASS::EntryCreateSpec.new('type' => VCENTER_HARDWARE_BOOT_DEVICE_CLASS::Type::DISK)]\n vm_create_spec = VCENTER_VM_CLASS::CreateSpec.new('name' => vm_name,\n 'guest_OS' => VCENTER_VM_GUESTOS_CLASS::WINDOWS_8_64,\n 'placement' => placement_spec,\n 'disks' => [boot_disk, data_disk],\n 'nics' => [ethernet_nic_0],\n 'boot_devices' => boot_device_order)\n log.info 'The CreateVM Spec is '\n #Pretty print the create spec of the VM.\n pp vm_create_spec\n vm_id = vm_svc.create(vm_create_spec)\n log.info \"Created vm #{vm_name} with the VM Identifier #{vm_id}\"\n end",
"def create_vbd(vm_ref, vdi_ref, position, boot = true)\n vbd_record = {\n 'VM' => vm_ref,\n 'VDI' => vdi_ref,\n 'empty' => false,\n 'other_config' => { 'owner' => '' },\n 'userdevice' => position.to_s,\n 'bootable' => boot,\n 'mode' => 'RW',\n 'qos_algorithm_type' => '',\n 'qos_algorithm_params' => {},\n 'qos_supported_algorithms' => [],\n 'type' => 'Disk'\n }\n\n task = xapi.Async.VBD.create(vbd_record)\n ui.msg 'Waiting for VBD create'\n vbd_ref = get_task_ref(task)\n vbd_ref\n end",
"def volume_inspect\n help = [\n '',\n \"Use: #{me} volume inspect VOLUME\",\n '',\n 'Displays details of the named cyber-dojo volume',\n ]\n # asked for help?\n vol = ARGV[2]\n if [nil,'help','--help'].include? vol\n show help\n exit failed\n end\n\n # TODO: check for unknown args\n\n exit_unless_is_cyber_dojo_volume(vol, 'inspect')\n\n command =\n [\n 'docker run',\n '--rm',\n \"--user=root\",\n \"--volume=#{vol}:/data:#{read_only}\",\n '--volume=/var/run/docker.sock:/var/run/docker.sock',\n \"#{cyber_dojo_hub}/web:#{docker_version}\",\n \"sh -c 'cd /usr/src/cyber-dojo/cli && ./volume_inspect.rb /data'\"\n ].join(space=' ')\n\n print run(command)\nend",
"def create_command\n name = get_param(\"name=\", \"([a-zA-Z]+)\")\n animal_type = get_param(\"type=\", \"([a-zA-Z]+)\")\n\n created = false\n\n if name\n created = @app.create_animal(name, animal_type)\n else\n puts \"Error!: A name is required to create an animal\"\n create_command_help()\n end\n end",
"def attach_volumes(node, disk_sizes)\n if $provider == :virtualbox\n node.vm.provider :virtualbox do |v, override|\n disk_num = 0\n disk_sizes.each do |disk_size|\n disk_num += 1\n diskname = File.join(File.dirname(File.expand_path(__FILE__)), \".virtualbox\", \"#{node.vm.hostname}-#{disk_num}.vdi\")\n unless File.exist?(diskname)\n v.customize ['createhd', '--filename', diskname, '--size', disk_size * 1024]\n end\n v.customize ['storageattach', :id, '--storagectl', 'SATA Controller', '--port', disk_num, '--device', 0, '--type', 'hdd', '--medium', diskname]\n end\n end\n end\n\n if $provider == :vmware_fusion\n node.vm.provider :vmware_fusion do |v, override|\n vdiskmanager = '/Applications/VMware\\ Fusion.app/Contents/Library/vmware-vdiskmanager'\n unless File.exist?(vdiskmanager)\n dir = File.join(File.dirname(File.expand_path(__FILE__)), \".vmware\")\n unless File.directory?( dir )\n Dir.mkdir dir\n end\n\n disk_num = 0\n disk_sizes.each do |disk_size|\n disk_num += 1\n diskname = File.join(dir, \"#{node.vm.hostname}-#{disk_num}.vmdk\")\n unless File.exist?(diskname)\n `#{vdiskmanager} -c -s #{disk_size}GB -a lsilogic -t 1 #{diskname}`\n end\n\n v.vmx[\"scsi0:#{disk_num}.filename\"] = diskname\n v.vmx[\"scsi0:#{disk_num}.present\"] = 'TRUE'\n v.vmx[\"scsi0:#{disk_num}.redo\"] = ''\n end\n end\n end\n end\n\n if $provider == :parallels\n node.vm.provider :parallels do |v, override|\n disk_sizes.each do |disk_size|\n v.customize ['set', :id, '--device-add', 'hdd', '--size', disk_size * 1024]\n end\n end\n end\n\nend",
"def create\n @volume_type_extra_spec = VolumeTypeExtraSpec.new(params[:volume_type_extra_spec])\n\n respond_to do |format|\n if @volume_type_extra_spec.save\n format.html { redirect_to @volume_type_extra_spec, notice: 'Volume type extra spec was successfully created.' }\n format.json { render json: @volume_type_extra_spec, status: :created, location: @volume_type_extra_spec }\n else\n format.html { render action: \"new\" }\n format.json { render json: @volume_type_extra_spec.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t type = @params[0].split('.')\n\n\t if type[1]\n\n\t if @params[1]\n\t FileUtils.touch(@params[1]+'/'+@params[0])\n\t else\n\t FileUtils.touch(@params[0])\n\t end\n\t else\n\t if @params[1]\n\t FileUtils::mkdir_p @params[1]+'/'+@params[0]\n\t else\n\t FileUtils::mkdir_p @params[0]\n\t end\n\t end\n\t end",
"def volume\n @length * @width * @depth\n end",
"def lv_create_size_in_kb(logical_volume_name, volume_group, size_in_kb)\n External.cmd(@server, \"#{@command} lvcreate -l #{size_in_kb} -n #{logical_volume_name} #{volume_group.name}\") if volume_group_check_space_in_kb(volume_group,size_in_kb)\n end",
"def volume (l, w, h)\n\tl * w * h\nend",
"def add_volume(bucket,mount,options=nil)\n s3fs_volumes << { :bucket => bucket, :mount => mount, :options => options }\n end",
"def add_hdd_to_vbox_vm(client_name,vbox_disk_name)\n message = \"Attaching:\\tStorage to VM \"+client_name\n command = \"VBoxManage storageattach \\\"#{client_name}\\\" --storagectl \\\"#{$vbox_disk_type}\\\" --port 0 --device 0 --type hdd --medium \\\"#{vbox_disk_name}\\\"\"\n execute_command(message,command)\n return\nend",
"def volume_ls\n help = [\n '',\n \"Use: #{me} volume ls\",\n '',\n 'Lists the names of all cyber-dojo volumes',\n '',\n minitab + '--quiet Only display volume names'\n ]\n\n if ['help','--help'].include? ARGV[2]\n show help\n exit failed\n end\n\n # There is currently no [--filter label=LABEL] option on [docker volume ls]\n # https://github.com/docker/docker/pull/21567\n # So I have to inspect all volumes. Could be slow if lots of volumes.\n\n names = run(\"docker volume ls --quiet\").split\n names = names.select{ |name| cyber_dojo_volume?(name) }\n\n if ARGV[2] == '--quiet'\n names.each { |name| puts name }\n else\n types = names.map { |name| cyber_dojo_type(name) }\n urls = names.map { |name| cyber_dojo_label(name) }\n\n headings = { :name => 'NAME', :type => 'TYPE', :url => 'SRC' }\n\n gap = 3\n max_name = ([headings[:name]] + names).max_by(&:length).length + gap\n max_type = ([headings[:type]] + types).max_by(&:length).length + gap\n max_url = ([headings[:url ]] + urls ).max_by(&:length).length + gap\n\n spaced = lambda { |max,s| s + (space * (max - s.length)) }\n\n name = spaced.call(max_name, headings[:name])\n type = spaced.call(max_type, headings[:type])\n url = spaced.call(max_url , headings[:url ])\n puts name + type + url\n names.length.times do |n|\n name = spaced.call(max_name, names[n])\n type = spaced.call(max_type, types[n])\n url = spaced.call(max_url , urls[n])\n puts name + type + url\n end\n end\nend",
"def create_vlan_dev\n converge_it(\"Create VLAN adapter #{new_resource.device}\") do\n shell_out = Mixlib::ShellOut.new(\"powershell.exe -Command \\\"New-NetlbfoTeam -Name '#{new_resource.device}' -TeamMembers '#{new_resource.device}-NIC' -Confirm:$False\\\"\")\n shell_out.run_command\n shell_out.error!\n end\n end"
] | [
"0.8132278",
"0.8132278",
"0.7921072",
"0.78841376",
"0.75485444",
"0.74330443",
"0.7336266",
"0.7272421",
"0.72379214",
"0.7168302",
"0.70387924",
"0.6966309",
"0.6957829",
"0.6932734",
"0.6885475",
"0.68473226",
"0.6844902",
"0.68243796",
"0.6798225",
"0.6669368",
"0.6601246",
"0.6580839",
"0.6576584",
"0.65656084",
"0.6535268",
"0.65018255",
"0.6439729",
"0.6433719",
"0.6421508",
"0.6392832",
"0.63682306",
"0.6354998",
"0.63502085",
"0.6279396",
"0.62792695",
"0.62472516",
"0.6166684",
"0.61659867",
"0.6150813",
"0.6137604",
"0.61302334",
"0.61001843",
"0.60824263",
"0.60801524",
"0.6059731",
"0.6043142",
"0.60329956",
"0.60322624",
"0.603201",
"0.6018504",
"0.60036075",
"0.59998196",
"0.5994664",
"0.59943426",
"0.5953283",
"0.59460384",
"0.5922277",
"0.5921986",
"0.5903068",
"0.58930075",
"0.589177",
"0.58836585",
"0.5870953",
"0.58628887",
"0.5861801",
"0.585892",
"0.585425",
"0.585425",
"0.5848379",
"0.58412313",
"0.58346164",
"0.58178645",
"0.5809752",
"0.57647866",
"0.5764407",
"0.5760577",
"0.5757289",
"0.57546145",
"0.57401043",
"0.5740021",
"0.57305276",
"0.5721466",
"0.57128894",
"0.5710899",
"0.56946355",
"0.56946355",
"0.5694008",
"0.5690084",
"0.5657064",
"0.56561303",
"0.5651991",
"0.5647022",
"0.56443363",
"0.5631288",
"0.5631082",
"0.5623543",
"0.5621994",
"0.56054187",
"0.5596143",
"0.5573671"
] | 0.74419034 | 5 |
========================================================================================= $ ./cyberdojo volume ls ========================================================================================= | def volume_ls
help = [
'',
"Use: #{me} volume ls",
'',
'Lists the names of all cyber-dojo volumes',
'',
minitab + '--quiet Only display volume names'
]
if ['help','--help'].include? ARGV[2]
show help
exit failed
end
# There is currently no [--filter label=LABEL] option on [docker volume ls]
# https://github.com/docker/docker/pull/21567
# So I have to inspect all volumes. Could be slow if lots of volumes.
names = run("docker volume ls --quiet").split
names = names.select{ |name| cyber_dojo_volume?(name) }
if ARGV[2] == '--quiet'
names.each { |name| puts name }
else
types = names.map { |name| cyber_dojo_type(name) }
urls = names.map { |name| cyber_dojo_label(name) }
headings = { :name => 'NAME', :type => 'TYPE', :url => 'SRC' }
gap = 3
max_name = ([headings[:name]] + names).max_by(&:length).length + gap
max_type = ([headings[:type]] + types).max_by(&:length).length + gap
max_url = ([headings[:url ]] + urls ).max_by(&:length).length + gap
spaced = lambda { |max,s| s + (space * (max - s.length)) }
name = spaced.call(max_name, headings[:name])
type = spaced.call(max_type, headings[:type])
url = spaced.call(max_url , headings[:url ])
puts name + type + url
names.length.times do |n|
name = spaced.call(max_name, names[n])
type = spaced.call(max_type, types[n])
url = spaced.call(max_url , urls[n])
puts name + type + url
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_all_volumes\n Docker::Volume.all({}, client)\n rescue\n []\n end",
"def list_volumes\n response = @connection.req(\"GET\", \"/#{@volume_path}\")\n volumes_hash = JSON.parse(response.body)[\"volumes\"]\n volumes_hash.inject([]){|res, current| res << OpenStack::Volume::Volume.new(current); res}\n end",
"def volume_names\n pool.list_volumes\n end",
"def list(opts)\n opts = check_params(opts,[:volume])\n super(opts)\n end",
"def volumes_list(state = \"active\", limit = \"1000\")\n case state\n when \"active\"\n api_call = {\n :method => \"ListActiveVolumes\",\n :params => {\n :startVolumeID => 0,\n :limit => limit\n }\n }\n when \"deleted\"\n api_call = {\n :method => \"ListDeletedVolumes\",\n :params => {}\n }\n end\n answer = query_sf(api_call)\n return answer[\"volumes\"]\n end",
"def volumes\n client = Aws::EC2::Client.new\n client.describe_volumes({\n filters: [{\n name: \"tag:backup\",\n values: [\"true\"]\n }]\n }).volumes\nend",
"def volume\n help = [\n '',\n \"Use: #{me} volume [COMMAND]\",\n '',\n 'Manage cyber-dojo setup volumes',\n '',\n 'Commands:',\n minitab + 'create Creates a new volume',\n minitab + 'rm Removes a volume',\n minitab + 'ls Lists the names of all volumes',\n minitab + 'inspect Displays details of a volume',\n minitab + \"pull Pulls the docker images inside a volume's manifest.json files\",\n '',\n \"Run '#{me} volume COMMAND --help' for more information on a command\",\n ]\n case ARGV[1]\n when 'create' then volume_create\n when 'rm' then volume_rm\n when 'ls' then volume_ls\n when 'inspect' then volume_inspect\n when 'pull' then volume_pull\n else show help\n end\nend",
"def volumes\n service.list_pool_volumes uuid\n end",
"def get_volumes\n volumes = get(\"cloud-instances/#{guid}/volumes\")[\"volumes\"] || []\n\n volumes.map do |volume|\n get_volume(volume[\"volumeID\"])\n end\n end",
"def init_ebs_volumes\n @@client.describe_volumes.volumes\n end",
"def volume_inspect\n help = [\n '',\n \"Use: #{me} volume inspect VOLUME\",\n '',\n 'Displays details of the named cyber-dojo volume',\n ]\n # asked for help?\n vol = ARGV[2]\n if [nil,'help','--help'].include? vol\n show help\n exit failed\n end\n\n # TODO: check for unknown args\n\n exit_unless_is_cyber_dojo_volume(vol, 'inspect')\n\n command =\n [\n 'docker run',\n '--rm',\n \"--user=root\",\n \"--volume=#{vol}:/data:#{read_only}\",\n '--volume=/var/run/docker.sock:/var/run/docker.sock',\n \"#{cyber_dojo_hub}/web:#{docker_version}\",\n \"sh -c 'cd /usr/src/cyber-dojo/cli && ./volume_inspect.rb /data'\"\n ].join(space=' ')\n\n print run(command)\nend",
"def volumes_list(options = {})\n state = options.fetch(:state, 'active')\n startid = options.fetch(:startid, 0)\n limit = options.fetch(:limit, 1000)\n accounts = options.fetch(:accountid, nil)\n name = options.fetch(:name, nil)\n \n if name\n api_call = {\n :method => \"ListVolumes\",\n :params => {\n :VolumeName => name,\n :limit => 1\n }\n }\n elsif accounts\n accounts = [ accounts ] if accounts.class == String || Integer\n api_call = {\n :method => \"ListVolumes\",\n :params => {\n :accounts => accounts,\n :limit => limit\n }\n }\n else\n api_call = {\n :method => \"ListVolumes\",\n :params => {\n :VolumeStatus => state,\n :startVolumeID => startid,\n :limit => limit\n }\n }\n end\n\n answer = query_sf(api_call)\n return answer[\"volumes\"]\n end",
"def volumes\n @volumes.to_a.freeze\n end",
"def retrieve_volumes\n dbg { \"retrieving #{pool_info}, #{hv_info}\" }\n\n volumes = pool.list_all_volumes\n dbg { \"list_all_volumes #{pool_info}, #{hv_info}\" }\n\n storage_volumes = volumes.map.with_index do |vol, index|\n id = \"#{uuid}--#{index}\"\n StorageVolume.new(vol, pool: self, id: id)\n end\n\n dbg { \"retrieved size=#{storage_volumes.size}, #{pool_info}, #{hv_info}\" }\n storage_volumes\n end",
"def get_volume\n @volume\n end",
"def volume\n app.speakers.ID(@id).volume.get\n end",
"def ls(path = \"\")\n\t\tcmd 'ls ' + path.to_s\n\tend",
"def volume _value, _abs=0\n send_cmd(\"volume #{_value} #{_abs}\")\n end",
"def mounts\r\n @mounts.list\r\n end",
"def volumes\n volumes = @ec2.volumes\n volumes.delete_if {|v| v.instance_id != id}\n end",
"def get_volume()\n return(get_cmd('AG;',0.1,0.5,3).gsub(/^AG/,'').gsub(/;$/,'').to_i)\nend",
"def get_volume(volume_id)\n get(\"cloud-instances/#{guid}/volumes/#{volume_id}\")\n end",
"def getVolumes\n require 'rest_client'\n require 'uri'\n\n if @role.nil? and !current_actor.superadmin\n json_response({ message: \"You don't have permission to view volumes\" }, :unauthorized)\n return\n end\n\n # Env variables for Manager host and port\n serviceManagerHost = Settings.service_manager_host\n serviceManagerPort = Settings.service_manager_port.to_s\n serviceManagerURI = 'http://' + serviceManagerHost + ':' + serviceManagerPort + '/v1/volume'\n\n # Create request for Service Manager\n stack = {\n 'engine-url' => @cluster.endpoint,\n 'ca-cert' => @cluster.ca,\n 'cert' => @cluster.cert,\n 'cert-key' => @cluster.key\n }.to_json\n\n begin\n response = RestClient.post(\n serviceManagerURI,\n stack,\n 'Accept' => 'application/json',\n 'Content-Type' => 'application/json'\n )\n puts \"Deploy Response: \" + response\n json_response(response, 200)\n rescue Exception => e\n # If error, respond with it\n puts e\n json_response({message: e}, :unprocessable_entity)\n end\n end",
"def list_partitions #by nelsongs\n\treturn `fdisk -l | grep /dev | grep -v Disk | awk '{print $1}'`.chomp.split\nend",
"def lvm_root(volume_group)\n %x{lvdisplay #{volume_group} 2>/dev/null| grep root}.split(' ').last.strip\nend",
"def root_volumes\n volumes.select {|vol| vol.parent_id == nil}\n end",
"def index\n @volumes = Volume.all\n end",
"def index\n @volumes = Volume.all\n end",
"def volume\n @cr[0xe] & 0x0f\n end",
"def volume_pull\n help = [\n '',\n \"Use: #{me} volume pull VOLUME\",\n '',\n 'Pulls all the docker images named inside the cyber-dojo volume'\n ]\n vol = ARGV[2]\n if [nil,'help','--help'].include? vol\n show help\n exit failed\n end\n\n exit_unless_is_cyber_dojo_volume(vol, 'pull')\n\n command =\n [\n 'docker run',\n '--rm',\n '--tty',\n \"--user=root\",\n \"--volume=#{vol}:/data:#{read_only}\",\n '--volume=/var/run/docker.sock:/var/run/docker.sock',\n \"#{cyber_dojo_hub}/web:#{docker_version}\",\n \"sh -c 'cd /usr/src/cyber-dojo/cli && ./volume_pull.rb /data'\"\n ].join(space=' ')\n\n system(command)\nend",
"def do_volume(num)\n\n fail CvlcClientError, \"The 'volume' command requires an integer value between 0 and 300...\" unless num.between?(0, 300)\n do_command(\"requests/status.json?command=volume&val=#{num}\")\n sleep STATUS_PAUSE\n return pretty_status(current_status)\n end",
"def tags\n # Strangely, this only lists the first snapshot. If you remove '-o name', it lists them all\n #command = \"zfs list -H -r -t snapshot -o name #{@dataset}/share\"\n command = \"ls -1 #{@mountpoint}/share/.zfs/snapshot\"\n logger.debug \"running: #{command}\"\n `#{command}`.chomp.split(/\\n/).map { |x| x.sub(/.*@/, '') }\n end",
"def volume; property('volume'); end",
"def getmountedvolumes\n # only support Linux for now\n return {} unless Facter['kernel'] && Facter['kernel'].value == 'Linux'\n\n dir = \"/etc\"\n mounted = {}\n\n # AUTOFS - gather only files named auto[._]*\n Dir.glob(File.join(dir, \"*\")).each do |file|\n next if file !~ /^auto[._].*/\n\n # AUTOFS - match only lines that look like nfs syntax such as host:/path\n IO.foreach(file) do |line|\n if line =~ /\\w:\\S/ && line !~ /^\\s*#/\n # Parse it, Example : \" nventory_backup -noatime,intr irvnetappbk:/vol/nventory_backup \"\n if line =~ /^(\\w[\\w\\S]+)\\s+\\S+\\s+(\\w[\\w\\S]+):(\\S+)/\n mnt = $1\n host = $2\n vol = $3\n mounted[\"volumes[mounted][/mnt/#{mnt}][config]\"] = file\n mounted[\"volumes[mounted][/mnt/#{mnt}][volume_server]\"] = host\n mounted[\"volumes[mounted][/mnt/#{mnt}][volume]\"] = vol\n mounted[\"volumes[mounted][/mnt/#{mnt}][type]\"] = 'nfs'\n end\n end\n end # IO.foreach\n end # Dir.glob\n\n # FSTAB - has diff syntax than AUTOFS. Example: \"server:/usr/local/pub /pub nfs rsize=8192,wsize=8192,timeo=14,intr\"\n IO.foreach(\"/etc/fstab\") do |line|\n if line =~ /^(\\w[\\w\\S]+):(\\S+)\\s+(\\S+)\\s+nfs/\n host = $1\n vol = $2\n mnt = $3\n mounted[\"volumes[mounted][#{mnt}][config]\"] = \"/etc/fstab\"\n mounted[\"volumes[mounted][#{mnt}][volume_server]\"] = host\n mounted[\"volumes[mounted][#{mnt}][volume]\"] = vol\n mounted[\"volumes[mounted][#{mnt}][type]\"] = 'nfs'\n end\n end # IO.foreach\n return mounted\n end",
"def list_kvms\n info = Hash[\n *Dir.glob(File.join(KVM_HOME, 'storage', '*.qcow2')).map{|dir|\n key = File.basename(dir).sub('.qcow2', '')\n [key, {:address => kvm_ip(key), :type => kvm_type(key)}]\n }.sort{|a,b|\n a.first <=> b.first\n }.flatten\n ]\n info.each do |name, info|\n puts \"#{name}\"\n puts \" Type: #{info[:type]}\"\n puts \" Address: #{info[:address]}\"\n end\nend",
"def volume\n $redis_pool.with { |redis| redis.get('warble:volume').to_i }\n end",
"def get_volume_id(sys_id,volume_name)\n response = request(:get, \"/devmgr/v2/storage-systems/#{sys_id}/volumes\")\n status(response, 200, 'Failed to get Volumes')\n volumes = JSON.parse(response.body)\n volumes.each do |vm|\n \t return vm['id'] if vm['name'] == volume_name\n \tend\n response = request(:get, \"/devmgr/v2/storage-systems/#{sys_id}/thin-volumes\")\n status(response, 200, 'Failed to get thin Volumes')\n volumes = JSON.parse(response.body)\n volumes.each do |vm|\n return vm['id'] if vm['name'] == volume_name\n end\n \tfalse\n end",
"def index\n @actual_volumes = ActualVolume.all\n end",
"def name\n self['VolumeName']\n end",
"def detachvolume\n false\n end",
"def volinfo(compute,name)\n\t\tvolumes = compute.describe_volumes\n\t\tif (volumes.status == 200)\n\t\t\t# check each of the volumes in our availability zone which match our name.\n\t\t\tvolumes.body['volumeSet'].each {|x|\n\t\t\t\t# Match the name unless the volume is actually being deleted...\n\t\t\t\tif (x['tagSet']['Name'] == resource[:volume_name] )\n\t\t\t\t\t#print \"ebsvol[aws]->volinfo: Volume #{x['volumeId']} has Name = #{resource[:volume_name]}\\n\" if $debug\n\t\t\t\t\treturn x\n\t\t\t\tend\n\t\t\t}\n\t\telse\n\t\t\traise \"ebsvol[aws]->volinfo: I couldn't list the ebsvolumes\"\n\t\tend\n\t\tnil\n\tend",
"def get_vol\n\t\tIO::popen('amixer sget Master') do |f|\n\t\t\tf.read.scan(/Front Left.*?\\[(\\d+)%\\].*?\\[(on|off)\\]\\n/) do |pc, on_or_off|\n\t\t\t\treturn {\n\t\t\t\t\t:vol => pc.to_i,\n\t\t\t\t\t:mute => 'off' == on_or_off\n\t\t\t\t}\n\t\t\tend\n\t\tend\n\t\treturn { :vol => -1, :mute => false }\n\tend",
"def volumes\n Collection::StorageVolumeCollection.new(self)\n end",
"def populate_volume(server)\n server.spot_check_command(\" echo \\\"blah blah blah\\\" > #{@mount_point}/data.txt\")\n end",
"def do_ls()\n\t\tif @system_type == WINDOWS then \n\t\t\treturn %x(dir #{@path})\n\t\tend \n\t\tif @system_type == UNIX then \n\t\t\treturn %x(ls #{@path})\n\t\tend\n\tend",
"def get_osx_disk_name(options)\n message = \"Information:\\tGetting root disk device ID\"\n command = \"df |grep '/$' |awk '{print \\\\$1}'\"\n output = execute_command(options,message,command)\n disk_id = output.chomp\n message = \"Information:\\tGetting volume name for \"+disk_id\n command = \"diskutil info #{disk_id} | grep 'Volume Name' |cut -f2 -d':'\"\n output = execute_command(options,message,command)\n volume = output.chomp.gsub(/^\\s+/,\"\")\n return volume\nend",
"def ls(path = '.')\n Cd.cd.ls(path)\n end",
"def all_devices search = nil\n partitions = []\n devices = []\n device = nil\n has_extended = false\n if DEBUG_MODE or Platform.ubuntu? or Platform.fedora?\n command = \"lsblk\"\n params = \" #{search} -b -P -o VENDOR,MODEL,TYPE,SIZE,KNAME,UUID,LABEL,MOUNTPOINT,FSTYPE,RM\"\n end\n lsblk = CommandsExecutor.new command, params\n lsblk.execute\n raise \"Command execution error: #{lsblk.stderr.read}\" if not lsblk.success?\n\n lsblk.result.each_line do |line|\n data_hash = {}\n line.squish!\n line_data = line.gsub!(/\"(.*?)\"/, '\\1#').split \"#\"\n line_data.each do |data|\n data.strip!\n key, value = data.split \"=\"\n data_hash[key.downcase] = value\n end\n data_hash['rm'] = data_hash['rm'].to_i # rm = 1 if device is a removable/flash device, otherwise 0\n if data_hash['type'] == 'mpath'\n data_hash.except!('uuid', 'label', 'mountpoint', 'fstype')\n if device\n multipath_info = {'mkname' => data_hash['kname'], 'multipath' => true, 'size' => data_hash['size']}\n device.merge! multipath_info\n else\n data_hash['multipath'] = true\n device = data_hash\n devices.push device\n end\n next\n end\n if data_hash['type'] == 'disk'\n data_hash.except!('uuid', 'label', 'mountpoint', 'fstype')\n unless device.nil?\n device['partitions'] = partitions\n partitions = []\n devices.push device\n device = nil # cleanup the variable\n end\n device = data_hash\n next\n end\n if data_hash['type'] == 'part'\n data_hash.except!('model', 'vendor')\n data_hash.merge! self.usage data_hash['kname']\n\n partition_number = get_partition_number \"/dev/#{data_hash['kname']}\" # For reference: data_hash['kname'].match(/[0-9]*$/)[0].to_i\n extended_partition_types = ['0x05'.hex, '0x0F'.hex]\n if partition_type_hex(data_hash['kname']).in? extended_partition_types\n has_extended = true\n next\n end\n if has_extended and partition_number > 4\n data_hash['logical'] = true\n end\n # device['partitions'].nil? ? device['partitions'] = [data_hash] : device['partitions'].push(data_hash)\n partitions.push(data_hash)\n end\n end\n device['partitions'] = partitions if device\n devices.push device\n if search\n return devices.first || partitions.first\n else\n return devices\n end\n end",
"def guess_usb_volume( dirs_to_sync )\n volumes = Dir.entries(@usb_volumes_dir).reject do |f|\n f.match(/\\.\\.?/) \n end\n volumes.sort_by { |v|\n puts \"Checking volume #{v}\"\n dirs_to_sync.select{ |dts|\n File.directory?( File.join(@usb_volumes_dir, usb, dts))\n }.size\n }[0]\n end",
"def mount_list(www_root)\n arr = []\n %x{mount -t iso9660}.scan(/\\S+ on (\\S+)/) do |a|\n mountpoint = a[0]\n arr << mountpoint if mountpoint.match %r{#{www_root}}\n end\n arr\nend",
"def child_volumes(name)\n parent = volume_by_name(name)\n volumes.select {|vol| vol.parent_id == parent.volume_id}\n end",
"def disks\n self.config.hardware.device.grep(RbVmomi::VIM::VirtualDisk)\n end",
"def volume_from(name)\n volumes << VolumeFrom.new(name)\n end",
"def volumes_for_account(accountid)\n api_call = {\n :method => \"ListVolumesForAccount\",\n :params => {\n :accountID => accountid\n }\n }\n answer = query_sf(api_call)\n return answer\n end",
"def storage_list(mixins = nil)\n storages = Occi::Core::Resources.new\n\n Backends::Ec2::Helpers::AwsConnectHelper.rescue_aws_service(@logger) do\n volumes = @ec2_client.describe_volumes.volumes\n volumes.each do |volume|\n next unless volume\n storages << storage_parse_backend_obj(volume)\n end if volumes\n end\n\n storages\n end",
"def current\n c = IO::popen(\"pacmd \\\"list-sinks\\\" | grep volume | head -1\").readlines[0]\n return c.split(\" \").last.sub(\"%\", \"\").strip.to_i\nend",
"def show_vol()\n\t\tvm = get_vol\n\t\[email protected]=$muted_colors[vm[:mute]]\n\t\[email protected]='Volume'\n\t\[email protected] += ' (Muted)' if vm[:mute]\n\t\[email protected]=vm[:vol]\n\t\[email protected]=5\n\tend",
"def ebs_volumes\n @ebs_volumes ||= init_ebs_volumes.reject do |vol|\n vol.attachments.any? do |att|\n attached_instance = id_instances[att.instance_id]\n attached_instance.root_device_name == att.device\n end\n end\n end",
"def volumes_for_account(accountid)\n api_call = {\n :method => \"ListVolumesForAccount\",\n :params => {\n :volumeID => accountid\n }\n }\n answer = query_sf(api_call)\n return answer\n end",
"def related_storage_volumes\n related_volumes.find_all do |volume|\n volume.provider_name == \"compellent\" || volume.provider_name == \"vnx\"\n end\n end",
"def command_get_device_list(command)\n\t\tdir = File.join(@module_dir, \"device\", \"*.rb\")\n\t\tDir.glob(dir) {|file| message(\" #{File.basename(file, \".rb\")}\") }\n\tend",
"def volume_count\n return unless exists?\n Dir.glob(folder_pathname.join(\"**\")).count do |file|\n File.directory?(file)\n end\n end",
"def volume; self.class.volume; end",
"def volume_report\n get_resource_list('volume', 'volumes', 'volumes')\n @volume_csv_array = []\n @resource_id_list.each do |volumeid|\n volume = rest_get(\"#{@resource_url}/volumes/#{volumeid}\", @token_id)\n volume_array = JSON.parse(volume)['volume']\n volume_name = volume_array['name']\n volume_status = volume_array['status']\n volume_template = volume_array['volume_type']\n volume_size = volume_array['size']\n @volume_csv_headers = %w(Volume_Name Volume_Status Storage_Template Volume_Size)\n @volume_csv_array << [volume_name, volume_status, volume_template, volume_size]\n end\n end",
"def fetch_volume_by_id\n vol = storage_api.find_by_id(volume_id)\n data = vol.body.fetch(\"volume\")\n @name = data.fetch('display_name')\n @volume_type = data.fetch('volume_type')\n @size = data.fetch('size')\n\n # Sometimes the Rackspace API takes time to update,\n # and newly-attached volumes don't report any attachments\n # yet.\n attachments = data.fetch('attachments')\n if attachments.any?\n @device = attachments.first.fetch('device')\n end\n end",
"def list_volumes request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_list_volumes_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Cloud::BareMetalSolution::V2::ListVolumesResponse.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end",
"def volume\n player_iface['Volume']\n end",
"def cmd_list(param)\n send_unauthorised and return unless logged_in?\n send_response \"150 Opening ASCII mode data connection for file list\"\n\n param = '' if param.to_s == '-a'\n\n dir = File.join(@name_prefix.to_s, param.to_s)\n\n now = Time.now\n\n items = list_dir(build_path(param))\n lines = items.map do |item|\n \"#{item.directory ? 'd' : '-'}#{item.permissions || 'rwxrwxrwx'} 1 #{item.owner || 'owner'} #{item.group || 'group'} #{item.size || 0} #{(item.time || now).strftime(\"%b %d %H:%M\")} #{item.name}\"\n end\n send_outofband_data(lines)\n # send_action_not_taken\n end",
"def get(options = nil)\n super(options, 'host', GET_PARAMS, [:show_volume])\n end",
"def devices\n\texecute(\"devices\").split(\"\\n\")[1..-1]\nend",
"def existing_kvms\n Dir.glob(File.join(KVM_HOME, 'storage', '*.qcow2')).map do |file|\n File.basename(file).sub('.qcow2', '')\n end\nend",
"def list\n all.each { |device| puts(device.pretty_name) }\n end",
"def has_logical_volume_management\n super\n end",
"def volume(x)\n\t\tsynchronized do\n\t\t\[email protected] \"volume #{x}\"\n\t\tend\n\tend",
"def volume(volume_id)\n volumes(volume_id)[0]\n end",
"def currently_attached_volume(instance_id, device)\n ec2.describe_volumes.find{|v| v[:aws_instance_id] == instance_id && v[:aws_device] == device}\n end",
"def list_directories(client)\n client.directories.each do |directory|\n puts \"Directory: #{directory.name}\"\n puts \" Description: #{directory.description}\"\n puts \" Status: #{directory.status}\"\n puts \" Href: #{directory.href}\"\n end\nend",
"def display_host(hostname, partitions)\n volume_groups = {}\n lvm_members = []\n\n puts hostname\n partitions.keys.sort.each do |partition|\n if partitions[partition]['filesystem'] == 'LVM2_member'\n lvm_members << partition\n next\n end\n next if partition == '/dev/mapper/rootvg-swap'\n next if partition == '/dev/mapper/rootvg-afscache'\n next unless partition.match(/^\\/dev\\/mapper\\/(\\S+)-(\\S+)/)\n\n vg = $~[1]\n short_partition = $~[2]\n volume_groups[vg] = [] unless volume_groups.key?(vg)\n volume_groups[vg] << partition\n end\n\n puts \"LVM partitions: \" + lvm_members.sort.join(', ')\n puts 'lvm::volume_groups:'\n volume_groups.keys.sort.each do |vg|\n puts \" #{vg}:\"\n puts ' logical_volumes:'\n volume_groups[vg].sort.each do |partition|\n\n next unless partition.match(/^\\/dev\\/mapper\\/\\S+-(\\S+)/)\n short_partition = $~[1]\n\n # Skip the partition if it's an expected size.\n space = format_space(partition, partitions[partition]['size'].to_s)\n next if space.nil?\n\n # Find if this is a known volume and set the mount to nil then, so we\n # don't print in useless data.\n mount = format_mount(partition, partitions[partition]['mount'].to_s)\n\n puts ' ' + short_partition + ':'\n puts ' ' + 'size: ' + space\n puts ' ' + 'mountpath: ' + mount unless mount.nil?\n puts ' ' + 'fs_type: ' + partitions[partition]['filesystem'].to_s unless mount.nil?\n end\n end\n\n puts\nend",
"def lvm_volume_group(partition)\n %x{pvs --noheadings --separator ' ' #{partition} 2>/dev/null| sed -e 's/^\\s*//' | cut -d ' ' -f 2}.strip\nend",
"def physical_disk_views\n client.enumerate(\"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/root/DCIM/DCIM_PhysicalDiskView\")\n end",
"def mounts_info\n @mounts_info ||= vault_client.request(:get, \"/v1/sys/internal/ui/mounts\")\n rescue Vault::VaultError\n unable_to_determine_version\n raise\n end",
"def list_ks_vbox_vms()\n search_string = \"rhel|centos|ubuntu\"\n list_vbox_vms(search_string)\n return\nend",
"def list_volumes request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_list_volumes_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Cloud::NetApp::V1::ListVolumesResponse.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end",
"def mounted?(name)\n mount_loc = File.join(KVM_MOUNT_POINT, name)\n system(\"mount | grep #{mount_loc}\")\nend",
"def lsblk(device)\n partitions = {}\n blocklist = ''\n\n cmd =\"#{COMMANDS[:lsblk]} -OJ #{device}\"\n\n 3.times do |t| # wait for device to be ready to be parsed\n rc, o, e = Command.execute(cmd, false)\n\n if rc != 0 || o.empty?\n OpenNebula.log_error(\"#{__method__}: #{rc}, #{o}, #{e}\") if t == 3\n sleep 1\n next\n end\n\n blocklist = o\n break\n end\n\n begin\n partitions = JSON.parse(blocklist)['blockdevices']\n\n if !device.empty?\n partitions = partitions[0]\n\n if partitions['children']\n partitions = partitions['children']\n else\n partitions = [partitions]\n end\n\n partitions.delete_if do |p|\n p['fstype'].casecmp('swap').zero? if p['fstype']\n end\n end\n rescue StandardError\n OpenNebula.log_error(\"lsblk: error parsing lsblk -OJ #{device}\")\n return {}\n end\n\n # Fix for lsblk paths for version < 2.33\n partitions.each do |p|\n lsblk_path(p)\n\n p['children'].each {|q| lsblk_path(q) } if p['children']\n end\n\n partitions\n end",
"def find_volume_service(filter)\n select(&service?(filter))\n .find(&volume_mount?)\n end",
"def volume\n `#{@sound}.volume`\n end",
"def print_ls(path = '/')\n elements = ls(path)\n elements.each do |e|\n puts e.longname\n end\n end",
"def mount_kvm_volume(name)\n dev = available_dev\n enable_netblockdev(name, dev)\n vol_grp = lvm_volume_group(\n lvm_partition(dev)\n )\n root = lvm_root(vol_grp)\n lvm_enable(vol_grp) unless lvm_enabled?(root)\n mount(name, root)\n dev\nend",
"def getservedvolumes\n # only support Linux for now\n return {} unless Facter['kernel'] && Facter['kernel'].value == 'Linux'\n\n # Don't do anything if exports file is not there\n return {} if !File.exists?(\"/etc/exports\")\n\n served = {}\n\n IO.foreach(\"/etc/exports\") do |line|\n if line =~ /(\\S+)\\s+/\n vol = $1\n served[\"volumes[served][#{vol}][config]\"] = \"/etc/exports\"\n served[\"volumes[served][#{vol}][type]\"] = 'nfs'\n end\n end\n return served\n end",
"def domain_volumes\n # Use the domain name as our volume base name.\n base_name = domain_name\n\n if not config[:image_name]\n config[:image_name] = default_image\n end\n\n # Clone our root volume from our base image.\n root_volume = clone_volume(config[:image_name], \"#{base_name}-root\")\n\n # Return the array of created volumes\n [root_volume].concat(\n create_volumes(\n extra_volumes(base_name)\n )\n )\n end",
"def list(msg)\n response \"125 Opening ASCII mode data connection for file list\"\n send_data(`ls -l`.split(\"\\n\").join(LBRK) << LBRK)\n \"226 Transfer complete\"\n end",
"def is_volume_wrapper?\n volumes = Bplmodels::Finder.getVolumeObjects(pid)\n volumes.present? ? true : false\n end",
"def virtual_disk_views\n client.enumerate(\"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/root/DCIM/DCIM_VirtualDiskView\")\n end",
"def exists?\n volumes = Hash.new\n qmgmt(['volume', 'list']).each_line { |l|\n if ( l.match(/^Name/) )\n next\n end\n line = l.split(/\\s{2,}/)\n volumes[line.shift()] = true\n }\n\n if ( volumes[resource[:name]] )\n return true\n else\n return false\n end\n end",
"def ls\n Dir.entries(@working_dir)\n end",
"def cmd_ls(*args)\n\t\tpath = args[0] || client.fs.dir.getwd\n\t\ttbl = Rex::Ui::Text::Table.new(\n\t\t\t'Header' => \"Listing: #{path}\",\n\t\t\t'Columns' =>\n\t\t\t\t[\n\t\t\t\t\t'Mode',\n\t\t\t\t\t'Size',\n\t\t\t\t\t'Type',\n\t\t\t\t\t'Last modified',\n\t\t\t\t\t'Name',\n\t\t\t\t])\n\n\t\titems = 0\n\n\t\t# Enumerate each item...\n\t\tclient.fs.dir.entries_with_info(path).sort { |a,b| a['FileName'] <=> b['FileName'] }.each { |p|\n\n\t\t\ttbl <<\n\t\t\t\t[\n\t\t\t\t\tp['StatBuf'] ? p['StatBuf'].prettymode : '',\n\t\t\t\t\tp['StatBuf'] ? p['StatBuf'].size : '',\n\t\t\t\t\tp['StatBuf'] ? p['StatBuf'].ftype[0,3] : '',\n\t\t\t\t\tp['StatBuf'] ? p['StatBuf'].mtime : '',\n\t\t\t\t\tp['FileName'] || 'unknown'\n\t\t\t\t]\n\n\t\t\titems += 1\n\t\t}\n\n\t\tif (items > 0)\n\t\t\tprint(\"\\n\" + tbl.to_s + \"\\n\")\n\t\telse\n\t\t\tprint_line(\"No entries exist in #{path}\")\n\t\tend\n\n\t\treturn true\n\tend",
"def keys\n @disk.keys\n end",
"def list(client, current_path)\n\n\tfiles = Dir.glob(\"#{current_path}/files/*\")\n\tclient.puts \"\\nList of Files:\"\n\tfiles.each{ |file|\n\tfile.slice! \"#{current_path}/files/\"}\n\tclient.puts files\n\nend",
"def test_volume_data(server)\n server.spot_check_command(\"test -f #{@mount_point}/data.txt\")\n end"
] | [
"0.74190503",
"0.73382515",
"0.7190842",
"0.68871546",
"0.68590057",
"0.67773986",
"0.6764583",
"0.6746657",
"0.6727527",
"0.67217493",
"0.65190095",
"0.6451039",
"0.641028",
"0.6404427",
"0.63665503",
"0.6321427",
"0.62932795",
"0.6290067",
"0.62753147",
"0.6224678",
"0.62147194",
"0.62074953",
"0.618339",
"0.61676395",
"0.6147906",
"0.61474854",
"0.61206",
"0.61206",
"0.6104272",
"0.61016166",
"0.6073718",
"0.6070696",
"0.6047201",
"0.6043299",
"0.60358185",
"0.60319394",
"0.6028984",
"0.60237855",
"0.6018801",
"0.6005967",
"0.6000807",
"0.5986381",
"0.59807163",
"0.5974688",
"0.5971945",
"0.5927312",
"0.59244496",
"0.5911525",
"0.5893191",
"0.58763176",
"0.5865174",
"0.58595556",
"0.5857936",
"0.5849052",
"0.5843916",
"0.5843618",
"0.5823641",
"0.5813507",
"0.5811286",
"0.58001333",
"0.5796628",
"0.57957155",
"0.57817703",
"0.57799155",
"0.5775181",
"0.57587045",
"0.5747021",
"0.5740778",
"0.57383496",
"0.5733685",
"0.5733482",
"0.57319915",
"0.5725382",
"0.5723834",
"0.57223547",
"0.57112515",
"0.56921625",
"0.56910604",
"0.5689718",
"0.56869394",
"0.56867814",
"0.568079",
"0.5677413",
"0.566719",
"0.5663852",
"0.56429315",
"0.5624678",
"0.56207615",
"0.5616672",
"0.55982965",
"0.559724",
"0.5596765",
"0.55815125",
"0.5574457",
"0.557252",
"0.557097",
"0.5568427",
"0.55459297",
"0.5536715",
"0.552699"
] | 0.7667499 | 0 |
========================================================================================= $ ./cyberdojo volume inspect ========================================================================================= | def volume_inspect
help = [
'',
"Use: #{me} volume inspect VOLUME",
'',
'Displays details of the named cyber-dojo volume',
]
# asked for help?
vol = ARGV[2]
if [nil,'help','--help'].include? vol
show help
exit failed
end
# TODO: check for unknown args
exit_unless_is_cyber_dojo_volume(vol, 'inspect')
command =
[
'docker run',
'--rm',
"--user=root",
"--volume=#{vol}:/data:#{read_only}",
'--volume=/var/run/docker.sock:/var/run/docker.sock',
"#{cyber_dojo_hub}/web:#{docker_version}",
"sh -c 'cd /usr/src/cyber-dojo/cli && ./volume_inspect.rb /data'"
].join(space=' ')
print run(command)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def volume_ls\n help = [\n '',\n \"Use: #{me} volume ls\",\n '',\n 'Lists the names of all cyber-dojo volumes',\n '',\n minitab + '--quiet Only display volume names'\n ]\n\n if ['help','--help'].include? ARGV[2]\n show help\n exit failed\n end\n\n # There is currently no [--filter label=LABEL] option on [docker volume ls]\n # https://github.com/docker/docker/pull/21567\n # So I have to inspect all volumes. Could be slow if lots of volumes.\n\n names = run(\"docker volume ls --quiet\").split\n names = names.select{ |name| cyber_dojo_volume?(name) }\n\n if ARGV[2] == '--quiet'\n names.each { |name| puts name }\n else\n types = names.map { |name| cyber_dojo_type(name) }\n urls = names.map { |name| cyber_dojo_label(name) }\n\n headings = { :name => 'NAME', :type => 'TYPE', :url => 'SRC' }\n\n gap = 3\n max_name = ([headings[:name]] + names).max_by(&:length).length + gap\n max_type = ([headings[:type]] + types).max_by(&:length).length + gap\n max_url = ([headings[:url ]] + urls ).max_by(&:length).length + gap\n\n spaced = lambda { |max,s| s + (space * (max - s.length)) }\n\n name = spaced.call(max_name, headings[:name])\n type = spaced.call(max_type, headings[:type])\n url = spaced.call(max_url , headings[:url ])\n puts name + type + url\n names.length.times do |n|\n name = spaced.call(max_name, names[n])\n type = spaced.call(max_type, types[n])\n url = spaced.call(max_url , urls[n])\n puts name + type + url\n end\n end\nend",
"def get_volume\n @volume\n end",
"def volume; property('volume'); end",
"def volumes\n client = Aws::EC2::Client.new\n client.describe_volumes({\n filters: [{\n name: \"tag:backup\",\n values: [\"true\"]\n }]\n }).volumes\nend",
"def init_ebs_volumes\n @@client.describe_volumes.volumes\n end",
"def volume; self.class.volume; end",
"def pretty_info\n volinfo = self.info\n mountpoint = volinfo['MountPoint']\n mountpoint = 'Not mounted' if mountpoint.empty?\n rw = volinfo['WritableVolume'] ? 'writable' : 'read-only'\n ownership = self.ownership_enabled? ? 'ownership enabled' : 'no ownership'\n return volinfo['VolumeName'] + \" (#{self.dev_node}, #{mountpoint}, #{rw}, #{ownership})\\n\" \n end",
"def name\n self['VolumeName']\n end",
"def get_volume()\n return(get_cmd('AG;',0.1,0.5,3).gsub(/^AG/,'').gsub(/;$/,'').to_i)\nend",
"def show_vol()\n\t\tvm = get_vol\n\t\[email protected]=$muted_colors[vm[:mute]]\n\t\[email protected]='Volume'\n\t\[email protected] += ' (Muted)' if vm[:mute]\n\t\[email protected]=vm[:vol]\n\t\[email protected]=5\n\tend",
"def volume_names\n pool.list_volumes\n end",
"def volume\n help = [\n '',\n \"Use: #{me} volume [COMMAND]\",\n '',\n 'Manage cyber-dojo setup volumes',\n '',\n 'Commands:',\n minitab + 'create Creates a new volume',\n minitab + 'rm Removes a volume',\n minitab + 'ls Lists the names of all volumes',\n minitab + 'inspect Displays details of a volume',\n minitab + \"pull Pulls the docker images inside a volume's manifest.json files\",\n '',\n \"Run '#{me} volume COMMAND --help' for more information on a command\",\n ]\n case ARGV[1]\n when 'create' then volume_create\n when 'rm' then volume_rm\n when 'ls' then volume_ls\n when 'inspect' then volume_inspect\n when 'pull' then volume_pull\n else show help\n end\nend",
"def volume \n puts \"The volume is #{@length * @width * @height}\"\n end",
"def volume\n @cr[0xe] & 0x0f\n end",
"def virtual_disk_views\n client.enumerate(\"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/root/DCIM/DCIM_VirtualDiskView\")\n end",
"def volinfo(compute,name)\n\t\tvolumes = compute.describe_volumes\n\t\tif (volumes.status == 200)\n\t\t\t# check each of the volumes in our availability zone which match our name.\n\t\t\tvolumes.body['volumeSet'].each {|x|\n\t\t\t\t# Match the name unless the volume is actually being deleted...\n\t\t\t\tif (x['tagSet']['Name'] == resource[:volume_name] )\n\t\t\t\t\t#print \"ebsvol[aws]->volinfo: Volume #{x['volumeId']} has Name = #{resource[:volume_name]}\\n\" if $debug\n\t\t\t\t\treturn x\n\t\t\t\tend\n\t\t\t}\n\t\telse\n\t\t\traise \"ebsvol[aws]->volinfo: I couldn't list the ebsvolumes\"\n\t\tend\n\t\tnil\n\tend",
"def list_volumes\n response = @connection.req(\"GET\", \"/#{@volume_path}\")\n volumes_hash = JSON.parse(response.body)[\"volumes\"]\n volumes_hash.inject([]){|res, current| res << OpenStack::Volume::Volume.new(current); res}\n end",
"def volume\n @length * @width * @depth\n end",
"def volume\n app.speakers.ID(@id).volume.get\n end",
"def volume\n player_iface['Volume']\n end",
"def get_volume(volume_id)\n get(\"cloud-instances/#{guid}/volumes/#{volume_id}\")\n end",
"def physical_disk_views\n client.enumerate(\"http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/root/DCIM/DCIM_PhysicalDiskView\")\n end",
"def pretty_info\n s = ''\n dev = self.device\n return \"Disk image: #{self.image_path.basename} (na, detached, na)\\n\" if dev.nil?\n return dev.pretty_info\n end",
"def list_all_volumes\n Docker::Volume.all({}, client)\n rescue\n []\n end",
"def volume_type\n return @volume_type\n end",
"def get_vol\n\t\tIO::popen('amixer sget Master') do |f|\n\t\t\tf.read.scan(/Front Left.*?\\[(\\d+)%\\].*?\\[(on|off)\\]\\n/) do |pc, on_or_off|\n\t\t\t\treturn {\n\t\t\t\t\t:vol => pc.to_i,\n\t\t\t\t\t:mute => 'off' == on_or_off\n\t\t\t\t}\n\t\t\tend\n\t\tend\n\t\treturn { :vol => -1, :mute => false }\n\tend",
"def volume _value, _abs=0\n send_cmd(\"volume #{_value} #{_abs}\")\n end",
"def volume(options)\n options[:width] * options[:height] * options[:depth]\nend",
"def get_osx_disk_name(options)\n message = \"Information:\\tGetting root disk device ID\"\n command = \"df |grep '/$' |awk '{print \\\\$1}'\"\n output = execute_command(options,message,command)\n disk_id = output.chomp\n message = \"Information:\\tGetting volume name for \"+disk_id\n command = \"diskutil info #{disk_id} | grep 'Volume Name' |cut -f2 -d':'\"\n output = execute_command(options,message,command)\n volume = output.chomp.gsub(/^\\s+/,\"\")\n return volume\nend",
"def current_volume(volume)\n\t\t\"The current volume is #{@volume}\"\n\tend",
"def volume\n return @width * @height / @depth\n end",
"def current\n c = IO::popen(\"pacmd \\\"list-sinks\\\" | grep volume | head -1\").readlines[0]\n return c.split(\" \").last.sub(\"%\", \"\").strip.to_i\nend",
"def do_volume(num)\n\n fail CvlcClientError, \"The 'volume' command requires an integer value between 0 and 300...\" unless num.between?(0, 300)\n do_command(\"requests/status.json?command=volume&val=#{num}\")\n sleep STATUS_PAUSE\n return pretty_status(current_status)\n end",
"def currently_attached_volume(instance_id, device)\n ec2.describe_volumes.find{|v| v[:aws_instance_id] == instance_id && v[:aws_device] == device}\n end",
"def ebs(device_name, type: 'gp2', size: 8)\n {\n device_name: device_name,\n ebs: {\n delete_on_termination: true,\n volume_size: size,\n volume_type: type\n },\n no_device: ''\n }\nend",
"def get_volumes\n volumes = get(\"cloud-instances/#{guid}/volumes\")[\"volumes\"] || []\n\n volumes.map do |volume|\n get_volume(volume[\"volumeID\"])\n end\n end",
"def retrieve_volumes\n dbg { \"retrieving #{pool_info}, #{hv_info}\" }\n\n volumes = pool.list_all_volumes\n dbg { \"list_all_volumes #{pool_info}, #{hv_info}\" }\n\n storage_volumes = volumes.map.with_index do |vol, index|\n id = \"#{uuid}--#{index}\"\n StorageVolume.new(vol, pool: self, id: id)\n end\n\n dbg { \"retrieved size=#{storage_volumes.size}, #{pool_info}, #{hv_info}\" }\n storage_volumes\n end",
"def lvm_root(volume_group)\n %x{lvdisplay #{volume_group} 2>/dev/null| grep root}.split(' ').last.strip\nend",
"def get(options = nil)\n super(options, 'host', GET_PARAMS, [:show_volume])\n end",
"def info\n Plist::parse_xml(diskutil 'info', '-plist', @dev_node)\n end",
"def show\n @admissive_volume = AdmissiveVolume.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @admissive_volume }\n end\n end",
"def volume\n $redis_pool.with { |redis| redis.get('warble:volume').to_i }\n end",
"def list_kvms\n info = Hash[\n *Dir.glob(File.join(KVM_HOME, 'storage', '*.qcow2')).map{|dir|\n key = File.basename(dir).sub('.qcow2', '')\n [key, {:address => kvm_ip(key), :type => kvm_type(key)}]\n }.sort{|a,b|\n a.first <=> b.first\n }.flatten\n ]\n info.each do |name, info|\n puts \"#{name}\"\n puts \" Type: #{info[:type]}\"\n puts \" Address: #{info[:address]}\"\n end\nend",
"def get_volume_id(sys_id,volume_name)\n response = request(:get, \"/devmgr/v2/storage-systems/#{sys_id}/volumes\")\n status(response, 200, 'Failed to get Volumes')\n volumes = JSON.parse(response.body)\n volumes.each do |vm|\n \t return vm['id'] if vm['name'] == volume_name\n \tend\n response = request(:get, \"/devmgr/v2/storage-systems/#{sys_id}/thin-volumes\")\n status(response, 200, 'Failed to get thin Volumes')\n volumes = JSON.parse(response.body)\n volumes.each do |vm|\n return vm['id'] if vm['name'] == volume_name\n end\n \tfalse\n end",
"def disks\n self.config.hardware.device.grep(RbVmomi::VIM::VirtualDisk)\n end",
"def list(opts)\n opts = check_params(opts,[:volume])\n super(opts)\n end",
"def encryptable_info\n wmi = WmiLite::Wmi.new(\"Root\\\\CIMV2\\\\Security\\\\MicrosoftVolumeEncryption\")\n disks = wmi.instances_of(\"Win32_EncryptableVolume\")\n encryption_properties(disks)\n rescue WmiLite::WmiException\n Ohai::Log.debug(\"Unable to access Win32_EncryptableVolume. Skipping encryptable details\")\n Mash.new\n end",
"def volumes\n service.list_pool_volumes uuid\n end",
"def show\n @vdisk = Vdisk.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @vdisk }\n end\n end",
"def volumes\n @volumes.to_a.freeze\n end",
"def volume_stats(vol_id)\n api_call = {\n :method => \"GetVolumeStats\",\n :params => {\n :volumeID => vol_id\n }\n }\n answer = query_sf(api_call)\n return answer[\"volumeStats\"]\n end",
"def volume_stats(vol_id)\n api_call = {\n :method => \"GetVolumeStats\",\n :params => {\n :volumeID => vol_id\n }\n }\n answer = query_sf(api_call)\n return answer[\"volumeStats\"]\n end",
"def volume\n `#{@sound}.volume`\n end",
"def index\n @actual_volumes = ActualVolume.all\n end",
"def volume_pull\n help = [\n '',\n \"Use: #{me} volume pull VOLUME\",\n '',\n 'Pulls all the docker images named inside the cyber-dojo volume'\n ]\n vol = ARGV[2]\n if [nil,'help','--help'].include? vol\n show help\n exit failed\n end\n\n exit_unless_is_cyber_dojo_volume(vol, 'pull')\n\n command =\n [\n 'docker run',\n '--rm',\n '--tty',\n \"--user=root\",\n \"--volume=#{vol}:/data:#{read_only}\",\n '--volume=/var/run/docker.sock:/var/run/docker.sock',\n \"#{cyber_dojo_hub}/web:#{docker_version}\",\n \"sh -c 'cd /usr/src/cyber-dojo/cli && ./volume_pull.rb /data'\"\n ].join(space=' ')\n\n system(command)\nend",
"def ebs_volumes\n @ebs_volumes ||= init_ebs_volumes.reject do |vol|\n vol.attachments.any? do |att|\n attached_instance = id_instances[att.instance_id]\n attached_instance.root_device_name == att.device\n end\n end\n end",
"def volumes_list(state = \"active\", limit = \"1000\")\n case state\n when \"active\"\n api_call = {\n :method => \"ListActiveVolumes\",\n :params => {\n :startVolumeID => 0,\n :limit => limit\n }\n }\n when \"deleted\"\n api_call = {\n :method => \"ListDeletedVolumes\",\n :params => {}\n }\n end\n answer = query_sf(api_call)\n return answer[\"volumes\"]\n end",
"def show_parts(device)\n action_parts(device, '-s -av')\n end",
"def volume_by_id(volume_id)\n ec2.describe_volumes.find{|v| v[:aws_id] == volume_id}\n end",
"def volume(volume_id)\n volumes(volume_id)[0]\n end",
"def volume_report\n get_resource_list('volume', 'volumes', 'volumes')\n @volume_csv_array = []\n @resource_id_list.each do |volumeid|\n volume = rest_get(\"#{@resource_url}/volumes/#{volumeid}\", @token_id)\n volume_array = JSON.parse(volume)['volume']\n volume_name = volume_array['name']\n volume_status = volume_array['status']\n volume_template = volume_array['volume_type']\n volume_size = volume_array['size']\n @volume_csv_headers = %w(Volume_Name Volume_Status Storage_Template Volume_Size)\n @volume_csv_array << [volume_name, volume_status, volume_template, volume_size]\n end\n end",
"def inspect\n self.each_pair do |k, v|\n print \"%-40s\" % k.to_s.yellow unless k == :mbr\n case k\n when :crc, :version then puts \"0x%08x\" % v\n when :mbr\n v.each_pair do |i, j|\n next if i == :reserved\n print \"%-40s\" % i.to_s.yellow unless i == :part\n case i\n when :part\n puts \"Partitions:\".light_blue\n c = 'a'\n j.each do |p|\n break if p.name.empty?\n print \"%-40s\" % p.name.yellow\n puts \"(nand%s) @ 0x%08x [% 5d MB] [0x%08x]\" % [c,\n p.address_low, p.lenlo/2048, p.keydata]\n c.next!\n end\n else\n puts \"#{j}\"\n end\n end\n else\n puts \"#{v}\"\n end\n end\n end",
"def radioVolume \n \"radioVolume\" \n end",
"def volume_by_id(ec2,volid)\n ec2.describe_volumes.body['volumeSet'].each do |volume|\n if volume['volumeId'] == volid\n x= {\n :type => volume['volumeType'],\n :status => volume['status'],\n :az => volume['availabilityZone'],\n :size => volume['size']\n }\n #puts \"VOLINFO #{volid}\\n\"+volume.to_yaml\n x[:instance_id] = volume['attachmentSet'].first['instanceId'] if volume['attachmentSet'].length>0 && volume['attachmentSet'].first.has_key?('instanceId')\n return x\n end\n end\n return {}\nend",
"def display_host(hostname, partitions)\n volume_groups = {}\n lvm_members = []\n\n puts hostname\n partitions.keys.sort.each do |partition|\n if partitions[partition]['filesystem'] == 'LVM2_member'\n lvm_members << partition\n next\n end\n next if partition == '/dev/mapper/rootvg-swap'\n next if partition == '/dev/mapper/rootvg-afscache'\n next unless partition.match(/^\\/dev\\/mapper\\/(\\S+)-(\\S+)/)\n\n vg = $~[1]\n short_partition = $~[2]\n volume_groups[vg] = [] unless volume_groups.key?(vg)\n volume_groups[vg] << partition\n end\n\n puts \"LVM partitions: \" + lvm_members.sort.join(', ')\n puts 'lvm::volume_groups:'\n volume_groups.keys.sort.each do |vg|\n puts \" #{vg}:\"\n puts ' logical_volumes:'\n volume_groups[vg].sort.each do |partition|\n\n next unless partition.match(/^\\/dev\\/mapper\\/\\S+-(\\S+)/)\n short_partition = $~[1]\n\n # Skip the partition if it's an expected size.\n space = format_space(partition, partitions[partition]['size'].to_s)\n next if space.nil?\n\n # Find if this is a known volume and set the mount to nil then, so we\n # don't print in useless data.\n mount = format_mount(partition, partitions[partition]['mount'].to_s)\n\n puts ' ' + short_partition + ':'\n puts ' ' + 'size: ' + space\n puts ' ' + 'mountpath: ' + mount unless mount.nil?\n puts ' ' + 'fs_type: ' + partitions[partition]['filesystem'].to_s unless mount.nil?\n end\n end\n\n puts\nend",
"def volumes(value_only: true)\n varfields('v', value_only: value_only)\n end",
"def show\n @sm_volume = SmVolume.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @sm_volume }\n end\n end",
"def lvm_volume_group(partition)\n %x{pvs --noheadings --separator ' ' #{partition} 2>/dev/null| sed -e 's/^\\s*//' | cut -d ' ' -f 2}.strip\nend",
"def populate_volume(server)\n server.spot_check_command(\" echo \\\"blah blah blah\\\" > #{@mount_point}/data.txt\")\n end",
"def fetch_volume_by_id\n vol = storage_api.find_by_id(volume_id)\n data = vol.body.fetch(\"volume\")\n @name = data.fetch('display_name')\n @volume_type = data.fetch('volume_type')\n @size = data.fetch('size')\n\n # Sometimes the Rackspace API takes time to update,\n # and newly-attached volumes don't report any attachments\n # yet.\n attachments = data.fetch('attachments')\n if attachments.any?\n @device = attachments.first.fetch('device')\n end\n end",
"def volume_params\n params[:volume]\n end",
"def show\n @mounted_inventory = MountedInventory.find(params[:id])\n end",
"def volumes\n volumes = @ec2.volumes\n volumes.delete_if {|v| v.instance_id != id}\n end",
"def series_volume\n end",
"def set_volume(volume)\n puts \"Setting volume to #{volume}\" if $verbose\n v='AG'+(('000'+volume.to_s)[-3..-1])+';'\n puts v if $verbose\n ret=send_cmd(v,'AG;',v,0.5,1.5,3)\n if(ret)\n return(ret.gsub(/^AG/,'').gsub(/;$/,'').to_i)\n else\n return(nil)\n end\nend",
"def traded_volume\n data.fetch('tradedVolume')\n end",
"def update_volume_info\n\t\t#\t\t@pool = Pool.find(self.pool_id)\n\t\t#\t\t@host = Host.find(@pool.host_id)\n\t\t#\n\t\t#\t\tconnection = ConnectionsManager.instance\n\t\t#\t\tconnection_hash = connection.get(@host.name)\n\t\t#\t\tconn = connection_hash[:conn]\n\n\t\t# get pool reference in order to get a reference to the volume\n\t\t@pool = @conn.lookup_storage_pool_by_name(@pool.name)\n\t\tvolume = @pool.lookup_volume_by_name(self.name)\n\t\tvolume_info = volume.info\n\t\t\n\t\t# add some stats to pool object\n\t\tdivide_to_gigabytes = (1024 * 1024 * 1024).to_f\n\t\tself.allocation = (volume_info.allocation.to_f / divide_to_gigabytes).to_f\n\tend",
"def get_road_volume\n @volumes_east = RoadVolume.get_road_volume('East')\n @volumes_west = RoadVolume.get_road_volume('West')\n end",
"def test_volume_size(server,expected_size)\n puts \"Testing with: #{@mount_point} #{expected_size}\"\nputs \"THIS DOES NOT WORK - cause of rounding errors during volume size determination, FS overhead and df's output\"\nputs \"Need to query the volumes attached to the server and verify that they #{expected_size}/#{@stripe_count}\"\nputs \"Check that the server's volumes are #{expected_size}\"\n# server.spot_check_command(\"df -kh | awk -F\\\" \\\" -v -v size=#{expected_size}G '/#{@mount_point}/ {exit $2!=size}'\")\n end",
"def mounts_info\n @mounts_info ||= vault_client.request(:get, \"/v1/sys/internal/ui/mounts\")\n rescue Vault::VaultError\n unable_to_determine_version\n raise\n end",
"def volume_snapshots(volume_id)\n ec2.snapshots.select { |snapshot| snapshot.volume_id == volume_id }\n end",
"def start_point_inspect\n help = [\n '',\n \"Use: #{me} start-point inspect NAME\",\n '',\n 'Displays details of the named start-point',\n ]\n\n vol = ARGV[2]\n if [nil,'--help'].include? vol\n show help\n exit succeeded\n end\n\n exit_unless_is_cyber_dojo_volume(vol, 'inspect')\n\n unless ARGV[3].nil?\n STDERR.puts \"FAILED: unknown argument [#{ARGV[3]}]\"\n exit failed\n end\n\n command =\n [\n 'docker run',\n '--rm',\n \"--user=root\",\n \"--volume=#{vol}:/data:#{read_only}\",\n '--volume=/var/run/docker.sock:/var/run/docker.sock',\n \"#{cyber_dojo_commander}\",\n \"sh -c './start_point_inspect.rb /data'\"\n ].join(space=' ')\n print run(command)\nend",
"def index\n @volumes = Volume.all\n end",
"def index\n @volumes = Volume.all\n end",
"def check_volume(volume) \n # Default warning_limit\n warning_limit=@warning_limit\n # Default critical_limit\n critical_limit=@critical_limit\n # Default nobackup_status\n nobackup_status=@nobackup_status\n\n puts \"Checking volume: #{volume}\" if @verbose\n\n if @objects.has_key?(volume) and not @objects[volume].has_key?(:skip)\n vol=DuplicityVolume.new(volume,@config_values,@objects[volume])\n vol.debug=@debug\n vol.testing=@testing\n vol.run(\"col\")\n\n puts \" Checking vol: #{volume} last backup: #{vol.last_backup}\" if @verbose\n warning_limit=@objects[volume][:warning_limit] if @objects[volume].has_key? :warning_limit\n\t puts \" warning_limit for #{volume} is #{warning_limit}\" if @debug\n critical_limit=@objects[volume][:critical_limit] if @objects[volume].has_key? :critical_limit\n\t puts \" critical_limit for #{volume} is #{critical_limit}\" if @debug\n nobackup_status=@objects[volume][:nobackup_status] if @objects[volume].has_key? :nobackup_status\n\t puts \" nobackup_status for #{volume} is #{nobackup_status}\" if @debug\n # Check backup age\n check_time=Time.now\n if vol.last_backup\n if check_time < vol.last_backup + warning_limit.to_i\n incstatus(\"OK\")\n elsif check_time >= vol.last_backup + warning_limit.to_i and check_time < vol.last_backup + critical_limit.to_i\n @short+=\"#{vol.name} OLD, \"\n @long+=\"#{vol.name} is too OLD\\n\"\n incstatus(\"WARNING\")\n elsif check_time >= vol.last_backup + critical_limit.to_i\n @short+=\"#{vol.name} OLD, \"\n @long+=\"#{vol.name} is too OLD\\n\"\n incstatus(\"CRITICAL\")\n end\n else\n @short+=\"no backups for #{vol.name}, \"\n @long+=\"No backups found for volume #{vol.name}\\n\"\n incstatus(nobackup_status)\n end\n else\n puts \"ERROR: Volume #{volume} is not defined\"\n return false\n end\n end",
"def formatted!\n self[:formatted] = true\n node[:volumes][name][:formatted] = true\n end",
"def show\n @volume = Volume.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @volume }\n end\n end",
"def root_volumes\n volumes.select {|vol| vol.parent_id == nil}\n end",
"def volume(x)\n\t\tsynchronized do\n\t\t\[email protected] \"volume #{x}\"\n\t\tend\n\tend",
"def get_gpu_driver_volume(json_result, slot)\n nvidia_volumes = json_result['Volumes'][slot].split(\":\")\n driver = nvidia_volumes[slot].gsub('nvidia_driver_', '')\n return '/var/lib/nvidia-docker/volumes/nvidia_driver/' + driver\nend",
"def show\n @volume_type = VolumeType.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @volume_type }\n end\n end",
"def volume(level = nil)\n level.nil? ? Integer(connection.write(\"volume\", false)) : connection.write(\"volume #{Integer(level)}\")\n rescue ArgumentError\n level.nil? ? 0 : nil\n end",
"def volume(level = nil)\n return Integer(connection.write(\"volume\", false)) if level.nil?\n connection.write(\"volume #{Integer(level)}\")\n rescue ArgumentError\n level.nil? ? 0 : nil\n end",
"def volume(level = nil)\n return Integer(connection.write(\"volume\", false)) if level.nil?\n connection.write(\"volume #{Integer(level)}\")\n rescue ArgumentError\n level.nil? ? 0 : nil\n end",
"def volume pub_xml_ng_doc\n idmd = identity_metadata pub_xml_ng_doc\n idmd.root.xpath('objectLabel').text.strip\n end",
"def has_logical_volume_management\n super\n end",
"def tags\n # Strangely, this only lists the first snapshot. If you remove '-o name', it lists them all\n #command = \"zfs list -H -r -t snapshot -o name #{@dataset}/share\"\n command = \"ls -1 #{@mountpoint}/share/.zfs/snapshot\"\n logger.debug \"running: #{command}\"\n `#{command}`.chomp.split(/\\n/).map { |x| x.sub(/.*@/, '') }\n end",
"def name\n \"Volume #{volume} Issue #{number}\"\n end",
"def getVolumes\n require 'rest_client'\n require 'uri'\n\n if @role.nil? and !current_actor.superadmin\n json_response({ message: \"You don't have permission to view volumes\" }, :unauthorized)\n return\n end\n\n # Env variables for Manager host and port\n serviceManagerHost = Settings.service_manager_host\n serviceManagerPort = Settings.service_manager_port.to_s\n serviceManagerURI = 'http://' + serviceManagerHost + ':' + serviceManagerPort + '/v1/volume'\n\n # Create request for Service Manager\n stack = {\n 'engine-url' => @cluster.endpoint,\n 'ca-cert' => @cluster.ca,\n 'cert' => @cluster.cert,\n 'cert-key' => @cluster.key\n }.to_json\n\n begin\n response = RestClient.post(\n serviceManagerURI,\n stack,\n 'Accept' => 'application/json',\n 'Content-Type' => 'application/json'\n )\n puts \"Deploy Response: \" + response\n json_response(response, 200)\n rescue Exception => e\n # If error, respond with it\n puts e\n json_response({message: e}, :unprocessable_entity)\n end\n end",
"def volume\n { bid: bid_volume, ask: ask_volume }\n end"
] | [
"0.6845138",
"0.682955",
"0.6801692",
"0.66896826",
"0.65809655",
"0.65715355",
"0.6490683",
"0.6469171",
"0.6362037",
"0.63325155",
"0.6292481",
"0.62908846",
"0.62411344",
"0.6193496",
"0.6136404",
"0.6136037",
"0.6127054",
"0.61041164",
"0.60990125",
"0.60829663",
"0.6025718",
"0.6023425",
"0.60030216",
"0.5975809",
"0.597414",
"0.5967159",
"0.59511626",
"0.5929003",
"0.5918776",
"0.5898055",
"0.5897927",
"0.5885191",
"0.58654773",
"0.5860391",
"0.58443695",
"0.5839187",
"0.58386725",
"0.5822323",
"0.5816029",
"0.5799936",
"0.5779321",
"0.5764894",
"0.5744826",
"0.5735916",
"0.5734448",
"0.5726259",
"0.5724288",
"0.57086843",
"0.569044",
"0.5685896",
"0.56799537",
"0.56799537",
"0.5674129",
"0.5663465",
"0.56614226",
"0.56410176",
"0.5639586",
"0.56353766",
"0.5632597",
"0.5632287",
"0.5627885",
"0.55877143",
"0.55737174",
"0.55711865",
"0.55674446",
"0.5561822",
"0.55579793",
"0.5552",
"0.5548489",
"0.55329585",
"0.55210847",
"0.55206096",
"0.5518137",
"0.5515102",
"0.5507766",
"0.5503111",
"0.5489486",
"0.5475235",
"0.5464341",
"0.5462034",
"0.5453099",
"0.545121",
"0.544802",
"0.544802",
"0.5446389",
"0.5435724",
"0.54298097",
"0.5427946",
"0.5427118",
"0.54227597",
"0.5414839",
"0.5406261",
"0.5404969",
"0.5404969",
"0.54012686",
"0.54008734",
"0.5381839",
"0.5367393",
"0.5364015",
"0.5360178"
] | 0.76942563 | 0 |
========================================================================================= $ ./cyberdojo volume rm ========================================================================================= | def volume_rm
# Allow deletion of a default volume.
# This allows you to create custom default volumes.
help = [
'',
"Use: #{me} volume rm VOLUME",
'',
"Removes a volume created with the [#{me} volume create] command"
]
vol = ARGV[2]
if [nil,'help','--help'].include? vol
show help
exit failed
end
exit_unless_is_cyber_dojo_volume(vol, 'rm')
run "docker volume rm #{vol}"
if $exit_status != 0
puts "FAILED [volume rm #{vol}] can't remove volume if it's in use"
exit failed
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def destroy\n ret = qmgmt(['volume', 'delete', resource[:name]])\n out = Array.new\n ret.each_line { |l|\n out.push(' ' + l)\n }\n if ( ret.exitstatus != 0 )\n fail(\"quobyte volume delete #{resource[:name]} failed with status #{ret.exitstatus.to_s}. Output follows.\" + out.join(\"\\n\"))\n end\n end",
"def destroy\n ret = qmgmt(['volume', 'config', 'delete', resource[:name]])\n if ( ret.exitstatus != 0 )\n fail(\"quobyte volume config delete #{resource[:name]} failed with status #{ret.exitstatus.to_s}. Output follows.\" + out.join(\"\\n\"))\n end\n end",
"def detachvolume\n false\n end",
"def volume_cleanup(domain)\n domain.volumes.each do |volume|\n debug(\"Removing volumes #{volume.key}\")\n volume.destroy if volume.key\n end\n end",
"def deletevolume\n if not checkRequirements([\"thezone\",\"thevolume\"])\n return false\n end\n checkToken(@thezone)\n submit = queryGCE(:path => '/compute/v1beta15/projects/#{@thezone.name}/zones/#{@thevolume.azone.name}/disks/#{@thevolume.serial}', :method => 'delete', :options => '', :access_token => @thezone.token )\n checkQuery(:type => 'zone', :token => @thezone.token, :projectname => @thezone.name, :zonename => @thevolume.azone.name, :operationname => submit[\"name\"])\n end",
"def delete(volume)\n dest_path = dest_path_resolver.path(volume)\n removed = fs.remove(dest_path)\n log(volume, removed ? \"removed\" : \"not present\")\n fs.rm_empty_tree(dest_path.parent)\n end",
"def delete_gdom_disk(options)\n gdom_dir = $ldom_base_dir+\"/\"+options['name']\n client_disk = gdom_dir+\"/vdisk0\"\n message = \"Information:\\tRemoving disk \"+client_disk\n command = \"rm #{client_disk}\"\n execute_command(options,message,command)\n return\nend",
"def start_point_rm\n # Allow deletion of a default volume.\n # This allows you to create custom default volumes.\n help = [\n '',\n \"Use: #{me} start-point rm NAME\",\n '',\n \"Removes a start-point created with the [#{me} start-point create] command\"\n ]\n\n vol = ARGV[2]\n if [nil,'help'].include? vol\n show help\n exit succeeded\n end\n\n exit_unless_is_cyber_dojo_volume(vol, 'rm')\n\n unless ARGV[3].nil?\n puts \"FAILED: unknown argument [#{ARGV[3]}]\"\n exit failed\n end\n\n run \"docker volume rm #{vol} 2>&1 /dev/null\"\n if $exit_status != 0\n puts \"FAILED cannot remove start-point #{vol}. Is it in use?\"\n exit failed\n end\n\nend",
"def rm(path)\n cmd 'rm', path\nend",
"def terminate_volume\n device = get_device_mount_point(self.MountPoint)\n STDERR.puts \"EBS device detected: #{device}...umounting it...\"\n umount_dir(self.MountPoint)\n #detache the mounted volume\n STDERR.puts \"Detaching current EBS volume:\"\n detached_vol=detach_volume(device)\n STDERR.puts \"detachment started (#{detached_vol.inspect})\"\n# this is necessary, for delete to succeed. however it may be too long of a wait time for decom\n wait_for_detachment(device, 60)\n delete_volume(detached_vol['aws_id'])\n detached_vol['aws_id']\n rescue => e\n display_exception(e, \"terminate_volume\")\n end",
"def cleanup_storage vm\n vm.volumes.each do |vol|\n @logger.debug \"Deleting volume #{vol.name} for OpenStack host #{vm.name}\"\n vm.detach_volume(vol.id)\n vol.wait_for { ready? }\n vol.destroy\n end\n end",
"def remove_gdom_disk(options)\n vds_disk = options['name']+\"_vdisk0\"\n message = \"Information:\\tRemoving disk \"+vds_disk+\" from Virtual Disk Server\"\n command = \"ldm remove-vdisk #{vds_disk} #{options['name']}\"\n execute_command(options,message,command)\n return\nend",
"def destroy\n @admissive_volume = AdmissiveVolume.find(params[:id])\n @admissive_volume.destroy\n\n respond_to do |format|\n format.html { redirect_to admissive_volumes_url }\n format.json { head :no_content }\n end\n end",
"def unmount_kvm_volume(name, dev)\n unmount(name)\n disable_netblockdev(dev)\nend",
"def delete_volume(volume_id)\n data = false\n conn = @ec2_main.environment.volume_connection\n if conn != nil\n if @ec2_main.settings.openstack\n response = conn.delete_volume(volume_id)\n if response.status == 202\n data = response.body\n else\n data = {}\n end\n elsif ((conn.class).to_s).start_with? \"Fog::Compute::AWS\"\n response = conn.delete_volume(volume_id)\n if response.status == 200\n data = true\n else\n data = false\n end\n else\n data = conn.delete_volume(volume_id)\n end\n else\n raise \"Connection Error\"\n end\n return data\n end",
"def destroy\n @volume.destroy\n respond_to do |format|\n format.html { redirect_to volumes_url }\n format.json { head :no_content }\n end\n end",
"def delete_from_disk; end",
"def detachvol(compute,volume)\n\t\tprint \"ebsvol[aws]->destroy: detaching #{volume['volumeId']} from #{volume['attachmentSet'][0]['instanceId']}\\n\" if $debug\n\t\tresponse = compute.detach_volume(volume['volumeId'], \n\t\t\t\t\t\t\t\t\t\t\t\t\t{ 'Device' => volume['attachmentSet'][0]['device'], \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Force' => true, \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'InstanceId' => volume['attachmentSet'][0]['instanceId'] })\n\t\tif (response.status == 200)\n\t\t\t# now wait for it to detach!\n\t\t\tcheck = volinfo(compute,volume['tagSet']['Name'])\n\t\t\twhile ( check['status'] != 'available' ) do\n\t\t\t\tprint \"ebsvol[aws]->detachvol: status is #{check['status']}\\n\" if $debug\n\t\t\t\tsleep 5\n\t\t\t\tcheck = volinfo(compute,volume['tagSet']['Name'])\n\t\t\tend\n\t\t\tsleep 5 # allow aws to propigate the fact\n\t\t\tprint \"ebsvol[aws]->detachvol: volume is now detached\\n\" if $debug\n\t\telse\n\t\t\traise \"ebsvol[aws]->detachvol: Sorry, I could not detach #{volume['volumeId']} from #{volume['attachmentSet'][0]['instanceId']}\"\n\t\tend\n\tend",
"def destroy\n @volume = Volume.find(params[:id])\n @volume.destroy\n\n respond_to do |format|\n format.html { redirect_to(volumes_url) }\n format.xml { head :ok }\n end\n end",
"def prune params = {}\n @connection.post(build_path(\"/volumes/prune\", params))\n end",
"def destroy\n @volume.destroy\n respond_to do |format|\n format.html { redirect_to volumes_url, notice: 'Volume was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sm_volume = SmVolume.find(params[:id])\n @sm_volume.destroy\n\n respond_to do |format|\n format.html { redirect_to sm_volumes_url }\n format.json { head :no_content }\n end\n end",
"def rm_r(path)\n cmd 'rm', '-r', path\nend",
"def delete_volume(volume_id)\n link = generate_request(\"DeleteVolume\",\n \"VolumeId\" => volume_id.to_s)\n request_info(link, RightBoolResponseParser.new(:logger => @logger))\n rescue Exception\n on_exception\n end",
"def detach!(volume_or_id)\n @@ec2.detach_volume(volume_or_id, id, device)\n @volumes = nil\n end",
"def delete_volume( options = {} )\n options = { :volume_id => '' }.merge(options)\n raise ArgumentError, \"No :volume_id provided\" if options[:volume_id].nil? || options[:volume_id].empty?\n params = {\n \"VolumeId\" => options[:volume_id]\n }\n return response_generator(:action => \"DeleteVolume\", :params => params)\n end",
"def unmount_command(path)\n \"udisksctl unmount --block-device #{path}\"\nend",
"def destroy\n @actual_volume.destroy\n respond_to do |format|\n format.html { redirect_to actual_volumes_url, notice: 'Actual volume was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def aliases\n [\n \"rm\", \"delete\", \"rm_vol\"\n ]\n end",
"def remove(name)\n sudo \"rm -rf #{god_confd}/#{name}\"\n end",
"def rm path\n end",
"def destroy_kvm(kvm_name)\n [\n \"virsh destroy #{kvm_name}\",\n \"virsh undefine #{kvm_name}\"\n ].each do |cmd|\n raise \"Failed to delete node: #{kvm_name}\" unless system(cmd)\n end\n File.delete(File.join(KVM_HOME, 'storage', \"#{kvm_name}.qcow2\"))\nend",
"def detachvolume\n if not checkRequirements([\"thezone\",\"theserver\",\"thevolume\"]) \n return false\n end\n checkToken(@thezone)\n data = queryGCE(:path => '/compute/v1beta15/projects/#{@thezone.name}/zones/#{@theserver.azone.name}/instances/#{@theserver.serial}/detachDisk', :method => 'post', :options => '', :access_token => @thezone.token )\n data ? data[\"floating_ip\"][\"ip\"] : false\n end",
"def remove!\n [\n PATH,\n ::File.expand_path('~/Library/Application Support/VLC'),\n ::File.expand_path('~/Library/Application Support/org.videolan.vlc')\n ].each do |d|\n directory d do\n recursive true\n action :delete\n end\n end\n end",
"def terminate_device(dev, keep_volume=true)\n vol_info = detach_volume(dev) \n wait_for_detachment(dev)\n delete_volume(vol_info['aws_id']) unless vol_info.nil? || keep_volume\n #depricating this rescue block -> see wait_for_detachment\n rescue Exception => e\n display_exception(e, \"terminate_device(#{dev}, #{keep_volume})\")\n STDERR.puts \"...was the previously mounted DB directory not an EBS volume??\\n continuing without the detachment...\"\n end",
"def remove_lvm(volume_group_name)\n RsMysql::Helper.remove_lvm(volume_group_name)\n end",
"def delete_volume(vol_id,wait=true)\n params = {:aws_id => vol_id,:api_version => 1.0}\n success=false\n 20.times do |i| \n begin\n STDERR.puts \"Making RightScale API call to delete EBS volume\"\n #STDERR.puts \"HERE IS THE URL: #{@api_url}/delete_ebs_volume.js (PARAMS: #{requestify(params)})\"\n body = RestClient.delete @api_url+\"/delete_ebs_volume.js\"+\"?\"+requestify(params)\n success=true\n #json = JSON.load(body)\n STDERR.puts \"Deleted VOLUME: #{vol_id}\"\n break\n rescue Exception => e\n display_exception(e, \"delete_volume(#{vol_id}, #{wait})\")\n sleep 5\n end\n end\n raise \"Couldn't delete volume #{vol_id}...aborting.\" unless success\n end",
"def remove\n dir = Pathname.new(path)\n syscmd(\"umount -f \\\"#{dir}\\\"\", valid_rcs: [32]) # 32 = not mounted\n File.unlink(readme_path) if File.exist?(readme_path)\n dir.rmdir if dir.exist?\n end",
"def destroy_storage_volume(volume_id)\n destroy_resource :storage_volume, volume_id\n end",
"def down(remove_volumes: false)\n run!('down', opts(v: [!!remove_volumes, false]))\n end",
"def vol_status(vs, vol_id)\n vol = vs.volumes.get(vol_id)\n unless vol.status == 'available'\n # puts \"vol status is not 'available' it is '#{status}' instead\"\n @log.error 'vol is not avaiable to delete'\n exit 2\n end\n end",
"def destroy_volume(id, volume_id=nil, params={}, payload={})\n url = nil\n if volume_id.is_a?(Array)\n url = \"#{base_path}/#{id}/volumes\"\n params['volumeId'] = volume_id\n elsif volume_id.is_a?(Numeric) || volume_id.is_a?(String)\n url = \"#{base_path}/#{id}/volumes/#{volume_id}\"\n else\n raise \"passed a bad volume_id: #{volume_id || '(none)'}\" # lazy\n end\n headers = { :params => params, :authorization => \"Bearer #{@access_token}\", 'Content-Type' => 'application/json' }\n execute(method: :delete, url: url, headers: headers, payload: payload.to_json)\n end",
"def rm(path)\n run_via \"rm #{path}\"\n end",
"def delete_vbox_vm_config(client_name)\n vbox_vm_dir = get_vbox_vm_dir(client_name)\n config_file = vbox_vm_dir+\"/\"+client_name+\".vbox\"\n if File.exist?(config_file)\n message = \"Removing:\\tVirtualbox configuration file \"+config_file\n command = \"rm \\\"#{config_file}\\\"\"\n execute_command(message,command)\n end\n return\nend",
"def detach_volume( options = {} )\n options = { :volume_id => '' }.merge(options)\n raise ArgumentError, \"No :volume_id provided\" if options[:volume_id].nil? || options[:volume_id].empty?\n options = { :instance_id => '' }.merge(options)\n options = { :device => '' }.merge(options)\n options = { :force => '' }.merge(options)\n params = {\n \"VolumeId\" => options[:volume_id],\n \"InstanceId\" => options[:instance_id],\n \"Device\" => options[:device],\n \"Force\" => options[:force].to_s\n }\n return response_generator(:action => \"DetachVolume\", :params => params)\n end",
"def volume_pull\n help = [\n '',\n \"Use: #{me} volume pull VOLUME\",\n '',\n 'Pulls all the docker images named inside the cyber-dojo volume'\n ]\n vol = ARGV[2]\n if [nil,'help','--help'].include? vol\n show help\n exit failed\n end\n\n exit_unless_is_cyber_dojo_volume(vol, 'pull')\n\n command =\n [\n 'docker run',\n '--rm',\n '--tty',\n \"--user=root\",\n \"--volume=#{vol}:/data:#{read_only}\",\n '--volume=/var/run/docker.sock:/var/run/docker.sock',\n \"#{cyber_dojo_hub}/web:#{docker_version}\",\n \"sh -c 'cd /usr/src/cyber-dojo/cli && ./volume_pull.rb /data'\"\n ].join(space=' ')\n\n system(command)\nend",
"def delete_errant_volumes(volumes)\n volumes_literal = \"\\\"#{volumes.keys.join('\",\"')}\\\"\"\n command = \"delete from results where volume_id not in (#{volumes_literal});\"\n puts \"Executing: #{command}\"\n @db.execute(command)\n end",
"def destroy\n begin\n # We need to set some variables, but we NEED the partition number to delete the partition\n partition= resource[:name]\n device=partition[0,(partition.length-1)]\n partition_nr=partition.slice(partition.length - 1)\n parted('--script',device,'rm',partition_nr)\n rescue Puppet::ExecutionFailure => e\n false\n end\n end",
"def destroy\n debug(\"#{self.class}::destroy\")\n\n #Retrieval of key\n if ((defined? $key) && !(($key.nil?) || ($key.empty?)))\n Puppet.debug('INFO: key already provided as a command parameter ' + $key)\n\n elsif (!($name.to_s.empty?) )\n\n #Retrieve key\n uriAttributeMap1 = {}\n uriAttributeMap1[:name] = $name\n resourceType = \"storage-service-levels\"\n $key = self.retrieveKeyOfObjectType('/api/1.0/slo/storage-service-levels', resourceType, uriAttributeMap1)\n\n end\n\n\n apiUri = '/api/1.0/slo/storage-service-levels/'+$key\n resourceType = \"storageservicelevel\"\n\n if(transport.http_delete_request(apiUri ,resourceType))\n if(resource[:name] != null)\n puts \"#{resourceType} : #{resource[:name]} successfully deleted\"\n\t\t\telse\n\t\t\t puts \" #{resourceType} successfully deleted\"\n\t\t\tend\n else\n if(resource[:name] != null)\n puts \" #{resourceType} : #{resource[:name]} deletion failed\"\n\t\t else\n\t\t\t puts \" #{resourceType} deletion failed\"\n\t\t end\n end\n\nend",
"def docker_rm\n sh 'docker rm --force brownbag', verbose: false\nrescue RuntimeError => error\n puts error.message\nend",
"def delete\n stop\n [ @resource['instances_dir'] + \"/\" + @resource[:name],\n @resource['instances_dir'] + \"/\" + \"_\" + @resource[:name]\n ].each do |dir|\n FileUtils.rm_rf(dir) if File.directory?(dir)\n end\n end",
"def smb_file_rm(file)\n fd = smb_open(file, 'ro')\n fd.delete\nend",
"def rm_rf(path)\n cmd 'rm', '-rf', path\nend",
"def remove_from(vm)\n VirtualBox.run_command! ['VBoxManage', '--nologo', 'storagectl', vm.uuid,\n '--name', name, '--remove']\n self\n end",
"def detach_volume(id, attachment)\n return delete_request(address(\"/servers/\"+id+\"/os-volume_attachments/\"+volume), @token)\n end",
"def cmd_rm(*args)\n\t\tif (args.length == 0)\n\t\t\tprint_line(\"Usage: rm file\")\n\t\t\treturn true\n\t\tend\n\n\t\tclient.fs.file.rm(args[0])\n\n\t\treturn true\n\tend",
"def volume_reduce(button)\n\t\tif @volumes > 0\n\t\t\t@volumes -= 1\n\t\t\tputs \"press #{button}! leaves volumes bar level at: #{@volumes}.\"\n\t\telse\n\t\t\tputs \" Volume bar level is at 0\"\n\t\tend\n\tend",
"def usage\n \"store delete_vol SHARE_NAME\"\n end",
"def destroy\n @volume_type = VolumeType.find(params[:id])\n @volume_type.destroy\n\n respond_to do |format|\n format.html { redirect_to volume_types_url }\n format.json { head :no_content }\n end\n end",
"def detach_volume(server, volume)\n @logger.info(\"Detaching volume `#{volume.id}' from `#{server.id}'...\")\n volume_attachments = @openstack.with_openstack { server.volume_attachments }\n attachment = volume_attachments.find { |a| a['volumeId'] == volume.id }\n if attachment\n @openstack.with_openstack { server.detach_volume(volume.id) }\n @openstack.wait_resource(volume, :available)\n else\n @logger.info(\"Disk `#{volume.id}' is not attached to server `#{server.id}'. Skipping.\")\n end\n end",
"def destroy\n output = \"oneimage delete #{resource[:name]} \", self.class.login\n `#{output}`\n end",
"def destroy!\n Dropio::Resource.client.delete_drop(self)\n end",
"def detach()\n $ec2.describe_volumes([self.id]).each do |result|\n if result[:aws_attachment_status] == 'attached'\n $ec2.detach_volume(self.id)\n end\n end\n self.attached_instance = nil\n self.save()\n end",
"def delete_volume request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_delete_volume_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Longrunning::Operation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end",
"def rm(key, options = {})\n return 1 unless self.class.subkeys.include?(key)\n begin\n puts \"Removing directory: #{MDT::DataStorage.instance.versioned_base_path}/#{MDT::DataStorage.instance.versioned_releases_dirname}/#{MDT::DataStorage.instance.versioned_version_id}\"\n FileUtils.rm_rf(Dir[\"#{MDT::DataStorage.instance.versioned_base_path}/#{MDT::DataStorage.instance.versioned_releases_dirname}/#{MDT::DataStorage.instance.versioned_version_id}\"].first)\n 0\n rescue\n 1\n end\n end",
"def unmount(name)\n mount_loc = File.join(KVM_MOUNT_POINT, name)\n if(system(\"umount #{mount_loc}\"))\n true\n else\n raise \"Failed to unmount kvm drive\"\n end\nend",
"def delete\n execute_prlctl('delete', @uuid)\n end",
"def unconfigure_vbox_vm(client_name)\n check_vbox_is_installed()\n exists = check_vbox_vm_exists(client_name)\n if exists == \"no\"\n puts \"VirtualBox VM \"+client_name+\" does not exist\"\n exit\n end\n stop_vbox_vm(client_name)\n sleep(5)\n message = \"Deleting:\\tVirtualBox VM \"+client_name\n command = \"VBoxManage unregistervm #{client_name} --delete\"\n execute_command(message,command)\n return\nend",
"def destroy\n log_debug \"[ #{@node}/#{@environment} ] - Destroy Podman Container #{@container} ...\"\n @cmd_runner.run_cmd \"#{podman_cmd} container rm #{@container}\"\n end",
"def detach_planned_volume(mapping)\n payload = {:agent_identity => @agent_identity, :device_name => mapping[:device_name]}\n Log.info(\"Detaching volume #{mapping[:volume_id]} for management purposes.\")\n req = RetryableRequest.new(\"/storage_valet/detach_volume\", payload, :retry_delay => VolumeManagement::VOLUME_RETRY_SECONDS)\n\n req.callback do |res|\n # don't set :volume_status here as that should only be queried\n mapping[:management_status] = 'detached'\n mapping[:attempts] = nil\n yield if block_given?\n end\n\n req.errback do |res|\n unless InstanceState.value == 'stranded'\n # volume could already be detaching or have been deleted\n # which we can't see because of latency; go around again\n # and check state of volume later.\n Log.error(\"Failed to detach volume #{mapping[:volume_id]} (#{res})\")\n mapping[:attempts] ||= 0\n mapping[:attempts] += 1\n # retry indefinitely so long as core api instructs us to retry or else fail after max attempts.\n if mapping[:attempts] >= VolumeManagement::MAX_VOLUME_ATTEMPTS\n strand(\"Exceeded maximum of #{VolumeManagement::MAX_VOLUME_ATTEMPTS} attempts detaching volume #{mapping[:volume_id]} with error: #{res}\")\n else\n yield if block_given?\n end\n end\n end\n\n req.run\n end",
"def destroy_digital\n digital.destroy\n end",
"def rm_deposit_bag_safely_for_ceph\n if deposit_bag_pathname.exist?\n deposit_bag_pathname.rmtree\n else\n Honeybadger.notify(\"Deposit bag was missing. This is unusual; it's likely that the workflow step ran once before, and \" \\\n \"failed on the network call to preservation_catalog. Please confirm that #{druid} passes checksum \" \\\n 'validation in preservation_catalog, and that its preserved version matches the Cocina in dor-services-app.')\n end\n\n stat_moab_dir_contents\n end",
"def short_desc\n 'Remove the specified target from the iSCSI volume store.'\n end",
"def run_destroy\n run(\n result:\n ::Kitchen::Terraform::Client::Command\n .destroy(\n options:\n ::Kitchen::Terraform::Client::Options\n .new\n .enable_lock\n .lock_timeout(duration: config_lock_timeout)\n .disable_input\n .maybe_no_color(toggle: !config_color)\n .parallelism(concurrent_operations: config_parallelism)\n .enable_refresh\n .state(path: config_state)\n .state_out(path: config_state)\n .vars(keys_and_values: config_variables)\n .var_files(paths: config_variable_files)\n .force,\n working_directory: instance_directory\n )\n )\n end",
"def volumes\n volumes = @ec2.volumes\n volumes.delete_if {|v| v.instance_id != id}\n end",
"def mute\n @volume = 0\n end",
"def volume\n help = [\n '',\n \"Use: #{me} volume [COMMAND]\",\n '',\n 'Manage cyber-dojo setup volumes',\n '',\n 'Commands:',\n minitab + 'create Creates a new volume',\n minitab + 'rm Removes a volume',\n minitab + 'ls Lists the names of all volumes',\n minitab + 'inspect Displays details of a volume',\n minitab + \"pull Pulls the docker images inside a volume's manifest.json files\",\n '',\n \"Run '#{me} volume COMMAND --help' for more information on a command\",\n ]\n case ARGV[1]\n when 'create' then volume_create\n when 'rm' then volume_rm\n when 'ls' then volume_ls\n when 'inspect' then volume_inspect\n when 'pull' then volume_pull\n else show help\n end\nend",
"def deleteEssence\n \n begin\n \n # Gets @filename and @path\n getPathAndFilename \n name = @filename \n filepath = @path\n puts \"filepath: \" + filepath \n puts \"filename: \" + name\n \n # Find the device \n device = User.find_by_username(params[:username]).devices.find_by_dev_name(params[:devicename])\n \n # Essence can't be deleted from a virtual container\n if device.dev_type == \"virtual_container\"\n render :text => \"Error: Essence can't be deleted from a virtual container'\", :status => 409\n return \n end\n \n file = nil\n if device != nil\n file = device.devfiles.find(:first, :conditions => [\"name = ? and path = ?\", name, filepath])\n if file == nil\n puts \"FILE NOT FOUND: \" + name\n render :text => \"Error. File's metadata can not be found.\", :status => 404\n return\n end\n \n if params[:blob_hash]\n blob = file.blobs.find(:first, :conditions => [\"blob_hash = ?\", params[:blob_hash]])\n else\n blob = file.blobs.find_by_follower_id(nil)\n end\n end\n \n # Checks that the file's and it's version's metadata can be found in database.\n if file == nil or blob == nil\n puts \"Blob not found for file: \" + name\n render :text => \"Error. File's metadata can not be found.\", :status => 404\n return\n end\n \n if blob.uploaded == false\n render :text => \"Error: Essence of the file was not on the server.\", :status => 409\n return\n end\n \n # Remove the fileupload entry\n fup = Fileupload.find_by_blob_id(blob.id)\n if fup != nil\n fup.destroy\n end\n \n # Update blob not to be uploaded and upload_requested to nil\n blob.update_attribute(:uploaded, false)\n blob.update_attribute(:upload_requested, nil)\n \n \n # Remove the actual essence\n deletepath = \"public/devfiles/\" + file.device_id.to_s + \"/\" + blob.blob_hash + \"_\" + file.name\n \n if File.exists?(deletepath)\n FileUtils.rm_f(deletepath)\n puts \"deleted the essence...\"\n else\n puts \"Essence not found and could not be deleted...\"\n end\n \n rescue => exp\n putsE(exp)\n render :text => \"There was an error when trying to delete the essence from the server\", :status => 409\n return\n end\n \n render :text => \"Essence of the file deleted from the server\", :status => 200\n return\n end",
"def volume_down!\n raise InvalidActionError, \"Cannot volume down an Output that is already voluming.\" unless not_voluming?\n volume_down_action.tap do |action|\n write_action action\n end\n end",
"def clean_related_volumes!\n delegate(provider, :clean_related_volumes!)\n end",
"def remove_from_disk\n File.delete @flv if @flv && (File.exist? @flv)\n File.delete @mp4 if @mp4 && (File.exist? @mp4)\n true\n rescue\n p 'Error while deleting files from disk!'\n false\n end",
"def detach_file_from_parallels_vm(options)\n message = \"Information:\\tAttaching Image \"+options['file']+\" to \"+options['name']\n command = \"prlctl set \\\"#{options['name']}\\\" --device-set cdrom0 --disable\\\"\"\n execute_command(options,message,command)\n return\nend",
"def delete\n puts \"Device #{name}::#{serial} Dettached!\\n\"\n log_message(\"#{self}\", \"Device #{name}::#{serial} Dettached!\\n\")\n rfid_delete\n end",
"def remove!\n windows_package 'Chef Development Kit' do\n action :remove\n end\n end",
"def long_desc\n 'This command deletes the specified target from the pool, and ' +\n 'unlinks the volume store backing the target. Since the underlying ' +\n 'volume store is destroyed, this action is ' + ANSI.bold{ \"irreversible\" } +\n 'and so this command should be used with ' + ANSI.bold{ \"great\" } + 'care.' +\n \"\\n\\n\" +\n 'NOTE: Any clients attached to the volume will have their ' +\n 'iSCSI session forcibly closed. This may result in the premature ' +\n 'death of the client if care is not taken.'\n end",
"def rm_str(options, src)\n\t\targ = \"rm \" + options + \" \" + src\n\t\tputs arg\n\t\tsystem arg\n\tend",
"def destroy_service\n # Disable automatically destroys the service with Runit.\n directory \"/var/log/#{new_resource.service_name}\" do\n action :delete\n recursive true\n end\n end",
"def stop_kvm(name)\n unless(system(\"virsh destroy #{name}\"))\n raise \"Failed to stop node: #{name}\"\n end\nend",
"def set_volume(volume)\n puts \"Setting volume to #{volume}\" if $verbose\n v='AG'+(('000'+volume.to_s)[-3..-1])+';'\n puts v if $verbose\n ret=send_cmd(v,'AG;',v,0.5,1.5,3)\n if(ret)\n return(ret.gsub(/^AG/,'').gsub(/;$/,'').to_i)\n else\n return(nil)\n end\nend",
"def volume_down!\n raise InvalidActionError, \"Cannot volume down an Output that is already voluming.\" unless not_voluming?\n volume_down_action.tap do |action|\n write_action action\n end\n end",
"def delete(key)\n log \"deleting #{key} from #{container_path}\"\n object_path = File.join(container_path, Raca::Util.url_encode(key))\n response = storage_client.delete(object_path)\n (200..299).cover?(response.code.to_i)\n end",
"def detach_volume(name=nil, volname=nil)\n if name\n @mgr.setparam(\"name\", name)\n end\n if volname\n @mgr.setparam(\"volname\", volname)\n end\n @mgr.normalize_name_parameters()\n name, volname = @mgr.getparams(\"name\", \"volname\")\n instance, err = resolve_instance()\n unless instance\n yield \"#{@mgr.timestamp()} detach_volume called on non-existing instance #{name}: #{err}\"\n return nil\n end\n return detach_instance_volume(instance, volname) { |s| yield s }\n end",
"def umount_and_detach_device(options={})\n detached_vol=nil\n device = get_device_mount_point(self.MountPoint)\n if(options[:device])\n STDERR.puts \"WARNING! the previously mounted device (#{device}) is different from the device we're asking to detach (#{options[:device]})\"\n device = options[:device]\n end\n begin\n umount_dir(self.MountPoint)\n rescue Exception => e\n STDERR.puts \"#{e}\\n ...continuing without unmounting\"\n end\n #detache the mounted volume\n STDERR.puts \"Detaching volume in device #{device}:\"\n begin\n detached_vol=detach_volume(device)\n\n raise EBSRemoteExecException.new(nil,$?,\"Timeout while waiting for the device to attach\") unless wait_for_detachment(device)\n rescue Exception => e\n display_exception(e, \"unmount_and_detach_device\")\n STDERR.puts \"...was the previously mounted DB directory not an EBS volume??\\n continuing without the detachment...\"\n end\n detached_vol\n end",
"def destroy\n @volume_metadatum = VolumeMetadatum.find(params[:id])\n @volume_metadatum.destroy\n\n respond_to do |format|\n format.html { redirect_to volume_metadata_url }\n format.json { head :no_content }\n end\n end",
"def volume _value, _abs=0\n send_cmd(\"volume #{_value} #{_abs}\")\n end",
"def destroy\n @album = Album.find(params[:id])\n @album.destroy\n # Dir.chdir(\"public/images\")\n Dir.delete(@album['directory'])\n\n respond_to do |format|\n format.html { redirect_to albums_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @product = Product.find(params[:id])\n if @product.stockvolume == 1\n @product.destroy\n else\n @product.update(stockvolume: @product.stockvolume - 1)\n end\n\n redirect_to products_path\n\n end",
"def clean()\n rels = releases()\n rels.pop()\n\n unless rels.empty?\n rm = ['rm', '-rf'].concat(rels.map {|r| release_dir(r)})\n rm << release_dir('skip-*')\n cmd.ssh(rm)\n end\n end",
"def cleanup_release\n if ssh.directory_exists?(release_path)\n ssh.run(\"rm -rf #{release_path}\")\n end\n end",
"def destroy\n vm.destroy\n FileUtils.rm_rf dir\n end"
] | [
"0.7865445",
"0.71562785",
"0.69014466",
"0.67364144",
"0.67362696",
"0.6727698",
"0.6705424",
"0.66121924",
"0.65491056",
"0.65086246",
"0.6469485",
"0.64405763",
"0.6416325",
"0.63992417",
"0.6385814",
"0.6303534",
"0.6276301",
"0.62409395",
"0.62321573",
"0.6213605",
"0.61722785",
"0.6105881",
"0.61037403",
"0.60796493",
"0.6055792",
"0.6053738",
"0.60486907",
"0.60387045",
"0.602103",
"0.60147196",
"0.6007037",
"0.59904957",
"0.59852713",
"0.5984713",
"0.596037",
"0.594363",
"0.59388775",
"0.5918258",
"0.59053105",
"0.5897625",
"0.58939874",
"0.58879834",
"0.5885873",
"0.58732355",
"0.5870549",
"0.58533174",
"0.5828119",
"0.5817354",
"0.5812272",
"0.580672",
"0.58037055",
"0.5790941",
"0.5785647",
"0.57639164",
"0.5761966",
"0.574815",
"0.5746821",
"0.5745843",
"0.5731985",
"0.57229",
"0.57035744",
"0.57024145",
"0.5690169",
"0.56838274",
"0.5671126",
"0.5652733",
"0.5644861",
"0.56419426",
"0.5623102",
"0.561301",
"0.5611435",
"0.56093717",
"0.55975056",
"0.55949837",
"0.5594522",
"0.558178",
"0.5580307",
"0.55774397",
"0.55759764",
"0.5570167",
"0.5559004",
"0.55506307",
"0.5539094",
"0.5538884",
"0.5526188",
"0.5513714",
"0.55020726",
"0.5500911",
"0.54929173",
"0.54921484",
"0.54901785",
"0.5487973",
"0.5486765",
"0.5485573",
"0.54852337",
"0.54817307",
"0.54815125",
"0.54705787",
"0.54553145",
"0.5454888"
] | 0.7651154 | 1 |
========================================================================================= $ ./cyberdojo volume pull ========================================================================================= | def volume_pull
help = [
'',
"Use: #{me} volume pull VOLUME",
'',
'Pulls all the docker images named inside the cyber-dojo volume'
]
vol = ARGV[2]
if [nil,'help','--help'].include? vol
show help
exit failed
end
exit_unless_is_cyber_dojo_volume(vol, 'pull')
command =
[
'docker run',
'--rm',
'--tty',
"--user=root",
"--volume=#{vol}:/data:#{read_only}",
'--volume=/var/run/docker.sock:/var/run/docker.sock',
"#{cyber_dojo_hub}/web:#{docker_version}",
"sh -c 'cd /usr/src/cyber-dojo/cli && ./volume_pull.rb /data'"
].join(space=' ')
system(command)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pull; end",
"def get_volume()\n return(get_cmd('AG;',0.1,0.5,3).gsub(/^AG/,'').gsub(/;$/,'').to_i)\nend",
"def fetch_volume_by_id\n vol = storage_api.find_by_id(volume_id)\n data = vol.body.fetch(\"volume\")\n @name = data.fetch('display_name')\n @volume_type = data.fetch('volume_type')\n @size = data.fetch('size')\n\n # Sometimes the Rackspace API takes time to update,\n # and newly-attached volumes don't report any attachments\n # yet.\n attachments = data.fetch('attachments')\n if attachments.any?\n @device = attachments.first.fetch('device')\n end\n end",
"def populate_volume(server)\n server.spot_check_command(\" echo \\\"blah blah blah\\\" > #{@mount_point}/data.txt\")\n end",
"def start_point_pull\n help = [\n '',\n \"Use: #{me} start-point pull NAME\",\n '',\n 'Pulls all the docker images inside the named start-point'\n ]\n\n vol = ARGV[2]\n if [nil,'--help'].include? vol\n show help\n exit succeeded\n end\n\n exit_unless_is_cyber_dojo_volume(vol, 'pull')\n\n unless ARGV[3].nil?\n STDERR.puts \"FAILED: unknown argument [#{ARGV[3]}]\"\n exit failed\n end\n\n command =\n [\n 'docker run',\n '--rm',\n '--tty',\n \"--user=root\",\n \"--volume=#{vol}:/data:#{read_only}\",\n '--volume=/var/run/docker.sock:/var/run/docker.sock',\n \"#{cyber_dojo_commander}\",\n \"sh -c './start_point_pull.rb /data'\"\n ].join(space=' ')\n\n system(command)\nend",
"def get_volume\n @volume\n end",
"def get_volume(volume_id)\n get(\"cloud-instances/#{guid}/volumes/#{volume_id}\")\n end",
"def do_volume(num)\n\n fail CvlcClientError, \"The 'volume' command requires an integer value between 0 and 300...\" unless num.between?(0, 300)\n do_command(\"requests/status.json?command=volume&val=#{num}\")\n sleep STATUS_PAUSE\n return pretty_status(current_status)\n end",
"def volume_inspect\n help = [\n '',\n \"Use: #{me} volume inspect VOLUME\",\n '',\n 'Displays details of the named cyber-dojo volume',\n ]\n # asked for help?\n vol = ARGV[2]\n if [nil,'help','--help'].include? vol\n show help\n exit failed\n end\n\n # TODO: check for unknown args\n\n exit_unless_is_cyber_dojo_volume(vol, 'inspect')\n\n command =\n [\n 'docker run',\n '--rm',\n \"--user=root\",\n \"--volume=#{vol}:/data:#{read_only}\",\n '--volume=/var/run/docker.sock:/var/run/docker.sock',\n \"#{cyber_dojo_hub}/web:#{docker_version}\",\n \"sh -c 'cd /usr/src/cyber-dojo/cli && ./volume_inspect.rb /data'\"\n ].join(space=' ')\n\n print run(command)\nend",
"def refresh_basic_state\n get_source\n get_volume\n end",
"def volume\n $redis_pool.with { |redis| redis.get('warble:volume').to_i }\n end",
"def pull\n start = Time.now\n job = job_of(\n clean(\n Typhoeus::Request.get(\n 'https://wts.zold.io/pull',\n headers: headers\n )\n )\n )\n @log.debug(\"PULL job #{job} started in #{Zold::Age.new(start)}\")\n job\n end",
"def set_volume(volume)\n puts \"Setting volume to #{volume}\" if $verbose\n v='AG'+(('000'+volume.to_s)[-3..-1])+';'\n puts v if $verbose\n ret=send_cmd(v,'AG;',v,0.5,1.5,3)\n if(ret)\n return(ret.gsub(/^AG/,'').gsub(/;$/,'').to_i)\n else\n return(nil)\n end\nend",
"def volume\n app.speakers.ID(@id).volume.get\n end",
"def volume _value, _abs=0\n send_cmd(\"volume #{_value} #{_abs}\")\n end",
"def test_pull\n \tassert_equal(UI.parseCommand('pull', PullCmd1*\" \"),UI.main(PullCmd1))\n \tassert_equal(UI.parseCommand('pull', PullCmdInv*\" \"),UI.main(PullCmdInv))\n end",
"def current\n c = IO::popen(\"pacmd \\\"list-sinks\\\" | grep volume | head -1\").readlines[0]\n return c.split(\" \").last.sub(\"%\", \"\").strip.to_i\nend",
"def traded_volume\n data.fetch('tradedVolume')\n end",
"def volume_ls\n help = [\n '',\n \"Use: #{me} volume ls\",\n '',\n 'Lists the names of all cyber-dojo volumes',\n '',\n minitab + '--quiet Only display volume names'\n ]\n\n if ['help','--help'].include? ARGV[2]\n show help\n exit failed\n end\n\n # There is currently no [--filter label=LABEL] option on [docker volume ls]\n # https://github.com/docker/docker/pull/21567\n # So I have to inspect all volumes. Could be slow if lots of volumes.\n\n names = run(\"docker volume ls --quiet\").split\n names = names.select{ |name| cyber_dojo_volume?(name) }\n\n if ARGV[2] == '--quiet'\n names.each { |name| puts name }\n else\n types = names.map { |name| cyber_dojo_type(name) }\n urls = names.map { |name| cyber_dojo_label(name) }\n\n headings = { :name => 'NAME', :type => 'TYPE', :url => 'SRC' }\n\n gap = 3\n max_name = ([headings[:name]] + names).max_by(&:length).length + gap\n max_type = ([headings[:type]] + types).max_by(&:length).length + gap\n max_url = ([headings[:url ]] + urls ).max_by(&:length).length + gap\n\n spaced = lambda { |max,s| s + (space * (max - s.length)) }\n\n name = spaced.call(max_name, headings[:name])\n type = spaced.call(max_type, headings[:type])\n url = spaced.call(max_url , headings[:url ])\n puts name + type + url\n names.length.times do |n|\n name = spaced.call(max_name, names[n])\n type = spaced.call(max_type, types[n])\n url = spaced.call(max_url , urls[n])\n puts name + type + url\n end\n end\nend",
"def pull\n if self.connect then\n @config = UBNT::Configuration.parse(@ssh_connection.scp.download!(\"/tmp/system.cfg\"))\n end\n end",
"def set_bunny_volume vol\n @exch.publish(vol.to_i) \n end",
"def detachvolume\n false\n end",
"def retrieve_volumes\n dbg { \"retrieving #{pool_info}, #{hv_info}\" }\n\n volumes = pool.list_all_volumes\n dbg { \"list_all_volumes #{pool_info}, #{hv_info}\" }\n\n storage_volumes = volumes.map.with_index do |vol, index|\n id = \"#{uuid}--#{index}\"\n StorageVolume.new(vol, pool: self, id: id)\n end\n\n dbg { \"retrieved size=#{storage_volumes.size}, #{pool_info}, #{hv_info}\" }\n storage_volumes\n end",
"def pull( source=nil, **options )\n\t\tself.server.run( :pull, source, **options )\n\t\treturn true\n\tend",
"def get_volumes\n volumes = get(\"cloud-instances/#{guid}/volumes\")[\"volumes\"] || []\n\n volumes.map do |volume|\n get_volume(volume[\"volumeID\"])\n end\n end",
"def pull_update( source=nil, **options )\n\t\toptions[:update] = true\n\t\treturn self.pull( source, **options )\n\tend",
"def set_pull\n @pull = Pull.find(params[:id])\n end",
"def set_pull\n @pull = Pull.find(params[:id])\n end",
"def volume\n help = [\n '',\n \"Use: #{me} volume [COMMAND]\",\n '',\n 'Manage cyber-dojo setup volumes',\n '',\n 'Commands:',\n minitab + 'create Creates a new volume',\n minitab + 'rm Removes a volume',\n minitab + 'ls Lists the names of all volumes',\n minitab + 'inspect Displays details of a volume',\n minitab + \"pull Pulls the docker images inside a volume's manifest.json files\",\n '',\n \"Run '#{me} volume COMMAND --help' for more information on a command\",\n ]\n case ARGV[1]\n when 'create' then volume_create\n when 'rm' then volume_rm\n when 'ls' then volume_ls\n when 'inspect' then volume_inspect\n when 'pull' then volume_pull\n else show help\n end\nend",
"def get_volume_id(sys_id,volume_name)\n response = request(:get, \"/devmgr/v2/storage-systems/#{sys_id}/volumes\")\n status(response, 200, 'Failed to get Volumes')\n volumes = JSON.parse(response.body)\n volumes.each do |vm|\n \t return vm['id'] if vm['name'] == volume_name\n \tend\n response = request(:get, \"/devmgr/v2/storage-systems/#{sys_id}/thin-volumes\")\n status(response, 200, 'Failed to get thin Volumes')\n volumes = JSON.parse(response.body)\n volumes.each do |vm|\n return vm['id'] if vm['name'] == volume_name\n end\n \tfalse\n end",
"def volumes\n client = Aws::EC2::Client.new\n client.describe_volumes({\n filters: [{\n name: \"tag:backup\",\n values: [\"true\"]\n }]\n }).volumes\nend",
"def volume(volume_id)\n volumes(volume_id)[0]\n end",
"def pull_latest_changes\n system \"cd #{Dots.home} && #{git_pull}\"\n end",
"def start_point_latest\n help = [\n '',\n \"Use: #{me} start-point latest NAME\",\n '',\n 'Re-pulls already pulled docker images inside the named start-point'\n ]\n\n vol = ARGV[2]\n if [nil,'--help'].include? vol\n show help\n exit succeeded\n end\n\n exit_unless_is_cyber_dojo_volume(vol, 'pull')\n\n unless ARGV[3].nil?\n STDERR.puts \"FAILED: unknown argument [#{ARGV[3]}]\"\n exit failed\n end\n\n command =\n [\n 'docker run',\n '--rm',\n '--tty',\n \"--user=root\",\n \"--volume=#{vol}:/data:#{read_only}\",\n '--volume=/var/run/docker.sock:/var/run/docker.sock',\n \"#{cyber_dojo_commander}\",\n \"sh -c './start_point_latest.rb /data'\"\n ].join(space=' ')\n\n system(command)\nend",
"def detachvolume\n if not checkRequirements([\"thezone\",\"theserver\",\"thevolume\"]) \n return false\n end\n checkToken(@thezone)\n data = queryGCE(:path => '/compute/v1beta15/projects/#{@thezone.name}/zones/#{@theserver.azone.name}/instances/#{@theserver.serial}/detachDisk', :method => 'post', :options => '', :access_token => @thezone.token )\n data ? data[\"floating_ip\"][\"ip\"] : false\n end",
"def list_volumes\n response = @connection.req(\"GET\", \"/#{@volume_path}\")\n volumes_hash = JSON.parse(response.body)[\"volumes\"]\n volumes_hash.inject([]){|res, current| res << OpenStack::Volume::Volume.new(current); res}\n end",
"def pull\n fetch\n merge\n end",
"def update_volume_info\n\t\t#\t\t@pool = Pool.find(self.pool_id)\n\t\t#\t\t@host = Host.find(@pool.host_id)\n\t\t#\n\t\t#\t\tconnection = ConnectionsManager.instance\n\t\t#\t\tconnection_hash = connection.get(@host.name)\n\t\t#\t\tconn = connection_hash[:conn]\n\n\t\t# get pool reference in order to get a reference to the volume\n\t\t@pool = @conn.lookup_storage_pool_by_name(@pool.name)\n\t\tvolume = @pool.lookup_volume_by_name(self.name)\n\t\tvolume_info = volume.info\n\t\t\n\t\t# add some stats to pool object\n\t\tdivide_to_gigabytes = (1024 * 1024 * 1024).to_f\n\t\tself.allocation = (volume_info.allocation.to_f / divide_to_gigabytes).to_f\n\tend",
"def get_workset_volumes (author, token, workset_name)\n Rails.logger.debug \"get_workset_volumes #{author}, #{workset_name}\"\n url = URI.parse(\"#{APP_CONFIG['registry_url']}/worksets/#{workset_name}/volumes?author=#{author}\")\n http = Net::HTTP.new(url.host, url.port)\n if Rails.env.development?\n http.set_debug_output($stdout)\n end\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Get.new(url.request_uri)\n request.add_field(\"Authorization\", \"Bearer #{token}\")\n request.add_field(\"Accept\", \"application/vnd.htrc-workset+xml\")\n response = http.request(request)\n\n case response\n when Net::HTTPUnauthorized then\n raise Exceptions::SessionExpiredError.new(\"Session expired. Please login again\")\n when Net::HTTPSuccess then\n # Do nothing\n else\n raise Exceptions::SystemError.new(\"Error retrieving worksets (HTTP #{response.code})\")\n end\n\n #Rails.logger.debug \"Response Code: #{response.code}\"\n\n volumes = response.body\n ids = volumes.split(\" \")\n return ids\n end",
"def pull_file(path)\n @bridge.pull_file(path)\n end",
"def volume_rm\n # Allow deletion of a default volume.\n # This allows you to create custom default volumes.\n help = [\n '',\n \"Use: #{me} volume rm VOLUME\",\n '',\n \"Removes a volume created with the [#{me} volume create] command\"\n ]\n\n vol = ARGV[2]\n if [nil,'help','--help'].include? vol\n show help\n exit failed\n end\n\n exit_unless_is_cyber_dojo_volume(vol, 'rm')\n\n run \"docker volume rm #{vol}\"\n if $exit_status != 0\n puts \"FAILED [volume rm #{vol}] can't remove volume if it's in use\"\n exit failed\n end\n\nend",
"def check_volume(volume) \n # Default warning_limit\n warning_limit=@warning_limit\n # Default critical_limit\n critical_limit=@critical_limit\n # Default nobackup_status\n nobackup_status=@nobackup_status\n\n puts \"Checking volume: #{volume}\" if @verbose\n\n if @objects.has_key?(volume) and not @objects[volume].has_key?(:skip)\n vol=DuplicityVolume.new(volume,@config_values,@objects[volume])\n vol.debug=@debug\n vol.testing=@testing\n vol.run(\"col\")\n\n puts \" Checking vol: #{volume} last backup: #{vol.last_backup}\" if @verbose\n warning_limit=@objects[volume][:warning_limit] if @objects[volume].has_key? :warning_limit\n\t puts \" warning_limit for #{volume} is #{warning_limit}\" if @debug\n critical_limit=@objects[volume][:critical_limit] if @objects[volume].has_key? :critical_limit\n\t puts \" critical_limit for #{volume} is #{critical_limit}\" if @debug\n nobackup_status=@objects[volume][:nobackup_status] if @objects[volume].has_key? :nobackup_status\n\t puts \" nobackup_status for #{volume} is #{nobackup_status}\" if @debug\n # Check backup age\n check_time=Time.now\n if vol.last_backup\n if check_time < vol.last_backup + warning_limit.to_i\n incstatus(\"OK\")\n elsif check_time >= vol.last_backup + warning_limit.to_i and check_time < vol.last_backup + critical_limit.to_i\n @short+=\"#{vol.name} OLD, \"\n @long+=\"#{vol.name} is too OLD\\n\"\n incstatus(\"WARNING\")\n elsif check_time >= vol.last_backup + critical_limit.to_i\n @short+=\"#{vol.name} OLD, \"\n @long+=\"#{vol.name} is too OLD\\n\"\n incstatus(\"CRITICAL\")\n end\n else\n @short+=\"no backups for #{vol.name}, \"\n @long+=\"No backups found for volume #{vol.name}\\n\"\n incstatus(nobackup_status)\n end\n else\n puts \"ERROR: Volume #{volume} is not defined\"\n return false\n end\n end",
"def set_volume\n @volume = Volume.find(params[:id])\n end",
"def set_volume\n @volume = Volume.find(params[:id])\n end",
"def volume; property('volume'); end",
"def volume; self.class.volume; end",
"def get_pull(owner, repo, number)\n\t\t\tPullRequests.get(\"/repos/#{owner}/#{repo}/pulls/#{number}\", headers: @auth)\n\t\tend",
"def list_all_volumes\n Docker::Volume.all({}, client)\n rescue\n []\n end",
"def set_volume\n @volume = services.block_storage.get_volume(params[:id])\n end",
"def init_ebs_volumes\n @@client.describe_volumes.volumes\n end",
"def get_vol\n\t\tIO::popen('amixer sget Master') do |f|\n\t\t\tf.read.scan(/Front Left.*?\\[(\\d+)%\\].*?\\[(on|off)\\]\\n/) do |pc, on_or_off|\n\t\t\t\treturn {\n\t\t\t\t\t:vol => pc.to_i,\n\t\t\t\t\t:mute => 'off' == on_or_off\n\t\t\t\t}\n\t\t\tend\n\t\tend\n\t\treturn { :vol => -1, :mute => false }\n\tend",
"def pull\n VehicleRealtime.pull_real_time()\n \n respond_to do |format|\n format.html { redirect_to vehicle_realtimes_url, notice: 'Vehicle realtime was successfully updated.' }\n format.json {\n render :json => {\n message: 'success'\n }\n }\n end\n end",
"def device\n @client.get('VBD', :device, @uuid)\n end",
"def pullLever\n\n system(%Q{say -v \"karen\" \"You pull the lever saving 5 innocent men\"})\n system(%Q{say -v \"karen\" \"But directly killing 1 \"})\n system(%Q{say -v \"karen\" \"You are responsible for this mans death\"})\n system(%Q{say -v \"karen\" \"and the blood is on your hands \"})\n\n end",
"def fetch_raw(format=nil)\n @format = RESPONSE_FORMATS[format] if format\n http_pull(build_url)\n end",
"def get(options = nil)\n super(options, 'host', GET_PARAMS, [:show_volume])\n end",
"def volumes_list(state = \"active\", limit = \"1000\")\n case state\n when \"active\"\n api_call = {\n :method => \"ListActiveVolumes\",\n :params => {\n :startVolumeID => 0,\n :limit => limit\n }\n }\n when \"deleted\"\n api_call = {\n :method => \"ListDeletedVolumes\",\n :params => {}\n }\n end\n answer = query_sf(api_call)\n return answer[\"volumes\"]\n end",
"def detach_volume( options = {} )\n options = { :volume_id => '' }.merge(options)\n raise ArgumentError, \"No :volume_id provided\" if options[:volume_id].nil? || options[:volume_id].empty?\n options = { :instance_id => '' }.merge(options)\n options = { :device => '' }.merge(options)\n options = { :force => '' }.merge(options)\n params = {\n \"VolumeId\" => options[:volume_id],\n \"InstanceId\" => options[:instance_id],\n \"Device\" => options[:device],\n \"Force\" => options[:force].to_s\n }\n return response_generator(:action => \"DetachVolume\", :params => params)\n end",
"def set_actual_volume\n @actual_volume = ActualVolume.find(params[:id])\n end",
"def get_osx_disk_name(options)\n message = \"Information:\\tGetting root disk device ID\"\n command = \"df |grep '/$' |awk '{print \\\\$1}'\"\n output = execute_command(options,message,command)\n disk_id = output.chomp\n message = \"Information:\\tGetting volume name for \"+disk_id\n command = \"diskutil info #{disk_id} | grep 'Volume Name' |cut -f2 -d':'\"\n output = execute_command(options,message,command)\n volume = output.chomp.gsub(/^\\s+/,\"\")\n return volume\nend",
"def jenkins_download(opts)\n\tputs \"### Downloading jenkins image ###\"\n\trun_in_shell \"docker pull #{opts[:source]}\"\n\tputs \"#################################\"\nend",
"def test_volume_data(server)\n server.spot_check_command(\"test -f #{@mount_point}/data.txt\")\n end",
"def pull_image image_name\n \[email protected] \"Pulling Image: #{image_name}\"\n ::Docker.options = {:chunk_size => 1, :read_timeout => 3600}\n ::Docker::Image.create('fromImage' => image_name)\n end",
"def show_vol()\n\t\tvm = get_vol\n\t\[email protected]=$muted_colors[vm[:mute]]\n\t\[email protected]='Volume'\n\t\[email protected] += ' (Muted)' if vm[:mute]\n\t\[email protected]=vm[:vol]\n\t\[email protected]=5\n\tend",
"def run\n db = Hathidb::Db.new();\n conn = db.get_conn();\n \n get_volids(ARGV) do |line|\n volume_id = line.chomp\n lineout = []\n conn.query(\"SELECT oclc FROM holdings_htitem_oclc WHERE volume_id = '#{volume_id}'\") do |row|\n lineout << row[:oclc] \n end \n puts \"#{volume_id}\\t#{lineout.join(',')}\"\n end\nend",
"def volume_down_action\n VolumeDown.new(:component_id => component_id, :call_id => call_id).tap do |s|\n s.original_component = self\n end\n end",
"def vol_decr\n %x[pactl set-sink-input-volume #{self.input_id} -- -5%]\n new_vol = vol_perc - 5\n new_vol = 0 if new_vol < 0\n @args[:props][\"volume\"] = \"0: #{new_vol}% 1: #{new_vol}%\"\n return nil\n end",
"def detach_volume(server, volume)\n @logger.info(\"Detaching volume `#{volume.id}' from `#{server.id}'...\")\n volume_attachments = @openstack.with_openstack { server.volume_attachments }\n attachment = volume_attachments.find { |a| a['volumeId'] == volume.id }\n if attachment\n @openstack.with_openstack { server.detach_volume(volume.id) }\n @openstack.wait_resource(volume, :available)\n else\n @logger.info(\"Disk `#{volume.id}' is not attached to server `#{server.id}'. Skipping.\")\n end\n end",
"def fetch!\n cm = @api.api('apps/v1').resource('deployments', namespace: @ns).get(@deployment)\n volume = cm.spec.template.spec.volumes.map(&:to_h).find { |h| h[:name] == @volume }\n items = volume.dig(:configMap, :items) || []\n @_current = items.find { |item| item[:key] == @key }\n end",
"def read_device_version()\n @ramps_arduino.execute_command('F83', false, @status_debug_msg)\n end",
"def vol_status(vs, vol_id)\n vol = vs.volumes.get(vol_id)\n unless vol.status == 'available'\n # puts \"vol status is not 'available' it is '#{status}' instead\"\n @log.error 'vol is not avaiable to delete'\n exit 2\n end\n end",
"def pull(*services)\n run!('pull', *services)\n end",
"def volume_down_action\n VolumeDown.new(:component_id => component_id, :target_call_id => target_call_id).tap do |s|\n s.original_component = self\n end\n end",
"def getVolumes\n require 'rest_client'\n require 'uri'\n\n if @role.nil? and !current_actor.superadmin\n json_response({ message: \"You don't have permission to view volumes\" }, :unauthorized)\n return\n end\n\n # Env variables for Manager host and port\n serviceManagerHost = Settings.service_manager_host\n serviceManagerPort = Settings.service_manager_port.to_s\n serviceManagerURI = 'http://' + serviceManagerHost + ':' + serviceManagerPort + '/v1/volume'\n\n # Create request for Service Manager\n stack = {\n 'engine-url' => @cluster.endpoint,\n 'ca-cert' => @cluster.ca,\n 'cert' => @cluster.cert,\n 'cert-key' => @cluster.key\n }.to_json\n\n begin\n response = RestClient.post(\n serviceManagerURI,\n stack,\n 'Accept' => 'application/json',\n 'Content-Type' => 'application/json'\n )\n puts \"Deploy Response: \" + response\n json_response(response, 200)\n rescue Exception => e\n # If error, respond with it\n puts e\n json_response({message: e}, :unprocessable_entity)\n end\n end",
"def pull_from_registry\n UI.important('Pulling the :latest image from the registry')\n docker_image_name = docker_image.gsub(':latest', '')\n Actions.sh(@docker_registry_login) if @docker_registry_login\n @docker_commander.pull_image(docker_image_name: docker_image_name)\n end",
"def volume(x)\n\t\tsynchronized do\n\t\t\[email protected] \"volume #{x}\"\n\t\tend\n\tend",
"def volume\n @cr[0xe] & 0x0f\n end",
"def get_road_volume\n @volumes_east = RoadVolume.get_road_volume('East')\n @volumes_west = RoadVolume.get_road_volume('West')\n end",
"def show\n @admissive_volume = AdmissiveVolume.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @admissive_volume }\n end\n end",
"def volume\n player_iface['Volume']\n end",
"def detachvol(compute,volume)\n\t\tprint \"ebsvol[aws]->destroy: detaching #{volume['volumeId']} from #{volume['attachmentSet'][0]['instanceId']}\\n\" if $debug\n\t\tresponse = compute.detach_volume(volume['volumeId'], \n\t\t\t\t\t\t\t\t\t\t\t\t\t{ 'Device' => volume['attachmentSet'][0]['device'], \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'Force' => true, \n\t\t\t\t\t\t\t\t\t\t\t\t\t\t'InstanceId' => volume['attachmentSet'][0]['instanceId'] })\n\t\tif (response.status == 200)\n\t\t\t# now wait for it to detach!\n\t\t\tcheck = volinfo(compute,volume['tagSet']['Name'])\n\t\t\twhile ( check['status'] != 'available' ) do\n\t\t\t\tprint \"ebsvol[aws]->detachvol: status is #{check['status']}\\n\" if $debug\n\t\t\t\tsleep 5\n\t\t\t\tcheck = volinfo(compute,volume['tagSet']['Name'])\n\t\t\tend\n\t\t\tsleep 5 # allow aws to propigate the fact\n\t\t\tprint \"ebsvol[aws]->detachvol: volume is now detached\\n\" if $debug\n\t\telse\n\t\t\traise \"ebsvol[aws]->detachvol: Sorry, I could not detach #{volume['volumeId']} from #{volume['attachmentSet'][0]['instanceId']}\"\n\t\tend\n\tend",
"def prune params = {}\n @connection.post(build_path(\"/volumes/prune\", params))\n end",
"def volume_by_id(ec2,volid)\n ec2.describe_volumes.body['volumeSet'].each do |volume|\n if volume['volumeId'] == volid\n x= {\n :type => volume['volumeType'],\n :status => volume['status'],\n :az => volume['availabilityZone'],\n :size => volume['size']\n }\n #puts \"VOLINFO #{volid}\\n\"+volume.to_yaml\n x[:instance_id] = volume['attachmentSet'].first['instanceId'] if volume['attachmentSet'].length>0 && volume['attachmentSet'].first.has_key?('instanceId')\n return x\n end\n end\n return {}\nend",
"def detach_volume(volume_id, options = {})\n action = 'DetachVolume'\n params = {\n 'Action' => action,\n 'VolumeId' => volume_id\n }\n params['InstanceId'] = options[:instance_id] unless options[:instance_id].blank?\n params['Device'] = options[:device] unless options[:device].blank?\n params['Force'] = options[:force] unless options[:force].blank?\n\n response = send_query_request(params)\n response.is_a?(Net::HTTPSuccess)\n end",
"def delete_volume(volume_id)\n data = false\n conn = @ec2_main.environment.volume_connection\n if conn != nil\n if @ec2_main.settings.openstack\n response = conn.delete_volume(volume_id)\n if response.status == 202\n data = response.body\n else\n data = {}\n end\n elsif ((conn.class).to_s).start_with? \"Fog::Compute::AWS\"\n response = conn.delete_volume(volume_id)\n if response.status == 200\n data = true\n else\n data = false\n end\n else\n data = conn.delete_volume(volume_id)\n end\n else\n raise \"Connection Error\"\n end\n return data\n end",
"def set_volume(volume)\n %x{#{echo()} volume #{volume} 1 > #{fifo()}} if running?\n end",
"def index\n @actual_volumes = ActualVolume.all\n end",
"def detach_planned_volume(mapping)\n payload = {:agent_identity => @agent_identity, :device_name => mapping[:device_name]}\n Log.info(\"Detaching volume #{mapping[:volume_id]} for management purposes.\")\n req = RetryableRequest.new(\"/storage_valet/detach_volume\", payload, :retry_delay => VolumeManagement::VOLUME_RETRY_SECONDS)\n\n req.callback do |res|\n # don't set :volume_status here as that should only be queried\n mapping[:management_status] = 'detached'\n mapping[:attempts] = nil\n yield if block_given?\n end\n\n req.errback do |res|\n unless InstanceState.value == 'stranded'\n # volume could already be detaching or have been deleted\n # which we can't see because of latency; go around again\n # and check state of volume later.\n Log.error(\"Failed to detach volume #{mapping[:volume_id]} (#{res})\")\n mapping[:attempts] ||= 0\n mapping[:attempts] += 1\n # retry indefinitely so long as core api instructs us to retry or else fail after max attempts.\n if mapping[:attempts] >= VolumeManagement::MAX_VOLUME_ATTEMPTS\n strand(\"Exceeded maximum of #{VolumeManagement::MAX_VOLUME_ATTEMPTS} attempts detaching volume #{mapping[:volume_id]} with error: #{res}\")\n else\n yield if block_given?\n end\n end\n end\n\n req.run\n end",
"def find_volume(name)\n Volume.new pool.lookup_volume_by_name(name), self\n rescue Libvirt::RetrieveError\n nil\n end",
"def get_voltage\n send_request(FUNCTION_GET_VOLTAGE, [], '', 2, 'S')\n end",
"def list(opts)\n opts = check_params(opts,[:volume])\n super(opts)\n end",
"def findDevfileAndBlob\n \n # find devfile\n if @device != nil\n puts \"PATH: #{@path}\"\n puts \"FILENAME: #{@filename}\"\n puts \"DEV_NAME: #{@device.dev_name}\"\n @devfile = @device.devfiles.find(:first, :conditions => ['name = ? and path = ?', @filename, @path])\n else\n # If the device was not found\n raise \"Device was not found!\"\n# render :text => \"Device was not found!\", :status => 404\n# return\n end\n \n if @devfile == nil\n raise \"File not found\"\n# render :text => \"File not found\", :status => 404\n# return\n end\n \n # If no version was given, fetches newest one.\n if params[:version] == nil\n puts \"Fetching newest version\"\n @blob = @devfile.blobs.find(:first, :conditions => ['id = ?', @devfile.blob_id])\n else\n puts \"Fetching version: \" + params[:version]\n @blob = @devfile.blobs.find(:first, :conditions => ['version = ?', params[:version]])\n end\n \n # If given version was not found, generates and returns list of versions available.\n if @blob == nil\n s = \"\"\n @devfile.blobs.each do |b|\n s = s + \" \" + b.version.to_s + \",\"\n end\n puts \"File didn't have version: \" + params[:version] + \". File only have versions:\" + s\n raise \"File didn't have version: \" + params[:version] + \". File only have versions:\" + s\n# render :text => \"File didn't have version: \" + params[:version] + \". File only have versions:\" + s, :status => 404\n# return\n end\n\n \n end",
"def read_device_version()\n start_command('F83', false, @status_debug_msg)\n end",
"def volumes_list(options = {})\n state = options.fetch(:state, 'active')\n startid = options.fetch(:startid, 0)\n limit = options.fetch(:limit, 1000)\n accounts = options.fetch(:accountid, nil)\n name = options.fetch(:name, nil)\n \n if name\n api_call = {\n :method => \"ListVolumes\",\n :params => {\n :VolumeName => name,\n :limit => 1\n }\n }\n elsif accounts\n accounts = [ accounts ] if accounts.class == String || Integer\n api_call = {\n :method => \"ListVolumes\",\n :params => {\n :accounts => accounts,\n :limit => limit\n }\n }\n else\n api_call = {\n :method => \"ListVolumes\",\n :params => {\n :VolumeStatus => state,\n :startVolumeID => startid,\n :limit => limit\n }\n }\n end\n\n answer = query_sf(api_call)\n return answer[\"volumes\"]\n end",
"def volume_by_id(volume_id)\n ec2.describe_volumes.find{|v| v[:aws_id] == volume_id}\n end",
"def update_volumes(username, token, workset_name, volume_ids)\n\n #<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n #<volumes xmlns=\"http://registry.htrc.i3.illinois.edu/entities/workset\">\n # <volume>\n # <id>9999999</id>\n # </volume>\n # <volume>\n # <id>3333333</id>\n # </volume>\n # </volumes>\n volumes_xml =\n \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"yes\\\"?>\" +\n \"<volumes xmlns=\\\"http://registry.htrc.i3.illinois.edu/entities/workset\\\">\";\n\n for id in volume_ids\n volumes_xml += \"<volume><id>#{id}</id></volume>\"\n end\n volumes_xml += \"</volumes>\"\n\n\n # curl -v --data @new_volumes.xml -X PUT \\\n # -H \"Content-Type: application/vnd.htrc-volume+xml\" \\\n # -H \"Accept: application/vnd.htrc-volume+xml\" \\\n # http://localhost:9763/ExtensionAPI-0.1.0/services/worksets/workset1/volumes?user=fred\n\n url = URI.parse(\"#{APP_CONFIG['registry_url']}/worksets/#{workset_name}/volumes\")\n http = Net::HTTP.new(url.host, url.port)\n if Rails.env.development?\n http.set_debug_output($stdout)\n end\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n request = Net::HTTP::Put.new(url.request_uri)\n request[\"Content-Type\"] = \"application/vnd.htrc-volume+xml\"\n request.add_field(\"Authorization\", \"Bearer #{token}\")\n\n request.body = volumes_xml\n response = http.request(request)\n\n #xml = response.body\n\n case response\n when Net::HTTPUnauthorized then\n raise Exceptions::SessionExpiredError.new(\"Session expired. Please login again\")\n when Net::HTTPSuccess then\n # Do nothing\n else\n raise Exceptions::SystemError.new(\"Error retrieving worksets (HTTP #{response.code})\")\n end\n\n end",
"def read\n client[\"/vaults/#{vault_id}/blobs/#{blob_id}\"].get\n end",
"def get(key)\n @disk.get(key)\n end",
"def retrieve\n raise RetrieverError.new(\"download retriever is unavailable\") unless available?\n ::FileUtils.remove_entry_secure @repo_dir if File.exists?(@repo_dir)\n ::FileUtils.remove_entry_secure workdir if File.exists?(workdir)\n ::FileUtils.mkdir_p @repo_dir\n ::FileUtils.mkdir_p workdir\n file = ::File.join(workdir, \"package\")\n\n # TEAL FIX: we have to always-download the tarball before we can\n # determine if contents have changed, but afterward we can compare the\n # previous download against the latest downloaded and short-circuit the\n # remaining flow for the no-difference case.\n @logger.operation(:downloading) do\n credential_command = if @repository.first_credential && @repository.second_credential\n ['-u', \"#{@repository.first_credential}:#{@repository.second_credential}\"]\n else\n []\n end\n @output = ::RightScale::RightPopen::SafeOutputBuffer.new\n @cmd = [\n 'curl',\n '--silent', '--show-error', '--location', '--fail',\n '--location-trusted', '-o', file, credential_command,\n @repository.url\n ].flatten\n begin\n ::RightScale::RightPopen.popen3_sync(\n @cmd,\n :target => self,\n :pid_handler => :pid_download,\n :timeout_handler => :timeout_download,\n :size_limit_handler => :size_limit_download,\n :exit_handler => :exit_download,\n :stderr_handler => :output_download,\n :stdout_handler => :output_download,\n :inherit_io => true, # avoid killing any rails connection\n :watch_directory => workdir,\n :size_limit_bytes => @max_bytes,\n :timeout_seconds => @max_seconds)\n rescue Exception => e\n @logger.note_phase(:abort, :running_command, 'curl', e)\n raise\n end\n end\n\n note_tag(file)\n\n @logger.operation(:unpacking) do\n path = @repository.to_url.path\n if path =~ /\\.gz$/\n extraction = \"xzf\"\n elsif path =~ /\\.bz2$/\n extraction = \"xjf\"\n else\n extraction = \"xf\"\n end\n Dir.chdir(@repo_dir) do\n @output = ::RightScale::RightPopen::SafeOutputBuffer.new\n @cmd = ['tar', extraction, file]\n begin\n ::RightScale::RightPopen.popen3_sync(\n @cmd,\n :target => self,\n :pid_handler => :pid_download,\n :timeout_handler => :timeout_download,\n :size_limit_handler => :size_limit_download,\n :exit_handler => :exit_download,\n :stderr_handler => :output_download,\n :stdout_handler => :output_download,\n :inherit_io => true, # avoid killing any rails connection\n :watch_directory => @repo_dir,\n :size_limit_bytes => @max_bytes,\n :timeout_seconds => @max_seconds)\n rescue Exception => e\n @logger.note_phase(:abort, :running_command, @cmd.first, e)\n raise\n end\n end\n end\n true\n end",
"def pull_state\n if @physical_object\n @status = 200\n @ds = @physical_object.digital_statuses.order(\"updated_at DESC\").last\n unless @ds.nil?\n @success = true\n @message = @ds.decided\n else\n @success = false\n @message = \"Physical object #{@physical_object.mdpi_barcode} has 0 Digital Statuses...\"\n end\n end\n render template: 'responses/pull_state.xml.builder', layout: false, status: @status\n end"
] | [
"0.64978135",
"0.63532764",
"0.63464457",
"0.6197382",
"0.61853695",
"0.61475164",
"0.606009",
"0.603484",
"0.5953611",
"0.573497",
"0.570758",
"0.5685409",
"0.56713295",
"0.5666276",
"0.5658976",
"0.56523544",
"0.560495",
"0.5597921",
"0.55848",
"0.5581547",
"0.556794",
"0.5544007",
"0.5520823",
"0.54737145",
"0.54651415",
"0.54399246",
"0.54365313",
"0.54365313",
"0.5400507",
"0.53995895",
"0.53926325",
"0.53687376",
"0.53517246",
"0.53468204",
"0.53366673",
"0.5321093",
"0.5310036",
"0.529781",
"0.5280494",
"0.52785367",
"0.52649575",
"0.52637595",
"0.5261467",
"0.5261467",
"0.52498674",
"0.52349466",
"0.5229561",
"0.5214616",
"0.5210278",
"0.5200405",
"0.51966494",
"0.51954275",
"0.5181255",
"0.51770395",
"0.5176634",
"0.5173232",
"0.5166961",
"0.51557845",
"0.51539284",
"0.5147796",
"0.51439345",
"0.51425445",
"0.5138952",
"0.51219666",
"0.5119453",
"0.51194507",
"0.5112708",
"0.5102419",
"0.51016015",
"0.50958025",
"0.50956905",
"0.5094093",
"0.5092986",
"0.5084939",
"0.50836813",
"0.50745034",
"0.505718",
"0.5054228",
"0.5046625",
"0.5037988",
"0.5026368",
"0.5013942",
"0.50065756",
"0.50063425",
"0.5001216",
"0.49956784",
"0.49940053",
"0.49936396",
"0.49886897",
"0.49877328",
"0.49814823",
"0.4974421",
"0.4973391",
"0.49677894",
"0.49676955",
"0.49494943",
"0.49447745",
"0.49426445",
"0.49344054",
"0.49221954"
] | 0.77412784 | 0 |
Allows you to attach a listener that accepts the created job (which has a useful job_id field). This is useful for recording a job ID persistently before you begin batch work (i.e. start modifying the salesforce database), so if the load process you are writing needs to recover, it can be aware of previous jobs it started and wait for them to finish. | def on_job_created(&block)
@listeners[:job_created] << block
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start\n interface.add_new_job_listener(self)\n end",
"def start\n interface.add_new_job_listener(self)\n end",
"def record_job(job_json)\n job = JSON.parse(job_json)\n processing_jobs.create!(\n :account_id => account_id,\n :cloud_crowd_id => job['id'],\n :title => title,\n :remote_job => job\n )\n end",
"def create(id, job)\n connection.post do |req|\n req.url \"job/#{id}\"\n req.body = job\n end\n end",
"def add_listener(identification, listener)\n listeners[identification] = listener\n end",
"def add_job(job)\n @stream.add_message(job.to_message)\n job\n end",
"def start_job\n associate(Wesabe::Job.from_xml(Hpricot::XML(post(:url => \"/credentials/#{id}/jobs.xml\")) / :job))\n end",
"def delegate(job)\n job = job.stringify_keys\n job['id'] = generate_job_id(job) unless job_failed?(job)\n @jobs[job['id']] = job\n job['env_options'][CapistranoMulticonfigParallel::ENV_KEY_JOB_ID] = job['id']\n # debug(@jobs)\n # start work and send it to the background\n @workers.async.work(job, Actor.current)\n end",
"def register_worker_for_job(job, worker)\n job = job.stringify_keys\n if job['id'].blank?\n debug(\"job id not found. delegating again the job #{job.inspect}\") if self.class.debug_enabled?\n delegate(job)\n else\n start_worker(job, worker)\n end\n end",
"def attach listener\n @listeners.push listener\n end",
"def add_listener(listener)\n @listeners << listener.new(@custom_run_name)\n end",
"def enqueue(job_id)\n create_job_record(job_id)\n BEANSTALK_QUEUE.yput(:job_id => job_id)\n @last_queried[job_id] = Time.now\n end",
"def enqueue_job(job, event)\n delayed_job = job.queue\n\n logger.info \"Queued #{event.event_description} as job #{delayed_job.id}\"\n\n {\n 'status' => 'ok',\n 'job_id' => delayed_job.id,\n 'queue' => delayed_job.queue,\n 'priority' => delayed_job.priority,\n 'created_at' => delayed_job.created_at,\n }\n end",
"def create\n @job_manager = JobManager.new(job_manager_params)\n @job_manager.job_id = @job.id\n\n respond_to do |format|\n if @job_manager.job_manager_id && @job_manager.save\n @job.pipeline_status_id = 2\n @job.save\n @user = @job_manager.job_manager\n @job.track 'Manager Assigned', current_user, @job_manager\n if @user.email\n UserMailer.manager_assignment(@user, @job_manager).deliver_later\n end\n format.html { redirect_to job_job_managers_path(@job), notice: 'Job manager was successfully created.' }\n format.json { render :show, status: :created, location: @job_manager }\n else\n format.html { render :new }\n format.json { render json: @job_manager.errors, status: :unprocessable_entity }\n end\n end\n end",
"def enqueue_job!(job, wait_until)\n job.run_callbacks :enqueue do\n job.enqueue!\n job.save! do\n Burstflow::Worker.set(wait_until: wait_until).perform_later(workflow.id, job.id)\n end\n end\n end",
"def create_job_record(job_id)\n if @dbh[:progress_bars].filter(:id => job_id).first\n @dbh[:progress_bars].filter(:id => job_id).\n update(:progress_text => 'queued...', \n :progress_percent => 0,\n :job_start => Time.now,\n :last_updated => Time.now,\n :job_finish => nil)\n else\n @dbh[:progress_bars].\n insert(:id => job_id, \n :progress_text => 'queued...', \n :job_start => Time.now, \n :last_updated => Time.now)\n end\n end",
"def new_job\n j = self.class.new\n j.save\n end",
"def create\n @job = Job.new(job_params)\n\n respond_to do |format|\n if @job.save\n JobsWorker.perform_async(@job.id, @job.server.id)\n flash[:success] = 'Job was successfully created.'\n format.html { redirect_to jobs_path }\n format.json { render :show, status: :created, location: @job }\n else\n flash[:error] = 'Please fill all fields correctly !!'\n format.html { redirect_to root_url }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def enqueue_job\n BgJob.enqueue(\n WebhookJob::RecordEvent,\n {\n client_id: @user_kyc_detail.client_id,\n event_source: GlobalConstant::Event.web_source,\n event_name: GlobalConstant::Event.update_ethereum_address_name,\n event_data: {\n user_kyc_detail: @user_kyc_detail.get_hash,\n admin: @admin.get_hash\n },\n event_timestamp: Time.now.to_i\n }\n )\n\n end",
"def create_listener\n return unless self.controller_name == \"registrations\"\n @listener = Listener.new\n @listener.save\n end",
"def monitor_job(job_id, start: true)\n job_state, placeholder_task, job_task = client.find_job_info_by_id(job_id)\n job = JobMonitor.new(self, job_id, state: job_state, placeholder_task: placeholder_task, task: job_task)\n if start\n job.start\n end\n job\n end",
"def create\n @job = Job.new(params[:job].reject{|key, value| key == 'jobs_queue_id'})\n @job.user = current_user\n\n respond_to do |format|\n if @job.save\n if @job.r_script.tags.collect{|tag| tag.name}.include?('install script')\n @job.pending \n elsif queue = JobsQueue.find_by_id(params[:job][:jobs_queue_id].to_i) \n @job.submit(queue) \n end\n create_log_entry(@job.r_script, @job, 'use')\n flash[:notice] = 'Job was successfully created.'\n format.html { redirect_to(jobs_url) }\n format.xml { render :xml => @job.to_xml(:include => { :job_parameters => { :include => :data_set } }), :status => :created, :location => @job }\n else\n @job.jobs_queue_id = params[:job][:jobs_queue_id]\n format.html { render :action => \"new\" }\n format.xml { render :xml => @job.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def add_job(job_def)\n\t\t\tjob = JobBuilder.new(self).build(job_def)\n\t\t\traise \"Error : job with name #{job.name} already exists\" if @jobs.has_key?(job.name)\n\t\t\t@jobs[job.name] = job\n\t\tend",
"def create\n job = Job.new\n job.job_name = params[:job_name]\n job.description = params[:description]\n job.quote = params[:quote].to_f\n job.running_total = 0\n \n if job.save\n jobConnect = JobToUser.new\n jobConnect.job_id = job.id\n jobConnect.user_id = current_user.id\n jobConnect.save\n redirect_to(\"/services/show\", :notice => 'Job was successfully created.')\n else\n redirect_to(\"/services/show\", :notice => 'Job Failed to Save. Try Again Later.')\n end\n end",
"def create_job_id\n application_job_overrides_method!(__method__)\n\n # default implementation for framework jobs\n Generators.generate_uuid(self)\n end",
"def add_listener(listener)\n @listeners.add(@listeners)\n end",
"def << job_data\n add_job(job_data)\n end",
"def add_job(item)\n @jobs[last_job_number] = item\n end",
"def addJob( job )\n\t\t\t\tThread.exclusive {\n\t\t\t\t\t@jobs << job\n\t\t\t\t\twake()\n\t\t\t\t}\n\t\t\tend",
"def on_new_resource(resource)\n debug \"Created: #{resource}\"\n OMF::JobService.scheduler.on_new_job(resource)\n end",
"def add_listener(listener)\n @listeners << listener\n end",
"def job(id)\n Job.new(id, self)\n end",
"def worker_listener\n @worker_listener ||= ManageIQ::Messaging::Client.open(worker_listener_opts)\n end",
"def add_job_with_callback(image_source, function_name, function_params, image_identifier, postback_url, application_id = nil)\n job = Blitline::Job.new(image_source)\n environment_app_id = ENV['BLITLINE_URL'] && ENV['BLITLINE_URL'].split(\"/\").last\n job.application_id = environment_app_id || application_id\n job.add_function(function_name, function_params, image_identifier)\n job.postback_url = postback_url\n @jobs << job\n end",
"def add_job_with_callback(image_source, function_name, function_params, image_identifier, postback_url, application_id = nil)\n job = Blitline::Job.new(image_source)\n environment_app_id = ENV['BLITLINE_URL'] && ENV['BLITLINE_URL'].split(\"/\").last\n job.application_id = environment_app_id || application_id\n job.add_function(function_name, function_params, image_identifier)\n job.postback_url = postback_url\n @jobs << job\n end",
"def create_batch_job(job_id)\n request = Net::HTTP::Put.new(\"/jobs/#{job_id}\")\n response = http.request(request)\n handle_response({ request_method: request.method, request_path: request.path }, response)\n end",
"def new\n job_name = params[:id]\n\n if @valid_jobs.include? job_name \n if queue_job(job_name)\n flash[:notice] = \"Created job: #{job_name}\"\n else\n flash[:alert] = \"Job #{job_name} is already running.\"\n end\n else\n flash[:alert] = \"Invalid job type.\"\n end\n \n #@counter = Delayed::Job.enqueue Paranoid.new\n redirect_to jobs_path\n end",
"def create\n @job = current_user.jobs.new(job_params)\n respond_to do |format|\n if @job.save\n \ttrack_activity @job\n format.html { redirect_to @job, notice: 'Job was successfully created.' }\n format.json { render :show, status: :created, location: @job }\n else\n format.html { render :new }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @job = @user.jobs.new(params[:job])\n\n respond_to do |format|\n if @job.save\n\t\t# send mail now or later...\n\t\tBackground.instance.delay.sendLater(@job)\n\t \n format.html { redirect_to(@job, :notice => 'Job was successfully created.') }\n format.xml { render :xml => @job, :status => :created, :location => @job }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @job.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n arg = params[:email]\n counter = Job.enqueue(arg)\n render :status => :accepted, :json => { jobId: counter }\n end",
"def handle_job_created(hostport, data)\n Util.log \"Got job_created with handle #{data} from #{hostport}\"\n if not @task_waiting_for_handle\n raise ProtocolError, \"Got unexpected job_created notification \" +\n \"with handle #{data} from #{hostport}\"\n end\n js_handle = Util.handle_to_str(hostport, data)\n task = @task_waiting_for_handle\n @task_waiting_for_handle = nil\n (@tasks_in_progress[js_handle] ||= []) << task\n nil\n end",
"def add_listener(type, params={}, &block)\n raise ArgumentError, 'listener block not given' unless block_given?\n id = __events.empty? ? 0 : __events.last[:id]+1\n __events << {\n :type => type.to_sym,\n :listener => block,\n :params => params,\n :id => id\n }\n id\n end",
"def create\n if current_user.saved_jobs.where(job_id: params[:saved_job][:job_id]).count > 0\n respond_to do |format|\n format.html { redirect_to worker_all_jobs_path, notice: t('saved_jobs_controller.saved_jobs_create_error') }\n end\n else\n @saved_job = current_user.saved_jobs.new(saved_job_params)\n\n respond_to do |format|\n if @saved_job.save\n format.html { redirect_to worker_all_jobs_path, notice: t('saved_jobs_controller.saved_jobs_create_success') }\n format.json { render :show, status: :created, location: @saved_job }\n\n else\n format.html { render :new }\n format.json { render json: @saved_job.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def create\n @job = Vger::Resources::Job.new(params[:job])\n\n respond_to do |format|\n if @job.save\n format.html { redirect_to company_job(:company_id => params[:company_id], :id => @job.id), notice: 'Job was successfully created.' }\n else\n format.html { render action: \"new\" }\n end\n end\n end",
"def send_job(job)\n begin\n response = RestClient::Request.execute(\n method: :post,\n url: build_jobs_url,\n payload: job.to_codem_json,\n timeout: EBU::NETWORK_TIMEOUT,\n open_timeout: EBU::NETWORK_TIMEOUT\n )\n if response.code == 202\n if (obj = JSON.parse(response.to_str))\n obj[\"job_id\"]\n else\n raise \"Job #{job.id} was created on transcoder #{self.id}, but no job ID was returned.\"\n end\n else\n nil\n end\n rescue Timeout::Error => e\n nil\n rescue => e\n nil\n end\n end",
"def record_event_job\n WebhookJob::RecordEvent.perform_now({\n client_id: @user_kyc_detail.client_id,\n event_source: GlobalConstant::Event.web_source,\n event_name: GlobalConstant::Event.kyc_reopen_name,\n event_data: {\n user_kyc_detail: @user_kyc_detail.get_hash,\n admin: @user_kyc_detail.get_last_acted_admin_hash\n },\n event_timestamp: Time.now.to_i\n })\n\n end",
"def add(job)\n if @workers.empty?\n @work_queue.insert(0, job)\n else\n worker = @workers.pop()\n ask_worker(worker, job)\n end\n end",
"def create\n @job = Job.new(job_params)\n respond_to do |format|\n if @job.save_series\n record_activity :create, @job\n format.html { redirect_to @job, notice: 'Job was successfully created.' }\n format.json { render :show, status: :created, location: @job }\n else\n @job_type = JobType.find_by(id: @job.job_type_id)\n format.html { render :new }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @job = @employer.jobs.build(job_params)\n respond_to do |format|\n if @job.save\n format.html { redirect_to edit_employer_path(@employer,anchor: \"jobs_tab\"), notice: 'Job was successfully created.' }\n format.json { render :show, status: :created, location: @job }\n else\n format.html { render :new }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n ensure_authenticated!\n\n job = Grid5000::Job.new(job_params)\n Rails.logger.info \"Received job = #{job.inspect}\"\n raise BadRequest, \"The job you are trying to submit is not valid: #{job.errors.join('; ')}\" unless job.valid?\n\n job_to_send = job.to_hash(destination: 'oar-2.4-submission')\n Rails.logger.info \"Submitting #{job_to_send.inspect}\"\n\n result = @oarapi.create_job(job_to_send)\n\n job_uid = JSON.parse(result)['id']\n location_uri = uri_to(\n resource_path(job_uid),\n :in, :absolute\n )\n\n job = OAR::Job.expanded.includes(:job_types, :job_events, :gantt).find(job_uid)\n job.links = links_for_item(job)\n\n render_opts = {\n methods: %i[resources_by_type assigned_nodes],\n location: location_uri,\n status: 201\n }\n render_result(job, render_opts)\n end",
"def Job(active_job)\n lambda do |object|\n active_job.perform_later(object.id)\n end\n end",
"def create_job(options = {})\n Job.create({:title => \"Another Dummy Job\", :description => \"This is just another dummy job\"}.merge(options))\n end",
"def enqueue_job\n BackgroundJob.enqueue(\n InviteJob,\n {\n manager_id: @invitee_manager[:id],\n invite_token: @invite_token\n }\n )\n\n success\n end",
"def enqueue\n # We need to save before passing to perform_later b/c perform_later will need our ID.\n # For this reason, the job_id col can't have a null constraint.\n save! unless persisted?\n job = job_class.constantize.perform_later(self, **job_params)\n update!(job_id: job.job_id, provider_job_id: job.provider_job_id)\n end",
"def create\n job = Job.find(params[:job_id])\n @saved_job = SavedJob.create(:job_id => params[:job_id], :user_id => current_user().id)\n\n respond_to do |format|\n if @saved_job.save\n format.html { redirect_to @saved_job, :notice => 'Saved job was successfully created.' }\n format.js\n format.json { render :json => @saved_job, :status => :created, :location => @saved_job }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @saved_job.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_job(json_payload)\n conn = @client.post do |req|\n req.url '/api/v2/job/create'\n req.headers[\"Authorization\"] = @token\n req.body = json_payload\n end\n conn.body\n end",
"def enqueue_job\n BgJob.enqueue(\n NewUserRegisterJob,\n {\n client_id: @client_id,\n user_id: @user.id,\n geoip_country: nil,\n event: {\n client_id: @user.client_id,\n event_source: GlobalConstant::Event.api_source,\n event_name: GlobalConstant::Event.user_register_name,\n event_data: {\n user: @user.get_hash\n },\n event_timestamp: Time.now.to_i\n }\n }\n )\n end",
"def listen\n Thread.new { EventMachine.run } unless EventMachine.reactor_running?\n jack.each_job(2) do |job|\n job = Job.new(job.conn, job.jobid, job.body)\n EventMachine.defer proc { process(job) }, proc {|res| raise(res) if res.kind_of?(Exception) }\n end\n end",
"def collections_user_added_to_job(user, job)\n @user = user\n @job = job\n\n mail(to: @user.email, subject: \"#{@user.full_name}, you have been added as a subscriber to #{@job.name}.\")\n end",
"def create\n flash[:notice] = 'Job Created' if @job_category.jobs.create params[:job]\n respond_with @job.job_category, @job\n end",
"def job_id\n @gapi.job_reference.job_id\n end",
"def create_for_job(job, batch)\n jr = JobRun.new(self)\n jr.created_at = Time.now\n jr.job_id = job.id\n jr.status = :new\n jr.batch = batch.to_json\n insert_sql = \"INSERT INTO #{@schema_name}.job_runs(created_at, updated_at, job_id, batch, status) VALUES ('#{Time.now}','#{Time.at(0)}', '#{job.id}', '#{batch.to_json}', 'new') RETURNING id\";\n r = exec_sql(insert_sql).values\n if r.length == 0\n return nil\n end\n jr.id = r.first[0].to_i\n jr\n end",
"def create\n\t\t@job = Job.new(params[:job])\n\n\t\trespond_to do |format|\n\t\t\tif @job.save\n\t\t\t\tformat.html { redirect_to @job, notice: 'Job was successfully created.' }\n\t\t\t\tformat.json { render json: @job, status: :created, location: @job }\n\t\t\telse\n\t\t\t\tformat.html { render action: \"new\" }\n\t\t\t\tformat.json { render json: @job.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def create\n @myjob = Myjob.new(myjob_params)\n\n respond_to do |format|\n if @myjob.save\n format.html { redirect_to @myjob, notice: 'Myjob was successfully created.' }\n format.json { render :show, status: :created, location: @myjob }\n else\n format.html { render :new }\n format.json { render json: @myjob.errors, status: :unprocessable_entity }\n end\n end\n end",
"def started(build, listener)\n end",
"def new_job(what, overrides)\n @pipeline << Job.new(what, overrides)\n yield\n @pipeline.pop\n end",
"def create\n @job = Job.new(params[:job])\n @job.company_id = current_company.id\n\n if @job.save\n response_message = {:message => \"Job created successfully.\", :job => @job}\n else\n response_message = {:message => \"Job creation failed. Please try again!\"}\n end\n\n respond_to do |format|\n format.xml { render :xml => response_message}\n format.json { render :json => response_message }\n end\n end",
"def initialize(job_id = nil, status = 'pending', scheduled_at = Time.now)\n if job_id\n @worker_record = WorkerJob.find_by(job_id: job_id)\n @errors = []\n else\n init_vars(status, scheduled_at)\n @worker_record = WorkerJob.create(status: @status, scheduled_at: @scheduled_at, class_name: @class_name, job_id: @job_id)\n end\n end",
"def create\n @job = Job.new(params[:job])\n\n respond_to do |format|\n if @job.save\n # after @job.save, initially the job is in a \"pending\" state.\n @job.initialize_job_parameters \n @job.nextstep! # pending - > launch_pending\n logger.debug( 'initiating background cluster launch...' ) \n # job state is now \"launching_instances\"... \n Delayed::Job.enqueue ClusterLaunchJob.new(@job) \n flash[:notice] = 'Job was successfully submitted.' \n\n format.html { redirect_to(jobs_url) }\n format.xml { render :xml => @job, :status => :created, :location => @job }\n format.json { render :json => @job, :status => :created, :location => @job } \n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @job.errors, :status => :unprocessable_entity }\n format.json { render :json => @job.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def job=(job)\n @job = job\n end",
"def create\n @launched_job = LaunchedJob.new(launched_job_params)\n\n respond_to do |format|\n if @launched_job.save\n format.html { redirect_to @launched_job, notice: 'Launched job was successfully created.' }\n format.json { render json: @launched_job, status: :created }\n else\n format.html { render action: 'new' }\n format.json { render json: @launched_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def listener; end",
"def create\n @job = Job.new(params[:job])\n @job.status = 'listed'\n\n respond_to do |format|\n if @job.save\n format.html { redirect_to @job, notice: 'Job was successfully created.' }\n format.json { render json: @job, status: :created, location: @job }\n else\n format.html { render action: \"new\" }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_launched_job\n @launched_job = LaunchedJob.find(params[:id])\n end",
"def set_background_job_ref(job)\n return unless respond_to?(:background_job_ref=)\n\n job = \"#{job.provider_job.class.name.ns_underscore}%#{job.provider_job.id}\" if job.respond_to?(:provider_job)\n self.background_job_ref = job\n end",
"def create\n @job = Job.new(job_params)\n @job.poster_id = current_user.id\n respond_to do |format|\n if @job.save\n\tformat.html { \n\t if session[:batch_job] == true\n\t redirect_to batch_job_path\n\t else\n\t redirect_to job_build_path(job_id: @job.id, id: :job_scope)\n\t end }\n format.json { render :show, status: :created, location: @job }\n else\n format.html { render :new }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def job_id=(value)\n @job_id = value.to_s\n end",
"def create\n attrs = to_hash_without_nils\n .except(:job)\n .merge({ job_id: job.id })\n copy self.class.create(attrs)\n true\n end",
"def register_listener(queue_name, listener = nil, &block)\n array_dispatcher = (listeners[queue_name] ||= ArrayMessageDispatcher.new)\n array_dispatcher.add_dispatcher MessageDispatcher.new(block.nil? ? listener : block)\n queue_manager.listen(queue_name)\n end",
"def save\n # if job is invalid return false\n return false unless valid?\n\n # update next_enqueue_timestamp\n @next_enqueue_timestamp = calculate_next_enqueue_time(Time.now.utc).to_i\n\n Sidekiq.redis do |conn|\n # add to set of all jobs\n conn.sadd(self.class.jobs_key, redis_key)\n\n # add informations for this job!\n conn.hmset(redis_key, *hash_to_redis(to_hash))\n end\n\n logger.info { \"CRON JOB: add job with name: #{@name}\" }\n end",
"def create\n @pending_job = PendingJob.new(pending_job_params)\n current_stage = 'E'\n @pending_job.time_queued = Time.now\n @pending_job.current_stage = current_stage\n @pending_job.current_stage_started = Time.now\n\n respond_to do |format|\n if @pending_job.save\n EFinishJob.perform_in(1.minutes, @pending_job.id, @pending_job.course, @pending_job.assignment, @pending_job.username)\n format.html { redirect_to @pending_job, notice: 'Pending job was successfully created.' }\n format.json { render :show, status: :created, location: @pending_job }\n else\n format.html { render :new }\n format.json { render json: @pending_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def subscribed\n id = params.fetch(:id)\n return unless execution = JobQueue.find_by_id(id)\n\n execution.viewers.push current_user\n\n Thread.new do\n ActiveRecord::Base.connection_pool.with_connection do\n builder = EventBuilder.new(execution.job)\n execution.output.each do |event, data|\n transmit event: event, data: builder.payload(event, data)\n end\n # TODO: disconnect all listeners so they close their sockets ?\n # then replace the reloaded/finished/waitUntilEnabled stuff with that\n end\n end\n end",
"def on_event(&listener)\n @lock.lock\n @event_listeners += [listener]\n ensure\n @lock.unlock\n end",
"def set_job\n @job = Job.find(params[:id])\n end",
"def create\n @listener = Listener.new(params[:listener])\n\n respond_to do |format|\n if @listener.save\n flash[:notice] = 'Listener was successfully created.'\n format.html { redirect_to(@listener) }\n format.xml { render :xml => @listener, :status => :created, :location => @listener }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @listener.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_create_jobs\n @create_job = CreateJob.find(params[:id])\n end",
"def queue(job_id)\n redis do |conn|\n conn.lpush(key.queued, job_id)\n end\n end",
"def create\n @applied_job = AppliedJob.new(job_id: params[:job_id], user_id: current_user.id)\n\n respond_to do |format|\n if @applied_job.save\n format.html { redirect_to applied_jobs_path, notice: 'Applied job was successfully created.' }\n format.json { render :show, status: :created, location: @applied_job }\n else\n format.html { render :new }\n format.json { render json: @applied_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n job = Job.create(job_params)\n render json: job\n end",
"def set_saved_job\n @saved_job = SavedJob.find(params[:id])\n end",
"def add_listener(obj)\n @listeners << obj\n obj.class.extend Anise::Annotation # give it the ability to sync\n obj.respond :added, self\n end",
"def subscribe(listener)\n listeners.add(listener)\n end",
"def create_job(lead, account)\n Job.create({\n company_id: lead.company_id,\n trade_id: lead.trade_id,\n name: lead.job_name,\n description: lead.job_description,\n lead_id: lead.id,\n address_id: lead.address_id,\n account_id: account.id\n })\n end",
"def create\n @db_job = DbJob.new(db_job_params)\n\n respond_to do |format|\n if @db_job.save\n format.html { redirect_to @db_job, notice: 'Db job was successfully created.' }\n format.json { render :show, status: :created, location: @db_job }\n else\n format.html { render :new }\n format.json { render json: @db_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @job = Job.new(job_params)\n\n respond_to do |format|\n if @job.save\n format.html { redirect_to @job, notice: 'Job was successfully created.' }\n format.json { render :show, status: :created, location: @job }\n else\n format.html { render :new }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @job = Job.new(job_params)\n\n respond_to do |format|\n if @job.save\n format.html { redirect_to @job, notice: 'Job was successfully created.' }\n format.json { render :show, status: :created, location: @job }\n else\n format.html { render :new }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @job = Job.new(job_params)\n\n respond_to do |format|\n if @job.save\n format.html { redirect_to @job, notice: 'Job was successfully created.' }\n format.json { render :show, status: :created, location: @job }\n else\n format.html { render :new }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @job = Job.new(params[:job])\n\n respond_to do |format|\n if @job.save\n flash[:notice] = 'Job was successfully created.'\n format.html { redirect_to verify_job_url(@job) }\n format.xml { render :xml => @job, :status => :created, :location => @job }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @job.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @job = Job.new(job_params)\n\n respond_to do |format|\n if @job.save\n format.html { redirect_to mentor_job_path(@job), notice: 'Job was successfully created.' }\n format.json { render action: 'show', status: :created, location: @job }\n else\n format.html { render action: 'new' }\n format.json { render json: @job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def job=(job)\n @job = job\n end"
] | [
"0.6758493",
"0.6758493",
"0.6204391",
"0.61469245",
"0.595604",
"0.59354687",
"0.58921534",
"0.5882724",
"0.5857593",
"0.5817491",
"0.5764012",
"0.5762483",
"0.56788224",
"0.56343603",
"0.56140906",
"0.55958074",
"0.558978",
"0.5584405",
"0.55800825",
"0.55635726",
"0.55531204",
"0.55517244",
"0.55192584",
"0.55173",
"0.54948837",
"0.54839104",
"0.54819906",
"0.5466779",
"0.54620755",
"0.5447027",
"0.5446813",
"0.5429131",
"0.5423749",
"0.5393439",
"0.5393439",
"0.5387775",
"0.5375071",
"0.5372058",
"0.53538877",
"0.53464866",
"0.53394073",
"0.53336024",
"0.53307724",
"0.53100663",
"0.53015333",
"0.52958274",
"0.52936983",
"0.528731",
"0.5286656",
"0.52751356",
"0.52733535",
"0.52729666",
"0.5270709",
"0.5269906",
"0.52586764",
"0.52485436",
"0.524821",
"0.5238055",
"0.5237776",
"0.52321094",
"0.5211778",
"0.5200779",
"0.51944625",
"0.51873523",
"0.51737803",
"0.5173371",
"0.5165041",
"0.51600856",
"0.5145356",
"0.5144862",
"0.5142359",
"0.5138339",
"0.5132501",
"0.5132093",
"0.51288444",
"0.51285595",
"0.51246613",
"0.51215893",
"0.51195836",
"0.51163465",
"0.5112735",
"0.5104395",
"0.50988775",
"0.50967294",
"0.5095754",
"0.50920004",
"0.50875026",
"0.5085589",
"0.5082476",
"0.50769514",
"0.50738496",
"0.50736517",
"0.5071576",
"0.5063832",
"0.5052325",
"0.5052325",
"0.5052325",
"0.50462",
"0.5045481",
"0.50448817"
] | 0.73519635 | 0 |
We're really an array. We swear! | def method_missing(m, *args, &block)
self.to_a.send m, *args, &block
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def array?\n false\n end",
"def array?(item)\n item.is_a?(Array)\n end",
"def __array__; self; end",
"def array?\n false\n end",
"def returns_array?\n true\n end",
"def array?\n value&.is_a?(Array)\n end",
"def returns_array?\n true\n end",
"def array\n raise \"Not implemented\"\n end",
"def returns_array?\n false\n end",
"def returns_array?\n false\n end",
"def array_type?\n type = self.sexp_type\n @@array_types.include? type\n end",
"def array?\n GtaScm::Types::ARRAY_TYPES.include?(self.arg_type_id)\n end",
"def returns_array?\n false\n end",
"def array\n @array\n end",
"def Array(p0) end",
"def test_array\n x = [1, \"two\", 3.0]\n assert_equal x, Marshal.load(Marshal.dump(x))\n end",
"def array()\n\t\t@array\n\tend",
"def converted_arrays; end",
"def healthy?() raw && raw.is_a?(Array) end",
"def visit_array(h); end",
"def array\n @@array\n end",
"def can_convert?\n array.is_a?(Array)\n end",
"def test2(array)\n\tputs \"Test2: Should return an array -> \"\n\tabg_maker(array).class == Array ? true : false\nend",
"def can_deconvert?\n array.is_a?(Array)\n end",
"def test3(array)\n\tputs \"Test3: Should return an array of arrays -> \"\n\tabg_maker(array).any? {|x| x.class != Array} ? false : true\nend",
"def maybe_array(x)\n x.is_a?(Array) ? x : [x]\n end",
"def array_method(input)\n\treturn \"thanks for the sweet array!\"\nend",
"def is_array_type?(type)\n return type =~ /^\\w+\\[\\w+\\]$/ ? true : false\n end",
"def expect_array(value, field, subfield)\n return true if value.blank?\n return true if value.is_a?(Array)\n errors.add(field, \"#{subfield} must be an array\")\n false\n end",
"def array_like?(obj)\n obj.respond_to?(:to_ary)\n end",
"def arrayify(a)\n ( a && a.respond_to?(:to_a) ) ? a.to_a : nil\n end",
"def arrayed(object) # :doc:\n (object.is_a?(Array) ? object : [object])\n end",
"def test1(array)\n\tputs \"Test1: Should take an array as argument -> \"\n\tarray.class == Array ? true : false\nend",
"def test1(array)\n\tputs \"Test1: Should take an array as argument -> \"\n\tarray.class == Array ? true : false\nend",
"def get_items\r\n @arr.to_a\r\n end",
"def array(arg)\n if arg\n arg = arg.chomp.rstrip.lstrip\n name = arg.scan(/\\s*(\\w*)\\[\\d*\\]?/).first.first\n \n # following 10 lines seem to be unnecessary\n # and are left over from early array work\n # but they are still here for a bit\n # determine if there is an array assignement, and how many\n # then eliminate the assignment and update the array size\n # if /\\w*\\[\\d*\\]\\s*\\=\\s*\\{(.*)\\}/ =~ arg\n # assignment = arg.scan(/\\w*\\[\\d*\\]\\s*\\=\\s*\\{(.*)\\}/).first.first\n # array_size = assignment.split(\",\").length\n # if /\\[(\\s*)\\]/ =~ arg\n # arg.gsub!(/(\\[\\d*\\])/, \"[#{array_size}]\")\n # end\n # end\n # arg = arg.scan(/^((\\s*|\\w*)*\\s*\\w*\\[\\d*\\])?/).first.first\n\n # help rad_processor do a better job with array types\n types = [\"int\", \"long\", \"char*\", \"unsigned int\", \"unsigned long\", \"byte\", \"bool\", \"float\" ]\n types.each_with_index do |type, i|\n @type = types[i] if /#{type}/ =~ arg\n end\n raise ArgumentError, \"type not currently supported.. got: #{arg}. Currently supporting #{types.join(\", \")}\" unless @type\n\n arg = \"#{arg};\" unless arg[-1,1] == \";\"\n $array_types[name] = @type\n @type = nil\n $external_var_identifiers << name unless $external_var_identifiers.include?(name)\n # add array_name declaration\n $external_array_vars << arg unless $external_array_vars.include?(arg)\n end\n end",
"def to_a; [Array]; end",
"def boolean_nested_array(array)\n array.each do |slot|\n return true if slot.kind_of?(Array)\n end\n return false\nend",
"def isArray _args\n \"isArray _args;\" \n end",
"def array_term?(data, term)\n data.first&.send(:[], term)&.is_a?(Array)\n end",
"def double_array(array)\n # your code here\nend",
"def is_array?(array)\n !array.kind_of?(Array) ? (raise Error, Constants::ERRORS[:invalid_array]) : false\n end",
"def k_array!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 60 )\n\n\n\n type = K_ARRAY\n channel = ANTLR3::DEFAULT_CHANNEL\n # - - - - label initialization - - - -\n\n\n # - - - - main rule block - - - -\n # at line 493:3: 'array'\n match( \"array\" )\n\n\n\n @state.type = type\n @state.channel = channel\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 60 )\n\n\n end",
"def check_array(object)\n raise Algolia::AlgoliaError, 'argument must be an array of objects' unless object.is_a?(Array)\n end",
"def cast_array\n <<-CODE\n t1 = stack_pop();\n if(REFERENCE_P(t1) && object_kind_of_p(state, t1, global->tuple)) {\n t1 = array_from_tuple(state, t1);\n } else if(!REFERENCE_P(t1) || !object_kind_of_p(state, t1, global->array)) {\n t2 = array_new(state, 1);\n array_set(state, t2, 0, t1);\n t1 = t2;\n }\n stack_push(t1);\n CODE\n end",
"def array(value)\n value.respond_to?(:to_ary) ? value : [value]\n end",
"def coerce_array(array, non_empty)\n unless array.kind_of?(Array)\n coercion_error!\n end\n if non_empty and array.empty?\n coercion_error!\n end\n array\n end",
"def to_a\n @arr\n end",
"def __init_check_row(arow)\n if arow._isArray\n return arow\n end\n if arow._kind_of?( Vector )\n return arow.__elements\n end\n Maglev::Type.coerce_to( arow, Array, :to_ary )\n end",
"def isArrayType(obj)\n return((obj.kind_of? FFI::Struct::InlineArray) or (obj.kind_of? ::Array))\n end",
"def array_nl()\n #This is a stub, used for indexing\n end",
"def to_a; Array(force) end",
"def chk_array(array)\n array.each_index do |i|\n array[i] = hash2os(array[i]) if array[i].is_a?(Hash)\n chk_array(array[i]) if array[i].is_a?(Array)\n end\n end",
"def array(op, len, work) # DK:P297\n\t\t\t\twarn \"array is not implemented\"\n\t\t\tend",
"def isBasicTypeArrayType(obj)\n if isArrayType(obj)\n if obj.size == 0\n return false # no len is no BasicType\n end\n if isPointerType(obj[0])\n return false\n end\n if isBasicType(obj[0])\n return true\n end\n end\n return false\n end",
"def to_ary() end",
"def getArray _args\n \"getArray _args;\" \n end",
"def saved_for_special_occasion(array)\n puts array[2]\nend",
"def attr_is_array(attribute)\n # Getter for objects\n define_method attribute.to_s do\n value = read_attribute(attribute).from_yaml\n if value.nil? or value.blank?\n []\n else\n value\n end\n \tend\n end",
"def to_ary; nil; end",
"def array\n\t\t#create an array of\n\t\tarray = [0, 1, 2, 3, 4, 5, 6, 7, 8]\n\tend",
"def test_mine_returns_array\n mine_results = @test_loc.mine\n assert mine_results.is_a? Array\n end",
"def test_neighbors_returns_an_array\n assert @cell.neighbors.is_a?(Array)\n end",
"def test_each_is_a_method_on_arrays\n assert_equal true, [].methods.include?(as_name(:each))\n end",
"def mabye_one_element_array(ast)\n if ast.is_a?(Array) && ast.size == 1\n ast[0]\n else\n ast\n end\n end",
"def has_nested_array?(array)\n array.each do |element|\n return true if element.is_a?(Array)\n end\n false\nend",
"def schema_is_valid_array?(schema, trace)\n schema_valid_trace(\"schema_is_valid_array?\", schema, trace)\n ((schema.length == 1) ?\n schema_is_valid_internal?(schema[0], trace) :\n schema_valid_error(schema, \"Schema array not of length 1\", trace))\n end",
"def to_array(value)\n value.class == Array ? value : [value]\n end",
"def to_ary\n end",
"def coerce_array(value)\n value&.to_a\n end",
"def calls_array\n a = return_array\n a[1]\n end",
"def test2(array)\n\tputs \"Test2: Should return an array -> \"\n\tgroupMaker(array).class == Array ? true : false\nend",
"def isArray(obj)\n if (Array.isArray)\n return Array.isArray(obj)\n else\n return Object.prototype.toString.call(obj) === '[object Array]'\n end\n end",
"def is_a?(klass)\n klass == Array || super(klass)\n end",
"def print_array(array)\n raise NotImplementedError\nend",
"def test3(array)\n\tputs \"Test3: Should return an array of arrays -> \"\n\tgroupMaker(array).any? {|x| x.class != Array} ? false : true\nend",
"def is_numeric_2d_array?\n self.all? do |data|\n data.is_a?(Array) &&\n data.size == 2 &&\n data.is_numeric_array?\n end\n end",
"def array_collection?\n @array_collection == true\n end",
"def print_array my_array\n\t\tp my_array\n\tend",
"def is_a?(klass)\n klass == Array || super(klass)\n end",
"def print_array(array)\n p array\nend",
"def test_array_literals\n array = Array.new\n assert_equal [], array\n\n array[0] = 1\n assert_equal [1], array\n\n array[1] = 2\n assert_equal [1, 2], array\n\n array << 333\n assert_equal [1, 2, 333], array\n end",
"def nonemptyArray?(thing)\n thing.kind_of?(Array) &&\n !thing.empty?\nend",
"def test_array_subtype_shortform\n s = Schema.new do\n type :array, :integer\n end\n assert_nothing_raised { s.validate! [5] }\n assert_verr { s.validate! [nil] }\n assert_verr { s.validate! ['a'] }\n assert_verr { s.validate! [5, 'a'] }\n assert_verr { s.validate! [5, nil] }\n end",
"def explode arr\n size = arr.map { |i| i.is_a?(Integer) ? i : 0 }.sum\n size.zero? ? \"Void!\" : Array.new(size, arr)\nend",
"def validate_array(_record, attribute, value)\n errors.add(attribute, 'not an array.') unless value.is_a? Array\n end",
"def test_packing_array\n array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 32000]\n assert_equal array, RubyVolt::DataType::Array.testpacking(array)[1..-1]\n end",
"def look_and_say(array)\n\nend",
"def doubler(array)\n \nend",
"def doubler(array)\n \nend",
"def types(array)\n yield(array)\nend",
"def as_content_array\n as_array[1]\n end",
"def multi_segment?\n @data.is_a?(Array)\n end",
"def to_ary\n\t []\n\tend",
"def verify_array(array, expected, verify_nesting)\n return wrong_type_error(array, expected.name, expected.type) unless expected.is_a?(WeaselDiesel::Response::Vector)\n expected = expected.elements && expected.elements.any? ? expected.elements.first : expected\n array.map{ |el| verify_element(el, expected, verify_nesting) }\n end",
"def added(array)\nend",
"def get_array_type(array)\r\n\t\t\r\n\t\tif @l_identificadores != nil\r\n\t\t\tarray << @tipo1\r\n\t\t\t@l_identificadores.get_array_type(array)\r\n\t\telse\r\n\t\t\tarray << @tipo2\r\n\t\t\tarray << @tipo1\t\r\n\t\t\treturn array\r\n\t\tend\r\n\r\n\tend",
"def Array(type)\n Strict(::Array).of(type)\n end",
"def to_ary; self.to_a; end",
"def value?\n value && !value.is_a?(Array)\n end",
"def array_start\n []\n end"
] | [
"0.7325143",
"0.731974",
"0.728423",
"0.72462523",
"0.7237629",
"0.7218187",
"0.7138658",
"0.7126627",
"0.71246904",
"0.71246904",
"0.7053896",
"0.7050514",
"0.70376354",
"0.6996002",
"0.69832945",
"0.6966359",
"0.6898526",
"0.68818253",
"0.6864665",
"0.6853551",
"0.6761297",
"0.6748985",
"0.6712865",
"0.6626122",
"0.6623738",
"0.6573801",
"0.651942",
"0.6496213",
"0.64936554",
"0.64828336",
"0.6439828",
"0.6437068",
"0.6372496",
"0.6372496",
"0.634471",
"0.63390285",
"0.6338468",
"0.63379115",
"0.63377357",
"0.63333356",
"0.6311885",
"0.63110125",
"0.6309508",
"0.6288097",
"0.62796915",
"0.627893",
"0.6266072",
"0.62470233",
"0.62388915",
"0.62112004",
"0.6199648",
"0.6183165",
"0.6147478",
"0.6131819",
"0.61235654",
"0.6116958",
"0.6111776",
"0.60918033",
"0.6069927",
"0.60697556",
"0.6058525",
"0.6043725",
"0.6037841",
"0.60195947",
"0.60162604",
"0.6006666",
"0.599458",
"0.5990835",
"0.5988877",
"0.5985126",
"0.5982757",
"0.5975055",
"0.5971188",
"0.5964724",
"0.59532374",
"0.594213",
"0.5940528",
"0.5938586",
"0.59380615",
"0.59303004",
"0.5928829",
"0.5914086",
"0.59098154",
"0.5909228",
"0.5905159",
"0.59032154",
"0.5895055",
"0.58929497",
"0.5890466",
"0.5890466",
"0.58869946",
"0.5884392",
"0.588057",
"0.5877563",
"0.5874767",
"0.5870738",
"0.5866461",
"0.5866294",
"0.5845882",
"0.58431417",
"0.583998"
] | 0.0 | -1 |
In the event of a tie: Highest ranking card at the top of the sequence wins. | def comparer_methods
super + [
:min_rank
]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def winning_player\n played_cards.max_by { |_, card| card_scores[card] }.first\n end",
"def tie_breaker_cards\n matched = self.matched_cards\n sorted = @cards.sort.reverse\n # sorted so the card with highest value is first \n if five_of_a_kind? \n # All cards break the tie\n return sorted \n elsif flush?\n # All cards break the tie\n return sorted \n elsif four_of_a_kind?\n four = matched.find{ |rank, cards| cards.size == 4}\n # quads break the tie first, then the other card \n return four + [(sorted - four).first] \n elsif full_house?\n three = matched.find{ |rank, cards| cards.size == 3}\n two = matched.find{ |rank, cards| cards.size == 2}\n return three + two\n elsif straight?\n # Special case for ace, 2, 3, 4 ,5 straight, which sorts as\n # 2,3,4,5,A \n if sorted.first.rank == Rank::Ace && sorted.last.rank == Rank::Two \n ace = sorted.pop \n sorted.unshift(ace) # put ace at the back\n return [ sorted.first ] # should be the 5 now \n else\n return [ sorted.first ] \n end\n elsif three_of_a_kind?\n three = matched.find{ |rank, cards| cards.size == 3} \n return three + (sorted - three).first(2)\n elsif two_pair?\n pairs = [] \n matched.each{ |rank, cards| pairs << cards if cards.size == 2 } \n two_pair = pairs[0] + pairs[1]\n two_pair + [(sorted - two_pair).first]\n elsif pair?\n two = matched.find{ |rank, cards| cards.size == 2} \n two + (sorted - two).first(3)\n else\n sorted.first(5)\n end\n end",
"def announce_winners(highcard,game)\n\n # now announce each winner that has highcard\n winners=[]\n game.each do |user|\n if user[:cardval] == highcard\n winners.push(user[:player])\n end # if\n end # game each do\n\n\n # BONUS if more than one winner Announce this\n print \"#{ (winners.length > 1) ? ' There is a tie between ' : ' There is one winner '}\"\n list_winners(winners)\n list_cards(winners,game)\nend",
"def winner\n\t\tbest_for_1 = best_hand(@hand1)\n\t\tbest_for_2 = best_hand(@hand2)\n\t\tcase best_for_1[:rank] <=> best_for_2[:rank]\n\t\t\twhen -1 then 2\n\t\t\twhen 1 then 1\n\t\t\twhen 0 then check_kicker(best_for_1, best_for_2)\n\t\tend\n\tend",
"def determine_winner\n @active_players.sort! do |player1, player2|\n if player1.strongest_hand > player2.strongest_hand\n -1\n elsif player1.strongest_hand < player2.strongest_hand\n 1\n else\n 0\n end\n end\nend",
"def winner\n $the_win_comb = { flash_straight: flash_straight, for_of_kind: four_of_kind, full_house: full_house,\n flush: flush, straight: straight, three: three, two_pair: two_pair,\n one_pair: one_pair, high_card: high_card }\n puts \"\\n The highest winner combinations and cards are - \"\n $the_win_comb.each { |comb, ans| return puts comb.upcase, $the_win_comb[comb], ' ' unless ans.nil?}\n end",
"def highest_card?\n single_cards = Array.new(5, -1)\n single_count = 0\n (12).downto(0) do |i|\n if @ranks[i] == 1 and single_count < 5\n single_cards[single_count] = i\n single_count += 1\n end\n end\n return [1] + single_cards\n end",
"def rank\n RANKS.detect { |method, rank| send :\"#{method}?\" } || [:high_card, 0]\n end",
"def winner\n big_p = 1\n \n marks = self.unrolled\n @@All_Runs.each do |run|\n #p = product of all the slots\n p = run.map {|i| marks[i]}.inject(:*)\n return :x if p == 8\n return :o if p == 1\n big_p *= p\n end\n \n return (big_p == 0) ? nil : :cat\n end",
"def winner\n @board.sort_by {|player, board_position| board_position}.last.first\n end",
"def worst_case board\n\t\tworst = 0\n\t\topp_board = board.rotate 7\n\t\t6.times {|i|\n\t\t\t\ts = score_for(opp_board, i)\n\t\t\t\tworst = s if worst < s\n\t\t\t}\n\t\t\tworst\n\tend",
"def determine_winner\n blackjack\n bust\n if player.score == dealer.score\n puts \"---------Tie - Player Wins!---------\"\n elsif player.score > dealer.score\n puts \"------------Player Wins!------------\"\n puts \"Dealer had #{dealer.score}.\"\n else dealer.score > player.score\n puts \"-------------Dealer Wins------------\"\n puts \"Dealer Score: #{dealer.score}\"\n end\n end",
"def determine_winner(comp_choice, player_choice)\n rock = 0\n paper = 1\n scissors = 2\n\n player_won = 0\n comp_won = 1\n tie = 2\n\n if comp_choice == rock\n if player_choice = rock\n return tie\n elsif player_choice = paper\n return player_won\n else\n return comp_won\n end\n elsif comp_choice == paper\n if player_choice = rock\n return comp_won\n elsif player_choice = paper\n return tie\n else\n return player_won\n end\n else \n if player_choice = rock\n return player_won\n elsif player_choice = paper\n return comp_won\n else\n return tie\n end\n end\nend",
"def high_card_winner\n\n\t # find high card winner card from numerical representation\n\t for i in 0..@best_hand_value_1.length-1 do \n\t if @best_hand_value_1[i] <= 10\n\t @high_card_winner_1[i] = @best_hand_value_1[i]\n\t elsif @best_hand_value_1[i] == 11\n\t @high_card_winner_1[i] = 'J'\n\t elsif @best_hand_value_1[i] == 12\n\t @high_card_winner_1[i] = 'Q'\n\t elsif @best_hand_value_1[i] == 13\n\t @high_card_winner_1[i] = 'K'\n\t elsif @best_hand_value_1[i] == 14\n\t @high_card_winner_1[i] = \"A\"\n\t end \n\t if @best_hand_value_2[i]<=10\n\t @high_card_winner_2[i] = @best_hand_value_2[i]\n\t elsif @best_hand_value_2[i] == 11\n\t @high_card_winner_2[i] = 'J'\n\t elsif @best_hand_value_2[i] == 12\n\t @high_card_winner_2[i] = 'Q'\n\t elsif @best_hand_value_2[i] == 13\n\t @high_card_winner_2[i] = 'K'\n\t elsif @best_hand_value_2[i] == 14\n\t @high_card_winner_2[i] = \"A\"\n\t end \n\t end\n\tend",
"def winner(array)\n\t#first sort our players by score, highest to lowest\n\tarray.sort! {|a,b| b <=> a}\n\thighest = array[0]\n\tsecond = array[1]\n\n\tif highest.score >= 21\n\t\t#make sure the winner wins by at least 2 points\n\t\tunless (highest - second).abs < 2\n\t\t\treturn highest\n\t\tend\n\tend\nend",
"def tie\n puts \"It's a draw! Nobody wins :(\"\n end",
"def winner\n count1, count2 = @cups[6].count, @cups[13].count\n if count1 > count2\n @name1\n elsif count2 > count1\n @name2\n else\n :draw\n end\n end",
"def calculate_winner players\r\n\r\n sorted_cards = @card_list.sort # sort cards in 'poker' order\r\n found=0\r\n winning_card_index=-1\r\n\r\n while found==0\r\n players.each_with_index do |player, i|\r\n # if we have the same winner twice in a row, we return the next best card (i.e. let someone else win)\r\n if sorted_cards[winning_card_index] == player.get_last_card_played\r\n if player.name==@last_winner\r\n\r\n changed\r\n notify_observers player.name,player.get_last_card_played.to_string\r\n\r\n winning_card_index=-2\r\n break\r\n else\r\n @last_winner=player.name\r\n found=1\r\n break\r\n end\r\n end\r\n end\r\n end\r\n\r\n # Switched off this observation for the moment\r\n #changed\r\n #notify_observers(sorted_cards[-1].to_string)\r\n\r\n #if sorted_cards[@winning_card_index].to_string_other.include?(\"WHITE\") then\r\n # changed\r\n # notify_observers(@last_winner,sorted_cards[@winning_card_index].to_string)\r\n #end\r\n\r\n #sorted_cards[@winning_card_index] # return best card\r\n sorted_cards[winning_card_index]\r\n\r\n end",
"def overall_winner?(p1_wins,p2_wins)\n if p1_wins > p2_wins\n return 1\n elsif p2_wins > p1_wins\n return 2\n else\n return nil\n end\nend",
"def heaviest_rock(rock_array)\n max_rock = 0\n\n rocks.each do |rock|\n max_rock = rock if max_rock < rock \n end\nend",
"def winner\n tie_string = \"\"\n @players.each do |player|\n if @position[player] == @length\n tie_string << \"#{player}\"\n end\n end\n\n if tie_string.length > 1\n return \"no one\"\n else\n return tie_string[0]\n end\n\n end",
"def winner\n players.sort.last\n end",
"def <=> card\n if rank_of_kind > card.rank_of_kind\n return 1\n end\n if rank_of_kind < card.rank_of_kind\n return -1\n end\n if rank_of_suit > card.rank_of_suit\n return 1\n end\n if rank_of_suit < card.rank_of_suit\n return -1\n end\n if rank_of_suit == card.rank_of_suit\n notify_observers_fraud card.to_string\n #return 0 # should not happen in a single-pack card game!\n end\n end",
"def calculate_winner players\n\n sorted_cards = @card_list.sort # sort cards in 'poker' order\n players.each_with_index {|player, i|\n if sorted_cards[-1] == player.get_last_card_played\n @last_winner=player.name\n end\n }\n # Switched off this observation for the moment\n #changed\n #notify_observers(sorted_cards[-1].to_string)\n\n if sorted_cards[-1].to_string_other.include?(\"FIVE\") then\n changed\n notify_observers(@last_winner,sorted_cards[-1].to_string)\n end\n\n sorted_cards[-1] # return best card\n end",
"def winner\n @player_positions.max_by{|player, position| position}[0]\n end",
"def rank_starting_hand\r\n sorted_hand = @hole_cards.sort_by { |card| card.rank } # [4,2] => [2,4]\r\n\r\n # Shorthand variables for two cards in hand\r\n (first,second) = [sorted_hand[0],sorted_hand[1]]\r\n\r\n suited = first.suit == second.suit # True if cards have same suit\r\n paired = first.rank == second.rank # True if cards have same rank\r\n connected = first.rank + 1 == second.rank # True if cards have consecutive ranks\r\n\r\n # Check for playable hands and return their rank\r\n # (Some of these checks aren't necessary but are included for readibility)\r\n case first.rank\r\n when 8 then return 14 if paired # Pocket Eights\r\n when 9 then return 9 if paired # Pocket Nines\r\n when 10\r\n return 6 if paired # Pocket Tens\r\n return 20 if second.rank == 12 and suited # Queen-Ten Suited\r\n return 16 if second.rank == 13 and suited # King-Ten Suited\r\n return 12 if second.rank == 14 and suited # Ace-Ten Suited\r\n when 11\r\n return 4 if paired # Pocket Jacks\r\n return 17 if second.rank == 12 and suited # Queen-Jack Suited\r\n return 15 if second.rank == 13 and suited # King-Jack Suited\r\n if second.rank == 14\r\n return suited ? 10 : 18 # Ace-Jack Suited/Offsuit\r\n end\r\n when 12\r\n return 3 if paired # Pocket Queens\r\n if second.rank == 13\r\n return suited ? 11 : 19 # King-Queen Suited/Offsuit\r\n elsif second.rank == 14\r\n return suited ? 8 : 13 # Ace-Queen Suited/Offsuit\r\n end\r\n when 13\r\n return 2 if paired # Pocket Kings\r\n if second.rank == 14\r\n return suited ? 5 : 7 # Ace-King Suited/Offsuit\r\n end\r\n when 14 then return 1 if paired # Pocket Aces\r\n end\r\n # Still played if the hand is suited, paired, or connected, otherwise not played\r\n return (suited or paired or connected) ? 21 : -1\r\n end",
"def print_scores_and_determine_winner\n tie = false\n puts \"\\nScores:\"\n winner = @players[0]\n (0..num_players - 1).each do |i|\n puts \"\\n#{@players[i].name} : #{@players[i].score}\"\n tie = @players[i].score == winner.score\n winner = @players[i] if @players[i].score > winner.score\n end\n\n puts \"\\nIt was a tie!\" if tie == true\n puts 'Congratulations ' + winner.name + \"!! You win!!\\n\" if tie == false\n end",
"def play_best_of()\n\n while @rounds != 0\n clear(); Banner::print_banner()\n play()\n sleep(2.7)\n\n if @player_wins > @computer_wins\n\n puts \"[$] Player win (#{@player_wins}/3) rounds !\"\n\n elsif @computer_wins > @player_wins\n\n puts \"[$] Computer win (#{@computer_wins}/3) rounds !\"\n\n\n elsif @player_wins == @computer_wins\n\n puts \"[~] No one win, Equals !\"\n\n end\n\n \n\n end\n\n again()\n\n end",
"def winner\n (score1 > score2 ? 1 : 2) if won?\n end",
"def find_winner()\n\t\tingame_players = 0\n\t\tlast_cards = []\n\n\t\t#puts \"In find winner method\"\n\t\tputs to_s\n\n\t\[email protected] do |player|\n\t\t\n\n\t\t\tif !player.is_fold\n\t\t\t\tlast_cards << player.get_cards\n\t\t\t\t\n\t\t\tend\n\n\t\tend\n\t\[email protected] do |player|\n\t\t\t\n\n\t\t\tif !player.is_fold\n\t\t\t\t\n\t\t\t\tputs\n\t\t\t\tplayer.increase_game\n\t\t\t\t#i = last_cards.index(player.get_cards)\n\t\t\t\t#last_cards.insert(0, last_cards.delete_at(i)) \n\t\t\t\tcards_of_players = \"#{last_cards.join(\"\")}\"\n\t\t\t\t#puts \"Order of cards: \" + cards_in_order\n\t\t\t\t#puts \"get cards: \" + get_cards\n\t\t\t\twinner = @pokeroddsproxy.get_winnercards(cards_of_players, get_cards)\n\t\t\t\t#odds = @pokeroddsproxy.get_odds(cards_in_order, get_cards, ingame_players)\n\t\t\t\t#puts odds\n\n\t\t\t\tif winner == player.get_cards #If winner's cards are same with the player\n\t\t\t\t\tputs \"#{player.get_name} is the winner\"\n\t\t\t\t\tplayer.addmoney(@pot)\n\t\t\t\t\tplayer.increase_win\n\t\t\t\telse\n\t\t\t\t\tputs \"#{player.get_name} is the loser\"\n\t\t\t\t\tplayer.increase_lose\n\t\t\t\tend\n\n\t\t\tend\n\n\t\tend\n\n\tend",
"def determine_game_winner(player1,player2)\n if player1.score > player2.score\n puts \"#{player1.name} is the winner!\"\n elsif player1.score < player2.score\n puts \"#{player2.name} is the winner!\"\n else\n puts \"It's a tie.\"\n end\nend",
"def computer_ai_3\n rock = 0\n paper = 0\n scissors = 0\n most_played = \"r\"\n choice = \"p\"\n\n # Find which moves have been played the most.\n \n @human_moves.each do |move|\n if move == 'r'\n rock = rock + 1\n elsif move == 'p'\n paper = paper + 1\n elsif move == 's'\n scissors = scissors + 1\n end\n end\n\n if rock > paper && rock > scissors\n most_played = \"r\"\n elsif paper > rock && paper > scissors\n most_played = \"p\"\n elsif scissors > paper && scissors > rock \n most_played = \"s\"\n else\n #choose random if they tie\n choices =['r', 'p', 's']\n most_played = choices.sample\n end\n\n #play the hand that beats the human move.\n if most_played == 'r'\n choice = 'p'\n elsif most_played == 'p'\n choice = 's'\n elsif most_played == 's'\n choice = 'r'\n end\n\n return choice\n end",
"def find_best_score(total_per_player)\n best_score = 0\n winner = ''\n total_per_player.each do |player_name,total|\n\n if total > best_score\n best_score = total\n winner = player_name\n end\n end\n return winner\n end",
"def winner \n if won? \n turn_count.even? ? \"O\" : \"X\"\n end \n end",
"def winner\n @players.max_by do |player|\n player.score\n end\n end",
"def high_ranking_cards\n cards.map do |card|\n if card.rank >= 11\n high_cards << card\n end\n end\n high_cards\n end",
"def high_card?\n cards_by_rank.count == @size\n end",
"def tie_breaker\n all_ranks.find{|truth| truth != 2014}\n end",
"def high_card\n @cards.sort[-1]\n end",
"def high_ranking_cards\n\n array_high_cards = []\n\n cards.each do |card|\n\n if card.rank >= 11\n array_high_cards << card\n end\n\n end\n\n array_high_cards\n\n end",
"def grand_winner?(wins)\n wins.key(5)\nend",
"def get_score\n flush = is_flush?\n straight = is_straight?\n pairs = pairs?\n\n return 45 if pairs.size == 1 && pairs[0][1] == 5\n return 44 if flush && straight\n return 31 + pairs[0][0] - 2 if pairs.size == 1 && pairs[0][1] == 4\n return 30 if pairs.size == 2 && (pairs[0][1] + pairs[1][1]) == 5\n return 29 if flush\n return 28 if straight\n return 15 + pairs[0][0] - 2 if pairs.size == 1 && pairs[0][1] == 3\n return 14 if pairs.size == 2\n return 1 + pairs[0][0] - 2 if pairs.size == 1\n -14 + high_card #high card return\n end",
"def high_card\n high_value = 0\n @grip.each do |card|\n new_value = FACE_VALUES.find_index(card.value)\n if new_value > high_value\n high_value = new_value\n end\n end\n FACE_VALUES[high_value]\n end",
"def winner\n if combo = won?\n winner = board.position(combo.first + 1)\n end\n winner\n end",
"def getRoundResult(winning_suit, suit1, number1, suit2, number2)\n # Write your code here\n return 'Player 1 wins' if suit1 == winning_suit && suit2 != winning_suit\n return 'Player 2 wins' if suit2 == winning_suit && suit1 != winning_suit\n if (suit1 == winning_suit && suit2 == winning_suit) || (suit1 != winning_suit && suit2 != winning_suit)\n if number1 > number2\n return 'Player 1 wins'\n elsif number2 > number1\n return 'Player 2 wins'\n else\n return 'Draw'\n end\n end\nend",
"def identify\n \n return if @value > 0 # no need to do it twice!\n return if @cards.size < 5 # need at least 5 cards\n \n @cards.sort!\n \n #puts \"@total_face_value = #{@total_face_value}\"\n \n if is_flush? then \n #puts 'have a flush of some kind...' \n \n if @total_face_value == 60 then\n #puts \"it's a royal flush!\"\n @rank = ROYAL_FLUSH\n @value = @cards.max.face_value\n return\n end\n \n if is_straight? then\n #puts \"it's straight flush!\"\n @rank = STRAIGHT_FLUSH\n @value = @cards.max.face_value\n return\n end\n \n #puts \"it's a regular flush!\"\n @rank = FLUSH\n @value = @cards.max.face_value\n return\n end\n \n #puts 'not a flush'\n \n if is_straight? then\n #puts \"it's a straight!\"\n @rank = STRAIGHT\n @value = @cards.max.face_value\n return\n end\n \n # look for pairs\n (pairs, @unpaired_cards) = find_pairs()\n if pairs.empty? then\n # high card!\n #puts \"high card \" + high_card.to_s\n @rank = HIGH_CARD\n @value = @cards.max.face_value\n return\n end\n \n if pairs.size == 1 then\n paired_cards = pairs[0].size\n @value = pairs[0].max.face_value\n if paired_cards == 2 then\n #puts \"it's a single pair!\"\n @rank = PAIR\n elsif paired_cards == 3 then\n #puts \"it's a three of a kind!\"\n @rank = THREE_KIND\n elsif paired_cards == 4 then\n @rank = FOUR_KIND\n end\n return\n \n elsif pairs.size == 2 then\n paired_cards = pairs[0].size + pairs[1].size\n a = pairs[0].max.face_value\n b = pairs[1].max.face_value\n if a > b then\n @value = a\n elsif b > a then\n @value = b\n else\n # should never happen since it means the\n # pairs are of the same face value\n # e.g., two pairs of 6s\n @value = a\n end\n if paired_cards == 4 then\n #puts \"it's two pair!\"\n @rank = TWO_PAIR\n elsif paired_cards == 5 then\n #puts \"it's a full house!\"\n @rank = FULL_HOUSE\n # add faces of each pair for value\n if a > b then\n @value = a * 100 + b\n elsif b > a then\n @value = b * 100 + a\n end\n end\n return\n \n end\n \n # should never get here\n raise \"oh no, should never have come to this!\"\n \n end",
"def winner\n @players.max_by{ |player| player.score}\n end",
"def tie?\n if @taken.length >= @board.length\n puts \"It's a tie! Game over.\"\n return true\n end\n return false\n end",
"def find_winner\n if @player_1.life == 0\n return 2\n end\n return 1\n end",
"def tie_winner \n\t\t# Store the winner information if there is a tie for player 1 and 2 \n\t\t@tie_1 = Array.new\n\t\t@tie_2 = Array.new\n\n\t\tfor i in 0..@best_hand_value_1.length-1 do \n\n\t\t\tif @best_hand_value_1[i] == @best_hand_value_2[i]\n\n\t\t\t\t# This cannot happen but included to be complete \n\t\t\t\tif @combo_name_1[i][0] == \"A Royal Flush\"\n\t\t\t\t\t@tie_1[i] = 0 \n\t\t\t\t\t@tie_2[i] = 0 \n\t\t\t\tend \n\t\t\t\t# find winner with two straight flushes\n\t\t\t\t# larger straight flush will be the largest value in the values array\n\t\t\t\tif @combo_name_1[i][0] == \"A Straight Flush\"\n\t\t\t\t\tif @hand_information_player_1[i]['vals'].sort[-1] > @hand_information_player_2[i]['vals'].sort[-1]\n\t\t\t\t\t\t@tie_1[i] = @hand_information_player_1[i]['vals'].sort[-1]\n\t\t\t\t\t\t@tie_2[i] = 0 \n\t\t\t\t\telsif @hand_information_player_1[i]['vals'].sort[-1] < @hand_information_player_2[i]['vals'].sort[-1]\n\t\t\t\t\t\t@tie_1[i] = 0\n\t\t\t\t\t\t@tie_2[i] = @hand_information_player_2[i]['vals'].sort[-1]\n\t\t\t\t\tend \n\t\t\t\tend\n\t\t\t\t# find winner with 2 four of a kinds\n\t\t\t\t# larger 4 of a kind will be the mode of the value array\n\t\t\t\tif @combo_name_1[i][0] == \"Four of a Kind\"\n\t\t\t\t\tif @hand_information_player_1[i]['vals'].mode > @hand_information_player_2[i]['vals'].mode\n\t\t\t\t\t\t@tie_1[i] = @hand_information_player_1[i]['vals'].mode\n\t\t\t\t\t\t@tie_2[i] = 0 \n\t\t\t\t\telsif @hand_information_player_1[i]['vals'].mode < @hand_information_player_2[i]['vals'].mode\n\t\t\t\t \t\t@tie_1[i] = 0\n\t\t\t\t \t\t@tie_2[i] = @hand_information_player_2[i]['vals'].mode\n\t\t\t\t \tend \n\t\t\t\tend \n\t\t\t\t# find winner with two three of a kinds\n\t\t\t\t# larger 3 of a kind will be the mode of the values array \n\t\t\t\tif @combo_name_1[i][0] == \"Three of a Kind\"\n\t\t\t\t\tif @hand_information_player_1[i]['vals'].mode > @hand_information_player_2[i]['vals'].mode\n\t\t\t\t\t\t@tie_1[i] = @hand_information_player_1[i]['vals'].mode\n\t\t\t\t\t\t@tie_2[i] = 0 \n\t\t\t\t\telsif @hand_information_player_1[i]['vals'].mode < @hand_information_player_2[i]['vals'].mode\n\t\t\t\t \t\t@tie_1[i] = 0\n\t\t\t\t \t\t@tie_2[i] = @hand_information_player_2[i]['vals'].mode\n\t\t\t\t \tend \n\t\t\t\tend \n\t\t\t\t# find winner with two full houses. Larger full house will be larger 3 of a kind, \n\t\t\t\t# which can be found as the mode of the values array \n\t\t\t\tif @combo_name_1[i][0] == \"A Full House\"\n\t\t\t\t\tif @hand_information_player_1[i]['vals'].mode > @hand_information_player_2[i]['vals'].mode\n\t\t\t\t\t\t@tie_1[i] = @hand_information_player_1[i]['vals'].mode\n\t\t\t\t\t\t@tie_2[i] = 0 \n\t\t\t\t\telsif @hand_information_player_1[i]['vals'].mode < @hand_information_player_2[i]['vals'].mode\n\t\t\t\t \t\t@tie_1[i] = 0\n\t\t\t\t \t\t@tie_2[i] = @hand_information_player_2[i]['vals'].mode\n\t\t\t\t \tend \n\t\t\t\tend \n\t\t\t\t# find winner with two flushes. Since a flush is 5 cards, max will store largest. \n\t\t\t\tif @combo_name_1[i][0] == \"A Flush\"\n\t\t\t\t\tif @hand_information_player_1[i]['max'] > @hand_information_player_2[i]['max'] \n\t\t\t\t\t\t@tie_1[i] = @hand_information_player_1[i]['max']\n\t\t\t\t\t\t@tie_2[i] = 0\n\t\t\t\t\telsif @hand_information_player_1[i]['max'] < @hand_information_player_2[i]['max'] \n\t\t\t\t\t\t@tie_1[i] = 0\n\t\t\t\t\t\t@tie_2[i] = @hand_information_player_2[i]['max']\n\t\t\t\t\tend \n\t\t\t\tend \n\t\t\t\t# find winner with two straights. Since a straight is 5 cards, the max will have \n\t\t\t\t# the larger of the two saved \n\t\t\t\tif @combo_name_1[i][0] == \"A Straight\"\n\t\t\t\t\tif @hand_information_player_1[i]['max'] > @hand_information_player_2[i]['max'] \n\t\t\t\t\t\t@tie_1[i] = @hand_information_player_1[i]['max']\n\t\t\t\t\t\t@tie_2[i] = 0\n\t\t\t\t\telsif @hand_information_player_1[i]['max'] < @hand_information_player_2[i]['max'] \n\t\t\t\t\t\t@tie_1[i] = 0\n\t\t\t\t\t\t@tie_2[i] = @hand_information_player_2[i]['max']\n\t\t\t\t\tend \n\t\t\t\tend \n\t\t\t\t# find winner with same high card. Itterate through all 5 cards until one is bigger (in order from highest)\n\t\t\t\tif @combo_name_1[i][0] == \"High Card\"\n\t\t\t\t\tfor k in 1..5 do\n\t\t\t\t\t\tif @hand_information_player_1[i]['vals'].sort[-k] > @hand_information_player_2[i]['vals'].sort[-k]\n\t\t\t\t\t\t\t@tie_1[i] = @hand_information_player_1[i]['vals'].sort[-k]\n\t\t\t\t\t\t\t@tie_2[i] = 0\n\t\t\t\t\t\t\tbreak \n\t\t\t\t\t\telsif @hand_information_player_1[i]['vals'].sort[-k] < @hand_information_player_2[i]['vals'].sort[-k]\n\t\t\t\t\t\t\t@tie_1[i] = 0\n\t\t\t\t\t\t\t@tie_2[i] = @hand_information_player_2[i]['vals'].sort[-k]\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\tend \n\t\t\t\t\tend \n\t\t\t\tend\n\t\t\t\t# find winner with same two pairs. First check each of the pair values (high to low) then check\n\t\t\t\t# the remaining cards high to low \n\t\t\t\tif @combo_name_1[i][0] == \"Two Pair\" \n\t\t\t\t\tif @hand_information_player_1[i]['pairvals'].sort[-1] > @hand_information_player_2[i]['pairvals'].sort[-1]\n\t\t\t\t\t\t@tie_1[i] = @hand_information_player_1[i]['pairvals'].sort[-1]\n\t\t\t\t\t\t@tie_2[i] = 0\n\t\t\t\t\telsif @hand_information_player_1[i]['pairvals'].sort[-1] < @hand_information_player_2[i]['pairvals'].sort[-1]\n\t\t\t\t\t\t@tie_1[i] = 0\n\t\t\t\t\t\t@tie_2[i] = @hand_information_player_2[i]['pairvals'].sort[-1]\n\t\t\t\t\telsif @hand_information_player_1[i]['pairvals'].sort[-1] == @hand_information_player_2[i]['pairvals'].sort[-1]\n\t\t\t\t\t\tif @hand_information_player_1[i]['pairvals'].sort[-2] > @hand_information_player_2[i]['pairvals'].sort[-2]\n\t\t\t\t\t\t\t@tie_1[i] = @hand_information_player_1[i]['pairvals'].sort[-2]\n\t\t\t\t\t\t\t@tie_2[i] = 0\n\t\t\t\t\t\telsif @hand_information_player_1[i]['pairvals'].sort[-2] < @hand_information_player_2[i]['pairvals'].sort[-2]\n\t\t\t\t\t\t\t@tie_1[i] = 0\n\t\t\t\t\t\t\t@tie_2[i] = @hand_information_player_2[i]['pairvals'].sort[-2]\n\t\t\t\t\t\telsif @hand_information_player_1[i]['pairvals'].sort[-2] == @hand_information_player_2[i]['pairvals'].sort[-2]\n\t\t\t\t\t\t\tfor k in 1..3 do\n\t\t\t\t\t\t\t\tif @hand_information_player_1[i]['vals'].sort[-k] > @hand_information_player_2[i]['vals'].sort[-k]\n\t\t\t\t\t\t\t\t\t@tie_1[i] = @hand_information_player_1[i]['vals'].sort[-k]\n\t\t\t\t\t\t\t\t\t@tie_2[i] = 0\n\t\t\t\t\t\t\t\t\tbreak \n\t\t\t\t\t\t\t\telsif @hand_information_player_1[i]['vals'].sort[-k] < @hand_information_player_2[i]['vals'].sort[-k]\n\t\t\t\t\t\t\t\t\t@tie_1[i] = 0\n\t\t\t\t\t\t\t\t\t@tie_2[i] = @hand_information_player_2[i]['vals'].sort[-k]\n\t\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\t\tend \n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend \n\t\t\t\t# find winner with same pairs, first check pair value (high to low), then itterate through all remaining cards\n\t\t\t\t# high to low \n\t\t\t\tif @combo_name_1[i][0] == \"A Pair\"\n\t\t\t\t\tif @hand_information_player_1[i]['pairvals'][0] > @hand_information_player_2[i]['pairvals'][0]\n\t\t\t\t\t\t@tie_1[i] = @hand_information_player_1[i]['pairvals'][0]\n\t\t\t\t\t\t@tie_2[i] = 0\n\t\t\t\t\telsif @hand_information_player_1[i]['pairvals'][0] < @hand_information_player_2[i]['pairvals'][0]\n\t\t\t\t\t\t@tie_1[i] = 0\n\t\t\t\t\t\t@tie_2[i] = @hand_information_player_2[i]['pairvals'][0]\n\t\t\t\t\telsif @hand_information_player_1[i]['pairvals'][0] == @hand_information_player_2[i]['pairvals'][0]\n\t\t\t\t\t\tfor k in 1..4 do\n\t\t\t\t\t\t\tif @hand_information_player_1[i]['vals'].sort[-k] > @hand_information_player_2[i]['vals'].sort[-k]\n\t\t\t\t\t\t\t\t@tie_1[i] = @hand_information_player_1[i]['vals'].sort[-k]\n\t\t\t\t\t\t\t\t@tie_2[i] = 0\n\t\t\t\t\t\t\t\tbreak \n\t\t\t\t\t\t\telsif @hand_information_player_1[i]['vals'].sort[-k] < @hand_information_player_2[i]['vals'].sort[-k]\n\t\t\t\t\t\t\t\t@tie_1[i] = 0\n\t\t\t\t\t\t\t\t@tie_2[i] = @hand_information_player_2[i]['vals'].sort[-k]\n\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\tend \n\t\t\t\t\t\tend \n\t\t\t\t\tend\n\t\t\t\tend \n\t\t\telse \n\t\t\t\t# if no tie, tie should be zero\n\t\t\t\t@tie_1[i] = 0\n\t\t\t\t@tie_2[i] = 0\n\t\t\tend\n\n\t\tend # Ends the loop for the different types of tied hands \n\n\tend",
"def tie(board)\n board.spaces_array.all? { |s| s == \"X\" || s == \"O\" } && !winner(board)\n end",
"def winner \n @board[won?[0]] if won?\n end",
"def game_is_over(board)\n someone_wins(board) || tie(board)\n end",
"def winner(player, comp)\n return 'tie' if player == comp\n if player == 'rock'\n comp == 'scissors' ? 'player' : 'comp'\n elsif player == 'paper'\n comp == 'rock' ? 'player' : 'comp'\n else # player = scissors\n comp == 'rock' ? 'comp' : 'player'\n end\nend",
"def winner()\n if won?()\n win = won?()\n if @board[win[0]] == \"X\"\n return \"X\"\n elsif @board[win[0]] == \"O\"\n return \"O\"\n else @board[win[0]] != \"X\" && @board[win[0]] != \"O\" #srsly..this is like ducttape over a huge hole\n return nil\n end\n end\nend",
"def high_ranking_cards\n\n cards.find_all do |card|\n card.rank >= 11\n end\n end",
"def find_winner\n\t\t@counter = 0\n\t\[email protected] do |player|\n\t\t\tif player.points > @winning\n\t\t\t\t@winner = @counter + 1\n\t\t\tend\n\t\t\t@counter += 1\n\t\tend\n\t\treturn @winner\n\tend",
"def check_for_winner\n \tcollect_winning_positions.each do |position| \t\t\n \t\tif position == \"OOO\"\n \t\t return 2 \t\t\n \t\telsif position == \"XXX\" \n \t return 1 \t\t \n \t\tend \t\n \tend\n \tcat_game? == true ? 0 : -1\n end",
"def winner\n if finished?\n if fold = @hand_history.all_actions.find(&:fold?)\n winner = (fold.player == small_blind) ? big_blind : small_blind\n else\n winner = if PokerHand.new( small_blind.hole_cards + @community_cards ) > PokerHand.new( big_blind.hole_cards + @community_cards )\n small_blind\n else\n big_blind\n end\n end\n else\n nil\n end\n end",
"def set_determine_set_winner()\n if @score_count > @other_score_count\n @set_winner = 1\n\n elsif @score_count < @other_score_count\n @set_winner = 2\n \n else @score_count == @other_score_count\n @set_winner = 0\n end\n end",
"def winner(game)\nwinner = \"\"\nwinner_points = 0\n game.each do |team, team_contents|\n total = 0\n team_contents[:roster].each do |player, player_contents| \n total += player_contents[:points]\n end\n if total > winner_points\n winner = team_contents[:team_name]\n winner_points = total\n elsif total == winner_points\n winner = \"tie\"\n end\n end\n\n if winner == \"tie\"\n puts \"The game was a tie, with each team scoring #{winner_points} points\"\n else\n puts \"#{winner} scored #{winner_points} points and won the game\"\n end\nend",
"def choose_winner; end",
"def winner\n if finished?\n @players.each do|key,score|\n if score.sum >=@length\n return key\n end\n end\n else\n nil\n end\n end",
"def main_game\n p1_wins = 0\n p2_wins = 0\n puts \"Let's play Rock-Paper-Scissors!\"\n games = how_many_games\n best_of(games)\n\n until p1_wins == games || p2_wins == games\n winner = one_round\n display_winner(winner)\n p1_wins += track_p1_wins(winner)\n p2_wins += track_p2_wins(winner)\n end\n\n overall_winner = overall_winner?(p1_wins, p2_wins)\n display_overall_winner(overall_winner)\nend",
"def outcome_score(theirs, mine)\n return 3 if (theirs == 'A' && mine == 'X') || (theirs == 'B' && mine == 'Y') || (theirs == 'C' && mine == 'Z') # tie\n return 6 if (theirs == 'A' && mine == 'Y') || (theirs == 'B' && mine == 'Z') || (theirs == 'C' && mine == 'X') # win\n 0 # lose\nend",
"def winner(board)\n if !(won?(board))\n return nil\n elsif won?(board).all?{|element| board[element] == \"X\"}\n return \"X\"\n elsif won?(board).all?{|element| board[element] == \"O\"}\n return \"O\"\n end\nend",
"def is_high_card( hand )\n\treturn hand.map { | e | card_value( e ) }.max\nend",
"def calculate_winner\n self.winner = case human.move <=> computer.move\n when 1\n human\n when -1\n computer\n when 0\n 'tie'\n end\n end",
"def determine_winner\n if @current_moves[0] == @current_moves[1]\n \t\tputs \"We have a tie!\"\n \telsif ((@current_moves[0] == \"Rock\") && (@current_moves[1] == \"Scissors\")) \n \t\tputs \"#{player_1.name} wins - #{@current_moves[0]} crushes #{@current_moves[1]}\"\n @winner = @player_1\n player_1.games_won\n \telsif ((@current_moves[0] == \"Scissors\") && (@current_moves[1] == \"Paper\")) \n \t\tputs \"#{player_1.name} wins - #{@current_moves[0]} cuts #{@current_moves[1]}\"\n @winner = @player_1\n player_1.games_won\n \telsif ((@current_moves[0] == \"Paper\") && (@current_moves[1] == \"Rock\"))\n \t\tputs \"#{player_1.name} wins - #{@current_moves[0]} covers #{@current_moves[1]}\"\n @winner = @player_1\n player_1.games_won\n \telse\n \t\tputs \"#{player_2.name} wins - #{@current_moves[1]} beats #{@current_moves[0]}\"\n @winner = @player_2\n player_2.games_won\n \tend\n end",
"def winner(board)\n # returns X when X won, O when O won and nill when there is no winner\n if (draw?(board) || !full?(board)) && !won?(board)\n return nil\n elsif (board[won?(board)[0]] == \"X\")\n return \"X\"\n elsif (board[won?(board)[0]] == \"O\")\n return \"O\"\n end\nend",
"def print_game_result\n # Winners stored in list in case of tie\n winners = []\n highestScore = @player_list[0].score\n\n # Determine who has the highest score\n @player_list.each do |player|\n\n # Highest score thus far is matched\n if highestScore == player.score\n winners.append(player.name)\n # Highest score is beaten\n elsif highestScore < player.score\n # Empty list of winners\n winners.clear\n # Add the current winner's name to the winner list\n winners.append(player.name)\n # Update current high score\n highestScore = player.score\n end\n\n end\n\n # Print the winner(s)\n if winners.size > 1\n puts(\"It's a tie! The winners:\")\n else\n puts(\"Winner:\")\n end\n\n winners.each { |winner| puts(winner) }\n end",
"def winner\n if won?\n @board[won?[0]]\n end\n end",
"def determine_match_winner\n @games_to_win = ((total_number_of_games / 2.0).floor) + 1\n if player1.score == games_to_win\n return player1\n elsif player2.score == games_to_win\n return player2\n else\n return nil\n end\n end",
"def hand_score\n cards.map {|a| a.value}.sort {|a,b| a <=> b}.last\n end",
"def check_who_wins(hand_total_dealer, hand_total_player)\n hand_to_use_dealer = 0\n hand_to_use_player = 0\n\n if hand_total_dealer[1] <= 21\n hand_to_use_dealer = hand_total_dealer[1]\n else\n hand_to_use_dealer = hand_total_dealer[0]\n end\n\n if hand_total_player[1] <= 21\n hand_to_use_player = hand_total_player[1]\n else\n hand_to_use_player = hand_total_player[0]\n end\n\n if hand_to_use_player < hand_to_use_dealer\n return \"dealer\"\n elsif hand_to_use_dealer < hand_to_use_player\n return \"player\"\n elsif hand_to_use_player = hand_to_use_dealer\n return \"draw\"\n end\n\nend",
"def winner(board)\n if (over?(board))\n if (board[won?(board)[0]] == \"X\")\n return \"X\"\n else\n return \"O\"\n end\n else\n end\n end",
"def winner(board)\n if !won?(board)\n return nil\n else board[won?(board)[0]]\n end\nend",
"def most_points_scored\n most_points = 0\n leading_scorer = \"\"\n\n game_hash.values.each do |roster|\n roster[:players].each do |player|\n if player[:points] > most_points\n most_points = player[:points]\n leading_scorer = player[:player_name]\n end\n end\n end\n return leading_scorer\nend",
"def check_score\n if @player_1.lose\n winner(@player_2)\n elsif @player_2.lose\n winner(@player_1)\n end\n end",
"def winner\n if (win?(player) == true) && (win?(dealer) == false)\n show_hands_final\n puts \"#{player.name} wins!!!\\n\" ;player.score += 1\n elsif (win?(dealer) == true) && (win?(player) == false)\n show_hands_final\n puts \"#{dealer.name} wins!!!\\n\" ;dealer.score += 1\n elsif (win?(player) == \"Bust\") || (win?(dealer) == \"Bust\")\n show_hands_final\n puts \"#{player.name} and #{dealer.name} busted. It's a tie!\\n\"\n elsif win?(player) == \"Tie\"\n show_hands_final\n if player.hand_count > dealer.hand_count\n puts \"\\n#{player.name} and #{dealer.name} both show #{player.hand_total}.\\n\\n#{player.name} wins with #{player.hand.length} cards!!!\"\n player.score += 1\n elsif dealer.hand_count > player.hand_count\n puts \"\\n#{player.name} and #{dealer.name} both show #{player.hand_total}.\\n\\nDealer wins with #{dealer.hand.length} cards!!!\"\n dealer.score += 1\n else\n puts \"\\n#{player.name} and #{dealer.name} both show #{player.hand_total}.\\n\\n#{player.name} wins since both players have #{player.hand.length} cards!!!\\n\"\n player.score += 1\n end\n end\n again?\n end",
"def winner(board)\n if !won?(board) == false\n board[won?(board).first]\n end\nend",
"def winner(board)\n won?(board) ? board[won?(board)[0]] : nil\nend",
"def winner\n return @board[won?[0]] if won?\n end",
"def winner\n if !won?\n nil\n else winner = @board[won?[0]]\n\n end\n\n end",
"def winner()\n if won?()\n return @board[won?()[0]]\n end\n return nil\n end",
"def winner(board)\n if won?(board) && board[won?(board)[0]] == \"X\"\n return \"X\"\n elsif won?(board) && board[won?(board)[0]] == \"O\"\n return \"O\"\n end\nend",
"def next_move\n moves.max{ |a, b| a.rank <=> b.rank }\n end",
"def check_score()\n if @player_score > @highest_score\n @highest_score = @player_score\n p \"BEAT THAT!\"\n puts\n @players_joined.rotate!()\n roll(@dice)\n elsif @player_score == @highest_score\n @draw = true\n end_game()\n else\n @won = true\n end_game()\n end\n end",
"def break_tie(other_hand) \n mycards = self.tie_breaker_cards\n othertb = other_hand.tie_breaker_cards\n stop = mycards.size\n for i in (0...stop) do\n res = mycards[i] <=> othertb[i]\n # Tie is broken\n # Note that wildcards will retain their own value\n # This means that, for example if deuces are wild,\n # a K K K three of a kind will beat a K K 2 three of a kind \n return res if res != 0 \n end \n # If we came here it's a split pot\n return 0\n end",
"def winner\n\n if type == :basic\n if @player_1.deck.cards[0].rank > @player_2.deck.cards[0].rank\n return @player_1\n else\n return @player_2\n end\n elsif type == :mutually_assured_destruction\n return \"No winner.\"\n elsif type == :war\n if @player_1.deck.cards[2].rank > @player_2.deck.cards[2].rank\n return @player_1\n else\n return @player_2\n end\n end\n end",
"def most_likely_play\n @must_learn = true\n best_move = nil\n max = 0\n\n search_space = SearchSpace.new(@board, @most_alike_board, @color)\n search_space.each do |move|\n prob = probability_of(move)\n return move if prob >= Config::PROBS_THRESHOLD\n if max < prob\n max = prob\n best_move = move\n end\n end\n\n best_move\n end",
"def high_ranking_cards\n high_cards = []\n @cards.each do|card|\n if card.rank >= 11\n high_cards << card\n end\n end\n high_cards\n end",
"def <=> card\r\n if rank_of_colour > card.rank_of_colour\r\n return 1\r\n end\r\n if rank_of_colour < card.rank_of_colour\r\n return -1\r\n end\r\n\r\n if rank_of_colour == card.rank_of_colour\r\n notify_observers_fraud card.to_string\r\n #return 0 # should not happen in a Noddy card game!\r\n end\r\n end",
"def frame?\n current_frame = []\n @scorecard.each do |key, value|\n current_frame << key if value.framescore[:roll_1].nil? || value.framescore[:roll_2].nil?\n end\n current_frame.sort\n # to get the current frame as an integer, use this:\n # p current_frame[0][-1].to_i\n current_frame[0]\n end",
"def best_taken_card(take_it)\r\n @log.debug(\"calculate best_taken_card\") \r\n w_cards = []\r\n take_it.each do |card_lbl|\r\n card_s = card_lbl.to_s # something like '_Ab'\r\n segno = card_s[2,1] # character with index 2 and string len 1\r\n curr_w = 0\r\n curr_w += 200 if card_s[2] == @briscola.to_s[2]\r\n # check if it is an asso or 3\r\n curr_w += 0 if card_s[1] == \"A\"[0]\r\n curr_w += 5 if card_s[1] == \"3\"[0] \r\n if card_s =~ /[24567]/\r\n # liscio value\r\n lisc_val = (card_s[1] - '0'[0]).to_i\r\n curr_w += 70 + lisc_val\r\n end\r\n curr_w += 40 if card_s[1] == \"F\"[0]\r\n # mariazza is possible?, horse and king has a different value\r\n if card_s[1] == \"C\"[0]\r\n if is_mariazz_possible?(segno)\r\n curr_w += 290\r\n else\r\n curr_w += 30\r\n end\r\n end \r\n if card_s[1] == \"R\"[0]\r\n if is_mariazz_possible?(segno)\r\n curr_w += 300\r\n else\r\n curr_w += 20\r\n end\r\n end\r\n w_cards << [card_lbl, curr_w ] \r\n end\r\n # find a minimum\r\n #p w_cards\r\n min_list = w_cards.min{|a,b| a[1]<=>b[1]}\r\n @log.debug(\"Best card to play on best_taken_card is #{min_list[0]}, w_cards = #{w_cards.to_s}\")\r\n return min_list\r\n end",
"def winner\n case\n when in_checkmate?(1)\n 2\n when in_checkmate?(2)\n 1\n else\n nil\n end\n end",
"def >(rhs)\n if @rank == rhs.rank\n if @rank == 0\n #compare highest cards\n if @cards[4] == rhs.cards[4]\n if @cards[3] == rhs.cards[3]\n if @cards[2] == rhs.cards[2]\n if @cards[1] == rhs.cards[1]\n return @cards[0] > rhs.cards[0]\n else\n return @cards[1] > rhs.cards[1]\n end\n else\n return @cards[2] > rhs.cards[2]\n end\n else\n return @cards[3] > rhs.cards[3]\n end\n else\n return @cards[4] > rhs.cards[4]\n end\n elsif @rank == 1\n #find higher pair\n return @cards[@handStart] > rhs.cards[rhs.handStart]\n elsif @rank == 2\n #find higher pair\n if @cards[@handStart] == rhs.cards[rhs.handStart]\n return @cards[@handSubstart] > rhs.cards[rhs.handSubstart]\n else\n return @cards[@handStart] > rhs.cards[rhs.handStart]\n end\n elsif @rank == 3\n #find higher triplet\n return @cards[@handStart] > rhs.cards[rhs.handStart]\n elsif @rank == 4\n #find higher straight\n return @cards[0] > rhs.cards[0]\n elsif @rank == 5\n #find higher flush\n return @cards[4] > rhs.cards[4]\n elsif @rank == 6\n #find higher full house\n if @handSubstart == 3\n if rhs.handSubstart == 3\n #both trips in front\n if @cards[@handStart] == rhs.cards[rhs.handStart]\n return @cards[@handSubstart] > rhs.cards[rhs.handSubstart]\n else\n return @cards[@handStart] > rhs.cards[rhs.handStart]\n end\n else\n #trip in front vs trip in back\n if @cards[@handStart] == rhs.cards[rhs.handSubstart]\n return @cards[@handSubstart] > rhs.cards[rhs.handStart]\n else\n return @cards[@handStart] > rhs.cards[rhs.handSubstart]\n end\n end\n elsif @handSubstart == 2\n #both trips in back\n if rhs.handSubstart == 2\n if @cards[@handSubstart] == rhs.cards[rhs.handSubstart]\n return @cards[@handStart] > rhs.cards[rhs.handStart]\n else\n return @cards[@handSubstart] > rhs.cards[rhs.handSubstart]\n end\n else\n #trip in back vs trip in front\n if @cards[@handSubstart] == rhs.cards[rhs.handStart]\n return @cards[@handStart] > rhs.cards[rhs.handSubstart]\n else\n return @cards[@handSubstart] > rhs.cards[rhs.handStart]\n end\n end\n \n end\n elsif @rank == 7\n #find higher quadruplet\n return @cards[self.handStart] > rhs.cards[rhs.handStart]\n elsif @rank == 8\n #find higher straight flush\n return @cards[0] > rhs.cards[0]\n elsif @rank == 9\n #find higher royal flush\n end\n else\n return @rank > rhs.rank\n end\n end",
"def best_leaveit_card(leave_it)\r\n @log.debug(\"calculate best_leaveit_card\") \r\n w_cards = []\r\n leave_it.each do |card_lbl|\r\n card_s = card_lbl.to_s # something like '_Ab'\r\n segno = card_s[2,1] \r\n\r\n curr_w = 0\r\n curr_w += 200 if card_s[2] == @briscola.to_s[2]\r\n curr_w += 500 if card_s[1] == \"A\"[0]\r\n curr_w += 400 if card_s[1] == \"3\"[0] \r\n curr_w += 300 if card_s[1] == \"R\"[0] \r\n curr_w += 280 if card_s[1] == \"C\"[0] \r\n curr_w += @deck_info.get_card_info(card_lbl)[:rank]\r\n\r\n w_cards << [card_lbl, curr_w ]\r\n end\r\n min_list = w_cards.min{|a,b| a[1]<=>b[1]}\r\n @log.debug(\"Best card to play on leave it cards is #{min_list[0]}, w_cards = #{w_cards.to_s}\")\r\n return min_list[0]\r\n end",
"def winner\n scoreboard.first\n end",
"def print_which_player_wins player_picked, comp_picked\n if player_picked == comp_picked\n puts \"It's a tie!\"\n elsif player_picked == \"Paper\"\n if comp_picked == \"Rock\"\n puts \"Paper wraps Rock, you win!\"\n elsif comp_picked == \"Scissors\"\n puts \"Scissors cuts Paper, you lose!\"\n end\n elsif player_picked == \"Rock\"\n if comp_picked == \"Paper\"\n puts \"Paper wraps Rock, you lose!\"\n elsif comp_picked == \"Scissors\"\n puts \"Rock crushes Scissors, you win!\"\n end\n elsif player_picked == \"Scissors\"\n if comp_picked == \"Paper\"\n puts \"Scissors cut Paper, you win!\"\n elsif comp_picked == \"Rock\"\n puts \"Rock crushes Scissors, you lose!\"\n end\n end\nend",
"def winner\n @hash.key(@hash.values.max)\n end"
] | [
"0.7342422",
"0.7073065",
"0.7052118",
"0.7051302",
"0.6945214",
"0.6929667",
"0.6888874",
"0.68515146",
"0.67931986",
"0.6705846",
"0.66058344",
"0.6581559",
"0.6573646",
"0.65641254",
"0.6558619",
"0.65416425",
"0.6507286",
"0.65065646",
"0.6499011",
"0.64841187",
"0.6480823",
"0.64696085",
"0.6467729",
"0.6453871",
"0.64301664",
"0.6415288",
"0.6407457",
"0.6405602",
"0.64036685",
"0.63886124",
"0.6384378",
"0.63754916",
"0.6353296",
"0.63480705",
"0.63446116",
"0.6342353",
"0.63404787",
"0.6338865",
"0.63284504",
"0.63280016",
"0.63187665",
"0.63077974",
"0.6293102",
"0.6290978",
"0.6288057",
"0.62866515",
"0.6278023",
"0.6271174",
"0.6265365",
"0.6261876",
"0.625324",
"0.6252301",
"0.6250537",
"0.6245406",
"0.6241724",
"0.6238884",
"0.6237667",
"0.6229517",
"0.62199795",
"0.6208836",
"0.6204227",
"0.6202225",
"0.6201225",
"0.6199903",
"0.6198946",
"0.6194183",
"0.61938876",
"0.61917514",
"0.6188475",
"0.6185508",
"0.6183049",
"0.61819637",
"0.6176213",
"0.6174958",
"0.61742383",
"0.61738354",
"0.61672497",
"0.6166721",
"0.6166265",
"0.61654466",
"0.6165243",
"0.6164705",
"0.6157721",
"0.61531705",
"0.6152922",
"0.6151869",
"0.6148497",
"0.61410856",
"0.6134031",
"0.61300606",
"0.61289686",
"0.6127925",
"0.61219674",
"0.6118985",
"0.6112835",
"0.61124897",
"0.611023",
"0.6101421",
"0.61013895",
"0.60976875",
"0.60940355"
] | 0.0 | -1 |
Add a request (API object) to batch | def << req
raise ArgumentError.new("argument should be an instance of Diffbot::APIClient::GenericAPI") unless req.is_a?(Diffbot::APIClient::GenericAPI)
@list << req
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_request( request )\n @thePosts << request\n end",
"def add_request(request)\n requests << request\n true\n end",
"def batch_create(request = nil, manifest: nil, items: nil, **opt)\n self.request = request ||= pre_flight(manifest, items, **opt)\n self.start_time = request[:start_time] ||= timestamp\n opt[:manifest_id] = request[:manifest_id] ||= manifest\n result_data = submit_batch(**opt)\n self.end_time = timestamp\n self.result = post_flight(result_data, **opt)\n end",
"def batch(request, request_options = {})\n client.post(Protocol.batch_uri(name), request.to_json, :batch, request_options)\n end",
"def add_requests\n @request = Requests.new(@txn_name, self.config, self.name, self.probability, self.type)\n end",
"def batch(*requests)\n Batch.new(requests)\n end",
"def add_to_batch_with_http_info(batch_id, add_to_batch_request_body, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: BatchesApi.add_to_batch ...'\n end\n # verify the required parameter 'batch_id' is set\n if @api_client.config.client_side_validation && batch_id.nil?\n fail ArgumentError, \"Missing the required parameter 'batch_id' when calling BatchesApi.add_to_batch\"\n end\n if @api_client.config.client_side_validation && batch_id.to_s.length > 25\n fail ArgumentError, 'invalid value for \"batch_id\" when calling BatchesApi.add_to_batch, the character length must be smaller than or equal to 25.'\n end\n\n if @api_client.config.client_side_validation && batch_id.to_s.length < 1\n fail ArgumentError, 'invalid value for \"batch_id\" when calling BatchesApi.add_to_batch, the character length must be great than or equal to 1.'\n end\n\n pattern = Regexp.new(/^se(-[a-z0-9]+)+$/)\n if @api_client.config.client_side_validation && batch_id !~ pattern\n fail ArgumentError, \"invalid value for 'batch_id' when calling BatchesApi.add_to_batch, must conform to the pattern #{pattern}.\"\n end\n\n # verify the required parameter 'add_to_batch_request_body' is set\n if @api_client.config.client_side_validation && add_to_batch_request_body.nil?\n fail ArgumentError, \"Missing the required parameter 'add_to_batch_request_body' when calling BatchesApi.add_to_batch\"\n end\n # resource path\n local_var_path = '/v1/batches/{batch_id}/add'.sub('{' + 'batch_id' + '}', CGI.escape(batch_id.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['text/plain', 'application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] || @api_client.object_to_http_body(add_to_batch_request_body) \n\n # return_type\n return_type = opts[:return_type] || 'String' \n\n # auth_names\n auth_names = opts[:auth_names] || ['api_key']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: BatchesApi#add_to_batch\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def batch_update(request = nil, manifest: nil, items: nil, **opt)\n self.request = request ||= pre_flight(manifest, items, **opt)\n self.start_time = request[:start_time] ||= timestamp\n opt[:manifest_id] = request[:manifest_id] ||= manifest\n result_data = submit_batch(**opt)\n self.end_time = timestamp\n self.result = post_flight(result_data, **opt)\n end",
"def batch!(request, request_options = {})\n res = batch(request, request_options)\n wait_task(res['taskID'], WAIT_TASK_DEFAULT_TIME_BEFORE_RETRY, request_options)\n res\n end",
"def add_item_request(item)\n if(@item_requests.has_key?(item.id))\n #error\n else\n @item_requests[item.id]=item\n end\n end",
"def register_batch_request_with_http_info(batch_request, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SystemAdministrationConfigurationNSXManagersAPIServicesAPIRequestBatchingApi.register_batch_request ...'\n end\n # verify the required parameter 'batch_request' is set\n if @api_client.config.client_side_validation && batch_request.nil?\n fail ArgumentError, \"Missing the required parameter 'batch_request' when calling SystemAdministrationConfigurationNSXManagersAPIServicesAPIRequestBatchingApi.register_batch_request\"\n end\n # resource path\n local_var_path = '/batch'\n\n # query parameters\n query_params = {}\n query_params[:'atomic'] = opts[:'atomic'] if !opts[:'atomic'].nil?\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(batch_request)\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'BatchResponse')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SystemAdministrationConfigurationNSXManagersAPIServicesAPIRequestBatchingApi#register_batch_request\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def add_request(request)\n @requests[request.floor] = { direction: request.direction }\n self\n end",
"def add_request(timestamp)\n # add to total requests\n @total_requests += 1\n @logger.debug(\"Pushing timestamp: #{Time.at(timestamp).to_s}\")\n @queue.push(timestamp)\n end",
"def store_request(request)\n @requests_lock.synchronize { @requests << request } if @keep_requests\n end",
"def add(item)\n @batch << item\n execute if ready?\n end",
"def add_objects(objects, request_options = {})\n batch(build_batch('addObject', objects, false), request_options)\n end",
"def add(request, &callback)\n @requests << request\n @callbacks[request] = callback if callback\n true\n end",
"def batch\n req = create_batch_request\n if block_given?\n yield req\n req.execute\n else\n req\n end\n end",
"def queue(request)\n request.hydra = self\n queued_requests << request\n end",
"def <<(item)\n @batch << item\n end",
"def bulk_insert request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_bulk_insert_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end",
"def batch_new\n end",
"def increment(request_id, value)\n unless has_request_id? request_id\n self.counts[actor][\"total\"] += value\n self.counts[actor][\"requests\"] << request_id\n end\n end",
"def add_request meth, uri\n props = {\n MrBelvedere::Fields::HTTP_METHOD => meth.to_s.downcase,\n MrBelvedere::Fields::REQUEST_URI => uri.to_s,\n MrBelvedere::Fields::CURRENT_TIME => Familia.now\n }.merge @props\n requests.unshift props # add to the end so we can read in reverse-chronological\n end",
"def register_batch_request(batch_request, opts = {})\n data, _status_code, _headers = register_batch_request_with_http_info(batch_request, opts)\n data\n end",
"def make_batch_request(batch_client, resource_name, method_name, params = {})\n end",
"def add_objects!(objects, request_options = {})\n res = add_objects(objects, request_options)\n wait_task(res['taskID'], WAIT_TASK_DEFAULT_TIME_BEFORE_RETRY, request_options)\n res\n end",
"def add_request_if_new\n last_request = session.requests.last\n maybe_next_request = yield(last_request)\n session.requests << maybe_next_request unless (\n maybe_next_request.nil? or maybe_next_request.equal?(last_request)\n )\n self\n end",
"def batch options = {}\n Diffbot::APIClient::Batch.new self, options\n end",
"def add_other(instance)\n # Throw error when instance has empty channel\n fail ::ArgumentError, 'Channel is required' unless instance.channel\n\n # Add\n requests << instance\n end",
"def add(active_jobs = nil, &block)\n record.save if record.new_record?\n\n buffer = Bulk::Buffer.new\n buffer.add(active_jobs)\n buffer.capture(&block) if block\n\n self.class.within_thread(batch_id: id) do\n buffer.enqueue\n end\n\n buffer.active_jobs\n end",
"def add(data)\n \n # selecting all records, skipping old ones.\n result = @db.get_first_row \"SELECT id, counter FROM requests WHERE domain=:domain AND request=:request AND status=:status AND referer=:referer AND ip=:ip AND first_seen<=:first_seen\",\n 'domain' => data[:domain],\n 'request' => data[:request],\n 'referer' => data[:referer],\n 'status' => data[:status],\n 'ip' => data[:ip],\n 'first_seen' => $config.detection['max_period'].seconds.ago.to_i\n # adding new request, overwriting too old ones.\n if result.nil?\n @db.execute \"INSERT OR REPLACE INTO requests (domain, request, referer, status, ip, first_seen, last_seen, counter) \n VALUES (:domain, :request, :referer, :status, :ip, strftime('%s','now'), strftime('%s','now'), 1)\",\n 'domain' => data[:domain],\n 'request' => data[:request],\n 'referer' => data[:referer],\n 'status' => data[:status],\n 'ip' => data[:ip]\n else\n # Look, Ma! We got fresh requests\n @db.execute \"UPDATE requests SET last_seen = strftime('%s','now'), counter = counter+1 WHERE id = ?\", result['id']\n end\n end",
"def batch(*requests)\n body = requests.map do |request|\n {method: request[0], params: request[1..-1], jsonrpc: '2.0', id: SecureRandom.uuid}\n end\n parsed_response = parse_response(post(body))\n errors = parsed_response.select{|response| response[:error]}\n raise Error, errors if !errors.empty?\n parsed_response.map{|response| response[:result]}\n end",
"def add(hash)\n batch << hash\n\n if batch.count % batch_size == 0\n solr_service_connection.add(batch, softCommit: soft_commit, commit: commit)\n batch.clear\n end\n end",
"def add_to_pending(packet)\n @pending_requests[packet.id] = {\n :packet => packet,\n :time => Time.now\n }\n end",
"def add_object!(object, objectID = nil, request_options = {})\n res = add_object(object, objectID, request_options)\n wait_task(res['taskID'], WAIT_TASK_DEFAULT_TIME_BEFORE_RETRY, request_options)\n res\n end",
"def log_request\n result = super\n push_outstanding_request\n result\n end",
"def update!(**args)\n @requests = args[:requests] if args.key?(:requests)\n end",
"def update!(**args)\n @requests = args[:requests] if args.key?(:requests)\n end",
"def update!(**args)\n @requests = args[:requests] if args.key?(:requests)\n end",
"def update!(**args)\n @requests = args[:requests] if args.key?(:requests)\n end",
"def insert request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n uri, body, query_string_params = transcode_insert_request request_pb\n response = @client_stub.make_post_request(\n uri: uri,\n body: body,\n params: query_string_params,\n options: options\n )\n result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, response if block_given?\n result\n end",
"def insert request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n uri, body, query_string_params = transcode_insert_request request_pb\n response = @client_stub.make_post_request(\n uri: uri,\n body: body,\n params: query_string_params,\n options: options\n )\n result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, response if block_given?\n result\n end",
"def send_request\n request = Request.new(@floor, @direction)\n @elevator.requests_queue.append(request)\n end",
"def iid_v1batch_add_post_with_http_info(inline_object, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: RelationshipMapsApi.iid_v1batch_add_post ...'\n end\n # verify the required parameter 'inline_object' is set\n if @api_client.config.client_side_validation && inline_object.nil?\n fail ArgumentError, \"Missing the required parameter 'inline_object' when calling RelationshipMapsApi.iid_v1batch_add_post\"\n end\n # resource path\n local_var_path = '/iid/v1:batchAdd'\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = @api_client.object_to_http_body(inline_object)\n auth_names = ['ServerKey']\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'InlineResponse200')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: RelationshipMapsApi#iid_v1batch_add_post\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def create_batch_with_http_info(create_batch_request_body, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: BatchesApi.create_batch ...'\n end\n # verify the required parameter 'create_batch_request_body' is set\n if @api_client.config.client_side_validation && create_batch_request_body.nil?\n fail ArgumentError, \"Missing the required parameter 'create_batch_request_body' when calling BatchesApi.create_batch\"\n end\n # resource path\n local_var_path = '/v1/batches'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] || @api_client.object_to_http_body(create_batch_request_body) \n\n # return_type\n return_type = opts[:return_type] || 'CreateBatchResponseBody' \n\n # auth_names\n auth_names = opts[:auth_names] || ['api_key']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: BatchesApi#create_batch\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def add_thing(thing)\n enqueue(thing)\n end",
"def add_item(item)\n @in_batch << item\n @in_count += 1\n @in_size += @size_of_item_proc.call(item)\n end",
"def post_request(object)\n end",
"def send_batch_request(batch)\n post_data = batch.to_json\n resp = RestClient.post(@url, post_data, content_type: 'application/json', user_agent: \"syncano-ruby-#{Syncano::VERSION}\")\n if resp.nil? || resp.body.nil? || resp.body.empty?\n raise Jimson::ClientError::InvalidResponse.new\n end\n\n return resp.body\n end",
"def perform(&block)\n raise Exception.new(\"You must have at least 2 requests\") unless @requests.length > 1\n @responses.clear\n requests.each_slice(Limit).to_a.each do |batch|\n body = {\n :batch => Yajl::Encoder.encode(batch),\n :access_token => Baloo.client_credentials\n }\n Client.post(\"/\", :body => body).each do |response|\n # response['headers'] = Yajl::Parser.parse(response['headers'])\n response['body'] = Yajl::Parser.parse(response['body'])\n yield response\n end\n end\n end",
"def batch_params\n params.require(:batch).permit(:item_id, :user_id, :count)\n end",
"def add(req)\n if req.requirement.exact?\n @exact.push req\n else\n @list.push req\n end\n req\n end",
"def each_request(&block)\n\t\trequests.each do |request|\n\t\t\tblock.call(request)\n\t\tend\n\tend",
"def each_request(&block)\n\t\trequests.each do |request|\n\t\t\tblock.call(request)\n\t\tend\n\tend",
"def request(method, *args, &response_cb)\n reqid = @request_id\n @request_id += 1\n\n @serializer.write([0, reqid, method, args])\n @pending_requests[reqid] = response_cb || Proc.new {}\n self\n end",
"def insert request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n verb, uri, query_string_params, body = ServiceStub.transcode_insert_request request_pb\n query_string_params = if query_string_params.any?\n query_string_params.to_h { |p| p.split \"=\", 2 }\n else\n {}\n end\n\n response = @client_stub.make_http_request(\n verb,\n uri: uri,\n body: body || \"\",\n params: query_string_params,\n options: options\n )\n operation = ::Gapic::Rest::TransportOperation.new response\n result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, operation if block_given?\n result\n end",
"def add(params = {})\n perform_request 'Add', params\n end",
"def add_search_request(search_request)\n if (@search_requests.has_key?(search_request.id))\n #error\n else\n @search_requests[search_request.id]= search_request\n Event::ItemUpdateEvent.add_handler search_request\n end\n end",
"def queue_request(kind, type, payload, target, callback)\n request = {:kind => kind, :type => type, :payload => payload, :target => target, :callback => callback}\n Log.info(\"[offline] Queuing request: #{request.inspect}\")\n vote_to_restart if (@restart_vote_count += 1) >= MAX_QUEUED_REQUESTS\n if @state == :initializing\n # We are in the initialization callback, requests should be put at the head of the queue\n @queue.unshift(request)\n else\n @queue << request\n end\n true\n end",
"def send_request method, params, &block\n message = {\n jsonrpc: \"2.0\",\n method: method,\n params: params,\n id: @next_request_id\n }\n json = message.to_json\n requests[@next_request_id] = Request.new(@next_request_id, &block)\n envelope = \"Content-Length: #{json.bytesize}\\r\\n\\r\\n#{json}\"\n queue envelope\n @next_request_id += 1\n end",
"def add_add_on_nr(key, to_add)\n if (@is_commit)\n raise RuntimeError.new('No further request supported after a commit!')\n end\n @requests << {'add_on_nr' => {key => to_add}}\n self\n end",
"def log_request\n bin = Bin.find_by({ url: request.params['bin_url'] })\n @incoming_request = Request.new({\n payload: request.raw_post,\n bin_id: bin.id,\n http_method: request.method\n })\n\n respond_to do |format|\n if @incoming_request.save!\n if !@incoming_request.bin.webhook_url.blank? # TODO: clean up this logic a bit\n RequestForwardingJob.perform_later @incoming_request, bin.webhook_url\n end\n\n ActionCable.server.broadcast(\n \"request_channel_#{bin.url}\", @incoming_request\n )\n\n format.json { render json: {}, status: :created }\n else\n format.json { render json: @bin.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add(request) \n new_data = request.data\t \n @model.create(new_data)\t\t\t\n response = DSResponse.new\n response.data = new_data\n response.status = 0 \n return response\n end",
"def batch_write_item(request_options)\n request_options[:request_items].each do |table_name, requests|\n table = get_table(table_name)\n\n requests.each do |request_hash|\n if request_hash[:put_request]\n item = request_hash[:put_request][:item].symbolize_keys\n hash_key_value = item[hash_key_attr]\n if range_key_attr.present?\n range_key_value = item[range_key_attr]\n table[hash_key_value] = {} if table[hash_key_value].nil?\n table[hash_key_value][range_key_value] = item\n else\n table[hash_key_value] = item\n end\n else\n item = request_hash[:delete_request][:key]\n id = item[hash_key_attr]\n table.delete(id)\n end\n end\n end\n end",
"def batch_params\n params.require(:batch).permit(:id, :date_collected, :count_total, :contributions_num, :comments)\n end",
"def build\n add_access_request\n add_track_request\n end",
"def add_object(object, objectID = nil, request_options = {})\n check_object(object)\n if objectID.nil? || objectID.to_s.empty?\n client.post(Protocol.index_uri(name), object.to_json, :write, request_options)\n else\n client.put(Protocol.object_uri(name, objectID), object.to_json, :write, request_options)\n end\n end",
"def queue_front(request)\n request.hydra = self\n queued_requests.unshift request\n end",
"def create_request\n Effective::QbRequest.new_requests_for_unsynced_items.first\n end",
"def request(object, method, args, options={})\n ResqueHandler.queue = options[:queue] || DEFAULT_QUEUE\n instance, id = instance_identifiers(object)\n ::Resque.enqueue(ResqueHandler, instance, id, method, *args)\n end",
"def send_batch(batch)\n return if batch.empty?\n json_package = JSON.generate(batch.map { |c| c.output_hash })\n begin\n resp = @http_client.post @solr_update_url, json_package, \"Content-type\" => \"application/json\"\n rescue StandardError => exception\n end\n\n if exception || resp.status != 200\n error_message = exception ? \n Traject::Util.exception_to_log_message(exception) : \n \"Solr response: #{resp.status}: #{resp.body}\"\n\n logger.error \"Error in Solr batch add. Will retry documents individually at performance penalty: #{error_message}\"\n \n batch.each do |c|\n send_single(c)\n end\n end\n end",
"def request(user_id, chunk_id)\n \n end",
"def new_entry(entry)\n BatchEntries.create(\n batch_registries_id: @current_batch_registry.id,\n payload: entry.to_json,\n complete: false,\n error: false,\n current_status: 'registered'\n )\n end",
"def set_batch\n # Находим данные объекта Batch по id\n @batch = Batch.find(params[:id])\n end",
"def process!(config, sub_batch)\n return if sub_batch.empty?\n opts = {}\n opts[:request_items] = {config.table_name => sub_batch}\n begin\n response = config.dynamo_db_client.batch_write_item(opts)\n opts[:request_items] = response[:unprocessed_items]\n end until opts[:request_items].empty?\n end",
"def handle(obj)\n request = Request.new(obj)\n @mutex.synchronize do\n @requests_queue.push(request)\n @cv.wait(@mutex) until request.re?\n request.re\n end\n end",
"def chunk(action, objects, with_object_id = false)\n objects.map do |object|\n check_object(object, true)\n request = { action: action, body: object }\n request[:objectID] = get_object_id(object).to_s if with_object_id\n request\n end\n end",
"def add_rule request_pb, options = nil\n raise ::ArgumentError, \"request must be provided\" if request_pb.nil?\n\n uri, body, query_string_params = transcode_add_rule_request request_pb\n response = @client_stub.make_post_request(\n uri: uri,\n body: body,\n params: query_string_params,\n options: options\n )\n result = ::Google::Cloud::Compute::V1::Operation.decode_json response.body, ignore_unknown_fields: true\n\n yield result, response if block_given?\n result\n end",
"def aggregate(request)\n @request_object = @request_class.new(:first_lineno => request.first_lineno, :last_lineno => request.last_lineno)\n request.lines.each do |line|\n class_columns = @orm_module.const_get(\"#{line[:line_type]}_line\".classify).column_names.reject { |column| ['id'].include?(column) }\n attributes = Hash[*line.select { |(k, v)| class_columns.include?(k.to_s) }.flatten]\n @request_object.send(\"#{line[:line_type]}_lines\").build(attributes)\n end\n @request_object.save!\n rescue SQLite3::SQLException => e\n raise Interrupt, e.message\n end",
"def send_request(batch)\n payload = batch.to_s\n request = Net::HTTP::Post.new(@path, @headers)\n\n if self.class.stub\n logger.debug \"stubbed request to #{@path}: \" \\\n \"batch = '#{batch}'\"\n\n [200, '', 'OK']\n else\n # If `start` is not called, Ruby adds a 'Connection: close' header to\n # all requests, preventing us from reusing a connection for multiple\n # HTTP requests\n @http.start unless @http.started?\n\n response = @http.request(request, payload)\n [response.code.to_i, response.body, response.message]\n end\n end",
"def add(args)\n return @client.api_helper.add(args, \"item_add\")\n end",
"def pre_flight(meth, arg = nil, items = nil, **opt)\n meth, arg, items = [nil, meth, arg] unless meth.nil? || meth.is_a?(Symbol)\n command = meth && (meth != SubmissionService::Request::DEFAULT_COMMAND)\n request = arg.is_a?(SubmissionService::Request)\n limited = items.present?\n if command && !request\n items ||= arg\n SubmissionService::ControlRequest.new(items, command: meth)\n elsif arg.is_a?(SubmissionService::SubmitRequest) || !request\n items ||= request ? arg.items : Array.wrap(arg)\n if (opt[:batch] = batch_size_for(opt[:batch], items))\n SubmissionService::BatchSubmitRequest.new(items, **opt)\n elsif limited || !request\n SubmissionService::SubmitRequest.new(items)\n else\n arg\n end\n elsif limited\n items ||= arg.items\n arg.class.new(items, **opt)\n else\n arg\n end\n end",
"def create_batch urls\n function = 'batch/'\n\n post_data = {}\n post_data[:urls] = urls.join(',')\n\n request(@resource, function, nil, 'post', post_data)\n end",
"def batch_params\n params.require(:batch).permit(:description, :committed_at, :total_cents, :total_currency, :status)\n end",
"def create_batch_with_http_info(batch_input_blog_post, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: BlogPostsApi.create_batch ...'\n end\n # verify the required parameter 'batch_input_blog_post' is set\n if @api_client.config.client_side_validation && batch_input_blog_post.nil?\n fail ArgumentError, \"Missing the required parameter 'batch_input_blog_post' when calling BlogPostsApi.create_batch\"\n end\n # resource path\n local_var_path = '/cms/v3/blogs/posts/batch/create'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])\n # HTTP header 'Content-Type'\n content_type = @api_client.select_header_content_type(['application/json'])\n if !content_type.nil?\n header_params['Content-Type'] = content_type\n end\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body] || @api_client.object_to_http_body(batch_input_blog_post)\n\n # return_type\n return_type = opts[:debug_return_type] || 'BatchResponseBlogPost'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['hapikey', 'oauth2']\n\n new_options = opts.merge(\n :operation => :\"BlogPostsApi.create_batch\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: BlogPostsApi#create_batch\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def create_batch_with_http_info(batch_input_blog_author, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: BlogAuthorsApi.create_batch ...'\n end\n # verify the required parameter 'batch_input_blog_author' is set\n if @api_client.config.client_side_validation && batch_input_blog_author.nil?\n fail ArgumentError, \"Missing the required parameter 'batch_input_blog_author' when calling BlogAuthorsApi.create_batch\"\n end\n # resource path\n local_var_path = '/cms/v3/blogs/authors/batch/create'\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json', '*/*'])\n # HTTP header 'Content-Type'\n content_type = @api_client.select_header_content_type(['application/json'])\n if !content_type.nil?\n header_params['Content-Type'] = content_type\n end\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body] || @api_client.object_to_http_body(batch_input_blog_author)\n\n # return_type\n return_type = opts[:debug_return_type] || 'BatchResponseBlogAuthor'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['oauth2']\n\n new_options = opts.merge(\n :operation => :\"BlogAuthorsApi.create_batch\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: BlogAuthorsApi#create_batch\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def add_batch\n result = RLetters::Solr::Connection.search(next_query)\n return false if result.num_hits == 0\n\n # Call the progress function\n @total ||= result.num_hits\n @progress.call((@start.to_f / @total.to_f * 100).to_i) if @progress\n\n # Import the dataset entries (quickly)\n ::Datasets::Entry.import([:uid, :dataset_id],\n result.documents.map do |d|\n [d.uid, @dataset_id]\n end,\n validate: false)\n\n # Check to see if there's any externally fetched documents here\n unless @dataset.fetch\n if result.documents.any? { |d| d.fulltext_url }\n @dataset.fetch = true\n @dataset.save\n end\n end\n\n # Tell the caller whether or not we should continue\n @start <= @total\n end",
"def set_batch\n @batch = Batch.find(params[:id])\n end",
"def mass_create\n requests = []\n group_invite_params[:mass_requests].each do |element|\n requests << @current_user.requests_as_sender.new(:group_id => element[:group_id], :receiver_id => element[:receiver_id], :status => \"pending\")\n end\n\n @invites = Request.import requests\n\n if @invites\n render json: requests, status: :created\n else\n render json: requests.errors, status: :unprocessable_entity\n end\n end",
"def put(request)\n do_request(request) { |client| client.http_put request.body }\n end",
"def send_batch\n batch = @batch.map(&:first) # get the requests\n response = send_batch_request(batch)\n\n begin\n responses = JSON.parse(response)\n rescue\n raise Jimson::ClientError::InvalidJSON.new(json)\n end\n\n process_batch_response(responses)\n responses = @batch\n\n @batch = []\n\n responses\n end",
"def group_request (v1_requests_params)\n req = Request.find(v1_requests_params[:id])\n @group = Group.where(id: v1_requests_params[:group_id]).first\n user = User.find(req.reciever_id)\n if v1_requests_params[:response]\n @group.users << user\n end\n @group\n end",
"def update_batch batch\n batch.file_name = @zip_file_name\n batch.arrival_time = Time.now\n batch.facility_id = facility.id\n batch.client_id = facility.client_id\n batch.contracted_time = (Time.now + facility.tat.to_i.hours)\n batch.target_time = (Time.now + facility.tat.to_i.hours)\n batch.date = Date.today if batch.date.blank?\n batch.bank_deposit_date = Date.today if batch.bank_deposit_date.blank?\n batch.correspondence = true if type == 'CORRESP'\n return batch\n end",
"def update_batch batch\n batch.file_name = @zip_file_name\n batch.arrival_time = Time.now\n batch.facility_id = facility.id\n batch.client_id = facility.client_id\n batch.contracted_time = (Time.now + facility.tat.to_i.hours)\n batch.target_time = (Time.now + facility.tat.to_i.hours)\n batch.date = Date.today if batch.date.blank?\n batch.bank_deposit_date = Date.today if batch.bank_deposit_date.blank?\n batch.correspondence = true if type == 'CORRESP'\n return batch\n end",
"def update_batch batch\n batch.file_name = @zip_file_name\n batch.arrival_time = Time.now\n batch.facility_id = facility.id\n batch.client_id = facility.client_id\n batch.contracted_time = (Time.now + facility.tat.to_i.hours)\n batch.target_time = (Time.now + facility.tat.to_i.hours)\n batch.date = Date.today if batch.date.blank?\n batch.bank_deposit_date = Date.today if batch.bank_deposit_date.blank?\n batch.correspondence = true if type == 'CORRESP'\n return batch\n end",
"def add(params = {})\n @hydra.queue(request('add', params))\n end",
"def batch_params\n # Инициализация параметров объекта Batch\n params.require(:batch).permit(:batch_id, :creation_date, :guid, :batch_file)\n end",
"def process_batch_with_http_info(batch_id, process_batch_request_body, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: BatchesApi.process_batch ...'\n end\n # verify the required parameter 'batch_id' is set\n if @api_client.config.client_side_validation && batch_id.nil?\n fail ArgumentError, \"Missing the required parameter 'batch_id' when calling BatchesApi.process_batch\"\n end\n if @api_client.config.client_side_validation && batch_id.to_s.length > 25\n fail ArgumentError, 'invalid value for \"batch_id\" when calling BatchesApi.process_batch, the character length must be smaller than or equal to 25.'\n end\n\n if @api_client.config.client_side_validation && batch_id.to_s.length < 1\n fail ArgumentError, 'invalid value for \"batch_id\" when calling BatchesApi.process_batch, the character length must be great than or equal to 1.'\n end\n\n pattern = Regexp.new(/^se(-[a-z0-9]+)+$/)\n if @api_client.config.client_side_validation && batch_id !~ pattern\n fail ArgumentError, \"invalid value for 'batch_id' when calling BatchesApi.process_batch, must conform to the pattern #{pattern}.\"\n end\n\n # verify the required parameter 'process_batch_request_body' is set\n if @api_client.config.client_side_validation && process_batch_request_body.nil?\n fail ArgumentError, \"Missing the required parameter 'process_batch_request_body' when calling BatchesApi.process_batch\"\n end\n # resource path\n local_var_path = '/v1/batches/{batch_id}/process/labels'.sub('{' + 'batch_id' + '}', CGI.escape(batch_id.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['text/plain', 'application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] || @api_client.object_to_http_body(process_batch_request_body) \n\n # return_type\n return_type = opts[:return_type] || 'String' \n\n # auth_names\n auth_names = opts[:auth_names] || ['api_key']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: BatchesApi#process_batch\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def index\n unless params[:requests] && params[:requests].is_a?(Array)\n render :json => {:error => \"Must pass an array of requests\"}, :status => :bad_request and return\n end\n\n if params[:requests].size > MAX_REQUESTS\n render :json => {:error => \"This batch API accepts a maximum of #{MAX_REQUESTS} requests\"}, :status => :bad_request and return\n end\n\n fetcher = Batchy::Fetcher.new(app: Rails.application, requests: params[:requests]).run\n render :json => {:succeeded => fetcher.succeeded, :failed => fetcher.failed, :responses => fetcher.responses}, :status => :ok\n end"
] | [
"0.69505984",
"0.6852873",
"0.6816558",
"0.6741807",
"0.6560005",
"0.65364385",
"0.64592576",
"0.6433923",
"0.62163174",
"0.6155841",
"0.6152654",
"0.61412096",
"0.61411595",
"0.6132737",
"0.6117577",
"0.6096208",
"0.60543114",
"0.5996252",
"0.5984472",
"0.5959678",
"0.5948207",
"0.59068775",
"0.5905171",
"0.5875635",
"0.58717895",
"0.5859997",
"0.58351064",
"0.5802805",
"0.5796468",
"0.5774777",
"0.57544565",
"0.5664793",
"0.5647308",
"0.5610746",
"0.5590806",
"0.55741984",
"0.5572569",
"0.5555517",
"0.5555517",
"0.5555517",
"0.5555517",
"0.5551158",
"0.5551158",
"0.5518129",
"0.5508663",
"0.5494231",
"0.54863036",
"0.5483452",
"0.5465447",
"0.5454541",
"0.54539984",
"0.5452718",
"0.54495627",
"0.543295",
"0.543295",
"0.5424572",
"0.5415218",
"0.54100287",
"0.540965",
"0.5393939",
"0.5378234",
"0.5374734",
"0.53710115",
"0.53543526",
"0.5347767",
"0.53281975",
"0.53250265",
"0.53229356",
"0.5320822",
"0.53161263",
"0.53114724",
"0.5308881",
"0.53063864",
"0.5279746",
"0.5278059",
"0.5276339",
"0.5271911",
"0.52678",
"0.5267385",
"0.5265796",
"0.5260132",
"0.5257775",
"0.5251766",
"0.5249161",
"0.524667",
"0.5239808",
"0.52396363",
"0.5239612",
"0.52328485",
"0.52314866",
"0.5228221",
"0.5223283",
"0.52214706",
"0.52161765",
"0.52161765",
"0.52161765",
"0.5203715",
"0.5202237",
"0.5202014",
"0.52014905"
] | 0.6506785 | 6 |
Further exploration with zip | def multiply_list_zip(array1,array2)
array1.zip(array2).map {|element| element.reduce(:*)}
# array 1's element would be spread out into three arrays, 3,5 and 7 being the first elements. Zip then iterates through the argument
# and mergers these elements into array1 one by one. The documentation then states if a block is given it invoked for EACH ARRAY, so in this case
# the combined arrays we have now created.
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zip(*rest) end",
"def test_0300_zip\n @@log.debug \"test_0300_zip starts\" if @@log.debug?\n assert_respond_to(@list, :zip, \"test_0300_zip_respond\")\n # Basic example\n a = [1]\n b = [2,3]\n c = [4,5,6]\n ta = @list.zip(a, b, c)\n #\n te = [[@aen, 1, 2, 4], \n [@bsb, nil, 3, 5], \n [@cab, nil, nil, 6], \n [@dad, nil, nil, nil]]\n #\n assert_equal(te, ta, \"test_0300_zip_basic\")\n # TODO: A practical example ??? What could this possibly be used for??\n @@log.debug \"test_0300_zip ends\" if @@log.debug?\n end",
"def zip(first, second)\n first.zip(second)\nend",
"def my_zip(*arrs)\n zipped = []\n self.each_with_index do |ele, i|\n sub = [ele]\n arrs.each do |arr|\n sub << arr[i]\n end\n zipped << sub\n end\n zipped\n end",
"def zip( *other_arrays, & block )\n\n load_parent_state\n \n return super\n \n end",
"def my_zip(*args)\n zipped = Array.new(self.length) {[]}\n\n self.each_with_index { |el, i_arr| zipped[i_arr] << el}\n args.each_with_index do |arg, i_arg|\n (zipped.length).times {|i_arg_el| zipped[i_arg_el] << arg[i_arg_el]}\n end\n zipped\n end",
"def my_zip(*given_arrays)\n result = []\n\n self.each_with_index do |el, idx|\n internal_array = [el]\n given_arrays.each { |given_array| internal_array << given_array[idx] }\n result << internal_array\n end\n\n result\n end",
"def zip(array1, array2)\n results = []\n array1.each_with_index do |current_element, current_index|\n results << [current_element, array2[current_index]]\n end\n results\nend",
"def zip\n end",
"def custom_zip(arr1, arr2)\n final=[]\n arr1.each_with_index do |item, index|\n nested_array= []\n arr2.each_with_index do |item2, index2|\n if index == index2\n nested_array << item\n nested_array << item2\n final << nested_array\n end\n end\n end\n final\nend",
"def custom_zip (arr1, arr2)\n final = []\n arr1.each_with_index do |item, index|\n final << [item, arr2[index]]\n end\n final\nend",
"def zip\n end",
"def zip(first, second)\n first.zip(second).flatten\nend",
"def custom_zip(arr1, arr2)\n result = []\n arr1.each_with_index do |item, index|\n result << [arr1[index], arr2[index]]\n end\n result\nend",
"def zip(arr1, arr2)\n arr1.each_with_index.with_object([]) do |(el, i), z|\n z << [el, arr2[i]]\n end\nend",
"def zip(*arr)\n (0...arr[0].length).map do |i|\n arr.map {|arr| arr[i]}\n end\nend",
"def custom_zip(arr1, arr2)\n final = []\n arr1.each_with_index do |value, index|\n final << [value, arr2[index]]\n end\n final\nend",
"def custom_zip(arr1, arr2)\n new_nested = []\n arr1.each_with_index do | arr1_value, arr1_index |\n arr2.each_with_index do | arr2_value, arr2_index |\n if arr1_index == arr2_index\n arr3 = [arr1[arr1_index], arr2[arr2_index]]\n new_nested << arr3\n end # end of if\n end # end of do (array 2)\n end # end of do (array 1)\n new_nested\nend",
"def zip(arr1, arr2)\n zipped = []\n arr1.each_with_index do |el, i|\n zipped << [el, arr2[i]]\n end\n zipped\nend",
"def zip(array1, array2)\n iterations = array1.size\n results = []\n iterations.times do |index|\n results << [array1[index], array2[index]]\n end\n results\nend",
"def my_zip(*arrays)\n i = 0\n zipped = []\n while i < self.length\n nest = [self[i]]\n arrays.my_each do |arr|\n if i < arr.length\n nest << arr[i]\n else\n nest << nil\n end\n end\n zipped << nest\n i += 1\n end\n return zipped\n end",
"def zipper(arr1, arr2)\n arr1.map.with_index { |val, idx| [val] << arr2[idx] }\nend",
"def zip_with(a, b, &op)\n result = []\n a.zip(b){ |aa,bb| result << op.call(aa,bb)}\n result\nend",
"def zip(arr1, arr2)\n zipped = []\n arr1.each_with_index { |ele, ind| zipped << [ele, arr2[ind]] }\n zipped\nend",
"def zip(*args, &result_selector)\n args.unshift(self)\n Observable.zip(*args, &result_selector)\n end",
"def zip(ar1, ar2)\n zip_rec = ->(ar1, ar2, result) do\n case [ar1, ar2]\n when [[], []]\n result\n else\n zip_rec.(ar1[1..-1], ar2[1..-1], result << [ar1[0], ar2[0]])\n end\n end\n zip_rec.(ar1, ar2, [])\nend",
"def zip(*arrs)\n return [] if arrs.any?(&:empty?)\n [arrs.map(&:first)] + zip(arrs.first.drop(1), arrs.last.drop(1))\nend",
"def zip(*args)\n \n multi = Array.new(args[0].length) {[]}\n\n (0...args.length).each do |i|\n (0...args[0].length).each do |j|\n multi[j] << args[i][j]\n end\n end\n multi\nend",
"def custom_zip(arr1, arr2)\n final = []\n arr1.each_with_index { |name, index| final << [name, arr2[index]] }\n final\nend",
"def zip(arr1, arr2)\n arr1.each_with_index.with_object([]) do |(el, idx), arr|\n arr << [el, arr2[idx]]\n end\nend",
"def zip first, second\n first.zip(second).flatten()\nend",
"def custom_zip(arr1, arr2, arr3)\n arr = []\n nest_arr = []\n arr1.each do |i|\n k = [] #initialize a temporary array\n k.push(i) #pushed first val\n k.push(arr2[arr1.index(i)]) #pushed 2nd val\n k.push(arr3[arr1.index(i)]) #pushed 3rd val\n nest_arr = k #assigned to nest_arr\n arr.push(nest_arr) # pushed nest_arr to arr in order to nest in\n end\n\n p arr\nend",
"def lecturer_zip(arr1,arr2)\n final = []\n arr1.each_with_index { |value, index| final << [value, arr2[index]] }\n final\nend",
"def zip(arr_1, arr_2)\n new_arr = []\n arr_1.size.times do |i|\n new_arr << [arr_1[i], arr_2[i]]\n end\n new_arr\nend",
"def zipper(arr1, arr2)\n arr1.map.with_index { |elem, ndx| [elem, arr2[ndx]] }\nend",
"def zany_zip(*args)\n length = args.map(&:length).max\n multi = Array.new(length) {[]}\n\n (0...args.length).each do |i|\n (0...length).each do |j|\n if j >= args[i].length\n multi[j] << nil\n else\n multi[j] << args[i][j]\n end\n end\n end\n multi\nend",
"def interzip(array1, array2)\n array1.zip(array2).flatten\nend",
"def zip(arr1, arr2)\n arr1.map.with_index { |el1, idx| [el1, arr2[idx]] }\nend",
"def zip(arr1, arr2)\n result = []\n idx = 0\n loop do\n result << [arr1[idx], arr2[idx]]\n idx += 1\n break if idx == arr1.size\n end\n result\nend",
"def zip(arr1, arr2)\n index = 0\n zipped = []\n while index < arr1.length\n zipped << [arr1[index], arr2[index]]\n index += 1\n end\n zipped\nend",
"def zip(arr1, arr2)\n arr1.each_with_index.reduce([]) { |result, (el, idx)| result << [el, arr2[idx]] }\nend",
"def my_zip(*arr)\n answer = Array.new([])\n each_with_index do |item, index|\n answer[index] = [item]\n arr.each do |elem|\n answer[index] << elem[index]\n end\n end\n answer\n end",
"def zip(*arr)\n new_arr = []\n i = 0\n while i < arr[0].length\n temp = []\n arr.each do |subarray|\n temp << subarray[i]\n end\n new_arr << temp\n i += 1\n end\n new_arr\nend",
"def zip first, second\n answer = Array.new\n first.each.with_index do |letter, index|\n answer << first[index]\n answer << second[index]\n end\n answer\nend",
"def zip_map(left, right)\n result = Array.new(left.length)\n\n # Hold the current index and increment in each iteration: its faster to\n # do this and prealloate the result array, than to create an empty array\n # and push each result.\n index = -1\n\n left.zip(right) do |l_val, r_val|\n result[index += 1] = yield(l_val, r_val)\n end\n\n result\n end",
"def zip\n @zip\n end",
"def zip(arr1, arr2)\n Array.new(arr1.size) do |idx|\n [arr1[idx], arr2[idx]]\n end\nend",
"def zany_zip(*arr)\n max_length = 0\n arr.each do |x|\n if x.length > max_length\n max_length = x.length\n end\n end\n result = []\n i = 0\n while i < max_length\n temp = []\n arr.each do |subarray|\n temp << subarray[i]\n end\n result << temp\n i += 1\n end\n result\nend",
"def zip(*enums)\r\n r = block_given? ? nil : []\r\n len = enums.collect { |x| x.size }.max\r\n len.times do |i|\r\n val = enums.collect { |x| x[i] }\r\n if block_given?\r\n yield val\r\n else\r\n r << val\r\n end\r\n end\r\n r\r\nend",
"def zip(*lists)\n length = nil\n values = []\n lists.each do |list|\n array = list.to_a\n values << array.dup\n length = length.nil? ? array.length : [length, array.length].min\n end\n values.each do |value|\n value.slice!(length)\n end\n new_list_value = values.first.zip(*values[1..-1])\n list(new_list_value.map {|list| list(list, :space)}, :comma)\n end",
"def paralell_array(*enums)\n zip(*enums)\n end",
"def zip(others)\n LazyList.new do\n next self if empty? && others.empty?\n Cons.new(Cons.new(head, Cons.new(others.head)), tail.zip(others.tail))\n end\n end",
"def zip_blocks(blks, filter = writable_mifare_blocks)\n filter.map\n .with_index { |i, x| [i, blks[x]] }\n .reject { |_a, b| b.nil? }\n end",
"def array_fusion\r\n results = Hash[*@citys_list.zip(@citys_mail).flatten]\r\n print results.each_slice(1).map(&:to_h)\r\n \r\nend",
"def user_comment_zipper\n @obj_comments.zip(@user)\n end",
"def zip(state_abbreviation: T.unsafe(nil)); end",
"def pairs\n seq = to_a\n seq.zip([*seq[1..-1], unit.advance(to)])\n end",
"def combine_zip(a, b)\n if a.length < b.length\n # fill in if a shorter than b\n a += Array.new(b.length - a.length)\n end\n a.zip(b).flatten!\nend",
"def demux\n x = []\n y = []\n self.each { |inz| raise \"wrong size (!= 2) - #{inz.inspect}\" if inz.size != 2; x << inz[0] ; y << inz[1] }\n [x,y]\n end",
"def zip_to_length(length, *arrays)\n (0...length).map do |i|\n arrays[-1].map { |array| array[i] }\n end\nend",
"def zip_sum(array, array2)\n new_arr = []\n array.length.times do |index|\n new_arr.push(array[index] + array2[index])\n end\n new_arr\nend",
"def zip_contents; end",
"def zip\n (match.first.to_i - 1).to_s\n end",
"def interleave(a, b)\n a.zip(b).flatten\nend",
"def ext_zip(values, options = {})\n zip_to_hash(self, values, options)\n end",
"def zip(*args, &result_selector)\n AnonymousObservable.new do |observer|\n result_selector ||= lambda {|*inner_args| inner_args }\n n = args.length\n\n queues = Array.new(n) {|i| Array.new }\n is_done = Array.new(n, false)\n\n next_action = lambda do |i|\n if queues.all? {|q| q.length > 0 }\n res = queues.map {|q| q.shift }\n begin\n observer.on_next(result_selector.call(*res))\n rescue => e\n observer.on_error e\n break\n end\n end\n if queues.each_with_index.any? { |q, j| q.empty? && is_done[j] }\n observer.on_completed\n end\n end\n\n done = lambda do |i|\n is_done[i] = true\n observer.on_completed if queues[i].empty?\n end\n\n gate = Monitor.new\n\n subscriptions = Array.new(n) do |i|\n sas = SingleAssignmentSubscription.new\n\n sas_obs = Observer.configure do |o|\n o.on_next do |x|\n queues[i].push(x)\n next_action.call i\n end\n\n o.on_error(&observer.method(:on_error))\n\n o.on_completed { done.call i }\n end\n\n sas.subscription = args[i].synchronize(gate).subscribe(sas_obs)\n sas\n end\n\n subscriptions.push(Subscription.create { queues.each {|q| q = [] }})\n\n CompositeSubscription.new subscriptions\n end\n end",
"def interleave(array1, array2)\n p array1.zip(array2).flatten\nend",
"def interleave(list1, list2)\n (list1.zip list2).flatten\nend",
"def unzip_entries(zipfile, destination, &block)\n SevenZipRuby::Reader.open(zipfile, password: @password) do |szr|\n szr.entries.each do |entry|\n # SECURE: TPG 2018-11-21: The path is stripped from the zipfile entry when extracted\n basename = ::File.basename(entry.path)\n next unless entry.file? && basename.match(@pattern)\n\n unzipped_filename = destination.join(basename)\n szr.extract([entry], unzipped_filename)\n\n unzipped_files(unzipped_filename, &block)\n end\n end\n end",
"def zip_and_flatten(array1,array2)\t\n\t\t(array1.zip(array2)).flatten(1).reject{|x| x.nil?}\n\tend",
"def zip?(other)\n tail.equal? other.tail \n end",
"def indexable_zip_codes\n zip_codes = self.zip_codes.collect(&:zip_code) \n zip_codes << original_address.zip_code if original_address\n zip_codes\n end",
"def generate_zip\n o = [(0..9)].map{|i| i.to_a}.flatten\n zip = (0...5).map{ o[rand(o.length)] }.join\n end",
"def alternating_mapper(arr, p1, p2)\n (0...arr.length).map {|i| i.even? ? p1.call(arr[i]) : p2.call(arr[i])}\nend",
"def interleave(arr1, arr2)\n results = []\n\n arr1.each_with_index do |el, i|\n results << el << arr2[i]\n # results << el << arr2[arr1.index(el)] ## if you wanted to do it without index as block param\n end\n\n results\nend",
"def extract\n Dir.mktmpdir do |dir|\n open_zip do |zip_file|\n zip_file.each do |entry|\n entry.extract(File.join(dir, File.basename(entry.name))) unless entry.name_is_directory?\n end\n\n yield dir\n end\n end\n end",
"def each_pair(*) end",
"def map_with_siblings\n self.map.with_index { |_, index|\n yield(\n index > 0 ? self.at(index - 1) : nil,\n self[index],\n index < self.count() - 1 ? self[index + 1] : nil\n )\n }\n end",
"def extract\n Dir.mktmpdir do |dir|\n open_zip do |zip_file|\n zip_file.each do |entry|\n unless entry.name_is_directory?\n entry.extract(File.join(dir, File.basename(entry.name)))\n end\n end\n\n yield dir\n end\n end\n end",
"def interleave(ary1, ary2)\n ary1.zip(ary2).flatten\nend",
"def position_filter(headers, *data)\n headers.zip(*data)\nend",
"def step\n\t\t\tprogram = pop\n\t\t\tlist = pop\n\t\t\traise ArgumentError, \"STEP: first element is not an Array.\" unless program.is_a? Array\n\t\t\traise ArgumentError, \"STEP: second element is not an array.\" unless list.is_a? Array\n\t\t\tlist.map do |e| \n\t\t\t\tpush e\n\t\t\t\t~program\n\t\t\tend\n\t\tend",
"def zip(data)\n Zip::OutputStream.write_buffer{ |zip|\n data.each{ |name, content|\n zip.put_next_entry(name)\n zip.write(content)\n }\n }.string\nend",
"def intra_delta vp\n vp.map {|x| x.map {|n| @intra_delta.call(n)}}\n end",
"def interleave(arr1,arr2)\n arr1.zip(arr2).flatten\nend",
"def interleave(arr_1, arr_2)\n arr_1.zip(arr_2).flatten\nend",
"def test_0930_flat_map\n @@log.debug \"test_0930_flat_map starts\" if @@log.debug?\n assert_respond_to(@list, :flat_map, \"test_0930_flat_map_respond\")\n # Need some arrays for this test .....\n part_one = [@aen, @bsb]\n part_two = [@cab, @dad]\n ary_all = [ part_one, part_two ]\n # This should be the orignal list\n cc_res = ary_all.flat_map {|pers| pers }\n 0.upto(cc_res.size-1) do |n|\n # Each element should be the same\n assert(cc_res[n] == @list[n], \"test_0930_flat_map_eltck_#{n}\")\n end\n #\n assert(cc_res == @list.to_a, \"test_0930_flat_map_eltck_all\")\n @@log.debug \"test_0930_flat_map ends\" if @@log.debug?\n end",
"def interleave(a1, a2)\n # new_array = []\n # index = 0\n # while index < a1.size\n # new_array.push(a1[index])\n # new_array.push(a2[index])\n # index += 1\n # end\n # new_array\n # LS solution\n # result = []\n # array1.each_with_index do |element, index|\n # result << element << array2[index]\n # end\n # result\n a1.zip(a2).flatten\nend",
"def unzip(x)\r\n outdir = x.sub(/.*\\//, '')\r\n outdir = '.' if outdir == \"\"\r\n Zip::ZipFile::open(x) { |zf|\r\n zf.each { |e|\r\n fpath = File.join(outdir, e.name)\r\n FileUtils.mkdir_p(File.dirname(fpath))\r\n zf.extract(e, fpath)\r\n }\r\n }\r\nend",
"def pairs_for_run(run)\r\n\t\ttemp = Array.new\r\n\t\t0.upto(run.size-2) do |index1|\r\n\t\t\t(index1+1).upto(run.size-1) do |index2|\r\n\t\t\t\ttemp << ([] << run[index1] << run[index2])\r\n\t\t\tend\r\n\t\tend\r\n\t\ttemp\r\n\tend",
"def zip(data)\n zipfile = \"rubyzip-#{rand 32768}\" \n Zip::ZipOutputStream::open(zipfile) do |io|\n count = 0\n data.each do |d, n|\n io.put_next_entry((\"#{n}\" or \"#{count += 1}.txt\"))\n io.write d\n end\n end\n zippy = File.open(zipfile).read\n #File.delete(zipfile)\n zippy \n end",
"def array_align (arr, *data)\n arr.zip(*data)\nend",
"def panoramic_pairs(landmarks)\n #make a new array for pairs of landmarks\n #starting with first landmakr, iterate through array and add two landmakrs to pair of landmarks\n\n pairs_of_landmarks = []\n\n idx = 0\n while idx < landmarks.length\n next_landmark = landmarks[idx + 1] || landmarks[0]\n pairs_of_landmarks << [landmarks[idx], next_landmark]\n idx += 1\n end\n\n pairs_of_landmarks\nend",
"def extract\n zip_file_path = \"#{Rails.root}/public/tmp/#{self.id}/#{self.zip_file_name}\"\n # 100.times { p File.exist?(zip_file_path) }\n\n Zip::ZipFile.open(zip_file_path) do |zipfile|\n zipfile.each do |file|\n export_path = \"#{Rails.root}/public/tmp/#{self.id}_2/\"\n zip_path = File.join(export_path, zip_file_name)\n\n 100.times do\n p zip_path\n end\n\n # export_path = \"#{Rails.root}/public/tmp/#{self.id}_2/\"\n # zip_path = File.join(export_path, zip_file_name)\n # FileUtils.mkdir_p(File.dirname(export_path))\n\n # unless File.exist?(zip_file_path)\n # zipfile.extract(file, zip_path)\n # # # ..stuff that it does..\n # end\n # 100.times do\n # p image_path\n # end\n # FileUtils.mkdir_p(File.dirname(image_path))\n # unless File.exist?(image_path)\n # zip_file.extract(image, image_path)\n # # ..stuff that it does..\n # end\n end\n end\n end",
"def caterpillar_method\n result=[]\n i=0\n while(i<self.size/2)\n j=i+1\n while (self[j] && (yield self[i],self[j]))\n result<<[self[i],self[j]]\n j+=1\n end\n i+=1\n end\n return result\n end",
"def unarchive\n unless in_zip?\n zips, gzs = selected_items.partition(&:zip?).tap {|z, others| break [z, *others.partition(&:gz?)]}\n zips.each do |item|\n FileUtils.mkdir_p current_dir.join(item.basename)\n Zip::File.open(item) do |zip|\n zip.each do |entry|\n FileUtils.mkdir_p File.join(item.basename, File.dirname(entry.to_s))\n zip.extract(entry, File.join(item.basename, entry.to_s)) { true }\n end\n end\n end\n gzs.each do |item|\n Zlib::GzipReader.open(item) do |gz|\n Gem::Package::TarReader.new(gz) do |tar|\n dest_dir = current_dir.join (gz.orig_name || item.basename).sub(/\\.tar$/, '')\n tar.each do |entry|\n dest = nil\n if entry.full_name == '././@LongLink'\n dest = File.join dest_dir, entry.read.strip\n next\n end\n dest ||= File.join dest_dir, entry.full_name\n if entry.directory?\n FileUtils.mkdir_p dest, mode: entry.header.mode\n elsif entry.file?\n FileUtils.mkdir_p dest_dir\n File.open(dest, 'wb') {|f| f.print entry.read}\n FileUtils.chmod entry.header.mode, dest\n elsif entry.header.typeflag == '2' # symlink\n File.symlink entry.header.linkname, dest\n end\n unless Dir.exist? dest_dir\n FileUtils.mkdir_p dest_dir\n File.open(File.join(dest_dir, gz.orig_name || item.basename), 'wb') {|f| f.print gz.read}\n end\n end\n end\n end\n end\n else\n Zip::File.open(current_zip) do |zip|\n zip.select {|e| selected_items.map(&:name).include? e.to_s}.each do |entry|\n FileUtils.mkdir_p File.join(current_zip.dir, current_zip.basename, File.dirname(entry.to_s))\n zip.extract(entry, File.join(current_zip.dir, current_zip.basename, entry.to_s)) { true }\n end\n end\n end\n ls\n end",
"def zip_file_entries(zip_file, &block)\n if not block_given?\n a = []\n end\n\n Zip::ZipFile.foreach(zip_file) do |entry|\n if block_given?\n block.call(entry.to_s)\n else\n a << entry.to_s\n end\n end\n\n if not block_given?\n return a.each\n end\n end",
"def cracklepop3\n (1..100).zip(Array.new 100, nil).map do |i,x|\n [i%3, i%5].map.with_index do |y, j| \n x = x.to_s + ['crackle','pop'][j] if y==0\n end\n x ? x : i\n end\nend",
"def extract_zip(data)\n dir = Dir.mktmpdir\n process_zip_data(data) do |zipfile|\n zipfile.each do |f|\n f_path = File.join(dir, f.name)\n FileUtils.mkdir_p(File.dirname(f_path))\n zipfile.extract(f, f_path) unless File.exist?(f_path)\n end\n end\n dir\n end",
"def compress(list)\n list.zip(list[1..-1] + [nil]). # Zip with shifted list\n select {|a,b| a != b}. # Filter dups\n map {|a,b| a} # Unzip\nend"
] | [
"0.7778387",
"0.68498844",
"0.68337524",
"0.67696965",
"0.67696536",
"0.6569666",
"0.6542337",
"0.6497158",
"0.64898837",
"0.6480811",
"0.64553034",
"0.64518684",
"0.64500314",
"0.6413858",
"0.63971937",
"0.639074",
"0.63869286",
"0.63819975",
"0.6375687",
"0.6355257",
"0.63354623",
"0.6333624",
"0.6300344",
"0.62950486",
"0.62879413",
"0.6286659",
"0.6283338",
"0.6275384",
"0.62687784",
"0.62549514",
"0.6253229",
"0.6189889",
"0.6180144",
"0.61588836",
"0.6154025",
"0.6090369",
"0.607016",
"0.60700345",
"0.6053047",
"0.6024203",
"0.5997506",
"0.59912306",
"0.5980575",
"0.5958084",
"0.59345275",
"0.5915918",
"0.5885213",
"0.5856401",
"0.57266474",
"0.5684319",
"0.5604745",
"0.5523686",
"0.54913956",
"0.5490848",
"0.5490179",
"0.5432326",
"0.5429176",
"0.54127884",
"0.53998315",
"0.5334064",
"0.5313263",
"0.52777296",
"0.5267986",
"0.5259906",
"0.5257071",
"0.51535",
"0.5121262",
"0.5110874",
"0.5087319",
"0.507798",
"0.503128",
"0.5018578",
"0.5005202",
"0.49706176",
"0.49608067",
"0.49475235",
"0.49327585",
"0.49326453",
"0.4925824",
"0.4907381",
"0.49016643",
"0.4901174",
"0.4895609",
"0.48674324",
"0.486255",
"0.48616478",
"0.48616207",
"0.48605466",
"0.4855482",
"0.484799",
"0.4840283",
"0.48322946",
"0.4822613",
"0.481701",
"0.4808622",
"0.48081598",
"0.4804681",
"0.47936064",
"0.47821316",
"0.4779873"
] | 0.57535756 | 48 |
Returns the given string unescaped. See the "Logging > Nonprintable characters" section in HAProxy documentation. | def unescape(string)
string.gsub(/#[[:xdigit:]]{2}/) do |match|
match[1..-1].to_i(16).chr
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strip_unprintable_characters(s)\n s.tr(8204.chr, \"\")\nend",
"def unescape(string)\n string.is_a?(String) ? string.gsub(/\\n|\\r/, \"\") : string\n end",
"def remove_nonprintable\n gsub(/[^[:print:]\\n\\t]/i, '')\n end",
"def unescape(string)\n \"\\\"#{string}\\\"\".undump\n end",
"def stripped(string)\n string.chars.gsub(/[^\\x20-\\x7E]/, '')\n end",
"def safe(str)\n CGI.unescape(str)\n end",
"def unescape(str)\n str.to_s.gsub(/%(..)/) { Regexp.last_match(1).hex.chr }\n end",
"def unescape(escaped_string)\n escaped_string.\n gsub(/\\$\\$|\\$'|\\$L|\\$P|\\$R|\\$P|\\$T/i) do |match|\n case match\n when \"$$\"\n \"$\"\n when \"$'\"\n \"'\"\n when \"$L\", \"$l\"\n \"\\n\"\n when \"$R\", \"$r\"\n \"\\r\"\n when \"$T\", \"$t\"\n \"\\t\"\n when \"$P\", \"$p\"\n \"\\f\"\n end\n end\n end",
"def strip_non_ascii_chars(s)\n # truncate the string at the first null character\n s = s[0, s.index(\"\\x00\")] if s.index(\"\\x00\")\n \n s.gsub(/[^\\x20-\\x7E]/,\"\")\n end",
"def uninspect(str)\n return nil unless str\n str.gsub(%r!\\\\([\\\\#\"abefnrstvx]|u\\d{4}|u\\{[^\\}]+\\}|\\d{1,3}|x\\d{1,2}|cx|C-[a-zA-Z]|M-[a-zA-Z]| |=|:)!) do |m|\n repl = \"\"\n if ['\\\\', '#', '\"'].include?($1)\n repl = $1\n else\n repl = eval(\"\\\"\\\\#{$1}\\\"\")\n end\n repl\n end\n end",
"def unescape( value )\n return value unless @escape\n\n value = value.to_s\n value.gsub!(%r/\\\\[0nrt\\\\]/) { |char|\n case char\n when '\\0'; \"\\0\"\n when '\\n'; \"\\n\"\n when '\\r'; \"\\r\"\n when '\\t'; \"\\t\"\n when '\\\\\\\\'; \"\\\\\"\n end\n }\n value\n end",
"def strip_except_escapes(string)\n rstrip_except_escapes(string.lstrip)\n end",
"def _raw(string)\n ::Hanami::Utils::Escape::SafeString.new(string)\n end",
"def remove_nonprintable!\n replace(remove_nonprintable)\n end",
"def strip_non_ascii(string)\n strip_diacritics(string).gsub(/[^a-z0-9]+/i, ' ')\n end",
"def sanitize(string_or_io)\n Loofah.scrub_fragment(string_or_io, :escape).to_s\n end",
"def unescape(str, escaped = @regexp[:ESCAPED])\n str.gsub(escaped) { [$&[1, 2].hex].pack('C') }.force_encoding(str.encoding)\n end",
"def filter_out(str)\n return '' if str.nil? || str.empty?\n if [email protected]_on\n str.gsub!(/\\n/, \"\\r\\n\")\n end\n str\n end",
"def unescape(str)\n # Escape all the things\n str.gsub(/\\\\(?:([#{UNESCAPES.keys.join}])|u([\\da-fA-F]{4}))|\\\\0?x([\\da-fA-F]{2})/) {\n if $1\n if $1 == '\\\\' then '\\\\' else UNESCAPES[$1] end\n elsif $2 # escape \\u0000 unicode\n [\"#$2\".hex].pack('U*')\n elsif $3 # escape \\0xff or \\xff\n [$3].pack('H2')\n end\n }\n end",
"def unescape(string)\n result = CGI.unescapeHTML(string)\n result.gsub!(/!-(.*?)-!/, '\\1')\n return result\n end",
"def parse_escaped_chars; end",
"def unescape_stringify(str)\n chars = {\n 'a' => \"\\x07\", 'b' => \"\\x08\", 't' => \"\\x09\", 'n' => \"\\x0a\", 'v' => \"\\x0b\", 'f' => \"\\x0c\",\n 'r' => \"\\x0d\", 'e' => \"\\x1b\", \"\\\\\\\\\" => \"\\x5c\", \"\\\"\" => \"\\x22\", \"'\" => \"\\x27\"\n }\n # Escape all the things\n str.gsub(/\\\\(?:([#{chars.keys.join}])|u([\\da-fA-F]{4}))|\\\\0?x([\\da-fA-F]{2})/) {\n if $1\n if $1 == '\\\\'\n then '\\\\'\n else\n chars[$1]\n end\n elsif $2\n [\"#$2\".hex].pack('U*')\n elsif $3\n [$3].pack('H2')\n end\n }\n end",
"def sanitise(str)\n str = str.to_s\n str.gsub!(\"\\n\", '\\n')\n str[0..400]\n return str\n end",
"def no_leading_spaces str\n return str.force_encoding('ASCII-8BIT').gsub(/\\302\\240/,'').strip # What a hack.\n end",
"def decode_quoted_printable!\n self.replace(self.decode_quoted_printable)\n end",
"def unescape(str, escaped = @regexp[:ESCAPED])\n enc = str.encoding\n enc = Encoding::UTF_8 if enc == Encoding::US_ASCII\n str.gsub(escaped) { [$&[1, 2]].pack('H2').force_encoding(enc) }\n end",
"def clean_string(string)\n string = string.gsub(/\\r|\\n/,'').sub(/^ */,'').sub(/\\s*$/,'').gsub(/ +/,' ')\n coder = HTMLEntities.new()\n string = coder.decode(string) # Remove html entities\n return string\n end",
"def escape(str)\n str.dump[1..-2]\nend",
"def unescape(str)\n str = str.force_encoding(\"UTF-8\") if str.respond_to?(:force_encoding)\n str = str.gsub(/&#(\\d{3});/) { [$1.to_i].pack(\"U\") }\n CGI.unescapeHTML(str)\n end",
"def extra_clean_str(str)\n str = str.downcase.gsub @extra_ua_filter, ''\n str = str.gsub(/[^\\x20-\\x7F]/, '')\n str.strip\n end",
"def e(str)\n str.to_s.gsub(/(?=[^a-zA-Z0-9_.\\/\\-\\x7F-\\xFF\\n])/n, '\\\\').\n gsub(/\\n/, \"'\\n'\").\n sub(/^$/, \"''\")\n end",
"def unansi(string)\n string.gsub(PATTERN, '')\n end",
"def unescape(input)\n CGI.unescapeHTML(input) rescue input\n end",
"def unansi(string = T.unsafe(nil)); end",
"def unansi(string = T.unsafe(nil)); end",
"def strip_control_characters_and_excesses(string)\n last = string.split(\"\\033[2;0f\").last#.gsub(/(\\e\\[\\d+\\w)|(\\e\\[\\w)/,\"\")\n if last.empty?\n \"\"\n else\n last.gsub(/(\\e\\[\\d+\\w)|(\\e\\[\\w)/,\"\").gsub(\" +\",\"\")\n end\nend",
"def sanitize(string)\n string.gsub(ANSI_MATCHER, \"\")\n end",
"def sanitized_string(string)\n text = Sanitize.fragment(string.to_s).squish\n CGI.unescapeHTML(text).gsub(/ /, ' ')\n end",
"def strip(string)\n string.to_s.gsub(/(\\[)?\\033(\\[)?[;?\\d]*[\\dA-Za-z](\\])?/, '')\n end",
"def regex_strip(string)\n return string.gsub(/[^\\p{L}\\p{N}]/u, \" \")\n end",
"def xlunicodestringnocch(io, cch)\n flags = io.read(1).unpack('C').first\n _read_unicodestring(io, cch, flags)\n end",
"def do_encoding_terminal(string)\n string = string.to_s\n string.gsub!(\"\\r\\r\", \"\\r\")\n string.gsub!(\"\\r\\n\", \"\\n\")\n string.gsub!(\"\\r\\$\\s\", \"\")\n\n string.gsub!(/.\\r/, \"\")\n string.gsub!(/\\x1B\\[\\d*?[ABCDsuKJ]/, '')\n string\n end",
"def unescape_string_if_needed(str)\n\t# unsafe characters - see above for complete list\n\tunsafeCharacters = [0x200c, 0x200d]\n\t# let's convert our string into array (to preserve proper unicode numbers)\n\tstr_array=str.unpack(\"U*\")\n\t# set this to false until the first replacement takes place\n\treplacement_done = false\n\n\t# loop over all unsafe character and try to replace all occurencies\n\tunsafeCharacters.each do |c|\n\t\t# find the first occurence of that character\n\t\ti = str_array.index(c)\n\t\twhile i != nil\n\t\t\t# replaces a single character with '%uXXXX', where XXXX is hex code of character\n\t\t\t# this only works with non-math characters, but it should not happen that any bigger number would occur\n\t\t\tstr_array[i,1] = sprintf(\"%%u%4X\", c).unpack(\"U*\")\n\t\t\ti = str_array.index(c)\n\t\t\treplacement_done = true\n\t\tend\n\tend\n\n\t# convert the array back to string\n\tstr = str_array.pack(\"U*\")\n\n\tif replacement_done\n\t\treturn \"unescape('#{str}')\"\n\telse\n\t\treturn \"'#{str}'\"\n\tend\nend",
"def clean(str)\n str = str[1...(str.length - 1)] if literal\n escaped = false\n cleaned = ''\n (0...str.length).each do |i|\n c = str[i]\n if escaped\n cleaned += c\n escaped = false\n elsif c == '\\\\'\n escaped = true\n else\n cleaned += c\n end\n end\n cleaned\n end",
"def unescape_special_chars( str )\n\t\t\tEscapeTable.each {|char, hash|\n\t\t\t\[email protected] \"Unescaping escaped %p with %p\" % [ char, hash[:md5re] ]\n\t\t\t\tstr.gsub!( hash[:md5re], hash[:unescape] )\n\t\t\t}\n\n\t\t\treturn str\n\t\tend",
"def raw_output(s)\n s\n end",
"def consume_escaped; end",
"def unescape_value(value)\n value = value.to_s\n value.gsub!(%r{\\\\[0nrt\\\\]}) do |char|\n case char\n when '\\0' then \"\\0\"\n when '\\n' then \"\\n\"\n when '\\r' then \"\\r\"\n when '\\t' then \"\\t\"\n when '\\\\\\\\' then '\\\\'\n end\n end\n value\n end",
"def decode_quoted_printable\n self.unpack(\"M*\").first\n end",
"def clean_str(str)\n str = str.downcase.gsub @device_ua_filter, ''\n str = str.gsub(/[^\\x20-\\x7F]/, '')\n str.strip\n end",
"def rstrip_except_escapes(string)\n string.sub(/(?<!\\\\)\\s+$/, '')\n end",
"def escape_str(str)\n str.gsub!(/[\\\\`\\#]/, '\\\\\\\\\\&')\n str.gsub!(/\\r\\n/, \"\\\\r\\r\\n\") if @newline == \"\\r\\n\"\n return str\n end",
"def unescape(s)\n s.gsub(/((?:%[0-9a-fA-F]{2})+)/n) {[$1.delete('%')].pack('H*')}\n end",
"def quoted_printable(str) \n return [] if str.nil?\n \n buffer = \"\"\n lines = []\n \n 0.upto(str.bytesize - 1) do |i|\n char = \"\"\n\n case b = str.getbyte(i)\n when 10, 13\n # line feed ('\\n') or carriage return ('\\r')\n p = str.getbyte(i - 1)\n\n unless b == 10 && p == 13 || b == 13 && p == 10\n lines << buffer\n buffer = \"\"\n end\n\n when 9, 32\n # tab or whitespace\n n = str.getbyte(i + 1)\n\n if n.nil? || n == 10 || n == 13\n char = \"=#{hex(b)}\"\n else\n char = b.chr\n end\n\n when 33..60, 62..126\n # printable character ('!'..'~', except '=')\n char = b.chr\n\n else\n # any other character\n char = \"=#{hex(b)}\"\n end\n\n if buffer.length >= 78 - char.length\n lines << (buffer << \"=\")\n buffer = \"\"\n end\n buffer << char\n end\n\n\n lines << buffer\n end",
"def unescapeHTML(string)\n\tstr = string.dup\n\tstr.gsub!(/&(.*?);/n) {\n\t\tmatch = $1.dup\n\t\tcase match\n\t\t\twhen /\\Aamp\\z/ni then '&'\n\t\t\twhen /\\Aquot\\z/ni then '\"'\n\t\t\twhen /\\Agt\\z/ni then '>'\n\t\t\twhen /\\Alt\\z/ni then '<'\n\t\t\twhen /\\A#(\\d+)\\z/n then Integer($1).chr\n\t\t\twhen /\\A#x([09af]+)\\\n\t\t\tz/ni then $1.hex.chr\n\t\tend\n\t\t}\n\tstr\nend",
"def escape(str); end",
"def sanitized_message\n message.to_s[0,140]\n end",
"def raw(s)\n RawString.new(s)\n end",
"def htex(str)\n return str unless str.kind_of? String\n # All special characters will have four backslashes prepended\n # Two of them are used to escape the other two, thus \\\\\\\\# will give \\\\# in the next step\n # In the next step one is used to escape the other, leaving \\# for the last step (which is the .tex one)\n str.blank? ? '' : str.gsub(/\\&/, '\\\\\\\\&').gsub(/%/, '\\\\\\\\%').gsub(/\\$/, '\\\\\\\\$').gsub(/\\#/, '\\\\\\\\#').gsub(/\\n/, '\\\\\\\\\\\\\\\\')\n end",
"def h(str)\n CGI.unescape_html(str.to_s)\n .gsub('&', '&')\n .gsub('\"', '"')\n .gsub('<', '<')\n .gsub('>', '>')\n end",
"def escape_string(str)\n replacement = {\n ':)' => \"\\n\", ':>' => \"\\t\", ':o' => \"\\a\", ':\"' => '\"', '::' => ':'\n }\n str\n .gsub(/:[\\)>o\":]/, replacement)\n .gsub(/:\\(([0-9a-fA-F]+)\\)/) do |match|\n $1.to_i(16).chr(Encoding::UTF_8)\n end\n .gsub(/:\\[(.+?)\\]/) do |match|\n code = Unicode::DATA[$1]\n if code\n code.chr(Encoding::UTF_8)\n else\n $stderr.puts(\"Unknown Unicode normative name: #{$1}\")\n match\n end\n end\n end",
"def unescape(x)\n # temporarily escape \\\\ as \\007f, which is disallowed in any text\n x.gsub(/\\\\\\\\/, \"\\u007f\").gsub(/\\\\,/, \",\").gsub(/\\\\[Nn]/, \"\\n\").\n tr(\"\\u007f\", \"\\\\\")\n end",
"def silence_trump(str)\n\treturn str.gsub(/[(aeouiAEIOU)]/,'')\nend",
"def unescape(s)\n s.to_s.gsub(/%2[Bb]/, \"+\")\n end",
"def remove_nonprinting_chars(text)\n return text if text.blank?\n\n text.chars.map { |char| rejected_char?(char) ? ' ' : char }.join\n end",
"def escape(string); end",
"def escape_string(str)\n str.gsub(/[\\0\\n\\r\\\\\\'\\\"\\x1a]/) do |s|\n case s\n when \"\\0\" then \"\\\\0\"\n when \"\\n\" then \"\\\\n\"\n when \"\\r\" then \"\\\\r\"\n when \"\\x1a\" then \"\\\\Z\"\n else \"\\\\#{s}\"\n end\n end\n end",
"def unescapeHTML(string)\n str = string.dup\n str.gsub!(/&(.*?);/n) {\n match = $1.dup\n case match\n when /\\Aamp\\z/ni then '&'\n when /\\Aquot\\z/ni then '\"'\n when /\\Agt\\z/ni then '>'\n when /\\Alt\\z/ni then '<'\n when /\\A#(\\d+)\\z/n then Integer($1).chr\n when /\\A#x([0-9a-f]+)\\z/ni then $1.hex.chr\n end\n }\n str\nend",
"def strip(str)\n str.gsub(UNICODE_LEADERS_PAT, '').gsub(UNICODE_TRAILERS_PAT, '')\n end",
"def unencode_javascript_unicode_escape(str)\n if str.respond_to?(:gsub!)\n str.gsub!(/\\\\u([0-9a-fA-F]{4})/) do |s| \n int = $1.to_i(16)\n if int.zero? && s != \"0000\"\n s\n else\n [int].pack(\"U\")\n end\n end\n end\n str\n end",
"def escape_string(str)\n str.gsub(/[\\0\\n\\r\\\\\\'\\\"\\x1a]/) do |s|\n case s\n when \"\\0\" then \"\\\\0\"\n when \"\\n\" then \"\\\\n\"\n when \"\\r\" then \"\\\\r\"\n when \"\\x1a\" then \"\\\\Z\"\n else \"\\\\#{s}\"\n end\n end\n end",
"def clean(message)\n message = message.to_s.dup\n message.strip!\n message.gsub!(/%/, '%%') # syslog(3) freaks on % (printf)\n message.gsub!(/\\e\\[[^m]*m/, '') # remove useless ansi color codes\n return message\n end",
"def clean(message)\n message = message.to_s.dup\n message.strip!\n message.gsub!(/%/, '%%') # syslog(3) freaks on % (printf)\n message.gsub!(/\\e\\[[^m]*m/, '') # remove useless ansi color codes\n return message\n end",
"def raw(s)\n RawString.new(s)\n end",
"def escape(str)\n str.dump\n end",
"def escape(string)\n #This is a stub, used for indexing\n end",
"def escape_str(str)\n str.gsub!(/[`\\\\]/, '\\\\\\\\\\&')\n str.gsub!(/\\r\\n/, \"\\\\r\\r\\n\") if @newline == \"\\r\\n\"\n return str\n end",
"def unescape( src )\n String.class_eval(%Q(\"#{src}\"))\nend",
"def unescapeHTML(string)\n enc = string.encoding\n unless enc.ascii_compatible?\n if enc.dummy?\n origenc = enc\n enc = Encoding::Converter.asciicompat_encoding(enc)\n string = enc ? string.encode(enc) : string.b\n end\n string = string.gsub(Regexp.new('&(apos|amp|quot|gt|lt|#[0-9]+|#x[0-9A-Fa-f]+);'.encode(enc))) do\n case $1.encode(Encoding::US_ASCII)\n when 'apos' then \"'\".encode(enc)\n when 'amp' then '&'.encode(enc)\n when 'quot' then '\"'.encode(enc)\n when 'gt' then '>'.encode(enc)\n when 'lt' then '<'.encode(enc)\n when /\\A#0*(\\d+)\\z/ then $1.to_i.chr(enc)\n when /\\A#x([0-9a-f]+)\\z/i then $1.hex.chr(enc)\n end\n end\n string.encode!(origenc) if origenc\n return string\n end\n return string unless string.include? '&'\n charlimit = case enc\n when Encoding::UTF_8; 0x10ffff\n when Encoding::ISO_8859_1; 256\n else 128\n end\n string = string.b\n string.gsub!(/&(apos|amp|quot|gt|lt|\\#[0-9]+|\\#[xX][0-9A-Fa-f]+);/) do\n match = $1.dup\n case match\n when 'apos' then \"'\"\n when 'amp' then '&'\n when 'quot' then '\"'\n when 'gt' then '>'\n when 'lt' then '<'\n when /\\A#0*(\\d+)\\z/\n n = $1.to_i\n if n < charlimit\n n.chr(enc)\n else\n \"&##{$1};\"\n end\n when /\\A#x([0-9a-f]+)\\z/i\n n = $1.hex\n if n < charlimit\n n.chr(enc)\n else\n \"&#x#{$1};\"\n end\n else\n \"&#{match};\"\n end\n end\n string.force_encoding enc\n end",
"def escape(string)\n out = +\"\"\n string.chars.each do |char|\n escape = nil\n case char\n when \"\\0\"\n escape = '0'\n when \"\\n\"\t\t\t\t# Must be escaped for logs */\n escape= 'n'\n when \"\\r\"\n escape= 'r';\n when \"\\\\\"\n escape= '\\\\';\n when '\\''\n escape= '\\'';\n when '\"'\t\t\t\t# Better safe than sorry */\n escape= '\"';\n end\n\n if escape\n out << '\\\\'\n out << escape\n else\n out << char\n end\n end\n out\n end",
"def strip_ansi(str)\n str.gsub(ANSI, '')\n end",
"def strip_ansi(str)\n str.gsub(\n ANSI_MATCHR, \"\"\n )\n end",
"def clear_utf_symbols(string)\n string.gsub(/[»«]/, '')\n end",
"def strip_control_and_extended_characters\n self.chars.inject(\"\") do |str, char|\n if char.ascii_only? and char.ord.between?(32,126)\n str << char\n end\n str\n end\n end",
"def strip(s)\n Sanitize.clean(s)\n end",
"def escape_string (string)\n string.gsub(/([\\x00-\\x1f\\x21-\\x2f\\x3a-\\x40\\x5b-\\x5e\\x60\\x7b-\\x7f])/, '\\\\\\\\\\\\1')\n end",
"def escape_string(str)\n return if str.nil?\n str.gsub(/[\\0\\n\\r\\\\\\'\\\"\\x1a]/) do |s|\n case s\n when \"\\0\" then \"\\\\0\"\n when \"\\n\" then \"\\\\n\"\n when \"\\r\" then \"\\\\r\"\n when \"\\x1a\" then \"\\\\Z\"\n else \"\\\\#{s}\"\n end\n end\nend",
"def remove_special_characters(string)\n string.gsub(/[~\"'&#%]/, '-')\n end",
"def scrub(text)\n return '' unless text.present?\n\n text.to_s.gsub(/[\\r\\n]/, ' ').gsub('%', '%25')\n end",
"def stripped(string, options = {})\n string ? Vidibus::Textile.new(string).to_text(options) : \"\"\n end",
"def u(str)\n CGI.escape(str)\n end",
"def remove_crap(myString)\n\treturn myString.gsub(/\\v/, '/')\nend",
"def sanitize_string(string)\n return string.encode(\"UTF-16BE\", :invalid=>:replace, :undef => :replace, :replace=>\"?\")\n .encode(\"UTF-8\")\n .gsub(/[\\u0080-\\u009F]/) {|x| x.getbyte(1).chr.force_encoding('windows-1252').encode('utf-8') }\n .gsub(/\\\"/, \"\\\\\\\"\") # escape double quotes in string\n end",
"def esc_ht str\n\t\treturn Escape.html str\n\tend",
"def strip_bad_chars(text)\n text.gsub!(/\"/, \"'\");\n text.gsub!(/\\u2018/, \"'\");\n text.gsub!(/[”“]/, '\"');\n text.gsub!(/’/, \"'\");\n return text\nend",
"def unescape(string)\n string.tr('+', ' ').gsub(/((?:%[0-9a-fA-F]{2})+)/n) do\n [$1.delete('%')].pack('H*')\n end\n\tend",
"def sanitize_escape_sequences(msg)\n msg = msg.gsub(\"\\r\", \"[CR]\")\n msg = msg.gsub(\"\\n\", \"[LF]\")\n msg = msg.gsub(/\\e\\[A/, '[CUU]')\n msg = msg.gsub(/\\e\\[B/, '[CUD]')\n msg = msg.gsub(/\\e\\[2K/, '[CLEAR]')\n msg = msg.gsub(/#{3.chr}/, '[ETX]')\n msg = msg.gsub(/#{4.chr}/, '[EOT]')\n msg = msg.gsub(/#{7.chr}/, '[BELL]')\n msg = msg.gsub(/#{8.chr}/, '[BS]')\n msg = msg.gsub(/#{9.chr}/, '[TAB]')\n msg = msg.gsub(/#{24.chr}/, '[CAN]')\n msg = msg.gsub(/#{27.chr}/, '[ESC]')\n msg = msg.gsub(/#{127.chr}/, '[DEL]')\n msg\n end",
"def get_unescaped(element, path='.')\n result = self.get(element, path)\n CGI.unescape(result) if result\n end",
"def escape_string(s)\n retval = StringBuffer.new\n i = 0\n while i < s.length\n retval.append(escape_char(s.char_at(i)))\n i += 1\n end\n return retval.to_s\n end"
] | [
"0.7379509",
"0.7003302",
"0.6750514",
"0.6705682",
"0.64984244",
"0.6497861",
"0.6343268",
"0.6336039",
"0.63255036",
"0.6260806",
"0.62292373",
"0.62266177",
"0.61973006",
"0.61847883",
"0.61642426",
"0.6094663",
"0.6092739",
"0.6078029",
"0.60523933",
"0.6012545",
"0.59715503",
"0.5925813",
"0.5925446",
"0.59243816",
"0.58777195",
"0.58706987",
"0.58570904",
"0.5848059",
"0.58429146",
"0.58347046",
"0.5834261",
"0.5831779",
"0.58299357",
"0.580297",
"0.580297",
"0.5781242",
"0.57796675",
"0.57750386",
"0.5770619",
"0.5760317",
"0.57410735",
"0.57306564",
"0.57284015",
"0.57180405",
"0.5714704",
"0.5695306",
"0.5694547",
"0.5693887",
"0.5672467",
"0.56694174",
"0.5665794",
"0.5662741",
"0.5656474",
"0.56487715",
"0.56417143",
"0.56363624",
"0.5621341",
"0.56157815",
"0.56025386",
"0.5601999",
"0.5598413",
"0.5588528",
"0.55865663",
"0.55789286",
"0.557828",
"0.5570838",
"0.555809",
"0.5555914",
"0.5547235",
"0.5546079",
"0.55328923",
"0.5528417",
"0.5510956",
"0.55097544",
"0.5505385",
"0.55035776",
"0.5499277",
"0.5489952",
"0.5489264",
"0.5484158",
"0.54753304",
"0.5471556",
"0.5469071",
"0.54582316",
"0.54554164",
"0.54537165",
"0.5446108",
"0.5444557",
"0.54377663",
"0.543104",
"0.5412953",
"0.5406476",
"0.54035145",
"0.5401677",
"0.5398684",
"0.53838545",
"0.5382059",
"0.5373118",
"0.5371128"
] | 0.600817 | 21 |
Converts the value of an accept_date field to a Time object. | def parse_accept_date(string)
parts = string.split(/[\/:.]/)
Time.local(*parts.values_at(2, 1, 0, 3..6))
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def accepted_date_time=(value)\n @accepted_date_time = value\n end",
"def accepted_date_time\n return @accepted_date_time\n end",
"def to_time\n return self.to_i.to_time if self =~ DIGIT_ONLY_REGEX\n if self =~ US_DATE_REGEX\n Time.parse(us_date_to_iso_str)\n elsif self =~ JSON_DATE_REGEX\n json_date_to_time\n else\n Time.parse(self)\n end\n end",
"def invite_date_time=(value)\n @invite_date_time = value\n end",
"def to_time(form = :utc)\n ::Time.send(\"#{form}_time\", *ParseDate.parsedate(self)[0..5].map {|arg| arg || 0})\n end",
"def date_value\n Time.parse(value) if value.present?\n end",
"def convert_to_time(value)\n value = ::Date.parse(value) if value.is_a?(::String)\n value = ::Date.civil(*value) if value.is_a?(::Array)\n ::Time.utc(value.year, value.month, value.day)\n end",
"def to_time(form = :utc)\n ::Time.send(\"#{form}_time\", *::Date._parse(self, false).values_at(:year, :mon, :mday, :hour, :min, :sec).map { |arg| arg || 0 })\n end",
"def to_time\n begin\n Time.parse(self)\n rescue => e\n raise Sequel::Error::InvalidValue, \"Invalid time value '#{self}' (#{e.message})\"\n end\n end",
"def to_time\n value\n end",
"def convert_from_date_to_time(x)\n if x.class == Date\n x.to_time + 12.hours\n elsif x.class == DateTime || x.class == Time\n x\n end\nend",
"def parse_time\n time_str = @request[FTIME].sub(REGEX_TIME_FIX) { \"#{$1} #{$2}\" }\n Time.parse(time_str) rescue nil\n end",
"def to_time(form = :utc)\n ::Time.send(\"#{form}\", year, month, day)\n end",
"def typecast_to_time(value)\n if value.kind_of?(Hash)\n typecast_hash_to_time(value)\n else\n Time.parse(value.to_s)\n end\n end",
"def post_process_datetime( val )\n\t\t\treturn Time.parse( val )\n\t\trescue ArgumentError\n\t\t\treturn nil\n\t\tend",
"def for value\n if value.is_a? Numeric\n Time.at value\n elsif value.respond_to? :to_s\n Time.parse value.to_s\n else\n value.to_time\n end\n rescue Exception\n raise ArgumentError, \"unable to convert #{value.inspect} to a Time object\"\n end",
"def time\n Time.parse(@data['date'])\n end",
"def as_of_time\n Conversions.string_to_utc_time attributes_before_type_cast['as_of_time']\n end",
"def convert_time(t)\n case t\n when nil then nil\n when Date then t.to_time.utc.iso8601(3)\n when Time then t.utc.iso8601(3)\n when String then Time.parse(t).utc.iso8601(3)\n else raise \"Invalid time format '#{t.class}'. Valid options are Time, Date, or String\"\n end\n rescue StandardError => e\n raise \"Failed to parse time value '#{t}'. #{e.message}\"\n end",
"def convert_to_time(value)\n time = Mongoid::Config.use_activesupport_time_zone? ? ::Time.zone : ::Time\n case value\n when ::String\n time.parse(value)\n when ::DateTime\n time.local(value.year, value.month, value.day, value.hour, value.min, value.sec)\n when ::Date\n time.local(value.year, value.month, value.day)\n when ::Array\n time.local(*value)\n else\n value\n end\n end",
"def completion_date_to_time\n if completion_date_type == \"completion_day\"\n return completion_date_value.to_i.days.ago\n elsif completion_date_type == \"completion_week\"\n return completion_date_value.to_i.weeks.ago\n elsif completion_date_type == \"completion_month\"\n return completion_date_value.to_i.months.ago\n elsif completion_date_type == \"completion_year\"\n return completion_date_value.to_i.years.ago\n elsif completion_date_type == \"completion_hour\"\n return completion_date_value.to_i.hours.ago\n end\n end",
"def typecast_hash_to_time(value)\n Time.utc(*extract_time(value))\n end",
"def to_time\n begin\n Vpim.decode_date_time_list(value).collect do |d|\n # We get [ year, month, day, hour, min, sec, usec, tz ]\n begin\n if(d.pop == \"Z\")\n Time.gm(*d)\n else\n Time.local(*d)\n end\n rescue ArgumentError => e\n raise Vpim::InvalidEncodingError, \"Time.gm(#{d.join(', ')}) failed with #{e.message}\"\n end\n end\n rescue Vpim::InvalidEncodingError\n Vpim.decode_date_list(value).collect do |d|\n # We get [ year, month, day ]\n begin\n Time.gm(*d)\n rescue ArgumentError => e\n raise Vpim::InvalidEncodingError, \"Time.gm(#{d.join(', ')}) failed with #{e.message}\"\n end\n end\n end\n end",
"def to_time(t)\n if t.is_a?(::Time) then t\n else from_string(to_string(t)) end\n end",
"def submitted_date_time=(value)\n @submitted_date_time = value\n end",
"def submitted_date_time=(value)\n @submitted_date_time = value\n end",
"def validate_time(time)\n\t\tif time.is_a? Time\n\t\t\treturn time\n\t\telse\n\t\t\treturn Time.parse(time)\n\t\tend\n\tend",
"def time_wrap(obj)\n obj.kind_of?(String) ? Time.parse(obj) : obj\n end",
"def to_datetime\n @date_time_value\n end",
"def visit_date_time(binding_type)\n dt_str = DateTimeConverter.convert_from_datetime(input)\n self.result = binding_type.definition.new_value(dt_str)\n end",
"def typecast_to_time(value)\n case value\n when Float # JSON oj already parses Time, FTW.\n Time.at(value).utc\n when Hash\n typecast_hash_to_time(value)\n else\n typecast_iso8601_string_to_time(value.to_s)\n end\n rescue ArgumentError\n nil\n rescue TypeError\n nil\n end",
"def time\n Types::Time.deserialize(@time)\n end",
"def coerce_time(value, options = {})\n value = coerce_string(value, options)\n return if !value || value.empty?\n\n begin\n Time.parse(value).utc\n rescue ArgumentError\n nil\n end\n end",
"def to_time(form = :utc)\n return nil if self.blank?\n d = ::Date._parse(self, false).values_at(:year, :mon, :mday, :hour, :min, :sec, :sec_fraction).map { |arg| arg || 0 }\n d[6] *= 1000000\n ::Time.send(\"#{form}_time\", *d)\n end",
"def convert_to_time(value)\n time = Mongoid::Config.use_activesupport_time_zone? ? ::Time.zone : ::Time\n case value\n when ::String\n time.parse(value)\n when ::DateTime\n return value if value.utc? && Mongoid.use_utc?\n time.local(value.year, value.month, value.day, value.hour, value.min, value.sec)\n when ::Date\n time.local(value.year, value.month, value.day)\n when ::Array\n time.local(*value)\n else\n value\n end\n end",
"def invite_date_time\n return @invite_date_time\n end",
"def as_of_time\n Conversions.string_to_utc_time attributes['as_of_time']\n end",
"def convert_uploadDate(v, opts = {})\n v.is_a?(Time) ? v : v['$date'] ? Time.parse(v['$date']) : upload_date\n end",
"def visit_date_time(binding_type)\n self.result = binding_type.to_ruby(input)\n end",
"def convert_date_time(v)\n yield v\n rescue InvalidValue\n case @convert_invalid_date_time\n when nil, :nil\n nil\n when :string\n v\n else \n raise\n end\n end",
"def attribute_to_time(time)\n time = Time.local(time.year, time.month, time.day) if time.is_a?(Date)\n time = Time.parse(time) if time.is_a?(String)\n time\n end",
"def time(value)\n _parse_time(value)\n end",
"def parsed_time(timezone = patient.timezone)\n self.datetime.in_time_zone(timezone)\n end",
"def fulfilled_date_time=(value)\n @fulfilled_date_time = value\n end",
"def coerce_time(value, options = {})\n value = coerce_string(value, options)\n return nil if !value || value.empty?\n\n begin\n Time.parse(value)\n rescue ArgumentError\n nil\n end\n end",
"def poa_time\n # Check if there's a recipient, and if it has a timezone, it it does use that to set tz\n representative_tz_from_recipient = @hearing.representative_recipient&.timezone\n return normalized_time(representative_tz_from_recipient) if representative_tz_from_recipient.present?\n # If there's a virtual hearing, use that tz even if it's empty\n return normalized_time(@hearing.virtual_hearing[:representative_tz]) if @hearing.virtual_hearing.present?\n\n # No recipient and no virtual hearing? Use the normalized_time fallback\n normalized_time(nil)\n end",
"def get_arrival_time\n DateTime.new(\n params[:date][:year].to_i,\n params[:date][:month].to_i,\n params[:date][:day].to_i,\n params[:date][:hour].to_i,\n params[:date][:minute].to_i\n )\n end",
"def validate(val)\n if ((val.is_a?(String)) &&\n # This could be expanded. @TODO\n (m = val.match(/([0-9]{4})-([0-9]{2})-([0-9]{2})/)))\n return Time.new(m[1], m[2], m[3])\n elsif (val.respond_to?(:to_time))\n return val.to_time\n elsif (val.is_a?(Time))\n return val\n else\n return nil\n end\n end",
"def parse_date\n REGEX_DATE.match(@request[FTIME]) ? Date.parse($1) : nil\n end",
"def datetime(date)\n if date.class == String\n date = Time.parse(date)\n end\n date\n end",
"def to_smart_time(form = :utc)\n# 1) Research parsedate to see how it's parsing\n# 2) Refacter the parse to insert the current values from the top down,\n# as they don't exist. Ignore seconds completely unless given by the string.\n ::Time.send(\"#{form}_time\", *ParseDate.parsedate(self)[0..5].map {|arg| arg || 0})\n end",
"def to_time\n self\n end",
"def arrival_time\n DateTime.parse(@raw_data[:ArrivalDateTime])\n end",
"def received_date_time=(value)\n @received_date_time = value\n end",
"def received_date_time=(value)\n @received_date_time = value\n end",
"def unsubmitted_date_time=(value)\n @unsubmitted_date_time = value\n end",
"def sender_date_time=(value)\n @sender_date_time = value\n end",
"def parse_filtered_time(time = nil)\n case time\n when String then Time.zone.parse(time)\n when nil then Time.zone.now\n when Time, ActiveSupport::TimeWithZone then time.in_time_zone\n else raise \"Invalid time: #{time.inspect}\"\n end\n end",
"def valid_time_or_date?(value)\n value.is_a?(Time) || value.is_a?(Date) || value.is_a?(ActiveSupport::TimeWithZone)\n end",
"def datetime(date)\n if date.class == String\n date = Time.parse(date)\n end\n date\n end",
"def to_time\r\n #MES- From activerecord-1.13.2\\lib\\active_record\\connection_adapters\\abstract\\schema_definitions.rb\r\n # Function was called string_to_time\r\n time_array = ParseDate.parsedate(self)[0..5]\r\n # treat 0000-00-00 00:00:00 as nil\r\n #MES- Next line WAS the following, but we don't have access to Base here\r\n #Time.send(Base.default_timezone, *time_array) rescue nil\r\n Time.utc(*time_array) rescue nil\r\n end",
"def time_date_hm ; time_date && time_date.strftime(\"%H:%M\") ; end",
"def to_sequel_time\n begin\n Sequel.datetime_class.parse(self)\n rescue => e\n raise Sequel::Error::InvalidValue, \"Invalid time value '#{self}' (#{e.message})\"\n end\n end",
"def string_to_time(string)\n super(handle_date_parse_input(string))\n end",
"def arrival_time\n Time.zone.parse(@arrival_time) if @arrival_time\n end",
"def date_time=(date_time)\n @date_time = DateTime.parse(date_time)\n end",
"def completion_date_to_time\n Chronic.parse(\"#{completion_date_value} #{completion_date} ago\")\n end",
"def date\n if value = self['date']\n begin\n # Rely on Ruby's standard time.rb to parse the time.\n (Time.rfc2822(value) rescue Time.parse(value)).localtime\n rescue\n # Exceptions during time parsing just cause nil to be\n # returned.\n end\n end\n end",
"def time\n @originalTime.gsub(/[ (AM|PM)]/, '').split(':').map(&:to_f)\n end",
"def expose_time\n return @expose_time if @expose_time\n\n expose_date = params[:game] ? params[:game][:expose_date] : params[:expose_date]\n expose_hour = params[:game] ? params[:game][:expose_hour] : params[:expose_hour]\n return nil unless expose_hour\n\n if expose_date && !expose_date.empty?\n expose_hour = expose_hour[/^(\\d{1,2}:\\d{1,2})$/, 1] if expose_hour && !expose_hour.empty?\n expose_hour = '0:0' unless expose_hour && !expose_hour.empty?\n @expose_time = Time.strptime(expose_date + '-' + expose_hour, '%m/%d/%Y-%H:%M')\n else\n @expose_time = nil\n end\n end",
"def time_value?(input)\n return input.is_a?(Time) || input.is_a?(Date)\n end",
"def sent_date_time=(value)\n @sent_date_time = value\n end",
"def castTime(hash={})\n\t\troundTime(hash)\n\tend",
"def parse_time(time)\n if time.is_a? Time\n return Time.parse time.httpdate\n elsif time.is_a String\n return Time.parse(Time.parse(time).httpdate)\n else\n raise \"Argument Error, #{time} is not a valid time\"\n end\n end",
"def s_time\n to_form_time(start_time.getlocal)\n end",
"def to_time\n raise NotImplementedError\n end",
"def apply_validations_for_time\n flex_column_class.validates_each field_name do |record, attr, value|\n record.errors.add(attr, \"must be a Time\") if value && (! value.kind_of?(Time))\n end\n end",
"def typecast_hash_to_datetime(value)\n DateTime.new(*extract_time(value))\n end",
"def time_to_accept\n if Time.now > accept_deadline\n 0\n else\n accept_deadline - Time.now\n end\n end",
"def parseTime(time)\n if(time.nil?)\n return nil ;\n elsif(time.is_a?(String))\n return Time.parse(time, DefaultDate) ;\n elsif(time.is_a?(Time))\n return time ;\n else\n raise \"can not convert to Time Object from :\" + time.inspect ;\n end\n end",
"def time(value)\n if value.respond_to? :to_time\n value.to_time\n elsif value.is_a? Time\n value\n elsif value.respond_to? :new_offset\n d = value.new_offset 0\n t = Time.utc d.year, d.mon, d.mday, d.hour, d.min, d.sec + d.sec_fraction\n t.getlocal\n elsif value.respond_to? :mday\n Time.local(value.year, value.mon, value.mday)\n elsif value.is_a? Numeric\n Time.at value\n elsif value.nil? or value.empty?\n nil\n else\n Time.parse value.to_s\n end\n rescue ArgumentError => boom\n raise boom\n rescue Exception\n raise ArgumentError, \"unable to convert #{value.inspect} to a Time object\"\n end",
"def datetime_timestamp\n return Date.parse(self.date).to_time\n end",
"def typecast_value_time(value)\n case value\n when Time\n if value.is_a?(SQLTime)\n value\n else\n # specifically check for nsec == 0 value to work around JRuby 1.6 ruby 1.9 mode bug\n SQLTime.create(value.hour, value.min, value.sec, (value.respond_to?(:nsec) && value.nsec != 0) ? value.nsec/1000.0 : value.usec)\n end\n when String\n Sequel.string_to_time(value)\n when Hash\n SQLTime.create(*[:hour, :minute, :second].map{|x| (value[x] || value[x.to_s]).to_i})\n else\n raise Sequel::InvalidValue, \"invalid value for Time: #{value.inspect}\"\n end\n end",
"def time_parser\n ::Time.zone || ::DateTime\n end",
"def returned_date_time=(value)\n @returned_date_time = value\n end",
"def type\n 'Edm.Time'\n end",
"def typecast_hash_to_date(value)\n ::Date.new(*extract_time(value)[0, 3])\n end",
"def upload_date_time=(value)\n @upload_date_time = value\n end",
"def convert_to_time(obj)\n case\n when obj.respond_to?(:seconds)\n obj.seconds >= MINIMUM_SECONDS && obj.seconds <= MAXIMUM_SECONDS ? make_time( obj.seconds ) : nil\n when obj.instance_of?(Time)\n make_time( obj.hour.hours + obj.min.minutes + obj.sec.seconds )\n else\n nil\n end\n end",
"def def_date_time sym, name=nil\n def_transform(sym) {|v| \n next v if v == nil || v.is_a?(Time)\n Time.parse(v.to_s).iso8601 rescue v\n }\n def_checker(sym) { |v|\n # v must be parseable as a time\n next true if v == nil || v.is_a?(Time)\n Time.parse(v.to_s) rescue next false\n true\n }\n def_alias sym, name if name \n end",
"def def_date_time sym, name=nil\n def_transform(sym) {|v| \n next v if v == nil || v.is_a?(Time)\n Time.parse(v.to_s).iso8601 rescue v\n }\n def_checker(sym) { |v|\n # v must be parseable as a time\n next true if v == nil || v.is_a?(Time)\n Time.parse(v.to_s) rescue next false\n true\n }\n def_alias sym, name if name \n end",
"def validate_and_parsetime(value)\n return unless value\n Time.iso8601(value).getutc.to_i\n rescue ArgumentError => e\n logger.error \"Couldn't parse time from '#{value}'\"\n nil\n end",
"def admitted_at\n if get(\"ADM_DATE\")\n Time.parse get(\"ADM_DATE\")\n else\n nil\n end\n end",
"def parse_time(time)\n case time\n when Time\n time\n when Integer, Float\n Time.at(time)\n else\n Time.parse(time.to_s)\n end\n end",
"def set_time_as_datetime(options)\n options[:type] = DateTime if options[:type] == Time\n end",
"def received_at\n\tTime.parse params['payment_date']\n end",
"def posted\n # Will interpret the stored date as being in the timezone set in Time.zone\n Time.zone.parse(posted_before_type_cast)\n end",
"def fulfilled_date_time\n return @fulfilled_date_time\n end",
"def to_datetime\n to_time.to_datetime\n end"
] | [
"0.6977994",
"0.64472353",
"0.6083102",
"0.6002853",
"0.59228677",
"0.5916261",
"0.5907152",
"0.5849504",
"0.576029",
"0.5745835",
"0.574527",
"0.55687726",
"0.5558864",
"0.5558081",
"0.554975",
"0.55393803",
"0.5529871",
"0.55263627",
"0.5503998",
"0.5499917",
"0.54936457",
"0.5484408",
"0.5473519",
"0.54662323",
"0.5459186",
"0.5459186",
"0.54560494",
"0.5448857",
"0.54409814",
"0.54402053",
"0.5433417",
"0.5432903",
"0.5427209",
"0.54264355",
"0.5418388",
"0.54109716",
"0.5400399",
"0.5399556",
"0.5395272",
"0.53852427",
"0.5381528",
"0.53799266",
"0.5379353",
"0.53673583",
"0.53287923",
"0.5327016",
"0.5322836",
"0.5298967",
"0.5296923",
"0.5295507",
"0.5290389",
"0.5281767",
"0.52618605",
"0.52529025",
"0.52529025",
"0.52470535",
"0.522824",
"0.522774",
"0.5226967",
"0.5221436",
"0.52035",
"0.5201114",
"0.51948017",
"0.5176015",
"0.51722807",
"0.5158312",
"0.5157768",
"0.51545584",
"0.5153443",
"0.5141755",
"0.51411545",
"0.5129957",
"0.511614",
"0.51136786",
"0.5103785",
"0.50878316",
"0.5067934",
"0.5067124",
"0.50626624",
"0.50620794",
"0.5057311",
"0.5049389",
"0.50325257",
"0.50247747",
"0.50130785",
"0.498378",
"0.49825984",
"0.49805582",
"0.49718937",
"0.49708548",
"0.49708548",
"0.4956438",
"0.49552494",
"0.4938418",
"0.49373898",
"0.49355465",
"0.49297664",
"0.4925115",
"0.4923748"
] | 0.49171776 | 100 |
Converts a captured headers string to an Array. | def decode_captured_headers(string)
string.split('|', -1).map! { |header| unescape(header) }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def header_array\n hash = get_headers \n arr = []\n hash.each do |k, v|\n\tv.each do |i|\n\tarr << k + \"=\" + i\n\tend\nend\n arr\nend",
"def headers_from_array(arr)\n clear_headers\n arr = arr.split(\"\\r\\n\\r\\n\").first if arr.class == String\n arr.each do |line|\n next if (line.empty? || line =~ /^(GET|POST)/)\n k,v = line.split(\":\",2)\n self.headers[k.strip] = v.strip\n end\n nil\n end",
"def split_header_string(header_string)\n range_spec, *params = header_string.split(';')\n [range_spec.strip, params.map { |s| s.strip }]\n end",
"def parse_headers(raw_headers)\n # raw headers from net_http have an array for each result. Flatten them out.\n raw_headers.inject({}) do |remainder, (k, v)|\n remainder[k] = [v].flatten.first\n remainder\n end\n end",
"def parse_headers raw_headers\n\t\theaders = Hash.new\n\n\t\t# Store values as hash, but don't include duplicate values\n\t\tremove_fws(raw_headers).map do |line|\n\t\t\tkey, value = line.split(\": \", 2)\n\t\t\theaders[key] ||= []\n\t\t\theaders[key] << value unless headers[key].include? value\n\t\tend\n\n\t\t# Pop value from array if there's only one value\n\t\theaders.each{ |key, value| headers[key] = value.pop if value.length == 1 }\n\tend",
"def parse_headers(raw_headers)\n headers = {}\n raw_headers.each do |h|\n if h =~ /^# *([a-zA-Z_]+) *:(.*)/\n h_key = $1.downcase.intern\n h_value = $2.split(\",\").collect { |v| v.strip }\n if h_value.length > 0 # ignore empty headers\n headers[h_key] = h_value.length > 1 ? h_value : h_value[0]\n end\n end\n end\n \n return headers\n end",
"def parse_header_line(header_str)\n @headers = header_str.split(',')\n @headers.map! do |h|\n h.gsub!('\"','')\n h.strip!\n h.underscore.to_sym\n end\n @headers\n end",
"def headers\r\n # NB: return value is supposed to be an array of strings\r\n @headers || []\r\n end",
"def headers\n begin\n JSON(data['message_headers'])\n rescue => e\n return []\n end\n end",
"def headers\n @headers.to_a\n end",
"def headers\n @headers.to_a\n end",
"def parse_header( data )\n k,v = data.split(\"\\0\", 2)\n return [k, v.delete(\"\\0\")]\n end",
"def parse_header_string(header_string)\n status, headers = nil, {}\n return [status, headers] unless header_string\n\n header_string.split(/\\r\\n/).each do |header|\n if header =~ %r|^HTTP/1.[01] \\d\\d\\d (.*)|\n status = $1\n else\n parts = header.split(':', 2)\n unless parts.empty?\n parts[1].strip! unless parts[1].nil?\n if headers.has_key?(parts[0])\n headers[parts[0]] = [headers[parts[0]]] unless headers[parts[0]].kind_of? Array\n headers[parts[0]] << parts[1]\n else\n headers[parts[0]] = parts[1]\n end\n end\n end\n end\n\n [status, headers]\n end",
"def proper_headers(arr)\n\t\tarr.first.map! {|i| i.split(/(?=[A-Z])/).join(' ')}\n\tend",
"def split_header_value(str)\n str.scan(/((?:\"(?:\\\\.|[^\"])+?\"|[^\",]+)+)\n (?:,\\s*|\\Z)/xn).collect{|v| v[0] }\nend",
"def headers\n list = @response.header_str.split(/[\\r\\n]+/).map(&:strip)\n Hash[list.flat_map{ |s| s.scan(/^(\\S+): (.+)/) }.map { |pair|\n [pair.first.to_s.camelcase, pair.second]\n }]\n end",
"def parse_to_array(line_as_string)\n as_array = line_as_string.split(\" \")\nend",
"def unify_headers(headers)\n lines = []\n headers.each_pair do |k, v|\n lines << v.map { |val| \"#{k}: #{val}\" }\n end\n\n logger.debug \"Unified headers #{lines.inspect}\" if logger_debug?\n lines.flatten.sort\n end",
"def headers\n\t\t\thdr = @curb.header_str\n\t\t\tself.class.recode(log?, @curb.content_type, hdr) ?\n\t\t\t\tself.class.parse_headers(hdr) :\n\t\t\t\tself.class.parse_headers(@curb.header_str) # recode failed\n\t\tend",
"def parse_headers(headers_hash)\n header_string = \"\"\n for header in headers_hash.select { |k,v| k.match(\"^HTTP.*\") } do\n header_string += header[0]+\":\"+header[1]+\"|\"\n end\n return header_string\n end",
"def parse_headers\n headers = {}\n @request.lines[1..-1].each do |line|\n # puts line.inspect\n # puts line.split.inspect\n return headers if line == \"\\r\\n\" # Because HTTP header's last line will be /r/n we return bc we're done\n header, value = line.split\n header = normalize(header)\n headers[header] = value\n end\n \n return headers\n end",
"def normalise_headers(headers)\n norm_headers = []\n\n headers.each_with_index do |header_name, i|\n # Process the current header\n normalised_header = normalise_header header_name\n\n # Add header name to index of normalised header names\n norm_headers[i] = normalised_header\n end\n\n norm_headers\n end",
"def postmark_headers\n array = []\n header_fields.each do |field|\n key = field.name.downcase\n # @see https://github.com/wildbit/postmark-gem/blob/master/lib/postmark/message_extensions/mail.rb#L74\n # @see https://github.com/wildbit/postmark-gem/pull/36#issuecomment-22298955\n unless %w(from to cc bcc reply-to subject tag content-type date).include?(key) || (Array === field.value && field.value.size > 1)\n array << {'Name' => field.name, 'Value' => field.value}\n end\n end\n array\n end",
"def get_headers_\n hin = ATS::Headers_in.new\n hin.all.reduce({}) do |memo, pair| \n memo[pair.first.downcase] = pair[1]; memo\n end\n end",
"def decode(buf)\n list = []\n decoding_pseudo_headers = true\n until buf.empty?\n next_header = @cc.process(header(buf))\n next if next_header.nil?\n is_pseudo_header = next_header.first.start_with? ':'\n if !decoding_pseudo_headers && is_pseudo_header\n fail ProtocolError, 'one or more pseudo headers encountered after regular headers'\n end\n decoding_pseudo_headers = is_pseudo_header\n list << next_header\n end\n list\n end",
"def headers(headers); end",
"def seperate_headers()\n\t\[email protected](\"\\n\\n\")[0].split(\"\\n\", 2)[1]\n\tend",
"def parseHeaders(request) \n headers = {};\n\n # Loop through headers\n request.lines[1..-1].each do |line|\n # If we are moving to the next line, return what we currently have\n return headers if line == \"\\r\\n\"\n\n # Structure data\n header, value = line.split\n header = header.gsub(\":\", \"\").downcase.to_sym\n headers[header] = value\n end\nend",
"def analyze_headers\n# @chron_list = nil\n chrons = []\n extractor.headers.each_with_index do |v, colnum|\n pv = ParsedValue.new(v)\n if !pv.chron.empty? then\n chrons << pv.chron.first\n if colnum < @ncolumns\n# puts \"Setting the column role to #{pv.chron.first}\"\n @columns[colnum].role = pv.chron.first\n end\n end\n end\n # p chrons\n# @chron_list = chrons unless chrons.empty?\n end",
"def parse_header_contents\n text = @src[\"contents\"]\n text.rstrip!\n id_match = HEADER_ID.match(text)\n if id_match\n id = id_match[\"id\"]\n text = text[0...-id_match[0].length]\n text.rstrip!\n end\n [text, id]\n end",
"def set_headers(v)\n @headers = []\n if v\n v.split('&').each do |x|\n @headers << x.split(/=/, 2)\n end\n end\n end",
"def parse_header_contents; end",
"def _extract_headers(str)\n \n asa = str.split(AMP)\n @headers = {}\n esa = nil\n hv = nil\n asa.each do |hdr|\n esa = hdr.split(EQL)\n hname = SipperUtil.methodize(esa[0])\n if esa[1]\n \n if esa[1] =~ DQ\n hv = esa[1][1...-1]\n else\n hv = esa[1]\n end\n hv = CGI.unescape(hv)\n @headers[hname] = SipperUtil.find_parser_and_parse(hname, hv, true)\n end \n end \n end",
"def get_headers\nheader_values = {}\n i = 1\n # while !params[:header][:type_.to_s + \"#{i}\"].nil?\n while !params[:header_values_.to_s + \"#{i}\"].nil?\n\t value = params[:header_values_.to_s + \"#{i}\"].map!{|i| CGI::unescape(i).gsub(\"\\\"\", \"'\")}\n \theader_values[params[:header][:type_.to_s + \"#{i}\"]] = value\n i += 1\n end\n header_values\nend",
"def process_headers\n { \"Content-Type\" => content_type }.tap do |result|\n headers.each do |header|\n result[header.name] = header.value\n end\n end\n end",
"def stringify_headers headers\n headers.inject({}) do |result, (key, value)|\n if key.is_a? Symbol\n key = key.to_s.split(/_/).map { |w| w.capitalize }.join('-')\n end\n if 'CONTENT-TYPE' == key.upcase\n target_value = value.to_s\n result[key] = MIME::Types.type_for_extension target_value\n elsif 'ACCEPT' == key.upcase\n # Accept can be composed of several comma-separated values\n if value.is_a? Array\n target_values = value\n else\n target_values = value.to_s.split ','\n end\n result[key] = target_values.map { |ext| MIME::Types.type_for_extension(ext.to_s.strip) }.join(', ')\n else\n result[key] = value.to_s\n end\n result\n end\n end",
"def extract_headers_from(raw_headers)\n raw_headers.\n to_h.\n keep_if { |header, _value| pagination_headers.include?(header) }.\n transform_keys(&:to_sym).\n transform_values(&:to_i)\n end",
"def headers=(_arg0); end",
"def headers=(_arg0); end",
"def headers=(_arg0); end",
"def headers=(_arg0); end",
"def test_data_headers(string)\n\n\t\theaders = test_data_response(string).headers\n\n\tend",
"def parse_header_lines\n if @parsed_values[\"\"].nil? || @parsed_values[\"\"][1].nil?\n @parsed_values[\"\"] = {}\n return\n end\n\n headers = {}\n # Heading lines may have escaped newlines in them\n @parsed_values[\"\"][1].split(/\\\\n/).each do |line|\n next if line.size == 0\n\n if line =~ /(.*?):(.*)/\n key, value = $1, $2\n if headers[key] && headers[key].size > 0\n @errors << [\"Duplicate header line: #{line}\"]\n elsif key =~ /#-#-#-#-#/\n @errors << [\"Marker in header line: #{line}\"]\n else\n headers[key] = value\n end\n else\n @errors << [\"Malformed header #{line}\"]\n end\n end\n\n @parsed_values[\"\"] = headers\n end",
"def headers\n @headers.reject {|k, v| k == :body }.map do |k, v|\n translate_header_name(k) + ': ' + v + \"\\n\"\n end.join\n end",
"def headers\n return @args[\"headers\"]\n end",
"def array_from_string string\n # takes the string found when params tries to return an array, and reconstruct the array.\n array = string.split(/[^Q1234567890]+/)\n array.delete(\"\")\n array\n end",
"def separate_header(header)\n xsc, non_xsc, xsc_key = {}, \"\", nil\n\n header.split(\"\\n\").each do |line|\n if line =~ /^X-SC-([^:]+):(.*)/ni\n xsc_key = $1.downcase\n xsc[xsc_key] = $2.to_s.strip\n\n elsif line =~ /^\\s/ && xsc_key\n xsc[xsc_key] += \" \" + line\n\n else\n xsc_key = nil\n non_xsc += line + \"\\n\"\n end\n end\n return [xsc, non_xsc]\n end",
"def separate_header(header)\n xsc, non_xsc, xsc_key = {}, \"\", nil\n\n header.split(\"\\n\").each do |line|\n if line =~ /^X-SC-([^:]+):(.*)/i\n xsc_key = $1.downcase\n xsc[xsc_key] = $2.to_s.strip\n\n elsif line =~ /^\\s/ && xsc_key\n xsc[xsc_key] += \" \" + line\n\n else\n xsc_key = nil\n non_xsc += line + \"\\n\"\n end\n end\n return [xsc, non_xsc]\n end",
"def headers\n @headers ||= begin\n @mail.header.fields.inject({}) do |memo, field|\n name = field.name.downcase.to_s\n next memo if self.class.skipped_headers.include?(name)\n\n header = unquoted_header(name)\n memo.update(name => self.class.unescape(header))\n end\n end\n end",
"def headers\n msg['headers']||{}\n end",
"def headers\n res = parsed_headers\n if has_delta?\n res.concat(delta_headers)\n end\n res\n end",
"def params_array_from(raw_params)\n raw_params.map { |param| param.split %r/=(.+)?/ }\n end",
"def headerlist; return ['X-MXL-NoteHash', 'X-MXL-Hash', 'X-MX-Bounce']; end",
"def parse_headers!(headers)\n @filename = headers[HEADER_CONTENT_DISPOSITION].split('filename=')[1]\n @filename = @filename[1...-1] if @filename[0] == '\"' # Unquote filenames\n end",
"def csv_to_array(phrase, delimiter = ',')\n phrase.split(delimiter).collect {|p| p.lstrip.rstrip }\n end",
"def vary_header_names\n return [] unless vary = headers['Vary']\n vary.split(/[\\s,]+/)\n end",
"def params_array_from(raw_params)\n raw_params.map { |param| param.split %r/=(.+)?/ }\n end",
"def headers\n @headers ||= begin\n mail = Mail.new(self.raw_headers)\n mail.header.fields.each_with_object({}) do |field, hash|\n hash[field.name.downcase] ||= []\n hash[field.name.downcase] << field.decoded\n end\n end\n end",
"def params_array_from(raw_params)\n raw_params.map { |param| param.split %r/=(.+)?/ }\n end",
"def convert_headers(original_headers)\n original_headers.inject({}) { |r, v|\n r[\"HTTP_#{v[0].gsub('-', '_').upcase}\"] = v[1]\n r\n }\n end",
"def headers\n return @args[:headers]\n end",
"def headers_hash\n @headers_hash ||= Hash[@http_headers.split(\"\\x00\").map{|x| x.split(': ',2)}]\n end",
"def stringify_headers(headers); end",
"def split_string_to_array(str)\n @string_as_array = str.split('')\n return @string_as_array\nend",
"def parse_status_and_headers(headers_str)\n status_and_headers = headers_str.split(\"\\r\\n\")\n status_line = status_and_headers.shift\n \n # TODO: there is no support for repeating headers (like Cookie:)\n header_hash = status_and_headers.each_with_object({}) do | header, h|\n split_at = header.index(':')\n key, value = header[0...split_at], header[(split_at + 1)..-1]\n h[key] = value.strip\n end\n raise \"Invalid response status line #{status_line}\" unless status_line =~ STATUS_PAT\n \n http_version, status_code, status = $1, $2, $3\n [status_code.to_i, header_hash]\n end",
"def read_headers!; end",
"def headers\n fields.map(&:name).map(&:to_sym)\n end",
"def curl_headers(url, insecure: false)\n puts \"#{cmd = curl_command(url, insecure: insecure)}\"\n `#{cmd}`.split(\"\\r\\n\\r\\n\").map{|x| x.split(\"\\r\\n\") }\n end",
"def header(hstring=nil)\n @header ||= []\n case hstring\n when Array\n @header = hstring\n when String\n @header << hstring\n when nil\n @header\n end\n end",
"def parse_headers!(block)\n headers.each { |header| block.call(header.key, parse_value(header.value)) }\n end",
"def row_set_to_array_of_hashes(headers, row_set)\n result = Array.new\n row_set.each do |row|\n if row.count == headers.count\n row_hash = Hash.new\n headers.zip(row).each do |header, value|\n row_hash[header.underscore.to_sym] = value\n end\n result.push row_hash\n else\n raise BadResponseError.new(\"Row set header count (#{headers.count}) doesn't match row item count (#{row.count}).\")\n end\n end\n result\n end",
"def to_a\n [status, headers.to_hash, body]\n end",
"def string_to_array(string)\n string.split(\" \")\nend",
"def string_to_array(string)\n string.split(\" \")\nend",
"def string_to_arr(str)\n arr = str.split(\" \")\n arr_f = []\n \n for a in arr\n if a != \"\"\n arr_f.push(a.strip)\n end\n end\n \n return arr_f\n end",
"def headers\n @headers ||= message.header_fields\n end",
"def csv_to_array(csv); end",
"def to_a\n [status.to_i, headers.to_h, body.to_s]\n end",
"def headers\n # units and source have to go last, so if we push in a new header, these go\n # at end\n @headers+['units','source']\n end",
"def normalize_headers(headers)\n result = headers.inject({}) do |h, (k, v)|\n # value is in raw form as array of sequential header values\n h[normalize_header_key(k)] = v\n h\n end\n\n # eliminate headers that interfere with playback or don't make sense to\n # record.\n %w(\n connection status host user_agent content_encoding\n ).each { |key| result.delete(key) }\n\n # always obfuscate cookie headers as they won't be needed for playback and\n # would be non-trivial to configure for each service.\n %w(cookie set_cookie).each do |k|\n if cookies = result[k]\n if cookies.is_a?(::String)\n cookies = cookies.split(';').map { |c| c.strip }\n end\n result[k] = cookies.map do |cookie|\n if offset = cookie.index('=')\n cookie_name = cookie[0..(offset-1)]\n \"#{cookie_name}=#{HIDDEN_CREDENTIAL_VALUE}\"\n else\n cookie\n end\n end\n end\n end\n result\n end",
"def convert_string_to_array(str = \"\", seperator = \" \")\n str.split(seperator).map(&:strip).uniq.compact\n end",
"def catch_pm_headers(headers)\n return {} unless Array === headers\n caught = {}\n headers.each do |h|\n case h[:name]\n when 'X-Spam-Status'\n caught[:spam_status] = h[:value].downcase.start_with?('yes')\n when 'X-Spam-Score'\n caught[:spam_score] = h[:value].to_f\n when 'Received-SPF'\n caught[:received_spf_status] = (h[:value].split)[0].downcase\n end\n end\n return caught\n end",
"def raw_headers; end",
"def convert_array_to_hash( headers, data )\n converted_data = {}\n headers.each_index do |position|\n if data[position].nil? or data[position] === \"\"\n converted_data[ headers[position] ] = nil\n else\n converted_data[ headers[position] ] = data[position]\n end\n \n end\n return converted_data\n end",
"def string_to_array(str)\n return [] if str.blank?\n return str.split(\",\").each{|t| t.strip!} if str.class == String\n return []\n end",
"def convert_hash_body_to_array_of_arrays\n arrays = []\n request.body.keys.each do | key |\n [*request.body[key]].each do | value |\n arrays << [key, value]\n end\n end\n\n Pact::Reification.from_term(arrays)\n end",
"def header_names headers\n header_names = []\n headers.each do |header|\n header_names.append header[:name]\n end\n header_names.join \",\"\nend",
"def header_to_hash data\n header = {}\n data = data.split(@opts[:delimiter])\n self.req[\"Verb\"], self.req[\"Url\"], self.req[\"Version\"] = data.shift.split(\" \", 3)\n data.each do |line|\n k,v = line.split(\":\", 2)\n if !@opts[:header_bl] || !(HEADER_BLACKLIST.include? k)\n header[k] = v.lstrip\n end\n end\n header\n end",
"def toptag2array(str)\n sep = \"\\001\"\n str.gsub(/\\n([A-Za-z\\/\\*])/, \"\\n#{sep}\\\\1\").split(sep)\n end",
"def init_headers!(names = [])\r\n names = [names] unless names.is_a?(Array)\r\n @headers = []\r\n names.each_with_index {|name, i| @headers[i] = name}\r\n end",
"def parse_csv(decoded_data)\n csv = CSV.parse(decoded_data)\n headers = csv.shift\n csv.to_a.map! { |row| Hash[headers.zip(row)] }\n end",
"def split_args(str)\n # We need to handle empty strings ourselves; CSV.parse_line() will\n # return [nil].\n return [] if not str or str.empty?\n return CSV.parse_line(str, ' ').map {|i| i.to_s }\n end",
"def parse(headers, &block)\n @headers = headers\n parse_headers!(block)\n end",
"def header_converters\n @header_converters.map do |converter|\n name = HeaderConverters.rassoc(converter)\n name ? name.first : converter\n end\n end",
"def content_as_array\n begin\n # '[\"a\",\"b\", \"c\"]' -> '\"a\",\"b\",\"c\"'\n no_brackets = content[1...-1]\n\n # '\"a\",\"b\",\"c\"' -> ['\"a\"', '\"b\"', '\"c\"']\n quoted_elements = no_brackets.split(\", \")\n\n # ['\"a\"', '\"b\"', '\"c\"'] -> ['a', 'b', 'c']\n quoted_elements.map { |quoted_elt| quoted_elt[1...-1] }\n rescue\n []\n end\n end",
"def parse_message message\n message.split(\"=>\").map { |i| i.strip }\n end",
"def headers (bundle)\n data = capture(:headers, bundle)\n extract_bundle_headers(data)\n end",
"def decode(buf)\n set = []\n set << @cc.process(header(buf)) while !buf.empty?\n @cc.refset.each do |i,header|\n set << header if !set.include? header\n end\n\n set.compact\n end",
"def received()\n\t\treceived = self.headers[\"Received\"]\n\t\treceived.class == Array ? received : [received]\n\tend"
] | [
"0.703389",
"0.68228275",
"0.6637026",
"0.65060157",
"0.6489471",
"0.64845294",
"0.64399105",
"0.63763016",
"0.63403124",
"0.63145477",
"0.63145477",
"0.6218634",
"0.6180902",
"0.6131345",
"0.6073011",
"0.60691416",
"0.6025443",
"0.5994925",
"0.59728396",
"0.5859533",
"0.58256125",
"0.5810031",
"0.57447857",
"0.5697561",
"0.5687629",
"0.56816196",
"0.56633127",
"0.565544",
"0.5639918",
"0.5615799",
"0.5594499",
"0.55859673",
"0.55819327",
"0.55501306",
"0.55299497",
"0.5520456",
"0.5520062",
"0.55110466",
"0.55110466",
"0.55110466",
"0.55110466",
"0.5506045",
"0.550103",
"0.5487964",
"0.5480514",
"0.54643166",
"0.5460558",
"0.5454232",
"0.5452338",
"0.54446465",
"0.54381573",
"0.5434204",
"0.54292566",
"0.54153",
"0.54141414",
"0.54134434",
"0.5391905",
"0.5371271",
"0.53677195",
"0.5357325",
"0.5334258",
"0.5327578",
"0.5315294",
"0.5305191",
"0.5302168",
"0.5297407",
"0.52854115",
"0.528284",
"0.5280263",
"0.5270224",
"0.5267812",
"0.52622014",
"0.5253238",
"0.5253238",
"0.5247463",
"0.5244525",
"0.52218384",
"0.52214766",
"0.5219999",
"0.52042633",
"0.5185131",
"0.5179765",
"0.5176565",
"0.5164832",
"0.51645297",
"0.51639766",
"0.51460797",
"0.5146057",
"0.51438195",
"0.5140368",
"0.51215225",
"0.5113762",
"0.510799",
"0.50943005",
"0.5082444",
"0.5074617",
"0.5074593",
"0.5062344",
"0.5062164"
] | 0.7107035 | 1 |
apply() applies this selector to a node set, returning the resulting node(s) | def apply( node )
return node
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply( node )\n bug( \"you must override Selector.apply()\" )\n end",
"def apply( nodes )\n nodes = nodes.to_a\n results = nodes\n difference = nodes\n until difference.empty?\n step_results = @selector.apply( difference )\n difference = step_results - results\n results.concat( difference )\n end\n \n return results.reverse\n end",
"def apply(nodes)\n node_manager.assert_known(nodes)\n for node in nodes\n node_manager.find(node).apply\n end\n end",
"def apply( node )\n @lhs_selector.unset( node )\n end",
"def css *args\n if children.any?\n children.css(*args)\n else\n NodeSet.new(document)\n end\n end",
"def on_axis_self(ast_node, context)\n nodes = XML::NodeSet.new\n\n context.each do |context_node|\n nodes << context_node if node_matches?(context_node, ast_node)\n end\n\n return nodes\n end",
"def method_missing(sym, *args, &block)\n if @node_set.respond_to?(sym)\n @node_set.send(sym, *args, &block)\n else\n super\n end\n end",
"def on_axis_descendant(ast_node, context)\n nodes = XML::NodeSet.new\n\n context.each do |context_node|\n context_node.each_node do |node|\n nodes.concat(process(ast_node, XML::NodeSet.new([node])))\n end\n end\n\n return nodes\n end",
"def assign( search_nodes, result_nodes )\n return apply(search_nodes)\n end",
"def apply(*args)\n case args = apply_args_conventions(*args)\n when CodeTree::AstNode\n apply_on_node(args)\n when Array\n args.collect{|c| apply(c)}\n else\n args\n end\n end",
"def map_nodes!(&ruby_block)\n @select = ruby_block.call(@select)\n @select.parent = self unless @select.parent\n map_choices!(&ruby_block)\n end",
"def traverse(operator,match)\n ParseNodeSet.new(self).traverse(operator,match)\n end",
"def select_nodes(&block)\n each_node.select &block\n end",
"def apply\n # TODO: This needs to happen in parallel but can't due to the way running multiple\n # actions on a single node works. Actions work on a node and don't know about other\n # actions which are being run on that node, so in a single node environment the\n # state of a node can get weird when actions stomp all over each other.\n #\n # We should refactor this to APPLY actions to nodes and then allow them to converge\n # together before we run them. This will allow us to execute multiple actions on a node at once\n # without getting weird race conditions.\n @on_procs.each do |on_proc|\n on_proc.call\n end\n\n @on_procs.clear\n end",
"def find(selector)\n nodes = @_node.getByXPath(selector).map { |node| Node.new(node) }\n @nodes << nodes\n nodes\n end",
"def apply_on_node(node)\n func = node.function\n if rules.key?(func)\n @rules[func].call(self, node)\n elsif rules.key?(\"*\")\n @rules[\"*\"].call(self, node)\n else\n nil\n end\n end",
"def parse\n self.class.rules.each do |target, (selector, delegate, plural)|\n if plural\n @doc.search(selector).each do |node|\n send(target) << parse_result(node, delegate)\n end\n else\n send(\"#{target}=\", parse_result(@doc.at(selector), delegate))\n end\n end\n self\n end",
"def call(*args)\n left = root.call(*args)\n right = nodes.map { |node| node.call(left) }\n\n Loaded.new(self, [left, right])\n end",
"def function_node(context, expression = nil)\n if expression\n node = process(expression, context)\n\n if node.is_a?(XML::NodeSet)\n node = node.first\n else\n raise TypeError, 'only node sets can be used as arguments'\n end\n else\n node = context.first\n end\n\n return node\n end",
"def with_node_set(nodes)\n @node_sets << nodes\n\n retval = yield\n\n @node_sets.pop\n\n return retval\n end",
"def each_node\n return to_enum(__method__) unless block_given?\n\n doc.xpath(query).each do |node|\n yield node\n end\n end",
"def recursive_apply_to(dataset)\n self.predicate.apply_to(dataset)\n end",
"def on_path(ast_node, context)\n nodes = XML::NodeSet.new\n\n ast_node.children.each do |test|\n nodes = process(test, context)\n\n if nodes.empty?\n break\n else\n context = nodes\n end\n end\n\n return nodes\n end",
"def select_nodes(&block)\r\n @map.select(&block)\r\n end",
"def on_axis_ancestor_or_self(ast_node, context)\n nodes = XML::NodeSet.new\n\n context.each do |xml_node|\n while has_parent?(xml_node)\n if node_matches?(xml_node, ast_node)\n nodes << xml_node\n break\n end\n\n xml_node = xml_node.parent\n end\n end\n\n return nodes\n end",
"def apply_to(dataset)\n if self.relation.relation?\n relation_name = self.relation.name\n self.predicate.apply_to(dataset[relation_name])\n else\n recursive_apply_to(self.relation.apply_to(dataset))\n end\n end",
"def expr( path_stack, nodeset, context=nil )\n enter(:expr, path_stack, nodeset) if @debug\n return nodeset if path_stack.length == 0 || nodeset.length == 0\n while path_stack.length > 0\n trace(:while, path_stack, nodeset) if @debug\n if nodeset.length == 0\n path_stack.clear\n return []\n end\n op = path_stack.shift\n case op\n when :document\n first_raw_node = nodeset.first.raw_node\n nodeset = [XPathNode.new(first_raw_node.root_node, position: 1)]\n when :self\n nodeset = step(path_stack) do\n [nodeset]\n end\n when :child\n nodeset = step(path_stack) do\n child(nodeset)\n end\n when :literal\n trace(:literal, path_stack, nodeset) if @debug\n return path_stack.shift\n when :attribute\n nodeset = step(path_stack, any_type: :attribute) do\n nodesets = []\n nodeset.each do |node|\n raw_node = node.raw_node\n next unless raw_node.node_type == :element\n attributes = raw_node.attributes\n next if attributes.empty?\n nodesets << attributes.each_attribute.collect.with_index do |attribute, i|\n XPathNode.new(attribute, position: i + 1)\n end\n end\n nodesets\n end\n when :namespace\n pre_defined_namespaces = {\n \"xml\" => \"http://www.w3.org/XML/1998/namespace\",\n }\n nodeset = step(path_stack, any_type: :namespace) do\n nodesets = []\n nodeset.each do |node|\n raw_node = node.raw_node\n case raw_node.node_type\n when :element\n if @namespaces\n nodesets << pre_defined_namespaces.merge(@namespaces)\n else\n nodesets << pre_defined_namespaces.merge(raw_node.namespaces)\n end\n when :attribute\n if @namespaces\n nodesets << pre_defined_namespaces.merge(@namespaces)\n else\n nodesets << pre_defined_namespaces.merge(raw_node.element.namespaces)\n end\n end\n end\n nodesets\n end\n when :parent\n nodeset = step(path_stack) do\n nodesets = []\n nodeset.each do |node|\n raw_node = node.raw_node\n if raw_node.node_type == :attribute\n parent = raw_node.element\n else\n parent = raw_node.parent\n end\n nodesets << [XPathNode.new(parent, position: 1)] if parent\n end\n nodesets\n end\n when :ancestor\n nodeset = step(path_stack) do\n nodesets = []\n # new_nodes = {}\n nodeset.each do |node|\n raw_node = node.raw_node\n new_nodeset = []\n while raw_node.parent\n raw_node = raw_node.parent\n # next if new_nodes.key?(node)\n new_nodeset << XPathNode.new(raw_node,\n position: new_nodeset.size + 1)\n # new_nodes[node] = true\n end\n nodesets << new_nodeset unless new_nodeset.empty?\n end\n nodesets\n end\n when :ancestor_or_self\n nodeset = step(path_stack) do\n nodesets = []\n # new_nodes = {}\n nodeset.each do |node|\n raw_node = node.raw_node\n next unless raw_node.node_type == :element\n new_nodeset = [XPathNode.new(raw_node, position: 1)]\n # new_nodes[node] = true\n while raw_node.parent\n raw_node = raw_node.parent\n # next if new_nodes.key?(node)\n new_nodeset << XPathNode.new(raw_node,\n position: new_nodeset.size + 1)\n # new_nodes[node] = true\n end\n nodesets << new_nodeset unless new_nodeset.empty?\n end\n nodesets\n end\n when :descendant_or_self\n nodeset = step(path_stack) do\n descendant(nodeset, true)\n end\n when :descendant\n nodeset = step(path_stack) do\n descendant(nodeset, false)\n end\n when :following_sibling\n nodeset = step(path_stack) do\n nodesets = []\n nodeset.each do |node|\n raw_node = node.raw_node\n next unless raw_node.respond_to?(:parent)\n next if raw_node.parent.nil?\n all_siblings = raw_node.parent.children\n current_index = all_siblings.index(raw_node)\n following_siblings = all_siblings[(current_index + 1)..-1]\n next if following_siblings.empty?\n nodesets << following_siblings.collect.with_index do |sibling, i|\n XPathNode.new(sibling, position: i + 1)\n end\n end\n nodesets\n end\n when :preceding_sibling\n nodeset = step(path_stack, order: :reverse) do\n nodesets = []\n nodeset.each do |node|\n raw_node = node.raw_node\n next unless raw_node.respond_to?(:parent)\n next if raw_node.parent.nil?\n all_siblings = raw_node.parent.children\n current_index = all_siblings.index(raw_node)\n preceding_siblings = all_siblings[0, current_index].reverse\n next if preceding_siblings.empty?\n nodesets << preceding_siblings.collect.with_index do |sibling, i|\n XPathNode.new(sibling, position: i + 1)\n end\n end\n nodesets\n end\n when :preceding\n nodeset = step(path_stack, order: :reverse) do\n unnode(nodeset) do |node|\n preceding(node)\n end\n end\n when :following\n nodeset = step(path_stack) do\n unnode(nodeset) do |node|\n following(node)\n end\n end\n when :variable\n var_name = path_stack.shift\n return [@variables[var_name]]\n\n when :eq, :neq, :lt, :lteq, :gt, :gteq\n left = expr( path_stack.shift, nodeset.dup, context )\n right = expr( path_stack.shift, nodeset.dup, context )\n res = equality_relational_compare( left, op, right )\n trace(op, left, right, res) if @debug\n return res\n\n when :or\n left = expr(path_stack.shift, nodeset.dup, context)\n return true if Functions.boolean(left)\n right = expr(path_stack.shift, nodeset.dup, context)\n return Functions.boolean(right)\n\n when :and\n left = expr(path_stack.shift, nodeset.dup, context)\n return false unless Functions.boolean(left)\n right = expr(path_stack.shift, nodeset.dup, context)\n return Functions.boolean(right)\n\n when :div, :mod, :mult, :plus, :minus\n left = expr(path_stack.shift, nodeset, context)\n right = expr(path_stack.shift, nodeset, context)\n left = unnode(left) if left.is_a?(Array)\n right = unnode(right) if right.is_a?(Array)\n left = Functions::number(left)\n right = Functions::number(right)\n case op\n when :div\n return left / right\n when :mod\n return left % right\n when :mult\n return left * right\n when :plus\n return left + right\n when :minus\n return left - right\n else\n raise \"[BUG] Unexpected operator: <#{op.inspect}>\"\n end\n when :union\n left = expr( path_stack.shift, nodeset, context )\n right = expr( path_stack.shift, nodeset, context )\n left = unnode(left) if left.is_a?(Array)\n right = unnode(right) if right.is_a?(Array)\n return (left | right)\n when :neg\n res = expr( path_stack, nodeset, context )\n res = unnode(res) if res.is_a?(Array)\n return -Functions.number(res)\n when :not\n when :function\n func_name = path_stack.shift.tr('-','_')\n arguments = path_stack.shift\n\n if nodeset.size != 1\n message = \"[BUG] Node set size must be 1 for function call: \"\n message += \"<#{func_name}>: <#{nodeset.inspect}>: \"\n message += \"<#{arguments.inspect}>\"\n raise message\n end\n\n node = nodeset.first\n if context\n target_context = context\n else\n target_context = {:size => nodeset.size}\n if node.is_a?(XPathNode)\n target_context[:node] = node.raw_node\n target_context[:index] = node.position\n else\n target_context[:node] = node\n target_context[:index] = 1\n end\n end\n args = arguments.dclone.collect do |arg|\n result = expr(arg, nodeset, target_context)\n result = unnode(result) if result.is_a?(Array)\n result\n end\n Functions.context = target_context\n return Functions.send(func_name, *args)\n\n else\n raise \"[BUG] Unexpected path: <#{op.inspect}>: <#{path_stack.inspect}>\"\n end\n end # while\n return nodeset\n ensure\n leave(:expr, path_stack, nodeset) if @debug\n end",
"def method_missing(method, *args, &block)\n if RUBY_ENGINE == 'opal' && node.respond_to?(method, true)\n n = node.send(method, *args, &block)\n elsif RUBY_ENGINE != 'opal'\n if node.is_a?(Oga::XML::NodeSet) && node.first.respond_to?(method, true)\n n = node.first.send(method, *args, &block)\n elsif node.respond_to?(method, true)\n n = node.send(method, *args, &block)\n else\n super\n end\n else\n super\n end\n\n if RUBY_ENGINE == 'opal'\n n.is_a?(Element) ? Instance.new(n, cache, scope) : n\n else\n n.class.name['Oga::'] ? Instance.new(n, cache, scope) : n\n end\n end",
"def walk(node=nil, match = Match.create({}) { true })\n self[node].walk match # calls Changeset#walk\n end",
"def on_test(ast_node, context)\n nodes = XML::NodeSet.new\n\n context.each do |xml_node|\n nodes << xml_node if node_matches?(xml_node, ast_node)\n end\n\n return nodes\n end",
"def call(*args)\n left = root.call(*args)\n\n right = nodes.map { |node|\n response =\n if node.lazy?\n node.call(args.first, left)\n else\n node.call(left)\n end\n\n if node.one? && !node.graph?\n [response]\n else\n response\n end\n }\n\n if one?\n [[left], right]\n else\n [left, right]\n end\n end",
"def /(*paths)\n NodeSet[paths.map { |path| xpath(path) }]\n end",
"def append( search_nodes, result_nodes )\n return apply(search_nodes)\n end",
"def map_nodes!(&ruby_block)\n @match = ruby_block.call(@match)\n @match.parent = self unless @match.parent\n @statement = ruby_block.call(@statement)\n @statement.parent = self unless @statement.parent\n end",
"def on_axis_preceding(ast_node, context)\n nodes = XML::NodeSet.new\n root = root_node(@document)\n\n context.each do |context_node|\n check = true\n\n root.each_node do |doc_node|\n # Test everything *until* we hit the current context node.\n if doc_node == context_node\n break\n elsif node_matches?(doc_node, ast_node)\n nodes << doc_node\n end\n end\n end\n\n return nodes\n end",
"def find(selector)\n nodes = current_frame.getByXPath(selector).map { |node| Node.new(node) }\n @nodes << nodes\n nodes\n end",
"def deep_apply(parser, context)\n parser = apply(parser, context)\n apply(parser.map_children { |child|\n deep_apply(child, child_context(parser, context))\n }, context)\n end",
"def apply_children\n \n end",
"def query_selector_all(expr)\n Traverser.new(expr).evaluate(Context.new(node: self))\n end",
"def xpath_for(selector, options = T.unsafe(nil)); end",
"def process_child_nodes(node); end",
"def call(node); end",
"def each\n @node_set.each do |c|\n yield NodeProxy.new(c, parent)\n end\n end",
"def generate_selector(node, full_selector)\n full_selector << node.selector\n unless node.parent.selector == 'root'\n generate_selector(node.parent, full_selector)\n end\n return full_selector\nend",
"def [](*args)\n args.inject(self) { |node, n| node.elements[n] }\n rescue NoMethodError\n return nil # Burrowed too deep\n end",
"def each(*selector, &blk)\n children(*selector, &blk)\n self\n end",
"def elements\n NodeSetProxy.new(@node.elements, self)\n end",
"def map_nodes!(&ruby_block)\n self.map_args!(&ruby_block)\n end",
"def search(*selectors)\n NodeSet.new selectors.map {|selector|\n xpath(selector).to_a.concat(css(selector).to_a)\n }.flatten.uniq\n end",
"def process_nodes(html_nodes, properties); end",
"def each\n @node_set.each do |c|\n yield NodeProxy.new(c, parent)\n end\n end",
"def on_axis_ancestor(ast_node, context)\n nodes = XML::NodeSet.new\n\n context.each do |xml_node|\n while has_parent?(xml_node)\n xml_node = xml_node.parent\n\n if node_matches?(xml_node, ast_node)\n nodes << xml_node\n break\n end\n end\n end\n\n return nodes\n end",
"def update!(**args)\n @apply_all = args[:apply_all] if args.key?(:apply_all)\n @node_ids = args[:node_ids] if args.key?(:node_ids)\n end",
"def map_nodes!(&ruby_block)\n # A block? Apply it on each child.\n @value = ruby_block.call(@value)\n map_whens!(&ruby_block)\n if @default then\n @default = ruby_block.call(@default)\n @default.parent = self unless @default.parent\n end\n end",
"def eachNode(&block)\n @nodeSets.each { |s|\n s.eachNode &block\n }\n end",
"def nodes(opts = {})\n node_or_ng = self[:node]\n nodes = \n if node_or_ng.is_node_group?()\n node_or_ng.get_node_group_members()\n else\n [node_or_ng]\n end\n if cols = opts[:cols]\n nodes.each { |node| node.update_object!(*cols) }\n end\n nodes\n end",
"def map_nodes!(&ruby_block)\n @index = ruby_block.call(@index)\n @index.parent = self unless @index.parent\n @ref = ruby_block.call(@ref)\n @ref.parent = self unless @ref.parent\n end",
"def method_missing method, *args\n @node.send method, *args\n end",
"def on_axis_following(ast_node, context)\n nodes = XML::NodeSet.new\n root = root_node(@document)\n\n context.each do |context_node|\n check = false\n\n root.each_node do |doc_node|\n # Skip child nodes of the current context node, compare all\n # following nodes.\n if doc_node == context_node\n check = true\n throw :skip_children\n end\n\n next unless check\n\n nodes << doc_node if node_matches?(doc_node, ast_node)\n end\n end\n\n return nodes\n end",
"def selected_nodes\n nodes_by_id.values_at(*selected_node_ids)\n end",
"def update\n\t\t\[email protected](self)\n\t\tend",
"def evaluate\n context = Context.new(self, node)\n context.instance_exec(&block)\n node\n end",
"def assign( search_nodes, result_nodes )\n return super unless target?\n \n update(search_nodes) do |node|\n node.usurper = result_nodes\n end\n end",
"def _perform(environment)\n node = dup\n node.perform!(environment)\n node\n end",
"def _perform(environment)\n node = dup\n node.perform!(environment)\n node\n end",
"def map_nodes!(&ruby_block)\n @range = ruby_block.call(@range.first)..ruby_block.call(@range.last)\n @range.first.parent = self unless @range.first.parent\n @range.last.parent = self unless @range.last.parent\n @ref = ruby_block.call(@ref)\n @ref.parent = self unless @ref.parent\n end",
"def node; changeset.node; end",
"def all_nodes\n [self] + descendants\n end",
"def map_nodes!(&ruby_block)\n # Nothing to do.\n end",
"def on_axis_descendant_or_self(ast_node, context)\n nodes = on_test(ast_node, context)\n\n nodes.concat(on_axis_descendant(ast_node, context))\n\n return nodes\n end",
"def map_nodes!(&ruby_block)\n # By default, nothing to do.\n end",
"def each_node(nodes)\n unless ::Nokogiri::XML::NodeSet === nodes\n nodes = [nodes]\n end\n nodes.each do |node|\n yield(node)\n end\n end",
"def map_nodes!(&ruby_block)\n @ref = ruby_block.call(@ref)\n @ref.parent = self unless @ref.parent\n end",
"def select(node, &matcher)\n return [] if node.empty? # base case \n head = node[0] \n rest = node[1..-1]\n if head.is_a? Array\n select(head, &matcher) + select(rest, &matcher)\n else\n (matcher.call(head) ? [head] : []) + select(rest, &matcher) \n end\nend",
"def on_axis_attribute(ast_node, context)\n nodes = XML::NodeSet.new\n\n context.each do |xml_node|\n next unless xml_node.is_a?(XML::Element)\n\n nodes += on_test(ast_node, xml_node.attributes)\n end\n\n return nodes\n end",
"def method_missing(meth, *args, &block) # :nodoc:\n xpath = _xpath_for_element(meth.to_s, args.shift)\n return nil if xpath.empty?\n\n if block_given?\n xpath.each_with_index do |node, idx|\n @nodes.push(node)\n case block.arity\n when 1\n yield idx\n when 2\n yield self.class.new(node, @namespaces, false), idx\n else\n yield\n end\n @nodes.pop\n end\n self\n else\n node = xpath.first\n\n if node.xpath('text()').length == 1\n content = node.xpath('text()').first.content\n case meth.to_s\n when /\\?$/\n !! Regexp.new(/(t(rue)?|y(es)?|1)/i).match(content)\n else\n content\n end\n else\n self.class.new(node, @namespaces, false)\n end\n end\n end",
"def run\n @xml.xpath(@object._nodes_xpath).each do |node|\n object = @object.new\n parse_text_properties(node,object)\n parse_attribute_properties(node,object)\n parse_embedded_properties(node,object)\n @nodes << object\n end\n @nodes\n end",
"def reapply_nodes\n @nodes.each { |node| node.data[:cluster] = self }\n end",
"def returns_from(node); end",
"def returns_from(node); end",
"def map_nodes!(&ruby_block)\n @statement = ruby_block.call(@statement)\n @statement.parent = self unless @statement.parent\n end",
"def on_axis_preceding_sibling(ast_node, context)\n nodes = XML::NodeSet.new\n root = parent_node(@document)\n\n context.each do |context_node|\n check = true\n parent = has_parent?(context_node) ? context_node.parent : nil\n\n root.each_node do |doc_node|\n # Test everything *until* we hit the current context node.\n if doc_node == context_node\n break\n elsif doc_node.parent == parent and node_matches?(doc_node, ast_node)\n nodes << doc_node\n end\n end\n end\n\n return nodes\n end",
"def selections\n selector.send(selector_method) rescue nil\n end",
"def xpath(*args); end",
"def xpath(*args); end",
"def update( search_nodes )\n if has_target_predicate? then\n search_nodes.each do |node|\n if node.slot_filled?(@slot_name) then\n unless @target_predicate.apply(node[@slot_name].to_a).empty?\n yield( node )\n end \n end\n end\n else\n search_nodes.each do |node|\n yield( node )\n end\n end\n end",
"def <<(node_or_tags); end",
"def <<(node_or_tags); end",
"def each\n\n this_node = @head\n\n size.times do |i|\n yield this_node.value\n this_node = this_node.child\n end\n\n return self\n end",
"def unset( search_nodes )\n return apply(search_nodes)\n end",
"def method_missing(name, *args, &block)\n @root_node.send name, *args, &block\n end",
"def add(selector)\n if selector.kind_of?(Array)\n # Check if each name in the 'selector' refer to a valid NodeSet\n # If so, then add this NodeSet to this new group of NodeSet\n selector.each { |name|\n s = NodeSet[name]\n if s == nil\n raise \"Unknown NodeSet (name '#{name}')\"\n end\n s.add_observer(self)\n @nodeSets.add(s)\n }\n elsif selector.kind_of?(ExperimentProperty)\n s = selector.value\n add(s)\n else\n raise \"Unrecognized node set selector type '#{selector.class}'.\"\n end\n end",
"def each\n self.traverse_down { |node| yield(node) }\n end",
"def select_node(path)\r\n node(path).select\r\n end",
"def method_missing(method, *args, &block)\n get_node.send(method, *args, &block)\n end",
"def from_node(node); end",
"def xpath_for selector, options={}\r\n Parser.new(options[:ns] || {}).xpath_for selector, options\r\n end",
"def children=(node_or_tags); end",
"def children=(node_or_tags); end",
"def method_missing(method, *args)\n if node.respond_to?(method)\n node.send(method, *args)\n else\n args.empty? ? self[method] : node.send(method, *args)\n end\n end"
] | [
"0.66601545",
"0.64154595",
"0.6065036",
"0.5784437",
"0.57756865",
"0.54986745",
"0.54721534",
"0.54504275",
"0.54338425",
"0.5379179",
"0.53335434",
"0.5299764",
"0.5279307",
"0.5256526",
"0.5197164",
"0.5193304",
"0.51319337",
"0.50820297",
"0.50318766",
"0.502184",
"0.5003871",
"0.499343",
"0.49580315",
"0.49492925",
"0.49424064",
"0.4917281",
"0.4882104",
"0.48735985",
"0.4872027",
"0.4867442",
"0.48610374",
"0.48571146",
"0.48557454",
"0.4829154",
"0.4812128",
"0.48022315",
"0.47997162",
"0.47995022",
"0.47952026",
"0.47895673",
"0.4782945",
"0.47752663",
"0.4750897",
"0.47397578",
"0.47372988",
"0.47267824",
"0.4725979",
"0.4725444",
"0.4702694",
"0.4694084",
"0.46899816",
"0.4679284",
"0.46788082",
"0.4676694",
"0.46753627",
"0.46669647",
"0.4657863",
"0.46431056",
"0.46404636",
"0.46277827",
"0.46152475",
"0.46089745",
"0.4605469",
"0.45999843",
"0.45999843",
"0.45875263",
"0.4580096",
"0.45780218",
"0.45712143",
"0.4563488",
"0.4557341",
"0.45545077",
"0.4554374",
"0.45535648",
"0.45259002",
"0.45214367",
"0.45214054",
"0.45104662",
"0.449463",
"0.449463",
"0.44928777",
"0.44864902",
"0.44722918",
"0.44577724",
"0.44577724",
"0.4449494",
"0.4449097",
"0.4449097",
"0.44485214",
"0.4441285",
"0.44394156",
"0.44370812",
"0.4436745",
"0.443663",
"0.4435586",
"0.44287166",
"0.4425141",
"0.44158345",
"0.44158345",
"0.44097236"
] | 0.6695583 | 0 |
assign() for self assignment, we need help; because nodes don't know their parent, we can't actually affect the change directly; instead, we set the ASN usurper, and leave ASN.commit() to do the patch up | def assign( search_nodes, result_nodes )
return super unless target?
update(search_nodes) do |node|
node.usurper = result_nodes
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parent=(parent_node); end",
"def parent=(parent_node); end",
"def parent=(other); end",
"def on_assign(node)\n reset_assignment_value\n value_stack.add_stack\n end",
"def parent=(obj); end",
"def coursenode_assignmentnode(res2, child)\n res2['directory'] = child.get_directory\n instructor_id = child.get_instructor_id\n update_instructor(res2, instructor_id)\n update_is_available_2(res2, instructor_id, child)\n assignments_method(child, res2) if child.type == 'AssignmentNode'\n end",
"def coursenode_assignmentnode(res2, child)\n res2[\"directory\"] = child.get_directory\n instructor_id = child.get_instructor_id\n update_instructor(res2, instructor_id)\n update_is_available_2(res2, instructor_id, child)\n assignments_method(child, res2) if child.type == \"AssignmentNode\"\n end",
"def attribute_assignment(node)\n if node.left_value.message.to_s =~ /_id$/\n subject = node.left_value.subject.to_s\n @assignments[subject] = true\n end\n end",
"def assign_to(new_owner)\n if new_owner != \"congress\"\n @assigned_to = new_owner\n end\n end",
"def attribute_assignment(node)\n if node.left_value.message.is_a?(Sexp) && node.left_value.message.to_s =~ /_id$/\n receiver = node.left_value.receiver.to_s\n @assignments[receiver] = true\n end\n end",
"def assign_tree(tree)\n nodes = tree.sort_by { |e| e['weight'].to_i }\n new_collection_ids = nodes.map { |e| e['id'] }\n if ordered_subset?(new_collection_ids)\n removed_collection_ids = collection_member_ids - new_collection_ids\n self.member_ids = (member_ids.map(&:to_s) - removed_collection_ids) unless removed_collection_ids.empty?\n else\n self.member_ids = new_collection_ids + noncollection_member_ids\n end\n nodes.each do |node|\n b = ActiveFedora::Base.find(node['id'])\n b.assign_tree node['children']\n b.save! #TODO We could move this save into an after_save hook.\n end\n end",
"def parent=(node) #node == new parents\n unless self.parent == nil # root node\n self.parent.children.delete(self)\n end\n # self = (Parents, [Mark]) = > (Parents, [])\n\n @parent = node # \n # debugger\n node.children << self unless node.nil? \n\n # (Bob & Mary, [Karen, Tom])\n # (Bob & Mary, [Karen, Tom, Mark])\n end",
"def parent=(_arg0); end",
"def parent=(_arg0); end",
"def parent=(_arg0); end",
"def parent=(_arg0); end",
"def parent=(_arg0); end",
"def propagate_assignment\n\t\tself.course.propagate_assignment(self)\n\tend",
"def parent=(new_parent) \n parent.children.delete(self) if @parent #=> this is the old parent removing the child that is being adopted \n @parent = new_parent #=> I have a new mommy! \n new_parent.children << self unless @parent == nil || new_parent.children.include?(self) \n end",
"def parent= parent_node\n parent_node.add_child(self)\n parent_node\n end",
"def parent=(new_parent_node)\n orphan_me\n @parent = new_parent_node\n unless @parent.nil?\n siblings = @parent.children\n siblings << self unless siblings.include?(self)\n end\n end",
"def parent=(other)\n raise 'Cannot set parent of root namespace' if root?\n @parent = other\n @registry = nil\n end",
"def translate_assign(curr_node = nil)\n # First handle errors\n if curr_node == nil or curr_node.name != \"ASSIGN\"\n raise @err_class, \"Malformed Assign Statement!\"\n end\n\n # Generate code for a valid numeral assignment\n if curr_node.children[0].name == \"GALNUMERAL\" and \\\n curr_node.children[1].name == \"GALNUMERAL\"\n @code.push(\"MOV $ar %#{curr_node.children[0].value}\")\n @code.push(\"MOV %#{curr_node.children[1].value} $ar\")\n # Generate code for a valid commodity assignment\n elsif curr_node.children[0].name == \"GALNUMBER\" and \\\n curr_node.children[1].name == \"COMMODITY\" and \\\n curr_node.children[2].name == \"NUMBER\"\n # Move result of division into memory location\n @code.push(\"MOV $ar %#{curr_node.children[1].value}\")\n @code.push(\"DIV $br $ar\") # Divide $ar by $br & store result in $ar\n @code.push(\"POP $br\")\n curr_node.children[0].children.each do |num|\n @code.push(\"PUSH\")\n @code.push(\"MOV %#{num.value} $nr\")\n end \n # Move number into $ar\n @code.push(\"MOV #{curr_node.children[2].value} $ar\")\n else\n raise @err_class, \"Malformed ASSIGN statement!\"\n end\n\n end",
"def new_parent=(a_parent)\n @new_parent = a_parent\n end",
"def parent=(parent)\n RTFError.fire(\"Table row nodes cannot have their parent changed.\")\n end",
"def rhs= exp\n expect :attrasgn, :safe_attrasgn, *ASSIGNMENT_BOOL\n @my_hash_value = nil\n\n if self.node_type == :attrasgn or self.node_type == :safe_attrasgn\n self[3] = exp\n else\n self[2] = exp\n end\n end",
"def left_child=(child)\n child.owner = self\n @left_child = child\n end",
"def set_parent(parent_node)\n @parent = parent_node\n end",
"def parent=(parent)\n raise UnmutableParentError unless parent.is_a? RDF::Mutable\n raise UnmutableParentError unless parent.mutable?\n @parent = parent\n end",
"def node=(_); end",
"def node=(_); end",
"def assign_to_parent(element)\n element.remove!\n element.parent = parent\n end",
"def node=(node)\n retract[:node] = node\n end",
"def assign(var_expr_leq)\n @ast||=Root.new\n var,expr=var_expr_leq.lhs,var_expr_leq.rhs\n @ast.body << Assign.new(var,expr)\n end",
"def add_virtual_assignments_to_parents\n # We can wimp out of actually walking the tree here and operate on\n # all_parent_groups. We avoid the explicit tree walking (which is done\n # by all_parent_groups) but might have to check more groups than we\n # would if we actually walked the tree if the vip has another real\n # assignment to a parent vip. If we walked the tree we could stop at\n # that point (as we would know that we inserted virtual\n # assignments above that parent when the NGNA to that parent was\n # created). And yes, in the time it took to write this comment I\n # probably could have written the tree walking code. :)\n node_group.all_parent_groups.each do |parent|\n logger.debug \"Checking for existing NGNA for parent #{parent.name} and vip #{vip.name}\"\n if !NodeGroupVipAssignment.exists?(:node_group_id => parent.id, :vip_id => vip.id)\n logger.debug \" No existing NGNA for parent #{parent.name} and vip #{vip.name}, creating\"\n ngna = NodeGroupVipAssignment.new(:node_group_id => parent.id, :vip_id => vip.id, :virtual_assignment => true)\n if !ngna.save\n logger.debug \" Save of new NGNA failed\"\n return false\n end\n end\n end\n end",
"def parent=(parent)\n raise NilParentError if parent.nil?\n raise UnmutableParentError unless parent.is_a? RDF::Mutable\n raise UnmutableParentError unless parent.mutable?\n\n @parent = parent\n reload\n end",
"def update_parent(node, num, new_node)\n\t\tparent = node.parent\n\t\tunless parent.nil?\n\t\t\tif parent.key > num\n\t\t\t\tparent.left = new_node\n\t\t\telse\n\t\t\t\tparent.right = new_node\n\t\t\tend\n\t\tend\n\tend",
"def parent=(p)\n @parent = p\n end",
"def create_assignment_node\n @assignment.create_node unless @assignment.nil?\n end",
"def parent=(parent_node)\n parent_node.add_child(self)\n parent_node\n end",
"def parent=(node)\n # this is for deleting child when we are reassigning parent\n if @parent != nil\n @parent.children.delete(self)\n end\n\n @parent = node\n if node\n node.children << self unless node.children.include?(self)\n end\n end",
"def child_node=(_); end",
"def on_casgn(node)\n super\n _scope, name, = *node\n position = find_local name\n if position\n # TODO: raise error, can't re-assign contstant\n else\n position = locals.length\n @locals << name\n end\n\n emit :FROMALTSTACK\n emit :DUP\n emit :TOALTSTACK\n emit_push position\n emit_push 2\n emit :ROLL\n emit :SETITEM\n end",
"def parent=(parent)\n @parent = parent\n end",
"def parent=(parent)\n @parent = parent\n end",
"def node=(_arg0); end",
"def _assign\n Memory::Value.new @left_operand.value.clone, @left_operand.type.id\n end",
"def node=(node)\n @node = node\n end",
"def set_attribute_node( new_attr )\n if new_attr.owner_document != self.owner_document then\n raise \"WRONG_DOCUMENT_ERR\"\n end\n if not new_attr.owner_element.nil? then\n raise \"INUSE_ATTRIBUTE_ERR\"\n end\n old_attr = nil\n @attr_nodes << new_attr\n new_attr._set_owner_element( self )\n old_attr\n end",
"def change_parent(child, parent)\n\t\tif child.is_a?(Node) #if its a node, modify the relation so its parent is the new_node\n\t\t\t\n\t\t\t#relation = child.parent_relationships.first #hierarchy relationship should always be first <- no longer true potentially\n\t\t\trelation = child.parent_relationships.find_by link_collection_id: nil #the first one not explicitly defined, so hierarchy\n\t\t\t#binding.pry\n\t\t\tif (parent != nil) #if there is a parent for it\n\n\t\t\t\tif relation != nil #if it already has a parent relation. should be .any?\n\t\t\t\t\trelation.parent_id = parent.id\n\t\t\t\t\trelation.save\n\t\t\t\t\tchild.save\n\t\t\t\t\tparent.save\n\t\t\t\telse #if it doesn't have a parent already\n\t\t\t\t\trelation = Link.new(child_id: child.id, parent_id: parent.id, work_id: self.id)\n\t\t\t\t\trelation.save\n\t\t\t\t\tchild.save\n\t\t\t\tend\n\t\t\t\t#parent.child_relationships << relation\n\n\t\t\telse #if it doesn't have a new parent to be assigned\n\t\t\t\tif (relation != nil) #if it exists, delete it\n\t\t\t\t\trelation.delete\n\t\t\t\tend #if it doesn't exist and doesn't need to, do nothing\n\t\t\tend\n\t\t\n\t\telsif child.is_a?(Note)\n\t\t\t#prev_parent_id = child.node_id\n\t\t\tif (parent != nil) #if it has a new parent parent already\n\t\t\t\tchild.node_id = parent.id\n\t\t\t\tchild.save\n\t\t\t\tparent.notes << child\n\t\t\t\tparent.save\n\t\t\telse #if it doesn't have a parent, don't set it to anything\n\t\t\t\tchild.node_id = nil\n\t\t\t\tchild.save\t\t\t\n\t\t\tend\n\n\t\t\t#update the notes of the other node, if it exists\n\t\t\t#if Node.exists?(prev_parent_id) #automatically false if nil, so if it has no prev_parent, works even if it thinks it does\n\t\t\t#\tprev_parent = Node.find(prev_parent_id)\n\t\t\t#\tprev_parent.combine_notes()\n\t\t\t#\tprev_parent.save\n\t\t\t#end\n\t\t\n\t\telsif child.is_a?(LinkCollection)\n\t\t\tif (parent != nil) #if it has a new parent\n\t\t\t\tchild.links.each do |link| #reassign its links to that parent\n\t\t\t\t\tlink.change_parent(parent)\n\t\t\t\tend\n\t\t\telse #if a new parent wasn't found for it\n\t\t\t\tchild.links.each do |link| #reassign its links to nil\n\t\t\t\t\tlink.change_parent(nil)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def update!(**args)\n @ancestor = args[:ancestor] if args.key?(:ancestor)\n end",
"def parent=(parent_node=nil)\n # if parent_node.nil?\n @parent = parent_node\n #emove_child(parent_node) if parent_node.nil?\n #add_child(parent_node) if parent_nod.nil?\n # add_child(parent_node)\n #add_child(parent_node)\n #parent.children << child_node unless parent.children.include?(child_node)\n # add_child(self)\n # else\n # remove_child(parent_node)\n # end\n #parent_node.parent = parent_node\n end",
"def set_parent\n tbc = self.class.preceding_key_column\n if tbc && self.respond_to?(tbc)\n write_attribute(tbc, @_before_to_new_record_values[:id])\n end\n end",
"def assignment?(node); end",
"def assignment?(node); end",
"def assignment?(node); end",
"def reassign_expressions!(node2reassign)\n # Build the replacement table.\n node2rep = node2reassign.map {|n,r| [n,r[0]] }.to_h\n\n # Performs the replacement.\n node2rep_done = {} # The performed replacements.\n # Replace on the sons of the reference.\n node2rep_done.merge!(self.ref.replace_expressions!(node2rep))\n # Shall we replace the ref?\n rep = node2rep[self.ref]\n if rep then\n # Yes, do it.\n rep = rep.clone\n node = self.ref\n # node.set_parent!(nil)\n self.set_ref!(rep)\n node2rep_done[node] = rep\n end\n\n # Assign the replaced nodes.\n node2rep_done.each do |node,rep|\n reassign = node2reassign[node][1].clone\n self.parent.parent.\n add_connection(Connection.new(reassign,node.clone))\n end\n end",
"def owner=(v); end",
"def call_assignment(node)\n if ['save', 'save!'].include? node.message.to_s\n receiver = node.receiver.to_s\n add_error \"use model association (for #{receiver})\" if @assignments[receiver]\n end\n end",
"def set_parent_item_base_cost(new_unit_price)\n\n price = 0.0\n case (self.item.price_basis.to_i)\n when 0#[:awp]\n self.item.awp_unit_price = new_unit_price\n when 1 #[:act]\n self.item.act_unit_price = new_unit_price\n when 2 #[:basis_340b]\n self.item.govt_340b_unit_price = new_unit_price\n when 3 #[:wac]\n self.item.wac_unit_price = new_unit_price\n when 4 #[:contract]\n self.item.contract_unit_price = new_unit_price\n when 5 #[:nadac]\n self.item.nadac_unit_price = new_unit_price\n when 6 #[:custom]\n self.item.custom_unit_price = new_unit_price\n when 7 #[:user]\n self.item.mac_unit_price = new_unit_price\n else\n price = 0.0\n end\n self.item.save!\n end",
"def set_replacement(parent, node, replacement, property)\n if node == @root\n @root = replacement\n else\n parent.send(property+'=',replacement)\n end\n end",
"def correct_reassignment(corrector, node, offending_name, preferred_name); end",
"def start_def(node)\n @assignments = {}\n node.recursive_children do |child|\n case child.sexp_type\n when :assign\n attribute_assignment(child)\n when :call\n call_assignment(child)\n else\n end\n end\n @assignments = nil\n end",
"def parent=(value)\n raise UnsupportedOperationError\n end",
"def parent=(parent)\n if @rank.nil?\n raise Taxonifi::NameError, \"Parent of name can not be set if rank of child is not set.\" \n end\n\n # TODO: ICZN class over-ride\n if parent.class != Taxonifi::Model::Name\n raise NameError, \"Parent is not a Taxonifi::Model::Name.\"\n end\n\n if (RANKS.index(parent.rank) >= RANKS.index(self.rank))\n # warn \"WARNING:: Assigning parent to Name at same or lower rank than self (#{rank}).\"\n raise NameError, \"Parent is same or lower rank than self (#{rank}).\"\n end\n\n @parent = parent\n end",
"def map_nodes!(&ruby_block)\n @child = ruby_block.call(@child)\n @child.parent = self unless @child.parent\n end",
"def update!(**args)\n @parent_chain = args[:parent_chain] if args.key?(:parent_chain)\n end",
"def assign!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 47 )\n\n type = ASSIGN\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 373:10: '='\n match( 0x3d )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 47 )\n\n end",
"def available_for_parents_attributes=(attributes)\n # puts \"available_for_parents_attributes: #{attributes.inspect}\"\n # puts \"OUTAGE: #{inspect}\"\n assign_attributes(parent_links_attributes: attributes)\n # puts \"OUTAGE: #{inspect}\"\n end",
"def assigned?(node)\n return false unless (parent = node.parent)&.assignment?\n\n lhs, _method, _rhs = *parent\n node == lhs\n end",
"def map_nodes!(&ruby_block)\n @ref = ruby_block.call(@ref)\n @ref.parent = self unless @ref.parent\n end",
"def push(node)\n node.parent = self if node.respond_to? :parent\n super(node)\n end",
"def set_parent(parent)\n @parent = parent\n end",
"def generate_assignment (node)\n\n\tputs \"Generating a nice assignment...\"\n\n\n\t# right side\n\tgenerate(node.children[1])\n\n\tsta($static_table.get(node.children[0].symbol).address)\n\nend",
"def parent=(par)\n if self.parent\n self.parent.children.delete(self) #delete ourselves \n end\n \n @parent = par\n self.parent.children << self unless self.parent.nil?\n end",
"def assign(*args)\n commit('assign', *args)\n end",
"def visitAssign(elem, data)\r\n @@log.debug(\"XmlRuleVisitor::visitAssign\")\r\n @@log.debug(elem.inspect)\r\n\r\n if (elem.elements.size < 1)\r\n @@log.error(\"Assign element has no children.\")\r\n end\r\n\r\n if (2 != elem.elements.size)\r\n @@log.error(\"Assign element did not have the expected number of child elements.\")\r\n return data\r\n end\r\n\r\n # visit the left side\r\n data = visit(elem.elements[1], data)\r\n\r\n data += \" = \" # Add the equals sign.\r\n\r\n # visit the assignment\r\n data = visit(elem.elements[2], data)\r\n\r\n data += \";\\n\\t\\t\" # Terminate the statement.\r\n\r\n return data\r\n end",
"def call_assignment(node)\n if [\"save\", \"save!\"].include? node.message.to_s\n subject = node.subject.to_s\n add_error \"use model association (for #{subject})\" if @assignments[subject]\n end\n end",
"def set_node(val)\n self.node = val\n self\n end",
"def set_node(val)\n self.node = val\n self\n end",
"def add_to_tree(item, node)\n return rebalance(super(item, node))\n end",
"def fork(attributes_overrides={})\n # Always empty out the data in fork nodes. Data will be read from parent node.\n attributes_overrides[:data] = nil\n child = Node.copy(self,attributes_overrides)\n child.is_fork = true\n child.save\n child\n end",
"def assign!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 48 )\n\n type = ASSIGN\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 400:9: {...}? => '='\n raise FailedPredicate( \"ASSIGN\", \" @tagMode \" ) unless ( ( @tagMode ) )\n match( 0x3d )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 48 )\n\n end",
"def updates_after_create\n parent_policy = Policy.where('parent_id IS NULL').first\n agency_policy = parent_policy.dup\n agency_policy.organization = self\n agency_policy.parent_id = parent_policy.id\n agency_policy.description = \"#{self.short_name} Transit Policy\"\n agency_policy.object_key = nil\n agency_policy.save!\n\n User.where(organization_id: Grantor.first.id).each{|user| user.viewable_organizations = user.user_organization_filter.try(:get_organizations)}\n end",
"def node=(v)\n @node = v.to_s\n if USE_STRINGPREP\n @node = IDN::Stringprep.nodeprep(@node) if @node\n end\n end",
"def assign\n\t\tself.status = :assigned\n\tend",
"def parent=(parent)\n @parent = parent\n end",
"def set_assigned_to_was\n @previous_assigned_to_id = assigned_to_id_was\n end",
"def self_propagation!\n new_rem = self.self_propagation\n new_rem.save\n\n new_rem\n end",
"def test_modified\n parent = RoBaseIf.new( 'parent', '' )\n base = RoBaseIf.new( 'lab1', '' )\n base.parent = parent\n assert_equal false, parent.modified\n assert_equal false, base.modified\n base.value = 'A'\n assert_equal true, parent.modified\n assert_equal true, base.modified\n end",
"def parent=(parent)\n if @parent\n @parent.remove_child(self)\n end\n\n @parent = parent\n\n if @parent\n @parent.children << self\n @parent.add_observer self\n set_depth @parent.depth + 1\n else\n set_depth 0\n end\n\n self\n end",
"def parent=(operator)\n @options[:parent]= operator\n end",
"def parent=(node)\n if self.parent\n self.parent.children.delete(self)\n end\n @parent = node\n node.children << self unless node == nil || node.children.include?(self)\n end",
"def compile_assign(scope, left, right)\n # transform \"foo.bar = baz\" into \"foo.bar=(baz) - FIXME: Is this better handled in treeoutput.rb?\n # Also need to handle :call equivalently.\n if left.is_a?(Array) && left[0] == :callm && left.size == 3 # no arguments\n return compile_callm(scope, left[1], (left[2].to_s + \"=\").to_sym, right)\n end\n\n source = compile_eval_arg(scope, right)\n atype = nil\n aparam = nil\n @e.save_register(source) do\n args = get_arg(scope,left,:save)\n atype = args[0] # FIXME: Ugly, but the compiler can't yet compile atype,aparem = get_arg ...\n aparam = args[1]\n atype = :addr if atype == :possible_callm\n end\n\n if atype == :addr\n @global_scope.globals << aparam\n @global_constants << aparam\n elsif atype == :ivar\n # FIXME: The register allocation here\n # probably ought to happen in #save_to_instance_var\n @e.pushl(source)\n ret = compile_eval_arg(scope, :self)\n @e.with_register do |reg|\n @e.popl(reg)\n @e.save_to_instance_var(reg, ret, aparam)\n end\n return [:subexpr]\n end\n\n if !(@e.save(atype, source, aparam))\n err_msg = \"Expected an argument on left hand side of assignment - got #{atype.to_s}, (left: #{left.inspect}, right: #{right.inspect})\"\n error(err_msg, scope, [:assign, left, right]) # pass current expression as well\n end\n return [:subexpr]\n end",
"def owner=(new_owner)\n if @owner != new_owner\n @dacl.reassign!(@owner, new_owner)\n @owner = new_owner\n end\n end",
"def reassign_network_id (new_network_id) \r\n term_root = self.find_root_termination_supporter\r\n term_root.update_support_hierrachy_network_id(new_network_id)\r\n term_root.find_connected_terminations_in_support_hierarchy.each do |t| \r\n t.find_connected_peer_terminations.each do |pt| \r\n pt.reassign_network_id(new_network_id) unless pt.network_id.eql?(new_network_id)\r\n end\r\n end\r\n end",
"def reassign_expressions!(node2reassign)\n # Build the replacement table.\n node2rep = node2reassign.map {|n,r| [n,r[0]] }.to_h\n\n # First recurse on the sub blocks.\n # self.each_block { |block| block.reassign_expressions!(node2rep) }\n self.each_block { |block| block.reassign_expressions!(node2reassign) }\n\n # Now work on the block.\n # Replace on the statements.\n self.map_statements! do |statement|\n # Do the replacement\n node2rep_done = statement.replace_expressions!(node2rep)\n # Assign the replaced nodes in a new block.\n unless node2rep_done.empty?\n blk = Block.new(:seq)\n node2rep_done.each do |node,rep|\n reassign = node2reassign[node][1].clone\n blk.add_statement(Transmit.new(reassign,node.clone))\n end\n blk.add_statement(statement.clone)\n blk\n else\n statement\n end\n end\n end",
"def __parent_hash=(hash)\n @__parent_hash = hash\n end",
"def map_nodes!(&ruby_block)\n @left = ruby_block.call(@left)\n left.parent = self unless left.parent\n @right = ruby_block.call(@right)\n right.parent = self unless right.parent\n end",
"def visitAssignTo(elem, data)\r\n @@log.debug(\"XmlRuleVisitor::visitAssignTo\")\r\n @@log.debug(elem.inspect)\r\n\r\n if (elem.elements.size < 1)\r\n @@log.error(\"AssignTo element has no children.\")\r\n end\r\n\r\n elem.each_element do |child|\r\n data = visit(child, data)\r\n end\r\n\r\n return data\r\n end"
] | [
"0.6804454",
"0.6804454",
"0.67807",
"0.6258756",
"0.62358046",
"0.6040949",
"0.6011162",
"0.5990504",
"0.5940112",
"0.5925864",
"0.59229577",
"0.5913215",
"0.58682567",
"0.58682567",
"0.58682567",
"0.58682567",
"0.58682567",
"0.5850792",
"0.57658243",
"0.572131",
"0.5706517",
"0.5677893",
"0.5675881",
"0.56411093",
"0.5634797",
"0.5627553",
"0.5622895",
"0.5618444",
"0.55899036",
"0.5580595",
"0.5580595",
"0.55641687",
"0.5563155",
"0.55500984",
"0.5541673",
"0.552994",
"0.55061895",
"0.5492572",
"0.54466826",
"0.54456234",
"0.54285187",
"0.54118216",
"0.5407565",
"0.5400604",
"0.5400604",
"0.5396645",
"0.53963166",
"0.5394121",
"0.5352591",
"0.53524894",
"0.53505176",
"0.5345398",
"0.5344947",
"0.5341939",
"0.5341939",
"0.5341939",
"0.5339262",
"0.5337918",
"0.5318182",
"0.53149205",
"0.5311955",
"0.5306605",
"0.5305444",
"0.5304134",
"0.52948993",
"0.5292434",
"0.5290371",
"0.5288185",
"0.52850455",
"0.5279161",
"0.52737933",
"0.5272504",
"0.52633595",
"0.5256195",
"0.52502704",
"0.5248822",
"0.52462196",
"0.52384293",
"0.52264696",
"0.52264696",
"0.52240217",
"0.52153563",
"0.52044076",
"0.5194279",
"0.5194132",
"0.5191744",
"0.5188441",
"0.5187673",
"0.5180374",
"0.5176855",
"0.5170498",
"0.5168361",
"0.51675934",
"0.5164979",
"0.5159232",
"0.5158152",
"0.5157734",
"0.5151915",
"0.51486737",
"0.5139742"
] | 0.517961 | 89 |
update() an internal routine that encapsulates the common functionality needed to use this Selector for update work | def update( search_nodes )
if has_target_predicate? then
search_nodes.each do |node|
if node.slot_filled?(@slot_name) then
unless @target_predicate.apply(node[@slot_name].to_a).empty?
yield( node )
end
end
end
else
search_nodes.each do |node|
yield( node )
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update() end",
"def update ; end",
"def update\n \n end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update\n # Not generally used\n end",
"def update\n # Not generally used\n end",
"def update!(**args)\n @render_effort = args[:render_effort] if args.key?(:render_effort)\n @selector_id = args[:selector_id] if args.key?(:selector_id)\n end",
"def update\n \t\n end",
"def update\n \t\n end",
"def update\n \n end",
"def update\r\n\r\n end",
"def update\r\n end",
"def update\r\n end",
"def update\r\n end",
"def update\r\n end",
"def update\r\n end",
"def update\n\t\t# Left empty intentionally.\n\tend",
"def update!(**args)\n @access_selector = args[:access_selector] if args.key?(:access_selector)\n @identity_selector = args[:identity_selector] if args.key?(:identity_selector)\n @parent = args[:parent] if args.key?(:parent)\n @resource_selector = args[:resource_selector] if args.key?(:resource_selector)\n end",
"def update()\n end",
"def update\n #\n # NO-OP\n #\n end",
"def update(opts); end",
"def update\n raise NotImplementedError\n end",
"def update\n raise NotImplementedError\n end",
"def update\n raise NotImplementedError\n end",
"def update\n\t\t\n\t\tend",
"def update; end",
"def update(node); end",
"def update\n raise NotImplementedError\n end",
"def update \n end",
"def update(...)\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def _update(*)\n fail NotImplementedError\n end",
"def update\n end",
"def update \n end",
"def update;end",
"def update\n # TODO: implement update\n end",
"def update\n #Nothing necessary\n end",
"def update\n ;\n end",
"def update\n raise NotImplementedError\n end",
"def update\n \n end",
"def update\n \n end",
"def update\n \n end",
"def update\n \n end",
"def update\n \n end",
"def update\n \n end",
"def update\n \n end",
"def update\n \n end",
"def update\n \n end",
"def update\n \n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end",
"def update\n end"
] | [
"0.71479994",
"0.70060945",
"0.6830604",
"0.67938995",
"0.67938995",
"0.67938995",
"0.67938995",
"0.67938995",
"0.67938995",
"0.67938995",
"0.67938995",
"0.66593814",
"0.66593814",
"0.6632417",
"0.6588756",
"0.6588756",
"0.6574683",
"0.6524907",
"0.64788467",
"0.6473403",
"0.6473403",
"0.6473403",
"0.6473403",
"0.6473092",
"0.6446384",
"0.6400851",
"0.6399508",
"0.6389424",
"0.638546",
"0.638546",
"0.6376168",
"0.6371841",
"0.6369896",
"0.6346879",
"0.6343261",
"0.6343025",
"0.63305056",
"0.6326897",
"0.6326897",
"0.6326897",
"0.6326897",
"0.6326897",
"0.6326897",
"0.6326897",
"0.6326897",
"0.6326897",
"0.6326897",
"0.6326897",
"0.6326352",
"0.63254005",
"0.6274851",
"0.6271301",
"0.6250258",
"0.62466395",
"0.62464553",
"0.6231744",
"0.6164216",
"0.6164216",
"0.6164216",
"0.6164216",
"0.6164216",
"0.6164216",
"0.6164216",
"0.6164216",
"0.6164216",
"0.6164216",
"0.61444086",
"0.61444086",
"0.61444086",
"0.61444086",
"0.61444086",
"0.61444086",
"0.61444086",
"0.61444086",
"0.61444086",
"0.61444086",
"0.61444086",
"0.61444086",
"0.61444086",
"0.61444086",
"0.61444086",
"0.61444086",
"0.61444086",
"0.61444086",
"0.61444086",
"0.61444086",
"0.61444086",
"0.61444086",
"0.61444086",
"0.61444086",
"0.61444086",
"0.61444086",
"0.61444086",
"0.61444086",
"0.61444086",
"0.61444086",
"0.61444086",
"0.61444086",
"0.61444086",
"0.61444086",
"0.61444086"
] | 0.0 | -1 |
go Executes the query returns LiteralResult a wrapper for the search results | def go
captured = query_by_referrer
return captured if captured.found?
default_ordered_query
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def execute\n # build the query string\n # run the query\n # return the results\n end",
"def query_result(**args)\n solr_service.query_result(build, **args)\n end",
"def execute_query\n the_query = create_query\n\n #to do: start and end offsets\n results = the_query.all.collect { |result|\n the_result = {id: result.id, uuid: result.uuid, start_offset_seconds: nil, end_offset_seconds: nil}\n OpenStruct.new(the_result)\n }\n to_return = {:search => self, :query => the_query, :items => results}\n OpenStruct.new(to_return)\n end",
"def execute\n reset\n params = @query.to_params\n @solr_result = @connection.request(\"/#{request_handler}\", params, {:header => {'Content-Type' => 'application/x-www-form-urlencoded'}})\n self\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = SearchResultSet.new(resp)\n return results\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = SearchResultSet.new(resp)\n return results\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = SearchResultSet.new(resp)\n return results\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = FullTextSearchResultSet.new(resp)\n return results\n end",
"def run\n self.prominence!\n return self.send_results if @query.any?\n\n self.fuzzy_match\n self.apply_narrowing_filters\n self.apply_limit\n self.load_and_sort_by_matches\n self.send_results\n end",
"def execute_search(query)\n search_resource.retrieve(query)\n end",
"def execute\n reset\n params = @query.to_params\n @solr_result = @connection.post \"#{request_handler}\", :data => params\n self\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = AdSearchResultSet.new(resp)\n return results\n end",
"def result\n return @result if defined?(@result)\n @search.populate_hits\n @result\n end",
"def complete_search\n if is_boolean? && !!@search_value != @search_value\n puts 'No result found'\n return\n end\n if NUMBER_TO_OBJECT_MAP[@object].column_names.include?(@search_term)\n results = NUMBER_TO_OBJECT_MAP[@object].where(\"#{@search_term}\" => @search_value)\n else\n results = NUMBER_TO_OBJECT_MAP[@object].joins(@search_term.to_sym).where(\"#{@search_term}\" => { value: @search_value })\n end\n \n if !results.empty?\n puts 'Result'\n puts '-------------'\n results.each do |result|\n result.render_object\n end\n else\n puts 'No result found'\n end\n results\n end",
"def execute\n @model_class.search(KEYWORD)\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = SearchWordsResultSet.new(resp)\n return results\n end",
"def search(query); end",
"def search\n engine = BentoSearch.get_engine(params[:engine_id])\n # put it in an iVar mainly for testing purposes.\n @engine = engine\n\n\n unless engine.configuration.allow_routable_results == true\n raise AccessDenied.new(\"engine needs to be registered with :allow_routable_results => true\")\n end\n\n @results = engine.search safe_search_args(engine, params)\n # template name of a partial with 'yield' to use to wrap the results\n @partial_wrapper = @results.display_configuration.lookup!(\"ajax.wrapper_template\")\n\n # partial HTML results\n render \"bento_search/search/search\", :layout => false\n\n end",
"def RunQueries\n if @reqs.empty?\n @error = 'No queries defined, issue AddQuery() first'\n return false\n end\n\n req = @reqs.join('')\n nreqs = @reqs.length\n @reqs = []\n response = PerformRequest(:search, req, nreqs)\n \n # parse response\n begin\n results = []\n ires = 0\n while ires < nreqs\n ires += 1\n result = {}\n \n result['error'] = ''\n result['warning'] = ''\n \n # extract status\n status = result['status'] = response.get_int\n if status != SEARCHD_OK\n message = response.get_string\n if status == SEARCHD_WARNING\n result['warning'] = message\n else\n result['error'] = message\n results << result\n next\n end\n end\n \n # read schema\n fields = []\n attrs = {}\n attrs_names_in_order = []\n \n nfields = response.get_int\n while nfields > 0\n nfields -= 1\n fields << response.get_string\n end\n result['fields'] = fields\n \n nattrs = response.get_int\n while nattrs > 0\n nattrs -= 1\n attr = response.get_string\n type = response.get_int\n attrs[attr] = type\n attrs_names_in_order << attr\n end\n result['attrs'] = attrs\n \n # read match count\n count = response.get_int\n id64 = response.get_int\n \n # read matches\n result['matches'] = []\n while count > 0\n count -= 1\n \n if id64 != 0\n doc = response.get_int64\n weight = response.get_int\n else\n doc, weight = response.get_ints(2)\n end\n \n r = {} # This is a single result put in the result['matches'] array\n r['id'] = doc\n r['weight'] = weight\n attrs_names_in_order.each do |a|\n r['attrs'] ||= {}\n \n case attrs[a]\n when SPH_ATTR_BIGINT\n # handle 64-bit ints\n r['attrs'][a] = response.get_int64\n when SPH_ATTR_FLOAT\n # handle floats\n r['attrs'][a] = response.get_float\n\t\t\t\twhen SPH_ATTR_STRING\n\t\t\t\t # handle string\n\t\t\t\t r['attrs'][a] = response.get_string\n else\n # handle everything else as unsigned ints\n val = response.get_int\n if attrs[a]==SPH_ATTR_MULTI\n r['attrs'][a] = []\n 1.upto(val) do\n r['attrs'][a] << response.get_int\n end\n elsif attrs[a]==SPH_ATTR_MULTI64\n r['attrs'][a] = []\n\t\t\t\t\tval = val/2\n 1.upto(val) do\n r['attrs'][a] << response.get_int64\n end\n else\n r['attrs'][a] = val\n end\n end\n end\n result['matches'] << r\n end\n result['total'], result['total_found'], msecs, words = response.get_ints(4)\n result['time'] = '%.3f' % (msecs / 1000.0)\n \n result['words'] = {}\n while words > 0\n words -= 1\n word = response.get_string\n docs, hits = response.get_ints(2)\n result['words'][word] = { 'docs' => docs, 'hits' => hits }\n end\n \n results << result\n end\n #rescue EOFError\n # @error = 'incomplete reply'\n # raise SphinxResponseError, @error\n end\n \n return results\n end",
"def execute_search\n variables = @search_stack.map { |el| el[0] }\n searches = @search_stack.map { |el| el[1] }\n @hits = Algolia.multiple_queries(searches)['results']\n variables.each_with_index do |variable, index|\n instance_variable_set \"@#{variable}\", SearchResults.new(@hits[index])\n end\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = FindResultSet.new(resp)\n return results\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = SearchByKeywordResultSet.new(resp)\n return results\n end",
"def run()\n if @type.nil?\n output_available_query_types\n else\n output_query_results\n end\n end",
"def response\n @response ||= search.execute!\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = ListSearchResultsResultSet.new(resp)\n return results\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = SiteSearchResultSet.new(resp)\n return results\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = SearchLoansResultSet.new(resp)\n return results\n end",
"def fetch\n @result = Result.new(data, :query => self)\n end",
"def run_query()\n return nil unless @query\n \n gres = @query.execute()\n if @filterClass \n fres = @filterClass.filter(gres)\n res = fres.kind_of?(Array) ? fres.join(\"\\n\") : fres.to_s\n elsif @filterBlock \n fres = @filterBlock.call(gres)\n res = fres.kind_of?(Array) ? fres.join(\"\\n\") : fres.to_s\n else\n res = fres.result_s\n end\n res\n end",
"def search\n @hits = []\n\n if params[:query]\n search = DesignMethod.solr_search do\n fulltext params[:query] do\n highlight\n minimum_match 0\n end\n end\n store_location\n @hits = search.hits\n @results = search.results\n end\n\n respond_to do |format|\n format.html\n format.json { render json: @results }\n end\n end",
"def results\n send_query\n end",
"def search_result\n query = search_params.presence && search_params\n results = query.present? ? helpers.search_query(query) :helpers.create_query(current_user)\n render json: {:data => results, :total => results.results.total}\n end",
"def find(query); end",
"def find(query); end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = SchoolSearchResultSet.new(resp)\n return results\n end",
"def results\n send_query\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = TransactionSearchResultSet.new(resp)\n return results\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = TransactionSearchResultSet.new(resp)\n return results\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = SearchLendersResultSet.new(resp)\n return results\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = FindByKeywordResultSet.new(resp)\n return results\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = GeoSearchResultSet.new(resp)\n return results\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = QueryResultSet.new(resp)\n return results\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = QueryResultSet.new(resp)\n return results\n end",
"def execute\n @result = MdnQuery::SearchResult.from_url(url)\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = QueryResultSet.new(resp)\n return results\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = FilterSearchResultsResultSet.new(resp)\n return results\n end",
"def find_with(results, with = nil)\n ret = QueryResult.new\n ret << results if results\n ret << with if with\n ret.flatten!\n\n ret.size == 1 ? ret[0] : ret\n end",
"def search(query)\n results(query).map { |r| result_class.new(r) }\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = SearchByCategoryResultSet.new(resp)\n return results\n end",
"def search_results(load: true)\n Pseud.search(body: search_body, load: load)\n end",
"def run(query:)\n Vidalia::log(\"SQL query text: \\\"#{query}\\\"\",:style => :debug)\n open_connection\n result = launch_query_command(query: query)\n if result.size > 0\n count = 1\n result.each do |r|\n Vidalia::log(\"SQL query result (#{count}): \\\"#{r.inspect}\\\"\",:style => :debug)\n count += 1\n end\n else\n Vidalia::log(\"SQL query: NO RESULTS FOUND\",:style => :debug)\n end\n rescue Exception => e\n raise e\n else\n return result\n ensure\n close_connection\n end",
"def results(query, reverse = false)\n raise NotImplementedError.new\n end",
"def run_query(terms)\n return Book.run_search(terms)\nend",
"def execute(input_set = nil)\n resp = super(input_set)\n results = NameSearchResultSet.new(resp)\n return results\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = SearchBySubjectResultSet.new(resp)\n return results\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = FindByLatLonResultSet.new(resp)\n return results\n end",
"def to_results\n info = request :q => @query, :rsz => @opts[:size], :start => ((@opts[:page] - 1) * @opts[:size])\n results = info[:results]\n query_strings = info[:query_strings]\n coder = HTMLEntities.new\n if(results['responseData']['cursor']['currentPageIndex'].nil?)\n new_one = Chen::Results.new\n new_one.estimated = 0\n return new_one\n end\n \n \n current_page = results['responseData']['cursor']['currentPageIndex']+1\n max_result = query_strings[:start] + query_strings[:rsz]\n estimated_results = results['responseData']['cursor']['resultCount']\n result_array = results['responseData']['results']\n \n datas = Chen::Results.new\n datas.estimated = estimated_results\n result_array.each_with_index do |result, i|\n new_data = Chen::SearchResult.new\n new_data.tap do |d|\n d.title = result[\"titleNoFormatting\"]\n d.url = result[\"url\"]\n d.desc = result[\"content\"].squeeze(\" \")\n d.number = (i + query_strings[:start] + 1)\n end\n datas << new_data\n end\n return datas\n end",
"def execute\n render json: Schema.instance.execute(\n params[:query],\n variables: to_hash(params[:variables]),\n context: context\n )\n end",
"def result \n # Get appropriate search types\n case params[:search_type]\n when \"purchase_order_search\"\n @class = PurchaseOrder\n @css_class = \"purchaseorders\"\n @name = \"Purchase Orders\"\n when \"keycodes_search\"\n @class = Key\n @css_class = \"keycodes\"\n @name = \"Key Codes\"\n when \"end_user_search\"\n @class = EndUser\n @css_class = \"endusers\"\n @name = \"End Users\"\n when \"purchaser_search\"\n @class = Purchaser\n @css_class = \"purchasers\"\n @name = \"Purchaser\"\n when \"assignment_search\"\n @class = Relationship\n @css_class = \"assignments\"\n @name = \"Assignments\"\n end\n \n # Execute search and sort results based on selected model\n @search = @class.search(params[:q])\n @list = @search.result\n @search.build_condition if @search.conditions.empty?\n @search.build_sort if @search.sorts.empty?\n end",
"def search_result\n # user specified that they want to search questions?\n # user specified that they want to search courses ?\n \n if params[:search_for] == \"question\"\n if !search_params[\"question_keyword\"].nil? and search_params[\"question_keyword\"].include?(',')\n search_params[\"question_keyword\"] = search_params[\"question_keyword\"].tr(',', '').strip #scrub any commas in our search\n end\n\n db = Search.search_questions(search_params.to_h)\n @results = JSON.parse(db.to_json)\n elsif params[:search_for] == \"course\"\n db = Search.search_courses(search_params.to_h)\n @results = JSON.parse(db.to_json)\n end\n\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = GetSearchRecordsResultSet.new(resp)\n return results\n end",
"def search_implementation(args)\n\n # 'args' should be a normalized search arguments hash including the following elements:\n # :query, :per_page, :start, :page, :search_field, :sort\n Rails.logger.debug(\"mjc12test: BlacklightEngine search called. Query is #{args[:query]}}\")\n bento_results = BentoSearch::Results.new\n\n # Format is passed to the engine using the configuration set up in the bento_search initializer\n # If not specified, we can maybe default to books for now.\n format = configuration[:blacklight_format] || 'Digital Collections'\n base = Addressable::URI.parse(\"https://digital.library.cornell.edu\")\n uri = URI( base + \"catalog.bento\")\n params = {\n :q => args[:oq],\n :utf8 => \"✓\",\n :search_field => \"all_fields\",\n :rows => 3\n }\n uri.query = URI.encode_www_form(params)\n url = Addressable::URI.parse(uri)\n url.normalize\n portal_response = JSON.load(URI.open(url))\n\n # Rails.logger.debug \"mjc12test: #{portal_response}\"\n if portal_response.nil? || portal_response['response'].nil? || portal_response['response']['docs'].nil?\n results = []\n else\n results = portal_response['response']['docs']\n end\n\n results.each do |i|\n\n item = BentoSearch::ResultItem.new\n item.title = i['title_tesim'][0].to_s\n [i['creator_facet_tesim']].each do |a|\n item.authors << a\n end\n if i['collection_tesim'].present? && i['solr_loader_tesim'].present? && i['solr_loader_tesim'][0] == \"eCommons\"\n item.abstract = i['collection_tesim'][0].to_s + \" Collection in eCommons\"\n elsif i['collection_tesim'].present?\n item.abstract = i['collection_tesim'][0].to_s\n elsif i['description_tesim'].present?\n item.abstract = i['description_tesim'][0].to_s\n end\n if i['media_URL_size_0_tesim'].present?\n item.format_str = i['media_URL_size_0_tesim'][0].to_s\n end\n if i['date_tesim'].present?\n item.publication_date = i['date_tesim'][0].to_s\n end\n if i['solr_loader_tesim'].present? && i['solr_loader_tesim'][0] == \"eCommons\"\n item.link =i['handle_tesim'][0]\n else\n url = URI(base + \"catalog/#{i['id']}\")\n url.normalize\n item.link = url.to_s\n end\n bento_results << item\n end\n\n if portal_response.nil? || portal_response['response'].nil? || portal_response['response']['pages'].nil? || portal_response['response']['pages']['total_count'].nil?\n bento_results.total_items = 0\n else\n bento_results.total_items = portal_response['response']['pages']['total_count']\n end\n\n return bento_results\n\n end",
"def query\n @query = Riddle::Query.escape params[:search]\n end",
"def query\n @query = Riddle::Query.escape params[:search]\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = SearchTeamsResultSet.new(resp)\n return results\n end",
"def query; end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = GetDocumentResultSet.new(resp)\n return results\n end",
"def query(query, args = {})\n args[:q] = query\n args[:qt] = 'standard'\n conn = ActiveFedora::SolrService.instance.conn\n result = conn.post('select', data: args)\n result.fetch('response').fetch('docs')\n end",
"def query\n unless @query\n parse_query()\n end\n @query\n end",
"def api_search(what, where, options={})\n uri = assemble_uri(what, where, @@default_options.merge(options))\n results = self::Results.new\n results.uri = uri\n results.success = false\n begin\n doc = Hpricot(Net::HTTP.get(URI(uri)))\n response = doc.at('response')\n results.query = response.at('query').inner_html\n results.location = response.at('location').inner_html\n results.dupefilter = determine_dupefilter(response)\n results.highlight = determine_highlight(response)\n results.totalresults = response.at('totalresults').inner_html.to_i\n results.start = response.at('start').inner_html.to_i\n results.end = response.at('end').inner_html.to_i\n response.search('result').each { |res| results << parse_result(res) }\n results.success = true\n rescue\n results.totalresults = 0\n end\n results\n end",
"def query_search(query, options={})\n run_query query, options\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = LookupResultSet.new(resp)\n return results\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = PlaceResultSet.new(resp)\n return results\n end",
"def query\n print_banner\n @value = query_ask\n end",
"def execute\n results = ResultSet.new( @db, @statement.to_s )\n\n if block_given?\n begin\n yield results\n ensure\n results.close\n end\n else\n return results\n end\n end",
"def _query(q, params={})\n engine = Java::OrgNeo4jCypherJavacompat::ExecutionEngine.new(db)\n result = engine.execute(q, Core::HashWithIndifferentAccess.new(params))\n Neo4j::Cypher::ResultWrapper.new(result)\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = AncestryResultSet.new(resp)\n return results\n end",
"def get_results()\n restriction_nodes = []\n result_nodes = []\n if !(@inputs.nil? || @inputs.empty? || @inputs.first.empty?)\n input_set = @inputs.first\n restriction_nodes= input_set.nodes\n result_nodes = input_set.breadth_first_search(true){|node| node.item.text.downcase.include?(@keyword_phrase.to_s.downcase)} \n end\n \n if !@inplace\n results = @server.match_all(parse_keyword_phrase(), restriction_nodes) \n result_nodes = results.map{|item| Xplain::Node.new(item: item)}\n end\n \n result_nodes\n \n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = QueryArticlesResultSet.new(resp)\n return results\n end",
"def exec_query( context, result, reference, query, lang )\n @trace_file.puts \"exec_query ref #{reference}, query #{query}, lang #{lang}\"\n result.done\n true\n end",
"def exec_query( context, result, reference, query, lang )\n @trace_file.puts \"exec_query ref #{reference}, query #{query}, lang #{lang}\"\n result.done\n true\n end",
"def exec_query( context, result, reference, query, lang )\n @trace_file.puts \"exec_query ref #{reference}, query #{query}, lang #{lang}\"\n result.done\n true\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = FindByURLResultSet.new(resp)\n return results\n end",
"def search\n query = params[:q]\n works = ActiveFedora::SolrService.query(query, fq: @fq, fl: @fl, df: @df, rows: @max_rows) \n format_solr_keys(works)\n render(json: works)\n end",
"def render\n\t\t\t@wiki_query.query_result.to_json\n\t\tend",
"def search(search_options={})\n result = jambase_search(search_options)\n return convert(result.body) unless result.blank?\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = GetWordOfTheDayResultSet.new(resp)\n return results\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = PostCodeSearchResultSet.new(resp)\n return results\n end",
"def run\n _escaped_sql = escaped_sql\n @query_logger << _escaped_sql if @query_logger\n result = @conn.exec_query _escaped_sql\n row_class = OccamsRecord::Results.klass(result.columns, result.column_types, @eager_loaders.names, model: @eager_loaders.model, modules: @use)\n rows = result.rows.map { |row| row_class.new row }\n @eager_loaders.run!(rows, query_logger: @query_logger)\n rows\n end",
"def query\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = CampaignSearchResultSet.new(resp)\n return results\n end",
"def execute\n yield ResultEnumerator.new(self)\n end",
"def query(query)\n res = LibDrizzle.drizzle_query_str(@con_ptr, nil, query, @ret_ptr)\n check_return_code\n Result.new(res)\n end",
"def init_results_for_search\n # try to find asqs and tags that match search string\n search_string = params[:search].downcase\n @title = \"Search for \\\"#{params[:search]}\\\"\"\n @matched_names = search_asqs_by_column('name', search_string)\n @matched_queries = search_asqs_by_column('query', search_string)\n @matched_tags = Asq.tagged_with(search_string.split(' '), wild: true)\n @matched_creator = Asq.where(created_by: search_string)\n @matched_modifier = Asq.where(modified_by: search_string)\n sort_matched_arrays\n redirect_if_single_result\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = ClosestMatchSearchResultSet.new(resp)\n return results\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = SpacialNameSearchResultSet.new(resp)\n return results\n end",
"def parse_results\n RETS4R::ResponseDocument::Search.parse(self.to_s).to_transaction\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = LodgingResultSet.new(resp)\n return results\n end",
"def execute()\n\t\n\t\t# Retrieve a single entry from CHG:Infrastructure Change based on Remedy Login ID\n\t\tentry = @@remedy_forms['CHG:Infrastructure Change'].find_entries(\n\t\t :single,\n\t\t :conditions => [%|'#{@search_by_field}' = \"#{@parameters['search_value']}\"|],\n\t\t :fields => :all\n\t\t)\n\t\tif entry.nil?\n\t\t raise(%|Could not find entry on CHG:Infrastructure Change with '#{@search_by_field}'=\"#{@parameters['search_value']}\"|)\n\t\tend\n\t\t\n\n\t\t#For backwards compability with ArsModels prior to v2 as prior versions do not have a .to_s method for the EnumFieldValue class.\n\t\t#Only Enum & non-remedy types are included in the temp hash of field values.\n\t\thash_entry = {}\n\t\tentry.to_h.each do |key, value|\n\t\t\tif value.is_a? ArsModels::FieldValues::EnumFieldValue\n\t\t\t\thash_entry[key] = value.value\n\t\t\telsif !entry[key].is_a? ArsModels::FieldValues\n\t\t\t\thash_entry[key] = value\n\t\t\tend\n\t\tend\n\n\t\t# Build the results to be returned by this handler\n\t\tresults = <<-RESULTS\n\t\t<results>\n\t\t\t<result name=\"Actual Start Date\">#{escape(hash_entry['Actual Start Date'])}</result>\n\t\t\t<result name=\"Actual End Date\">#{escape(hash_entry['Actual End Date'])}</result>\n\t\t\t<result name=\"Change Timing\">#{escape(hash_entry['Change Timing'])}</result>\n\t\t\t<result name=\"Change Type\">#{escape(hash_entry['Change Type'])}</result>\n\t\t\t<result name=\"Company\">#{escape(hash_entry['Company'])}</result>\n\t\t\t<result name=\"Company3\">#{escape(hash_entry['Company3'])}</result>\n\t\t\t<result name=\"Completed Date\">#{escape(hash_entry['Completed Date'])}</result>\n\t\t\t<result name=\"Description\">#{escape(hash_entry['Description'])}</result>\n\t\t\t<result name=\"Detailed Description\">#{escape(hash_entry['Detailed Description'])}</result>\n\t\t\t<result name=\"Earliest Start Date\">#{escape(hash_entry['Earliest Start Date'])}</result>\n\t\t\t<result name=\"First Name\">#{escape(hash_entry['First Name'])}</result>\n\t\t\t<result name=\"Impact\">#{escape(hash_entry['Impact'])}</result>\n\t\t\t<result name=\"Last Name\">#{escape(hash_entry['Last Name'])}</result>\n\t\t\t<result name=\"Location Company\">#{escape(hash_entry['Location Company'])}</result>\n\t\t\t<result name=\"Risk Level\">#{escape(hash_entry['Risk Level'])}</result>\n\t\t\t<result name=\"Scheduled End Date\">#{escape(hash_entry['Scheduled End Date'])}</result>\n\t\t\t<result name=\"Scheduled Start Date\">#{escape(hash_entry['Scheduled Start Date'])}</result>\n\t\t\t<result name=\"Status\">#{escape(hash_entry['Change Request Status'])}</result>\n\t\t\t<result name=\"SRID\">#{escape(hash_entry['SRID'])}</result>\n\t\t\t<result name=\"SRInstanceID\">#{escape(hash_entry['SRInstanceID'])}</result>\n\t\t\t<result name=\"SRMSAOIGuid\">#{escape(hash_entry['SRMSAOIGuid'])}</result>\n\t\t\t<result name=\"Submitter\">#{escape(hash_entry['Submitter'])}</result>\n\t\t\t<result name=\"Support Group Name\">#{escape(hash_entry['Support Group Name'])}</result>\n\t\t\t<result name=\"Support Organization\">#{escape(hash_entry['Support Organization'])}</result>\n\t\t\t<result name=\"Urgency\">#{escape(hash_entry['Urgency'])}</result>\n\t\t</results>\n\t\tRESULTS\n\t\tputs(results) if @debug_logging_enabled\t\n\n\t\t# Return the results String\n\t\treturn results\n\tend",
"def query\n @query ||= search.query\n end",
"def execute(input_set = nil)\n resp = super(input_set)\n results = LiteracyAndLanguageResultSet.new(resp)\n return results\n end"
] | [
"0.7323687",
"0.681167",
"0.6775319",
"0.66252273",
"0.6583636",
"0.6581239",
"0.6569499",
"0.6485346",
"0.6452613",
"0.6442163",
"0.6427986",
"0.6379311",
"0.63543785",
"0.6335833",
"0.6288873",
"0.62706095",
"0.6247185",
"0.6246871",
"0.62231237",
"0.62059677",
"0.6192346",
"0.6172573",
"0.6165491",
"0.61642057",
"0.6159391",
"0.6153174",
"0.615165",
"0.61252016",
"0.6105544",
"0.610023",
"0.6088203",
"0.608119",
"0.60788715",
"0.60788715",
"0.60656303",
"0.6041551",
"0.60342586",
"0.6029124",
"0.60285854",
"0.60158443",
"0.6009552",
"0.59995407",
"0.5995521",
"0.5994244",
"0.59926814",
"0.59913844",
"0.59889525",
"0.5977946",
"0.5961943",
"0.5960798",
"0.59370697",
"0.5927612",
"0.5918994",
"0.591746",
"0.5913654",
"0.59046596",
"0.5899394",
"0.5896572",
"0.5874038",
"0.58661777",
"0.58606064",
"0.5856554",
"0.58468",
"0.5843918",
"0.58372545",
"0.58348215",
"0.5826773",
"0.5809311",
"0.57922196",
"0.57894593",
"0.5783949",
"0.57835263",
"0.5772321",
"0.5766798",
"0.5760033",
"0.575919",
"0.5756901",
"0.57545775",
"0.574571",
"0.57432926",
"0.57432926",
"0.57432926",
"0.57413226",
"0.5741119",
"0.57300633",
"0.57270205",
"0.57264405",
"0.57168835",
"0.5714007",
"0.5712371",
"0.57084966",
"0.5706123",
"0.57023",
"0.570013",
"0.5699246",
"0.5698731",
"0.56956834",
"0.5694444",
"0.568531",
"0.56790304",
"0.56787837"
] | 0.0 | -1 |
Public: Updates a Ticket in FogBugz Returns boolean indicating whether or not the Ticket was persisted | def save
!update_case.has_key?("error")
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update\n @ticket.update(ticket_params)\n\n end",
"def update\n if current_user.id == @ticket.user_id || ProjectUser.verify_role(current_user.id, @project, 'developer')\n if params[:ticket][:status] == 'closed'\n # Unless doesn't work, but if! does for some reason?\n if !ProjectUser.verify_role(current_user.id, @project, 'owner')\n render json: { error: 'You must be the ticket author, or project owner to edit this' }, status: :unauthorized\n return\n end\n end\n if @ticket.update(ticket_params)\n render json: @ticket, status: 200\n else\n render json: @ticket.errors, status: :unprocessable_entity\n end\n else\n render json: { error: 'You must be the entry author, or on the admin team to edit this' }, status: :unauthorized\n end\n end",
"def update\n respond_to do |format|\n if @ticket.update(ticket_params)\n format.html { redirect_to @ticket, notice: \"Ticket was successfully updated.\" }\n format.json { render :show, status: :ok, location: @ticket }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ticket.update(ticket_params)\n format.html { redirect_to @ticket, notice: \"Ticket was successfully updated.\" }\n format.json { render :show, status: :ok, location: @ticket }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ticket = Ticket.find(params[:id])\n\n respond_to do |format|\n if @ticket.update_attributes(params[:ticket])\n flash[:notice] = 'Ticket was successfully updated.'\n format.html { redirect_to(@ticket) }\n format.xml { head :ok }\n else\n format.html { render :edit }\n format.xml { render :xml => @ticket.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @ticket = Ticket.find(params[:id])\n\n respond_to do |format|\n if @ticket.update_attributes(params[:ticket])\n format.html { redirect_to @ticket, notice: 'Ticket was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ticket = Ticket.find(params[:id])\n\n respond_to do |format|\n if @ticket.update_attributes(params[:ticket])\n format.html { redirect_to @ticket, notice: 'Ticket was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ticket = Ticket.find(params[:id])\n\n respond_to do |format|\n if @ticket.update_attributes(params[:ticket])\n format.html { redirect_to @ticket, notice: 'Ticket was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ticket = Ticket.find(params[:id])\n\n respond_to do |format|\n if @ticket.update_attributes(params[:ticket])\n format.html { redirect_to @ticket, notice: 'Ticket was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ticket = Ticket.find(params[:id])\n\n respond_to do |format|\n if @ticket.update_attributes(params[:ticket])\n format.html { redirect_to @ticket, notice: 'Ticket was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ticket = Ticket.find(params[:id])\n\n respond_to do |format|\n if @ticket.update_attributes(params[:ticket])\n format.html { redirect_to @ticket, notice: 'Ticket was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ticket = Ticket.find(params[:id])\n\n respond_to do |format|\n if @ticket.update_attributes(params[:ticket])\n format.html { redirect_to(@ticket, :notice => 'Ticket was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ticket.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ticket.update(ticket_params)\n format.html { redirect_to @ticket, notice: 'Ticket updated.' }\n format.json { render :show, status: :ok, location: @ticket }\n else\n format.html { render :edit }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @ticket.update(ticket_params)\n redirect_to @ticket, notice: 'Ticket was successfully updated.'\n else\n render :edit\n end\n end",
"def update\n respond_to do |format|\n if @ticket.update(ticket_params)\n format.html { redirect_to @ticket, notice: 'Ticket was successfully updated.' }\n format.json { render json: {status: :ok}, status: :ok }\n else\n format.html { render :edit }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ticket = Ticket.find(params[:id])\n\n respond_to do |format|\n if @ticket.update_attributes(params[:ticket])\n flash[:notice] = 'Ticket was successfully updated.'\n format.html { redirect_to(@ticket) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ticket.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @ticket = Ticket.find(params[:id])\n\n respond_to do |format|\n if @ticket.update_attributes(params[:ticket])\n flash[:notice] = 'Ticket was successfully updated.'\n format.html { redirect_to(@ticket) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ticket.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ticket.update(ticket_params_update)\n TicketMailer.send_ticket_status(@ticket, 'updated').deliver_later\n format.html { redirect_to @ticket, notice: 'Ticket was successfully updated.' }\n format.json { render :show, status: :ok, location: @ticket }\n else\n format.html { render :edit }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ticket = Ticket.find(params[:id])\n\n respond_to do |format|\n if @ticket.update_attributes(params[:ticket])\n format.html { redirect_to tickets_path, notice: 'Ticket was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ticket.update(ticket_params)\n format.html { \n flash[:notice] = 'La boleta se actualizó satisfactoriamente.'\n redirect_to tickets_path\n }\n format.json { render :show, status: :ok, location: @ticket }\n else\n format.html { render :edit }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ticket.update(ticket_params)\n format.html { redirect_to @ticket, notice: 'Ticket was successfully updated.' }\n format.json { render :show, status: :ok, location: @ticket }\n else\n format.html { render :edit }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ticket.update(ticket_params)\n format.html { redirect_to @ticket, notice: 'Ticket was successfully updated.' }\n format.json { render :show, status: :ok, location: @ticket }\n else\n format.html { render :edit }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ticket.update(ticket_params)\n format.html { redirect_to @ticket, notice: 'Ticket was successfully updated.' }\n format.json { render :show, status: :ok, location: @ticket }\n else\n format.html { render :edit }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ticket.update(ticket_params)\n format.html { redirect_to @ticket, notice: 'Ticket was successfully updated.' }\n format.json { render :show, status: :ok, location: @ticket }\n else\n format.html { render :edit }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ticket.update(ticket_params)\n format.html { redirect_to @ticket, notice: 'Ticket was successfully updated.' }\n format.json { render :show, status: :ok, location: @ticket }\n else\n format.html { render :edit }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ticket.update(ticket_params)\n format.html { redirect_to @ticket, notice: 'Ticket was successfully updated.' }\n format.json { render :show, status: :ok, location: @ticket }\n else\n format.html { render :edit }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ticket.update(ticket_params)\n format.html { redirect_to @ticket, notice: 'Ticket was successfully updated.' }\n format.json { render :show, status: :ok, location: @ticket }\n else\n format.html { render :edit }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ticket.update(ticket_params)\n format.html { redirect_to @ticket, notice: 'Ticket was successfully updated.' }\n format.json { render :show, status: :ok, location: @ticket }\n else\n format.html { render :edit }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ticket.update(ticket_params)\n format.html { redirect_to @ticket, notice: 'Ticket was successfully updated.' }\n format.json { render :show, status: :ok, location: @ticket }\n else\n format.html { render :edit }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ticket.update(ticket_params)\n format.html { redirect_to @ticket, notice: 'Ticket was successfully updated.' }\n format.json { render :show, status: :ok, location: @ticket }\n else\n format.html { render :edit }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ticket.update(ticket_params)\n format.html { redirect_to @ticket, notice: 'Ticket was successfully updated.' }\n format.json { render :show, status: :ok, location: @ticket }\n else\n format.html { render :edit }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ticket.update(ticket_params)\n format.html { redirect_to @ticket, notice: 'Ticket was successfully updated.' }\n format.json { render :show, status: :ok, location: @ticket }\n else\n format.html { render :edit }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ticket.update(ticket_params)\n format.html { redirect_to @ticket, notice: 'Ticket was successfully updated.' }\n format.json { render :show, status: :ok, location: @ticket }\n else\n format.html { render :edit }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ticket.update(ticket_params)\n format.html { redirect_to @ticket, notice: 'Ticket was successfully updated.' }\n format.json { render :show, status: :ok, location: @ticket }\n else\n format.html { render :edit }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ticket.update(ticket_params)\n format.html { redirect_to @ticket, notice: 'Ticket was successfully updated.' }\n format.json { render :show, status: :ok, location: @ticket }\n else\n format.html { render :edit }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ticket.update(ticket_params)\n format.html { redirect_to @ticket, notice: 'Ticket was successfully updated.' }\n format.json { render :show, status: :ok, location: @ticket }\n else\n format.html { render :edit }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ticket.update(ticket_params)\n format.html { redirect_to @ticket, notice: 'Ticket was successfully updated.' }\n format.json { render :show, status: :ok, location: @ticket }\n else\n format.html { render :edit }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ticket.update(ticket_params)\n format.html { redirect_to @ticket, notice: 'Ticket was successfully updated.' }\n format.json { render :show, status: :ok, location: @ticket }\n else\n format.html { render :edit }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ticket = Ticket.find(params[:id])\n\n respond_to do |format|\n if @ticket.update_attributes(params[:ticket])\n format.html { redirect_to(@ticket, :notice => 'Bilet został pomyślnie zaktualizowany.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ticket.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ticket.update(ticket_params)\n format.html { redirect_to @ticket, notice: 'Ticket was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :edit }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ticket.update(ticket_params)\n format.html { redirect_to edit_ticket_path(@ticket), notice: 'Ticket was successfully updated.' }\n format.json { render :show, status: :ok, location: @ticket }\n else\n format.html { render :edit }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ticket = Ticket.find(params[:id])\n\n respond_to do |format|\n if @ticket.update_attributes(params[:ticket])\n format.html { redirect_to @ticket, notice: 'Home was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ticket = Ticket.find(params[:id])\n\n # if open \n if params[:ticket][:ticket_status_id] == \"1\"\n \[email protected]_id = nil\n # if solved\n elsif params[:ticket][:ticket_status_id] == \"2\"\n \[email protected]_id = current_user.id\n \[email protected]_at = Time.now\n end\n \n respond_to do |format|\n if @ticket.update_attributes(params[:ticket])\n \t\n format.html { redirect_to(@ticket, :notice => 'Ticket was successfully updated.') }\n # format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n # format.xml { render :xml => @ticket.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ticket.update(ticket_params)\n format.html { redirect_to @ticket, notice: 'Ticket was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ticket.update(ticket_params)\n format.html { redirect_to @ticket, notice: 'Ticket was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ticket.update(ticket_params)\n format.html { redirect_to @ticket, notice: 'Ticket was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ticket = Helpdesk::Ticket.find(params[:id])\n\n respond_to do |format|\n if @ticket.update_attributes(ticket_params)\n format.html { redirect_to @ticket, notice: 'Ticket was successfully updated.'}\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ticket = @project.tickets.find_by_scoped_id!(params[:id])\n\n respond_to do |format|\n if @ticket.update_attributes(params[:ticket])\n format.html { redirect_to([@project, @ticket], :notice => 'Ticket was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ticket.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |wants|\n if @ticket.update_attributes(params[:ticket])\n flash[:notice] = 'Ticket was successfully updated.'\n wants.html { redirect_to(@ticket) }\n wants.xml { head :ok }\n wants.json { head :ok }\n else\n wants.html { render :action => \"edit\" }\n wants.xml { render :xml => @ticket.errors, :status => :unprocessable_entity }\n wants.json { render :json => @ticket.errors.full_messages, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @ticket.update_attributes(params[:ticket])\n\n respond_with(@story, @ticket)\n end",
"def update\n \n @ticket = Ticket.find(params[:id])\n \n\n if @ticket.update_attributes(params[:ticket])\n flash[:notice] = 'Ticket was successfully updated.'\n else\n flash[:notice] = 'Failed to update ticket.' \n end \n\n if params[:send_email]\n send_email\n end \n \n redirect_to :action => \"edit\", :id => @ticket \n end",
"def update\n if @ticket.update(@ticket_params)\n render_success_format('client created correctly', @ticket)\n end\n rescue StandardError => e\n Airbrake.notify(e)\n raise e\n end",
"def update\n @ticket = Ticket.find(params[:id])\n @ticket.previous_assignee_id = @ticket.assignee_id\n @ticket.updater_id = session[:user]\n\n respond_to do |format|\n if @ticket.update_attributes(params[:ticket])\n flash[:notice] = 'Ticket was successfully updated.'\n format.html { redirect_to @coll_url }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ticket.errors.to_xml }\n end\n end\n end",
"def update\n @admin_ticket = Ticket.find(params[:id])\n\n respond_to do |format|\n if @admin_ticket.update_attributes(params[:ticket])\n format.html { redirect_to admin_ticket_path(@admin_ticket), notice: 'Ticket was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @admin_ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if !check_session #Validate if the user session is active\n return #If not force return to trigger the redirect of the check_session function\n end\n resp = Ticket.find(params[:id],session[:user]) #Retrieve the original ticket object to update\n if resp[0] #Validate if the response was successfull\n @ticket = resp[1] #Set the ticket object to be updated\n elsif validate_authorized_access(resp[1]) #If the response was unsucessful, validate if it was caused by unauthorized access to the app or expired session\n flash[:danger] = t(:ticket_get_error_flash) #Set the error message for the user\n redirect_to tickets_path #Redirect the user to the tickets list page\n else\n return #If not force return to trigger the redirect of the check_session function\n end\n resp2 = @ticket.update_attributes(ticket_params,session[:user]) #Update the ticket object\n if resp2[0] #Validate if the response was successfull\n flash[:success] = t(:ticket_modification_success_flash, ticket: @ticket.name) #Set the success message for the user\n redirect_to tickets_path(:election_id =>@ticket.election_id) #Redirect the user to the tickets list page\n elsif validate_authorized_access(resp[1]) #If the response was unsucessful, validate if it was caused by unauthorized access to the app or expired session\n if(resp[1].kind_of?(Array)) #If the response was unsucessful, validate if it was caused by an invalid Ticket object sent to the model. If so the server would have returned an array with the errors\n flash[:warning] = Util.format_validation_errors(resp[1]) #Set the invalid object message for the user\n end\n flash[:danger] = t(:ticket_modification_error_flash) #Set the error message for the user\n redirect_to edit_ticket_path #Redirect the user to the Tickets edition page\n else\n return #If not force return to trigger the redirect of the check_session function\n end\n rescue #Error Handilng code\n general_error_redirection('Controller: '+params[:controller]+'.'+action_name,$!)\n end",
"def update\n respond_to do |format|\n if @ticket.update(admin_ticket_params)\n format.html { redirect_to admin_tickets_url, notice: 'Ticket was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ticket = Ticket.find(params[:id])\n\n\t\[email protected] = params[:ticket]\n\n respond_to do |format|\n if @ticket.valid?\n\t\t\t\tif TicketLog.make_log(params[:log], @ticket, current_user)\n\t\t\t\t\[email protected]\n\t\t\t\t\tflash[:notice] = 'Ticket was successfully updated.'\n\t\t\t\t\tformat.html { redirect_to(@ticket) }\n\t\t\t\t\tformat.xml { head :ok }\n\t\t\t\telse\n\t\t\t\t\[email protected] :log, \"entry cannot be blank\"\n\t\t\t\t\tformat.html { render :action => \"edit\" }\n\t\t\t\t\tformat.xml { render :xml => @ticket.errors, :status => :unprocessable_entity }\n\t\t\t\tend\n else\n\t\t\t\[email protected]\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ticket.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @ticket = @event.tickets.find(params[:id])\n respond_to do |format|\n if @ticket.update(ticket_params)\n format.html { redirect_to event_ticket_path(@event.ticket), notice: 'Ticket was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ticket_owner = TicketOwner.find(params[:id])\n\n respond_to do |format|\n if @ticket_owner.update_attributes(params[:ticket_owner])\n format.html { redirect_to @ticket_owner, notice: 'Ticket Owner was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ticket_owner.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ticketing.update(ticketing_params)\n format.html { redirect_to @ticketing, notice: \"Ticketing was successfully updated.\" }\n format.json { render :show, status: :ok, location: @ticketing }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @ticketing.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ticket = Ticket.find(params[:id])\n if params[:ticket][:user_id][0]\n @ticket.user = current_user\n end\n\n respond_to do |format|\n if @ticket.update_attributes(params[:ticket])\n unless @ticket.response.nil?\n begin\n CustomerMailer.response_email(@ticket).deliver\n rescue Net::SMTPAuthenticationError\n logger.error \"No email sent, please configure config/email.yml\"\n rescue ArgumentError\n logger.error \"No email sent, please give some arguments, empty strings\"\n end\n end\n format.html { redirect_to ticket_path(@ticket.reference), notice: 'Ticket was successfully updated.' }\n else\n format.html { render action: \"edit\" }\n end\n end\n end",
"def update\n\n respond_to do |format|\n if @ticket_purchase.update(ticket_purchase_params)\n @ticket_purchase.send_ticket\n format.html { redirect_to event_ticket_ticket_purchase_url(:id => @ticket_purchase.id, :ticket_id => @ticket_purchase.ticket_id), notice: 'Ticket purchase was successfully updated.' }\n format.json { render :show, status: :ok, location: @ticket_purchase }\n else\n format.html { render :edit }\n format.json { render json: @ticket_purchase.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ticket.update(ticket_params)\n @ticket.payment.credit.terminado\n format.html { redirect_to @ticket, notice: 'Ticket was successfully updated.' }\n format.json { render :show, status: :ok, location: @ticket }\n else\n format.html { render :edit }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ticket.update(ticket_params)\n @ticket.update_responsible(:status, 'Waiting for Staff Response')\n format.html { redirect_to @ticket, notice: 'Ticket was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ticketold = Ticket.find(@ticket.id)\n respond_to do |format|\n if @ticket.update(ticket_params)\n Account::Tickets::TicketLogs.update(@ticket, @ticketold)\n format.html { redirect_to account_tickets_path, notice: 'Ticket was successfully updated.' }\n format.json { render :show, status: :ok, location: @ticket }\n else\n format.html { render :edit }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @support_ticket = SupportTicket.find(params[:id])\n\n respond_to do |format|\n if @support_ticket.update_attributes(support_ticket_params)\n format.html { redirect_to @support_ticket, notice: 'Support ticket was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @support_ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @ticket.update(namechange_params)\n redirect_to authenticated_root_url, notice: 'Ticket was successfully updated.'\n else\n render action: 'edit'\n end\n end",
"def update\n respond_to do |format|\n if @ticketstate.update(ticketstate_params)\n format.html { redirect_to @ticketstate, notice: '更新成功' }\n format.json { render :show, status: :ok, location: @ticketstate }\n else\n format.html { render :edit }\n format.json { render json: @ticketstate.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n logger.info { \"PARAMS: #{params.inspect}\" }\n project_id, id = params[:id].split('-')\n ticket = Lighthouse::Ticket.find(id, :params => {:project_id => project_id})\n \n # insanely hacky. can't nest json, so don't want to do a willy-nilly merge.\n # move mergeable params to the [:ticket] hash to follow usual rails conventions\n # before merging\n params[:ticket] = {}\n %w(assigned_user_id state milestone_id).each do |field|\n params[:ticket].merge!( field => params.delete(field) ) if params[field]\n end\n logger.info { \"TICKET ATTRS TO UPDATE: #{params[:ticket].inspect}\"}\n \n ticket.attributes.merge!( params[:ticket] )\n ticket.save\n\n respond_to do |format|\n # if @ticket.update_attributes(params[:ticket])\n # flash[:notice] = 'Ticket was successfully updated.'\n # format.html { redirect_to(@ticket) }\n # format.xml { head :ok }\n # else\n # format.html { render :action => \"edit\" }\n # format.xml { render :xml => @ticket.errors, :status => :unprocessable_entity }\n # end\n end\n end",
"def update\n respond_to do |format|\n if @ticketbill.update(ticketbill_params)\n format.html { redirect_to @ticketbill, notice: 'Ticketbill was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @ticketbill.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sold_ticket.update(sold_ticket_params)\n format.html { redirect_to @sold_ticket, notice: 'Sold ticket was successfully updated.' }\n format.json { render :show, status: :ok, location: @sold_ticket }\n else\n format.html { render :edit }\n format.json { render json: @sold_ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @support_ticket.update(support_ticket_params)\n format.html { redirect_to @support_ticket, notice: 'Support ticket was successfully updated.' }\n format.json { render :show, status: :ok, location: @support_ticket }\n else\n format.html { render :edit }\n format.json { render json: @support_ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def UpdateTicket params = {}\n \n APICall(path: 'tickets.json',method: 'PUT',payload: params.to_json)\n \n end",
"def update\n @ticketorder = Ticketorder.find(params[:id])\n\n respond_to do |format|\n if @ticketorder.update_attributes(params[:ticketorder])\n flash[:notice] = 'Ticketorder was successfully updated.'\n format.html { redirect_to(@ticketorder) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ticketorder.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @ticket_code = TicketCode.find(params[:id])\n\n respond_to do |format|\n if @ticket_code.update_attributes(params[:ticket_code])\n format.html { redirect_to @ticket_code, notice: 'Ticket code was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @ticket_code.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n ticket = Ticket.find(params[:id])\n status = params[:status]\n\n if status and ticket.update_attributes(status: status)\n render json: {\"notice\"=>\"status updated successfully to '#{status}'\"}\n else\n render json: {\"alert\"=>\"status not updated. check params.\"}\n end\n end",
"def update\n find_changes\n \n # Prevent assigned dev from being empty string on update\n if params[:ticket][:assigned_dev_id].blank?\n params[:ticket][:assigned_dev_id] = nil\n end\n \n if ok_to_edit? and save_histories and @ticket.update(ticket_params) \n redirect_to ticket_dashboard_path(@ticket.id), notice: \"Ticket was successfully updated.\"\n else\n flash[:alert] = \"Could not update ticket.\"\n redirect_to ticket_dashboard_path(@ticket.id)\n end\n end",
"def update\n @ticket.approved_at = Time.now\n \n if @ticket.update(ticket_params)\n \n # Add customer feedback to Notes\n if @ticket.approval_feedback.present?\n @ticket.notes.create(\n note_type: :from_customer,\n note: @ticket.approval_feedback\n )\n end\n \n # Email approval\n Ticket::CustomerMailer.ticket_approval_email(@ticket).deliver_later\n \n message = if @ticket.approved?\n 'Thanks for approving our work.'\n else\n 'Thank you for your feedback.'\n end\n message += \" A confirmation will be emailed to #{@ticket.approval_email}.\"\n \n redirect_to ticket_approval_path, notice: message\n else\n approval_confirm\n end\n end",
"def update\n @breadcrumb = 'update'\n @ticket = Ticket.find(params[:id])\n @ticket.updated_by = current_user.id if !current_user.nil?\n # Should use attachment from drag&drop?\n if $attachment != nil && !$attachment.avatar.blank? && $attachment.updated_at > @ticket.updated_at\n @ticket.attachment = $attachment.avatar\n end\n if (params[:ticket][:updated_by].blank?)\n params[:ticket][:updated_by] = current_user.id if !current_user.nil?\n end\n\n respond_to do |format|\n if @ticket.update_attributes(params[:ticket])\n destroy_attachment\n $attachment = nil\n # format.html { redirect_to @ticket, notice: I18n.t('activerecord.successful.messages.updated', :model => @ticket.class.model_name.human) }\n # format.html { redirect_to params[:referrer], notice: I18n.t('activerecord.successful.messages.updated', :model => @ticket.class.model_name.human) }\n format.html { redirect_to params[:referrer],\n notice: (crud_notice('updated', @ticket) + \"#{undo_link(@ticket)}\").html_safe }\n format.json { head :no_content }\n else\n destroy_attachment\n $attachment = Attachment.new\n @offices = @ticket.organization.blank? ? offices_dropdown : offices_dropdown_edit(@ticket.organization_id)\n @technicians = @ticket.organization.blank? ? technicians_dropdown : @ticket.organization.technicians.order(:name)\n format.html { render action: \"edit\" }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ticket_action = TicketAction.find(params[:id])\n\n respond_to do |format|\n if @ticket_action.update_attributes(params[:ticket_action])\n flash[:notice] = 'TicketAction was successfully updated.'\n format.html { redirect_to(@ticket_action) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ticket_action.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @ticket = Ticket.find(params[:id])\n\t\tchanges = \"\"\n\t\tnew_employee = params[:ticket][:employee_id].nil? || params[:ticket][:employee_id].empty? ? nil : Employee.find(params[:ticket][:employee_id])\n\t\tunless new_employee == @ticket.employee\n\t\t\tchanges += \"> Responsible changed from #{@ticket.employee ? @ticket.employee.login : \"None\"} to #{new_employee.login}\"\n\t\t\[email protected] = new_employee\n\t\tend\n\t\tnew_status = params[:ticket][:status_id].nil? || params[:ticket][:status_id].empty? ? nil : Status.find(params[:ticket][:status_id])\n\t\tunless new_status == @ticket.status\n\t\t\tchanges += $/ + \"> Status changed from \\\"#{@ticket.status ? @ticket.status.name : \"None\"}\\\" to \\\"#{new_status.name}\\\"\"\n\t\t\[email protected] = new_status\n\t\tend\n\t\t@reply = @ticket.replies.build(params[:reply])\n\t\[email protected] = changes\n\t\[email protected] = current_user.login\n respond_to do |format|\n if @ticket.valid? && @reply.valid?\n\t\t\t\[email protected]\n\t\t\t\[email protected]\n\t\t\t\tCustomerSupport.update_ticket_email(@ticket,@reply).deliver\n format.html { redirect_to backend_ticket_path(@ticket), notice: 'Ticket was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"show\" }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def valid?\n @ticket.present?\n end",
"def update\n respond_to do |format|\n if @ticket_option.update(ticket_option_params)\n format.html { redirect_to @ticket_option, notice: 'Ticket option was successfully updated.' }\n format.json { render :show, status: :ok, location: @ticket_option }\n else\n format.html { render :edit }\n format.json { render json: @ticket_option.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ticket_item.update(ticket_item_params)\n format.html { redirect_to [:admin, @ticket_item], notice: 'Ticket item was successfully updated.' }\n format.json { render :show, status: :ok, location: @ticket_item }\n else\n format.html { render :edit }\n format.json { render json: @ticket_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def ticket_status_updated(ticket)\n\t@ticket = ticket\n\n mail to: @ticket.customer_email, subject: \"You ticket updated\"\n end",
"def update\n a = Ticket.find(params[:id])\n a.destroy()\n render json: \"success\"\n end",
"def update\n respond_to do |format|\n if @ticket_event.update(ticket_event_params)\n format.html { redirect_to @ticket_event, notice: 'Ticket event was successfully updated.' }\n format.json { render :show, status: :ok, location: @ticket_event }\n else\n format.html { render :edit }\n format.json { render json: @ticket_event.errors, status: :unprocessable_entity }\n end\n end\n end",
"def activate\n @ticket = Ticket.find(params[:id]) \n if isAuth @ticket # only ticket owner or admin can update\n @ticket.updated_by = current_user.id\n @ticket.active = true\n if @ticket.save\n flash[:ticket] = \"Ticket has been successfully activated!\"\n render 'show', :status => :ok\n else\n @errMsg = @ticket.errors.full_messages\n print @errMsg \n render 'error', :status => :unprocessable_entity\n end\n else\n @errMsg = \"user is not authorized to update.\"\n print @errMsg \n render 'error', :status => :unprocessable_entity\n end\n end",
"def update\n @submitval = params[:commit]\n if @submitval == \"Close\"\n @ticket_item.finished_on = Time.new\n elsif @submitval == \"Assign to me\"\n @ticket_item.assigned_on = Time.new\n end\n \n respond_to do |format|\n if @ticket_item.update(ticket_item_params)\n format.html { redirect_to @ticket_item, notice: 'Ticket item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @ticket_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @labticket.update(labticket_params)\n format.html { redirect_to @labticket, notice: 'Labticket was successfully updated.' }\n format.json { render :show, status: :ok, location: @labticket }\n else\n format.html { render :edit }\n format.json { render json: @labticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n if @ticket.update(ticket_params)\n\n @obj = {\n id: @ticket.id,\n title: @ticket.title,\n body: @ticket.body,\n statu_id: @ticket.statu_id,\n user_id: @ticket.user_id,\n active: @ticket.active,\n image: @ticket.image.attached? ? url_for(@ticket.image) : nil,\n media: @ticket.media.attached? ? url_for(@ticket.media) : nil\n }\n\n render json: @obj\n # 'ticket was successfully updated.'\n else\n render json: @ticket.errors, status: :unprocessable_entity\n end\n end",
"def status\n respond_to do |format|\n if @ticket.update(ticket_params)\n format.html { redirect_to @ticket, notice: 'Ticket was successfully created.' }\n format.json { render action: 'show', status: :created, location: @ticket }\n else\n format.html { render action: 'new' }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ticket.update(ticket_params)\n format.html { redirect_to @ticket, :notice => 'Ticket was successfully Updated.' }\n format.js do\n render :json => @ticket.to_json\n end\n else\n format.html { render :action => 'edit' }\n format.js { render :json => @ticket.errors, :status => :unprocessable_entity }\n end\n end\n\n end",
"def update\n respond_to do |format|\n if @ticketrez.update_attributes(params[:ticketrez])\n flash[:notice] = 'Ticketrez was successfully updated.'\n format.html { redirect_to(@ticketrez) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ticketrez.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ticket_detalle.update(ticket_detalle_params)\n format.html { redirect_to @ticket_detalle, notice: 'Ticket detalle was successfully updated.' }\n format.json { render :show, status: :ok, location: @ticket_detalle }\n else\n format.html { render :edit }\n format.json { render json: @ticket_detalle.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n errors = false\n respond_to do |format|\n if @seat.update(seat_params)\n @ticket = Ticket.find_by(seat: @seat)\n if @ticket.update(code: seat_params[:code], given_away: seat_params[:given_away], ticket_type_id: seat_params[:ticket_type])\n format.html { redirect_to admin_seat_path(@seat), notice: 'Seat was successfully updated.' }\n format.json { render :show, status: :ok, location: @seat }\n else\n errors = true\n end\n else\n errors = true\n end\n\n if errors\n format.html { render :edit }\n format.json { render json: @seat.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @ticket_file.update(ticket_file_params)\n format.html { redirect_to @ticket_file, notice: 'Ticket file was successfully updated.' }\n format.json { render :show, status: :ok, location: @ticket_file }\n else\n format.html { render :edit }\n format.json { render json: @ticket_file.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @ticket.update(ticket_params)\n params.permit!\n if params[:activate]\n @ticket.activated_on = Date.today\n else\n @ticket.activated_on = params[:activated_on]\n end\n if params[:type] == \"Časově omezená\"\n @ticket.entries_remaining = -1\n\n # pokud omezena vstupy -> activerecord nastaví sám od sebe do modelu (form_for)\n end\n if params[:time_restriction_months]\n @ticket.time_restriction = (params[:time_restriction_months].to_i.months).to_i\n respond_to do |format|\n if @ticket.save\n format.html { redirect_to tickets_path, notice: 'Permanentka upravena' }\n format.json { render :show, status: :created, location: @ticket }\n else\n format.html { render :new }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n else\n if !params[:time_restriction_months]\n @ticket.errors.add(:time_restriction_months, \"musí být kladné číslo\")\n end\n render :new\n end\n end",
"def update\n @task.update(task_params) ? respond_with(@task) : false\n end",
"def mark_close\n respond_to do |format|\n if @ticket.update({status: Ticket::STATUS[:closed]})\n format.html { redirect_to @ticket, notice: 'Ticket was successfully marked as close.' }\n format.json { render json: {status: :ok}, status: :ok }\n else\n format.html { render :edit }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def save_edited_ticket_entry\n @raw_date = params[:delivery_date]\n \n @day = @raw_date[3..4]\n @month = @raw_date[0..1]\n @year = @raw_date[6..9]\n \n @delivery_date = \"#{@year}-#{@month}-#{@day}\"\n \n @ticket = Ticket.find(params[:id])\n @ticket.number = params[:ticket_number]\n @ticket.delivery_date = @delivery_date\n @ticket.job_id = params[:job_id]\n @ticket.destination_id = params[:destination_id]\n @ticket.wood_type = params[:wood_type_id]\n \n #Because the tickets value (load pay) comes in as string in currency format\n # some parts have to be stripped off to be able to turn it into float correctly\n @value = params[:load_pay].to_s\n 3.times do\n @value.sub!(\",\", \"\")\n end\n @value = @value.to_f\n \n @ticket.value = @value\n \n @ticket.load_details.each_with_index do |i, x|\n i.species_id = params[:specieses][x]\n i.tonnage = params[:tonnages][x]\n i.mbfs = params[:mbfs][x]\n \n unless i.save\n render :status => 306, :nothing => true\n return\n end\n end\n \n unless @ticket.save\n render :status => 306, :nothing => true\n else\n render :status => 200, :nothing => true\n end\n end"
] | [
"0.7075008",
"0.69759566",
"0.6900604",
"0.6900604",
"0.6899547",
"0.68989575",
"0.6887619",
"0.6887619",
"0.6887619",
"0.6887619",
"0.6887619",
"0.68726313",
"0.686913",
"0.68513954",
"0.6850062",
"0.684869",
"0.684869",
"0.68477166",
"0.6843562",
"0.68401426",
"0.682231",
"0.6821798",
"0.6821798",
"0.6821798",
"0.6821798",
"0.6821798",
"0.6821798",
"0.6821798",
"0.6821798",
"0.6821798",
"0.6821798",
"0.6821798",
"0.6821798",
"0.6821798",
"0.6821798",
"0.6821798",
"0.6821798",
"0.6821798",
"0.6816757",
"0.680219",
"0.67900264",
"0.6786822",
"0.6770184",
"0.6750405",
"0.6750405",
"0.6750405",
"0.6729691",
"0.66372484",
"0.6624389",
"0.66199297",
"0.6582137",
"0.65652627",
"0.65363145",
"0.65307397",
"0.6490035",
"0.647547",
"0.64431477",
"0.642398",
"0.6386558",
"0.63652134",
"0.634779",
"0.6334547",
"0.6328563",
"0.6321194",
"0.6318529",
"0.63177586",
"0.6289711",
"0.62566656",
"0.62458116",
"0.6234225",
"0.62257475",
"0.62023526",
"0.61878365",
"0.61739975",
"0.61680204",
"0.6140548",
"0.61370385",
"0.61202115",
"0.60976785",
"0.6044268",
"0.6042678",
"0.604207",
"0.6030632",
"0.60076505",
"0.60069835",
"0.59715956",
"0.5959231",
"0.59468913",
"0.5941672",
"0.59373534",
"0.59238416",
"0.5918716",
"0.591662",
"0.59010917",
"0.5900701",
"0.5862427",
"0.5851445",
"0.5808311",
"0.5781525",
"0.5761683",
"0.5742691"
] | 0.0 | -1 |
Public: Creates a new Ticket based on passed attributes and persists it to Fogbugz attrs hash of Ticket attributes Returns a new Ticket | def create(attrs)
if attrs.has_key? :description
warn "Fogbugz Case does not handle description"
end
options = translate attrs,
:title => :sTitle,
:priority => :ixPriority,
:assignee => :ixPersonAssignedTo,
:project_id => :ixProject
new_case = api.command(:new, options)
options.merge!(:ixBug => new_case["case"]["ixBug"])
self.new options
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_ticket(params = {})\n Ticket.create(self, params)\n end",
"def create(params)\n ticket = Tessera::Otrs::Ticket.new(params[:ticket]).to_hash\n article = Tessera::Otrs::Article.new(params[:article]).to_hash\n attachment = if params[:attachment] && params[:attachment].is_a?(Hash)\n Tessera::Otrs::Attachment.new(params[:attachment]).to_hash\n elsif params[:attachment] && params[:attachment].is_a?(Array)\n params[:attachment].map do |a|\n Tessera::Otrs::Attachment.new(a).to_hash\n end\n end\n body = { Ticket: ticket }\n body = body.merge(Article: article)\n body = body.merge(Attachment: attachment) if attachment\n\n Tessera::Api::TicketCreate.call(body)\n end",
"def create_ticket(ticket)\n if ticket.priority.nil? or ticket.project_id.nil? or ticket.summary.nil?\n raise Unfuddled::Error.new(\"Must have Priority (1..5), Project ID and Summary\")\n end\n\n begin\n url = \"/api/v1/projects/#{ticket.project_id}/tickets.json\"\n id = send(:post , url, ticket.to_h)[:body][:id]\n \n # Add the ID with to ticket\n ticket.id = id\n\n # Attach the client to the ticket\n ticket.client = self\n \n ticket\n rescue Unfuddled::HTTPErrorResponse => error\n raise error\n end\n\n end",
"def create_ticket(opts)\n t = Ticket.create\n t.update_attribute(:event, Site::Config.event)\n t.update_attribute(:cost, Site::Config.event.cost)\n t.update_attribute(:punter, opts[:punter] || Punter.generate!)\n t.update_attribute(:order, opts[:order] || Order.generate!)\n t\nend",
"def create\n \n @ticket = Ticket.new(params[:ticket])\n @ticket.ticket_status_id = 1\n @ticket.requestor_id = current_user.id\n @ticket.account_id = current_user.company.account_id\n\n respond_to do |format|\n if @ticket.save\n format.html { redirect_to(@ticket, :notice => 'Ticket was successfully created.') }\n format.xml { render :xml => @ticket, :status => :created, :location => @ticket }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @ticket.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def CreateTicket params = {}\n\n APICall(path: 'tickets.json',method: 'POST',payload: {ticket: params}.to_json)\n \n end",
"def create(ticket)\n ticket.assign_available_locker_from(@lockers)\n add_ticket(ticket)\n end",
"def create\n @breadcrumb = 'create'\n @ticket = Ticket.new(params[:ticket])\n @ticket.created_by = current_user.id if !current_user.nil?\n @ticket.source_ip = request.remote_ip\n @ticket.hd_email = mail_to\n @ticket.office_id = from_office\n # Should use attachment from drag&drop?\n if @ticket.attachment.blank? && !$attachment.avatar.blank?\n @ticket.attachment = $attachment.avatar\n end\n\n respond_to do |format|\n if @ticket.save\n $attachment.destroy\n $attachment = nil\n format.html { redirect_to @ticket, notice: crud_notice('created', @ticket) }\n format.json { render json: @ticket, status: :created, location: @ticket }\n else\n $attachment.destroy\n $attachment = Attachment.new\n @offices = offices_dropdown\n @technicians = technicians_dropdown\n format.html { render action: \"new\" }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n obj = JSON[request.body.read]\n @ticket = Ticket.new()\n @ticket.description = obj[\"description\"]\n @ticket.address = obj[\"address\"]\n @ticket.status = obj[\"status\"]\n @ticket.priority = obj[\"priority\"]\n @ticket.category = obj[\"category\"]\n @ticket.private = obj[\"private\"]\n @ticket.lat = obj[\"lat\"].to_f\n @ticket.lon = obj[\"lon\"].to_f\n @ticket.image = obj[\"image\"]\n if @ticket.save\n @ticket.image = nil\n render json: @ticket.to_json()\n else\n render json: @ticket.errors\n end\n end",
"def create\n # user_id = params[\"user_id\"]\n user_id = @user.id\n store_id = params[\"store_id\"]\n \n @ticket = Ticket.new\n @ticket.user_id = user_id\n @ticket.store_id = store_id\n @ticket.cnt = get_new_ticket_number (store_id)\n\n respond_to do |format|\n if @ticket.save\n @newTicket = TicketsHelper::Ticket.new\n @newTicket.store_id = @ticket.store.id\n @newTicket.store_name = @ticket.store.name\n @newTicket.reg_time = @ticket.created_at\n @newTicket.wait_number = @ticket.cnt\n @newTicket.wait_ahead_count = get_current_user_wait_ahead_count(@ticket)\n \n format.html { redirect_to @ticket, notice: 'Ticket was successfully created.' }\n format.json { render :show}\n else\n format.html { render :new }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_ticket(params)\n ticket = Lighthouse::Ticket.new(:project_id => project_id)\n ticket.title = params[:title]\n ticket.body = params[:body]\n ticket.tags = params[:tags]\n ticket.save\n end",
"def create\n @ticket = Ticket.new(ticket_params)\n @ticket.ticket_status = 'Waiting for Staff Response'\n @ticket.ticket_interface = 'New unassigned tickets'\n @ticket.make_uniq_reference\n\n TicketConfirmingMailer.new_ticket_confirmation(@ticket).deliver\n\n respond_to do |format|\n if @ticket.save\n format.html { redirect_to @ticket, notice: 'Ticket was successfully created.' }\n format.json { render action: 'show', status: :created, location: @ticket }\n else\n format.html { render action: 'new' }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ticket = Ticket.new(params[:ticket])\n @ticket.previous_assignee_id = nil\n @ticket.updater_id = session[:user]\n \n respond_to do |format|\n if @ticket.save\n flash[:notice] = 'Ticket was successfully created.'\n format.html { redirect_to @coll_url }\n format.xml { head :created, :location => ticket_url(@ticket) }\n else\n @content_title = @title = @ticket.asset.nil? ? 'Editing new ticket' : \"Editing new ticket for #{a.title}\"\n @submit_value = 'Create'\n format.html { render :action => \"new\" }\n format.xml { render :xml => @ticket.errors.to_xml }\n end\n end\n end",
"def new\n @ticket = Ticket.new\n end",
"def new\n @ticket = Ticket.new\n end",
"def create\n @ticket = Ticket.new(ticket_params)\n @ticket.user = current_user if current_user\n\n respond_to do |format|\n if @ticket.save\n format.html { redirect_to @ticket, notice: 'Ticket was successfully created.' }\n format.json { render json: {id: @ticket.id, status: :created}, status: :created }\n else\n format.html { render :new }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def CreateNewTicket(userId)\n\t\tSetPreviousTicketsToNotCurrent(userId)\n\t\tnewTicket = Ticket.new(UserId: userId, IsCurrent: 1)\n\t\tnewTicket.save\n\t\tCreateNewTicketProperty(newTicket.id)\n\tend",
"def create\n @ticket = Ticket.new(ticket_params)\n @ticket.user = current_user\n respond_to do |format|\n if @ticket.save\n format.html { redirect_to edit_ticket_path(@ticket), notice: 'Ticket was successfully created.' }\n format.json { render :show, status: :created, location: @ticket }\n else\n format.html { render :new }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n ticket_params.inspect\n @ticket = Ticket.new(ticket_params)\n @ticket.user = nil\n @ticket.status = \"for_sale\"\n respond_to do |format|\n if @ticket.save\n format.html { redirect_to @ticket, notice: 'Ticket was successfully created.' }\n format.json { render :show, status: :created, location: @ticket }\n else\n format.html { render :new }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ticket = Ticket.new(params[:ticket])\n @ticket.from_email = current_user.email\n @ticket.user_id = current_user.id\n\n respond_to do |format|\n if @ticket.save\n zt = ZendeskTicket.new(@ticket.platform)\n zt.build(@ticket, request.base_url)\n zd_ticket = zt.create\n @ticket.zendesk_ticket_id = zd_ticket.id\n @ticket.save\n\n msg = 'Your ticket was successfully created'\n\n format.html { redirect_to @ticket, notice: msg}\n format.json { render json: @ticket, status: :created, location: @ticket }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ticket = Ticket.new(ticket_params)\n @ticket.user_id = current_user.id\n\n respond_to do |format|\n if @ticket.save\n format.html { redirect_to @ticket, notice: 'Ticket was successfully created.' }\n format.json { render :show, status: :created, location: @ticket }\n else\n format.html { render :new }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ticket = Ticket.new(params[:ticket])\n\n \n #Security check. You can only add a ticket for an event you also created!´\n \n respond_to do |format|\n if @ticket.save\n flash[:notice] = 'Ticket was successfully created.'\n format.html { redirect_to tickets_path() }\n format.xml { render :xml => @ticket, :status => :created, :location => @ticket }\n else\n flash[:notice_bad] = 'Please fill in all required fields.'\n format.html { render :action => \"new\" }\n format.xml { render :xml => @ticket.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n \n @ticket = Ticket.new(ticket_params)\n\n respond_to do |format|\n if @ticket.save\n format.html { redirect_to @ticket, notice: 'Ticket was successfully created.' }\n format.json { render :show, status: :created, location: @ticket }\n else\n format.html { render :new }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def build_ticket(subject:, requester_id:, group_id:, external_id: nil, body:, fields: {}, **extra_attributes)\n ZendeskAPI::Ticket.new(\n client,\n subject: subject,\n requester_id: requester_id,\n group_id: group_id,\n external_id: external_id,\n comment: { body: body },\n fields: [fields],\n **extra_attributes\n )\n end",
"def create\n @ticket = Ticket.new(ticket_params)\n @ticket.customer = current_user\n respond_to do |format|\n if @ticket.save\n format.html { redirect_to @ticket, notice: 'Ticket was successfully created.' }\n format.json { render :show, status: :created, location: @ticket }\n else\n format.html { render :new }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ticket = Ticket.new(ticket_params)\n respond_to do |format|\n if @ticket.save\n format.html { render json: @ticket.to_json }\n format.json { render :show, status: :created, location: @ticket }\n else\n format.html { render :new }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ticket = Ticket.new(ticket_params_create)\n\n respond_to do |format|\n if @ticket.save\n TicketMailer.send_ticket_status(@ticket).deliver_later\n format.html { redirect_to @ticket, notice: 'Ticket was successfully created.' }\n format.json { render :show, status: :created, location: @ticket }\n else\n format.html { render :new }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def ticket_params_create\n params.require(:ticket).permit(*PARAMS_CREATE)\n end",
"def create\n @ticket = Ticket.new(ticket_params)\n\n respond_to do |format|\n if @ticket.save\n format.html { redirect_to @ticket, notice: 'Ticket was successfully created.' }\n format.json { render :show, status: :created, location: @ticket }\n else\n format.html { render :new }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ticket = Ticket.new(ticket_params)\n\n respond_to do |format|\n if @ticket.save\n format.html { redirect_to @ticket, notice: 'Ticket was successfully created.' }\n format.json { render :show, status: :created, location: @ticket }\n else\n format.html { render :new }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ticket = Ticket.new(ticket_params)\n\n respond_to do |format|\n if @ticket.save\n format.html { redirect_to @ticket, notice: 'Ticket was successfully created.' }\n format.json { render :show, status: :created, location: @ticket }\n else\n format.html { render :new }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ticket = Ticket.new(ticket_params)\n\n respond_to do |format|\n if @ticket.save\n format.html { redirect_to @ticket, notice: 'Ticket was successfully created.' }\n format.json { render :show, status: :created, location: @ticket }\n else\n format.html { render :new }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ticket = Ticket.new(ticket_params)\n\n respond_to do |format|\n if @ticket.save\n format.html { redirect_to @ticket, notice: 'Ticket was successfully created.' }\n format.json { render :show, status: :created, location: @ticket }\n else\n format.html { render :new }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n puts \"llego\"\n @ticket = Ticket.new(ticket_params)\n if @ticket.save\n render_success_format('ticket created correctly', @ticket)\n end\n rescue Exception => e\n render_default_error e, 401\n e.inspect\n end",
"def create\n #@ticket = Ticket.new(ticket_params)\n @ticket = current_user.tickets.build(ticket_params)\n\n respond_to do |format|\n if @ticket.save\n format.html { redirect_to @ticket, notice: \"Your ticket has been submitted. We will get back to you ASAP\" }\n format.json { render :show, status: :created, location: @ticket }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ticket = Ticket.new(ticket_params)\n\n respond_to do |format|\n if @ticket.save\n format.html { redirect_to @ticket, notice: \"Ticket was successfully created.\" }\n format.json { render :show, status: :created, location: @ticket }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ticket = Ticket.new(params[:ticket])\n\n respond_to do |format|\n if @ticket.save\n format.html { redirect_to @ticket, notice: 'Ticket was successfully created.' }\n format.json { render json: @ticket, status: :created, location: @ticket }\n else\n format.html { render action: 'new' }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n event = Event.find(params[:event_id])\n batch_id = params[:batch_id] # for when an event has multiple types of tickets\n amount = params[:amount] # amount of tickets\n user_info = { anonymous: SecureRandom::hex } # instead of a random string this could have user info\n price = event.price * amount\n address = TicketAddresses.create_ticket_address(event.id, batch_id)\n\n ticket = Ticket.create!(\n event: event,\n batch_id: batch_id,\n amount: amount,\n price: price,\n user_info: user_info,\n address: address,\n status: :unconfirmed\n )\n\n render json: {\n address: address,\n salt: ticket.salt,\n price: event.price * amount,\n }\n end",
"def create\n @ticket = @current_user.tickets.build(ticket_params)\n respond_to do |format|\n if @ticket.save\n format.html { redirect_to @ticket, :notice => 'Ticket was successfully created.' }\n format.json { render :action => 'show', :status => :created, :location => @ticket }\n else\n format.html { render :action => 'new' }\n format.json { render :json => @ticket.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n\n @ticket = Ticket.new(params[:ticket])\n\n respond_to do |format|\n if @ticket.save\n format.html { redirect_to @ticket, notice: 'Ticket was successfully created.' }\n format.json { render json: @ticket, status: :created, location: @ticket }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create(attributes_hash)\n #the tap method allows preconfigured methods and values to\n #be associated with the instance during instantiation while also automatically returning\n #the object after its creation is concluded.\n self.new.tap do |card|\n attributes_hash.each do |key, value|\n #sending the new instance the key name as a setter with the value\n card.send(\"#{key}=\", value)\n #string interpolation is used as the method doesn't know the key name yet\n #but an = sign is implemented into the string in order to asssociate it as a setter\n end\n #saves the new instance into the database\n card.save\n end\n end",
"def create\n @ticket = Ticket.new(ticket_params)\n @ticket.single_use = false\n params.permit!\n if params[:activate]\n @ticket.activated_on = Date.today\n else\n @ticket.activated_on = params[:activated_on]\n end\n if params[:type] == \"Časově omezená\"\n @ticket.entries_remaining = -1\n\n # pokud omezena vstupy -> activerecord nastaví sám od sebe do modelu (form_for)\n end\n if params[:time_restriction_months]\n @ticket.time_restriction = (params[:time_restriction_months].to_i.months).to_i\n respond_to do |format|\n if @ticket.save\n format.html { redirect_to @ticket.user, notice: 'Permanentka vytvořena' }\n format.json { render :show, status: :created, location: @ticket }\n else\n format.html { render :new }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n else\n if !params[:time_restriction_months]\n @ticket.errors.add(:time_restriction_months, \"musí být kladné číslo\")\n end\n render :new\n end\n end",
"def ticket_params\n params.fetch(:ticket, {}).permit(ticket_attributes)\n end",
"def create\n @ticket = Ticket.new(params[:ticket])\n\n respond_to do |format|\n if @ticket.save\n format.html { redirect_to @ticket, notice: 'Ticket was successfully created.' }\n format.json { render json: @ticket, status: :created, location: @ticket }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ticket = Ticket.new(params[:ticket] )\n\n respond_to do |format|\n if @ticket.valid?\n\t\t\t\tif TicketLog.make_log(params[:log], @ticket, current_user)\n\t\t\t\t\[email protected]\n\t\t\t\t\tflash[:notice] = 'Ticket was successfully created.'\n\t\t\t\t\tformat.html { redirect_to(@ticket) }\n\t\t\t\t\tformat.xml { render :xml => @ticket, :status => :created, :location => @ticket }\n\t\t\t\telse\n\t\t\t\t\[email protected] :log, \"entry cannot be blank\"\n\t\t\t\t\tformat.html { render :action => \"new\" }\n\t\t\t\t\tformat.xml { render :xml => @ticket.errors, :status => :unprocessable_entity }\n\t\t\t\tend\n else\n\t\t\t\[email protected]\n format.html { render :action => \"new\" }\n format.xml { render :xml => @ticket.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n case params[:ticket][:type]\n when \"one-day\"\n @ticket = ParttimeTicket.new\n @ticket.day_count = 1\n when \"five-day\"\n @ticket = ParttimeTicket.new()\n @ticket.day_count = 5\n when \"twelve-day\"\n @ticket = ParttimeTicket.new()\n @ticket.day_count = 12\n when \"month\"\n @ticket = FulltimeTicket.new()\n end\n \n @ticket.creator_id = current_user.id;\n @ticket.user_id = current_user.id;\n \n respond_to do |format|\n if @ticket.save\n format.html { redirect_to(tickets_path, :notice => 'Ticket was successfully created.') }\n format.xml { render :xml => @ticket, :status => :created, :location => @ticket }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @ticket.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @ticket = Ticket.new(ticket_params)\n\n respond_to do |format|\n if @ticket.save\n format.html { redirect_to @ticket, notice: 'Ticket was successfully created.' }\n format.json { render action: 'show', status: :created, location: @ticket }\n else\n format.html { render action: 'new' }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ticket = Ticket.new(ticket_params)\n\n respond_to do |format|\n if @ticket.save\n format.html { redirect_to @ticket, notice: 'Ticket was successfully created.' }\n format.json { render action: 'show', status: :created, location: @ticket }\n else\n format.html { render action: 'new' }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ticket = @customer.tickets.create(ticket_params)\n\n respond_to do |format|\n if @ticket.save\n format.html { redirect_to edit_customer_path(@customer), notice: 'Ticket was successfully created.' }\n format.json { render :show, status: :created, location: @ticket }\n else\n format.html { render :new }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ticket = Ticket.new(ticket_params)\n @ticket.ticket_date = Time.now\n @ticket.user_id = current_user.id\n\n respond_to do |format|\n if @ticket.save\n update_warehouse\n format.html { \n flash[:notice] = 'La boleta se creó satisfactoriamente.'\n redirect_to tickets_path\n }\n format.json { render :show, status: :created, location: @ticket }\n else\n format.html { render :new }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ticket = Ticket.new(params[:ticket])\n # set user\n @ticket.creator = current_user\n if current_user.is? :admin\n @ticket.contact = User.find_by_name params[:user_name]\n else\n @ticket.contact = current_user\n end\n \n\n\n respond_to do |format|\n if @ticket.save\n format.html { redirect_to tickets_path, notice: 'Help ticket was successfully created.' }\n format.json { render json: @ticket, status: :created, location: @ticket }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create!(attributes)\n new(attributes).tap(&:save!)\n end",
"def create!(attributes)\n new(attributes).tap(&:save!)\n end",
"def create\n @ticket = Ticket.new(ticket_params)\np \"ticket_params: #{ticket_params}\"\n respond_to do |format|\n if @ticket.errors.size == 0 && @ticket.save\n format.html { redirect_to @ticket, notice: 'Ticket was successfully created.' }\n format.json { render :show, status: :created, location: @ticket }\n else\n format.html { render :new }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ticket = Ticket.new(params[:ticket])\n @ticket.project = @project\n @ticket.owner = current_user\n respond_to do |format|\n if @ticket.save\n TicketMailer.ticket_created(@ticket).deliver \n format.html { redirect_to([@project, @ticket], :notice => 'Ticket was successfully created.') }\n format.xml { render :xml => @ticket, :status => :created, :location => @ticket }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @ticket.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n\n @ticket = current_user.tickets.build(ticket_params)\n @ticket.status = current_user.new_ticket_status\n\n return render action: 'new' unless @ticket.valid?\n\n notice = %{You've been placed on the waiting list for your ticket.\n We will contact you via email with the result of your ticket application.}\n if @ticket.reserved?\n @ticket.charges.build([{amount: @ticket.ticket_type.price, description: @ticket.ticket_type.name},\n {amount: @ticket.donation, description: 'Ticket donation'}])\n notice = 'Ticket successfully ordered. Please consult the Charges section.'\n end\n\n if @ticket.save\n if @ticket.reserved?\n UserMailer.reserved_ticket(current_user, @ticket).deliver_later\n elsif @ticket.waiting_list?\n UserMailer.waiting_list_ticket(current_user, @ticket).deliver_later\n end\n redirect_to authenticated_root_url, notice: notice\n else\n render action: 'new'\n end\n end",
"def create\n @ticket = current_user.tickets.new(ticket_params)\n\n if @ticket.save\n redirect_to @ticket, notice: 'Ticket was successfully created.'\n else\n render :new\n end\n end",
"def create\n @ticket = Ticket.new(params[:ticket])\n\n respond_to do |format|\n if @ticket.save\n flash[:notice] = 'Ticket was successfully created.'\n format.html { redirect_to(@ticket) }\n format.xml { render :xml => @ticket, :status => :created, :location => @ticket }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @ticket.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def ticket_params\n # params[:ticket]\n params.require(:ticket).permit(:name, :second_name, :donation, :ticket_type_id, :first_guest_date_of_birth, :second_guest_date_of_birth)\n end",
"def create\n @ticket = Ticket.new(params[:ticket])\n @ticket.created_id = session[:staff_id]\n\n if @ticket.save\n flash[:notice] = 'Ticket was successfully created.'\n else\n flash[:notice] = 'Failed to created new ticket.' \n end\n \n redirect_to :action => \"edit\", :id => @ticket \n end",
"def create\n @ticket = Ticket.new(ticket_params)\n @ticket.submitted_by = current_user\n if @ticket.save\n redirect_to ticket_dashboard_path(@ticket), notice: \"Ticket was successfully created.\"\n else\n flash[:alert] = \"Ticket could not be created.\"\n redirect_to project_dashboard_path(params[:ticket][:project_id])\n end\n end",
"def create\n @ticket = Ticket.new(ticket_params)\n set_default_data\n respond_to do |format|\n if @ticket.save\n Account::Tickets::TicketLogs.create(@ticket)\n format.html { redirect_to account_tickets_path, notice: 'Ticket was successfully created.' }\n format.json { render :show, status: :created, location: @ticket }\n else\n format.html { render :new }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_ticket(creditcard, options={})\n post = {}\n\n add_order_id(post, options)\n add_creditcard(post, creditcard, options)\n add_currency(post, options)\n add_customer_data(post, options)\n add_test(post)\n commit(:createticket, post)\n end",
"def ticket_params\n params.require(:ticket).permit(:name, :seat_id_seq, :address, :price, :email_address, :event_id)\n end",
"def add pid, title, description, cid, tracker\n\t\[email protected] Hash[\n\t\t\t'pid' => pid, \n\t\t\t'title' => title, \n\t\t\t'description' => description,\n\t\t\t'creator' => cid, \n\t\t\t'tracker' => tracker,\n\t\t\t'status' => 'new',\n\t\t\t'assigned' => '-1']\n\tend",
"def create_record attributes\n creator = @creator_class.new attributes, @context\n FactoryGirl.create @clazz.name.underscore.to_sym, creator.factorygirl_attributes\n end",
"def initialize( ticket, comment, original_n, user = nil )\n\t\t\t@created = DateTime.now()\n\t\t\t@ticket = ticket\n\t\t\t@comment = comment\n\t\t\t@created_by = user == nil ? Etc.getlogin() : user\n\t\t\tself.original_name = original_n\n\t\tend",
"def create\n @ticket = Ticket.new(params[:ticket])\n\n respond_to do |format|\n if @ticket.save\n format.html { redirect_to(@ticket, :notice => 'Bilet został pomyślnie utworzony.') }\n format.xml { render :xml => @ticket, :status => :created, :location => @ticket }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @ticket.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @ticket = Ticket.new(params[:ticket])\n \n respond_to do |format|\n if @ticket.save\n format.html { redirect_to ticket_path( @ticket ), notice: '感謝您參與本次活動,我們將於 10 個工作日回覆您!' }\n format.json { render json: @ticket, status: :created, location: @ticket }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if !check_session #Validate if the user session is active\n return #If not force return to trigger the redirect of the check_session function\n end\n @ticket = Ticket.new(ticket_params) #Create a new ticket object with the parameters set by the user in the create form\n resp = @ticket.save(session[:user]) #Save the new Ticket object\n if resp[0] #Validate if the response was successfull\n flash[:success] = t(:ticket_creation_success_flash, ticket: @ticket.name) #Set the success message for the user\n redirect_to tickets_path(:election_id =>@ticket.election_id) #Redirect the user to the tickets list page\n elsif validate_authorized_access(resp[1]) #If the response was unsucessful, validate if it was caused by unauthorized access to the app or expired session\n if(resp[1].kind_of?(Array)) #If the response was unsucessful, validate if it was caused by an invalid Ticket object sent to the model. If so the server would have returned an array with the errors\n flash[:warning] = Util.format_validation_errors(resp[1]) #Set the invalid object message for the user\n end\n flash[:danger] = t(:ticket_creation_error_flash) #Set the error message for the user\n @ticket = Ticket.new #Reset the Ticket object to an empty one\n redirect_to new_ticket_path #Redirect the user to the Ticket creation page\n else\n return #If not force return to trigger the redirect of the check_session function\n end\n rescue #Error Handilng code\n general_error_redirection('Controller: '+params[:controller]+'.'+action_name,$!)\n end",
"def create!(attributes = {})\n _create(false, attributes)\n end",
"def add_ticket(ticket)\n @reservations[ticket.confirmation_number] = ticket\n end",
"def create\n @ticket = Ticket.new(ticket_params)\n\n if @ticket.save\n @obj = {\n id: @ticket.id,\n title: @ticket.title,\n body: @ticket.body,\n statu_id: @ticket.statu_id,\n user_id: @ticket.user_id,\n active: @ticket.active,\n image: @ticket.image.attached? ? url_for(@ticket.image) : nil,\n media: @ticket.image.attached? ? url_for(@ticket.image) : nil\n }\n render json: @obj, status: :created, location: @obj\n # 'ticket was successfully created.'\n else\n render json: @ticket.errors, status: :unprocessable_entity\n end\n end",
"def create(attribs={})\n obj = new\n obj.send :create, attribs\n obj\n end",
"def create\n @ticket_item = TicketItem.new\n# @post.number = params[:post][:number].gsub(/,/,'.').to_f # => 12.13\n \n @ticket_item.created_on = Time.new\n @ticket_item.user = current_user\n @ticket_item.user_id = current_user.id\n \n #@ticket_item = TicketItem.new(ticket_item)\n\n# @ticket_item = TicketItem.new(ticket_item_params)\n\n\n respond_to do |format|\n if @ticket_item.save\n flash[:id] = \"Created ticket with id:\" + @ticket_item.id.to_s\n format.html { redirect_to @ticket_item, notice: 'Ticket item was successfully created.' }\n format.json { render action: 'show', status: :created, location: @ticket_item }\n format.xml { render xml: @ticket_item }\n else\n format.html { render action: 'new' }\n format.json { render json: @ticket_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n @task = Task.find(params[:task_id]) if params[:task_id]\n @task ||= Task.new\n @tasks = @ticket.tasks\n @note = Note.find(params[:note_id]) if params[:note_id]\n @note ||= Note.new\n @notes = @ticket.notes \n end",
"def create(attributes)\n new(attributes).tap(&:save)\n end",
"def create(attributes)\n new(attributes).tap(&:save)\n end",
"def create\n \n if @diagnostic.nil?\n @ticket = Ticket.new(ticket_params)\n #@expected_date = @ticket.due_date + 3.days\n \n else\n \n @diagnostic = @ticket.diagnostics.build(diagnostic_params)\n @ticket = Ticket.new(ticket_params)\n @ticket = @client.tickets.build(ticket_params)\n @ticket = @computer.tickets.build(ticket_params)\n \nend\n\n respond_to do |format|\n if @ticket.save\n \n format.html { redirect_to @ticket, notice: 'Ticket was successfully created.' }\n format.json { render :show, status: :created, location: @ticket }\n else\n format.html { render :new }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def CreateField params = {}\n \n APICall(path: 'ticket_fields.json',method: 'POST',payload: params.to_json)\n \n end",
"def create_ticket(area_id)\n # TODO Watch out for race conditions here\n area = Area.find(area_id)\n if area.ticketable?\n ticket = self.tickets.create(:area => area)\n # Renew order expiration as new tickets are added\n set_expires_at!\n return true\n else\n return false\n end\n end",
"def initialize(params)\n @ticket_id = params['TicketID']\n @lock_id = params['LockID']\n @real_till_time_not_used = params['RealTillTimeNotUsed']\n @changed = params['Changed']\n @customer_user_id = params['CustomerUserID']\n @queue_id = params['QueueID']\n @escalation_solution_time = params['EscalationSolutionTime']\n @owner_id = params['OwnerID']\n @unlock_timeout = params['UnlockTimeout']\n @priority_id = params['PriorityID']\n @escalation_time = params['EscalationTime']\n @type = params['Type']\n @queue = params['Queue']\n @escalation_response_time = params['EscalationResponseTime']\n @escalation_update_time = params['EscalationUpdateTime']\n @customer_id = params['CustomerID']\n @age = params['Age']\n @until_time = params['UntilTime']\n @responsible = params['Responsible']\n @lock = params['Lock']\n @priority = params['Priority']\n @state_id = params['StateID']\n @created_by = params['CreateBy']\n @state = params['State']\n @type_id = params['TypeID']\n @ticket_number = params['TicketNumber']\n @group_id = params['GroupID']\n @created = params['Created']\n @service_id = params['ServiceID']\n @owner = params['Owner']\n @slaid = params['SLAID']\n @state_type = params['StateType']\n @title = params['Title']\n @responsible_id = params['ResponsibleID']\n @create_tim_nix = params['CreateTimeUnix']\n @changed_by = params['ChnageBy']\n @archive_flag = params['ArchiveFlag']\n end",
"def create\n @ticket = Ticket.find(params[:ticket_action][:ticket_id])\n# logger.debug(@ticket.to_yaml)\n @ticket_action = @ticket.ticket_actions.build(params[:ticket_action])\n\n respond_to do |format|\n if @ticket_action.save\n flash[:notice] = 'TicketAction was successfully created.'\n format.html { redirect_to(@ticket_action) }\n format.xml { render :xml => @ticket_action, :status => :created, :location => @ticket_action }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @ticket_action.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def createNewTicket(description=0, requesterid=0)\n\n # make a default description if none is provided\n if description == 0\n description = \"Default description in a test at \" + Time.new.to_s()\n end\n\n #Post the request to the server\n resp = @@conn.post do |req|\n req.url '/tickets.xml'\n req.headers['Authorization'] = 'Basic aHIuc2VsbGVydEBnbWFpbC5jb206c2VzMTEy' #@TODO make this a class param\n req.headers['Content-Type'] = 'application/xml'\n req.body = \"<ticket><description>\"+ description.to_s() +\"</description><requester_id>\"+ requesterid.to_s() +\"</requester_id></ticket>\"\n end\n\n #Formating the return\n returnXML = resp['location'].to_s()\n returnXML.slice! \"http://sellert.zendesk.com/api/v1\"\n\n return returnXML\n end",
"def ticket_params\n params.require(:ticket).permit(:name, :email, :feedback, :company,\n :attend_dinner, :attend_speakers_dinner, :dietary_info, :ticket_type_id, :reference)\n end",
"def ticket_params\n params.require(:ticket).permit(:name, :email, :feedback, :company,\n :attend_dinner, :attend_speakers_dinner, :dietary_info, :ticket_type_id, :reference)\n end",
"def create(attrs = {})\n instance = self.new(attrs)\n instance.save\n instance\n end",
"def ticket_params\n params.require(:ticket).permit(:user_id, :client, :ticket_date, :ticket_number, :delivery_date, :delivery_method_id, :payment_method_id,:delivery_hour_id, :delivery_cost, :discount_coupon, :ammount, :delivery_address_line1, :delivery_address_line2,\n ticket_details_attributes: [:id, :ticket_id, :product_id, :quantity, :unit_price, :subtotal, :_destroy])\n end",
"def create\n @ticket = OTRS::Ticket.new(params[:ticket])\n\n respond_to do |wants|\n if @ticket.save\n flash[:notice] = 'Ticket was successfully created.'\n wants.html { redirect_to(@ticket) }\n wants.xml { render :xml => @ticket, :status => :created, :location => @ticket }\n wants.json { render :json => @ticket, :status => :created, :location => @ticket }\n else\n wants.html { render :action => \"new\" }\n wants.xml { render :xml => @ticket.errors, :status => :unprocessable_entity }\n wants.json { render :json => @ticket.errors.full_messages, :status => :unprocessable_entity }\n end\n end\n end",
"def create!(attributes)\n build(attributes).save!\n end",
"def initialize(ticket_id = nil)\n if ticket_id\n @ticket = Effective::QbTicket.find_by_id(ticket_id)\n else\n @ticket = Effective::QbTicket.create\n end\n end",
"def create\n @user = current_user\n @ticket = Ticket.new(ticket_params)\n \n if params.has_key?(\"products\")\n #add the products\n @ticket.products.new(params[:products])\n end\n \n if params.has_key?(\"assignee_id\")\n @ticket.user_id = params[:assignee_id][:id]\n end\n \n @ticket.reporter_id = @user.id\n\n if params.has_key?(\"department_id\")\n theDepartment = Department.find(params[:department_id])\n @ticket.department = theDepartment\n end\n\n @ticket.status = 'new'\n\n respond_to do |format|\n if @ticket.save\n format.html { redirect_to @ticket, notice: 'Ticket was successfully created.' }\n format.json { render action: 'show', status: :created, location: @ticket }\n else\n format.html { render action: 'new' }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_ticket params\n [:project, :summary].each do |param|\n raise(ArgumentError, \"#{param} required\") unless params[param]\n end\n\n issue = Jira4R::V2::RemoteIssue.new\n issue.project = params[:project]\n issue.summary = params[:summary]\n issue.description = params[:description]\n issue.assignee = params[:assignee] || @username\n issue.components = params[:components]\n issue.type = '1' #FIXME: wtf is this for?\n issue.priority = '5'\n issue = @ctx.createIssue issue\n ticket issue.key\n end",
"def create\n @ticket = Ticket.new(ticket_params)\n\n respond_to do |format|\n if @ticket.save\n format.html { redirect_to \"/pages/user_dashboard\", notice: 'Ticket was successfully created.' }\n format.json { render :show, status: :created, location: @ticket }\n else\n format.html { render :new }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_with(attrs = {})\n tap do\n @create_attrs ||= {}\n @create_attrs.update(attrs)\n end\n end",
"def create\n @ticket = Ticket.new(ticket_params)\n respond_to do |format|\n if @ticket.save\n if @ticket.table_id\n Table.find(@ticket.table_id).update(status: Table.statuses[:occupied])\n end\n if @ticket.customer_id\n Customer.find(@ticket.customer_id).update(status: Customer.statuses[:occupied])\n end\n format.html { redirect_to @ticket, notice: 'Ticket was successfully created.' }\n format.json { render :show, status: :created, location: @ticket }\n else\n format.html { render :new }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ticket = Ticket.new(params[:ticket])\n if params[:ticket][:user]\n @ticket.user = current_user\n end\n @ticket.url = request.original_url\n respond_to do |format|\n if @ticket.save\n flash[:notice] = \"The ticket was successfully created\"\n format.html { redirect_to root_path, notice: 'Ticket was successfully created, our team will now take a look at it.' }\n else\n flash[:error] = \"An error occurred\"\n format.html { render action: \"customer\" }\n end\n end\n end",
"def ticket_params\n params.require(:ticket).permit(:title, :description, :owner_id)\n end",
"def create!(attributes = {})\n object = klass.new(attributes)\n object.save!\n object\n end",
"def buy_ticket(event)\n Ticket.new(event, self)\n end"
] | [
"0.7747452",
"0.6945511",
"0.6942958",
"0.69121987",
"0.67621434",
"0.67238426",
"0.66958165",
"0.6636592",
"0.65551955",
"0.6541369",
"0.6526149",
"0.6513416",
"0.64901674",
"0.6467038",
"0.6467038",
"0.6433461",
"0.63950604",
"0.63902",
"0.6387986",
"0.63662726",
"0.63573885",
"0.63554156",
"0.6334386",
"0.63222975",
"0.6298234",
"0.6285697",
"0.6284149",
"0.6256532",
"0.62357605",
"0.62351984",
"0.62351984",
"0.62351984",
"0.62351984",
"0.6222419",
"0.6210465",
"0.62051576",
"0.6204346",
"0.61997825",
"0.619082",
"0.61773294",
"0.61701995",
"0.61533487",
"0.6148842",
"0.61474687",
"0.61220217",
"0.61119294",
"0.6111827",
"0.6111827",
"0.6092573",
"0.608153",
"0.60815126",
"0.60539556",
"0.60539556",
"0.6041558",
"0.60371816",
"0.6036482",
"0.6033696",
"0.60282326",
"0.6026346",
"0.60147524",
"0.60127974",
"0.59962046",
"0.5982559",
"0.59816676",
"0.5970331",
"0.5956032",
"0.59371424",
"0.5934938",
"0.59287554",
"0.59233654",
"0.5923193",
"0.59213275",
"0.59122217",
"0.59101486",
"0.5909963",
"0.5908808",
"0.5906395",
"0.5906395",
"0.59053224",
"0.5897968",
"0.58877236",
"0.58809084",
"0.58752364",
"0.5869368",
"0.586563",
"0.586563",
"0.58631146",
"0.5860367",
"0.5858548",
"0.58557117",
"0.58449066",
"0.5834708",
"0.5827694",
"0.5823091",
"0.5811293",
"0.580369",
"0.5791617",
"0.57862616",
"0.57708156",
"0.5767904"
] | 0.59570676 | 65 |
Public: Finds Tickets based on a hash of attributes project_id ID of the project the tickets belong to attributes hash of Ticket attributes to use when searching Returns an array of matching Tickets | def find_by_attributes(project_id, attributes = {})
search_by_attribute(self.find_all(project_id), attributes)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tickets\n Ticket.find_all_by_project_id_and_milestone_id(project_id, id)\n end",
"def tickets_for_project(project_id)\n tickets = send(:get , \"/api/v1/projects/#{project_id}/tickets.json\")\n\n process_list_response( tickets , Unfuddled::Ticket )\n end",
"def find_tickets(*ids)\n ids.map do |id|\n project.tickets(id).first\n end.compact\n end",
"def where(params)\n result = Tessera::Api::TicketSearch.call(params)\n ticket_ids = result['TicketID'] ? result['TicketID'] : []\n new(ticket_ids)\n end",
"def tickets\n Ticket.find(:all, :params => { :q => \"milestone:\\\"#{title}\\\" state:open sort:priority\" })\n end",
"def find_all(project_id)\n query = \"project:=#{project_id}\"\n cols = %w(dtLastUpdated ixBug sStatus sTitle sLatestTextSummary\n ixProject sProject sPersonAssignedTo sPriority).join(',')\n api.command(:search, :q => query, :cols => cols).collect do |ticket|\n self.new ticket[1][\"case\"]\n end.flatten\n end",
"def tickets()\n sql = \"SELECT * FROM tickets where customer_id = $1\"\n values = [@id]\n ticket_data = SqlRunner.run(sql, values)\n return ticket_data.map{|ticket| Ticket.new(ticket)}\n end",
"def search_tickets(term, value)\n results = @tickets_indice.search(term: term, value: value)\n if perform_search_by_id?(term)\n results.each do |ticket|\n # Get related organizations\n ticket['organizations'] =\n @organizations_indice.search_by_primary_key(value: ticket['organization_id'])\n\n # Get related users who are submitters\n ticket['submitters'] =\n @users_indice.search_by_primary_key(value: ticket['submitter_id'])\n\n # Get related users who are assignees\n ticket['assignees'] =\n @users_indice.search_by_primary_key(value: ticket['assignee_id'])\n end\n end\n results\n end",
"def ticket_search(query, page = 1)\n Ticket.search(self, query, page)\n end",
"def tickets\n sql = \"\n SELECT * FROM tickets\n WHERE customer_id = $1\n \"\n values = [@id]\n result = SqlRunner.run(sql, values)\n return nil if result.count == 0\n return result.map {|ticket| Ticket.new(ticket)}\n end",
"def index\n @project = Project.find(params[:project_id])\n @ticket = @project.tickets.new\n\n @tags = Ticket.tag_counts_on(:tags)\n\n if params[:tags]\n @tickets = {}\n @tickets[:both] = [params[:tags].gsub(', ', ',').split(',').map(&:capitalize).join(', '), @project.tickets.tagged_with(params[:tags])]\n @tickets[:other] = params[:tags].gsub(', ', ',').split(',').map do |tag|\n [tag.capitalize, (@project.tickets.tagged_with(tag) - @tickets[:both][1])]\n end\n else\n @tickets = @project.tickets\n end\n end",
"def tickets\n sql = \"SELECT * FROM tickets\"\n values = []\n tickets = SqlRunner.run(sql, values)\n result = tickets.map { |ticket| Ticket.new( ticket ) }\n return result\n end",
"def GetTickets params = {}\n\n params = params.merge(path: 'tickets.json')\n APICall(params)\n\n end",
"def find_tickets(*ids)\n ids.map do |id|\n tickets(id).first\n end.compact\n end",
"def tickets\n records do |instance|\n instance['tickets'] = ticket.where('organization_id': instance['_id'])\n end\n end",
"def find_tickets(res)\n if res.key?(\"tickets\")\n tickets_info = res[\"tickets\"]\n @tickets = []\n tickets_info.each do |ticket_info|\n ticket = Ticket.new(ticket_info) \n @tickets << ticket\n end\n @tickets\n elsif res.key?(\"error\")\n raise res[\"error\"]\n else\n raise \"unknown error from API\"\n end\n end",
"def tickets()\n sql = \"SELECT * FROM tickets\n WHERE customer_id = $1\"\n values = [@id]\n tickets = SqlRunner.run(sql, values)\n return tickets.map{|ticket|Ticket.new(ticket)}\nend",
"def tickets(*options)\n options.insert 0, id\n easy_finder(provider_parent(self.class)::Ticket, :all, options, 1)\n end",
"def get_ticket_ids\n @tickets = Ticket.all.map(&:id)\n end",
"def tickets\n Ticket.all.select do |ticket|\n ticket.event == self\n end\n end",
"def find(ticket)\n\t\t\tself.result.select{ |p| p['Ticket_Number'] == ticket }.first\n\t\tend",
"def index\n @sprint = params[:sprint].presence || Sprint.current!\n @tickets = Ticket.for_sprint(@sprint).by_created_at_desc\n @tickets = @tickets.for_project(params[:project]) if params[:project].present?\n @tickets = @tickets.for_user(params[:user]) if params[:user].present?\n @tickets = @tickets.search_name(params[:description]) if params[:description].present?\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tickets }\n end\n end",
"def filtered_tickets(filter=nil)\n filter ||= default_ticket_filter\n query_filter = {}\n case filter\n when 'open'\n query_filter = {status: 'open'}\n when 'closed'\n query_filter = {status: 'closed'}\n when 'all'\n query_filter = {status: ['open', 'closed']}\n end\n query_criteria = query_filter.merge(additional_ticket_query_filter)\n results = Ticket.where(query_criteria)\n [results, filter]\n end",
"def my_tickets\n if user_type_id == 1\n Ticket.where(issuer_user_id: id)\n else\n Ticket.where(assigned_to_id: id)\n end\n end",
"def all_ticket_entries\n @ac = ApplicationController.new\n @tickets = Ticket.find(:all, :order => \"created_at\")[0..5000].reverse!\n @species = Specie.all\n @woodtypes = WoodType.all\n end",
"def tickets\n where(:_type => TicketCategory.name)\n end",
"def ticket_type_tickets ticket_type_id\n if self.ticket_types.where(id: ticket_type_id).size.zero?\n raise_error(\"Given ticket type not found on transaction\")\n end\n\n self.tickets.where(ticket_type_id: ticket_type_id)\n end",
"def tickets\n subtree_map(Ticket, :tickets)\n end",
"def tickets(filters = {})\n tickets = send(:get , '/api/v1/ticket_reports/dynamic.json', filters)\n\n tickets = tickets[:body][\"groups\"].first[\"tickets\"]\n\n process_list_response( tickets , Unfuddled::Ticket)\n end",
"def ticket(q)\n Ticket.find(self, q)\n end",
"def my_tickets\n user = current_user.id if !current_user.nil?\n # OCO\n init_oco if !session[:organization]\n\n @search = Ticket.search do\n fulltext params[:search]\n if session[:organization] != '0'\n with :organization_id, session[:organization]\n end\n if !user.blank?\n with :created_by, user\n end\n with(:ticket_status_id).less_than(4)\n order_by :id, :desc\n paginate :page => params[:page] || 1, :per_page => per_page\n end\n\n @tickets = @search.results\n\n respond_to do |format|\n format.html # my_tickets.html.erb\n format.json { render json: @tickets }\n end\n end",
"def index\n \n @tickets = Ticket.all\n @tickets = @tickets.order(:updated_at)\n @tickets = @tickets.joins(:payment).where(\"payments.id = ?\",params[:clave]) unless params[:clave]==\"\" or params[:clave].nil?\n \n @payment = Payment.find(params[:clave])\n end",
"def index\n page = params[:page] || 1\n page = page.to_i unless page == 1\n @lh_project = Project.find_by_lighthouse_project(current_user, params[:project_id])\n db_project = current_user.projects.find_by_lighthouse_id(@lh_project.id)\n @bin = @lh_project.bins.find {|bin| bin.id.to_s == params[:bin_id].to_s}\n if @bin\n @search_query = @bin.query\n @lh_tickets = Ticket.search(db_project, @bin.query, page)\n else\n @search_query = session[:ticket_search]\n @lh_tickets = Ticket.search(db_project, @search_query) if @search_query\n end\n if @lh_tickets.blank? && !request.xhr?\n flash[:error] = \"No tickets found for '#{h @search_query}'\"\n redirect_to :controller => 'projects', :action => 'index'\n else\n if @search_query.include?('sort:number') || !@search_query.include?('sort:')\n @lh_tickets.sort! {|x, y| x.number <=> y.number}\n end\n prep_bucket_form\n session[:bin_id] = params[:bin_id]\n if request.xhr?\n session[:tickets] += @lh_tickets.collect(&:number)\n else\n session[:tickets] = @lh_tickets.collect(&:number)\n session[:ticket_index] = 0\n end\n session[:ticket_search] = @search_query\n end\n if @bin\n @ticket_count = @bin.tickets_count\n else\n @ticket_count = @lh_tickets.length\n end\n if page != 1 && request.xhr?\n @page = page\n render :partial => 'later_ticket_pages', :locals => { :tickets => @lh_tickets, :project => @lh_project }\n end\n end",
"def search(options)\n tm = TicketMaster.new(options[:provider], options[:authentication])\n projects = tm.projects(options[:project_attributes])\n puts \"Found #{projects.length} projects\"\n projects.each_with_index do |project, index|\n puts \"#{index+1}) Project #{project.name} (#{project.id})\"\n #read_project project\n #puts\n end\n exit\nend",
"def tickets_bought()\n sql = \"SELECT * FROM tickets WHERE customer_id = $1;\"\n values = [@id]\n ticket_hash = SqlRunner.run(sql, values)\n result = Ticket.map_tickets(ticket_hash)\n end",
"def scoped_tickets\n return @sprint.assigned_tickets if @sprint\n return @project.tickets if @project\n end",
"def getUserTicketsByType\n @conditions = {user_id: params[:id], ticket_type: params[:ticket_type]}\n @tickets = Ticket.find(:all, :conditions => @conditions)\n\n # Handle empty results\n if @tickets.empty?\n raise(ActiveRecord::RecordNotFound)\n end\n\n render json: @tickets\n end",
"def index\n @tickets = Ticket.where(user: current_user)\n end",
"def ticket_params\n params.require(:ticket).permit(:code, :host_id, raw_log_ids: [])\n end",
"def get_logger_tickets\n @tickets = Ticket.find_all_by_job_id_and_paid_to_logger(params[:id], false, :order => \"number\")\n render \"get_tickets.html.erb\"\n end",
"def extract_jira_tickets(projects: CCL_PROJECTS, from:)\n minmax_string = projects.map{|x|x.size}.minmax.join(',')\n project_string = projects.join + projects.join.downcase\n project_string = project_string.scan(/\\w/).uniq.sort.join\n regex_string = \"([#{project_string}]{#{minmax_string}}-\" + '\\d+)'\n jira_re = Regexp.new(regex_string)\n jira_tickets = from.join(' ').scan(jira_re).flatten.map{|t|t.upcase}.sort.uniq\n return jira_tickets\nend",
"def get_trucker_tickets\n @tickets = Ticket.find_all_by_job_id_and_paid_to_trucker(params[:id], false, :order => \"number\")\n render \"get_tickets.html.erb\"\n end",
"def index\n\n @clients = Ticket.joins(:clients).where(client_id: params[:id])\n # @tickets = Ticket.joins(:computers).where(client_id: params[:id])\n @tickets = Ticket.all.order(:due_date).limit(10).offset(0).page params[:page]\n if params[:search]\n @tickets = Ticket.search(params[:search]).order(\"created_at DESC\").page params[:page]\n else\n @tickets = Ticket.all.order(:due_date).limit(10).offset(0).page params[:page]\n @tickets = Ticket.all.order(:due_date).limit(10).offset(0).page params[:page]\n end\n \n #@client = Ticket.joins(:clients).where(@ticket => client.full_name)\n @open_tickets = Ticket.where.not(\"status_id = 8\").count\n #@computers = @ticket.computer.id\n @new_tickets = Ticket.where(\"status_id = 4\").limit(10).offset(0).page params[:page]\n @diagnostic_tickets = Ticket.where(\"status_id = 9\").page params[:page] \n @parts_tickets = Ticket.where(\"status_id = 6\").page params[:page]\n @waiting_tickets = Ticket.where(\"status_id = 7\").page params[:page]\n @in_progress_tickets = Ticket.where(\"status_id = 5\").page params[:page]\n @completed_tickets = Ticket.where(\"status_id = 8\").limit(10).offset(0).page params[:page]\n @expected_date = Date.today + (@open_tickets / 5) + 3.days\n #@expected_date = Ticket.due_date.created_at + 3.days\n end",
"def all_tickets()\n sql = \"SELECT customers.name, films.title, tickets.id\n FROM tickets\n INNER JOIN customers\n ON tickets.customer_id = customers.id\n INNER JOIN screenings\n ON tickets.screening_id = screenings.id\n INNER JOIN films\n ON screenings.film_id = films.id\n WHERE customers.id = $1\"\n values = [@id]\n result = Sqlrunner.run(sql, values)\n return result.each {|info| p info}\n end",
"def show\n @ticket = @project.tickets.find_by_scoped_id!(params[:id])\n @ticket_comment = @ticket.ticket_comments.new\n @ticket_comment.status_to = @ticket.status\n @ticket_comment.responsible_id_to = @ticket.responsible_id\n @ticket_comment.priority_to = @ticket.priority\n @assets = @project.assets.where(:attachable_type=>[Ticket.to_s, TicketComment.to_s]).where(:attachable_id=>([@ticket.id]|@ticket.ticket_comments.all.map{|tc|tc.id})).order('updated_at desc').all\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ticket }\n end\n end",
"def find_all_issues\n version_id_sql = \"project_id =\\\"#{@project.id}\\\" \" + \\\n \"AND name = \\\"#{@version}\\\"\"\n # obtaining the unique ID from the chosen project version\n version = Version.all(conditions: [version_id_sql]).at(0).id.to_s \\\n if Version.all(conditions: [version_id_sql]) != []\n issues_sql = \"project_id = \\\"#{@project.id}\\\" \" + \\\n \"AND fixed_version_id = \\\"#{version}\\\"\"\n populate_issues_array(issues_sql)\n end",
"def ticket_params\n params[:ticket]\n end",
"def index\n @tickets = Ticket.all\n if params[:search]\n @tickets = Ticket.search(params[:search]).order(\"created_at DESC\")\n end\n end",
"def get_ticket(ticket)\n @tickets << ticket\nend",
"def index\n @tickets = @project.tickets.desc.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tickets }\n end\n end",
"def index\n\n # default: show all\n @tickets=Ticket.all\n\n # cases for showing open tockets, closed tickets, and per technician\n case params[:state]\n when \"open\"\n @[email protected](closed: nil)\n when \"closed\"\n @[email protected](closed: nil)\n end\n if params.has_key? :assigned_technician\n @[email protected](assigned_technician: params[:assigned_technician])\n end\n end",
"def index\n @tickets = Ticket.all\n end",
"def index\n @tickets = Ticket.all\n end",
"def index\n @tickets = Ticket.all\n end",
"def index\n @tickets = Ticket.all\n end",
"def index\n @tickets = Ticket.all\n end",
"def index\n @tickets = Ticket.all\n end",
"def index\n @tickets = Ticket.all\n end",
"def index\n @tickets = Ticket.all\n end",
"def index\n @tickets = Ticket.all\n end",
"def index\n @tickets = Ticket.all\n end",
"def index\n @tickets = Ticket.all\n end",
"def index\n @tickets = Ticket.all\n end",
"def index\n @tickets = Ticket.all\n end",
"def index\n session[:search_params] = params[:ticket] ? params[:ticket] : nil\n\n session[:set_pager_number] = params[:set_pager_number] if params[:set_pager_number]\n\n if session[:set_pager_number].nil?\n session[:set_pager_number] = 10\n end\n if current_company\n tickets = @current_company.tickets\n else\n tickets = Ticket \n end\n @o_all = tickets.\n user_search(session[:search_params]).\n order(sort_column + \" \" + sort_direction).\n paginate(:per_page => session[:set_pager_number], :page => params[:page])\n\n @params_arr = { :subject => { \"type\" => 'text' } }\n\n @ticket = controller_name.classify.constantize.new\n end",
"def search\n # search_condition = \"%\" + sort_query + \"%\"\n # @tickets = Ticket.find(:all, :conditions => ['name LIKE ? OR category LIKE ? OR place LIKE ?', search_condition, search_condition, search_condition], :order => (sort_column + ' ' + sort_direction))\n\n @search = params[:search]\n @query_string = \"\"\n\n if(@search[:name] == \"\")\n query_name = \"%\"\n else\n query_name = \"%\" + @search[:name] + \"%\"\n @query_string = @query_string + @search[:name] + \" \"\n end\n if(@search[:category] == \"\")\n query_category = \"%\"\n else\n query_category = \"%\" + @search[:category] + \"%\"\n @query_string = @query_string + @search[:category] + \" \"\n end\n # query_date = \"%\" + @search[:date] + \"%\"\n # query_time = \"%\" + @search[:time] + \"%\"\n if(@search[:place] == \"\")\n query_place = \"%\"\n else\n query_place = \"%\" + @search[:place] + \"%\"\n @query_string = @query_string + @search[:place] + \" \"\n end\n\n @tickets = Ticket.find(:all, :conditions => ['name LIKE ? AND category LIKE ? AND place LIKE ?', query_name, query_category, query_place])\n\n respond_to do |format|\n format.html # search.html.erb\n format.json { render json: @tickets }\n end\n end",
"def find_by_project(project_id, options = {})\n options.merge!({project_id: project_id })\n result = Paymo::API.get :entries, :find_by_project, options\n if result['status'] == 'ok'\n result['entries']['entry'].map! do |entry|\n Paymo::Entry.new(entry)\n end\n end\n end",
"def index\n @tickets = get_current_user_ticket_list(@user)\n end",
"def GetTicket id\n\n APICall(path: \"tickets/#{id}.json\")\n\n end",
"def getUserTickets\n @user = User.find(params[:id])\n render json: @user.tickets\n end",
"def index\n if @project\n if ProjectUser.verify_role(current_user.id, @project, 'client')\n @tickets = Ticket.all_for_project(@project)\n render json: @tickets, status: 200\n else\n render json: { error: 'You must be a member of a project to see its content' }, status: :unauthorized\n end\n else\n render json: { error: \"no project found with id of #{params[:project_id]}\" }, status: 404\n end\n end",
"def get_jira_tickets(status, project, version, max_num_results=300)\n\n response = @client.call(:get_issues_from_jql_search,\n message: {:token => @token,\n :jqlSearch => 'status in (' + status + ') and project=' + project + ' and fixVersion in (' + version + ')',\n :maxNumResults => max_num_results})\n #if response is empty\n if response.to_hash[:multi_ref].nil?\n nil\n else\n jira_tickets = []\n response.to_hash[:multi_ref].each do |tickets|\n if !tickets[:key].nil? and !tickets[:summary].nil?\n jira_tickets << [tickets[:key], tickets[:summary], 'http://'+@jira_host+'/browse/'+tickets[:key].to_s]\n end\n end\n jira_tickets\n end\n rescue Savon::SOAPFault => error\n return false, error.to_hash[:fault][:faultstring].match(/.*?:(.*)/)[1]\n end",
"def index\n @tickets, params[:filter] = current_user.filtered_tickets(params[:filter])\n @tickets = @tickets.order(created_at: :desc)\n end",
"def index\n if params[:status] \n status = params[:status].to_sym\n if Status.statuses.has_key? status\n status_id = Status.statuses[status] \n @tickets = Ticket.where(status_id: status_id)\n end\n elsif params[:search]\n search = Ticket.search{fulltext params[:search]}\n @tickets = search.results\n else\n @tickets = Ticket.all\n end\n end",
"def get(ticket_id)\r\n\r\n # Validate required parameters\r\n if ticket_id == nil\r\n raise ArgumentError.new \"Required parameter 'ticket_id' cannot be nil.\"\r\n end\r\n\r\n # the base uri for api requests\r\n _query_builder = Configuration.base_uri.dup\r\n\r\n # prepare query string for API call\r\n _query_builder << '/tickets/{ticket_id}'\r\n\r\n # process optional query parameters\r\n _query_builder = APIHelper.append_url_with_template_parameters _query_builder, {\r\n 'ticket_id' => ticket_id\r\n }\r\n\r\n # validate and preprocess url\r\n _query_url = APIHelper.clean_url _query_builder\r\n\r\n # prepare headers\r\n _headers = {\r\n 'user-agent' => 'APIMATIC 2.0',\r\n 'accept' => 'application/json',\r\n 'X-API-TOKEN' => Configuration.x_api_token,\r\n 'X-API-EMAIL' => Configuration.x_api_email\r\n }\r\n\r\n # append custom auth authorization\r\n CustomAuthUtility.append_custom_auth_params _headers\r\n\r\n # invoke the API call request to fetch the response\r\n _response = Unirest.get _query_url, headers: _headers\r\n\r\n # Error handling using HTTP status codes\r\n if _response.code == 401\r\n raise APIException.new 'Your API key is incorrect', 401, _response.body\r\n elsif _response.code == 400\r\n raise APIException.new 'There is an error in the parameters you send', 400, _response.body\r\n elsif _response.code == 404\r\n raise APIException.new 'Cannot find the resource specified', 404, _response.body\r\n elsif !_response.code.between?(200, 206) # [200,206] = HTTP OK\r\n raise APIException.new 'HTTP Response Not OK', _response.code, _response.body\r\n end\r\n\r\n # Try to cast response to desired type\r\n if _response.body.instance_of? Hash\r\n begin\r\n Ticket.from_hash(_response.body)\r\n rescue Exception\r\n raise APIException.new \"Invalid JSON returned.\", _response.code, _response.body\r\n end\r\n end\r\n end",
"def index\n # @tickets = Ticket.all\n @q = Ticket.ransack(params[:q])\n @tickets = @q.result(distinct: true).paginate(:page => params[:page], :per_page => 10).order('created_at DESC')\n end",
"def preload_tickets\n @tickets = if params[:story_id]\n Story.find(params[:story_id]).tickets\n else\n Sprint.find(params[:sprint_id]).tickets\n end\n end",
"def index\n @tickets = @event.tickets\n end",
"def find_issues(key, search_title: true, search_commits: false, search_branch: false)\n regexp = build_regexp_from_key(key)\n jira_issues = []\n\n jira_issues.concat(search_title(regexp)) if search_title\n jira_issues.concat(search_commits(regexp)) if search_commits\n jira_issues.concat(search_branch(regexp)) if search_branch\n jira_issues.concat(search_pr_body(regexp)) if jira_issues.empty?\n\n @issues = jira_issues.uniq(&:downcase).map { |issue_key| @api.Issue.find(issue_key) }\n end",
"def index\n @tickets_recently = Ticket.where(reporter: current_user)\n .where.not('status_id = (?) OR status_id = (?)', Status.closed_id, Status.cancel_id)\n .where(updated_at: (Time.now - 24.hours)..Time.now)\n .order(updated_at: :desc)\n .page(params[:recently]).per(6)\n @tickets = Ticket.where(reporter: current_user).order(updated_at: :desc).page(params[:page]).per(10)\n end",
"def index\n @support_tickets = SupportTicket.all\n end",
"def list\r\n # the base uri for api requests\r\n _query_builder = Configuration.base_uri.dup\r\n\r\n # prepare query string for API call\r\n _query_builder << '/tickets'\r\n\r\n # validate and preprocess url\r\n _query_url = APIHelper.clean_url _query_builder\r\n\r\n # prepare headers\r\n _headers = {\r\n 'user-agent' => 'APIMATIC 2.0',\r\n 'accept' => 'application/json',\r\n 'X-API-TOKEN' => Configuration.x_api_token,\r\n 'X-API-EMAIL' => Configuration.x_api_email\r\n }\r\n\r\n # append custom auth authorization\r\n CustomAuthUtility.append_custom_auth_params _headers\r\n\r\n # invoke the API call request to fetch the response\r\n _response = Unirest.get _query_url, headers: _headers\r\n\r\n # Error handling using HTTP status codes\r\n if _response.code == 401\r\n raise APIException.new 'Your API key is incorrect', 401, _response.body\r\n elsif _response.code == 400\r\n raise APIException.new 'There is an error in the parameters you send', 400, _response.body\r\n elsif _response.code == 404\r\n raise APIException.new 'Cannot find the resource specified', 404, _response.body\r\n elsif !_response.code.between?(200, 206) # [200,206] = HTTP OK\r\n raise APIException.new 'HTTP Response Not OK', _response.code, _response.body\r\n end\r\n \r\n # Try to cast response to list of desired type\r\n if _response.body.instance_of? Array\r\n value = Array.new\r\n _response.body.each do |item|\r\n begin\r\n value << (Ticket.from_hash(item))\r\n rescue Exception\r\n raise APIException.new \"Invalid JSON returned.\", _response.code, _response.body\r\n end\r\n end\r\n value\r\n end\r\n end",
"def get_ticket(ticket_id:)\n ZendeskAPI::Ticket.find(client, id: ticket_id)\n end",
"def index\n if current_user.is_admin\n @tickets = Ticket.joins(:event)\n else\n @tickets = current_user.tickets.joins(:event)\n end\n @tickets = @tickets.merge(Event.where(\"events.name LIKE :search\", search: \"%#{params[:event_name]}%\"))\n .where(\"seat_id_seq LIKE '%#{params[:seat_number]}%'\")\n\n if params[:event_date].try(:to_date)\n @tickets = @tickets.merge(Event.where(event_date: params[:event_date].to_date))\n end\n\n if params[:client_name] && params[:client_name].mb_chars.length > 0\n @tickets = @tickets.where(\"tickets.name LIKE '%#{params[:client_name]}%'\")\n end\n\n @tickets = @tickets.paginate(:page => params[:page], :per_page => 10)\n end",
"def update\n logger.info { \"PARAMS: #{params.inspect}\" }\n project_id, id = params[:id].split('-')\n ticket = Lighthouse::Ticket.find(id, :params => {:project_id => project_id})\n \n # insanely hacky. can't nest json, so don't want to do a willy-nilly merge.\n # move mergeable params to the [:ticket] hash to follow usual rails conventions\n # before merging\n params[:ticket] = {}\n %w(assigned_user_id state milestone_id).each do |field|\n params[:ticket].merge!( field => params.delete(field) ) if params[field]\n end\n logger.info { \"TICKET ATTRS TO UPDATE: #{params[:ticket].inspect}\"}\n \n ticket.attributes.merge!( params[:ticket] )\n ticket.save\n\n respond_to do |format|\n # if @ticket.update_attributes(params[:ticket])\n # flash[:notice] = 'Ticket was successfully updated.'\n # format.html { redirect_to(@ticket) }\n # format.xml { head :ok }\n # else\n # format.html { render :action => \"edit\" }\n # format.xml { render :xml => @ticket.errors, :status => :unprocessable_entity }\n # end\n end\n end",
"def ticket_params\n params.require(:ticket).permit(:title, :description, :project_id, :priority, :status, :ticket_type, :assigned_dev_id)\n end",
"def index\n @ticket_items = TicketItem.all\n end",
"def show\n @projects = @board.projects\n @columns = @board.columns.order(:position)\n @sprints = @board.sprints.where(is_active: true)\n @backlog_tickets = Ticket.all.where(\"project_id In (?)\", @board.projects.pluck(:id))\n if @board.sprints.joins(:tickets).pluck(\"tickets.id\").length > 0\n @backlog_tickets = @backlog_tickets.where(\"id not in (?)\", @board.sprints.joins(:tickets).pluck(\"tickets.id\"))\n end\n @tickets = Ticket.where(\"project_id IN (?)\", @board.projects.pluck(:id))\n @tickets = @tickets.joins(:sprints).where(\"board_sprints_tickets.board_sprint_id IN (?)\", @sprints.where(\"is_complete IS NOT ?\", true).pluck(:id))\n end",
"def index\n @ticket_items = TicketItem.sorted\n end",
"def find_by(hash)\n # firebase does not have complex querying\n # so we have to grab all objects satisfying\n # first key/value\n init_key, init_value = hash.shift\n firebase_response = firebase_request :get,\n firebase_model,\n orderBy: \"\\\"#{init_key}\\\"\",\n equalTo: encode_init_value(init_value)\n\n # we then filter the remaining key/values with ruby\n hash.each do |key, value|\n firebase_response = firebase_response.select do |_firebase_key, firebase_hash|\n firebase_hash[key.to_s] == value\n end\n end\n\n firebase_hashes_array = normalize_firebase_hashes(firebase_response)\n\n firebase_hashes_array.map { |hash_item| create_firebase_object(hash_item) }\n end",
"def project_issues(project)\n Issue.where(:project_id=>project.id)\n end",
"def get_events_for_ticket( session_key, ticket_id)\n response_xml = self.call( :get_events_for_ticket, message: {\n arg0: session_key,\n arg1: ticket_id\n })\n response = IssueCentre::Response.parse( response_xml)\n end",
"def index\n @tickets = Ticket.includes({ :comments => :user}, :creator, :assignee).in_progress\n end",
"def search_tickets( session_key, company_id, contact_id,\n vendor_id, product_id, status, owner_id,\n ticket_reference, client_reference,\n supplier_reference, company_reference,\n date_from, date_to, ticket_status, priority, free_text,\n page_size, page_num, tags)\n\n response_xml = self.call( :search_tickets, message: {\n arg0: session_key,\n arg1: company_id,\n arg2: contact_id,\n arg3: vendor_id,\n arg4: product_id,\n arg5: status,\n arg6: owner_id,\n arg7: ticket_reference,\n arg8: client_reference,\n arg9: supplier_reference,\n arg10: company_reference,\n arg11: date_from,\n arg12: date_to,\n arg13: ticket_status,\n arg14: priority,\n arg15: free_text,\n arg16: page_size,\n arg17: page_num,\n arg18: tags\n })\n response = IssueCentre::Response.parse( response_xml)\n end",
"def tickets_report\n manage_filter_state\n id = params[:Id]\n user = params[:User]\n office = params[:OfficeT]\n from = params[:From]\n to = params[:To]\n category = params[:Category]\n priority = params[:Priority]\n status = params[:Status]\n technician = params[:Technician]\n destination = params[:Destination]\n # OCO\n init_oco if !session[:organization]\n\n search = Ticket.search do\n fulltext params[:search]\n if session[:organization] != '0'\n with :organization_id, session[:organization]\n end\n if !id.blank?\n with :id, id\n end\n if !user.blank?\n with :created_by, user\n end\n if !office.blank?\n with :office_id, office\n end\n if !from.blank?\n any_of do\n with(:created_at).greater_than(from)\n with :created_at, from\n end\n end\n if !to.blank?\n any_of do\n with(:created_at).less_than(to)\n with :created_at, to\n end\n end\n if !category.blank?\n with :ticket_category_id, category\n end\n if !priority.blank?\n with :ticket_priority_id, priority\n end\n if !status.blank?\n with :ticket_status_id, status\n end\n if !technician.blank?\n with :technician_id, technician\n end\n if !destination.blank?\n with :hd_email, destination\n end\n order_by :id, :desc\n paginate :page => params[:page] || 1, :per_page => Ticket.count\n end\n\n @tickets_report = search.results\n\n if !@tickets_report.blank?\n title = t(\"activerecord.models.ticket.few\")\n @to = formatted_date(@tickets_report.first.created_at)\n @from = formatted_date(@tickets_report.last.created_at)\n respond_to do |format|\n # Render PDF\n format.pdf { send_data render_to_string,\n filename: \"#{title}_#{@from}-#{@to}.pdf\",\n type: 'application/pdf',\n disposition: 'inline' }\n end\n end\n end",
"def index\n @bugs = Project.find(params[:project_id]).bugs.all\n end",
"def index\n tickets = Ticket.all_relevant_tickets\n @pagy, @tickets = pagy(tickets)\n ticket_records_with_associations =\n TicketSerializer.new(@tickets, { params: { :ticketlist => true } }).hash_for_collection[:data].map { | ticket |\n ticket[:attributes]\n }\n # When we need pagination lets use the below\n #render json: { data: ticket_records_with_associations,\n # pagy: pagy_metadata(@pagy) }\n paginate json: ticket_records_with_associations\n end",
"def index\n @bugs = Bug.where(project_id: params[:project_id])\n @project = params[:project_id]\n end",
"def get_ticket_message_entries ticket_no\n if( ticket_no.is_a?( ARINcli::Registration::Ticket ) )\n ticket_no = ticket_no.ticket_no\n end\n ticket_area = prepare_ticket_area(ticket_no)\n retval = []\n dir = Dir.new( ticket_area )\n dir.each do |file_name|\n retval << File.join( ticket_area, file_name ) if file_name.end_with?( \".xml\" )\n end\n return retval\n end",
"def index\n @search_keywords = SearchKeyword.where(team_id: params[:team_id])\n end"
] | [
"0.7127366",
"0.7060546",
"0.69178826",
"0.6719761",
"0.6519268",
"0.6456936",
"0.6405557",
"0.64035344",
"0.63723797",
"0.6313196",
"0.6277238",
"0.61540866",
"0.6114577",
"0.61130935",
"0.6103761",
"0.61005586",
"0.59171915",
"0.58814967",
"0.5873627",
"0.5807041",
"0.5779533",
"0.570066",
"0.56667787",
"0.5642275",
"0.56421506",
"0.5636767",
"0.56117725",
"0.5572446",
"0.5564827",
"0.55449176",
"0.55443656",
"0.5540188",
"0.5533279",
"0.5498569",
"0.5443043",
"0.54199076",
"0.5408574",
"0.5384556",
"0.53806907",
"0.5378525",
"0.5330646",
"0.5316728",
"0.5290433",
"0.5281161",
"0.527288",
"0.52643675",
"0.5259938",
"0.525359",
"0.52484244",
"0.52477384",
"0.5239617",
"0.52302337",
"0.52302337",
"0.52302337",
"0.52302337",
"0.52302337",
"0.52302337",
"0.52302337",
"0.52302337",
"0.52302337",
"0.52302337",
"0.52302337",
"0.52302337",
"0.5228006",
"0.52271765",
"0.5227132",
"0.5224147",
"0.5195631",
"0.5189567",
"0.51769674",
"0.517075",
"0.5167379",
"0.51634765",
"0.5161457",
"0.51565784",
"0.5141024",
"0.5130804",
"0.51217425",
"0.51171",
"0.511208",
"0.5107891",
"0.50998324",
"0.509664",
"0.5091686",
"0.5077366",
"0.50729126",
"0.5062381",
"0.50564677",
"0.5040469",
"0.5032734",
"0.5014609",
"0.49957457",
"0.49863556",
"0.4975419",
"0.49639177",
"0.49540174",
"0.4940652",
"0.4935896",
"0.49340478",
"0.49334845"
] | 0.5233525 | 51 |
Public: Finds all Tickets belonging to a project project_id ID of Project to fetch Tickets for Returns an array of Tickets | def find_all(project_id)
query = "project:=#{project_id}"
cols = %w(dtLastUpdated ixBug sStatus sTitle sLatestTextSummary
ixProject sProject sPersonAssignedTo sPriority).join(',')
api.command(:search, :q => query, :cols => cols).collect do |ticket|
self.new ticket[1]["case"]
end.flatten
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tickets_for_project(project_id)\n tickets = send(:get , \"/api/v1/projects/#{project_id}/tickets.json\")\n\n process_list_response( tickets , Unfuddled::Ticket )\n end",
"def tickets\n Ticket.find_all_by_project_id_and_milestone_id(project_id, id)\n end",
"def tickets()\n sql = \"SELECT * FROM tickets where customer_id = $1\"\n values = [@id]\n ticket_data = SqlRunner.run(sql, values)\n return ticket_data.map{|ticket| Ticket.new(ticket)}\n end",
"def tickets\n sql = \"\n SELECT * FROM tickets\n WHERE customer_id = $1\n \"\n values = [@id]\n result = SqlRunner.run(sql, values)\n return nil if result.count == 0\n return result.map {|ticket| Ticket.new(ticket)}\n end",
"def GetTickets params = {}\n\n params = params.merge(path: 'tickets.json')\n APICall(params)\n\n end",
"def find_tickets(*ids)\n ids.map do |id|\n project.tickets(id).first\n end.compact\n end",
"def tickets\n sql = \"SELECT * FROM tickets\"\n values = []\n tickets = SqlRunner.run(sql, values)\n result = tickets.map { |ticket| Ticket.new( ticket ) }\n return result\n end",
"def get_ticket_ids\n @tickets = Ticket.all.map(&:id)\n end",
"def tickets()\n sql = \"SELECT * FROM tickets\n WHERE customer_id = $1\"\n values = [@id]\n tickets = SqlRunner.run(sql, values)\n return tickets.map{|ticket|Ticket.new(ticket)}\nend",
"def tickets\n records do |instance|\n instance['tickets'] = ticket.where('organization_id': instance['_id'])\n end\n end",
"def GetTicket id\n\n APICall(path: \"tickets/#{id}.json\")\n\n end",
"def index\n @tickets = @project.tickets.desc.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tickets }\n end\n end",
"def index\n if @project\n if ProjectUser.verify_role(current_user.id, @project, 'client')\n @tickets = Ticket.all_for_project(@project)\n render json: @tickets, status: 200\n else\n render json: { error: 'You must be a member of a project to see its content' }, status: :unauthorized\n end\n else\n render json: { error: \"no project found with id of #{params[:project_id]}\" }, status: 404\n end\n end",
"def find_tickets(res)\n if res.key?(\"tickets\")\n tickets_info = res[\"tickets\"]\n @tickets = []\n tickets_info.each do |ticket_info|\n ticket = Ticket.new(ticket_info) \n @tickets << ticket\n end\n @tickets\n elsif res.key?(\"error\")\n raise res[\"error\"]\n else\n raise \"unknown error from API\"\n end\n end",
"def index\n @tickets = Ticket.all\n end",
"def index\n @tickets = Ticket.all\n end",
"def index\n @tickets = Ticket.all\n end",
"def index\n @tickets = Ticket.all\n end",
"def index\n @tickets = Ticket.all\n end",
"def index\n @tickets = Ticket.all\n end",
"def index\n @tickets = Ticket.all\n end",
"def index\n @tickets = Ticket.all\n end",
"def index\n @tickets = Ticket.all\n end",
"def index\n @tickets = Ticket.all\n end",
"def index\n @tickets = Ticket.all\n end",
"def index\n @tickets = Ticket.all\n end",
"def index\n @tickets = Ticket.all\n end",
"def all_ticket_entries\n @ac = ApplicationController.new\n @tickets = Ticket.find(:all, :order => \"created_at\")[0..5000].reverse!\n @species = Specie.all\n @woodtypes = WoodType.all\n end",
"def index\n @tickets = get_current_user_ticket_list(@user)\n end",
"def getUserTickets\n @user = User.find(params[:id])\n render json: @user.tickets\n end",
"def tickets(filters = {})\n tickets = send(:get , '/api/v1/ticket_reports/dynamic.json', filters)\n\n tickets = tickets[:body][\"groups\"].first[\"tickets\"]\n\n process_list_response( tickets , Unfuddled::Ticket)\n end",
"def find_tickets(*ids)\n ids.map do |id|\n tickets(id).first\n end.compact\n end",
"def index\n @support_tickets = SupportTicket.all\n end",
"def my_tickets\n user = current_user.id if !current_user.nil?\n # OCO\n init_oco if !session[:organization]\n\n @search = Ticket.search do\n fulltext params[:search]\n if session[:organization] != '0'\n with :organization_id, session[:organization]\n end\n if !user.blank?\n with :created_by, user\n end\n with(:ticket_status_id).less_than(4)\n order_by :id, :desc\n paginate :page => params[:page] || 1, :per_page => per_page\n end\n\n @tickets = @search.results\n\n respond_to do |format|\n format.html # my_tickets.html.erb\n format.json { render json: @tickets }\n end\n end",
"def tickets(*options)\n options.insert 0, id\n easy_finder(provider_parent(self.class)::Ticket, :all, options, 1)\n end",
"def ticket_search(query, page = 1)\n Ticket.search(self, query, page)\n end",
"def tickets\n where(:_type => TicketCategory.name)\n end",
"def tickets\n Ticket.find(:all, :params => { :q => \"milestone:\\\"#{title}\\\" state:open sort:priority\" })\n end",
"def all_tickets()\n sql = \"SELECT customers.name, films.title, tickets.id\n FROM tickets\n INNER JOIN customers\n ON tickets.customer_id = customers.id\n INNER JOIN screenings\n ON tickets.screening_id = screenings.id\n INNER JOIN films\n ON screenings.film_id = films.id\n WHERE customers.id = $1\"\n values = [@id]\n result = Sqlrunner.run(sql, values)\n return result.each {|info| p info}\n end",
"def get_logger_tickets\n @tickets = Ticket.find_all_by_job_id_and_paid_to_logger(params[:id], false, :order => \"number\")\n render \"get_tickets.html.erb\"\n end",
"def index\n @tickets = Ticket.where(user: current_user)\n end",
"def index\n @ticket_items = TicketItem.all\n end",
"def get_ticket(ticket_id:)\n ZendeskAPI::Ticket.find(client, id: ticket_id)\n end",
"def index\n @sprint = params[:sprint].presence || Sprint.current!\n @tickets = Ticket.for_sprint(@sprint).by_created_at_desc\n @tickets = @tickets.for_project(params[:project]) if params[:project].present?\n @tickets = @tickets.for_user(params[:user]) if params[:user].present?\n @tickets = @tickets.search_name(params[:description]) if params[:description].present?\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tickets }\n end\n end",
"def list\r\n # the base uri for api requests\r\n _query_builder = Configuration.base_uri.dup\r\n\r\n # prepare query string for API call\r\n _query_builder << '/tickets'\r\n\r\n # validate and preprocess url\r\n _query_url = APIHelper.clean_url _query_builder\r\n\r\n # prepare headers\r\n _headers = {\r\n 'user-agent' => 'APIMATIC 2.0',\r\n 'accept' => 'application/json',\r\n 'X-API-TOKEN' => Configuration.x_api_token,\r\n 'X-API-EMAIL' => Configuration.x_api_email\r\n }\r\n\r\n # append custom auth authorization\r\n CustomAuthUtility.append_custom_auth_params _headers\r\n\r\n # invoke the API call request to fetch the response\r\n _response = Unirest.get _query_url, headers: _headers\r\n\r\n # Error handling using HTTP status codes\r\n if _response.code == 401\r\n raise APIException.new 'Your API key is incorrect', 401, _response.body\r\n elsif _response.code == 400\r\n raise APIException.new 'There is an error in the parameters you send', 400, _response.body\r\n elsif _response.code == 404\r\n raise APIException.new 'Cannot find the resource specified', 404, _response.body\r\n elsif !_response.code.between?(200, 206) # [200,206] = HTTP OK\r\n raise APIException.new 'HTTP Response Not OK', _response.code, _response.body\r\n end\r\n \r\n # Try to cast response to list of desired type\r\n if _response.body.instance_of? Array\r\n value = Array.new\r\n _response.body.each do |item|\r\n begin\r\n value << (Ticket.from_hash(item))\r\n rescue Exception\r\n raise APIException.new \"Invalid JSON returned.\", _response.code, _response.body\r\n end\r\n end\r\n value\r\n end\r\n end",
"def get_trucker_tickets\n @tickets = Ticket.find_all_by_job_id_and_paid_to_trucker(params[:id], false, :order => \"number\")\n render \"get_tickets.html.erb\"\n end",
"def index_all\n @tickets = Ticket.all_tickets\n render json: @tickets, status: 200\n end",
"def scoped_tickets\n return @sprint.assigned_tickets if @sprint\n return @project.tickets if @project\n end",
"def articles\n Ticket::Article.where(ticket_id: id).order(:created_at, :id)\n end",
"def ticket_type_tickets ticket_type_id\n if self.ticket_types.where(id: ticket_type_id).size.zero?\n raise_error(\"Given ticket type not found on transaction\")\n end\n\n self.tickets.where(ticket_type_id: ticket_type_id)\n end",
"def my_tickets\n if user_type_id == 1\n Ticket.where(issuer_user_id: id)\n else\n Ticket.where(assigned_to_id: id)\n end\n end",
"def get(ticket_id)\r\n\r\n # Validate required parameters\r\n if ticket_id == nil\r\n raise ArgumentError.new \"Required parameter 'ticket_id' cannot be nil.\"\r\n end\r\n\r\n # the base uri for api requests\r\n _query_builder = Configuration.base_uri.dup\r\n\r\n # prepare query string for API call\r\n _query_builder << '/tickets/{ticket_id}'\r\n\r\n # process optional query parameters\r\n _query_builder = APIHelper.append_url_with_template_parameters _query_builder, {\r\n 'ticket_id' => ticket_id\r\n }\r\n\r\n # validate and preprocess url\r\n _query_url = APIHelper.clean_url _query_builder\r\n\r\n # prepare headers\r\n _headers = {\r\n 'user-agent' => 'APIMATIC 2.0',\r\n 'accept' => 'application/json',\r\n 'X-API-TOKEN' => Configuration.x_api_token,\r\n 'X-API-EMAIL' => Configuration.x_api_email\r\n }\r\n\r\n # append custom auth authorization\r\n CustomAuthUtility.append_custom_auth_params _headers\r\n\r\n # invoke the API call request to fetch the response\r\n _response = Unirest.get _query_url, headers: _headers\r\n\r\n # Error handling using HTTP status codes\r\n if _response.code == 401\r\n raise APIException.new 'Your API key is incorrect', 401, _response.body\r\n elsif _response.code == 400\r\n raise APIException.new 'There is an error in the parameters you send', 400, _response.body\r\n elsif _response.code == 404\r\n raise APIException.new 'Cannot find the resource specified', 404, _response.body\r\n elsif !_response.code.between?(200, 206) # [200,206] = HTTP OK\r\n raise APIException.new 'HTTP Response Not OK', _response.code, _response.body\r\n end\r\n\r\n # Try to cast response to desired type\r\n if _response.body.instance_of? Hash\r\n begin\r\n Ticket.from_hash(_response.body)\r\n rescue Exception\r\n raise APIException.new \"Invalid JSON returned.\", _response.code, _response.body\r\n end\r\n end\r\n end",
"def get_events_for_ticket( session_key, ticket_id)\n response_xml = self.call( :get_events_for_ticket, message: {\n arg0: session_key,\n arg1: ticket_id\n })\n response = IssueCentre::Response.parse( response_xml)\n end",
"def index\n @tickets = @event.tickets\n end",
"def get_jira_tickets(status, project, version, max_num_results=300)\n\n response = @client.call(:get_issues_from_jql_search,\n message: {:token => @token,\n :jqlSearch => 'status in (' + status + ') and project=' + project + ' and fixVersion in (' + version + ')',\n :maxNumResults => max_num_results})\n #if response is empty\n if response.to_hash[:multi_ref].nil?\n nil\n else\n jira_tickets = []\n response.to_hash[:multi_ref].each do |tickets|\n if !tickets[:key].nil? and !tickets[:summary].nil?\n jira_tickets << [tickets[:key], tickets[:summary], 'http://'+@jira_host+'/browse/'+tickets[:key].to_s]\n end\n end\n jira_tickets\n end\n rescue Savon::SOAPFault => error\n return false, error.to_hash[:fault][:faultstring].match(/.*?:(.*)/)[1]\n end",
"def tickets\n Ticket.all.select do |ticket|\n ticket.event == self\n end\n end",
"def index\n @tickets = current_user.tickets\n end",
"def index\n @tickets = current_user.tickets\n end",
"def index\n @project = Project.find(params[:project_id])\n @ticket = @project.tickets.new\n\n @tags = Ticket.tag_counts_on(:tags)\n\n if params[:tags]\n @tickets = {}\n @tickets[:both] = [params[:tags].gsub(', ', ',').split(',').map(&:capitalize).join(', '), @project.tickets.tagged_with(params[:tags])]\n @tickets[:other] = params[:tags].gsub(', ', ',').split(',').map do |tag|\n [tag.capitalize, (@project.tickets.tagged_with(tag) - @tickets[:both][1])]\n end\n else\n @tickets = @project.tickets\n end\n end",
"def index\n @bugs = Project.find(params[:project_id]).bugs.all\n end",
"def index\n @ticket_events = TicketEvent.all\n end",
"def index\n \n @tickets = Ticket.all\n @tickets = @tickets.order(:updated_at)\n @tickets = @tickets.joins(:payment).where(\"payments.id = ?\",params[:clave]) unless params[:clave]==\"\" or params[:clave].nil?\n \n @payment = Payment.find(params[:clave])\n end",
"def index\n @tickets = Ticket.order(id: :desc).all\n end",
"def getUserTicketsByType\n @conditions = {user_id: params[:id], ticket_type: params[:ticket_type]}\n @tickets = Ticket.find(:all, :conditions => @conditions)\n\n # Handle empty results\n if @tickets.empty?\n raise(ActiveRecord::RecordNotFound)\n end\n\n render json: @tickets\n end",
"def where(params)\n result = Tessera::Api::TicketSearch.call(params)\n ticket_ids = result['TicketID'] ? result['TicketID'] : []\n new(ticket_ids)\n end",
"def index\n @ticketings = Ticketing.all\n end",
"def index\n if params[:tickets] == 'closed'\n @tickets = Helpdesk::Ticket.where(:requester_id => helpdesk_user.id).closed.page(params[:page])\n else\n @tickets = Helpdesk::Ticket.where(:requester_id => helpdesk_user.id).active.page(params[:page])\n end\n\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tickets }\n end\n end",
"def index\n @ticket_loops = TicketLoop.all\n end",
"def get_all_withassigned(projectid)\n get(\"projects/#{projectid}/assigned_todos.json\")\n end",
"def project_issues(project)\n Issue.where(:project_id=>project.id)\n end",
"def get_support_ticket_all_using_get(opts = {})\n data, _status_code, _headers = get_support_ticket_all_using_get_with_http_info(opts)\n data\n end",
"def index\n @ticket_files = TicketFile.all\n end",
"def tickets_bought()\n sql = \"SELECT * FROM tickets WHERE customer_id = $1;\"\n values = [@id]\n ticket_hash = SqlRunner.run(sql, values)\n result = Ticket.map_tickets(ticket_hash)\n end",
"def index\n @tickets = Ticket.all\n if params[:search]\n @tickets = Ticket.search(params[:search]).order(\"created_at DESC\")\n end\n end",
"def getList fields = [\"*\"]\n\t\tputs \"here\"\n\t\ttickets = @tickets.read fields\n\t\tputs \"here jjj\"\n\t\toutput = \"Projects:\\n\"\n\n\t\ttickets.each do |row|\n\t\t\toutput += \"| \"\n\t\t\trow.each do |cell|\n\t\t\t output += \"#{cell[1]} | \"\n\t\t\tend\n\t\t\toutput += \"\\n\"\n\t\tend\n\t\toutput\n\tend",
"def show\n if @ticket\n if ProjectUser.verify_role(current_user.id, @ticket.project_id, 'client')\n render json: Ticket.build_ticket_object(@ticket, current_user.id), status: 200\n else\n render json: { error: 'You must be a member of a project to see its content' }, status: :unauthorized\n end\n else\n render json: { error: \"no ticket found with id of #{params[:project_id]}\" }, status: 404\n end\n end",
"def index\n\t @tickets = Ticket.order('created_at DESC').page(params[:page])\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tickets }\n end\n end",
"def index\n @ticket_items = TicketItem.sorted\n end",
"def tickets\n subtree_map(Ticket, :tickets)\n end",
"def index\n @tickets = Ticket.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @ticket }\n end\n end",
"def index\n @support_tickets = SupportTicket.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @support_tickets }\n end\n end",
"def get_hfi_tickets\n @tickets = Ticket.find_all_by_job_id_and_paid_to_hfi(params[:id], false, :order => \"number\")\n render \"get_tickets.html.erb\"\n end",
"def index\n\n @clients = Ticket.joins(:clients).where(client_id: params[:id])\n # @tickets = Ticket.joins(:computers).where(client_id: params[:id])\n @tickets = Ticket.all.order(:due_date).limit(10).offset(0).page params[:page]\n if params[:search]\n @tickets = Ticket.search(params[:search]).order(\"created_at DESC\").page params[:page]\n else\n @tickets = Ticket.all.order(:due_date).limit(10).offset(0).page params[:page]\n @tickets = Ticket.all.order(:due_date).limit(10).offset(0).page params[:page]\n end\n \n #@client = Ticket.joins(:clients).where(@ticket => client.full_name)\n @open_tickets = Ticket.where.not(\"status_id = 8\").count\n #@computers = @ticket.computer.id\n @new_tickets = Ticket.where(\"status_id = 4\").limit(10).offset(0).page params[:page]\n @diagnostic_tickets = Ticket.where(\"status_id = 9\").page params[:page] \n @parts_tickets = Ticket.where(\"status_id = 6\").page params[:page]\n @waiting_tickets = Ticket.where(\"status_id = 7\").page params[:page]\n @in_progress_tickets = Ticket.where(\"status_id = 5\").page params[:page]\n @completed_tickets = Ticket.where(\"status_id = 8\").limit(10).offset(0).page params[:page]\n @expected_date = Date.today + (@open_tickets / 5) + 3.days\n #@expected_date = Ticket.due_date.created_at + 3.days\n end",
"def get_owner_tickets\n @tickets = Ticket.find_all_by_job_id_and_paid_to_owner(params[:id], false, :order => \"number\")\n render \"get_tickets.html.erb\"\n end",
"def get_ticket_message_entries ticket_no\n if( ticket_no.is_a?( ARINcli::Registration::Ticket ) )\n ticket_no = ticket_no.ticket_no\n end\n ticket_area = prepare_ticket_area(ticket_no)\n retval = []\n dir = Dir.new( ticket_area )\n dir.each do |file_name|\n retval << File.join( ticket_area, file_name ) if file_name.end_with?( \".xml\" )\n end\n return retval\n end",
"def show\n @projects = @board.projects\n @columns = @board.columns.order(:position)\n @sprints = @board.sprints.where(is_active: true)\n @backlog_tickets = Ticket.all.where(\"project_id In (?)\", @board.projects.pluck(:id))\n if @board.sprints.joins(:tickets).pluck(\"tickets.id\").length > 0\n @backlog_tickets = @backlog_tickets.where(\"id not in (?)\", @board.sprints.joins(:tickets).pluck(\"tickets.id\"))\n end\n @tickets = Ticket.where(\"project_id IN (?)\", @board.projects.pluck(:id))\n @tickets = @tickets.joins(:sprints).where(\"board_sprints_tickets.board_sprint_id IN (?)\", @sprints.where(\"is_complete IS NOT ?\", true).pluck(:id))\n end",
"def index\n # @tickets = Ticket.all\n @q = Ticket.ransack(params[:q])\n @tickets = @q.result(distinct: true).paginate(:page => params[:page], :per_page => 10).order('created_at DESC')\n end",
"def index\n @tickets = Ticket.all\n @tickets_ordered \n end",
"def index\n @o_all = @ticket.ticket_logs\n end",
"def index\n @tickets = Ticket.includes({ :comments => :user}, :creator, :assignee).in_progress\n end",
"def show\n @ticket = @project.tickets.find_by_scoped_id!(params[:id])\n @ticket_comment = @ticket.ticket_comments.new\n @ticket_comment.status_to = @ticket.status\n @ticket_comment.responsible_id_to = @ticket.responsible_id\n @ticket_comment.priority_to = @ticket.priority\n @assets = @project.assets.where(:attachable_type=>[Ticket.to_s, TicketComment.to_s]).where(:attachable_id=>([@ticket.id]|@ticket.ticket_comments.all.map{|tc|tc.id})).order('updated_at desc').all\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @ticket }\n end\n end",
"def index\n # @open_tickets are tickets not assgined to any agent\n # @ip_tickets are in progress tickets\n # @closed_tickets are closed tickets to show in history\n @ip_tickets, @closed_tickets, @open_tickets = current_user.get_tickets\n end",
"def index\n @title = \"Tickets\"\n @tickets = Ticket.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @tickets }\n end\n end",
"def extract_jira_tickets(projects: CCL_PROJECTS, from:)\n minmax_string = projects.map{|x|x.size}.minmax.join(',')\n project_string = projects.join + projects.join.downcase\n project_string = project_string.scan(/\\w/).uniq.sort.join\n regex_string = \"([#{project_string}]{#{minmax_string}}-\" + '\\d+)'\n jira_re = Regexp.new(regex_string)\n jira_tickets = from.join(' ').scan(jira_re).flatten.map{|t|t.upcase}.sort.uniq\n return jira_tickets\nend",
"def find_all_issues\n version_id_sql = \"project_id =\\\"#{@project.id}\\\" \" + \\\n \"AND name = \\\"#{@version}\\\"\"\n # obtaining the unique ID from the chosen project version\n version = Version.all(conditions: [version_id_sql]).at(0).id.to_s \\\n if Version.all(conditions: [version_id_sql]) != []\n issues_sql = \"project_id = \\\"#{@project.id}\\\" \" + \\\n \"AND fixed_version_id = \\\"#{version}\\\"\"\n populate_issues_array(issues_sql)\n end",
"def show_ticket_details(ticket_id)\n url = \"https://alanli1.zendesk.com/api/v2/tickets/#{ticket_id}.json\"\n\n res = ApiHelper.make_req_to_api(url)\n @ticket = find_ticket_details(res)\n @ticket.requester_name = get_user_name(@ticket.requester_id)\n return @ticket\n end",
"def tickets()\n sql = \"SELECT * FROM tickets WHERE film_id = $1;\"\n values = [@id]\n tickets = SqlRunner.run(sql, values)\n return Ticket.map_items(tickets).count\n end",
"def index\n tickets = Ticket.all_relevant_tickets\n @pagy, @tickets = pagy(tickets)\n ticket_records_with_associations =\n TicketSerializer.new(@tickets, { params: { :ticketlist => true } }).hash_for_collection[:data].map { | ticket |\n ticket[:attributes]\n }\n # When we need pagination lets use the below\n #render json: { data: ticket_records_with_associations,\n # pagy: pagy_metadata(@pagy) }\n paginate json: ticket_records_with_associations\n end",
"def index\n @ticket_transcations = TicketTranscation.all\n end",
"def search_tickets(term, value)\n results = @tickets_indice.search(term: term, value: value)\n if perform_search_by_id?(term)\n results.each do |ticket|\n # Get related organizations\n ticket['organizations'] =\n @organizations_indice.search_by_primary_key(value: ticket['organization_id'])\n\n # Get related users who are submitters\n ticket['submitters'] =\n @users_indice.search_by_primary_key(value: ticket['submitter_id'])\n\n # Get related users who are assignees\n ticket['assignees'] =\n @users_indice.search_by_primary_key(value: ticket['assignee_id'])\n end\n end\n results\n end"
] | [
"0.8186321",
"0.7989205",
"0.7292086",
"0.72084427",
"0.7192272",
"0.7144361",
"0.7023476",
"0.6636827",
"0.6624961",
"0.64781344",
"0.6378727",
"0.63545233",
"0.6350541",
"0.6283819",
"0.6247126",
"0.6247126",
"0.6247126",
"0.6247126",
"0.6247126",
"0.6247126",
"0.6247126",
"0.6247126",
"0.6247126",
"0.6247126",
"0.6247126",
"0.6247126",
"0.6244887",
"0.624013",
"0.62258863",
"0.61959743",
"0.6152522",
"0.61462116",
"0.61216533",
"0.6105285",
"0.6103847",
"0.6093798",
"0.6088209",
"0.6085686",
"0.60676634",
"0.6019517",
"0.5993302",
"0.59781903",
"0.59753275",
"0.5965742",
"0.5963574",
"0.59542423",
"0.5953076",
"0.59169704",
"0.590965",
"0.5908007",
"0.58951145",
"0.58904374",
"0.58829737",
"0.5847755",
"0.58429986",
"0.5838805",
"0.58161485",
"0.58161485",
"0.5811624",
"0.5809727",
"0.57791054",
"0.5737196",
"0.5736151",
"0.5735596",
"0.57328147",
"0.5732799",
"0.57157475",
"0.57101",
"0.5677643",
"0.5673162",
"0.5672384",
"0.5654526",
"0.56338495",
"0.55870706",
"0.55829453",
"0.55747783",
"0.55618274",
"0.5532677",
"0.55168283",
"0.55143434",
"0.55094934",
"0.5502996",
"0.549814",
"0.54768676",
"0.5472512",
"0.5471582",
"0.54637",
"0.54629076",
"0.545779",
"0.5455352",
"0.545009",
"0.54416126",
"0.5430432",
"0.5428934",
"0.5428762",
"0.5414641",
"0.54126257",
"0.54112196",
"0.5401862",
"0.5396085"
] | 0.66266304 | 8 |
Private: Shortcut for accessing Fogbugz API instance Returns Fogbugz API wrapper object | def api
TaskMapper::Provider::Fogbugz.api
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def api\n TaskMapper::Provider::Fogbugz.api\n end",
"def api_object\n unless $api\n $api = FyberAPI.new(\n 'b07a12df7d52e6c118e5d47d3f9e60135b109a1f',\n {\n appid: 157,\n format: 'json',\n device_id: '2b6f0cc904d137be2e1730235f5664094b83',\n locale: 'de',\n ip: '109.235.143.113'\n }\n )\n end\n $api\n end",
"def flickr_api\n @flickr_api ||= Flickr.new(FLICKR.merge(:token => flickr_token))\n end",
"def api\n # Should return an instance of the API instantiated \n # with the credentials passed into the initialized.\n # Raise an error to warn it isn't implemented.\n raise NotImplementedError.new \n end",
"def api\n # Don't cache instance for now because of a ruby marshaling bug present\n # in MRI 1.9.3 (Bug #7627) that causes instance variables to be\n # marshaled even when explicitly specifying #marshal_dump.\n Octokit::Client.new(:login => login, :access_token => token)\n end",
"def fog\n @fog ||= Fogger.new(config[environment])\n end",
"def api\n @config = ZipMoney::Configuration\n configure_api if @_api.nil?\n \t @_api\n end",
"def api\n @api ||= KynetxAmApi::DirectApi.new({:access_token => @access_token, :access_secret => @access_secret})\n return @api\n end",
"def api\n return @api\n end",
"def api\n @api\n end",
"def fog_connection\n @fog_wrapper.fog_connection\n end",
"def api\n @api ||= Battlenet.new(:eu)\n end",
"def inspect\n return 'Ballchasing API'\n end",
"def client\n return @client if @client\n @client = DropboxApi::Client.new(api_token)\n\n rescue => err\n raise Error.wrap(err, \"Authorization Failed\")\n end",
"def api; end",
"def api; end",
"def create_api_instance\n facturama_user='prueba'\n facturama_password='pruebas2011'\n is_development = true # true = Modo de pruebas / sandbox, false = Modo de Producción (Timbrado real)\n\n\n #Creacion de una instancia de FacturamaApi\n Facturama::FacturamaApiWeb.new(facturama_user,facturama_password,is_development)\n end",
"def fitbit_client\n # On authorization, we stored the user's credentials in the database\n # now, whenever we like, we can call this method anywhere\n\n client = FitbitAPI::Client.new(\n client_id: ENV[\"FITBIT_ID\"],\n client_secret: ENV[\"FITBIT_SECRET\"],\n access_token: self.fitbit_access_token,\n refresh_token: self.fitbit_refresh_token,\n expires_at: self.fitbit_expires_at,\n user_id: self.fitbit_user_id\n )\n\n return client\n end",
"def instrumented_class\n defined?(::Grape::API::Instance) ? ::Grape::API::Instance : ::Grape::API\n end",
"def api_client\n self.class.api_client\n end",
"def connection\n @connection ||= Gandi::Connection.new(apikey, url)\n end",
"def restful_api\n @restful_api ||= AlephApi::RestfulApiClient.new(url: @restful_api_url)\n end",
"def initialize(api)\n @api = api\n end",
"def api\n @api ||= WeatherApiCalls.new\n end",
"def api\n if @api.nil?\n @api = BigBlueButton::BigBlueButtonApi.new(self.url, self.salt,\n self.version.to_s, false)\n end\n @api\n end",
"def api\n @api ||= Octokit::Client.new(:login => login, :oauth_token => token)\n end",
"def client\n @client ||= ::Flickr.new({:key => @appid, :secret => @secret, :token => @token.token})\n end",
"def initialize\r\n @apiKey = API_KEY\r\n @secret = SECRET\r\n end",
"def client\n @client ||= Contentful::Client.new(\n access_token: options.access_token,\n space: options.space,\n dynamic_entries: :auto,\n api_url: options.api_url\n )\n end",
"def set_api\r\n api = EVEAPI::API.new\r\n api.api_id = api_key.api_id\r\n api.v_code = api_key.v_code\r\n api.character_id = id\r\n api\r\n end",
"def api\n @http ||= Http.new(config)\n end",
"def flickr\n @flickr_object ||= Flickr.new(FLICKR_CACHE, FLICKR_KEY, FLICKR_SECRET)\n end",
"def initialize\n\t\t@zomato = Zomato::Base.new(@@api_key)\n\tend",
"def getRestforceObj()\n return @restForce\nend",
"def initialize\n endpoint = Figaro.env.cf_endpoint\n credentials = {version: 2, token: Figaro.env.cf_token, refresh_token: Figaro.env.cf_refresh_token}\n token = CFoundry::AuthToken.from_hash(credentials)\n @client = CFoundry::Client.get(endpoint, token)\n end",
"def fogParams \n \"fogParams\" \n end",
"def api_client( )\n if self.session_token?\n db_session = DropboxSession.deserialize(self.session_token)\n begin\n return DropboxClient.new(db_session, ACCESS_TYPE)\n rescue DropboxAuthError => e\n \tRails.logger.info(\"Could not authenticate DropBox Account\" )\n end\n else\n \tRails.logger.info(\"User does not have a DropBox Account\" )\n end\n\n \treturn nil \n\tend",
"def client\n @client ||= Faraday.new(api_host) do |faraday|\n faraday.headers[\"Authorization\"] = \"Bearer #{access_token}\"\n faraday.response :logger if Rails.env.test?\n faraday.adapter Faraday.default_adapter\n end\n end",
"def api\n @api ||= PrismicService.init_api\n end",
"def fog_model_interface\n @fog_model_interface ||= Vcloud::Core::Fog::ModelInterface.new\n end",
"def connection\n @connection ||= Fog::Compute.new(credentials)\nend",
"def api_client\n env[:api_client]\n end",
"def scryfall; ScryfallApi.new end",
"def initialize(options = {})\n @api_secret = options.fetch(:api_secret, ShippingEasy.api_secret)\n @method = options.fetch(:method, :get)\n @path = options.fetch(:path)\n @body = options.fetch(:body, nil)\n @params = options.fetch(:params, {})\n @api_signature = params.delete(:api_signature)\n @api_timestamp = params.fetch(:api_timestamp, nil).to_i\n @expected_signature = ShippingEasy::Signature.new(api_secret: @api_secret, method: @method, path: @path, params: @params, body: @body)\n end",
"def client\n @client = Faceberry::Client.new(options) unless defined?(@client) && @client.cache_key == options.hash\n @client\n end",
"def api\n @api ||= Ncio::Api::V1.new(opts)\n end",
"def new_api\n load_config\n require 'extensions/metasploit/extension.rb'\n @api = BeEF::Extension::Metasploit::RpcClient.instance\n @api.unit_test_init()\n end",
"def api_client\n @api_client ||= ::Lokalise.client LokaliseRails.api_token, {enable_compression: true}.merge(LokaliseRails.timeouts)\n end",
"def initialize(*args)\n @client ||= Betaface::REST::Client.new(*args) \n end",
"def initialize(apikey='f47a72ab00afe64aab78b9919ee3d427')\n\t\t@api_key = apikey\n\t\t@headers = {\"Accept\" => \"application/JSON\", \"user-key\" => @api_key}\n\t\t@base_uri = \"https://developers.zomato.com/api/v2.1/\"\n\tend",
"def fog(type)\n stype = type.to_sym\n require 'fog' unless @fog\n @fog ||= {}\n unless(@fog[stype])\n require 'fog'\n args = {\n :rackspace_username => agent_options['rackspace']['username'],\n :rackspace_api_key => agent_options['rackspace']['api_key']\n }\n if(agent_options['rackspace']['region'])\n args[:rackspace_region] = agent_options['rackspace']['region']\n end\n case stype\n when :compute\n klass = Fog::Compute::RackspaceV2\n when :blockstorage\n klass = Fog::Rackspace::BlockStorage\n when :storage\n klass = Fog::Storage::Rackspace\n when :loadbalancers\n klass = Fog::Rackspace::LoadBalancers\n when :databases\n klass = Fog::Rackspace::Databases\n when :cloud_monitoring\n klass = Fog::Monitoring::Rackspace\n when :cdn\n klass = Fog::CDN::Rackspace\n when :dns\n klass = Fog::DNS::Rackspace\n else\n raise ArgumentError.new \"Invalid fog connection type received: #{type}\"\n end\n log.debug(\"Establishing connection to Rackspace for: #{klass} service\")\n @fog[stype] = klass.new(args)\n end\n @fog[stype]\n end",
"def initialize(options = {})\n opts = {\n oauth_site: 'https://user.gini.net/',\n oauth_redirect: 'http://localhost',\n api_uri: 'https://api.gini.net',\n api_version: 'v1',\n api_type: 'json',\n upload_timeout: 90,\n processing_timeout: 180,\n log: Logger.new(STDOUT),\n user_agent: \"gini-api-ruby/#{VERSION} (Faraday v#{Faraday::VERSION})\"\n }.merge(options)\n\n # Ensure mandatory keys are set\n [:client_id, :client_secret].each do |k|\n raise Gini::Api::Error.new(\"Mandatory option key is missing: #{k}\") unless opts.key?(k)\n end\n\n # Populate instance variables from merged opts\n opts.each do |k, v|\n instance_variable_set(\"@#{k}\", v)\n self.class.send(:attr_reader, k)\n end\n\n # Ensure STDOUT is flushed\n STDOUT.sync = true\n\n # Sanitize api_uri\n @api_uri.sub!(/(\\/)+$/, '')\n\n # Register parser (json+xml) based on API version\n register_parser\n\n @log.info('Gini API client initialized')\n @log.info(\"Target: #{@api_uri}\")\n end",
"def Toadhopper(api_key)\n Toadhopper.new(api_key)\nend",
"def api_client\n @api_client ||= GooglePlaces::Client.new(GOOGLE_API_KEY)\n end",
"def client\n @client ||= Curl::Easy.new\n end",
"def fog \n \"fog\" \n end",
"def setup_api_client\n # see http://rubydoc.info/github/heroku/databasedotcom/master/Databasedotcom/Client:initialize\n # add :debugging => true to constructor hash to log API request/responses\n #u = current_user\n #debugger\n @client = Databasedotcom::Client.new({})\n @client.version = API_VERSION\n @client.authenticate :token => @current_user.access_token,\n :refresh_token => @current_user.refresh_token,\n :instance_url => @current_user.instance_url\n @client.materialize(\"Account\")\n end",
"def initialize(api_key)\n @client = Juicer::Client.new(api_key)\n end",
"def create_buckets_api\n InfluxDB2::API::BucketsApi.new(@api_client)\n end",
"def api_client\n @api_client ||= WildFly::ApiClient.new\n end",
"def initialize base_url, api_key\n\t\t\t\t\t@connection = Freshdesk::Api::Client::Request.new base_url, api_key\n\t\t\t\tend",
"def client\r\n @client ||= APIController.new config\r\n end",
"def connection\n @connection ||= Fog::Storage.new(@fog_options)\n end",
"def flickr_auth\n # Just for fast testing it will be public,\n # in production it will be hidden in ENV VARS\n #\n FlickRaw.api_key = '142c9f2ece1cadf0771cec9aca1740fe'\n FlickRaw.shared_secret = '12f66489ef933ebb'\n end",
"def api\n # Only instantiate the API if needed. validate_update doesn't require it, so we shouldn't\n # make an unnecessary request to get the app_access_token.\n @api ||= API.new(app_access_token)\n end",
"def client\n @client ||= Github::ApiProxy.new(@options[:access_token])\n end",
"def initialize\n @format = 'json'\n @scheme = 'https'\n @host = 'api.imagga.com:443'\n @base_path = '/v2'\n @user_agent = 'Swagger/Ruby/0.1.0/beta'\n @inject_format = false\n @force_ending_format = false\n @camelize_params = false\n # for API key/token authentication\n @api_key = '';\n @api_key_type = '';\n @api_key_name = '';\n @api_key_prefix = '';\n # for http basic authentication\n @username = ''\n @password = ''\n @user_agent = 'Swagger/Ruby/0.1.0/beta'\n end",
"def api\n {\n 'host' => self['apiHost'],\n 'password' => self['apiPassword'],\n 'path' => self['apiPath'],\n 'port' => self['apiPort'],\n 'protocol' => self['apiProtocol'],\n 'username' => self['apiUsername']\n }\n end",
"def connection\n @connection ||= Faraday.new(api_endpoint) do |http|\n http.headers[:accept] = \"application/json, */*\"\n http.headers[:user_agent] = user_agent\n\n http.request :authorization, :Bearer, -> { token_store.get_token }\n http.request :json\n\n http.use Keap::REST::Response::RaiseError\n\n http.response :dates\n http.response :json, content_type: \"application/json\"\n # http.response :logger do |logger|\n # logger.filter(/(Bearer) (\\w+)/, '\\1 [FILTERED]')\n # end\n\n http.adapter adapter, @stubs\n end\n end",
"def initialize\n @app_name = \"FPS\"\n @http_method = \"GET\"\n @service_end_point = Rails.application.config.amazon_fps_endpoint\n @version = \"2008-09-17\"\n\n @access_key = Rails.application.config.aws_access_key\n @secret_key = Rails.application.config.aws_secret_key\n @params = get_default_parameters()\n end",
"def client\n ENV[\"CHEF_API_CLIENT\"] || config[\"CHEF_API_CLIENT\"]\n end",
"def client\n @client ||= Curl::Easy.new\n end",
"def gardener_xmlrpc\n Log.logger.info(\"Starting gardener XML RPC call\")\n #unless (@env_set)\n # raise \"You have not set the gardener env properly\"\n #end\n return XMLRPC::Client.new2(self.gardener_api_url)\n end",
"def orgs\n OrgsAPI.new(self)\n end",
"def initialize (api_key)\n\t\t@params = {\n\t\t\t\"key\" => api_key,\n\t\t\t\"wrapper\" => \"cleverbotrb\"\n\t\t}\n\t\t@endpoint = ENDPOINT\n\tend",
"def z_factory\n @zfactory\n end",
"def auth\n StockQuote::Stock.new(api_key: 'pk_8dd852fe4adb468dbee87c0459e0b83a')\n end",
"def initialize()\n\t\tFlickRaw.api_key = \"b907fe707248d846c970de37fdf212e0\"\n\t\tFlickRaw.shared_secret = \"d6300bd479506d23\"\n\tend",
"def client\n @client = Zaim::Client.new(options) unless defined?(@client) && @client.hash == options.hash\n @client\n end",
"def auth\n StockQuote::Stock.new(api_key: 'pk_8dd852fe4adb468dbee87c0459e0b83a')\n end",
"def version; env['api.version'] end",
"def initialize(key=nil)\n CloudMade.api_key = key if key\n raise \"\\n\\nYou must provide your API key to use the CloudMade service.\\n\\nIn init.rb (or whatever):\\nCloudMade.api_key = 'YOUR_API_KEY_HERE'\\n - or - \\nCloudMade.new('YOUR_API_KEY_HERE')\\n\\n\" unless CloudMade.api_key\n end",
"def connection\n @connection ||= ::Fog::Storage.new(self.config.fog_options)\n end",
"def create_api_instance\n facturama_user='prueba'\n facturama_password='pruebas2011'\n is_development = true # true = Modo de pruebas / sandbox, false = Modo de Producción (Timbrado real)\n\n\n #Creacion de una instancia de FacturamaApiMultiemisor\n Facturama::FacturamaApiMulti.new(facturama_user,facturama_password,is_development)\n end",
"def create_client_of_cybozu\n cybozu = Cybozu.find(1) \n CybozuApi::Client.new(cybozu.url, cybozu.login_id, cybozu.password)\n end",
"def forex_symbols_with_http_info(exchange, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DefaultApi.forex_symbols ...'\n end\n # verify the required parameter 'exchange' is set\n if @api_client.config.client_side_validation && exchange.nil?\n fail ArgumentError, \"Missing the required parameter 'exchange' when calling DefaultApi.forex_symbols\"\n end\n # resource path\n local_var_path = '/forex/symbol'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'exchange'] = exchange\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Array<ForexSymbol>' \n\n # auth_names\n auth_names = opts[:auth_names] || ['api_key']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#forex_symbols\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def dnsimple_client\n @dnsimple_client ||= begin\n if provider = self.omni_auth_providers.where(name: \"dnsimple\").first\n Fog::DNS.new(\n provider: \"DNSimple\",\n dnsimple_email: provider.email,\n dnsimple_token: provider.access_token\n )\n end\n end\n end",
"def connection\n @connection ||= Fog::Storage.new(\n :provider => provider,\n :rackspace_username => username,\n :rackspace_api_key => api_key,\n :rackspace_auth_url => auth_url,\n :rackspace_servicenet => servicenet\n )\n end",
"def bwapi\n abort \"You have no current user set!\".yellow unless current_user_exists?\n abort \"There is no access token set for the current user\".yellow if config.current_user.access_token.nil?\n abort \"There is no environment set for the current user\".yellow if config.current_user.environment.nil?\n\n return @bwapi ||= BWAPI::Client.new(:username => current_user.username, :password => decrypt_password(current_user.username, current_user.password), :api_endpoint => api_endpoint)\n end",
"def initialize(api_key, secret, format_options={})\n @auth = { :api_key => api_key }\n @secret = secret\n end",
"def get_adwords_api\n @api ||= create_adwords_api\n end",
"def client\n @client ||= PlacesAPI.new(ENV['GOOGLE_PLACES_API_KEY'])\n end",
"def connection\n Fog::Storage.new(\n :provider => provider,\n :aws_access_key_id => access_key_id,\n :aws_secret_access_key => secret_access_key,\n :region => region\n )\n end",
"def connection\n @connection ||= Fog::Storage.new(\n :provider => provider,\n :aws_access_key_id => access_key_id,\n :aws_secret_access_key => secret_access_key,\n :region => region\n )\n end",
"def fog\n $fog || Fog::Storage.new(\n :provider => 'Local',\n :local_root => Pusher.server_path\n )\nend",
"def connection(uri:, params:)\n Faraday.new(\n url: \"#{@endpoint}/#{@api_version}/#{uri}\",\n params: params,\n headers: {\n 'User-Agent' => \"RubyGem-zombie_battleground-api_#{VERSION}\",\n 'Content-Type' => 'application/json'\n }\n )\n end",
"def get_fog_storage\n return Fog::Storage.new( :provider => 'AWS',\n :aws_access_key_id => CONFIG[:aws_access_key_id], \n :aws_secret_access_key => CONFIG[:aws_access_key],\n :region => \"us-east-1\" )\n end",
"def apis; end",
"def connection\n @connection ||= RestClient::Resource.new(api_uri.to_s)\n end"
] | [
"0.7762242",
"0.7042285",
"0.6563517",
"0.65257937",
"0.6236395",
"0.62154925",
"0.6197963",
"0.61913455",
"0.6171996",
"0.6154027",
"0.60924584",
"0.6088912",
"0.60846514",
"0.5924184",
"0.591459",
"0.591459",
"0.5894217",
"0.58888674",
"0.58715916",
"0.5849171",
"0.5847214",
"0.5837063",
"0.5832951",
"0.5823858",
"0.5817938",
"0.5785222",
"0.5760062",
"0.5759499",
"0.5759399",
"0.5743456",
"0.57275856",
"0.56985193",
"0.56849015",
"0.5673501",
"0.5653983",
"0.5652621",
"0.562046",
"0.55968416",
"0.55590516",
"0.5550406",
"0.5548798",
"0.553309",
"0.5530254",
"0.5529566",
"0.5526695",
"0.552473",
"0.5521608",
"0.5514567",
"0.5511163",
"0.5509934",
"0.55010194",
"0.54560536",
"0.5455407",
"0.5453038",
"0.5449552",
"0.54437613",
"0.5442672",
"0.5441916",
"0.54411507",
"0.54390204",
"0.543573",
"0.54271996",
"0.5415156",
"0.5414757",
"0.5413559",
"0.54121107",
"0.53905565",
"0.5383085",
"0.538182",
"0.5381103",
"0.53759533",
"0.5369491",
"0.53650814",
"0.53513604",
"0.5351354",
"0.5346865",
"0.53447515",
"0.5339996",
"0.53383785",
"0.5333217",
"0.53242844",
"0.5311359",
"0.5310758",
"0.5310629",
"0.5310058",
"0.5308087",
"0.530546",
"0.52997124",
"0.52949643",
"0.52910656",
"0.5289855",
"0.52874357",
"0.52829677",
"0.52827215",
"0.5279988",
"0.52786016",
"0.52718574",
"0.52702856",
"0.52683926"
] | 0.7682219 | 2 |
Private: Shortcut for accessing Fogbugz API instance Returns Fogbugz API wrapper object | def api
TaskMapper::Provider::Fogbugz.api
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def api\n TaskMapper::Provider::Fogbugz.api\n end",
"def api\n TaskMapper::Provider::Fogbugz.api\n end",
"def api_object\n unless $api\n $api = FyberAPI.new(\n 'b07a12df7d52e6c118e5d47d3f9e60135b109a1f',\n {\n appid: 157,\n format: 'json',\n device_id: '2b6f0cc904d137be2e1730235f5664094b83',\n locale: 'de',\n ip: '109.235.143.113'\n }\n )\n end\n $api\n end",
"def flickr_api\n @flickr_api ||= Flickr.new(FLICKR.merge(:token => flickr_token))\n end",
"def api\n # Should return an instance of the API instantiated \n # with the credentials passed into the initialized.\n # Raise an error to warn it isn't implemented.\n raise NotImplementedError.new \n end",
"def api\n # Don't cache instance for now because of a ruby marshaling bug present\n # in MRI 1.9.3 (Bug #7627) that causes instance variables to be\n # marshaled even when explicitly specifying #marshal_dump.\n Octokit::Client.new(:login => login, :access_token => token)\n end",
"def fog\n @fog ||= Fogger.new(config[environment])\n end",
"def api\n @config = ZipMoney::Configuration\n configure_api if @_api.nil?\n \t @_api\n end",
"def api\n @api ||= KynetxAmApi::DirectApi.new({:access_token => @access_token, :access_secret => @access_secret})\n return @api\n end",
"def api\n return @api\n end",
"def api\n @api\n end",
"def fog_connection\n @fog_wrapper.fog_connection\n end",
"def api\n @api ||= Battlenet.new(:eu)\n end",
"def inspect\n return 'Ballchasing API'\n end",
"def client\n return @client if @client\n @client = DropboxApi::Client.new(api_token)\n\n rescue => err\n raise Error.wrap(err, \"Authorization Failed\")\n end",
"def api; end",
"def api; end",
"def create_api_instance\n facturama_user='prueba'\n facturama_password='pruebas2011'\n is_development = true # true = Modo de pruebas / sandbox, false = Modo de Producción (Timbrado real)\n\n\n #Creacion de una instancia de FacturamaApi\n Facturama::FacturamaApiWeb.new(facturama_user,facturama_password,is_development)\n end",
"def fitbit_client\n # On authorization, we stored the user's credentials in the database\n # now, whenever we like, we can call this method anywhere\n\n client = FitbitAPI::Client.new(\n client_id: ENV[\"FITBIT_ID\"],\n client_secret: ENV[\"FITBIT_SECRET\"],\n access_token: self.fitbit_access_token,\n refresh_token: self.fitbit_refresh_token,\n expires_at: self.fitbit_expires_at,\n user_id: self.fitbit_user_id\n )\n\n return client\n end",
"def instrumented_class\n defined?(::Grape::API::Instance) ? ::Grape::API::Instance : ::Grape::API\n end",
"def api_client\n self.class.api_client\n end",
"def connection\n @connection ||= Gandi::Connection.new(apikey, url)\n end",
"def restful_api\n @restful_api ||= AlephApi::RestfulApiClient.new(url: @restful_api_url)\n end",
"def initialize(api)\n @api = api\n end",
"def api\n @api ||= WeatherApiCalls.new\n end",
"def api\n if @api.nil?\n @api = BigBlueButton::BigBlueButtonApi.new(self.url, self.salt,\n self.version.to_s, false)\n end\n @api\n end",
"def api\n @api ||= Octokit::Client.new(:login => login, :oauth_token => token)\n end",
"def client\n @client ||= ::Flickr.new({:key => @appid, :secret => @secret, :token => @token.token})\n end",
"def client\n @client ||= Contentful::Client.new(\n access_token: options.access_token,\n space: options.space,\n dynamic_entries: :auto,\n api_url: options.api_url\n )\n end",
"def initialize\r\n @apiKey = API_KEY\r\n @secret = SECRET\r\n end",
"def set_api\r\n api = EVEAPI::API.new\r\n api.api_id = api_key.api_id\r\n api.v_code = api_key.v_code\r\n api.character_id = id\r\n api\r\n end",
"def api\n @http ||= Http.new(config)\n end",
"def flickr\n @flickr_object ||= Flickr.new(FLICKR_CACHE, FLICKR_KEY, FLICKR_SECRET)\n end",
"def initialize\n\t\t@zomato = Zomato::Base.new(@@api_key)\n\tend",
"def getRestforceObj()\n return @restForce\nend",
"def initialize\n endpoint = Figaro.env.cf_endpoint\n credentials = {version: 2, token: Figaro.env.cf_token, refresh_token: Figaro.env.cf_refresh_token}\n token = CFoundry::AuthToken.from_hash(credentials)\n @client = CFoundry::Client.get(endpoint, token)\n end",
"def fogParams \n \"fogParams\" \n end",
"def api_client( )\n if self.session_token?\n db_session = DropboxSession.deserialize(self.session_token)\n begin\n return DropboxClient.new(db_session, ACCESS_TYPE)\n rescue DropboxAuthError => e\n \tRails.logger.info(\"Could not authenticate DropBox Account\" )\n end\n else\n \tRails.logger.info(\"User does not have a DropBox Account\" )\n end\n\n \treturn nil \n\tend",
"def client\n @client ||= Faraday.new(api_host) do |faraday|\n faraday.headers[\"Authorization\"] = \"Bearer #{access_token}\"\n faraday.response :logger if Rails.env.test?\n faraday.adapter Faraday.default_adapter\n end\n end",
"def api\n @api ||= PrismicService.init_api\n end",
"def fog_model_interface\n @fog_model_interface ||= Vcloud::Core::Fog::ModelInterface.new\n end",
"def connection\n @connection ||= Fog::Compute.new(credentials)\nend",
"def api_client\n env[:api_client]\n end",
"def scryfall; ScryfallApi.new end",
"def initialize(options = {})\n @api_secret = options.fetch(:api_secret, ShippingEasy.api_secret)\n @method = options.fetch(:method, :get)\n @path = options.fetch(:path)\n @body = options.fetch(:body, nil)\n @params = options.fetch(:params, {})\n @api_signature = params.delete(:api_signature)\n @api_timestamp = params.fetch(:api_timestamp, nil).to_i\n @expected_signature = ShippingEasy::Signature.new(api_secret: @api_secret, method: @method, path: @path, params: @params, body: @body)\n end",
"def client\n @client = Faceberry::Client.new(options) unless defined?(@client) && @client.cache_key == options.hash\n @client\n end",
"def api\n @api ||= Ncio::Api::V1.new(opts)\n end",
"def new_api\n load_config\n require 'extensions/metasploit/extension.rb'\n @api = BeEF::Extension::Metasploit::RpcClient.instance\n @api.unit_test_init()\n end",
"def api_client\n @api_client ||= ::Lokalise.client LokaliseRails.api_token, {enable_compression: true}.merge(LokaliseRails.timeouts)\n end",
"def initialize(*args)\n @client ||= Betaface::REST::Client.new(*args) \n end",
"def initialize(apikey='f47a72ab00afe64aab78b9919ee3d427')\n\t\t@api_key = apikey\n\t\t@headers = {\"Accept\" => \"application/JSON\", \"user-key\" => @api_key}\n\t\t@base_uri = \"https://developers.zomato.com/api/v2.1/\"\n\tend",
"def fog(type)\n stype = type.to_sym\n require 'fog' unless @fog\n @fog ||= {}\n unless(@fog[stype])\n require 'fog'\n args = {\n :rackspace_username => agent_options['rackspace']['username'],\n :rackspace_api_key => agent_options['rackspace']['api_key']\n }\n if(agent_options['rackspace']['region'])\n args[:rackspace_region] = agent_options['rackspace']['region']\n end\n case stype\n when :compute\n klass = Fog::Compute::RackspaceV2\n when :blockstorage\n klass = Fog::Rackspace::BlockStorage\n when :storage\n klass = Fog::Storage::Rackspace\n when :loadbalancers\n klass = Fog::Rackspace::LoadBalancers\n when :databases\n klass = Fog::Rackspace::Databases\n when :cloud_monitoring\n klass = Fog::Monitoring::Rackspace\n when :cdn\n klass = Fog::CDN::Rackspace\n when :dns\n klass = Fog::DNS::Rackspace\n else\n raise ArgumentError.new \"Invalid fog connection type received: #{type}\"\n end\n log.debug(\"Establishing connection to Rackspace for: #{klass} service\")\n @fog[stype] = klass.new(args)\n end\n @fog[stype]\n end",
"def initialize(options = {})\n opts = {\n oauth_site: 'https://user.gini.net/',\n oauth_redirect: 'http://localhost',\n api_uri: 'https://api.gini.net',\n api_version: 'v1',\n api_type: 'json',\n upload_timeout: 90,\n processing_timeout: 180,\n log: Logger.new(STDOUT),\n user_agent: \"gini-api-ruby/#{VERSION} (Faraday v#{Faraday::VERSION})\"\n }.merge(options)\n\n # Ensure mandatory keys are set\n [:client_id, :client_secret].each do |k|\n raise Gini::Api::Error.new(\"Mandatory option key is missing: #{k}\") unless opts.key?(k)\n end\n\n # Populate instance variables from merged opts\n opts.each do |k, v|\n instance_variable_set(\"@#{k}\", v)\n self.class.send(:attr_reader, k)\n end\n\n # Ensure STDOUT is flushed\n STDOUT.sync = true\n\n # Sanitize api_uri\n @api_uri.sub!(/(\\/)+$/, '')\n\n # Register parser (json+xml) based on API version\n register_parser\n\n @log.info('Gini API client initialized')\n @log.info(\"Target: #{@api_uri}\")\n end",
"def Toadhopper(api_key)\n Toadhopper.new(api_key)\nend",
"def api_client\n @api_client ||= GooglePlaces::Client.new(GOOGLE_API_KEY)\n end",
"def client\n @client ||= Curl::Easy.new\n end",
"def fog \n \"fog\" \n end",
"def setup_api_client\n # see http://rubydoc.info/github/heroku/databasedotcom/master/Databasedotcom/Client:initialize\n # add :debugging => true to constructor hash to log API request/responses\n #u = current_user\n #debugger\n @client = Databasedotcom::Client.new({})\n @client.version = API_VERSION\n @client.authenticate :token => @current_user.access_token,\n :refresh_token => @current_user.refresh_token,\n :instance_url => @current_user.instance_url\n @client.materialize(\"Account\")\n end",
"def initialize(api_key)\n @client = Juicer::Client.new(api_key)\n end",
"def create_buckets_api\n InfluxDB2::API::BucketsApi.new(@api_client)\n end",
"def api_client\n @api_client ||= WildFly::ApiClient.new\n end",
"def initialize base_url, api_key\n\t\t\t\t\t@connection = Freshdesk::Api::Client::Request.new base_url, api_key\n\t\t\t\tend",
"def client\r\n @client ||= APIController.new config\r\n end",
"def connection\n @connection ||= Fog::Storage.new(@fog_options)\n end",
"def flickr_auth\n # Just for fast testing it will be public,\n # in production it will be hidden in ENV VARS\n #\n FlickRaw.api_key = '142c9f2ece1cadf0771cec9aca1740fe'\n FlickRaw.shared_secret = '12f66489ef933ebb'\n end",
"def api\n # Only instantiate the API if needed. validate_update doesn't require it, so we shouldn't\n # make an unnecessary request to get the app_access_token.\n @api ||= API.new(app_access_token)\n end",
"def client\n @client ||= Github::ApiProxy.new(@options[:access_token])\n end",
"def initialize\n @format = 'json'\n @scheme = 'https'\n @host = 'api.imagga.com:443'\n @base_path = '/v2'\n @user_agent = 'Swagger/Ruby/0.1.0/beta'\n @inject_format = false\n @force_ending_format = false\n @camelize_params = false\n # for API key/token authentication\n @api_key = '';\n @api_key_type = '';\n @api_key_name = '';\n @api_key_prefix = '';\n # for http basic authentication\n @username = ''\n @password = ''\n @user_agent = 'Swagger/Ruby/0.1.0/beta'\n end",
"def api\n {\n 'host' => self['apiHost'],\n 'password' => self['apiPassword'],\n 'path' => self['apiPath'],\n 'port' => self['apiPort'],\n 'protocol' => self['apiProtocol'],\n 'username' => self['apiUsername']\n }\n end",
"def connection\n @connection ||= Faraday.new(api_endpoint) do |http|\n http.headers[:accept] = \"application/json, */*\"\n http.headers[:user_agent] = user_agent\n\n http.request :authorization, :Bearer, -> { token_store.get_token }\n http.request :json\n\n http.use Keap::REST::Response::RaiseError\n\n http.response :dates\n http.response :json, content_type: \"application/json\"\n # http.response :logger do |logger|\n # logger.filter(/(Bearer) (\\w+)/, '\\1 [FILTERED]')\n # end\n\n http.adapter adapter, @stubs\n end\n end",
"def initialize\n @app_name = \"FPS\"\n @http_method = \"GET\"\n @service_end_point = Rails.application.config.amazon_fps_endpoint\n @version = \"2008-09-17\"\n\n @access_key = Rails.application.config.aws_access_key\n @secret_key = Rails.application.config.aws_secret_key\n @params = get_default_parameters()\n end",
"def client\n ENV[\"CHEF_API_CLIENT\"] || config[\"CHEF_API_CLIENT\"]\n end",
"def client\n @client ||= Curl::Easy.new\n end",
"def gardener_xmlrpc\n Log.logger.info(\"Starting gardener XML RPC call\")\n #unless (@env_set)\n # raise \"You have not set the gardener env properly\"\n #end\n return XMLRPC::Client.new2(self.gardener_api_url)\n end",
"def orgs\n OrgsAPI.new(self)\n end",
"def initialize (api_key)\n\t\t@params = {\n\t\t\t\"key\" => api_key,\n\t\t\t\"wrapper\" => \"cleverbotrb\"\n\t\t}\n\t\t@endpoint = ENDPOINT\n\tend",
"def z_factory\n @zfactory\n end",
"def auth\n StockQuote::Stock.new(api_key: 'pk_8dd852fe4adb468dbee87c0459e0b83a')\n end",
"def client\n @client = Zaim::Client.new(options) unless defined?(@client) && @client.hash == options.hash\n @client\n end",
"def initialize()\n\t\tFlickRaw.api_key = \"b907fe707248d846c970de37fdf212e0\"\n\t\tFlickRaw.shared_secret = \"d6300bd479506d23\"\n\tend",
"def auth\n StockQuote::Stock.new(api_key: 'pk_8dd852fe4adb468dbee87c0459e0b83a')\n end",
"def version; env['api.version'] end",
"def connection\n @connection ||= ::Fog::Storage.new(self.config.fog_options)\n end",
"def create_api_instance\n facturama_user='prueba'\n facturama_password='pruebas2011'\n is_development = true # true = Modo de pruebas / sandbox, false = Modo de Producción (Timbrado real)\n\n\n #Creacion de una instancia de FacturamaApiMultiemisor\n Facturama::FacturamaApiMulti.new(facturama_user,facturama_password,is_development)\n end",
"def initialize(key=nil)\n CloudMade.api_key = key if key\n raise \"\\n\\nYou must provide your API key to use the CloudMade service.\\n\\nIn init.rb (or whatever):\\nCloudMade.api_key = 'YOUR_API_KEY_HERE'\\n - or - \\nCloudMade.new('YOUR_API_KEY_HERE')\\n\\n\" unless CloudMade.api_key\n end",
"def create_client_of_cybozu\n cybozu = Cybozu.find(1) \n CybozuApi::Client.new(cybozu.url, cybozu.login_id, cybozu.password)\n end",
"def forex_symbols_with_http_info(exchange, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DefaultApi.forex_symbols ...'\n end\n # verify the required parameter 'exchange' is set\n if @api_client.config.client_side_validation && exchange.nil?\n fail ArgumentError, \"Missing the required parameter 'exchange' when calling DefaultApi.forex_symbols\"\n end\n # resource path\n local_var_path = '/forex/symbol'\n\n # query parameters\n query_params = opts[:query_params] || {}\n query_params[:'exchange'] = exchange\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:body] \n\n # return_type\n return_type = opts[:return_type] || 'Array<ForexSymbol>' \n\n # auth_names\n auth_names = opts[:auth_names] || ['api_key']\n\n new_options = opts.merge(\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: DefaultApi#forex_symbols\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def dnsimple_client\n @dnsimple_client ||= begin\n if provider = self.omni_auth_providers.where(name: \"dnsimple\").first\n Fog::DNS.new(\n provider: \"DNSimple\",\n dnsimple_email: provider.email,\n dnsimple_token: provider.access_token\n )\n end\n end\n end",
"def connection\n @connection ||= Fog::Storage.new(\n :provider => provider,\n :rackspace_username => username,\n :rackspace_api_key => api_key,\n :rackspace_auth_url => auth_url,\n :rackspace_servicenet => servicenet\n )\n end",
"def bwapi\n abort \"You have no current user set!\".yellow unless current_user_exists?\n abort \"There is no access token set for the current user\".yellow if config.current_user.access_token.nil?\n abort \"There is no environment set for the current user\".yellow if config.current_user.environment.nil?\n\n return @bwapi ||= BWAPI::Client.new(:username => current_user.username, :password => decrypt_password(current_user.username, current_user.password), :api_endpoint => api_endpoint)\n end",
"def initialize(api_key, secret, format_options={})\n @auth = { :api_key => api_key }\n @secret = secret\n end",
"def get_adwords_api\n @api ||= create_adwords_api\n end",
"def client\n @client ||= PlacesAPI.new(ENV['GOOGLE_PLACES_API_KEY'])\n end",
"def connection\n Fog::Storage.new(\n :provider => provider,\n :aws_access_key_id => access_key_id,\n :aws_secret_access_key => secret_access_key,\n :region => region\n )\n end",
"def connection\n @connection ||= Fog::Storage.new(\n :provider => provider,\n :aws_access_key_id => access_key_id,\n :aws_secret_access_key => secret_access_key,\n :region => region\n )\n end",
"def fog\n $fog || Fog::Storage.new(\n :provider => 'Local',\n :local_root => Pusher.server_path\n )\nend",
"def connection(uri:, params:)\n Faraday.new(\n url: \"#{@endpoint}/#{@api_version}/#{uri}\",\n params: params,\n headers: {\n 'User-Agent' => \"RubyGem-zombie_battleground-api_#{VERSION}\",\n 'Content-Type' => 'application/json'\n }\n )\n end",
"def get_fog_storage\n return Fog::Storage.new( :provider => 'AWS',\n :aws_access_key_id => CONFIG[:aws_access_key_id], \n :aws_secret_access_key => CONFIG[:aws_access_key],\n :region => \"us-east-1\" )\n end",
"def apis; end",
"def connection\n @connection ||= RestClient::Resource.new(api_uri.to_s)\n end"
] | [
"0.7682961",
"0.7682961",
"0.70419866",
"0.6563051",
"0.65245533",
"0.62355727",
"0.6215915",
"0.61968285",
"0.61906075",
"0.61714756",
"0.61533237",
"0.6092402",
"0.6088986",
"0.6083813",
"0.5923803",
"0.5913553",
"0.5913553",
"0.58943206",
"0.5889345",
"0.5871025",
"0.5848335",
"0.5847226",
"0.5836743",
"0.583186",
"0.5822423",
"0.5816465",
"0.5784953",
"0.575959",
"0.57588744",
"0.5758279",
"0.5742495",
"0.57271194",
"0.56984556",
"0.5684274",
"0.56737494",
"0.5653541",
"0.5652912",
"0.56203055",
"0.5596685",
"0.55585456",
"0.5550389",
"0.5548536",
"0.55332893",
"0.5529035",
"0.55283874",
"0.55264956",
"0.552492",
"0.55212224",
"0.55138767",
"0.5510116",
"0.550929",
"0.5500891",
"0.54552656",
"0.5454621",
"0.5451965",
"0.5449723",
"0.5444181",
"0.5441841",
"0.54407066",
"0.5439439",
"0.5438028",
"0.543446",
"0.5426118",
"0.5414876",
"0.54143554",
"0.5411802",
"0.54112595",
"0.53908235",
"0.53839827",
"0.53813547",
"0.53802806",
"0.53768045",
"0.5369748",
"0.5364583",
"0.53504497",
"0.5349663",
"0.5347776",
"0.5343184",
"0.5338945",
"0.5338549",
"0.5331792",
"0.5324674",
"0.53106064",
"0.5310394",
"0.53102386",
"0.5309944",
"0.53072244",
"0.53053296",
"0.5299075",
"0.5294204",
"0.52898914",
"0.52882624",
"0.52867556",
"0.5282077",
"0.52820015",
"0.527949",
"0.5279261",
"0.5272184",
"0.5269629",
"0.52682537"
] | 0.77630323 | 0 |
Private: Updates Fogbugz Case in Fogbugz Returns updated case | def update_case
api.command :edit, to_case_hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_case(id, *args)\n options = args.last.is_a?(Hash) ? args.pop : {}\n response = put(\"cases/#{id}\",options)\n response.case\n end",
"def create_or_update_case(feature, parent_case = nil)\n old_attachments = []\n\n parameters = {\n sTitle: feature.name,\n sEvent: html_to_plain(feature.description.body),\n ixProject: data.projects\n }\n\n parameters[:sTags] = feature.tags.join(\",\") if feature.tags\n parameters[:ixBugParent] = parent_case if parent_case\n\n\n if found_fogbugz_case = fetch_case_from_feature(feature)\n parameters = set_edit_parameters(found_fogbugz_case, parameters)\n old_attachments = has_attachments(found_fogbugz_case)\n end\n\n attachments = feature.description.attachments.map do |attachment|\n {:filename => attachment.file_name, :file_url => attachment.download_url} if !old_attachments.include?(attachment.file_name) && attachment.download_url\n end.compact\n\n if found_fogbugz_case\n fogbugz_case = fogbugz_case_resource.edit_case(parameters, attachments)\n else\n fogbugz_case = fogbugz_case_resource.new_case(parameters, attachments)\n end\n\n integrate_resource_with_case(feature, fogbugz_case)\n\n if feature.requirements\n feature.requirements.each do |requirement|\n create_or_update_case(requirement, fogbugz_case.ixBug)\n end\n end\n\n fogbugz_case\n end",
"def update\n respond_to do |format|\n if @vf_case.update(vf_case_params)\n format.html { redirect_to @vf_case, notice: 'Vf case was successfully updated.' }\n format.json { render :show, status: :ok, location: @vf_case }\n else\n format.html { render :edit }\n format.json { render json: @vf_case.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @case.update(case_params)\n format.html { redirect_to @case, notice: 'Case was successfully updated.' }\n format.json { render :show, status: :ok, location: @case }\n else\n format.html { render :edit }\n format.json { render json: @case.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @case.update(case_params)\n format.html { redirect_to @case, notice: 'Case was successfully updated.' }\n format.json { render :show, status: :ok, location: @case }\n else\n format.html { render :edit }\n format.json { render json: @case.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @case.update(case_params)\n format.html { redirect_to cases_path, notice: 'Case was successfully updated.' }\n format.json { render :show, status: :ok, location: @case }\n else\n format.html { render :edit }\n format.json { render json: @case.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @case.update(case_params)\n format.html { redirect_to back_url, notice: 'Case was successfully updated.' }\n format.json { render :show, status: :ok, location: @case }\n else\n format.html { render :edit }\n format.json { render json: @case.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @case.update(case_params)\n format.html { redirect_to cases_path, notice: 'Case was successfully updated.' }\n format.json { render action: 'index' }\n else\n format.html { render action: 'edit' }\n format.json { render json: @case.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_case\n if params[:action] == \"update\" \n @case = Case.find(params[:format])\n else\n @case = Case.find(params[:id])\n end\n end",
"def update\n h = sf_case_params.to_h\n h[:Id] = params[:id]\n @sf_case = SFCase.update(h.symbolize_keys)\n\n respond_to do |format|\n if @sf_case.sf_valid?\n set_success_flash_message(\"Case was successfully updated.\")\n format.html { redirect_to sf_case_path(h[\"Id\"])}\n format.json { render :show, status: :ok, location: @sf_case }\n else\n set_flash_error_message\n format.html { redirect_to edit_sf_case_path(@sf_case.Id) }\n format.json { render json: @sf_case.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t\tsurgery_case = current_user.cases.where( id: params[:id] )[0]\n\t\tif surgery_case.present?\n\t\t\tsurgery_case.update_attributes(case_params)\n\t\t\t# Updating the patient to the particular case\n\t\t\tsurgery_case.update_attributes(patient_id: params[:patient_id])\n \t\t# response to the JSON\n\t\t\trender json: { success: true,message: \"Case Successfully Updated.\", response: surgery_case.as_json(\"case_show\") },:status=>200\n\t else\n\t render :json=> { success: false, message: \"Case is not available\" },:status=> 404\n\t end\n\tend",
"def update\n @case = Case.find(params[:id])\n \n\t\n respond_to do |format|\n if @case.update_attributes(params[:case])\n\t \n format.js \n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @case.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @task = Task.find(params[:id])\n case\n when params[:key] then close_case(params)\n when params[:upgrade] then upgrade_case(params)\n else\n pending_case(params)\n end\n #if( params[:key])\n # @task.finished_time=Time.now\n # @task.it_case.closer=@current_user.id\n # @task.it_case.status=ItCase::STATUSES['已完成']\n #else\n # @task.it_case.status=ItCase::STATUSES['处理中']\n #end\n\n #respond_to do |format|\n # if @task.it_case.update_attributes(params[:it_case])\n # format.html { redirect_to '/mytasks', notice: 'Task was successfully updated.' }\n\n #else\n # format.html { render action: \"mytasks/check_case\" }\n\n #end\n #end\n end",
"def update\n if @case.update(case_params)\n redirect_to \"/#{@case.case_type}\"\n else\n render :edit\n end\n end",
"def user_updated_case _user, the_case\n data = {\n category: 'Cases',\n action: 'Updated a Case',\n label: the_case.case_name,\n value: nil,\n bounce: false,\n }\n\n create_event data\n end",
"def update\n # updating hard info\n hard_info = HardInfo.where(use_case_no: @use_case.use_case_no, client_name: @use_case.client_name, product_name: @use_case.product_name)\n hard_info.first.update(use_case_params.except(\n :division,\n :sc_tel,\n :project_no,\n :industry,\n :service_product,\n :customer_count,\n :vendor_count,\n :product_count,\n :vehicle_count,\n :driver_count,\n :sc_name,\n :memo,\n :use_case_code\n )\n )\n #--\n respond_to do |format|\n if @use_case.update(use_case_params)\n format.html { redirect_to @use_case }\n format.json { render :show, status: :ok, location: @use_case }\n else\n format.html { render :edit }\n format.json { render json: @use_case.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @case = Case.find(params[:id])\n\n if current_user.district_id and !current_user.admin?\n @districts = District.where(\"id = #{current_user.district_id}\")\n @phis = Phi.where(\"district_id = #{current_user.district_id}\")\n else\n @districts = District.all\n @phis = Phi.all\n @centers = Center.all\n end\n @centers = (@phis.count == 1)? Center.where(\"phi_id = #{@phis.first.id}\") : Center.all\n @hes = He.where(:center_id => @centers.map { |id| id })\n\n @laboratories = Laboratory.all\n @agents = Agent.all\n @doctors = User.find_all_by_user_type(1)\n @nurses = User.find_all_by_user_type(2)\n\n @municipalities = Municipality.all\n @icds = Icd.all\n\n respond_to do |format|\n if @case.update_attributes(params[:case])\n format.html { redirect_to @case, notice: t(\"record_updated\") }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @case.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @support_case.update(support_case_params)\n format.html { redirect_to @support_case, notice: 'Support case was successfully updated.' }\n format.json { render :show, status: :ok, location: @support_case }\n else\n format.html { render :edit }\n format.json { render json: @support_case.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_case\n @case = Case.find(params[:case_id])\n end",
"def update\n @quote = Quote.find(params[:quote_id])\n @use_case = UseCase.find(params[:id])\n\n respond_to do |format|\n if @use_case.update_attributes(params[:use_case])\n format.html { redirect_to @quote , notice: 'Use case was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @use_case.errors, status: :unprocessable_entity }\n end\n realizarCostos\n end\n end",
"def update\n respond_to do |format|\n if @case_request.update(case_request_params)\n Case.create(case_title: @case_request.title, case_content: @case_request.content)\n \n @case_request.user.messages.create(content: \"The \" + @case_request.title + \" case is now available at Cases Section.\", is_lea_response: true)\n \n @case_request.destroy\n format.html { redirect_to @case_request, notice: 'Case request was successfully updated.' }\n format.json { render :show, status: :ok, location: @case_request }\n else\n format.html { render :edit }\n format.json { render json: @case_request.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @answer_case.update(answer_case_params)\n format.html { redirect_to @answer_case, notice: 'Answer case was successfully updated.' }\n format.json { render :show, status: :ok, location: @answer_case }\n else\n format.html { render :edit }\n format.json { render json: @answer_case.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @yfcase.update(yfcase_params)\n format.html { redirect_to @yfcase, notice: 'Yfcase was successfully updated.' }\n format.json { render :show, status: :ok, location: @yfcase }\n else\n format.html { render :edit }\n format.json { render json: @yfcase.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_case\n @case = Case.find(params[:id])\n end",
"def set_case\n @case = Case.find(params[:id])\n end",
"def set_case\n @case = Case.find(params[:id])\n end",
"def set_case\n @case = Case.find(params[:id])\n end",
"def set_case\n @case = Case.find(params[:id])\n end",
"def set_case\n @case = Case.find(params[:id])\n end",
"def set_case\n @case = Case.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @code_case.update(code_case_params)\n format.html { redirect_to design_cases_path, notice: 'Code case was successfully updated.' }\n format.json { render :show, status: :ok, location: @code_case }\n else\n format.html { render :edit }\n format.json { render json: @code_case.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @help_case.update(help_case_params)\n format.html { redirect_to @help_case, notice: 'Help case was successfully updated.' }\n format.json { render :show, status: :ok, location: @help_case }\n else\n format.html { render :edit }\n format.json { render json: @help_case.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @casefile.update(casefile_params)\n format.html { redirect_to @casefile, notice: 'Casefile was successfully updated.' }\n format.json { render :show, status: :ok, location: @casefile }\n else\n format.html { render :edit }\n format.json { render json: @casefile.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @it_case = ItCase.find(params[:id])\n\n respond_to do |format|\n if @it_case.update_attributes(params[:it_case])\n format.html { redirect_to mycases_path, notice: '已完成评价' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @it_case.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @use_case = UseCase.find(params[:id])\n @use_case.data = params[:data].to_json\n\n respond_to do |format|\n if @use_case.update_attributes(params[:use_case])\n\n if params[:subaction]==\"step\"\n format.html { redirect_to requirements_project_use_case_path(@use_case.project, @use_case, :type=>\"step\"), notice: 'Use case was successfully updated.' }\n else\n format.html { redirect_to project_use_case_path(@project, @use_case), notice: 'Use case was successfully updated.' }\n end\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @use_case.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @case_doc.update(case_doc_params)\n format.html { redirect_to @case_doc, notice: 'Case doc was successfully updated.' }\n format.json { render :show, status: :ok, location: @case_doc }\n else\n format.html { render :edit }\n format.json { render json: @case_doc.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_vf_case\n @vf_case = VfCase.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @line_case.update(line_case_params)\n format.html { redirect_to @line_case, notice: 'Line case was successfully updated.' }\n format.json { render :show, status: :ok, location: @line_case }\n else\n format.html { render :edit }\n format.json { render json: @line_case.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @clientcase = Clientcase.find(params[:id])\n\n respond_to do |format|\n if @clientcase.update_attributes(params[:clientcase])\n format.html { redirect_to @clientcase, :notice => 'Clientcase was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @clientcase.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @case_support.update(case_support_params)\n format.html { redirect_to @case_support, notice: 'Case support was successfully updated.' }\n format.json { render :show, status: :ok, location: @case_support }\n else\n format.html { render :edit }\n format.json { render json: @case_support.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @application_case.update(application_case_params)\n format.html { redirect_to @application_case, notice: 'Application case was successfully updated.' }\n format.json { render :show, status: :ok, location: @application_case }\n else\n format.html { render :edit }\n format.json { render json: @application_case.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @case_type.update(case_type_params)\n format.html { redirect_to @case_type, notice: 'Case type was successfully updated.' }\n format.json { render :show, status: :ok, location: @case_type }\n else\n format.html { render :edit }\n format.json { render json: @case_type.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @casedeal.update(casedeal_params)\n format.html { redirect_to casedeals_url, notice: 'Casedeal was successfully updated.' }\n format.json { render :show, status: :ok, location: @casedeal }\n else\n format.html { render :edit }\n format.json { render json: @casedeal.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @health_case.update(health_case_params)\n format.html { redirect_to @health_case, notice: 'Health case was successfully updated.' }\n format.json { render :show, status: :ok, location: @health_case }\n else\n format.html { render :edit }\n format.json { render json: @health_case.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @case_support.update(case_support_params)\n format.html { redirect_to back_index_case_url, notice: 'Case support was successfully updated.' }\n # format.json { render :show, status: :ok, location: @case_support }\n else\n format.html { render :edit }\n format.json { render json: @case_support.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n \n end",
"def reopen_case\n # Update USer kyc detail\n @user_kyc_detail.admin_status = GlobalConstant::UserKycDetail.unprocessed_admin_status\n @user_kyc_detail.aml_status = GlobalConstant::UserKycDetail.pending_aml_status if @user_kyc_detail.aml_status !=\n GlobalConstant::UserKycDetail.unprocessed_aml_status\n\n @user_kyc_detail.aml_user_id = nil\n @user_kyc_detail.whitelist_status = GlobalConstant::UserKycDetail.unprocessed_whitelist_status\n @user_kyc_detail.kyc_confirmed_at = nil\n @user_kyc_detail.last_acted_by = @edit_kyc_request.admin_id\n @user_kyc_detail.last_acted_timestamp = Time.now.to_i\n @user_kyc_detail.last_reopened_at = Time.now.to_i\n @user_kyc_detail.save!\n\n update_edit_kyc_row(GlobalConstant::EditKycRequest.processed_status)\n end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update; end",
"def update\n @use_case = UseCase.find(params[:id])\n\n respond_to do |format|\n if @use_case.update_attributes(params[:use_case])\n\n if params[:use_case].has_key?(:file) && params[:use_case][:file]\n @use_case.upload_main_asset(params[:use_case][:file])\n elsif params.has_key?(:file) && params[:file]\n @use_case.upload_main_asset(params[:file])\n end\n \n format.html { redirect_to @use_case, notice: 'Use case was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @use_case.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @success_case = SuccessCase.find(params[:id])\n\n respond_to do |format|\n if @success_case.update_attributes(params[:success_case])\n format.html { redirect_to(@success_case, :notice => 'Success case was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @success_case.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update ; end",
"def update\n @case_data = Case.find(params[:format])\n if params[:file].nil?\n @case_data.update_attributes(case_params)\n else \n @multi_edit_file = params[:file]\n @case_data.filename = @multi_edit_file.original_filename\n @case_data.content_type = @multi_edit_file.content_type\n @case_data.file_contents = @multi_edit_file.read\n @case_data.update_attributes(case_params)\n end\n redirect_to cases_path\n end",
"def update\n respond_to do |format|\n if @case_contact.update(case_contact_params)\n format.html { redirect_to @case_contact, notice: 'Case contact was successfully updated.' }\n format.json { render :show, status: :ok, location: @case_contact }\n else\n format.html { render :edit }\n format.json { render json: @case_contact.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_yfcase\n @yfcase = current_user.yfcases.find(params[:id])\n end",
"def set_case\n case_id = params[:case_id]\n is_encrypted_case_id = !Float(case_id, exception: false)\n\n @case = if is_encrypted_case_id\n Case.public_cases.find_by(id: decrypt_case_id(case_id))\n elsif current_user\n current_user.cases_involved_with.where(id: case_id).first\n else\n Case.public_cases.find_by(id: case_id)\n end\n end",
"def update\r\n\r\n end",
"def update\n \n end",
"def set_sf_case\n @sf_case = SFCase.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @design_case.update(design_case_params)\n format.html { redirect_to @design_case, notice: 'Design case was successfully updated.' }\n format.json { render :show, status: :ok, location: @design_case }\n else\n format.html { render :edit }\n format.json { render json: @design_case.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update() end",
"def update\n respond_to do |format|\n if @computer_case.update(computer_case_params)\n format.html { redirect_to @computer_case, notice: 'Computer case was successfully updated.' }\n format.json { render :show, status: :ok, location: @computer_case }\n else\n format.html { render :edit }\n format.json { render json: @computer_case.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @support_case = SupportCase.find(params[:id])\n support_case_changed = @support_case\n\n if(params[:support_case][:employee_id]!=nil)\n @support_case.employee = Employee.find(params[:support_case][:employee_id])\n else\n @support_case.employee = nil\n end\n\n support_case_changed.attributes =params[:support_case]\n\n createEvents(support_case_changed)\n\n respond_to do |format|\n if (@support_case.update_attributes(params[:support_case]))\n format.html { redirect_to @support_case, notice: 'Support case was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @support_case.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @test_case = TestCase.find(params[:id])\n\n respond_to do |format|\n if @test_case.update_attributes(params[:test_case])\n format.html { redirect_to(@test_case, :notice => 'TestCase was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @test_case.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n\n if get_case\n @task = @case.tasks.create(task_params)\n path_tasks = case_tasks_path\n else\n path_tasks = tasks_path\n end\n respond_to do |format|\n if @task.update(task_params)\n track_activity @task\n format.html { redirect_to path_tasks, notice: 'Task successfully updated.' }\n format.json { render :show, status: :ok, location: @task }\n else\n format.html { render :edit }\n format.json { render json: @task.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_plan(plan_id,run_id,case_ids)\n test_plan = testrail_api_client.send_get(\"get_plan/#{plan_id}\")\n entry_id = test_plan['entries'].detect{|e| e['runs'].any?{|r| r['id']==run_id}}['id']\n testrail_api_client.send_post(\"update_plan_entry/#{plan_id}/#{entry_id}\",case_ids)\n end",
"def update\n params.permit!\n @security_case = SecurityCase.find(params[:id])\n\n respond_to do |format|\n if @security_case.update_attributes(params[:security_case])\n format.html { redirect_to(@security_case, :notice => 'Security case was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @security_case.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n return false unless authorize(permissions = [\"update_casefile\"])\n\n @case_file = CaseFile.find(params[:id])\n\n respond_to do |format|\n if @case_file.update_attributes(params[:case_file])\n flash.now[:notice] = t(\"case_file.messages.update_success\")\n format.html { redirect_to patient_case_file_path(:patient_id => params[:patient_id], :id => params[:id]) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @case_file.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @casecategory.update(casecategory_params)\n format.html { redirect_to @casecategory, notice: \"Casecategory was successfully updated.\" }\n format.json { render :show, status: :ok, location: @casecategory }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @casecategory.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @case_test.update(case_test_params)\n format.html { redirect_to @case_test, notice: 'Case test was successfully updated.' }\n format.json { render :show, status: :ok, location: @case_test }\n else\n format.html { render :edit }\n format.json { render json: @case_test.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t\t\n\t\tend",
"def fogbugz_to_aha_category(fogbugz_case)\n status = meta_data.statuses[fogbugz_case.ixStatus]\n if status.nil?\n raise ConfigurationError, \"Unhandled Fogbugz status: '#{fogbugz_case.ixStatus}', use the 'Test connection' button to update the configuration\"\n end\n if status.fWorkDone == \"false\" && status.fResolved == \"false\"\n \"in_progress\"\n elsif status.fWorkDone == \"true\" && status.fResolved == \"true\" && fogbugz_case.fOpen == \"false\"\n \"shipped\"\n elsif status.fWorkDone == \"true\" && status.fResolved == \"true\"\n \"done\"\n elsif status.fWorkDone == \"false\" && status.fResolved == \"true\"\n \"will_not_do\"\n else\n raise ConfigurationError, \"Unhandled Fogbugz status: '#{status.sStatus} - #{status.ixStatus}', use the 'Test connection' button to update the configuration\"\n end\n end",
"def update_test_cases\n unless test_case_ids.nil?\n self.plan_cases.each do |p|\n p.destroy unless test_case_ids.include?(p.test_case_id.to_s)\n test_case_ids.delete(p.test_case_id.to_s)\n end \n test_case_ids.each do |c|\n self.plan_cases.create(:test_case_id => c) unless c.blank?\n end\n reload\n self.test_case_ids = nil\n end\n end",
"def update\n @test_case_entry = TestCaseEntry.find(params[:id])\n\n respond_to do |format|\n if @test_case_entry.update_attributes(params[:test_case_entry])\n format.html { redirect_to(@test_case_entry, :notice => 'Test case entry was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @test_case_entry.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def set_case\n @case = Announcement.find(params[:id])\n end",
"def update\r\n # write some gangsta code here\r\n end",
"def update\n\n end",
"def update\n respond_to do |format|\n if @case.update(case_params)\n params[:case_attachments]['photo'].each do |a|\n @case_attachment = @case.case_attachments.create!(:photo => a, :case_id => @case.id)\n end\n format.html { redirect_to admin_cases_path, notice: \"Caso Clínico (#{@case.title}), alterado com sucesso!\" }\n format.json { render :show, status: :ok, location: [:admin, @case] }\n else\n format.html { render :edit }\n format.json { render json: @case.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update;end",
"def test_update\n\n admin_session = cathy_admin_session\n \n ibm = fab_houses(:ibm)\n fab_house = FabHouse.find(ibm.id)\n fab_house.name = 'new_fab_house'\n\n post(:update, { :fab_house => fab_house.attributes }, admin_session)\n assert_redirected_to(:action => 'edit', :id => fab_house.id)\n assert_equal('Update recorded', flash['notice'])\n assert_equal('new_fab_house', fab_house.name)\n \n post(:update, \n { :fab_house => { :name => fab_house.name, \n :id => fab_house.id.to_s, \n :active => fab_house.active.to_s } }, \n cathy_admin_session)\n assert_redirected_to(:action => 'edit', :id => fab_house.id)\n #assert_equal('Update recorded', flash['notice'])\n \n end",
"def update\r\n end",
"def set_casefile\n @casefile = Casefile.find(params[:id])\n end",
"def update\r\n end",
"def update\r\n end",
"def update\r\n end",
"def update\r\n end",
"def set_case_doc\n @case_doc = CaseDoc.find(params[:id])\n end",
"def update\n @project = Project.find(params[:id])\n @caseTabela= CaseTabela.find_or_create_by_case_id_and_tabela_id(\n :case_id => params[:case_id], \n :tabela_id => params[:tabela_id]\n )\n params[:case_tabela][:lock_version] = params[:lock_version]\n \n respond_to do |format|\n if @caseTabela.update_attributes(params[:case_tabela])\n format.html { redirect_to @caseTabela, notice: 'Project was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @caseTabela.errors, status: :unprocessable_entity }\n end\n end\n rescue ActiveRecord::StaleObjectError\n respond_to do |format|\n h = { :status => \"error\", :message => \"ERROR: Controle de concorrencia <br> \n Alguem antes de voce ja atualizou esse registro! <br> \n O Registro que voce tentou salvar era absoleto.\" }\n format.json { render :json => h, :status => :forbidden }\n end \n end",
"def update_intest\n @context = 1\n update_submission\n end",
"def set_requests\n @case = Case.find(params[:case_id])\n end",
"def update\n \n end",
"def update\n \n end",
"def update\n \n end",
"def update\n \n end"
] | [
"0.7139557",
"0.6857494",
"0.67728275",
"0.66847235",
"0.66847235",
"0.6637263",
"0.66363126",
"0.6605919",
"0.65485656",
"0.6347041",
"0.6343665",
"0.63300556",
"0.63281345",
"0.6291381",
"0.6260999",
"0.62322074",
"0.61884075",
"0.6182646",
"0.61819303",
"0.61790425",
"0.6171862",
"0.616829",
"0.61625314",
"0.61421096",
"0.61421096",
"0.61421096",
"0.61421096",
"0.61421096",
"0.61421096",
"0.6141416",
"0.612236",
"0.6106393",
"0.60786057",
"0.6074911",
"0.60691684",
"0.60217136",
"0.60075897",
"0.5993905",
"0.59756124",
"0.5925378",
"0.59186745",
"0.58868915",
"0.586964",
"0.58634055",
"0.58374435",
"0.58019626",
"0.5801483",
"0.5789228",
"0.5789228",
"0.5789228",
"0.5789228",
"0.5789228",
"0.5789228",
"0.5789228",
"0.5789228",
"0.5787537",
"0.5785861",
"0.578553",
"0.57818",
"0.5777178",
"0.5772839",
"0.5768597",
"0.5765357",
"0.57641757",
"0.5762133",
"0.57589895",
"0.5755815",
"0.5740794",
"0.5716871",
"0.5713164",
"0.57084155",
"0.57009697",
"0.56793576",
"0.56686866",
"0.5666934",
"0.5657531",
"0.56429464",
"0.5642268",
"0.56392705",
"0.5631077",
"0.5624839",
"0.55862856",
"0.5571295",
"0.55333394",
"0.5531828",
"0.5530089",
"0.5529325",
"0.5526222",
"0.5513642",
"0.5513642",
"0.5513642",
"0.5513642",
"0.55134976",
"0.55131817",
"0.55086744",
"0.5508458",
"0.5506721",
"0.5506721",
"0.5506721",
"0.5506721"
] | 0.7373121 | 0 |
Private: Converts Ticket to Fogbugz Case for use when updating Case via API Returns a hash | def to_case_hash
{
:ixBug => id,
:sTitle => title
}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transform_ticket(ticket)\n fields = []\n fields << ticket['id']\n fields << ticket['status']\n fields << ticket['subject']\n fields << get_component(ticket['custom_fields'])\n fields << clean_text(ticket['description'], 5)\n fields << get_user_name(ticket['requester_id'])\n created = Date.parse(ticket['created_at'])\n updated = Date.parse(ticket['updated_at'])\n fields << created.to_s\n fields << updated.to_s\n fields << (updated - created).to_i\n fields << jira_escalated?(ticket['tags'])\n end",
"def ticket(auth_options = {})\n auth = RbSSO::Authentication.new auth_options\n ticket = RbSSO::Ticket.sign auth, key\n return ticket.to_base64\n end",
"def create_intervention_ticket\n client = ZendeskAPI::Client.new do |config|\n config.url = ENV['ZENDESK_URL']\n config.username = ENV['ZENDESK_USERNAME']\n config.token = ENV['ZENDESK_TOKEN']\n end\n \n ZendeskAPI::Ticket.create!(client, \n :subject => \"Building: #{@intervention.building_id} requires intervention\", \n :comment => { \n :value => \n \"The Requester: #{Employee.find(@intervention.author_id).first_name+''+Employee.find(@intervention.author_id).last_name }\n The Customer (Company Name): #{@intervention.customer.company_name}\\n\n Building ID: #{@intervention.building_id}\\n\n Battery ID: #{params[:battery]}\\n\n Column ID: #{if (params[:column] == \"None\") then \"\" else params[:column] end} \n Elevators ID: #{if (params[:elevator] == \"None\" ) then \"\" else params[:elevator] end}\n #{if (@intervention.employee_id) then \"The employee to be assigned to the task: #{@intervention.employee.first_name} #{@intervention.employee.last_name}\" end}\n \n Description:#{@intervention.report}\"\n }, \n :requester => { \n \"name\": Employee.find(@intervention.author_id).first_name+''+Employee.find(@intervention.author_id).last_name \n },\n \n :type => \"problem\",\n :priority => \"normal\"\n )\n end",
"def get_ticket(ticket_id:)\n ZendeskAPI::Ticket.find(client, id: ticket_id)\n end",
"def ticket\n @ticket ||= @api.get_ticket['ticket']\n end",
"def create_intervention_ticket\n #Call zendesk API create new client method\n client = ZendeskAPI::Client.new do |config|\n #Get config parameters from application.yml \n #These parameters are ignored by git \n config.url = ENV['ZENDESK_URL']\n config.username = ENV['ZENDESK_USERNAME']\n config.token = ENV['ZENDESK_TOKEN']\n end\n #create the ticket \n ZendeskAPI::Ticket.create!(client,\n #define subject with the current user name \n :subject => \"NEW INTERVENTION created by : \" + @currentusername.to_s ,\n #Requirements : \n # The Requester\n # The Customer (Company Name)\n # Building ID\n # The Battery ID\n # The Column ID if specified\n # Elevator ID if specified\n # The employee to be assigned to the task\n # Description of the request for intervention\n\n :comment => \"The customer ID : #{params[:customer]} \n Building ID : #{params[:building]} \n Battery ID : #{params[:battery]} \n Column ID : #{params[:column]} \n Elevator ID : #{params[:elevator]} \n Affected employee ID : #{params[:employee]} \n Description : #{params[:report]} \",\n #Set the priority \n :priority => \"urgent\",\n #Set the type \n :type => \"question\")\n end",
"def create_ticket\n jiraPair = @defect.getJiraList\n mapping = jiraAPIMapping\n payload = {\n :fields =>\n {:project =>\n {:key => \"#{jiraPair['Project']}\"},\n :summary => jiraPair['Summary'] + \" (#{@defect.get_story})\",\n :description => Sanitize.clean(jiraPair['Description']),\n mapping['Release Milestone'] => {:value => jiraPair['Release Milestone']},\n :customfield_10143 => [{:value => jiraPair['Environment'],}],\n :issuetype => {:name => jiraPair['issuetype']},\n mapping['Functional Group'] => {:value => jiraPair['Functional Group']},\n mapping['Project Manager'] => {:value => jiraPair['Project Manager']},\n :versions => [{:name => \"#{jiraPair['Release']}\",}],\n },\n }\n\n response = self.class.post('/rest/api/latest/issue/',\n :body => payload.to_json,\n :headers => {'Content-Type' => 'application/json' },\n :verify => false)\n\n url = \"\"\n if response['key']\n url = $JIRA['base_uri'] + \"/browse/\" + response['key']\n @defect.setJiraLink(url)\n else\n errormsg = \"Error (#{@defect.get_story}): #{response}\"\n p errormsg\n @defect.setDefectError(errormsg)\n end\n\n return url\n end",
"def convert_back_office_hash(body)\n @case_references = []\n @case_ref_nos = []\n ServiceClient.iterate_element(body[:application_cases]) do |cases|\n @case_references.push(cases[:case_reference])\n @case_ref_nos.push(cases[:case_refno])\n end\n end",
"def create\n @ticket = Ticket.new(params[:ticket])\n @ticket.from_email = current_user.email\n @ticket.user_id = current_user.id\n\n respond_to do |format|\n if @ticket.save\n zt = ZendeskTicket.new(@ticket.platform)\n zt.build(@ticket, request.base_url)\n zd_ticket = zt.create\n @ticket.zendesk_ticket_id = zd_ticket.id\n @ticket.save\n\n msg = 'Your ticket was successfully created'\n\n format.html { redirect_to @ticket, notice: msg}\n format.json { render json: @ticket, status: :created, location: @ticket }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n obj = JSON[request.body.read]\n @ticket = Ticket.new()\n @ticket.description = obj[\"description\"]\n @ticket.address = obj[\"address\"]\n @ticket.status = obj[\"status\"]\n @ticket.priority = obj[\"priority\"]\n @ticket.category = obj[\"category\"]\n @ticket.private = obj[\"private\"]\n @ticket.lat = obj[\"lat\"].to_f\n @ticket.lon = obj[\"lon\"].to_f\n @ticket.image = obj[\"image\"]\n if @ticket.save\n @ticket.image = nil\n render json: @ticket.to_json()\n else\n render json: @ticket.errors\n end\n end",
"def ticket number\n Geera::Ticket.new self, number\n end",
"def show_ticket_details(ticket_id)\n url = \"https://alanli1.zendesk.com/api/v2/tickets/#{ticket_id}.json\"\n\n res = ApiHelper.make_req_to_api(url)\n @ticket = find_ticket_details(res)\n @ticket.requester_name = get_user_name(@ticket.requester_id)\n return @ticket\n end",
"def create_ticket(ticket)\n if ticket.priority.nil? or ticket.project_id.nil? or ticket.summary.nil?\n raise Unfuddled::Error.new(\"Must have Priority (1..5), Project ID and Summary\")\n end\n\n begin\n url = \"/api/v1/projects/#{ticket.project_id}/tickets.json\"\n id = send(:post , url, ticket.to_h)[:body][:id]\n \n # Add the ID with to ticket\n ticket.id = id\n\n # Attach the client to the ticket\n ticket.client = self\n \n ticket\n rescue Unfuddled::HTTPErrorResponse => error\n raise error\n end\n\n end",
"def set_ticket\n @ticket = Ticket.friendly.find(params[:id])\n end",
"def create(params)\n ticket = Tessera::Otrs::Ticket.new(params[:ticket]).to_hash\n article = Tessera::Otrs::Article.new(params[:article]).to_hash\n attachment = if params[:attachment] && params[:attachment].is_a?(Hash)\n Tessera::Otrs::Attachment.new(params[:attachment]).to_hash\n elsif params[:attachment] && params[:attachment].is_a?(Array)\n params[:attachment].map do |a|\n Tessera::Otrs::Attachment.new(a).to_hash\n end\n end\n body = { Ticket: ticket }\n body = body.merge(Article: article)\n body = body.merge(Attachment: attachment) if attachment\n\n Tessera::Api::TicketCreate.call(body)\n end",
"def issue_ticket(token)\n if is_token_valid token # NOTE: we don't need a transaction here because we are just reading data. For each query done to the databse, Sequel will automatically wrap it in a transaction\n total = 0.0\n details = []\n client = Client[:token_id => token] # Easy way to retrieve a client based on its token_id\n client.orders.each { |order| # Here, we are using the one_to_many property that we used on line 71. Thanks to this, Sequel can give us an array of orders linked to the client.\n order.ordered_drinks.each { |ordered_drink| # And again, we use the one_to_many property from Order to get all the OrderedDrink values\n total += ordered_drink.qty * ordered_drink.drink.price\n details.push({:name => ordered_drink.drink.name, :qty => ordered_drink.qty}) # add to the array a new Hash. The keys are :name and :qty\n }\n }\n return {:total => total, :details => details} # return a new Hash\n else\n raise 'The provided token is not valid'\n end\nend",
"def ticketexport tid,count\n\n begin\n ticket = ZendeskAPI::Ticket.find($client, :id => tid, :include => :users)\n rescue\n puts \"The call to the Zendesk API failed for ticket #{tid}, moving on.\"\n end\n\n if ticket.nil?\n puts \"No ticket at #{tid}\"\n return\n elsif ticket.organization.nil?\n puts \"No organization on ticket #{tid}\"\n return\n elsif ticket.requester.nil?\n puts \"No requester on ticket #{tid}\"\n return\n #elsif ticket.status.to_s != \"closed\" \n # puts \"Ticket status is not closed\"\n # return\n end\n\n\n #if ticket.requester.nil?\n # return \"No requester on ticket #{tid}\"\n #else ticket.organization.nil?\n # return \"No organization on ticket #{tid}\"\n #end\n puts ticket.id\n puts ticket.to_json\n\n #puts ticket.status\n #puts ticket.url\n #puts ticket.date\n puts \"Company: #{ticket.organization.name}\"\n puts \"Requester: #{ticket.requester.name}\"\n puts \"Requester Email: #{ticket.requester.email}\"\n puts \"Requester Alias: #{ticket.requester.alias}\"\n #puts ticket.subject\n #puts ticket.description\n\n ctime = Time.parse(\"#{ticket.created_at}\")\n cdate = ctime.in_timezone 'America/Chicago'\n cwtime = ctime.strftime(\"%m/%d/%Y\")\n\n #puts cdate\n begin\n audits = ticket.audits.each\n rescue\n puts \"Collecting audits failed, trying again in 30 seconds.\"\n sleep 30\n audits = ticket.audits.each\n end\n # puts audits.to_json\n # This is a UNC PATH where we will put all of the files\n # On a Windows server.\n # This is NOT ideal, but is a side effect of using a janky import process.\n # It works, but it's a dirty hack.\n path = '\\\\\\\\share.somedomain.com\\cw\\\\'\n\n $pubc = \"\\n\\n################################\\n\\nThese were Zendesk Public Comments.\\n\\n\"\n $pubc << \"Zendesk Ticket URL: https://zen.somedomain.com/tickets/#{ticket.id}\\n\\n\"\n $privc = \"\\n\\n################################\\n\\nThese Were Zendesk Private Comments.\\n\\n\"\n # $pubc << \"Full text: #{path}#{ticket.id}\\\\FullThread.txt\\n\\n\"\n \n\n\n audits.each do |i|\n \n t = Time.parse(\"#{i.created_at}\")\n $localtime = t.in_timezone 'America/Chicago'\n $endtime = t.strftime(\"%m/%d/%Y\")\n i.events.each do |e|\n #if e.body =~ /Ticket \\{\\{ticket\\.id\\}\\}/\n #puts e.attachments\n if e.attachments\n if ! File.directory?(\"./cw/#{ticket.id}\")\n dir = Dir.mkdir(\"./cw/#{ticket.id}\")\n #dir = Dir.mkdir(\"./cw/#{ticket.id}/msgs\")\n end\n e.attachments.each do |att|\n begin\n afile = att.file_name.gsub(/\\//, '-')\n afile = afile.gsub(/^\\./, '')\n puts afile\n $pubc << \"\\n\\nAttachment: #{path}#{ticket.id}\\\\#{afile}\\n\\n\"\n # File.write(\"./cw/#{ticket.id}/#{att.file_name}\", Net::HTTP.get(URI.parse(\"#{att.content_url}\"))) \n File.write(\"./cw/#{ticket.id}/#{afile}\", fetchData(\"#{att.content_url}\"))\n rescue\n puts \"There was a problem writing the attachment #{afile}\"\n end\n end\n end \n if e.type.to_s == \"Comment\"\n if e.public.to_s == 'false'\n # puts \"This is a \" + ( e.public.to_s == 'false' ? \"PRIVATE comment.\\n\" : \"PUBLIC comment.\\n\" )\n $privc << \"\\n\\n################################\\n\\n\"\n $privc << \"At #{$localtime}, #{i.author.email} said:\\n\\n\" rescue \"There was an error here\"\n #out = e.body[0..30000]\n $privc << e.body\n #if e.attachments\n else\n # puts \"This is a \" + ( e.public.to_s == 'false' ? \"PRIVATE comment.\\n\" : \"PUBLIC comment.\\n\" )\n $pubc << \"\\n\\n################################\\n\\n\"\n $pubc << \"At #{$localtime}, #{i.author.email} said:\\n\\n\" rescue \"There was an error here\"\n #out = e.body[0..30000]\n $pubc << e.body\n $pubc + \"\\n\\n\"\n \n end\n\n else\n next\n end\n end \n end\n\n $pubc << ticket.description\n # Per connectwise, we have to strip out the pipes from the descriptions\n $privc.gsub!('|','*pipe character was removed here*')\n #puts $privc\n\n $pubc.gsub!('|', '*pipe character was removed here*')\n #puts $pubc\n\n #puts $privc\n #puts $pubc\n\n #fulltext = FILE.open(\"./cw/#{ticket.id}/FullThread.txt\", \"w\") do |ffile|\n # ffile << $privc\n # ffile <<pubc\n #end\n\n headers = %w{SrBoard CompanyName ContactName SrStatus SrType SrSubType SrItem SrSource SrLocation SrPriority Summary DetailDescription InternalAnalysis Resolution AssignedBy DateEntered DateCompleted ConfigName ResourceMember}\n\n output = [{\n 'SrBoard' => \"Service Desk\",\n 'CompanyName' => \"#{ticket.organization.name}\",\n 'ContactName' => \"#{ticket.requester.alias}\",\n 'SrStatus' => \"Closed\",\n 'SrType' => \"\",\n 'SrSubType' => \"\",\n 'SrItem' => \"\",\n 'SrSource' => \"Zendesk\",\n 'SrLocation' => \"Remote\",\n 'SrPriority' => \"Priority 5 - No SLA\",\n 'Summary' => \"#{ticket.subject}\",\n 'DetailDescription' => \"#{$pubc}\",\n 'InternalAnalysis' => \"#{$privc}\",\n 'Resolution' => \"\",\n 'AssignedBy' => \"zadmin\",\n 'DateEntered' => \"#{cwtime}\",\n 'DateCompleted' => \"#{$endtime}\",\n 'ConfigName' => \"\",\n 'ResourceMember' => \"\"\n }]\n\n cols = output.first.keys\n excsv cols,output,count,tid\nend",
"def save_edited_ticket_entry\n @raw_date = params[:delivery_date]\n \n @day = @raw_date[3..4]\n @month = @raw_date[0..1]\n @year = @raw_date[6..9]\n \n @delivery_date = \"#{@year}-#{@month}-#{@day}\"\n \n @ticket = Ticket.find(params[:id])\n @ticket.number = params[:ticket_number]\n @ticket.delivery_date = @delivery_date\n @ticket.job_id = params[:job_id]\n @ticket.destination_id = params[:destination_id]\n @ticket.wood_type = params[:wood_type_id]\n \n #Because the tickets value (load pay) comes in as string in currency format\n # some parts have to be stripped off to be able to turn it into float correctly\n @value = params[:load_pay].to_s\n 3.times do\n @value.sub!(\",\", \"\")\n end\n @value = @value.to_f\n \n @ticket.value = @value\n \n @ticket.load_details.each_with_index do |i, x|\n i.species_id = params[:specieses][x]\n i.tonnage = params[:tonnages][x]\n i.mbfs = params[:mbfs][x]\n \n unless i.save\n render :status => 306, :nothing => true\n return\n end\n end\n \n unless @ticket.save\n render :status => 306, :nothing => true\n else\n render :status => 200, :nothing => true\n end\n end",
"def defect_to_hash(input)\n Hash[ input[\"Fields\"][\"Field\"].\n map{ |x| [nice_name[x[\"Name\"]],x[\"Value\"]] }.\n reject{ |x,y| y.empty? or y == \"None\" }\n ]\n end",
"def submit_ticket(ticket)\n @ticket = ticket\n\n mail :to => \"[email protected]\", \n :subject => \"Ticket: \" + ticket.id.to_s,\n :reply_to => \"[email protected]\"\n end",
"def save_ticket(ticket)\n stmt = \"INSERT INTO #{@@tickets_table} values(#{ticket.id}, '#{ticket.requester.to_json}', '#{ticket.status}', '#{ticket.subject}', '#{ticket.content}', '#{ticket.created_at}', '#{ticket.updated_at}', '#{ticket.comment}')\"\n execute_statement(stmt)\n end",
"def create\r\n p intervention_params\r\n @intervention = Intervention.new(intervention_params)\r\n\r\n @intervention.status = \"Pending\"\r\n\r\n @intervention.author_id = session[:author_id]\r\n @the_author = Employee.find(session[:author_id])\r\n @the_employee = User.find(params[:employee_id])\r\n\r\n \r\n # @intervention. = params[:current_employee]\r\n logger.info(intervention_params)\r\n\r\n# --------------------------------- ZENDESK ----------------------------------\r\n# --------------------------------- ZENDESK ----------------------------------\r\nputs \"this is the employee id #{params[:employee_id]}\"\r\n\r\n\r\nZendeskAPI::Ticket.create!($client,\r\n :priority => \"low\",\r\n :subject => \"#{@intervention.author_id} from #{@the_employee.first_name}\",\r\n\r\n\r\n :comment => { :body => \"The Author is : #{@the_author.first_name} \r\nclient is : #{@intervention.customer.company_name}\r\ncustomer ID is : #{@intervention.customer_id}\r\nbuilding ID is : #{@intervention.building_id} \r\nBattery ID is : #{@intervention.battery_id} \r\nColumn ID is : #{@intervention.column_id} \r\nElevator ID (if specified) is : #{@intervention.elevator_id} \r\nEmployee (if specified) is : #{@the_employee.first_name}\r\nDescription of report : #{@intervention.report}\"}\r\n\r\n)\r\n\r\n# --------------------------------- ZENDESK ----------------------------------\r\n# --------------------------------- ZENDESK ----------------------------------\r\n\r\n\r\n respond_to do |format|\r\n if @intervention.save\r\n format.html { redirect_to @intervention, notice: 'Intervention was successfully created.' }\r\n format.json { render :show, status: :created, location: @intervention }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @intervention.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def fogbugz_to_aha_category(fogbugz_case)\n status = meta_data.statuses[fogbugz_case.ixStatus]\n if status.nil?\n raise ConfigurationError, \"Unhandled Fogbugz status: '#{fogbugz_case.ixStatus}', use the 'Test connection' button to update the configuration\"\n end\n if status.fWorkDone == \"false\" && status.fResolved == \"false\"\n \"in_progress\"\n elsif status.fWorkDone == \"true\" && status.fResolved == \"true\" && fogbugz_case.fOpen == \"false\"\n \"shipped\"\n elsif status.fWorkDone == \"true\" && status.fResolved == \"true\"\n \"done\"\n elsif status.fWorkDone == \"false\" && status.fResolved == \"true\"\n \"will_not_do\"\n else\n raise ConfigurationError, \"Unhandled Fogbugz status: '#{status.sStatus} - #{status.ixStatus}', use the 'Test connection' button to update the configuration\"\n end\n end",
"def create_or_update_case(feature, parent_case = nil)\n old_attachments = []\n\n parameters = {\n sTitle: feature.name,\n sEvent: html_to_plain(feature.description.body),\n ixProject: data.projects\n }\n\n parameters[:sTags] = feature.tags.join(\",\") if feature.tags\n parameters[:ixBugParent] = parent_case if parent_case\n\n\n if found_fogbugz_case = fetch_case_from_feature(feature)\n parameters = set_edit_parameters(found_fogbugz_case, parameters)\n old_attachments = has_attachments(found_fogbugz_case)\n end\n\n attachments = feature.description.attachments.map do |attachment|\n {:filename => attachment.file_name, :file_url => attachment.download_url} if !old_attachments.include?(attachment.file_name) && attachment.download_url\n end.compact\n\n if found_fogbugz_case\n fogbugz_case = fogbugz_case_resource.edit_case(parameters, attachments)\n else\n fogbugz_case = fogbugz_case_resource.new_case(parameters, attachments)\n end\n\n integrate_resource_with_case(feature, fogbugz_case)\n\n if feature.requirements\n feature.requirements.each do |requirement|\n create_or_update_case(requirement, fogbugz_case.ixBug)\n end\n end\n\n fogbugz_case\n end",
"def CreateTicket params = {}\n\n APICall(path: 'tickets.json',method: 'POST',payload: {ticket: params}.to_json)\n \n end",
"def response_to_h(resp) # :nodoc:\n resp = resp.body.gsub(/RT\\/\\d+\\.\\d+\\.\\d+\\s\\d{3}\\s.*\\n\\n/,\"\") # toss the HTTP response\n\n # unfold folded fields\n # A newline followed by one or more spaces is treated as a\n # single space\n resp.gsub!(/\\n +/, \" \")\n\n #replace CF spaces with underscores\n while resp.match(/CF\\.\\{[\\w_ ]*[ ]+[\\w ]*\\}/)\n resp.gsub!(/CF\\.\\{([\\w_ ]*)([ ]+)([\\w ]*)\\}/, 'CF.{\\1_\\3}')\n end\n return {:error => resp } if (resp =~ /^#/ and resp =~/does not exist\\.$/) or (resp =~ /Transaction \\d+ is not related to Ticket/)\n\n # convert fields to key value pairs\n ret = {}\n resp.each_line do |ln|\n next unless ln =~ /^.+?:/\n ln_a = ln.split(/:/,2)\n ln_a.map! {|item| item.strip}\n ln_a[0].downcase!\n ret[ln_a[0]] = ln_a[1]\n end\n\n return ret\n end",
"def create\n # user_id = params[\"user_id\"]\n user_id = @user.id\n store_id = params[\"store_id\"]\n \n @ticket = Ticket.new\n @ticket.user_id = user_id\n @ticket.store_id = store_id\n @ticket.cnt = get_new_ticket_number (store_id)\n\n respond_to do |format|\n if @ticket.save\n @newTicket = TicketsHelper::Ticket.new\n @newTicket.store_id = @ticket.store.id\n @newTicket.store_name = @ticket.store.name\n @newTicket.reg_time = @ticket.created_at\n @newTicket.wait_number = @ticket.cnt\n @newTicket.wait_ahead_count = get_current_user_wait_ahead_count(@ticket)\n \n format.html { redirect_to @ticket, notice: 'Ticket was successfully created.' }\n format.json { render :show}\n else\n format.html { render :new }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def ticket\n end",
"def create\n @ticket = Ticket.new(params[:ticket])\n # set user\n @ticket.creator = current_user\n if current_user.is? :admin\n @ticket.contact = User.find_by_name params[:user_name]\n else\n @ticket.contact = current_user\n end\n \n\n\n respond_to do |format|\n if @ticket.save\n format.html { redirect_to tickets_path, notice: 'Help ticket was successfully created.' }\n format.json { render json: @ticket, status: :created, location: @ticket }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def format_conversion\n { account_id: self.account_id.to_s, app_id: self.app_id.to_s, actor_id: self.actor_id.to_s, properties: self.properties, time: self.updated_at}\n rescue => e\n Rails.logger.error(\"**** ERROR **** #{e.message}\")\n {}\n end",
"def update\n if @ticket.update(ticket_params)\n\n @obj = {\n id: @ticket.id,\n title: @ticket.title,\n body: @ticket.body,\n statu_id: @ticket.statu_id,\n user_id: @ticket.user_id,\n active: @ticket.active,\n image: @ticket.image.attached? ? url_for(@ticket.image) : nil,\n media: @ticket.media.attached? ? url_for(@ticket.media) : nil\n }\n\n render json: @obj\n # 'ticket was successfully updated.'\n else\n render json: @ticket.errors, status: :unprocessable_entity\n end\n end",
"def create\n \n @ticket = Ticket.new(params[:ticket])\n @ticket.ticket_status_id = 1\n @ticket.requestor_id = current_user.id\n @ticket.account_id = current_user.company.account_id\n\n respond_to do |format|\n if @ticket.save\n format.html { redirect_to(@ticket, :notice => 'Ticket was successfully created.') }\n format.xml { render :xml => @ticket, :status => :created, :location => @ticket }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @ticket.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @breadcrumb = 'create'\n @ticket = Ticket.new(params[:ticket])\n @ticket.created_by = current_user.id if !current_user.nil?\n @ticket.source_ip = request.remote_ip\n @ticket.hd_email = mail_to\n @ticket.office_id = from_office\n # Should use attachment from drag&drop?\n if @ticket.attachment.blank? && !$attachment.avatar.blank?\n @ticket.attachment = $attachment.avatar\n end\n\n respond_to do |format|\n if @ticket.save\n $attachment.destroy\n $attachment = nil\n format.html { redirect_to @ticket, notice: crud_notice('created', @ticket) }\n format.json { render json: @ticket, status: :created, location: @ticket }\n else\n $attachment.destroy\n $attachment = Attachment.new\n @offices = offices_dropdown\n @technicians = technicians_dropdown\n format.html { render action: \"new\" }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def get(ticket_id)\r\n\r\n # Validate required parameters\r\n if ticket_id == nil\r\n raise ArgumentError.new \"Required parameter 'ticket_id' cannot be nil.\"\r\n end\r\n\r\n # the base uri for api requests\r\n _query_builder = Configuration.base_uri.dup\r\n\r\n # prepare query string for API call\r\n _query_builder << '/tickets/{ticket_id}'\r\n\r\n # process optional query parameters\r\n _query_builder = APIHelper.append_url_with_template_parameters _query_builder, {\r\n 'ticket_id' => ticket_id\r\n }\r\n\r\n # validate and preprocess url\r\n _query_url = APIHelper.clean_url _query_builder\r\n\r\n # prepare headers\r\n _headers = {\r\n 'user-agent' => 'APIMATIC 2.0',\r\n 'accept' => 'application/json',\r\n 'X-API-TOKEN' => Configuration.x_api_token,\r\n 'X-API-EMAIL' => Configuration.x_api_email\r\n }\r\n\r\n # append custom auth authorization\r\n CustomAuthUtility.append_custom_auth_params _headers\r\n\r\n # invoke the API call request to fetch the response\r\n _response = Unirest.get _query_url, headers: _headers\r\n\r\n # Error handling using HTTP status codes\r\n if _response.code == 401\r\n raise APIException.new 'Your API key is incorrect', 401, _response.body\r\n elsif _response.code == 400\r\n raise APIException.new 'There is an error in the parameters you send', 400, _response.body\r\n elsif _response.code == 404\r\n raise APIException.new 'Cannot find the resource specified', 404, _response.body\r\n elsif !_response.code.between?(200, 206) # [200,206] = HTTP OK\r\n raise APIException.new 'HTTP Response Not OK', _response.code, _response.body\r\n end\r\n\r\n # Try to cast response to desired type\r\n if _response.body.instance_of? Hash\r\n begin\r\n Ticket.from_hash(_response.body)\r\n rescue Exception\r\n raise APIException.new \"Invalid JSON returned.\", _response.code, _response.body\r\n end\r\n end\r\n end",
"def hash\n [ach_type, routing_number, account_number, account_type, check_number, check_type, product_code, manual_id_info, supplement_id_info, agent_id, terminal_id, registration_id, registration_date, release_type, vip_customer, session_id, terminal_state, terminal_city, ach_bill_to].hash\n end",
"def map_ticket_hash_to_timeslip(ticket_hash, default_attrs={})\n ticket = Trac2bex::OpenStructWithId.new(ticket_hash)\n ticket.id = ticket.id.to_s\n attrs = {\n \"foreignAppName\" => \"trac\",\n \"foreignAppEntityName\" => \"ticket\",\n \"category.name\" => 'Trac Ticket',\n \"activeForTiming\" => true,\n \"name\" => \"##{ticket.id}: #{ticket.summary}\",\n \"foreignAppImportID\" => \"#{ticket.id}\",\n \"dueDate\" => Time.at(ticket.sprint_end),\n \"createDate\" => Time.now,\n \"comment\" => \"#{ticket.description}\"\n }.merge(default_attrs)\n\n sprint = ticket.sprint\n def sprint.number\n m=self.match(/Sprint (\\d+)/i)\n puts \"m.inspect\"\n m[1]\n end\n \n interpolated_attrs = {}\n attrs.each_pair do |k, v|\n if v.is_a?(String) and (match = v.match(/^%\\{(.*)\\}$/))\n interpolated_attrs[k] = eval(match[1])\n else\n interpolated_attrs[k] = v\n end\n end\n \n timeslip = Trac2bex::Billings::Timeslip.new(interpolated_attrs)\n\n end",
"def test_solveticket\n\n # create ticket\n @zendeskclient.createticket(\"test ticket\", \"4\", 'Captain Cool', \"[email protected]\")\n assert_equal(201, @zendeskclient.responsecode)\n assert(@zendeskclient.response.to_s.match('http://rateitindia.zendesk.com'))\n tktcreationresponse = @zendeskclient.response\n\n resource = RestClient::Resource.new tktcreationresponse, '[email protected]', 'aashiana'\n doc = Document.new(resource.get)\n # a new ticket; assert on the status of the ticket\n assert_equal(\"0\", doc.root.elements[\"status-id\"].text)\n\n\n ticketid = ZenDeskAPI.extractid(tktcreationresponse)\n\n\n # solve the ticket and test for the http error code\n @zendeskclient.solveticket(\"31198262\", ticketid)\n assert_equal(200, @zendeskclient.responsecode)\n\n resource = RestClient::Resource.new tktcreationresponse, '[email protected]', 'aashiana'\n doc = Document.new(resource.get)\n # after solving the ticket; assert on the status of the ticket\n assert_equal(\"3\", doc.root.elements[\"status-id\"].text)\n\n end",
"def hash\r\n return to_s.hash\r\n end",
"def to_hash() end",
"def create\n #@matches = Match.all\n\n @ticket = current_fan.tickets.new(params[:ticket])\n\n respond_to do |format|\n if @ticket.save\n format.html { redirect_to @ticket, notice: 'Ticket was successfully created.' }\n format.json { render json: @ticket, status: :created, location: @ticket }\n else\n format.html { render action: \"new\" }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def send_ticket(ticket)\n @ticket = ticket\n @email = ticket.email\n\n mail to: ticket.email, subject: ticket.subject + \"Ticket <#{ticket.id}>\"\n end",
"def create\n @ticket = OTRS::Ticket.new(params[:ticket])\n\n respond_to do |wants|\n if @ticket.save\n flash[:notice] = 'Ticket was successfully created.'\n wants.html { redirect_to(@ticket) }\n wants.xml { render :xml => @ticket, :status => :created, :location => @ticket }\n wants.json { render :json => @ticket, :status => :created, :location => @ticket }\n else\n wants.html { render :action => \"new\" }\n wants.xml { render :xml => @ticket.errors, :status => :unprocessable_entity }\n wants.json { render :json => @ticket.errors.full_messages, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @ticket = Ticket.new(ticket_params)\n respond_to do |format|\n if @ticket.save\n format.html { render json: @ticket.to_json }\n format.json { render :show, status: :created, location: @ticket }\n else\n format.html { render :new }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n case params[:ticket][:type]\n when \"one-day\"\n @ticket = ParttimeTicket.new\n @ticket.day_count = 1\n when \"five-day\"\n @ticket = ParttimeTicket.new()\n @ticket.day_count = 5\n when \"twelve-day\"\n @ticket = ParttimeTicket.new()\n @ticket.day_count = 12\n when \"month\"\n @ticket = FulltimeTicket.new()\n end\n \n @ticket.creator_id = current_user.id;\n @ticket.user_id = current_user.id;\n \n respond_to do |format|\n if @ticket.save\n format.html { redirect_to(tickets_path, :notice => 'Ticket was successfully created.') }\n format.xml { render :xml => @ticket, :status => :created, :location => @ticket }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @ticket.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def get_case_id\n end",
"def test_createticket\n\n @zendeskclient.createticket(\"test ticket\", \"4\", 'Captain Cool', \"[email protected]\")\n assert_equal(201, @zendeskclient.responsecode)\n assert(@zendeskclient.response.to_s.match('http://rateitindia.zendesk.com'))\n\n end",
"def create\n \n if @diagnostic.nil?\n @ticket = Ticket.new(ticket_params)\n #@expected_date = @ticket.due_date + 3.days\n \n else\n \n @diagnostic = @ticket.diagnostics.build(diagnostic_params)\n @ticket = Ticket.new(ticket_params)\n @ticket = @client.tickets.build(ticket_params)\n @ticket = @computer.tickets.build(ticket_params)\n \nend\n\n respond_to do |format|\n if @ticket.save\n \n format.html { redirect_to @ticket, notice: 'Ticket was successfully created.' }\n format.json { render :show, status: :created, location: @ticket }\n else\n format.html { render :new }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @ticket = Ticket.new(ticket_params)\n @ticket.ticket_status = 'Waiting for Staff Response'\n @ticket.ticket_interface = 'New unassigned tickets'\n @ticket.make_uniq_reference\n\n TicketConfirmingMailer.new_ticket_confirmation(@ticket).deliver\n\n respond_to do |format|\n if @ticket.save\n format.html { redirect_to @ticket, notice: 'Ticket was successfully created.' }\n format.json { render action: 'show', status: :created, location: @ticket }\n else\n format.html { render action: 'new' }\n format.json { render json: @ticket.errors, status: :unprocessable_entity }\n end\n end\n end",
"def get_ticket\n ticket_details = self.class.get(\"/rest/api/2/issue/\", :verify => false)\n File.open(\"custom.txt\", 'w') {|f| f.write(ticket_details) }\n end",
"def hash\n to_s.hash\n end",
"def hash\n to_s.hash\n end",
"def send_zendesk\n\t\tif !($zenclient && ENV[\"ZENDESK_URL\"] && ENV[\"ZENDESK_TOKEN\"] && ENV[\"ZENDESK_OAUTH_TOKEN\"] && ENV[\"ZENDESK_EMAIL\"] && ENV[\"ZENDESK_PASSWORD\"]) || $rocketseeding then\n\t\t\t\n\t\t\treturn\n\t\tend\n\n\t\tsubject = \"#{self.FullName} from #{self.CompanyName}\"\n\t\tcomment = \"The contact #{self.FullName} from company #{self.CompanyName} can be reached at email #{self.Email} and at phone number #{self.Phone}. #{self.Departement} has a project named #{self.ProjectName} which would require contribution from Rocket Elevators.\\n#{self.ProjectDescription}\"\n\t\tticket = ZendeskAPI::Ticket.create($zenclient, :subject => subject, :comment => { :value => comment }, :priority => \"normal\", :type => \"question\" ) # :email_ccs => [{ :user_email => :Email, :action => \"put\"}],\n\t\t\n\t\tif !self.file.nil? && self.file.attached? then\n\t\t\turi = URI.parse(ENV[\"ZENDESK_URL\"]+\"/uploads.json?filename=#{SecureRandom.hex}.png\")\n\t\t\trequest = Net::HTTP::Post.new(uri)\n\t\t\trequest.basic_auth(ENV[\"ZENDESK_EMAIL\"], ENV[\"ZENDESK_PASSWORD\"])\n\t\t\trequest.content_type = \"application/binary\"\n\t\t\trequest.body = \"\"\n\t\t\trequest.body << self.file.download\n\t\t\treq_options = {\n\t\t\t use_ssl: uri.scheme == \"https\",\n\t\t\t}\n\t\t\t# \n\t\t\tresponse = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|\n\t\t\t http.request(request)\n\t\t\tend\n\t\t\tjsonresponse = JSON.parse(response.body)\n\n\t\t\ttoken = jsonresponse[\"upload\"][\"token\"]\n\t\t\n\t\t\turiupload = URI.parse(ENV[\"ZENDESK_URL\"]+\"/tickets/\"+ticket.id.to_s)\n\t\t\trequestupload = Net::HTTP::Put.new(uriupload)\n\t\t\trequestupload.basic_auth(ENV[\"ZENDESK_EMAIL\"], ENV[\"ZENDESK_PASSWORD\"])\n\t\t\trequestupload.content_type = \"application/json\"\n\t\t\trequestupload.body = JSON.dump({\n\t\t\t \"ticket\" => {\n\t\t\t\t\"comment\" => {\n\t\t\t\t \"body\" => \"Attachment:\",\n\t\t\t\t \"uploads\" => [\n\t\t\t\t\ttoken\n\t\t\t\t ]\n\t\t\t\t}\n\t\t\t }\n\t\t\t})\n\t\t \n\t\t\treq_options = {\n\t\t\t use_ssl: uriupload.scheme == \"https\",\n\t\t\t}\n\n\t\t\tresponseupload = Net::HTTP.start(uriupload.hostname, uriupload.port, req_options) do |http|\n\t\t\t http.request(requestupload)\n\t\t\tend\n\n\t\tend\n\tend",
"def ticket_type\n\t @ticket_type = EventTicketType.where(:event_id => id)\n end",
"def set_bug_ticket\n @bug_ticket = BugTicket.find(params[:id])\n end",
"def ticket_description(ticket)\n simple_format(ticket.description)\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n end",
"def get_ticket_details( session_key, ticket_id)\n response_xml = self.call( :get_ticket_details, message: {\n api_key: session_key,\n ticket: ticket_id\n })\n response = IssueCentre::Response.parse( response_xml)\n end",
"def set_ticket\n @ticket = Ticket.includes(:comments).find(params[:id])\n end",
"def create_ticket(params = {})\n Ticket.create(self, params)\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n end",
"def set_ticket\n @ticket = Ticket.find(params[:id])\n end"
] | [
"0.6015627",
"0.57627153",
"0.5679114",
"0.5646849",
"0.5531624",
"0.55173254",
"0.53820366",
"0.5291586",
"0.5237896",
"0.5234413",
"0.52162",
"0.5168233",
"0.50967395",
"0.5076714",
"0.5013058",
"0.50030804",
"0.4998394",
"0.49882782",
"0.4976785",
"0.49710226",
"0.4960525",
"0.4950263",
"0.49377605",
"0.4918913",
"0.48566008",
"0.48532215",
"0.48467147",
"0.483841",
"0.48383674",
"0.48342",
"0.48294175",
"0.48208433",
"0.48207533",
"0.47867122",
"0.47766423",
"0.47754136",
"0.4765559",
"0.47616982",
"0.47598132",
"0.47572976",
"0.47464064",
"0.4727705",
"0.47276625",
"0.4726478",
"0.47236073",
"0.4723304",
"0.47146988",
"0.47044984",
"0.46948963",
"0.46902215",
"0.46902215",
"0.46884552",
"0.46878818",
"0.468167",
"0.46814385",
"0.4662531",
"0.4662531",
"0.4662531",
"0.4662531",
"0.4662531",
"0.4662531",
"0.4662531",
"0.4662531",
"0.46561587",
"0.46490395",
"0.46477085",
"0.4647391",
"0.4647391",
"0.4647391",
"0.4647391",
"0.4647391",
"0.4647391",
"0.4647391",
"0.4647391",
"0.4647391",
"0.4647391",
"0.4647391",
"0.4647391",
"0.4647391",
"0.4647391",
"0.4647391",
"0.4647391",
"0.4647391",
"0.4647391",
"0.4647391",
"0.4647391",
"0.4647391",
"0.4647391",
"0.4647391",
"0.4647391",
"0.4647391",
"0.4647391",
"0.4647391",
"0.4647391",
"0.4647391",
"0.4647391",
"0.4647391",
"0.4647391",
"0.4647391",
"0.4647391"
] | 0.5715616 | 2 |
when saved, a file is split into chunks with the following requirements A. Each of the chunks is named with the sha of its content. B. The file is named with the sha of its content C. The file lists the chunks its made of. D. An adler directory is updated with the reference of the chunks | def test_store_file
#emulate the saving of a file whose content is 'test content'
@writer.save_file('test content')
#we expect three chunks for
expected_chunks = ['test ', 'conte', 'nt']
expected_chunks_sha = expected_chunks.map{|s| ComputeSHADigest s}
#A. Each of the chunk is named with the sha on its content
expected_chunks_sha.each{|sha| assert( @ioservice.exists? :chunk, sha )}
#B. The filename is retrieved from the sha of the whole string
file_sha = ComputeSHADigest 'test content'
assert( @ioservice.exists?(:file, file_sha), "file not found: #{file_sha} in #{@ioservice.store[:file]}" )
#C. The file lists all its chunks
@ioservice.read_elem(:file, file_sha) do |c|
c.each_line.zip(expected_chunks_sha).each{ |l, sha| assert_equal(l.strip, sha) }
end
#D. the adlers directory should be filled with the adler32 code of each chunk
CheckChunksInAdlerDirectory( @adlers, expected_chunks )
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_splited_part(zip_file, partial_zip_file_name, zip_file_size, szip_file_index, segment_size, segment_count); end",
"def chunk(file_name, prefix, chunksize = 1_073_741_824)\n File.open(file_name\"r\") do |f|\n until f.eof?\n File.open(\"#{prefix}_#{\"%05d\"%(f.pos/chunksize)}.txt\",\"w\") do |fc|\n fc << f.read(chunksize)\n end\n end\n end\nend",
"def save_splited_part(zip_file, partial_zip_file_name, zip_file_size, szip_file_index, segment_size, segment_count)\n ssegment_size = zip_file_size - zip_file.pos\n ssegment_size = segment_size if ssegment_size > segment_size\n szip_file_name = \"#{partial_zip_file_name}.#{format('%03d', szip_file_index)}\"\n ::File.open(szip_file_name, 'wb') do |szip_file|\n if szip_file_index == 1\n ssegment_size = put_split_signature(szip_file, segment_size)\n end\n chunk_bytes = 0\n until ssegment_size == chunk_bytes || zip_file.eof?\n segment_bytes_left = ssegment_size - chunk_bytes\n buffer_size = segment_bytes_left < DATA_BUFFER_SIZE ? segment_bytes_left : DATA_BUFFER_SIZE\n chunk = zip_file.read(buffer_size)\n chunk_bytes += buffer_size\n szip_file << chunk\n # Info for track splitting\n yield segment_count, szip_file_index, chunk_bytes, ssegment_size if block_given?\n end\n end\n end",
"def test_reuse_existing_chunks_when_append\n CheckFile @writer, @ioservice, @adlers, 'test content', ['test ', 'conte', 'nt']\n CheckFile @writer, @ioservice, @adlers, 'test content updated', ['test ', 'conte', 'nt', ' upda', 'ted']\n end",
"def new_chunk(index)\n chunk_num = (index / CHUNK_LINE_SIZE).to_i\n write_file = File.new(\"data/chunk#{chunk_num}\", \"w\")\n\n return write_file\nend",
"def test_reuse_existing_chunks_when_prepend\n CheckFile @writer, @ioservice, @adlers, 'test content', ['test ', 'conte', 'nt']\n CheckFile @writer, @ioservice, @adlers, 'a new test content', ['a new', ' ', 'test ', 'conte', 'nt']\n end",
"def split_input filename, pieces\n input = {}\n name = nil\n seq=\"\"\n sequences=0\n File.open(filename).each_line do |line|\n if line =~ /^>(.*)$/\n sequences+=1\n if name\n input[name]=seq\n seq=\"\"\n end\n name = $1\n else\n seq << line.chomp\n end\n end\n input[name]=seq\n # construct list of output file handles\n outputs=[]\n output_files=[]\n pieces = [pieces, sequences].min\n pieces.times do |n|\n outfile = File.basename(\"#{filename}_chunk_#{n}.fasta\")\n outfile = \"#{@working_dir}/#{outfile}\"\n outputs[n] = File.open(\"#{outfile}\", \"w\")\n output_files[n] = \"#{outfile}\"\n end\n # write sequences\n count=0\n input.each_pair do |name, seq|\n outputs[count].write(\">#{name}\\n\")\n outputs[count].write(\"#{seq}\\n\")\n count += 1\n count %= pieces\n end\n outputs.each do |out|\n out.close\n end\n output_files\n end",
"def split_input filename, pieces\n input = {}\n name = nil\n seq=\"\"\n sequences=0\n output_files=[]\n if pieces > 1\n File.open(filename).each_line do |line|\n if line =~ /^>(.*)$/\n sequences+=1\n if name\n input[name]=seq\n seq=\"\"\n end\n name = $1\n else\n seq << line.chomp\n end\n end\n input[name]=seq\n # construct list of output file handles\n outputs=[]\n pieces = [pieces, sequences].min\n pieces.times do |n|\n outfile = \"#{filename}_chunk_#{n}.fasta\"\n outfile = File.expand_path(outfile)\n outputs[n] = File.open(\"#{outfile}\", \"w\")\n output_files[n] = \"#{outfile}\"\n end\n # write sequences\n count=0\n input.each_pair do |name, seq|\n outputs[count].write(\">#{name}\\n\")\n outputs[count].write(\"#{seq}\\n\")\n count += 1\n count %= pieces\n end\n outputs.each do |out|\n out.close\n end\n else\n output_files << filename\n end\n output_files\n end",
"def chunks\n Dir[\"#{model.file}-*\"].sort\n end",
"def split!\n return unless model.chunk_size.is_a?(Integer)\n\n if File.size(model.file) > bytes_representation_of(model.chunk_size)\n Logger.message \"#{ self.class } started splitting the packaged archive in to chunks of #{ model.chunk_size } megabytes.\"\n run(\"#{ utility(:split) } -b #{ model.chunk_size }m '#{ model.file }' '#{ model.file + SUFFIX_SEPARATOR }'\")\n Backup::Model.chunk_suffixes = chunk_suffixes\n end\n end",
"def line_chunk(file_name, prefix, chunksize = 1_073_741_824)\n outfilenum = 1\n File.open(file_name,\"r\") do |f|\n until f.eof?\n File.open(\"#{out_pref}_#{outfilenum}.txt\",\"w\") do |outfile|\n line = \"\"\n while outfile.size <= (chunksize-line.length) && !f.eof?\n line = f.readline\n outfile << line\n end\n end\n outfilenum += 1\n end\n end\nend",
"def go\n\nlines = 3 # cut it at line 3\n\nbasename = 'file_to_split.txt'\nextname = \"part\"\n\npart = 1\nline = 0\n\nfline = 0\nfor i in ifp = open(basename)\n fline = fline + 1\nend\nifp.close\n\nparts = fline / lines + 1\n\nfor i in ifp = open(basename)\n if line == 0\n ofp = open(sprintf(\"%s.%s%02d\", basename, extname, part), \"w\")\n printf(ofp, \"%s part%02d/%02d\\n\", basename, part, parts)\n ofp.write(\"BEGIN--cut here--cut here\\n\")\n end\n ofp.write(i)\n line = line + 1\n if line >= lines and !ifp.eof?\n ofp.write(\"END--cut here--cut here\\n\")\n ofp.close\n part = part + 1\n line = 0\n end\nend\nofp.write(\"END--cut here--cut here\\n\")\nofp.close\n\nifp.close\n\nend",
"def splitByFile\n outfile = nil\n stream = open(@filename)\n until (stream.eof?)\n line = stream.readline\n\n # we need to create a new file\n if (line =~ /--- .*/) == 0\n if (outfile) \n outfile.close_write\n end\n #find filename\n tokens = line.split(\" \")\n tokens = tokens[1].split(\":\")\n tokens = tokens[0].split(\"/\")\n filename = tokens[-1]\n filename << \".patch\"\n if File.exists?(filename)\n puts \"File #{filename} already exists. Renaming patch.\"\n appendix = 0\n while File.exists?(\"#{filename}.#{appendix}\")\n appendix += 1\n end\n filename << \".#{appendix}\"\n end\n outfile = open(filename, \"w\")\n outfile.write(line)\n else\n if outfile\n outfile.write(line)\n end\n end\n end\n end",
"def split_refseq\n # prepare output files\n system(%Q[cut -f4 #{$prepare_dir}/refseq_genes_result.tsv | cut -c1-5 | sort | uniq > #{$prepare_dir}/refp_prefix_list.txt ]) # get exist prefix list of protein_id\n FileUtils.mkdir_p(\"#{$prepare_dir}/refp\") unless File.exist?(\"#{$prepare_dir}/refp\")\n refp_output = {}\n File.open(\"#{$prepare_dir}/refp_prefix_list.txt\") do |f|\n f.each_line do |line|\n prefix = line.chomp.strip\n refp_output[prefix] = File.open(\"#{$prepare_dir}/refp/#{prefix}.dat\", \"w\")\n end\n end\n refp_output[\"no_protein_id\"] = File.open(\"#{$prepare_dir}/refp/no_protein_id.dat\", \"w\") # protein_id is optional\n\n File.open(\"#{$prepare_dir}/refseq_genes_result.tsv\") do |f|\n f.each_line do |line|\n columns = line.chomp.strip.split(\"\\t\")\n prefix = (columns[3].nil? || columns[3] == \"\") ? \"no_protein_id\" : columns[3][0..4] # protein_id is optional\n refp_output[prefix].puts line.chomp.strip\n end\n end\n refp_output.each do |k, v|\n v.flush\n v.close\n end\nend",
"def initialize(info, prefix_dir) \r\n @info_dictionary = info\r\n @files = Array.new\r\n @piece_files = Array.new\r\n @pieceLength = info[\"piece length\"]\r\n @numBytes = 0\r\n @totalPieces = info[\"pieces\"].bytesize / 20\r\n \r\n build_dir_path(prefix_dir)\r\n \r\n unless prefix_dir.chars.last == File::SEPARATOR \r\n prefix_dir += File::SEPARATOR \r\n end\r\n \r\n no_files_existed = true\r\n if info[\"files\"] != nil\r\n # multiple file mode\r\n \r\n unless Dir.exists?(prefix_dir + info[\"name\"])\r\n Dir.mkdir(prefix_dir + info[\"name\"])\r\n end\r\n \r\n info[\"files\"].each { |file|\r\n @numBytes += file[\"length\"]\r\n filename = file[\"path\"].last\r\n \r\n build_dir = prefix_dir + info[\"name\"] + File::SEPARATOR # for making directory trees\r\n file[\"path\"].rotate(-1).drop(1).each { |dir| # don't use filename (last element)\r\n build_dir += (dir + File::SEPARATOR) # use constant separator for portability\r\n unless Dir.exists?(build_dir)\r\n Dir.mkdir(build_dir)\r\n end\r\n }\r\n \r\n if File.exists?(build_dir + filename)\r\n no_files_existed = false\r\n end\r\n @files << [File.open(build_dir + filename, File::RDWR | File::CREAT), file[\"length\"]]\r\n if @files.last[0].size < @files.last[1]\r\n @files.last[0].seek(@files.last[0].size, IO::SEEK_SET)\r\n @files.last[0].write(\"\\0\" * (@files.last[1] - @files.last[0].size))\r\n end\r\n }\r\n else\r\n # single file mode\r\n @numBytes = info[\"length\"] \r\n if File.exists?(prefix_dir + info[\"name\"])\r\n no_files_existed = false\r\n end\r\n @files << [File.open(prefix_dir + info[\"name\"], File::RDWR | File::CREAT), info[\"length\"]]\r\n if @files.last[0].size < @files.last[1] # still needs to be checked even if file exists\r\n @files.last[0].seek(@files.last[0].size, IO::SEEK_SET)\r\n (0..((@files.last[1] - @files.last[0].size)/1024)).each {\r\n @files.last[0].write(\"\\0\" * 1024)\r\n }\r\n end\r\n end\r\n unless no_files_existed\r\n recheckComplete()\r\n else\r\n gen_initial_states()\r\n end\r\n \r\n #puts @bitfield.to_binary_string\r\n end",
"def all_split_files_in dir_name\n return super unless @hax_mode\n @hax_last_dirname = dir_name\n ret = super\n lone_files = [\"#{dir_name}.md\", dir_name]\n lone_file = find_first_file(lone_files)\n if lone_file # e.g. '../README.md', 'README'\n @hax_last_filename = lone_file.dup\n class << lone_file\n #\n # supremely fragile hack:\n # make it so that it ignores the next + operation in the first\n # line of Nanoc3::DataSources::Filesystem#all_split_files_in()\n # this is shorter and easier than overriding and rewring\n # the above function but it is a supreme haxie guaranteed to fail\n # one day!!!\n #\n def + _; self end\n end\n other = super(lone_file)\n ret.merge!(other)\n end\n ret\n end",
"def create_upload_job_chunks(jobs, state, apikey, filename, filepath, filesize, start_response)\n jobs.each { |job|\n job[:chunks] = chunk_job(\n job, state, apikey, filename, filepath, filesize, start_response\n )\n }\n jobs\n end",
"def save chunk_nr, io\n\t\t\t# retrieve data from io and compare sig \n\t\tend",
"def join(owned_chunks)\n \n end",
"def chunk_job(job, state, apikey, filename, filesize, start_response, storage)\n offset = 0\n seek_point = job[:seek_point]\n chunk_list = []\n\n while (offset < FilestackConfig::DEFAULT_CHUNK_SIZE) && (seek_point + offset) < filesize\n chunk_list.push(\n seek_point: seek_point,\n filename: filename,\n apikey: apikey,\n part: job[:part],\n size: job[:size],\n uri: start_response['uri'],\n region: start_response['region'],\n upload_id: start_response['upload_id'],\n location_url: start_response['location_url'],\n store: { location: storage },\n offset: offset\n )\n offset += state.offset\n end\n chunk_list\n end",
"def chunk_path(c)\n\t\tRails.application.routes.url_helpers.chunk_fyle_path(id: self.id.to_s.rjust(3, \"0\"), chunk: c, format: 'txt')\n\tend",
"def write_chunk(start, buffer)\n @local_file.seek(start)\n @local_file.write(buffer)\n end",
"def save_level\n File.open(@file_name, 'w') do |file|\n @blocks_array.each do |block|\n new_block = Block.new block.relative_position\n puts new_block.to_s\n end\n end\n end",
"def split_data_into_files(datafile)\n\n datafiles = []\n output = NIL\n File.open(Rails.root.join(datafile)) do |file| \n counter = 0\n something_was_written = FALSE\n while line = file.gets \n # parse lines and break into different files at #\n if( line.match( /^\\s*\\#+/ ) )\n if (something_was_written && output) \n output.close\n output = NIL\n end\n something_was_written = FALSE\n else \n if (!something_was_written) \n outputfile_name = datafile.gsub(/input/,\"input\" +\n counter.to_s)\n counter +=1\n output = File.open(Rails.root.join(outputfile_name), \"w\") \n datafiles.push((Rails.root.join(outputfile_name)).to_s)\n #datafiles.push( \"../\" + outputfile_name)\n #datafiles.push(Dir.getwd + \"/\" + outputfile_name)\n end\n # check if line matches @n_nodes digits\n nodes_minus_one = (@job.nodes - 1).to_s\n if (line.match( /^\\s*(\\.?\\d+\\.?\\d*\\s+){#{nodes_minus_one}}\\.?\\d+\\.?\\d*\\s*$/ ) ) \n output.puts line\n logger.info \"write line\" + line\n something_was_written = TRUE\n else\n @error_message = \"The data you entered is invalid. This :#{line.chop!}: is not a correct line.\"\n logger.warn \"Error: Input data not correct. This :#{line}: is not a correct line.\"\n return NIL\n end\n end\n end \n file.close\n if (output) \n output.close\n end\n end\n return datafiles\n end",
"def export\n return if fragments.count.zero?\n File.open(\"#{bin_file_name}.new\", \"wb\") do |f|\n i = 0;\n fragments.order(:order).each do |fr|\n i = export_object f, fr, i\n end\n end\n end",
"def add(chunk)\n if chunk.full_chunk?\n @chunks[chunk.x / 16] ||= {}\n # if @chunks[chunk.x / 16][chunk.z / 16]\n # puts \"replacing: #{[chunk.x, chunk.z].inspect}\"\n # else\n # puts \"adding : #{[chunk.x, chunk.z].inspect}\"\n # end\n @chunks[chunk.x / 16][chunk.z / 16] = chunk\n\n key = [chunk.x/16, chunk.z/16]\n\n if @pending_changes[key]\n @pending_changes[key].each do |x, y, z, block|\n # puts \"applying stored change #{[x, y, z].inspect} #{block}\"\n self[x, y, z] = block\n end\n @pending_changes.delete key\n end\n\n if @pending_updates[key]\n @pending_updates[key].each do |x, y, z, data|\n # puts \"applying stored update #{[x,y,z].inspect} #{data}\"\n update(x, y, z, data)\n @pending_updates.delete key\n end\n end\n\n else\n # puts \"incremental: #{[chunk.x, chunk.y, chunk.z].inspect} #{[chunk.size_x, chunk.size_y, chunk.size_z].inspect}\"\n chunk.each_column do |x, y, z, data|\n # puts \"updating #{[x,y,z].inspect} #{data.size} blocks\"\n update(x, y, z, data)\n end\n end\n end",
"def process_workspace_bucket_files(files)\n # first mark any files that we already know are study files that haven't changed (can tell by generation tag)\n files_to_remove = []\n files.each do |file|\n # first, check if file is in a submission directory, and if so mark it for removal from list of files to sync\n if @submission_ids.include?(file.name.split('/').first) || file.name.end_with?('/')\n files_to_remove << file.generation\n else\n directory_name = DirectoryListing.get_folder_name(file.name)\n found_file = {'name' => file.name, 'size' => file.size, 'generation' => file.generation}\n # don't add directories to files_by_dir\n unless file.name.end_with?('/')\n # add to list of discovered files\n @files_by_dir[directory_name] ||= []\n @files_by_dir[directory_name] << found_file\n end\n found_study_file = @study_files.detect {|f| f.generation.to_i == file.generation }\n if found_study_file\n @synced_study_files << found_study_file\n files_to_remove << file.generation\n end\n end\n end\n\n # remove files from list to process\n files.delete_if {|f| files_to_remove.include?(f.generation)}\n\n # next update map of existing files to determine what can be grouped together in a directory listing\n @file_extension_map = DirectoryListing.create_extension_map(files, @file_extension_map)\n\n files.each do |file|\n # check first if file type is in file map in a group larger than 10 (or 20 for text files)\n file_extension = DirectoryListing.file_extension(file.name)\n directory_name = DirectoryListing.get_folder_name(file.name)\n max_size = file_extension == 'txt' ? 20 : 10\n if @file_extension_map.has_key?(directory_name) && !@file_extension_map[directory_name][file_extension].nil? && @file_extension_map[directory_name][file_extension] >= max_size\n process_directory_listing_file(file, file_extension)\n else\n # we are now dealing with singleton files or fastqs, so process accordingly (making sure to ignore directories)\n if DirectoryListing::PRIMARY_DATA_TYPES.any? {|ext| file_extension.include?(ext)} && !file.name.end_with?('/')\n # process fastq file into appropriate directory listing\n process_directory_listing_file(file, 'fastq')\n else\n # make sure file is not actually a folder by checking its size\n if file.size > 0\n # create a new entry\n unsynced_file = StudyFile.new(study_id: @study.id, name: file.name, upload_file_name: file.name, upload_content_type: file.content_type, upload_file_size: file.size, generation: file.generation, remote_location: file.name)\n @unsynced_files << unsynced_file\n end\n end\n end\n end\n end",
"def vac(filename)\n if File.file?(filename)\n puts 'vac in progress ...'\n data = File.read(filename)\n address_list = []\n\n File.open(filename,'rb') do |f|\n f.each_chunk(10000) do |c| \n address_list += write_blocks(c, 100)\n end\n end\n\n #TODO: further investigate the condition whether to set address_list to nil on the first step?\n while address_list.size != 1 do\n address_list = write_blocks(address_list, 5)\t\n end\n\n vacfile = filename.chomp(File.extname(filename)) + \".vac\"\n\n #convert the hash to bin before writing\n file_details = {name: filename, size: data.size, address: address_list.first, directory: @directory}\n\n File.open(vacfile , \"wb\") do |file| \n file.write(Marshal.dump(file_details))\n end \n\n puts \"vac completed successfully\"\n else\n puts \"Error #{filename} does not exist\" \n end\n end",
"def hash_file(name, length)\n pieces = String.new\n file = ::File.open(name, 'r')\n pieces << Digest::SHA1.digest(file.read(length)) until file.eof?\n file.close\n pieces\n end",
"def patch_file(uid, input, info = {})\n grid_info = files_collection.find(filename: uid).first\n current_length = grid_info[:length]\n chunk_size = grid_info[:chunkSize]\n bytes_saved = 0\n\n # It's possible that the previous data append didn't fill in the last\n # GridFS chunk completely, so we fill in that gap now before creating\n # new GridFS chunks.\n bytes_saved += patch_last_chunk(input, grid_info) if current_length % chunk_size != 0\n\n # Create an Enumerator which yields chunks of input data which have the\n # size of the configured :chunkSize of the GridFS file.\n chunks_enumerator = Enumerator.new do |yielder|\n while (data = input.read(chunk_size))\n yielder << data\n end\n end\n\n chunks_in_batch = (BATCH_SIZE.to_f / chunk_size).ceil\n chunks_offset = chunks_collection.count(files_id: grid_info[:_id]) - 1\n\n # Iterate in batches of data chunks and bulk-insert new GridFS chunks.\n # This way we try to have a balance between bulking inserts and keeping\n # memory usage low.\n chunks_enumerator.each_slice(chunks_in_batch) do |chunks|\n grid_chunks = chunks.map do |data|\n Mongo::Grid::File::Chunk.new(\n data: BSON::Binary.new(data),\n files_id: grid_info[:_id],\n n: chunks_offset += 1,\n )\n end\n\n chunks_collection.insert_many(grid_chunks)\n\n # Update the total length and refresh the upload date on each update,\n # which are used in #get_file, #concatenate and #expire_files.\n files_collection.find(filename: uid).update_one(\n \"$inc\" => { length: chunks.map(&:bytesize).inject(0, :+) },\n \"$set\" => { uploadDate: Time.now.utc },\n )\n bytes_saved += chunks.map(&:bytesize).inject(0, :+)\n\n chunks.each(&:clear) # deallocate strings\n end\n\n bytes_saved\n end",
"def write_benchmark opts={}\n files, size = opts[:files], opts[:size]\n block_size = opts[:block_size] || 100_000\n block = 0.chr * block_size\n blocks, remaining = size.divmod block_size\n remaining = 0.chr * remaining\n Tempfile.open 'ole_storage_benchmark' do |temp|\n Ole::Storage.open temp do |ole|\n files.times do |i|\n ole.file.open \"file_#{i}\", 'w' do |f|\n blocks.times { f.write block }\n f.write remaining\n end\n end\n end\n end\n end",
"def write_benchmark opts={}\n\t\tfiles, size = opts[:files], opts[:size]\n\t\tblock_size = opts[:block_size] || 100_000\n\t\tblock = 0.chr * block_size\n\t\tblocks, remaining = size.divmod block_size\n\t\tremaining = 0.chr * remaining\n\t\tTempfile.open 'ole_storage_benchmark' do |temp|\n\t\t\tOle::Storage.open temp do |ole|\n\t\t\t\tfiles.times do |i|\n\t\t\t\t\tole.file.open \"file_#{i}\", 'w' do |f|\n\t\t\t\t\t\tblocks.times { f.write block }\n\t\t\t\t\t\tf.write remaining\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def write_out\n @all_content.each do |venue_id, venue_content|\n manifest_dir = \"#{@base.deploy_path}\" / \"#{venue_content.sha1_digest}\"\n venue_dir = \"#{@base.deploy_path}\" / \"#{Venue.get!(venue_id).router.identifier}\"\n manifest_file = manifest_dir / \"manifest.json\"\n files_dir = manifest_dir / \"files\"\n venue_content_ln = \"#{venue_dir}\" / \"content\"\n sha1_file = manifest_dir / \"#{venue_content.sha1_digest}.sha1\"\n \n FileUtils.rm(venue_content_ln) if File.exists?(venue_content_ln)\n FileUtils.mkdir_p(venue_dir)\n if File.exists?(sha1_file)\n FileUtils.ln_sf(manifest_dir, venue_content_ln)\n next\n end\n\n FileUtils.mkdir_p(manifest_dir)\n\n open(manifest_file, \"w+\") do |f|\n f << venue_content.manifest.to_json\n end\n\n #FileUtils.mkdir_p(files_dir)\n source_files = venue_content.filelist\n venue_content.filelist.each do |f|\n #UploadManager is using the first 2 bytes of the file digest as directory names.\n #The split('/'[-3..-1].join('') restores the filename to the full digest when it is copied\n #from the upload dir to the deployment dir\n dest = \"#{manifest_dir}\" / \"#{f.split('/')[-3..-1].join('')}\"\n FileUtils.cp(f, dest)\n end\n \n open(sha1_file, \"w+\") do |f|\n f << venue_content.sha1_digest\n end\n \n FileUtils.ln_sf(manifest_dir, venue_content_ln)\n end\n end",
"def import\n fragments.each(&:destroy)\n File.open(bin_file_name, \"rb\") do |f|\n order = 0\n new_lines = 0\n until f.eof?\n new_lines += import_next_object(f, order)\n order += 1\n end\n update! lines: new_lines\n end\n add_locations\n end",
"def parse_chunk(size)\n File.open(@auth_log.file, 'r') do |f|\n f.seek(-size, IO::SEEK_END)\n f.read(size).split(\"\\n\").each { |line| build_block(line) }\n end\n end",
"def patch_last_chunk(input, grid_info)\n last_chunk = chunks_collection.find(files_id: grid_info[:_id]).sort(n: -1).limit(1).first\n data = last_chunk[:data].data\n patch = input.read(grid_info[:chunkSize] - data.bytesize)\n data << patch\n\n chunks_collection.find(files_id: grid_info[:_id], n: last_chunk[:n])\n .update_one(\"$set\" => { data: BSON::Binary.new(data) })\n\n files_collection.find(_id: grid_info[:_id])\n .update_one(\"$inc\" => { length: patch.bytesize })\n\n patch.bytesize\n end",
"def drive\n exit 1 if in_a_bourbon_house?\n links = []\n read_subbacks.each do |subback_file|\n subbacks = YAML.load_file(subback_file)\n links = get_links(subbacks)\n links.sort {|a, b| a.tv <=> b.tv}.each do |link|\n link.save\n end\n end\n rescue BourbonHouseException => e\n $stderr.puts \"#{e.class}|#{e.message}||#{Time.now}\"\n File.open(LOCK_FILE, 'w').close\n rescue => e\n $stderr.puts \"#{e.class}|#{e.message}|#{e.backtrace}|#{Time.now}\"\n end",
"def ingest_new_content( depositor, dirname, wsname, current, total )\n\n filename = File.join( dirname, wsname )\n _, asset_filenames = IngestHelpers.load_workset( filename )\n\n puts \"Ingesting #{current} of #{total}: #{filename} ...\"\n\n work_id = IngestHelpers.get_ingest_id( filename )\n if work_id.blank?\n puts \"ERROR: #{filename} has no ingest id, continuing anyway\"\n return false\n end\n\n work = TaskHelpers.get_work_by_id( work_id )\n if work.nil?\n puts \"ERROR: work #{work_id} does not exist, continuing anyway\"\n return false\n end\n\n asset_filenames.each_with_index do |f, ix|\n label = IngestHelpers.construct_file_label( ix + 1, f, work )\n puts \" asset #{ix + 1} of #{asset_filenames.length}: #{f} (#{label})\"\n\n # handle dry running\n next if ENV[ 'DRY_RUN' ]\n\n # and upload the file\n fileset = TaskHelpers.upload_file( depositor, work, File.join( dirname, f ), label )\n fileset.date_uploaded = DateTime.now\n fileset.save!\n end\n\n return true\n end",
"def create\n revisions do |orig_file, sha_list|\n sha_list.each_with_index do |sha, i|\n ver = (i + 1).to_s\n # Git revisioned file\n composeversions(orig_file, sha, ver) do |content, data, file_path|\n # dont re-write files\n if File.exist?(file_path)\n linecount(file_path)\n next\n end\n\n version_content = FrontMatter.new(data)\n version_content.content = content \n write(file_path, version_content.update)\n linecount(file_path)\n end\n end\n\n sha_list.map!.with_index { |sha, i| [] << sha << (i + 1) }\n # Git Diff combination files\n composediffs(orig_file, line_count, sha_list.combination(2)) do |content, data, file_path|\n content.sub!(DIFF_HEADER_REGEXP, '')\n if change?(content)\n VersionedFiles.frontmatter[\"no_change\"] = false\n styled_content = @style.style(content)\n data.merge!(@style.stats.final)\n else\n VersionedFiles.frontmatter[\"no_change\"] = \"no_change\"\n data[\"no_change\"] = true\n end\n\n fm = FrontMatter.new(data).create\n diff_file = fm << styled_content\n write(file_path, diff_file)\n end\n end\n end",
"def bust(out: nil, preserve_tree: false, preserve_original: true)\n FileUtils.mkdir_p(out) if out\n\n @map = @files.each_with_object({}) do |f, result|\n hash = Digest::MD5.hexdigest File.read f\n basename = File.basename f\n dirname = File.dirname f\n new_name = hash[0...6] + \"_\" + basename\n\n destination = out ? out : dirname\n\n if preserve_tree && destination\n dirname = out ? path_diff(dirname, out) : dirname\n destination = File.join(out, dirname)\n FileUtils.mkdir_p(destination)\n end\n \n # TODO: This will remove a hashed file if it follows the format of\n # 6letters_anything.css\n rm_busted(destination)\n\n FileUtils.cp f, File.join(destination, new_name)\n result[basename] = new_name\n result\n end\n\n FileUtils.rm(@files) if (not preserve_original)\n\n return self\n end",
"def split_command\n \"#{utility(:split)} -a #{suffix_length} -b #{chunk_size}m - \" \\\n \"'#{File.join(Config.tmp_path, package.basename + \"-\")}'\"\n end",
"def split_with\n Logger.info \"Splitter configured with a chunk size of #{chunk_size}MB \" \\\n \"and suffix length of #{suffix_length}.\"\n yield split_command\n after_packaging\n end",
"def save_files\n @law_h = [:law, :link, :section]\n @case_h = [:case, :link, :date]\n\n # Parse into hashes\n @single_matches = @single_matches-@double_matches\n case_hash = @double_matches.map{|i| {@case_h[0] => i[0], @case_h[1] => i[1], @case_h[2] => i[2]}}\n law_hash = @single_matches.map{|i| {@law_h[0] => i[0], @law_h[1] => i[1], @law_h[2] => i[2]}}\n \n # Write files\n write_files(case_hash, law_hash)\n end",
"def all_chunk_hashes\n\t\t\n\t\tbegin\n\t\t\t@all_chunk_map = \"\"\n\t\t\t0.upto(num_chunks-1) { |i|\n\t\t\t\t@all_chunk_map += sha1_chunk(i)\n\t\t\t}\n\n\t\tend unless @all_chunk_map\n\t\t@all_chunk_map\n\tend",
"def chunks\n Dir[File.join(Config.tmp_path, package.basename + \"-*\")].sort\n end",
"def <<( file_path )\n if file_path.is_a?( Array )\n file = file_path.shift\n path = file_path\n else\n file = file_path\n path = []\n end\n File.open( file ) do |file_io|\n while( piece = file_io.read( @contents['info']['piece length'] - ( @carry_over ? @carry_over.length : 0 ) ) ) do\n if @carry_over\n piece = @carry_over + piece\n @carry_over = nil\n end\n if piece.length < @contents['info']['piece length']\n @carry_over = piece\n else\n @contents['info']['pieces'] << Digest::SHA1.digest( piece )\n end\n end\n @contents['info']['files'] << {\n 'path' => [ path, File.basename( file ) ].flatten,\n 'length' => file_io.pos\n }\n end\n self\n end",
"def checksum!(path = nil, opts = {})\n opts = opts.inject({}){ |r, (k,v)| r[k.to_sym] = v; r }\n \n raise \"Path uses differnt extension\" if path && File.extname(path) != File.extname(self.local_path)\n \n \n if opts[:debug]\n raise (\"File '%s' does not exist\" % File.expand_path( path ) ) if path && !File.exist?( File.expand_path( path ) )\n else\n raise (\"File '%s' does not exist\" % path ) if path && !File.exist?( File.expand_path( path ) )\n end\n \n raise \"Can not specify both piece_size and piece_count\" if opts[:piece_size] && opts[:piece_count]\n raise \"piece_size must be an Integer\" if opts[:piece_size] && !opts[:piece_size].is_a?(Integer)\n raise \"piece_count must be an Integer\" if opts[:piece_count] && !opts[:piece_count].is_a?(Integer)\n \n path ||= self.local_path\n \n #get filesize\n self.size = File.size( File.expand_path( path ) )\n\n # Overrides piece_count if set\n # minimum size of 1KB for a piece\n if opts[:piece_size]\n @piece_count = nil\n @piece_size = [opts[:piece_size], 1024].max\n end\n\n\n # Overrides piece_size if set\n # This will be a multiple of 1024, and the last file will be slightly smaller\n # this means 1KB is the minimum size for a piece\n if opts[:piece_count]\n @piece_count = opts[:piece_count]\n @piece_size = ((@size / @piece_count) / 1024.0).ceil * 1024 \n end\n\n self.hashes = []\n self.hashes << Metalink4FileHash.new( hash_value: Digest::SHA256.file( File.expand_path( path ) ).hexdigest, hash_type: \"sha-256\" )\n if self.piece_size\n i = 0\n (0...@size).step(self.piece_size).each do |offset|\n self.hashes << Metalink4FileHash.new( hash_value: Digest::SHA256.hexdigest(File.read(File.expand_path( path ), self.piece_size, offset)), hash_type: \"sha-256\", piece: i )\n i += 1\n end\n end\n end",
"def file_ids_hash\n if @file_ids_hash.blank?\n # load the file sha's from cache if possible\n cache_file = File.join(self.path,'.loopoff')\n if File.exists?(cache_file)\n @file_ids_hash = YAML.load(File.read(cache_file))\n else\n # build it\n @file_ids_hash = {}\n self.loopoff_file_names.each do |f|\n @file_ids_hash[File.basename(f)] = Grit::GitRuby::Internal::LooseStorage.calculate_sha(File.read(f),'blob')\n end\n # write the cache\n File.open(cache_file,'w') do |f|\n f.puts YAML.dump(@file_ids_hash) \n end\n end \n end\n @file_ids_hash\n end",
"def import_map_chunks\n puts 'Importing map chunks...'\n\n puts \"-> Identifying tiled maps...\"\n\n tiled_maps = Map.target(target).where(tiled: true).all\n\n tiled_maps.each do |map|\n next if map.chunks_loaded?\n\n puts \"-> Seeding chunks for map: #{map.name} (#{map.directory})\"\n\n map.tiles.extant.each do |tile|\n next if tile.chunks_loaded?\n\n tile_adt_path = \"#{map_path_for(map.directory)}/#{map.directory}_#{tile.tile_x}_#{tile.tile_y}.adt\"\n tile_adt_hash = file_hash(tile_adt_path)\n\n seed_map_tile_adt(map, tile, tile_adt_path)\n\n GC.start\n end\n end\n end",
"def append uri\n count = 0\n File.open('storage.db','r+') do |f|\n f.flock(File::LOCK_EX)\n count = f.gets.to_i+1\n f.seek(0,IO::SEEK_SET)\n f.write \"%20i\" % count\n f.seek(0,IO::SEEK_END)\n f.write \"\\n\"+uri\n f.flock(File::LOCK_UN)\n end\n count\n end",
"def fitFiles(target)\n buckets()\n runningSize = 0\n fileSet = FileSet.new(target, @log, @DEBUG, @LOG_DEBUG)\n \n # Go thru each bucket...\n @sortedBuckets.each do |bkt|\n Utils.printMux(@log, \"Processing bucket '#{bkt}'\")\n\n # ... And each file in the bucket\n @data[bkt].each do |file| \n Utils.printMux(@log, \"\\tProcessing file '#{file}'\")\n\n # The regular call to size won't work with larger (> 2 GB) files in some versions of Ruby, so call the custom version added above.\n fsize = File.size_big(file)\n\n Utils.printMux(@log, \"\\t\\t fsize: #{fsize}\\n\", @DEBUG, @LOG_DEBUG, Utils::DEBUG_LOW, Utils::LOG_LOW)\n Utils.printMux(@log, \"\\t\\trunningSize: #{runningSize}\\n\", @DEBUG, @LOG_DEBUG, Utils::DEBUG_LOW, Utils::LOG_LOW)\n Utils.printMux(@log, \"\\t\\t target: #{target}\\n\", @DEBUG, @LOG_DEBUG, Utils::DEBUG_LOW, Utils::LOG_LOW)\n\n\t\t\t # Sanity check the file size\n if (fsize < 0)\n Utils.printMux(@log, \"\\t\\t*** WARNING: fsize < 0 - skipping!\\n\", @DEBUG, @LOG_DEBUG, Utils::DEBUG_LOW, Utils::LOG_LOW)\n next\n end\n\n # Make sure this file won't push us over the limit\n if (fsize + runningSize) < target\n # take the first file in this bucket \n Utils.printMux(@log, \"\\t\\tAdding '#{file}' and removing from bucket\")\n fileSet.add(file, fsize)\n runningSize += fsize\n \n # Remove the file from the original list\n @data[bkt].delete(file)\n \n # See if we should remove the bucket, too\n if @data[bkt].size() == 0\n @data.delete(bkt)\n Utils.printMux(@log, \"Removed bucket '#{bkt}'\\n\")\n end\n else\n # Go to the next bucket and look at smaller files\n Utils.printMux(@log, \"\\t\\tDropping down to next bucket\\n\")\n break\n end\n\n # Give the CPU a bit of a break in between files\n sleep @sleepInterval\n end # iterate files\n\n # Give the CPU a bit of a break in between buckets\n sleep @sleepInterval\n end # iterate buckets\n \n # Save off the running size in the object\n @totalSize = runningSize\n \n # Save off the file set\n @fileSets << fileSet\n\n Utils.printMux(@log, \"totalSize: #{totalSize}\\n\", @DEBUG, @LOG_DEBUG, Utils::DEBUG_LOW, Utils::LOG_LOW)\n Utils.printMux(@log, \"fileSets:\\n\" + @fileSets.pretty_inspect(), @DEBUG, @LOG_DEBUG, Utils::DEBUG_LOW, Utils::LOG_LOW)\n\n return fileSet\n end",
"def save\n ole = File.open(@file_name, 'w')\n ole << header\n ole << fat\n @storages.each { |s| ole << s.to_s }\n ole << Array.new((512-(ole.pos % 512)), 0).pack('c*')\n ole << mini_fat\n ole << mini_fat_stream\n ole << fat_stream\n ole.close\n end",
"def splitDirectory(directory, array, hash)\n array.each do |num|\n splitData(directory, hash[num])\n end\nend",
"def ingest_new_content( depositor, work, file_str, asset_dir, current, total )\n file_names = file_str.split('|')\n\n puts \"Ingesting row #{current} of #{total}: #{work.title.join} (#{file_names.length} assets)...\"\n\n # handle dry running\n return true if ENV[ 'DRY_RUN' ]\n\n # and upload each file\n file_names.each do |file_name|\n\n # Clamav can't handle file names with space, (, or )\n # Assume they have been removed, but keep them in the label\n adjusted_file_name = file_name.gsub(/[() ]/, '_')\n file_path = File.join( asset_dir, adjusted_file_name )\n\n # remove spaces in filename\n #file_no_spaces = file_path.gsub(' ', '_')\n #File.rename(file_path, file_no_spaces)\n #file_path = file_no_spaces\n\n # Check for existing asset\n if work.file_sets.any? {|fs| fs.title.first == file_name }\n puts \"Skipping existing file: #{file_name}\"\n next\n end\n\n if File.exist?(file_path)\n fileset = TaskHelpers.upload_file( depositor, work, file_path, file_name, work.visibility )\n else\n puts \"File does not exist: #{file_path}\"\n end\n # Upload very slowly...\n sleep(30)\n\n end\n\n return true\n end",
"def create_lists\n pid_files_dir = Rails.root.join('tmp', 'external_files_conversion', timestamp)\n FileUtils.mkdir_p pid_files_dir\n file_path = \"#{pid_files_dir}/large_objects.txt\"\n File.open(file_path, 'w') { |file| file.puts(large_objects) }\n lists_of_pids = small_objects.each_slice(NUMBER_OF_PIDS_PER_FILE).to_a\n lists_of_pids.each_with_index do |list, index|\n file_path = \"#{pid_files_dir}/#{index}.txt\"\n File.open(file_path, 'w') { |file| file.puts(list) }\n pid_lists << file_path\n end\n end",
"def fast_export_file\n mark = next_mark\n text = <<FILE\nblob\nmark #{mark}\n#{fast_export_data 'Yay, data!'}\nFILE\n return [mark, text]\nend",
"def split(zip_file_name, segment_size = MAX_SEGMENT_SIZE, delete_zip_file = true, partial_zip_file_name = nil)\n raise Error, \"File #{zip_file_name} not found\" unless ::File.exist?(zip_file_name)\n raise Errno::ENOENT, zip_file_name unless ::File.readable?(zip_file_name)\n\n zip_file_size = ::File.size(zip_file_name)\n segment_size = get_segment_size_for_split(segment_size)\n return if zip_file_size <= segment_size\n\n segment_count = get_segment_count_for_split(zip_file_size, segment_size)\n # Checking for correct zip structure\n ::Zip::File.open(zip_file_name) {}\n partial_zip_file_name = get_partial_zip_file_name(zip_file_name, partial_zip_file_name)\n szip_file_index = 0\n ::File.open(zip_file_name, 'rb') do |zip_file|\n until zip_file.eof?\n szip_file_index += 1\n save_splited_part(zip_file, partial_zip_file_name, zip_file_size, szip_file_index, segment_size, segment_count)\n end\n end\n ::File.delete(zip_file_name) if delete_zip_file\n szip_file_index\n end",
"def save\n return if File.exists?(file)\n\n # Create parent directories\n FileUtils.mkdir_p(File.dirname(file))\n\n File.open(file, \"w\") do |f|\n f.write(compressed_contents)\n end\n\n puts \"Wrote blob #{file}\"\n end",
"def add_ids_to_file( filename )\n\t\tpath = \"#{ @view_directory }#{ filename }\"\n\t\ttemp_file = Tempfile.new( 'foo' )\n\n\t\tbegin\n\t\t File.open( path, 'r' ) do |file|\n\t\t file.each_line do |line|\n\t\t temp_file.puts show_me_your_id( line )\n\t\t end\n\t\t end\n\t\t temp_file.close\n\t\t FileUtils.mv( temp_file.path, path )\n\t\trescue Exception => e\n\t\t\tbaxter( e )\n\t\tensure\n\t\t temp_file.close\n\t\t temp_file.unlink\n\t\tend\n\tend",
"def hash_file path, hash_store\r\n\thexdigest = HASH_DIGEST.hexdigest(open(path, 'rb') { |io| io.read })\r\n\thash_store[hexdigest] << path\r\nend",
"def writeEntry(bs)\n return if not @dirty\n cluster = @parentCluster; offset = @parentOffset\n buf = bs.getCluster(cluster)\n if @lfn_ents\n @lfn_ents.each {|ent|\n buf[offset...(offset + DIR_ENT_SIZE)] = BinaryStruct.encode(ent, DIR_ENT_LFN)\n offset += DIR_ENT_SIZE\n if offset >= bs.bytesPerCluster\n bs.putCluster(cluster, buf)\n cluster, buf = bs.getNextCluster(cluster)\n offset = 0\n end\n }\n end\n buf[offset...(offset + DIR_ENT_SIZE)] = BinaryStruct.encode(@dir_ent, DIR_ENT_SFN)\n bs.putCluster(cluster, buf)\n @dirty = false\n end",
"def save!\n File.open(@config[\"state_file\"], \"r\") do |fl|\n fl.flock(File::LOCK_EX)\n\n sequence = (@state.key?(\"sequence\") ? @state[\"sequence\"] + 1 : 0)\n data_file = @config[\"data_dir\"] + format(\"/%03d/%03d/%03d.osm.gz\", sequence / 1000000, (sequence / 1000) % 1000, (sequence % 1000))\n tmp_state = @config[\"state_file\"] + \".tmp\"\n tmp_data = \"/tmp/changeset_data.osm.tmp\"\n # try and write the files to tmp locations and then\n # move them into place later, to avoid in-progress\n # clashes, or people seeing incomplete files.\n begin\n FileUtils.mkdir_p(File.dirname(data_file))\n Zlib::GzipWriter.open(tmp_data) do |fh|\n fh.write(changeset_dump(open_changesets))\n end\n @state[\"sequence\"] = sequence\n File.open(tmp_state, \"w\") do |fh|\n fh.write(YAML.dump(@state))\n end\n\n # sanity check: the files we're moving into place\n # should be non-empty.\n raise \"Temporary gzip file should exist, but doesn't.\" unless File.exist?(tmp_data)\n raise \"Temporary state file should exist, but doesn't.\" unless File.exist?(tmp_state)\n raise \"Temporary gzip file should be non-empty, but isn't.\" if File.zero?(tmp_data)\n raise \"Temporary state file should be non-empty, but isn't.\" if File.zero?(tmp_state)\n\n FileUtils.mv(tmp_data, data_file)\n FileUtils.mv(tmp_state, @config[\"state_file\"])\n fl.flock(File::LOCK_UN)\n\n rescue\n STDERR.puts(\"Error! Couldn't update state.\")\n fl.flock(File::LOCK_UN)\n raise\n end\n end\n end",
"def attach_files\n @parent = Work.find_by_friendlier_id!(params[:parent_id])\n authorize! :update, @parent\n\n current_position = @parent.members.maximum(:position) || 0\n\n files_params = (params[:cached_files] || []).\n collect { |s| JSON.parse(s) }.\n sort_by { |h| h && h.dig(\"metadata\", \"filename\")}\n\n files_params.each do |file_data|\n asset = Asset.new()\n\n if derivative_storage_type = params.dig(:storage_type_for, file_data[\"id\"])\n asset.derivative_storage_type = derivative_storage_type\n end\n\n asset.position = (current_position += 1)\n asset.parent_id = @parent.id\n asset.file = file_data\n asset.title = (asset.file&.original_filename || \"Untitled\")\n asset.published = @parent.published\n asset.save!\n end\n\n if @parent.representative_id == nil\n @parent.update(representative: @parent.members.order(:position).first)\n end\n\n redirect_to admin_work_path(@parent.friendlier_id, anchor: \"nav-members\")\n end",
"def addLargeFiletoUUID(pid, filepath)\n addLargeFile(pid,filepath)\n print \"File Uploaded successfully!\"\n end",
"def test_chrm_chunk\n\n each_file_with_updated_info do\n |file_path|\n\n if @test_feature == \"c\" && @parameter[0] == \"c\"\n img = Imgrb::Image.new(file_path, :only_metadata)\n assert_equal [0.3127, 0.3290, 0.64, 0.33, 0.30, 0.60, 0.15, 0.06],\n img.ancillary_chunks[:cHRM][0].get_data\n end\n end\n\n\n img = Imgrb::Image.new(10, 10, [255,155,55])\n chrm_dat = [0.42, 0.32, 0.22, 0.11, 0.55, 0.44, 0.33, 0.22]\n chrm = Imgrb::Chunks::ChunkcHRM.assemble(*chrm_dat)\n img.add_chunk(chrm)\n\n png_str = save_png_to_string(img)\n img_saved = Imgrb::Image.new(png_str, :from_string)\n chrm_dat_saved = img_saved.ancillary_chunks[:cHRM][0].get_data\n\n assert_equal chrm_dat, chrm_dat_saved\n\n end",
"def lock_file\n keynumber = rand(1000000000)\n newfile = \"content#{keynumber}.txt\"\n newpath = \"#{@frpath}#{newfile}\"\n lasterror = \"\"\n\n # Try for up to approximately 12 seconds\n for i in 0..13\n begin\n FileUtils.mv(\"#{@frpath}content.txt\", newpath)\n return newpath\n rescue\n lasterror = $!\n # Sleep a random amount of time. Primes make collisions less likely.\n sleep [1.1,1.3,0.5,0.7][rand(4)]\n end\n end\n raise \"Unable to lock page #{@fitnesse_path} moving #{@frpath}content.txt to #{newpath}: #{lasterror}\"\n end",
"def process_hardlinks\n counter = 0\n @hardlinks.each do |file, target|\n counter += 1 \n\n # in case of recursive redirects, which shouldn't happen, but alas\n recursion = 0\n while @hardlinks[target] && recursion < 3\n recursion += 1\n target = @hardlinks[target]\n end\n\n # we'll just traverse the index and fetch the coords of the target\n sha1, firstfour = sha1_w_sub(file)\n sha1_target, firstfour_target = sha1_w_sub(target)\n\n entries = @index[firstfour_target]\n next if entries.nil?\n\n target = entries.select {|entry| entry.sha1 == sha1_target}\n\n # it really shouldn't be empty... if it is - the redirect is useless\n # anyway\n unless target.empty? \n entry = target[0].dup # so we don't overwrite the original\n\n # we just reuse the same entry, rewrite the sha1, and add it to the index\n entry.sha1 = sha1\n @index[firstfour] ||= [] \n @index[firstfour] << entry\n end\n\n end\n @hardlinks = nil # clean up some memory\n end",
"def upload(chunk_size = 4*1024*1024)\n last_chunk = nil\n\n while @offset < @total_size\n if not last_chunk\n last_chunk = @file_obj.read(chunk_size)\n end\n\n body, result = @client.files.partial_chunked_upload(last_chunk,\n @upload_id, @offset)\n last_chunk = nil\n\n if result.offset > @offset\n @offset = result.offset\n last_chunk = nil\n end\n @upload_id = result.upload_id\n end\n end",
"def store_entries(entries)\n path_checksums = {}\n entries.each do |entry|\n path_checksums[entry.path] = entry.sha256 if entry.sha256.present?\n store_entry entry\n end\n store_checksums path_checksums\n end",
"def update_file\n output = (@blocks[:before] + @blocks[:attributes] + @blocks[:after]).join(\"\\n\").strip + \"\\n\"\n File.open(@filename,'w') { |f| f.write(output) } if output != @file\n end",
"def chunk_url(c)\n\t\tRails.application.routes.url_helpers.chunk_fyle_url(id: self.id.to_s.rjust(3, \"0\"), chunk: c, format: 'txt')\n\tend",
"def update_file_paths \n if self.url_part_was && self.url_part && self.short_name_changed?\n old_url_part = self.url_part\n old_ref_path = self.assignment_reference_repository.git_path\n set_url_part\n \n if old_url_part == self.url_part\n # Nothing changes\n return\n end\n \n self.save\n \n # Move reference repository folder if necessary\n if File.directory?(old_ref_path) \n new_ref_path = String.new(old_ref_path)\n new_ref_path[new_ref_path.index(File.basename(new_ref_path))..-1] = self.url_part\n \n FileUtils.mv old_ref_path, new_ref_path\n end\n \n # Move assignment repositories if necessary\n self.assignment_offerings.each do |assignment_offering|\n old_assignment_repo_path = File.join(\n assignment_offering.course_offering.storage_path,\n 'assignments',\n old_url_part)\n \n if File.directory?(old_assignment_repo_path)\n new_assignment_repo_path = File.join(\n assignment_offering.course_offering.storage_path,\n 'assignments',\n self.url_part) \n \n FileUtils.mv old_assignment_repo_path, new_assignment_repo_path\n end \n \n end\n end\n end",
"def recombinate_files_for_multiple_transfers_possibly\r\n got_end_big_transfer = false\r\n \tif @current_transfer_file =~ /recombinate_ok/\r\n\t recombinate_files_split_piece_wise @copied_files\r\n\t @copied_files = []\r\n\t got_end_big_transfer = true\r\n\tend\r\n\t@current_transfer_file = nil\r\n\tgot_end_big_transfer\r\n end",
"def descramble_file( path )\n pathname = Pathname.new( path )\n # Not exist Pathname#binwrite on Ruby 2.0.0\n #pathname.binwrite( descramble( pathname.binread ) )\n IO.binwrite( pathname, descramble( pathname.binread ) )\n end",
"def write_file_list\n if EventMachine.reactor_thread? || !@update_lock.locked?\n raise 'Should not write file list in reactor thread or without' \\\n ' the local list lock!'\n end\n\n FileUtils.mkdir_p config.config_dir\n @local_file_list.root['CID'] = SecureRandom.hex(12).upcase\n output = @local_file_list.to_s(:indent => true)\n Bzip2::Writer.open(local_file_list_path, 'wb') { |f| f << output }\n @share_size = nil\n\n output = Marshal.dump([@local_file_info, @shared_directories])\n File.open(cache_file_list_path, 'wb'){ |f| f << output }\n end",
"def group_files file_data, output_path, options = {:prefix => \"L\", :suffix => \".fastq.gz\", :exclude_undetermined => true}\n\t\t\t\t# alternatively inherit the parent class and call super???? \n\t\t\t\t# super \n\t\t\t\t# \t\n groups = {}\n file_data.each do |data|\n if data[:barcode] == \"Undetermined\" and options[:exclude_undetermined]\n log \"# Undetermined sample lane: #{data[:lane]} - name: #{data[:sample_name]}. Skipping\"\n next\n end\n \n group_key = name_for_data data, options\n \n if groups.include? group_key\n if groups[group_key][:sample_name] != data[:sample_name]\n raise \"ERROR: sample names not matching #{group_key} - #{data[:path]}:#{data[:sample_name]}vs#{groups[group_key][:sample_name]}\"\n end\n if groups[group_key][:lane] != data[:lane]\n raise \"ERROR: lanes not matching #{group_key} - #{data[:path]}\"\n end\n groups[group_key][:files] << data\n else\n group_path = File.join(output_path, group_key)\n groups[group_key] = {:group_name => group_key,\n :path => group_path,\n :sample_name => data[:sample_name],\n :read => data[:read],\n :lane => data[:lane],\n :files => [data]\n }\n end\n end\n \n # sort based on read set\n groups.each do |key, group|\n group[:files] = group[:files].sort {|x,y| x[:set] <=> y[:set]}\n group[:paths] = group[:files].collect {|data| data[:path]}\n end\n groups.values\n end",
"def commit\n # TODO\n # Update ./docProps\n # app.xml slides, notes, counts, etc\n # core.xml Times\n entries.each do |path, buffer|\n path = path.to_s\n if @original_files.include? path\n @zip.replace_buffer path, buffer\n else\n @zip.add_buffer path, buffer\n end\n end\n @zip.commit\n end",
"def create_final_contract(address, final_contract, files_to_load, table_of_contents)\n files_to_load.unshift(\"table_of_contents.pdf\")\n files_to_load.each do |file|\n\n final_contract << CombinePDF.load(file)\n end\n\n final_contract.save \"#{address}_final_contract.pdf\"\nend",
"def process_and_write_to file\n \n return unless @is_relevant\t\n\n # svnadmin: Malformed dumpstream: Revision 0 must not contain node records\n #\n # so discard revision without nodes, _except_ for revision 0\n if @nodes.empty? && @num > 0\n return\n end\n\n file.puts \"# process_and_write #{self}\" if $debug\n\n faked_nodes = []\n\n @nodes.each do |node|\n \n next if node.action == :delete\n\n # check node.path and if we already have all parent dirs\n path = node.path\n if node.kind == :file\n\tpath = File.dirname(path)\n elsif node.kind == :dir\n\tcase node.path\n\twhen \"trunk\", \"branches\", \"tags\"\n\t next\n\tend\n end\n last_relevant, last_path = find_and_write_last_relevant_for path, file\n exit 1 unless last_relevant\n # check if this was an 'extra' path and if we have to add directories\n \n # if the node creates the dir path, then the dirname is missing, not the full path\n # (for the 'file' case, we take the parent dir already above)\n #\n missing_path = (node.kind == :dir) ? File.dirname(path) : path\n if $extra_pathes[node.path] &&\n\t last_path != missing_path # last_relevant was a parent\n missings = []\n\twhile last_path != missing_path\n\t missings << File.basename(missing_path)\n\t missing_path = File.dirname(missing_path)\n\t break if missing_path == \".\"\n\tend\n\t# consistency check. Maybe last_past was no parent ?!\n\tif missing_path == \".\"\n\t STDERR.puts \"Couldn't find missing directories\"\n\t STDERR.puts \"Last directory was #{last_path}\"\n\t STDERR.puts \"Missings #{missings.inspect}\"\n\t exit 1\n\tend\n # add fake nodes to create missing directories\n\twhile !missings.empty?\n\t missing_path = File.join(missing_path, missings.pop)\n\t unless $created_extras[missing_path]\n\t file.puts \"# Create #{missing_path}\" if $debug\n\t faked_nodes << FakeNode.new(:dir, :add, missing_path)\n\t $created_extras[missing_path] = true\n\t end\n\tend\n end\n\n if $extra_pathes[node.path]\n\tunless $created_extras[node.path]\n#\t STDERR.puts \"Cutting history for #{node} at rev #{@num}\"\n\t # the extra file could be a 'change' node. This happens\n\t # if it was created in another directory and then the directory\n\t # was renamed. Instead of backtracking directory renames, we cut\n\t # history here and make it an 'add' node\n\t node.action = :add if node.action == :change\n\t $created_extras[node.path] = true\n\tend\n end\n\n # check for Node-copyfrom-path and evtl. rewrite / backtrack\n\n path = node['Node-copyfrom-path']\n if path\n\t# backtrack, find last relevant revision for this path\n\trevnum = node['Node-copyfrom-rev'].to_i\n\tlast_relevant, last_path = find_and_write_last_relevant_for path, file, revnum\n\texit 1 unless last_relevant\n\tnewnum = @@revision_number_mapping[last_relevant.num]\n\tfile.puts \"# Node-copyfrom-rev #{revnum} -> #{newnum}<#{last_relevant.num}>\" if $debug\n\tnode['Node-copyfrom-rev'] = newnum\n end\n end # nodes.each\n \n # write Revision item\n \n self.copy_to file\n # write nodes\n faked_nodes.each do |node|\n node.copy_to file\n end\n @nodes.each do |node|\n node.copy_to file\n path = node.path\n while path != \".\"\n\t@@last_relevant_for[path] ||= []\n\t@@last_relevant_for[path] << self\n\tpath = File.dirname(path)\n end\n end\n end",
"def write_to_file\n File.open(config.block_list_path, 'a') do |f|\n block_count = old_newest_block ? (block_list.size - old_newest_block.height - 1) : block_list.size\n block_list = self.block_list.sort{|(k1, v1), (k2, v2)| v1.height <=> v2.height}\n block_list = block_list[(old_newest_block.height + 1)..-1] if old_newest_block\n block_list.each_with_index do |(k, b), index|\n f.write(b.to_payload)\n f.flush\n print \"\\r#{(((index + 1).to_f / block_count) * 100).to_i}% done write parsed block to #{config.block_list_path}.\"\n end\n f.write(newest_block.to_payload)\n puts\n end\n end",
"def upload_chunk_intelligently(job, state, apikey, filepath, io, options, storage)\n file = filepath ? File.open(filepath) : io\n file.seek(job[:seek_point] + job[:offset])\n\n chunk = file.read(state.offset)\n md5 = Digest::MD5.new\n md5 << chunk\n data = {\n apikey: apikey,\n part: job[:part],\n size: chunk.length,\n md5: md5.base64digest,\n uri: job[:uri],\n region: job[:region],\n upload_id: job[:upload_id],\n store: { location: storage },\n offset: job[:offset],\n fii: true\n }\n\n data = data.merge!(options) if options\n\n fs_response = Typhoeus.post(FilestackConfig.multipart_upload_url(job[:location_url]),\n body: data.to_json,\n headers: FilestackConfig::HEADERS)\n\n # POST to multipart/upload\n begin\n unless fs_response.code == 200\n if [400, 403, 404].include? fs_response.code\n raise 'FAILURE'\n else\n raise 'BACKEND_SERVER'\n end\n end\n\n rescue\n raise 'BACKEND_NETWORK'\n end\n fs_response = JSON.parse(fs_response.body)\n\n # PUT to S3\n begin\n amazon_response = Typhoeus.put(\n fs_response['url'], headers: fs_response['headers'], body: chunk\n )\n unless amazon_response.code == 200\n if [400, 403, 404].include? amazon_response.code\n raise 'FAILURE'\n else\n raise 'S3_SERVER'\n end\n end\n\n rescue\n raise 'S3_NETWORK'\n end\n amazon_response\n end",
"def each_chunk\n iend_reached = false\n File.open(@file_path, 'rb') do |file|\n # check if file is not PNG at all\n return false if file.read(8) != PNG_MAGIC_NUMBER\n\n chunks = 0\n\n # We could be dealing with large number of chunks,\n # so the code should be optimized to create as few objects as possible.\n # All literal strings are frozen and read() function uses string buffer.\n chunkheader = ''\n while file.read(8, chunkheader)\n # ensure that first 8 bytes from chunk were read properly\n if chunkheader.nil? || chunkheader.length < 8\n return false\n end\n\n current_pos = file.tell\n\n chunk_len, chunk_name = chunkheader.unpack(\"Na4\".freeze)\n return false if chunk_name =~ /[^A-Za-z]/\n yield chunk_name, chunk_len, file\n\n # no need to read further if IEND is reached\n if chunk_name == \"IEND\".freeze\n iend_reached = true\n break\n end\n\n # check if we processed too many chunks already\n # if we did, file is probably maliciously formed\n # fail gracefully without marking the file as corrupt\n chunks += 1\n if chunks > 100_000\n iend_reached = true\n break\n end\n\n # jump to the next chunk - go forward by chunk length + 4 bytes CRC\n file.seek(current_pos + chunk_len + 4, IO::SEEK_SET)\n end\n end\n\n iend_reached\n end",
"def wrote_fasta_files(current)\n if current % increment == 0\n info.attributes = {\n percent_complete: percent(current)/2,\n message: \"Wrote fasta files for #{current}/#{species_count} species\"\n }\n info.save(path)\n end\n end",
"def flush\n flush_block unless @buffer.empty? \n process_hardlinks\n\n # writing the location of the archive (it's after the dump data)\n writeloc(@file, [@location].pack('V'), 0) \n\n indexloc = @location\n location = (sha1subset('FFFFFFFFFF', @idx_size) * 8) + indexloc\n # p = File.open(\"zlog\", \"w\")\n each_entry_with_index do |entry, idx|\n next if entry.nil? \n\n writeloc(@file, [location, entry.size].pack('V2'), (idx * 8) + indexloc)\n writeloc(@file, entry, location)\n\n # p << \"*\" * 80 << \"\\n\" \n # p << \"seek #{(idx * 8) + indexloc} location #{location} size #{entry.size}\" << \"\\n\"\n # p << unpack(entry).join(\":\") << \"\\n\"\n\n location += entry.size\n end\n\n # meta location\n writeloc(@file, [location, @compressor.method, @idx_size].pack('VCC'), 4)\n\n writeloc(@file, Marshal.dump(@meta), @location) if defined?(@meta)\n\n @file.close\n end",
"def put_raw_object(content, type)\n size = content.length.to_s\n LooseStorage.verify_header(type, size)\n \n header = \"#{type} #{size}\\0\"\n store = header + content\n \n sha1 = Digest::SHA1.hexdigest(store)\n path = @directory+'/'+sha1[0...2]+'/'+sha1[2..40]\n \n if !File.exists?(path)\n content = Zlib::Deflate.deflate(store)\n \n FileUtils.mkdir_p(@directory+'/'+sha1[0...2])\n File.open(path, 'w') do |f|\n f.write content\n end\n end\n return sha1\n end",
"def add data, offset\n next_frag = 0\n $LOG.debug \"Setting partition at offset \" + offset.to_s + \" To \" + data\n len = data.length\n\n # can we fit it in??\n # lets say no. so we have to create a ????? and use that as\n # an enumerator\n #\n\n \n\n dary = [data].pack(\"a*\").unpack(\"C*\")\n @part[offset, dary.length] = dary\n\n @part[(offset + dary.length), 2] = [next_frag].pack(\"n\").unpack(\"C2\")\n \n @rem -= (dary.length + FileSystem::get_link_size)\n end",
"def grouped(files); end",
"def files_to_final_location\n if @temp_file && (@temp_file.size > 0)\n logger.info(\"Saving attachment '#{self.filename}' (#{@temp_file.size} bytes) to database\")\n md5 = Digest::MD5.new\n buffer = \"\"\n self.data = \"\"\n while (buffer = @temp_file.read(8192))\n md5.update(buffer)\n self.data << buffer\n end\n self.digest = md5.hexdigest\n end\n @temp_file = nil\n # Don't save the content type if it's longer than the authorized length\n if self.content_type && self.content_type.length > 255\n self.content_type = nil\n end\n end",
"def split_upids(idmap_file)\n puts \"split idmapping.dat to each prefix files\"\n up_refp_output = prepare_prefix_files(idmap_file, \"protein_id\")\n up_refg_output = prepare_prefix_files(idmap_file, \"gene_id\")\n\n cnt = 0\n # it is assumed that the tax_id is followed by a protein_id or gene_id\n current_tax = {upid: nil, tax_id: nil}\n taxid_missing_list = [] \n File.open(idmap_file, \"r\") do |f|\n f.each_line do |line|\n up, xref, id = line.strip.split(\"\\t\")\n case xref\n when \"NCBI_TaxID\"\n current_tax = {upid: up.split(\"-\").first, tax_id: id}\n when \"RefSeq\", \"GeneID\"\n # Push only the tax_id with refseq protein_id or gene_id\n if current_tax[:upid] == up.split(\"-\").first\n if xref == \"RefSeq\"\n prefix = id.chomp.strip[0..4]\n up_refp_output[prefix].puts line.chomp.strip + \"\\t\" + current_tax[:tax_id]\n elsif xref == \"GeneID\"\n prefix = id.chomp.strip[0]\n up_refg_output[prefix].puts line.chomp.strip + \"\\t\" + current_tax[:tax_id]\n end\n else\n taxid_missing_list.push(up)\n end\n end\n cnt += 1\n if (cnt % 100000 == 0)\n puts cnt\n end\n end\n # list of upid that can't get taxid. Depends on the order of idmapping.dat\n out = File.open(\"taxid_missing_list.json\", \"w\") unless taxid_missing_list.size == 0\n taxid_missing_list.each do |upid|\n out.puts JSON.pretty_generate(taxid_missing_list)\n end\n end\n\n # close files\n up_refp_output.each do |k, v|\n v.flush\n v.close\n end\n up_refg_output.each do |k, v|\n v.flush\n v.close\n end\nend",
"def name\n chunk_name = nil\n File.open(@file_name) do |file|\n file.seek(@offset, IO::SEEK_CUR)\n chunk_name = file.read(4)\n end\n puts \"[WARNING] - Doesn't look like a valid chunk name: #{chunk_name}\" if @warnings && !(chunk_name =~ /^[\\w ]{4}$/)\n chunk_name\n end",
"def generate_basename(chunk)\n salt = nil\n while true\n filename = Digest::MD5.hexdigest(\"#{chunk.range_start}#{salt}\") + CHUNK_EXT\n return filename unless chunks_by_basename[filename]\n salt = (salt||0) + 1\n end\n end",
"def store_backup\n ret = true\n base = Util.data_path(EMMConfig[\"DATA_BACK_DIR\"])\n $files.each do |f|\n # directory of the file \n # LSMSS10, LSMSS30 , etc\n dir = File.basename(File.expand_path(\"#{f}/..\"))\n back_path = base + \"/\" + dir + \"/\" + File.basename(f)\n cmd = \"mv #{f} #{back_path}\"\n unless system(cmd)\n $stderr.puts \"Move #{cmd} did not work ... Next\" if $opts[:v]\n ret = false\n next\n end\n\n # compress the file\n cmd = EMMConfig[\"COMPRESS\"] + \" #{back_path}\"\n unless system(cmd)\n $stderr.puts \"Compress #{cmd} did not work ... Next\" if $opts[:v]\n ret = false\n next\n end\n end \n ret\nend",
"def bundleTimestampBundleSize(dest_folder,new_timestamp,max_size) \n puts \"Modifying timestamp based on size\"\n max_size=max_size*1024\n target_folder=\"\"\n# ts= Time.parse(new_timestamp.utc.to_s().split(\"UTC\").first)\n ts= Time.parse(new_timestamp.to_s())\n initial_ts=ts\n fileSize=0 \n total_file_count=0 \n old_output_ihtml=@outputRenamed+\"/ihtml/\" \n # Timestamp new files \n @files = Dir.glob(dest_folder+\"**/**\")\n for file in @files\n partName=file.split(dest_folder).last\n if !(File.exists?old_output_ihtml+partName) && !(File.directory?(file))\n if !file.to_s().end_with?(\"searchDB.sql\") && !file.to_s().end_with?(\"deletedFiles.list\")\n fileSize=fileSize+File.size(file) \n if(fileSize>=max_size)\n ts=ts+60\n fileSize=File.size(file)\n end \n File.utime(ts, ts, file)\n total_file_count=total_file_count+1\n # Add to zip bundle \n target_folder=zipBundle(file,ts)\n end\n end\n if !(File.exists?old_output_ihtml+partName) && File.directory?(file) \n File.utime(ts, ts, file)\n end\n end \n # searchDB.sql timestamp as the last bundle of new files but before edited files\n if File.exists?(dest_folder+\"searchDB.sql\") \n fileSize=fileSize+File.size(dest_folder+\"searchDB.sql\") \n if(fileSize>=max_size && total_file_count!=0)\n ts=ts+60 \n fileSize=File.size(dest_folder+\"searchDB.sql\") \n end \n File.utime(ts, ts, dest_folder+\"searchDB.sql\")\n total_file_count=total_file_count+1\n # Add to zip bundle \n archive=zipBundle(dest_folder+\"searchDB.sql\",ts)\n end\n # Timestamp edited files after new files and searchDB.sql\n @files = Dir.glob(dest_folder+\"**/**\")\n for file in @files\n partName=file.split(dest_folder).last\n if File.exists?(old_output_ihtml+partName) && !(File.directory?(file))\n if !file.to_s().end_with?(\"searchDB.sql\") && !file.to_s().end_with?(\"deletedFiles.list\")\n fileSize=fileSize+File.size(file) \n if(fileSize>=max_size)\n ts=ts+60\n fileSize=File.size(file)\n end \n File.utime(ts, ts, file) \n total_file_count=total_file_count+1\n # Add to zip bundle \n archive=zipBundle(file,ts) \n end\n end\n if File.directory?(file)\n File.utime(initial_ts, initial_ts, file)\n end \n end \n # Timestamp deleted file as last bundle\n if (File.exists?(dest_folder+\"deletedFiles.list\"))\n fileSize=fileSize+File.size(dest_folder+\"deletedFiles.list\") \n if(fileSize>=max_size)\n ts=ts+60\n fileSize=File.size(dest_folder+\"deletedFiles.list\") \n end \n File.utime(ts, ts, dest_folder+\"deletedFiles.list\")\n total_file_count=total_file_count+1\n # Add to zip bundle \n archive=zipBundle(dest_folder+\"deletedFiles.list\",ts) \n end\n generateZipBundle() \n @latest_ts=ts+60\nend",
"def doing_raw_file_to_verified_unique_researches # adjustable line length filter\n consumer = Fiber.new do |producer, queue|\n a = File.read(\"../../Documents/20111224-research.txt\")\n\t new = a.to_textual\n#TODO finishe\t \n @megadata = a.sort do |x,y|\n x.downcase <=> y.downcase\n end\n @megadata_unique = @megadata.uniq\n f = open(\"./tmp/database_doings/doing_uniques/uniques_done.txt\", \"a\") do |f| \n loop do\n queue = producer.transfer(consumer, queue)\n puts f << queue\n queue.clear\n end\n raise StopIteration\n end\n end\n producer = Fiber.new do |consumer, queue|\n #IO.foreach(\"./tmp/database_doings/doing_uniques/uniques_todo.txt\") do |line|\n queue = \"\"\n puts queue\n @megadata_unique.each do |line|\n sequence_text = line.to_textual.de_comma\n if sequence_text.length < 50 # adjustable\n puts \"line ignored due to length\"\n elsif Sequence.find_by_sequence_text(sequence_text)\n puts \"line ignored as it is already in database : \" + \"#{sequence_text}\"\n else\n sequence_creation = sequence_text.de_space unless nil\n sequence_complete = sequence_text.split(//).sort.join('').strip unless nil\n sequence_lexigram = lexigram_sequencer(sequence_text) unless nil\n sequence_singular = sequence_complete.squeeze unless nil\n description = \"research\"\n reference = \"literoti\"\n anagram = 0\n name = 0\n phrase = 0\n research = 1\n external = 0\n internal = 0\n created_at = \"2011-12-21 12:12:00\"\n #line = \"#{sequence_text}\\n\"\n line = \"#{sequence_text}\\t#{sequence_creation}\\t#{sequence_complete}\\t#{sequence_lexigram}\\t#{sequence_singular}\\t#{description}\\t#{reference}\\t#{anagram}\\t#{name}\\t#{phrase}\\t#{research}\\t#{external}\\t#{internal}\\t#{created_at}\\n\"\n queue << line\n break unless line\n consumer.transfer queue\n queue.clear\n end\n end\n end\n raise StopIteration\n end",
"def upgrade_file_key(key, save = true)\n cname = self.collection.name\n\n files = self.database[\"#{cname}.files\"]\n chunks = self.database[\"#{cname}.chunks\"]\n\n fname = self[\"_#{key}\"] rescue nil\n return if fname.blank?\n\n begin\n n = Mongo::GridIO.new(files, chunks, fname, \"r\", :query => {:filename => fname})\n\n v = n.read\n\n if !v.empty?\n data = StringIO.new(v)\n self.put_file(key, data)\n self[\"_#{key}\"] = nil\n\n self.save(:validate => false) if save\n end\n rescue => e\n puts \"ERROR: #{e}\"\n puts e.backtrace.join(\"\\t\\n\")\n return\n end\n\n files.remove(:_id => fname)\n chunks.remove(:_id => fname)\n end",
"def resize(data_size)\n @fileobj.seek(@offset + 4)\n @fileobj.write([data_size].pack('I>'))\n unless @parent_chunk.nil?\n size_diff = @data_size - data_size\n @parent_chunk.resize(@parent_chunk.data_size - size_diff)\n end\n @data_size = data_size\n @size = data_size + HEADER_SIZE\n end",
"def add(filename)\n raise StandardError, \"That filename is invalid, its too long\" if filename.length > 255\n # Get the next record number\n p n = getNextRecordNumber\n \n filename = File.expand_path(filename)\n filename.gsub!(/^([a-z])/){$1.upcase}\n \n utf8 = filename\n # Are there any UTF8 characters to deal with?\n if not filename =~ /^[\\x21-\\x7E]+$/i\n # Use File::SEPARATOR\n filename = filename[0,3]+(filename[3..-1].split(\"\\\\\").collect { |chunk| ((chunk =~ /^[\\x21-\\x7E]+$/i) ? chunk : chunk.gsub(/([^a-z0-9_])/i,\"\")[0..5].upcase+\"~1\"+File.extname(chunk))}.join(\"\\\\\"))\n end\n \n test = open(\"temp.txt\",\"w\")\n # Go to the end of the file, where the next record needs to be written\n @fh.sysseek(0, IO::SEEK_END)\n @fh.write filename.ljust(280,\"\\000\")\n @fh.write [n].pack(\"V\")\n @fh.write [filename.match(/^([A-Z]):/i)[1].upcase[0] - 65].pack(\"V\")\n @fh.write [((Time.now.to_f+11644473600)*(10**7)).to_i].pack(\"Q\")\n @fh.write [(open(utf8).read.length / Sys::Filesystem.stat(filename[0,3]).block_size).ceil].pack(\"V\")\n @fh.write Iconv.new(\"UTF-16LE\",\"UTF-8\").iconv(utf8).ljust(520,\"\\000\")\n @fh.write \"\\x0D\\x0A\"\n \"D#{filename[0..0].downcase}#{n+1}\"+File.extname(utf8)\n end",
"def make_bag\n move_files_to_bag\n bag.write_chipmunk_info(common_tags.merge(audio_metadata))\n bag.download_metadata\n bag.manifest!\n end",
"def splitData(directory, item)\n n = rand * 10\n if n < 3\n outputText = File.open(directory + 'test' + 'text/' + 'clean'+ item + '.txt', 'w')\n else\n outputText = File.open(directory + 'text/' + 'clean' + item + '.txt', 'w')\n end\n writeFile(outputText, directory, item)\nend",
"def writeFinalSequenceFrag()\n outFile = File.new(@seqNameRead1, \"w\")\n\n @read1FileList.each do |file|\n reader = Zlib::GzipReader.open(file)\n while(line = reader.gets)\n line.strip!\n\n if line.match(/^@/)\n @numReadsRead1 = @numReadsRead1 + 1\n\n # Read next 3 lines to complete reading 1 Fastq record\n readString = reader.gets.strip\n qualHeader = reader.gets.strip\n qualString = reader.gets.strip\n\n if line.match(/\\s\\d:N:/)\n @numFilteredRead1 = @numFilteredRead1 + 1\n writeFastqRecordToFile(outFile, line, readString, qualHeader,\n qualString)\n end\n end\n end\n reader.close\n end\n outFile.close\n end"
] | [
"0.66069794",
"0.63819015",
"0.6312199",
"0.61628807",
"0.60527945",
"0.5902103",
"0.5734337",
"0.5718231",
"0.56422997",
"0.55895823",
"0.55892223",
"0.54797614",
"0.5440361",
"0.5380231",
"0.53789425",
"0.53715587",
"0.5365633",
"0.5340018",
"0.5335716",
"0.5282279",
"0.5259509",
"0.52098024",
"0.5189629",
"0.5149994",
"0.51415837",
"0.5125275",
"0.50928074",
"0.5078487",
"0.5075971",
"0.50631446",
"0.50487566",
"0.5041094",
"0.50301945",
"0.5024062",
"0.5011246",
"0.5009556",
"0.5008776",
"0.4989633",
"0.49769834",
"0.4971401",
"0.49632403",
"0.49395734",
"0.49347925",
"0.49189216",
"0.4917213",
"0.49008614",
"0.4899947",
"0.4886977",
"0.4878782",
"0.48719347",
"0.48645",
"0.48630002",
"0.48602653",
"0.4858655",
"0.485147",
"0.48404124",
"0.48325613",
"0.48277104",
"0.48205346",
"0.48179996",
"0.48174033",
"0.4814549",
"0.48091596",
"0.48031124",
"0.48030907",
"0.47943303",
"0.4790298",
"0.47891155",
"0.47794947",
"0.47761473",
"0.47731763",
"0.47720525",
"0.47677985",
"0.47674322",
"0.476156",
"0.47554895",
"0.4753497",
"0.47513795",
"0.4748992",
"0.47488248",
"0.47360876",
"0.47307417",
"0.47263527",
"0.47261345",
"0.4721802",
"0.47210312",
"0.4715851",
"0.47078112",
"0.47074187",
"0.46983823",
"0.4696828",
"0.469661",
"0.46964702",
"0.46949875",
"0.46927074",
"0.46900827",
"0.46892637",
"0.46841362",
"0.46797583",
"0.4673123"
] | 0.64926106 | 1 |
check that a same file is not stored twice | def test_no_duplicated_file
#emulate the saving of a file whose content is 'test content'
@writer.save_file('test content')
#an exception should be raised by ioservice if file is attempted to be saved twice
assert_nothing_thrown do
@writer.save_file('test content')
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def already_stored?\n !file_uniqueness\n end",
"def path_is_unique\n return true if self.mp3.file.blank?\n\n # Guess what the audio path will be before it's actually saved there.\n # This is predictable for uploaded audio.\n # This could potentially fail if someone was uploading audio at exactly\n # midnight and some audio already existed for the next day.\n path = File.join(\n AUDIO_PATH_ROOT,\n self.store_dir,\n self.filename\n )\n\n if File.exist?(path)\n self.errors.add(:mp3, \"A file with that name already exists; \" \\\n \"please rename your local audio file and try again. \" \\\n \"If you are trying to replace the audio file, first delete the \" \\\n \"old audio.\")\n end\n end",
"def file_different?\n if @name && File.exist?( @name )\n Digest::MD5.hexdigest(\n @lines.join( \"\\n\" )\n ) != Digest::MD5.hexdigest(\n File.read( @name )\n )\n else\n true\n end\n end",
"def verify_identical_file!(bucket_file)\n disk_contents = IO.binread(path_for(bucket_file.bucket_path, bucket_file.checksum_data, 'contents'))\n\n # If the contents don't match, then we've found a conflict.\n # Unlikely, but quite bad.\n if disk_contents != bucket_file.contents\n raise Puppet::FileBucket::BucketError, \"Got passed new contents for sum #{bucket_file.checksum}\"\n else\n Puppet.info \"FileBucket got a duplicate file #{bucket_file.checksum}\"\n end\n end",
"def check_files\n updated = []\n files.each do |filename, mtime| \n begin\n current_mtime = File.stat(filename).mtime\n rescue Errno::ENOENT\n # file was not found and was probably deleted\n # remove the file from the file list \n files.delete(filename)\n next\n end\n if current_mtime != mtime \n updated << filename\n # update the mtime in file registry so we it's only send once\n files[filename] = current_mtime\n puts \"quick_serve: spotted change in #{filename}\"\n end\n end\n QuickServe::Rails::Snapshot.reset if updated != []\n false\n end",
"def object_filepaths_unique?\n filepaths.count == filepaths.uniq.count\n end",
"def files_are_same(file1, file2)\n begin\n File.open(file1, 'rb').read == File.open(file1, 'rb').read\n rescue\n false\n end\nend",
"def test_does_not_duplicate_if_file_already_exists\n test_file = 'extractor_test_small_sample'\n src_directory = File.join('testRawData', 'pdf/')\n dst_directory = File.join('testExtractedData', 'pdf/')\n\n\tnumber_files_before = TestUtils.count_files_directory(dst_directory)\n\n # Order of tests is not guaranteed, so create the file if necessary\n if (not File.exists?(\"#{dst_directory}#{test_file}.txt\"))\n system(\"#{$extractor_command} #{src_directory}#{test_file}.pdf #{dst_directory}\")\n number_files_before = number_files_before + 1\n end\n system(\"#{$extractor_command} #{src_directory}#{test_file}.pdf #{dst_directory}\")\n number_of_files_after = TestUtils.count_files_directory(dst_directory)\n \n assert_equal number_files_before, number_of_files_after\n end",
"def check_data\n if MissouriDatum.last.new_file\n @downloads.each_with_index do |download, index|\n obj = s3.bucket('missouridata').object(\"new/#{file_names[index]}\")\n @file_status = \"new\"\n puts \"new file\"\n upload(obj, download)\n end\n else \n downloads.each_with_index do |download, index|\n obj = s3.bucket('missouridata').object(\"same/#{file_names[index]}\")\n @file_status = \"same\"\n puts \"same file\"\n upload(obj, download)\n end\n end \n end",
"def identical?(file1, file2)\n File.identical?(file1, file2)\n end",
"def files_same?(file1, file2) \n if (File.size(file1) != File.size(file2)) then\n return false\n end\n f1 = IO.readlines(file1)\n f2 = IO.readlines(file2)\n if ((f1 - f2).size == 0) then\n return true\n else\n return false\n end\n end",
"def files_same?(file1, file2) \n if (File.size(file1) != File.size(file2)) then\n return false\n end\n f1 = IO.readlines(file1)\n f2 = IO.readlines(file2)\n if ((f1 - f2).size == 0) then\n return true\n else\n return false\n end\n end",
"def files_same?(file1, file2) \n if (File.size(file1) != File.size(file2)) then\n return false\n end\n f1 = IO.readlines(file1)\n f2 = IO.readlines(file2)\n if ((f1 - f2).size == 0) then\n return true\n else\n return false\n end\n end",
"def sameFile( fileA, fileB )\n\n\n # Both exist.\n return false unless File.exists?( fileA ) and File.exists?( fileB )\n # Both are the same size.\n aBytes = File.stat( fileA ).size\n bBytes = File.stat( fileB ).size\n return false unless aBytes == bBytes\n\n # Random sample comparison.\n same = true\n $options[:samples].times do \n start = rand( aBytes ) \n length = [aBytes, start + SampleSize].min - start + 1\n aSample = File.read( fileA, length, start )\n bSample = File.read( fileB, length, start )\n same = same && aSample == bSample\n end\n return same\nrescue\n STDOUT.puts \"ERROR: Can't read file [#{fileA}]\"\n $errorCount += 1\n return true # So we don't get two messages for the same file\nend",
"def sameFile( fileA, fileB )\n\n # If symlinks, make sure they link to the same thing.\n if File.symlink?( fileA ) || File.symlink?( fileB )\n return false unless File.symlink?( fileA ) and File.symlink?( fileB )\n linkA = File.readlink( fileA )\n linkB = File.readlink( fileB )\n return linkA == linkB\n end\n\n # Both exist.\n return false unless File.exists?( fileA ) and File.exists?( fileB )\n # Both are the same size.\n aBytes = File.stat( fileA ).size\n bBytes = File.stat( fileB ).size\n return false unless aBytes == bBytes\n\n # Random sample comparison.\n same = true\n $options[:samples].times do\n start = rand( aBytes )\n length = [aBytes, start + SampleSize].min - start + 1\n aSample = File.read( fileA, length, start )\n bSample = File.read( fileB, length, start )\n same = same && aSample == bSample\n end\n return same\nrescue\n STDOUT.puts \"ERROR: Can't read file [#{fileA}]\"\n $errorCount += 1\n return true # So we don't get two messages for the same file\nend",
"def test_reuse_single_file2\n CheckFile @writer, @ioservice, @adlers, 'try with try with', ['try w', 'ith ', 'try w', 'ith']\n end",
"def validate_name_uniqueness\n existing_files = ProjectFile.where(directory_id: directory_id, \n project_id: project_id, name: name)\n unless existing_files.empty? or (existing_files.size == 1 and \n existing_files.first == self)\n errors.add(:name, \"must be unique within a folder; please \"+\n \"change #{project.name}:#{path} to something different.\")\n end\n end",
"def already_uploaded?\n false\n seen_before = Zaphod::PhotoStorage.get(\"seen_id_#{@post_id}\",\"recommendation\")\n if seen_before && seen_before == @post_id\n @log.debug(\"already uploaded ID #{seen_before}... skipping\")\n true\n end\n end",
"def file_new?(file)\n MTIMES[file].nil?\n end",
"def previously_ran?\n File.exist?(previous_runs_filename)\n end",
"def test_reuse_single_file\n CheckFile @writer, @ioservice, @adlers, 'test tests test ', ['test ', 'tests', ' ', 'test ']\n end",
"def ignore_blanks_and_duplicates\n if (self.image_file_name.nil? || self.image_file_name.blank?) && (self.unique_image_file_name.nil? || self.unique_image_file_name.blank?)\n self.errors[:unique_image_file_name].push 'cannot be blank unless uploading from a browser'\n return false\n end\n \n master = self.variant.product.master\n if !master.nil?\n master.variant_images.each do |i|\n if i.unique_image_file_name==self.unique_image_file_name \n self.errors[:unique_image_file_name].push 'is a duplicate with a master image'\n return false\n end\n end\n end\n end",
"def same_file?(a, b)\n File.expand_path(a) == File.expand_path(b)\n end",
"def duplicate?\n\t\tother = Ng2::WordDetail.find(@word).last\n\t\t!other.nil? &&\n\t\tother.file_path == self.file_path &&\n\t\tother.line_no == self.line_no &&\n\t\tother.word_no == self.word_no\n\tend",
"def previously_existed?\n true\n end",
"def same_files?(*files)\n images = files.map { |fname| Digest::MD5.digest(File.binread(fname)) }\n images.all? { |img| img == images[0] }\nend",
"def identical?\n exists? && File.identical?(render, destination)\n end",
"def has_duplicate_import?\n duplicate_imports_info.length > 0\n end",
"def is_new?\n !File.exists? @filename\n end",
"def stored?(file)\n ok_file = get_ok_file_for(file)\n fail_file = get_fail_file_for(file) \n if ( File.exists?(ok_file) or File.exists?(fail_file) )\n return true\n end \n return false\n end",
"def find_path_validation\n\t\troot_storage_path = Rails.root.join 'public', 'musics', '000', '000'\n\t\tlatest_path = root_storage_path.children.sort.last\n\t\tif Dir.entries(latest_path).last == self.audio_file_name\n\t\t\ttrue\n\t\telse\n\t\t\tself.destroy\n\t\t\tfalse\n\t\tend\n\tend",
"def files_match?\n @fixture.files == @local.files\n end",
"def is_pic_url_dup?\n self.class.where(\"pic = ? and id != ?\", pic, id).count > 0\n end",
"def files_with_duplicate_imports\n files.select(&:has_duplicate_import?)\n end",
"def already_being_processed?\n # if origional exists and destination has existed for 30s+\n # assume a previous run didn't get around to cleaning up the file\n if(File.exist?(@origional_file) && File.exist?(destination_file) && !recently_modified?(destination_file))\n $logger.info \"Found origional and transcoded file; moving origional\"\n move_origional_file\n return true\n end\n\n if File.exist? temp_file\n # if file has been modified in the last 30 seconds consider it in flight by another\n if recently_modified?(temp_file)\n $logger.info \" temp file modified recently (maybe by another process?) so skipping #{temp_file}\"\n return true\n else\n $logger.info \" temp file is old, deleting #{temp_file}\"\n File.delete temp_file\n end\n end\n false\n end",
"def change?(file)\n @file != file\n end",
"def shared?\n self[:filename].nil? or self[:filename].start_with? \"content/\"\n end",
"def different?(a, b)\n !FileUtils.compare_file(a, b)\n end",
"def check_new\n if File.exist?(@new_file_path)\n #TODO: error properly\n abort\n end\n end",
"def verify_update_file\n @log.info('Beginning integrity check of downloaded file .')\n @file_sha1 = Digest::SHA1.file(@update_file.path).hexdigest\n\n @log.info('Verifying integrity of downloaded file.')\n\n if download_remote_sha1 == @file_sha1\n @log.info('Integrity verified.')\n true\n else\n abort('File was not downloaded correctly. Please try again.')\n end\n end",
"def check_file(local_file)\n # Immateriel.info binding, @url\n uniq_str = Digest::MD5.hexdigest(\"#{@url}:#{local_file}\")\n uri = URI.parse(@url)\n fn = \"/tmp/#{uniq_str}_\" + Digest::MD5.hexdigest(File.basename(uri.path)) + File.extname(uri.path)\n self.class.download(@url, fn)\n if File.exist?(fn)\n check_result = self.class.check_image(fn, local_file, uniq_str)\n FileUtils.rm_f(fn)\n if check_result\n true\n else\n false\n end\n else\n false\n end\n end",
"def unique_record_check(record,row)\n #recupero tutte le info necessarie per memorizzare la chiave primaria\n plot_id = Plot.find(:first,:conditions => [\"numero_plot = ? AND deleted = false\",record.cod_plot]).id\n active_campaign_id = Campagne.find(:first,:conditions => [\"active = true\"]).id\n file = ImportFile.find(session[:file_id])\n #cerco la chiave primaria\n pk = Copl.find(:first,:conditions => [\"campagne_id = ? AND plot_id = ? AND subplot = ? AND in_out = ? AND priest = ? AND file_name_id = ? AND import_num = ?\", active_campaign_id, plot_id, record.subplot, record.in_out, record.priest, file.id, file.import_num])\n #se già è presente\n if pk\n #salvo l'errore\n save_error(record,\"Duplicate row\",row)\n #segnalo che c'è stato un errore sulla riga\n session[:row_error] = true\n #e segnalo l'errore sul file\n session[:file_error] = true\n end\n end",
"def already_loaded?(uploaded_file)\n uploaded_file.reload\n originals = uploaded_file.original_inputs\n return false unless originals.present?\n sha2_hashes = []\n originals.each do |orig|\n return false if orig.nil? || orig.sha2_hash.nil?\n sha2_hashes << orig.sha2_hash\n end\n\n return false if sha2_hashes.empty?\n\n UploadedFile.joins(:original_inputs)\n .where(status: 'S')\n .where(validate_only: false)\n .where(original_input: {sha2_hash: sha2_hashes,\n mime_type: 'text/stix'}).count > 0\n end",
"def document_media_is_unique\n return if self.documents.count == 0\n\n valid = true\n\n corpus_media = Array.new\n\n self.documents.each { |d| corpus_media.push(:id => d.id, :media => d.media_descriptors) }\n\n last_media_urls = Array.new\n last = self.documents.last\n last.media_descriptors.each { |m| last_media_urls.push(m[:media_url]) }\n\n corpus_media.each do |m|\n if m[:id] != last.id then\n item_media_urls = Array.new\n m[:media].each { |m| item_media_urls.push(m[:media_url]) }\n\n if (last_media_urls == item_media_urls)\n valid = false\n break\n end\n end\n end\n\n errors.add :file, \"contains a media set already in this corpus.\" if valid == false\n end",
"def validate_local_files\n expected_user_id = user.id\n uploaded_files.each do |file|\n if file.user_id != expected_user_id\n Rails.logger.error \"User #{user.user_key} attempted to ingest uploaded_file #{file.id}, but it belongs to a different user\"\n return false\n end\n end\n true\n end",
"def remote_file_differs?(full_path, content)\n !remote_file_exists?(full_path) || remote_file_exists?(full_path) && !remote_file_content_same_as?(full_path, content)\n end",
"def validate_files\n expected_user_id = user.id\n uploaded_files.each do |file|\n if file.user_id != expected_user_id\n Rails.logger.error \"User #{user.user_key} attempted to ingest uploaded_file #{file.id}, but it belongs to a different user\"\n return false\n end\n end\n true\n end",
"def test_reuse_existing_chunks_when_append\n CheckFile @writer, @ioservice, @adlers, 'test content', ['test ', 'conte', 'nt']\n CheckFile @writer, @ioservice, @adlers, 'test content updated', ['test ', 'conte', 'nt', ' upda', 'ted']\n end",
"def duplicate?\n @duplicate == true\n end",
"def already_shared(user_id, file_id)\n if $db.execute(\"SELECT * FROM shared_files WHERE file_id = ? AND user_id = ?\", file_id, user_id) != []\n return true\n end\n return false\nend",
"def needCopy(destItem,srcItem)\n oldfile = !FiRe::filesys.uptodate?(destItem,srcItem)\n missingfile = !FiRe::filesys.exist?(destItem) || smaller?(destItem,srcItem)\n\n if !(oldfile || missingfile)\n FiRe::log.debug \"item already there! [#{srcItem}]\"\n end\n \n oldfile || missingfile\n \n end",
"def find_same_files\n # loop over find_similar_files groups\n # diff -b file1 file2\n end",
"def is_up?\n\t\tFile.exists?(@file)\n\tend",
"def verify_overwriting\n overwrite = ask_nicely\n\n while overwrite.empty?\n overwrite = ask_nicely\n end\n\n overwrite == 'y' ? FileUtils.rm_rf(Frank.export.path) : exit\n end",
"def new_file?(name, mtime)\n # unknown file\n return true unless @table.has_key?(name)\n # updated file\n return mtime > @table[name]\n end",
"def file_content_match?\n @fixture.full_files.zip(@local.full_files).all? do |fixture_file, local_file|\n if File.directory?(fixture_file)\n File.directory?(local_file)\n else\n !File.directory?(local_file) && IO.read(fixture_file) == IO.read(local_file)\n end\n end\n end",
"def check_duplicate(line)\n return line.uniq.length == line.length\nend",
"def files_differ?(backup_path, restore_path, io)\n !@symlinked && (@backup_directory || @restore_directory || io.read(backup_path) != io.read(restore_path))\n end",
"def rename_once?(filename)\n basename = File.basename(filename, File.extname(filename))\n basename.match(/^(.*)_(\\d+)_(\\d+)_\\2_\\3$/)\n end",
"def temporary?\n @file == @default_file\n end",
"def new_file?\n @new_file\n end",
"def uniq_tag?(tag)\n values = @selected_files.map { |file| file[tag] }\n values.reduce(true) { |r, v| r && (v.size == 1) } && (values.map { |v| v.first }.uniq.length == 1)\n end",
"def file?\n not identifier.blank?\n end",
"def check_for_duplicate_sha1\n # Generate the SHA1.\n self.sha1 = Digest::SHA1.hexdigest(raw_eml)\n\n old_mail_log = nil\n user_thread.schedule do\n old_mail_log = user.mail_logs.find_by_sha1(sha1)\n end\n\n if old_mail_log\n Log.librato(:count, \"system.process_uid.duplicate_sha1\", 1)\n return false\n else\n return true\n end\n end",
"def duplications?\n size != uniq.size \n end",
"def file_exists?(file)\n false\n end",
"def rerun_needed?\n\t\t\[email protected](\"log\", true).rerun_needed?\n\t\tend",
"def files_different?(path, local_path, content=nil)\n end",
"def file_matching_path\n !!container.stored_files.where(file_name: file_name, path: path).first\n end",
"def has_file\n if id == nil \n false\n else\n FileTest.exists?( local_file_path )\n end\n end",
"def check_files_similarity(files, extension)\n duplicates = {}\n files.each_with_index do |f1, index|\n next if f1 == nil || index == files.length - 1\n ((index + 1)..(files.length - 1)).each do |j|\n next if files[j] == nil\n f2 = files[j]\n break if @options[\"s\"][:value] == 1 && f1[:size] != f2[:size]\n next if Algorithms.levenshtein(f1[:name], f2[:name]) > @options[\"l\"][:value]\n begin\n result = compare_files(f1, f2)\n rescue => e\n @show.call \"\\t[Not treated]:\\n\\t\\t - #{f1[:path]} \\n\\t\\t - #{f2[:path]} \\n\\t\\t => #{e}\"\n end\n next if result == nil\n f3 = f2.clone\n f3[:similarity] = result\n if (@options[\"p\"][:value] == 100 && result == 100) || (result >= @options[\"p\"][:value])\n # remove one of the file 100% duplicated\n # 2 files 100% duplicated will also be duplicated with other files\n # if sim(a,b) == 100 && sim(a, c) == 100 so sim(a, c) == 100\n files[j] = nil if @options[\"p\"][:value] == 100 && result == 100\n if duplicates.key?(f1[:path])\n duplicates[f1[:path]] << [f3[:path], result]\n else\n duplicates[f1[:path]] = [[f3[:path], result]]\n end\n end\n end\n end\n @show.call \"Process[#{Process.pid}]: Extension #{extension.name} processed!\"\n duplicates\n end",
"def assert_identifiable_youngest_file(filenames)\n return unless filenames.length > 1\n \n # This separate return check because it's possible some of the\n # filenames are left over from an earlier run.\n return if @greatest_backup_tag == '000'\n\n same_mods = filenames.find_all { | x |\n test(?M, filenames[0]) == test(?M, x)\n }\n\n assert(filenames.length > same_mods.length) {\n files = filenames.collect { | e | \"#{e} -> #{test(?M, e)}\" }\n files[0,0] = \"Every backup file has the same modification time: \"\n files.push \"There's no way to know which should be replaced.\"\n lines(files)\n }\n end",
"def check_files\n @files.delete_if do |file|\n if File.exist? file then\n if File.readable? file then\n false\n else\n warn \"file '#{file}' not readable\"\n\n true\n end\n else\n warn \"file '#{file}' not found\"\n\n true\n end\n end\n end",
"def isStale?(file, old_files)\n\t\treturn true unless File.exist?(file)\n\t\tnew_time = File.mtime(file)\n\t\told_files.each do |old|\n\t\t\tif File.exist?(old)\n\t\t\t\t#debug \"New Time: #{new_time}\"\n\t\t\t\t#debug \"Old Time: #{File.mtime(old)}\"\n\t\t\t\treturn true if new_time < File.mtime(old)\n\t\t\tend\n\t\tend\n\t\treturn false\n\tend",
"def _check_duplicates_gb(file)\n\t\tinfo \"* check duplicates: \" + file\n\t\tsystem \"./check_duplicates_gb.pl \" + file\n\tend",
"def _valid_file?(name)\n @cache_valid ||= {}\n @cache_valid[name.to_sym] ||= !_config_files(name).empty?\n end",
"def save_exists?(index)\n File.exists?(DataManager.make_filename(index-1))\n end",
"def validate_files(files, env)\n expected_user_id = env.user.id\n files.each do |file|\n if file.user_id != expected_user_id\n Hyrax.logger.error \"User #{env.user.user_key} attempted to ingest uploaded_file #{file.id}, but it belongs to a different user\"\n return false\n end\n end\n true\n end",
"def isNew()\n if !File.file?(getConfigFilePath()) || ! File.file?(getMyIDFilePath())\n return true\n end\n return false\n end",
"def eql?(other)\n\t\t\tself.fileid.eql?(other.fileid)\n\t\tend",
"def destination_file_exist?\n File.exist?(final_destination_path)\n end",
"def suspend_file_exists?\n File.file? File.join(path, \"#{@name}.vmem\")\n end",
"def suspend_file_exists?\n File.file? File.join(path, \"#{@name}.vmem\")\n end",
"def belongs_to_me? file\n #The only difference between shared files that have been added to your Drive\n #and those that haven't is that those that have have a file path (parents)\n return true if @config['sync_shared_in_drive'] and file.parents != nil and file.parents != []\n file.shared_with_me_time.nil? and file.owners != nil and file.owners.select{|owner| owner.me}.count > 0\n end",
"def saved?\n return [email protected]?\n end",
"def empty?\n File.size(@filename) <= 2\n end",
"def check_files(files)\r\n files_before = @file_info.keys\r\n used_files = {} \r\n files.each do |file|\r\n begin\r\n if @file_info[file]\r\n if @file_info[file].timestamp != File.mtime(file)\r\n @file_info[file].timestamp = File.mtime(file)\r\n digest = calc_digest(file)\r\n if @file_info[file].digest != digest\r\n @file_info[file].digest = digest \r\n @file_changed && @file_changed.call(file)\r\n end\r\n end\r\n else\r\n @file_info[file] = FileInfo.new\r\n @file_info[file].timestamp = File.mtime(file)\r\n @file_info[file].digest = calc_digest(file)\r\n @file_added && @file_added.call(file)\r\n end\r\n used_files[file] = true\r\n # protect against missing files\r\n rescue Errno::ENOENT\r\n # used_files is not set and @file_info will be removed below\r\n # notification hook hasn't been called yet since it comes after file accesses\r\n end\r\n end\r\n files_before.each do |file|\r\n if !used_files[file]\r\n @file_info.delete(file)\r\n @file_removed && @file_removed.call(file)\r\n end\r\n end\r\n end",
"def file_backed?\n @tempfile_in\n end",
"def has_same_photo?(fb_photos, f)\n\n # album = Mogli::Album.find(album_id, client)\n # fb_photos = album.photos\n has_photo = false\n \n fb_photos.each do |p|\n break if has_photo\n \n fb_photo_url = p.source\n fb_photo_file = get_photo_as_file_from_url(fb_photo_url)\n \n # Rails.logger.info \"reference photo(from flickr): #{f.path} - exists? #{File.exists?(f.path)}\"\n # Rails.logger.info \"compared to (from fb): #{fb_photo_file.path} - exists? #{File.exists?(fb_photo_file.path)}\" \n # Delayed::Worker.info \"reference photo(from flickr): #{f.path} - exists? #{File.exists?(f.path)}\"\n # Delayed::Worker.logger.info \"comparing incoming flickr photo to fb photos: #{fb_photo_file.path} - exists? #{File.exists?(fb_photo_file.path)}\"\n Delayed::Worker.logger.info \"comparing incoming flickr photo to fb photos: #{p.name} - #{fb_photo_url}\"\n \t\n comparer = ImageCompare.new(f.path, fb_photo_file.path)\n has_photo = true if comparer.identical?(:tolerance => 0.02)\n Delayed::Worker.logger.info \"identical to flickr photo?: #{has_photo.inspect}\"\n end\n\n Delayed::Worker.logger.info \" ********** Found duplicate in album?: #{has_photo.inspect}\"\n Delayed::Worker.logger.info \" \"\n \n return has_photo\n end",
"def rec_exists?(file_name, unique_keys, data)\n json = File.read(file_name + \".json\")\n json = json.split(\",\\n\")\n data = data.to_s\n data = eval data.gsub(\"},\", \"}\")\n json.each do |h|\n h = eval h\n flag = true\n unique_keys.each do |k|\n if h[k.to_s].to_s != data[k.to_s].to_s\n flag = false\n end\n end # end unique keys loop\n if flag == true\n #p \"rec exists!!!!!!!\"\n return true\n end\n end # end json loop\n #p \"doesn't exist, safe to move on\"\n false\nend",
"def users_first_run?\n test_file.test_runs(true) # Cache-busting\n test_file.test_runs.length == 1 && owner.test_files.select{|f| (f.id != test_file.id) && !f.test_runs.empty?}.blank? \n end",
"def should_copy?(source, target)\n return true\n return true if !File.exists?(target)\n\n source_sha = Digest::SHA1.hexdigest(File.read(source))\n target_sha = Digest::SHA1.hexdigest(File.read(target))\n \n debugger if source_sha != target_sha\n \n return true if source_sha == target_sha\n \n return false\n end",
"def clear_ingest_id( filename )\n\n begin\n File.delete( \"#{filename}.id\" )\n return true\n rescue => e\n end\n return false\n end",
"def find_invalid_primary_st_ops_filenames\n # TODO: Validate that st-ops-files in primary repo have no\n # duplicate time stamps, and that from and to commits form a\n # contiguos, linear sequence.\n true\n end",
"def rerunNeeded? ( timestampFilePath , rerunEach )\n\n isNeeded = true\n\n # Checking if timestamp file already exists\n if (File.exist?(timestampFilePath))\n timestampFile = File.new(timestampFilePath, \"r\")\n firstLine = timestampFile.gets\n previousTimestamp = firstLine.nil? ? 0 : firstLine.to_i\n isNeeded = (Time.now.to_i - previousTimestamp) > rerunEach\n end\n\n if (isNeeded)\n FileUtils.mkdir_p(File.dirname(timestampFilePath))\n timestampFile = File.new( timestampFilePath , \"w\" )\n timestampFile.write(Time.now.to_i.to_s+\"\\n\")\n timestampFile.close\n end\n \n return isNeeded\n\n end",
"def contain?(filename); end",
"def should_process? \n #return false if it has been set to skip processing \n return false if self.persistence_checksum.eql?(\"skip\")\n\n #return true if there are different number of craft files than records of craft that are not marked as deleted\n craft_files = campaigns_instance.identify_craft_in(self.name)\n craft = self.craft.where(:deleted => false) #if craft.nil?\n return true if craft_files.map{|k,v| v}.flatten.size != craft.count\n\n #return true if the stored checksum for persistent.sfs does not match the one generated for the current persistent.sfs\n Dir.chdir(self.path)\n return true unless File.exists?(\"persistent.sfs\")\n checksum = Digest::SHA256.file(\"persistent.sfs\").hexdigest\n not checksum.eql?(self.persistence_checksum)\n end",
"def check_file_exists(file_name)\n \tif File.exist?(file_name)\n logger.fatal \"#{file_name} already exists.\"\n \t\tabort\n \tend\n end",
"def check_file(entry, pathname, previous_size)\n size = pathname.size\n if previous_size && (previous_size == size)\n logger.info(\"File stabilized: #{pathname}. Starting: #{entry.job_class_name}\")\n entry.later(pathname)\n nil\n else\n logger.info(\"Found file: #{pathname}. File size: #{size}\")\n # Keep for the next run\n size\n end\n end",
"def test_ut_original_file_01\n assert @original_file.save\n original_file_copy = OriginalFile.find(@original_file.id)\n assert_equal @original_file.normal_result_id, original_file_copy.normal_result_id\n assert @original_file.valid?\n assert @original_file.destroy\n end"
] | [
"0.78644377",
"0.7141948",
"0.7022745",
"0.68293506",
"0.6816571",
"0.6777013",
"0.66742957",
"0.6665063",
"0.6635987",
"0.6629165",
"0.66233206",
"0.6598193",
"0.6598193",
"0.65877014",
"0.6507532",
"0.64849436",
"0.64064527",
"0.64006424",
"0.6342413",
"0.6238458",
"0.6236779",
"0.6227258",
"0.61795497",
"0.6170077",
"0.6166309",
"0.6162571",
"0.6158203",
"0.61179525",
"0.61176157",
"0.61117744",
"0.6067346",
"0.60416394",
"0.6031346",
"0.60209435",
"0.60173684",
"0.6011986",
"0.60023093",
"0.5996327",
"0.59862494",
"0.59577966",
"0.5952702",
"0.5932853",
"0.5923008",
"0.5920112",
"0.5911057",
"0.5910566",
"0.5903492",
"0.5900644",
"0.58955055",
"0.5874923",
"0.58712226",
"0.5868505",
"0.5841344",
"0.5826188",
"0.5825642",
"0.58014834",
"0.57908",
"0.5780873",
"0.57710695",
"0.57681674",
"0.57646036",
"0.5762892",
"0.57538116",
"0.57499534",
"0.57416135",
"0.5739094",
"0.572806",
"0.5717207",
"0.5710741",
"0.57071143",
"0.570248",
"0.56997484",
"0.569859",
"0.5697208",
"0.56784457",
"0.5671271",
"0.5670739",
"0.5667122",
"0.56611305",
"0.56593585",
"0.56568927",
"0.56459546",
"0.56459546",
"0.56428427",
"0.56375015",
"0.56364757",
"0.56286424",
"0.56066954",
"0.5603802",
"0.5593096",
"0.55859625",
"0.55840695",
"0.55826485",
"0.55816483",
"0.55758965",
"0.5575504",
"0.5575176",
"0.5571759",
"0.55668336",
"0.5561866"
] | 0.65201795 | 14 |
When something is added at the end, all the full existing chunks are reused | def test_reuse_existing_chunks_when_append
CheckFile @writer, @ioservice, @adlers, 'test content', ['test ', 'conte', 'nt']
CheckFile @writer, @ioservice, @adlers, 'test content updated', ['test ', 'conte', 'nt', ' upda', 'ted']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_reuse_existing_chunks_when_prepend\n CheckFile @writer, @ioservice, @adlers, 'test content', ['test ', 'conte', 'nt']\n CheckFile @writer, @ioservice, @adlers, 'a new test content', ['a new', ' ', 'test ', 'conte', 'nt']\n end",
"def append_queue\n if free_space > 0 \n free_blocks.times { \n if already_read < current_track.file.size\n buffer_block current_track\n else\n # We've finished this track, on to the next one\n load_next_track\n return\n end\n }\n else\n #puts \"Buffer full\" \n end\n end",
"def add(chunk)\n if chunk.full_chunk?\n @chunks[chunk.x / 16] ||= {}\n # if @chunks[chunk.x / 16][chunk.z / 16]\n # puts \"replacing: #{[chunk.x, chunk.z].inspect}\"\n # else\n # puts \"adding : #{[chunk.x, chunk.z].inspect}\"\n # end\n @chunks[chunk.x / 16][chunk.z / 16] = chunk\n\n key = [chunk.x/16, chunk.z/16]\n\n if @pending_changes[key]\n @pending_changes[key].each do |x, y, z, block|\n # puts \"applying stored change #{[x, y, z].inspect} #{block}\"\n self[x, y, z] = block\n end\n @pending_changes.delete key\n end\n\n if @pending_updates[key]\n @pending_updates[key].each do |x, y, z, data|\n # puts \"applying stored update #{[x,y,z].inspect} #{data}\"\n update(x, y, z, data)\n @pending_updates.delete key\n end\n end\n\n else\n # puts \"incremental: #{[chunk.x, chunk.y, chunk.z].inspect} #{[chunk.size_x, chunk.size_y, chunk.size_z].inspect}\"\n chunk.each_column do |x, y, z, data|\n # puts \"updating #{[x,y,z].inspect} #{data.size} blocks\"\n update(x, y, z, data)\n end\n end\n end",
"def fill_buffer num_bytes\n while @buffer.bytesize < num_bytes && more_chunks?\n @buffer << next_chunk\n end\n end",
"def join(owned_chunks)\n \n end",
"def chunked?; end",
"def chunk(*chunks)\n @queue += chunks\n schedule_dequeue\n end",
"def each_chunk; end",
"def patch_last_chunk(input, grid_info)\n last_chunk = chunks_collection.find(files_id: grid_info[:_id]).sort(n: -1).limit(1).first\n data = last_chunk[:data].data\n patch = input.read(grid_info[:chunkSize] - data.bytesize)\n data << patch\n\n chunks_collection.find(files_id: grid_info[:_id], n: last_chunk[:n])\n .update_one(\"$set\" => { data: BSON::Binary.new(data) })\n\n files_collection.find(_id: grid_info[:_id])\n .update_one(\"$inc\" => { length: patch.bytesize })\n\n patch.bytesize\n end",
"def done_adding(*) end",
"def ignore_bad_chunking; end",
"def ignore_bad_chunking; end",
"def new_chunk(index)\n chunk_num = (index / CHUNK_LINE_SIZE).to_i\n write_file = File.new(\"data/chunk#{chunk_num}\", \"w\")\n\n return write_file\nend",
"def fuse(_following_chunk)\n nil\n end",
"def flush() end",
"def flush() end",
"def flush() end",
"def write_chunk(start, buffer)\n @local_file.seek(start)\n @local_file.write(buffer)\n end",
"def put_copy_end(*args)\n\t\tuntil sync_put_copy_end(*args)\n\t\t\tflush\n\t\tend\n\t\t@calls_to_put_copy_data = 0\n\t\tflush\n\tend",
"def prepareForReuse; end",
"def add(is_full_flush)\n content_data = $local_content_data\n return if content_data.empty?\n\n # for the latest content data added to the DB\n latest_snapshot = nil\n # for instances that were added regarding latest_snapshot\n added_cd = nil\n # for insrances that were removed regarding latest_snapshot\n removed_cd = nil\n\n latest_index_time = nil\n content_data.each_instance do |_,_,_,_,_,_,index_time|\n if latest_index_time.nil? || latest_index_time < index_time.to_i\n latest_index_time = index_time.to_i\n end\n end\n\n # Checking time consistency\n content_data_timestamp = DateTime.from_epoch(latest_index_time)\n if !@latest_timestamp.nil? && (content_data_timestamp <= @latest_timestamp)\n # It is possible when instances added at @latest_timestamp\n # were removed and any new instances addded,\n # then latest indexed time in the new content data\n # is earlier then @latest_timestamp\n # Example:\n # ContentData for Date1 (noted as latest_snapshot):\n # Content1\n # location1\n # location2\n # Between Date1 and Date2 location2 was removed\n # and no other file operations were done.\n # ContentData for Date2 (noted as content_data):\n # Content1\n # location1\n # Then:\n # content_data.remove_instances(latest_snapshot) is empty.\n latest_snapshot = get(@latest_timestamp)\n added_cd = content_data.remove_instances(latest_snapshot)\n msg = \"latest index time of the content data: #{content_data_timestamp}\" +\n \"must be later then latest timestamp: #{latest_timestamp}\"\n if added_cd.empty?\n # In this case we do not know exactly when the indexation was\n # then the timestamp is fake\n # TODO better solution?\n latest_timestamp_epoch = @latest_timestamp.strftime('%s')\n content_data_timestamp = DateTime.from_epoch(latest_timestamp_epoch.to_i + 1)\n Log.warning msg\n else\n fail msg\n end\n end\n\n if is_full_flush\n save(content_data,\n DiffFile::SNAPSHOT_TYPE,\n nil, # 'from' param is not relevant for full flush\n content_data_timestamp)\n end\n\n # If it is not the first content data that we store,\n # i.e there are already stored content data,\n # then a diff files are relevant.\n # NOTE we save diff (added/removed) files even in the case of full flush\n # cause of data consistency. It is crucial for the diff operation.\n # Example (simple, without removed):\n # When:\n # date1-date2.added\n # date2-date3.added (added along with a snapshot)\n # date3.snapshot\n # date3-date4.added\n # Then:\n # ContentDataDb.diff(date2, date4) = date2-date3.added + date3-date4.added\n if @latest_timestamp.nil?\n earliest_index_time = nil\n content_data.each_instance do |_,_,_,_,_,_,index_time|\n if earliest_index_time.nil? || earliest_index_time > index_time\n earliest_index_time = index_time\n end\n end\n content_data_from = DateTime.from_epoch(earliest_index_time)\n save(content_data,\n DiffFile::ADDED_TYPE,\n content_data_from,\n content_data_timestamp)\n else\n latest_snapshot ||= get(@latest_timestamp)\n\n added_cd ||= content_data.remove_instances(latest_snapshot)\n unless added_cd.empty?\n save(added_cd,\n DiffFile::ADDED_TYPE,\n @latest_timestamp,\n content_data_timestamp)\n end\n\n removed_cd = latest_snapshot.remove_instances(content_data)\n unless removed_cd.empty?\n save(removed_cd,\n DiffFile::REMOVED_TYPE,\n @latest_timestamp,\n content_data_timestamp)\n end\n end\n\n @latest_timestamp = content_data_timestamp\n end",
"def batch_finished\n end",
"def local_flush\n end",
"def next_chunk\n mwc = (new_z << 16) + new_w\n [mwc].pack('L>')\n end",
"def <<(chunk, last_chunk = T.unsafe(nil)); end",
"def <<(chunk, last_chunk = T.unsafe(nil)); end",
"def <<(chunk, last_chunk = T.unsafe(nil)); end",
"def <<(chunk, last_chunk = T.unsafe(nil)); end",
"def flush()\n #This is a stub, used for indexing\n end",
"def flush\n if @carry_over\n @contents['info']['pieces'] << Digest::SHA1.digest( @carry_over )\n end\n unless @contents['creation date']\n @contents['creation date'] = Time.now.tv_sec\n end\n @io << @contents.bencode\n @io.flush\n self\n end",
"def finish\n\t\t\t\t\t# Internally, this invokes `self.each` which then invokes `self.close`.\n\t\t\t\t\tBuffered.for(self)\n\t\t\t\tend",
"def start_new_block\n if (@block_buffer)\n add_block(@block_buffer)\n @block_buffer = nil\n end\n end",
"def finalize\n @buffer.each_key do |bucket|\n write_and_flush bucket\n end\n clear_buffer!\n nil\n end",
"def chunk(count=100)\n criteria[:chunk] = count\n self\n end",
"def append(new_data)\n end",
"def flush; end",
"def flush; end",
"def flush; end",
"def flush; end",
"def flush; end",
"def flush_next_out\n\t\t@out_pos = @output_buffer.length\n\t\t@finished = true\n\t\tret = @output_buffer.pack(\"c*\")\n\t\t@output_buffer = []\n\t\tret\n\tend",
"def merge!\n\t\t\twhile handle = @queue.pop\n\t\t\t\tnext if handle.cancelled?\n\t\t\t\t\n\t\t\t\[email protected](handle)\n\t\t\tend\n\t\tend",
"def at_end; end",
"def force_update_every_chunk\r\n @chunk_hash.each_value { |chunk| chunk.flag_chunk_update = true }\r\n end",
"def on_finish_batch; end",
"def each\n pos = 0\n while(pos < @original_duration) do\n chunk = nil\n begin\n chunk = Chunk.new(@original_file, @original_duration, pos, (@chunk_duration + @overlap), @rate)\n yield chunk\n pos = pos + [chunk.duration, @chunk_duration].min\n ensure\n chunk.close_file if chunk\n end\n end\n end",
"def flush_next_in\n\t\t@in_pos = @input_buffer.length\n\t\t@finished = true\n\t\tret = @input_buffer.pack(\"c*\")\n\t\t@input_buffer = []\n\t\tret\n\tend",
"def finish\n if batch.present?\n solr_service_connection.add(batch, softCommit: true, commit: false)\n batch.clear\n end\n end",
"def flush_next_out\n\t\t\t@out_pos = @output_buffer.length\n\t\t\t@finished = true\n\t\t\tret = @output_buffer.pack(\"c*\")\n\t\t\t@output_buffer = []\n\t\t\tret\n\t\tend",
"def hash_end(_key)\n save_batch\n end",
"def flush_next_in\n\t\t\t@in_pos = @input_buffer.length\n\t\t\t@finished = true\n\t\t\tret = @input_buffer.pack(\"c*\")\n\t\t\t@input_buffer = []\n\t\t\tret\n\t\tend",
"def add_to_length_written(size)\n @length_written += size\n raise \"Content-Length overwritten: #{@length_written}, #{@content_length}\" if @content_length != nil && @length_written > @content_length\n end",
"def enqueue(chunk)\n raise NotImplementedError, \"Implement this method in child class\"\n end",
"def write(data, offset = 0)\n # Track our offset into the remote file\n fptr = offset\n\n # Duplicate the data so we can use slice!\n data = data.dup\n\n # Take our first chunk of bytes\n chunk = data.slice!(0, self.chunk_size)\n\n # Keep writing data until we run out\n while (chunk.length > 0)\n ok = self.client.write(self.file_id, fptr, chunk)\n cl = ok['Payload'].v['CountLow']\n\n # Partial write, push the failed data back into the queue\n if (cl != chunk.length)\n data = chunk.slice(cl - 1, chunk.length - cl) + data\n end\n\n # Increment our painter and grab the next chunk\n fptr += cl\n chunk = data.slice!(0, self.chunk_size)\n end\n end",
"def << data\n buffer << data if data\n parse_loop!\n end",
"def add(data)\n if count == 0\n fh.puts \"[\"\n else\n fh.puts \",\"\n end\n fh.write(JSON.pretty_generate(data))\n self.count += 1\n if count >= 100\n close\n end\n end",
"def start record\n self.size = 0\n end",
"def write( chunk )\n begin\n $log.debug \"Size of chunk is: #{chunk.size}\"\n requests = self.build_add_events_body( chunk )\n $log.debug \"Chunk split into #{requests.size} request(s).\"\n\n requests.each_with_index { |request, index|\n $log.debug \"Request #{index + 1}/#{requests.size}: #{request[:body].bytesize} bytes\"\n begin\n response = self.post_request( @add_events_uri, request[:body] )\n self.handle_response( response )\n rescue OpenSSL::SSL::SSLError => e\n if e.message.include? \"certificate verify failed\"\n $log.warn \"SSL certificate verification failed. Please make sure your certificate bundle is configured correctly and points to a valid file. You can configure this with the ssl_ca_bundle_path configuration option. The current value of ssl_ca_bundle_path is '#{@ssl_ca_bundle_path}'\"\n end\n $log.warn e.message\n $log.warn \"Discarding buffer chunk without retrying or logging to <secondary>\"\n rescue Scalyr::Client4xxError => e\n $log.warn \"4XX status code received for request #{index + 1}/#{requests.size}. Discarding buffer without retrying or logging.\\n\\t#{response.code} - #{e.message}\\n\\tChunk Size: #{chunk.size}\\n\\tLog messages this request: #{request[:record_count]}\\n\\tJSON payload size: #{request[:body].bytesize}\\n\\tSample: #{request[:body][0,1024]}...\"\n\n end\n }\n\n rescue JSON::GeneratorError\n $log.warn \"Unable to format message due to JSON::GeneratorError.\"\n raise\n end\n end",
"def on_body(chunk)\n @currently_reading.fill_buffer(chunk)\n end",
"def add(hash)\n batch << hash\n\n if batch.count % batch_size == 0\n solr_service_connection.add(batch, softCommit: soft_commit, commit: commit)\n batch.clear\n end\n end",
"def read_more(size); end",
"def finish()\n #This is a stub, used for indexing\n end",
"def ignore_bad_chunking=(_arg0); end",
"def append_to(buffer)\n tempfile.rewind\n\n buf = String.new\n buffer << tempfile.readpartial(65_536, buf) until tempfile.eof?\n\n tempfile.rewind\n\n nil\n end",
"def ingest_new_content( depositor, dirname, wsname, current, total )\n\n filename = File.join( dirname, wsname )\n _, asset_filenames = IngestHelpers.load_workset( filename )\n\n puts \"Ingesting #{current} of #{total}: #{filename} ...\"\n\n work_id = IngestHelpers.get_ingest_id( filename )\n if work_id.blank?\n puts \"ERROR: #{filename} has no ingest id, continuing anyway\"\n return false\n end\n\n work = TaskHelpers.get_work_by_id( work_id )\n if work.nil?\n puts \"ERROR: work #{work_id} does not exist, continuing anyway\"\n return false\n end\n\n asset_filenames.each_with_index do |f, ix|\n label = IngestHelpers.construct_file_label( ix + 1, f, work )\n puts \" asset #{ix + 1} of #{asset_filenames.length}: #{f} (#{label})\"\n\n # handle dry running\n next if ENV[ 'DRY_RUN' ]\n\n # and upload the file\n fileset = TaskHelpers.upload_file( depositor, work, File.join( dirname, f ), label )\n fileset.date_uploaded = DateTime.now\n fileset.save!\n end\n\n return true\n end",
"def flush(events, close=false)\n #buffer_flush should pass here the :final boolean value.\n @redisearch_client.add_docs(events)\n @logger.info(\"Buffer Inserted Successfully\", :length => events.length)\n end",
"def chunk_it_up\n\n # start with an empty working set before any messages have been received\n working_set = []\n\n # pop a chunk (array of lines of filtered btmon output) off the\n # incoming queue\n while current_msg = @incoming_q.pop\n\n # test if the message indicates the start of a new message\n #\n # also bypass if our working set is empty as this indicates we are\n # receiving our first device of the run\n if starting_chunk?(current_msg) && !working_set.empty?\n\n # if we just got a new message shovel the working set into the\n # outgoing queue and reset it\n @outgoing_q.push working_set\n working_set = []\n end\n\n # inject a timestamp onto the message parsed out of the first line of\n # btmon output\n ts = Time.parse(current_msg.first.strip.scan(/\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}.\\d*$/)[0]).to_i\n current_msg << \"last_seen: #{ts}\"\n\n # add the current message to the working set\n working_set << current_msg\n end\n end",
"def written_blocks\n (@real_time_memory + @user_memory).reject(&:nil?).count\n end",
"def after_appending( state )\n\t\t# Nothing to do\n\t\treturn nil\n\tend",
"def finish\n # Look up our bucket, if there is one\n bucket\n super\n end",
"def tracks_collection_end\n @filehandle << \"\\n\\t</dict>\"\n end",
"def close_and_write_buffer\n nested_buffer = @out\n @out = @out_buffers.pop\n @out << nested_buffer\n end",
"def on_eof(&block); end",
"def handle_append_entries(payload)\n response = super(payload)\n\n if response[:success]\n timeout.reset\n end\n\n response\n end",
"def write(chunk)\n @size += chunk.bytesize\n # Worth noting that size always appears larger during this check than it\n # is in reality since the size is updated prior to writing out the data to\n # ensure that the amount of data stored in RAM doesn't exceed the maximum\n # in memory size.\n update_io if @in_memory && @size > @max_in_memory_size\n @io << chunk\n chunk\n end",
"def add data, offset\n next_frag = 0\n $LOG.debug \"Setting partition at offset \" + offset.to_s + \" To \" + data\n len = data.length\n\n # can we fit it in??\n # lets say no. so we have to create a ????? and use that as\n # an enumerator\n #\n\n \n\n dary = [data].pack(\"a*\").unpack(\"C*\")\n @part[offset, dary.length] = dary\n\n @part[(offset + dary.length), 2] = [next_frag].pack(\"n\").unpack(\"C2\")\n \n @rem -= (dary.length + FileSystem::get_link_size)\n end",
"def playlists_collection_end\n @filehandle << \"\\n\\t</array>\"\n end",
"def finish \n @_.dup.freeze\n end",
"def finish \n @_.dup.freeze\n end",
"def flush_check\n flush if @item_array.size >= BATCH_SIZE\n end",
"def <<(blob)\n @buf << blob\n buf_flush if @buf.size > BUFFER_SIZE\n self\n end",
"def finish\n\tmanager.flush\n end",
"def avail_out= size\n\t\tsize.times do \n\t\t\tif size > avail_out\n\t\t\t\t@output_buffer.push nil\n\t\t\telse\n\t\t\t\t@output_buffer.pop\n\t\t\tend\n\t\tend\n\tend",
"def chunks\n @_chunks ||= find_chunks(input)\n end",
"def chunks\n @_chunks ||= find_chunks(input)\n end",
"def flush\n end",
"def flush\n end",
"def flush\n end",
"def flush\n end",
"def finished; end",
"def finish(&block)\n (@finish ||= [ ]) << block\n end",
"def move_later\n nekst = self.next\n self.append_to(nekst) if nekst\n end",
"def push &put\n #Thread.pass while self.full?\n sleep 0.01 while self.full?\n self.push! &put\n end",
"def flush_buffer\r\n data = @buffer.clone\r\n clear_buffer\r\n @uploader.queue(data) \r\n end",
"def rolling_buffer1(buffer, max_buffer_size, new_element)\n buffer << new_element\n buffer.shift if buffer.size > mas_buffer_size\n buffer\nend",
"def rebuild\n header.sh_size = data.size\n @data\n end",
"def flush\n #\n end",
"def reconsume; end",
"def packing_finished\n end",
"def flush_url_distribution_buffer\n @routed ||= {}\n @routed.dup.each do |peer, r_urls|\n\n if !@first_run.include?( peer.url )\n @first_run << peer.url\n peer_not_done( peer.url )\n end\n\n peer.spider.push( r_urls ) do |included_new_paths|\n peer_not_done( peer.url ) if included_new_paths\n end\n end\n\n # Clear the counters and the buffer.\n @fillup_attempts = 0\n @buffer_size = 0\n @routed.clear\n end"
] | [
"0.71136314",
"0.6811389",
"0.6487453",
"0.63042635",
"0.6271669",
"0.61752576",
"0.61128914",
"0.6016184",
"0.59229547",
"0.5909456",
"0.57401544",
"0.57401544",
"0.5711156",
"0.56965065",
"0.5622255",
"0.5622255",
"0.5622255",
"0.5619329",
"0.5609445",
"0.5597237",
"0.5594002",
"0.5556271",
"0.5547241",
"0.55436176",
"0.5528108",
"0.5528108",
"0.5528108",
"0.5528108",
"0.55236584",
"0.5508821",
"0.5506815",
"0.54995924",
"0.54908925",
"0.54542017",
"0.5442917",
"0.5434613",
"0.5434613",
"0.5434613",
"0.5434613",
"0.5434613",
"0.5399861",
"0.53995275",
"0.53988254",
"0.53974366",
"0.5395609",
"0.53863233",
"0.5374281",
"0.53742176",
"0.5371533",
"0.53642327",
"0.5359138",
"0.5344009",
"0.53436434",
"0.5341928",
"0.5338565",
"0.5333566",
"0.5332616",
"0.5324121",
"0.5323321",
"0.53002733",
"0.52928334",
"0.5291404",
"0.5285297",
"0.52792066",
"0.527696",
"0.5267346",
"0.5264479",
"0.52621907",
"0.5261555",
"0.52607477",
"0.525131",
"0.5246639",
"0.5238289",
"0.5236358",
"0.5230487",
"0.5223779",
"0.5223413",
"0.52230203",
"0.52230203",
"0.52208805",
"0.52144635",
"0.52130854",
"0.5208822",
"0.5207655",
"0.5207655",
"0.5195003",
"0.5195003",
"0.5195003",
"0.5195003",
"0.519157",
"0.51914424",
"0.51889056",
"0.5184707",
"0.5183223",
"0.51814353",
"0.51813185",
"0.5179954",
"0.5178144",
"0.5173027",
"0.51726"
] | 0.75094116 | 0 |
when something is added at the beginning, all the full existing chunks are reused | def test_reuse_existing_chunks_when_prepend
CheckFile @writer, @ioservice, @adlers, 'test content', ['test ', 'conte', 'nt']
CheckFile @writer, @ioservice, @adlers, 'a new test content', ['a new', ' ', 'test ', 'conte', 'nt']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_reuse_existing_chunks_when_append\n CheckFile @writer, @ioservice, @adlers, 'test content', ['test ', 'conte', 'nt']\n CheckFile @writer, @ioservice, @adlers, 'test content updated', ['test ', 'conte', 'nt', ' upda', 'ted']\n end",
"def add(chunk)\n if chunk.full_chunk?\n @chunks[chunk.x / 16] ||= {}\n # if @chunks[chunk.x / 16][chunk.z / 16]\n # puts \"replacing: #{[chunk.x, chunk.z].inspect}\"\n # else\n # puts \"adding : #{[chunk.x, chunk.z].inspect}\"\n # end\n @chunks[chunk.x / 16][chunk.z / 16] = chunk\n\n key = [chunk.x/16, chunk.z/16]\n\n if @pending_changes[key]\n @pending_changes[key].each do |x, y, z, block|\n # puts \"applying stored change #{[x, y, z].inspect} #{block}\"\n self[x, y, z] = block\n end\n @pending_changes.delete key\n end\n\n if @pending_updates[key]\n @pending_updates[key].each do |x, y, z, data|\n # puts \"applying stored update #{[x,y,z].inspect} #{data}\"\n update(x, y, z, data)\n @pending_updates.delete key\n end\n end\n\n else\n # puts \"incremental: #{[chunk.x, chunk.y, chunk.z].inspect} #{[chunk.size_x, chunk.size_y, chunk.size_z].inspect}\"\n chunk.each_column do |x, y, z, data|\n # puts \"updating #{[x,y,z].inspect} #{data.size} blocks\"\n update(x, y, z, data)\n end\n end\n end",
"def append_queue\n if free_space > 0 \n free_blocks.times { \n if already_read < current_track.file.size\n buffer_block current_track\n else\n # We've finished this track, on to the next one\n load_next_track\n return\n end\n }\n else\n #puts \"Buffer full\" \n end\n end",
"def fill_buffer num_bytes\n while @buffer.bytesize < num_bytes && more_chunks?\n @buffer << next_chunk\n end\n end",
"def prepareForReuse; end",
"def start_new_block\n if (@block_buffer)\n add_block(@block_buffer)\n @block_buffer = nil\n end\n end",
"def start record\n self.size = 0\n end",
"def chunk(*chunks)\n @queue += chunks\n schedule_dequeue\n end",
"def ignore_bad_chunking; end",
"def ignore_bad_chunking; end",
"def chunked?; end",
"def each_chunk; end",
"def join(owned_chunks)\n \n end",
"def done_adding(*) end",
"def force_update_every_chunk\r\n @chunk_hash.each_value { |chunk| chunk.flag_chunk_update = true }\r\n end",
"def patch_last_chunk(input, grid_info)\n last_chunk = chunks_collection.find(files_id: grid_info[:_id]).sort(n: -1).limit(1).first\n data = last_chunk[:data].data\n patch = input.read(grid_info[:chunkSize] - data.bytesize)\n data << patch\n\n chunks_collection.find(files_id: grid_info[:_id], n: last_chunk[:n])\n .update_one(\"$set\" => { data: BSON::Binary.new(data) })\n\n files_collection.find(_id: grid_info[:_id])\n .update_one(\"$inc\" => { length: patch.bytesize })\n\n patch.bytesize\n end",
"def add(is_full_flush)\n content_data = $local_content_data\n return if content_data.empty?\n\n # for the latest content data added to the DB\n latest_snapshot = nil\n # for instances that were added regarding latest_snapshot\n added_cd = nil\n # for insrances that were removed regarding latest_snapshot\n removed_cd = nil\n\n latest_index_time = nil\n content_data.each_instance do |_,_,_,_,_,_,index_time|\n if latest_index_time.nil? || latest_index_time < index_time.to_i\n latest_index_time = index_time.to_i\n end\n end\n\n # Checking time consistency\n content_data_timestamp = DateTime.from_epoch(latest_index_time)\n if !@latest_timestamp.nil? && (content_data_timestamp <= @latest_timestamp)\n # It is possible when instances added at @latest_timestamp\n # were removed and any new instances addded,\n # then latest indexed time in the new content data\n # is earlier then @latest_timestamp\n # Example:\n # ContentData for Date1 (noted as latest_snapshot):\n # Content1\n # location1\n # location2\n # Between Date1 and Date2 location2 was removed\n # and no other file operations were done.\n # ContentData for Date2 (noted as content_data):\n # Content1\n # location1\n # Then:\n # content_data.remove_instances(latest_snapshot) is empty.\n latest_snapshot = get(@latest_timestamp)\n added_cd = content_data.remove_instances(latest_snapshot)\n msg = \"latest index time of the content data: #{content_data_timestamp}\" +\n \"must be later then latest timestamp: #{latest_timestamp}\"\n if added_cd.empty?\n # In this case we do not know exactly when the indexation was\n # then the timestamp is fake\n # TODO better solution?\n latest_timestamp_epoch = @latest_timestamp.strftime('%s')\n content_data_timestamp = DateTime.from_epoch(latest_timestamp_epoch.to_i + 1)\n Log.warning msg\n else\n fail msg\n end\n end\n\n if is_full_flush\n save(content_data,\n DiffFile::SNAPSHOT_TYPE,\n nil, # 'from' param is not relevant for full flush\n content_data_timestamp)\n end\n\n # If it is not the first content data that we store,\n # i.e there are already stored content data,\n # then a diff files are relevant.\n # NOTE we save diff (added/removed) files even in the case of full flush\n # cause of data consistency. It is crucial for the diff operation.\n # Example (simple, without removed):\n # When:\n # date1-date2.added\n # date2-date3.added (added along with a snapshot)\n # date3.snapshot\n # date3-date4.added\n # Then:\n # ContentDataDb.diff(date2, date4) = date2-date3.added + date3-date4.added\n if @latest_timestamp.nil?\n earliest_index_time = nil\n content_data.each_instance do |_,_,_,_,_,_,index_time|\n if earliest_index_time.nil? || earliest_index_time > index_time\n earliest_index_time = index_time\n end\n end\n content_data_from = DateTime.from_epoch(earliest_index_time)\n save(content_data,\n DiffFile::ADDED_TYPE,\n content_data_from,\n content_data_timestamp)\n else\n latest_snapshot ||= get(@latest_timestamp)\n\n added_cd ||= content_data.remove_instances(latest_snapshot)\n unless added_cd.empty?\n save(added_cd,\n DiffFile::ADDED_TYPE,\n @latest_timestamp,\n content_data_timestamp)\n end\n\n removed_cd = latest_snapshot.remove_instances(content_data)\n unless removed_cd.empty?\n save(removed_cd,\n DiffFile::REMOVED_TYPE,\n @latest_timestamp,\n content_data_timestamp)\n end\n end\n\n @latest_timestamp = content_data_timestamp\n end",
"def fuse(_following_chunk)\n nil\n end",
"def buffer_prev\n buffer_update_info\n if @_buffer_ctr < 1\n buffer_last\n return\n end\n @_buffer_ctr -= 1 if @_buffer_ctr > 0\n x = @_buffer_ctr\n l = @_buffers[x]\n if l\n populate_buffer_from_filename x\n l = @_buffers[x]\n $log.debug \"bp calling set_content with #{l.class} \"\n set_content l, @_buffers_conf[x]\n buffer_update_position\n end\n end",
"def ignore_bad_chunking=(_arg0); end",
"def new_chunk(index)\n chunk_num = (index / CHUNK_LINE_SIZE).to_i\n write_file = File.new(\"data/chunk#{chunk_num}\", \"w\")\n\n return write_file\nend",
"def enqueue(chunk)\n raise NotImplementedError, \"Implement this method in child class\"\n end",
"def begin_adding(*) end",
"def prepend_fragments(fragments)\n @fragments.unshift(*fragments)\n\n fragments.each do |fragment|\n @memory_used += fragment.memory_weight\n @tags += fragment.tags.to_set\n @run_list = (fragments.map(&:run_list).flatten.to_set +\n @run_list.to_set.to_set).to_a\n end\n end",
"def next_chunk\n mwc = (new_z << 16) + new_w\n [mwc].pack('L>')\n end",
"def chunk(count=100)\n criteria[:chunk] = count\n self\n end",
"def each\n pos = 0\n while(pos < @original_duration) do\n chunk = nil\n begin\n chunk = Chunk.new(@original_file, @original_duration, pos, (@chunk_duration + @overlap), @rate)\n yield chunk\n pos = pos + [chunk.duration, @chunk_duration].min\n ensure\n chunk.close_file if chunk\n end\n end\n end",
"def write_chunk(start, buffer)\n @local_file.seek(start)\n @local_file.write(buffer)\n end",
"def prepare_for_new_batch\n invoke_callback(:before_each_batch)\n\n new_rows.clear\n update_attrs.clear\n records.clear\n Thread.current[:existing_ids] = nil\n end",
"def flush()\n #This is a stub, used for indexing\n end",
"def test_enqueue_chunk_with_empty_key\n buf = Fluent::FileBuffer.new\n buf.configure({'buffer_path' => bufpath('enqueue2')})\n prefix = buf.instance_eval{ @buffer_path_prefix }\n suffix = buf.instance_eval{ @buffer_path_suffix }\n\n chunk = buf.new_chunk('')\n chunk << \"data1\\ndata2\\n\"\n\n assert chunk\n old_path = chunk.path.dup\n assert File.exist?(chunk.path)\n # chunk key is empty\n assert chunk.path =~ /\\A#{prefix}\\.b[0-9a-f]+#{suffix}\\Z/, \"path from new_chunk must be a 'b' buffer chunk\"\n\n buf.enqueue(chunk)\n\n assert chunk\n assert File.exist?(chunk.path)\n assert !(File.exist?(old_path))\n # chunk key is empty\n assert chunk.path =~ /\\A#{prefix}\\.q[0-9a-f]+#{suffix}\\Z/, \"enqueued chunk's path must be a 'q' buffer chunk\"\n\n data = chunk.read\n assert \"data1\\ndata2\\n\", data\n end",
"def add data, offset\n next_frag = 0\n $LOG.debug \"Setting partition at offset \" + offset.to_s + \" To \" + data\n len = data.length\n\n # can we fit it in??\n # lets say no. so we have to create a ????? and use that as\n # an enumerator\n #\n\n \n\n dary = [data].pack(\"a*\").unpack(\"C*\")\n @part[offset, dary.length] = dary\n\n @part[(offset + dary.length), 2] = [next_frag].pack(\"n\").unpack(\"C2\")\n \n @rem -= (dary.length + FileSystem::get_link_size)\n end",
"def chunk_it_up\n\n # start with an empty working set before any messages have been received\n working_set = []\n\n # pop a chunk (array of lines of filtered btmon output) off the\n # incoming queue\n while current_msg = @incoming_q.pop\n\n # test if the message indicates the start of a new message\n #\n # also bypass if our working set is empty as this indicates we are\n # receiving our first device of the run\n if starting_chunk?(current_msg) && !working_set.empty?\n\n # if we just got a new message shovel the working set into the\n # outgoing queue and reset it\n @outgoing_q.push working_set\n working_set = []\n end\n\n # inject a timestamp onto the message parsed out of the first line of\n # btmon output\n ts = Time.parse(current_msg.first.strip.scan(/\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}.\\d*$/)[0]).to_i\n current_msg << \"last_seen: #{ts}\"\n\n # add the current message to the working set\n working_set << current_msg\n end\n end",
"def rebuild\n header.sh_size = data.size\n @data\n end",
"def next_chunk_number\n\t\t\treturn -1\n\t\tend",
"def grow\n @is_growing =true\n end",
"def rewind\n @seen.clear\n super\n end",
"def try_insert_new(value)\n return false if used == @size\n\n entry = GClockBufferEntry.new(value, 1)\n @buffer[@pointer] = entry\n advance_pointer\n\n true\n end",
"def ingest_new_content( depositor, dirname, wsname, current, total )\n\n filename = File.join( dirname, wsname )\n _, asset_filenames = IngestHelpers.load_workset( filename )\n\n puts \"Ingesting #{current} of #{total}: #{filename} ...\"\n\n work_id = IngestHelpers.get_ingest_id( filename )\n if work_id.blank?\n puts \"ERROR: #{filename} has no ingest id, continuing anyway\"\n return false\n end\n\n work = TaskHelpers.get_work_by_id( work_id )\n if work.nil?\n puts \"ERROR: work #{work_id} does not exist, continuing anyway\"\n return false\n end\n\n asset_filenames.each_with_index do |f, ix|\n label = IngestHelpers.construct_file_label( ix + 1, f, work )\n puts \" asset #{ix + 1} of #{asset_filenames.length}: #{f} (#{label})\"\n\n # handle dry running\n next if ENV[ 'DRY_RUN' ]\n\n # and upload the file\n fileset = TaskHelpers.upload_file( depositor, work, File.join( dirname, f ), label )\n fileset.date_uploaded = DateTime.now\n fileset.save!\n end\n\n return true\n end",
"def chunks\n @_chunks ||= find_chunks(input)\n end",
"def chunks\n @_chunks ||= find_chunks(input)\n end",
"def _run\n super.tap { reenqueue }\n end",
"def push_dup; end",
"def local_flush\n end",
"def run\n begin\n yield @first_line if block_given?\n while (size = File::Stat.new(@filename).size) >= @next_start\n size = @file.stat.size\n reset_buffer_size\n begin\n line = \"\"\n @file.seek(@next_start, File::SEEK_SET)\n @file.read(@buf_size, @buffer)\n buffer_start = @next_start\n found_new_line = false\n 0.upto(@buffer.size - 1) do |index|\n line << @buffer[index]\n if @buffer[index].chr == \"\\n\"\n yield(line) if block_given?\n line = \"\"\n found_new_line = true\n @next_start = buffer_start + index + 1\n end\n end\n unless found_new_line || @buffer.empty?\n raise BufferError\n end\n rescue BufferError\n increment_buffer_size\n retry\n end\n\t sleep 0.01\n end\n rescue Errno::ENOENT\n # Wait until the file is recreated\n while !File.exists?(@filename)\n sleep 0.05\n end\n end\n end",
"def reset\n super\n @first_iteration = true\n end",
"def refresh\n generate_part_rects\n generate_buffers\n self\n end",
"def flush_next_in\n\t\t@in_pos = @input_buffer.length\n\t\t@finished = true\n\t\tret = @input_buffer.pack(\"c*\")\n\t\t@input_buffer = []\n\t\tret\n\tend",
"def inserir_item(item)\n # Insere um item no inicio do buffer\n BUFFER.unshift item\n end",
"def move_later\n nekst = self.next\n self.append_to(nekst) if nekst\n end",
"def flush_next_in\n\t\t\t@in_pos = @input_buffer.length\n\t\t\t@finished = true\n\t\t\tret = @input_buffer.pack(\"c*\")\n\t\t\t@input_buffer = []\n\t\t\tret\n\t\tend",
"def rewind; begin!; self end",
"def fill_buffer(step, iterations)\n buffer = [0]\n pos = 0\n\n (1..iterations).each do |i|\n pos = (pos + step) % buffer.length + 1\n buffer.insert(pos, i)\n end\n\n buffer\nend",
"def add_for_num_blocks(words)\n # We just add to the single block, and we split this when we call\n # #blocks\n @single_block += words\n end",
"def flush\n if @carry_over\n @contents['info']['pieces'] << Digest::SHA1.digest( @carry_over )\n end\n unless @contents['creation date']\n @contents['creation date'] = Time.now.tv_sec\n end\n @io << @contents.bencode\n @io.flush\n self\n end",
"def add_for_num_blocks(words)\n # We just add to the single block, and we split this when we call\n # #blocks\n single_block.concat(words)\n end",
"def new_trick\n put(:trick, Hamster::Deque.empty)\n end",
"def pre_append(storage_obj)\n if (item = @cache.get(storage_obj.key)) # the key exists in cache\n pre_append_storage item, storage_obj\n else\n NOT_STORED_MSG\n end\n end",
"def advance_head\n\t\t\t@head_index += 1\n\t\t\t@head_index = 0 if @head_index == @queue.size\n\t\tend",
"def next_item\n storage.rotate!\n\n update\n end",
"def next_item\n storage.rotate!\n\n update\n end",
"def rolling_buffer1(buffer, max_buffer_size, new_element)\n buffer << new_element\n buffer.shift if buffer.size > mas_buffer_size\n buffer\nend",
"def pre_sync\n #move\n end",
"def initial_add(&block)\n @tree.initial_add(&block)\n do_refresh\n\n ## Launch a timer to refresh the file list\n #Gtk.timeout_add(Config[:files_refresh_interval] * 100000) do \n # puts \"Auto-refreshing\"\n # do_refresh\n # true\n #end\n end",
"def reconsume; end",
"def batch_new\n end",
"def test_normal_prepend\n @store.set(@key, @flag, @exp_time, @size, @value, @no_reply)\n\n assert_equal(STORED, @store.prepend(@key, @size_prepend, @value_prepend, @no_reply), STORED_MESSAGE)\n end",
"def sync() end",
"def sync() end",
"def sync() end",
"def process_slice\n @block.call(@slice) if @slice.any?\n @seen |= @slice.map(&:filename).map(&:to_s)\n @slice = []\n end",
"def <<(chunk, last_chunk = T.unsafe(nil)); end",
"def <<(chunk, last_chunk = T.unsafe(nil)); end",
"def <<(chunk, last_chunk = T.unsafe(nil)); end",
"def <<(chunk, last_chunk = T.unsafe(nil)); end",
"def next()\n\n @filehandler.pos = @list_of_positions[@current_iteration]\n\n if @list_of_positions.length > @current_iteration\n @current_iteration += 1\n end\n\n make_entry()\n\n end",
"def take_place\n super(1)\n end",
"def ignore_bad_chunking=(ignore_bad_chunking); end",
"def keep_going; end",
"def rewind()\n #This is a stub, used for indexing\n end",
"def chunk_job(job, state, apikey, filename, filesize, start_response, storage)\n offset = 0\n seek_point = job[:seek_point]\n chunk_list = []\n\n while (offset < FilestackConfig::DEFAULT_CHUNK_SIZE) && (seek_point + offset) < filesize\n chunk_list.push(\n seek_point: seek_point,\n filename: filename,\n apikey: apikey,\n part: job[:part],\n size: job[:size],\n uri: start_response['uri'],\n region: start_response['region'],\n upload_id: start_response['upload_id'],\n location_url: start_response['location_url'],\n store: { location: storage },\n offset: offset\n )\n offset += state.offset\n end\n chunk_list\n end",
"def add(hash)\n batch << hash\n\n if batch.count % batch_size == 0\n solr_service_connection.add(batch, softCommit: soft_commit, commit: commit)\n batch.clear\n end\n end",
"def after_appending( state )\n\t\t# Nothing to do\n\t\treturn nil\n\tend",
"def on_body(chunk)\n @currently_reading.fill_buffer(chunk)\n end",
"def before_appending( state )\n\t\t# Nothing to do\n\t\treturn nil\n\tend",
"def flush() end",
"def flush() end",
"def flush() end",
"def merge!\n\t\t\twhile handle = @queue.pop\n\t\t\t\tnext if handle.cancelled?\n\t\t\t\t\n\t\t\t\[email protected](handle)\n\t\t\tend\n\t\tend",
"def enqueue_pending_output; end",
"def add_block block\n block.at self.length\n @blocks << block\n end",
"def rewind()\n #This is a stub, used for indexing\n end",
"def next_item\n storage.rotate!\n\n update\n end",
"def rolling_buffer1(buffer, max_buffer_size, new_element)\n buffer << new_element # Mutates the caller \n buffer.shift if buffer.size > max_buffer_size\n buffer\nend",
"def beginning_to_pack_fragment(_fragment)\n end",
"def next_state!\n if cur_val\n self.cur_val += chunk.value\n else\n self.cur_val = chunk.value\n end\n\n if chunk.value_size.zero?\n persist_cell\n self.state = ROW_IN_PROGRESS\n else\n self.state = CELL_IN_PROGRESS\n end\n\n return unless chunk.commit_row\n\n self.last_key = row.key\n completed_row = row\n reset_to_new_row\n completed_row\n end",
"def start! *_\n self.count = 0\n end",
"def push &put\n #Thread.pass while self.full?\n sleep 0.01 while self.full?\n self.push! &put\n end",
"def flush; end",
"def flush; end"
] | [
"0.7177806",
"0.6609853",
"0.6422074",
"0.6190774",
"0.60896546",
"0.5950836",
"0.59035337",
"0.5858389",
"0.58377206",
"0.58377206",
"0.5808672",
"0.5759759",
"0.57495934",
"0.5720551",
"0.5671632",
"0.5633452",
"0.56172466",
"0.5604962",
"0.56021214",
"0.55881464",
"0.55529106",
"0.5549552",
"0.55457497",
"0.55314475",
"0.54979616",
"0.5420889",
"0.5397224",
"0.53877604",
"0.5385901",
"0.5375849",
"0.5359404",
"0.535232",
"0.5341657",
"0.533007",
"0.53192437",
"0.5308451",
"0.5297988",
"0.5296655",
"0.52947354",
"0.52934945",
"0.52934945",
"0.52865046",
"0.5279032",
"0.527032",
"0.52669644",
"0.5261476",
"0.52569395",
"0.52564764",
"0.5251392",
"0.524683",
"0.5235941",
"0.5229964",
"0.52281857",
"0.52108574",
"0.52077633",
"0.51997495",
"0.5197434",
"0.5197014",
"0.51947355",
"0.5190474",
"0.5190474",
"0.51853323",
"0.51825947",
"0.5179951",
"0.51702803",
"0.51608515",
"0.51506793",
"0.5149438",
"0.5149438",
"0.5149438",
"0.5140119",
"0.5137048",
"0.5137048",
"0.5137048",
"0.5137048",
"0.51352173",
"0.51339525",
"0.51338077",
"0.5125048",
"0.51213175",
"0.5119966",
"0.5118991",
"0.5116075",
"0.5115122",
"0.5111985",
"0.51103604",
"0.51103604",
"0.51103604",
"0.51081127",
"0.50864536",
"0.5086391",
"0.5086184",
"0.5086135",
"0.50852495",
"0.5075228",
"0.5070363",
"0.50649",
"0.50591046",
"0.50491434",
"0.50491434"
] | 0.7507271 | 0 |
test save with funny char | def test_exotic_char
CheckFile @writer, @ioservice, @adlers,
"J'espère que ça va marcher",
"J'espère que ça va marcher".bytes.each_slice(@chunkSize).to_a.map{|a| a.pack('C*')}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save\n ConsoleGlitter.escape(\"s\")\n end",
"def write_to_disk\n if @params and errors.empty?\n unless DiskWriter.save_textfile(@old_location, self.location, self.contents)\n errors.add(\"Write to disk failed:\", \"check for invalid characters in '#{self.location}'\")\n throw(:abort)\n end\n end\n end",
"def save\n\n playerset('')\n $savefile = File.new(\"../Resources/Saves/save.txt\", \"w\")\n $savefile.puts(@@hand, @@ehand)\n cputs(\"saved\", \"green\")\n\nend",
"def test_encoded_in_different_out\n doc = Document.new( @encoded )\n REXML::Formatters::Default.new.write( doc.root, Output.new( out=\"\", \"UTF-8\" ) )\n out.force_encoding(::Encoding::ASCII_8BIT)\n assert_equal( @not_encoded.b, out )\n end",
"def save_character account, filename, data\n end",
"def test_encoded_in_encoded_out\n doc = Document.new( @encoded )\n doc.write( out=\"\" )\n out.force_encoding(::Encoding::ASCII_8BIT)\n assert_equal( @encoded.b, out )\n end",
"def modify\n save = modify_save_for_slot(2)\n\n save_hex = bin_file_to_hex save\n before_length = save_hex.length\n broad_sword_count = save_hex.scan(broad_sword).length\n puts \"[before] Broad sword x#{broad_sword_count}\"\n\n save_hex.gsub!(broad_sword, zwill_crossblades)\n after_length = save_hex.length\n raise 'Save corrupted!' unless before_length == after_length\n\n broad_sword_count = save_hex.scan(broad_sword).length\n puts \"[after] Broad sword x#{broad_sword_count}\"\n\n hex_to_bin_file(save, save_hex)\n\n FileUtils.cp save, 'C:\\Users\\surface\\AppData\\Local\\Temp\\SWPS4MAX\\__gameplay____slot2__gameplay0.save'\n end",
"def test_notes_export_format\n assert_equal(\n \"\",\n observations(:minimal_unknown_obs).notes_export_formatted\n )\n\n assert_equal(\n \"Found in a strange place... & with śtrangè characters™\",\n observations(:detailed_unknown_obs).notes_export_formatted\n )\n assert_equal(\n \"substrate: soil\",\n observations(:substrate_notes_obs).notes_export_formatted\n )\n assert_equal(\n \"substrate: soil\\nOther: slimy\",\n observations(:substrate_and_other_notes_obs).notes_export_formatted\n )\n end",
"def save!(filename = T.unsafe(nil)); end",
"def save!(filename = T.unsafe(nil)); end",
"def test_encoded_in_change_out\n doc = Document.new( @encoded )\n doc.xml_decl.encoding = \"UTF-8\"\n assert_equal(\"UTF-8\", doc.encoding)\n REXML::Formatters::Default.new.write( doc.root, out=\"\" )\n out.force_encoding(::Encoding::ASCII_8BIT)\n assert_equal( @not_encoded.b, out )\n char = XPath.first( doc, \"/a/b/text()\" ).to_s\n char.force_encoding(::Encoding::ASCII_8BIT)\n assert_equal( \"ĉ\".b, char )\n end",
"def test_that_char_setting_is_accurate\n end",
"def save(filename = T.unsafe(nil)); end",
"def save(filename = T.unsafe(nil)); end",
"def encode_string_ex; end",
"def test_save_encrypted_type_d_format_3\n ppk = create_test_ppk\n temp_file_name do |file|\n ppk.save(file, 'Test Passphrase', format: 3, argon2_params: PuTTY::Key::Argon2Params.new(type: :d, memory: 4096, passes: 9, salt: \"\\xbc\\x44\\x19\\x1a\\xa9\\x26\\x73\\xa5\\xc0\\x54\\x3f\\x37\\x36\\x33\\xdd\\xf4\".b ))\n assert_identical_to_fixture(\"test-encrypted-type-d-format-3.ppk\", file)\n end\n end",
"def test_validate_reason_code_with_valid_special_characters_only\n reason_code1 = ReasonCode.new\n reason_code1.reason_code = \"-._\"\n reason_code1.save\n assert !reason_code1.valid?, reason_code1.errors.full_messages.to_s\n end",
"def is_ascii_character?\n dup.force_encoding(\"binary\")[0].ord < 128\n end",
"def test_it_displays_correct_encoded_confirmation_msg\n #skipped when message.txt changes from Hello world and resulting byte-count changes\n if ARGV[0] == \"message.txt\" #skips test depending on encoding or decoding\n night_write = NightWrite.new\n expected = \"Created 'braille.txt' containing 74 characters.\"\n actual = night_write.display_encoded_confirmation_message\n assert_equal expected, actual\n end\n end",
"def save_as(filename = T.unsafe(nil)); end",
"def save_as(filename = T.unsafe(nil)); end",
"def save_as(filename = T.unsafe(nil)); end",
"def create_save\n @save_data = {:turns => @turns,:guesses => @guesses,:secret_word => @secret_word, :hidden_word => @hidden_word}\n save = File.new(\"./lib/save.txt\", \"w+\")\n save.puts JSON::dump(save_data)\n save.close\n end",
"def test_save?\n c = cli\n refute(c.save?)\n\n c = cli(['-s'])\n assert(c.save?)\n end",
"def stub_valid_text\n FileUtils.mkdir(\"/b\")\n File.open(\"/b/b_n000001_m.tif\", \"w\") do |f|\n f.puts(\"hohoho\")\n end\n Nyudl::Text::Base.new('/b', 'b')\n end",
"def ascii_only?()\n #This is a stub, used for indexing\n end",
"def save!; File.write @path, @data end",
"def utf8write(str,f)\n File.open(f,\"wb:utf-8\"){|ff|\n ff.write(str)\n }\nend",
"def test_in_change_out\n doc = Document.new( @not_encoded )\n doc.xml_decl.encoding = \"ISO-8859-3\"\n assert_equal(\"ISO-8859-3\", doc.encoding)\n doc.write( out=\"\" )\n out.force_encoding(::Encoding::ASCII_8BIT)\n assert_equal( @encoded.b, out )\n end",
"def save\n File.open(@test_name, \"w+\") do |file|\n file.write(render)\n end\n end",
"def create_save\n @save_data = {:turns => @turns,:guesses => @guesses,:secret_word => @secret_word, :hidden_word => @hidden_word}\n save = File.new(\"save.txt\", \"w+\")\n save.puts JSON::dump(save_data)\n save.close\n end",
"def characterize(save: true)\n persister.save(resource: @file_node) if save\n @file_node\n end",
"def test_serialize_non_ascii_data_to_json\n data = {\"foo\" => \"\\u3042\\u4e9c\\u03b1\"}\n driver = create_driver('')\n assert_equal(%q({\"foo\":\"\\u3042\\u4e9c\\u03b1\"}), driver.instance.to_json(data))\n end",
"def test_in_different_out\n doc = Document.new( @not_encoded )\n doc.write( Output.new( out=\"\", \"ISO-8859-3\" ) )\n out.force_encoding(::Encoding::ASCII_8BIT)\n assert_equal( \"<?xml version='1.0'?>#{@encoded_root}\".b, out )\n end",
"def writeencoding; end",
"def ascii?\n not binary?\n end",
"def before_save \n filename.strip!\n filename.gsub(/^(..)+/, \".\")\n filename.gsub(/[^\\s]/, \"\") # replace spaces with \n # replace all non alphanumeric, underscore or periods with underscore\n filename.gsub(/^[\\W]+$/, '_')\n end",
"def save_turn_without_rescue\n File.open(SAVE_FILE, \"wb\") do |file|\n Marshal.dump($game_variables[VAR], file)\n Marshal.dump($game_variables[VAR2], file)\n end\n return true\n end",
"def test_validate_reason_code_with_invalid_special_characters\n reason_code1 = ReasonCode.new\n reason_code1.reason_code = \"RC&&\"\n reason_code1.save\n assert !reason_code1.valid?, reason_code1.errors.full_messages.to_s\n end",
"def valid_guess?(guess)\n\t\tguess == 'SAVE' || (('A'..'Z').include?(guess) && (!(@wrong_letters.include?(guess))))\n\tend",
"def test_validate_patient_name_and_account_number_with_consecutive_occurrence_of_valid_special_characters\n image_type_record = ImageType.new\n image_type_record.patient_first_name = \"RAJ..p\"\n image_type_record.patient_last_name = \"mek..ha\"\n image_type_record.patient_account_number= \"A89--990\"\n image_type_record.image_type = \"NOT\"\n image_type_record.save\n assert !image_type_record.valid?, image_type_record.errors.full_messages.to_s\n end",
"def test_sdbm\n key = 'あいうえおかきくけこ'\n val = 'たちつてとなにぬねの'\n @tag.tag_db[key] = val\n assert_equal val, @tag.tag_db[key].force_encoding(Encoding::UTF_8)\n end",
"def test_save_insert\r\n @new = TestLibrary.new\r\n @new.autor = \"Novy\"\r\n @new.text = \"La la la la...\"\r\n \r\n if @new.save.is_a? Numeric\r\n assert true\r\n else \r\n assert false, \"Nepodarilo se ulozit\"\r\n end\r\n end",
"def test_odd_chars\n file = Chisel.new\n a = file.odd_chars\n assert a[2].include?(\"&\")\n end",
"def unsafe_save(namespace, key, data)\n path = make_path(namespace, key)\n tmp = Tempfile.new('abbey') \n size = tmp.write(MultiJson.encode(data))\n tmp.close\n FileUtils.mv(tmp.path, path)\n settings.logger.info(\"Written #{make_key(namespace, key)} (size: #{size})\")\n tmp.unlink\n end",
"def write_save_data(file)\r\n write_characters(file)\r\n write_frame(file)\r\n write_setup(file)\r\n write_data(file)\r\n end",
"def test_illegal_char\n\t\tassert_equal(\"877195GILL869x\", glosub(\"877195G IL--L869x\"))\n\tend",
"def test_should_not_allow_escaped_characters_without_quotes\n [\n 'Fred\\ [email protected]',\n 'Abc\\@[email protected]',\n 'Joe.\\\\[email protected]'\n ].each do |email|\n p = create_person(:email => email)\n save_fails(p, email)\n end\n end",
"def ascii(type)\n if type == \"products\"\n store_to_file \"\\n _ _ \"\n store_to_file \" | | | | \"\n store_to_file \" _ __ _ __ ___ __| |_ _ ___| |_ ___ \"\n store_to_file \"| '_ \\\\| '__/ _ \\\\ / _` | | | |/ __| __/ __|\"\n store_to_file \"| |_) | | | (_) | (_| | |_| | (__| |_\\\\__ \\\\\"\n store_to_file \"| .__/|_| \\\\___/ \\\\__,_|\\\\__,_|\\\\___|\\\\__|___/\"\n store_to_file \"| | \"\n store_to_file \"|_| \\n\\n \"\n elsif type == \"brands\"\n store_to_file \"\\n _ _ \"\n store_to_file \"| | | | \"\n store_to_file \"| |__ _ __ __ _ _ __ __| |___ \"\n store_to_file \"| '_ \\\\| '__/ _` | '_ \\\\ / _` / __|\"\n store_to_file \"| |_) | | | (_| | | | | (_| \\\\__ \\\\\"\n store_to_file \"|_.__/|_| \\\\__,_|_| |_|\\\\__,_|___/\\n\\n\"\n elsif type == \"sales\"\n store_to_file \"\\n _ _ \"\n store_to_file \" | | | | \"\n store_to_file \" ___ __ _| | ___ ___ _ __ ___ _ __ ___ _ __| |_ \"\n store_to_file \"/ __|/ _` | |/ _ \\\\/ __| | '__/ _ \\\\ '_ \\\\ / _ \\\\| '__| __| \"\n store_to_file \"\\\\__ \\\\ (_| | | __/\\\\__ \\\\ | | | __/ |_) | (_) | | | |_ \"\n store_to_file \"|___/\\\\__,_|_|\\\\___||___/ |_| \\\\___| .__/ \\\\___/|_| \\\\__| \"\n store_to_file \" | | \"\n store_to_file \" |_|\\n\\n\"\n end\nend",
"def determine_savefile\n if @saving\n if FileTest.exist?(make_filename(@last_slot_index))\n Sound.play_decision\n @confirm_window.show()\n @window_slotlist.active=false\n else\n Sound.play_save\n do_save()\n end\n else\n if FileTest.exist?(make_filename(@last_slot_index))\n Sound.play_load\n do_load()\n else\n Sound.play_buzzer\n end\n end\n end",
"def test_write\n # Use a temp directory to clean-up everything automatically.\n Dir.mktmpdir { |tmpdir|\n tmpdir = Pathname.new(tmpdir)\n file = tmpdir + \"test.ogg\"\n\n FileUtils.cp(\"test/data/empty.ogg\", file.to_s)\n\n ogg = OggAlbumTagger::OggFile.new(file)\n ogg.set_values \"GENRE\", \"Acoustic\", \"Rock\"\n ogg.set_values \"UNICODETAG\", \"öäüoΣø\"\n ogg.set_values \"METADATA_BLOCK_PICTURE\", LENA\n ogg.write file.to_s\n\n # Make sure the data written can be properly reloaded.\n ogg2 = OggAlbumTagger::OggFile.new(file)\n assert_equal %w{GENRE UNICODETAG METADATA_BLOCK_PICTURE}.to_set, ogg2.tags.to_set\n assert_equal %w{Acoustic Rock}.to_set , ogg2['GENRE']\n assert_equal Set[\"öäüoΣø\"] , ogg2['UNICODETAG']\n assert_equal Set[LENA] , ogg2['METADATA_BLOCK_PICTURE']\n }\n end",
"def save\n file_name = ask_save_file\n save_file = File.open(file_name, 'w')\n save_file.puts(serialize)\n save_file.close\n puts \"Game has been saved to Save File #{file_name[-5]}!\"\n puts \"\\n\\n\"\n end",
"def guess_char\n\n\t\tbegin\n\t\t\tputs \"Input your guess or save:\"\n\t\t\tchar = gets.chomp.downcase\n\t\t\n\t\traise puts \"Wrong input!\" unless (char.length == 1 && ('a'..'z').include?(char)) || char == 'save'\n\n\t\trescue\n\t\t\tretry\n\t\t\n\t\telse\n\n\t\t\tif char == 'save'\n\t\t\t\tsave_game\n\t\t\t\tputs \"Game saved!\"\n\n\t\t\t\t@lives += 1 # because this is counted as a turn? :S\n\t\t\tend\n\t\t\n\t\tend\n\n\n\n\t\tguess_check(char)\n\t\tturn\n\tend",
"def write_char(c)\n if c == \"\\000\"\n # Return to original text\n c = \"\\\\\"\n end\n # If \\C[n]\n if c == \"\\001\"\n # Change text color\n @text.sub!(/\\[([0-9]+)\\]/, \"\")\n color = $1.to_i\n if color >= 0 and color <= 7\n self.contents.font.color = text_color(color)\n end\n # go to next text\n return\n end\n # If \\G\n if c == \"\\002\"\n # Make gold window\n if @gold_window == nil\n @gold_window = Window_Gold.new\n @gold_window.x = 560 - @gold_window.width\n if $game_temp.in_battle\n @gold_window.y = 192\n else\n @gold_window.y = self.y >= 128 ? 32 : 384\n end\n @gold_window.opacity = self.opacity\n @gold_window.back_opacity = self.back_opacity\n end\n # go to next text\n return\n end\n # If \\skip\n if c == \"\\003\"\n # toggle text skipping\n #$game_system.text_skip = !$game_system.text_skip\n # go to next text\n return\n end\n # If \\b\n if c == \"\\004\"\n # toggle bold\n self.contents.font.bold = !self.contents.font.bold\n # go to next text\n return\n end\n # If \\i\n if c == \"\\005\"\n # toggle italics\n self.contents.font.italic = !self.contents.font.italic\n # go to next text\n return\n end\n # If \\s\n if c == \"\\006\"\n # toggle shadow\n #$game_system.shadowed_text = !$game_system.shadowed_text\n # go to next text\n return\n end\n # If \\font\n if c == \"\\007\"\n # change font\n @text.sub!(/\\[(.*?)\\]/, \"\")\n font = $1.to_s\n @font = font\n if font == \"\"\n self.contents.font.name = Font.default_name\n else\n self.contents.font.name = font\n end\n # go to next text\n return\n end\n # If \\p[n]\n if c == \"\\010\"\n @text.sub!(/\\[([0-9]+)\\]/, \"\")\n @pause_time = $1.to_i\n\n # go to next text\n return\n end\n \n # If \\w[n]\n if c == \"\\011\"\n @text.sub!(/\\[([0-9]+)\\]/, \"\")\n @wait = $1.to_i\n\n # go to next text\n return\n end\n \n # If \\ws[n]\n if c == \"\\013\"\n @text.sub!(/\\[([0-9]+)\\]/, \"\")\n $game_system.write_speed = $1.to_i\n\n # go to next text\n return\n end \n # If \\oa[n]\n if c == \"\\014\"\n @text.sub!(/\\[([0-9]+)\\]/, \"\")\n index = $1.to_i\n @text.sub!(\" \", \"\")\n item = $data_armors[index]\n # draw the icon\n icon = RPG::Cache.icon(item.icon_name)\n self.contents.blt(@x + 2, (@y * 32) + 4, icon, Rect.new(0, 0, 24, 24))\n @x += 24\n\n # go to next text\n return\n end\n \n # If \\oi[n]\n if c == \"\\015\"\n @text.sub!(/\\[([0-9]+)\\]/, \"\")\n index = $1.to_i\n @text.sub!(\" \", \"\")\n item = $data_items[index]\n # draw the icon\n icon = RPG::Cache.icon(item.icon_name)\n self.contents.blt(@x + 2, (@y * 32) + 4, icon, Rect.new(0, 0, 24, 24))\n @x += 24\n\n # go to next text\n return\n end\n \n # If \\os[n]\n if c == \"\\016\"\n @text.sub!(/\\[([0-9]+)\\]/, \"\")\n index = $1.to_i\n @text.sub!(\" \", \"\")\n item = $data_skills[index]\n # draw the icon\n icon = RPG::Cache.icon(item.icon_name)\n self.contents.blt(@x + 2, (@y * 32) + 4, icon, Rect.new(0, 0, 24, 24))\n @x += 24\n\n # go to next text\n return\n end\n \n # If \\ow[n]\n if c == \"\\017\"\n @text.sub!(/\\[([0-9]+)\\]/, \"\")\n index = $1.to_i\n @text.sub!(\" \", \"\")\n item = $data_weapons[index]\n # draw the icon\n icon = RPG::Cache.icon(item.icon_name)\n self.contents.blt(@x + 2, (@y * 32) + 4, icon, Rect.new(0, 0, 24, 24))\n @x += 24\n \n # go to next text\n return\n end\n \n # If \\tc\n if c == \"\\020\"\n # center justify\n @text_justification = CENTER\n get_x_value\n # go to next text\n return\n end\n \n # If \\tl\n if c == \"\\021\"\n # left justify\n @text_justification = LEFT\n get_x_value\n # go to next text\n return\n end\n \n # If \\tr\n if c == \"\\022\"\n # right justify\n @text_justification = RIGHT\n get_x_value\n # go to next text\n return\n end\n \n # If \\ignr\n if c == \"\\023\"\n # set ignore flage\n @ignore = true\n # go to next text\n return\n end\n \n # if \\c (hex color)\n if c == \"\\026\"\n # convert hex color to RGB\n @text.sub!(/\\[([0123456789abcdef]+)\\]/, \"\")\n hex_code = $1.to_s\n \n red = (\"0x\" + hex_code.slice(0..1)).hex\n blue = (\"0x\" + hex_code.slice(2..3)).hex\n green = (\"0x\" + hex_code.slice(4..5)).hex\n \n self.contents.font.color = Color.new(red, blue, green)\n return\n end\n \n # If new line text\n if c == \"\\n\"\n # Add 1 to y\n if !@ignore\n @y += 1\n end\n if @text != \"\"\n get_x_value\n end\n @ignore = false\n\n # go to next text\n return\n end\n if @ignore\n return\n end\n # Draw text\n line = self.contents.text_size(\"dj\").height\n if $game_system.shadowed_text\n old_color = self.contents.font.color.clone\n self.contents.font.color = $game_system.shadow_color\n self.contents.draw_text(6 + @x, line * @y + 2, 40, 32, c)\n self.contents.font.color = old_color\n end\n self.contents.draw_text(4 + @x, line * @y, 40, 32, c)\n # Add x to drawn text width\n @x += self.contents.text_size(c).width\n end",
"def write_txt\n true\n end",
"def write_char(c)\n if c == \"\\000\"\n # Return to original text\n c = \"\\\\\"\n end\n # If \\C[n]\n if c == \"\\001\"\n # Change text color\n @text.sub!(/\\[([0-9]+)\\]/, \"\")\n color = $1.to_i\n if color >= 0 and color <= 7\n self.contents.font.color = text_color(color)\n end\n # go to next text\n return\n end\n # If \\G\n if c == \"\\002\"\n # Make gold window\n if @gold_window == nil\n @gold_window = Window_Gold.new\n @gold_window.x = 560 - @gold_window.width\n if $game_temp.in_battle\n @gold_window.y = 192\n else\n @gold_window.y = self.y >= 128 ? 32 : 384\n end\n @gold_window.opacity = self.opacity\n @gold_window.back_opacity = self.back_opacity\n end\n # go to next text\n return\n end\n # If \\skip\n if c == \"\\003\"\n # toggle text skipping\n $game_system.text_skip = !$game_system.text_skip\n # go to next text\n return\n end\n # If \\b\n if c == \"\\004\"\n # toggle bold\n self.contents.font.bold = !self.contents.font.bold\n # go to next text\n return\n end\n # If \\i\n if c == \"\\005\"\n # toggle italics\n self.contents.font.italic = !self.contents.font.italic\n # go to next text\n return\n end\n # If \\s\n if c == \"\\006\"\n # toggle shadow\n $game_system.shadowed_text = !$game_system.shadowed_text\n # go to next text\n return\n end\n # If \\font\n if c == \"\\007\"\n # change font\n @text.sub!(/\\[(.*?)\\]/, \"\")\n font = $1.to_s\n $game_system.font = font\n if font == \"\"\n self.contents.font.name = Font.default_name\n else\n self.contents.font.name = font\n end\n # go to next text\n return\n end\n # If \\p[n]\n if c == \"\\010\"\n @text.sub!(/\\[([0-9]+)\\]/, \"\")\n @pause_time = $1.to_i\n\n # go to next text\n return\n end\n \n # If \\w[n]\n if c == \"\\011\"\n @text.sub!(/\\[([0-9]+)\\]/, \"\")\n @wait = $1.to_i\n\n # go to next text\n return\n end\n \n # If \\ws[n]\n if c == \"\\013\"\n @text.sub!(/\\[([0-9]+)\\]/, \"\")\n $game_system.write_speed = $1.to_i\n\n # go to next text\n return\n end \n # If \\oa[n]\n if c == \"\\014\"\n @text.sub!(/\\[([0-9]+)\\]/, \"\")\n index = $1.to_i\n @text.sub!(\" \", \"\")\n item = $data_armors[index]\n # draw the icon\n icon = RPG::Cache.icon(item.icon_name)\n line = self.contents.text_size(\"dj\").height\n self.contents.blt(@x + 4, (@y * line) + 4, icon, Rect.new(0, 0, 24, 24))\n @x += 24\n\n # go to next text\n return\n end\n \n # If \\oi[n]\n if c == \"\\015\"\n @text.sub!(/\\[([0-9]+)\\]/, \"\")\n index = $1.to_i\n @text.sub!(\" \", \"\")\n item = $data_items[index]\n # draw the icon\n\t if item != nil\n\t\ticon = RPG::Cache.icon(item.icon_name) \n\t\tline = self.contents.text_size(\"dj\").height\n\t\tself.contents.blt(@x + 4, (@y * line) + 4, icon, Rect.new(0, 0, 24, 24))\n\t\t@x += 24\n\t end\n\n # go to next text\n return\n end\n \n # If \\os[n]\n if c == \"\\016\"\n @text.sub!(/\\[([0-9]+)\\]/, \"\")\n index = $1.to_i\n @text.sub!(\" \", \"\")\n item = $data_skills[index]\n # draw the icon\n icon = RPG::Cache.icon(item.icon_name)\n line = self.contents.text_size(\"dj\").height\n self.contents.blt(@x + 2, (@y * line) + 4, icon, Rect.new(0, 0, 24, 24))\n @x += 24\n\n # go to next text\n return\n end\n \n # If \\ow[n]\n if c == \"\\017\"\n @text.sub!(/\\[([0-9]+)\\]/, \"\")\n index = $1.to_i\n @text.sub!(\" \", \"\")\n item = $data_weapons[index]\n # draw the icon\n icon = RPG::Cache.icon(item.icon_name)\n line = self.contents.text_size(\"dj\").height\n self.contents.blt(@x + 2, (@y * line) + 4, icon, Rect.new(0, 0, 24, 24))\n @x += 24\n \n # go to next text\n return\n end\n \n # If \\tc\n if c == \"\\020\"\n # center justify\n $game_system.text_justification = CENTER\n get_x_value\n # go to next text\n return\n end\n \n # If \\tl\n if c == \"\\021\"\n # left justify\n $game_system.text_justification = LEFT\n get_x_value\n # go to next text\n return\n end\n \n # If \\tr\n if c == \"\\022\"\n # right justify\n $game_system.text_justification = RIGHT\n get_x_value\n # go to next text\n return\n end\n \n # If \\ignr\n if c == \"\\023\"\n # set ignore flage\n @ignore = true\n # go to next text\n return\n end\n \n # if \\slv\n if c == \"\\024\"\n # we need to show a slave window\n @text.sub!(/\\[(.*?)\\]/, \"\")\n name = $1.to_s\n $game_system.slave_windows[name].show = true\n return\n end\n \n # if \\ind\n if c == \"\\025\"\n # we need to show a independent window\n @text.sub!(/\\[(.*?)\\]/, \"\")\n name = $1.to_s\n if $game_system.indy_windows[name].show\n $game_system.indy_windows[name].dispose\n $game_system.indy_windows.delete(name)\n else\n $game_system.indy_windows[name].show = true\n end\n return\n end\n \n # if \\c (hex color)\n if c == \"\\026\"\n # convert hex color to RGB\n @text.sub!(/\\[([0123456789abcdef]+)\\]/, \"\")\n hex_code = $1.to_s\n \n red = (\"0x\" + hex_code.slice(0..1)).hex\n blue = (\"0x\" + hex_code.slice(2..3)).hex\n green = (\"0x\" + hex_code.slice(4..5)).hex\n \n self.contents.font.color = Color.new(red, blue, green)\n return\n end\n \n # If new line text\n if c == \"\\n\"\n # Add 1 to y\n if !@ignore\n @y += 1\n end\n if @text != \"\"\n get_x_value\n end\n @ignore = false\n\n # go to next text\n return\n end\n if @ignore\n return\n end\n # Draw text\n line = self.contents.text_size(\"dj\").height\n if $game_system.shadowed_text\n old_color = self.contents.font.color.clone\n self.contents.font.color = $game_system.shadow_color \n self.contents.draw_text(6 + @x, line * @y + 2, 40, 32, c)\n self.contents.font.color = old_color\n end\n self.contents.draw_text(4 + @x, line * @y, 40, 32, c)\n # Add x to drawn text width\n @x += self.contents.text_size(c).width\n end",
"def save_data?\n return safeExists?(RTP.getSaveFileName(\"Game.rxdata\"))\n end",
"def save\n return false unless Restaurant.file_usable? #? better way? need to do given next line will return false if need be?..or will it return an error\n File.open(@@filepath,\"a\") do |file|\n file.puts \"#{[@name, @cuisine, @price].join(\"\\t\")}\\n\" #? better way?\n end\n return true\n # if ...\n # return true\n # else\n # return false\n # end\n end",
"def test_special_characters\n v = Verify.new\n return_code = v.verify_second_pipeset('2.s3', '2.s3')\n assert_equal 1, return_code\n end",
"def save filename = nil\n filename = find_free_name filename\n save! filename\n end",
"def test_removes_ascii_del\n text = \"\\x7F\"\n text.force_encoding(\"UTF-8\")\n assert_equal \"\", Latexpdf.escape_latex(text)\n end",
"def save_game\n file_name = input_save_name\n begin\n Dir.mkdir('saves') unless Dir.exist?('saves')\n save_file = File.new(file_name, 'w')\n save_file.puts generate_save\n save_file.close\n puts 'Game saved!'\n rescue IOError\n puts 'Save failed'\n end\n end",
"def write_character(character)\n characters = read_characters()\n characters << $character\n f = File.open(\"characters.json\", \"w\")\n f << characters.to_json\n f.close\nend",
"def fix_drive_letter(path); end",
"def save_to(path); end",
"def test_characters_added_to_valid_password\nresult = add_characters_if_valid(\"shawn\")\nassert_equal(\"xX_shawn_Xx\", result)\nend",
"def output(char, file)\n if (file != nil) \n file.write(char) \n else\n print(char)\n end\n end",
"def write_down! \n File.open(@filename, \"wb\").write(raw)\n end",
"def save(idea)\n print \"File encoded. Please enter a name for this idea: \"\n idea_name = $stdin.gets.strip\n File::open( \"idea-\" + idea_name + \".md\", \"w\" ) do |f|\n f << idea\n end\n end",
"def save_temp(model_name, as_pdf=false)\n raise_if_no_document\n\n retries=0\n begin\n filename = UniqueTempFile.get_filename((as_pdf ? \"pdf\" : \"doc\"), \"letter\", model_name)\n save filename, as_pdf\n return filename\n rescue\n Rails.logger.warn \"Saving generated letter in <#{filename}> failed!! Retry (#{retries})\" unless defined?(Rails).nil?\n retries+=1\n if retries < 3\n retry\n else\n raise\n end\n end\n end",
"def test_can_save_before_letter_challenge\n challenge = Challenge.new({ :question => 'What letter comes before B?', :answer => 'A' })\n assert challenge.save\n end",
"def fix_encoding(output)\n output[/test/] # Running a regexp on the string throws error if it's not UTF-8\n rescue ArgumentError\n output.force_encoding(\"ISO-8859-1\")\n end",
"def test_char(table=\"test_monetdb_char\", coldefs=[\"char_field CHAR(1)\"])\n test_create_table(table, coldefs)\n char = 'a'\n\n @db.query(\"INSERT INTO \" + table + \" VALUES ( '\" + char +\"' ) \")\n\n res = @db.query(\"SELECT char_field FROM \" + table + \" where char_field = '\" + char +\"'\")\n stored_string = res.fetch_hash\n \n assert_equal(char, stored_string['char_field']) \n end",
"def test_blanks\n filename = 'test.apetag'\n File.new(filename,'wb').close\n [0,1,63,64,65,127,128,129,191,192,193,8191,8192,8193].each do |x|\n [true, false].each do |check_id3|\n s = StringIO.new(' ' * x)\n item_test(s, check_id3)\n item_test(ApeTag.new(s, check_id3), check_id3)\n f = File.new(filename,'rb+')\n f.write(' ' * x)\n item_test(f, check_id3)\n item_test(ApeTag.new(f, check_id3), check_id3)\n f.close()\n item_test(filename, check_id3)\n item_test(ApeTag.new(filename, check_id3), check_id3)\n end\n end\n File.delete(filename)\n end",
"def save_unknown!\n\t\t @saved = []\n\t end",
"def test_02c\r\n db = ITestUtils.newdb\r\n nm = File.join(test_data,'image-1.jpg')\r\n r = db.store(nm,:name => 'image-1a.jpg')\r\n #puts %x{file #{r}}\r\n assert_equal 'image-1a.jpg',File.basename(r)\r\n end",
"def fileable\n tr(' ', '_').downcase\n end",
"def test_unsupported_types\n assert_equal \"@\\xD0\\x00\\x00\\xFFstring\", to_binary_string([6.5, 255, true, false, \"string\"])\n end",
"def test_putpoi_create_with_invalid_utf8\n # This node has no tags\n\n # create a node with random lat/lon\n lat = rand(-50..49) + rand\n lon = rand(-50..49) + rand\n\n changeset = create(:changeset)\n user = changeset.user\n\n invalid = \"\\xc0\\xc0\"\n tags = { \"something\" => \"foo#{invalid}bar\" }\n\n amf_content \"putpoi\", \"/1\", [\"#{user.email}:test\", changeset.id, nil, nil, lon, lat, tags, nil]\n post :amf_write\n assert_response :success\n amf_parse_response\n result = amf_result(\"/1\")\n\n assert_equal 2, result.size\n assert_equal -1, result[0], \"Expected to get the status FAIL in the amf\"\n assert_equal \"One of the tags is invalid. Linux users may need to upgrade to Flash Player 10.1.\", result[1]\n end",
"def rand_string_alpha(length, save_as = nil)\n chars = 'abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ'\n result = Array.new(length) { chars[rand(chars.length)].chr }.join\n $test_params[save_as] = result if save_as\n result\nend",
"def edit\n puts \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\"\n end",
"def test_gem_handles_weird_chars_without_exceptions\r\n assert_nothing_raised do\r\n assert_equal \"DE\", Autometal::Geoip.new('78.46.60.181').country\r\n assert_equal \"SE\", Autometal::Geoip.new('81.237.231.174').country\r\n end\r\n end",
"def save_as_eps(code, filepath, dimensions=\"110x12\")\n\tif /^[0-9]{50}$/.match(code)\n\t\tsystem(\"#{@path_to_barcode} -o #{Shellwords.escape(filepath)} -b #{Shellwords.escape(code)} -u mm -g #{Shellwords.escape(dimensions)} -n -e code128c -E\")\n\telse\n\t\tfalse\n\tend\nend",
"def test_validate_reason_code_with_consecutive_occurrence_of_valid_special_characters\n reason_code1 = ReasonCode.new\n reason_code1.reason_code = \"RC..\"\n reason_code1.save\n assert !reason_code1.valid?, reason_code1.errors.full_messages.to_s\n end",
"def save_custom_file(custom)\r\n # Save the result to custom file\r\n @custom.save_custom(custom)\r\n # In case the wrting file process failed, inform user\r\n rescue StandardError, IOError\r\n puts 'Oops, some thing wrong with the saving process.'\r\n end",
"def save\n save!\n rescue StandardError\n false\n end",
"def save\n\t\t# Ask the user for a file.\n\t\t# Defaults to current file.\n\t\tans = $screen.ask(\"save to: \",[@filename],true,true)\n\t\tif ans == nil\n\t\t\t$screen.write_message(\"Cancelled\")\n\t\t\treturn\n\t\tend\n\t\tif ans == \"\" then ans = @filename end\n\t\tif ans == \"\"\n\t\t\t$screen.write_message(\"Cancelled\")\n\t\t\treturn\n\t\tend\n\t\t# If name is different from current file name,\n\t\t# ask for verification.\n\t\tif ans != @filename\n\t\t\tyn = $screen.ask_yesno(\"save to different file: \"+ans+\" ? [y/n]\")\n\t\t\tif yn == \"yes\"\n\t\t\t\t@filename = ans\n\t\t\t\tset_filetype(@filename)\n\t\t\telse\n\t\t\t\t$screen.write_message(\"aborted\")\n\t\t\t\treturn\n\t\t\tend\n\t\tend\n\t\t# Dump the text to the file.\n\t\tFile.open(@filename,\"w\"){|file|\n\t\t\ttext = @text.join(@eol)\n\t\t\tfile.write(text)\n\t\t}\n\t\t# Let the undo/redo history know that we have saved,\n\t\t# for revert-to-saved purposes.\n\t\t@buffer_history.save\n\t\t# Save the command/search histories.\n\t\tif $hist_file != nil\n\t\t\t$buffers.save_hists\n\t\tend\n\t\t$screen.write_message(\"saved to: \"+@filename)\n\tend",
"def save?\n save == true\n end",
"def save(filename, data)\n\tf = File.open(filename, 'w')\n\tf.puts(data)\n\tf.close\nend",
"def encode!; end",
"def save_without_revision\n save_without_revision!\n true\n rescue\n false\n end",
"def test_it_can_save_input_to_output\n night_writer = NightWriter.new\n night_writer.save_input_to_output\n\n assert_equal \"hello world\\n\", night_writer.read_output\n end",
"def save\n valid_file? and successful_conversion?\n end",
"def savable?\n false\n end",
"def send_vi_exit_save\n send_ctrl_escape\n data = \":x!\" + \"\\n\"\n session.shell_write(data)\n end",
"def store_file\n # TODO\n # - kick BOM if present\n # - convert to UTF-8 if a different encoding is given\n # - we should check double encoding because the tempfile is always read as utf8\n\n # writes the file binary/raw without taking encodings into account.\n # If we want to convert incoming files this should be done before\n File.open(full_filename, 'wb') do |f| #w:UTF-8\n f.write @uploaded_file.read\n end\n end",
"def to_ascii!; self.replace(self.to_ascii); end",
"def test_writing_null_data\n\t\tassert_nothing_raised do \n\t\t\tassert_equal nil, @record.direction\n\t\t\tio = Palm::WabaStringIO.new(s = '', \"w\")\n\t\t\[email protected](io)\n\t\t\tassert s.length > 0\t# ha! I had forgotten to write it out :)\n\t\t\t@load_record = TestWabaRecord.new\n\t\t\t@load_record.read(Palm::WabaStringIO.new(s, \"r\") )\n\t\t\tassert_equal 0, @load_record.direction\n\t\tend\n\tend",
"def save\n begin\n save!\n true\n rescue\n false\n end\n end",
"def save_as\n # the join is required in case we hit a multiple choice question.\n # It’s highly unlikely that this kind of question will ever use the\n # save_as attribute, but what the heck.\n # Also, keep only valid chars\n [@db_column].join.gsub(/[^a-z0-9-]/i, \"\")\n end"
] | [
"0.619361",
"0.6099045",
"0.5809216",
"0.5762555",
"0.576243",
"0.5735529",
"0.56535786",
"0.5632213",
"0.55245054",
"0.55245054",
"0.54943734",
"0.5481706",
"0.54587394",
"0.54587394",
"0.5425676",
"0.5420517",
"0.5403541",
"0.5396913",
"0.5386988",
"0.53623706",
"0.53623706",
"0.53623706",
"0.53411",
"0.53398347",
"0.5334422",
"0.5330164",
"0.5328656",
"0.5322472",
"0.531349",
"0.5312418",
"0.52912074",
"0.52861017",
"0.5280845",
"0.52563876",
"0.52401155",
"0.5232756",
"0.52067554",
"0.51993006",
"0.51933354",
"0.51720434",
"0.51483756",
"0.51313984",
"0.5128846",
"0.51188344",
"0.5113835",
"0.51041704",
"0.5098187",
"0.50806403",
"0.5079781",
"0.50586736",
"0.5052916",
"0.50500166",
"0.50465703",
"0.5032436",
"0.5022916",
"0.50152165",
"0.5011885",
"0.5005589",
"0.5004624",
"0.49976942",
"0.4997362",
"0.4996161",
"0.49914595",
"0.4978377",
"0.49730444",
"0.4970325",
"0.49699798",
"0.4968775",
"0.49635398",
"0.4955282",
"0.4948922",
"0.49373356",
"0.4935938",
"0.49286464",
"0.4926097",
"0.49244764",
"0.49218196",
"0.4910763",
"0.49096772",
"0.4908833",
"0.49016133",
"0.48996428",
"0.48977932",
"0.48963487",
"0.48929343",
"0.48926413",
"0.48889807",
"0.48874158",
"0.4884245",
"0.4882814",
"0.48805404",
"0.48735785",
"0.48731628",
"0.48720282",
"0.48693076",
"0.48618087",
"0.48615554",
"0.4859134",
"0.48542017",
"0.48502994"
] | 0.6681962 | 0 |
test that chunks are reused if possible in a single save | def test_reuse_single_file
CheckFile @writer, @ioservice, @adlers, 'test tests test ', ['test ', 'tests', ' ', 'test ']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_reuse_existing_chunks_when_append\n CheckFile @writer, @ioservice, @adlers, 'test content', ['test ', 'conte', 'nt']\n CheckFile @writer, @ioservice, @adlers, 'test content updated', ['test ', 'conte', 'nt', ' upda', 'ted']\n end",
"def test_reuse_existing_chunks_when_prepend\n CheckFile @writer, @ioservice, @adlers, 'test content', ['test ', 'conte', 'nt']\n CheckFile @writer, @ioservice, @adlers, 'a new test content', ['a new', ' ', 'test ', 'conte', 'nt']\n end",
"def save chunk_nr, io\n\t\t\t# retrieve data from io and compare sig \n\t\tend",
"def chunk_this_seed?\n 0 == (self.number_of_seeds % (config[:chunk_size] || 100))\n end",
"def morechunks?\n Dir.entries(\"data/\").size > 2\n end",
"def test_store_file\n #emulate the saving of a file whose content is 'test content'\n @writer.save_file('test content')\n #we expect three chunks for\n expected_chunks = ['test ', 'conte', 'nt']\n expected_chunks_sha = expected_chunks.map{|s| ComputeSHADigest s}\n #A. Each of the chunk is named with the sha on its content\n expected_chunks_sha.each{|sha| assert( @ioservice.exists? :chunk, sha )}\n \n #B. The filename is retrieved from the sha of the whole string\n file_sha = ComputeSHADigest 'test content'\n assert( @ioservice.exists?(:file, file_sha), \"file not found: #{file_sha} in #{@ioservice.store[:file]}\" )\n #C. The file lists all its chunks\n @ioservice.read_elem(:file, file_sha) do |c|\n c.each_line.zip(expected_chunks_sha).each{ |l, sha| assert_equal(l.strip, sha) }\n end\n #D. the adlers directory should be filled with the adler32 code of each chunk\n CheckChunksInAdlerDirectory( @adlers, expected_chunks )\n end",
"def ignore_bad_chunking; end",
"def ignore_bad_chunking; end",
"def validate_parts_full_chunks!(grid_infos)\n grid_infos.each do |grid_info|\n if grid_info[:length] % grid_info[:chunkSize] != 0 && grid_info != grid_infos.last\n raise Tus::Error, \"cannot concatenate parts which aren't evenly distributed across chunks\"\n end\n end\n end",
"def test_no_duplicated_file\n #emulate the saving of a file whose content is 'test content'\n @writer.save_file('test content')\n #an exception should be raised by ioservice if file is attempted to be saved twice\n assert_nothing_thrown do\n @writer.save_file('test content')\n end\n end",
"def test_chrm_chunk\n\n each_file_with_updated_info do\n |file_path|\n\n if @test_feature == \"c\" && @parameter[0] == \"c\"\n img = Imgrb::Image.new(file_path, :only_metadata)\n assert_equal [0.3127, 0.3290, 0.64, 0.33, 0.30, 0.60, 0.15, 0.06],\n img.ancillary_chunks[:cHRM][0].get_data\n end\n end\n\n\n img = Imgrb::Image.new(10, 10, [255,155,55])\n chrm_dat = [0.42, 0.32, 0.22, 0.11, 0.55, 0.44, 0.33, 0.22]\n chrm = Imgrb::Chunks::ChunkcHRM.assemble(*chrm_dat)\n img.add_chunk(chrm)\n\n png_str = save_png_to_string(img)\n img_saved = Imgrb::Image.new(png_str, :from_string)\n chrm_dat_saved = img_saved.ancillary_chunks[:cHRM][0].get_data\n\n assert_equal chrm_dat, chrm_dat_saved\n\n end",
"def all_parts_replicated?\n return false unless persisted? && ok?\n parts = zipped_moab_version.zip_parts.where(suffix: suffixes_in_set)\n parts.count == parts_count && parts.all?(&:ok?)\n end",
"def test_reuse_single_file2\n CheckFile @writer, @ioservice, @adlers, 'try with try with', ['try w', 'ith ', 'try w', 'ith']\n end",
"def copy_used!\n if self.active?\n self.used = 0 unless self.used\n self.used += 1\n self.save\n else\n false\n end\n end",
"def test_size\n assert_equal 0, Cfg.test.count\n assert_equal Cfg.test.size, Cfg.test.count\n Cfg.test.save(\"x\" => 1)\n Cfg.test.save(\"x\" => 2)\n assert_equal Cfg.test.size, Cfg.test.count\n end",
"def test_rack_doesnt_contain_enough_duplicate_letters\n [:A,:B,:A,:C].each{|x| @newTileRack.append(x)}\n assert_equal(false,@newTileRack.has_tiles_for?('AAAA'))\n end",
"def test_sbit_chunk\n\n each_file_with_updated_info do\n |file_path|\n\n if @test_feature == \"c\" && @parameter[0] == \"s\"\n img = Imgrb::Image.new(file_path, :only_metadata)\n next if img.ancillary_chunks[:sBIT].size == 0\n if img.header.bit_depth == 16\n expected = [13,13,13]\n else\n expected = [@parameter[1].to_i]*3\n end\n\n assert_equal expected,\n img.ancillary_chunks[:sBIT][0].get_data\n end\n end\n\n\n\n img = Imgrb::Image.new(10, 10, [255,155])\n sbit_dat = [3,5]\n sbit = Imgrb::Chunks::ChunksBIT.assemble(*sbit_dat)\n img.add_chunk(sbit)\n\n png_str = save_png_to_string(img)\n img_saved = Imgrb::Image.new(png_str, :from_string)\n sbit_dat_saved = img_saved.ancillary_chunks[:sBIT][0].get_data\n\n assert_equal sbit_dat, sbit_dat_saved\n end",
"def ignore_bad_chunking=(ignore_bad_chunking); end",
"def new_chunk(index)\n chunk_num = (index / CHUNK_LINE_SIZE).to_i\n write_file = File.new(\"data/chunk#{chunk_num}\", \"w\")\n\n return write_file\nend",
"def force_update_every_chunk\r\n @chunk_hash.each_value { |chunk| chunk.flag_chunk_update = true }\r\n end",
"def prepareForReuse; end",
"def test_that_full_tile_rack_doesnt_need_any_tiles\n 7.times{|num| @newTileRack.append(:A)}\n assert_equal(0,@newTileRack.number_of_tiles_needed)\n end",
"def test_ut_original_file_01\n assert @original_file.save\n original_file_copy = OriginalFile.find(@original_file.id)\n assert_equal @original_file.normal_result_id, original_file_copy.normal_result_id\n assert @original_file.valid?\n assert @original_file.destroy\n end",
"def chunk(count=100)\n criteria[:chunk] = count\n self\n end",
"def ignore_bad_chunking=(_arg0); end",
"def each_chunk; end",
"def test_create_fixtures_resets_sequences_when_not_cached\n @instances.each do |instance|\n max_id = create_fixtures(instance.class.table_name).first.fixtures.inject(0) do |_max_id, (_, fixture)|\n fixture_id = fixture[\"id\"].to_i\n fixture_id > _max_id ? fixture_id : _max_id\n end\n\n # Clone the last fixture to check that it gets the next greatest id.\n instance.save!\n assert_equal max_id + 1, instance.id, \"Sequence reset for #{instance.class.table_name} failed.\"\n end\n end",
"def test_hist_chunk\n\n each_file_with_updated_info do\n |file_path|\n\n if @test_feature == \"c\" && @parameter[0] == \"h\"\n img = Imgrb::Image.new(file_path, :only_metadata)\n\n if @parameter[1].to_i == 1\n assert_equal [64, 112, 48, 96, 96, 32, 32, 80, 16, 128, 64, 16, 48, 80, 112],\n img.ancillary_chunks[:hIST][0].get_data\n else\n assert_equal [4]*256, img.ancillary_chunks[:hIST][0].get_data\n end\n end\n end\n\n\n\n img = Imgrb::Image.new(10, 10, [255,155,10])\n hist_dat = [10*10]\n hist = Imgrb::Chunks::ChunkhIST.assemble(*hist_dat)\n img.add_chunk(hist)\n\n png_str = save_png_to_string(img, 1)\n img_saved = Imgrb::Image.new(png_str, :from_string, :only_metadata)\n hist_dat_saved = img_saved.ancillary_chunks[:hIST][0].get_data\n\n assert_equal hist_dat, hist_dat_saved\n end",
"def duplicate_batch?(previous_batch)\n return false if previous_batch.nil?\n \n previous_batch.sf_integrity_hash == integrity_hash\n end",
"def import_map_chunks\n puts 'Importing map chunks...'\n\n puts \"-> Identifying tiled maps...\"\n\n tiled_maps = Map.target(target).where(tiled: true).all\n\n tiled_maps.each do |map|\n next if map.chunks_loaded?\n\n puts \"-> Seeding chunks for map: #{map.name} (#{map.directory})\"\n\n map.tiles.extant.each do |tile|\n next if tile.chunks_loaded?\n\n tile_adt_path = \"#{map_path_for(map.directory)}/#{map.directory}_#{tile.tile_x}_#{tile.tile_y}.adt\"\n tile_adt_hash = file_hash(tile_adt_path)\n\n seed_map_tile_adt(map, tile, tile_adt_path)\n\n GC.start\n end\n end\n end",
"def test_commit_stress_1\n Repository.create()\n\n # should be 1000, since we wrote 1000 in our acceptance test\n (0..10).each do |e| \n filename = '.test_file' + e.to_s\n FileUtils.touch(filename)\n a = [filename]\n Repository.add(a) \n Repository.commit()\n end\n end",
"def test_02d\r\n db = build\r\n n1 = db.fetch('image-1.jpg',:width => 101)\r\n n2 = db.fetch('image-1.jpg',:width => 102)\r\n assert File.exists?(n1)\r\n assert File.exists?(n2)\r\n nm = File.join(test_data,'image-2.jpg')\r\n r = db.store(nm,:name => 'image-1.jpg',:force => true)\r\n assert !File.exists?(n1)\r\n assert !File.exists?(n2)\r\n end",
"def patch_last_chunk(input, grid_info)\n last_chunk = chunks_collection.find(files_id: grid_info[:_id]).sort(n: -1).limit(1).first\n data = last_chunk[:data].data\n patch = input.read(grid_info[:chunkSize] - data.bytesize)\n data << patch\n\n chunks_collection.find(files_id: grid_info[:_id], n: last_chunk[:n])\n .update_one(\"$set\" => { data: BSON::Binary.new(data) })\n\n files_collection.find(_id: grid_info[:_id])\n .update_one(\"$inc\" => { length: patch.bytesize })\n\n patch.bytesize\n end",
"def recombinate_files_for_multiple_transfers_possibly\r\n got_end_big_transfer = false\r\n \tif @current_transfer_file =~ /recombinate_ok/\r\n\t recombinate_files_split_piece_wise @copied_files\r\n\t @copied_files = []\r\n\t got_end_big_transfer = true\r\n\tend\r\n\t@current_transfer_file = nil\r\n\tgot_end_big_transfer\r\n end",
"def test_0900_chunk\n @@log.debug \"test_0900_chunk starts\" if @@log.debug?\n assert_respond_to(@list, :chunk, \"test_0900_chunk_respond\")\n # Type check\n result = @list.chunk {|pers| pers.first > \"Cary\" }\n type_check = result.is_a? Enumerator\n assert(type_check,\"test_0900_chunk_class\") \n # chunk results check. In this case, should be a simple (and single)\n # true/false switch.\n result.each do |even, ary|\n if even\n assert(ary == [@cab, @dad], \"test_0900_chunk_truec\")\n else\n assert(ary == [@aen, @bsb], \"test_0900_chunk_falsec\")\n end\n end\n #\n @@log.debug \"test_0900_chunk ends\" if @@log.debug?\n end",
"def flush_check\n flush if @item_array.size >= BATCH_SIZE\n end",
"def chunks\n @_chunks ||= find_chunks(input)\n end",
"def chunks\n @_chunks ||= find_chunks(input)\n end",
"def save_seed\n File.open(cache_file, 'w') do |file|\n file.puts MultiJson.dump(@seed)\n end\n true\n end",
"def test_start_chunk\n storable_class = new_storable_class\n storable_class.class_eval do\n def total_chunks\n 10\n end\n end\n obj = storable_class.new\n assert_equal(1, obj.start_chunk)\n end",
"def test_s34_Smart_and_failed_commits\n W('s34a');\n\n p1 = Metakit::IntProp.new(\"p1\");\n\n Metakit::Storage.open(\"s34a\", 1) {|s1|\n s1.set_structure(\"a[p1:I]\");\n v1 = s1.view(\"a\");\n v1.add(p1[111]);\n assert_equal 1, v1.get_size\n assert_equal 111, p1.get(v1[0])\n f1 = s1.commit();\n assert(f1);\n assert_equal 1, v1.get_size\n assert_equal 111, p1.get(v1[0])\n\n f2 = s1.commit();\n assert(f2); #// succeeds, but should not write anything\n assert_equal 1, v1.get_size\n assert_equal 111, p1.get(v1[0])\n }\n \n Metakit::Storage.open(\"s34a\", 0) {|s1|\n v1 = s1.view(\"a\");\n v1.add(p1[222]);\n assert_equal 2, v1.get_size\n assert_equal 111, p1.get(v1[0])\n assert_equal 222, p1.get(v1[1])\n f1 = s1.commit();\n assert(!f1)\n assert_equal 2, v1.get_size\n assert_equal 111, p1.get(v1[0])\n assert_equal 222, p1.get(v1[1])\n }\n\n # D(s34a);\n R('s34a');\n end",
"def dechunk?\n self.class.dechunk? && chunked?\n end",
"def save_splited_part(zip_file, partial_zip_file_name, zip_file_size, szip_file_index, segment_size, segment_count)\n ssegment_size = zip_file_size - zip_file.pos\n ssegment_size = segment_size if ssegment_size > segment_size\n szip_file_name = \"#{partial_zip_file_name}.#{format('%03d', szip_file_index)}\"\n ::File.open(szip_file_name, 'wb') do |szip_file|\n if szip_file_index == 1\n ssegment_size = put_split_signature(szip_file, segment_size)\n end\n chunk_bytes = 0\n until ssegment_size == chunk_bytes || zip_file.eof?\n segment_bytes_left = ssegment_size - chunk_bytes\n buffer_size = segment_bytes_left < DATA_BUFFER_SIZE ? segment_bytes_left : DATA_BUFFER_SIZE\n chunk = zip_file.read(buffer_size)\n chunk_bytes += buffer_size\n szip_file << chunk\n # Info for track splitting\n yield segment_count, szip_file_index, chunk_bytes, ssegment_size if block_given?\n end\n end\n end",
"def saving_memory?\n nnz < (m * (n - 1) - 1) / 2\n end",
"def static_reference_recycle( object_chunk, json_path )\n case\n when object_chunk.is_a?(Array)\n object_chunk.each_with_index do | el, i |\n static_reference_recycle el, \"#{ json_path }[#{ i }]\"\n end\n when object_chunk.is_a?(Hash)\n case \n when object_chunk.has_key?(reference_property)\n # Test Validation\n\n # Stored Reference\n reference_id = object_chunk[ reference_property ]\n referenced_object = self.parser.object_tracker[ reference_id ]\n\n # Current Reference\n current_path = JsonPath.new( json_path )\n current_referenced_object = current_path.on( recycled_hash ).first\n\n # It should be exactly the same object in memory\n self.context.instance_eval do\n expect( referenced_object ).to equal current_referenced_object\n end\n when object_chunk.has_key?(values_property)\n static_reference_recycle object_chunk[ values_property ], json_path\n else\n object_chunk.each do | k, v |\n static_reference_recycle v, \"#{ json_path }.#{ k }\"\n end\n end\n end\n end",
"def check_for_stuck_jobs\n Job.incomplete.each do |job|\n if job.stuck_chunks?\n job.priority = 50\n job.save!\n job.resend_stuck_chunks \n elsif job.stuck_packing?\n job.send_pack_request\n end\n end\n end",
"def join(owned_chunks)\n \n end",
"def test_s32_Set_memo_empty_or_same_size\n W('s32a');\n\n empty = Metakit::Bytes.default_new;\n full = Metakit::Bytes.new(\"full\", 4);\n more = Metakit::Bytes.new(\"more\", 4);\n\n p1 = Metakit::BytesProp.new(\"p1\");\n Metakit::Storage.open(\"s32a\", 1) {|s1|\n s1.set_structure(\"a[p1:B]\");\n v1 = s1.view(\"a\");\n\n v1.add(p1[full]);\n assert_equal full, p1.get(v1[0])\n s1.commit();\n assert_equal full, p1.get(v1[0])\n\n p1.set(v1[0], empty)\n assert_equal empty, p1.get(v1[0])\n s1.commit();\n assert_equal empty, p1.get(v1[0])\n\n p1.set(v1[0], more)\n assert_equal more, p1.get(v1[0])\n s1.commit();\n assert_equal more, p1.get(v1[0])\n\n p1.set(v1[0], full)\n assert_equal full, p1.get(v1[0])\n s1.commit();\n assert_equal full, p1.get(v1[0])\n }\n #D(s32a);\n R('s32a');\n end",
"def save_splited_part(zip_file, partial_zip_file_name, zip_file_size, szip_file_index, segment_size, segment_count); end",
"def add(chunk)\n if chunk.full_chunk?\n @chunks[chunk.x / 16] ||= {}\n # if @chunks[chunk.x / 16][chunk.z / 16]\n # puts \"replacing: #{[chunk.x, chunk.z].inspect}\"\n # else\n # puts \"adding : #{[chunk.x, chunk.z].inspect}\"\n # end\n @chunks[chunk.x / 16][chunk.z / 16] = chunk\n\n key = [chunk.x/16, chunk.z/16]\n\n if @pending_changes[key]\n @pending_changes[key].each do |x, y, z, block|\n # puts \"applying stored change #{[x, y, z].inspect} #{block}\"\n self[x, y, z] = block\n end\n @pending_changes.delete key\n end\n\n if @pending_updates[key]\n @pending_updates[key].each do |x, y, z, data|\n # puts \"applying stored update #{[x,y,z].inspect} #{data}\"\n update(x, y, z, data)\n @pending_updates.delete key\n end\n end\n\n else\n # puts \"incremental: #{[chunk.x, chunk.y, chunk.z].inspect} #{[chunk.size_x, chunk.size_y, chunk.size_z].inspect}\"\n chunk.each_column do |x, y, z, data|\n # puts \"updating #{[x,y,z].inspect} #{data.size} blocks\"\n update(x, y, z, data)\n end\n end\n end",
"def in_use?\n !batch.nil?\n end",
"def test_load_save\n @valid_source.save\n source_loaded = Source.find(@valid_source.uri)\n source_loaded['http://loadsavetest/name'] << '4'\n source_loaded.save\n \n source_reloaded = Source.find(@valid_source.uri)\n assert_equal('4', source_reloaded['http://loadsavetest/name'][0])\n end",
"def test_uniqueness_of_batchid\n client1 = Client.create(:name => 'Test Client1',:tat => 12)\n facility1 = Facility.create(:name => \"Test facility1\",:sitecode => 8234,:client => client1)\n batch1 = Batch.new(:id => 20,\n :batchid=>999,\n :date => Date.today.strftime(\"%m/%d/%Y\"),\n :eob => 30,\n :facility=> facility1,\n :arrival_time => \"#{Time.now}\",\n :target_time => \"#{Time.now}\",\n :status => \"New\"\n )\n assert_equal(true, batch1.save, \"Save failed!\")\n\n client2 = Client.create(:name => 'Test Client2',:tat => 13)\n facility2 = Facility.create(:name => \"Test facility2\",:sitecode => 8235,:client => client2)\n batch2 = Batch.new(:id => 21,\n :batchid=>999,\n :date => \"2006-10-09\",\n :eob => 30,\n :facility=> facility2,\n :arrival_time => \"#{Time.now}\",\n :target_time => \"#{Time.now}\",\n :status => \"New\"\n )\n assert_equal(false, batch2.save)\n end",
"def dup_test\n duplicate = dup\n duplicate.update_attributes(\n state: :incomplete,\n step: :details,\n wizard_progress: 0,\n qrda_progress: 0,\n results: { passed: 0, total: 0 },\n disable_details: false,\n file_path: ''\n )\n duplicate.save\n duplicate\n end",
"def skip_test_inmutable\n #they come fully loaded\n Status.load_inmutable_instances\n status1 = Status.where.all.sort_by { |s| s.code }\n status2 = Status.where.all.sort_by { |s| s.code }\n assert status1.length == 4\n assert status2.length == 4\n #same referencs\n status1.each_index do |i|\n assert status1[i].object_id==status2[i].object_id \n end\n\n #create a new object\n stt = Status.new(code: \"xx\", description: (\"xx\" + \" some desc\"))\n stt.save\n\n status1 = Status.where.all.sort_by { |s| s.code }\n status2 = Status.where.all.sort_by { |s| s.code }\n assert status1.length == 5\n assert status2.length == 5\n #same referencs\n status1.each_index do |i|\n assert status1[i].object_id==status2[i].object_id \n end \n\n status1.each do |st|\n assert st.code\n assert st.description\n end\n\n marr = Status.find(\"divorced\").first\n assert marr.code == \"divorced\"\n assert marr.description\n assert marr.object_id == status1.first.object_id\n\n people = Person.where.include(:name, status: [ :code, :description ]).all\n people.each do |p|\n assert p.status.object_id == status1.select { |st| st.id == p.status.id }.first.object_id\n assert p.status.code\n assert p.status.description\n end\n end",
"def nr_chunks\n ENV['NR_CHUNKS'] ? ENV['NR_CHUNKS'].to_i : 10\n end",
"def initialize_new_test_store\n verify_store_is_blank_for_init\n add_chunk MemoryChunk.new(:max_chunk_size=>max_chunk_size,:max_index_block_size=>max_index_block_size)\n end",
"def split!\n return unless model.chunk_size.is_a?(Integer)\n\n if File.size(model.file) > bytes_representation_of(model.chunk_size)\n Logger.message \"#{ self.class } started splitting the packaged archive in to chunks of #{ model.chunk_size } megabytes.\"\n run(\"#{ utility(:split) } -b #{ model.chunk_size }m '#{ model.file }' '#{ model.file + SUFFIX_SEPARATOR }'\")\n Backup::Model.chunk_suffixes = chunk_suffixes\n end\n end",
"def save\n if valid?\n write\n increment\n true\n else\n false\n end\n end",
"def test_does_not_duplicate_if_file_already_exists\n test_file = 'extractor_test_small_sample'\n src_directory = File.join('testRawData', 'pdf/')\n dst_directory = File.join('testExtractedData', 'pdf/')\n\n\tnumber_files_before = TestUtils.count_files_directory(dst_directory)\n\n # Order of tests is not guaranteed, so create the file if necessary\n if (not File.exists?(\"#{dst_directory}#{test_file}.txt\"))\n system(\"#{$extractor_command} #{src_directory}#{test_file}.pdf #{dst_directory}\")\n number_files_before = number_files_before + 1\n end\n system(\"#{$extractor_command} #{src_directory}#{test_file}.pdf #{dst_directory}\")\n number_of_files_after = TestUtils.count_files_directory(dst_directory)\n \n assert_equal number_files_before, number_of_files_after\n end",
"def test_enqueue_chunk_with_empty_key\n buf = Fluent::FileBuffer.new\n buf.configure({'buffer_path' => bufpath('enqueue2')})\n prefix = buf.instance_eval{ @buffer_path_prefix }\n suffix = buf.instance_eval{ @buffer_path_suffix }\n\n chunk = buf.new_chunk('')\n chunk << \"data1\\ndata2\\n\"\n\n assert chunk\n old_path = chunk.path.dup\n assert File.exist?(chunk.path)\n # chunk key is empty\n assert chunk.path =~ /\\A#{prefix}\\.b[0-9a-f]+#{suffix}\\Z/, \"path from new_chunk must be a 'b' buffer chunk\"\n\n buf.enqueue(chunk)\n\n assert chunk\n assert File.exist?(chunk.path)\n assert !(File.exist?(old_path))\n # chunk key is empty\n assert chunk.path =~ /\\A#{prefix}\\.q[0-9a-f]+#{suffix}\\Z/, \"enqueued chunk's path must be a 'q' buffer chunk\"\n\n data = chunk.read\n assert \"data1\\ndata2\\n\", data\n end",
"def test_stale_save\n collection = Collection.create!(parent_url: @config.fedora_url,\n requested_slug: SLUGS[0],\n key: 'cats')\n\n item = Item.create!(parent_url: collection.repository_url,\n requested_slug: SLUGS[1])\n item.collection = collection\n item.save!\n\n collection.key = 'dogs'\n collection.save! # absence of an error is a pass\n end",
"def test_tile_rack_with_several_tiles_should_need_some_tiles\n [:A,:B,:C].each{|x| @newTileRack.append(x)}\n assert_equal(4,@newTileRack.number_of_tiles_needed)\n end",
"def should_process? \n #return false if it has been set to skip processing \n return false if self.persistence_checksum.eql?(\"skip\")\n\n #return true if there are different number of craft files than records of craft that are not marked as deleted\n craft_files = campaigns_instance.identify_craft_in(self.name)\n craft = self.craft.where(:deleted => false) #if craft.nil?\n return true if craft_files.map{|k,v| v}.flatten.size != craft.count\n\n #return true if the stored checksum for persistent.sfs does not match the one generated for the current persistent.sfs\n Dir.chdir(self.path)\n return true unless File.exists?(\"persistent.sfs\")\n checksum = Digest::SHA256.file(\"persistent.sfs\").hexdigest\n not checksum.eql?(self.persistence_checksum)\n end",
"def run_once(send_twice: false)\n num_streamed = 0\n\n # Need at least repeatable read isolation level so that our DELETE after\n # enqueueing will see the same records as the original SELECT.\n DB.transaction(isolation_level: :repeatable_read) do\n records = StagedLogRecord.order(:id).limit(BATCH_SIZE)\n\n unless records.empty?\n RDB.multi do\n records.each do |record|\n stream(record.data)\n num_streamed += 1\n\n # simulate a double-send by adding the same record again\n if send_twice\n stream(record.data)\n num_streamed += 1\n end\n\n $stdout.puts \"Enqueued record: #{record.action} #{record.object} #{record.id}\"\n end\n end\n\n StagedLogRecord.where(Sequel.lit(\"id <= ?\", records.last.id)).delete\n end\n end\n\n num_streamed\n end",
"def test_add_transparency_chunk\n img = Imgrb::Image.new(41,41,0)\n transparency_chunk = Imgrb::Chunks::ChunktRNS.assemble(0,:indexed)\n img.add_chunk(transparency_chunk)\n\n png_str = save_png_to_string(img, 1)\n img_saved = Imgrb::Image.new(png_str, :from_string)\n\n assert img_saved.has_alpha?\n end",
"def already_stored?\n !file_uniqueness\n end",
"def testReuseMixWithMixProcessed\n lProcessID = {\n :Param1 => 'TestParam1'\n }.unique_id\n execute_Mix_WithConf({\n :WaveFiles => {\n :FilesList => [\n {\n :Name => 'Wave.wav'\n }\n ]\n },\n :Mix => {\n 'Mix1' => {\n :Tracks => {\n 'Wave.wav' => {}\n },\n :Processes => [\n {\n :Name => 'Test',\n :Param1 => 'TestParam1'\n }\n ]\n },\n 'Final' => {\n :Tracks => {\n 'Mix1' => {\n :Processes => [\n {\n :Name => 'Test',\n :Param1 => 'TestParam2'\n }\n ]\n }\n }\n }\n }\n },\n :PrepareFiles => [\n [ 'Wave/Empty.wav', 'Wave.wav' ],\n [ 'Wave/Noise1s.wav', \"05_Mix/Wave.0.Test.#{lProcessID}.wav\" ]\n ]) do |iStdOUTLog, iStdERRLog, iExitStatus|\n assert_exitstatus 0, iExitStatus\n lWave0FileName = getFileFromGlob('05_Mix/Wave.0.Test.0.Test.????????????????????????????????.wav')\n assert_rb_content [\n {\n :InputFileName => \"05_Mix/Wave.0.Test.#{lProcessID}.wav\",\n :OutputFileName => lWave0FileName,\n :Params => {\n :Param1 => 'TestParam2'\n }\n }\n ], 'Process_Test.rb'\n assert_wave_lnk 'Noise1s', '05_Mix/Final/Mix1.wav'\n assert_wave_lnk 'Noise1s', '05_Mix/Final/Final.wav'\n end\n end",
"def test_s38_Lots_of_empty_subviews\n W('s38a');\n\n p1 = Metakit::BytesProp.new(\"p1\");\n\n Metakit::Storage.open(\"s38a\", 1) {|s1|\n v = s1.get_as(\"v[v1[p1:S]]\");\n\n v.set_size(100000);\n s1.commit();\n }\n \n Metakit::Storage.open(\"s38a\", 1) {|s2|\n v2 = s2.view(\"v\");\n # // this should not materialize all the empty subviews\n v2.set_size(v2.get_size() + 1);\n # // nor should this\n s2.commit();\n }\n \n Metakit::Storage.open(\"s38a\", 1) {|s3|\n v3 = s3.view(\"v\");\n v3.remove_at(1, v3.get_size() - 2);\n assert_equal 2, v3.get_size\n s3.commit();\n }\n\n # D(s38a);\n R('s38a');\n end",
"def split_size_counts(sub_ranges)\n self.transaction do\n #update the ranges of the current record\n self.standard_size_count_from = sub_ranges[0][0]\n self.standard_size_count_to = sub_ranges[0][1]\n self.update\n #create a new rebin record for each item from 1 onwards and copy\n #the attribues from this record to each new record\n for i in 1..sub_ranges.length()-1\n rebin_setup = RebinSetup.new\n rebin_setup.production_schedule = self.production_schedule\n export_attributes(rebin_setup)\n \n rebin_setup.standard_size_count_from = sub_ranges[i][0]\n rebin_setup.standard_size_count_to = sub_ranges[i][1]\n rebin_setup.auto_created = false\n rebin_setup.create\n if self.rebin_label_setup\n rebin_label_setup = RebinLabelSetup.new\n self.rebin_label_setup.export_attributes(rebin_label_setup)\n rebin_label_setup.rebin_setup = rebin_setup\n rebin_label_setup.label = self.rebin_label_setup.label\n rebin_label_setup.create\n end\n \n \n end\n \n \n end\n \n end",
"def testReuseMixWithSourceFilesProcessed\n lProcessID = {\n :Param1 => 'TestParam1'\n }.unique_id\n execute_Mix_WithConf({\n :WaveFiles => {\n :FilesList => [\n {\n :Name => 'Wave.wav'\n }\n ]\n },\n :Mix => {\n 'Mix1' => {\n :Tracks => {\n 'Wave.wav' => {\n :Processes => [\n {\n :Name => 'Test',\n :Param1 => 'TestParam1'\n }\n ]\n }\n }\n },\n 'Final' => {\n :Tracks => {\n 'Mix1' => {\n :Processes => [\n {\n :Name => 'Test',\n :Param1 => 'TestParam2'\n }\n ]\n }\n }\n }\n }\n },\n :PrepareFiles => [\n [ 'Wave/Empty.wav', 'Wave.wav' ],\n [ 'Wave/Noise1s.wav', \"05_Mix/Wave.0.Test.#{lProcessID}.wav\" ]\n ]) do |iStdOUTLog, iStdERRLog, iExitStatus|\n assert_exitstatus 0, iExitStatus\n lWave0FileName = getFileFromGlob('05_Mix/Wave.0.Test.0.Test.????????????????????????????????.wav')\n assert_rb_content [\n {\n :InputFileName => \"05_Mix/Wave.0.Test.#{lProcessID}.wav\",\n :OutputFileName => lWave0FileName,\n :Params => {\n :Param1 => 'TestParam2'\n }\n }\n ], 'Process_Test.rb'\n assert_wave_lnk 'Noise1s', '05_Mix/Final/Mix1.wav'\n assert_wave_lnk 'Noise1s', '05_Mix/Final/Final.wav'\n end\n end",
"def test_09b\r\n db = ITestUtils.newdb\r\n nm = File.join(test_data,'image-1.jpg')\r\n db.store(nm)\r\n db.fetch 'image-1.jpg',:width => 102\r\n r = db.fetch('image-1.jpg',:width => 103)\r\n db.fetch 'image-1.jpg',:width => 104\r\n db.hooks = hooks()\r\n db.delete 'image-1.jpg',:width => 103\r\n assert_equal 1,db.hooks.count[:deletes]\r\n assert_equal r,db.hooks.params[:sized].first\r\n #assert_equal File.basename(r),db.hooks.params[:sized].first\r\n assert_equal 1,db.hooks.params[:sized].size\r\n end",
"def write_benchmark opts={}\n files, size = opts[:files], opts[:size]\n block_size = opts[:block_size] || 100_000\n block = 0.chr * block_size\n blocks, remaining = size.divmod block_size\n remaining = 0.chr * remaining\n Tempfile.open 'ole_storage_benchmark' do |temp|\n Ole::Storage.open temp do |ole|\n files.times do |i|\n ole.file.open \"file_#{i}\", 'w' do |f|\n blocks.times { f.write block }\n f.write remaining\n end\n end\n end\n end\n end",
"def repeated?\n mode == \"REPEATED\"\n end",
"def _apply_heuristics io, prev_chunk, chunk\n prev_pos = io.tell\n HEUR_CHUNK_SIZE_RANGE.each do |delta|\n next if delta == 0\n next if prev_chunk.data.size + delta < 0\n io.seek(chunk.offset+delta, IO::SEEK_SET)\n potential_chunk = Chunk.new(io)\n if potential_chunk.valid?\n STDERR.puts \"[!] heuristics: found invalid #{chunk.type.inspect} chunk at offset #{chunk.offset}, but valid #{potential_chunk.type.inspect} at #{chunk.offset+delta}. using latter\".red\n if delta > 0\n io.seek(chunk.offset, IO::SEEK_SET)\n data = io.read(delta)\n STDERR.puts \"[!] #{delta} extra bytes of data: #{data.inspect}\".red\n else\n io.seek(chunk.offset+delta, IO::SEEK_SET)\n end\n return true\n end\n end\n false\n end",
"def test_batch_hooks\n assert_equal(false, Job.batch_exist?(@batch_id))\n\n assert_nothing_raised do\n 5.times { Resque.enqueue(Job, @batch_id, \"arg#{rand(100)}\") }\n end\n\n assert_equal(false, $batch_complete)\n assert_equal(false, Job.batch_complete?(@batch_id))\n assert(Job.batch_exist?(@batch_id))\n\n assert_nothing_raised do\n 4.times { Resque.reserve(:test).perform }\n end\n\n assert_equal(false, $batch_complete)\n assert_equal(false, Job.batch_complete?(@batch_id))\n assert(Job.batch_exist?(@batch_id))\n\n assert_nothing_raised do\n Resque.reserve(:test).perform\n end\n\n assert($batch_complete)\n assert(Job.batch_complete?(@batch_id))\n assert_equal(false, Job.batch_exist?(@batch_id))\n end",
"def use!\n self.used = true\n self.save\n end",
"def verify_ready_copies_per_group(wanted_amount)\n for i in 0...8\n #bucketdb = vespa.storage['mycluster'].distributor[i.to_s].getBucketDB()\n #bucketdb.each { |bucket|\n # ready_count = Array.new(3)\n # bucket.copies().each { |copy|\n # if (copy.is_trusted())\n # ++ready_count[ copy.index() / 3 ]\n # end\n # }\n # assert_equal(wanted_amount, ready_count[0])\n # assert_equal(wanted_amount, ready_count[1])\n # assert_equal(wanted_amount, ready_count[2])\n #}\n end\n end",
"def flush?\n suits.uniq.count == 1\n end",
"def confirmed_good_split_times\n ordered_existing_split_times.dup.each { |st| st.data_status = 'confirmed' if st.good? }\n end",
"def chunked?; end",
"def test_duplicate_args\n assert_equal(false, Job.batch_exist?(@batch_id))\n\n assert_nothing_raised do\n 5.times { Resque.enqueue(JobWithoutArgs, @batch_id) }\n end\n\n assert_equal(false, $batch_complete)\n assert_equal(false, Job.batch_complete?(@batch_id))\n assert(Job.batch_exist?(@batch_id))\n\n assert_nothing_raised do\n 2.times { Resque.reserve(:test).perform }\n end\n\n assert_equal(false, $batch_complete)\n assert_equal(false, Job.batch_complete?(@batch_id))\n assert(Job.batch_exist?(@batch_id))\n\n assert_nothing_raised do\n 3.times { Resque.reserve(:test).perform }\n end\n\n assert($batch_complete)\n assert(Job.batch_complete?(@batch_id))\n assert_equal(false, Job.batch_exist?(@batch_id))\n end",
"def test_default_counter_cache_not_update_counters_when_change_association_but_not_save\n f1, m = build_fixture\n assert_equal 1, f1.reload.messages_count\n f2 = Folder.create\n assert_equal 0, f2.reload.messages_count\n m.folder = f2\n assert_equal f1, m.reload.folder, \"folder not changed\"\n assert_equal 1, f1.reload.messages_count\n assert_equal 0, f2.reload.messages_count\n end",
"def chunk_size()\n #This is a stub, used for indexing\n end",
"def preparation\n return unless inspect_duplicates(@hidden + @open)\n @hidden = my_split(@hidden)\n @open = my_split(@open)\n end",
"def shrink?\n hash_size / 4 == buckets.compact.count / 4\n end",
"def test_avoid_duplicates\n # @migration.debug = true\n @migration.dry_run = true\n\n @migration.is_article?(@migration.html_dir + \"index.php?option=com_content&task=view&id=111&Itemid=32.html\") == true\n @migration.is_article?(@migration.html_dir + \"index.php?option=com_content&task=view&id=111&Itemid=300.html\") == false\n # @migration.is_article?(@migration.html_dir + \"index2.php?option=com_content&task=view&id=111&pop=1&page=0&Itemid=300.html\") == false\n # @migration.is_article?(@migration.html_dir + \"index2.php?option=com_content&task=view&id=111&pop=1&page=0&Itemid=32.html\") == false\n end",
"def mark_validly_repeated_pages\n\n fids = {}\n @sequence.each do |entry|\n next unless is_page? entry\n fids[entry.fid] ||= []\n fids[entry.fid].push entry\n end\n\n fids.keys.each do |k|\n if fids[k].length > 1\n fids[k][0..-2].each { |e| e.valid_repeat = true } # don't mark the last one, it's the one we will eventually include in the sequence to ingest\n end\n end\n\n image_filenames = {}\n @sequence.each do |entry|\n next unless is_page? entry\n image_filenames[entry.image_filename] ||= []\n image_filenames[entry.image_filename].push entry\n end\n\n image_filenames.keys.each do |k|\n if image_filenames[k].length > 1\n image_filenames[k][0..-2].each { |e| e.valid_repeat = true } # don't mark the last one, it's the one we will eventually include in the sequence to ingest\n end\n end\n end",
"def done?\n\t\treturn @num_valid == @max_block\n\tend",
"def test_rack_contains_a_word_with_duplicate_letters\n [:A,:B,:A,:C].each{|x| @newTileRack.append(x)}\n assert_equal(true,@newTileRack.has_tiles_for?('AAB'))\n end",
"def save\n save_tries = 0\n begin\n return false unless file_set.save\n rescue RSolr::Error::Http => error\n ActiveFedora::Base.logger.warn \"CurationConcerns::FileSetActor#save Caught RSOLR error #{error.inspect}\"\n save_tries += 1\n # fail for good if the tries is greater than 3\n raise error if save_tries >= 3\n sleep 0.01\n retry\n end\n yield if block_given?\n true\n end",
"def dirty?\n super || run_once(true) { dirty_embedments? }\n end",
"def each_chunk\n iend_reached = false\n File.open(@file_path, 'rb') do |file|\n # check if file is not PNG at all\n return false if file.read(8) != PNG_MAGIC_NUMBER\n\n chunks = 0\n\n # We could be dealing with large number of chunks,\n # so the code should be optimized to create as few objects as possible.\n # All literal strings are frozen and read() function uses string buffer.\n chunkheader = ''\n while file.read(8, chunkheader)\n # ensure that first 8 bytes from chunk were read properly\n if chunkheader.nil? || chunkheader.length < 8\n return false\n end\n\n current_pos = file.tell\n\n chunk_len, chunk_name = chunkheader.unpack(\"Na4\".freeze)\n return false if chunk_name =~ /[^A-Za-z]/\n yield chunk_name, chunk_len, file\n\n # no need to read further if IEND is reached\n if chunk_name == \"IEND\".freeze\n iend_reached = true\n break\n end\n\n # check if we processed too many chunks already\n # if we did, file is probably maliciously formed\n # fail gracefully without marking the file as corrupt\n chunks += 1\n if chunks > 100_000\n iend_reached = true\n break\n end\n\n # jump to the next chunk - go forward by chunk length + 4 bytes CRC\n file.seek(current_pos + chunk_len + 4, IO::SEEK_SET)\n end\n end\n\n iend_reached\n end",
"def save!\n File.open(@config[\"state_file\"], \"r\") do |fl|\n fl.flock(File::LOCK_EX)\n\n sequence = (@state.key?(\"sequence\") ? @state[\"sequence\"] + 1 : 0)\n data_file = @config[\"data_dir\"] + format(\"/%03d/%03d/%03d.osm.gz\", sequence / 1000000, (sequence / 1000) % 1000, (sequence % 1000))\n tmp_state = @config[\"state_file\"] + \".tmp\"\n tmp_data = \"/tmp/changeset_data.osm.tmp\"\n # try and write the files to tmp locations and then\n # move them into place later, to avoid in-progress\n # clashes, or people seeing incomplete files.\n begin\n FileUtils.mkdir_p(File.dirname(data_file))\n Zlib::GzipWriter.open(tmp_data) do |fh|\n fh.write(changeset_dump(open_changesets))\n end\n @state[\"sequence\"] = sequence\n File.open(tmp_state, \"w\") do |fh|\n fh.write(YAML.dump(@state))\n end\n\n # sanity check: the files we're moving into place\n # should be non-empty.\n raise \"Temporary gzip file should exist, but doesn't.\" unless File.exist?(tmp_data)\n raise \"Temporary state file should exist, but doesn't.\" unless File.exist?(tmp_state)\n raise \"Temporary gzip file should be non-empty, but isn't.\" if File.zero?(tmp_data)\n raise \"Temporary state file should be non-empty, but isn't.\" if File.zero?(tmp_state)\n\n FileUtils.mv(tmp_data, data_file)\n FileUtils.mv(tmp_state, @config[\"state_file\"])\n fl.flock(File::LOCK_UN)\n\n rescue\n STDERR.puts(\"Error! Couldn't update state.\")\n fl.flock(File::LOCK_UN)\n raise\n end\n end\n end",
"def test_put_too_many_locktokens_given\n new_coll 'httplock'\n new_file 'httplock/a', StringIO.new(\"hello\")\n new_file 'httplock/b', StringIO.new(\"world\")\n\n b_locktoken = lock('httplock/b', :depth => 0).token\n a_locktoken = lock('httplock/a', :depth => 0).token\n\n response = @request.put('httplock/a', StringIO.new('hello'), :if => [a_locktoken, b_locktoken])\n assert_equal '412', response.status\n \n response = @request.put('httplock/a', StringIO.new('hello'), { :if => [a_locktoken, b_locktoken], :strict_if => false } )\n assert_equal '204', response.status \n\n # cleanup\n unlock('httplock/a', a_locktoken)\n unlock('httplock/b', b_locktoken)\n delete_coll('httplock')\n end",
"def test_readings_url_are_real\n reading = Reading.new(order_number: 1234, lesson_id: 223, url: \"www.google.com\")\n reading_two = Reading.new(order_number: 1, lesson_id: 254, url: \"http://stopfailingatmaths.com\")\n reading_three = Reading.new(order_number: 3, lesson_id: 274, url: \"56672http://stopfailingatmaths.com\")\n\n assert reading_two.save\n refute reading.save\n refute reading_three.save\n end",
"def test_serialize\n first=[[0,0,0],[0,0,0],[0,0,0]]\n f1='test_first.sav'\n\n second=[[0,1,0],[1,0,1],[0,1,0]]\n f2='test_second.sav'\n\n @game.state=first\n @game.save f1\n @game.state=second\n @game.save f2\n\n @game.load f1\n assert_equal first,@game.state\n\n @game.load f2\n assert_equal second,@game.state\n\n File.delete('test_first.sav')\n File.delete('test_second.sav')\n end",
"def chunk(file_name, prefix, chunksize = 1_073_741_824)\n File.open(file_name\"r\") do |f|\n until f.eof?\n File.open(\"#{prefix}_#{\"%05d\"%(f.pos/chunksize)}.txt\",\"w\") do |fc|\n fc << f.read(chunksize)\n end\n end\n end\nend",
"def test_legacy_codes_unique\n spods = Person.find(:all, :limit => 2)\n person1 = spods[0]\n person2 = spods[1]\n \n new_leg_code = \"AAAA\"\n assert person1.legacy4d_identity_code !=person2.legacy4d_identity_code\n person1.legacy4d_identity_code = new_leg_code\n person2.legacy4d_identity_code = new_leg_code\n assert !person1.save\n assert !person2.save\n \n end",
"def fail_test_default_counter_cache_update_counters_when_change_association_via_id\n f1, m = build_fixture\n assert_equal 1, f1.reload.messages_count\n f2 = Folder.create\n assert_equal 0, f2.reload.messages_count\n m.folder_id = f2.id\n m.save\n assert_equal 0, f1.reload.messages_count\n assert_equal 1, f2.reload.messages_count\n end"
] | [
"0.7280976",
"0.70450926",
"0.5759455",
"0.57587314",
"0.5740955",
"0.5677437",
"0.5666324",
"0.5666324",
"0.556692",
"0.5508822",
"0.5502131",
"0.5483559",
"0.54794127",
"0.54491895",
"0.5446638",
"0.54160845",
"0.538678",
"0.5374471",
"0.5359461",
"0.5306936",
"0.5290686",
"0.52769226",
"0.5249543",
"0.5235246",
"0.5216789",
"0.5202017",
"0.51766723",
"0.51334566",
"0.5125855",
"0.51249254",
"0.5121919",
"0.5119808",
"0.5110802",
"0.5109145",
"0.51061517",
"0.51005316",
"0.5088261",
"0.5088261",
"0.508262",
"0.5069348",
"0.50632095",
"0.5055666",
"0.50440276",
"0.50419545",
"0.50359666",
"0.5009002",
"0.50072676",
"0.49897248",
"0.4988391",
"0.49870697",
"0.49824902",
"0.49631345",
"0.49623436",
"0.4959137",
"0.49583",
"0.49559015",
"0.49444866",
"0.49374905",
"0.4935429",
"0.49276707",
"0.49255672",
"0.49242213",
"0.492276",
"0.49202755",
"0.49198714",
"0.4907914",
"0.4904187",
"0.49025157",
"0.4895707",
"0.48824847",
"0.48808175",
"0.48794955",
"0.48760608",
"0.4872349",
"0.4862119",
"0.4858124",
"0.48560905",
"0.4848776",
"0.48476213",
"0.48430216",
"0.48422366",
"0.48403406",
"0.48374668",
"0.4835209",
"0.48333162",
"0.48311535",
"0.48248684",
"0.48068368",
"0.48042732",
"0.48008358",
"0.47990245",
"0.47873244",
"0.47863862",
"0.4785967",
"0.47794732",
"0.47776037",
"0.47766274",
"0.47740632",
"0.4773705",
"0.4771547"
] | 0.5382451 | 17 |
test a more complicated case where chunks should be reused | def test_reuse_single_file2
CheckFile @writer, @ioservice, @adlers, 'try with try with', ['try w', 'ith ', 'try w', 'ith']
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_reuse_existing_chunks_when_prepend\n CheckFile @writer, @ioservice, @adlers, 'test content', ['test ', 'conte', 'nt']\n CheckFile @writer, @ioservice, @adlers, 'a new test content', ['a new', ' ', 'test ', 'conte', 'nt']\n end",
"def test_0900_chunk\n @@log.debug \"test_0900_chunk starts\" if @@log.debug?\n assert_respond_to(@list, :chunk, \"test_0900_chunk_respond\")\n # Type check\n result = @list.chunk {|pers| pers.first > \"Cary\" }\n type_check = result.is_a? Enumerator\n assert(type_check,\"test_0900_chunk_class\") \n # chunk results check. In this case, should be a simple (and single)\n # true/false switch.\n result.each do |even, ary|\n if even\n assert(ary == [@cab, @dad], \"test_0900_chunk_truec\")\n else\n assert(ary == [@aen, @bsb], \"test_0900_chunk_falsec\")\n end\n end\n #\n @@log.debug \"test_0900_chunk ends\" if @@log.debug?\n end",
"def each_chunk; end",
"def ignore_bad_chunking; end",
"def ignore_bad_chunking; end",
"def test_reuse_existing_chunks_when_append\n CheckFile @writer, @ioservice, @adlers, 'test content', ['test ', 'conte', 'nt']\n CheckFile @writer, @ioservice, @adlers, 'test content updated', ['test ', 'conte', 'nt', ' upda', 'ted']\n end",
"def ignore_bad_chunking=(_arg0); end",
"def test_chrm_chunk\n\n each_file_with_updated_info do\n |file_path|\n\n if @test_feature == \"c\" && @parameter[0] == \"c\"\n img = Imgrb::Image.new(file_path, :only_metadata)\n assert_equal [0.3127, 0.3290, 0.64, 0.33, 0.30, 0.60, 0.15, 0.06],\n img.ancillary_chunks[:cHRM][0].get_data\n end\n end\n\n\n img = Imgrb::Image.new(10, 10, [255,155,55])\n chrm_dat = [0.42, 0.32, 0.22, 0.11, 0.55, 0.44, 0.33, 0.22]\n chrm = Imgrb::Chunks::ChunkcHRM.assemble(*chrm_dat)\n img.add_chunk(chrm)\n\n png_str = save_png_to_string(img)\n img_saved = Imgrb::Image.new(png_str, :from_string)\n chrm_dat_saved = img_saved.ancillary_chunks[:cHRM][0].get_data\n\n assert_equal chrm_dat, chrm_dat_saved\n\n end",
"def chunked?; end",
"def chunks\n @_chunks ||= find_chunks(input)\n end",
"def chunks\n @_chunks ||= find_chunks(input)\n end",
"def test_store_file\n #emulate the saving of a file whose content is 'test content'\n @writer.save_file('test content')\n #we expect three chunks for\n expected_chunks = ['test ', 'conte', 'nt']\n expected_chunks_sha = expected_chunks.map{|s| ComputeSHADigest s}\n #A. Each of the chunk is named with the sha on its content\n expected_chunks_sha.each{|sha| assert( @ioservice.exists? :chunk, sha )}\n \n #B. The filename is retrieved from the sha of the whole string\n file_sha = ComputeSHADigest 'test content'\n assert( @ioservice.exists?(:file, file_sha), \"file not found: #{file_sha} in #{@ioservice.store[:file]}\" )\n #C. The file lists all its chunks\n @ioservice.read_elem(:file, file_sha) do |c|\n c.each_line.zip(expected_chunks_sha).each{ |l, sha| assert_equal(l.strip, sha) }\n end\n #D. the adlers directory should be filled with the adler32 code of each chunk\n CheckChunksInAdlerDirectory( @adlers, expected_chunks )\n end",
"def test_sbit_chunk\n\n each_file_with_updated_info do\n |file_path|\n\n if @test_feature == \"c\" && @parameter[0] == \"s\"\n img = Imgrb::Image.new(file_path, :only_metadata)\n next if img.ancillary_chunks[:sBIT].size == 0\n if img.header.bit_depth == 16\n expected = [13,13,13]\n else\n expected = [@parameter[1].to_i]*3\n end\n\n assert_equal expected,\n img.ancillary_chunks[:sBIT][0].get_data\n end\n end\n\n\n\n img = Imgrb::Image.new(10, 10, [255,155])\n sbit_dat = [3,5]\n sbit = Imgrb::Chunks::ChunksBIT.assemble(*sbit_dat)\n img.add_chunk(sbit)\n\n png_str = save_png_to_string(img)\n img_saved = Imgrb::Image.new(png_str, :from_string)\n sbit_dat_saved = img_saved.ancillary_chunks[:sBIT][0].get_data\n\n assert_equal sbit_dat, sbit_dat_saved\n end",
"def test_hist_chunk\n\n each_file_with_updated_info do\n |file_path|\n\n if @test_feature == \"c\" && @parameter[0] == \"h\"\n img = Imgrb::Image.new(file_path, :only_metadata)\n\n if @parameter[1].to_i == 1\n assert_equal [64, 112, 48, 96, 96, 32, 32, 80, 16, 128, 64, 16, 48, 80, 112],\n img.ancillary_chunks[:hIST][0].get_data\n else\n assert_equal [4]*256, img.ancillary_chunks[:hIST][0].get_data\n end\n end\n end\n\n\n\n img = Imgrb::Image.new(10, 10, [255,155,10])\n hist_dat = [10*10]\n hist = Imgrb::Chunks::ChunkhIST.assemble(*hist_dat)\n img.add_chunk(hist)\n\n png_str = save_png_to_string(img, 1)\n img_saved = Imgrb::Image.new(png_str, :from_string, :only_metadata)\n hist_dat_saved = img_saved.ancillary_chunks[:hIST][0].get_data\n\n assert_equal hist_dat, hist_dat_saved\n end",
"def validate_parts_full_chunks!(grid_infos)\n grid_infos.each do |grid_info|\n if grid_info[:length] % grid_info[:chunkSize] != 0 && grid_info != grid_infos.last\n raise Tus::Error, \"cannot concatenate parts which aren't evenly distributed across chunks\"\n end\n end\n end",
"def join(owned_chunks)\n \n end",
"def test_chunked_data\n server = FakeJobServer.new(self)\n client, sock, task, taskset, res = nil\n\n s = TestScript.new\n c = TestScript.new\n\n server_thread = Thread.new { s.loop_forever }.run\n client_thread = Thread.new { c.loop_forever }.run\n\n c.exec { client = Gearman::Client.new(\"localhost:#{server.port}\") }\n task = Gearman::Task.new('foo', 'bar', { :retry_count => 3 })\n received_data = \"\"\n task.on_data {|data| received_data << data }\n task.on_complete {|data| received_data << data}\n\n c.exec { taskset = Gearman::TaskSet.new(client) }\n c.exec { taskset.add_task(task) }\n s.exec { sock = server.expect_connection }\n s.wait\n\n c.exec { taskset.wait }\n s.exec { server.expect_request(sock, :submit_job, \"foo\\000\\000bar\") }\n s.exec { server.send_response(sock, :job_created, 'a') }\n s.exec { server.send_response(sock, :work_data, \"a\\000data chunk 1\\n\") }\n s.exec { server.send_response(sock, :work_data, \"a\\000data chunk 2\\n\") }\n s.exec { server.send_response(sock, :work_complete, \"a\\000data complete\") }\n c.wait\n s.wait\n\n assert_equal(\"data chunk 1\\ndata chunk 2\\ndata complete\", received_data)\n end",
"def test_read_file_many_blocks\r\n hash_calc = Minitest::Mock.new('test_hash_calculator')\r\n block_checker = Minitest::Mock.new('test_block_checker')\r\n account_tracker = Minitest::Mock.new('account_tracker')\r\n def block_checker.read_next_line; \"1|2|3|4|5|6\"; end\r\n def block_checker.parse(string, char); [\"1\",\"2\",\"3\",\"4\",\"5\",\"6\"]; end\r\n output = \"Line 0: Too many '|' in the block '1|2|3|4|5|6'\"\r\n assert_equal output, @g.read_file(hash_calc, block_checker, account_tracker)\r\n end",
"def chunk(array, size)\nend",
"def got_three chunks\n\nchunks.sort.chunk{ |e| e }.select { |e, chunk| chunk.size == 3 }.map.any?\n\nend",
"def chunk(array, n)\n\nend",
"def chunk(array, n)\nend",
"def chunk(count=100)\n criteria[:chunk] = count\n self\n end",
"def process_blocks(blocks); end",
"def test_0650_each_slice\n @@log.debug \"test_0650_each_slice starts\" if @@log.debug?\n assert_respond_to(@list, :each_slice, \"test_0650_each_slice_respond\")\n # Type check.\n enum = @list.each_slice(2)\n result = enum.is_a? Enumerator\n assert(result,\"test_0650_each_slice_class\") \n # Check each array slice.\n pass = 0\n @list.each_slice(2) {|suba|\n pass += 1\n case pass\n when 1\n assert_equal([@aen, @bsb], suba, \"test_0650_each_slice_p1\")\n when 2\n assert_equal([@cab, @dad], suba, \"test_0650_each_slice_p2\")\n else\n fail(\"test_0650_each_slice_invalid\")\n end\n }\n #\n pass = 0\n @list.each_slice(3) {|suba|\n pass += 1\n case pass\n when 1\n assert_equal([@aen, @bsb, @cab], suba, \"test_0650_each_slice_p1b\")\n when 2\n assert_equal([@dad], suba, \"test_0650_each_slice_p2b\")\n else\n fail(\"test_0650_each_slice_invalid_b\")\n end\n }\n @@log.debug \"test_0650_each_slice ends\" if @@log.debug?\n end",
"def chunk_size()\n #This is a stub, used for indexing\n end",
"def ignore_bad_chunking=(ignore_bad_chunking); end",
"def test_start_chunk\n storable_class = new_storable_class\n storable_class.class_eval do\n def total_chunks\n 10\n end\n end\n obj = storable_class.new\n assert_equal(1, obj.start_chunk)\n end",
"def morechunks?\n Dir.entries(\"data/\").size > 2\n end",
"def query_each_side_has_a_block x, y, z, do_update = false\r\n arr = Array.new(6, false)\r\n arr[0] = get_block_at(x, y - 1, z) == nil #bottom\r\n arr[1] = get_block_at(x, y, z - 1) == nil #sides\r\n arr[2] = get_block_at(x - 1, y, z) == nil #sides\r\n arr[3] = get_block_at(x + 1, y, z) == nil #sides\r\n arr[4] = get_block_at(x, y, z + 1) == nil #sides\r\n arr[5] = get_block_at(x, y + 1, z) == nil #top\r\n \r\n if do_update \r\n chx = (x / Util::Chunk_Size).floor\r\n chy = (y / Util::Chunk_Size).floor\r\n chz = (z / Util::Chunk_Size).floor\r\n \r\n if chy != ((y - 1) / Util::Chunk_Size).floor\r\n add_chunk_update_request(chx, ((y - 1) / Util::Chunk_Size).floor, chz)\r\n elsif chy != ((y + 1) / Util::Chunk_Size).floor\r\n add_chunk_update_request(chx, ((y + 1) / Util::Chunk_Size).floor, chz)\r\n end\r\n \r\n if chx != ((x - 1) / Util::Chunk_Size).floor\r\n add_chunk_update_request(((x - 1) / Util::Chunk_Size).floor, chy, chz)\r\n elsif chx != ((x + 1) / Util::Chunk_Size).floor\r\n add_chunk_update_request(((x + 1) / Util::Chunk_Size).floor, chy, chz)\r\n end\r\n \r\n if chz != ((z + 1) / Util::Chunk_Size).floor\r\n add_chunk_update_request(chx, chy, ((z + 1) / Util::Chunk_Size).floor)\r\n elsif chz != ((z - 1) / Util::Chunk_Size).floor\r\n add_chunk_update_request(chx, chy, ((z - 1) / Util::Chunk_Size).floor)\r\n end\r\n \r\n end\r\n\r\n #@called += 1\r\n #puts @called\r\n \r\n return arr\r\n end",
"def test_tile_rack_with_several_tiles_should_need_some_tiles\n [:A,:B,:C].each{|x| @newTileRack.append(x)}\n assert_equal(4,@newTileRack.number_of_tiles_needed)\n end",
"def each_chunk\n iend_reached = false\n File.open(@file_path, 'rb') do |file|\n # check if file is not PNG at all\n return false if file.read(8) != PNG_MAGIC_NUMBER\n\n chunks = 0\n\n # We could be dealing with large number of chunks,\n # so the code should be optimized to create as few objects as possible.\n # All literal strings are frozen and read() function uses string buffer.\n chunkheader = ''\n while file.read(8, chunkheader)\n # ensure that first 8 bytes from chunk were read properly\n if chunkheader.nil? || chunkheader.length < 8\n return false\n end\n\n current_pos = file.tell\n\n chunk_len, chunk_name = chunkheader.unpack(\"Na4\".freeze)\n return false if chunk_name =~ /[^A-Za-z]/\n yield chunk_name, chunk_len, file\n\n # no need to read further if IEND is reached\n if chunk_name == \"IEND\".freeze\n iend_reached = true\n break\n end\n\n # check if we processed too many chunks already\n # if we did, file is probably maliciously formed\n # fail gracefully without marking the file as corrupt\n chunks += 1\n if chunks > 100_000\n iend_reached = true\n break\n end\n\n # jump to the next chunk - go forward by chunk length + 4 bytes CRC\n file.seek(current_pos + chunk_len + 4, IO::SEEK_SET)\n end\n end\n\n iend_reached\n end",
"def setup_process_in_batches_tests\n @array = %W[one two three four five six seven eight nine ten]\n @empty = Array.new\n end",
"def each_chunk_from\n if actual_content.is_a?(String)\n yield actual_content\n elsif content_is_really_a_checksum? && actual_content.nil?\n yield read_file_from_filebucket\n elsif actual_content.nil?\n yield ''\n end\n end",
"def test_resumable_continuations\n nr = 1000\n header = \"GET / HTTP/1.1\\r\\n\" \\\n \"X-ASDF: \\r\\n\" \\\n \" hello\\r\\n\"\n tmp = []\n nr.times { |i|\n parser = HttpParser.new\n req = parser.env\n parser.buf << \"#{header} #{i}\\r\\n\"\n assert parser.parse.nil?\n asdf = req['HTTP_X_ASDF']\n assert_equal \"hello #{i}\", asdf\n tmp << [ parser, asdf ]\n }\n tmp.each_with_index { |(parser, asdf), i|\n parser.buf << \" .\\r\\n\\r\\n\"\n assert parser.parse\n assert_equal \"hello #{i} .\", asdf\n }\n end",
"def new_chunk(index)\n chunk_num = (index / CHUNK_LINE_SIZE).to_i\n write_file = File.new(\"data/chunk#{chunk_num}\", \"w\")\n\n return write_file\nend",
"def _apply_heuristics io, prev_chunk, chunk\n prev_pos = io.tell\n HEUR_CHUNK_SIZE_RANGE.each do |delta|\n next if delta == 0\n next if prev_chunk.data.size + delta < 0\n io.seek(chunk.offset+delta, IO::SEEK_SET)\n potential_chunk = Chunk.new(io)\n if potential_chunk.valid?\n STDERR.puts \"[!] heuristics: found invalid #{chunk.type.inspect} chunk at offset #{chunk.offset}, but valid #{potential_chunk.type.inspect} at #{chunk.offset+delta}. using latter\".red\n if delta > 0\n io.seek(chunk.offset, IO::SEEK_SET)\n data = io.read(delta)\n STDERR.puts \"[!] #{delta} extra bytes of data: #{data.inspect}\".red\n else\n io.seek(chunk.offset+delta, IO::SEEK_SET)\n end\n return true\n end\n end\n false\n end",
"def test_it_turns_strings_into_chunks\n markdown = \"a\\nbbca\\nbc\\n\"\n actual = Chisel.new(\"\").string_to_chunks(markdown)\n expected = [\"a\", \"bbca\", \"bc\"]\n\n assert_equal expected, actual\n end",
"def test_enqueue_chunk_with_empty_key\n buf = Fluent::FileBuffer.new\n buf.configure({'buffer_path' => bufpath('enqueue2')})\n prefix = buf.instance_eval{ @buffer_path_prefix }\n suffix = buf.instance_eval{ @buffer_path_suffix }\n\n chunk = buf.new_chunk('')\n chunk << \"data1\\ndata2\\n\"\n\n assert chunk\n old_path = chunk.path.dup\n assert File.exist?(chunk.path)\n # chunk key is empty\n assert chunk.path =~ /\\A#{prefix}\\.b[0-9a-f]+#{suffix}\\Z/, \"path from new_chunk must be a 'b' buffer chunk\"\n\n buf.enqueue(chunk)\n\n assert chunk\n assert File.exist?(chunk.path)\n assert !(File.exist?(old_path))\n # chunk key is empty\n assert chunk.path =~ /\\A#{prefix}\\.q[0-9a-f]+#{suffix}\\Z/, \"enqueued chunk's path must be a 'q' buffer chunk\"\n\n data = chunk.read\n assert \"data1\\ndata2\\n\", data\n end",
"def test1\n yield\n yield\n yield\nend",
"def chunk(file_name, prefix, chunksize = 1_073_741_824)\n File.open(file_name\"r\") do |f|\n until f.eof?\n File.open(\"#{prefix}_#{\"%05d\"%(f.pos/chunksize)}.txt\",\"w\") do |fc|\n fc << f.read(chunksize)\n end\n end\n end\nend",
"def chunk_job(job, state, apikey, filename, filesize, start_response, storage)\n offset = 0\n seek_point = job[:seek_point]\n chunk_list = []\n\n while (offset < FilestackConfig::DEFAULT_CHUNK_SIZE) && (seek_point + offset) < filesize\n chunk_list.push(\n seek_point: seek_point,\n filename: filename,\n apikey: apikey,\n part: job[:part],\n size: job[:size],\n uri: start_response['uri'],\n region: start_response['region'],\n upload_id: start_response['upload_id'],\n location_url: start_response['location_url'],\n store: { location: storage },\n offset: offset\n )\n offset += state.offset\n end\n chunk_list\n end",
"def test_that_full_tile_rack_doesnt_need_any_tiles\n 7.times{|num| @newTileRack.append(:A)}\n assert_equal(0,@newTileRack.number_of_tiles_needed)\n end",
"def testSplitTask\n executeSimpleTest(\n [ [ 'T1', 'R1', 500, 1, ['T2'], '='],\n [ 'T2', 'R2', 900, 2, [], ' =='],\n [ 'T3', 'R2', 100, 4, [], '= ==='] ] )\n end",
"def testReuseMixWithSourceFilesProcessed\n lProcessID = {\n :Param1 => 'TestParam1'\n }.unique_id\n execute_Mix_WithConf({\n :WaveFiles => {\n :FilesList => [\n {\n :Name => 'Wave.wav'\n }\n ]\n },\n :Mix => {\n 'Mix1' => {\n :Tracks => {\n 'Wave.wav' => {\n :Processes => [\n {\n :Name => 'Test',\n :Param1 => 'TestParam1'\n }\n ]\n }\n }\n },\n 'Final' => {\n :Tracks => {\n 'Mix1' => {\n :Processes => [\n {\n :Name => 'Test',\n :Param1 => 'TestParam2'\n }\n ]\n }\n }\n }\n }\n },\n :PrepareFiles => [\n [ 'Wave/Empty.wav', 'Wave.wav' ],\n [ 'Wave/Noise1s.wav', \"05_Mix/Wave.0.Test.#{lProcessID}.wav\" ]\n ]) do |iStdOUTLog, iStdERRLog, iExitStatus|\n assert_exitstatus 0, iExitStatus\n lWave0FileName = getFileFromGlob('05_Mix/Wave.0.Test.0.Test.????????????????????????????????.wav')\n assert_rb_content [\n {\n :InputFileName => \"05_Mix/Wave.0.Test.#{lProcessID}.wav\",\n :OutputFileName => lWave0FileName,\n :Params => {\n :Param1 => 'TestParam2'\n }\n }\n ], 'Process_Test.rb'\n assert_wave_lnk 'Noise1s', '05_Mix/Final/Mix1.wav'\n assert_wave_lnk 'Noise1s', '05_Mix/Final/Final.wav'\n end\n end",
"def dynamic_chunk(base_ten_num) #=>inncludes first 1 in output\n base_two_num = binarify(base_ten_num)\n base_two_num.slice(static_chunk(base_ten_num).length..(base_two_num.length - 1))\nend",
"def testReuseMixWithMixProcessed\n lProcessID = {\n :Param1 => 'TestParam1'\n }.unique_id\n execute_Mix_WithConf({\n :WaveFiles => {\n :FilesList => [\n {\n :Name => 'Wave.wav'\n }\n ]\n },\n :Mix => {\n 'Mix1' => {\n :Tracks => {\n 'Wave.wav' => {}\n },\n :Processes => [\n {\n :Name => 'Test',\n :Param1 => 'TestParam1'\n }\n ]\n },\n 'Final' => {\n :Tracks => {\n 'Mix1' => {\n :Processes => [\n {\n :Name => 'Test',\n :Param1 => 'TestParam2'\n }\n ]\n }\n }\n }\n }\n },\n :PrepareFiles => [\n [ 'Wave/Empty.wav', 'Wave.wav' ],\n [ 'Wave/Noise1s.wav', \"05_Mix/Wave.0.Test.#{lProcessID}.wav\" ]\n ]) do |iStdOUTLog, iStdERRLog, iExitStatus|\n assert_exitstatus 0, iExitStatus\n lWave0FileName = getFileFromGlob('05_Mix/Wave.0.Test.0.Test.????????????????????????????????.wav')\n assert_rb_content [\n {\n :InputFileName => \"05_Mix/Wave.0.Test.#{lProcessID}.wav\",\n :OutputFileName => lWave0FileName,\n :Params => {\n :Param1 => 'TestParam2'\n }\n }\n ], 'Process_Test.rb'\n assert_wave_lnk 'Noise1s', '05_Mix/Final/Mix1.wav'\n assert_wave_lnk 'Noise1s', '05_Mix/Final/Final.wav'\n end\n end",
"def inside_chunks(chunk_types)\n chunk_types.each{|chunk_type| chunk_type.apply_to(self) }\n \n chunk_types.each{|chunk_type| @chunks_by_type[chunk_type].each{|hide_chunk|\n scan_chunkid(hide_chunk.text){|id| yield id }\n }\n } \n end",
"def test(m,n,&block)\n\tif (m > 20000)\n\t\treturn\n\tend\n\n\tyield(m,n)\n\ttest(2*m - n, m, &block)\n\ttest(2*m + n, m, &block)\n\t#if (n != 1)\n\t#test(m + 2*n, n, &block)\n\t#end\nend",
"def test_example_part_two\n input = ['1, 1', '1, 6', '8, 3', '3, 4', '5, 5', '8, 9'].join(\"\\n\")\n grid = Grid.new(input, true, 32)\n\n assert_equal 16, grid.region_size\n end",
"def chunk_size\n 4096\n end",
"def assert_read_node(node, assert_nblocks, assert_string, chunksize = 1024)\r\n count = 0\r\n read_str = ''\r\n node.read_stream(chunksize) do |bytes|\r\n read_str += bytes\r\n count += 1\r\n end\r\n assert_equal(assert_nblocks, count)\r\n assert_equal(assert_string, read_str)\r\nend",
"def block_size; end",
"def each_chunk_from(source_or_content)\n if source_or_content.is_a?(String)\n yield source_or_content\n elsif content_is_really_a_checksum? && source_or_content.nil?\n yield read_file_from_filebucket\n elsif source_or_content.nil?\n yield ''\n elsif self.class.standalone?\n yield source_or_content.content\n elsif source_or_content.local?\n chunk_file_from_disk(source_or_content) { |chunk| yield chunk }\n else\n chunk_file_from_source(source_or_content) { |chunk| yield chunk }\n end\n end",
"def test_generate_with_block\n actual = SingleXLSX.generate do |sheet|\n sheet << [\"Name\", \"Age\"]\n sheet << [\"Einstein\", 76]\n sheet << [\"Feynman\", 69]\n end\n\n tempfile = Tempfile.new(self.class.name)\n tempfile.write actual\n tempfile.close\n arr_of_arr = SingleXLSX.read(tempfile.path)\n\n expected = [\n [\"Name\", \"Age\"],\n [\"Einstein\", 76],\n [\"Feynman\", 69],\n ]\n assert_equal expected, arr_of_arr\n ensure\n tempfile.unlink if tempfile\n end",
"def test_0260_partition\n @@log.debug \"test_0260_partition starts\" if @@log.debug?\n assert_respond_to(@list, :partition, \"test_0260_partition_respond\")\n # Basic partition\n ta = @list.partition {|obj| obj.ndata >= 3 }\n assert_equal(2, ta.size,\"test_0260_partition_basic_01\")\n # First array: block evaluated to true\n assert_equal([@aen, @bsb], ta[0], \"test_0260_partition_basic_02\")\n # Second array: block evaluated to false\n assert_equal([@cab, @dad], ta[1], \"test_0260_partition_basic_03\")\n # Check Enumerator or Enumerable::Enumerator return, no block given\n # This form not documented by the 1.8 Pickaxe.\n new_list = @list.partition\nif RUBY_VERSION >= \"1.9\"\n result = new_list.is_a? Enumerator\n assert(result, \"test_0260_partition_enumcheck\")\nelse\n # Note: the author's version of the 1.8 Pickaxe documents this\n # as an Array, however does not document this form of code at all.\n # YMMV.\n result = new_list.is_a? Enumerable::Enumerator\n assert(result, \"test_0260_partition_enumenumcheck\")\nend\n\n @@log.debug \"test_0260_partition ends\" if @@log.debug?\n end",
"def nr_chunks\n ENV['NR_CHUNKS'] ? ENV['NR_CHUNKS'].to_i : 10\n end",
"def test_the_whole_process\n #changed to return array when i removed splitter and joiner between paragraph and header classes\n pm = ParagraphMarker.new\n assert_equal [\"#Some\", \"<p>of\\nThese</p>\", \"#should\", \"<p>get</p>\", \"#tagged\"], pm.mark_paragraphs(\"#Some\\n\\nof\\nThese\\n\\n#should\\n\\nget\\n\\n#tagged\")\n end",
"def fuse(_following_chunk)\n nil\n end",
"def remainder_as_buffer; end",
"def test_breakdown_data_limit_one\n root_segment = mock('root_segment')\n # this is for 1.9 compatibility - calling each on something calls\n # #to_a on it - which is fun and exciting\n root_segment.stubs(:to_a).returns([root_segment])\n other_segment = mock('other_segment')\n # this is for 1.9 compatibility - calling each on something calls\n # #to_a on it - which is fun and exciting\n other_segment.stubs(:to_a).returns([other_segment])\n other_segment.expects(:metric_name).twice.returns('Controller/foo')\n other_segment.expects(:duration).returns(0.1)\n other_segment.expects(:exclusive_duration).returns(0.1)\n yet_another = mock('another segment')\n # this is for 1.9 compatibility - calling each on something calls\n # #to_a on it - which is fun and exciting\n yet_another.stubs(:to_a).returns([yet_another])\n yet_another.expects(:metric_name).twice.returns('Controller/bar')\n yet_another.expects(:duration).returns(0.2)\n yet_another.expects(:exclusive_duration).returns(0.2)\n self.expects(:each_segment_with_nest_tracking).multiple_yields(root_segment, other_segment, yet_another)\n self.expects(:root_segment).times(3).returns(root_segment)\n self.expects(:duration).returns(0.1)\n data = breakdown_data(1)\n assert_equal 1, data.size\n assert_equal 'Controller/bar', data[0].metric_name\n end",
"def read_chunk(chunk)\n puts \"[ESP DEBUG] - Read chunk #{chunk.name}...\" if @debug\n description = nil\n decoded_data = nil\n subchunks = []\n header = chunk.header\n case chunk.name\n when 'TES4'\n # Always read fields of TES4 as they define the masters, which are needed for others\n puts \"[ESP DEBUG] - Read children chunks of #{chunk}\" if @debug\n subchunks = chunk.sub_chunks(sub_chunks_format: {\n '*' => { header_size: 0, size_length: 2 },\n 'ONAM' => {\n data_size_correction: proc do |file|\n # Size of ONAM field is sometimes badly computed. Correct it.\n file.seek(4, IO::SEEK_CUR)\n stored_size = file.read(2).unpack('S').first\n file.read(chunk.size).index('INTV') - stored_size\n end\n }\n })\n chunk_type = :record\n when 'MAST'\n description = chunk.data[0..-2].downcase\n @masters << description\n @master_ids[sprintf('%.2x', @master_ids.size)] = description\n chunk_type = :field\n when 'GRUP'\n puts \"[ESP DEBUG] - Read children chunks of #{chunk}\" if @debug\n subchunks = chunk.sub_chunks(sub_chunks_format: Hash[(['GRUP'] + KNOWN_GRUP_RECORDS_WITHOUT_FIELDS + KNOWN_GRUP_RECORDS_WITH_FIELDS).map do |known_sub_record_name|\n [\n known_sub_record_name,\n {\n header_size: 16,\n data_size_correction: known_sub_record_name == 'GRUP' ? -24 : 0\n }\n ]\n end])\n chunk_type = :group\n when *KNOWN_GRUP_RECORDS_WITHOUT_FIELDS\n # GRUP record having no fields\n form_id_str = sprintf('%.8x', header[4..7].unpack('L').first)\n @form_ids << form_id_str\n description = \"FormID: #{form_id_str}\"\n puts \"[WARNING] - #{chunk} seems to have fields: #{chunk.data.inspect}\" if @warnings && chunk.data[0..3] =~ /^\\w{4}$/\n chunk_type = :record\n when *KNOWN_GRUP_RECORDS_WITH_FIELDS\n # GRUP record having fields\n form_id_str = sprintf('%.8x', header[4..7].unpack('L').first)\n @form_ids << form_id_str\n description = \"FormID: #{form_id_str}\"\n if @decode_fields\n puts \"[ESP DEBUG] - Read children chunks of #{chunk}\" if @debug\n subchunks = chunk.sub_chunks(sub_chunks_format: { '*' => { header_size: 0, size_length: 2 } })\n end\n chunk_type = :record\n when *KNOWN_FIELDS\n # Field\n record_module_name =\n if Data.const_defined?(chunk.parent_chunk.name.to_sym)\n chunk.parent_chunk.name.to_sym\n elsif Data.const_defined?(:All)\n :All\n else\n nil\n end\n unless record_module_name.nil?\n record_module = Data.const_get(record_module_name)\n data_class_name =\n if record_module.const_defined?(\"#{record_module_name}_#{chunk.name}\".to_sym)\n \"#{record_module_name}_#{chunk.name}\".to_sym\n elsif record_module.const_defined?(\"#{record_module_name}_All\".to_sym)\n \"#{record_module_name}_All\".to_sym\n else\n nil\n end\n unless data_class_name.nil?\n data_info = record_module.const_get(data_class_name)\n decoded_data = {}\n data_info.read(chunk.data).each_pair do |property, value|\n decoded_data[property] = value\n end\n end\n end\n chunk_type = :field\n else\n warning_desc = \"Unknown chunk: #{chunk}. Data: #{chunk.data.inspect}\"\n if @ignore_unknown_chunks\n puts \"[WARNING] - #{warning_desc}\" if @warnings\n @unknown_chunks << chunk\n chunk_type = :unknown\n else\n raise warning_desc\n end\n end\n # Decorate the chunk with our info\n esp_info = {\n description: description,\n type: chunk_type\n }\n esp_info[:decoded_data] = decoded_data unless decoded_data.nil?\n unless header.empty?\n header_class_name =\n if Headers.const_defined?(chunk.name.to_sym)\n chunk.name.to_sym\n elsif Headers.const_defined?(:All)\n :All\n else\n nil\n end\n unless header_class_name.nil?\n header_info = Headers.const_get(header_class_name)\n esp_info[:decoded_header] = {}\n header_info.read(header).each_pair do |property, value|\n esp_info[:decoded_header][property] = value\n end\n end\n end\n chunk.instance_variable_set(:@esp_info, esp_info)\n @chunks_tree[chunk] = subchunks\n subchunks.each.with_index do |subchunk, idx_subchunk|\n read_chunk(subchunk)\n end\n end",
"def initialize_new_test_store\n verify_store_is_blank_for_init\n add_chunk MemoryChunk.new(:max_chunk_size=>max_chunk_size,:max_index_block_size=>max_index_block_size)\n end",
"def each\n pos = 0\n while(pos < @original_duration) do\n chunk = nil\n begin\n chunk = Chunk.new(@original_file, @original_duration, pos, (@chunk_duration + @overlap), @rate)\n yield chunk\n pos = pos + [chunk.duration, @chunk_duration].min\n ensure\n chunk.close_file if chunk\n end\n end\n end",
"def test_listchunk_attributes\n\t\t\n\tend",
"def verify_chunk_size! chunk_size\n chunk_size = chunk_size.to_i\n chunk_mod = 256 * 1024 # 256KB\n if (chunk_size.to_i % chunk_mod) != 0\n chunk_size = (chunk_size / chunk_mod) * chunk_mod\n end\n return if chunk_size.zero?\n chunk_size\n end",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def my_array_splitting_method(source)\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\nend",
"def test_load_0\n\n map = {}\n\n @engine.register_participant(\"count\") do |workitem|\n count = map[workitem.flow_id]\n count = unless count\n 1\n else\n count + 1\n end\n map[workitem.flow_id] = count\n end\n\n n = 1000\n\n n.times do |i|\n li = LaunchItem.new(TestDefinition0)\n li.flow_id = i\n @engine.launch(li)\n end\n\n #while @engine.get_expression_storage.size > 1\n # sleep 0.001\n #end\n @engine.join_until_idle\n\n good = true\n\n n.times do |i|\n c = map[i]\n if c == 2\n #if c == 1\n print \".\"\n else\n print c\n good = false\n end\n end\n\n #puts \"\\n__good ? #{good}\"\n assert good, \"missing count\"\n\n # 100 in 1s (in memory engine)\n # 1'000 in 14s (in memory engine)\n # 10'000 in 143s (in memory engine)\n # 1'000 in 31s (cache engine)\n # 10'000 in 321s (cache engine)\n # 1'000 in 113s (persistence only engine)\n # 10'000 in 1173s (persistence only engine)\n #\n #\n # ruby 1.8.5 (2006-12-25 patchlevel 12) [i686-darwin8.8.3]\n #\n # Machine Name: Mac\n # Machine Model: MacBook2,1\n # Processor Name: Intel Core 2 Duo\n # Processor Speed: 2 GHz\n # Number Of Processors: 1\n # Total Number Of Cores: 2\n # L2 Cache (per processor): 4 MB\n # Memory: 2 GB\n # Bus Speed: 667 MHz\n\n # Thu Sep 13 15:38:46 JST 2007\n #\n # 100 in 3s (in memory engine)\n # 1'000 in 85s (in memory engine)\n # 10'000 in s (in memory engine)\n end",
"def test_that_grids_do_not_work_for_small_imgs\n end",
"def find_chunks(text)\n meta_info = text.scan(CHUNK_REGEXP)\n returning(chunks = []) do\n split = text.split(CHUNK_REGEXP)\n split.shift\n split.each_with_index do |lines, idx| \n chunks << PrettyDiff::Chunk.new(meta_info[idx], lines)\n end\n end\n end",
"def test_add100\n\n # make new file and fill with data\n\t\tfill_file(100)\n\t\t \t\n \tfb=Fastabin.new(TEST_FILE,'r') \t \t\n assert_equal(100,fb.count)\n fb.close\n \t\t\n end",
"def test_line_buffer_size\n wrapper = S3io::ReadWrapper.new(@s3object, :line_buffer_size => 25)\n\n wrapper.lines.each_with_index do |line, index|\n break if index == 1 # skip two buffered reads\n end\n\n assert_equal(50, wrapper.pos)\n assert_equal(S3_TEST_DATA[50..-1], wrapper.read)\n end",
"def my_array_splitting_method(source)\r\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\r\nend",
"def my_array_splitting_method(source)\r\n source # This line is here to make sure all tests initially fail. Delete it when you begin coding.\r\nend",
"def test_rack_doesnt_contain_enough_duplicate_letters\n [:A,:B,:A,:C].each{|x| @newTileRack.append(x)}\n assert_equal(false,@newTileRack.has_tiles_for?('AAAA'))\n end",
"def find_chunks(text)\n meta_info = text.scan(CHUNK_REGEXP)\n chunks = []\n chunks.tap do\n split = text.split(CHUNK_REGEXP)\n split.shift\n split.each_with_index do |lines, idx| \n chunks << MailDiff::Chunk.new(self, meta_info[idx], lines)\n end\n end\n end"
] | [
"0.7111465",
"0.67383045",
"0.6709689",
"0.67064005",
"0.67064005",
"0.66966504",
"0.6480198",
"0.6420431",
"0.61722076",
"0.6031122",
"0.6031122",
"0.6019802",
"0.6019592",
"0.59731174",
"0.5929808",
"0.58299136",
"0.5815501",
"0.58149874",
"0.57944113",
"0.5757867",
"0.5746516",
"0.57448524",
"0.5735407",
"0.57288325",
"0.5681666",
"0.567819",
"0.5671101",
"0.56558263",
"0.5654152",
"0.5652971",
"0.56063527",
"0.5565255",
"0.5558204",
"0.55295026",
"0.5527631",
"0.5514667",
"0.55026555",
"0.54946023",
"0.5490208",
"0.5486318",
"0.5479744",
"0.542591",
"0.5423731",
"0.54206634",
"0.5411507",
"0.5402204",
"0.5401459",
"0.53982276",
"0.5374561",
"0.53703487",
"0.5358802",
"0.5312516",
"0.5310982",
"0.530746",
"0.5306121",
"0.529617",
"0.5291813",
"0.5290876",
"0.5275852",
"0.52722037",
"0.5248431",
"0.52184945",
"0.52183247",
"0.5212245",
"0.52047753",
"0.51971835",
"0.5196154",
"0.5196154",
"0.5196154",
"0.5196154",
"0.5196154",
"0.5196154",
"0.5196154",
"0.5196154",
"0.5196154",
"0.5196154",
"0.5196154",
"0.5196154",
"0.5196154",
"0.5196154",
"0.5196154",
"0.5196154",
"0.5196154",
"0.5196154",
"0.5196154",
"0.5196154",
"0.5196154",
"0.5196154",
"0.5196154",
"0.5196154",
"0.5196154",
"0.51960427",
"0.5189184",
"0.5186837",
"0.51830214",
"0.5175651",
"0.5167099",
"0.5167099",
"0.5157278",
"0.5148455"
] | 0.5231456 | 61 |
When a tree is saved: A. the tree file is named with the sha of its content B. the tree file stores the list of the file in it C. each file is normaly saved | def test_save_tree
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def storeTree(inTree, filename)\n File.open(filename, \"w\") do |file|\n file.puts YAML::dump(inTree)\n end\n end",
"def save_path_tree\n file = File.open(DATA_STORE, 'w')\n file.write path_tree.dump.to_json\n file.close\n end",
"def save_hashes\n @storage.save_hash_tree @hash_tree_controller.node_hashes\n end",
"def writeTree(file)\n file.write toString\n end",
"def create(filename,serialized_tree)\n File.open(File.join(@base_path, filename),\"w\") do |f|\n f.write(serialized_tree)\n end\n end",
"def writeTree(file)\n file.write @tree.toString\n end",
"def save_hash_tree(node_hashes)\n tree_size = SpStore::Merkle::HashTreeHelper.full_tree_node_count @blocks\n raise ArgumentError, \"Hash tree size doesn't match the size of the existed one\" unless (tree_size+1) == node_hashes.length\n File.open(disk_hash_file, 'wb') do |file|\n file.seek( hash_byte_size, IO::SEEK_SET)\n (1..tree_size).each do |node|\n file.write node_hashes[node]\n end\n end\n end",
"def write_to(git)\n self.mode ||= git.default_tree_mode\n self.sha ||= begin\n lines = []\n each_pair(false) do |key, entry|\n mode, sha = case entry\n when Tree then entry.write_to(git)\n when Array then entry\n else [entry.mode, entry.id]\n end\n \n # modes should not begin with zeros (although it is not fatal\n # if they do), otherwise fsck will print warnings like this:\n #\n # warning in tree 980127...: contains zero-padded file modes\n lines << zero_strip(\"#{mode} #{key}\\0#{[sha].pack(\"H*\")}\")\n end\n\n git.set(:tree, lines.join)\n end\n\n [mode, sha]\n end",
"def after_update\r\n\t\t\tself.children.each do |child|\r\n\t\t\t\tchild.path = self.path + '/' + child.filename\r\n\t\t\t\tchild.save\r\n\t\t\tend\r\n\t\tend",
"def after_update\n\t\t\tself.children.each do |child|\n\t\t\t\tchild.path = self.path + '/' + child.filename\n\t\t\t\tchild.save\n\t\t\tend\n\t\tend",
"def save args={}\n raise ArgumentError, \"No file name provided\" if args[:filename].nil?\n @savable_sgf = \"(\"\n @root.children.each { |child| write_node child }\n @savable_sgf << \")\"\n\n File.open(args[:filename], 'w') { |f| f << @savable_sgf }\n end",
"def tree\n # Caution: use only for small projects, don't use in root.\n @title = 'Full Tree'\n # @files = `zsh -c 'print -rl -- **/*(#{@sorto}#{@hidden}M)'`.split(\"\\n\")\n @files = Dir['**/*']\n message \"#{@files.size} files.\"\nend",
"def process_and_write_to file\n \n return unless @is_relevant\t\n\n # svnadmin: Malformed dumpstream: Revision 0 must not contain node records\n #\n # so discard revision without nodes, _except_ for revision 0\n if @nodes.empty? && @num > 0\n return\n end\n\n file.puts \"# process_and_write #{self}\" if $debug\n\n faked_nodes = []\n\n @nodes.each do |node|\n \n next if node.action == :delete\n\n # check node.path and if we already have all parent dirs\n path = node.path\n if node.kind == :file\n\tpath = File.dirname(path)\n elsif node.kind == :dir\n\tcase node.path\n\twhen \"trunk\", \"branches\", \"tags\"\n\t next\n\tend\n end\n last_relevant, last_path = find_and_write_last_relevant_for path, file\n exit 1 unless last_relevant\n # check if this was an 'extra' path and if we have to add directories\n \n # if the node creates the dir path, then the dirname is missing, not the full path\n # (for the 'file' case, we take the parent dir already above)\n #\n missing_path = (node.kind == :dir) ? File.dirname(path) : path\n if $extra_pathes[node.path] &&\n\t last_path != missing_path # last_relevant was a parent\n missings = []\n\twhile last_path != missing_path\n\t missings << File.basename(missing_path)\n\t missing_path = File.dirname(missing_path)\n\t break if missing_path == \".\"\n\tend\n\t# consistency check. Maybe last_past was no parent ?!\n\tif missing_path == \".\"\n\t STDERR.puts \"Couldn't find missing directories\"\n\t STDERR.puts \"Last directory was #{last_path}\"\n\t STDERR.puts \"Missings #{missings.inspect}\"\n\t exit 1\n\tend\n # add fake nodes to create missing directories\n\twhile !missings.empty?\n\t missing_path = File.join(missing_path, missings.pop)\n\t unless $created_extras[missing_path]\n\t file.puts \"# Create #{missing_path}\" if $debug\n\t faked_nodes << FakeNode.new(:dir, :add, missing_path)\n\t $created_extras[missing_path] = true\n\t end\n\tend\n end\n\n if $extra_pathes[node.path]\n\tunless $created_extras[node.path]\n#\t STDERR.puts \"Cutting history for #{node} at rev #{@num}\"\n\t # the extra file could be a 'change' node. This happens\n\t # if it was created in another directory and then the directory\n\t # was renamed. Instead of backtracking directory renames, we cut\n\t # history here and make it an 'add' node\n\t node.action = :add if node.action == :change\n\t $created_extras[node.path] = true\n\tend\n end\n\n # check for Node-copyfrom-path and evtl. rewrite / backtrack\n\n path = node['Node-copyfrom-path']\n if path\n\t# backtrack, find last relevant revision for this path\n\trevnum = node['Node-copyfrom-rev'].to_i\n\tlast_relevant, last_path = find_and_write_last_relevant_for path, file, revnum\n\texit 1 unless last_relevant\n\tnewnum = @@revision_number_mapping[last_relevant.num]\n\tfile.puts \"# Node-copyfrom-rev #{revnum} -> #{newnum}<#{last_relevant.num}>\" if $debug\n\tnode['Node-copyfrom-rev'] = newnum\n end\n end # nodes.each\n \n # write Revision item\n \n self.copy_to file\n # write nodes\n faked_nodes.each do |node|\n node.copy_to file\n end\n @nodes.each do |node|\n node.copy_to file\n path = node.path\n while path != \".\"\n\t@@last_relevant_for[path] ||= []\n\t@@last_relevant_for[path] << self\n\tpath = File.dirname(path)\n end\n end\n end",
"def tree\n # Caution: use only for small projects, don't use in root.\n $title = \"Full Tree\"\n $files = `zsh -c 'print -rl -- **/*(#{$sorto}#{$hidden}M)'`.split(\"\\n\")\nend",
"def tree_append(tree_sha, item)\n child = {\n path: full_path(item.path).gsub(/^\\//, ''),\n sha: push_blob(item),\n type: 'blob',\n mode: '100644'\n }\n new_tree = @client.create_tree(repo, [child], base_tree: tree_sha)\n new_tree.sha\n end",
"def tree(root = '')\n build_hash(files(root), root)\n end",
"def save\n prepare\n atoms_sorted = {}\n @atoms.each do |atom_name, records|\n e_p = encoded_prefix(atom_name)\n atoms_sorted[e_p] = {} if !atoms_sorted.has_key?(e_p)\n atoms_sorted[e_p][atom_name] = records\n end\n atoms_sorted.each do |e_p, atoms|\n #p \"Saving #{e_p}.\"\n File.open(File.join(@root + [e_p.to_s]),'w+') do |f|\n Marshal.dump(atoms,f)\n end\n end\n save_record_size\n end",
"def write_tree\n invoke(:write_tree)\n end",
"def create\n \t@tree = current_user.trees.build(tree_params)\n \tupload\n \[email protected]_at = Time.now\n \[email protected] = @tree.file.original_filename\n \trespond_to do |format|\n \t\tif @tree.save\n\t\t \tnodes = Node.new\n \t \t\tvariaveis = nodes.extract_variables(@nome_arquivo,@numero_da_linha[:numero_de_variaveis]+1,@numero_da_linha[:test_mode]-1)\n \t \t\tnodes.extract_tree(@nome_arquivo,@numero_da_linha[:classifier_model]+5,@numero_da_linha[:numero_de_folhas]-2,variaveis,@tree.id)\n\t\t\t### adicionar a migracao que tira o autoincremt da buceta da tabela de nodes\n\t\t\t### adicionar um numero prefixo que não vá dar problema e resa muleke\n\t\t\ti= 0\n \t\t\tformat.html { redirect_to @tree, notice: 'Arquivo Adicionado com sucesso.' }\n \t\t\tformat.json { render :show, status: :created, location: @tree }\n \t\telse\n \t\t\tformat.html { render :new }\n \t\t\tformat.json { render json: @tree.errors, status: :unprocessable_entity }\n \t\tend\n \tend\n end",
"def build_hash_tree(filenames)\n files_tree = filenames.inject({}) { |h, i| t = h; i.split(\"/\").each { |n| t[n] ||= {}; t = t[n] }; h }\nend",
"def file_structure\n #@root_file = \"C:/App_factory/app_factory\"\n #@root_file = \"C:/Documents and Settings/Luxolo Matoti/My Documents/Exercises\"\n @root_file = \"C:/reports_yml\"\n #@root_file = \"C:/current projects/Kromco mes\"\n #@root_file = \"C:/Documents and Settings/Luxolo Matoti/My Documents/My Pictures\"\n\n#_______________________________________________________________\n tree_builder = ReportTreeBuilder.new\n @tree = tree_builder.build_tree(@root_file) # Store in session state to rebuild location of selected file\n session[:tree] = @tree\n#________________________________________________________________\n\n render :inline => %{\n <% @content_header_caption = \"'#{@root_file}'\" %>\n <% @tree_script = build_file_structure_form(@tree,@tree[0].values[0]) %>\n }, :layout => 'tree'\n end",
"def characterize(save: true)\n new_file = original_file.new(file_characterization_attributes.to_h)\n @file_node.file_metadata = @file_node.file_metadata.select { |x| x.id != new_file.id } + [new_file]\n @persister.save(resource: @file_node) if save\n @file_node\n end",
"def save_level\n File.open(@file_name, 'w') do |file|\n @blocks_array.each do |block|\n new_block = Block.new block.relative_position\n puts new_block.to_s\n end\n end\n end",
"def export_nodes\n existing_hiera = Dir.glob(Path.named_path([:hiera, '*'], @provider_dir))\n existing_files = Dir.glob(Path.named_path([:node_files_dir, '*'], @provider_dir))\n updated_hiera = []\n updated_files = []\n self.each_node do |node|\n filepath = Path.named_path([:node_files_dir, node.name], @provider_dir)\n updated_files << filepath\n hierapath = Path.named_path([:hiera, node.name], @provider_dir)\n updated_hiera << hierapath\n Util::write_file!(hierapath, node.dump)\n end\n (existing_hiera - updated_hiera).each do |filepath|\n Util::remove_file!(filepath)\n end\n (existing_files - updated_files).each do |filepath|\n Util::remove_directory!(filepath)\n end\n end",
"def writeToFile(fileName)\n #N Without this, the user would not have feedback that the content tree is being written to the named file\n puts \"Writing content tree to file #{fileName} ...\"\n #N Without this, the named file cannot be written to\n File.open(fileName, \"w\") do |outFile|\n #N Without this, the lines of information for the content tree will not be written to the open file\n writeLinesToFile(outFile)\n end\n end",
"def upload\n \tset_up_instances_variable\n \tuploaded_io = @tree.file\n \t@nome_arquivo = Rails.root.join('public', 'uploads', uploaded_io.original_filename)\n \tFile.open(Rails.root.join('public', 'uploads', uploaded_io.original_filename), 'wb') do |file|\n \t\tfile.write(uploaded_io.read)\n \tend\n \tler_texto @nome_arquivo\n end",
"def on_postbuild(src_tree, dst_tree, converter)\n current_branch = @git_itf.current_branch\n\n dst_tree.traverse_preorder do |level, dst_node|\n unless dst_node.leaf?\n dst_node.data = DataDelegator.new if dst_node.data.nil?\n dst_node.data.add(FileHistory.new(current_branch))\n next\n end\n\n src_node = dst_node.data.src_node\n next unless src_node.pathname.exist?\n\n # Get the commit history of the doc as an Array of entries\n file_log = FileHistory.new(current_branch)\n @git_itf.file_log(src_node.pathname.to_s).each do |log_entry|\n file_log.history << FileHistory::LogEntry.new(\n log_entry[\"date\"],\n log_entry[\"author\"],\n log_entry[\"message\"],\n log_entry[\"sha\"]\n )\n end\n dst_node.data.add(file_log)\n end\n end",
"def save_file \n Grit.debug = true\n contents = params[:contents]\n message = params[:commit_message]\n @node = Node.new(:name => params[:name], :git_repo_id => params[:git_repo_id], :git_repo_path => params[:git_repo_path])\n save_file_to_disk(contents, @node.abspath)\n stage_and_commit_file(@node.repo_base_path, @node.git_repo_path, message)\n flash[:notice] = \"Created New Version\"\n render :action => :file\n end",
"def bust(out: nil, preserve_tree: false, preserve_original: true)\n FileUtils.mkdir_p(out) if out\n\n @map = @files.each_with_object({}) do |f, result|\n hash = Digest::MD5.hexdigest File.read f\n basename = File.basename f\n dirname = File.dirname f\n new_name = hash[0...6] + \"_\" + basename\n\n destination = out ? out : dirname\n\n if preserve_tree && destination\n dirname = out ? path_diff(dirname, out) : dirname\n destination = File.join(out, dirname)\n FileUtils.mkdir_p(destination)\n end\n \n # TODO: This will remove a hashed file if it follows the format of\n # 6letters_anything.css\n rm_busted(destination)\n\n FileUtils.cp f, File.join(destination, new_name)\n result[basename] = new_name\n result\n end\n\n FileUtils.rm(@files) if (not preserve_original)\n\n return self\n end",
"def save_attached_files; end",
"def save_attached_files; end",
"def file_tree(root, tree_contents)\n set_pwd = nil\n tree_contents.each do |tree_entry|\n if tree_entry.start_with?('pwd:')\n raise 'Already have a pwd selected' if set_pwd\n tree_entry = tree_entry.sub(/^pwd:/, '')\n raise \"#{tree_entry} is not a directory entry (must end with /), can't use as pwd\" unless tree_entry.end_with?('/')\n set_pwd = true # Set later\n end\n\n # Avoid a simple mistake\n tree_entry = tree_entry[1..-1] if tree_entry[0] == '/'\n\n path = File.absolute_path(tree_entry, root)\n set_pwd = path if set_pwd == true\n\n if tree_entry.end_with?('/')\n FileUtils.mkdir_p(path)\n else\n FileUtils.mkdir_p(File.dirname(path))\n content = if REQUIRABLE_EXTENSIONS[File.extname(path)] == :native_extension\n File.read(SAMPLE_NATIVE_LIB)\n else\n <<-RUBY\n $last_test_tree_file_executed = #{tree_entry.inspect}\n RUBY\n end\n File.write(path, content)\n end\n end\n\n Dir.chdir(set_pwd || '.')\n end",
"def characterize(save: true)\n persister.save(resource: @file_node) if save\n @file_node\n end",
"def store_entries(entries)\n path_checksums = {}\n entries.each do |entry|\n path_checksums[entry.path] = entry.sha256 if entry.sha256.present?\n store_entry entry\n end\n store_checksums path_checksums\n end",
"def file_set_append\n # Append the array of file metadata values to any FileSets with new FileNodes being appended\n parent.file_metadata += file_nodes\n file_nodes\n end",
"def before_save\r\n\t\t\tself.name ||= ''\r\n\t\t\tself.filename ||= self.name.downcase.gsub(/[^a-z0-9]+/, '-')\r\n\r\n# We're doing this manually in the below migration code\r\n#\t\t\tif self.parent.nil?\r\n#\t\t\t\tself.path = ''\r\n#\t\t\telsif self.parent.path.empty?\r\n#\t\t\t\tself.path = filename\r\n#\t\t\telse\r\n#\t\t\t\tself.path = self.parent.path + '/' + self.filename\r\n#\t\t\tend\r\n\r\n\t\t\tif self.sequence.nil? || self.sequence.zero?\r\n\t\t\t\tsiblings = Category.count(:id, :conditions => list_scope_condition)\r\n\t\t\t\tself.sequence = siblings + 1\r\n\t\t\tend\r\n\t\tend",
"def save_and_close( filename = clean_name )\n result.parent.export filename\n end",
"def getContentTree\n #N Without this we won't have timestamp and the map of file hashes used to efficiently determine the hash of a file which hasn't been modified after the timestamp\n cachedTimeAndMapOfHashes = getCachedContentTreeMapOfHashes\n #N Without this we won't have the timestamp to compare against file modification times\n cachedTime = cachedTimeAndMapOfHashes[0]\n #N Without this we won't have the map of file hashes\n cachedMapOfHashes = cachedTimeAndMapOfHashes[1]\n #N Without this we won't have an empty content tree which can be populated with data describing the files and directories within the base directory\n contentTree = ContentTree.new()\n #N Without this we won't have a record of a time which precedes the recording of directories, files and hashes (which can be used when this content tree is used as a cached for data when constructing some future content tree)\n contentTree.time = Time.now.utc\n #N Without this, we won't record information about all sub-directories within this content tree\n for subDir in @baseDirectory.subDirs\n #N Without this, this sub-directory won't be recorded in the content tree\n contentTree.addDir(subDir.relativePath)\n end\n #N Without this, we won't record information about the names and contents of all files within this content tree\n for file in @baseDirectory.allFiles\n #N Without this, we won't know the digest of this file (if we happen to have it) from the cached content tree\n cachedDigest = cachedMapOfHashes[file.relativePath]\n #N Without this check, we would assume that the cached digest applies to the current file, even if one wasn't available, or if the file has been modified since the time when the cached value was determined.\n # (Extra note: just checking the file's mtime is not a perfect check, because a file can \"change\" when actually it or one of it's enclosing sub-directories has been renamed, which might not reset the mtime value for the file itself.)\n if cachedTime and cachedDigest and File.stat(file.fullPath).mtime < cachedTime\n #N Without this, the digest won't be recorded from the cached digest in those cases where we know the file hasn't changed\n digest = cachedDigest\n else\n #N Without this, a new digest won't be determined from the calculated hash of the file's actual contents\n digest = hashClass.file(file.fullPath).hexdigest\n end\n #N Without this, information about this file won't be added to the content tree\n contentTree.addFile(file.relativePath, digest)\n end\n #N Without this, the files and directories in the content tree might be listed in some indeterminate order\n contentTree.sort!\n #N Without this check, a new version of the cached content file will attempt to be written, even when no name has been specified for the cached content file\n if cachedContentFile != nil\n #N Without this, a new version of the cached content file (ready to be used next time) won't be created\n contentTree.writeToFile(cachedContentFile)\n end\n return contentTree\n end",
"def print_to_file\n #f = File.new(\"#{Dir.pwd}/tmp/geoname_tree.txt\", \"wb\")\n File.open(\"geoname_tree.txt\", 'w') do |f|\n nodes.keys.each do |id|\n ts = tree_numbers(id).join(\"|\")\n f.write(\"#{id}|#{ts}\")\n f.write(\"\\n\")\n puts \"#{id}|#{ts}\"\n end\n end\n end",
"def cleanup(paths)\n item = path_tree.descend(paths)\n item.cleanup \n save_path_tree\n # print what happened here\n print_depth item\n end",
"def recurse_and_hash_tree(node)\n\n ## exit program if given a bunk file/dir\n print_and_exit \"given a bunk file/node\" unless File.exist? node\n\n ## if we have a file then return it's hash\n return Digest::MD5.hexdigest( node + File.read(node) ) if File.file? node\n\n ## we should have a directory now. exit otherwise...\n print_and_exit \"is there a strange device in this dir?\" unless File.directory? node\n\n ## recurse through each element in the directory and remember their hashes\n children_hash = \"\"\n Dir.glob(File.join node, '*' ) { |element| children_hash << recurse_and_hash_tree(element) }\n \n ## return the mashed up hash\n return Digest::MD5.hexdigest( node + children_hash ) \n\n end",
"def save_to(path); end",
"def save\n on_each_node :save\n end",
"def getFile(tree, name, path = '')\n blob = nil\n\n tree.each_blob do |file|\n blob = file if file[:name] == name[/[^\\/]*/]\n blob[:name] = path + blob[:name]\n end\n\n if blob.nil?\n tree.each_tree do |subtree|\n if subtree[:name] == name[/[^\\/]*/]\n path += name.slice! name[/[^\\/]*/]\n name[0] = ''\n return getFile($repo.lookup(subtree[:oid]), name, path + '/')\n end\n end\n end\n\n return blob\nend",
"def writeEntry(bs)\n return if not @dirty\n cluster = @parentCluster; offset = @parentOffset\n buf = bs.getCluster(cluster)\n if @lfn_ents\n @lfn_ents.each {|ent|\n buf[offset...(offset + DIR_ENT_SIZE)] = BinaryStruct.encode(ent, DIR_ENT_LFN)\n offset += DIR_ENT_SIZE\n if offset >= bs.bytesPerCluster\n bs.putCluster(cluster, buf)\n cluster, buf = bs.getNextCluster(cluster)\n offset = 0\n end\n }\n end\n buf[offset...(offset + DIR_ENT_SIZE)] = BinaryStruct.encode(@dir_ent, DIR_ENT_SFN)\n bs.putCluster(cluster, buf)\n @dirty = false\n end",
"def commit\n # Compose changes array\n @changes=Array.new\n @folders.each do |key|\n @changes.push({ :name => FOLDERS_BASE+'\\\\'+key[:name], :value => key[:value] })\n end\n w=WinReg.new(@file,@debug)\n w.write_keys(@changes)\n end",
"def save(record)\n track = MyBiaDJ::Table(:files).create(:name => name, :path => relative_path)\n track.add_parent(record)\n track\n end",
"def store(recursive=false)\n files_to_store = new_files(recursive)\n files_to_store.each do |filename|\n file = File.new(filename)\n store_file(file, filename)\n end\n end",
"def save\n return if File.exists?(file)\n\n # Create parent directories\n FileUtils.mkdir_p(File.dirname(file))\n\n File.open(file, \"w\") do |f|\n f.write(compressed_contents)\n end\n\n puts \"Wrote blob #{file}\"\n end",
"def hier_graph_create(filename)\n @@name_id = Hash.new \n ### Making the name of the file from the parameter filename \n newfilename= make_filename(filename) \n ######################################################## \n\n ## Hierarchical Hash -- where the module are connected based on the instantiation\n load_cycloHash() \n \n\n @hierHash=Hash.new\n @block.each do|key,value|\n @@name_id[value.name]= value.id \n a=[]\n value.each_instance(){|y| a.push(y)}\n b = Array.new\n a.each {|val| if(@block.has_key?(val)) then b.push(val) end}\n @hierHash[key] = b.uniq\n end # end of @lock.each do....\n xArr = Array.new\n @hierHash.each {|key, value|\n if (value.length > 0) then \n xArr.concat(value) \n end \n }\n xArr.each{|key| \n if (@hierHash.has_key?(key)) then \n tmp =Array.new\n tmp = @hierHash[key]\n if (tmp.length === 0) then\n @hierHash.delete(key) \n end\n end \n }\n\n write_file(newfilename) ## Makes directed graph that must be called by dot\n @@name_id.each{|k,v| print k, \": \",v, \"\\n\"}\n end",
"def build_tree tree_root=nil\n tree_root ||= self.tree_root\n Dir.mkdir(tree_root) unless File.directory?(tree_root)\n Dir.chdir(tree_root) do\n self.files.each do |entry|\n visit_tree entry do |type, name|\n case type\n when :file\n FileUtils.touch(name)\n when :directory\n Dir.mkdir(name)\n else\n throw \"BAD VISIT TREE TYPE. #{type}\"\n end\n end\n end\n end\n end",
"def save!\n File.open(@config[\"state_file\"], \"r\") do |fl|\n fl.flock(File::LOCK_EX)\n\n sequence = (@state.key?(\"sequence\") ? @state[\"sequence\"] + 1 : 0)\n data_file = @config[\"data_dir\"] + format(\"/%03d/%03d/%03d.osm.gz\", sequence / 1000000, (sequence / 1000) % 1000, (sequence % 1000))\n tmp_state = @config[\"state_file\"] + \".tmp\"\n tmp_data = \"/tmp/changeset_data.osm.tmp\"\n # try and write the files to tmp locations and then\n # move them into place later, to avoid in-progress\n # clashes, or people seeing incomplete files.\n begin\n FileUtils.mkdir_p(File.dirname(data_file))\n Zlib::GzipWriter.open(tmp_data) do |fh|\n fh.write(changeset_dump(open_changesets))\n end\n @state[\"sequence\"] = sequence\n File.open(tmp_state, \"w\") do |fh|\n fh.write(YAML.dump(@state))\n end\n\n # sanity check: the files we're moving into place\n # should be non-empty.\n raise \"Temporary gzip file should exist, but doesn't.\" unless File.exist?(tmp_data)\n raise \"Temporary state file should exist, but doesn't.\" unless File.exist?(tmp_state)\n raise \"Temporary gzip file should be non-empty, but isn't.\" if File.zero?(tmp_data)\n raise \"Temporary state file should be non-empty, but isn't.\" if File.zero?(tmp_state)\n\n FileUtils.mv(tmp_data, data_file)\n FileUtils.mv(tmp_state, @config[\"state_file\"])\n fl.flock(File::LOCK_UN)\n\n rescue\n STDERR.puts(\"Error! Couldn't update state.\")\n fl.flock(File::LOCK_UN)\n raise\n end\n end\n end",
"def save_branch\n @@save_branch << @@obj.current_branch\n end",
"def save_commit_info(sha)\n unless File.directory?(File.dirname(commit_info_file))\n FileUtils.mkdir_p(File.dirname(commit_info_file))\n end\n File.write(commit_info_file, sha)\n end",
"def store\n @files.each do |file, lines|\n text = \"\"\n dirty = false\n lines.each do |l|\n if l.is_a?(Section)\n dirty ||= l.dirty?\n text << l.format\n l.mark_clean\n else\n text << l\n end\n end\n if dirty\n Puppet::Util::FileType.filetype(:flat).new(file).write(text)\n return file\n end\n end\n end",
"def properties_subfolders_docs_documentnames_for_move_to_function(mf,af,pid)\n master_folders = Folder.find(:all,:conditions=> [\"portfolio_id = ? and parent_id = ? and is_deleted = ?\",pid,mf.id,false])\n master_files = Document.find(:all,:conditions=> [\"folder_id = ? and is_deleted = ?\",mf.id,false])\n master_folders.each do |mfldr|\n fol = Folder.new\n fol.attributes = mfldr.attributes\n fol.parent_id = af.id\n fol.user_id = current_user.id\n fol.real_estate_property_id = af.real_estate_property_id\n fol.portfolio_id = af.portfolio_id\n fol.save\n properties_subfolders_docs_documentnames_for_move_to_function(mfldr,fol,pid)\n end\n master_files.each do |fl|\n path =\"#{Rails.root.to_s}/public\"+fl.public_filename.to_s\n temfile = Tempfile.new(fl.filename)\n begin\n temfile.write(File.open(path).read)\n temfile.flush\n upload_data = ActionDispatch::Http::UploadedFile.new({:filename=>fl.filename,:type=>fl.content_type, :tempfile=>temfile})\n d= Document.new\n d.attributes = fl.attributes\n d.uploaded_data = upload_data\n d.user_id = current_user.id\n d.folder_id = af.id\n d.real_estate_property_id = af.real_estate_property_id\n d.save\n ensure\n temfile.close\n temfile.unlink\n end\n @task_and_variance_task = false\n @loop =1\n end\nend",
"def save_nodes\n subject.save if subject\n predicate.save if predicate\n object.save if object\n# modifier.save if modifier\n# user.save if user\n# context.save if context\n end",
"def save_moves file, tree, player\n # If we have -1, -1 as coordinates, which we just skip\n if tree['x'] != -1 and tree['y'] != -1 then\n # color and coordinates\n file.write \";#{player}[#{sgf_board_position(tree)}]\"\n\n # the other player is to play next\n player = invert_color(player)\n\n # do we have any move comments?\n comment = tree['text']\n\n # Is this the answer (right or wrong) already?\n if tree['correct_answer'] == true then\n comment = \"Correct.\\n#{comment}\"\n elsif tree['wrong_answer'] == true then\n comment = \"Wrong.\\n#{comment}\"\n end\n\n file.write \"C[#{comment.escape_for_sgf}]\" unless comment.nil? or comment.empty?\n end\n\n # do we have any marks?\n unless tree['marks'].nil? or tree['marks'].size == 0\n tree['marks'].each { |mark|\n position = sgf_board_position mark\n type = mark['marks']\n\n file.write \"CR[#{position}]\" unless type['circle'].nil?\n file.write \"TR[#{position}]\" unless type['triangle'].nil?\n file.write \"MA[#{position}]\" unless type['cross'].nil?\n file.write \"SQ[#{position}]\" unless type['square'].nil?\n file.write \"LB[#{position}:#{type['letter']}]\" unless type['letter'].nil?\n }\n end\n\n # do we have follow-ups?\n unless tree['branches'].nil? or tree['branches'].size == 0\n if tree['branches'].size > 1 then\n # multiple possible moves\n tree['branches'].each { |branch|\n file.write '('\n save_moves file, branch, player\n file.write \")\\n\"\n }\n\n elsif tree['branches'].size == 1 then\n # a single follow-up move\n save_moves file, tree['branches'][0], player\n end\n end\n end",
"def make_directory_tree\n project_tmp = \"/tmp/#{@package_name}\"\n @scratch = \"#{project_tmp}/#{@title}\"\n @working_tree = {\n 'scripts' => \"#{@scratch}/scripts\",\n 'resources' => \"#{@scratch}/resources\",\n 'working' => \"#{@scratch}/root\",\n 'payload' => \"#{@scratch}/payload\",\n }\n puts \"Cleaning Tree: #{project_tmp}\"\n FileUtils.rm_rf(project_tmp)\n @working_tree.each do |key,val|\n puts \"Creating: #{val}\"\n FileUtils.mkdir_p(val)\n end\n File.open(\"#{@scratch}/#{'prototype.plist'}\", \"w+\") do |f|\n f.write(ERB.new(File.read('tasks/templates/prototype.plist.erb')).result())\n end\n File.open(\"#{@working_tree[\"scripts\"]}/preflight\", \"w+\") do |f|\n f.write(ERB.new(File.read('ext/osx/preflight.erb')).result())\n end\nend",
"def save_to_git\n FileUtils.makedirs File.dirname(blob_path(false)) unless File.exists? File.dirname(blob_path(false))\n File.open(blob_path(false), 'w') do |file|\n file.write to_yaml_git\n end\n if (repository.tree/blob_path).nil?\n add_blob\n end\n end",
"def after_save\n super rescue nil\n unless (@tempfile_path.nil? || @tempfile_path.empty?)\n stash_path = file_root(true)\n D::mkdir(stash_path) unless F::exist?(stash_path)\n @tempfile_path.each do |k,v|\n url = file_path(k, nil, true)\n destroy_files_for(k, url) # Destroy previously saved files\n FU.move(v, url) # Save the new one\n FU.chmod(0777, url)\n after_stash(k)\n end\n # Reset in case we access two times the entry in the same session\n # Like setting an attachment and destroying it in a row\n # Dummy ex: Model.create(:img => file).update(:img => nil)\n @tempfile_path = nil\n end\n end",
"def file_list tree_root=nil\n tree_root ||= self.tree_root\n file_list = []\n current_dir = tree_root\n visit_entries self.files do |type, name|\n case type\n when :directory\n current_dir = current_dir + \"/\" + name\n when :file\n file_list.push(current_dir + \"/\" + name)\n else\n throw \"BAD VISIT TYREE TYPE. #{type}\"\n end\n end\n file_list\n end",
"def create_new_tree_with_blobs(oauth_token, file_information, sha_base_tree)\n client = Octokit::Client.new(access_token: oauth_token)\n blob_information = []\n file_information.each do |file|\n # This mode property on this hash represents the file mode for a GitHub tree. \n # The mode is 100644 for a file blob. See https://developer.github.com/v3/git/trees/ for more information\n blob_information << { path: file[:path],\n mode: '100644',\n type: 'blob',\n sha: file[:blob_sha] }\n end\n client.create_tree(full_repo_name, blob_information, base_tree: sha_base_tree)[:sha]\n end",
"def save\n entries = []\n entries << '#'\n entries << '# This file is managed by Chef, using the hostsfile cookbook.'\n entries << '# Editing this file by hand is highly discouraged!'\n entries << '#'\n entries << '# Comments containing an @ sign should not be modified or else'\n entries << '# hostsfile will be unable to guarantee relative priority in'\n entries << '# future Chef runs!'\n entries << '#'\n entries << ''\n entries += unique_entries.map(&:to_line)\n entries << ''\n\n contents = entries.join(\"\\n\")\n contents_sha = Digest::SHA512.hexdigest(contents)\n\n # Only write out the file if the contents have changed...\n if contents_sha != current_sha\n ::File.open(hostsfile_path, 'w') do |f|\n f.write(contents)\n end\n end\n end",
"def sync_child_pages\n children.each{ |p| p.save! } if full_path_changed?\n end",
"def save_files\n @law_h = [:law, :link, :section]\n @case_h = [:case, :link, :date]\n\n # Parse into hashes\n @single_matches = @single_matches-@double_matches\n case_hash = @double_matches.map{|i| {@case_h[0] => i[0], @case_h[1] => i[1], @case_h[2] => i[2]}}\n law_hash = @single_matches.map{|i| {@law_h[0] => i[0], @law_h[1] => i[1], @law_h[2] => i[2]}}\n \n # Write files\n write_files(case_hash, law_hash)\n end",
"def writeAll(filename)\n out = File.new(filename, \"w\")\n @names.keys.sort.each {|num|\n out.printf(\"%d\\t%d\\t%s\\t%s\\n\", num, @parent[num], @names[num],\n @rank[num]) \n }\n out.close\n end",
"def browse_tree(tree = nil, cur = nil)\n return [[], []] if barerepo.empty?\n tree ||= barerepo.head.target.tree\n images = []\n directories = []\n tree.each do |item|\n next if item[:name][0] == '.'\n dest = cur.nil? ? item[:name] : File.join(cur, item[:name])\n if item[:type] == :blob\n images.push({\n data: barerepo.read(item[:oid]).data,\n dest: dest, name: item[:name]\n })\n else\n directories.push({\n dest: dest, name: item[:name]\n })\n end\n end\n [images, directories]\n end",
"def save\n all_files.each{ |file| parse_and_save(file) }\n end",
"def cache_ancestry\n self.names_depth_cache = path.map(&:name).join('/')\n end",
"def save_hashes_for_write\n \n end",
"def export\n @tree\n end",
"def expand_tree(path)\n names = path.split('/')\n names.pop\n parent = work_tree\n names.each do |name|\n object = parent[name]\n break if !object\n if object.type == :blob\n parent.move(name, name + CONTENT_EXT)\n break\n end\n parent = object\n end\n end",
"def generate_class_tree\n debug_msg \"Generating class tree\"\n tree = generate_class_tree_level\n debug_msg \" writing class tree to %s\" % TREE_FILE\n File.open(TREE_FILE, \"w\", 0644) do |f|\n f.write('var tree = '); f.write(tree.to_json(:max_nesting => 0))\n end unless $dryrun\nend",
"def tree\n read_repo\n if @branches.count < 1\n render :template => 'repositories/newrepo'\n return\n end\n\n @files = @repository.files(@branch, @path)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @repository }\n end\n end",
"def write_tree outfile\n writer = Bio::PhyloXML::Writer.new(outfile)\n writer.write(@tree)\n end",
"def attach_files\n @parent = Work.find_by_friendlier_id!(params[:parent_id])\n authorize! :update, @parent\n\n current_position = @parent.members.maximum(:position) || 0\n\n files_params = (params[:cached_files] || []).\n collect { |s| JSON.parse(s) }.\n sort_by { |h| h && h.dig(\"metadata\", \"filename\")}\n\n files_params.each do |file_data|\n asset = Asset.new()\n\n if derivative_storage_type = params.dig(:storage_type_for, file_data[\"id\"])\n asset.derivative_storage_type = derivative_storage_type\n end\n\n asset.position = (current_position += 1)\n asset.parent_id = @parent.id\n asset.file = file_data\n asset.title = (asset.file&.original_filename || \"Untitled\")\n asset.published = @parent.published\n asset.save!\n end\n\n if @parent.representative_id == nil\n @parent.update(representative: @parent.members.order(:position).first)\n end\n\n redirect_to admin_work_path(@parent.friendlier_id, anchor: \"nav-members\")\n end",
"def store obj, msg\n Dir.chdir(working_dir) do\n dirname = File.dirname(obj.path)\n FileUtils.mkdir_p(dirname) unless File.directory?(dirname)\n File.open(obj.path, 'w'){ |f| f.write(obj.content) }\n add(obj.path)\n end\n commit_index(msg)\n end",
"def save_locally(dir)\n FileUtils.mkdir_p(dir) unless File.exists? dir\n \n # remove HTML BASE tag if it exists\n @contents.xpath('//base').each { |t| t.remove }\n # remove head tag\n @contents.xpath('//head').each { |t| t.remove }\n # remove link tags\n @contents.xpath('//link').each { |t| t.remove }\n # remove script tags\n @contents.xpath('//script').each { |t| t.remove }\n # remove comments\n @contents.xpath('//comment()').each { |t| t.remove }\n # remove mediawiki meta tag\n @contents.xpath('//meta').each { |t| t.remove if t['name'] == \"generator\" }\n # remove sitesub h3 tag\n @contents.xpath('//h3').each { |t| t.remove if t['id'] == \"siteSub\" }\n\n # get lastmod/viewcount values\n @contents.xpath('//li').each do |t|\n if t['id'] == \"lastmod\"\n @lastmod = t.text.strip\n end\n if t['id'] == \"viewcount\"\n @viewcount = t.text.strip\n end\n end\n\n # remove unneeded divs\n @contents.xpath('//div').each do |t|\n t.remove if t['id'] == \"column-one\"\n t.remove if t['id'] == \"footer\"\n t.remove if t['id'] == \"catlinks\"\n t.remove if t['id'] == \"contentSub\"\n t.remove if t['id'] == \"jump-to-nav\"\n t.remove if t['class'] == \"printfooter\"\n t.remove if t['class'] == \"visualClear\"\n end\n\n if @main_page == true\n save_path = File.join(dir, \"index\")\n title = 'Dublin Core Metadata Initiative Media-Wiki Archive'\n else\n save_path = File.join(dir, File.basename(uri.to_s))\n title = File.basename(uri.to_s).gsub(\"_\", \" \")\n end\n save_path += '.html' if save_path !~ /\\.((html?)|(txt))$/\n File.open(save_path, 'w') { |f| f.write(\"<!DOCTYPE html>\\n<html>\\n<head>\\n<meta http-equiv=\\\"Content-Type\\\" content=\\\"text/html; charset=UTF-8\\\">\\n<meta http-equiv=\\\"Content-Language\\\" content=\\\"en-us\\\">\\n<title>#{title}</title>\\n</head>\\n<body>\\n<p><b>This is an archived MediaWiki page.</b><br />#{@lastmod}<br />#{@viewcount}</p>\\n#{@contents.xpath('//div[@id=\"bodyContent\"]').to_html}\\n</body>\\n</html>\") }\n # File.open(save_path, 'w') { |f| f.write(\"---\\nlayout: page\\ntitle: #{title}\\n---\\n\\n#{@contents.xpath('//div[@id=\"bodyContent\"]').to_html}\") }\n end",
"def sub_tree\n files = ProjectFile.where(directory_id: id)\n files = files.nil? ? [] : files \n\n files.sort{|x,y| \n if x.is_directory and not y.is_directory\n -1\n elsif not x.is_directory and y.is_directory\n 1\n else\n x.name <=> y.name\n end\n }\n end",
"def save(path = self.path)\n Ops.atomic_write(path) do |io|\n marshalled_package_sets = each_package_set.map do |v|\n Hash['package_set' => v.name,\n 'vcs' => v.vcs.to_hash,\n 'raw_local_dir' => v.raw_local_dir,\n 'user_local_dir' => v.user_local_dir]\n end\n marshalled_packages = each_package.map do |package_def|\n v = package_def.autobuild\n Hash['name' => v.name,\n 'type' => v.class.name,\n 'vcs' => package_def.vcs.to_hash,\n 'srcdir' => v.srcdir,\n 'importdir' => (v.importdir if v.respond_to?(:importdir)),\n 'builddir' => (v.builddir if v.respond_to?(:builddir)),\n 'logdir' => v.logdir,\n 'prefix' => v.prefix,\n 'dependencies' => v.dependencies]\n end\n io.write YAML.dump(marshalled_package_sets + marshalled_packages)\n end\n end",
"def expand_tree(path)\n names = path.split('/')\n names.pop\n parent = @git.root\n names.each do |name|\n object = parent[name]\n break if !object\n if object.type == :blob\n parent.move(name, name + CONTENT_EXT)\n break\n end\n parent = object\n end\n end",
"def display_saves\n Dir.children('./saves').each_with_index { |name, idx| puts \"#{idx}. #{name}\" }\nend",
"def config_write\n # Putting it in a format that zfm can also read and write\n f1 = File.expand_path(\"~/.cygnusinfo\")\n #f1 = File.expand_path(CONFIG_FILE)\n d = $used_dirs.join \":\"\n f = $visited_files.join \":\"\n File.open(f1, 'w+') do |f2| \n # use \"\\n\" for two lines of text \n f2.puts \"DIRS=\\\"#{d}\\\"\"\n f2.puts \"FILES=\\\"#{f}\\\"\"\n $bookmarks.each_pair { |k, val| \n f2.puts \"BM_#{k}=\\\"#{val}\\\"\"\n #f2.puts \"BOOKMARKS[\\\"#{k}\\\"]=\\\"#{val}\\\"\"\n }\n end\n $writing = $modified = false\nend",
"def tree_entry(commit)\n pathname = Pathname.new(path)\n tmp_entry = nil\n\n pathname.each_filename do |dir|\n if tmp_entry.nil?\n tmp_entry = commit.tree[dir]\n else\n tmp_entry = rugged.lookup(tmp_entry[:oid])\n return nil unless tmp_entry.type == :tree\n tmp_entry = tmp_entry[dir]\n end\n end\n\n tmp_entry\n end",
"def export_nodes(node_list=nil)\n updated_hiera = []\n updated_files = []\n existing_hiera = nil\n existing_files = nil\n\n unless node_list\n node_list = self.nodes\n existing_hiera = Dir.glob(Path.named_path([:hiera, '*'], @provider_dir))\n existing_files = Dir.glob(Path.named_path([:node_files_dir, '*'], @provider_dir))\n end\n\n node_list.each_node do |node|\n filepath = Path.named_path([:node_files_dir, node.name], @provider_dir)\n hierapath = Path.named_path([:hiera, node.name], @provider_dir)\n Util::write_file!(hierapath, node.dump_yaml)\n updated_files << filepath\n updated_hiera << hierapath\n end\n\n if @disabled_nodes\n # make disabled nodes appear as if they are still active\n @disabled_nodes.each_node do |node|\n updated_files << Path.named_path([:node_files_dir, node.name], @provider_dir)\n updated_hiera << Path.named_path([:hiera, node.name], @provider_dir)\n end\n end\n\n # remove files that are no longer needed\n if existing_hiera\n (existing_hiera - updated_hiera).each do |filepath|\n Util::remove_file!(filepath)\n end\n end\n if existing_files\n (existing_files - updated_files).each do |filepath|\n Util::remove_directory!(filepath)\n end\n end\n end",
"def saveRepositoryObject(objectName, toSave)\n\n #puts \"saveRepositoryObject : #{@DIR_NAME}#{@FILE_NAME}_Contents#{@@FS}\"\n if !File.exist? (\"#{@DIR_NAME}#{@FILE_NAME}_Contents#{@@FS}\")\n FileUtils.mkdir_p(\"#{@DIR_NAME}#{@FILE_NAME}_Contents#{@@FS}\")\n end\n saveFile(\"#{@DIR_NAME}#{@FILE_NAME}_Contents#{@@FS}#{objectName}.obj\", toSave)\n return \"#{@DIR_NAME}#{@FILE_NAME}_Contents#{@@FS}#{objectName}\"\n\n end",
"def rearrange\n rootpath = \"#{$paths.restore_path}/Student_Records_D20130520/Student_Records\"\n Dir.entries(rootpath).each{|entry|\n if !entry.gsub(/\\.|rb/,\"\").empty?\n Dir.chdir(\"#{rootpath}/#{entry}/SY_2012-2013\")\n if !File.directory?(\"#{rootpath}/#{entry}/SY_2012-2013/Withdrawal\")\n Dir.mkdir(\"#{rootpath}/#{entry}/SY_2012-2013/Withdrawal\")\n end\n Dir.glob('WD_**') do |file|\n #puts File.expand_path(file)\n oldpath = File.expand_path(file)\n FileUtils.mv(\"#{oldpath}\",\"#{rootpath}/#{entry}/SY_2012-2013/Withdrawal\")\n end\n end\n }\n end",
"def write\n make_parent_directory\n generate_file\n end",
"def traverse_nav_tree_and_convert_to_xml(node)\n \n # traverse subfolders, go deep\n if node_has_children(node)\n node.children.items.each do |child|\n traverse_nav_tree_and_convert_to_xml(child)\n end\n end\n \n return if node.nav_level == 0\n \n mod = node.dup\n\n link = node.link\n full_link = node.full_link\n \n mod.parent_link = parent_link = node.link[0..(link.rindex(\"/\") - 1)] if node.nav_level > 1\n \n if CONTENT_LINK_PREFIX && CONTENT_LINK_PREFIX.length > 0\n full_link = mod.full_link = \"/\" + CONTENT_LINK_PREFIX + node.full_link unless node.full_link.start_with?(\"/#{CONTENT_LINK_PREFIX}\")\n end\n\n \n mod.delete :source_path\n mod.delete :parent_path\n mod.delete :children\n\n\n #puts \"storing [#{mod.nav_level}][#{mod.nav_order}][#{mod.nav_type}] - #{mod.nav_title}\"\n case mod.nav_type \n \n when \"folder\"\n\t\t# do nothing for these\n when \"markdown\"\n metadata, markdown = parse_markdown_file(node.source_path)\n\t\t\n\t\tfilepath_markdown = node.source_path.dup\t\t\n\t\tfilepath_markdown += \".markdown\"\tunless filepath_markdown.end_with? (\".markdown\")\t\t\n\t\tmod.updated_at = Chronic.parse(File.mtime(filepath_markdown).to_s).utc.to_i\n\t\t\n mod.metadata = metadata if metadata\n mod.markdown = markdown\n \n\t\thtml = MarkdownRender::render(mod.markdown)\n\t\tdoc = Nokogiri::HTML(html) \n\t\txml = doc.css('body')[0].serialize #(save_with: 0)\n\t\txml.gsub!(/^<p><img /, \"<img \")\n\t\txml = Nokogiri::XML(xml)\n\t\tb = xml.at_css \"body\"\n\t\tb.name = \"doc\"\n\t\t\n File.open(\"#{filepath_markdown.gsub(/.markdown/, \".xml\")}\", 'w') { |f| xml.write_xml_to f }\n\n when \"folder+markdown\"\n metadata, markdown = parse_markdown_file(node.source_path)\n\t\t\n\t\tfilepath_markdown = node.source_path.dup\t\t\n\t\tfilepath_markdown += \".markdown\"\tunless filepath_markdown.end_with? (\".markdown\")\t\t\n\t\tmod.updated_at = Chronic.parse(File.mtime(filepath_markdown).to_s).utc.to_i\n\t\t\n mod.metadata = metadata if metadata\n mod.markdown = markdown\n\n\t\thtml = MarkdownRender::render(mod.markdown)\n\t\tdoc = Nokogiri::HTML(html)\n\t\txml = doc.css('body')[0].serialize #(save_with: 0)\n\t\txml.gsub!(/^<p><img /, \"<img \")\n\t\txml = Nokogiri::XML(xml)\n\n img_sizes = {\n \"40%\" => \"min\",\n \"50%\" => \"small\",\n \"65%\" => \"medium\",\n \"100%\" => \"full\",\n \"600px\" => \"large\"\n }\n \n img_sizes.each do |size,name|\n img = xml.at_css \"img[width=\\\"#{size}\\\"]\"\n img['size'] = name if img\n puts img.inspect if img\n end\n\n\t\tb = xml.at_css \"body\"\n\t\tb.name = \"doc\"\n\t\t\n File.open(\"#{filepath_markdown.gsub(/.markdown/, \".xml\")}\", 'w') { |f| xml.write_xml_to f }\n end\n \nend",
"def children\n c = file_log.children(file_node)\n c.map do |x|\n VersionedFile.new(@repo, @path, :file_id => x, :file_log => file_log)\n end \n end",
"def entries_to_dir entries, path\n if File.exists? path\n raise \"directory #{path} already exists\"\n else\n Dir.mkdir path\n end\n\n entries.each do |entry|\n e = entry.to_s\n\n new_filename = path + '/0x' + MD5.new(e).hexdigest[0,8] + '.atom'\n\n File.open(new_filename, 'w') { |f| f.write e }\n end\n end",
"def print_saves\n puts 'Current saves:'\n Dir.children(SAVE_FOLDER).each { |file| puts file.delete('.JSON') }\n end",
"def repo_all_commits_structures(repo_dir, commits_file, structures_dir)\n sdir = Pathname.new(Dir.pwd) + Pathname.new(structures_dir)\n base_dir = Pathname.new(repo_dir).basename.to_s\n FileUtils.mkdir_p(sdir + \"dir\")\n FileUtils.mkdir_p(sdir + \"dep\")\n lang = detect_language(repo_dir) # Detect programming language \n i = MCommits.new(commits_file).all_commits.size # Reverse order\n file_kenc = KeyEncoder.new\n make_temp_dir do |tmpdir|\n # Copy repo to temp folder\n FileUtils.cp_r repo_dir, tmpdir\n temp_repo_dir = tmpdir + \"/\" + base_dir\n \n chdir_return(temp_repo_dir) do\n keep_going = true\n while keep_going do\n i -= 1\n # Generate Directory Structure Graph\n puts \"Generating Dir Structure Graph\"\n directory_graph(\".\", \"%s/%d.txt\" % [(sdir+\"dir\").relative_path_from(Pathname.new Dir.pwd).to_s, i], file_kenc)\n\n key_count = file_kenc.key_count\n\n # Generate dependency graph if language is supported\n unless lang.nil?\n case lang\n when :ruby\n puts \"Generating Dependency Graph\"\n RubyFilesMatcher.new('.').dependency_graph_to_file(\"%s/%d.txt\" % [(sdir+\"dep\").relative_path_from(Pathname.new Dir.pwd).to_s, i], file_kenc)\n else\n puts \"Unsupported Programming Language\"\n end\n raise \"Dependency Graph is not supposed to generate more keys!\" if key_count != file_kenc.key_count\n end\n\n puts \"Rewinding...\"\n stdin, stdout, stderr = Open3.popen3(\"git reset --hard HEAD~1\")\n keep_going = false if stderr.readlines.length > 0 # While not getting \"...unknown revision or path not in the working tree...\"\n end\n end\n \n end\n raise \"Number of Commits Don't Match\" if i != 0\n file_kenc.to_file(sdir + \"file_key.txt\")\nend",
"def write_file_list\n if EventMachine.reactor_thread? || !@update_lock.locked?\n raise 'Should not write file list in reactor thread or without' \\\n ' the local list lock!'\n end\n\n FileUtils.mkdir_p config.config_dir\n @local_file_list.root['CID'] = SecureRandom.hex(12).upcase\n output = @local_file_list.to_s(:indent => true)\n Bzip2::Writer.open(local_file_list_path, 'wb') { |f| f << output }\n @share_size = nil\n\n output = Marshal.dump([@local_file_info, @shared_directories])\n File.open(cache_file_list_path, 'wb'){ |f| f << output }\n end",
"def tree(data_path, options = {})\n\t\t\t\tresult = \"\"\n\n\t\t\t\t# Unique hash\n\t\t\t\t@hash = Digest::SHA1.hexdigest(data_path.to_s)\n\n\t\t\t\t# Options\n\t\t\t\t@options = options.nil? ? {} : options\n\n\t\t\t\t# Clipboard\n\t\t\t\tif @options[:clipboard_attrs]\n\t\t\t\t\tclipboard = true\n\t\t\t\t\t@options[:clipboard_attrs] = [@options[:clipboard_attrs]] if !@options[:clipboard_attrs].is_a?(Array)\n\t\t\t\t\tclipboard_attrs_js = \"[\" + @options[:clipboard_attrs].map { |item| \"'#{item}'\" }.join(\",\") + \"]\"\n\t\t\t\telse\n\t\t\t\t\tclipboard = false\n\t\t\t\t\tclipboard_attrs_js = \"[]\"\n\t\t\t\tend\n\n\t\t\t\t# Actions\n\t\t\t\tif @options[:actions]\n\t\t\t\t\tactions_js = \"[\"\n\t\t\t\t\toptions[:actions].each do |key, action|\n\t\t\t\t\t\tactions_js += %{\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\turl: '#{action[:path] ? @path_resolver.resolve(action[:path], \":id\") : \"\"}',\n\t\t\t\t\t\t\t\ticon: '#{action[:icon]}',\n\t\t\t\t\t\t\t\tlabel: '#{action[:label]}',\n\t\t\t\t\t\t\t\tcollapsed: #{action[:collapsed] == true ? \"true\" : \"false\"},\n\t\t\t\t\t\t\t\tstyle: '#{action[:style] ? action[:style] : \"default\"}',\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}\n\t\t\t\t\tend\n\t\t\t\t\tactions_js += \"]\"\n\t\t\t\telse\n\t\t\t\t\tactions_js = \"[]\"\n\t\t\t\tend\n\n\t\t\t\t# Parent\n\t\t\t\tparent = (options[:parent] ? options[:parent] : nil)\n\n\t\t\t\t# Save state\n\t\t\t\tsave_state = (options[:save_state] ? options[:save_state] : :simple)\n\n\t\t\t\t# Application JS\n\t\t\t\tresult += @template.javascript_tag(%{\n\t\t\t\t\tvar rug_tree_#{@hash} = null;\n\t\t\t\t\t$(document).ready(function() {\n\t\t\t\t\t\trug_tree_#{@hash} = new RugTree('#{@hash}', {\n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t// Model\n\t\t\t\t\t\t\tmodel: 'node',\n\n\t\t\t\t\t\t\t// State\n\t\t\t\t\t\t\tsaveState: '#{save_state.to_s}',\n\n\t\t\t\t\t\t\t// Parent element\n\t\t\t\t\t\t\tparent: '#{parent.to_s}',\n\n\t\t\t\t\t\t\t// Icons\n\t\t\t\t\t\t\tclosedIcon: '#{@icon_builder.render(@options[:closed_icon] ? @options[:closed_icon] : \"chevron-right\")}',\n\t\t\t\t\t\t\topenedIcon: '#{@icon_builder.render(@options[:opened_icon] ? @options[:opened_icon] : \"chevron-down\")}',\n\n\t\t\t\t\t\t\t// Show\n\t\t\t\t\t\t\tshow: #{check_show(@options) ? 'true' : 'false'},\n\t\t\t\t\t\t\tshowEvent: '#{@options[:show_event] && @options[:show_event].to_sym == :double_click ? \"dblclick\" : \"click\"}',\n\t\t\t\t\t\t\tshowUrl: '#{@path_resolver.resolve(@options[:paths][:show], \":id\")}',\n\n\t\t\t\t\t\t\t// Create\n\t\t\t\t\t\t\tcreate: #{check_create(@options) ? 'true' : 'false'}, \n\t\t\t\t\t\t\tcreateUrl: '#{@path_resolver.resolve(@options[:paths][:create])}',\n\t\t\t\t\t\t\tcreateIcon: '#{@icon_builder.render(@options[:update_icon] ? @options[:update_icon] : \"plus\")}',\n\t\t\t\t\t\t\tcreateLabel: '#{I18n.t(\"general.action.create_child\").upcase_first}',\n\t\t\t\t\t\t\tcreateActionCollapsed: #{@options[:create_action_collapsed] == true ? 'true' : 'false'}, \n\t\t\t\t\t\t\tcreateSuccessMessage: '#{I18n.t(\"general.messages.create.success\")}',\n\n\t\t\t\t\t\t\t// Update\n\t\t\t\t\t\t\tupdate: #{check_update(@options) ? 'true' : 'false'}, \n\t\t\t\t\t\t\tupdateUrl: '#{@path_resolver.resolve(@options[:paths][:update], \":id\")}', \n\t\t\t\t\t\t\tupdateIcon: '#{@icon_builder.render(@options[:update_icon] ? @options[:update_icon] : \"pencil\")}',\n\t\t\t\t\t\t\tupdateLabel: '#{I18n.t(\"general.action.update\").upcase_first}',\n\t\t\t\t\t\t\tupdateActionCollapsed: #{@options[:update_action_collapsed] == true ? 'true' : 'false'}, \n\t\t\t\t\t\t\tupdateSuccessMessage: '#{I18n.t(\"general.messages.create.success\")}',\n\n\t\t\t\t\t\t\t// Destroy\n\t\t\t\t\t\t\tdestroy: #{check_destroy(@options) ? 'true' : 'false'}, \n\t\t\t\t\t\t\tdestroyUrl: '#{@path_resolver.resolve(@options[:paths][:destroy], \":id\")}', \n\t\t\t\t\t\t\tdestroyIcon: '#{@icon_builder.render(@options[:update_icon] ? @options[:update_icon] : \"trash\")}',\n\t\t\t\t\t\t\tdestroyLabel: '#{I18n.t(\"general.action.destroy\").upcase_first}',\n\t\t\t\t\t\t\tdestroyActionCollapsed: #{@options[:destroy_action_collapsed] == true ? 'true' : 'false'}, \n\t\t\t\t\t\t\tdestroyConfirmMessage: '#{I18n.t(\"general.are_you_sure\")}',\n\t\t\t\t\t\t\tdestroySuccessMessage: '#{I18n.t(\"general.messages.destroy.success\")}',\n\n\t\t\t\t\t\t\t// Moving\n\t\t\t\t\t\t\tmoving: #{check_moving(@options) ? 'true' : 'false'},\n\t\t\t\t\t\t\tmovingUrl: '#{@path_resolver.resolve(@options[:paths][:move], \":id\", \":relation\", \":destination_id\")}',\n\t\t\t\t\t\t\n\t\t\t\t\t\t\t// Type\n\t\t\t\t\t\t\ttypeIconTemplate: '#{@icon_builder.render(\":icon\", class: \"jqtree-icon\")}',\n\t\t\t\t\t\t\ttypeIconAttr: '#{@options[:type_icon_attr]}',\n\n\t\t\t\t\t\t\t// Actions\n\t\t\t\t\t\t\tactions: #{actions_js},\n\t\t\t\t\t\t\tactionsIconTemplate: '#{@icon_builder.render(\":icon\")}',\n\n\t\t\t\t\t\t\t// Clipboard\n\t\t\t\t\t\t\tclipboard: #{clipboard ? 'true' : 'false'},\n\t\t\t\t\t\t\tclipboardIcon: '#{@icon_builder.render(@options[:clipboard_icon] ? @options[:clipboard_icon] : \"clipboard\")}',\n\t\t\t\t\t\t\tclipboardTemplate: \"#{clipboard ? (@options[:clipboard_template] ? @options[:clipboard_template].gsub('\"', \"'\") : \":\" + @options[:clipboard_attrs].first) : \"\"}\",\n\t\t\t\t\t\t\tclipboardAttrs: #{clipboard_attrs_js},\n\t\t\t\t\t\t\tclipboardActionCollapsed: #{@options[:clipboard_action_collapsed] == true ? 'true' : 'false'}, \n\t\t\t\t\t\t\t\n\t\t\t\t\t\t\t// Select\n\t\t\t\t\t\t\tselectByDefault: #{@options[:select_by_default] ? @options[:select_by_default].to_i : \"null\"},\n\n\t\t\t\t\t\t\t// Reload\n\t\t\t\t\t\t\treloadIcon: '#{@icon_builder.render(@options[:update_icon] ? @options[:update_icon] : \"refresh\")}',\n\t\t\t\t\t\t\treloadLabel: '#{I18n.t(\"general.action.reload\").upcase_first}',\n\t\t\t\t\t\t});\n\t\t\t\t\t\trug_tree_#{@hash}.ready();\n\t\t\t\t\t});\n\t\t\t\t\t$(document).on('turbolinks:load', function() {\n\t\t\t\t\t\trug_tree_#{@hash}.repair();\n\t\t\t\t\t});\n\t\t\t\t})\n\n\t\t\t\tresult += %{\n\t\t\t\t\t<div id=\"tree-#{@hash}\" data-url=\"#{data_path.to_s}\"></div>\n\t\t\t\t}\n\n\t\t\t\treturn result.html_safe\n\t\t\tend",
"def update_content_paths\n\n # Checking if the parent id has changed for the current content have to change the content paths table only if parent id is changed\n new_parent_id = ContentData.get_parent_id(self.id)\n\n # Getting the old parent data from the content path table\n old_parent_id = 0\n old_parent = ContentPath.where(:descendant => self.id, :depth => 1)\n # If there are any parents found with the getting the old parent id\n if old_parent.length > 0\n old_parent_id = old_parent.first.ancestor\n end\n\n # If the parent id is changed then update the content path structure\n if new_parent_id != old_parent_id\n\n # Refer to the article \"http://www.mysqlperformanceblog.com/2011/02/14/moving-subtrees-in-closure-table/\" for the logic\n # Detach the node from the old parent \n delete_query = \"DELETE a FROM content_paths AS a JOIN content_paths AS d ON a.descendant = d.descendant LEFT JOIN content_paths AS x ON x.ancestor = d.ancestor AND x.descendant = a.ancestor WHERE d.ancestor = '\"+self.id.to_s+\"' AND x.ancestor IS NULL\"\n ActiveRecord::Base.connection.execute(delete_query)\n\n # Attach the node to the new parent\n insert_query = \"INSERT INTO content_paths (ancestor, descendant, depth) SELECT supertree.ancestor, subtree.descendant, supertree.depth+subtree.depth+1 FROM content_paths AS supertree JOIN content_paths AS subtree WHERE subtree.ancestor = '\"+self.id.to_s+\"' AND supertree.descendant = '\"+new_parent_id.to_s+\"'\"\n ActiveRecord::Base.connection.execute(insert_query)\n\n ## The code for changing the childrens data of the edited node with the new parent data\n ## Getting the data of the new parent\n new_parent_data = Content.find(new_parent_id)\n\n ## Board is at the top level no need to change the children data\n if self.type == 'Board'\n\n ## Content year parent is changed update all the children with the current board id\n elsif self.type == 'ContentYear'\n if self.children.map(&:descendant).length > 1\n Content.where(:id => self.children.map(&:descendant)).update_all(:board_id => self.board_id)\n end\n\n ## Subject parent is changed update all the children with the curent board id and content year id\n elsif self.type == 'Subject'\n if self.children.map(&:descendant).length > 1\n Content.where(:id => self.children.map(&:descendant)).update_all(:board_id => self.board_id, :content_year_id => self.content_year_id)\n end\n\n ## Chapter parent is changed update all the children with the current board id , content year id and subject id\n elsif self.type == 'Chapter'\n if self.children.map(&:descendant).length > 1\n Content.where(:id => self.children.map(&:descendant)).update_all(:board_id => self.board_id, :content_year_id => self.content_year_id, :subject_id => self.subject_id)\n end\n\n ## Topic parent is changed update all the children with the current board id, content year id, subject id and chapter id\n elsif self.type == 'Topic'\n if self.children.map(&:descendant).length > 1\n Content.where(:id => self.children.map(&:descendant)).update_all(:board_id => self.board_id, :content_year_id => self.content_year_id, :subject_id => self.subject_id, :chapter_id => self.chapter_id)\n end\n\n ## Subtopic parent is changed update all the children with the current board id, content year id, subject id, chapter id and topic id\n elsif self.type == 'SubTopic'\n if self.children.map(&:descendant).length > 1\n Content.where(:id => self.children.map(&:descendant)).update_all(:board_id => self.board_id, :content_year_id => self.content_year_id, :subject_id => self.subject_id, :chapter_id => self.chapter_id, :topic_id => self.topic_id)\n end\n end\n\n ## End of code for changing the childrens data\n\n end\n end",
"def check_tree\n unless @trees\n @trees = {}\n @blobs = {}\n @base.ls_tree(@objectish).each do |hash|\n if hash[:type] == 'tree'\n @trees[hash[:path]] = TinyGit::Object::Tree.new(@base, hash[:sha], hash[:mode])\n elsif hash[:type] == 'blob'\n @blobs[hash[:path]] = TinyGit::Object::Blob.new(@base, hash[:sha], hash[:mode])\n end\n end\n end\n end",
"def save\n load_cache\n\n all_classes_and_modules.each do |klass|\n save_class klass\n\n klass.each_method do |method|\n save_method klass, method\n end\n\n klass.each_attribute do |attribute|\n save_method klass, attribute\n end\n end\n\n all_files.each do |file|\n save_page file\n end\n\n save_cache\n end",
"def save(filename)\n SGF::Writer.new.save(@root, filename)\n end"
] | [
"0.64106363",
"0.63570917",
"0.6314763",
"0.60909194",
"0.603289",
"0.602521",
"0.59784293",
"0.5954609",
"0.59007466",
"0.5863738",
"0.5828076",
"0.5781941",
"0.577882",
"0.576617",
"0.57591856",
"0.57278883",
"0.57113636",
"0.56846803",
"0.56611633",
"0.55395055",
"0.5490015",
"0.54765177",
"0.54762113",
"0.5458637",
"0.54398954",
"0.5422417",
"0.54175097",
"0.54133",
"0.53775436",
"0.5369748",
"0.5369748",
"0.5365317",
"0.5328716",
"0.532519",
"0.53212106",
"0.53003025",
"0.52941996",
"0.5290158",
"0.5271641",
"0.5265569",
"0.5254612",
"0.5250779",
"0.5244947",
"0.52332425",
"0.5231826",
"0.52269423",
"0.52237034",
"0.52232325",
"0.52177346",
"0.52098596",
"0.5207619",
"0.5201316",
"0.519746",
"0.51973027",
"0.51888025",
"0.51730204",
"0.5172049",
"0.5145476",
"0.51380736",
"0.5127902",
"0.51229507",
"0.51227635",
"0.5119021",
"0.5092705",
"0.50924385",
"0.5084805",
"0.5082515",
"0.5073719",
"0.5071804",
"0.50707644",
"0.506363",
"0.5028629",
"0.5027173",
"0.5027156",
"0.5018881",
"0.501885",
"0.5006527",
"0.49882227",
"0.49875578",
"0.49846905",
"0.49833298",
"0.49816015",
"0.49721026",
"0.49715346",
"0.49704903",
"0.49698535",
"0.49543008",
"0.49535826",
"0.49477658",
"0.4944807",
"0.49420083",
"0.49342048",
"0.4927991",
"0.49275935",
"0.49267304",
"0.4924811",
"0.49119288",
"0.49081826",
"0.49049193",
"0.49031332"
] | 0.54602915 | 23 |
========================================================================================================= Separate methods for quiz questionnaire ========================================================================================================= View a quiz questionnaire | def view_quiz
@questionnaire = Questionnaire.find(params[:id])
@participant = Participant.find(params[:pid]) #creating an instance variable since it needs to be sent to submitted_content/edit
render :view
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n @questions = get_questions\n @answers\n @count = -1\n @total_questions\n @new_quiz = Quiz.new\n end",
"def view_quiz\n @questionnaire = Questionnaire.find(params[:id])\n @participant = Participant.find_by_id(params[:pid]) #creating an instance variable since it needs to be sent to submitted_content/edit\n render :view\n end",
"def show\n authorize! :answer, @questionnaire\n\n respond_to do |format|\n format.html {\n @answer_set = AnswerSet.new()\n @answer_set.questionnaire_id = @questionnaire.id\n @answer_set.init_questionnaire(@questionnaire)\n }\n format.json { render :json => @questionnaire.questions.to_json }\n end\n end",
"def edit_quiz\n\n @questionnaire = Questionnaire.find(params[:id])\n render :edit\n end",
"def show\n @questions = @exam.questions\n @question = Question.new\n end",
"def show\n # @answers = @response.answers\n # @questionnaire_name = @response.questionnaire.name\n # @user = @response.user\n end",
"def show\n idx = params[:id]\n @question = Question.find(params[:id])\n @newAnswer = Answer.new(:question_id => params[:id])\n @Answers = Answer.where(question_id: idx)\n @answer = Answer.all\n end",
"def index\n @questionnaires = Questionnaire.all\n end",
"def index\n @questionnaires = Questionnaire.all\n end",
"def index\n @questionnaires = Questionnaire.all\n end",
"def answer_show\n @questionnaire = Questionnaire.find(params[:id])\n answer = @questionnaire.answer_questionnaires.build\n render 'answer_show'\n end",
"def index\n # @questionnaires = Questionnaire.all \n end",
"def show\n \t@quiz = Quiz.find(params[:id])\n end",
"def show\n @questions = @line_case.questions\n end",
"def index\n @questionnaires = Questionnaire.all\n end",
"def show\n @quiz = params[:quiz_id]\n @fake_answers = FakeAnswer.where(question_id: params[:id])\n end",
"def show\n @quiz = Quiz.find(params[:id])\n end",
"def quiz\n end",
"def show\n @questions = Question.find(params[:id])\n @answers = @question.answers.all\n end",
"def index\n @quiz_answers = QuizAnswer.all\n end",
"def show\n @question = Question.find(params[:id])\n @answerlist = Answer.where(\"question_id = ?\", @question.id )\n \n end",
"def show\n @question = Question.find(params[:id])\n #if !(@question.accessible(current_user.id, current_user.institution_id))\n # respond_to do |format|\n # format.html { redirect_to action: \"index\" }\n # #format.json { render json: @question }\n # end\n # return\n #end\n @listed_tags = [\"concept_names\", \"academic_class\", \"chapter\", \"blooms_taxonomy\", \"subject\", \"course\", \"qsubtype\", \"specialCategory\", \"difficulty_level\"]\n @edit_copy = 'copy'\n if (@question.edit_access(current_user.id))\n @edit_copy = 'edit'\n end\n #@can_delete = @question.join(:quiz_question_instances).join(:quiz_targeted_groups)\n values = {}\n where = \"quiz_question_instances.question_id = :question_id\"\n values[:question_id] = params[:id]\n @used = nil #Quiz.select(\"quizzes.id,quizzes.name\").joins(:quiz_question_instances).select(\"quiz_question_instances.grade\").joins(:quiz_targeted_groups).select(\"published_on,published_by\").where(where,values).order('quizzes.timecreated DESC')\n respond_to do |format|\n format.html { render \"show_\"[email protected]}\n format.json { render json: @question }\n end\n end",
"def show\n @answer = Answer.find(params[:id])\n @question = @answer.question\n end",
"def view\n @quiz = Quiz.find(params[:id])\n render 'show'\n end",
"def quiz_questions\n @questions = set_quiz.questions\n end",
"def index\n @questionnairedetails = Questionnairedetail.all\n end",
"def index\n if params[:quiz_id]\n @quiz = Quizzes::Quiz.find(params[:quiz_id])\n @quizzes_questions = @quiz.questions\n else\n @quizzes_questions = Quizzes::Question.all\n end\n end",
"def show\n if current_user.has_role? :admin\n else\n @quiz = Quiz.find(session[:quiz_id])\n @cardbox = Cardbox.find(session[:cardbox_id])\n @practice = @quiz_item.practice\n end\n end",
"def index\n @questions = @questionable.questions\n end",
"def set_questionnaire\n @questionnaire = Questionnaire.find(params[:id])\n end",
"def set_questionnaire\n @questionnaire = Questionnaire.find(params[:id])\n end",
"def set_questionnaire\n @questionnaire = Questionnaire.find(params[:id])\n end",
"def set_questionnaire\n @questionnaire = Questionnaire.find(params[:id])\n end",
"def set_questionnaire\n @questionnaire = Questionnaire.find(params[:id])\n end",
"def set_questionnaire\n @questionnaire = Questionnaire.find(params[:id])\n end",
"def set_questionnaire\n @questionnaire = Questionnaire.find(params[:id])\n end",
"def set_questionnaire\n @questionnaire = Questionnaire.find(params[:id])\n end",
"def set_questionnaire\n @questionnaire = Questionnaire.find(params[:id])\n end",
"def quiz\n @questions = Question.all\n @idx = params[:idx] ? (params[:idx].to_i + 1) : 0\n if params[:answer]\n question = Question.find(params[:id])\n if check_answer(params[:answer], question.answer)\n @correct_answer_number = params[:correct_answer_number].to_i + 1\n if @idx < @questions.size\n flash[:notice] = \"Correct\"\n else\n flash[:notice] = \"Correct. Summary: You have answered #{@correct_answer_number} question(s) correctly out of #{@questions.size}\"\n end\n else\n @correct_answer_number = params[:correct_answer_number].to_i\n if @idx < @questions.size\n flash[:notice] = \"Incorrect\"\n else\n flash[:notice] = \"Incorrect. Summary: You have answered #{@correct_answer_number} question(s) correctly out of #{@questions.size}\"\n end\n end\n else\n @correct_answer_number = 0\n end\n if @idx >= @questions.size\n @idx = 0\n @correct_answer_number = 0\n end\n flash[:notice] = \"No questions have been added yet. Please ask the administrator to add some questions first.\" if @questions.size == 0\n end",
"def new_quiz\n @questionnaire = Object.const_get(params[:model]).new\n @questionnaire.private = params[:private]\n @questionnaire.min_question_score = 0\n @questionnaire.max_question_score = 1\n @participant_id = params[:pid] #creating an instance variable to hold the participant id\n @assignment_id = params[:aid] #creating an instance variable to hold the assignment id\n render :new\n end",
"def show\n #TODO: Qiita 記事がない場合はrouteを変えて飛ばす\n if @question == nil\n render \"questions/delete_question\"\n return\n end\n # before_action :set_question\n if @question.best_answer_id\n @bestanswer = Answer.find(@question.best_answer_id)\n end\n\n if user_signed_in?\n @answer = @question.answers.build(user_id: current_user.id)\n end\n impressionist(@question, nil, unique: [:session_hash])\n\n end",
"def set_questionnaire\n @questionnaire = Questionnaire.find(params[:id])\n end",
"def show\n @id=params[:qid]\n @question=Question.find(@id)\n session[:qid]=@id\n @answers=Answer.where(:question_id => @id)\n #added by lyz\n @article = Article.find(@question.article_id)\n end",
"def questionnaire_items\n questions = opts[:questionnaire_response]&.questionnaire_response_data&.fetch('item')\n\n composer.move_down(composer.bounds.top - 120)\n\n questions.each do |q|\n answers = q['answer']\n\n composer.table([[q['text'], '']], table_question_style)\n composer.move_down(16)\n\n answers.each do |a|\n composer.table([['', a['valueString']]], table_answer_style)\n composer.move_down(10)\n end\n end\n end",
"def index\n @quizzes_answers = Quizzes::Answer.all\n end",
"def show\n @questions = Question.all\n end",
"def show\n @rec_not_saved = false\n @question = Question.find(params[:id])\n @answers = @question.answers.find(:all, :order => \"answers.created_at ASC\", :include => :user)\n @answer = @question.answers.new\n @answer.user_id = session[:user_id]\n end",
"def show\n @problem_set = ProblemSet.find(params[:problem_set_id])\n if session[:user_id].nil?\n session[:redirect_url] = \"/problem_sets/#{@problem_set.id}/questions/\"\n redirect_to(\"/login/\")\n else\n @question = Question.where(:problem_set_id => params[:problem_set_id], :count => params[:id]).first\n if @question.nil?\n flash[:notice] = \"NO SUCH QUESTION!\"\n redirect_to :action=>\"index\"\n else\n @answer = Answer.where(:question_id => @question.id).all\n @response = Response.where(:user_id => session[:user_id], :question_id => @question.id).first\n if @response.nil?\n @response = Response.new\n end\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @question }\n end\n end\n end\n end",
"def quiz_answer(quiz)\n if quiz.answer_type == 'multi'\n show_multi_answer(quiz.answers.first.text, quiz.answer_input)\n elsif quiz.answer_type == 'check'\n show_check_answer(quiz.answers.first.text, quiz.answer_input)\n else\n quiz.answers.first.text\n end\n end",
"def show\n @question = Question.find(params[:id])\n @avatar = Avatar.find_by_user_id(@question.user_id)\n @user = User.find(@question.user_id)\n @answers = Question.findanswers(@question.id.to_s)\n @correctanswers = Question.findcorrectanswers(@question.id.to_s)\n @totalanswers = @answers.size + @correctanswers.size\n\t if current_user == @user\n @asker = true\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @question }\n end\n end",
"def index\n @quizzes = Quiz.all\n end",
"def index\n @quizzes = Quiz.all\n end",
"def index\n @quizzes = Quiz.all\n end",
"def index\n @quizzes = Quiz.all\n end",
"def index\n @quizzes = Quiz.all\n end",
"def index\n @quiz = Quiz.all\n end",
"def view\n @assignment = Assignment.find(params[:id])\n @questions = Hash.new\n questionnaires = @assignment.questionnaires\n questionnaires.each {\n |questionnaire|\n @questions[questionnaire.symbol] = questionnaire.questions\n }\n\n @scores = @assignment.get_scores(@questions)\n end",
"def show\n @questions = Question.find(params[:id])\n end",
"def show\n @tabs = Tab.order(:position).all\n @answer = Answer.new\n @courses = Course.where(program_id: @program.id, year_id: @year.id)\n end",
"def questions\n \n end",
"def show\n @questionnaire = Questionnaire.find(params[:id])\n\n respond_to do |format|\n format.html\n format.json { render json: @questionnaire }\n end\n end",
"def survey_answer_for attempt, question\n question.field(attempt: attempt, answer: attempt.answer_to(question))\n\n render partial: question.field.show_path, locals: { question: question }\n end",
"def show\n @exam = Exam.find(params[:id])\n @question = Question.new\n end",
"def show\n @quiz = Quiz.find_by(user_id: current_user)\n if !@quiz\n redirect_to quiz_types_path\n end\n end",
"def show\n @questionnaire = Questionnaire.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @questionnaire }\n end\n end",
"def show\n @questionnaire = Questionnaire.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @questionnaire }\n end\n end",
"def show\n @question_sheet = @answer_sheet.question_sheet\n pf = Qe.table_name_prefix\n @elements = @question_sheet.pages.collect {|p| p.elements.includes(:pages).order(\"#{pf}pages.number,#{pf}page_elements.position\").all}.flatten\n @elements = QuestionSet.new(@elements, @answer_sheet).elements.group_by{ |e| e.pages.first }\n end",
"def show\n @answers = @journal.journal_answers\n end",
"def index\n @questionnaires = Questionnaire.all\n# @questionnaires = User.questionnaire.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @questionnaires }\n end\n end",
"def show\n if user_signed_in? && current_user.admin?\n @question = @quiz.questions.build\n elsif user_signed_in?\n else\n redirect_to root_url, notice: \"Sorry, you have to sign in first.\"\n end\n end",
"def show\n\t\t_get_current_question_and_choices(params[:id])\n\tend",
"def index\n @pub_quiz_answers = PubQuizAnswer.all\n end",
"def show\n @questionnaire = Questionnaire.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @questionnaire }\n end\n end",
"def show\n @questionnaire = Questionnaire.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @questionnaire }\n end\n end",
"def set_practice\n @practice = Practice.find(params[:id])\n @questions = @practice.questions\n end",
"def set_questionnairedetail\n @questionnairedetail = Questionnairedetail.find(params[:id])\n end",
"def show\n set_game\n @questions = @game.questions\n end",
"def find_quiz\n @quiz = Quiz.find(params[:id])\n end",
"def show\n\t\tif next_quiz == 0\n \tredirect_to quizzes_path\n\t\t\tsession[:quiz_index] = 0\n\t\t\tuser_lesson = UserLesson.find_by(lesson_id: current_lesson.id)\n\t\t\tuser_lesson.status = \"completed\"\n\t\t\tuser_lesson.save\n\t\telse\n\t\t\t@quiz = Quiz.find(next_quiz)\n\t\t\tif @quiz == nil\n\t\t\t\tsession[:quiz_index] = 0 \n\t\t\telse\n\t\t\t\tif UserLessonQuiz.check_presence(@quiz.id).empty?\n\t\t\t\t\tUserLessonQuiz.create(user_id: current_user.id, lesson_id: current_lesson.id, quiz_id: @quiz.id)\n\t\t\t\tend\n\t\t\tend\n\t\tend\n end",
"def index\n @quizzes = Quiz.all.where(lesson_id: current_lesson.id)\n end",
"def index\n @questionaries = Questionary.all\n end",
"def show\n @answer = Answer.find_by_uuid(params[:id])\n @question = @answer.question\n end",
"def show\n @question = Question.find(params[:id])\n session[:question_id] = @question.id\n @answers = @question.answers\n @comments = @question.comments\n end",
"def view_completed_question(count, answer,questionnaire_max)\n\t\thtml = '<big><b>Question '+count.to_s+\":</b> <I>\"+self.txt+\"</I></big><BR/><BR/>\"\n if !answer.answer.nil?\n\t\t html += '<TABLE CELLPADDING=\"5\"><TR><TD valign=\"top\"><B>Score:</B></TD><TD><FONT style=\"BACKGROUND-COLOR:gold\">'+answer.answer.to_s+'</FONT> out of <B>'+questionnaire_max.to_s+'</B></TD></TR>'\n else\n html += '<TABLE CELLPADDING=\"5\"><TR><TD valign=\"top\"><B>Score:</B></TD><TD><FONT style=\"BACKGROUND-COLOR:gold\">--</FONT> out of <B>'+questionnaire_max.to_s+'</B></TD></TR>'\n end\n\t\tif answer.comments != nil\n\t\t\thtml += '<TR><TD valign=\"top\"><B>Response:</B></TD><TD>' + answer.comments.gsub(\"<\", \"<\").gsub(\">\", \">\").gsub(/\\n/, '<BR/>')\n\t\tend\n\t\thtml += '</TD></TR></TABLE><BR/>'\n\t\thtml.html_safe\n end",
"def show\n # id from url comes in as :id key of params hash\n @question = Question.find(params[:id])\n\n @answers = @question.answers.order(created_at: :desc)\n end",
"def show\n @quizSelect = Quiz.find(1)\n @questions = @quizSelect.questions\n @cards = Card.all.limit(@quizSelect.questions.count*3).shuffle\n\n \tend",
"def with_answers\n @questions = Question.answered\n render(:action => \"index\")\n end",
"def show\n if current_user.has_role? :admin\n else\n session[:quiz_id] = @quiz.id\n redirect_to quiz_items_url\n end\n end",
"def question\n answer.question\n end",
"def show\n @_question = Question.find(params[:id])\n @question = QuestionPresenter.new(@_question)\n end",
"def questions\n # Get a list of questionnaires that belong to instances of the current race\n if @course\n questionnaire_ids = @course.questionnaire_ids\n elsif @instance\n questionnaire_ids = @instance.questionnaire_ids\n else\n questionnaire_ids = []\n end\n\n # Collect question_ids that are used in those questionnaires\n question_ids = Set.new\n Questionnaire.where(:id => questionnaire_ids).find_each do |questionnaire|\n question_ids.merge(questionnaire.question_ids)\n end\n\n @questions = Question.find(question_ids.to_a)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @questions.to_json }\n end\n end",
"def index\n #show answers for particular survey\n @survey = Survey.find(params[:survey_id])\n @answers = @survey.answers.order(\"question_id, created_at\")\n \n #show answers for specific question\n if (params[:question_id])\n @question = Question.find(params[:question_id])\n @answers = @question.answers.order(\"question_id, created_at\")\n end\n #show answers for specific response\n if (params[:response_id])\n @response = Response.find(params[:response_id])\n @answers = @response.answers.order(\"question_id\")\n end\n end",
"def new\n @question = @quiz.questions.new\n\n 4.times { @question.answers.build }\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @question }\n end\n end",
"def show\n \n @dquestion = Dquestion.find(params[:id])\n session[:quest_id] = @dquestion.id\n @danswers = Danswer.where(dquestion_id: @dquestion.id)\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: [@dtest, @dquestion] }\n end\n end",
"def index\n @examquestions = Examquestion.all\n end",
"def show\n # @question_answer = Question::Answer.new\n @question = Question.find(params[:question_id])\n @answer = Answer.new(:question_id => @question.id, :quiz_id => @question.quiz.id)\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @question_answer }\n end\n end",
"def set_quiz\n @quiz = Quiz.find(params[:id])\n end",
"def set_quiz\n @quiz = Quiz.find(params[:id])\n end",
"def index\n @questid = params[:questionnaire_id]\n end",
"def index\n @quiz_free_answers = QuizFreeAnswer.all\n end"
] | [
"0.75456136",
"0.7263283",
"0.7181319",
"0.71634144",
"0.71592253",
"0.71343815",
"0.7077878",
"0.7068398",
"0.7068398",
"0.7068398",
"0.704416",
"0.7041188",
"0.703839",
"0.703686",
"0.7034626",
"0.6996436",
"0.6994688",
"0.69931734",
"0.69399494",
"0.69312733",
"0.6925771",
"0.68696743",
"0.68524307",
"0.6850476",
"0.68482906",
"0.6823961",
"0.68068784",
"0.67840827",
"0.6757259",
"0.67543316",
"0.67543316",
"0.67543316",
"0.67543316",
"0.67543316",
"0.67543316",
"0.67543316",
"0.67543316",
"0.67543316",
"0.67494935",
"0.67493206",
"0.67390776",
"0.67359537",
"0.6729588",
"0.6727606",
"0.671053",
"0.6684002",
"0.66548216",
"0.66302687",
"0.662326",
"0.66079354",
"0.66056633",
"0.66056633",
"0.66056633",
"0.66056633",
"0.66056633",
"0.6603022",
"0.6582005",
"0.657967",
"0.6578433",
"0.65704453",
"0.65690637",
"0.6565051",
"0.6561594",
"0.65562636",
"0.6550641",
"0.6550641",
"0.65382373",
"0.6503025",
"0.6498498",
"0.6491394",
"0.6489023",
"0.6487008",
"0.64854676",
"0.64854676",
"0.64843065",
"0.6480408",
"0.6477252",
"0.6476908",
"0.6473161",
"0.64579403",
"0.6448564",
"0.644298",
"0.64408636",
"0.64400715",
"0.64392024",
"0.6433141",
"0.64303994",
"0.64246213",
"0.6411264",
"0.64063674",
"0.6405287",
"0.6405216",
"0.64022195",
"0.6400632",
"0.63934356",
"0.63909006",
"0.63835007",
"0.63835007",
"0.63819206",
"0.6378411"
] | 0.72761625 | 1 |
define a new quiz questionnaire method invoked by the view | def new_quiz
valid_request=true
@assignment_id = params[:aid] #creating an instance variable to hold the assignment id
@participant_id = params[:pid] #creating an instance variable to hold the participant id
assignment = Assignment.find(@assignment_id)
if !assignment.require_quiz? #flash error if this assignment does not require quiz
flash[:error] = "This assignment does not support quizzing feature."
valid_request=false
else
team = AssignmentParticipant.find(@participant_id).team
if team.nil? #flash error if this current participant does not have a team
flash[:error] = "You should create or join a team first."
valid_request=false
else
if assignment.has_topics? && team.topic.nil?#flash error if this assignment has topic but current team does not have a topic
flash[:error] = "Your team should have a topic first."
valid_request=false
end
end
end
if valid_request
@questionnaire = Object.const_get(params[:model]).new
@questionnaire.private = params[:private]
@questionnaire.min_question_score = 0
@questionnaire.max_question_score = 1
render :new_quiz
else
redirect_to controller: 'submitted_content', action: 'view', id: params[:pid]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quiz\n end",
"def create_quiz_questionnaire\n create_questionnaire\n end",
"def new_quiz\n @questionnaire = Object.const_get(params[:model]).new\n @questionnaire.private = params[:private]\n @questionnaire.min_question_score = 0\n @questionnaire.max_question_score = 1\n @participant_id = params[:pid] #creating an instance variable to hold the participant id\n @assignment_id = params[:aid] #creating an instance variable to hold the assignment id\n render :new\n end",
"def new_quiz\n @quiz = Quiz.new\n end",
"def questions\n \n end",
"def new\n\t\t@quiz = Quiz.new\n\tend",
"def new\n @quiz = Quiz.new\n end",
"def new\n @quiz = Quiz.new\n end",
"def take_quiz\n end",
"def show\n @questions = get_questions\n @answers\n @count = -1\n @total_questions\n @new_quiz = Quiz.new\n end",
"def create_questionnaire\n\n @questionnaire = Object.const_get(params[:questionnaire][:type]).new(params[:questionnaire])\n\n if @questionnaire.type == \"QuizQuestionnaire\" #checking if it is a quiz questionnaire\n participant_id = params[:pid] #creating a local variable to send as parameter to submitted content if it is a quiz questionnaire\n @questionnaire.min_question_score = 0\n @questionnaire.max_question_score = 1\n\n @assignment = Assignment.find_by_id(params[:aid])\n if @assignment.team_assignment?\n teams = TeamsUser.find(:all, :conditions => [\"user_id = ?\", session[:user].id])\n for t in teams do\n if team = Team.find(:first, :conditions => [\"id = ? and parent_id = ?\", t.team_id, @assignment.id])\n break\n end\n end\n @questionnaire.instructor_id = team.id #for a team assignment, set the instructor id to the team_id\n else\n @questionnaire.instructor_id = participant_id #for an individual assignment, set the instructor id to the participant_id\n end\n save_questionnaire\n save_choices @questionnaire.id\n flash[:note] = \"Quiz was successfully created\"\n redirect_to :controller => 'submitted_content', :action => 'edit', :id => participant_id\n else\n if (session[:user]).role.name == \"Teaching Assistant\"\n @questionnaire.instructor_id = Ta.get_my_instructor((session[:user]).id)\n end\n save_questionnaire\n\n redirect_to :controller => 'tree_display', :action => 'list'\n end\n end",
"def new\n @question = Question.new \n end",
"def question\n \t\trender 'question'\n \tend",
"def new\n # Define a new question to properly generate a form\n @question = Question.new\n end",
"def new\n @question = Question.new\n end",
"def new\n @question = Question.new\n end",
"def new\n @question = Question.new\n end",
"def new\n @question = Question.new\n end",
"def create\n\n\t\trespond_to do |format|\n\t\t\tif @answer.save\n\t\t\t\tformat.html { redirect_to @answer, notice: 'Survey was successfully created.' }\n\t\t\t\tformat.json { render action: 'show', status: :created, location: @answer }\n\t\t\telse\n\t\t\t\tformat.html { render action: 'new' }\n\t\t\t\tformat.json { render json: @answer.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def view_quiz\n @questionnaire = Questionnaire.find(params[:id])\n @participant = Participant.find(params[:pid]) #creating an instance variable since it needs to be sent to submitted_content/edit\n render :view\n end",
"def view_quiz\n @questionnaire = Questionnaire.find(params[:id])\n @participant = Participant.find_by_id(params[:pid]) #creating an instance variable since it needs to be sent to submitted_content/edit\n render :view\n end",
"def create_question\n question_hash = Adapter.quiz_api(difficulty) #use adapter method, with difficulty passes into the url as a variable, to gnerate a new list of questions.\n new_question = Question.new #make a new question instance\n new_question.save #save now so we can store the question's id in the answer by calling self.id\n new_question.content = question_hash['question'] #adding all necessary column data to this question object/row\n new_question.create_answers(question_hash)\n new_question.quiz_id = self.id\n new_question.save #send the newly created question to the database\n end",
"def create_question(question) \n visit questions_path\n \n click_on \"Ask question\"\n fill_in \"Title\", with: question.title\n fill_in \"Body\", with: question.body\n click_on \"Create\"\n end",
"def answer_show\n @questionnaire = Questionnaire.find(params[:id])\n answer = @questionnaire.answer_questionnaires.build\n render 'answer_show'\n end",
"def create\n @quiz = Quiz.find(params[:quiz_id])\n @question = Question.new(question_params) \n #respond_to do |format|\n if @question.save\n link_quiz_question(@quiz, @question)\n #format.json { render :show, status: :created, location: @question }\n else\n redirect_to quizzes_path\n flash[:notice] = 'Falha em criar pergunta'\n #format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n #end\n end",
"def new\n @answer = Answer.new\n end",
"def add_new_questions\n questionnaire_id = params[:id]\n # If the questionnaire is being used in the active period of an assignment, delete existing responses before adding new questions\n if AnswerHelper.check_and_delete_responses(questionnaire_id)\n flash[:success] = 'You have successfully added a new question. Any existing reviews for the questionnaire have been deleted!'\n else\n flash[:success] = 'You have successfully added a new question.'\n end\n\n questionnaire = Questionnaire.find(questionnaire_id)\n current_num_of_questions = questionnaire.questions.size\n max_seq = 0\n Questionnaire.find(questionnaire_id).questions.each do |question|\n if !question.seq.nil? && question.seq > max_seq\n max_seq = question.seq\n end\n end\n ((current_num_of_questions + 1)..(current_num_of_questions + params[:question][:total_num].to_i)).each do\n max_seq += 1\n # Create question object based on type using question_factory\n question = question_factory(params[:question][:type], questionnaire_id, max_seq)\n if question.is_a? ScoredQuestion\n question.weight = params[:question][:weight]\n question.max_label = Question::MAX_LABEL\n question.min_label = Question::MIN_LABEL\n end\n\n if Question::SIZES.key?(question.class.name)\n question.size = Question::SIZES[question.class.name]\n end\n if Question::ALTERNATIVES.key?(question.class.name)\n question.alternatives = Question::ALTERNATIVES[question.class.name]\n end\n\n begin\n question.save\n rescue StandardError => e\n flash[:error] = e.message\n end\n end\n redirect_to edit_questionnaire_path(questionnaire_id.to_sym)\n end",
"def new\n # using the render method is not necessary if there is a view in 'views/questions'\n # with the same name as the action 'new'\n @question = Question.new\n\n end",
"def new\n @template = @question.template\n end",
"def new\n \n load_quiz_section_and_question\n @option = Option.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @option }\n end\n end",
"def run_quiz\n self.questions_explanation\n self.display_questions\n self.skipped_questions_explanation\n self.skipped_questions\n self.answers_explanation\n self.display_results\n self.show_score\n end",
"def create\n respond_to do |format|\n if @question.save\n @question_link = QuizQuestion.create!(:qtype => params[:qtype], :qid => @question.id, :quizid => params[:quizid], :points => params[:points])\n @question_link.save\n @question.update(:questionid => @question_link.id)\n @quiz = Quiz.find_by_id(params[:quizid])\n format.html { redirect_to admin_quiz_path(@quiz), notice: 'Quiz multiple choice question was successfully created.' }\n format.json { render :show, status: :created, location: @question }\n else\n format.html { render :new }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def quiz\n @questions = Question.all\n @idx = params[:idx] ? (params[:idx].to_i + 1) : 0\n if params[:answer]\n question = Question.find(params[:id])\n if check_answer(params[:answer], question.answer)\n @correct_answer_number = params[:correct_answer_number].to_i + 1\n if @idx < @questions.size\n flash[:notice] = \"Correct\"\n else\n flash[:notice] = \"Correct. Summary: You have answered #{@correct_answer_number} question(s) correctly out of #{@questions.size}\"\n end\n else\n @correct_answer_number = params[:correct_answer_number].to_i\n if @idx < @questions.size\n flash[:notice] = \"Incorrect\"\n else\n flash[:notice] = \"Incorrect. Summary: You have answered #{@correct_answer_number} question(s) correctly out of #{@questions.size}\"\n end\n end\n else\n @correct_answer_number = 0\n end\n if @idx >= @questions.size\n @idx = 0\n @correct_answer_number = 0\n end\n flash[:notice] = \"No questions have been added yet. Please ask the administrator to add some questions first.\" if @questions.size == 0\n end",
"def new\n user_id = session[:user_id]\n quiz_id = Question.find(params[:question_id]).quiz_id\n\n @question = Question.find(params[:question_id])\n @question_answer = Answer.new(:question_id => @question.id, :quiz_id => @question.quiz.id, :user_id => current_user.id)\n\n # check if user has already submitted an answer for this question\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question_answer }\n end\n end",
"def answer_form\n AnswerForm.new(view_context)\n end",
"def show\n @answer = Answer.new\n end",
"def new\n @question_id = (@exam_session.exam.questions.find :first,\n :offset => (@exam_session.current_question - 1)).id\n \n @exam_session.update_attribute(:updated_at, Time.now)\n \n @question = Question.find_by_id_and_return_xml_table(@question_id)\n \n @choices = { 'choiceA' => @question.choice_a,\n 'choiceB' => @question.choice_b,\n 'choiceC' => @question.choice_c,\n 'choiceD' => @question.choice_d,\n 'choiceE' => @question.choice_e,\n }\n end",
"def add_question\n\t\t\tif(current_instructor.quizzes.exists?(:id => params[:quiz_id]))\n\t\t\t\tquiz = current_instructor.quizzes.find(params[:quiz_id])\n\t\t\t\tno = quiz.no_of_MCQ + quiz.no_of_rearrangeQ\t\n\t\t\t\tno.times do |n|\n\t\t\t\t\tquestion = Question.create((params[\"_json\"][n]).permit([:text, :mark, :right_answer, :choices => []]))\n\t\t\t\t\tquiz.questions << question\n\t\t\t\tend\n\t\t\t\trender json: { info: \"created\"}, status: 201\n\t\t\telse\n\t\t\t\trender json: { error:\"Quiz is not found\" }, status: 422\n\t\t\tend\n\t\tend",
"def create_question_for(name)\n define_method \"#{name}?\" do\n attributes[name]\n end\n end",
"def add_ask_question_box\n view_context.render\n end",
"def new\n @question = @quiz.questions.new\n\n 4.times { @question.answers.build }\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @question }\n end\n end",
"def with_answers\n @questions = Question.answered\n render(:action => \"index\")\n end",
"def add_question\n frm.link(:id=>\"editform:addQlink\").click\n SelectQuestionType.new(@browser)\n end",
"def new\n @questionnaire = Object.const_get(params[:model]).new\n @questionnaire.private = params[:private]\n @questionnaire.min_question_score = Questionnaire::DEFAULT_MIN_QUESTION_SCORE\n @questionnaire.max_question_score = Questionnaire::DEFAULT_MAX_QUESTION_SCORE\n end",
"def create\n\n #user query\n @user = User.find(current_user.id)\n\n #profile query\n @profile = Profile.find_by_user_id(@user.id)\n\n #new quiz object\n @quiz = Quiz.new\n\n @level_name = Level.find(@profile.level_id)\n\n #check quiz type\n if params[:test_type][0] == '1'\n @quiz.title = 'Assesment'\n @quiz.description = 'This is a quiz for '[email protected]_name.to_s+' at all levels'\n @quiz.is_attempted =false\n @quiz.is_complete = false\n @quiz.num_of_questions = 10\n @quiz.user_id = @user.id\n @quiz.level_id = 0\n @quiz.save\n\n @questions = Question.limit(10).order(\"RANDOM()\")\n @quiz.questions << @questions\n \n\n else\n @quiz.title = 'Quiz '+ @level_name.name.to_s\n @quiz.description = 'This is a quiz for '[email protected]_name.to_s+' at '+ @level_name.name.to_s+' level'\n @quiz.is_attempted =false\n @quiz.is_complete = false\n @quiz.num_of_questions = 10\n @quiz.user_id = @user.id\n @quiz.level_id = @profile.level_id\n @quiz.save\n\n @questions = Question.where(:level_id => @quiz.level_id).limit(10).order(\"RANDOM()\")\n @quiz.questions << @questions\n end\n end",
"def edit_quiz\n\n @questionnaire = Questionnaire.find(params[:id])\n render :edit\n end",
"def set_answer\n\t\t#@answer = Survey.find(params[:id])\n\tend",
"def create\n @answer = Answer.new(answer_params)\n\n respond_to do |format|\n if @answer.save\n format.html { redirect_to users_quizzes_question_path(params[type_of_answer(params)][:question_id]), notice: 'Answer was successfully created.' }\n format.json { render :show, status: :created, location: @answer }\n else\n format.html { \n @question = Question.find(params[type_of_answer(params)][:question_id])\n render :new \n }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def question\n answer.question\n end",
"def new\n @question = Question.new\n render :new\n end",
"def show\n @questions = @exam.questions\n @question = Question.new\n end",
"def new\n # Using the render method is not necessary if\n # there is a view in `views/questions` with the\n # same name as the action `new`\n @question = Question.new\n end",
"def create\n\t@question = Question.new(params[:question])\n\t if @question.type.name==\"Matrix Type Question\"\n\t @question.answer=100\n\t end\n\t@questionnaire = Questionnaire.find(params[:questionnaire_id])\n\n\trespond_to do |format|\n\t if @question.save\n\t\t@questionnaire_question = QuestionnaireQuestion.new\n\t\t@[email protected]\n\t\t@[email protected]\n\t\t@questionnaire_question.save\n\n\t\ts=\"True\"\n\t\tif @question.type.name==\"True-False Question\"\n\t\t 2.times do |i|\n\t\t\t@option=Option.new\n\t\t\[email protected]=s\n\t\t\ts=\"False\"\n\t\t\[email protected][email protected]\n\t\t\[email protected]_number=(i+1)\n\t\t\[email protected]\n\n\t\t end\n\t\tend\n\t\tif (@question.type.name==\"Open Ended Question\" || @question.type.name==\"True-False Question\") then\n\t\t format.html { redirect_to new_question_path(:questionnaire_id=>@questionnaire.id), :notice => 'Question was successfully created.' }\n\t\telse\n\t\t if (@question.type.name==\"Matrix Type Question\")\n\n\t\t\tformat.html { redirect_to :controller => :matrix, :action => 'index', :question_id=>@question.id, :notice => 'Question was successfully created.' }\n\t\t end\n\t\t format.html { redirect_to new_option_path(:question_id=>@question.id, :notice => 'Question was successfully created.') }\n\t\tend\n\t else\n\t\tformat.html { redirect_to :action => \"new\" ,:questionnaire_id=>@questionnaire.id}\n\t\tformat.xml { render :xml => @question.errors, :status => :unprocessable_entity }\n\t end\n\tend\n end",
"def show\n idx = params[:id]\n @question = Question.find(params[:id])\n @newAnswer = Answer.new(:question_id => params[:id])\n @Answers = Answer.where(question_id: idx)\n @answer = Answer.all\n end",
"def set_questionnaire\n @questionnaire = Questionnaire.find(params[:id])\n end",
"def set_questionnaire\n @questionnaire = Questionnaire.find(params[:id])\n end",
"def set_questionnaire\n @questionnaire = Questionnaire.find(params[:id])\n end",
"def set_questionnaire\n @questionnaire = Questionnaire.find(params[:id])\n end",
"def set_questionnaire\n @questionnaire = Questionnaire.find(params[:id])\n end",
"def set_questionnaire\n @questionnaire = Questionnaire.find(params[:id])\n end",
"def set_questionnaire\n @questionnaire = Questionnaire.find(params[:id])\n end",
"def set_questionnaire\n @questionnaire = Questionnaire.find(params[:id])\n end",
"def set_questionnaire\n @questionnaire = Questionnaire.find(params[:id])\n end",
"def view_completed_question\n nil\n end",
"def view_completed_question\n nil\n end",
"def new # GET /answers/new\n @answer = Answer.new\n end",
"def create_quiz_questionnaire\n valid = valid_quiz\n if valid.eql?(\"valid\")\n create_questionnaire\n else\n flash[:error] = valid.to_s\n redirect_to :back\n end\n end",
"def show\n @answer = Answer.new\n # render plain: \"In show action\"\n end",
"def create\n @questionnaire = Questionnaire.new(questionnaire_params)\n @questionnaire.build_questionnaire_with_options(\n questionnaire_params[:options][:question_count],\n questionnaire_params[:options][:answer_count])\n\n respond_to do |format|\n if @questionnaire.save\n format.html { redirect_to @questionnaire,\n notice:\n 'Тест успешно создан, для заполнения вопросов и ответов\n - пройдите в раздел \"Редактировать тест\".'}\n format.json { render :show, status: :created, location: @questionnaire }\n else\n format.html { render :new }\n format.json { render json: @questionnaire.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_questionnaire\n @questionnaire = Questionnaire.find(params[:id])\n end",
"def create\n question = current_user.questions.new(question_params)\n question.answers.first.creator = current_user\n question.save\n\n # users get one vote for their own questions by default\n # (so their karma/score improves as they create questions)\n current_user.vote_for(question)\n\n msg = %Q[Your question has been submitted! View it #{view_context.link_to(\"here\", qset_path(question_params[:qset_id]))}].html_safe\n redirect_to new_question_path, notice: msg, flash: { html_safe: true }\n end",
"def set_quiz\n @quiz = Quiz.find(params[:id])\n end",
"def set_quiz\n @quiz = Quiz.find(params[:id])\n end",
"def create\n @quizzes_answer = Quizzes::Answer.new(quizzes_answer_params)\n\n respond_to do |format|\n if @quizzes_answer.save\n format.html { redirect_to @quizzes_answer, notice: 'Answer was successfully created.' }\n format.json { render :show, status: :created, location: @quizzes_answer }\n else\n format.html { render :new }\n format.json { render json: @quizzes_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_quiz_answer\n @quiz_answer = QuizAnswer.find(params[:id])\n end",
"def create\n if (params[:question]!=nil)\n @question = Question.new(params[:question])\n @question.subject_id=session[:subjectid] \n else\n @question = Question.new\n end \n \n respond_to do |format|\n if @question.save\n format.html { redirect_to(@question, :notice => 'Question was successfully created.') }\n format.xml { render :xml => @question, :status => :created, :location => @question }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @question.errors, :status => :unprocessable_entity }\n end\n \n end\n \n if (params[:A]!=nil)\n @choices = Choice.new()\n @choices.value = params[:A]\n @[email protected]\n @choices.save \n end\n if (params[:B]!=nil)\n @choices = Choice.new()\n @choices.value = params[:B]\n @[email protected]\n @choices.save \n end\n if (params[:C]!=nil)\n @choices = Choice.new()\n @choices.value = params[:C]\n @[email protected]\n @choices.save \n end\n \n @choices = Choice.new()\n @choices.value = @question.answer\n @[email protected]\n @choices.save \n \n end",
"def index\n @question = Question.new\n super\n end",
"def set_answer\n @answer = Form::Answer.find(params[:id])\n end",
"def ask\n @question = params[:question]\n end",
"def create\n \tif(current_user.quiz != nil)\n current_user.quiz.destroy\n end\n \n @quiz = Quiz.new(params[:quiz])\n @quiz.userName=current_user.name\n @quiz.user_id=current_user.id\n @activities = Activity.all \n if current_user.position == \"High School\"\n @quiz.q3=\"High School\"\n @quiz.q4= \"High School\" \n else\n @quiz.q3=\"College\"\n @quiz.q5= \"None\"\n end\n respond_to do |format|\n if @quiz.save\n current_user.quiz=@quiz\n format.html { redirect_to @quiz, notice: 'Thank You for Taking the Quiz!.' }\n format.json { render json: @quiz, status: :created, location: @quiz }\n else\n format.html { render action: \"new\" }\n format.json { render json: @quiz.errors, status: :unprocessable_entity }\n end\n end\n end",
"def quiz\n $game.new_quiz\n @title_page = 'Quiz app'\n\n number_questions = params['question_number'].to_i\n puts number_questions\n $game.player.username = params['username']\n\n if number_questions < 1 or number_questions > 10\n redirect '/start-quiz'\n else\n response = Request.post_request(URL_GET_QUESTIONS, {\n number: number_questions\n })\n\n questions_response = Request.manage_response(response)\n\n questions_response.each do |question|\n $game.quiz.question_answer << question['Answer']\n $game.quiz.questions << Question.new(question)\n end\n @questions = $game.quiz.questions\n\n if @questions.empty?\n redirect '/start-quiz'\n else\n erb :quiz, layout: :template\n end\n end\nend",
"def survey_answer_for attempt, question\n question.field(attempt: attempt, answer: attempt.answer_to(question))\n\n render partial: question.field.show_path, locals: { question: question }\n end",
"def create\n \n @dquestion = @dtest.dquestions.new(params[:dquestion])\n\n respond_to do |format|\n if @dquestion.save\n # @dquestion.count_answer\n format.html { redirect_to dtest_dquestions_url(@dtest) }\n format.js\n else\n \n format.html { redirect_to dtests_url }\n end\n\n end\n #(@dquestion.count_answer).times { |i| Danswer.create!(answer_text: 'Answer ' + i.to_s, dquestion_id: @dquestion.id)}\n\n end",
"def set_answer\n @answer = Answer.find(params[:id])\n @question = @answer.question\n end",
"def new\n @quick_answer = QuickAnswer.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quick_answer }\n end\n end",
"def question(n)\n send \"question_#{n}\"\n end",
"def show\n @feedback_active = !!current_user\n @new_answer = @question.answers.new\n end",
"def create\n @answer = @question.answers.build(answer_params)\n @answer.save\n respond_with( [ :admin, @survey, @section, @question, @answer ] )\n end",
"def new\n\t\tall_questions = Question.select('short_name,text').all\n\t\t@question_names = \"[#{all_questions.collect { |q| \"\\\"#{q.short_name}\\\"\" }.compact.join(',')}]\"\n\t\t@question_texts = \"[#{all_questions.collect { |q| \"\\\"#{q.text}\\\"\" }.compact.join(',')}]\"\n\t\t\n\t\t@all_choices = \"[#{Choice.select('value').order('value ASC').all.collect { |c| \"\\\"#{c.value}\\\"\" }.compact.join(',')}]\" # construct list for typeahead\n\t\t@new_question = Question.new\n\tend",
"def create\n @question = Question.new(:online => false,\n :chapter => @chapter,\n :statement => params[:question][:statement],\n :level => (@chapter.section.fondation? ? 0 : params[:question][:level]),\n :explanation => \"À écrire\")\n if params[:question][:is_qcm] == '1'\n @question.is_qcm = true\n @question.many_answers = (params[:question][:many_answers] == '1')\n @question.answer = 0\n else\n @question.is_qcm = false\n if params[:question][:decimal] == '1'\n @question.decimal = true\n @question.answer = params[:question][:answer].gsub(\",\",\".\").to_f\n else\n @question.decimal = false\n @question.answer = params[:question][:answer].gsub(\",\",\".\").to_i\n end\n end\n before = 0\n unless @chapter.questions.empty?\n need = @chapter.questions.order('position').reverse_order.first\n before = need.position\n end\n @question.position = before + 1\n if @question.save\n flash[:success] = \"Exercice ajouté.\"\n if @question.is_qcm\n redirect_to question_manage_items_path(@question)\n else\n redirect_to chapter_path(@chapter, :type => 5, :which => @question.id)\n end\n else\n render 'new'\n end\n end",
"def create\n @question = Quizzes::Question.new(quizzes_question_params)\n\n respond_to do |format|\n if @question.save\n if params[:commit] =~ /add/i\n format.html { redirect_to edit_quiz_question_path(@question.quiz, @question) }\n else\n format.html { redirect_to quiz_questions_path(@question.quiz), notice: 'Question was successfully created.' }\n format.json { render :show, status: :created, location: @question }\n end\n else\n format.html { render :new }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\n\t@exam_answer = ExamAnswer.new(exam_answer_params)\n\tif @exam_answer.exam_id == 999\n\t\t@exam_answer.exam_level = params[:exam_lv]\n\t\t@questions = Question.all.where(level: params[:exam_lv])\n\t\t@exams_questions = @questions.all.where(id: [params[:q1_id], params[:q2_id], params[:q3_id], params[:q4_id], params[:q5_id], params[:q6_id], params[:q7_id], params[:q8_id], params[:q9_id], params[:q10_id]])\n\telse\n\t\t@exam = Exam.find(@exam_answer.exam_id)\n\t\t@exam_answer.exam_level = @exam.level\n\t\t@questions = Question.all.where(level: @exam_answer.exam_level)\n\t\t@exams_questions = @questions.all.where(id: [@exam.question1, @exam.question2, @exam.question3, @exam.question4, @exam.question5, @exam.question6, @exam.question7, @exam.question8, @exam.question9, @exam.question10])\n\tend\n\t\n\t@exam_answer.user_id = current_user.id\n\t@exam_answer.ans1 = params[:q1]\n\t@exam_answer.q1 = (@exam_answer.ans1 == @exams_questions[0].answerR ? true : false)\n\t@exam_answer.ans2 = params[:q2]\n\t@exam_answer.q2 = (@exam_answer.ans2 == @exams_questions[1].answerR ? true : false)\n\t@exam_answer.ans3 = params[:q3]\n\t@exam_answer.q3 = (@exam_answer.ans3 == @exams_questions[2].answerR ? true : false)\n\t@exam_answer.ans4 = params[:q4]\n\t@exam_answer.q4 = (@exam_answer.ans4 == @exams_questions[3].answerR ? true : false)\n\t@exam_answer.ans5 = params[:q5]\n\t@exam_answer.q5 = (@exam_answer.ans5 == @exams_questions[4].answerR ? true : false)\n\t@exam_answer.ans6 = params[:q6]\n\t@exam_answer.q6 = (@exam_answer.ans6 == @exams_questions[5].answerR ? true : false)\n\t@exam_answer.ans7 = params[:q7]\n\t@exam_answer.q7 = (@exam_answer.ans7 == @exams_questions[6].answerR ? true : false)\n\t@exam_answer.ans8 = params[:q8]\n\t@exam_answer.q8 = (@exam_answer.ans8 == @exams_questions[7].answerR ? true : false)\n\t@exam_answer.ans9 = params[:q9]\n\t@exam_answer.q9 = (@exam_answer.ans9 == @exams_questions[8].answerR ? true : false)\n\t@exam_answer.ans10 = params[:q10]\n\t@exam_answer.q10 = (@exam_answer.ans10 == @exams_questions[9].answerR ? true : false)\n\t\n\trec_point = (@exam_answer.q1 ? 1:0) + (@exam_answer.q2 ? 1:0) + (@exam_answer.q3 ? 1:0) + (@exam_answer.q4 ? 1:0) + (@exam_answer.q5 ? 1:0) + (@exam_answer.q6 ? 1:0) + (@exam_answer.q7 ? 1:0) + (@exam_answer.q8 ? 1:0) + (@exam_answer.q9 ? 1:0) + (@exam_answer.q10 ? 1:0)\n\tpoints = rec_point/10.to_f\n\tif @exam_answer.exam_id == 999\n\t\tif params[:exam_lv] == \"Początkujący\"\n\t\t\tpoints2 = points*10.to_i\n\t\telse\n\t\t\tpoints2 = points*20.to_i\n\t\tend\n\telse\n\t\tpoints2 = points*@exam.points.to_i\n\tend\n\t@exam_answer.rec_points = points2\n\n\tif @exam_answer.exam_id == 999\n\t\ttemp = 7/10.to_f\n\t\tif params[:exam_lv] == \"Początkujący\"\n\t\t\t@min = temp*10.to_i\n\t\telse\n\t\t\t@min = temp*20.to_i\n\t\tend\n\telse\n\t\ttemp = 7/10.to_f\n\t\t@min = temp*@exam.points.to_i\n\tend\n\n\tif @exam_answer.rec_points >= @min\n\t\t@user_progress = UserProgress.find_by user_id: current_user.id\n\t\tif @exam_answer.exam_id == 999\n\t\t\tif params[:exam_lv] == \"Początkujący\" && @user_progress.p10?\n\t\t\t\t@user_progress.update(poczatkujacy: true)\n\t\t\telsif params[:exam_lv] == \"Zaawansowany\" && @user_progress.z10?\n\t\t\t\t@user_progress.update(complete_all: true)\n\t\t\t\t@user_progress.update(zaawansowany: true)\n\t\t\tend\n\n\n\t\telse\n\n\t\t\tif @exam.level == \"Początkujący\" && @user_progress.p10?\n\t\t\t\t@user_progress.update(poczatkujacy: true)\n\t\t\telsif @exam.level == \"Zaawansowany\" && @user_progress.z10?\n\t\t\t\t@user_progress.update(complete_all: true)\n\t\t\t\t@user_progress.update(zaawansowany: true)\n\t\t\tend\n\t\tend\n\t\tcurrent_user.increment!(:points, points2)\n\t\trespond_to do |format|\n\t\t if @exam_answer.save\n\t\t format.html { redirect_to @exam_answer, :notice => \"Zdales egzamin!.\" }\n\t\t format.json { render :show, status: :created, location: @exam_answer }\n\t\t else\n\t\t format.html { render :new }\n\t\t format.json { render json: @exam_answer.errors, status: :unprocessable_entity }\n\t\t end\n\t\tend\n\t\t\n\telse\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to exam_list_path , :notice => \"Nie zdales egzaminu, zdobyles za malo punktow, liczba otrzymanych punktow - #{@exam_answer.rec_points} , minimum do zdania - #{@min}\" }\n\t\t format.json { render exam_list_path, status: :unprocessable_entity , location: exam_list }\n\t\tend\n\tend\nend",
"def create\n @quiz = Quiz.new(params[:quiz])\n\n if @quiz.save\n redirect_to @quiz, notice: 'Quiz was successfully created.'\n else\n render action: \"new\"\n end\n end",
"def new\n @question_response = QuestionResponse.new\n @question_response.question_id = params[:question_id]\n\t\trender :action => 'new'\n end",
"def new_answer\n answer = Answer.last\n UserMailer.new_answer(answer)\n end",
"def create\n if params[:questionnaire][:original_id]\n flash[:notice] = \"Questionnaire duplication is underway, you will receive an email when it is finished.\"\n redirect_to questionnaires_path\n else\n @questionnaire.last_editor = current_user\n @questionnaire.user = current_user\n respond_to do |format|\n if @questionnaire.save\n flash[:notice] = 'Questionnaire was successfully created.'\n format.html { redirect_to(@questionnaire) }\n format.js { render :layout => false }\n else\n #fill variables need to the new.html.erb page\n @questionnaires_created = Questionnaire.last_created(10)\n @questionnaire.build_questionnaire_fields!\n format.html { render :action => \"new\" }\n format.js\n end\n end\n end\n end",
"def create\n\t\t@question = Question.find(params[:question_id])\n\t\t@answer = @question.answers.build(answer_params)\n\t\[email protected] = current_user\n\t\tif @answer.save\n\t\t\tflash[:success] = \"answer submitted\"\n\t\t\tredirect_to root_url\n\t\telse\n\t\t\tflash[:danger] = \"some error occured\"\n\t\t\trender 'new'\n\t\tend\n \n end",
"def create\n @ques = QuestionDatabase.all\n answer = params[:is_answer]\n @que = QuestionDatabase.new(question_type_params)\n if @que.save\n QuestionDatabase.create_que(params[:question][:option], @que, answer)\n redirect_to new_question_database_path\n flash[:notice] = 'question was successfully created.'\n else\n render 'new'\n end\n end",
"def create\n @quiz = Quiz.new(current_question: 1)\n @question = Question.find(@quiz.current_question)\n @response = Response.new\n respond_to do |format|\n if @quiz.save\n cookies[:finished_quiz] = false\n format.js\n else\n format.js { flash[:alert] = 'There was a problem creating quiz.' }\n end\n end\n end",
"def create\n @questionnaire = Questionnaire.new(params[:questionnaire])\n @quest = Quest.new(params[:quest])\n @choice = Choice.new(params[:choice])\n\n respond_to do |format|\n if @questionnaire.save\n flash[:notice]=\"Questionnaire Name #{@questionnaire.questionnaireName} Created\"\n format.html { redirect_to(:controller =>\"questionnaires\",:action =>\"new\") }\n #format.html { redirect_to(@questionnaire, :notice => 'Questionnaire was successfully created.') }\n format.xml { render :xml => @questionnaire, :status => :created, :location => @questionnaire }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @questionnaire.errors, :status => :unprocessable_entity }\n end\n end\n end"
] | [
"0.7677077",
"0.74242634",
"0.7331367",
"0.7032842",
"0.70093507",
"0.68291557",
"0.6825268",
"0.6825268",
"0.67953235",
"0.6755578",
"0.6613819",
"0.6602317",
"0.65977603",
"0.6569758",
"0.6535151",
"0.6535151",
"0.6535151",
"0.6535151",
"0.6501104",
"0.64952946",
"0.6466948",
"0.64398444",
"0.6435721",
"0.64347386",
"0.63966703",
"0.6376984",
"0.6373636",
"0.63547736",
"0.6345512",
"0.6327361",
"0.63137335",
"0.6311447",
"0.63079864",
"0.62946624",
"0.6291959",
"0.6289156",
"0.62859565",
"0.6277419",
"0.6268039",
"0.6266179",
"0.6261293",
"0.6256443",
"0.6253817",
"0.62432784",
"0.6230774",
"0.6227356",
"0.6225487",
"0.6208329",
"0.6188269",
"0.6185411",
"0.6167952",
"0.6162072",
"0.61269844",
"0.6123083",
"0.6110827",
"0.6110827",
"0.6110827",
"0.6110827",
"0.6110827",
"0.6110827",
"0.6110827",
"0.6110827",
"0.6110827",
"0.6105917",
"0.6105917",
"0.6103835",
"0.6100451",
"0.6090167",
"0.6089194",
"0.6080271",
"0.6073647",
"0.6069475",
"0.6069475",
"0.60685784",
"0.60682195",
"0.6065432",
"0.6055639",
"0.60554504",
"0.60480374",
"0.60472757",
"0.6047273",
"0.6046596",
"0.60310704",
"0.6028827",
"0.6017118",
"0.60154563",
"0.60115427",
"0.59954566",
"0.5994509",
"0.59940124",
"0.5981987",
"0.59818596",
"0.59764135",
"0.59745264",
"0.59646",
"0.59630275",
"0.59603316",
"0.5957326",
"0.59552044",
"0.59493905"
] | 0.6785072 | 9 |
seperate method for creating a quiz questionnaire because of differences in permission | def create_quiz_questionnaire
valid = valid_quiz
if valid.eql?("valid")
create_questionnaire
else
flash[:error] = valid.to_s
redirect_to :back
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_quiz_questionnaire\n create_questionnaire\n end",
"def create_questionnaire\n\n @questionnaire = Object.const_get(params[:questionnaire][:type]).new(params[:questionnaire])\n\n if @questionnaire.type == \"QuizQuestionnaire\" #checking if it is a quiz questionnaire\n participant_id = params[:pid] #creating a local variable to send as parameter to submitted content if it is a quiz questionnaire\n @questionnaire.min_question_score = 0\n @questionnaire.max_question_score = 1\n\n @assignment = Assignment.find_by_id(params[:aid])\n if @assignment.team_assignment?\n teams = TeamsUser.find(:all, :conditions => [\"user_id = ?\", session[:user].id])\n for t in teams do\n if team = Team.find(:first, :conditions => [\"id = ? and parent_id = ?\", t.team_id, @assignment.id])\n break\n end\n end\n @questionnaire.instructor_id = team.id #for a team assignment, set the instructor id to the team_id\n else\n @questionnaire.instructor_id = participant_id #for an individual assignment, set the instructor id to the participant_id\n end\n save_questionnaire\n save_choices @questionnaire.id\n flash[:note] = \"Quiz was successfully created\"\n redirect_to :controller => 'submitted_content', :action => 'edit', :id => participant_id\n else\n if (session[:user]).role.name == \"Teaching Assistant\"\n @questionnaire.instructor_id = Ta.get_my_instructor((session[:user]).id)\n end\n save_questionnaire\n\n redirect_to :controller => 'tree_display', :action => 'list'\n end\n end",
"def create\n\n #user query\n @user = User.find(current_user.id)\n\n #profile query\n @profile = Profile.find_by_user_id(@user.id)\n\n #new quiz object\n @quiz = Quiz.new\n\n @level_name = Level.find(@profile.level_id)\n\n #check quiz type\n if params[:test_type][0] == '1'\n @quiz.title = 'Assesment'\n @quiz.description = 'This is a quiz for '[email protected]_name.to_s+' at all levels'\n @quiz.is_attempted =false\n @quiz.is_complete = false\n @quiz.num_of_questions = 10\n @quiz.user_id = @user.id\n @quiz.level_id = 0\n @quiz.save\n\n @questions = Question.limit(10).order(\"RANDOM()\")\n @quiz.questions << @questions\n \n\n else\n @quiz.title = 'Quiz '+ @level_name.name.to_s\n @quiz.description = 'This is a quiz for '[email protected]_name.to_s+' at '+ @level_name.name.to_s+' level'\n @quiz.is_attempted =false\n @quiz.is_complete = false\n @quiz.num_of_questions = 10\n @quiz.user_id = @user.id\n @quiz.level_id = @profile.level_id\n @quiz.save\n\n @questions = Question.where(:level_id => @quiz.level_id).limit(10).order(\"RANDOM()\")\n @quiz.questions << @questions\n end\n end",
"def create_question\n question_hash = Adapter.quiz_api(difficulty) #use adapter method, with difficulty passes into the url as a variable, to gnerate a new list of questions.\n new_question = Question.new #make a new question instance\n new_question.save #save now so we can store the question's id in the answer by calling self.id\n new_question.content = question_hash['question'] #adding all necessary column data to this question object/row\n new_question.create_answers(question_hash)\n new_question.quiz_id = self.id\n new_question.save #send the newly created question to the database\n end",
"def new_quiz\n valid_request=true\n @assignment_id = params[:aid] #creating an instance variable to hold the assignment id\n @participant_id = params[:pid] #creating an instance variable to hold the participant id\n assignment = Assignment.find(@assignment_id)\n if !assignment.require_quiz? #flash error if this assignment does not require quiz\n flash[:error] = \"This assignment does not support quizzing feature.\"\n valid_request=false\n else\n team = AssignmentParticipant.find(@participant_id).team\n if team.nil? #flash error if this current participant does not have a team\n flash[:error] = \"You should create or join a team first.\"\n valid_request=false\n else\n if assignment.has_topics? && team.topic.nil?#flash error if this assignment has topic but current team does not have a topic\n flash[:error] = \"Your team should have a topic first.\"\n valid_request=false\n end\n end\n end\n\n if valid_request\n @questionnaire = Object.const_get(params[:model]).new\n @questionnaire.private = params[:private]\n @questionnaire.min_question_score = 0\n @questionnaire.max_question_score = 1\n render :new_quiz\n else\n redirect_to controller: 'submitted_content', action: 'view', id: params[:pid]\n end\n end",
"def create\n @current_user = User.find session[:user_id]\n if @current_user.admin\n pa=question_params\n s=pa[:subgenre]\n b=Subgenre.find s.to_i\n @question= Question.new(question: pa[:question],correct_ans: pa[:a]+pa[:b]+pa[:c]+pa[:d],subgenre_id: s)\n if @question.save && b.genre_id == pa[:genre].to_i\n p @choice1 = Choice.new(text: pa[:option1],correct: pa[:a],question_id: @question.id)\n p @choice2 = Choice.new(text: pa[:option2],correct: pa[:b],question_id: @question.id)\n p @choice3 = Choice.new(text: pa[:option3],correct: pa[:c],question_id: @question.id)\n p @choice4 = Choice.new(text: pa[:option4],correct: pa[:d],question_id: @question.id)\n if @choice1.save && @choice2.save && @choice3.save && @choice4.save\n flash[:notice] = \"Question created\"\n flash[:color] = \"valid\"\n redirect_to questions_path\n else\n @question.destroy\n p @choice1.errors\n flash[:notice] = \"Options Incorrect\"\n flash[:color] = \"invalid\"\n redirect_to new_question_path\n end\n else\n @question.destroy\n flash[:notice] = \"Question not created\"\n flash[:color] = \"invalid\"\n redirect_to new_question_path\n end\n else\n flash[:notice] = \"Acces Denied\"\n flash[:color] = \"invalid\"\n redirect_to home_path\n end\n end",
"def create\n @question = Question.new(question_params)\n if current_user.has_role? :iAsk\n @question.platform_type = 0\n elsif current_user.has_role? :udn\n @question.platform_type = 1 \n elsif current_user.has_role? :reader\n @question.platform_type = 2\n elsif current_user.has_role? :admin\n @question.platform_type = session[:platform_id]\n end\n\n if @question.question_type == \"vignette\" or @question.question_type == \"nonchoice\"\n @question.answer = \"\"\n end\n respond_to do |format|\n if @question.save\n format.html { redirect_to paper_questions_path, notice: '題目已被成功建立' }\n format.json { render :show, status: :created, location: @question }\n else\n format.html { render :new }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n respond_to do |format|\n if @question.save\n @question_link = QuizQuestion.create!(:qtype => params[:qtype], :qid => @question.id, :quizid => params[:quizid], :points => params[:points])\n @question_link.save\n @question.update(:questionid => @question_link.id)\n @quiz = Quiz.find_by_id(params[:quizid])\n format.html { redirect_to admin_quiz_path(@quiz), notice: 'Quiz multiple choice question was successfully created.' }\n format.json { render :show, status: :created, location: @question }\n else\n format.html { render :new }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_assessment\n @unique_questions = []\n\n questions = QuizQuestion.for_language_course(self, [\"multiple_choice\", \"short_answer\"])\n questions_grouped_by_lesson = questions.group_by(&:lesson_id).values.shuffle\n\n setup_multiple_choice_questions(questions_grouped_by_lesson)\n setup_short_answer_questions(questions_grouped_by_lesson)\n\n @unique_questions\n end",
"def new_quiz\n @questionnaire = Object.const_get(params[:model]).new\n @questionnaire.private = params[:private]\n @questionnaire.min_question_score = 0\n @questionnaire.max_question_score = 1\n @participant_id = params[:pid] #creating an instance variable to hold the participant id\n @assignment_id = params[:aid] #creating an instance variable to hold the assignment id\n render :new\n end",
"def create\n \tif(current_user.quiz != nil)\n current_user.quiz.destroy\n end\n \n @quiz = Quiz.new(params[:quiz])\n @quiz.userName=current_user.name\n @quiz.user_id=current_user.id\n @activities = Activity.all \n if current_user.position == \"High School\"\n @quiz.q3=\"High School\"\n @quiz.q4= \"High School\" \n else\n @quiz.q3=\"College\"\n @quiz.q5= \"None\"\n end\n respond_to do |format|\n if @quiz.save\n current_user.quiz=@quiz\n format.html { redirect_to @quiz, notice: 'Thank You for Taking the Quiz!.' }\n format.json { render json: @quiz, status: :created, location: @quiz }\n else\n format.html { render action: \"new\" }\n format.json { render json: @quiz.errors, status: :unprocessable_entity }\n end\n end\n end",
"def quiz\n end",
"def create\n @ques = QuestionDatabase.all\n answer = params[:is_answer]\n @que = QuestionDatabase.new(question_type_params)\n if @que.save\n QuestionDatabase.create_que(params[:question][:option], @que, answer)\n redirect_to new_question_database_path\n flash[:notice] = 'question was successfully created.'\n else\n render 'new'\n end\n end",
"def create\n @survey_quiz = Survey::Quiz.new(survey_quiz_params)\n authorize @survey_quiz\n\n respond_to do |format|\n if @survey_quiz.save\n format.html { redirect_to [:new, @survey_quiz, :question], notice: 'Quiz was successfully created.' }\n format.json { render :show, status: :created, location: @survey_quiz }\n else\n format.html { render :new }\n format.json { render json: @survey_quiz.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @quiz = Quiz.new(quiz_params)\n questions_arr.each do |i|\n question = Question.new(question_params(i))\n choices_arr(i).each do |j|\n choice = Choice.new(choice_params(j))\n choice.save\n question.choices << choice\n end\n @quiz.questions << question\n end\n\n if @quiz.save\n User.find(params[:user_id]).quizzes << @quiz\n render json: @quiz, status: :created, location: @quiz\n else\n render json: @quiz.errors, status: :unprocessable_entity\n end\n end",
"def create\n @question = Question.create(params[:question])\n authorize! :create, @question\n respond_to do |format|\n if @question.save\n format.html { redirect_to quiz_path(@question.subsection_id), notice: 'Question was successfully created.' }\n format.json { render json: @question, status: :created, location: @question }\n else\n format.html { render action: \"new\", params: { subsection_id: @question.subsection_id }}\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def _create_new_question(short_name, text, question_type, domain, current_user_id, choices)\n\t\t@new_question = Question.new(:short_name => short_name, :text => text, :question_type => question_type, :created_by => current_user.id, :updated_by => current_user.id, :domain => domain)\n\t \tif @new_question.save\n\t \t\t@error_message = '[INFO] Question saved to database!'\n \t\telse\n \t\t\t@error_message = 'ERROR: could not save new question'\n \t\tend\n \t\t\n \t\tif question_type != 'TEXT' # if this was a choice question, store the choices\n \t\t\t_update_current_choices_and_inclusions(@new_question.id,choices)\n\t\tend\n\tend",
"def add_question\n\t\t\tif(current_instructor.quizzes.exists?(:id => params[:quiz_id]))\n\t\t\t\tquiz = current_instructor.quizzes.find(params[:quiz_id])\n\t\t\t\tno = quiz.no_of_MCQ + quiz.no_of_rearrangeQ\t\n\t\t\t\tno.times do |n|\n\t\t\t\t\tquestion = Question.create((params[\"_json\"][n]).permit([:text, :mark, :right_answer, :choices => []]))\n\t\t\t\t\tquiz.questions << question\n\t\t\t\tend\n\t\t\t\trender json: { info: \"created\"}, status: 201\n\t\t\telse\n\t\t\t\trender json: { error:\"Quiz is not found\" }, status: 422\n\t\t\tend\n\t\tend",
"def save_questionnaire \n begin\n @questionnaire.save!\n\n save_questions @questionnaire.id if @questionnaire.id != nil and @questionnaire.id > 0\n\n if @questionnaire.type != \"QuizQuestionnaire\"\n pFolder = TreeFolder.find_by_name(@questionnaire.display_type)\n parent = FolderNode.find_by_node_object_id(pFolder.id)\n if QuestionnaireNode.find_by_parent_id_and_node_object_id(parent.id,@questionnaire.id) == nil\n QuestionnaireNode.create(:parent_id => parent.id, :node_object_id => @questionnaire.id)\n end\n end\n rescue\n flash[:error] = $!\n end\n end",
"def create\n question = current_user.questions.new(question_params)\n question.answers.first.creator = current_user\n question.save\n\n # users get one vote for their own questions by default\n # (so their karma/score improves as they create questions)\n current_user.vote_for(question)\n\n msg = %Q[Your question has been submitted! View it #{view_context.link_to(\"here\", qset_path(question_params[:qset_id]))}].html_safe\n redirect_to new_question_path, notice: msg, flash: { html_safe: true }\n end",
"def create\n\t @question = Question.new(question_params)\n\tif User.find(session[:userid]).useraccount_type == User::PROF\n\t\[email protected]_id = session[:useraccount_id]\n\telse\n\t\[email protected]_id = Teacher.limit(1).pluck(\"id\").first\n\n\tend\n\n\t if @question.save\n\t flash[:notice] = 'Pregunta creada.'\n\t\t\t\tredirect_to :action => \"edit\" , :id => @question.id\n\t else\n\t render :action => \"new\" \n\t end\n\tend",
"def create\n @question = Question.new(question_params)\n link_response_sets(params)\n\n if @question.all_versions.count >= 1\n if @question.not_owned_or_in_group?(current_user) || @question.prev_not_owned_or_in_group?(current_user)\n render(json: @question.errors, status: :unauthorized) && return\n elsif @question.all_versions.last.status == 'draft'\n render(json: @question.errors, status: :unprocessable_entity) && return\n end\n @question.version = @question.most_recent + 1\n end\n assign_author\n if @question.save\n render :show, status: :created, location: @question\n else\n # @categories = Category.all\n render json: @question.errors, status: :unprocessable_entity\n end\n end",
"def create\n @question = Question.new(:online => false,\n :chapter => @chapter,\n :statement => params[:question][:statement],\n :level => (@chapter.section.fondation? ? 0 : params[:question][:level]),\n :explanation => \"À écrire\")\n if params[:question][:is_qcm] == '1'\n @question.is_qcm = true\n @question.many_answers = (params[:question][:many_answers] == '1')\n @question.answer = 0\n else\n @question.is_qcm = false\n if params[:question][:decimal] == '1'\n @question.decimal = true\n @question.answer = params[:question][:answer].gsub(\",\",\".\").to_f\n else\n @question.decimal = false\n @question.answer = params[:question][:answer].gsub(\",\",\".\").to_i\n end\n end\n before = 0\n unless @chapter.questions.empty?\n need = @chapter.questions.order('position').reverse_order.first\n before = need.position\n end\n @question.position = before + 1\n if @question.save\n flash[:success] = \"Exercice ajouté.\"\n if @question.is_qcm\n redirect_to question_manage_items_path(@question)\n else\n redirect_to chapter_path(@chapter, :type => 5, :which => @question.id)\n end\n else\n render 'new'\n end\n end",
"def create\n\t@question = Question.new(params[:question])\n\t if @question.type.name==\"Matrix Type Question\"\n\t @question.answer=100\n\t end\n\t@questionnaire = Questionnaire.find(params[:questionnaire_id])\n\n\trespond_to do |format|\n\t if @question.save\n\t\t@questionnaire_question = QuestionnaireQuestion.new\n\t\t@[email protected]\n\t\t@[email protected]\n\t\t@questionnaire_question.save\n\n\t\ts=\"True\"\n\t\tif @question.type.name==\"True-False Question\"\n\t\t 2.times do |i|\n\t\t\t@option=Option.new\n\t\t\[email protected]=s\n\t\t\ts=\"False\"\n\t\t\[email protected][email protected]\n\t\t\[email protected]_number=(i+1)\n\t\t\[email protected]\n\n\t\t end\n\t\tend\n\t\tif (@question.type.name==\"Open Ended Question\" || @question.type.name==\"True-False Question\") then\n\t\t format.html { redirect_to new_question_path(:questionnaire_id=>@questionnaire.id), :notice => 'Question was successfully created.' }\n\t\telse\n\t\t if (@question.type.name==\"Matrix Type Question\")\n\n\t\t\tformat.html { redirect_to :controller => :matrix, :action => 'index', :question_id=>@question.id, :notice => 'Question was successfully created.' }\n\t\t end\n\t\t format.html { redirect_to new_option_path(:question_id=>@question.id, :notice => 'Question was successfully created.') }\n\t\tend\n\t else\n\t\tformat.html { redirect_to :action => \"new\" ,:questionnaire_id=>@questionnaire.id}\n\t\tformat.xml { render :xml => @question.errors, :status => :unprocessable_entity }\n\t end\n\tend\n end",
"def create_question(question_text,question_bank_id,tenant_id,question_type,explanation,direction_id,passage_id)\n question = Question.new\n question.question_text = question_text\n question.question_bank_id = question_bank_id\n question.tenant_id = tenant_id\n question.explanation = explanation\n question.question_type = question_type\n question.save\n question_attribute = create_question_attribute(question.id,\"\",question_bank_id,\"\",\"\",\"\",direction_id,passage_id,\"\",\"\",tenant_id)\n question_attribute.update_attribute(\"difficulty_id\",get_difficulty(\"not defined\"))\n unless question_type.nil? or question_type.blank?\n question_type = QuestionType.find_by_value(question_type)\n question_attribute.update_attribute(\"question_type_id\",question_type.id)\n end\n return question\n end",
"def create\n @quiz = current_user.quizzes.build(quiz_params)\n\n @quiz.questions.each do |q|\n if q.question_type == \"free_answer\"\n q.answers = []\n end\n end\n\n puts @quiz.questions\n\n respond_to do |format|\n if @quiz.save\n format.html { redirect_to current_user, notice: 'Quiz was successfully created.' }\n format.json { render :show, status: :created, location: @quiz }\n else\n format.html { render :new }\n format.json { render json: @quiz.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create # rubocop:disable Metrics/AbcSize\n @quiz = @topic.quizzes.build(quiz_params)\n respond_to do |format|\n if @quiz.save\n format.html {\n redirect_to discipline_topic_quiz_path(@discipline, @topic, @quiz), notice: 'Quiz was successfully created.'\n }\n format.json { render :show, status: :created, location: @quiz }\n else\n format.html { render :new }\n format.json { render json: @quiz.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if (params[:question]!=nil)\n @question = Question.new(params[:question])\n @question.subject_id=session[:subjectid] \n else\n @question = Question.new\n end \n \n respond_to do |format|\n if @question.save\n format.html { redirect_to(@question, :notice => 'Question was successfully created.') }\n format.xml { render :xml => @question, :status => :created, :location => @question }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @question.errors, :status => :unprocessable_entity }\n end\n \n end\n \n if (params[:A]!=nil)\n @choices = Choice.new()\n @choices.value = params[:A]\n @[email protected]\n @choices.save \n end\n if (params[:B]!=nil)\n @choices = Choice.new()\n @choices.value = params[:B]\n @[email protected]\n @choices.save \n end\n if (params[:C]!=nil)\n @choices = Choice.new()\n @choices.value = params[:C]\n @[email protected]\n @choices.save \n end\n \n @choices = Choice.new()\n @choices.value = @question.answer\n @[email protected]\n @choices.save \n \n end",
"def create\n @questionnaire = Questionnaire.new(params[:questionnaire])\n# @questionnaire.user_id = User.find(?)\n @questionnaire.user_id = current_user.id\n\n# if !Qfounder.params_any?(params['qfounder'])\n if !params['qfounder'].nil? && params['qfounder'].any?\n params['qfounder'].each { |k, fdr|\n if Qfounder.new(fdr).valid?\n @questionnaire.qfounders.build(fdr)\n end\n }\n end # !params['q'].nil?\n\n respond_to do |format|\n# @questionnaire.valid?\n# if @questionnaire.errors.empty?\n if @questionnaire.save # also saves qfounders using build()\n format.html { redirect_to(@questionnaire) }\n# flash[:notice] = 'Accelerator Application was successfully created.'\n# format.html { render :action => \"show\" }\n format.xml { render :xml => @questionnaire, :status => :created, :location => @questionnaire }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @questionnaire.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create_question(name, ideas = [])\n ideas = ideas.join(\"\\n\") if ideas.is_a? Array\n q = Pairwise::Question.create({\n :name => name,\n :visitor_identifier => @local_identifier.to_s,\n :local_identifier => @local_identifier.to_s,\n :ideas => ideas\n })\n q.it_should_autoactivate_ideas = true\n q.active = true\n q.save\n q\n end",
"def create\n @admin_question = Admin::Question.new(admin_question_params)\n authorize! :create, @admin_question\n\n respond_to do |format|\n if @admin_question.save\n format.html { redirect_to @admin_question, notice: 'Question was successfully created.' }\n format.json { render action: 'show', status: :created, location: @admin_question }\n else\n format.html { render action: 'new' }\n format.json { render json: @admin_question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n #@errors = {}\n if params[ :quiz_id ] && params[ :user_id ]\n# lead_answer_id = params[ :lqa ]\n# if lead_answer_id.blank? && !params[ :questions ].blank?\n# params[ :questions ].each_pair do |qid,aid|\n# if QuizQuestion.find_by_id( qid ).quiz_phase.position == 0\n# lead_answer_id = aid\n# end\n# end\n# end\n \n @quiz_instance = QuizInstance.create(\n :quiz_id => params[ :quiz_id ],\n :user_id => nil,\n :quiz_instance_uuid => @@uuid_generator.generate( :compact ),\n :lead_answer_id => nil,\n :partner_user_id => params[ :user_id ]\n )\n\n if !params[ :questions ].blank?\n params[ :questions ].each_pair do |qid,aid_list|\n aid_list.split( ',' ).each do |aid|\n answer_text=''\n answer_text = params[ :answer ][aid.to_s] unless params[ :answer ].blank? || params[ :answer ][aid.to_s].blank?\n UserQuizAnswer.create( :quiz_answer_id => aid, :user_id => ( @user ? @user.id : nil ), :quiz_instance_id => @quiz_instance.id, :user_answer_text_response => answer_text )\n end\n end\n end\n\n qiid_cookie_write @quiz_instance.quiz_instance_uuid\n\n if @quiz_instance\n # no more POST / Redirect, so we have to revert to this sort of mess.\n # now we need to set up all the data we'll need to render the first\n # phase of the quiz.\n previous_quiz_phase = QuizPhase.first(:conditions => ['quiz_id = ? and position = 0', @quiz_instance.quiz_id])\n begin\n if params[:lqa]\n next_phase_id = QuizAnswer.find(params[:lqa]).next_quiz_phase_id\n else\n next_phase_id = QuizAnswer.find(params[:questions][previous_quiz_phase.branch_question_id.to_s]).next_quiz_phase_id\n end\n @quiz_phase = QuizPhase.find(next_phase_id)\n rescue\n @quiz_phase = QuizPhase.first(:conditions => ['quiz_id = ? and position = 1', @quiz_instance.quiz_id])\n end\n @quiz = @quiz_instance.quiz\n @quiz_page = 1\n\n # also build the resume URI if we have previous instances of this\n # quiz from this user. resume URI is based on the LAST instanced\n # opened.\n load_previous_quiz_instance\n\n @total_quiz_questions = QuizQuestion.count(\n :conditions => [ 'quizzes.id = ? and quiz_questions.active = 1', @quiz.id ],\n :joins => { :quiz_phase => :quiz }\n )\n\n render :file => 'quiz_instances/show.xml'\n\n else\n @errors[ 'quiz' ] = [\n 'Internal Service Error. Unable to create quiz instance.',\n #'We are unable to start your quiz at this time.',\n 500 ]\n\n end\n else\n if !params[ :quiz_id ]\n @errors[ 'quiz_id' ] = [\n 'Required parameter Quiz ID not provided',\n #'Please select a quiz to continue.',\n 400 ]\n end\n\n if !params[ :user_id ]\n @errors[ 'user_id' ] = [\n 'Required parameter User ID not provided.',\n #'Please select a quiz to continue.',\n 400 ]\n end\n #render :text => \"You must supply a quiz id in order to create an open quiz instance.\", :status => 400\n end\n\n if @errors.size != 0\n #if params[ :format ] = 'xml'\n render 'errors.xml.builder'#, :status => @error_code\n #end\n end\n end",
"def create\n\t\n\t@exam_answer = ExamAnswer.new(exam_answer_params)\n\tif @exam_answer.exam_id == 999\n\t\t@exam_answer.exam_level = params[:exam_lv]\n\t\t@questions = Question.all.where(level: params[:exam_lv])\n\t\t@exams_questions = @questions.all.where(id: [params[:q1_id], params[:q2_id], params[:q3_id], params[:q4_id], params[:q5_id], params[:q6_id], params[:q7_id], params[:q8_id], params[:q9_id], params[:q10_id]])\n\telse\n\t\t@exam = Exam.find(@exam_answer.exam_id)\n\t\t@exam_answer.exam_level = @exam.level\n\t\t@questions = Question.all.where(level: @exam_answer.exam_level)\n\t\t@exams_questions = @questions.all.where(id: [@exam.question1, @exam.question2, @exam.question3, @exam.question4, @exam.question5, @exam.question6, @exam.question7, @exam.question8, @exam.question9, @exam.question10])\n\tend\n\t\n\t@exam_answer.user_id = current_user.id\n\t@exam_answer.ans1 = params[:q1]\n\t@exam_answer.q1 = (@exam_answer.ans1 == @exams_questions[0].answerR ? true : false)\n\t@exam_answer.ans2 = params[:q2]\n\t@exam_answer.q2 = (@exam_answer.ans2 == @exams_questions[1].answerR ? true : false)\n\t@exam_answer.ans3 = params[:q3]\n\t@exam_answer.q3 = (@exam_answer.ans3 == @exams_questions[2].answerR ? true : false)\n\t@exam_answer.ans4 = params[:q4]\n\t@exam_answer.q4 = (@exam_answer.ans4 == @exams_questions[3].answerR ? true : false)\n\t@exam_answer.ans5 = params[:q5]\n\t@exam_answer.q5 = (@exam_answer.ans5 == @exams_questions[4].answerR ? true : false)\n\t@exam_answer.ans6 = params[:q6]\n\t@exam_answer.q6 = (@exam_answer.ans6 == @exams_questions[5].answerR ? true : false)\n\t@exam_answer.ans7 = params[:q7]\n\t@exam_answer.q7 = (@exam_answer.ans7 == @exams_questions[6].answerR ? true : false)\n\t@exam_answer.ans8 = params[:q8]\n\t@exam_answer.q8 = (@exam_answer.ans8 == @exams_questions[7].answerR ? true : false)\n\t@exam_answer.ans9 = params[:q9]\n\t@exam_answer.q9 = (@exam_answer.ans9 == @exams_questions[8].answerR ? true : false)\n\t@exam_answer.ans10 = params[:q10]\n\t@exam_answer.q10 = (@exam_answer.ans10 == @exams_questions[9].answerR ? true : false)\n\t\n\trec_point = (@exam_answer.q1 ? 1:0) + (@exam_answer.q2 ? 1:0) + (@exam_answer.q3 ? 1:0) + (@exam_answer.q4 ? 1:0) + (@exam_answer.q5 ? 1:0) + (@exam_answer.q6 ? 1:0) + (@exam_answer.q7 ? 1:0) + (@exam_answer.q8 ? 1:0) + (@exam_answer.q9 ? 1:0) + (@exam_answer.q10 ? 1:0)\n\tpoints = rec_point/10.to_f\n\tif @exam_answer.exam_id == 999\n\t\tif params[:exam_lv] == \"Początkujący\"\n\t\t\tpoints2 = points*10.to_i\n\t\telse\n\t\t\tpoints2 = points*20.to_i\n\t\tend\n\telse\n\t\tpoints2 = points*@exam.points.to_i\n\tend\n\t@exam_answer.rec_points = points2\n\n\tif @exam_answer.exam_id == 999\n\t\ttemp = 7/10.to_f\n\t\tif params[:exam_lv] == \"Początkujący\"\n\t\t\t@min = temp*10.to_i\n\t\telse\n\t\t\t@min = temp*20.to_i\n\t\tend\n\telse\n\t\ttemp = 7/10.to_f\n\t\t@min = temp*@exam.points.to_i\n\tend\n\n\tif @exam_answer.rec_points >= @min\n\t\t@user_progress = UserProgress.find_by user_id: current_user.id\n\t\tif @exam_answer.exam_id == 999\n\t\t\tif params[:exam_lv] == \"Początkujący\" && @user_progress.p10?\n\t\t\t\t@user_progress.update(poczatkujacy: true)\n\t\t\telsif params[:exam_lv] == \"Zaawansowany\" && @user_progress.z10?\n\t\t\t\t@user_progress.update(complete_all: true)\n\t\t\t\t@user_progress.update(zaawansowany: true)\n\t\t\tend\n\n\n\t\telse\n\n\t\t\tif @exam.level == \"Początkujący\" && @user_progress.p10?\n\t\t\t\t@user_progress.update(poczatkujacy: true)\n\t\t\telsif @exam.level == \"Zaawansowany\" && @user_progress.z10?\n\t\t\t\t@user_progress.update(complete_all: true)\n\t\t\t\t@user_progress.update(zaawansowany: true)\n\t\t\tend\n\t\tend\n\t\tcurrent_user.increment!(:points, points2)\n\t\trespond_to do |format|\n\t\t if @exam_answer.save\n\t\t format.html { redirect_to @exam_answer, :notice => \"Zdales egzamin!.\" }\n\t\t format.json { render :show, status: :created, location: @exam_answer }\n\t\t else\n\t\t format.html { render :new }\n\t\t format.json { render json: @exam_answer.errors, status: :unprocessable_entity }\n\t\t end\n\t\tend\n\t\t\n\telse\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to exam_list_path , :notice => \"Nie zdales egzaminu, zdobyles za malo punktow, liczba otrzymanych punktow - #{@exam_answer.rec_points} , minimum do zdania - #{@min}\" }\n\t\t format.json { render exam_list_path, status: :unprocessable_entity , location: exam_list }\n\t\tend\n\tend\nend",
"def add_new_questions\n questionnaire_id = params[:id]\n # If the questionnaire is being used in the active period of an assignment, delete existing responses before adding new questions\n if AnswerHelper.check_and_delete_responses(questionnaire_id)\n flash[:success] = 'You have successfully added a new question. Any existing reviews for the questionnaire have been deleted!'\n else\n flash[:success] = 'You have successfully added a new question.'\n end\n\n questionnaire = Questionnaire.find(questionnaire_id)\n current_num_of_questions = questionnaire.questions.size\n max_seq = 0\n Questionnaire.find(questionnaire_id).questions.each do |question|\n if !question.seq.nil? && question.seq > max_seq\n max_seq = question.seq\n end\n end\n ((current_num_of_questions + 1)..(current_num_of_questions + params[:question][:total_num].to_i)).each do\n max_seq += 1\n # Create question object based on type using question_factory\n question = question_factory(params[:question][:type], questionnaire_id, max_seq)\n if question.is_a? ScoredQuestion\n question.weight = params[:question][:weight]\n question.max_label = Question::MAX_LABEL\n question.min_label = Question::MIN_LABEL\n end\n\n if Question::SIZES.key?(question.class.name)\n question.size = Question::SIZES[question.class.name]\n end\n if Question::ALTERNATIVES.key?(question.class.name)\n question.alternatives = Question::ALTERNATIVES[question.class.name]\n end\n\n begin\n question.save\n rescue StandardError => e\n flash[:error] = e.message\n end\n end\n redirect_to edit_questionnaire_path(questionnaire_id.to_sym)\n end",
"def create \t\n\t \t# TODO: make sure that there are no duplicates for questions\n\t \t\n\t \tif params[:question].nil?\n\t \t\t@error_message = 'ERROR: no question parameter provided'\n \t\telsif params[:question][:short_name].nil? or params[:question][:short_name].empty?\n \t\t\t@error_message = 'ERROR: no short name provided'\n \t\telsif params[:question][:text].nil? or params[:question][:text].empty?\n \t\t\t@error_message = 'ERROR: no question text provided'\n \t\telsif params[:question][:question_type].nil? or params[:question][:question_type].empty?\n \t\t\t@error_message = 'ERROR: no question type provided'\n\t\telsif params[:question][:domain].nil? or params[:question][:domain].empty?\n\t\t\t@error_message = 'ERROR: no question domain provided'\n\t\telsif not [Question::UNFILED_DOMAIN,Question::PROFILE_DOMAIN,Question::FEEDBACK_DOMAIN].include?(params[:question][:domain].downcase)\n\t\t\t@error_message = 'ERROR: invalid question domain provided'\n \t\telsif not ['Text','Multiple Choice','Multiple Selection'].include?(params[:question][:question_type])\n \t\t\t@error_message = 'ERROR: invalid question type'\n \t\telsif params[:question][:question_type] != 'Text' and (params[:choices].nil? or params[:choices].empty?)\n \t\t\t@error_message = 'ERROR: did not specify choices for a choice question' \t\t\t\n \t\telse\n\t\t \tquestion_type = _condense_question_type(params[:question][:question_type])\n \t\t\t# TODO: make sure that there are no duplicates\n\t\t \t \t\t\t\n\t\t \tif question_type.nil?\n \t\t\t\t@error_message = 'ERROR: could not condense question type properly!'\n \t\t\telse\n\t\t\t \t_create_new_question params[:question][:short_name], params[:question][:text], question_type, params[:question][:domain].downcase, current_user.id, params[:choices]\n\t \t\tend\n \t\tend\n \t\tif @error_message.nil? or @error_message.index('ERROR').nil? # if there is an error, stay on this page; else, allow user to continue\n \t\t\tredirect_to :action => :index\n \t\tend\n\tend",
"def create\n @questionnaire = Questionnaire.new(params[:questionnaire])\n @questionnaire.course_instance = @instance\n \n authorize! :create, @questionnaire\n\n respond_to do |format|\n if @questionnaire.save\n format.html { redirect_to [@instance, @questionnaire], notice: 'Kysymyslomakkeen luominen onnistui.' }\n format.json { render json: @questionnaire, status: :created, location: @questionnaire }\n else\n format.html { render action: \"new\" }\n format.json { render json: @questionnaire.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_allowed?\n params[:quiz].keys.to_s == \"[\\\"answer#{cookies[:question_number]}\\\"]\"\n end",
"def make_quiz\n MakeQuizCommand.new(nil).execute\n end",
"def create\n @answer = Answer.new(answer_params)\n\n respond_to do |format|\n if @answer.save\n format.html { redirect_to users_quizzes_question_path(params[type_of_answer(params)][:question_id]), notice: 'Answer was successfully created.' }\n format.json { render :show, status: :created, location: @answer }\n else\n format.html { \n @question = Question.find(params[type_of_answer(params)][:question_id])\n render :new \n }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @quiz = Quiz.find(params[:quiz_id])\n @question = Question.new(question_params) \n #respond_to do |format|\n if @question.save\n link_quiz_question(@quiz, @question)\n #format.json { render :show, status: :created, location: @question }\n else\n redirect_to quizzes_path\n flash[:notice] = 'Falha em criar pergunta'\n #format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n #end\n end",
"def create\n @questionnaire = Questionnaire.new(questionnaire_params)\n @questionnaire.build_questionnaire_with_options(\n questionnaire_params[:options][:question_count],\n questionnaire_params[:options][:answer_count])\n\n respond_to do |format|\n if @questionnaire.save\n format.html { redirect_to @questionnaire,\n notice:\n 'Тест успешно создан, для заполнения вопросов и ответов\n - пройдите в раздел \"Редактировать тест\".'}\n format.json { render :show, status: :created, location: @questionnaire }\n else\n format.html { render :new }\n format.json { render json: @questionnaire.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t@question = current_user.create_questions.build(question_params)\n\t\[email protected] = StringIO.new(params[:question][:i_data].read).read.gsub(/\\R/, \"\\n\") if params[:question][:i_data]\n\t\[email protected] = StringIO.new(params[:question][:o_data].read).read.gsub(/\\R/, \"\\n\") if params[:question][:o_data]\n\t\[email protected]_level = params[:question][:question_level].to_i\n\t\tif @question.save\n\t\t\tpost = current_user.posts.build(category: 0)\n\t\t\[email protected] << post\n\t\t\tcurrent_user.save\n\t\t\tnum = current_user.created_question_number + 1\n\t\t\tcurrent_user.update_attribute(:created_question_number, num)\n\t\t\tredirect_to @question, flash: { notice: 'Question was successfully created.' }\n\t\telse\n\t\t\trender :new\n\t\tend\n\tend",
"def create_single_quiz_question(course_id,quiz_id,question__question_name__,question__question_text__,question__question_type__,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n :question__question_name__,\n :question__question_text__,\n :question__quiz_group_id__,\n :question__question_type__,\n :question__position__,\n :question__points_possible__,\n :question__correct_comments__,\n :question__incorrect_comments__,\n :question__neutral_comments__,\n :question__text_after_answers__,\n :question__answers__,\n \n ]\n\n # verify existence of params\n raise \"course_id is required\" if course_id.nil?\n raise \"quiz_id is required\" if quiz_id.nil?\n raise \"question__question_name__ is required\" if question__question_name__.nil?\n raise \"question__question_text__ is required\" if question__question_text__.nil?\n raise \"question__question_type__ is required\" if question__question_type__.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :course_id => course_id,\n :quiz_id => quiz_id,\n :question__question_name__ => question__question_name__,\n :question__question_text__ => question__question_text__,\n :question__question_type__ => question__question_type__\n )\n\n # resource path\n path = path_replace(\"/v1/courses/{course_id}/quizzes/{quiz_id}/questions\",\n :course_id => course_id,\n :quiz_id => quiz_id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:post, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:post, path, query_params, form_params, headers)\n page_params_store(:post, path)\n QuizQuestion.new(response)\n end",
"def create\n @question = @quiz.questions.new(params[:question])\n\n respond_to do |format|\n @question.save\n if @question.errors.blank?\n flash[:notice] = 'Question was successfully created.'\n format.html { redirect_to(quiz_questions_path(@quiz)) }\n format.xml { render :xml => @question, :status => :created, :location => @question }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @question.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @question = Question.new(question_params)\n @question.user_id = @user.id\n if @question.save\n redirect_to set_answer_question_path(@question)\n else\n redirect_to new_question_path\n end\n end",
"def create\n @answer = @question.answers.build(answer_params)\n @answer.save\n respond_with( [ :admin, @survey, @section, @question, @answer ] )\n end",
"def create\n if user_signed_in? && current_user.admin?\n @courses = Course.all\n @quiz = current_user.quizzes.build(quiz_params)\n\n respond_to do |format|\n if @quiz.save\n format.html { redirect_to @quiz, notice: 'Quiz was successfully created.' }\n format.json { render :show, status: :created, location: @quiz }\n else\n format.html { render :new }\n format.json { render json: @quiz.errors, status: :unprocessable_entity }\n end\n end\n else\n redirect_to root_url, notice: \"Sorry, you have to sign in first.\"\n end\n end",
"def create\n @quiz = Quiz.new(quiz_params)\n\n respond_to do |format|\n if @quiz.save\n format.html { redirect_to new_temp_question_path(:qid => @quiz.id), notice: 'Quiz temporarily created. Proceed with adding Questions for your Quiz'}\n format.json { render action: 'show', status: :created, location: @quiz }\n else\n format.html { render action: 'new' }\n format.json { render json: @quiz.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new_quiz\n @quiz = Quiz.new\n end",
"def create\n @question = Question.find(params[:question_id])\n\n if !@question\n redirect_to :controller => :questions, :action => \"show\", :id => params[:question_id]\n end\n @answer = @question.answers.build(params[:answer])\n @answer.user_id = @current_user.id\n\n respond_to do |format|\n if @answer.save\n format.html { redirect_to @question, notice: 'Answer was successfully created.' }\n format.json { render json: @answer, status: :created, location: @answer }\n else\n format.html { render action: \"new\" }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_answer(answer_text,question_id,tenant_id,question_bank_id,answer_status)\n answer = Answer.new\n answer.answer_text = answer_text\n answer.question_id = question_id\n answer.question_bank_id = question_bank_id\n answer.tenant_id = tenant_id\n answer.answer_status = answer_status\n answer.save\n return answer\n end",
"def create\n if current_user.member?\n @answer = Answer.new(answer_params)\n @answer.user_id = current_user.id\n @answer.question_id = params[:questid]\n respond_to do |format|\n if @answer.save\n AnswerMailer.answer_email(@answer.question.user,@answer.user).deliver_now\n format.html { redirect_to '/', notice: 'Answer was successfully created.' }\n format.json { render :show, status: :created, location: @answer }\n else\n format.html { render :new }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n\n else\n respond_to do |format|\n format.html { redirect_to '/',notice: 'You are not authorized to answer questions' }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n\n end\n end",
"def create\n @quizzes_answer = Quizzes::Answer.new(quizzes_answer_params)\n\n respond_to do |format|\n if @quizzes_answer.save\n format.html { redirect_to @quizzes_answer, notice: 'Answer was successfully created.' }\n format.json { render :show, status: :created, location: @quizzes_answer }\n else\n format.html { render :new }\n format.json { render json: @quizzes_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @quiz = Quiz.new(quiz_params)\n @quiz.user_id = current_user.id\n @quiz.cardbox_id = session[:cardbox_id]\n if @quiz.save\n @practices = @quiz.cardbox.cards.collect{|c| c.practice_id}.sample(@quiz.number)\n @quiz.number.times do \n @quiz.repetition.times do\n quiz_item = QuizItem.new { |quiz_item|\n quiz_item.user_id = current_user.id\n quiz_item.quiz_id = @quiz.id\n quiz_item.practice_id = @practices.first\n }\n quiz_item.save\n end\n @practices.shift\n end\n session[:quiz_id] = @quiz.id\n respond_to do |format|\n format.html { redirect_to quiz_item_url(@quiz.quiz_items.first.id), notice: '测试开始,请您务必集中精力!' }\n format.json { render :show, status: :created, location: @quiz }\n end\n else\n respond_to do |format|\n format.html { render :new }\n format.json { render json: @quiz.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_answers_if\n if self.type.name == 'satisfaction-100'\n 5.times do |n|\n Answer.create(question: self, value: (n*25).to_s + \"%\")\n end\n end\n if self.type.name == 'free-text'\n Answer.create(question: self, value: \"textarea\")\n end\n end",
"def set_survey_quiz\n @survey_quiz = @survey_questionnaire = Survey::Quiz.find(params[:id])\n authorize @survey_quiz\n end",
"def create_question(question) \n visit questions_path\n \n click_on \"Ask question\"\n fill_in \"Title\", with: question.title\n fill_in \"Body\", with: question.body\n click_on \"Create\"\n end",
"def create\n @question = Question.find_by_id params[:question_id]\n @answer = Answer.new\n @answer.user = current_user\n @answer.question = @question\n @answer.content = params[:answer][:content]\n @answer.save\n end",
"def create\n @questionnaire = Questionnaire.new(params[:questionnaire])\n @quest = Quest.new(params[:quest])\n @choice = Choice.new(params[:choice])\n\n respond_to do |format|\n if @questionnaire.save\n flash[:notice]=\"Questionnaire Name #{@questionnaire.questionnaireName} Created\"\n format.html { redirect_to(:controller =>\"questionnaires\",:action =>\"new\") }\n #format.html { redirect_to(@questionnaire, :notice => 'Questionnaire was successfully created.') }\n format.xml { render :xml => @questionnaire, :status => :created, :location => @questionnaire }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @questionnaire.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def take_quiz\n end",
"def create\n authorize_action_for Question\n @question = current_user.questions.new(question_params)\n @question.user = current_user\n\n respond_to do |format|\n if @question.save\n format.html { redirect_to @question, notice: 'Question was successfully created.' }\n format.json { render :show, status: :created, location: @question }\n else\n format.html { render :new }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @quiz = Quiz.new(quiz_params)\n\n respond_to do |format|\n if @quiz.save\n format.html { redirect_to new_question_path, notice: 'Quiz was successfully created.' }\n format.json { render :show, status: :created, location: @quiz }\n else\n format.html { render :new }\n format.json { render json: @quiz.errors, status: :unprocessable_entity }\n end\n end\n end",
"def make_question_answer_tree\n before :each do\n @reply = 1\n @type_vendor = make_forms_for_app_type \"vendor\"\n @type_donor = make_forms_for_app_type \"donor\"\n \n @q1 = Questionnaire.create(:question => \"hello world\")\n @q2 = Questionnaire.create(:question => \"how are you?\")\n @a1a = Answers.create(:ans => \"hi\", :questionnaire_id => @q1.id, :leads_to => @q2.id)\n @a1b = Answers.create(:ans => @type_donor.app_type, :questionnaire_id => @q1.id, :results_to => @type_donor.id)\n @a2 = Answers.create(:ans => @type_vendor.app_type, :questionnaire_id => @q2.id, :results_to => @type_vendor.id)\n @q2.parent_id = @a1a.id\n @q2.save\n end\n end",
"def create\n begin\n ActiveRecord::Base.transaction do\n @learning_object.answers.create!({\n answer_text: params[:answer][:answer_text],\n is_correct: params[:answer][:is_correct] == \"1\",\n visible: params[:answer][:visible_answer] == \"1\"\n })\n @learning_object.validate_answers!\n end\n rescue AnswersCorrectnessError\n return redirect_to(edit_admin_learning_object_path(id: @learning_object.id, anchor: 'answer-settings'), :alert => \"Otázka nesmie mať viac ako jednu správnu odpoveď.\")\n rescue AnswersVisibilityError\n return redirect_to(edit_admin_learning_object_path(id: @learning_object.id, anchor: 'answer-settings'), :alert => \"Otázka nesmie mať viac ako jednu viditeľnú odpoveď.\")\n end\n\n redirect_to edit_admin_learning_object_path(id: @learning_object.id, anchor: 'answer-settings'), :notice => \"Odpoveď bola pridaná.\"\n end",
"def create_question\n @question = \"#{operand} #{type} #{operand}\"\n end",
"def create\n \t@quiz = Quiz.create(quiz_params)\n \[email protected] = current_user\n \tredirect_to :back\n\tend",
"def create\n\t\t@quiz = Quiz.new\n\t\t#create the quiz\n\t\t@quiz = Quiz.create(quiz_params)\n \t#redirections if quiz was saved or not along with flash messaging\n \tif @quiz.save\n \t\tflash[:notice] = \"Quiz was created\"\n \t\t#redirect to the home index page\n \t\tredirect_to root_path\n \telse\n \t\tflash[:alert] = \"Something went wrong.\"\n \t\tredirect_to root_path\n \tend\n end",
"def create\n #before_action :set_tag\n #ログインしているユーザーが質問を作る\n @question = current_user.questions.build(question_params)\n # respond_to: リクエストされるフォーマットがHTML形式の場合とJSON形式の場合で処理を分けることができる\n respond_to do |format|\n if @question.save\n # TODO: 経験値機能の処理\n # current_user.get_exp(10)\n # current_user.check_level_up\n format.html { redirect_to @question, notice: \"質問を投稿しました\" }\n format.json { render :show, status: :created, location: @question }\n else\n #savaできなかった場合\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t\tquiz = Quiz.new(quiz_params)\n\t\t\tif quiz.save\n\t\t\t\tcurrent_instructor.quizzes << quiz\n\t\t\t\trender json: { id: quiz.id }, status: 201\n\t\t\telse\n\t\t\t\trender json: { error: quiz.errors }, status: 422\n\t\t\tend\n\t\tend",
"def save_new_questions(questionnaire_id)\n\n if params[:new_question]\n # The new_question array contains all the new questions\n # that should be saved to the database\n for question_key in params[:new_question].keys\n q = Question.new(params[:new_question][question_key])\n q.questionnaire_id = questionnaire_id\n if @questionnaire.type == \"QuizQuestionnaire\"\n q.weight = 1 #setting the weight to 1 for quiz questionnaire since the model validates this field\n q.true_false = false\n end\n q.save if !q.txt.strip.empty?\n end\n end\n end",
"def create\n @question = Question.new(params[:question])\n @problem_set = ProblemSet.find(params[:problem_set_id])\n @question.problem_set_id = @problem_set.id\n @question.count = @problem_set.question_count + 1\n\n c = false\n ans = false\n\n @ans1 = Answer.new(params[:answer1]) \n @ans2 = Answer.new(params[:answer2]) \n @ans3 = Answer.new(params[:answer3]) \n @ans4 = Answer.new(params[:answer4]) \n\n if @ans1.correct or @ans2.correct or @ans3.correct or @ans4.correct\n c = true\n end\n if params[:answer1][:answer] == \"\"\n @ans1 = nil\n end\n if params[:answer2][:answer] == \"\"\n @ans2 = nil\n end\n if params[:answer3][:answer] == \"\"\n @ans3 = nil\n end\n if params[:answer4][:answer] == \"\"\n @ans4 = nil\n end\n\n if @ans1 or @ans2 or @ans3 or @ans4\n ans = true \n end\n\n respond_to do |format|\n if c and ans \n if @question.save\n @problem_set.question_count += 1\n @problem_set.save \n if @ans1\n @ans1.question_id = @question.id\n @ans1.save\n end\n \n if @ans2\n @ans2.question_id = @question.id\n @ans2.save\n end\n\n if @ans3\n @ans3.question_id = @question.id\n @ans3.save\n end\n \n if @ans4\n @ans4.question_id = @question.id\n @ans4.save\n end\n\n format.html { redirect_to(problem_set_questions_path(@problem_set), :notice => 'Question was successfully created.') }\n format.xml { render :xml => @question, :status => :created, :location => @question }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @question.errors, :status => :unprocessable_entity }\n end\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @ans1, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @quiz = Quiz.new(quiz_params)\n\n if @quiz.save\n redirect_to @quiz, notice: 'Assignment was successfully created.'\n else\n render :new\n end\n end",
"def create\n @question = Quizzes::Question.new(quizzes_question_params)\n\n respond_to do |format|\n if @question.save\n if params[:commit] =~ /add/i\n format.html { redirect_to edit_quiz_question_path(@question.quiz, @question) }\n else\n format.html { redirect_to quiz_questions_path(@question.quiz), notice: 'Question was successfully created.' }\n format.json { render :show, status: :created, location: @question }\n end\n else\n format.html { render :new }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n #return respond_access_denied \"Vastausaika on päättynyt\"\n @answer = Answer.new(params[:answer])\n @answer.deprecated = false\n\n note = %Q{Kiitos vastauksestasi.}\n respond_to do |format|\n if @answer.save\n session[:answer_id] = @answer.id\n format.html { redirect_to answer_path(@answer.key), notice: note }\n else\n format.html { render action: \"new\" }\n end\n end\n end",
"def create\n @question = Question.new(params[:question])\n \n # find user id\n add_user_id_or_nil(session[:user_id])\n \n # find category (to be changed)\n #@category = Category.find(3)\n #@question.category = @category\n \n # current time to created_at\n @question.created_at = Time.now\n \n # state approved\n @question.status = \"approved\"\n\n respond_to do |format|\n if @question.save\n format.html { redirect_to(@question, :notice => 'Question was successfully created.') }\n format.xml { render :xml => @question, :status => :created, :location => @question }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @question.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def quiz_params\n params.require(:quiz).permit(:name, :description, :course_id, :due_date, :randomize_questions, :randomize_answers, :show_all_questions, question_attributes: [:id, :body, :_destroy, choice_attributes: [:id, :choice_body, :correct, :_destroy]])\n end",
"def create\n @question = current_user.questions.new(post_params)\n if @question.save\n redirect_to @question, notice: t(:question_create)\n else\n render :new\n end\n end",
"def quiz_params\n params.require(:quiz).permit(:content, :answer, :category_id, :group_id, :order, :explanation)\n end",
"def start_questionnaire\n # bypassing the need for the user to select the survey - since we're launching with just one 'legislation'\n # When multiple legislations are available, this value will need to be provided by the form\n access_code = params[:survey_access_code] ||\n current_user.try(:default_jurisdiction) ||\n Survey::DEFAULT_ACCESS_CODE\n\n\n # if a dataset isn't supplied, create one for an authenticated user, or mock one for unauthenticated\n @dataset = Dataset.find_by_id(params[:dataset_id]) || (user_signed_in? ? current_user.datasets.create : Dataset.new)\n authorize! :update, @dataset\n\n # use the most recent survey\n @survey = Survey.where(:access_code => access_code).order(\"survey_version DESC\").first\n\n @response_set = ResponseSet.\n create(:survey => @survey,\n :user_id => current_user.try(:id),\n :dataset_id => @dataset.id\n )\n\n if @survey && @response_set\n session[:response_set_id] = current_user ? nil : @response_set.id\n\n if params[:source_response_set_id]\n source_response_set = ResponseSet.find(params[:source_response_set_id]) # TODO: ensure user has rights to copy the response set answers?\n @response_set.copy_answers_from_response_set!(source_response_set)\n end\n\n # flash[:notice] = t('surveyor.survey_started_success')\n redirect_to(surveyor.edit_my_survey_path(\n :survey_code => @survey.access_code, :response_set_code => @response_set.access_code))\n else\n flash[:notice] = t('surveyor.unable_to_find_that_legislation')\n redirect_to (user_signed_in? ? dashboard_path : root_path)\n end\n end",
"def create_a_question\n q = ShortQuestion.create({\n :text => params[:text],\n :belongs_to_topic => params[:topic],\n :by => params[:by] || \"admin\",\n :by_id => params[:by_id]\n })\n params[:answers].each do |ans|\n a = q.short_answers.create({\n :text => ans.text,\n :choice_num => ans.choice \n })\n end\n $r.hset(\"question:#{q.id}:answers\", :num_choices, params[:answers].length)\n # Not setting the value of the answers to 0, as any increment will take care of initializing those keys\n end",
"def save_questions(questionnaire_id)\n delete_questions questionnaire_id\n save_new_questions questionnaire_id\n \n if params[:question]\n for question_key in params[:question].keys\n begin\n if params[:question][question_key][:txt].strip.empty?\n # question text is empty, delete the question\n Question.delete(question_key)\n else\n if (@questionnaire.type == \"QuizQuestionnaire\")\n Question.update(question_key,:weight => 1, :txt => params[:question][question_key][:txt] )\n else\n Question.update(question_key, params[:question][question_key])\n end\n Question.update(question_key, params[:question][question_key])\n end\n rescue ActiveRecord::RecordNotFound \n end\n end\n end\n end",
"def create\n @question = Question.new(question_params)\n # topic = Topic.create(name: question_params[:topics])\n # usertopic = UserTopic.create(user_id: helpers.current_user, topic_id: topic.id)\n @question.user = helpers.current_user\n respond_to do |format|\n if @question.save\n format.html { redirect_to @question, notice: 'Question was successfully created.' }\n format.json { render :show, status: :created, location: @question }\n else\n format.html { render :new }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @admin_academy_question = Academy::Question.new(admin_academy_question_params)\n\n respond_to do |format|\n if @admin_academy_question.save\n format.html { redirect_to @admin_academy_question, notice: 'Question was successfully created.' }\n format.json { render action: 'show', status: :created, location: @admin_academy_question }\n else\n format.html { render action: 'new' }\n format.json { render json: @admin_academy_question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t@question = Question.find(params[:question_id])\n\t\t@answer = @question.answers.build(answer_params)\n\t\[email protected] = current_user\n\t\tif @answer.save\n\t\t\tflash[:success] = \"answer submitted\"\n\t\t\tredirect_to root_url\n\t\telse\n\t\t\tflash[:danger] = \"some error occured\"\n\t\t\trender 'new'\n\t\tend\n \n end",
"def create \n if params[:answer].present?\n if params[:answer].keys.length== 6 && [1,2].include?(params[:step].to_i) \n # render :text => params.inspect and return false\n params[:answer].each do |key,value|\n Answer.create(:question_id=>key,:answer=>value,:user_id=>1)\n end \n redirect_to courses_path(:step=>params[:step].to_i+1)\n elsif params[:answer].keys.length==4 && [3,4].include?(params[:step].to_i)\n params[:answer].each do |key,value|\n Answer.create(:question_id=>key,:answer=>value,:user_id=>1)\n end \n redirect_to courses_path(:step=>params[:step].to_i+1)\n else\n redirect_to courses_path \n end \n else\n redirect_to courses_path \n end\n end",
"def create\n @question = current_user.questions.build(params[:question])\n respond_to do |format|\n if @question.save\n format.html { redirect_to(@question, :notice => 'Question was successfully created.') }\n format.xml { render :xml => @question, :status => :created, :location => @question }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @question.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @quiz = Quiz.new(params[:quiz])\n\n if @quiz.save\n redirect_to @quiz, notice: 'Quiz was successfully created.'\n else\n render action: \"new\"\n end\n end",
"def questions\n \n end",
"def create\n\n\t\trespond_to do |format|\n\t\t\tif @answer.save\n\t\t\t\tformat.html { redirect_to @answer, notice: 'Survey was successfully created.' }\n\t\t\t\tformat.json { render action: 'show', status: :created, location: @answer }\n\t\t\telse\n\t\t\t\tformat.html { render action: 'new' }\n\t\t\t\tformat.json { render json: @answer.errors, status: :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def create\n @quiz = Quiz.new(quiz_params)\n\n respond_to do |format|\n if @quiz.save\n format.html { redirect_to @quiz, notice: \"Quiz was successfully created.\" }\n format.json { render :show, status: :created, location: @quiz }\n\t\tmy_array = []\n\t\tmy_array << @quiz.option1\n\t\tmy_array << @quiz.option2\n\t\tmy_array << @quiz.option3\n\t\tmy_array << @quiz.option4\n\t\t\n\t\tcorrect_respo = my_array[@quiz.correct_response.to_i - 1]\n\t\[email protected]_response_text = correct_respo\n\t\[email protected]\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @quiz.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n user_id = session[:user_id]\n quiz_id = Question.find(params[:question_id]).quiz_id\n\n @question = Question.find(params[:question_id])\n @question_answer = Answer.new(:question_id => @question.id, :quiz_id => @question.quiz.id, :user_id => current_user.id)\n\n # check if user has already submitted an answer for this question\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @question_answer }\n end\n end",
"def test_AnswerQuestionsFromQuestionSet\n randomName = SecureRandom.hex(4)\n randomReq = SecureRandom.hex(4)\n \n randomEmail = SecureRandom.hex(4) \n randomLastName = SecureRandom.hex(4)\n \n #PRECONDITION: Must be logged in\n Common.login(Users::USER_EMAIL, Users::PASSWORD)\n \n current_url = $browser.current_url\n \n #Create an empty Question Sets\n self.CreateQuestionSetEmpty(randomName)\n \n $wait.until{\n $browser.find_element(:xpath => QuestionSetsDetail::QUESTION_SETS_DETAIL_NEW_QUESTION_XPATH).displayed? \n }\n \n # Click on \"New Question\"\n Common.click_and_load(QuestionSetsDetail::QUESTION_SETS_DETAIL_NEW_QUESTION_XPATH)\n $wait.until{\n $browser.find_element(:xpath => QuestionSetsNewQuestion::QUESTION_SETS_NEW_QUESTION_NAME_XPATH).displayed?\n }\n $wait.until{\n $browser.find_element(:xpath => QuestionSetsNewQuestion::QUESTION_SETS_NEW_QUESTION_QUESTION_XPATH).displayed?\n } \n \n # Fill all the fields\n $browser.find_element(:xpath => QuestionSetsNewQuestion::QUESTION_SETS_NEW_QUESTION_NAME_XPATH).send_keys QuestionSetsNewQuestion::QUESTION_SETS_NEW_QUESTION_NAME_TEXT_XPATH\n $browser.find_element(:xpath => QuestionSetsNewQuestion::QUESTION_SETS_NEW_QUESTION_ORDER_XPATH).send_keys QuestionSetsNewQuestion::QUESTION_SETS_NEW_QUESTION_ORDER_INT_XPATH\n $browser.find_element(:xpath => QuestionSetsNewQuestion::QUESTION_SETS_NEW_QUESTION_QUESTION_XPATH).send_keys QuestionSetsNewQuestion::QUESTION_SETS_NEW_QUESTION_NAME_TEXT_XPATH\n elementText = $browser.find_element(:xpath => QuestionDetailPage::QUESTION_DETAIL_TEXT_XPATH)\n if elementText.attribute(\"checked\")\n $browser.find_element(:xpath => QuestionSetsQuestionBuilder::QUESTION_SETS_QUESTION_BUILDER_TEXT_XPATH).click\n end\n elementOptional = $browser.find_element(:xpath => QuestionDetailPage::QUESTION_DETAIL_OPTIONAL_XPATH)\n if elementOptional.attribute(\"checked\")\n $browser.find_element(:xpath => QuestionSetsQuestionBuilder::QUESTION_SETS_QUESTION_BUILDER_OPTIONAL_XPATH).click\n end\n \n # Click on \"Save\"\n Common.click_and_load(QuestionSetsNewQuestion::QUESTION_SETS_NEW_QUESTION_BTN_SAVE_XPATH)\n \n #Add Answers\n $wait.until{\n $browser.find_element(:xpath => QuestionDetailPage::QUESTION_DETAIL_NEW_ANSWER_XPATH).displayed?\n }\n Common.click_and_load(QuestionDetailPage::QUESTION_DETAIL_NEW_ANSWER_XPATH) \n Common.displayed(AnswerEditPage::ANSWER_EDIT_BTN_SAVE_XPATH) \n \n Common.displayed(AnswerEditPage::ANSWER_EDIT_NAME_XPATH) \n Common.displayed(AnswerEditPage::ANSWER_EDIT_ANSWER_XPATH) \n Common.displayed(AnswerEditPage::ANSWER_EDIT_ORDER_XPATH) \n Common.displayed(AnswerEditPage::ANSWER_EDIT_SCORE_XPATH) \n \n $browser.find_element(:xpath => AnswerEditPage::ANSWER_EDIT_NAME_XPATH).send_keys AnswerEditPage::ANSWER_DATA_NAME_1_TEXT\n $browser.find_element(:xpath => AnswerEditPage::ANSWER_EDIT_ANSWER_XPATH).send_keys AnswerEditPage::ANSWER_DATA_NAME_1_TEXT\n $browser.find_element(:xpath => AnswerEditPage::ANSWER_EDIT_ORDER_XPATH).send_keys AnswerEditPage::ANSWER_DATA_ORDER_1_INT\n $browser.find_element(:xpath => AnswerEditPage::ANSWER_EDIT_SCORE_XPATH).send_keys AnswerEditPage::ANSWER_DATA_SCORE_1_INT\n Common.click_and_load(AnswerEditPage::ANSWER_EDIT_BTN_SAVE_NEW_XPATH)\n Common.displayed(AnswerEditPage::ANSWER_EDIT_BTN_SAVE_XPATH) \n \n Common.displayed(AnswerEditPage::ANSWER_EDIT_NAME_XPATH) \n Common.displayed(AnswerEditPage::ANSWER_EDIT_ANSWER_XPATH) \n Common.displayed(AnswerEditPage::ANSWER_EDIT_ORDER_XPATH) \n Common.displayed(AnswerEditPage::ANSWER_EDIT_SCORE_XPATH) \n \n $browser.find_element(:xpath => AnswerEditPage::ANSWER_EDIT_NAME_XPATH).send_keys AnswerEditPage::ANSWER_DATA_NAME_2_TEXT\n $browser.find_element(:xpath => AnswerEditPage::ANSWER_EDIT_ANSWER_XPATH).send_keys AnswerEditPage::ANSWER_DATA_NAME_2_TEXT\n $browser.find_element(:xpath => AnswerEditPage::ANSWER_EDIT_ORDER_XPATH).send_keys AnswerEditPage::ANSWER_DATA_ORDER_2_INT\n $browser.find_element(:xpath => AnswerEditPage::ANSWER_EDIT_SCORE_XPATH).send_keys AnswerEditPage::ANSWER_DATA_SCORE_2_INT\n \n Common.click_and_load(AnswerEditPage::ANSWER_EDIT_BTN_SAVE_XPATH)\n Common.displayed(AnswerDetailPage::ANSWER_DETAIL_BACK_TO_QUESTION_XPATH)\n \n # Create Job with Question Set asociated\n Common.goToTab(HomePage::REQUISITIONS_LINK_XPATH)\n $wait.until{\n $browser.find_element(:xpath => RequisitionsHomePage::REQUISITIONS_PAGE_BTN_NEW_XPATH).displayed?\n }\n Common.click_and_load(RequisitionsHomePage::REQUISITIONS_PAGE_BTN_NEW_XPATH) \n $wait.until{\n $browser.find_element(:xpath => RequisitionsNewAndEdit::REQUISITIONS_NEW_BTN_CONTINUE_XPATH).displayed?\n }\n Common.click_and_load(RequisitionsNewAndEdit::REQUISITIONS_NEW_BTN_CONTINUE_XPATH) \n $wait.until{\n $browser.find_element(:xpath => RequisitionsNewAndEdit::REQUISITIONS_NEW_QUESTIONS_SET_XPATH).displayed?\n }\n $browser.find_element(:id => RequisitionsNewAndEdit::REQUISITIONS_NEW_JOB_TITLE_ID).send_keys randomReq\n $browser.find_element(:xpath => RequisitionsNewAndEdit::REQUISITIONS_NEW_PRIMARY_RECRUITER_TEXT_XPATH).send_keys RequisitionsNewAndEdit::REQUISITIONS_NEW_DATA_PRIMARY_RECRUITER_TEXT\n $browser.find_element(:xpath => RequisitionsNewAndEdit::REQUISITIONS_NEW_LOCATION_XPATH).send_keys RequisitionsNewAndEdit::REQUISITIONS_NEW_DATA_LOCATION_TEXT\n $browser.find_element(:xpath => RequisitionsNewAndEdit::REQUISITIONS_NEW_DEPARTAMENT_OPTION_XPATH).click\n $browser.find_element(:xpath => RequisitionsNewAndEdit::REQUISITIONS_NEW_MIN_SALARY_XPATH).send_keys RequisitionsNewAndEdit::REQUISITIONS_NEW_DATA_MIN_SALARY_TEXT\n $browser.find_element(:xpath => RequisitionsNewAndEdit::REQUISITIONS_NEW_MAX_SALARY_XPATH).send_keys RequisitionsNewAndEdit::REQUISITIONS_NEW_DATA_MAX_SALARY_TEXT\n $browser.find_element(:xpath => RequisitionsNewAndEdit::REQUISITIONS_NEW_QUESTIONS_SET_XPATH).send_keys randomName\n unless $browser.find_element(:xpath => RequisitionsNewAndEdit::REQUISITIONS_NEW_POST_JOB_BOX_XPATH).attribute(\"checked\")\n $browser.find_element(:xpath => RequisitionsNewAndEdit::REQUISITIONS_NEW_POST_JOB_BOX_XPATH).click\n end\n \n Common.click_and_load(RequisitionsNewAndEdit::REQUISITIONS_NEW_BTN_SAVE_XPATH)\n \n #JobBoard without login\n CustomSettings.JobBoardLogin(false)\n \n Common.goToTab(HomePage::BOARD_SETUP_TAB_LINK_XPATH)\n Common.displayed(BoardSetupHomePage::CAREERS_LINK_LIST_XPATH)\n Common.click_and_load(BoardSetupHomePage::CAREERS_LINK_LIST_XPATH)\n CustomSettings.BoardSetupInit\n CustomSettings.ResumeRequired(false)\n CustomSettings.DefineEEOQuestions(false, false, false, false, false)\n \n # Go to Job Board\n $browser.get(HomePage::JOB_BOARD_URL)\n \n # 1 - Apply to a job from the job board site, with Question Set asociated.\n $browser.get(HomePage::JOB_BOARD_URL)\n $wait.until{\n $browser.find_element(:xpath => JobBoardHomePage::JOB_BOARD_RETURN_TO_SEARCH_XPATH).displayed?\n }\n Common.click_and_load(JobBoardHomePage::JOB_BOARD_JOB_LIST_XPATH + \"//*[text()[contains(.,'\" + randomReq + \"')]]\") \n $wait.until{\n $browser.find_element(:xpath => JobBoardJobDetail::JOB_BOARD_APPLY_JOB_LINK_XPATH).displayed?\n }\n Common.click_and_load(JobBoardJobDetail::JOB_BOARD_APPLY_JOB_LINK_XPATH) \n $wait.until{\n $browser.find_element(:xpath => JobBoardJobDetail::JOB_BOARD_APPLY_JOB_EMAIL_XPATH).displayed?\n }\n $browser.find_element(:xpath => JobBoardJobDetail::JOB_BOARD_APPLY_JOB_EMAIL_XPATH).send_keys randomEmail + Users::EMAIL_DOMAIN\n $browser.find_element(:xpath => JobBoardJobDetail::JOB_BOARD_APPLY_JOB_FIRST_NAME_XPATH).send_keys randomEmail\n $browser.find_element(:xpath => JobBoardJobDetail::JOB_BOARD_APPLY_JOB_LAST_NAME_XPATH).send_keys randomLastName\n \n #If How did you hear about us? is displayed\n begin\n aboutUsSelect = $browser.find_element(:xpath => JobBoardJobDetail::JOB_BOARD_APPLY_JOB_HEAR_ABOUT_US_XPATH).displayed?\n rescue\n aboutUsSelect = false\n end \n if aboutUsSelect\n $browser.find_element(:xpath => JobBoardJobDetail::JOB_BOARD_APPLY_JOB_HEAR_ABOUT_US_XPATH).send_keys \"Job Board\"\n end\n Common.click_and_load(JobBoardJobDetail::JOB_BOARD_APPLY_JOB_CONTINUE_XPATH) \n \n $wait.until{\n $browser.find_element(:xpath => JobBoardJobDetail::JOB_BOARD_APPLY_JOB_RETURN_JOBSEARCH_XPATH).displayed?\n }\n begin\n continue_button = $browser.find_element(:xpath => JobBoardJobDetail::JOB_BOARD_APPLY_JOB_CONTINUE_XPATH).displayed?\n rescue\n continue_button = false\n end \n if continue_button\n Common.click_and_load(JobBoardJobDetail::JOB_BOARD_APPLY_JOB_CONTINUE_XPATH)\n end\n \n $wait.until{\n $browser.find_element(:xpath => JobBoardJobDetail::JOB_BOARD_APPLY_JOB_RETURN_JOBSEARCH_XPATH).displayed?\n }\n begin\n continue_button = $browser.find_element(:xpath => JobBoardJobDetail::JOB_BOARD_APPLY_JOB_CONTINUE_XPATH).displayed?\n rescue\n continue_button = false\n end \n if continue_button\n Common.click_and_load(JobBoardJobDetail::JOB_BOARD_APPLY_JOB_CONTINUE_XPATH)\n end\n $wait.until{\n $browser.find_element(:xpath => JobBoardJobDetail::JOB_BOARD_APPLY_JOB_SUBMIT_XPATH).displayed?\n } \n \n \n # 2 - Answer questions\n $browser.find_element(:xpath => JobBoardJobDetail::JOB_BOARD_QUESTIONS_SET_QUESTION_1_INPUT_XPATH + \"//select\").send_keys AnswerEditPage::ANSWER_DATA_NAME_1_TEXT\n \n # 3 - Click on Submit\n Common.click_and_load(JobBoardJobDetail::JOB_BOARD_QUESTIONS_SET_BTN_SUBMIT_XPATH)\n \n $wait.until{\n $browser.find_element(:xpath => JobBoardJobDetail::JOB_BOARD_APPLY_JOB_RETURN_JOBSEARCH_XPATH).displayed?\n }\n \n $browser.get(current_url)\n # Click on Tab \"Question Sets\"\n Common.goToTab(HomePage::QUESTION_SETS_LINK_XPATH)\n $wait.until{\n $browser.find_element(:xpath => QuestionSetsHomePage::QUESTION_SETS_HOME_BTN_NEW_XPATH).displayed?\n }\n \n # Click on previously created Question Set's name from the list\n Common.click_and_load(QuestionSetsHomePage::QUESTION_SET_LIST_XPATH + \"//*[text()[contains(.,'\" + randomName + \"')]]\")\n $wait.until{\n $browser.find_element(:xpath => QuestionSetsDetail::QUESTION_SETS_DETAIL_NEW_QUESTION_XPATH).displayed? \n } \n \n assert $wait.until{\n $browser.find_element(:xpath => QuestionSetsDetail::QUESTION_SET_DETAIL_PRESCREENS_FIRST_XPATH).displayed?\n }\n \n Common.click_and_load(QuestionSetsDetail::QUESTION_SET_DETAIL_PRESCREENS_FIRST_APPLICATION_XPATH)\n $wait.until{\n $browser.find_element(:xpath => ApplicationsDetailPage::APPLICATIONS_DETAIL_PRESCREEN_1_XPATH).displayed?\n }\n assert $wait.until{\n $browser.find_element(:xpath => ApplicationsDetailPage::APPLICATIONS_DETAIL_JOB_TEXT_XPATH + \"[//*[text()[contains(.,'\" + randomReq + \"')]]]\").displayed?\n $browser.find_element(:xpath => ApplicationsDetailPage::APPLICATIONS_DETAIL_PRESCREEN_1_XPATH).displayed?\n } \n \n end",
"def create\n @question = current_user.questions.build(question_params)\n\t \n\t if @question.save\n\t\tflash[:suceess] = \"New question posted\"\n\t else\n\t \tflash[:error] = \"Unexpected Error!\"\n end\n\t redirect_to(user_path(current_user))\n end",
"def new\n @question = @quiz.questions.new\n\n 4.times { @question.answers.build }\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @question }\n end\n end",
"def new\n\t\t@quiz = Quiz.new\n\tend",
"def create\n \n @user_answer = UserAnswer.new(user_answer_params)\n count = 0\n \n #Loop through questions indefinitely\n respond_to do |format|\n if @user_answer.save\n @question = Question.where(id: @user_answer.question_id).first\n @quiz_id = @question.quiz_id\n @questions = Question.where(quiz_id: @quiz_id)\n @numquestions = @questions.count\n @quizzes = Quiz.where(id: @quiz_id)\n @lessonId = @quizzes.first.lesson_id\n\n if @question.questionNum < @numquestions\n @test = @questions.where('id > ?', @question.id).order(id: :asc).first\n\n format.html { redirect_to :controller=>'questions', :id => @test, :action=>'show', notice: 'User answer was successfully created.'}\n else\n #format.html { redirect_to :controller=>'questions', :id=>@questions.shuffle.first.id, :action=>'show' }\n format.html { redirect_to :controller=>'questions', :id=>@questions.first.id, :action=>'show' }\n end\n else\n format.html { render :new }\n format.json { render json: @user_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @questionnaire = Questionnaire.new(questionnaire_params)\n @questionnaire.user = @current_user_email\n # flash[:alert] = \"----------> #{@questionnaire.is_name_unique?} <-----------\"\n\n respond_to do |format|\n if @questionnaire.save\n format.html { redirect_to @questionnaire, notice: 'Questionnaire was successfully created.' }\n format.json { render :show, status: :created, location: @questionnaire }\n else\n format.html { render :new }\n format.json { render json: @questionnaire.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if params[:commit] == 'Avançar'\n @quiz = Quiz.find(params[:quiz_id])\n answer = params[:user_answ]\n\n answer = compare_answers @quiz, answer\n \n\n\n respond_to do |format|\n if answer >= 0.7\n format.html { redirect_to root_path, notice: \"Muito bem!\" }\n else\n format.html { redirect_to root_path, notice: \"Você é muito feio!\" }\n end\n end\n else \n @quiz = Quiz.new(quiz_params)\n respond_to do |format|\n if @quiz.save\n format.html { redirect_to quizzes_path, notice: 'Quiz was successfully created.' }\n format.json { render :show, status: :created, location: @quiz }\n else\n format.html { render :new }\n format.json { render json: @quiz.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def create\n #render :json => params[:quiz_answer]\n #return\n @quiz=Quiz.find(params[:quiz_id])\n\n\n @quiz_answer = QuizAnswer.new(quiz_answer_params)\n\n @question=Question.find(params[:quiz_answer][:question_id])\n #render :json => @quiz.questions\n #return\n\n @next_question = (@quiz.questions.map(&:id) - current_user.quiz_answers.map(&:question_id) - [@question.id])\n #render :json => @quiz.questions\n #return\n\n\n respond_to do |format|\n if @quiz_answer.save\n\n #puts \"check next question #{@next_question}\"\n if @next_question == []\n current_user.current_route = \"/my_dashboard\"\n current_user.save!\n #redirect_to snazzmeup_path,:alert=>\"Successfully given quiz response\"\n redirect_to quiz_review_path(@quiz.id), :alert=>\"Successfully given quiz response\"\n return\n else\n @next_question = @next_question[0]\n current_user.current_route = \"/take_test/#{@quiz.id}/#{@next_question}\"\n current_user.save!\n end\n\n format.html { redirect_to take_test_path(@quiz.id,@next_question)}\n format.json { render action: 'show', status: :created, location: @quiz_answer }\n\n else\n format.html { redirect_to take_test_path(@quiz.id, @question.id), notice: 'Howdy!! You need to select one option.' }\n format.json { render json: @quiz_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n purpose = params[:question].delete(:purpose)\n @question = Question.new(params[:question])\n @question.caption ||= \"\"\n @question.page = @page\n\n respond_to do |format|\n if @question.save and @question.update_attribute(:type, params[:question][:type])\n if purpose\n SpecialFieldAssociation.create :question => @question, :purpose => purpose, :questionnaire => @questionnaire\n end\n \n @question = Question.find(@question.id)\n if @question.kind_of? Questions::Field and @question.caption.blank?\n # get the default field caption in\n @question.caption = \"Pulse aqu’ para escribir una pregunta\"\n @question.save\n end\n \n format.html { redirect_to question_url(@question) }\n format.xml { head(:created, :location => question_url(@questionnaire, @page, @question, :format => 'xml')) }\n format.json { head(:created, :location => question_url(@questionnaire, @page, @question, :format => 'json')) }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @question.errors.to_xml, :status => 500 }\n format.json { render :json => @question.errors.to_json, :status => 500 }\n end\n end\n end"
] | [
"0.7897601",
"0.7501515",
"0.7403573",
"0.7266644",
"0.72099024",
"0.71171844",
"0.71104497",
"0.7106334",
"0.70619726",
"0.6953774",
"0.6934844",
"0.6914081",
"0.68823755",
"0.6860595",
"0.6855735",
"0.68445885",
"0.6761288",
"0.6761188",
"0.67550564",
"0.6740952",
"0.6721489",
"0.6721314",
"0.6711183",
"0.6709678",
"0.6674255",
"0.66620773",
"0.66544336",
"0.6651024",
"0.66419625",
"0.6640797",
"0.66236776",
"0.66112125",
"0.66079515",
"0.6603606",
"0.65813726",
"0.6566193",
"0.65552914",
"0.65429497",
"0.6540302",
"0.65352535",
"0.6524998",
"0.6521256",
"0.65185696",
"0.65003824",
"0.6495317",
"0.6487771",
"0.64819247",
"0.6456208",
"0.6442567",
"0.64381427",
"0.6437139",
"0.6433839",
"0.6432303",
"0.64187276",
"0.6415541",
"0.6414787",
"0.64134973",
"0.6401297",
"0.63965255",
"0.6377696",
"0.63653606",
"0.63535225",
"0.6346733",
"0.63411736",
"0.63395756",
"0.6331232",
"0.6330325",
"0.632941",
"0.63280606",
"0.63080984",
"0.63066465",
"0.630633",
"0.6302817",
"0.6297354",
"0.6275011",
"0.6274686",
"0.6272087",
"0.626545",
"0.62586397",
"0.6249269",
"0.6239834",
"0.6231243",
"0.6230725",
"0.62270105",
"0.62147826",
"0.6209885",
"0.6209771",
"0.62089354",
"0.6204586",
"0.62042254",
"0.6198651",
"0.6194116",
"0.6191264",
"0.61830837",
"0.6176526",
"0.6174292",
"0.6165329",
"0.6162452",
"0.61591446",
"0.61555254"
] | 0.7123384 | 5 |
edit a quiz questionnaire | def edit_quiz
@questionnaire = Questionnaire.find(params[:id])
if [email protected]_by_anyone?
render :edit
else
flash[:error] = "Your quiz has been taken by some other students, editing cannot be done any more."
redirect_to controller: 'submitted_content', action: 'view', id: params[:pid]
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def edit_quiz\n\n @questionnaire = Questionnaire.find(params[:id])\n render :edit\n end",
"def update_quiz\n @questionnaire = Questionnaire.find(params[:id])\n redirect_to controller: 'submitted_content', action: 'view', id: params[:pid] if @questionnaire == nil\n if params['save']\n @questionnaire.update_attributes(questionnaire_params)\n for qid in params[:question].keys\n @question = Question.find(qid)\n @question.txt = params[:question][qid.to_sym][:txt]\n @question.save\n @quiz_question_choices = QuizQuestionChoice.where(question_id: qid)\n i=1\n for quiz_question_choice in @quiz_question_choices\n choose_question_type(i, quiz_question_choice)\n i+=1\n end\n end\n end\n redirect_to controller: 'submitted_content', action: 'view', id: params[:pid]\n end",
"def edit_quiz(id)\r\n clear\r\n custom_banner\r\n puts\r\n # In case the file is corrupted or empty, useing rescue to handle exception and prompt user to go back to create a new custom object and save.\r\n begin quiz_array = @custom.custom_load['Custom'][id - 1]['Content']\r\n options = []\r\n if quiz_array.size > 0\r\n # Passing the custom id and selecting question item to edit_single_question method\r\n quiz_array.each do |e|\r\n options.push({ name: \"Question:#{e['Id']}\", value: lambda {\r\n edit_single_question(id, e)\r\n } })\r\n end\r\n else\r\n puts 'Sorry,the content is empty.'\r\n end\r\n rescue JSON::ParserError, NoMethodError, NoMemoryError, StandardError\r\n puts \"It seems the custom content is empty. Please move to custom menu to add a new custom collection.\\n\\n\\n\"\r\n end\r\n # Provide go back access\r\n options.push({ name: 'Back', value: lambda {\r\n clear\r\n edit_collection\r\n } })\r\n option = @prompt.select(\"Please select one question to edit or turn back to upper menu.\\n\\n\", options,\r\n help: \"(Select with pressing ↑/↓ arrow keys, and then pressing Enter)\\n\\n\\n\", show_help: :always)\r\n end",
"def edit\n\t\t@quiz = Quiz.find(params[:id])\n \tend",
"def edit_question\n\t\t\tquizzes = current_instructor.quizzes\n\t\t\t@found = 0\n\t\t\tquizzes.each do |quiz|\n\t\t\t\tif(quiz.questions.exists?(:id => params[:question_id]))\n\t\t\t\t\t@found = @found + 1\n\t\t\t\tend \n\t\t\tend\n\t\t\tif (@found > 0)\n\t\t\t\tquestion = Question.find(params[:question_id])\n\t\t\t\tif (question.update(question_params))\n\t\t\t\t\trender json: { success: true, data: { :question => question }, info:{} }, status: 200\n\t\t\t\telse\n\t\t\t\t\trender json: { error: question.errors }, status: 422 \n\t\t\t\tend\t\n\t\t\telse\n\t\t\t\trender json: { error:\"Question is not found\" }, status: 422\n\t\t\tend\n\t\tend",
"def edit(index, params)\n question.update(question: params[:questions][\"question_#{index + 1}\".to_sym])\n choice_num = 1\n @choices.select { |choice| choice.question_id == question.id}.each do |choice|\n choice.update(choice: params[\"choice_#{choice_num}\".to_sym])\n choice_num += 1\n end\n end",
"def edit_question(part_num, question_num)\n frm.link(:id=>\"assesssmentForm:parts:#{part_num.to_i-1}:parts:#{question_num.to_i-1}:modify\").click\n end",
"def update\n @question = Question.find(params[:id])\n @quiz = Quiz.find(params[:id])\n if @quiz.update(quiz_params)\n flash[:success] = \"Quiz updated\"\n redirect_to @quiz\n else\n render 'edit'\n end\n end",
"def update_quiz\n @questionnaire = Questionnaire.find(params[:id])\n redirect_to :controller => 'submitted_content', :action => 'edit', :id => params[:pid] if @questionnaire == nil\n if params['save']\n @questionnaire.update_attributes(params[:questionnaire])\n\n for qid in params[:question].keys\n question_advices = QuestionAdvice.find_all_by_question_id(qid)\n i=1\n for question_advice in question_advices\n if params[:question][qid][\"weight\"] == i.to_s\n score = 1\n else\n score = 0\n end\n i+=1\n question_advice.update_attributes(:score => score, :advice => params[:question_advice][question_advice.id.to_s][\"advice\"])\n end\n end\n save_questionnaire\n #save_choices @questionnaire.id\n end\n redirect_to :controller => 'submitted_content', :action => 'edit', :id => params[:pid]\n end",
"def edit_question\n require_admin\n if request.post? # pass in the entire object you want to edit\n #over-write the data of the existing question\n #title, text, etc.\n #lookup the existing object in the db, edit the values, and save it.\n \n @question = Question.find(edit_question_params[:id]) #inbound data object with the 3 params\n @question.title = edit_question_params[:title]\n @question.text = edit_question_params[:text]\n @question.forum_id = edit_question_params[:forum_id]\n @question.keywords = edit_question_params[:keywords]\n @question.save() # save the db!\n \n #send the user back to the view_question with hte question id we just saved\n redirect_to controller:\"qa\", action:\"view_question\", id:@question.id\n #returns the form\n else # handles the get request which is to return a single question\n @question = Question.find(Integer(params[\"id\"]))\n end\n end",
"def update\n @question = @quiz.questions.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n flash[:notice] = 'Question was successfully updated.'\n format.html { redirect_to(quiz_questions_path(@quiz)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @question.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @question.statement = params[:question][:statement]\n unless @question.online\n @question.level = (@chapter.section.fondation? ? 0 : params[:question][:level])\n if @question.is_qcm\n if params[:question][:many_answers] == '1'\n @question.many_answers = true\n else\n if @question.many_answers\n # Must check there is only one true\n i = 0\n @question.items.order(:id).each do |c|\n if c.ok\n if i > 0\n c.ok = false\n flash[:info] = \"Attention, il y avait plusieurs réponses correctes à cet exercice, seule la première a été gardée.\"\n c.save\n end\n i = i+1\n end\n end\n if @question.items.count > 0 && i == 0\n # There is no good answer\n flash[:info] = \"Attention, il n'y avait aucune réponse correcte à cet exercice, une réponse correcte a été rajoutée aléatoirement.\"\n @item = @question.items.order(:id).first\n @item.ok = true\n @item.save\n end\n end\n @question.many_answers = false\n end\n else\n if params[:question][:decimal] == '1'\n @question.decimal = true\n @question.answer = params[:question][:answer].gsub(\",\",\".\").to_f\n else\n @question.decimal = false\n @question.answer = params[:question][:answer].gsub(\",\",\".\").to_i\n end\n end\n end\n \n if @question.save\n redirect_to chapter_path(@chapter, :type => 5, :which => @question.id)\n else\n render 'edit'\n end\n end",
"def update\n\t@question = Question.find(params[:id])\n\t@questionnaire_question=QuestionnaireQuestion.find_by_question_id(@question.id)\n\t@questionnaire=Questionnaire.find(@questionnaire_question.questionnaire_id)\n\n\trespond_to do |format|\n\t if @question.update_attributes(params[:question])\n\t#\tformat.html { redirect_to(@question, :notice => 'Question was successfully updated.') }\n\t\tformat.html { redirect_to new_question_path(:questionnaire_id=>@questionnaire.id), :notice => 'Answer was successfully Saved.' }\n\t\tformat.xml { head :ok }\n\t else\n\t\tformat.html { render :action => \"edit\" }\n\t\tformat.xml { render :xml => @question.errors, :status => :unprocessable_entity }\n\t end\n\tend\n end",
"def edit \n redirect_to root_path unless current_user.is_admin?\n \t@quiz = Quiz.find(params[:id]) \n end",
"def update\n @quiz = Quiz.find(params[:id])\n\n if @quiz.update_attributes(params[:quiz])\n redirect_to @quiz, notice: 'Quiz was successfully updated.'\n else\n render action: \"edit\"\n end\n end",
"def test_edit_questionnaire\r\n post :edit, {:id => @Questionnaire, :save => true, \r\n :questionnaire => {:name => \"test edit name\", \r\n :type => \"ReviewQuestionnaire\",\r\n :min_question_score => 1,\r\n :max_question_score => 3}}\r\n assert_response(:success)\r\n assert_not_nil(Questionnaire.find(:first, :conditions => [\"name = ?\", \"test edit name\"]))\r\n end",
"def set_quiz_answer\n @quiz_answer = QuizAnswer.find(params[:id])\n end",
"def save_questions(questionnaire_id)\n delete_questions questionnaire_id\n save_new_questions questionnaire_id\n \n if params[:question]\n for question_key in params[:question].keys\n begin\n if params[:question][question_key][:txt].strip.empty?\n # question text is empty, delete the question\n Question.delete(question_key)\n else\n if (@questionnaire.type == \"QuizQuestionnaire\")\n Question.update(question_key,:weight => 1, :txt => params[:question][question_key][:txt] )\n else\n Question.update(question_key, params[:question][question_key])\n end\n Question.update(question_key, params[:question][question_key])\n end\n rescue ActiveRecord::RecordNotFound \n end\n end\n end\n end",
"def quiz\n end",
"def edit_answer\n require_admin\n if request.post?\n @answer = Answer.find(edit_answer_params[:id]) #inbound data object with 2 params(possibly 3 if we need to include question id)\n @answer.text = edit_answer_params[:text]\n @answer.save() #save to the db\n #@answer.questionId = edit_question_params.questionId\n redirect_to controller:\"qa\", action:\"view_question\", id:@answer.question_id\n \n else\n @answer = Answer.find(Integer(params[\"id\"]))\n end\n end",
"def edit\n @question = Question.find(params[:id])\n end",
"def edit\n @question = Question.find(params[:id])\n end",
"def update_existing_quiz_question(course_id,quiz_id,id,question__question_name__,question__question_text__,question__question_type__,opts={})\n query_param_keys = [\n \n ]\n\n form_param_keys = [\n :question__question_name__,\n :question__question_text__,\n :question__quiz_group_id__,\n :question__question_type__,\n :question__position__,\n :question__points_possible__,\n :question__correct_comments__,\n :question__incorrect_comments__,\n :question__neutral_comments__,\n :question__text_after_answers__,\n :question__answers__,\n \n ]\n\n # verify existence of params\n raise \"course_id is required\" if course_id.nil?\n raise \"quiz_id is required\" if quiz_id.nil?\n raise \"id is required\" if id.nil?\n raise \"question__question_name__ is required\" if question__question_name__.nil?\n raise \"question__question_text__ is required\" if question__question_text__.nil?\n raise \"question__question_type__ is required\" if question__question_type__.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :course_id => course_id,\n :quiz_id => quiz_id,\n :id => id,\n :question__question_name__ => question__question_name__,\n :question__question_text__ => question__question_text__,\n :question__question_type__ => question__question_type__\n )\n\n # resource path\n path = path_replace(\"/v1/courses/{course_id}/quizzes/{quiz_id}/questions/{id}\",\n :course_id => course_id,\n :quiz_id => quiz_id,\n :id => id)\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:put, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:put, path, query_params, form_params, headers)\n page_params_store(:put, path)\n QuizQuestion.new(response)\n end",
"def update\n if @question.update(question_params)\n redirect_to overview_exam_path(@question.exam), notice: _('Question was successfully updated.')\n else\n render :edit\n end\n end",
"def set_quiz\n @quiz = Quiz.find(params[:id])\n end",
"def set_quiz\n @quiz = Quiz.find(params[:id])\n end",
"def set_quiz\n @quiz = Quiz.find(params[:id])\n end",
"def set_quiz\n @quiz = Quiz.find(params[:id])\n end",
"def set_quiz\n @quiz = Quiz.find(params[:id])\n end",
"def set_quiz\n @quiz = Quiz.find(params[:id])\n end",
"def set_quiz\n @quiz = Quiz.find(params[:id])\n end",
"def set_quiz\n @quiz = Quiz.find(params[:id])\n end",
"def set_quiz\n @quiz = Quiz.find(params[:id])\n end",
"def set_quiz\n @quiz = Quiz.find(params[:id])\n end",
"def set_quiz\n @quiz = Quiz.find(params[:id])\n end",
"def set_quiz\n @quiz = Quiz.find(params[:id])\n end",
"def set_quiz\n @quiz = Quiz.find(params[:id])\n end",
"def set_quiz\n @quiz = Quiz.find(params[:id])\n end",
"def update\n if @quiz.update(quiz_params)\n redirect_to @quiz, notice: 'Assignment was successfully updated.'\n else\n render :edit\n end\n end",
"def edit\n if [email protected]\n @question.answer = @question.answer.to_i\n end\n end",
"def edit_single_question(collection_id, question)\r\n clear\r\n begin\r\n puts \"#{question['Id']}. #{question['Question']}\\n\"\r\n puts \"A: #{question['A']}\\n\"\r\n puts \"B: #{question['B']}\\n\"\r\n puts \"C: #{question['C']}\\n\"\r\n puts \"D: #{question['D']}\\n\"\r\n puts \"Correct option: #{question['Right_answer']}\\n\"\r\n puts \"-------------------------\\n\".colorize(:light_cyan)\r\n rescue JSON::ParserError, NoMethodError, NoMemoryError, StandardError\r\n puts \"It seems the custom content is empty. Please move to custom menu to add a new custom collection.\\n\\n\\n\"\r\n end\r\n # Passing the inheritance arguments plus corresponding keys to edit the content\r\n options = [\r\n { name: 'Question Content', value: -> { edit_content(collection_id, question, 'Question') } },\r\n { name: 'Option A', value: -> { edit_content(collection_id, question, 'A') } },\r\n { name: 'Option B', value: -> { edit_content(collection_id, question, 'B') } },\r\n { name: 'Option C', value: -> { edit_content(collection_id, question, 'C') } },\r\n { name: 'Option D', value: -> { edit_content(collection_id, question, 'D') } },\r\n { name: 'Correct option', value: -> { edit_correct_option(collection_id, question, 'Right_answer') } },\r\n { name: 'Comfirm the change', value: lambda {\r\n @prompt.yes?(\"\\nDo you want to comfirm the change or continue editing?\") ? comfirm_edit(collection_id, question['Id'], question) : return\r\n } },\r\n { name: 'Ignore the changes and go back to upper menu', value: lambda {\r\n @prompt.yes?(\"\\nDo you really want to go back to upper menu without saving?\") ? edit_quiz(collection_id) : return\r\n } }\r\n ]\r\n option = @prompt.select('Please select from the following options.', options,\r\n help: \"(Select with pressing ↑/↓ arrow keys, and then pressing Enter)\\n\\n\\n\", show_help: :always, per_page: 8)\r\n end",
"def edit\n @answer = Answer.find_by_uuid(params[:id])\n if [email protected]?\n redirect_to(answer_path(@answer.uuid), notice: 'You have already answered this question.') and return\n end\n\n @question = @answer.question\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @answer }\n end\n end",
"def update_explanation\n @question.explanation = params[:question][:explanation]\n if @question.save\n flash[:success] = \"Explication modifiée.\"\n redirect_to chapter_path(@chapter, :type => 5, :which => @question.id)\n else\n render 'explanation'\n end\n end",
"def edit(_count)\n html = '<td align=\"center\"><a rel=\"nofollow\" data-method=\"delete\" href=\"/questions/' + id.to_s + '\">Remove</a></td>'\n\n html += '<td><input size=\"6\" value=\"' + seq.to_s + '\" name=\"question[' + id.to_s + '][seq]\"'\n html += ' id=\"question_' + id.to_s + '_seq\" type=\"text\"></td>'\n\n html += '<td><textarea cols=\"50\" rows=\"1\" name=\"question[' + id.to_s + '][txt]\"'\n html += ' id=\"question_' + id.to_s + '_txt\" placeholder=\"Edit question content here\">' + txt + '</textarea></td>'\n\n html += '<td><input size=\"10\" disabled=\"disabled\" value=\"' + type + '\" name=\"question[' + id.to_s + '][type]\"'\n html += ' id=\"question_' + id.to_s + '_type\" type=\"text\"></td>'\n\n html += '<td><input size=\"2\" value=\"' + weight.to_s\n html += '\" name=\"question[' + id.to_s + '][weight]\" id=\"question_' + id.to_s + '_weight\" type=\"text\"></td>'\n\n html += '<td>text area size <input size=\"3\" value=\"' + size.to_s\n html += '\" name=\"question[' + id.to_s + '][size]\" id=\"question_' + id.to_s + '_size\" type=\"text\"></td>'\n\n html += '<td> max_label <input size=\"10\" value=\"' + max_label.to_s + '\" name=\"question[' + id.to_s\n html += '][max_label]\" id=\"question_' + id.to_s + '_max_label\" type=\"text\"> min_label <input size=\"12\" value=\"' + min_label.to_s\n html += '\" name=\"question[' + id.to_s + '][min_label]\" id=\"question_' + id.to_s + '_min_label\" type=\"text\"></td>'\n\n safe_join(['<tr>'.html_safe, '</tr>'.html_safe], html.html_safe)\n end",
"def update\n\n qp = question_params\n if qp[:question_type] == \"vignette\" or qp[:question_type] == \"nonchoice\"\n qp[:answer] = \"\"\n end\n\n respond_to do |format|\n if @question.update(qp)\n format.html { redirect_to paper_questions_path(question_params[:paper_id],question_params[:id]), notice: '題目已被成功編輯' }\n format.json { render :show, status: :ok, location: @question }\n else\n format.html { redirect_to edit_paper_question_path, notice: '上傳檔案大小不可超過500KB' }\n format.json { render json: paper_questions_path.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_questionnaire\n @questionnaire = Questionnaire.find(params[:id])\n end",
"def set_questionnaire\n @questionnaire = Questionnaire.find(params[:id])\n end",
"def set_questionnaire\n @questionnaire = Questionnaire.find(params[:id])\n end",
"def set_questionnaire\n @questionnaire = Questionnaire.find(params[:id])\n end",
"def set_questionnaire\n @questionnaire = Questionnaire.find(params[:id])\n end",
"def set_questionnaire\n @questionnaire = Questionnaire.find(params[:id])\n end",
"def set_questionnaire\n @questionnaire = Questionnaire.find(params[:id])\n end",
"def set_questionnaire\n @questionnaire = Questionnaire.find(params[:id])\n end",
"def set_questionnaire\n @questionnaire = Questionnaire.find(params[:id])\n end",
"def admin_update\n @question = Question.find(params[:id])\n authorize @question\n\n guidance = @question.get_guidance_annotation(current_user.org_id)\n current_tab = params[:r] || 'all-templates'\n if params[\"question-guidance-#{params[:id]}\"].present?\n unless guidance.present?\n guidance = Annotation.new(type: :guidance, org_id: current_user.org_id, question_id: @question.id)\n end\n guidance.text = params[\"question-guidance-#{params[:id]}\"]\n guidance.save\n else\n # The user cleared out the guidance value so delete the record\n guidance.destroy! if guidance.present?\n end\n example_answer = @question.get_example_answer(current_user.org_id)\n if params[\"question\"][\"annotations_attributes\"].present? && params[\"question\"][\"annotations_attributes\"][\"0\"][\"id\"].present?\n unless example_answer.present?\n example_answer = Annotation.new(type: :example_answer, org_id: current_user.org_id, question_id: @question.id)\n end\n example_answer.text = params[\"question\"][\"annotations_attributes\"][\"0\"][\"text\"]\n example_answer.save\n else\n # The user cleared out the example answer value so delete the record\n example_answer.destroy if example_answer.present?\n end \n \n if @question.question_format.textfield?\n @question.default_value = params[\"question-default-value-textfield\"]\n elsif @question.question_format.textarea?\n @question.default_value = params[\"question-default-value-textarea\"]\n end\n @section = @question.section\n @phase = @section.phase\n template = @phase.template\n \n attrs = params[:question]\n attrs[:theme_ids] = [] unless attrs[:theme_ids]\n \n if @question.update_attributes(attrs)\n @phase.template.dirty = true\n @phase.template.save!\n\n redirect_to admin_show_phase_path(id: @phase.id, section_id: @section.id, question_id: @question.id, r: current_tab), notice: success_message(_('question'), _('saved'))\n else\n @edit = (@phase.template.org == current_user.org)\n @open = true\n @sections = @phase.sections\n @section_id = @section.id\n @question_id = @question.id\n\n flash[:alert] = failed_update_error(@question, _('question'))\n if @phase.template.customization_of.present?\n @original_org = Template.where(dmptemplate_id: @phase.template.customization_of).first.org\n else\n @original_org = @phase.template.org\n end\n redirect_to admin_show_phase_path(id: @phase.id, section_id: @section.id, question_id: @question.id, r: current_tab)\n end\n end",
"def update\n respond_to do |format|\n if @question.update(question_params)\n @question_link = QuizQuestion.find_by_id(@question.questionid)\n @question_link.update(:points => params[:points])\n @quiz = Quiz.find_by_id(@question_link.quizid)\n format.html { redirect_to admin_quiz_path(@quiz), notice: 'Quiz multiple choice question was successfully updated.' }\n format.json { render :show, status: :ok, location: @question }\n else\n format.html { render :edit }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_quiz\n @quiz = Quiz.find(params[:id])\n end",
"def set_quiz\n @quiz = Quiz.find(params[:id])\n end",
"def update\n @quiz = Quiz.find(params[:id])\n \n respond_to do |format|\n if @quiz.update_attributes(params[:quiz])\n format.html { redirect_to @quiz, notice: 'Quiz was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @quiz.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_questionnaire\n @questionnaire = Questionnaire.find(params[:id])\n end",
"def set_quiz\n @quiz = Quiz.find_by_id(params[:id])\n end",
"def edit\n knowledge = Knowledge.first(:idurl => (knowledge_idurl = params[:knowledge_idurl]))\n quizze = Quizze.first(:idurl => (quizze_idurl = params[:quizze_idurl]))\n quizze.question_idurls = params[:select_question_idurls]\n quizze.product_idurls = params[:select_product_idurls]\n quizze.save\n redirect_to(\"/quizzes/#{knowledge_idurl}/#{quizze_idurl}\")\n end",
"def edit_form\n\t\tnewform = \"\"\n\t\titem_text = question_items.first.text #\n\t\tanswer_item = (self.answer_item.nil? or (self.answer_item =~ /\\d+([a-z]+)/).nil?) ? \"\" : \"\\t\" + $1 + \". \"\n\t\tself.question_items.each do |item|\n\t\t\tnewform = if item.position==1\n\t\t\t\tdiv_item( answer_item + item.text, \"itemquestiontext span-9\")\n\t\t\telse\n\t\t\t\tdiv_item( item_text, \"itemquestiontext span-9\")\n\t\t\tend\n\t\tend\n\t\tnewform\n\tend",
"def set_correct_answer\r\n set_question_and_answer\r\n @answer.correct = 1\r\n save_answer_and_render\r\n end",
"def update\n @question_tab = @test_tab.question_tabs.find(params[:id])\n\n respond_to do |format|\n if @question_tab.update_attributes(params[:question_tab])\n flash[:notice] = 'Questão alterada com sucesso.'\n format.html { redirect_to([@test_tab,@question_tab]) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @question_tab.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @questionnaire.update_attributes(\n status: :completed,\n answer: questionnaire_params.to_xml\n )\n render_to_msg('Успешно пройден')\n rescue => e\n logger.info(\"ОШИБКА: #{e}\")\n @questionnaire.update_attributes(status: :error)\n render_to_msg('Возникла непредвиденная ошибка, попробуйте еще раз')\n end",
"def set_answer\n @quiz = Quiz.find(params[:quiz_id])\n @question = Question.find_by(quiz_id: @quiz.id, number: params[:question_id]) || Question.find_by(quiz_id: @quiz.id, id: params[:question_id])\n @answer = Answer.find_by(question_id: @question.id, id: params[:id]) if params.key?(:id)\n end",
"def set_quizzes_answer\n @quizzes_answer = Quizzes::Answer.find(params[:id])\n end",
"def edit\n @questions = Question.all\n @categories = [\"Learning from Labs\", \"Lab Instructor\", \"Lab Space and Equipment\", \"Time Required to Complete Labs\", \"Lecture Section Instructor\"]\n @qKey = params[:queryKey]\n end",
"def edit\n @presenter = AnswerPagesPresenter.new(self, @answer_sheet, params[:a])\n unless @presenter.active_answer_sheet.pages.present?\n flash[:error] = \"Sorry, there are no questions for this form yet.\"\n if request.env[\"HTTP_REFERER\"]\n redirect_to :back\n else\n render :text => \"\", :layout => true\n end\n else\n @elements = @presenter.questions_for_page(:first).elements\n @page = @presenter.pages.first\n end\n end",
"def edit_content(collection_id, question, question_key)\r\n new_value = @prompt.ask(\"What is your new value for #{question_key}?\") do |q|\r\n q.required true\r\n q.modify :capitalize\r\n end\r\n question[question_key] = new_value\r\n edit_single_question(collection_id, question)\r\n end",
"def update\n if @question.update(question_params)\n redirect_to set_answer_question_path(@question)\n end\n end",
"def set_admin_academy_question\n @admin_academy_question = Academy::Question.find(params[:id])\n end",
"def update\n def answer_given(question_id)\n return (params[:answer] and params[:answer][question_id.to_s] and\n params[:answer][question_id.to_s].length > 0)\n end\n \n @resp = Response.find(params[:id])\n\n @questionnaire.questions.each do |question|\n if question.kind_of? Questions::Field\n ans = Answer.find_answer(@resp, question)\n if answer_given(question.id)\n if ans.nil?\n ans = Answer.new :question_id => question.id, :response_id => @resp.id\n end\n ans.value = params[:answer][question.id.to_s]\n ans.save\n else\n # No answer provided\n if not ans.nil?\n ans.destroy\n end\n end\n end\n end\n\n respond_to do |format|\n if @resp.update_attributes(params[:response])\n format.html { redirect_to(response_url(@questionnaire, @resp)) }\n format.js { redirect_to(response_url(@questionnaire, @resp, :format => \"js\")) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.js { render :action => \"edit\" }\n format.xml { render :xml => @resp.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n format.html { redirect_to quiz_path(@question.subsection_id), notice: 'Question was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @quiz.update(quiz_params)\n format.html { redirect_to @quiz, notice: \"Quiz was successfully updated.\" }\n format.json { render :show, status: :ok, location: @quiz }\n\t\tmy_array = []\n my_array << @quiz.option1\n my_array << @quiz.option2\n my_array << @quiz.option3\n my_array << @quiz.option4\n\n correct_respo = my_array[@quiz.correct_response.to_i - 1]\n @quiz.correct_response_text = correct_respo\n @quiz.save\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @quiz.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n unless @edit_or_delete_right\n redirect_to exams_url,notice:\"您无权修改别人编写的考试\"\n end\n parsed_param=exam_params\n @exam.questions.delete_all\n @exam.add_questions_to_exam(@validated_question)\n respond_to do |format|\n if @exam.update(parsed_param)\n format.html { redirect_to @exam, notice: \"已成功更新考试“#{@exam.name}.”\" }\n format.json { render :show, status: :ok, location: @exam }\n else\n format.html { render :edit }\n format.json { render json: @exam.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @questionnaire = Questionnaire.find(params[:id])\n\n respond_to do |format|\n if @questionnaire.update_attributes(params[:questionnaire])\n format.html { redirect_to @questionnaire, notice: 'Questionnaire was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @questionnaire.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_quizzes_question\n @quizzes_question = @question = (@quiz ? @quiz.questions : Quizzes::Question).find(params[:id])\n @quiz = @question.quiz\n @group = @quiz.group\n end",
"def update\n @questionnaire = Questionnaire.find(params[:id])\n\n respond_to do |format|\n if @questionnaire.update_attributes(params[:questionnaire])\n format.html { redirect_to(@questionnaire, :notice => 'Questionnaire was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @questionnaire.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def comfirm_edit(collection_id, question_id, question)\r\n new_custom = @custom.custom_load\r\n new_custom['Custom'][collection_id - 1]['Content'][question_id - 1] = question\r\n save_custom_file(new_custom)\r\n enter_to_continue\r\n edit_single_question(collection_id, question)\r\n end",
"def update\n @survey = Survey.find_by_id( params[:survey_id] )\n @question = Question.find_by_id( params[:id] )\n\n if @question.update( question_params )\n if params[:commit] == \"Continue to the Next Step\"\n params[:option_num].to_i.times do\n @question.options.create # TODO: cleanup, could create empty options in db\n end\n\n redirect_to edit_survey_question_path(@survey, @question)\n else\n flash.now[:success] = \"Question Added!\"\n\n # Create new empty question for render\n @question = @survey.questions.build\n\n render :new\n end\n else\n flash.now[:error] = \"Sorry, we couldn't add that question due to errors.\"\n render :new\n end\n end",
"def set_quiz_item\n @quiz_item = QuizItem.find(params[:id])\n end",
"def set_survey_quiz\n @survey_quiz = @survey_questionnaire = Survey::Quiz.find(params[:id])\n authorize @survey_quiz\n end",
"def update\n answer = current_user.answers.create!(quiz: @quiz, correctness: (params[:answer].to_i > 0) )\n\n respond_to do |format|\n format.html { redirect_to topic_quiz_path(@quiz, @quiz.topic), notice: 'Your answer is saved.' }\n format.json { render :show, status: :ok, location: topic_quiz_path(@quiz, @quiz.topic) }\n end\n end",
"def edit(count)\n html ='<tr>'\n html+='<td align=\"center\"><a rel=\"nofollow\" data-method=\"delete\" href=\"/questions/' +self.id.to_s+ '\">Remove</a></td>'\n html+='<td><input size=\"6\" value=\"'+self.seq.to_s+'\" name=\"question['+self.id.to_s+'][seq]\" id=\"question_'+self.id.to_s+'_seq\" type=\"text\"></td>'\n html+='<td><textarea cols=\"50\" rows=\"1\" name=\"question['+self.id.to_s+'][txt]\" id=\"question_'+self.id.to_s+'_txt\">'+self.txt+'</textarea></td>'\n html+='<td><input size=\"10\" disabled=\"disabled\" value=\"'+self.type+'\" name=\"question['+self.id.to_s+'][type]\" id=\"question_'+self.id.to_s+'_type\" type=\"text\">''</td>'\n html+='<td><input size=\"2\" value=\"'+self.weight.to_s+'\" name=\"question['+self.id.to_s+'][weight]\" id=\"question_'+self.id.to_s+'_weight\" type=\"text\">''</td>'\n html+='<td>text area size <input size=\"3\" value=\"'+self.size.to_s+'\" name=\"question['+self.id.to_s+'][size]\" id=\"question_'+self.id.to_s+'_size\" type=\"text\"></td>'\n html+='<td> max_label <input size=\"10\" value=\"'+self.max_label.to_s+'\" name=\"question['+self.id.to_s+'][max_label]\" id=\"question_'+self.id.to_s+'_max_label\" type=\"text\"> min_label <input size=\"10\" value=\"'+self.min_label.to_s+'\" name=\"question['+self.id.to_s+'][min_label]\" id=\"question_'+self.id.to_s+'_min_label\" type=\"text\"></td>'\n html+='</tr>'\n\n html.html_safe\n end",
"def update\n @question = Question.find(params[:id])\n\n # @question.question_type_id = params[:question][:question_type_id]\n # @question.question_category_id = @question.question_type.question_category_id\n\n # authorize! :update, @question\n # @question.question_type_id = params[:question][:question_type_id]\n # @question.question_category_id = @question.question_type.question_category_id\n\n \n # # get fields from the form to update the question's section\n # @question.book = params[:question][:book]\n # @question.chapter = params[:question][:chapter]\n # @question.verse = params[:question][:verse]\n # @question.section_id = @question.set_section\n #---------------------------------------------------------\n \n # # if the the question has been approved, set the approver and the date approved\n # unless params[:question][:approval_level] == nil\n # @question.approved_by = current_user.id\n # @question.approved_on = DateTime.now\n # end\n\t\n @question.update_attributes(params[:question])\n unless @question.approval_level == -1\n respond_with @question\n\tend\n\t\n\t# set the section for this question\n\t#@question.section_id = @question.set_section\n \n # the quesiton is marked as refused, drop from database\n if @question.approval_level == -1\n \[email protected]\n destroyed = 1\n redirect_to approve_path, :notice => \"Successfully deleted question\"\n return\n end\n # if @question.update_attributes(params[:question])\n # # determine user and send them to appropriate page\n # if current_user.is_writer?\n # redirect_to write_path, :notice => \"Successfully updated question.\"\n # elsif current_user.is_approver?\n # redirect_to approve_path, :notice => \"Successfully updated question.\"\n # else\n # redirect_to @question, :notice => \"Successfully updated question.\"\n # end\n # else\n # render :action => 'edit'\n # end\n end",
"def quiz\n @questions = Question.all\n @idx = params[:idx] ? (params[:idx].to_i + 1) : 0\n if params[:answer]\n question = Question.find(params[:id])\n if check_answer(params[:answer], question.answer)\n @correct_answer_number = params[:correct_answer_number].to_i + 1\n if @idx < @questions.size\n flash[:notice] = \"Correct\"\n else\n flash[:notice] = \"Correct. Summary: You have answered #{@correct_answer_number} question(s) correctly out of #{@questions.size}\"\n end\n else\n @correct_answer_number = params[:correct_answer_number].to_i\n if @idx < @questions.size\n flash[:notice] = \"Incorrect\"\n else\n flash[:notice] = \"Incorrect. Summary: You have answered #{@correct_answer_number} question(s) correctly out of #{@questions.size}\"\n end\n end\n else\n @correct_answer_number = 0\n end\n if @idx >= @questions.size\n @idx = 0\n @correct_answer_number = 0\n end\n flash[:notice] = \"No questions have been added yet. Please ask the administrator to add some questions first.\" if @questions.size == 0\n end",
"def set_exam_question\n @exam_question = ExamQuestion.find(params[:id])\n end",
"def update\n respond_to do |format|\n if @quizzes_answer.update(quizzes_answer_params)\n format.html { redirect_to quiz_assessments_path(@quizzes_answer.assessment.quiz) }\n format.json { render :show, status: :ok, location: @quizzes_answer }\n else\n format.html { render :edit }\n format.json { render json: @quizzes_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def edit_correct_option(collection_id, question, key_for_correct_option)\r\n options = %w[A B C D]\r\n new_right_option = @prompt.select('Choose your new correct option:', options, per_page: 4)\r\n question[key_for_correct_option] = new_right_option\r\n edit_single_question(collection_id, question)\r\n end",
"def update\n respond_to do |format|\n if @quiz.update(quiz_params)\n format.html {\n redirect_to discipline_topic_quiz_path(@discipline, @topic, @quiz), notice: 'Quiz was successfully updated.'\n }\n format.json { render :show, status: :ok, location: @quiz }\n else\n format.html { render :edit }\n format.json { render json: @quiz.errors, status: :unprocessable_entity }\n end\n end\n end",
"def edit_form\n\t\titem_text = question_items.first.text #in_place_editor_field :question_cell, :items, {}, :rows => 3\n\t\tdiv_item(item_text, \"iteminformation\")\n\tend",
"def update\n @question = Question.find(params[:id])\n if @question.update(question_params)\n redirect_to @question\n else\n render 'edit'\n end\n end",
"def update\n @question = @page.questions.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n flash[:notice] = 'Your question was successfully updated.'\n format.html { redirect_to(offering_page_question_url(@offering, @page, @question)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @question.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n if not (granted_for?('root') || granted_for('survey'))\n access_denied\n else\n \n @survey = Survey.find(params[:id])\n \n @survey.add_question(params[:new_question],\n params[:new_question_values],\n params[:question_type]) unless params[:new_question].blank?\n \n respond_to do |format|\n if @survey.update_attributes(params[:survey])\n flash[:notice] = 'Survey was successfully updated.'\n format.html { redirect_to( edit_survey_path(@survey)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @survey.errors, :status => :unprocessable_entity }\n end\n end\n end\n end",
"def update\n\t\[email protected] = StringIO.new(params[:question][:i_data].read).read.gsub(/\\R/, \"\\n\") if params[:question][:i_data]\n\t\[email protected] = StringIO.new(params[:question][:o_data].read).read.gsub(/\\R/, \"\\n\") if params[:question][:o_data]\n\n\t\tif @question.update(question_params)\n\t\t\tredirect_to @question, flash: {notice: 'Question was successfully updated.' }\n\t\telse\n\t\t\trender :edit \n\t\tend\n\tend",
"def update\n respond_to do |format|\n if @quizzes_question.update(quizzes_question_params)\n if params[:commit] =~ /add/i\n format.html { redirect_to edit_quiz_question_path(@question.quiz, @question) }\n else\n format.html { redirect_to quiz_questions_path(@question.quiz), notice: 'Question was successfully updated.' }\n format.json { render :show, status: :ok, location: @quizzes_question }\n end\n else\n format.html { render :edit }\n format.json { render json: @quizzes_question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @question_response = QuestionResponse.find(params[:id])\n\n\t\t\t@question = @question_response.question\n if @question_response.update(qr_params)\n flash[:notice] = t('questionresponse_updated_success')\n\t\t\t\trender :action => 'list' \n else\n render :action => \"edit\" \n end\n end",
"def set_answer\n\t\t#@answer = Survey.find(params[:id])\n\tend"
] | [
"0.78736377",
"0.7705088",
"0.7496314",
"0.74926126",
"0.7429192",
"0.7319658",
"0.7226312",
"0.72018594",
"0.7053109",
"0.70383626",
"0.69802076",
"0.6976677",
"0.69575685",
"0.69298786",
"0.68901175",
"0.6888413",
"0.6854092",
"0.6836597",
"0.6788975",
"0.6783555",
"0.6777611",
"0.6777611",
"0.6771184",
"0.6748887",
"0.6744723",
"0.6744723",
"0.6744723",
"0.6744723",
"0.6744723",
"0.6744723",
"0.6744723",
"0.6744723",
"0.6744723",
"0.6744723",
"0.6744723",
"0.6744723",
"0.6744723",
"0.6744723",
"0.6743735",
"0.67383134",
"0.6733831",
"0.6730096",
"0.6720106",
"0.66965663",
"0.66958123",
"0.6694576",
"0.6694576",
"0.6694576",
"0.6694576",
"0.6694576",
"0.6694576",
"0.6694576",
"0.6694576",
"0.6694576",
"0.66884136",
"0.6674918",
"0.6666545",
"0.6666545",
"0.66574186",
"0.6655657",
"0.6651415",
"0.66360784",
"0.6633039",
"0.66157854",
"0.66048443",
"0.66010916",
"0.6581358",
"0.65747225",
"0.6570064",
"0.6565199",
"0.65295744",
"0.6529404",
"0.6525419",
"0.65223795",
"0.6519604",
"0.6514721",
"0.6500879",
"0.6490763",
"0.64839065",
"0.64784086",
"0.6460706",
"0.64466065",
"0.6443149",
"0.6442705",
"0.6437153",
"0.64355457",
"0.64347595",
"0.6422597",
"0.642058",
"0.6418707",
"0.6417499",
"0.6415556",
"0.6404437",
"0.63898134",
"0.63894516",
"0.6388407",
"0.6386041",
"0.6384667",
"0.6382943",
"0.6380502"
] | 0.6835008 | 18 |
save an updated quiz questionnaire to the database | def update_quiz
@questionnaire = Questionnaire.find(params[:id])
redirect_to controller: 'submitted_content', action: 'view', id: params[:pid] if @questionnaire == nil
if params['save']
@questionnaire.update_attributes(questionnaire_params)
for qid in params[:question].keys
@question = Question.find(qid)
@question.txt = params[:question][qid.to_sym][:txt]
@question.save
@quiz_question_choices = QuizQuestionChoice.where(question_id: qid)
i=1
for quiz_question_choice in @quiz_question_choices
choose_question_type(i, quiz_question_choice)
i+=1
end
end
end
redirect_to controller: 'submitted_content', action: 'view', id: params[:pid]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save\n if self.valid?\n return false\n else\n QUIZ.execute(\"UPDATE questions SET question = '#{@question}' WHERE id = #{@id};\")\n end\n end",
"def save_questions(questionnaire_id)\n delete_questions questionnaire_id\n save_new_questions questionnaire_id\n \n if params[:question]\n for question_key in params[:question].keys\n begin\n if params[:question][question_key][:txt].strip.empty?\n # question text is empty, delete the question\n Question.delete(question_key)\n else\n if (@questionnaire.type == \"QuizQuestionnaire\")\n Question.update(question_key,:weight => 1, :txt => params[:question][question_key][:txt] )\n else\n Question.update(question_key, params[:question][question_key])\n end\n Question.update(question_key, params[:question][question_key])\n end\n rescue ActiveRecord::RecordNotFound \n end\n end\n end\n end",
"def save_questionnaire \n begin\n @questionnaire.save!\n\n save_questions @questionnaire.id if @questionnaire.id != nil and @questionnaire.id > 0\n\n if @questionnaire.type != \"QuizQuestionnaire\"\n pFolder = TreeFolder.find_by_name(@questionnaire.display_type)\n parent = FolderNode.find_by_node_object_id(pFolder.id)\n if QuestionnaireNode.find_by_parent_id_and_node_object_id(parent.id,@questionnaire.id) == nil\n QuestionnaireNode.create(:parent_id => parent.id, :node_object_id => @questionnaire.id)\n end\n end\n rescue\n flash[:error] = $!\n end\n end",
"def save_new_questions(questionnaire_id)\n\n if params[:new_question]\n # The new_question array contains all the new questions\n # that should be saved to the database\n for question_key in params[:new_question].keys\n q = Question.new(params[:new_question][question_key])\n q.questionnaire_id = questionnaire_id\n if @questionnaire.type == \"QuizQuestionnaire\"\n q.weight = 1 #setting the weight to 1 for quiz questionnaire since the model validates this field\n q.true_false = false\n end\n q.save if !q.txt.strip.empty?\n end\n end\n end",
"def save\n @questionnaire.save!\n redirect_to controller: 'questions', action: 'save_questions', questionnaire_id: @questionnaire.id, questionnaire_type: @questionnaire.type and return unless @questionnaire.id.nil? || @questionnaire.id <= 0\n undo_link(\"Questionnaire \\\"#{@questionnaire.name}\\\" has been updated successfully. \")\n end",
"def update_quiz\n @questionnaire = Questionnaire.find(params[:id])\n redirect_to :controller => 'submitted_content', :action => 'edit', :id => params[:pid] if @questionnaire == nil\n if params['save']\n @questionnaire.update_attributes(params[:questionnaire])\n\n for qid in params[:question].keys\n question_advices = QuestionAdvice.find_all_by_question_id(qid)\n i=1\n for question_advice in question_advices\n if params[:question][qid][\"weight\"] == i.to_s\n score = 1\n else\n score = 0\n end\n i+=1\n question_advice.update_attributes(:score => score, :advice => params[:question_advice][question_advice.id.to_s][\"advice\"])\n end\n end\n save_questionnaire\n #save_choices @questionnaire.id\n end\n redirect_to :controller => 'submitted_content', :action => 'edit', :id => params[:pid]\n end",
"def update\n @question.statement = params[:question][:statement]\n unless @question.online\n @question.level = (@chapter.section.fondation? ? 0 : params[:question][:level])\n if @question.is_qcm\n if params[:question][:many_answers] == '1'\n @question.many_answers = true\n else\n if @question.many_answers\n # Must check there is only one true\n i = 0\n @question.items.order(:id).each do |c|\n if c.ok\n if i > 0\n c.ok = false\n flash[:info] = \"Attention, il y avait plusieurs réponses correctes à cet exercice, seule la première a été gardée.\"\n c.save\n end\n i = i+1\n end\n end\n if @question.items.count > 0 && i == 0\n # There is no good answer\n flash[:info] = \"Attention, il n'y avait aucune réponse correcte à cet exercice, une réponse correcte a été rajoutée aléatoirement.\"\n @item = @question.items.order(:id).first\n @item.ok = true\n @item.save\n end\n end\n @question.many_answers = false\n end\n else\n if params[:question][:decimal] == '1'\n @question.decimal = true\n @question.answer = params[:question][:answer].gsub(\",\",\".\").to_f\n else\n @question.decimal = false\n @question.answer = params[:question][:answer].gsub(\",\",\".\").to_i\n end\n end\n end\n \n if @question.save\n redirect_to chapter_path(@chapter, :type => 5, :which => @question.id)\n else\n render 'edit'\n end\n end",
"def save_choices(questionnaire_id)\n\n if params[:new_question] and params[:new_choices]\n questions = Question.find_all_by_questionnaire_id(questionnaire_id)\n i = 1\n for question in questions\n for choice_key in params[:new_choices][i.to_s].keys\n\n if choice_key == params[:new_question][i.to_s][\"weight\"]\n score = 1\n else\n score = 0\n end\n q = QuestionAdvice.new(:score => score, :advice => params[:new_choices][i.to_s][choice_key], :question_id => question.id)\n q.save\n end\n i += 1\n question.weight = 1\n question.true_false = false\n end\n end\n end",
"def update\n answer = current_user.answers.create!(quiz: @quiz, correctness: (params[:answer].to_i > 0) )\n\n respond_to do |format|\n format.html { redirect_to topic_quiz_path(@quiz, @quiz.topic), notice: 'Your answer is saved.' }\n format.json { render :show, status: :ok, location: topic_quiz_path(@quiz, @quiz.topic) }\n end\n end",
"def update\n @questionnaire.update_attributes(\n status: :completed,\n answer: questionnaire_params.to_xml\n )\n render_to_msg('Успешно пройден')\n rescue => e\n logger.info(\"ОШИБКА: #{e}\")\n @questionnaire.update_attributes(status: :error)\n render_to_msg('Возникла непредвиденная ошибка, попробуйте еще раз')\n end",
"def answer\n # TODO: サマリ更新ロジックをモデルに移動\n @question = Question.find(params[:id])\n @user = current_user\n @summary = Summary.find_by_user_id_and_question_id(@user[:id], @question[:id])\n @score = @user.scores.build(:question => @question, :summary_id => @summary[:id], :user_answer => params[:answer].to_i, :answer_date => Time.current)\n\n if @question.answer == @score[:user_answer]\n @correct = true\n @score.correct = true\n @summary.attributes = { :total => @summary[:total] + 1, :right => @summary[:right] + 1 }\n else\n @correct = false\n @score.correct = false\n @summary.attributes = { :total => @summary[:total] + 1 }\n end \n @summary.save!\n @score.save!\n end",
"def update\n\t@question = Question.find(params[:id])\n\t@questionnaire_question=QuestionnaireQuestion.find_by_question_id(@question.id)\n\t@questionnaire=Questionnaire.find(@questionnaire_question.questionnaire_id)\n\n\trespond_to do |format|\n\t if @question.update_attributes(params[:question])\n\t#\tformat.html { redirect_to(@question, :notice => 'Question was successfully updated.') }\n\t\tformat.html { redirect_to new_question_path(:questionnaire_id=>@questionnaire.id), :notice => 'Answer was successfully Saved.' }\n\t\tformat.xml { head :ok }\n\t else\n\t\tformat.html { render :action => \"edit\" }\n\t\tformat.xml { render :xml => @question.errors, :status => :unprocessable_entity }\n\t end\n\tend\n end",
"def save_question\n if @question.save\n Question.normalize_position(@survey)\n\n flash[:success] = success_message(@question, :create)\n redirect_to presentation_survey_path(@presentation.id, @question.survey_id)\n else\n flash.now[:error] = error_message(@question, :create)\n render :new\n end\n end",
"def save\n if new?\n _create\n else\n handle_response SurveyGizmo.post(handle_route(:update), :query => self.attributes_without_blanks) do\n _response.ok? ? saved! : false\n end\n end\n end",
"def update\n if @question.update(question_params)\n redirect_to set_answer_question_path(@question)\n end\n end",
"def add_new_questions\n questionnaire_id = params[:id]\n # If the questionnaire is being used in the active period of an assignment, delete existing responses before adding new questions\n if AnswerHelper.check_and_delete_responses(questionnaire_id)\n flash[:success] = 'You have successfully added a new question. Any existing reviews for the questionnaire have been deleted!'\n else\n flash[:success] = 'You have successfully added a new question.'\n end\n\n questionnaire = Questionnaire.find(questionnaire_id)\n current_num_of_questions = questionnaire.questions.size\n max_seq = 0\n Questionnaire.find(questionnaire_id).questions.each do |question|\n if !question.seq.nil? && question.seq > max_seq\n max_seq = question.seq\n end\n end\n ((current_num_of_questions + 1)..(current_num_of_questions + params[:question][:total_num].to_i)).each do\n max_seq += 1\n # Create question object based on type using question_factory\n question = question_factory(params[:question][:type], questionnaire_id, max_seq)\n if question.is_a? ScoredQuestion\n question.weight = params[:question][:weight]\n question.max_label = Question::MAX_LABEL\n question.min_label = Question::MIN_LABEL\n end\n\n if Question::SIZES.key?(question.class.name)\n question.size = Question::SIZES[question.class.name]\n end\n if Question::ALTERNATIVES.key?(question.class.name)\n question.alternatives = Question::ALTERNATIVES[question.class.name]\n end\n\n begin\n question.save\n rescue StandardError => e\n flash[:error] = e.message\n end\n end\n redirect_to edit_questionnaire_path(questionnaire_id.to_sym)\n end",
"def save_all_questions\n questionnaire_id = params[:id]\n begin\n if params[:save]\n update_questionnaire_questions\n flash[:success] = 'All questions have been successfully saved!'\n end\n rescue StandardError\n flash[:error] = $ERROR_INFO\n end\n\n if params[:view_advice]\n redirect_to controller: 'advice', action: 'edit_advice', id: params[:id]\n elsif questionnaire_id\n redirect_to edit_questionnaire_path(questionnaire_id.to_sym)\n end\n end",
"def update\n @question = Question.find(params[:id])\n @quiz = Quiz.find(params[:id])\n if @quiz.update(quiz_params)\n flash[:success] = \"Quiz updated\"\n redirect_to @quiz\n else\n render 'edit'\n end\n end",
"def save\n\n quiz = frm.div(:class=>\"portletBody\").div(:index=>0).text\n pool = frm.div(:class=>\"portletBody\").div(:index=>1).text\n\n frm.button(:value=>\"Save\").click\n\n if quiz =~ /^Assessments/\n EditAssessment.new(@browser)\n elsif pool =~ /^Question Pools/\n EditQuestionPool.new(@browser)\n else\n puts \"Unexpected text: \"\n p pool\n p quiz\n end\n\n end",
"def update\n puts params\n @question = Question.find(params[:id])\n if params[:commit] == 'Answer'\n @question.resolved = true\n @question.end_time = Time.now\n @question.username = current_user.email.split('@')[0]\n if @question.update(update_question_params)\n redirect_to solve_path\n end\n end\n\n if params[:commit] == 'Escalate'\n @question.escalated = true\n @escalate = @question.escalatings.create();\n @question.save\n @escalate.username = current_user.email.split('@')[0]\n @escalate.save\n redirect_to solve_path\n end \n \n end",
"def set_answers!(params)\n SurveyQuestion.with_question.find_all_by_survey_id(survey_id).each do |question| # iterate through all survey questions\n if params[question.id.to_s].blank? # if the question hasn't been answered\n remove_answer(question.id)\n else\n set_answer(question, params[question.id.to_s]) # save the answer\n end\n end\n save\n end",
"def admin_update\n @question = Question.find(params[:id])\n authorize @question\n\n guidance = @question.get_guidance_annotation(current_user.org_id)\n current_tab = params[:r] || 'all-templates'\n if params[\"question-guidance-#{params[:id]}\"].present?\n unless guidance.present?\n guidance = Annotation.new(type: :guidance, org_id: current_user.org_id, question_id: @question.id)\n end\n guidance.text = params[\"question-guidance-#{params[:id]}\"]\n guidance.save\n else\n # The user cleared out the guidance value so delete the record\n guidance.destroy! if guidance.present?\n end\n example_answer = @question.get_example_answer(current_user.org_id)\n if params[\"question\"][\"annotations_attributes\"].present? && params[\"question\"][\"annotations_attributes\"][\"0\"][\"id\"].present?\n unless example_answer.present?\n example_answer = Annotation.new(type: :example_answer, org_id: current_user.org_id, question_id: @question.id)\n end\n example_answer.text = params[\"question\"][\"annotations_attributes\"][\"0\"][\"text\"]\n example_answer.save\n else\n # The user cleared out the example answer value so delete the record\n example_answer.destroy if example_answer.present?\n end \n \n if @question.question_format.textfield?\n @question.default_value = params[\"question-default-value-textfield\"]\n elsif @question.question_format.textarea?\n @question.default_value = params[\"question-default-value-textarea\"]\n end\n @section = @question.section\n @phase = @section.phase\n template = @phase.template\n \n attrs = params[:question]\n attrs[:theme_ids] = [] unless attrs[:theme_ids]\n \n if @question.update_attributes(attrs)\n @phase.template.dirty = true\n @phase.template.save!\n\n redirect_to admin_show_phase_path(id: @phase.id, section_id: @section.id, question_id: @question.id, r: current_tab), notice: success_message(_('question'), _('saved'))\n else\n @edit = (@phase.template.org == current_user.org)\n @open = true\n @sections = @phase.sections\n @section_id = @section.id\n @question_id = @question.id\n\n flash[:alert] = failed_update_error(@question, _('question'))\n if @phase.template.customization_of.present?\n @original_org = Template.where(dmptemplate_id: @phase.template.customization_of).first.org\n else\n @original_org = @phase.template.org\n end\n redirect_to admin_show_phase_path(id: @phase.id, section_id: @section.id, question_id: @question.id, r: current_tab)\n end\n end",
"def post_execute\n save({'answer' => @datastore['answer']})\n end",
"def post_execute\n save({'answer' => @datastore['answer']})\n end",
"def answered\n @the_question = Question.find(params[:id])\n @the_question.answered = true\n @the_question.save\n render json: [{question: @the_question}]\n end",
"def update\n if @que.update(question_type_params)\n redirect_to new_question_database_path\n flash[:notice] = 'question was successfully updated.'\n else\n render 'new'\n end\n end",
"def update\n # If 'Add' or 'Edit/View advice' is clicked, redirect appropriately\n if params[:add_new_questions]\n permitted_params = params.permit(:id, new_question: params[:new_question].keys)\n redirect_to action: 'add_new_questions', id: permitted_params[:id], question: permitted_params[:new_question]\n elsif params[:view_advice]\n redirect_to controller: 'advice', action: 'edit_advice', id: params[:id]\n else\n @questionnaire = Questionnaire.find(params[:id])\n if @questionnaire.update_attributes(questionnaire_params)\n update_questionnaire_questions\n flash[:success] = 'The questionnaire has been successfully updated!'\n else\n flash[:error] = @questionnaire.errors.full_messages.join(', ')\n end\n redirect_to action: 'edit', id: @questionnaire.id.to_s.to_sym\n end\n rescue StandardError => e\n flash[:error] = e.message\n redirect_to action: 'edit', id: @questionnaire.id.to_s.to_sym\n end",
"def update\n @question = Question.find(params[:question_id])\n @answer = @question.answers.new(answer_params)\n respond_to do |format|\n if @answer.update(answer_params)\n format.html { redirect_to question_answer_url(@question, @answer), notice: \"Answer was successfully updated.\" }\n format.json { render :show, status: :ok, location: @answer }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def set_correct_answer\r\n set_question_and_answer\r\n @answer.correct = 1\r\n save_answer_and_render\r\n end",
"def create_question\n question_hash = Adapter.quiz_api(difficulty) #use adapter method, with difficulty passes into the url as a variable, to gnerate a new list of questions.\n new_question = Question.new #make a new question instance\n new_question.save #save now so we can store the question's id in the answer by calling self.id\n new_question.content = question_hash['question'] #adding all necessary column data to this question object/row\n new_question.create_answers(question_hash)\n new_question.quiz_id = self.id\n new_question.save #send the newly created question to the database\n end",
"def update\n if @answer.update(answer_params)\n respond_to_save_success(@answer, [@question, @answer])\n else\n respond_to_save_failure(:edit, @answer)\n end\n end",
"def update\n @question = @quiz.questions.find(params[:id])\n\n respond_to do |format|\n if @question.update_attributes(params[:question])\n flash[:notice] = 'Question was successfully updated.'\n format.html { redirect_to(quiz_questions_path(@quiz)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @question.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update \t\n\t \t# TODO: make sure that there are no duplicates for questions\n\t \t\n\t \t@param_list = params # for debugging in case of errors (see update.html.erb)\n\t \t\n\t \t#return\n\t \tif params[:id].nil?\n\t \t\t@error_message = 'ERROR: invalid question id'\n\t \telsif params[:question].nil?\n\t \t\t@error_message = 'ERROR: no question parameter provided'\n \t\telsif params[:question][:short_name].nil? or params[:question][:short_name].empty?\n \t\t\t@error_message = 'ERROR: no short name provided'\n \t\telsif params[:question][:text].nil? or params[:question][:text].empty?\n \t\t\t@error_message = 'ERROR: no question text provided'\n \t\telsif params[:question][:question_type].nil? or params[:question][:question_type].empty?\n \t\t\t@error_message = 'ERROR: no question type provided'\n\t\telsif params[:question][:domain].nil? or params[:question][:domain].empty?\n\t\t\t@error_message = 'ERROR: no question domain provided'\n\t\telsif not [Question::UNFILED_DOMAIN,Question::PROFILE_DOMAIN,Question::FEEDBACK_DOMAIN].include?(params[:question][:domain].downcase)\n\t\t\t@error_message = 'ERROR: invalid question domain provided'\n \t\telsif not ['Text','Multiple Choice','Multiple Selection'].include?(params[:question][:question_type])\n \t\t\t@error_message = 'ERROR: invalid question type'\n \t\telsif params[:question][:question_type] != 'Text' and (params[:choices].nil? or params[:choices].empty?)\n \t\t\t@error_message = 'ERROR: did not specify choices for a choice question' \t\t\t\n \t\telse\n\t\t \tquestion_type = _condense_question_type(params[:question][:question_type]) # represents the desired new question type\n \t\t\t# TODO: make sure that there are no duplicates\n\t\t \t\n\t\t \tif question_type.nil?\n \t\t\t\t@error_message = 'ERROR: could not condense question type properly!'\n \t\t\telse\n \t\t\t\t# now can save the question, but first must check if it already exists - won't the question always exist?\n \t\t\t\tcurrent_question = Question.where('id = ?',params[:id]).first \t\t\t\t\n\t\t\t \tif current_question.nil? # not found, so will make and store a new one - rare occasion, but enforces idempotency\t\t \t\t\n\t\t\t \t\t# this will create a new question, create any choices that don't already exist, and replace all Inclusions\n\t\t\t \t \t_create_new_question params[:question][:short_name], params[:question][:text], question_type, params[:question][:domain].downcase, current_user.id, params[:choices]\t\t \t\t\n\t\t \t\telse # this question already exists - just update its information and update the choices database with any new choices; also replace all Inclusion links\n\t\t\t \t\t@previous_question_type = current_question.question_type\n\t\t \t\t\t@question = Question.update(current_question.id.to_i, :short_name => params[:question][:short_name], :text => params[:question][:text], :question_type => question_type, :updated_by => current_user.id, :domain => params[:question][:domain].downcase) # updated_at will be done automatically by Rails\n\t\t\t \t\t@error_message = '[INFO] Question updated in database!'\n\t\t\t \t\t\n\t\t \t\t\t# update possbilities:\n\t\t \t\t\t# text -> text: do nothing (just modify the question above)\n\t\t \t\t\t# text -> mc/ms (non-text): add all non-existing choices from params, add Inclusion records between choices and all params (no need to replace here; can't be any choices for a former text question)\n\t\t\t\t\t# mc/ms (non-text) -> text: delete all existing Inclusion records between choices and question\n\t\t\t\t\t# mc/ms (non-text) -> mc/ms (non-text): \n\t\t \t\t\t\n\t\t\t \t\tif @previous_question_type == 'TEXT' and question_type != 'TEXT'\n\t\t\t \t\t\t_update_current_choices_and_inclusions(@question.id,params[:choices])\n\t\t \t\t\telsif @previous_question_type != 'TEXT' and question_type == 'TEXT'\n\t\t \t\t\t\t# only delete the old inclusion ties (questions are, after all, decoupled from choices)\n\t\t \t\t\t\t#old_ties = Inclusion.where('question_id = ?',).all.collect { |i| i.choice_id.to_i }\n\t\t \t\t\t\t#Inclusion.destroy_all(\"question_id = #{current_question.id.to_i}\")\n\t\t \t\t\t\tActiveRecord::Base.connection.execute(\"DELETE FROM inclusions WHERE question_id = #{current_question.id.to_i}\") # is there a better way?\t\n\t\t \t\t\t\t\n\t\t \t\t\telsif @previous_question_type != 'TEXT' and question_type != 'TEXT'\n\t\t \t\t\t\t# here, must delete old Inclusion ties before adding the new ones (which, in effect, replaces all ties)\n\t\t \t\t\t\t#Inclusion.destroy_all(\"question_id = #{current_question.id.to_i}\")\n\t\t \t\t\t\tActiveRecord::Base.connection.execute(\"DELETE FROM inclusions WHERE question_id = #{current_question.id.to_i}\")\n\t\t \t\t\t\t_update_current_choices_and_inclusions(@question.id,params[:choices])\n\t \t\t\t\tend\t\t \t\t\n\t\t \t\tend\n\t \t\tend\n \t\tend\n \t\t\n \t\tif @error_message.index('ERROR').nil? # if there is an error, stay on this page; else, allow user to continue\n \t\t\tredirect_to :action => :index\n \t\tend\n\tend",
"def update\n if not (granted_for?('root') || granted_for('survey'))\n access_denied\n else\n \n @survey = Survey.find(params[:id])\n \n @survey.add_question(params[:new_question],\n params[:new_question_values],\n params[:question_type]) unless params[:new_question].blank?\n \n respond_to do |format|\n if @survey.update_attributes(params[:survey])\n flash[:notice] = 'Survey was successfully updated.'\n format.html { redirect_to( edit_survey_path(@survey)) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @survey.errors, :status => :unprocessable_entity }\n end\n end\n end\n end",
"def update\n @quiz = Quiz.find(params[:id])\n\n if @quiz.update_attributes(params[:quiz])\n redirect_to @quiz, notice: 'Quiz was successfully updated.'\n else\n render action: \"edit\"\n end\n end",
"def update_form_question(old_q, new_q)\n old_q.position = new_q[:position]\n old_q.program_var = new_q[:program_var]\n old_q.question_id = new_q[:question_id]\n old_q.response_set_id = new_q[:response_set_id]\n # While this seems unecessary, checking changed? here improves performance\n old_q.save! if old_q.changed?\n old_q\n end",
"def update_question\n @question = Question.find(params[:id])\n @question.update(params[:question])\n redirect \"/questions/#{@question.id}\"\n end",
"def update\n if @test.created_at != @test.updated_at \n respond_to do |format|\n format.html { redirect_to @test, notice: \"Cheating activity is not allowed! You have done this test!\" } # Khong cho phep user lam lai bai test da nop\n end\n else\n begin\n answers = params[:test][:answer_ids]\n score = 0\n @test.questions.each do |question|\n ans = answers[\"question_#{question.id}\"]\n if !ans.nil?\n if question.answers.where(\"answers.id = #{ans.to_i}\").first.right_answer\n score = score + 1\n end\n ## Cap nhat Answer ID da chon ##\n QuestionsTest.where(:question_id => question.id, :test_id => @test.id)\n .update_all(:chosen_answer_id => ans.to_i)\n end\n end\n ## Luu diem ##\n @test.score = score\n @test.save\n\n respond_to do |format|\n format.html { redirect_to @test }\n format.json { render :show, status: :ok, location: @test }\n end\n rescue\n @test.score = 0\n @test.save\n respond_to do |format|\n format.html { redirect_to @test }\n format.json { render json: @test.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def update\n respond_to do |format|\n if @question.update(question_params)\n @question_link = QuizQuestion.find_by_id(@question.questionid)\n @question_link.update(:points => params[:points])\n @quiz = Quiz.find_by_id(@question_link.quizid)\n format.html { redirect_to admin_quiz_path(@quiz), notice: 'Quiz multiple choice question was successfully updated.' }\n format.json { render :show, status: :ok, location: @question }\n else\n format.html { render :edit }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @problem_set = ProblemSet.find(params[:problem_set_id])\n @question = Question.where(:id => params[:id], :problem_set_id => params[:problem_set_id]).first\n @answers = Answer.where(:question_id => @question.id)\n\n ans = [:answer1, :answer2, :answer3, :answer4]\n respond_to do |format|\n if @question.update_attributes(params[:question])\n \n @answers.each_with_index do |a, i|\n a.answer = params[ans[i]][:answer]\n a.correct = params[ans[i]][:correct]\n a.save\n end\n\n if @answers.size < 4 and params[ans[@answers.size]][:answer] != \"\"\n for i in @answers.size..4\n if params[ans[i]][:answer] != \"\"\n a = Answer.new(params[ans[i-1]])\n a.question_id = @question.id\n a.save\n end\n end\n end\n format.html { redirect_to(edit_problem_set_question_path(@problem_set.id, @question.count), :notice => 'Question was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @question.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @question = Question.find(params[:id])\n question = params.require(:question).permit(:title, :text, :tag1, :tag2, :tag3)\n Question.where('id = ?',@question.id).update(question)\n redirect_to questions_path, notice: '更新しました。'\n end",
"def create\n @quiz = Quiz.new(quiz_params)\n @article=Article.find(@quiz.article_id)\n @course=Course.find(@article.course_id)\n [email protected]+1\n # @course.update(:totalQuizzes, temp)\n Course.update({totalQuizzes: temp})\n\n\n respond_to do |format|\n if @quiz.save\n format.html { redirect_to :controller => 'articles', :action => 'index', notice: 'Quiz was successfully created.' }\n format.json { render :show, status: :created, location: @quiz }\n else\n format.html { render :new }\n format.json { render json: @quiz.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n # Using first or create allows users to update their answer (or create it obviously)\n answer = Answer.where(:question_id => params[:question_id], :user_id => current_user.id).first_or_create! do |answer|\n answer.user_id = current_user.id\n answer.survey_id = params[:survey_id]\n answer.group_id = current_user.group.id\n answer.question_id = params[:question_id]\n answer.answer = params[:answer]\n\n @created = true\n\n if answer.save\n q = IQuestion.find_by_id(params[:question_id])\n\n if q.present?\n qdes = q.description\n else\n qdes = \"Orphaned question\"\n end\n\n s = ISurvey.find_by_id(params[:survey_id])\n\n if s.present?\n sdes = s.title\n else\n sdes = \"Orphaned survey\"\n end\n #sendCable(\"#{current_user.name} <#{current_user.email}>\", \"[#{sdes}] #{qdes}:\", params[:answer])\n\n render json:{\"continue\" => true}\n else\n render json:{\"continue\" => false}\n end\n end\n if !@created && answer\n answer.answer = params[:answer]\n if answer.save\n #sendCable(\"#{current_user.name} <#{current_user.email}>\", \"Updated Answer: \", params[:answer])\n render json:{\"continue\" => true}\n else\n render json:{\"continue\" => false}\n end\n end\n end",
"def create_questionnaire\n\n @questionnaire = Object.const_get(params[:questionnaire][:type]).new(params[:questionnaire])\n\n if @questionnaire.type == \"QuizQuestionnaire\" #checking if it is a quiz questionnaire\n participant_id = params[:pid] #creating a local variable to send as parameter to submitted content if it is a quiz questionnaire\n @questionnaire.min_question_score = 0\n @questionnaire.max_question_score = 1\n\n @assignment = Assignment.find_by_id(params[:aid])\n if @assignment.team_assignment?\n teams = TeamsUser.find(:all, :conditions => [\"user_id = ?\", session[:user].id])\n for t in teams do\n if team = Team.find(:first, :conditions => [\"id = ? and parent_id = ?\", t.team_id, @assignment.id])\n break\n end\n end\n @questionnaire.instructor_id = team.id #for a team assignment, set the instructor id to the team_id\n else\n @questionnaire.instructor_id = participant_id #for an individual assignment, set the instructor id to the participant_id\n end\n save_questionnaire\n save_choices @questionnaire.id\n flash[:note] = \"Quiz was successfully created\"\n redirect_to :controller => 'submitted_content', :action => 'edit', :id => participant_id\n else\n if (session[:user]).role.name == \"Teaching Assistant\"\n @questionnaire.instructor_id = Ta.get_my_instructor((session[:user]).id)\n end\n save_questionnaire\n\n redirect_to :controller => 'tree_display', :action => 'list'\n end\n end",
"def update\n respond_to do |format|\n @test_question.assign_attributes(test_question_params)\n @test_question.attempts += 1\n if @test_question.save\n alert, notice = nil\n notice = 'Well done, all correct!' if @test_question.correct?\n alert = 'One or more of your answers was incorrect. Take a look at the hints below' if !@test_question.correct? && @test_question.next_chance?\n alert = 'One or more of your answers was incorrect' if !@test_question.correct? && !@test_question.next_chance? && !@test_question.last?\n\n if @test_question.next_test_question\n format.html { redirect_to edit_test_question_path(@test_question.next_test_question), alert: alert, notice: notice }\n elsif @test_question.tutorial?\n current_user.tutorial_completed = true\n current_user.save!\n format.html { redirect_to dashboard_path(@test_question.test), notice: \"Well done! Now do some real stuff. Click 'Take a Test' below to get started\" }\n else\n format.html { redirect_to test_path(@test_question.test) , alert: alert, notice: notice }\n end\n format.json { render :show, status: :ok, location: @test_question }\n else\n format.html { render :edit }\n format.json { render json: @test_question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_explanation\n @question.explanation = params[:question][:explanation]\n if @question.save\n flash[:success] = \"Explication modifiée.\"\n redirect_to chapter_path(@chapter, :type => 5, :which => @question.id)\n else\n render 'explanation'\n end\n end",
"def update_answers\n last_user_answers.each do |lua|\n lua.correct= (lua.response.to_f == self.response.to_f)\n lua.save!\n end\n end",
"def update\n respond_to do |format|\n if @quiz.update(quiz_params)\n format.html { redirect_to @quiz, notice: \"Quiz was successfully updated.\" }\n format.json { render :show, status: :ok, location: @quiz }\n\t\tmy_array = []\n my_array << @quiz.option1\n my_array << @quiz.option2\n my_array << @quiz.option3\n my_array << @quiz.option4\n\n correct_respo = my_array[@quiz.correct_response.to_i - 1]\n @quiz.correct_response_text = correct_respo\n @quiz.save\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @quiz.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @questionnaire = Questionnaire.find(params[:id])\n\n respond_to do |format|\n if @questionnaire.update_attributes(params[:questionnaire])\n format.html { redirect_to(@questionnaire, :notice => 'Questionnaire was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @questionnaire.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @answer = Answer.new(answer_params)\n @answer.update(user_id: session[:user_id], question_id: params[:question_id])\n if @answer.save\n redirect_to question_path(@answer.question)\n else\n flash[:warn] = \"Sorry that answer was not created. Please try again.\"\n redirect_to :back\n end\n end",
"def update\n respond_to do |format|\n if @questionnaire.update(questionnaire_params)\n format.html { redirect_to @questionnaire, notice: 'Тест успешно обновлен.' }\n format.json { render :show, status: :ok, location: @questionnaire }\n else\n format.html { render :edit }\n format.json { render json: @questionnaire.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n unless @edit_or_delete_right\n redirect_to exams_url,notice:\"您无权修改别人编写的考试\"\n end\n parsed_param=exam_params\n @exam.questions.delete_all\n @exam.add_questions_to_exam(@validated_question)\n respond_to do |format|\n if @exam.update(parsed_param)\n format.html { redirect_to @exam, notice: \"已成功更新考试“#{@exam.name}.”\" }\n format.json { render :show, status: :ok, location: @exam }\n else\n format.html { render :edit }\n format.json { render json: @exam.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @add_quizid_to_quesiton.update(add_quizid_to_quesiton_params)\n format.html { redirect_to @add_quizid_to_quesiton, notice: 'Add quizid to quesiton was successfully updated.' }\n format.json { render :show, status: :ok, location: @add_quizid_to_quesiton }\n else\n format.html { render :edit }\n format.json { render json: @add_quizid_to_quesiton.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @questionnaire = Questionnaire.new(questionnaire_params)\n @audit = Audit.find(params[:audit]) \n if @questionnaire.save\n @audit.update_attribute(:questionnaire_id, @questionnaire.id)\n redirect_to @audit, notice: \"The questionnaire has been saved.\"\n else\n flash[:error] = \"The questionnaire could not be saved.\"\n render \"new\"\n end\n end",
"def edit_answer\n require_admin\n if request.post?\n @answer = Answer.find(edit_answer_params[:id]) #inbound data object with 2 params(possibly 3 if we need to include question id)\n @answer.text = edit_answer_params[:text]\n @answer.save() #save to the db\n #@answer.questionId = edit_question_params.questionId\n redirect_to controller:\"qa\", action:\"view_question\", id:@answer.question_id\n \n else\n @answer = Answer.find(Integer(params[\"id\"]))\n end\n end",
"def update\n @survey = Survey.find_by_id( params[:survey_id] )\n @question = Question.find_by_id( params[:id] )\n\n if @question.update( question_params )\n if params[:commit] == \"Continue to the Next Step\"\n params[:option_num].to_i.times do\n @question.options.create # TODO: cleanup, could create empty options in db\n end\n\n redirect_to edit_survey_question_path(@survey, @question)\n else\n flash.now[:success] = \"Question Added!\"\n\n # Create new empty question for render\n @question = @survey.questions.build\n\n render :new\n end\n else\n flash.now[:error] = \"Sorry, we couldn't add that question due to errors.\"\n render :new\n end\n end",
"def create_quiz_questionnaire\n create_questionnaire\n end",
"def edit_question\n require_admin\n if request.post? # pass in the entire object you want to edit\n #over-write the data of the existing question\n #title, text, etc.\n #lookup the existing object in the db, edit the values, and save it.\n \n @question = Question.find(edit_question_params[:id]) #inbound data object with the 3 params\n @question.title = edit_question_params[:title]\n @question.text = edit_question_params[:text]\n @question.forum_id = edit_question_params[:forum_id]\n @question.keywords = edit_question_params[:keywords]\n @question.save() # save the db!\n \n #send the user back to the view_question with hte question id we just saved\n redirect_to controller:\"qa\", action:\"view_question\", id:@question.id\n #returns the form\n else # handles the get request which is to return a single question\n @question = Question.find(Integer(params[\"id\"]))\n end\n end",
"def update\n @audit = Audit.find(params[:audit]) \n if @questionnaire.update_attributes(questionnaire_params)\n flash[:notice] = \"The questionnaire has been updated.\"\n redirect_to @audit\n else\n render :action => 'edit'\n end\n end",
"def update\n respond_to do |format|\n if @quizzes_answer.update(quizzes_answer_params)\n format.html { redirect_to quiz_assessments_path(@quizzes_answer.assessment.quiz) }\n format.json { render :show, status: :ok, location: @quizzes_answer }\n else\n format.html { render :edit }\n format.json { render json: @quizzes_answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @questionnaire = Questionnaire.find(params[:id])\n\n respond_to do |format|\n if @questionnaire.update_attributes(params[:questionnaire])\n format.html { redirect_to @questionnaire, notice: 'Questionnaire was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @questionnaire.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_to_database\n if self.valid?\n Choice.add({\"choice\" => \"#{self.choice}\", \"question_id\" => \"#{self.question_id}\"})\n else\n false\n end\n end",
"def save_exam_answer_for!(exam, question_answered, user_answers=[], answer=false)\n custom_exam_answer = CustomExamAnswer.find_or_create_by(custom_exam: exam, flashcard: self)\n\n custom_exam_answer.update(answered: question_answered, correct: answer, answered_correct_in_exam: answer, user_answers: user_answers)\n end",
"def update\n respond_to do |format|\n if @quizzes_question.update(quizzes_question_params)\n if params[:commit] =~ /add/i\n format.html { redirect_to edit_quiz_question_path(@question.quiz, @question) }\n else\n format.html { redirect_to quiz_questions_path(@question.quiz), notice: 'Question was successfully updated.' }\n format.json { render :show, status: :ok, location: @quizzes_question }\n end\n else\n format.html { render :edit }\n format.json { render json: @quizzes_question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @question_answer_nested = Answer.new(params[:answer])\n next_question = @question_answer_nested.quiz.next_question(@question_answer_nested.question)\n user_id = session[:user_id]\n quiz_id = Question.find(params[:question_id]).quiz_id\n\n respond_to do |format|\n if @question_answer_nested.save\n user_scoring = UserQuiz.find_or_create_by_user_id_and_quiz_id(user_id, quiz_id)\n if next_question\n user_scoring.update_attributes(:status => \"In Progress\")\n format.html { redirect_to new_question_answer_path(next_question.id) }\n else\n user_scoring.update_attributes(\n :total_questions => @question_answer_nested.quiz.approved_questions.count,\n :num_correct => QuizGrader.num_correct(current_user.answers_for_quiz(@question_answer_nested.quiz_id), @question_answer_nested.quiz),\n :status => \"Completed\" \n )\n\n format.html { redirect_to score_path(:id => @question_answer_nested.quiz_id , :user_id => current_user.id), notice: 'Your completed quiz has been recorded.' }\n\n end\n else\n format.html { render action: \"new\" }\n end\n end\n end",
"def create\n respond_to do |format|\n if @question.save\n @question_link = QuizQuestion.create!(:qtype => params[:qtype], :qid => @question.id, :quizid => params[:quizid], :points => params[:points])\n @question_link.save\n @question.update(:questionid => @question_link.id)\n @quiz = Quiz.find_by_id(params[:quizid])\n format.html { redirect_to admin_quiz_path(@quiz), notice: 'Quiz multiple choice question was successfully created.' }\n format.json { render :show, status: :created, location: @question }\n else\n format.html { render :new }\n format.json { render json: @question.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n game = Game.find(params[:id])\n game.update(game_attributes)\n if game.previous_question.correct?\n flash[:success] = \"Correct!\"\n else\n flash[:error] = \"Nope, that's wrong\"\n end\n redirect_to edit_game_path(game)\n end",
"def save\n CONNECTION.execute(\"UPDATE partners SET assignment_id = '#{self.assignment_id}', name_worked = '#{self.name_worked}', WHERE id = #{self.id};\")\n end",
"def update_assignment_questionnaires(attributes)\n return if attributes.nil? || attributes.empty?\n\n if attributes[0].key?(:questionnaire_weight)\n validate_assignment_questionnaires_weights(attributes)\n @errors = @assignment.errors.to_s\n topic_id = nil\n end\n unless @has_errors\n # Update AQ if found, otherwise create new entry\n attributes.each do |attr|\n next if attr[:questionnaire_id].blank?\n\n questionnaire_type = Questionnaire.find(attr[:questionnaire_id]).type\n topic_id = attr[:topic_id] if attr.key?(:topic_id)\n duty_id = attr[:duty_id] if attr.key?(:duty_id) # if duty_id is present in the attributes, save it.\n aq = assignment_questionnaire(questionnaire_type, attr[:used_in_round], topic_id, duty_id)\n if aq.id.nil?\n unless aq.save\n @errors = @assignment.errors.to_s\n @has_errors = true\n next\n end\n end\n unless aq.update_attributes(attr)\n @errors = @assignment.errors.to_s\n @has_errors = true\n end\n end\n end\n end",
"def update\n @questions = Question.all\n @categories = [\"Learning from Labs\", \"Lab Instructor\", \"Lab Space and Equipment\", \"Time Required to Complete Labs\", \"Lecture Section Instructor\"]\n respond_to do |format|\n if @survey.update(survey_params)\n format.html { redirect_to @survey, notice: 'Survey was successfully submitted.' }\n format.json { render :show, status: :ok, location: @survey }\n\n # Update 'completed' attribute to true\n submission = Survey.find_by(survey_ID: @survey.survey_ID)\n submission.update(status: true)\n\n # Increment 'completed' attribute for section\n @section = Section.find_by(class_num: @survey.class_num)\n @section.update(completed: @section.completed + 1)\n\n\n else\n format.html { render :edit }\n format.json { render json: @survey.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n qp = question_params\n if qp[:question_type] == \"vignette\" or qp[:question_type] == \"nonchoice\"\n qp[:answer] = \"\"\n end\n\n respond_to do |format|\n if @question.update(qp)\n format.html { redirect_to paper_questions_path(question_params[:paper_id],question_params[:id]), notice: '題目已被成功編輯' }\n format.json { render :show, status: :ok, location: @question }\n else\n format.html { redirect_to edit_paper_question_path, notice: '上傳檔案大小不可超過500KB' }\n format.json { render json: paper_questions_path.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n \t@answer1 = params[:input1]\n \t@answer2 = params[:input2]\n \t@answer3 = params[:input3]\n \t@answer4 = params[:input4]\n \t@answer5 = params[:input5]\n\n \t@user = current_user\n \t@score = @user.score\n \t@quizscore = 0\n \t@quiz = Quiz.find(params[:id])\n @perfects = 0\n @quiztotal = @user.quizzes_taken + 1\n \t\n\n if @quiz.check1 == @quiz.answer1\n @score = @score + 1 \n @quizscore = @quizscore + 1\n end\n if @quiz.check2 == @quiz.answer2\n @score = @score + 1\n @quizscore = @quizscore + 1\n end\n if @quiz.check3 == @quiz.answer3\n @score = @score + 1\n @quizscore = @quizscore + 1\n end\n if @quiz.check4 == @quiz.answer4\n @score = @score + 1\n @quizscore = @quizscore + 1\n end\n if @quiz.check5 == @quiz.answer5\n @score = @score + 1\n @quizscore = @quizscore + 1\n end\n\n if @quizscore == 5\n @perfects = @perfects + 1\n @user.update_attributes(perfect_scores: @perfects)\n end\n \n #Allows users to submit their quizzes for gradsing and logs the event\n if current_user.is_admin != true \n @log = Log.new\n @log.update_attributes(score: @quizscore, userid: @user.id, quizid: @quiz.id, user: @user.email,\n quiz: @quiz.name, last_sign_in_ip: @user.current_sign_in_ip, event: \"Quiz Taken\") \t\n @user.update_attributes(score: @score, quizzes_taken: @quiztotal)\n\n if @quiz.update_attributes(check1: @answer1, check2: @answer2, check3: @answer3, check4: @answer4, check5: @answer5)\n redirect_to root_path\n flash[:success] = \"You got \" + @quizscore.to_s + \"/5 correct!\"\n end\n end\n\n \n if current_user.is_admin?\n #Declares required variables for admins to update quizzes\n @name = params[:name]\n @question1 = params[:question1]\n @question2 = params[:question2]\n @question3 = params[:question3]\n @question4 = params[:question4]\n @question5 = params[:question5]\n @ans1 = params[:answer1]\n @ans2 = params[:answer2]\n @ans3 = params[:answer3]\n @ans4 = params[:answer4]\n @ans5 = params[:answer5]\n @dis11 = params[:distract11]\n @dis12 = params[:distract12]\n @dis13 = params[:distract13]\n @dis21 = params[:distract21] \n @dis22 = params[:distract22]\n @dis23 = params[:distract23]\n @dis31 = params[:distract31]\n @dis32 = params[:distract32]\n @dis33 = params[:distract33]\n @dis41 = params[:distract41]\n @dis42 = params[:distract42]\n @dis43 = params[:distract43]\n @dis51 = params[:distract51]\n @dis52 = params[:distract52]\n @dis53 = params[:distract53]\n\n #Updates quiz parameters for new questions answers and distractors\n @quiz.update_attributes(name: @name, question1: @question1, question2: @question2, question3: @question3, question4: @question4,\n question5: @question5, answer1: @ans1, answer2: @ans2, answer3: @ans3, answer4: @ans3, answer5: @ans5, distract11: @dis11, distract12: @dis12,\n distract13: @dis13, distract21: @dis21, distract22: @dis22, distract23: @dis23, distract31: @dis31, distract32: @dis32, distract33: @dis33,\n distract41: @dis41, distract42: @dis42, distract43: @dis43, distract51: @dis51, distract52: @dis52, distract53: @dis53)\n\n @log = Log.new\n @log.update_attributes(updated_by: @user.email, quizid: @quiz.id, event: \"Quiz Updated\", \n last_sign_in_ip: @user.current_sign_in_ip)\n\n redirect_to admin_panel_quizzes_path\n \n \n end\n end",
"def update\n updater = QuestionUpdater.new(@_question, question_params) # TODO QuestionUpdater\n if updater.save\n flash[:success] = updater.message\n redirect_to question_path(@question)\n else\n flash.now[:error] = t('.update_error')\n render :edit\n end\n end",
"def create\n @quiz = Quiz.new(quiz_params)\n respond_to do |format|\n if @quiz.save\n if @quiz.answer == @quiz.question.name\n @quiz.update_points\n format.html { redirect_to @quiz, notice: \"BENAR point anda = #{@quiz.points}\" }\n else\n format.html { redirect_to edit_quiz_path(@quiz), notice: 'SALAH! silahkan coba lagi!' }\n end\n else\n format.html { render :new }\n end\n end\n end",
"def update\n @quiz = Quiz.find(params[:id])\n \n respond_to do |format|\n if @quiz.update_attributes(params[:quiz])\n format.html { redirect_to @quiz, notice: 'Quiz was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @quiz.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @quiz_attempt.update(quiz_attempt_params)\n @quiz_attempt.check_answers\n format.html { redirect_to @quiz_attempt, notice: 'Quiz attempt was successfully updated.' }\n format.json { render :show, status: :ok, location: @quiz_attempt }\n else\n format.html { render :edit }\n format.json { render json: @quiz_attempt.errors, status: :unprocessable_entity }\n end\n end\n end",
"def single_quiz_update\r\n #allow receiving all parameters\r\n params.permit!\r\n #response format pre-defined\r\n result = {\"str_id\" => nil, :status => \"\", :message => \"\" }\r\n begin\r\n current_quiz = Mongodb::BankQuizQiz.find_by(id: params[:str_id])\r\n current_quiz.save_quiz(params)\r\n result[:str_id]=current_quiz._id\r\n flash[:notice] = I18n.t(\"quizs.messages.update.success\" , :id => current_quiz._id)\r\n result[:status] = 200\r\n result[:message] = I18n.t(\"quizs.messages.update.success\", :id => current_quiz._id)\r\n rescue Exception => ex\r\n result[:status] = 500\r\n result[:message] = I18n.t(\"quizs.messages.update.fail\", :id => current_quiz._id)\r\n ensure\r\n render json: result.to_json\r\n end\r\n end",
"def respond_save\n\t\t@poll = Poll.find(params[:id])\n\t\tif current_user.save_answers_and_respond_to!(@poll, params)\n\t\t\tredirect_to @poll, notice: \"Successfully responded to this poll.\"\n\t\telse\n\t\t\tredirect_to respond_poll_path(@poll), notice: \"Something went wrong: please try again.\"\n\t\tend\n\tend",
"def update\n @questionnaire = current_questionnaire\n @questionnaire.step += 1\n\n respond_to do |format|\n if @questionnaire.update_attributes(params[:questionnaire])\n format.html { redirect_to new_questionnaire_path }\n # format.json { head :no_content }\n else\n format.html { render \"questionnaires/steps/step#{@questionnaire.step - 1}\" }\n # format.json { render json: @questionnaire.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @quiz = current_user.quizzes.build(quiz_params)\n\n @quiz.questions.each do |q|\n if q.question_type == \"free_answer\"\n q.answers = []\n end\n end\n\n puts @quiz.questions\n\n respond_to do |format|\n if @quiz.save\n format.html { redirect_to current_user, notice: 'Quiz was successfully created.' }\n format.json { render :show, status: :created, location: @quiz }\n else\n format.html { render :new }\n format.json { render json: @quiz.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @questionnaire.update(questionnaire_params)\n format.html { redirect_to @questionnaire, notice: 'Questionnaire was successfully updated.' }\n format.json { render :show, status: :ok, location: @questionnaire }\n else\n format.html { render :edit }\n format.json { render json: @questionnaire.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_question\n @questions=Admin::Questionbank.find(:all,:select=>\"id,question_code,subject_name,question_number,internal_ref_number\",:order=>'created_at DESC',:limit=>3)\n @questionbank=Admin::Questionbank.find(params[:id])\n @examtypes=Admin::Examtype.find(:all,:select=>\"id,examtype\",:order=>'examtype')\n @sectiontopics=Admin::Sectiontopic.find(:all,:select => 'DISTINCT Topic,id')\n @sectiontags=Admin::Sectiontemplate.find(:all,:select=>'SectionTags')\n totalexamtypes = \"\"\n i=1\n @examtypes.size.times{\n examtypes = params['etype'+i.to_s]['checked']\n if totalexamtypes == ''\n totalexamtypes = examtypes\n else\n totalexamtypes = totalexamtypes+','+examtypes\n end\n i=i+1\n }\n @questionbank.examtype_tags=totalexamtypes\n if @questionbank.question_media_type==0 # if question type is textual\n @questionbank.update_attributes(params[:questionbank])\n redirect_to :action => 'edit_success', :id => @questionbank\n elsif @questionbank.question_media_type==1 #if question type is graphical \n @questionbank.topic=params[:questionbank][:topic]\n @questionbank.sub_topic=params[:questionbank][:sub_topic]\n @questionbank.sub_sub_topic=params[:questionbank][:sub_sub_topic]\n @questionbank.tags=params[:questionbank][:tags]\n @questionbank.correct_answer=params[:questionbank][:correct_answer]\n @questionbank.source=params[:questionbank][:source]\n @questionbank.author=params[:questionbank][:author]\n @questionbank.comments=params[:questionbank][:comments]\n @questionbank.internal_ref_number=params[:questionbank][:internal_ref_number]\n @questionbank.topic=params[:questionbank][:topic].strip\n @questionbank.tags=params[:questionbank][:tags].strip\n Admin::Questionbank.save_imagepaths_in_db(params[:questionbank],@questionbank,@questionbank.subject_code,@questionbank.question_code)## to save the image paths in db\n @questionbank.save\n Admin::Questionbank.delete_previous_files(params[:questionbank]) ## to delete the previous files in application if they exist \n Admin::Questionbank.save_images(params[:questionbank],@questionbank.subject_code,@questionbank.question_code)## and save the files(images) again\n redirect_to :action => 'edit_success', :id => @questionbank\n else\n render :action => 'edit_question'\n end\n end",
"def salasquiz\n @exposicion = Exposicion.find(params[:id])\n @salas = @exposicion.salas\n current_user.currentPoints = 0\n current_user.save\n end",
"def update\n route = edit_admin_learning_object_path(id: @learning_object.id, anchor: 'answer-settings')\n\n begin\n ActiveRecord::Base.transaction do\n @learning_object.answers.force_all.each do |a|\n a.update!(\n is_correct: params[\"correct_answer_#{a.id}\"] == \"1\",\n visible: params[\"visible_answer_#{a.id}\"] == \"1\",\n answer_text: params[\"edit_answer_text_#{a.id}\"]\n )\n end\n @learning_object.validate_answers!\n end\n rescue AnswersCorrectnessError\n return redirect_to(route, :alert => \"Otázka nesmie mať viac ako jednu správnu odpoveď.\")\n rescue AnswersVisibilityError\n return redirect_to(route, :alert => \"Otázka nesmie mať viac ako jednu viditeľnú odpoveď.\")\n end\n\n redirect_to route, :notice => \"Zmeny v odpovediach boli úspešne uložené.\"\n end",
"def update\n respond_to do |format|\n if @evaluation.update(evaluation_params)\n @practice = Practice.find(@evaluation.practice_id)\n if @practice.answer == @evaluation.your_answer\n @justice = Justice.create!(\n user_id: 1,\n evaluation_user_id: @evaluation.user_id,\n practice_id: @evaluation.practice_id,\n\t evaluation_id: @evaluation.id,\n\t score: @evaluation.practice_score, # 得到满分\n\t p_score: @evaluation.practice_score,\n remark: \"完全正确!\",\n )\n @evaluation.update(score: @evaluation.practice_score)\n end\n format.html { redirect_to @evaluation, notice: \"答案更新成功\" }\n format.json { render :show, status: :ok, location: @evaluation }\n else\n format.html { render :edit }\n format.json { render json: @evaluation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @question.user_id = current_user.id\n @question.update(question_params)\n redirect_to qset_path(@question.qset), notice: \"Your question has been updated!\"\n end",
"def add_test_to_account\n \n quiz_user = QuizUser.new\n quiz_user.quiz_id = params[:quiz_id]\n quiz_user.user_id = current_user.id\n quiz_user.save!\n \n redirect_to homes_index_path, notice: \"Test added to your account.\"\n \n end",
"def update\n respond_to do |format|\n if @survey_quiz.update(survey_quiz_params)\n format.html { redirect_to @survey_quiz, notice: 'Quiz was successfully updated.' }\n format.json { render :show, status: :ok, location: @survey_quiz }\n else\n format.html { render :edit }\n format.json { render json: @survey_quiz.errors, status: :unprocessable_entity }\n end\n end\n end",
"def quiz\n @questions = Question.all\n @idx = params[:idx] ? (params[:idx].to_i + 1) : 0\n if params[:answer]\n question = Question.find(params[:id])\n if check_answer(params[:answer], question.answer)\n @correct_answer_number = params[:correct_answer_number].to_i + 1\n if @idx < @questions.size\n flash[:notice] = \"Correct\"\n else\n flash[:notice] = \"Correct. Summary: You have answered #{@correct_answer_number} question(s) correctly out of #{@questions.size}\"\n end\n else\n @correct_answer_number = params[:correct_answer_number].to_i\n if @idx < @questions.size\n flash[:notice] = \"Incorrect\"\n else\n flash[:notice] = \"Incorrect. Summary: You have answered #{@correct_answer_number} question(s) correctly out of #{@questions.size}\"\n end\n end\n else\n @correct_answer_number = 0\n end\n if @idx >= @questions.size\n @idx = 0\n @correct_answer_number = 0\n end\n flash[:notice] = \"No questions have been added yet. Please ask the administrator to add some questions first.\" if @questions.size == 0\n end",
"def update\n respond_to do |format|\n if @answer.update(answer_params)\n format.html { redirect_to @answer.question, notice: 'Respuesta actualizada satisfactoriamente' }\n format.json { render :show, status: :ok, location: @answer }\n else\n format.html { render :edit }\n format.json { render json: @answer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def question_add\n\t\t$DATABASE.execute('INSERT INTO jeopardy (cat_id, question, answer,points) VALUES (?,?,?,?)', [category, question, answer, points])\n\tend",
"def answer\n params[:answers].each do |question_id, value|\n answer = Answer.find_or_initialize_by_question_id_and_user_id(question_id, current_user.id)\n answer.content = value[:content]\n answer.save\n end if params[:answers]\n\n survey = Survey.find(params[:id])\n redirect_to survey.next_url || root_url, :notice => survey.confirmation\n end",
"def update\n @page = Page.find(params[:id])\n questions = @presenter.all_questions_for_page(params[:id])\n questions.post(params[:answers], @answer_sheet)\n \n questions.save\n \n @elements = questions.elements\n \n # Save references\n if params[:reference].present?\n params[:reference].each do |id, values|\n ref = @answer_sheet.reference_sheets.find(id)\n # if the email address has changed, we have to trash the old reference answers\n ref.attributes = values\n ref.save(:validate => false)\n end\n end\n @presenter.active_page = nil\n @answer_sheet.touch\n respond_to do |format|\n format.js\n #format.html\n end\n end",
"def create\n @quiz = Quiz.new(quiz_params)\n\n respond_to do |format|\n if @quiz.save\n format.html { redirect_to @quiz, notice: \"Quiz was successfully created.\" }\n format.json { render :show, status: :created, location: @quiz }\n\t\tmy_array = []\n\t\tmy_array << @quiz.option1\n\t\tmy_array << @quiz.option2\n\t\tmy_array << @quiz.option3\n\t\tmy_array << @quiz.option4\n\t\t\n\t\tcorrect_respo = my_array[@quiz.correct_response.to_i - 1]\n\t\[email protected]_response_text = correct_respo\n\t\[email protected]\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @quiz.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @question = Account.new.update_question(question_params)\n if @question\n return render json: {message: 'Question was created succesfully', error: false}\n else\n return render json: {message: 'Error: Question was not created succesfully', error: true}\n end\n end",
"def test_edit_questionnaire\r\n post :edit, {:id => @Questionnaire, :save => true, \r\n :questionnaire => {:name => \"test edit name\", \r\n :type => \"ReviewQuestionnaire\",\r\n :min_question_score => 1,\r\n :max_question_score => 3}}\r\n assert_response(:success)\r\n assert_not_nil(Questionnaire.find(:first, :conditions => [\"name = ?\", \"test edit name\"]))\r\n end",
"def update\n @question.update\n @cancel.update\n end",
"def save\n end",
"def add_answer(ans_attr)\n return nil if answers.find_by_question_id(ans_attr[:question_id])\n ans = answers.build(ans_attr)\n if ans.question_option_id && option = ans.question.options.find(ans.question_option_id)\n ans.points = option.points_to_award\n ans.correct = option.correct?\n ans.entry_id = option.entry_id\n end \n ans.save\n reload\n ans\n end",
"def save_edits\n DATABASE.execute(\"UPDATE boards SET title = '#{@title}', description = '#{@description}' WHERE id = #{@id}\")\n end"
] | [
"0.7704281",
"0.76687604",
"0.7614883",
"0.75466186",
"0.736566",
"0.7299445",
"0.6883573",
"0.6839848",
"0.66819066",
"0.66391426",
"0.662807",
"0.6601551",
"0.65679485",
"0.6503789",
"0.6503784",
"0.6454465",
"0.6451807",
"0.64460045",
"0.6445716",
"0.6412378",
"0.6399056",
"0.63429856",
"0.6339469",
"0.6339469",
"0.6333868",
"0.6328246",
"0.6327645",
"0.62968016",
"0.6292587",
"0.6289102",
"0.6271326",
"0.62639904",
"0.626338",
"0.62533385",
"0.6251878",
"0.62476367",
"0.624365",
"0.62424487",
"0.6226284",
"0.621392",
"0.62030727",
"0.6197926",
"0.619764",
"0.6178189",
"0.617378",
"0.6171224",
"0.61668915",
"0.6166614",
"0.6164773",
"0.61575127",
"0.61533916",
"0.61512685",
"0.61495185",
"0.6142115",
"0.6137049",
"0.6136579",
"0.6131606",
"0.6131012",
"0.61292523",
"0.6127079",
"0.6121428",
"0.6120131",
"0.61132765",
"0.6107856",
"0.6103009",
"0.6098323",
"0.6087432",
"0.6082423",
"0.6081961",
"0.6070065",
"0.6067009",
"0.6065188",
"0.60566777",
"0.6056482",
"0.60401475",
"0.6036643",
"0.60333747",
"0.6032071",
"0.60275155",
"0.6023483",
"0.60188806",
"0.60186577",
"0.6018592",
"0.601047",
"0.6007225",
"0.6002102",
"0.5998049",
"0.5986373",
"0.5983606",
"0.59794784",
"0.5974042",
"0.59662545",
"0.5963769",
"0.59608257",
"0.5959679",
"0.5955882",
"0.59537184",
"0.59516263",
"0.5946805",
"0.594514"
] | 0.75679433 | 3 |
GET /messages list of users you have had message encounters with | def index
raise ApiAccessEvanta::PermissionDenied unless AppSettings::Value.new(:messages, user: current_user).on?
@messages = Message.get_message_list(current_user)
render json: @messages
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def messages_from user\n backend.messages_page(user).messages\n end",
"def index\n\t\t@messages = Message.where(:to_user => current_user.id)\n\t\trespond_with(@messages) \n\tend",
"def list_of_messages()\n\t\t\n\t\t#Create a new request\n\t\trequest_url = \"https://www.googleapis.com/gmail/v1/users/#{@email}/messages?labelIds=Label_1&access_token=#{@access_token}\"\n\n\t\t#GET REQUEST\n\t\tresponse = RestClient.get request_url\n\t\tresponse_body = JSON.parse(response.body)\n\n\t\t#Looping through all the Messages and grabbing id\n\t\tmessages= Array.new\n\n\t\ttemp = response_body['messages']\n\t\ttemp.each do |item|\n\t\t\tmessages.push(item['id'])\n\t\tend \n\t\n\t\treturn messages\n\tend",
"def messages\n user_ids = users.pluck(:id)\n rooms_user_ids = RoomsUser.where(room_id: self.id, user_id: user_ids).pluck(:id)\n RoomMessage.where(rooms_user_id: rooms_user_ids).order(created_at: :asc)\n end",
"def index\n @messages = current_user.messages\n respond_with(@messages)\n end",
"def index\n @user_messages = UserMessage.all\n end",
"def show_messages\n @messages = get_user.messages.search(params[:page])\n end",
"def index\n @messages = current_user.received_messages\n @messages = @messages.order(created_at: :desc)\n @messages = @messages.paginate(page: params[:page], per_page:5)\n @messages = @messages.to_a\n end",
"def index\n @messages = Message.where(user_id: current_user.id)\n end",
"def index\n \n # puts \" begin \"\n # puts User.findUser(params[:user_email]).inspect #Message.where(reciever: params[:user_id])\n # puts \" end \"\n \n @messages = Message.where(reciever: User.findUser(params[:user_email]).id)\n end",
"def index\n @messages = current_user.received_messages\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end",
"def receivedMessagesToUser\n render json: Message.where(receiver_id: params[:id], created_at: (Time.now - 30.day)..Time.now).limit(100)\n end",
"def index\n @messages = current_user.received_messages\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end",
"def get_messages\n \tuser = User.find(params[:user_id]);\n \tif user\n \t\tmessages = Message.where(message_type: user.user_type)\n \t\tconversation = Conversation.where(request_id: params[:request_id])\n texts = []\n conversation.each{ |msg| texts.push(Message.find_by(id: msg.message_id) ? Message.find(msg.message_id) : {})}\n \t\trender json: {messages: messages, conversation: conversation, texts: texts}\n \telse\n\t\trender json: {error: 'User not found.'}\n \tend\n end",
"def messages\n read_only()\n @conn.uid_search(['ALL']).map do |uid|\n Message.new(@conn, uid)\n end\n end",
"def unread_messages user_id\n messages.unread(user_id)\n end",
"def messages\n Client.get(EVENTS_PATH, {\n recipient: @email_address\n })\n end",
"def messages\n\t\t@musician = User.find_by_id(params[:id])\n\t\t@messages = @musician.messages\n\tend",
"def index\n #@messages = Message.all\n #@messages = current_owner.messages\n @users = current_owner.conversation_users\n end",
"def messages\n get_json('messages.json')\n end",
"def get_messages(page = 0)\r\n if page > 0\r\n message_url = \"/message_threads?page=#{page}\"\r\n else\r\n message_url = \"/message_threads\"\r\n end\r\n response = self.class.get(message_url, headers: { \"authorization\" => @user_auth_token })\r\n JSON.parse(response.body)\r\n end",
"def messages\n proxy_exceptions do\n @page.conversations.map do |conversation|\n conversation.messages.map do |data|\n Services::Facebook::Message.new do |message|\n message.id = data.identifier\n message.message = data.message\n message.created_at = data.created_time\n message.author = Services::Facebook::User.new do |user|\n user.id = data.from.identifier\n user.name = data.from.name\n end\n end\n end\n end.flatten\n end\n end",
"def index\n @messages = Room.find(params['room_id']).messages\n end",
"def unread_messages(user)\n Rails.cache.fetch(\"#{cache_key_with_version}/unread_messages/#{user.id}\") do\n Message.unread_by(user).where(chat_room: self).where.not(user: user).to_a\n end\n end",
"def index\n\n @users_with_conversation = []\n @messages = Message.where(receiver_id: params[:user_id]).reverse_order\n @new_messages = @messages.where(unread: true)\n @messages.each do |message|\n unless @users_with_conversation.include?(message.sender)\n @users_with_conversation.push(message.sender)\n end\n end\n @messages = Message.all\n end",
"def index\n @users = current_user.sent_messages.distinct.map(&:receiver)\n @users += current_user.received_messages.distinct.map(&:sender)\n @users = @users.uniq\n end",
"def my_messages(opts = {})\n client.get_my_messages(opts)\n end",
"def index\n @messages = Message.find_all_by_user_id(session[:user_id], :order => \"timestamp DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @messages }\n end\n end",
"def getAllMessagesForUser(index, group_id, user_id)\n query = {\n \"size\" => 100000,\n \"query\" => {\n \"bool\" => {\n \"must\" => [\n { \n \"term\" => { \n \"user_id\" => \"#{user_id}\" \n }\n },\n {\n \"term\" => { \n \"group_id\" => \"#{group_id}\" \n }\n }\n ]\n }\n }\n }\n self.class.get(\"#{index}/message/_search\", :body => query.to_json)\n end",
"def index\n @messages = current_user.messages.limit(10).order('id desc')\n end",
"def index\n user = User.includes(message_threads: [:messages])\n .find(params[:user_id])\n\n if user.role === \"patient\"\n unread_messages = user.messages.where(read: false)\n render json: {\n unread_messages_count: unread_messages.count,\n unread_messages: unread_messages\n }\n elsif user.role === \"care_manager\"\n threads = user.patients.as_json(include: :messages)\n render json: threads\n end\n end",
"def unread_messages\n @user_wise_unread_messages = current_user.user_messages\n .where(is_read: false)\n .joins(:message)\n .group('messages.user_id').count\n end",
"def read_all_messages\n post(\"/api/read_all_messages\")\n end",
"def index\n\n if params[:user_id]\n @messages = Message.where(:user_id => params[:user_id].to_i)\n else\n @messages = Message.all\n end\n if params[:page] and params[:per_page]\n @messages = @messages.paginate(:per_page=>params[:per_page].to_i,:page=>params[:page].to_i).order(\"id desc\")\n @page = params[:page]\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :messages }\n end\n end",
"def fetch\n messages = paginate ConversationMessage.where(conversation_id: params[:conversation_id])\n .order('created_at DESC')\n render json: messages.to_json(:include => :user)\n end",
"def all_messages\r\n self.users_messaged + self.users_messaged_by\r\n end",
"def all_messages\r\n self.users_messaged + self.users_messaged_by\r\n end",
"def index\n # Only get the messages for the user currently signed in\n if current_user.group.messages_released\n \t@messages = current_user.messages\n else\n \t@messages = {}\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { send_data @messages }\n end\n end",
"def index\n @messages = current_user.messages_in.order('created_at ASC').group('sender_id')\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end",
"def received_messages(page = 1)\n _received_messages.paginate(:page => page, :per_page => MESSAGES_PER_PAGE)\n end",
"def index\n @diary_entries = @current_user.messages.where(message_type: \"diary_entry\")\n \n end",
"def show_messages(uids)\n return if uids.nil? or (Array === uids and uids.empty?)\n\n fetch_data = 'BODY.PEEK[HEADER.FIELDS (DATE SUBJECT MESSAGE-ID)]'\n messages = imap.fetch uids, fetch_data\n fetch_data.sub! '.PEEK', '' # stripped by server\n\n messages.each do |res|\n puts res.attr[fetch_data].delete(\"\\r\")\n end\n end",
"def retrieve_messages(from = 10)\n uri = \"/#{@get_url}?#{get_query_string}\"\n lists = []\n @https_.start do\n body = @https_.get(uri, @get_header_).body\n StringIO.open(body, 'rb') do |sio|\n content = Zlib::GzipReader.wrap(sio).read\n lists = JSON.load(content)['result']['chat_list']\n end\n end\n\n new_message = []\n lists.each do |list|\n if list['tm'] >= Time.now.to_i - from\n new_message << list['msg']\n end\n end\n\n return new_message\n end",
"def show\n @messages = @message_room.messages.order(:created_at)\n @subscribers = @message_room.users\n end",
"def index\n @custom_messages = CustomMessage.where(user_id: current_user.id)\n end",
"def index\n # @messages = Message.all\n # @messages = Message.where(user_id: session[:user_id])\n\n @messages = Message.where(recipient: current_user[:email])\n @sent_messages = Message.where(user_id: session[:user_id])\n @username = current_user[:email]\n end",
"def getContacts\n messages = [] \n \n if !self.received_messages.nil?\n messagesRecv = (self.received_messages.order(:updated_at)).reverse \n\t messagesRecv.each do |recv|\n\t user = User.find(recv.sender_id)\n\t unless messages.include?(user)\n\t\t messages += [user]\n\t\t end\n\t end\n end\n if !self.send_messages.nil?\n messagesSend = (self.send_messages.order(:updated_at)).reverse \n\t messagesSend.each do |send|\n\t user = User.find(send.receiver_id)\n\t unless messages.include?(user)\n\t\t messages += [user]\n\t\t end\n\t end\n end\n\t return messages\n end",
"def messages\n msgs = []\n favorites.each do |fav|\n fav.messages.each do |message|\n msgs << message\n end\n end\n msgs\n end",
"def index\n @messages_received = current_user.messages\n @messages_sent = Array.new\n\n Message.all.each do |message|\n if message.sender == current_user.username\n @messages_sent.push(message)\n end\n end\n end",
"def messages\n\t\t@content_title = \"Messages\"\n\t\t@messages = Message.paginate(:order => 'created_at DESC', :page => params[:page])\n\tend",
"def index\n messages = Message.all\n end",
"def index\n @messages = current_user.received_messages.paginate(:page => params[:page])\n @title = \"Входящие сообщения\"\n @path = \"index\"\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end",
"def get_messages( page=0 )\n\t result = []\n\t if page > 0\n\t response = self.class.get( '/message_threads', body: { page: page }, headers: {'authorization' => @auth_token} )\n\t JSON.parse( response.body )\n\t else\n\t response = self.class.get( '/message_threads', body: { page: 1 }, headers: {'authorization' => @auth_token} )\n for page in 1..(response[\"count\"]/10 + 1)\n response = self.class.get( '/message_threads', body: { page: page }, headers: {'authorization' => @auth_token} )\n result << JSON.parse(response.body)\n end\n result\n\t end\n\tend",
"def search_user_names_for_message\n @users = (session[:from_follower_following] ? @login_user.from_follower_following(params[:term]) : @login_user.all_message_users(params[:term]))\n @usernames = []\n @users.collect{|u| @usernames << u.username}\n respond_to do |format|\n format.json { render :json => @usernames }\n end\n end",
"def index\n @messages = @conversation.messages\n @message = Message.new(user_id:current_user.id)\n @conversation.messages_for(current_user).unread.update_all(read: true)\n end",
"def inbox\n cur_emp = get_logged_employee\n @messages = Message.where(\"sent_to = ?\", cur_emp).where(:is_deleted => nil )\n render \"resumes/message_show\"\n end",
"def my_messages\n my_mesgs = Message.includes(:user).where(receiver_id: @current_user.id).order(created_at: :desc)\n if my_mesgs.any?\n render json: my_mesgs, :include => {\n :user => {\n :only => [:id, :firstname, :lastname]\n }\n },\n status: :ok\n else\n render json: {\n status: 'no-content',\n message: 'You don\\'t have any message yet',\n data: []\n },\n status: :no_content\n end\n end",
"def index\n if params[:last_message_id]\n @messages = Message.includes(:user).where(\"id > ?\", params[:last_message_id])\n else\n @messages = Message.includes(:user).limit(5).order(:created_at).reverse_order\n end\n\n @message_data = []\n @messages.each do |message|\n @message_data.push({\n :id => message.id,\n :user => message.user.name,\n :content => message.content\n })\n end\n \n respond_to do |format|\n format.json { render :json => @message_data}\n end\n end",
"def index\n @lier_private_message_users = LierPrivateMessageUser.all\n end",
"def all_messages\n Message.all\n end",
"def messages(older_than = nil, newer_than = nil)\n oauth_response = access_token.get \"/api/v1/messages.json\"\n JSON.parse(oauth_response.body)\n end\n\n # Return a list of the 20 most recent direct messages sent by the\n # authenticated user\n def sent_messages\n oauth_response = access_token.get \"/api/v1/messages/sent.json\"\n JSON.parse(oauth_response)\n end\n\n # Return messages received by the logged-in user. Corresponds to the\n # \"Received\" tab on the website.\n def received_messages\n oauth_response = access_token.get \"/api/v1/messages/received.json\"\n JSON.parse(oauth_response)\n end\n\n # Return messages in the group with the given ID. Corresponds to the\n # messages you'd see on a group's profile page.\n def group_messages(group_id)\n oauth_response = access_token.get \"/api/v1/messages/in_group/#{group_id}.json\"\n JSON.parse(oauth_response)\n end\n\n # Update the current user's status\n def update(message, group_id = nil)\n if group_id.nil?\n oauth_response = access_token.post(\"/api/v1/messages\", :body => message)\n else\n oauth_response = access_token.post(\"/api/v1/messages\", :body => message, :group_id => group_id)\n end\n JSON.parse(oauth_response)\n end\n\n # Delete a message owned by the current user\n def delete(message_id)\n oauth_response = access_token.delete(\"/api/v1/messages/#{message_id}\")\n JSON.parse(oauth_response)\n end\n\n # Reply to a message\n def reply_to(message, message_id)\n oauth_response = access_token.post(\"/api/v1/messages\", :body => message, :replied_to_id => message_id)\n JSON.parse(oauth_response)\n end\n\n # Sends a private message direct to the user indicated\n def direct_to(message, user_id)\n oauth_response = access_token.post(\"/api/v1/messages\", :body => message, :direct_to_id => user_id)\n JSON.parse(oauth_response)\n end\n end\nend",
"def messages\n all_messages = []\n @all.each do |e|\n all_messages += e[:messages]\n end\n all_messages\n end",
"def messages\n responses.map(&:messages).flatten\n end",
"def index\n @messages = Message.all\n @unread = Recipient.where(:user_id => current_user.id,:status => false).map {|r| r.message}.reverse\n @read = Recipient.where(:user_id => current_user.id,:status => true).map {|r| r.message}.reverse\n end",
"def unseen\n messages = current_user.received_messages.where(seen: false)\n render json: messages\n end",
"def index\n @messages = Message.where(:to_user => current_user.id).order('id desc').paginate(:page => params[:page])\n @sent_messages = Message.where(:user_id => current_user.id).order('id desc').paginate(:page => params[:sent_page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @messages }\n end\n end",
"def index\n if User::ROLES.first(User::AdminThreshold).include? current_user.role\n @messages = Message.all\n else\n @messages = Message.where(\"visible_to = 0 OR visible_to = ?\", current_user.id).order(\"created_at DESC\")\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end",
"def index\n @direct_messages = DirectMessage.get_direct_messages(current_user)\n \n @recipients = User.reachable_users(current_user)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @direct_messages }\n end \n end",
"def messages options = {}\n query = {\n \"skip\" => options[:skip],\n \"beforeId\" => options[:before],\n \"afterId\" => options[:after],\n \"aroundId\" => options[:around],\n \"limit\" => options[:limit],\n \"q\" => options[:search]\n }\n\n data = client.get \"/v1/rooms/#{id}/chatMessages\", query\n\n Message::Collection.new self, data\n end",
"def index\n @user_chats = Chatroom.where(friendship_id: friendship_chats)\n @messages = Message.where(chatroom_id: @user_chats)\n end",
"def unread_messages\n data = client.get \"#{api_prefix}/user/#{client.user.id}/rooms/#{id}/unreadItems\"\n\n Message::Collection.new self, data\n end",
"def read_messages\n @useConversations = Message.where(\"user_id = (?)\", current_user.id).pluck(:conversation_id)\n if @useConversations.count > 0\n @useConversations = @useConversations.uniq # Unique\n @useConversations = @useConversations.map(&:inspect).join(', ')\n #@updatemsg = Message.where(\"user_id != (?) and conversation_id IN (?)\", current_user.id, @useConversations).update_all(:mark_as_read => true)\n @updatemsg = Message.where(\"user_id != #{current_user.id} and conversation_id in (#{@useConversations})\").update_all(:mark_as_read => true)\n session[:mark_messages] = 0 # Mark as read messages\n end\n end",
"def index\n list = current_user.chats.pluck :id\n\n options = filter_params\n options[:id] = filter_params[:id] == 'all' ? list : [filter_params[:id]]\n @messages = ChatMessage.filter options\n @messages = @messages.group_by(&:chat_id)\n end",
"def get_messages\n @messages = Message.order(:created_at).last(50)\n @message = current_user.messages.new\n end",
"def unread_messages\n current_user.messages_in.where(read: false).count\n end",
"def index\n @messages = StarshipMessage.paginate( :page => params[:page], :per_page => 50, \n :conditions => [\"person_id=?\", @loggedin_user.id ], :order => \"id DESC\" )\n end",
"def list_of_commmessages_for_user(user_id,opts={})\n query_param_keys = [\n :user_id,\n :start_time,\n :end_time\n ]\n\n form_param_keys = [\n \n ]\n\n # verify existence of params\n raise \"user_id is required\" if user_id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :user_id => user_id\n )\n\n # resource path\n path = path_replace(\"/v1/comm_messages\",\n )\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:get, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:get, path, query_params, form_params, headers)\n page_params_store(:get, path)\n response.map {|response|CommMessage.new(response)}\n end",
"def inbox\n @messages = current_user.received_messages\n end",
"def inbox\n @messages = current_user.received_messages\n respond_with @messages\n end",
"def get_chat_messages\n # get chat messages\n chats = Message.includes(:user).where(receiver_id: @current_user.id, user_id: params[:user_id], request_id: params[:request_id]).or(Message.includes(:user).where(user_id: @current_user.id, receiver_id: params[:user_id], request_id: params[:request_id])).order(created_at: :asc)\n if chats.any?\n render json: chats, :include => {\n :user => {\n :only => [:id, :firstname, :lastname]\n },\n },\n status: :ok\n else\n render json: {\n status: 'no-content',\n message: 'No chat on this request yet'\n },\n status: :no_content\n end\n end",
"def index\n @messages = current_user.is_support? ? Message.where(message_id: nil).order(\"support_call desc, updated_at desc\").includes(:replies).all : Message.where(user_id: current_user.id, message_id: nil).order(\"user_call desc, updated_at desc\").includes(:replies).all\n end",
"def message_list(filters = {})\n params = { limit: 10, offset: 0 }.merge(filters).compact\n query = \"messages?#{URI.encode_www_form(params)}\"\n\n List.new(Message, request(:get, query))\n end",
"def messagebox\n\t\t# retrieve all messages and unread messages of current user\n @user = current_user\n @messages = Message.paginate_by_receiver_id @user.id, :page => params[:page], :order => 'created_at DESC', :per_page => 10\n @unread_messages = Message.find(:all, :conditions => {:receiver_id => current_user.id, :unread => true})\n end",
"def read_messages!(user)\n if has_unread_messages?(user)\n user.reset_unread_chats_count\n self.chat_participations.where(user_id: user.id).first.try(:read_messages!)\n end\n end",
"def get_all\n if @messages = Message.all\n render json: @messages\n else\n render json: \"Error!\"\n end\n\n end",
"def index\n @user = current_user\n @messages = current_user.extension.messages\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @messages }\n end\n end",
"def messages\n Message\n .where(\"messages.user_id = :user OR messages.recipient_id = :user\", user: id)\n .where.not(\"messages.recipient_id = :user AND messages.status = :status\", user: id, status: 0)\n .where.not(\"messages.recipient_id = :user AND messages.status = :status\", user: id, status: 4)\n .includes(:permissions).order(\"permissions.created_at DESC\")\n end",
"def index\n @messages = Message.all\n end",
"def index\n @messages = Message.all\n end",
"def index\n @messages = Message.all\n end",
"def index\n @messages = Message.all\n end",
"def index\n @messages = Message.all\n end",
"def index\n @messages = Message.all\n end",
"def index\n @messages = Message.all\n end",
"def index\n @messages = Message.all\n end",
"def index\n @messages = Message.all\n end",
"def index\n @messages = Message.all\n end",
"def index\n @messages = Message.all\n end",
"def index\n @messages = Message.all\n end",
"def index\n @messages = Message.all\n end"
] | [
"0.7299288",
"0.72869104",
"0.7123604",
"0.712256",
"0.7096278",
"0.70948744",
"0.7084978",
"0.70153713",
"0.7003086",
"0.6950845",
"0.6942538",
"0.6929815",
"0.6920845",
"0.6918929",
"0.6874944",
"0.68563616",
"0.68385607",
"0.6810919",
"0.67887604",
"0.67701995",
"0.6712138",
"0.6709921",
"0.6703457",
"0.67023015",
"0.66934896",
"0.66855896",
"0.6657884",
"0.6635102",
"0.66218513",
"0.66120714",
"0.6605945",
"0.65939003",
"0.6591217",
"0.65814966",
"0.65544605",
"0.65301716",
"0.65301716",
"0.6515688",
"0.6510931",
"0.6508331",
"0.64990807",
"0.64942306",
"0.6477114",
"0.6461063",
"0.6456603",
"0.6454754",
"0.64490163",
"0.64444363",
"0.6440958",
"0.64156705",
"0.6404907",
"0.6402987",
"0.6374277",
"0.63737804",
"0.6370679",
"0.6368889",
"0.6362461",
"0.6361037",
"0.6358958",
"0.63523036",
"0.6347417",
"0.6340007",
"0.6336762",
"0.6335358",
"0.6332808",
"0.6330565",
"0.63296247",
"0.6320908",
"0.6311267",
"0.6292791",
"0.6291615",
"0.6290348",
"0.6282876",
"0.6269994",
"0.62587714",
"0.6247887",
"0.624161",
"0.6241056",
"0.6234929",
"0.62347484",
"0.6232433",
"0.6230085",
"0.62294257",
"0.62159324",
"0.6213481",
"0.6212106",
"0.6210777",
"0.6210063",
"0.6210063",
"0.6210063",
"0.6210063",
"0.6210063",
"0.6210063",
"0.6210063",
"0.6210063",
"0.6210063",
"0.6210063",
"0.6210063",
"0.6210063",
"0.6210063"
] | 0.7117326 | 4 |
GET /messages/conversation/:user_id list messages you have had with another user Needs to mark all messages as read | def conversation
@messages = Message.get_conversation(current_user, params[:user_id])
render json: @messages, each_serializer: MessageConversationSerializer
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_messages\n @useConversations = Message.where(\"user_id = (?)\", current_user.id).pluck(:conversation_id)\n if @useConversations.count > 0\n @useConversations = @useConversations.uniq # Unique\n @useConversations = @useConversations.map(&:inspect).join(', ')\n #@updatemsg = Message.where(\"user_id != (?) and conversation_id IN (?)\", current_user.id, @useConversations).update_all(:mark_as_read => true)\n @updatemsg = Message.where(\"user_id != #{current_user.id} and conversation_id in (#{@useConversations})\").update_all(:mark_as_read => true)\n session[:mark_messages] = 0 # Mark as read messages\n end\n end",
"def conversation\n @user = User.find(params[:id])\n @messages = Message.find(:all, :conditions => [\"((messages.user_id = #{current_user.id} and messages.receiver_id = #{params[:id]}) and messages.user_status != 'deleted') or ((messages.receiver_id = #{current_user.id} and messages.user_id = #{params[:id]}) and messages.receiver_status != 'deleted')\"], :order => \"created_at Desc\")\n for message in @messages\n if message.receiver_id == current_user.id\n message.update_attribute(:receiver_status, \"read\") if message.receiver_status == \"unread\"\n end\n end\n respond_to do |format|\n format.xml { render :xml => @messages }\n format.json { render :json => @messages }\n end\n end",
"def read_messages!(user)\n if has_unread_messages?(user)\n user.reset_unread_chats_count\n self.chat_participations.where(user_id: user.id).first.try(:read_messages!)\n end\n end",
"def index\n @messages = @conversation.messages\n @messages.where(\"user_id != ? AND read = ?\", current_user.id, false).update_all(read: true)\n if @conversation.sender == current_user\n @msg_not = @conversation.recipient\n else\n @msg_not = @conversation.sender\n end\n if current_user != @conversation.sender \n if current_user != @conversation.recipient\n redirect_to conversations_path\n end\n end\n @message = @conversation.messages.new\n end",
"def show\n @user = User.find(params[:user_id])\n @message = @user.messages.find(params[:id])\n @message.update_attribute(:read, true)\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: user_messages_path(@user) }\n end\n end",
"def index\n @messages = @conversation.messages\n @message = Message.new(user_id:current_user.id)\n @conversation.messages_for(current_user).unread.update_all(read: true)\n end",
"def index\n\n @users_with_conversation = []\n @messages = Message.where(receiver_id: params[:user_id]).reverse_order\n @new_messages = @messages.where(unread: true)\n @messages.each do |message|\n unless @users_with_conversation.include?(message.sender)\n @users_with_conversation.push(message.sender)\n end\n end\n @messages = Message.all\n end",
"def read_for!(user)\n received_message.read! if received_message\n replies.map { |r|\n r.received_message if r.recipient == user\n }.compact.each(&:read!)\n end",
"def unread_by(user)\n self.includes(:chat_participations, :messages).where([\n \"(chat_participations.read_at < messages.created_at OR chat_participations.read_at IS NULL)\\\n AND chat_participations.user_id = :user_id AND messages.user_id <> :user_id\",\n {user_id: user.id}]).order(\"messages.created_at DESC\")\n end",
"def show\n @conversation = current_user.mailbox.conversations.find(params[:id])\n @conversation.mark_as_read(current_user)\n\n respond_with(@conversation)\n end",
"def unread_messages user_id\n messages.unread(user_id)\n end",
"def conversation\n current_user_id = current_user.id\n other_user_id = params[:id]\n @messages = Message.get_conversation(current_user_id, other_user_id)\n render json: @messages\n end",
"def read\n @admin_message = Admin::Message.find(params[:id])\n\n # Mark either the conversation or the message itself as read by the user\n if @admin_message.recipients_can_reply? && current_user\n conversations = current_user.admin_conversations.find_all_by_admin_message_id(@admin_message.id)\n conversations.present? && conversations.each{|conversation| conversation.read_by!(current_user)}\n else\n @admin_message.read_by!(current_user)\n end\n\n render :nothing => true\n end",
"def mark_read_messages(conversation)\n time = Time.current\n conversation = Conversation.find(conversation) if conversation.is_a?(Integer)\n conversation_members.where(conversation_id: conversation).update_all(last_seen: time)\n Rails.cache.delete(conversation.get_unread_cache_key_for(id))\n Rails.cache.delete(\"user-unread_messages_count-#{id}\")\n PubSub::Publisher.new.publish_for(conversation.user_participants.where.not(id: id), 'read_messages', {id: conversation.id, seen_at: time.to_i, user_id: id}, {foreground: true})\n end",
"def get_messages\n \tuser = User.find(params[:user_id]);\n \tif user\n \t\tmessages = Message.where(message_type: user.user_type)\n \t\tconversation = Conversation.where(request_id: params[:request_id])\n texts = []\n conversation.each{ |msg| texts.push(Message.find_by(id: msg.message_id) ? Message.find(msg.message_id) : {})}\n \t\trender json: {messages: messages, conversation: conversation, texts: texts}\n \telse\n\t\trender json: {error: 'User not found.'}\n \tend\n end",
"def read user_id\n messages.unread(user_id).each do |m|\n m.read = true\n m.save\n end\n end",
"def set_to_read\n\t\t#We find all the messages in the current conversation\n\t\t@conversation_messages = PersonalMessage.where(conversation_id: @conversation).all\n\t\t@conversation_messages.each do |message|\n\t\t\t# We mark as read the messages recieved by the current user \n\t\t\tif message.user_id != current_user.id\n\t\t\t\tmessage.update(read: true) unless message.read != false\n\t\t\tend\n\t\tend\n\tend",
"def list_of_commmessages_for_user(user_id,opts={})\n query_param_keys = [\n :user_id,\n :start_time,\n :end_time\n ]\n\n form_param_keys = [\n \n ]\n\n # verify existence of params\n raise \"user_id is required\" if user_id.nil?\n # set default values and merge with input\n options = underscored_merge_opts(opts,\n :user_id => user_id\n )\n\n # resource path\n path = path_replace(\"/v1/comm_messages\",\n )\n headers = nil\n form_params = select_params(options, form_param_keys)\n query_params = select_params(options, query_param_keys)\n if opts[:next_page]\n pagination_params = page_params_load(:get, path)\n query_params.merge! pagination_params if pagination_params\n end\n response = mixed_request(:get, path, query_params, form_params, headers)\n page_params_store(:get, path)\n response.map {|response|CommMessage.new(response)}\n end",
"def unread_messages(user)\n Rails.cache.fetch(\"#{cache_key_with_version}/unread_messages/#{user.id}\") do\n Message.unread_by(user).where(chat_room: self).where.not(user: user).to_a\n end\n end",
"def index\n @messages = @conversation.messages.includes(:user).order('created_at ASC').page(1)\n\n conversation_user = ConversationUser.find_by(conversation: @conversation, user: current_user)\n @message = conversation_user.messages.build\n\n authorize @message\n @other = @conversation.users.find_by('users.id != ?', current_user.id)\n end",
"def index\n\t\t@messages = Message.where(:to_user => current_user.id)\n\t\trespond_with(@messages) \n\tend",
"def mark_as_read\n @client.post('/api/mod/conversations/read', conversationIds: [get_attribute(:id)])\n end",
"def messages_from user\n backend.messages_page(user).messages\n end",
"def sent_messages\n @user = User.find(params[:id])\n @messages = Message.find(:all, :conditions => [\"(messages.user_id = #{current_user.id} and messages.receiver_id = #{@user.id}) and messages.user_status != 'deleted'\"], :order => \"created_at Desc\")\n respond_to do |format|\n format.xml { render :xml => @messages }\n format.json { render :json => @messages }\n end\n end",
"def index\n #@messages = Message.all\n #@messages = current_owner.messages\n @users = current_owner.conversation_users\n end",
"def getAllMessagesForUser(index, group_id, user_id)\n query = {\n \"size\" => 100000,\n \"query\" => {\n \"bool\" => {\n \"must\" => [\n { \n \"term\" => { \n \"user_id\" => \"#{user_id}\" \n }\n },\n {\n \"term\" => { \n \"group_id\" => \"#{group_id}\" \n }\n }\n ]\n }\n }\n }\n self.class.get(\"#{index}/message/_search\", :body => query.to_json)\n end",
"def index\n @messages = Message.all\n @unread = Recipient.where(:user_id => current_user.id,:status => false).map {|r| r.message}.reverse\n @read = Recipient.where(:user_id => current_user.id,:status => true).map {|r| r.message}.reverse\n end",
"def index\n user = User.includes(message_threads: [:messages])\n .find(params[:user_id])\n\n if user.role === \"patient\"\n unread_messages = user.messages.where(read: false)\n render json: {\n unread_messages_count: unread_messages.count,\n unread_messages: unread_messages\n }\n elsif user.role === \"care_manager\"\n threads = user.patients.as_json(include: :messages)\n render json: threads\n end\n end",
"def index\n @messages = Message.where(user_id: current_user.id)\n end",
"def show\n @conversation = current_user.conversations.find_by_id params.require(:id)\n @messages = @conversation.messages.order('created_at')\n\n uc = @conversation.user_conversations.find_by_user_id(current_user)\n uc.read = true\n uc.save\n\n friend = @conversation.users.collect { |u| u if u != current_user }.compact.first\n @message = Message.new user: friend\n @to = friend.number\n @name = friend.name\n\n respond_to do |format|\n format.html\n format.json { render :json => @messages.to_json(include: :user, :methods => [:file_url]) }\n end\n end",
"def messagebox\n\t\t# retrieve all messages and unread messages of current user\n @user = current_user\n @messages = Message.paginate_by_receiver_id @user.id, :page => params[:page], :order => 'created_at DESC', :per_page => 10\n @unread_messages = Message.find(:all, :conditions => {:receiver_id => current_user.id, :unread => true})\n end",
"def messages\n Message\n .where(\"messages.user_id = :user OR messages.recipient_id = :user\", user: id)\n .where.not(\"messages.recipient_id = :user AND messages.status = :status\", user: id, status: 0)\n .where.not(\"messages.recipient_id = :user AND messages.status = :status\", user: id, status: 4)\n .includes(:permissions).order(\"permissions.created_at DESC\")\n end",
"def unread_messages\n @user_wise_unread_messages = current_user.user_messages\n .where(is_read: false)\n .joins(:message)\n .group('messages.user_id').count\n end",
"def index\n\n @messages = Message.none\n\n if user_signed_in? then\n my_mutes = Mute.where(user_id: current_user.id).select(:target_id)\n receive_messages = Message.where(user_id: current_user.id)\n\n messages = Message.none.or(receive_messages).where.not(sender_id: my_mutes)\n @messages = Message.none.or(messages).where(\"create_datetime > ?\", Constants::MESSAGE_RETENTION_PERIOD.ago).order(create_datetime: :desc)\n\n @messages.update(read_flag: true)\n\n send_messages = Message.where(sender_id: current_user.id)\n @send_messages = Message.none.or(send_messages).where(\"create_datetime > ?\", Constants::MESSAGE_RETENTION_PERIOD.ago).order(create_datetime: :desc)\n\n else\n respond_to do |format|\n format.html { redirect_to new_user_session_path, alert: 'ログインしてください。' }\n format.json { head :no_content }\n end\n end\n\n end",
"def index\n # check if this current_user are involved in conversation\n if current_user == @conversation.sender || current_user == @conversation.recipient\n @other = current_user == @conversation.sender ? @conversation.recipient : @conversation.sender\n\n # 送信先のユーザー名を取得\n if current_user == @conversation.sender\n @recipient_user_name = @conversation.recipient.name\n else\n @recipient_user_name = @conversation.sender.name\n end\n\n @messages = @conversation.messages.order(\"created_at DESC\")\n else\n redirect_to conversations_path, alert: \"他人のメッセージにアクセスできません\"\n end\n\n end",
"def receivedMessagesToUser\n render json: Message.where(receiver_id: params[:id], created_at: (Time.now - 30.day)..Time.now).limit(100)\n end",
"def show\n @conversation.mark_messages_as_read\n end",
"def index\n @user_conversations = UserConversation.all\n end",
"def show\n @message = Message.find(params[:id])\n if params[:user_id] == @message.user_id\n @message.update_attribute(:user_read, true)\n elsif params[:user_id] == @message.recipient_id\n @message.update_attribute(:recipient_read, true)\n end\n end",
"def index\n @conversations = \n if params[:read].present? && params[:read] == \"true\"\n current_user.mailbox.inbox(:read => true)\n elsif params[:read].present? && params[:read] == \"false\"\n current_user.mailbox.inbox(:unread => true)\n else \n current_user.mailbox.inbox\n end.page(params[:page])\n \n respond_with(@conversations)\n end",
"def show\n puts \"############ messages show ###############\"\n @message = current_user.messages.find_by_id(params[:id])\n if [email protected]?\n @conversations = @message.conversations.includes(:sender => [:profile, :profile_photo])\n\n @message_status = @message.message_statuses.find_by_user_id(current_user)\n latest_conversation = @message_status.start_at\n if @message_status.start_at == nil\n @conversations = @message.conversations.includes(:sender => [:profile, :profile_photo])\n else\n @conversations = @message.conversations.where(\"id > ?\", latest_conversation).includes(:sender => [:profile, :profile_photo])\n end\n if !@message_status.nil?\n if @message_status.status == MessageStatus::UNREAD\n @message_status.status = MessageStatus::READ\n @message_status.save!\n end\n else\n flash[:error] = \"Message is not found\"\n return redirect_to messages_path\n end\n @reply_conversation = Conversation.new\n @reply_conversation.content = nil\n else\n flash[:error] = \"Message is not found\"\n return redirect_to messages_path\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @message }\n end\n end",
"def show_messages\n @messages = get_user.messages.search(params[:page])\n end",
"def index\n #find the current user object\n @user = User.find(session[:user_id])\n #get the id of current user\n user_id = User.find(session[:user_id]).id\n #get all conversations of current user\n @started_conversations = @user.started_conversations\n @joined_conversations = @user.joined_conversations\n end",
"def index\n @messages = current_user.received_messages\n @messages = @messages.order(created_at: :desc)\n @messages = @messages.paginate(page: params[:page], per_page:5)\n @messages = @messages.to_a\n end",
"def index\n @page_title = \"Messages\"\n @message_threads = MessageThread.related_to(current_user)\n @message_thread = @message_threads.first\n if @message_thread\n @message_thread.mark_read!(current_user)\n end\n end",
"def index\n @conversations = current_user.conversations\n end",
"def inbox\n cur_emp = get_logged_employee\n @messages = Message.where(\"sent_to = ?\", cur_emp).where(:is_deleted => nil )\n render \"resumes/message_show\"\n end",
"def read_message(message_id)\n message =\n if self.is_client?\n self.messages.find(message_id)\n elsif self.is_employee?\n self.client.messages.find(message_id)\n end\n if self.is_client?\n message.update_columns(is_read: true)\n else\n u_ids = message.message_status.user_ids.push(self.id)\n logger.info u_ids\n message.message_status.update_columns(user_ids: u_ids)\n end\n end",
"def read\n conversation = Conversation.find(params[:id])\n if conversation\n if conversation.buyer_id == @current_user.id || conversation.seller_id == @current_user.id\n\n\t\tif(conversation.buyer_id == @current_user.id)\n\t\t conversation.buyer_marker = conversation.messages.count \n\t\telse\n\t\t conversation.seller_marker = conversation.messages.count\n\t\tend\n\t\tconversation.save()\n \n params[:messages_per_page] ||= 10\n params[:page] ||= 1\n\n messages_per_page = params[:messages_per_page].to_i\n page = params[:page].to_i\n\n offset = (page - 1) * messages_per_page\n \n message_ids = conversation.message_ids\n \n messages = Message.where(id: message_ids)\n .limit(params[:messages_per_page])\n .offset(offset)\n .order(created_at: :desc)\n .all\n \n messages_for_json = []\n messages.reverse_each do |message|\n messages_for_json << {\n user_id: message.user_id,\n message: message.message,\n created_at: message.created_at.strftime('on %-m/%-d/%Y at %-l:%M%P')\n }\n end\n payload = {\n id: conversation.id,\n seller: {\n user_id: conversation.seller.id,\n username: conversation.seller.username,\n first_name: conversation.seller.first_name,\n last_name: conversation.seller.last_name\n },\n buyer: {\n user_id: conversation.buyer.id,\n username: conversation.buyer.username,\n first_name: conversation.buyer.first_name,\n last_name: conversation.buyer.last_name\n },\n is_seller: conversation.seller_id == @current_user.id,\n product: {\n product_id: conversation.offer.product.id,\n product_name: conversation.offer.product.product_name,\n price: conversation.offer.product.price,\n product_type: conversation.offer.product.product_type\n },\n offer: {\n id: conversation.offer.id,\n offer_id: conversation.offer.id,\n price: conversation.offer.price\n },\n messages: messages_for_json\n }\n render status: 200, json: payload\n else\n render status: 472, json: {error: true}\n end\n else\n render status: 404, json: {error: true}\n end\n end",
"def index\n @diary_entries = @current_user.messages.where(message_type: \"diary_entry\")\n \n end",
"def show\n @other_user = (@chat.user == current_user) ? @chat.reciever : @chat.user\n\n Chat.where(reciever_id: current_user.id, user_id: @other_user.id, status: 'unread').each do |chat|\n chat.update_attribute(:status, 'read')\n end\n\n @chats = Chat.where(\"(reciever_id = ? AND user_id = ?) OR (reciever_id = ? AND user_id = ?)\", @other_user.id, current_user.id, current_user.id, @other_user.id).order('created_at DESC').limit(50).reverse\n @new_chat = Chat.new\n end",
"def get_unread(user)\n list = []\n if unread?(user)\n list.push(self)\n end\n public_replies(user).unread_by(user).each do |reply|\n list.push(reply)\n end\n list\n end",
"def show\n @page_title = \"Messages\"\n @message_thread = MessageThread.find(params[:id])\n @message_thread.mark_read!(current_user)\n @message_threads = MessageThread.related_to(current_user)\n\n respond_to do |format|\n format.html { render :index }\n\n format.json do\n if @message_thread.related_to?(current_user)\n render json: thread_data(@message_thread)\n else\n render json: { error: \"Access denied.\" }\n end\n end\n end\n end",
"def show\n\n\t\t@conversation = Conversation.find(params[:id])\n\n\t\tredirect_to \"/messages\" and return if [email protected]?(current_teacher.id.to_s)\n\n\t\t@other = Teacher.find(@conversation.get_other(current_teacher.id.to_s))\n\n\t\t@unread = @conversation.unread_messages(current_teacher.id.to_s)\n\n\t\t@title = \"#{@other.full_name} - Messages\"\n\n\t\[email protected][current_teacher.id.to_s] = 0\n\n\t\[email protected]\n\n\t\t@messages = @conversation.get_messages\n\n\t\tsrc = Mongo.log(current_teacher.id.to_s,\n\t\t\t\t\t\t__method__.to_s,\n\t\t\t\t\t\tparams[:controller].to_s,\n\t\t\t\t\t\[email protected]_s,\n\t\t\t\t\t\tparams)\n\n\t\[email protected] do |message|\n\n\t\t\tmessage.add_read(current_teacher) if !message.read_by?(current_teacher.id.to_s)\n\n\t\t\tMongo.log(\tcurrent_teacher.id.to_s,\n\t\t\t\t\t__method__.to_s,\n\t\t\t\t\tparams[:controller].to_s,\n\t\t\t\t\tmessage.id.to_s,\n\t\t\t\t\tparams,\n\t\t\t\t\t{:src => src})\n\n\t\tend\n\n\tend",
"def sent\n @messages = current_user.messages.order('created_at DESC').unarchived.paginate(:page => params[:page], :per_page => 10)\n end",
"def index\n @messages = Message.where(:to_user => current_user.id).order('id desc').paginate(:page => params[:page])\n @sent_messages = Message.where(:user_id => current_user.id).order('id desc').paginate(:page => params[:sent_page])\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @messages }\n end\n end",
"def sent_messages\n @user = current_user\n\t # retrieve all sent messages by the current user\n @sent_messages = @user.sent_messages.sort_by{|m| m.created_at}.reverse\n @unread_messages = Message.find(:all, :conditions => {:receiver_id => current_user.id, :unread => true})\n end",
"def index\n # @conversations = Conversation.all\n @conversations = current_user.conversations\n end",
"def index\n @user_messages = UserMessage.all\n end",
"def show\n @message = current_user.messages.find(params[:id])\n @message.mark_as_unread\n end",
"def read?(_user_id)\n conversation.conversation_members.where(user_id: _user_id).take.last_seen > created_at\n end",
"def get(user, show_all = false, &block)\n url, opt = url_for(user, 'timeline'), opt_for(user)\n\n if data = @cache.get(url, opt)\n JSON.parse(data).reverse.each do |row|\n cached = @store.has_message?(row['id'])\n\n if show_all || !cached\n # cache message\n @store.add_message(row['id'], row)\n\n # send to parent\n block.call(\n row['id'], \n Time.parse(row['created_at']), \n row['user']['screen_name'], \n row['text']\n )\n end\n end\n end\n end",
"def messages\n\t\t@musician = User.find_by_id(params[:id])\n\t\t@messages = @musician.messages\n\tend",
"def index\n @conversations = Conversation.involving(current_user)\n conversations_new_message = Array.new\n unread = 0\n\n @conversations.each do |conversation|\n conversation.last_message = ActionView::Base.full_sanitizer.sanitize(conversation.messages.order('created_at').last.body[0..75])\n conversation.last_message_date = conversation.messages.order('created_at').last.created_at\n conversation.count_unread = conversation.messages.unread(conversation.id, current_user).size\n\n size = conversation.messages.unread(conversation.id, current_user).size\n if size > 0\n conversations_new_message.push(conversation)\n unread = unread + size\n end\n\n @subs=current_user.subscribtions\n end\n\n conversations_new_message.each do |conversation|\n set_messages_receive(conversation, false)\n end\n\n if unread > 0\n if unread == 1\n flash[:info] = t('welcome.you_have') + unread.to_s + t('welcome.unread_message')\n else\n flash[:info] = t('welcome.you_have') + unread.to_s + t('welcome.unread_messages')\n end\n end\n\n @invites = Invite.by_recipient_id(current_user.id).order('id');\n\n\n end",
"def read\n @message = Message.find(params[:id])\n @message.read(current_user)\n respond_to do |format|\n format.html # read.html.erb\n format.json { render json: @message }\n end\n end",
"def index\n raise UserBlocked if UserBlock.between_users(current_user.id, params[:to_user_id_eq]).any?\n raise NoHails if Hail.between_users(current_user.id, params[:to_user_id_eq]).empty?\n @messages = Message.between_users(current_user.id, params[:to_user_id_eq]).order('created_at ASC')\n current_user.update_attribute(:last_chatted_user_id, params[:to_user_id_eq]) if params[:to_user_id_eq] && params[:poll]\n Message.where(user_id: params[:to_user_id_eq], to_user_id: current_user.id).update_all(read: true)\n rescue UserBlocked\n current_user.update_attribute(:last_chatted_user_id, nil) if current_user.last_chatted_user_id == params[:to_user_id_eq]\n render json: { error: 'blocked' }, status: :unprocessable_entity\n rescue NoHails\n current_user.update_attribute(:last_chatted_user_id, nil) if current_user.last_chatted_user_id == params[:to_user_id_eq]\n render json: { error: 'no_hails' }, status: :unprocessable_entity\n end",
"def index\n \n # puts \" begin \"\n # puts User.findUser(params[:user_email]).inspect #Message.where(reciever: params[:user_id])\n # puts \" end \"\n \n @messages = Message.where(reciever: User.findUser(params[:user_email]).id)\n end",
"def messages\n user_ids = users.pluck(:id)\n rooms_user_ids = RoomsUser.where(room_id: self.id, user_id: user_ids).pluck(:id)\n RoomMessage.where(rooms_user_id: rooms_user_ids).order(created_at: :asc)\n end",
"def inbox\n @messages = current_user.received_messages\n end",
"def index_user\n\t\t@user_convos = Conversation.involving_user(params[:user_id])\n\t\trender_list_of_convos(@user_convos)\n\tend",
"def index\n if !user_signed_in?\n flash.alert = \"You must be logged in to use Messaging\"\n redirect_to root_path\n return\n elsif current_user.rolable.class.name != \"Charity\" && current_user.rolable.class.name != \"Business\"\n flash.alert = \"Messaging is available to Charities and Businesses only\"\n redirect_to root_path\n return\n end\n\n all_messages = (Message.where(\"user_received_id = \" + current_user.id.to_s + \" OR user_sent_id = \" + current_user.id.to_s)).order(:id)\n \n @friends = []\n \n # get people online\n @friends << User.where.not(rolable_type: \"Donor\").where(\"last_ping_time >= ? AND id != ?\", Time.current - 1.minutes, current_user.id) \n\n # get existing conversations\n all_messages.each do |x|\n if(x.user_received_id == current_user.id)\n @friends << User.find(x.user_sent_id) unless @friends.include?(User.find(x.user_sent_id))\n else\n @friends << User.find(x.user_received_id) unless @friends.include?(User.find(x.user_sent_id))\n end\n end\n\n # get people up to 10 total people\n if(@friends.count < 9) \n @friends << User.where.not(rolable_type: [\"Donor\", current_user.rolable_type]).where(\"last_ping_time <= ? or last_ping_time is null\", Time.current - 1.minutes).limit(10 - @friends.count)\n end\n\n @friends.flatten!\n @friends.uniq!\n @search_users = searchUsers()\n @last_message = all_messages.last()\n end",
"def unread\n home\n #@dirmesg = TDirmessage.select(\"m_users.user_name,t_dirmessages.dir_message,t_dirmessages.created_at\")\n #.joins(\"join m_users on m_users.user_id=t_dirmessages.sender_user_id\")\n #.where(\"dirworkspace_id=? and ((receiver_user_id=? and sender_user_id=?)||(t_dirmessages.receiver_user_id=? and t_dirmessages.sender_user_id=?))\", session[:workspace_id], session[:user_id], params[:clickuserid], params[:clickuserid], session[:user_id]).order(\"t_dirmessages.created_at ASC\")\n @clickchannel = MChannel.find_by(\"channel_id=?\", session[:clickchannel_id])\n\n @m_clickchuser = MUser.joins(\"join m_channels on m_channels.user_id=m_users.user_id\")\n .where(\"m_channels.channel_name=? and m_channels.workspace_id=?\", session[:clickchannel_name], session[:workspace_id])\n\n @dirmsg = TDirmessage.select(\"m_users.user_name,t_dirmessages.dir_message,t_dirmessages.created_at\")\n .joins(\"join m_users on m_users.user_id=t_dirmessages.sender_user_id\")\n .where(\"dirworkspace_id=? and receiver_user_id=? and is_read=true\", session[:workspace_id], session[:user_id])\n @chmesg = TChannelMessage.select(\"m_channels.channel_name ,m_users.user_name ,t_channel_messages.chmessage,t_channel_messages.created_at\")\n .joins(\"join m_users on t_channel_messages.chsender_id=m_users.user_id join t_chunread_messages on t_chunread_messages.chmsg_id=t_channel_messages.chmsg_id join m_channels on m_channels.channel_id=t_channel_messages.channel_id\")\n .where(\"t_chunread_messages.is_read =true and t_chunread_messages.chuser_id=? and m_channels.user_id=? and m_channels.workspace_id=? \", session[:user_id], session[:user_id], session[:workspace_id])\n end",
"def show\n\t\t@conversation = current_user.mailbox.conversations.find(params[:id]).receipts_for(current_user)\n\tend",
"def inbox\n @messages = current_user.received_messages\n respond_with @messages\n end",
"def index\n\n if params[:user_id]\n @messages = Message.where(:user_id => params[:user_id].to_i)\n else\n @messages = Message.all\n end\n if params[:page] and params[:per_page]\n @messages = @messages.paginate(:per_page=>params[:per_page].to_i,:page=>params[:page].to_i).order(\"id desc\")\n @page = params[:page]\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :messages }\n end\n end",
"def show\n @users = User.all.where(\"followed_id != ?\", current_user.id)\n @users = User.all.where(\"id != ?\", current_user.id)\n @favorite = current_user.favorites.find_by(user_id: @user.id)\n @favorites_users = current_user.favorite_users\n @admission = @user.admissions\n @publications = Publication.all\n @conversations = Conversation.all.where(\"id != ?\", current_user.id)\n @messages = Message.all.where(\"id != ?\", current_user.id)\n if @messages.length > 5\n @over_five = true\n @messages = @messages[-5..-1]\n end\n\n if params[:m]\n @over_ten = false\n @messages = Message.all\n end\n\n if @messages.last\n if @messages.last.user_id != current_user.id\n @messages.last.read = true\n end\n end\n \n end",
"def index\n @direct_messages = DirectMessage.get_direct_messages(current_user)\n \n @recipients = User.reachable_users(current_user)\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @direct_messages }\n end \n end",
"def check_for_messages\n @message_unviewed = Message.all(:recipient_id => current_user.id, :viewed => false, :opportunity => Opportunity.all(:active => true))\n if @message_unviewed != []\n flash.now[:warning] = 'You have unread messages'\n end\n end",
"def conversation\n Conversation\n .where(\"creator_id = ? or member_id = ?\", user_id, user_id)\n .order(\"latest_message_id DESC\").first\n end",
"def inbox\n @direct_messages = current_user.received_messages.where(_type: 'DirectMessage')\n respond_with @direct_messages\n end",
"def index\n @messages = current_user.is_support? ? Message.where(message_id: nil).order(\"support_call desc, updated_at desc\").includes(:replies).all : Message.where(user_id: current_user.id, message_id: nil).order(\"user_call desc, updated_at desc\").includes(:replies).all\n end",
"def get_conversations\n n = Notification.where(user_id:current_user)\n conversation_ids = Array.new\n n.each do |v|\n conversation_ids << v.conversation_id\n end\n conversations = Conversation.where(id:conversation_ids)\n\n end",
"def index\n\t\t@conversations = current_user.mailbox.conversations\n\tend",
"def show_message\n\t\t# find message with specified ID and set its 'unread' attribute to FALSE\n \t@message = Message.find(params[:id])\n @message.update_attribute(:unread,false)\n @unread_messages = Message.find(:all, :conditions => {:receiver_id => current_user.id, :unread => true})\n\n\t\t# check if reciever is current user, security \n if current_user.id == @message.receiver.id\n render :action => 'show_message'\n else\n gflash :error => \"Unknown request.\"\n redirect_back_or_default('/messagebox')\n end\n end",
"def index\n @messages = current_user.messages\n respond_with(@messages)\n end",
"def index\n @messages = @conversation.messages.order(created_at: :desc)\n @messages.unread(@conversation.partner(current_user)).update_all(read: true) # 既読処理\n @new_message = Message.new\n end",
"def show\n @messages = @conversation.messages.sort_by(&:updated_at)\n @messages.each do |m|\n (m[:viewed] = true) && m.save if m.viewed == false && @current_user.id != m.author\n end\n end",
"def index\n @messages = current_user.received_messages\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end",
"def fetch\n messages = paginate ConversationMessage.where(conversation_id: params[:conversation_id])\n .order('created_at DESC')\n render json: messages.to_json(:include => :user)\n end",
"def read\n @tour.join_requests\n .accepted\n .where(user: current_user)\n .update_all(last_message_read: DateTime.now)\n head :no_content\n end",
"def new_message_check\n if(!current_user.nil?)\n ids = Message.where(user_received_id: current_user.id, read: false).pluck(:user_sent_id).uniq\n if ids.count > 0\n ids = Message.where(user_received_id: current_user.id, read: false).pluck(:user_sent_id).uniq\n render text: '{\"unread\":\"true\", \"ids\":[' + ids.join(',') + ']}'\n else\n render text: '{\"unread\":\"false\"}'\n end\n else \n render text: '{\"unread\":\"false\"}'\n end\n end",
"def conversations\n Conversation.where(\"sender_id = ? OR recipient_id = ?\", id,id)\n end",
"def index\n # @messages = Message.all\n # @messages = Message.where(user_id: session[:user_id])\n\n @messages = Message.where(recipient: current_user[:email])\n @sent_messages = Message.where(user_id: session[:user_id])\n @username = current_user[:email]\n end",
"def inbox\n user_sent = Message.where(user_id: current_user, group_id: nil, show_user: true)\n user_received = Message.where(recipient_id: current_user, show_recipient: true)\n @messages = (user_sent + user_received).sort{|a,b| a.created_at <=> b.created_at }\n end",
"def index\n @messages = current_user.messages.limit(10).order('id desc')\n end",
"def index\n @users = current_user.sent_messages.distinct.map(&:receiver)\n @users += current_user.received_messages.distinct.map(&:sender)\n @users = @users.uniq\n end",
"def index\n\n if current_user\n #id = current_user.id\n #@messages = Message.where([\"sender = ? or receiver = ?\", id, id])\n #@messages = current_user.messages\n @contacts = current_user.contacts\n\n end\n\n #@messages = Message.all\n end",
"def index\n @messages = current_user.received_messages\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @messages }\n end\n end",
"def index\n @chats = Chat.where(\"reciever_id = ? OR user_id = ?\", current_user.id, current_user.id).order('created_at DESC')\n end",
"def show_sent_message\n\t\t# find message with specified ID \n @message = Message.find(params[:id])\n @unread_messages = Message.find(:all, :conditions => {:receiver_id => current_user.id, :unread => true})\n \n\t\t# check if reciever is current user, security\n\t\tif current_user.id == @message.sender.id\n render :action => 'show_sent_message'\n else\n gflash :error => \"Unknown request.\"\n redirect_back_or_default('/sent_messages')\n end\n end"
] | [
"0.7628869",
"0.75682914",
"0.7340077",
"0.72378355",
"0.717201",
"0.7155813",
"0.71218157",
"0.7099798",
"0.7064991",
"0.703641",
"0.6975814",
"0.6950426",
"0.69329643",
"0.69103104",
"0.689679",
"0.6885737",
"0.6867392",
"0.68490905",
"0.6760762",
"0.67348397",
"0.66528404",
"0.6649139",
"0.66293174",
"0.662686",
"0.6581802",
"0.65747577",
"0.6553811",
"0.6547951",
"0.65442884",
"0.6527283",
"0.6514621",
"0.65063757",
"0.6490906",
"0.6490241",
"0.6476676",
"0.6461288",
"0.64599156",
"0.6452726",
"0.64513326",
"0.6432546",
"0.6414045",
"0.6408907",
"0.64033526",
"0.63772625",
"0.63448125",
"0.6329459",
"0.6328808",
"0.6306867",
"0.6299475",
"0.62703675",
"0.62696904",
"0.6258037",
"0.6254058",
"0.6252701",
"0.625232",
"0.6250987",
"0.62492937",
"0.6248242",
"0.62445384",
"0.62406945",
"0.6240204",
"0.6206168",
"0.6198306",
"0.6196633",
"0.61854756",
"0.6179471",
"0.6175301",
"0.6173822",
"0.617325",
"0.6170942",
"0.6170141",
"0.6164347",
"0.61636746",
"0.6145815",
"0.61338115",
"0.6133729",
"0.6122511",
"0.6120092",
"0.61160797",
"0.61085933",
"0.6101588",
"0.60960746",
"0.6093279",
"0.6083268",
"0.6079688",
"0.6077666",
"0.6074182",
"0.6072622",
"0.6062184",
"0.60506076",
"0.60503376",
"0.6049146",
"0.60477775",
"0.60433424",
"0.6041274",
"0.60402673",
"0.6036017",
"0.6029871",
"0.602209",
"0.6013778"
] | 0.68029016 | 18 |
Never trust parameters from the scary internet, only allow the white list through. | def post_message_params
params.require(:message).permit(:body, :recipient_user_id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def allow_params_authentication!; end",
"def allowed_params\n ALLOWED_PARAMS\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def param_whitelist\n [:role, :title]\n end",
"def expected_permitted_parameter_names; end",
"def safe_params\n params.except(:host, :port, :protocol).permit!\n end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def valid_params_request?; end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def user_params\n params.permit(:name, :phoneNumber, :address, :postalCode, :local, :link, :counter, :latitude, :longitude) \n end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def whitelist_url_params\n params.require(:whitelist_url).permit(:domain)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def permitted_params\n []\n end",
"def trim_whitelisted(params, whitelist)\n # remove any parameters that are not whitelisted\n params.each do |key, value|\n # if white listed\n if whitelist.include? key\n # strip the parameters of any extra spaces, save as string\n params[key] = value.to_s.strip\n else\n # delete any unauthorized parameters\n params.delete key\n end\n end\n params\n end",
"def safe_params\n params.permit(:id, :name, :origin, :emails => []); #emails is an array\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def user_params\n ActionController::Parameters.permit_all_parameters = true\n params.require(:user) #.permit(:name, :surname, :phone, :password, :email, :time_zone)\n end",
"def safe_params\n params.require(:user).permit(:name)\n end",
"def strong_params\n params.require(:metric_change).permit(param_whitelist)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def check_params; true; end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def quote_params\n params.permit!\n end",
"def valid_params?; end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def user_params\n\t\tparams.permit(:nickname, :avatar, :description, :password, :gender, :birthday, :email, :phone, :qq_id, :wechat_id)\n\tend",
"def filtered_parameters; end",
"def user_params\n params.permit(\n \t:id,\n \t:email, \n \t:first_name, \n \t:last_name, \n \t:password, \n \t:confirm_token, \n \t:phone_number,\n \t:facebook_link,\n \t:car_model,\n \t:license_plate)\n end",
"def filtering_params\n params.permit(:email, :name)\n end",
"def check_params\n true\n end",
"def wx_public_params\n params.require(:wx_public).permit(:nickname, :manager, :alias)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def listing_params\n\t\tparams.permit(:address, :transit_info, :rules, :other_info, :lat, :lng)\n\tend",
"def social_account_params\n\t\t\tparams.require(:social_account).permit!\n\t\tend",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def user_params\n params.require(:user).permit(:uri, :username, :password, :realname, :email, :publicvisible)\n end",
"def url_params\n params.require(:url).permit(:short_url, :original_url, :clicks, :ip_addresses)\n end",
"def model_params\n\t\tparams.require(:manager).permit(\n\t :user_name,\n :password,\n :email,\n \t\t\t)\n\tend",
"def article_params_whitelist\n params.require(:article).permit(:title, :description, category_ids: [])\n end",
"def college_whitelist_params\n params.require(:college_whitelist).permit(:status)\n end",
"def active_code_params\n params[:active_code].permit\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def filtering_params\n params.permit(:email)\n end",
"def ip_address_params\n\t\t\tparams.require(:ip_address).permit!\n end",
"def reserved_params\n params.require(:reserved).permit(:name, :email, :pax, :address, :KTP, :title)\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end",
"def post_params\n if current_user.admin? \n params.permit(:title, :body, :city, :country, :gps_location, :privacy, :visible, :latitude, :longitude, images: [], files: [])\n else \n params.permit(:title, :body, :city, :country, :gps_location, :privacy,:latitude, :longitude, images: [], files: [])\n end \n end",
"def list_params\n params.permit(:name)\n end",
"def filter_parameters; end",
"def filter_parameters; end",
"def vineyard_params\n params.permit(:vineyard_name, :email, :website_url, :phone, :address, :city, :region, :postcode, :country, :specialty, :description, :pet_friendly, :holiday, :tours, :events, :family_friendly, :cover_image, :image_one, :image_two, :image_three, :image_four, :user_id, :base64)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def user_params\n params.permit(:name, :username, :email, :password, :img_url, :bg_url, :coinbank)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def url_whitelist; end",
"def admin_social_network_params\n params.require(:social_network).permit!\n end",
"def filter_params\n params.require(:filters).permit(:letters)\n end",
"def valid_params(params)\n params.permit(:login, :first_name, :last_name, \n :password, :password_confirmation)\n end",
"def origin_params\n params.permit(:country, :state, :city, :postal_code, :address, :description)\n end",
"def sensitive_params=(params)\n @sensitive_params = params\n end",
"def permit_request_params\n params.permit(:address)\n end",
"def user_params\n # Ensure a user can't give themselves admin priveleges\n params.delete(:admin) if current_user.admin?\n params.require(:user).permit(:name, :email, :admin, :image)\n end",
"def secure_params\n params.require(:location).permit(:name)\n end",
"def strong_params\n params.require( :setting ).\n permit( :global_scan_limit, :per_user_scan_limit,\n :target_whitelist_patterns, :target_blacklist_patterns )\n end",
"def question_params\n params.require(:survey_question).permit(question_whitelist)\n end",
"def case_insensitive_params\n params.require(:case_insensitive).permit(:name)\n end",
"def empire_master_no_match_params\n params.require(:empire_master_no_match).permit(:uid, :last_name, :list, :search_date, :double, :source)\n end",
"def maintenance_request_params\n params[:maintenance_request].permit! #allow all parameters for now\n end",
"def unwanted_params\n params.require(:unwanted).permit(:title, :description, :image)\n end",
"def url_params\n params[:url].permit(:full)\n end",
"def backend_user_params\n params.permit!\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def speed_measurement_params\n\n #fuckit, to lazy to deal with permit crap right now\n ActionController::Parameters.permit_all_parameters = true\n\n params[:speed_measurement]\n end",
"def user_params\n params.permit(:name, :age, :username, :display_photo, :password)\n end",
"def get_params\r\n #params.require(:article).permit(:title, :permalink, :content, :source_site, :introtext, :type_id, :order_by, :searchable, :created_by, :edited_by, :published_by, :published_on, :user_id)\r\n params.require(:article).permit!\r\n\r\n end",
"def pub_params\n params.require(:pub).permit(:name, :description, :phone, :email, :hidden, :city_id, :address)\n end",
"def pass_params\n params[:pass].permit(:name, :price, :description, :colour, :events)\n end",
"def droptraining_params\n params.permit(:training_id,:user_id, :utf8, :authenticity_token, :commit)\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end"
] | [
"0.6980384",
"0.6782743",
"0.6746196",
"0.6742575",
"0.6736",
"0.6594004",
"0.65037984",
"0.6496699",
"0.64819324",
"0.64791185",
"0.6456292",
"0.64403296",
"0.63795286",
"0.6375975",
"0.6365291",
"0.63210756",
"0.6300542",
"0.6299717",
"0.62943304",
"0.6292561",
"0.6290683",
"0.6290449",
"0.6282986",
"0.6241265",
"0.62392694",
"0.62192893",
"0.621427",
"0.62099457",
"0.6195319",
"0.61785376",
"0.61747766",
"0.6172739",
"0.6162921",
"0.6152228",
"0.6152062",
"0.6148811",
"0.6122391",
"0.6117956",
"0.61083806",
"0.6106195",
"0.609274",
"0.60815483",
"0.60710186",
"0.6064253",
"0.60213476",
"0.6018128",
"0.60146624",
"0.601063",
"0.60068774",
"0.60068774",
"0.60026145",
"0.6000521",
"0.59987193",
"0.5992379",
"0.59922844",
"0.5991889",
"0.59803206",
"0.5966244",
"0.5959778",
"0.5959708",
"0.59588563",
"0.5956974",
"0.5953329",
"0.59528023",
"0.59439695",
"0.59413165",
"0.59397036",
"0.59397036",
"0.5933782",
"0.59323835",
"0.59258395",
"0.59253365",
"0.5917244",
"0.59111005",
"0.59093463",
"0.5907942",
"0.59047514",
"0.58979666",
"0.58971125",
"0.589613",
"0.5895083",
"0.5893643",
"0.5892825",
"0.5887658",
"0.5883417",
"0.5878839",
"0.5874345",
"0.5869008",
"0.5868205",
"0.58672875",
"0.5867031",
"0.58662426",
"0.5864551",
"0.5863614",
"0.5862626",
"0.5861952",
"0.58596134",
"0.5855716",
"0.58536863",
"0.5851665",
"0.5850823"
] | 0.0 | -1 |
initialize new cash register instance | def initialize(discount=0)
@total = 0
@discount = discount
@items = []
@last_transaction = {}
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize(discount = 0) #new optionally takes an employee discount on initialization\n @total = 0 #SETS AN INSTANCE VARIABLE @TOTAL ON INITIALIZATION TO ZERO\n @discount = discount # CashRegister ::new optionally takes an employee discount on initialization\n @items = [] #returns an array containing all items that have been added\n end",
"def initialize\n # Call function to generate the account number\n account_number_gen\n # Initialize instance variables\n @checking_account_balance = 0\n @saving_account_balance = 0\n @@total_accounts += 1\n @interest_rate = 0.01\n end",
"def initialize\n createAccountNumber\n @CheckingAccount = 500\n @SavingAccount = 50\n @interestRate = 0.05\n @@account_counter += 1\n end",
"def initialize(exisiting_savings) #This gets called when a new instance of a bank account gets created\n # @balance = 0\n @balance = exisiting_savings\n end",
"def initialize_account\n self.credits = 0\n end",
"def initialize (name, cash)\n\t\tself.name = name \t\t\t\t\t\t\t\t\t\t\t\t#defining .name to to act on self method and to take name parameter\n\t\tself.cash = cash \n\t\tself.accounts = Hash.new(name)\t\t\t\t\t\t\t\t\t\t\t\t#defining .cash to to act on self method and to take cash parameter\n\t\tputs \"Hi, #{name}. You have $#{cash}!\" \t#interpolating the parameters into the puts\n\tend",
"def cashRegister(price, cash)\n\nend",
"def initialize\n @account_number = new_account_number\n @balance_total = 0\n @interest_rate = 0.0025 #per month or 3% per year.\n @balance_savings = 0\n @balance_checking = 0\n @@total_accounts += 1\n puts \"Your account has been created.\"\n end",
"def initialize\n\t\t@wallets = Set[ \"0\" ]\n\t\t@uuid = UUID.new\n\n\t\tsuper\n\tend",
"def initialize(account_number, first_name, last_name, bank)\n # Instance variables\n @account_number = account_number\n @first_name = first_name\n @last_name = last_name\n @bank = bank\n\n # self is the instance that is being created\n @@all_accounts << self\n end",
"def initialize_account\n if employer_profile_account.blank?\n self.build_employer_profile_account\n employer_profile_account.next_premium_due_on = (published_plan_year.start_on.last_month) + (Settings.aca.shop_market.binder_payment_due_on).days\n employer_profile_account.next_premium_amount = 100\n # census_employees.covered\n save\n end\n end",
"def register\n cc = 0\n end",
"def initialize(name)\n # BankAccount BankAccount #initialize initializes with a name\n @name = name\n # BankAccount BankAccount #initialize always initializes with balance of 1000\n @balance = 1000\n # BankAccount BankAccount #initialize always initializes with a status of 'open'\n @status = 'open'\n end",
"def initialize(name)\n\t\t#when I initialize the bank account I need to do so with my name\n\t\t#always initialize with a balance of 1000\n\t\t@name = name\n\t\t@balance = 1000 \n\t\t@status = \"open\"\n\tend",
"def initialize (banco, numero_cuenta, saldo_cuenta = 0)\n @banco = banco\n @numero_cuenta = numero_cuenta\n @saldo_cuenta = saldo_cuenta\n end",
"def initialize\n @credit_card = false\n @debit_card = false\n @cash = false\n end",
"def new\n @class_register = ClassRegister.new\n end",
"def register\n \n end",
"def register\r\n \r\n end",
"def initialize (bank_name)\t\t\t\n\t\tself.bank_name = bank_name \t\t\t\t\t\t\t\t#self.bank_name defined as a particular instance of parameter bank_name\n\t\tself.accounts = {}\t\t\t\t\t\t\t\t\t\t\t\t#creates empty hash accounts to store future account info in\n\t\tself.name_counter = {}\n\t\tprint_initialize\n\tend",
"def initialize(id, name, is_online, last_login, clearance, registration)\n super(id, name, is_online, last_login)\n @clearance = clearance\n @registration = registration\n end",
"def new\n @credit_card = ActiveMerchant::Billing::CreditCard.new\n end",
"def initialize(opening_balance, name)\n @opening_balance = opening_balance # We want to know the initial opening balance\n @balance = opening_balance # and set the current balance to the opening balance\n @name = name # We want an account name so we can identify the account and to display the name on the screen.\n @transactions = [] # We want to keep a list of our transactions\n end",
"def initialize(numero, titular, saldo)\n @numero = numero#variavel de instacia\n @titular = titular\n @saldo = saldo\n end",
"def initialize(bankname)\n\t\t@bankname = bankname\n\t\t@accounts = {}\n\t\t@cc_limits = {}\n\t\t@cc_balances = {}\n\t\t@cc_holds = {}\n\t\t@cc_rates = {}\n\t\tputs \"#{@bankname} bank was just created.\"\n\tend",
"def initialize\n @registry = Registry.new\n end",
"def initialize(account_hash)\n super\n @checks = 0\n @fee = 1\n @limit = 0\n end",
"def new_credit_card\n # populate new card with some saved values\n ActiveMerchant::Billing::CreditCard.new(\n :first_name => user.first_name,\n :last_name => user.last_name,\n # :address etc too if we have it\n :brand => cc_type\n )\n end",
"def register\n end",
"def initialize\n @registry = {}\n end",
"def initialize (trader, cash, sessions)\n\t\t@trader = Trader.new(trader, cash)\n\t\t@sessions = sessions\n\t\t@starting_cash = cash\n\t\t#set up the 'stockmarket' by creating stocks and putting them into an array\n\t\t@g_a = Stock.new(\"General_Assembly\", 200, 0.15, \"Learning institution.. they teach stuff!\")\n\t\t@r_l = Stock.new(\"Lomas\", 100, 0.25, \"Expert programming.. Could be huge one day!\")\n\t\t@aapl = Stock.new(\"Apple\", 750, 0.05, \"Nothing to do with fruit.. but everyone still wants one!\")\n\t\t@ud = Stock.new(\"UDS\", 75, 0.75, \"Dodgy...\") \n\t\t@stockmarket = [@g_a, @r_l, @aapl, @ud]\n\tend",
"def initialize\n @first_name = Forgery::Name.first_name\n @last_name = Forgery(:basic).password(:at_least => 6, :at_most => 8)\n @full_name = \"#@first_name #@last_name\"\n @type = 'Visa'\n @number = Forgery::CreditCard.number(:type => 'Visa', :length => 16, :prefixes => %w\"470758 473099 475034 474480 477462\").to_s\n @cvv = Random.new.rand(100..999).to_s\n @cvv2 = ''\n @expire_month = Forgery::Date.month(:numerical => true).to_s\n @expire_year = Forgery::Date.year(:future => true, :past => false, :min_delta => 1, :max_delta => 5).to_s\n @last_four_digits = @number[12..-1]\n end",
"def register\n end",
"def register\n end",
"def register\n end",
"def initialize(user_id, balance)\n # Setting the user_id instance variable to the first value passed in when a bank account is created\n @user_id = user_id\n # Setting the balance instance variable to the second value passed in when a bank account is created\n @balance = balance\n @username = \"\"\n\n # Pushes the newly created instance of bank account into the class variable all\n @@all << self\n end",
"def initialize(hex)\n super\n @a = 1\n @hex = hex\n end",
"def initialize_finance_details(registration)\n registration.finance_details = FinanceDetails.new unless registration.finance_details.present?\n initialize_orders(registration)\n initialize_payments(registration)\n end",
"def initialize(saldo)\n self.saldo = saldo\n end",
"def initialize(campos = {})\n campos = { carteira: '21' }.merge!(campos)\n super(campos)\n end",
"def initialize (account_info) #initialize is actually a class method called on by .new\n #these are the hash keys:\n @id = account_info[:id].to_i\n @balance = account_info[:initial_balance].to_i\n if @balance < 10 #cannot start a new account with less than $10 minimum balance\n raise ArgumentError.new(\"Nope.\")\n end\n @creation_date = account_info[:creation_date]\n\n end",
"def initialize( name )\n @name = name\n @accounts = {} # Initialise accounts to an empty hash\n end",
"def initialize(account_hash)\n @id = account_hash[:id]\n @balance = account_hash[:balance]\n @open_date = account_hash[:open_date]\n @fee = 0\n @limit = 0\n\n @@accounts.push(self)\n\n #Gives error if balance is negative\n if @balance < 0\n raise ArgumentError.new(\"A new account cannot be created with a negative balance.\")\n end\n end",
"def initialize\n @account_number = account_number # private method\n @checking_balance = 100\n @savings_balance = 100\n @rate = interest_rate # private method\n @@account_count += 1\n end",
"def new\n\t\t@bank = Bank.new\n\tend",
"def initialize(balance, account_holder)\n @balance = balance\n @account_holder = account_holder\n @@all << self\n # self.account_holder.accounts << self\n end",
"def initialize(campos={})\n\t\t\t campos = {:carteira => \"101\",\n\t\t\t :conta_corrente => '00000', # Obrigatória na classe base\n\t\t\t :especie_documento => \"RC\",\n\t\t\t :carteira => \"101\",\n\t\t\t :aceite => \"N\",\n\t\t\t :dias_vencimento => 3\n\t\t\t }.merge!(campos)\n\t\t\t super(campos)\n\t\t\tend",
"def initiate_registeration_in_saas\n\n @parent_tx_activity_type = GlobalConstant::CriticalChainInteractions.propose_bt_activity_type\n\n params = {\n token_symbol: @client_token.symbol,\n client_id: @client_token.client_id,\n client_token_id: @client_token.id,\n stake_and_mint_params: {\n bt_to_mint: @bt_to_mint,\n st_prime_to_mint: @st_prime_to_mint,\n client_eth_address: @client_eth_address,\n transaction_hash: @transaction_hash\n },\n airdrop_params: {\n airdrop_amount: @airdrop_amount,\n airdrop_user_list_type: @airdrop_user_list_type\n }\n }\n\n SaasApi::OnBoarding::Start.new.perform(params)\n\n end",
"def initialize(payment)\n @payment = payment\n end",
"def initialize(holder, id)\n super\n # calls the super initialize method of customer account\n @type = :Business\n # sets type to business, this will be used by the accounts controller\n @daily_limit = LIMIT\n # sets the daily limit to LIMIT constant. this will be used to restrict withdrawals\n end",
"def set_register\n @register = Register.find(params[:id])\n end",
"def set_register\n @register = Register.find(params[:id])\n end",
"def new\n \t@account = Account.new\n end",
"def register\n @is_registered = true\n self\n end",
"def initialize(customer, bartender)\n @customer = customer\n @bartender = bartender\nend",
"def initialize(balance)\n @balance = balance\n end",
"def initialize\n @balance = 0 # software won't be as pure with exposed balance\n @transactions = [] # object calisthenics? primitive obsession -> array is suspect, some sort of collection object\n # store as hash instead?\n end",
"def initialize(owner, expire_date, type)#, dob, phone, vip)\n\t\t@number = rand(10000000)\n\t\t@expire_date = Date.parse(expire_date)\n\t\t@cvv = rand(1000)\n\t\t@name = owner.name\n\t\t# Customer.new(name, dob, phone, vip)\n\tend",
"def initialize(name)\n @name = name #expect(avi).to be_a(BankAccount)\n @balance = 1000\n @status = \"open\"\n @account_total = []\n end",
"def register\n @user = User.new\n @newclient = Client.new\n end",
"def initialize(house, unit, controller)\r\n\t@house = house\r\n\t@unit = unit\r\n\t@controller = controller\r\n\t@address = X10.make_address(house, unit)\r\n end",
"def initialize(name, addr)\n @cust_id = @@no_of_customers\n @cust_name = name\n @cust_addr = addr\n @@no_of_customers += 1\n end",
"def initialize(**new_customer_hash)\n\t\t@first_name = new_customer_hash[:info_first_name]\n\t\t@last_name = new_customer_hash[:info_last_name]\n\t\t@active = false \n\t\t@street_address = new_customer_hash[:info_street_address]\n\t\t@city = new_customer_hash[:info_city]\n\t\t@state = new_customer_hash[:info_state]\n\t\t@postal_code = new_customer_hash[:info_postal_code]\n\t\t@phone = new_customer_hash[:info_phone_number]\n\t\t@payment = nil\n\tend",
"def initialize\n @payment_method_service = SpreeQuickbooks::Services::PaymentMethod.new({})\n end",
"def initialize(creep)\n @creep = creep\n end",
"def register\n\n\tend",
"def new\t\n\t @currencies = CURRENCIES\t\n\tend",
"def set_bank_register\n @bank_register = BankRegister.find(params[:id])\n end",
"def set_account\n Finance::Account.create.save\n @account = Finance::Account.first\n end",
"def initialize(campos = {})\n campos = { carteira: 'CNR' }.merge!(campos)\n super(campos)\n end",
"def initialize\n raise \"Cannot instantiate Dependo::Registry\"\n end",
"def initialize(name)\n @name = name\n @accounts = {} # Initialize accounts as an empty hash\n end",
"def initialize salon = \"coeco\"\n\t\t@salon = salon\n\tend",
"def build_account(data)\n Account.new(\n bank: self,\n id: data['referencia'],\n name: data['empresaDes'],\n available_balance: data['saldoValor'].to_f,\n balance: data['saldoContable'],\n currency: data['divisa'],\n iban: data['numeroAsunto'],\n description: \"#{data['bancoDes']} #{data['numeroAsuntoMostrar']}\"\n )\n end",
"def initialize(name, age)\n @name = name\n @age = age\n @report_card = Report_Card.new\n end",
"def new\n @wallet = get_wallet\n @transaction = Transaction.new\n end",
"def initialize(x)\t\t# constructor\r\n\t\t@inst = x \t\t\t# instance variable start with @\r\n\t\t@@cla += 1\t\t\t# each object shares @@cla\r\n\tend",
"def initialize(campos = {})\n campos = { aceite: 'A', instrucao_cobranca: '05', primeira_instrucao: '00', segunda_instrucao: '00' }.merge!(campos)\n super(campos)\n end",
"def initialize(company, symbol, price_per_share, currency, quantity)\n @company = company\n @symbol = symbol\n @price_per_share = price_per_share.to_i\n @currency = currency\n @quantity = quantity\n end",
"def register\n params = Serializer.new(self).to_params\n Response.new Request.post(\"checkout\", params)\n end",
"def initialize(client_code, name, balance, password, credit_card_number)\n @client_code = client_code\n @name = name\n @balance = balance\n @password = password\n @credit_card_number = credit_card_number\n end",
"def initialize(name, id, addr)\n @cust_name = name\n @cust_id = id\n @cust_addr = addr\n end",
"def initialize\n @funds = 1000\n end",
"def initialize(account_hash)\n super\n @fee = 2\n @limit = 10\n if @balance < 10\n raise ArgumentError.new(\"A new account cannot be created with less than $10.\")\n end\n end",
"def set_reg\n @reg = Reg.find(params[:id])\n end",
"def set_reg\n @reg = Reg.find(params[:id])\n end",
"def build_account(data)\n Account.new(\n bank: self,\n id: data['numProd'],\n name: data['description'],\n available_balance: Money.new(data['availableBalance'] * 100, 'EUR'),\n balance: Money.new(data['balance'] * 100, 'EUR'),\n iban: data['iban']['ibanCode'],\n description: \"ARQUIA: #{data['description']}\"\n )\n end",
"def initialize # clinic\n # @company = clinic.company\n\n response = create\n end",
"def initialize(name, email = '', phone = '')\n @name = name\n @email = email\n @phone = phone\n\n # Customer has many accounts\n @accounts = []\n end",
"def signup\n @companion = Companion.new\n end",
"def initialize(attrs={})\n super\n self.donationLineItems = instantiate_donation_line_items(self.donationLineItems)\n self.payment = instantiate_payment_method(self.payment)\n self.addOrDeductFeeAmount = 0 unless addOrDeductFeeAmount.present?\n end",
"def initialize\n\t\t\t@addressCollection = Array.new\n\t\t\t@buyerKey = '00000000-0000-0000-0000-000000000000'\n\t\t\t@personTypeEnum = Buyer.PersonTypeEnum[:Person]\n\t\t\t@taxDocumentTypeEnum = Buyer.DocumentTypeEnum[:CPF]\n\t\tend",
"def initialize\n @codigo = Faker::Barcode.ean\n @total = 0\n @productos = []\n @fecha_creacion = Time.now.strftime(\"%d-%m-%Y\")\n @fecha_entrega = Faker::Date.forward(days: 2).strftime(\"%d/%m/%Y\")\n @estado = \"preparando\"\n end",
"def build_account(data)\n account, iban = data\n Account.new(\n bank: self,\n id: account['cviejo']['numerodecontrato'],\n name: account.fetch('descripcion', '').strip(),\n available_balance: money(account['saldoActual']),\n balance: money(account['saldoActual']),\n iban: iban['codIban'].values().join.strip,\n description: account.fetch('descripcion', '').strip(),\n contract_id: account['cviejo']['subgrupo']\n )\n end",
"def new \n @cuber = Cuber.new\n end",
"def initialize()\n @bet = \"user:#{settings.id}:bet\"\n @redis = settings.redis\n @redis_money = \"user:#{settings.id}:money\"\n @redis_chips = \"user:#{settings.id}:chips\"\n @money = @redis.get @redis_money\n @money = @money.to_i\n end",
"def initialize(nfe_company)\n @nfe_company = nfe_company\n @company = nfe_company.company\n @clinic = nfe_company.clinic\n @social_contract = @clinic.clinic_social_contract\n @regime_parameter = @clinic.clinic_regime_parameter\n @tax_regime = Operations::Products::Clinics::RegimeParameterRepository::TAX_REGIME[@regime_parameter.tax_regime]\n @special_tax_regime = Operations::Products::Clinics::RegimeParameterRepository::SPECIAL_TAX_REGIME[@regime_parameter.special_tax_regime]\n @legal_nature = Operations::Products::Clinics::RegimeParameterRepository::LEGAL_NATURE[@regime_parameter.legal_nature]\n @cnae_main = @clinic.clinic_cnaes.where(kind: \"main\").first\n @address = @company.addresses.where(is_main: true, kind: \"commercial\").first\n @email = @company.emails.where(is_main: true, kind: \"commercial\").first\n @phone = @company.phones.where(is_main: true, kind: \"commercial\").first\n\n response = create\n end",
"def initialize\n @balance = 0\n end",
"def initialize(number)\n validate!\n @type_car = :cargo\n @number_car = number\n super(@number_car, @type_car)\n end",
"def initialize() end",
"def initialize(name)\n\t\t@name = name\n\t\t@transactions = [ ]\n\t\taddtransaction(\"Beggining balance\", 0.00)\n\tend"
] | [
"0.6509862",
"0.6349476",
"0.6268034",
"0.6241197",
"0.62274337",
"0.619365",
"0.618544",
"0.6175208",
"0.6150307",
"0.61391604",
"0.6098538",
"0.60733455",
"0.60699993",
"0.60544527",
"0.60501355",
"0.5993032",
"0.59788656",
"0.58794343",
"0.5857411",
"0.58511317",
"0.58245605",
"0.58228785",
"0.5813543",
"0.58115274",
"0.57994556",
"0.5794579",
"0.57924443",
"0.57916206",
"0.5790256",
"0.57736963",
"0.57533073",
"0.5752924",
"0.5751091",
"0.5751091",
"0.5751091",
"0.5737127",
"0.57358956",
"0.57325256",
"0.57319415",
"0.57161087",
"0.5695662",
"0.56925917",
"0.5691429",
"0.56795365",
"0.56742525",
"0.56719",
"0.5670042",
"0.56676507",
"0.5667635",
"0.565266",
"0.56495017",
"0.56495017",
"0.5647489",
"0.56428283",
"0.5637685",
"0.5626265",
"0.56200176",
"0.5616088",
"0.56124085",
"0.561211",
"0.56011903",
"0.55947167",
"0.55886966",
"0.55831546",
"0.55801916",
"0.5578287",
"0.5576122",
"0.5569017",
"0.55637187",
"0.55599165",
"0.5558193",
"0.55564964",
"0.5552141",
"0.55334187",
"0.5529298",
"0.5524843",
"0.55232286",
"0.55222255",
"0.5517967",
"0.5512869",
"0.5508205",
"0.55024827",
"0.54988354",
"0.549452",
"0.5490068",
"0.5490068",
"0.5489108",
"0.54873157",
"0.54807115",
"0.54699683",
"0.54688966",
"0.5464467",
"0.54643834",
"0.54576164",
"0.5456012",
"0.5455528",
"0.5449287",
"0.544812",
"0.5445272",
"0.5445183",
"0.5443298"
] | 0.0 | -1 |
adding new item to cash register instance adds to total, adds items to an array, and tracks last transaction in a hash | def add_item(item, price, quantity=1)
@total += (price * quantity)
@items.fill(item, @items.size, quantity)
@last_transaction = {item => (price * quantity)}
@last_qty = quantity
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_item (title, price, quantity = 1)\n # adds purchase price to total\n @total += price * quantity\n # Adds proper quanity of item to cart\n count = 0\n while count < quantity\n @items << title\n count += 1\n end\n # keeps track of last_added item\n @last_transaction[:item] = title\n @last_transaction[:price] = price\n @last_transaction[:quantity] = quantity\n\n end",
"def add_item(item, price, quantity = 1)\n @total += price * quantity\n @transactions << price * quantity\n i = quantity\n until i == 0 do\n @items << item\n i -= 1\n end\n end",
"def add_item(string, float, integer = 1)\n # adds item price to total\n @total += float * integer\n # accepts an optional quantity of the item\n quantity = integer\n # loops to add item multiple times to the list \n quantity.times {@items << string}\n # holds the amount of the last transaction\n self.last_transaction = float * quantity\n end",
"def add_item(hash, item, quantity)\r\n\thash.store(item, quantity)\r\n\thash\r\nend",
"def add_item(item, price, quantity = 1)\n self.total += price * quantity\n self.last_item = price\n self.last_quantity = quantity\n\n counter = 0\n while counter < quantity\n self.cart << item\n counter += 1\n end\n self.cart\n end",
"def add(item)\n self.items.push(item)\n if self.min_price > item.price.to_i\n self.min_price = item.price.to_i\n end\n self.owners.push(item.owner)\n self.owners = self.owners.uniq\n self.quantity += item.quantity\n self\n end",
"def add_item(item, price, quantity=1)\n # to call an instance method inside another instance method, use the self keyword to refer to the instance on which you are operating\n self.total += price * quantity # increment the total by the result of (price X quantity)\n # puts \"total: #{self.total}\"\n\n quantity.times do\n @items << item # add item to array 'quantity' # of times ***see note below\n end\n\n @last_transaction = price * quantity # keep track of the last transaction amount added\n # puts \"last transaction: #{@last_transaction}\"\n end",
"def add_item(title, price, quantity=1) \n self.total += price * quantity\n quantity.times do\n items << title \n end\n self.last_transaction = price * quantity\n\n end",
"def add_item(title, price, quantity=1)\n self.total += price * quantity\n #quantity amount of times it'll add the title to the items array\n quantity.times {items << title}\n self.last_transaction = price * quantity\n end",
"def add_item(hash, new_item, qty)\n hash[new_item] = qty\n hash \nend",
"def add_item(item_list, item, qty)\r\n item_list[item] = qty\r\n item_list\r\nend",
"def add_item(title, price, quantity = 1)\n @total += price*quantity\n @instance_items << [title, price, quantity]\nend",
"def add_item(item_name, price, quantity = 1)\n @transactions << Transaction.new(item_name, price, quantity)\n quantity.times{self.items << item_name}\n self.total += price*quantity\n end",
"def add_item_to_list(hash, item_to_add, qty)\n hash[item_to_add] = qty\nend",
"def add_item(new_item, new_item_quantity, grocery_hash) \n grocery_hash[new_item] = new_item_quantity\n return grocery_hash\nend",
"def add(item, quantity, hash)\n hash[item] = quantity\nend",
"def add_item(title, amount, quantity=1)\n self.total += amount * quantity\n quantity.times do\n items << title\n end\n self.last_transaction = amount * quantity\n end",
"def add_item(current_list, item_added, quantity)\n current_list[item_added] = quantity\n current_list\nend",
"def add(cash)\n @current_balance = @current_balance + cash\n end",
"def add_item(hash, item, quantity)\n\t hash[item] = quantity\n\t return hash\nend",
"def add_item(hash_of_items, item, quantity=1)\n hash_of_items[item] = quantity\n hash_of_items\nend",
"def add_item(item, qty)\n for ele in @order do\n order_item = ele.keys[0]\n if order_item.name == item.name\n ele[order_item] += qty\n return \n end\n end\n @order.push({item => qty})\n \n end",
"def add\n @item.increment(:quantity)\n @item.save!\n\n refresh\n end",
"def add_item(title, price, quantity=1)\n #and increases the total\n self.total += price * quantity\n #times.do for all the items\n quantity.times do\n @items << title\n end\n #doesn't forget about the previous total\n self.last_transaction = price * quantity\n end",
"def add_item(hash, item, quantity)\n hash[item] = hash[item].to_i + quantity\n hash\nend",
"def add_item(item, amount, quantity = 1)\n\n if quantity > 1\n self.total += (amount * quantity)\n quantity.times do \n @items << item\n end\n else\n self.total += amount\n @items << item\n end\n @last_amount = amount * quantity\n end",
"def add_item(hash, item, quantity=1)\r\n grocery_list=hash\r\n if grocery_list.include?item\r\n grocery_list[item]+=quantity\r\n else\r\n grocery_list[item]=quantity\r\n end\r\n p grocery_list\r\nend",
"def add_item item\n @items << item\n @@all_items << item\n end",
"def add(hash, item, qty)\n hash[item] = qty\n\nend",
"def add(hash, item, qty)\n hash[item] = qty\n \nend",
"def add_item(grocery_hash, new_item)\n new_item.each do |i|\n grocery_hash[i] += 1\n end\n grocery_hash\nend",
"def add_item(item)\n @cart_items[item] = @cart_items[item].to_i + 1\n end",
"def add_item(item, amount)\n # Check if the Entity already has that item\n # in the inventory. If so, just increase\n # the amount.\n @inventory.each do |couple|\n if (couple.first == item)\n couple.second += amount\n return\n end\n end\n # If not already in the inventory, push a Couple.\n @inventory.push(Couple.new(item, amount))\n end",
"def add_to_list(list_hash, item, qty)\r\n\tlist_hash[item] = qty\r\n\tlist_hash\t\r\nend",
"def add_item(list, item, quantity)\n #list = item.push\n list[item] = quantity.to_i\n list\nend",
"def add_item(hash,item)\n hash[:inventory].push(item)\nend",
"def add_to_cart(product, amount)\n purchase = \" • #{amount} #{product}\\n\"\n @cart << purchase\n\n cost_per_item = @inventory[product][\"price\"]\n @total_cart_value += (cost_per_item * amount)\n\n @inventory[product][\"quantity\"] -= amount\nend",
"def add_item(shopping_list, item, quantity)\r\n\tshopping_list[item] = quantity\r\n\tshopping_list\r\nend",
"def list_add(hash_items, item_name, quantity = 1)\n hash_items [item_name] = quantity\n return hash_items\nend",
"def add_item(hash, new_item, item_quantity)\n hash[new_item] = item_quantity\nend",
"def add_item(hash, item, quantity)\n\n hash[item] = quantity.to_i \n\n return hash\nend",
"def add_item (groceries_list, new_item, quantity)\n\t# add 1 new item to list\n\tgroceries_list.merge!({new_item => quantity})\n\t# return updated list\n\tgroceries_list\n# output: hash\nend",
"def add_item(grocery_list, item, qty)\n grocery_list[item] = qty \n grocery_list\nend",
"def add(selected_item, count = 1)\n item = find_item(selected_item)\n if item != nil\n init_count = item.fetch(\"count\").to_i\n init_count += count.to_i\n item.store(\"count\", init_count)\n else\n struct = CartItem.new\n struct.cart_item_id = selected_item.id\n struct.count = count.to_i\n @items.push(struct)\n end\n end",
"def additem(list, item, number = 1)\n# input: hash, item name and optional quantity\n# steps: push an item into the hash\n list.store(item, number)\nend",
"def add_item(list, add_item, add_quantity=1)\n# steps:\n # Add item as key and quantity as value to final_list hash(item and quantity will be user inputs)\n list[add_item] = add_quantity\n # Return updated hash\n list\nend",
"def add_item(hash_list, new_item, quantity = 1)\n hash_list[new_item] = quantity\n p hash_list\nend",
"def add_item(item, amount = 1)\n\n # Increase the amount if the item already exists in the inventory.\n @inventory.each do |couple|\n if (couple.first == item)\n couple.second += amount\n return\n end\n end\n\n # If not already in the inventory, push a Couple.\n @inventory.push(Couple.new(item, amount))\n end",
"def add_item(input_hash, item, qty = 0)\n# steps: use input item as key and input quantity as value \n input_hash[item] = qty\n# output: hash data structure of key/value pairs\n return input_hash\nend",
"def add_item (title, price, quantity = 1)\n i = 0\n while i < quantity\n @items << title\n i += 1\n end\n my_price = price * quantity\n @transactions << my_price\n @total += (price * quantity)\n end",
"def add(item, quantity, hash)\n hash[item] = quantity\n puts hash\nend",
"def add_item(title, price, quantity = 1)\n item = {\n title: title,\n price: price,\n quantity: quantity\n}\n\n\n@items_array << item\n@total += price * quantity\n\n\nend",
"def purchase(item_price)\n @total += item_price\n total\n end",
"def add_money\n @total += fee\n end",
"def add_item(item, amount = 1)\n\n # Increase the amount if the item already exists in the inventory.\n @inventory.each do |couple|\n if (couple.first == item)\n couple.second += amount\n return\n end\n end\n\n # If not already in the inventory, push a couple.\n @inventory.push(C[item, amount])\n end",
"def add(grocery_list, item, quantity)\n grocery_list[item] = quantity\nend",
"def add_item(hash, item, qty)\n\n if hash.has_key?(item)\n hash[ item ] += qty\n else\n hash[ item ] = qty\n end\n\nend",
"def add_item(list, item, qty)\n list[item] = qty\n list\nend",
"def add_item(item, quantity=1, hash)\n# get item name and quantity\n# if there's no quantity, set it to 1\n\thash[item] = quantity\n\t# output: return the hash with updated key/value pairs\n\thash\nend",
"def add_to_receipt(item)\n balance = item.is_a?(Array) ? item[2] ? item[2].to_i <=> 0 : 0 : 0\n if @marw_queue.empty? || @marw_queue.all? { |receipt| \n receipt.closed || balance != receipt.balance }\n label = (balance == 0 ? marw_label_default : (balance > 0 ? \n MARW_CONFIGURATION[:vocab_gain_label] : MARW_CONFIGURATION[:vocab_lose_label]))\n show_receipt_window(label, [], balance)\n end\n @marw_queue.reverse.each { |receipt| \n if !receipt.closed && receipt.balance == balance\n receipt.item_array.push(item) \n break\n end\n }\n end",
"def add_item(item_name, item_qty)\n# $list_items[item_name] = item_qty\n # my_hash[key] = value\n # This will create a NEW key value pair\n # OR update (aka replace) the value for an existing key.\n \n # my_hash[key] += value\n # will INCREASE the value for an existing key.\n if $list_items.include?(item_name)\n # Increase that item\n $list_items[item_name] += item_qty\n else\n # Create the new item\n $list_items[item_name] = item_qty\n end\nend",
"def add(final_list, item, quan)\r\n p final_list[item] = quan\r\nend",
"def add(list, item, quantity)\r\n\tlist[item] = quantity\r\n\tlist\r\nend",
"def add(item)\n save do\n items.push(Item.new(item)).last\n end\n end",
"def add_to_inventory(item)\n @inventory.push(item)\n update\n end",
"def add(list, item, quantity)\r\n list[item] = quantity\r\n list\r\n\r\nend",
"def add_item(title, p, q=1) # accepts a title and a price AND inc. the total. Optional quantity set to 1 since u will always have at least one item.\n @total += (p*q) # @ total is price times quantity, and increments (does not forget previous total as u add new items)\n q.times do # want to add the item as many times to the list as its quantity so keep doing this the # of times its quantity is\n @items << title\n end\n @last_transaction = p # the last transaction = the price of the last item added\n end",
"def add_to_transactions()\n\n\t\tcreate_id\n\t\tputs \"id created\"\n\t\tputs @id\n\t\t#we validate if we have transactions in the array, if so we check if the transaction\n\t \t#that we want to add is already there\n\t if @@transactions.count >0\n\n\t \tif Transaction.transaction_include_by_id?(self.id)\n\t \traise DuplicateProductError, \"#{self.id} already exists.\"\n\t \telse\n\t \t\t@@transactions.push(self)\n\t\t\tend\n\n\t\telse\n\n\t @@transactions.push(self)\n\t end\n\tend",
"def add(hash); end",
"def add_item(list, item, quantity)\n\n\tlist[item] = quantity\n\tlist\n\nend",
"def add_to_list(new_item, quantity)\n #addition = { new_item => quantity }\n addition = Hash.new\n addition[new_item] = quantity\n new_list = addition.merge($old_list.to_h)\n #p new_list\nend",
"def add_item(title, price, quantity = 1)\n @title = title\n @price = price\n quantity.times {@items << title}\n @last_transaction = @price * quantity\n @total = @total + (@price * quantity)\n @total\n end",
"def add_item(hash, item, quantity)\n if !hash.has_key?(item)\n hash[item] = quantity\n end\n return hash\nend",
"def add_item(inventory, item, quantity)\n\tinventory[item] = quantity\n\t@full_inventory = inventory\n\t#this is what updates your inventory with the new item & quantity.\nend",
"def add_item(barcode, name, price)\n @barcodes << barcode\n @names << name\n @prices << price\n end",
"def add(input_list, item, quantity)\n input_list[item] = quantity\nend",
"def add_item(item, quantity, list)\n\tlist[item] = quantity\n\titem\nend",
"def add_item(grocery_hash, grocery, quantity)\n grocery_hash [grocery] = quantity \nend",
"def add_item (grocery_list, grocery_item)\n grocery_list.store(grocery_item, 0)\nend",
"def add_item(list, new_item, opt_quant)\n list_hash = list\n if opt_quant == nil || opt_quant == 0\n opt_quant = 2\n end\n list_hash[new_item] = opt_quant\n return list_hash\nend",
"def add_to_customer_total\n \tcurrent_total = self.customer.total_repair\n \tcustomer = self.customer\n \tif current_total\n \t\tcustomer.total_repair += self.total_charge\n \telse\n \t\tcustomer.total_repair = self.total_charge\n \tend\n \tcustomer.save\n end",
"def add_item (list, item, qty)\n list[item]=qty\nend",
"def add_item(grocery_list, new_item, new_quant=1)\r\n grocery_list[new_item] = new_quant\r\n p grocery_list\r\nend",
"def add(item)\n @clxn[key_for(item)] = item\n end",
"def new_quantity(list, item, qty)\n list[item] += qty\n p list\nend",
"def add_item(my_list, item, quantity)\r\n #input: a string seperated by an integer \r\n #steps: use a method that adds an item and quantity to the hash.\r\n my_list.store(item, quantity)\r\n # use a hash or store method hash.merge!(key => value) \r\n #output = hash with the updated item/quantity. \r\n my_list\r\n \r\nend",
"def void_last_transaction\n#save add item to last transaction\n#take total and items list, and remove last transaction\n self.total -= self.last_transaction\n @title.pop\n end",
"def add_item(hash, grocery, quantity)\n\thash[grocery] = quantity # and set value to their quantity\nend",
"def add_item(list_items, item_name, item_qty)\n if list_items.include?(item_name)\n list_items[item_name] += item_qty\n else\n list_items[item_name] = item_qty\n end\nend",
"def refill(items = {})\n validate_refill(items)\n items.each do |key, value|\n return unless value.to_f && @inventory[key.to_s]\n\n new_value = @inventory[key.to_s] + value.to_f\n @inventory[key.to_s] += value.to_f\n end\n end",
"def add_item(item,quantity,list)\n\tlist[item] = quantity\nend",
"def add_item(new_item)\n item = Item.new(new_item)\n items.push(item)\n end",
"def add_item(item, quant=0)\n\t$grocery_list.store(item, quant)\n\tp \"You added #{item} to your list.\"\nend",
"def add (list, item, quantity)\n\tlist[item] = quantity\nend",
"def add_an_item(grocery_list, new_item, qty = 1)\n grocery_list[new_item] = qty\n grocery_list\nend",
"def add_item(item, price, *quantity)\n q = quantity.join(\"\").to_i\n if q > 1\n q.times do\n @items.push(item)\n end\n else\n @items.push(item)\n end\n if q > 1\n price_with_quantity = q * price\n @last = price_with_quantity\n @total += price_with_quantity\n else\n @last = price\n @total += price\n end\n\n end",
"def add_item (title, price, quantity=1)\n self.total += price * quantity\n quantity.times do\n @items << title\n end\n end",
"def update_it(new_list, item, amount)\n \n new_list[item] = amount\n \n new_list\nend",
"def add_item(item,amount=1,the_lists)\r\n\t# steps: accept 2 arguments. Item name and Quantity (with default)\r\n\tif the_lists[item] != nil\r\n\t puts \"Item is already on the List !\"\r\n\t puts \"Added amount to the quantity\"\r\n\t the_lists[item] += amount\r\n\telse\r\n the_lists[item] = amount\r\n\tend\r\n\r\n\tprint_list(the_lists)\r\nend",
"def void_last_transaction\n @items = self.last_item\n self.total = @total - @transactions[-1]\n end"
] | [
"0.72258765",
"0.68470055",
"0.6771469",
"0.6748451",
"0.67401516",
"0.66924566",
"0.6625887",
"0.6622018",
"0.65900964",
"0.6563566",
"0.6519667",
"0.65079874",
"0.6494941",
"0.6486597",
"0.6476313",
"0.6451452",
"0.64410144",
"0.6406616",
"0.6404375",
"0.6401386",
"0.6390001",
"0.6380634",
"0.63784564",
"0.6365094",
"0.6303829",
"0.6302892",
"0.6302671",
"0.62996763",
"0.6295662",
"0.62918264",
"0.6280693",
"0.6276947",
"0.62631446",
"0.62614304",
"0.6252455",
"0.6248237",
"0.6239745",
"0.6237004",
"0.62246186",
"0.6220816",
"0.6219777",
"0.6215826",
"0.6204535",
"0.6203865",
"0.6191819",
"0.6179089",
"0.616892",
"0.61680895",
"0.61671585",
"0.61625105",
"0.61618555",
"0.6156909",
"0.6156839",
"0.6153481",
"0.6145469",
"0.61454195",
"0.6143444",
"0.6140375",
"0.612504",
"0.6110831",
"0.6101637",
"0.61006075",
"0.6098905",
"0.60800004",
"0.60734284",
"0.6072179",
"0.60673773",
"0.6049203",
"0.6048892",
"0.604772",
"0.6037361",
"0.6036359",
"0.60339326",
"0.6024384",
"0.60189164",
"0.6014599",
"0.6012552",
"0.6012536",
"0.6007285",
"0.6005854",
"0.5993464",
"0.5986716",
"0.5984141",
"0.5981799",
"0.59809375",
"0.5975619",
"0.59704345",
"0.5969709",
"0.5969231",
"0.5966494",
"0.5966292",
"0.5962143",
"0.59620917",
"0.5952921",
"0.59503645",
"0.5950137",
"0.59434706",
"0.5941964",
"0.5939311",
"0.5932804"
] | 0.7257366 | 0 |
returns new total w/ discount applied + message | def apply_discount
@total *= (1 - (discount * 0.01))
if discount == 0
return "There is no discount to apply."
else
return "After the discount, the total comes to $#{@total.to_i}."
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_discount\n if @discount == 0\n \"There is no discount to apply.\"\n else\n @discounted_price = (self.total * @discount * 0.01)\n @total -= @discounted_price\n \"After the discount, the total comes to $#{@total.to_i}.\"\n end\n end",
"def apply_discount\n # checks if there is any discount\n if discount == 0\n \"There is no discount to apply.\"\n else\n #applies discount\n @total = @total * (1-@discount/100.0)\n # converts back to integer\n @total = @total.to_i\n \"After the discount, the total comes to $#{@total}.\"\n end\n end",
"def apply_discount\n if self.discount > 0\n self.total = @total - @total * @discount / 100\n return \"After the discount, the total comes to $#{@total}.\"\n else\n return \"There is no discount to apply.\"\n end\n end",
"def apply_discount\n # conditional to check if there's a discount\n if discount > 0\n @total -= @total * (discount / 100.0).to_f\n #gets rid of trailing zeros \n total = @total.to_s.sub(/\\.?0+$/, '')\n return \"After the discount, the total comes to $#{total}.\"\n else\n return \"There is no discount to apply.\"\n end\n end",
"def apply_discount\n if discount > 0 \n @total = @total * 0.8\n \"After the discount, the total comes to $#{@total.to_i}.\"\n else\n \"There is no discount to apply.\"\n end\n end",
"def apply_discount\n self.total -= (self.discount * 0.01) * self.total\n return self.total > 0 ? \"After the discount, the total comes to $#{self.total.to_i}.\" : \"There is no discount to apply.\"\n end",
"def discounted_total\n line_item.total_in_cents - discount_amount\n end",
"def apply_discount\n if self.discount == 0\n return \"There is no discount to apply.\"\n else self.total *= (1 - (self.discount.to_f / 100))\n return \"After the discount, the total comes to $#{self.total.to_i}.\"\n end\n end",
"def apply_discount\n if discount != 0\n self.total = (total * ((100.0 - discount.to_f)/100)).to_i\n \"After the discount, the total comes to $#{self.total}.\"\n else\n \"There is no discount to apply.\"\n end\n end",
"def apply_discount\n if discount !=0\n self.total = total- (total*(discount/100.to_f)).to_i\n \"After the discount, the total comes to $#{self.total}.\"\n else\n \"There is no discount to apply.\"\n end\n end",
"def discounted_total\n line_items = line_items_total\n fees = [item_fees_in_cents].sum\n credits = [customer_credits_total, promo_code_total].sum\n discounts = [membership_discount_total, quantity_discount_total].sum\n\n total = line_items + fees - credits - discounts\n [total, 0].max\n end",
"def apply_discount\n # if @discount != 20\n discount_percent = ((100.0 - @discount.to_f) / 100.0)\n @total *= discount_percent\n return \"After the discount, the total comes to $#{@total.to_i}.\"\n # else\n # return \"There is no discount to apply.\"\n # end\n end",
"def apply_discount\n if @discount != 0\n @discount = @discount.to_f / 100 # discount is 20%, so must convert to float before dividing by 100 to get percent\n self.total = (@total * (1 - @discount)).to_i # convert back to integer so result is $800 not $800.0\n \"After the discount, the total comes to $#{self.total}.\"\n # puts @total\n # puts @discount.to_f / 100\n # puts 1 - (@discount.to_f / 100)\n else\n \"There is no discount to apply.\"\n end\n end",
"def apply_discount\n\t\t@total -= @discount\n\t\tputs \"Total price expected: £ #{@total.round(3)}\"\n\tend",
"def apply_discount\n if @discount\n discount = @total * @discount / 100 \n @total = @total - discount\n return \"After the discount, the total comes to $#{@total}.\"\n else # cash register wasn't initiailzied w/ discount\n return \"There is no discount to apply.\"\n end\n end",
"def final_amount\n amount_paid - discount_value - discount_percent\n end",
"def apply_discount\nif @discount != nil \n @total -= (@total*@discount/100)\n \"After the discount, the total comes to $#{@total}.\"\nelse\n \"There is no discount to apply.\"\nend\nend",
"def total_discount(items)\n 0\n end",
"def apply_discount\n #binding.pry\n self.total *= (1-(self.discount/100.0))\n discount_s = \"After the discount, the total comes to $#{self.total.to_i}.\"\n no_discount_s = \"There is no discount to apply.\"\n discount > 0 ? discount_s : no_discount_s\n end",
"def discount_total_base\n total * (conv_discount / 100)\n end",
"def pre_discount_total\n sum(:pre_discount_total)\n end",
"def discount_amount\n has_discount? ? (line_item.total_in_cents * discount.percentage/100.0).to_i : 0\n end",
"def get_discounted_amount\n\t\tif self.discount.nil?\n\t\t\t0\n\t\telse\n\t\t\tself.amount * self.discount\n\t\tend\n\n end",
"def collection_discount(total)\n (discount * total) / 100\n end",
"def total\n regular_total = sub_total\n if used_promo\n regular_total -= discount_from_promo\n end\n regular_total >= 0 ? (\"%.2f\" % regular_total).to_f : 0.0 \n end",
"def discount_on_line_item_total\n total_discount = 0\n\n line_item_promotions.each do |promotion|\n total_discount += discount_for_line_item_promotion(promotion)\n end\n\n total_discount\n end",
"def total\r\n\t\tthe_cost = product[:wholesale_base_price] + option_value[:wholesale_extra_cost]\r\n\t\tthe_discount = product[:discount]\r\n\t\tabs_discount = product[:discount_is_abs]\r\n\r\n\t\tmultiplier = draft.priced ? 1.0 : 1.1\r\n\r\n\t\tProduct.discount_price(the_cost, the_discount, abs_discount) * quantity * multiplier\r\n\tend",
"def compute_total(total)\n if discount.eq?('percent')\n percent_value = amount.to_f / 100\n total = total - (total * percent_value)\n else\n total = total - amount\n (total < 0) ? 0 : total \n end \n end",
"def calculate_discount_for(total)\n if self.discount_percentage.present? && self.discount_percentage != 0.0\n (total / 100) * self.discount_percentage.round(2)\n else\n 0\n end\n end",
"def membership_discount_total\n membership_fixed_total + membership_percent_total\n end",
"def final_price\n price * (100 - discount) / 100\n end",
"def computeTotal\n # get rule for total\n rule = @rules.find{ |obj| obj.getCode == \"total\" } \n # sum item prices\n total = @items.inject(0){|sum, x| sum + x.getPrice} \n # if rule exists and condition is met, apply discount\n if rule && total > rule.getThreshold \n total = rule.getPercent ? total * (1-rule.getValue) : total - rule.getValue\n end\n return total\n end",
"def total\n total = with_product_discounts\n total = with_basket_discounts(total)\n return \"£#{total}\"\n end",
"def final_total\n fees = [ticket_fees_in_cents, delivery_fee_in_cents].sum\n reductions = [reduction_code_credit_total].sum\n\n discounted_total + fees - reductions\n end",
"def discount_amount\n all_discounts = line_items.collect { |li| li.discounts }.flatten\n mapping = all_discounts.map(&:price_extend)\n # when we create the discount items, we need to set calculate their price_extend value\n mapping.sum\n end",
"def discount\n @price - @price * @discount/100\n end",
"def discounted_item_total\n ( self.item_total - self.discountable_item_total )\n end",
"def total\n # Calculo el total sin descuentos\n self.total_prize = @products.map {|p| p.prize }.inject :+\n\n # Aplico todos los descuentos dinamicamente\n @discounts.each do |discount|\n discount.call self\n end\n\n self.total_prize # Retorno el precio final\n end",
"def set_total\n @coupon = Coupon.find_by(code: session[:coupon_applied])\n @cart_items = current_user.cart_items\n @sub_total = 0\n @cart_items.each do |item|\n @sub_total += item.quantity * item.product.price\n end\n if @coupon.present?\n @discount = (@sub_total * @coupon.percent.to_i)/100\n else\n @discount = 0\n end\n @cart_total = @sub_total - @discount\n if @cart_total < 5000\n @shipping_cost = 50.to_f\n else\n @shipping_cost = 0.to_f\n end\n end",
"def total_amount_before_modifier\n sale_amount + discount_amount + tax_amount + shipping_amount\n end",
"def calculate_net_amount\n @items.each do |item|\n item.price_after_discount = @discount_processor.calculate_item_amount_with_discount(item, @user)\n end\n\n #total items bill amount\n items_total = @items.map(&:price_after_discount).reduce(:+)\n\n #applying discount on total amount.\n @discount_processor.apply_discount_on_total(items_total)\n end",
"def total_amount\n self.tickets.inject(0) do |amount, ticket|\n amount += ticket.price_minus_discount\n end\n end",
"def total_price\r\n total = 0\r\n\r\n #Adds the prices of the orders up\r\n order_items.each do |order_item|\r\n total += order_item.item.price*order_item.quantity\r\n end\r\n\r\n #Applies any discounts\r\n if(campaign)\r\n discount = campaign.campaign_type.percentage_reduced\r\n if discount != 100\r\n total -= (total * discount / 100)\r\n elsif discount == 100\r\n i = []\r\n order_items.each do |order_item|\r\n i.push(order_item.item.price)\r\n end\r\n total -= i.min\r\n end\r\n end\r\n return total\r\n end",
"def total_discounted_price\n # convert to array so it doesn't try to do sum on database directly\n line_items.to_a.sum(&:total_discounted_price)\n end",
"def calculate_product_total(items_bought)\n result = items_bought * @price\n if @discount\n result -= @discount.apply(self, items_bought)\n end\n result \n end",
"def apply_discount_on_total(total_amount)\n return total_amount if total_amount < 100\n\n discount_amount = (total_amount.to_i / 100) * EACH_HUNDRED_DOLLAR\n total_amount - discount_amount\n end",
"def checkout(cart, coupons)\n #call the consolidate to get the count item first\n hash_cart = consolidate_cart(cart)\n #apply coupon to the new cart\n applied_coupons= apply_coupons(hash_cart, coupons)\n #apply clearance after discount from coupon\n applied_discount= apply_clearance(applied_coupons)\n\ntotal = applied_discount.reduce(0){ |acc,(key, value)| acc+= value[:price]*value[:count]}\n total >= 100 ? total * 0.9 : total\n end",
"def big_spender_discount(cart:[])\n cart_total = cart.reduce(0.0) { |total, (item, info)| total += info[:price] * info[:count] }\n cart_total > 100 ? cart_total -= cart_total * 0.1 : cart_total\nend",
"def total\n conv_price_single * conv_quantity\n end",
"def get_total\n counts = convert_to_hash(@item_list)\n uniq_items = @item_list.uniq\n\n final = (@total - @sale.apply(uniq_items, counts)).round(2) # Used round for precision\n puts get_invoice + final.to_s\n final\n end",
"def discount_amount\n return 0.0 if @code.blank?\n\n if applicable?\n options = all_coupons[@code.to_s]\n if options[2] == :fixed\n options[1]\n elsif options[2] == :percent\n (@order_or_cart.total_product_amount * options[1]) / 100.0\n end\n else\n 0.0\n end\n end",
"def apply_discount\n initialize_discount_rules\n bill = Bill.new(1,110,Time.now(),'NEWUSER',1, 1)\n bill.amount = get_discounted_value(bill)\n ## some other code\n end",
"def discount\n return 0 unless product.price and product.price != 0\n (100 - (price/product.price)*100).round(0)\n end",
"def get_discount\n if @discount\n @discount.amountOff ? '$'+ @discount.amountOff.to_s : @discount.percentOff.to_s + '%'\n else\n 'N/A'\n end\n end",
"def subtotal\n fees = [ticket_fees_in_cents].sum\n\n discounted_total + fees\n end",
"def final_price\n (self.price*(1 - self.discount.to_f / 100)).to_i\n end",
"def update_discounted_price\n self.price = product.price * (100-discount)/100 \n end",
"def discountable_item_total\n tot = 0\n self.line_items.each do |li|\n tot += li.total if li.product.taxons.any? {|t| t.name == \"Discountable\"}\n end\n self.item_total = tot\n end",
"def update_totals\n\n\t\tset_sale\n\n\t\[email protected] = 0\n\n\t\tfor line_item in @sale.items\n\t\t\[email protected] += line_item.total_price\n\t\tend\n\n\t\ttotal_amount = @sale.amount\n\n\t\tif @sale.discount.blank?\n\t\t\[email protected]_amount = total_amount\n\t\telse\n\t\t\tdiscount_amount = total_amount * @sale.discount\n\t\t\[email protected]_amount = total_amount - discount_amount\n\t\tend\n\n\t\[email protected]\n\tend",
"def total_with_coupon\n \"€#{object.order_items.sum(&:subtotal)}\"\n end",
"def obvious_total(subtotal:, tax:, discount:)\r\n subtotal + tax - discount\r\nend",
"def balance_owed\n discounted_price - amount_paid\n end",
"def total\n @total ||= ((shipping_amount * subtotal).to_f/100) + subtotal + promotion_amount.to_i\n end",
"def calculate_total\n self.total = total_money(total_gross)\n end",
"def price\n return base_price - quantity_discount + shipping\nend",
"def calculate_total\n\t\t@total_items.each do |element|\n\t\t\tif element.class==Apples\n\t\t\t\t@apple_count=@apple_count+1\n\t\t\t\tif @apple_count==2\n\t\t\t\t\t@apple_count=0\n\t\t\t\t\t@apple_discounts = @apple_discounts+1\n\t\t\t\telse\n\t\t\t\t\t@total = @total + element.price\n\t\t\t\tend\n\n\t\t\telsif ((@today.wday==6 || @today.wday==0) && element.class==Watermelons)\n\t\t\t\t@total = @total + (element.price*0.9) #10% on watermelons on weekends\n\t\t\t\t@weekendWatermelon = true\n\t\t\t\t\n\t\t\telse\n\t\t\t@total = @total + element.price\n\t\t\tend\n\n\n\t\tend\n\n\t\t#Checks for Weekend Watermelon discount applied\n\t\tif @weekendWatermelon\n\t\t\tputs \"10% discount on Watermelons on weekends!\"\n\t\tend\n\n\t\t#Count number of 2x1's applied\n\t\tif (discountApple)>0\n\t\t\tputs \"Congratulations! You received #{@apple_discounts} 2x1's on apples and saved #{@apple_discounts*10} euros!\"\n\t\tend\n\t\t#Check for 10 euro discount\n\t\tif (discount100(@total))\n\t\t\t@total = @total-10\n\t\t\tputs \"Congratulations! You received a 10 euro discount for buying more than 100 euros worth of fruit!\"\n\t\tend\n\n\t\t#Check for 5% discount\n\t\tif (discount5)\n\t\t\t@total = @total*0.95\n\t\t\tputs \"Congratulations! You received a 5% discount for buying more than 5 items!\"\n\t\tend\n\t\treturn @total\n\tend",
"def coupDiscounts\n\t\t@new_cart.each do |item, details|\n\t\t\tcase\n\t\t\t\twhen item == \"CHEESE\" && details[:coups] == 1 && details[:count] > 2\n\t\t\t\t\tdetails[:cost] = (((details[:count] / 3) * 15) + ((details[:count] % 3) * details[:price]))\n\t\t\t\twhen item == \"AVOCADO\" && details[:coups] == 1 && details[:count] > 1\n\t\t\t\t\tdetails[:cost] = (((details[:count] / 2) * 5) + ((details[:count] % 2) * details[:price]))\n\t\t\t\twhen item == \"BEER\" && details[:coups] == 1 && details[:count] > 1\n\t\t\t\t\tdetails[:cost] = (((details[:count] / 2) * 20) + ((details[:count] % 2) * details[:price]))\n\t\t\t\tend\t\t\t\t\n\t\tend\n\tend",
"def discount_amount\n $tracer.trace(format_method(__method__))\n tt = ToolTag.new(@tag.find(\"td\")[2], format_method(__method__))\n return tt.inner_text\n end",
"def add_total_discount(name, discount, threshold)\n total_discounts << TotalDiscount.new(name, discount, threshold)\n end",
"def current_subtotal\n debt_claim_items.reject(&:marked_for_destruction?).sum(&:current_debt)\n end",
"def adjusted_total\n total = unadjusted_total\n \n for adjustment in adjustments\n total += adjustment.amount\n end\n \n total\n end",
"def total_revenue_after_discounts\n total_revenue.first.to_f - total_discount.to_f\n end",
"def total\n Money.new(self.expense_entries.sum('unit_cost_pence * qty'))\n end",
"def dollar_total\n total / 100.0\n end",
"def total\n apply_rules(subtotal).round\n end",
"def perform\n invoice.update!(discount: discount, relief: (invoice.try(:amount_due) - discount))\n coupon.increment!(:times_redeemed, 1)\n end",
"def total_calcium\n food.calcium * quantity\n end",
"def discount(discount_percent)\n # debugger\n discount = discount_percent / 100.00\n @price = @price - (@price * discount)\n end",
"def total_goods(discount_goods)\n #total_info = Hash.new\n total_info = {'total_cost'=>0,'total_discount'=>0}\n discount_goods.each do |item|\n total_info['total_cost'] += item['total_price']\n total_info['total_discount'] += item['discount']\n end\n total_info\n end",
"def effective_total\n total = effective_total_money\n \"#{total.currency} #{total.format}\"\n end",
"def predict_price_after_discounts!\n m_discounts = []\n f = build_discount_items :fixed_amount\n m_discounts += f\n \n self.price_after_fixed_discounts = (self.price * self.qty).to_i + m_discounts.each {|discount| discount.price_extend }.sum(&:price_extend).to_i\n\n p = build_discount_items :percentage\n m_discounts += p\n \n self.price_after_all_discounts = (self.price * self.qty).to_i + m_discounts.each {|discount| discount.price_extend }.sum(&:price_extend).to_i\n \n if self.price_after_all_discounts < 0\n discount_amount = self.price_after_all_discounts * -1\n discount_sku = Product.find_by_name(\"Discount\").sku\n discount_attributes = {:product_sku => discount_sku, :qty => 1, \n :currency_used => \"BTC\", \n :price => discount_amount, :price_extend => discount_amount,\n :description => \"Discount to prevent line_item from less than zero condition\" }\n \n self.discounts.create(discount_attributes)\n end\n \n [self.price_after_all_discounts, m_discounts]\n end",
"def calculate\n @item_list.each { |item|\n tax_rate = (item.exempt? ? 0.00 : Constants::NON_IMPORT_TAX_RATE) + (item.imported? ? Constants::IMPORT_TAX_RATE : 0.00)\n total_before_tax = item.qty * item.price\n tax = (total_before_tax * tax_rate).round_to_05\n\n @receipt_tax += tax\n @receipt_total += item.total = total_before_tax + tax\n }\n\n # do final rounding - needed due to Float quirks\n @receipt_tax = @receipt_tax.round(2)\n @receipt_total = @receipt_total.round(2)\n return self\n end",
"def update_totals\n # update_adjustments\n self.payment_total = payments.completed.map(&:amount).sum\n self.item_total = line_items.map(&:amount).sum\n \n self.adjustment_total = adjustments.eligible.map(&:amount).sum\n self.total = item_total + adjustment_total + gift_packaging_total\n end",
"def apply_discount\r\n if subscription_discount_id_changed?\r\n subscription_plan.discount = discount\r\n self.amount = subscription_plan.amount\r\n end\r\n end",
"def conv_discount\n ((self.respond_to?(:discount) && discount) || 0).to_r\n end",
"def promo_total\n 0.0\n end",
"def test_total_merchant_discount\n\t\tputs \"--Running the test to fetch total discount from a merchant--\\n\"\n\t\tMerchant.create(@@merchant_details['name'], @@merchant_details['email'], @@merchant_details['discount'])\n\t\tupdated_discount = 3\n\t\tMerchant.update_discount(@@merchant_details['name'], updated_discount)\n\t\tquery = \"select total_discount from merchant where name=\\\"#{@@merchant_details['name']}\\\";\"\n\t\tresult = EntityHelper.execute_command(query)\n\t\tassert_equal(result[0][0], 4.5)\n\tend",
"def get_additional_cost_totals\n pos_cost = 0.0 # init result\n neg_cost = 0.0 # init result\n AppParameterCustomizations.get_receipt_costs().each do |c|\n if c[:value] > 0\n pos_cost += c[:value].to_f / 100.0\n elsif self.price >= 78.19\n neg_cost += c[:value].to_f / 100.0 unless self.patient.is_a_firm?\n end\n end\n return { :negative => neg_cost, :positive => pos_cost }\n end",
"def calc_total\n (@total_after_tax * @gratuity) + @total_after_tax\n end",
"def total\n total = 0\n self.menu_items.each do |item|\n total += item.price\n end\n \"$#{total}\"\n end",
"def total_trans\n food.trans * quantity\n end",
"def discount\n\t\[email protected] do |code, quantity|\n\t\t\tif code == :SR1 && quantity >= 3\n\t\t\t\t@discount = 4.50\n\t\t\t\tputs \"your strawberry has been reduced of 4.50\"\n\t\t\tend\n\n\t\t\tif code == :GR1 && quantity >=2\n\t\t\t\t@discount = @pricing_rules[code]\n\t\t\t\tputs \"Buy one green tea get one free!\"\n\t\t\tend\n\t\tend\n\t\tapply_discount\n\tend",
"def cumulative_total_after_tax\n amount = 0.0\n @products_in_cart.each do |product|\n amount += product.total\n end#each\n return amount\nend",
"def total_debt\n self.amount\n end",
"def discount\n params['discount']\n end",
"def total_discounts\n ipod = @items.index { |x| x.product.name == 'iPod' && x.quantity >= 2 }\n imac = @items.index { |x| x.product.name == 'iMac' }\n if ipod && imac\n # discount applies\n iphone = @items.index { |x| x.product.name == 'iPhone 4' }\n total_discount = @items[iphone].quantity * (@items[iphone].product.price - @items[iphone].product.discounted) if iphone \n end\n total_discount ||= 0\n end",
"def ticket_discount(user, paid: false)\n ticket_purchases.by_user(user).where(paid: paid).sum{ |tp| (tp.discount_value || 0) + (tp.discount_percent || 0) }\n end",
"def total_amount\n \t amount = 0\n \t operation_items.each do | oi |\n \t\tamount = amount + oi.amount\n end\n amount\n end",
"def remaining_total\n total\n end",
"def charge\n subtotal * 0\n end"
] | [
"0.8136538",
"0.80670786",
"0.80542064",
"0.79802155",
"0.7979578",
"0.79795504",
"0.7958708",
"0.79484594",
"0.7940084",
"0.7886445",
"0.78285795",
"0.77942383",
"0.77931917",
"0.77696216",
"0.7764497",
"0.7706728",
"0.76481175",
"0.763304",
"0.759868",
"0.7479528",
"0.74374646",
"0.74036247",
"0.7339792",
"0.73365426",
"0.73271143",
"0.732602",
"0.7305839",
"0.73018354",
"0.7262125",
"0.7259481",
"0.72548693",
"0.7231952",
"0.7216788",
"0.72161394",
"0.72027683",
"0.71539414",
"0.71175617",
"0.70919037",
"0.7068965",
"0.7045193",
"0.7021254",
"0.6983532",
"0.6979781",
"0.6973197",
"0.69499177",
"0.6922032",
"0.68856615",
"0.6851718",
"0.68483746",
"0.6845129",
"0.68209934",
"0.6815546",
"0.6810173",
"0.67910016",
"0.67857563",
"0.6781293",
"0.67660046",
"0.67492294",
"0.67093",
"0.6701352",
"0.6696423",
"0.66725516",
"0.6666826",
"0.66667616",
"0.66652733",
"0.6640418",
"0.66171736",
"0.6611438",
"0.66049206",
"0.6604449",
"0.6603373",
"0.6598481",
"0.6594597",
"0.6591846",
"0.6588792",
"0.6576592",
"0.6571825",
"0.65700656",
"0.6569876",
"0.65631807",
"0.65623176",
"0.6557355",
"0.6551652",
"0.6534989",
"0.65342265",
"0.65303737",
"0.6528017",
"0.6526932",
"0.6525669",
"0.651291",
"0.6501703",
"0.6500276",
"0.64866096",
"0.64697874",
"0.64695895",
"0.64674306",
"0.64668363",
"0.6462192",
"0.64606667",
"0.64548993"
] | 0.79163975 | 9 |
returns array w/ all added items | def items
@items
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_items\r\n list = Array.new\r\n items.each{ |item| list.push(item)}\r\n list\r\n end",
"def get_items\r\n @arr.to_a\r\n end",
"def make_item_list\n @data = $game_party.all_items.select {|item| include?(item)}\n @data.push(nil) if include?(nil)\n end",
"def items\n result = []\n each_item { |item| result.push(item) }\n result\n end",
"def append_all(items)\n items.each { |item| append(item) }\n end",
"def items; @items.clone end",
"def to_a\n items.deep_dup\n end",
"def additions\n Array(@gapi.additions).map { |gapi| Record.from_gapi gapi }\n end",
"def items\n @items ||= []\n end",
"def processed_items\n @processed.to_a\n end",
"def get_items\n\t\t@arr\n\tend",
"def added(array)\nend",
"def all_items\n all_items = []\n collections.each do |c|\n c.items.each do |i|\n all_items.push i\n end\n end\n all_items\n end",
"def add_item(new_item)\n grocery_list.push(new_item)\n return grocery_list \nend",
"def to_a\n a = []\n while (item = self.next)\n a << item.item\n end\n a\n end",
"def add_item(elective_array, item)\n elective_array.push(item)\n puts elective_array\nend",
"def to_a\n result = []\n self.each do |item|\n result << item\n end\n return result\n end",
"def items\n res = []\n each_element('item') { |item|\n res << item\n }\n res\n end",
"def to_ary\n entries\n end",
"def entries\n return Array(@entries)\n end",
"def mappend\n result = []\n self.each { |a| b = yield(a); b.each { |c| result << c } if b }\n result\n end",
"def all_item_ids\n [id] + item_ids\n end",
"def to_ary\n [ self ]\n end",
"def append(array,input)\n array << input\n return array\nend",
"def push *items\n @items.concat items\n end",
"def addins\n @addins ||= []\n end",
"def added\n @added ||= {}\n end",
"def << item\n @items << item\n end",
"def items\n lineitems.each_with_object([]) {|lineitem,arr| arr << lineitem.item}\n end",
"def add_item item\n @items << item\n @@all_items << item\n end",
"def storage_all_items\n storage_items + storage_equip_items\n end",
"def items\n items = []\n iter = @obj.items\n\n while (i = iter.next)\n items << i\n end\n\n items\n end",
"def add_item(item)\r\n \[email protected](item)\r\n end",
"def add_ins\n return @add_ins\n end",
"def all_items\n @allitems ||= syncitems :lastsync => \"1970-01-01 00:00:00\"\n end",
"def items\n items, iter = [], @obj.items\n while (i = iter.next) do\n items << i\n end\n items\n end",
"def fetch_entries\n entries.inject([]){ |all, entry| all << entry << addendas[entry] }.flatten.compact\n end",
"def to_a\n a = []\n each { |item|\n a.push(item)\n }\n a\n end",
"def items\n return @items\n end",
"def aggregate\n []\n end",
"def add_ingredients(ingredient_arr)\n ingredient_arr.each do |ingredient|\n @ingredients << ingredient\n end\n @ingredients\n end",
"def items\n @items ||= line_items.to_a\n end",
"def add_to_array(array, item)\n array << item\nend",
"def all_items\n # retzrb => [ \"item23\", \"item42\", \"item17\", (...) ]\n raise \"implemented in subclass\"\n end",
"def add_item(array, item)\n\tarray << item\nend",
"def to_a\n items = []\n @stock.each do |code, item|\n items.push(item.to_a)\n end\n items\n end",
"def additions()\n return @additions\n end",
"def all\n end_time = (Time.now - (30 * 60 * 60 * 24)).to_i\n all_items = Array.new\n cur_items = self\n begin\n all_items += cur_items.items\n cur_items = cur_items.next(:count => 200, :start_time => end_time)\n end until cur_items.nil?\n all_items\n end",
"def add_item(array, item)\n\tarray.push(item)\nend",
"def all\n @items.values.flatten\n end",
"def to_a\n [ self ]\n end",
"def songs \n Song.all.select{|song| add_song(song)}.to_a\n # binding.pry\n end",
"def entries\n @entries ||= each_entry.to_a\n end",
"def added_pairs\n return @added_pairs\n end",
"def feed_items\n []\n end",
"def add_to_array(array, item)\n\tarray += [item]\n\tp array\nend",
"def to_a\n [self]\n end",
"def to_ary\n resolve\n @items\n end",
"def to_a\n resolve\n @items\n end",
"def all\n @items\n end",
"def items\n return @items\n end",
"def items\n return @items\n end",
"def clone_list_to_array\n clone = Array.new\n self.items.each do |item| \n result.push(item.get_clone())\n end\n return clone\n end",
"def items_to_obj\n item_basket = []\n @items.each do |id, nbr|\n nbr.times do |i|\n item_basket << $data_items[id]\n end\n end\n item_basket\n end",
"def all_expense_items\n owing_expense_items + paid_expense_items\n end",
"def to_a\n [ self ]\n end",
"def _payplug_build_items\n cart_obj = self\n method_name = Payplug.item_klass.to_s.underscore.pluralize # getting line_items from LineItem\n original_items = cart_obj.send(method_name) # @cart.line_items\n extended_items = original_items.map{|i| i.extend(Payplug::Item) } # extend each item with Payplug::Item\n extended_items\n end",
"def end_push\n ## empty\n return [[], []]\n end",
"def perform\n entries.each do |entry|\n @items << generate_item(entry)\n end\n add_ids\n end",
"def items\n @total_items.flatten\n end",
"def buyable_items(_entity)\n []\n end",
"def all\n return @recipearray\n end",
"def to_a\n [self]\n end",
"def items\n self.purchases.map { |purchase| purchase.item }\n\n # items = []\n # purchases.each do |purchase|\n # items << purchase.item\n # end\n # items\n end",
"def allItems\n\n self.mapping = {\n\t\t\t\t\"@heading\"=>\"name\",\n\t\t\t\t\"@subHeading\"=>\"email\"\n\t\t\t}\n\n return [\n { 'name'=>\"jimmy hands\", 'email'=> \"[email protected]\" },\n ];\n end",
"def add_to_back(item)\n @array << item\n end",
"def items\n to_return = []\n @items.each do |item_data|\n item_data[:quantity].times do\n to_return << item_data[:title]\n end\n end\n return to_return\n end",
"def add_to_array!(array, item)\n array << item\nend",
"def all\n []\n end",
"def get_items\n\t\treturn @list\n\tend",
"def assignation_array() \n array = []\n \n count = self.assignation_count()\n #puts \"COUNT: #{count}\".yellow.on_black\n for i in 0..(count-1)\n #puts \"ADD element\".yellow.on_black\n array << self.assignation(i)\n end\n \n array\n end",
"def add_value(item)\n array.push(item)\n end",
"def\tcollect\n\t\ta = []\n\t\tself.each{|v| a << v}\n\t\ta\n\tend",
"def get_list\n \t@items\n end",
"def add(item)\n #push item into the array\n @array << item\n view\n end",
"def to_ary\n\t []\n\tend",
"def add_and_return_array(data)\n # Create new array\n days = []\n # Loop through dates\n (1.week.ago.to_date..Date.today).each do |date|\n # Set datetime to beginning of day\n date = date.midnight\n # Push to hash into array\n days << { m: date, a: data[date] }\n end\n # return days as array\n days\n end",
"def to_array\n array = []\n self.each { |x| array.push x }\n return array\n end",
"def entries; end",
"def entries; end",
"def entries; end",
"def entries; end",
"def atomic_array_add_to_sets\n @atomic_array_add_to_sets ||= {}\n end",
"def to_a\n x = []\n self.each do |it|\n x << it\n end\n x\n end",
"def to_a\n each.to_a\n end",
"def to_a\n each.to_a\n end",
"def in_memory\n []\n end",
"def batch_badge_creator(attendee)\n # the below code would work more effectively but since I found it somewhere else I decided to use another method to prove to myself I could do it on my own. Since the collect method saves the results automatically to a new array, it doesnt require the extra step I needed to do with the .each method.\n # attendee.collect do |i|\n # badge_maker(i)\n # end\n\n badges =[]\n attendee.each {|i| badges.push badge_maker(i)}\n return badges\nend",
"def items\n if @items.nil?\n raise NoData.new(\"No data has been retrieved yet.\", self)\n else\n @items.collect do |hsh|\n item = self.class.item_class.new\n item.store_result(:attrs => hsh)\n item\n end\n end\n end",
"def added; status[:added] || []; end",
"def to_a\n Array(each)\n end"
] | [
"0.70425993",
"0.6816972",
"0.6651816",
"0.65886414",
"0.6553055",
"0.6532963",
"0.6430804",
"0.6429881",
"0.6422382",
"0.6417038",
"0.64005536",
"0.6303324",
"0.6296054",
"0.62805456",
"0.6274694",
"0.6268957",
"0.62522864",
"0.6240065",
"0.6224634",
"0.62211615",
"0.62089777",
"0.620592",
"0.61887527",
"0.6185936",
"0.6183907",
"0.6172591",
"0.61701494",
"0.6164224",
"0.61583024",
"0.6152772",
"0.614538",
"0.6119026",
"0.6118168",
"0.6105239",
"0.6103829",
"0.61013395",
"0.6074742",
"0.60720074",
"0.60598624",
"0.6055921",
"0.6054867",
"0.60517603",
"0.6048236",
"0.60416484",
"0.60369474",
"0.6035551",
"0.60247326",
"0.6024705",
"0.601791",
"0.59931916",
"0.59899354",
"0.5975417",
"0.5971801",
"0.59693664",
"0.59583616",
"0.594932",
"0.5945995",
"0.59449375",
"0.5941622",
"0.59413373",
"0.5937409",
"0.5937409",
"0.59138095",
"0.59111226",
"0.59057915",
"0.5900861",
"0.5895579",
"0.58911186",
"0.589044",
"0.58889025",
"0.587924",
"0.5868395",
"0.58588314",
"0.5854774",
"0.58447003",
"0.5843893",
"0.5838118",
"0.5837757",
"0.5828781",
"0.5825381",
"0.58210135",
"0.5816546",
"0.58143836",
"0.5814195",
"0.5802745",
"0.57973796",
"0.5797116",
"0.5783332",
"0.5781293",
"0.5781293",
"0.5781293",
"0.5781293",
"0.5775554",
"0.57726043",
"0.57512945",
"0.57512945",
"0.57464063",
"0.57460415",
"0.5742525",
"0.5739898",
"0.5739703"
] | 0.0 | -1 |
updates total with items voided also updates items array with the last added removed | def void_last_transaction
@items.slice!(@items.length-@last_qty, @items.length)
@total -= @last_transaction.values[0]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def item_total\n tot = 0\n self.line_items.each do |li|\n tot += li.total\n end\n self.item_total = tot\n end",
"def update_total\n self.total = self.line_items.reload.map(&:total).inject(:+).to_f\n end",
"def update(items)\n # clear!\n self.items.each do |i|\n number = items[i.id].blank? ? 1 : items[i.id].to_i <= 0 ? 1 : items[i.id]\n number.to_i < 99 ? i.quantity = number.to_i : i.quantity=99\n end\n # items.each { |id, quantity| add_items(id, quantity) }\n end",
"def update_total\n # Group our items by their name\n grouped_items = @current_items.group_by {|item| item.name }\n\n # Create a variable that we can use to store all of our total prices for each group of items\n grouped_prices = []\n \n # Iterate over each item group and pass each group to calculate_group_by, then store each group total price in grouped_totals \n grouped_items.each_key do |item_group|\n # Calculate our group total and store \n group_total = self.calculate_group_total(grouped_items[item_group]) \n\n # Add to our grouped item prices array\n grouped_prices << group_total \n end unless @current_items.count == 0 # Ensure that we don't iterate over an empty array\n\n # Sum all group item prices\n new_total = grouped_prices.sum\n\n # If the new total is greater than 150 subtract 20 \n new_total = new_total - 20 unless new_total <= 150 \n\n # Update total price\n @total_price = new_total \n end",
"def total_items\r\n\t\[email protected](0) { |sum, i| sum + i.quantity }\r\n\tend",
"def update_total\n self.total = self.shipments.map(&:item_cost).sum\n end",
"def update_totals\n # update_adjustments\n self.payment_total = payments.completed.map(&:amount).sum\n self.item_total = line_items.map(&:amount).sum\n \n self.adjustment_total = adjustments.eligible.map(&:amount).sum\n self.total = item_total + adjustment_total + gift_packaging_total\n end",
"def update_totals\n # update_adjustments\n self.payment_total = payments.completed.map(&:amount).sum\n self.item_total = line_items.map(&:amount).sum\n self.adjustment_total = adjustments.eligible.map(&:amount).sum\n self.total = item_total + adjustment_total\n end",
"def item_total\n line_items.map(&:total).reduce(:+)\n end",
"def total\n @total = 0\n @ordered_items.each do |item|\n @total += item[1]\n end\n return @total\n end",
"def total\n @items_total = []\n self.line_items.each do |item|\n @item = Item.find_by_id(item.item_id)\n @items_total << @item.price.to_f\n end\n cart_total = @items_total.inject(0){|sum, x| sum + x }\n @cart_total = cart_total.round(2)\n @cart_total\n end",
"def total_items\n order_items.inject(0) { |t,i| t + i.quantity }\n end",
"def update_totals\n # update_adjustments\n self.payment_total = payments.completed.map(&:amount).sum\n \n self.item_total = order_items.map(&:amount).sum\n self.billing_total = order_items.map(&:cost).sum\n self.customer_total = item_total\n self.full_total = order_items.map(&:full).sum\n end",
"def total_items\n order_items.inject(0) { |t, i| t + i.quantity }\n end",
"def total_items\n order_items.inject(0) { |t, i| t + i.quantity }\n end",
"def total_items\n @cart_items.sum{|k,v| v}\n end",
"def total_items\n\t\tline_items.sum(:quantity)\n\tend",
"def product_total\n\t\ttotal = 0\n\t\tself.items.each do |item|\n\t\t\ttotal += item.amount\n\t\tend\n\t\ttotal\n\tend",
"def update_totals\n update_payment_total\n update_item_total\n update_order_total\n end",
"def cat_update_item_count\n self.categories.each do |category|\n if (category.displayed_items.count - 1) == category.item_count\n category.inc_item_count\n end\n if (category.displayed_items.count + 1) == category.item_count\n category.dec_item_count\n end\n end\n end",
"def inventory_without_hiting_the_database\n variants.inject(0) {|total, variant| total += variant.inventory}\n end",
"def update_totals\n update_payment_total\n update_item_total\n update_shipment_total\n update_adjustment_total\n end",
"def total\n return (@listOfItem.inject(0){|sum,e| sum += e.total}).round_to(2)\n end",
"def update_amounts\n @items = @items.each do |item|\n item[:good_tax] = set_tax(item[:good], item[:total], @good_tax_rate)\n item[:import_tax] = set_tax(item[:import], item[:total], @import_tax_rate)\n item[:sales_tax] = add_taxes(item[:sales_tax], item[:good_tax], item[:import_tax])\n item[:total] = add_taxes(item[:total], item[:good_tax], item[:import_tax])\n end\n end",
"def total_items\n line_items.sum(:quantity)\n end",
"def total_items\n line_items.sum(:quantity)\n end",
"def total_item\n @items.reject {|item| item.quantity == 0}\n invoice_total = @items.sum {|item| item.sale_price * item.quantity}\n\n end",
"def consolidate_cart(cart)\n updated_cart = []\n i = 0\n while i < cart.length do\n updated_cart_item = find_item_by_name_in_collection(cart[i][:item], updated_cart)\n if updated_cart_item #if it does have a value\n updated_cart_item[:count] += 1\n else\n updated_cart_item = {\n :item => cart[i][:item],\n :price => cart[i][:price],\n :clearance => cart[i][:clearance],\n :count => 1\n }\n updated_cart << updated_cart_item\n end\n i += 1\n end\n updated_cart\nend",
"def get_total_qty\n return self.items.sum(:qty)\n end",
"def refill(items = {})\n validate_refill(items)\n items.each do |key, value|\n return unless value.to_f && @inventory[key.to_s]\n\n new_value = @inventory[key.to_s] + value.to_f\n @inventory[key.to_s] += value.to_f\n end\n end",
"def update_podcasts\n unless podcast_ids.nil?\n self.allocations.clear\n podcast_ids.each do |p|\n self.allocations.create(:podcast_id => p, :amount_cents=> self.amount_cents/podcast_ids.length) unless p.blank?\n end\n #apply remainder\n if ((remainder = self.amount_cents%podcast_ids.length) != 0 )\n self.allocations.each do |a|\n a.amount_cents+=1 if remainder > 0\n remainder = remainder -1\n a.save\n \n end\n end\n reload\n self.podcast_ids = nil\n end\n end",
"def update_qty(item_list, item, qty)\r\n item_list[item] = qty\r\n item_list\r\nend",
"def update_counts response\n self.sess_items += response.num_items\n end",
"def update_quantity(list,item,item_count)\n\tlist[item] = item_count\nend",
"def subtotal\n return items.inject(0) {|total, item| total + item.subtotal}\n end",
"def total\n @total = items.inject(0.0) { |sum, order_line_item| sum + order_line_item.subtotal }\n end",
"def update_subtotal_items!\n subtotal = @customer_order.order_items.collect do |order_item|\n order_item.cache_provider_item_precio!\n order_item.subtotal\n end.sum\n @customer_order.assign_attributes(\n subtotal_items: subtotal\n )\n end",
"def recalculate!\n attributes = { price: 0, item_count: 0 }\n self.order_items(true).map do |order_item|\n attributes[:price] += order_item.price * order_item.quantity\n attributes[:item_count] += order_item.quantity\n end\n update attributes\n end",
"def reset\n self.total = 0\n self.menu_items.each do |item|\n item.add_to_prepped\n item.save\n end\n self.menu_items.clear\n end",
"def update_totals\n\n\t\tset_sale\n\n\t\[email protected] = 0\n\n\t\tfor line_item in @sale.items\n\t\t\[email protected] += line_item.total_price\n\t\tend\n\n\t\ttotal_amount = @sale.amount\n\n\t\tif @sale.discount.blank?\n\t\t\[email protected]_amount = total_amount\n\t\telse\n\t\t\tdiscount_amount = total_amount * @sale.discount\n\t\t\[email protected]_amount = total_amount - discount_amount\n\t\tend\n\n\t\[email protected]\n\tend",
"def update_quality(items)\n items.each do |item|\n if is_special_item?(item)\n special_item(item)\n else\n item.sell_in > 0 ? decrement_normal_item(item, 1) : decrement_normal_item(item, 2)\n end\n\n item.sell_in -= 1\n end\nend",
"def line_items_total\n\t\ttotal = 0\n\t\tfor item in self.order_line_items\n\t\t\ttotal += item.total\n\t\tend\n\t\treturn total\n\tend",
"def update_counts_and_value!\n entries = inventory_entries.reload\n total_on_hand = entries.sum(:on_hand)\n total_reserved = entries.sum(:reserved)\n total_pending = entries.sum(:pending)\n weighted_total_cents = entries.map { |e| e.on_hand * e.value_cents }.sum\n\n update_columns(\n on_hand: total_on_hand,\n reserved: total_reserved,\n pending: total_pending,\n value_cents: total_on_hand == 0 ? nil : weighted_total_cents / total_on_hand\n )\n end",
"def total\n total = 0\n line_items.each do |line_item|\n total += line_item.item.price * line_item.quantity\n end\n total\n end",
"def items_value_calc(items)\n value = 0\n\n items.each do |item|\n value += item[:value]\n end\n\n value\n end",
"def update_category_item_count\n Rails.logger.debug \"Item saved, updating categories#item_count...\"\n self.categories.each do |category|\n if (category.displayed_items.count - 1) == category.item_count\n category.increment_item_count\n elsif (category.displayed_items.count + 1) == category.item_count\n category.decrement_item_count\n end\n end\n end",
"def update_inventory\n self.order_items.each { |item| item.variant.add_pending_to_customer }\n end",
"def update_quan(older_list, item, quantity)\r\n older_list[item] = quantity\r\n return older_list \r\nend",
"def add_items(grocery_list, item, quantity)\n if grocery_list.include? item\n grocery_list[item] += quantity\n else\n grocery_list[item] = quantity\n end\n grocery_list\nend",
"def add_items(grocery_list, item, quantity)\n if grocery_list.include? item\n grocery_list[item] += quantity\n else\n grocery_list[item] = quantity\n end\n grocery_list\nend",
"def update_hunt\n @total_rubies += @rubies_found\n @total_fake_rubies += @fake_rubies_found\n @total_days += 1\n end",
"def update_usage(served_quantity) \n self.used_quantity += served_quantity \n self.save \n \n self.mark_as_finished\n \n item = self.item \n item.deduct_ready_quantity(served_quantity ) \n \n return self \n end",
"def update_usage(served_quantity) \n self.used_quantity += served_quantity \n self.save \n \n self.mark_as_finished\n \n item = self.item \n item.deduct_ready_quantity(served_quantity ) \n \n return self \n end",
"def update_quant(current_list, item, quantity)\n current_list[item] = quantity\n current_list\nend",
"def items_count\n counter = 0\n self.line_items.each do |item|\n counter += item.quantity\n end\n counter\n end",
"def items_sub_total\n order_items.inject(BigDecimal(0)) { |t, i| t + i.sub_total }\n end",
"def items_sub_total\n order_items.inject(BigDecimal(0)) { |t, i| t + i.sub_total }\n end",
"def update_qty(shopping_list, item, quantity)\r\n\r\n\tadd_item(shopping_list, item, quantity)\r\n\r\nend",
"def update_total\n self.total = self.note_1 + self.note_2 + self.note_3 + self.note_4 if self.note_1 && self.note_2 && self.note_3 && self.note_4\n end",
"def update_total\n self.total = self.note_1 + self.note_2 + self.note_3 + self.note_4 if self.note_1 && self.note_2 && self.note_3 && self.note_4\n end",
"def total\n cart_value = 0\n self.line_items.each do |line_item|\n cart_value += line_item.value\n end\n cart_value\n end",
"def calculate_invoice_total\n res = [ ]\n self.line_items.each do |item|\n res.push(item.qty * item.price)\n end\n # Return the sum of the items\n self.total = res.inject(:+) \n end",
"def discountable_item_total\n tot = 0\n self.line_items.each do |li|\n tot += li.total if li.product.taxons.any? {|t| t.name == \"Discountable\"}\n end\n self.item_total = tot\n end",
"def update()\r\n\t\tto_remove = []\r\n for i in [email protected]\r\n @units[i].main()\r\n\t\t\tif @units[i].vie <= 0\r\n\t\t\t\tto_remove << @units[i]\r\n\t\t\t\t@units[i].die()\r\n\t\t\tend\r\n end\r\n\t\t@units -= to_remove\r\n end",
"def update(list, item, qty)\n add_item(list, item, qty)\nend",
"def unadjusted_total\n total = Money.new( 0, 'USD' )\n \n for line_item in line_items\n total += ( line_item.price * line_item.quantity )\n end\n \n total\n end",
"def item_total\n @promotion_attributed_line_items.map(&:amount).sum\n end",
"def add_item(item, qty)\n for ele in @order do\n order_item = ele.keys[0]\n if order_item.name == item.name\n ele[order_item] += qty\n return \n end\n end\n @order.push({item => qty})\n \n end",
"def add_item(grocery_list, item, quantity)\n grocery_list = grocery_list.each {|item,quantity|}\n if grocery_list.has_key?(item)\n grocery_list[item] += quantity\n else\n grocery_list[item] = quantity\n end\nend",
"def consolidate_cart(cart)\n new_cart = []\ncart.each do |grocery_item|\n current_item = find_item_by_name_in_collection(grocery_item[:item],new_cart)\n if current_item\n new_cart.each do |new_cart_item|\n if new_cart_item[:item] == current_item[:item]\n new_cart_item[:count]+=1 \n end\n end\n else\n grocery_item[:count] = 1 \n new_cart << grocery_item\nend\nend\nnew_cart\nend",
"def cart_total_qty\n total = 0\n params[:items].each do |item|\n if variant = Variant.find_by(id: item[:variant_id])\n total += item[:quantity].to_i\n end\n end\n total\n end",
"def update_transaction(shopItems)\n total = 0\n for shopItem in shopItems\n total += shopItem.item.price * shopItem.quantity\n end\n \n @transaction_window.window_update(@buy_window.active, total)\n end",
"def update_shipped!\n update!(shipped: completed_transfer_items.sum(:amount))\n end",
"def total\n total = 0\n self.menu_items.each do |item|\n total += item.price\n end\n \"$#{total}\"\n end",
"def update_qty(grocery_list, item, qty)\n grocery_list[item] = qty\n grocery_list\nend",
"def subtotal\r\n\t\[email protected](0.0) { |sum, i| sum + i.total_unit_price * i.quantity }\r\n\tend",
"def summ\n result = 0.0\n self.propose_items.each do |item|\n result += item.price\n end\n return result\n end",
"def items\n @total_items.flatten\n end",
"def update_quantity_of_item(list,item,quantity)\r\n add_item_to_list(list,item,quantity)\r\n list\r\nend",
"def draw_total_items\n header_r.draw_total_items count: items.size, size: items.inject(0) {|sum, i| sum += i.size}\n end",
"def update_qty!(list, item, qty)\r\n counter = 0\r\n if list.include?(item)\r\n list[item] = qty\r\n else\r\n puts \"Sorry, that item isn't in the list\"\r\n end\r\n list\r\nend",
"def update_total_cost\n TotalAmountArray.clear\n values_hash = self.material_usages.group(\"material_id\").select(\"material_id\").sum(\"quantity\")\n values_hash.each do |id, total_units|\n TotalAmountArray << Material.find(id).average_cost_per_unit * total_units\n end\n total_cost = self.service_procurements.sum(:cost) + TotalAmountArray.sum + self.wages.sum(:cost)\n self.update_attributes(:actual_cost => total_cost)\n end",
"def update_it(new_list, item, amount)\n \n new_list[item] = amount\n \n new_list\nend",
"def subtotal\n items.map(&:price).reduce(&:+)\n end",
"def total_price\n # convert to array so it doesn't try to do sum on database directly\n @total = 0\n line_items.each do |item|\n @total = item.price\n end\n line_items.to_a.sum {|item| (item.quantity * item.price) }\n end",
"def total_life\n items.map(&:life).inject(0) { |sum, current| sum += current }\n end",
"def add_item(current_list, item_added, quantity)\n current_list[item_added] = quantity\n current_list\nend",
"def item_count\n self.line_items.inject(0) { |total, line_item| total + line_item.quantity }\n end",
"def total\n total = order_items.inject(0) { |sum, p| sum + p.subtotal }\n end",
"def add_item(list_items, item_name, item_qty)\n if list_items.include?(item_name)\n list_items[item_name] += item_qty\n else\n list_items[item_name] = item_qty\n end\nend",
"def total_price\n items.map(&:price).sum\n end",
"def set_total\r\n self.total = self.order_items.collect{ |order_item| order_item.valid? ? (order_item.sub_total) : 0 }.sum.to_d\r\n end",
"def subtotal\n @items.sum { |item| item.subtotal }\n end",
"def update_count(glist, item, count)\n\tglist[item] = count\n\treturn glist\nend",
"def total_volume\n quantity * Item.find(item_id).volume\n end",
"def total\n total_invoice_items_price(invoice_items)\n end",
"def increment_units\n contents.each do |key,content|\n id = content[\"_id\"] || content[\"item_id\"]\n begin\n \n product = shop.products.find(id)\n return false if product.nil? || product.dont_track_quantities?\n\n new_pv = []\n\n if product.price_variants.length==1\n\n new_pv = product.price_variants.first\n new_pv['quantity'] = new_pv['quantity'].to_i+content['quantity'].to_i\n product.num_orders = [product.num_orders-content['quantity'].to_i].max\n product.price_variants = [ new_pv ]\n\n else\n\n product.price_variants.each do |pv|\n name = [pv['primary'],pv['secondary']].join(\" \").downcase.trim\n name = \"\" if name==\" \"\n if name==content['variant_name'].trim.downcase && !pv['quantity'].blank?\n new_pv << pv.merge( 'quantity' => (pv['quantity'].to_i+content['quantity'].to_i) )\n else \n new_pv << pv\n end\n end\n product.num_orders = [product.num_orders-content['quantity'].to_i].max\n product.price_variants = new_pv\n\n end\n product.save\n\n rescue Exception => e\n ::Exceptional::Catcher.handle(e)\n # raise(e)\n end\n end\n end",
"def merge_drops_items(items)\n drop_items = []\n for item in items\n if item != nil\n \n victory_item = nil\n drop_items.each() { |vi| victory_item = vi if vi.item.id == item.id }\n \n if victory_item.nil?\n drop_items.push(VictoryItem.new(item, 1))\n else\n victory_item.quantity += 1\n end\n end\n end\n return drop_items\n end",
"def update_quantity(item, list, quantity)\n add_item(item, list, quantity)\nend",
"def total_num_items\n line_items.reduce(0) { |sum, item| sum + item.quantity }\n end"
] | [
"0.6825899",
"0.6741231",
"0.6679843",
"0.66447496",
"0.66257375",
"0.6625242",
"0.6590345",
"0.6522727",
"0.63197327",
"0.6281329",
"0.6275104",
"0.6265877",
"0.6256093",
"0.6254553",
"0.6254553",
"0.60918605",
"0.6070158",
"0.6051017",
"0.60231215",
"0.6017169",
"0.5976218",
"0.597579",
"0.5965022",
"0.59578097",
"0.5948351",
"0.5948351",
"0.5944075",
"0.5932863",
"0.5928627",
"0.592736",
"0.5924017",
"0.59113795",
"0.5904968",
"0.59048766",
"0.59015125",
"0.5866824",
"0.58661026",
"0.5861277",
"0.5851658",
"0.58507484",
"0.58480966",
"0.5836044",
"0.58300805",
"0.5829414",
"0.58293873",
"0.5815257",
"0.5814198",
"0.5808633",
"0.58024967",
"0.58024967",
"0.57669747",
"0.57665473",
"0.57665473",
"0.5766454",
"0.57639897",
"0.5757621",
"0.5757621",
"0.57536757",
"0.57531774",
"0.57531774",
"0.5747952",
"0.5743639",
"0.5738819",
"0.57360697",
"0.57343006",
"0.5716536",
"0.57163686",
"0.5710002",
"0.57098085",
"0.56989056",
"0.5694418",
"0.569011",
"0.5681057",
"0.5680069",
"0.5674684",
"0.56705827",
"0.567031",
"0.5663942",
"0.5659843",
"0.565816",
"0.5647814",
"0.56441706",
"0.56425893",
"0.5633415",
"0.5631163",
"0.5622673",
"0.5622463",
"0.561999",
"0.56186974",
"0.5618377",
"0.5616667",
"0.5615952",
"0.5609827",
"0.5601371",
"0.5600841",
"0.5598148",
"0.55948126",
"0.5594104",
"0.55927306",
"0.5592427"
] | 0.5645086 | 81 |
start ssl connection over existing tcpserver socket | def start(io)
# start SSL negotiation
ssl = OpenSSL::SSL::SSLSocket.new(io, @ssl_context)
# connect to server socket
ssl.accept
# make sure to close also the underlying io
ssl.sync_close = true
# return as new io socket
return ssl
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start(io)\n # start SSL negotiation\n ssl = OpenSSL::SSL::SSLSocket.new(io, @ctx)\n # connect to server socket\n ssl.accept\n # make sure to close also the underlying io\n ssl.sync_close = true\n # return as new io socket\n return ssl\n end",
"def start(io)\n # start SSL negotiation\n ssl = OpenSSL::SSL::SSLSocket.new(io, @ctx)\n # connect to server socket\n ssl.accept\n # make sure to close also the underlying io\n ssl.sync_close = true\n # return as new io socket\n return ssl\n end",
"def init_ssl\n ctx = OpenSSL::SSL::SSLContext.new\n ctx.set_params(verify_mode: OpenSSL::SSL::VERIFY_PEER)\n # We are overwriting the TCP socket with the SSL socket here.\n @socket = OpenSSL::SSL::SSLSocket.new(@socket, ctx)\n @socket.sync_close = true\n @socket.connect\n end",
"def start_tls(plain_socket)\n ssl_socket_class.new(plain_socket, ssl_context).tap do |ssl_socket|\n ssl_socket.sync_close = true\n ssl_socket.connect\n end\n end",
"def start_tls(host, ssl_socket_class, ssl_context); end",
"def connect\n ssl_socket.connect\n handshake.execute!\n end",
"def socket\n connect unless connected?\n @ssl_sock\n end",
"def getSslTcpConnection(host, port)\n store = OpenSSL::X509::Store.new\n store.add_file(OpenSSL::X509::DEFAULT_CERT_FILE)\n sslContext = OpenSSL::SSL::SSLContext.new\n sslContext.cert_store = store\n sslContext.ssl_version = :SSLv23\n sslSocket = OpenSSL::SSL::SSLSocket.new(TCPSocket.new(host, port), sslContext)\n sslSocket.hostname = host #for Server Name Indication (SNI)\n sslSocket.sync_close = true #instead of calling close on tcp socket\n sslSocket.connect\n sslSocket\nend",
"def connect\n socket = TCPSocket.new(@server, @port.to_i)\n if @options[:ssl] == nil\n return socket\n end\n ssl_context = @options[:ssl]\n ssl_context = OpenSSL::SSL::SSLContext.new()\n unless ssl_context.verify_mode\n warn \"warning: peer certificate won't be verified this session.\"\n ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n ssl_socket = OpenSSL::SSL::SSLSocket.new(socket, ssl_context)\n ssl_socket.sync_close = true\n ssl_socket.connect\n return ssl_socket\n end",
"def setup_socket\n ctx = setup_certificate\n\n APN.log(:debug, \"Connecting to #{@host}:#{@port}...\")\n\n socket_tcp = TCPSocket.new(@host, @port)\n OpenSSL::SSL::SSLSocket.new(socket_tcp, ctx).tap do |s|\n s.sync = true\n s.connect\n end\n end",
"def tls_begin\n logdebug \"tls begin\", :sni_hostname => @sni_hostname\n @sslsocket = OpenSSL::SSL::SSLSocket.new(@tcpsocket, @ctx)\n if @sni_hostname\n if @sslsocket.respond_to? :hostname\n @sslsocket.hostname = @sni_hostname\n else\n logwarn \"#{@sslsocket.class} does not support setting an SNI hostname! This requires Ruby 1.9.x built against OpenSSL with SNI support.\",\n :ruby_version => RUBY_VERSION\n end\n end\n @state = :initialized\n end",
"def connection_action\n @sslsocket.connect_nonblock\n end",
"def connect(global = true, opts={})\r\n\r\n self.sock = super(global, opts)\r\n\r\n if datastore['NRPESSL'] or @force_ssl\r\n ctx = OpenSSL::SSL::SSLContext.new(\"TLSv1\")\r\n ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE\r\n ctx.ciphers = \"ADH\"\r\n\r\n @ssl_socket = OpenSSL::SSL::SSLSocket.new(self.sock, ctx)\r\n\r\n @ssl_socket.connect\r\n\r\n self.sock.extend(Rex::Socket::SslTcp)\r\n self.sock.sslsock = @ssl_socket\r\n self.sock.sslctx = ctx\r\n end\r\n\r\n return self.sock\r\n end",
"def create_ssl_socket\n ctx = OpenSSL::SSL::SSLContext.new\n ctx.set_params ssl_version: :TLSv1_2\n\n socket = TCPSocket.new(@uri.host, @port)\n OpenSSL::SSL::SSLSocket.new(socket, ctx)\n end",
"def ssl_connect()\n $log.debug(\"Initiating SSL Connect Test\")\n disable_validations\n s = timeout(@open_timeout) { TCPSocket.open(conn_address(), conn_port()) }\n s = OpenSSL::SSL::SSLSocket.new(s, @ssl_context)\n s.sync_close = true\n\n @socket = BufferedIO.new(s)\n @socket.read_timeout = @read_timeout\n @socket.debug_output = @debug_output\n\n if proxy?\n @socket.writeline sprintf('CONNECT %s:%s HTTP/%s', @address, @port, HTTPVersion)\n @socket.writeline \"Host: #{@address}:#{@port}\"\n @socket.writeline ''\n HTTPResponse.read_new(@socket).value\n end\n\n begin\n s.connect\n return ResultContainer.new(true, nil)\n rescue OpenSSL::SSL::SSLError => ex\n return ResultContainer.new(false, ex)\n rescue => ex2\n return ResultContainer.new(false, ex2)\n end\n end",
"def connect_ssl; end",
"def open_connection\n @connection = TCPSocket.new(server, port)\n @context = OpenSSL::SSL::SSLContext.new\n @context.cert = @cert\n @context.key = @key\n\n @socket = OpenSSL::SSL::SSLSocket.new(@connection, @context) if @connection\n @socket.sync_close = true\n @socket.connect\n\n get_frame\n end",
"def conn_start host, port, ssl\n con = Net::HTTP.new(host, port)\n if ssl\n con.use_ssl = true\n con.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n con.start\n if block_given?\n begin\n return yield(con)\n ensure\n con.finish\n end\n end\n con\nend",
"def start\n\n self.listener = Rex::Socket::TcpServer.create(\n 'LocalHost' => self.listen_host,\n 'LocalPort' => self.listen_port,\n 'Context' => self.context,\n 'SSL' => self.ssl,\n 'SSLCert' => self.ssl_cert,\n 'SSLCompression' => self.ssl_compression,\n 'SSLCipher' => self.ssl_cipher,\n 'Comm' => self.comm\n )\n\n # Register callbacks\n self.listener.on_client_connect_proc = Proc.new { |cli|\n on_client_connect(cli)\n }\n self.listener.on_client_data_proc = Proc.new { |cli|\n on_client_data(cli)\n }\n\n self.listener.start\n end",
"def starttls?; end",
"def tls_socket socket\n socket = OpenSSL::SSL::SSLSocket.new socket, create_ssl_context\n socket.sync_close = true\n socket.hostname = @host unless RE_IP_ADDR.match(@host)\n socket.connect\n socket\n end",
"def start_tls(req, options)\n return unless req.uri.https? && !failed_proxy_connect?\n\n ssl_context = options.ssl_context\n\n unless ssl_context\n ssl_context = OpenSSL::SSL::SSLContext.new\n ssl_context.set_params(options.ssl || {})\n end\n\n @socket.start_tls(req.uri.host, options.ssl_socket_class, ssl_context)\n end",
"def open_ssl_socket()\n require 'openssl' unless defined?(OpenSSL)\n begin # Any raised SSL exceptions\n ctx = @sslctx_newparm ? OpenSSL::SSL::SSLContext.new(@sslctx_newparm) : OpenSSL::SSL::SSLContext.new\n ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE # Assume for now\n #\n # Note: if a client uses :ssl => true this would result in the gem using\n # the _default_ Ruby ciphers list. This is _known_ to fail in later\n # Ruby releases. The gem now detects :ssl => true, and replaces that\n # with:\n # * :ssl => Stomp::SSLParams.new\n #\n # The above results in the use of Stomp default parameters.\n #\n # To specifically request Stomp default parameters, use:\n # * :ssl => Stomp::SSLParams.new(..., :ciphers => Stomp::DEFAULT_CIPHERS)\n #\n # If connecting with an SSLParams instance, and the _default_ Ruby\n # ciphers list is actually required, use:\n # * :ssl => Stomp::SSLParams.new(..., :use_ruby_ciphers => true)\n #\n # If a custom ciphers list is required, connect with:\n # * :ssl => Stomp::SSLParams.new(..., :ciphers => custom_ciphers_list)\n #\n if @ssl != true\n #\n # Here @ssl is:\n # * an instance of Stomp::SSLParams\n # Control would not be here if @ssl == false or @ssl.nil?.\n #\n\n # Back reference the SSLContext\n @ssl.ctx = ctx\n\n # Server authentication parameters if required\n if @ssl.ts_files\n ctx.verify_mode = OpenSSL::SSL::VERIFY_PEER\n truststores = OpenSSL::X509::Store.new\n fl = @ssl.ts_files.split(\",\")\n fl.each do |fn|\n # Add next cert file listed\n raise Stomp::Error::SSLNoTruststoreFileError if !File::exists?(fn)\n raise Stomp::Error::SSLUnreadableTruststoreFileError if !File::readable?(fn)\n truststores.add_file(fn)\n end\n ctx.cert_store = truststores\n end\n\n # Client authentication parameters.\n # Both cert file and key file must be present or not, it can not be a mix.\n raise Stomp::Error::SSLClientParamsError if @ssl.cert_file.nil? && [email protected]_file.nil?\n raise Stomp::Error::SSLClientParamsError if [email protected]_file.nil? && @ssl.key_file.nil?\n if @ssl.cert_file # Any check will do here\n raise Stomp::Error::SSLNoCertFileError if !File::exists?(@ssl.cert_file)\n raise Stomp::Error::SSLUnreadableCertFileError if !File::readable?(@ssl.cert_file)\n ctx.cert = OpenSSL::X509::Certificate.new(File.read(@ssl.cert_file))\n raise Stomp::Error::SSLNoKeyFileError if !File::exists?(@ssl.key_file)\n raise Stomp::Error::SSLUnreadableKeyFileError if !File::readable?(@ssl.key_file)\n ctx.key = OpenSSL::PKey::RSA.new(File.read(@ssl.key_file), @ssl.key_password)\n end\n\n # Cipher list\n # As of this writing, there are numerous problems with supplying\n # cipher lists to jruby. So we do not attempt to do that here.\n if [email protected]_ruby_ciphers # No Ruby ciphers (the default)\n if @ssl.ciphers # User ciphers list?\n ctx.ciphers = @ssl.ciphers # Accept user supplied ciphers\n else\n ctx.ciphers = Stomp::DEFAULT_CIPHERS # Just use Stomp defaults\n end\n end unless @jruby\n\n # Set SSLContext Options if user asks for it in Stomp::SSLParams\n # and SSL supports it.\n if @ssl.ssl_ctxopts && ctx.respond_to?(:options=)\n ctx.options = @ssl.ssl_ctxopts\n end\n\n end\n\n #\n ssl = nil\n slog(:on_ssl_connecting, log_params)\n # _dump_ctx(ctx)\n Timeout::timeout(@connect_timeout, Stomp::Error::SocketOpenTimeout) do\n tcp_socket = TCPSocket.open(@host, @port)\n ssl = OpenSSL::SSL::SSLSocket.new(tcp_socket, ctx)\n ssl.hostname = @host if ssl.respond_to? :hostname=\n ssl.sync_close = true # Sync ssl close with underlying TCP socket\n ssl.connect\n if (ssl.context.verify_mode != OpenSSL::SSL::VERIFY_NONE) && @ssl_post_conn_check\n ssl.post_connection_check(@host)\n end\n end\n def ssl.ready?\n ! @rbuffer.empty? || @io.ready?\n end\n if @ssl != true\n # Pass back results if possible\n if RUBY_VERSION =~ /1\\.8\\.[56]/\n @ssl.verify_result = \"N/A for Ruby #{RUBY_VERSION}\"\n else\n @ssl.verify_result = ssl.verify_result\n end\n @ssl.peer_cert = ssl.peer_cert\n end\n slog(:on_ssl_connected, log_params)\n ssl\n rescue Exception => ex\n lp = log_params.clone\n lp[:ssl_exception] = ex\n slog(:on_ssl_connectfail, lp)\n if ssl\n # shut down the TCP socket - we just failed to do the SSL handshake in time\n ssl.close\n end\n #\n puts ex.backtrace\n $stdout.flush\n raise # Reraise\n end\n end",
"def connect_to_mycroft\n if ARGV.include?(\"--no-tls\")\n @client = TCPSocket.open(@host, @port)\n else\n socket = TCPSocket.new(@host, @port)\n ssl_context = OpenSSL::SSL::SSLContext.new\n ssl_context.cert = OpenSSL::X509::Certificate.new(File.open(@cert))\n ssl_context.key = OpenSSL::PKey::RSA.new(File.open(@key))\n @client = OpenSSL::SSL::SSLSocket.new(socket, ssl_context)\n begin\n @client.connect\n rescue\n end\n end\n end",
"def new_server(*args)\n ctx = OpenSSL::SSL::SSLContext.new\n ctx.key, ctx.cert = @key, @cert\n tcps = TCPServer.new(*args)\n OpenSSL::SSL::SSLServer.new(tcps, ctx)\n end",
"def connection_action\n @sslsocket.accept_nonblock\n end",
"def connect!\n unless socket\n @socket = address.socket(timeout, ssl_opts)\n @socket.connect!\n end\n true\n end",
"def connect\n sock = TCPSocket.new(@host, @port)\n if @ssl\n sock = OpenSSL::SSL::SSLSocket.new(sock)\n sock.sync_close = true\n sock.connect\n sock.post_connection_check(@host) if @verify_ssl\n end\n sock\n end",
"def start_tls(req, options); end",
"def initialize(config = {})\n cert = config[:cert] || raise(ArgumentError, \"Missing option 'cert'\")\n host = config[:host] || raise(ArgumentError, \"Missing option 'host'\")\n pass = config[:cert_pass] || ''\n port = 2195\n\n ssl_ctx = OpenSSL::SSL::SSLContext.new\n ssl_ctx.key = OpenSSL::PKey::RSA.new(cert, pass)\n ssl_ctx.cert = OpenSSL::X509::Certificate.new(cert)\n\n @tcp_socket = TCPSocket.new(host, port)\n @tcp_socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, true)\n @ssl_socket = OpenSSL::SSL::SSLSocket.new(@tcp_socket, ssl_ctx)\n @ssl_socket.sync = true\n @ssl_socket.connect\n end",
"def ssl_generate_certificate\n Rex::Socket::SslTcpServer.ssl_generate_certificate\n end",
"def start(request_params)\n # close the previous if exists\n @http.finish if @http && @http.started?\n # create new connection\n @server = request_params[:server]\n @port = request_params[:port]\n logger.info(\"Opening new HTTP connection to #{@server}\")\n @http = Net::HTTP.new(@server, @port)\n @http.open_timeout = HTTP_CONNECTION_OPEN_TIMEOUT\n @http.read_timeout = HTTP_CONNECTION_READ_TIMEOUT\n if @port == 443\n verifyCallbackProc = Proc.new{ |ok, x509_store_ctx|\n code = x509_store_ctx.error\n msg = x509_store_ctx.error_string\n #debugger\n logger.warn(\"##### #{@server} certificate verify failed: #{msg}\") unless code == 0\n true\n }\n @http.use_ssl = true\n @http.verify_mode = OpenSSL::SSL::VERIFY_PEER\n @http.verify_callback = verifyCallbackProc\n @http.ca_file = \"#{RAILS_ROOT}/lib/ec2/f73e89fd.0\"\n end\n # open connection\n @http.start\n end",
"def _connect\n return if @ssl_connected\n\n Error.translate do\n @plaintext_connected ||= super\n return if !@plaintext_connected\n\n # Mark the connection as not connected due to the pending SSL handshake.\n @connected = false\n\n @socket.connect_nonblock\n @ssl_connected = @connected = true\n end\n rescue IO::WaitReadable, IO::WaitWritable, Errno::EINPROGRESS\n rescue Error => e\n close e\n end",
"def start\n Socket.accept_loop(@tcpserver) do |connection|\n SLogger.debug(\"[server] accepted a new connection (#{connection})\")\n\n self.session.connection = connection\n self.handle_connection(connection)\n end\n rescue IOError\n Thread.exit\n end",
"def open_connection\n @connection = TCPSocket.new(@server, @port)\n @socket = OpenSSL::SSL::SSLSocket.new(@connection)\n \n # Synchronously close the connection & socket\n @socket.sync_close\n \n # Connect\n @socket.connect\n \n # Get the initial frame\n get_frame\n end",
"def connect!\n @connection = Net::HTTP.new(@server, 80)\n if @ssl\n @connection.use_ssl = true\n @connection.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n @connection.start\n end",
"def starttls_always?; end",
"def connect_to_server\n @socket = TCPSocket.open(@serverip, @serverport)\n end",
"def initialize(options = {})\n @options = {\n logger: nil,\n transport: 'tls',\n port: 0,\n address: '0.0.0.0',\n ssl_certificate: nil,\n ssl_key: nil,\n ssl_key_passphrase: nil,\n ssl_verify: false,\n ssl_verify_default_ca: false,\n ssl_verify_ca: nil,\n max_packet_size: 10_485_760,\n add_peer_fields: false,\n min_tls_version: 1.2,\n disable_handshake: false,\n }.merge!(options)\n\n @logger = @options[:logger]\n\n if @options[:transport] == 'tls'\n [:ssl_certificate, :ssl_key].each do |k|\n raise \"input/courier: '#{k}' is required\" if @options[k].nil?\n end\n\n if @options[:ssl_verify] && (!@options[:ssl_verify_default_ca] && @options[:ssl_verify_ca].nil?)\n raise 'input/courier: Either \\'ssl_verify_default_ca\\' or \\'ssl_verify_ca\\' must be specified when ssl_verify is true'\n end\n end\n\n begin\n @tcp_server = ExtendedTCPServer.new(@options[:address], @options[:port])\n\n # Query the port in case the port number is '0'\n # TCPServer#addr == [ address_family, port, address, address ]\n @port = @tcp_server.addr[1]\n\n if @options[:transport] == 'tls'\n ssl = OpenSSL::SSL::SSLContext.new\n\n # Disable SSLv2 and SSLv3\n # Call set_params first to ensure options attribute is there (hmmmm?)\n ssl.set_params\n # Modify the default options to ensure SSLv2 and SSLv3 is disabled\n # This retains any beneficial options set by default in the current Ruby implementation\n # TODO: https://github.com/jruby/jruby-openssl/pull/215 is fixed in JRuby 9.3.0.0\n # As of 7.15 Logstash, JRuby version is still 9.2\n # Once 9.3 is in use we can switch to using min_version and max_version\n ssl.options |= OpenSSL::SSL::OP_NO_SSLv2\n ssl.options |= OpenSSL::SSL::OP_NO_SSLv3\n ssl.options |= OpenSSL::SSL::OP_NO_TLSv1 if @options[:min_tls_version] > 1\n ssl.options |= OpenSSL::SSL::OP_NO_TLSv1_1 if @options[:min_tls_version] > 1.1\n ssl.options |= OpenSSL::SSL::OP_NO_TLSv1_2 if @options[:min_tls_version] > 1.2\n raise 'Invalid min_tls_version - max is 1.3' if @options[:min_tls_version] > 1.3\n\n # Set the certificate file\n ssl.cert = OpenSSL::X509::Certificate.new(File.read(@options[:ssl_certificate]))\n ssl.key = OpenSSL::PKey::RSA.new(File.read(@options[:ssl_key]), @options[:ssl_key_passphrase])\n\n if @options[:ssl_verify]\n cert_store = OpenSSL::X509::Store.new\n\n # Load the system default certificate path to the store\n cert_store.set_default_paths if @options[:ssl_verify_default_ca]\n\n if File.directory?(@options[:ssl_verify_ca])\n cert_store.add_path(@options[:ssl_verify_ca])\n else\n cert_store.add_file(@options[:ssl_verify_ca])\n end\n\n ssl.cert_store = cert_store\n\n ssl.verify_mode = OpenSSL::SSL::VERIFY_PEER | OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT\n end\n\n # Create the OpenSSL server - set start_immediately to false so we can multithread handshake\n @server = OpenSSL::SSL::SSLServer.new(@tcp_server, ssl)\n @server.start_immediately = false\n else\n @server = @tcp_server\n end\n\n @logger&.warn 'Ephemeral port allocated', transport: @options[:transport], port: @port if @options[:port].zero?\n rescue StandardError => e\n raise \"input/courier: Failed to initialise: #{e}\"\n end\n end",
"def reconnect()\r\n\r\n #puts \"reconnect() called.\"\r\n\r\n begin\r\n\r\n if ($sslsocket.nil? || $sslsocket.closed?)\r\n #puts \"Socket inactive. Reconnecting...\"\r\n\r\n #puts \"Setting up SSL context ...\"\r\n ctx = OpenSSL::SSL::SSLContext.new()\r\n\r\n # Options:\r\n # \"cert\", \"key\", \"client_ca\", \"ca_file\", \"ca_path\",\r\n # \"timeout\", \"verify_mode\", \"verify_depth\",\r\n # \"verify_callback\", \"options\", \"cert_store\", \"extra_chain_cert\"\r\n\r\n ctx.cert = OpenSSL::X509::Certificate.new(File.read(@keyfile))\r\n ctx.key = OpenSSL::PKey::RSA.new(File.read(@keyfile), @keypass)\r\n\r\n ctx.ca_file = @cafile\r\n ctx.verify_mode = OpenSSL::SSL::VERIFY_PEER | OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT\r\n #ctx.verify_mode = OpenSSL::SSL::VERIFY_PEER\r\n #ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE\r\n ctx.timeout = @@timeout\r\n\r\n if ctx.cert.nil?\r\n #puts \"warning: peer certificate won't be verified this session.\"\r\n ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE\r\n end\r\n\r\n #puts \"Opening socket to #{@host}:#{@port}...\"\r\n @socket = TCPSocket.open(@host, @port)\r\n #puts \"socket open\"\r\n #@socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_RCVTIMEO, @@timeout)\r\n\r\n #@socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_SNDTIMEO, @@timeout)\r\n\r\n $sslsocket = OpenSSL::SSL::SSLSocket.new(@socket, ctx)\r\n #puts \"socket created\"\r\n #$sslsocket.sync_close = true\r\n\r\n # $sslsocket should be good now\r\n #puts \"Connecting SSL socket ...\"\r\n $sslsocket.connect\r\n\r\n _startConnection()\r\n\r\n end\r\n\r\n if block_given?\r\n #puts \"Connecting SSL socket in block ...\"\r\n $sslsocket.connect if $sslsocket.closed?\r\n yield\r\n #puts \"SSL connection block finished.\"\r\n else\r\n #puts \"SSL connection wanting to do something else ...\"\r\n # do something non-OO\r\n end\r\n rescue Exception => ex\r\n warn \"Error reading from server: #{ex}\"\r\n end\r\n\r\n end",
"def prepare_socket_server!\n _log { \"prepare_socket_server! #{port}\" }\n @server = TCPServer.open(port)\n @server.setsockopt(Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, false)\n end",
"def proceed\n @stream.start_tls\n success\n end",
"def start_server\t\n\t\tloop{\n\t\t\tThread.new(@server.accept) do |client|\n\t\t\t\t\t\t\n\t\t\t\t#connection and request\n\t\t\t\tsock_domain, remote_port, remote_hostname, remote_ip = client.peeraddr\n\t\t\t\tclient_ip = remote_ip.to_s\t\n\t\t\t\t@@static_id += 1\n\t\t\t\t@connection_no = @@static_id \t\t\t\t\n\t\t\t\tputs \"\\nConnection ##{@connection_no} client #{client_ip} accepted\"\t\n\t\t\t\t\n\t\t\t\t#send client secret key \n\t\t\t\tclient.puts @key\t\t\t\t\t\t\n\t\t\t\t\t\t\t\n\t\t\t\t#receive data from client\n\t\t\t\tdata = client.gets.chomp\n\t\t\t\tputs \"received encoded: #{data}\"\n\t\t\t\t\n\t\t\t\tdecdata = Base64.decode64(data)\n\t\t\t\tputs \"decoded message #{decdata}\"\n\t\t\t\t\t\n\t\t\t\t#encrypts message with secret key and newly generated\n\t\t\t\t#initialization vector. \n\t\t\t\tiv = @aes_cipher.random_iv\t\n\t\t\t\t@aes_cipher.iv = iv\n\t\t\t\tputs \"generated IV: #{iv}\"\n\t\t\t\tencrypted = @aes_cipher.update(decdata)\n\t\t\t\tencrypted << @aes_cipher.final\t\n\t\t\t\tputs \"Encrypted Msg: #{encrypted}\"\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t#send back IV and encrypted data\n\t\t\t\tenc_encrypted = Base64.encode64(encrypted)\n\t\t\t\tclient.puts enc_encrypted\n\t\t\t\tclient.puts iv\t\t\t\t\n\t\t\t\t\n\t\t\t\t#close connections\n\t\t\t\tclient.close\t\t\n\t\t\t\t\n\t\t\tend\n\t\t}\n\tend",
"def open_socket(url, options)\n uri = URI(url)\n port = uri.port || (uri.scheme == \"wss\" ? 443 : 80) # redundant? test uri.port if port is unspecified but because ws: & wss: aren't default protocols we'll maybe still need this(?)\n logger.debug \"Opening Connection to #{uri.hostname} on port #{port}\"\n io = TCPSocket.new uri.hostname, port\n return io unless uri.scheme == \"wss\"\n logger.debug \"Upgrading Connection #{io} to ssl\"\n ssl = upgrade_to_ssl(io, options).connect\n logger.info \"Connection #{io} upgraded to #{ssl}\"\n ssl\n end",
"def open\n @socket = TCPSocket.new(@uri.host, @uri.port)\n\n @ssl = OpenSSL::SSL::SSLSocket.new(@socket, @ssl_context)\n @ssl.sync_close = true\n @ssl.hostname = @uri.hostname\n @ssl.connect\n\n @http = HTTP2::Client.new\n @http.on(:frame) do |bytes|\n @ssl.print(bytes)\n @ssl.flush\n end\n\n @main_queue = Threading::DispatchQueue.new\n @work_queue = Threading::DispatchQueue.new\n @requests = Threading::Counter.new\n @exceptions = Queue.new\n @worker_thread = start_worker_thread!\n end",
"def serverssl\n super\n end",
"def configure_ssl(http); end",
"def accept\n # when @ctx.servername_cb is set, we use a worker thread to run the\n # ssl.accept call. We need to do this because:\n # - We cannot switch fibers inside of the servername_cb proc (see\n # https://github.com/ruby/openssl/issues/415)\n # - We don't want to stop the world while we're busy provisioning an ACME\n # certificate\n if @use_accept_worker.nil?\n if (@use_accept_worker = use_accept_worker_thread?)\n start_accept_worker_thread\n end\n end\n\n # STDOUT.puts 'SSLServer#accept'\n sock, = @svr.accept\n # STDOUT.puts \"- raw sock: #{sock.inspect}\"\n begin\n ssl = OpenSSL::SSL::SSLSocket.new(sock, @ctx)\n # STDOUT.puts \"- ssl sock: #{ssl.inspect}\"\n ssl.sync_close = true\n if @use_accept_worker\n # STDOUT.puts \"- send to accept worker\"\n @accept_worker_fiber << [ssl, Fiber.current]\n # STDOUT.puts \"- wait for accept worker\"\n r = receive\n # STDOUT.puts \"- got reply from accept worker: #{r.inspect}\"\n r.invoke if r.is_a?(Exception)\n else\n ssl.accept\n end\n ssl\n rescue Exception => e\n # STDOUT.puts \"- accept exception: #{e.inspect}\"\n if ssl\n ssl.close\n else\n sock.close\n end\n raise e\n end\n end",
"def connect\n @connection = Net::HTTP.new(@params[:server], @params[:port])\n @connection.use_ssl = true if @params[:scheme] == 'https'\n @connection.start\n end",
"def ssl; end",
"def establish_connection\n LOG.debug self.inspect\n LOG.debug \"establish_connection:\"\n LOG.debug([@config['CONNECTION_HOST'], @config['CONNECTION_PORT']].inspect)\n @socket = TCPSocket.new(@config['CONNECTION_HOST'], @config['CONNECTION_PORT']) # The port should be an arg.\n handshake_data_hash = {:ident => @config['IDENT'], :pid => Process.pid}\n @socket.write_object(handshake_data_hash)\n end",
"def connect(url, options={})\n puts \"start ***************\"\n return if @socket\n @url = url\n uri = URI.parse url\n @socket = TCPSocket.new(uri.host,\n uri.port || (uri.scheme == 'wss' ? 443 : 80))\n if ['https', 'wss'].include? uri.scheme\n ctx = OpenSSL::SSL::SSLContext.new\n ctx.ssl_version = options[:ssl_version] || 'SSLv23'\n ctx.verify_mode = options[:verify_mode] || OpenSSL::SSL::VERIFY_NONE #use VERIFY_PEER for verification\n cert_store = OpenSSL::X509::Store.new\n cert_store.set_default_paths\n ctx.cert_store = cert_store\n @socket = ::OpenSSL::SSL::SSLSocket.new(@socket, ctx)\n @socket.connect\n end\n puts url\n @handshake = ::WebSocket::Handshake::Client.new :url => url, :headers => options[:headers]\n puts @handshake.to_s\n @handshaked = false\n @pipe_broken = false\n frame = ::WebSocket::Frame::Incoming::Client.new\n @closed = false\n once :__close do |err|\n puts \"clooooseeee ***********\"\n close\n emit :close, err\n end\n puts frame\n @thread = Thread.new do\n puts \"start while!!!!***********\"\n while !@closed do\n begin\n # puts \"1 ***************\"\n unless recv_data = @socket.getc\n puts \"2 ***************\"\n sleep 1\n next\n end\n unless @handshaked\n # puts \"3 ***************\"\n @handshake << recv_data\n if @handshake.finished?\n @handshaked = true\n puts \"Open!!!\"\n emit :open\n end\n else\n puts \"4 ***************\"\n frame << recv_data\n while msg = frame.next\n puts \"msg ***************\"\n emit :message, msg\n end\n end\n rescue => e\n puts \"error ***************\"\n emit :error, e\n end\n end\n end\n puts \"write ***************\"\n @socket.write @handshake.to_s\n end",
"def setup_ssl\n @connection.use_ssl = @config[:use_ssl]\n\n if @config[:ssl_verify_peer]\n @connection.verify_mdoe = OpenSSL::SSL::VERIFY_PEER\n @connection.ca_file = @config[:ssl_ca_file]\n else\n @connection.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n end",
"def socket_setup()\n ctx = { 'Msf' => self.options['Msf'], 'MsfExploit' => self.options['MsfExploit'] }\n self.socket = case self.handle.protocol\n\n when 'ncacn_ip_tcp'\n Rex::Socket.create_tcp(\n 'PeerHost' => self.handle.address,\n 'PeerPort' => self.handle.options[0],\n 'Context' => ctx,\n 'Timeout' => self.options['connect_timeout']\n )\n\n when 'ncacn_np'\n begin\n socket = Rex::Socket.create_tcp(\n 'PeerHost' => self.handle.address,\n 'PeerPort' => 445,\n 'Context' => ctx,\n 'Timeout' => self.options['connect_timeout']\n )\n rescue ::Timeout::Error, Rex::ConnectionRefused\n socket = Rex::Socket.create_tcp(\n 'PeerHost' => self.handle.address,\n 'PeerPort' => 139,\n 'Context' => ctx,\n 'Timeout' => self.options['connect_timeout']\n )\n end\n socket\n else nil\n end\n\n # Add this socket to the exploit's list of open sockets\n options['MsfExploit'].add_socket(self.socket) if (options['MsfExploit'])\n end",
"def starttls\n raise NotImplementedError\n end",
"def create_ssl_socket(raw_socket)\n SSLSocketWrap.new(raw_socket, @ssl_config, (DEBUG_SSL ? @debug_dev : nil))\n end",
"def begin_handshake\n if incoming? && [email protected]_connections?\n return close_connection unless @node.config[:connect].include?([@host, @port.to_s])\n end\n log.info { \"Established #{@direction} connection\" }\n @node.connections << self\n @state = :handshake\n send_version\n rescue Exception\n log.fatal { \"Error in #begin_handshake\" }\n p $!; puts *$@\n end",
"def connect()\n @sock = TCPSocket.open(@server, @port)\n end",
"def connect_to_unit\n puts \"Connecting to '#{@host}...\"\n begin\n tcp_client = TCPSocket.new @host, @port\n @ssl_client = OpenSSL::SSL::SSLSocket.new tcp_client, @context\n @ssl_client.connect\n rescue Exception => e\n puts \"Could not connect to '#{@host}: #{e}\"\n end\n end",
"def connect(&block)\n\t\t\t\tSSLSocket.connect(@endpoint.connect, context, hostname, &block)\n\t\t\tend",
"def create_socket\n if @uri.scheme == 'wss'\n create_ssl_socket.tap(&:connect)\n else\n TCPSocket.new(@uri.host, @port)\n end\n end",
"def starttls_auto?; end",
"def socket_accept\n Error.translate do\n socket = to_io.accept_nonblock\n\n ssl_socket = OpenSSL::SSL::SSLSocket.new(\n socket,\n @ssl_context\n )\n ssl_socket.sync_close = true\n ssl.accept if @start_immediately\n ssl_socket\n end\n rescue IO::WaitReadable, IO::WaitWritable\n rescue Error => e\n close e\n end",
"def connect\n close\n @socket = TCPSocket.new(@host, @port)\n @socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, true)\n self\n end",
"def post_init\n @state = :connecting\n @handshake = ::WebSocket::Handshake::Server.new(:secure => @secure_proxy)\n start_tls(@tls_options) if @secure\n end",
"def setup_socket\n self.socket = Socket.new(Socket::AF_INET, Socket::SOCK_STREAM, 0)\n address = Socket.pack_sockaddr_in(@options[:port], @options[:host])\n socket.bind(address)\n socket.listen(@options[:max_connection_queue])\n log.info(\"Listening on #{@options[:host]}:#{@options[:port]}\")\n end",
"def startWss(callback_opts) do\n server = TCPServer.new @port\n while session = server.accept\n @implementation(session.gets)\n end\n end",
"def establish_socket_server\n @socket_server = Uninterruptible::Binder.new(server_configuration.bind).bind_to_socket\n\n if server_configuration.tls_enabled?\n @socket_server = Uninterruptible::TLSServerFactory.new(server_configuration).wrap_with_tls(@socket_server)\n end\n @socket_server\n end",
"def set_socket\r\n @socket = TCPSocket.new(@server, @port) \r\n end",
"def connect!\n @http = Net::HTTP.new(@uri.host, @uri.port)\n if secure?\n @http.use_ssl = true\n if @@ca_path\n @http.verify_mode = OpenSSL::SSL::VERIFY_PEER\n @http.ca_path = @@ca_path\n else\n @http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n end\n end",
"def cork_socket(socket); end",
"def enable_ssl(opts); end",
"def use_dtls\n @MySocket = MySocket.new\n @MySocket.socket_type = CoDTLS::SecureSocket\n @MySocket.ack_timeout = @ack_timeout\n\n self\n end",
"def init_http_ssl(http)\n if @ssl_init_http\n @ssl_init_http.call(self, http)\n else\n # enable SSL for this HTTP connection\n http.use_ssl = true\n\n if @ssl_verify\n # set the verify mode and the cert store\n http.verify_mode = @ssl_verify_mode\n http.cert_store = @ssl_store\n end\n end\n end",
"def enable_ssl(verify = OpenSSL::SSL::VERIFY_PEER, certs = nil, \n port = SSL_PORT)\n @usessl = true\n @verify = verify\n @certs = certs\n @port = port\n end",
"def listening_thread(local_port)\n LOG.info(\"%06d\"%Process::pid) {\"listening on port #{local_port}...\"}\n \n # check the parameter to see if it's valid\n m = /^(([0-9a-fA-F]{0,4}:{0,1}){1,8})\\/([0-9]{1,5})|(([0-9]{1,3}\\.{0,1}){4}):([0-9]{1,5})|([0-9]{1,5})$/.match(local_port)\n #<MatchData \"2001:4800:7817:104:be76:4eff:fe05:3b18/2000\" 1:\"2001:4800:7817:104:be76:4eff:fe05:3b18\" 2:\"3b18\" 3:\"2000\" 4:nil 5:nil 6:nil 7:nil>\n #<MatchData \"23.253.107.107:2000\" 1:nil 2:nil 3:nil 4:\"23.253.107.107\" 5:\"107\" 6:\"2000\" 7:nil>\n #<MatchData \"2000\" 1:nil 2:nil 3:nil 4:nil 5:nil 6:nil 7:\"2000\">\n case\n when !m[1].nil? # its AF_INET6\n socket = bind_socket(AF_INET6,m[3],m[1])\n when !m[4].nil? # its AF_INET\n socket = bind_socket(AF_INET,m[6],m[4])\n when !m[7].nil?\n socket = bind_socket(AF_INET6,m[7],\"0:0:0:0:0:0:0:0\")\n else\n raise ArgumentError.new(local_port)\n end\n ssl_server = OpenSSL::SSL::SSLServer.new(socket, $ctx);\n\n # main listening loop starts in non-encrypted mode\n ssl_server.start_immediately = false\n loop do\n # we can't use threads because if we drop root privileges on any thread,\n # they will be dropped for all threads in the process--so we have to fork\n # a process here in order that the reception be able to drop root privileges\n # and run at a user level--this is a security precaution\n connection = ssl_server.accept\n Process::fork do\n begin\n drop_root_privileges if !UserName.nil?\n begin\n remote_hostname, remote_service = connection.io.remote_address.getnameinfo\n rescue SocketError => e\n LOG.info(\"%06d\"%Process::pid) { e.to_s }\n remote_hostname, remote_service = \"(none)\", nil\n end\n remote_ip, remote_port = connection.io.remote_address.ip_unpack\n process_call(connection, local_port, remote_port.to_s, remote_ip, remote_hostname, remote_service)\n LOG.info(\"%06d\"%Process::pid) {\"Connection closed on port #{local_port} by #{ServerName}\"}\n rescue Errno::ENOTCONN => e\n LOG.info(\"%06d\"%Process::pid) {\"Remote Port scan on port #{local_port}\"}\n ensure\n # here we close the child's copy of the connection --\n # since the parent already closed it's copy, this\n # one will send a FIN to the client, so the client\n # can terminate gracefully\n connection.close\n # and finally, close the child's link to the log\n LOG.close\n end\n end\n # here we close the parent's copy of the connection --\n # the child (created by the Process::fork above) has another copy --\n # if this one is not closed, when the child closes it's copy,\n # the child's copy won't send a FIN to the client -- the FIN\n # is only sent when the last process holding a copy to the\n # socket closes it's copy\n connection.close\n end\n end",
"def ssl?; end",
"def ssl?; end",
"def start_server!; @server = TCPServer.open($port) end",
"def servername_cb(sslsock, hostname)\n sslsock.context\n end",
"def start\n loop do\n begin\n socket = tcp_server.accept\n\n handle_request(socket)\n ensure\n socket.close\n end\n end\n end",
"def connect()\n @s = @s || TCPsocket.open(@host, @port)\n end",
"def initialize() #Isopen is a boolean for if the socket is still open or not\n @socket = TCPServer.open(PortNumber)\n @IsOpen = true\n end",
"def test_ssl_with_cert\n client = create_client(@connect_info, :connect => false,\n :ssl => true,\n :ssl_cert => CLIENT_CERT,\n :ssl_key => CLIENT_CERT)\n assert client.connect\n end",
"def connect\n http = Net::HTTP.new @host, @port\n # http.set_debug_output($stdout)\n http.use_ssl = @ssl\n http.start\n http\n end",
"def start_server\n @signature = EM.start_server(@host, @port, @handler) do |connection|\n setup_connection_opts(connection)\n end\n log(:info, \"Started listener #{@signature} on tcp://#{@host}:#{@port} (separator=#{@separator.inspect}).\")\n super\n end",
"def obtain_socket(uri)\n socket = TCPSocket.new(uri.host, uri.port || socket_port(uri))\n\n if secure_uri?(uri)\n ctx = OpenSSL::SSL::SSLContext.new\n\n if ENV['DISCORDRB_SSL_VERIFY_NONE']\n ctx.ssl_version = 'SSLv23'\n ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE # use VERIFY_PEER for verification\n\n cert_store = OpenSSL::X509::Store.new\n cert_store.set_default_paths\n ctx.cert_store = cert_store\n else\n ctx.set_params ssl_version: :TLSv1_2 # rubocop:disable Naming/VariableNumber\n end\n\n socket = OpenSSL::SSL::SSLSocket.new(socket, ctx)\n socket.connect\n end\n\n socket\n end",
"def test_cipher_strings\n socket = TCPSocket.new('rubyforge.org', 443)\n ctx = OpenSSL::SSL::SSLContext.new\n ctx.cert_store = OpenSSL::X509::Store.new\n ctx.verify_mode = 0\n ctx.cert = nil\n ctx.key = nil\n ctx.client_ca = nil\n ctx.ciphers = \"ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH\"\n\n ssl_socket = OpenSSL::SSL::SSLSocket.new(socket, ctx)\n ssl_socket.connect\n ssl_socket.close\n end",
"def starttls\n @stream.send \"<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>\"\n end",
"def dsi_send(request)\n socket = TCPSocket.new(URL, test? ? TEST_PORT : LIVE_PORT )\n\n ssl_context = OpenSSL::SSL::SSLContext.new\n ssl_context.verify_mode = OpenSSL::SSL::VERIFY_PEER\n\n ssl_socket = OpenSSL::SSL::SSLSocket.new(socket, ssl_context)\n ssl_socket.sync_close = true\n ssl_socket.connect\n \n ssl_socket.puts(request)\n ssl_socket.flush\n \n response = \"\"\n \n while line = ssl_socket.gets\n response << line unless line.include? \"endofdata\"\n end\n \n ssl_socket.close\n return response\n end",
"def set_serverssl(opts)\n opts = check_params(opts,[:serverssls])\n super(opts)\n end",
"def capable_starttls?; end",
"def starttls(value)\n send_text(\"220 2.0.0 TLS go ahead\")\n LOG.info(@mail[:mail_id]) {\"<-> (handshake)\"} if LogReceiverConversation\n conn = @connection.deepclone # save the unencrypted connection in case of error\n begin\n @connection.accept\n @mail[:encrypted] = @encrypted = true\n rescue OpenSSL::SSL::SSLError => e\n # STARTTLS failed: restore the unencrypted connection\n LOG.error(@mail[:mail_id]) {\"Error during STARTTLS: #{e}\"}\n @connection = conn # restore original\n @mail[:encrypted] = @encrypted = false\n return \"500 5.0.0 STARTTLS failed: #{e}\"\n end\n return nil\n end",
"def do_secure(handshake_method, timeout=nil)\n # SSLSocket#connect_nonblock will do the SSL/TLS handshake.\n # TODO(sissel): refactor this into a method that both secure and connect\n # methods can call.\n start = Time.now\n begin\n @socket.send(handshake_method)\n rescue IO::WaitReadable, IO::WaitWritable\n # The ruby OpenSSL docs for 1.9.3 have example code saying I should use\n # IO::WaitReadable, but in the real world it raises an SSLError with\n # a specific string message instead of Errno::EAGAIN or IO::WaitReadable\n # explicitly...\n #\n # This SSLSocket#connect_nonblock raising WaitReadable (Technically,\n # OpenSSL::SSL::SSLError) is in contrast to what Socket#connect_nonblock\n # raises, WaitWritable (ok, Errno::EINPROGRESS, technically)\n # Ruby's SSL exception for 'this call would block' is pretty shitty.\n #\n # So we rescue both IO::Wait{Readable,Writable} and keep trying\n # until timeout occurs.\n #\n \n if !timeout.nil?\n time_left = timeout - (Time.now - start)\n raise SecureHandshakeTimeout.new if time_left < 0\n r, w, e = IO.select([@socket], [@socket], nil, time_left)\n else\n r, w, e = IO.select([@socket], [@socket], nil, timeout)\n end\n\n # keep going if the socket is ready\n retry if r.size > 0 || w.size > 0\n rescue => e\n @logger.warn(e)\n raise e\n end\n\n @secure = true\n end",
"def installssl(options = {})\n result = server.perform_request('installssl', options)\n end",
"def accept_client_connection\n Thread.start(socket_server.accept) do |client_socket|\n if client_socket.is_a?(OpenSSL::SSL::SSLSocket)\n begin\n client_socket.accept\n rescue OpenSSL::SSL::SSLError => e\n logger.warn e.message\n client_socket.close rescue true\n Thread.exit\n end\n end\n process_request(client_socket)\n end\n end",
"def makessl(params)\n\n if params.ssl_cert\n key, cert, chain = ssl_parse_pem(params.ssl_cert)\n else\n key, cert, chain = ssl_generate_certificate\n end\n\n ctx = OpenSSL::SSL::SSLContext.new()\n ctx.key = key\n ctx.cert = cert\n ctx.extra_chain_cert = chain\n ctx.options = 0\n\n if params.ssl_cipher\n ctx.ciphers = params.ssl_cipher\n end\n\n # Older versions of OpenSSL do not export the OP_NO_COMPRESSION symbol\n if defined?(OpenSSL::SSL::OP_NO_COMPRESSION)\n # enable/disable the SSL/TLS-level compression\n if params.ssl_compression\n ctx.options &= ~OpenSSL::SSL::OP_NO_COMPRESSION\n else\n ctx.options |= OpenSSL::SSL::OP_NO_COMPRESSION\n end\n end\n\n ctx.session_id_context = Rex::Text.rand_text(16)\n\n return ctx\n end",
"def serve_https\n @server = Support::HTTP::Server.new\n @server.run\n end",
"def startHttp(callback_opts) do\n server = TCPServer.new @host, @port\n while session = server.accept\n @implementation(session, callback_opts)\n end\n end",
"def connect(host, port, options=nil, &block)\n if options.is_a?(Numeric) || options.nil?\n timeout = options || 5\n ssl = false\n elsif options\n timeout = options[:timeout] || 5\n ssl = options[:ssl]\n end\n connection = Connection.new(host, port, timeout, @unblocker, @clock)\n f = connection.connect\n @io_loop.add_socket(connection)\n @unblocker.unblock if running?\n if ssl\n f = f.flat_map do\n ssl_context = ssl == true ? nil : ssl\n upgraded_connection = SslConnection.new(host, port, connection.to_io, @unblocker, ssl_context)\n ff = upgraded_connection.connect\n @io_loop.remove_socket(connection)\n @io_loop.add_socket(upgraded_connection)\n @unblocker.unblock\n ff\n end\n end\n f = f.map(&block) if block_given?\n f\n end"
] | [
"0.7794769",
"0.7794769",
"0.7715263",
"0.75440913",
"0.7469398",
"0.7426566",
"0.7267545",
"0.72429603",
"0.7201536",
"0.71997315",
"0.718864",
"0.7178205",
"0.710683",
"0.7022352",
"0.6986863",
"0.6928714",
"0.6906046",
"0.68722165",
"0.6851468",
"0.6822239",
"0.6768816",
"0.6758577",
"0.67483777",
"0.66956717",
"0.6635658",
"0.6579503",
"0.6567736",
"0.6561264",
"0.6513515",
"0.65120256",
"0.6509515",
"0.64726925",
"0.64360756",
"0.64159703",
"0.6415025",
"0.6407222",
"0.64049953",
"0.63885856",
"0.6358459",
"0.6341671",
"0.63169765",
"0.6316812",
"0.6307421",
"0.6291475",
"0.6289365",
"0.6279067",
"0.62755954",
"0.6243049",
"0.62378824",
"0.62324154",
"0.62013644",
"0.6198238",
"0.61915535",
"0.61704284",
"0.6166436",
"0.61523485",
"0.6151287",
"0.61356634",
"0.61251974",
"0.6110548",
"0.61028534",
"0.609055",
"0.6083613",
"0.6075603",
"0.605237",
"0.6052259",
"0.6049786",
"0.6049447",
"0.6047405",
"0.6046668",
"0.60450447",
"0.6042087",
"0.6030148",
"0.6029211",
"0.6026736",
"0.6024436",
"0.6017824",
"0.6017824",
"0.60074043",
"0.6007227",
"0.6003446",
"0.5997555",
"0.5993994",
"0.59896374",
"0.59591186",
"0.5944767",
"0.5942104",
"0.59417087",
"0.59412426",
"0.5936321",
"0.591931",
"0.59156466",
"0.5915335",
"0.5888442",
"0.5888282",
"0.588086",
"0.5877566",
"0.58580244",
"0.58575654",
"0.58496344"
] | 0.7836249 | 0 |
find a better way to sort, not really gonna work with this (possibly sort.by) | def find_teams(league)
teams = []
league.each do |team|
teams << team[:home_team]
teams << team[:away_team]
end
uniq_teams = teams.uniq!
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stable_sort_by(list); end",
"def bigSorting(unsorted)\n\nend",
"def sort_entries; end",
"def sort_entries=(_arg0); end",
"def sort a\r\n sort_rec a, []\r\nend",
"def sort a\r\n sort_rec a, []\r\nend",
"def using_sort(array)\narray.sort\nend",
"def using_sort(array)\narray.sort\nend",
"def mothrah_sort (an_array)\n\tdef move_to_end (value, array)\n\t\tarray.delete(value)\n\t\tarray.push(value)\n\tend\n\tpos = 0\n\twhile pos < an_array.length \n\t\tif an_array[pos] > an_array[pos + 1]\n\t\t\tmove_to_end(an_array[pos], an_array)\n\t\telse\n\t\t\tpos += 1\n\t\tend\n\tend\n\tan_array\nend",
"def sort!\n sort_if_needed\n self\n end",
"def sort\n @pokers.sort.reverse\n end",
"def merge_sort(&prc)\n end",
"def sort(&block)\n self.map{|*val| val.__svalue}.sort(&block)\n end",
"def using_sort(array)\n array.sort\nend",
"def using_sort(array)\n array.sort\nend",
"def using_sort(array)\n array.sort\nend",
"def sort(array_of_nodes, order); end",
"def sort_data\n store.sort_data!\n end",
"def sort arr\r\n\trec_sort arr, []\r\nend",
"def sorting(numbers)\n numbers.sort\nend",
"def my_array_sorting_method(source)\n sourceDup = source.dup\n # p sourceDup.sort_by{|word| word.to_s}\n\n return sourceDup.sort_by{|word| word.to_s}\nend",
"def sort some_array # This \"wraps\" rec_sort so you don't have to pass rec_sort an empty array each iteration \n rec_sort some_array, []\nend",
"def sort arr \n\trec_sort arr, []\nend",
"def sort\n return @sort\n end",
"def sort sortfield = :id, descending = false\n @sortfield = sortfield.to_sym\n reverse = descending ? -1 : 1\n @data = @data.compact.sort { |us1, us2|\n comp =\n if us1[@sortfield] && us2[@sortfield]\n us1[@sortfield] <=> us2[@sortfield]\n elsif us1[@sortfield]\n 1\n elsif us2[@sortfield]\n -1\n else\n 0\n end\n comp * reverse\n }\n end",
"def apply_sorting(chain)\n chain\n end",
"def sort_files!; end",
"def gnomesort(a)\n a.start_logging\n\n i = 0\n while i < a.length\n if i == 0 || a[i] > a[i - 1]\n i += 1\n else\n a[i], a[i - 1] = a[i - 1], a[i]\n a.log\n i -= 1\n end\n end\n\n a\nend",
"def sort_params; end",
"def sort_params; end",
"def sort_by_luck(arr)\n arr.sort! { |a,b|\n b[0] <=> a[0]\n }\n return arr\nend",
"def my_array_sorting_method(source)\n source.sort_by { |x| x.to_s }\nend",
"def test_sort\n\n a_plus = Grade.new(\"A+\")\n a = Grade.new(\"A\")\n b_minus = Grade.new(\"B-\")\n\n ordered = [a_plus,b_minus, a].sort # should return [a, a_plus]\n\n assert(ordered[0] == b_minus)\n assert(ordered[1] == a)\n assert(ordered[2] == a_plus)\n\n end",
"def sorting(teamsarrayswins)\n rec_sorting(teamsarrayswins, [])\nend",
"def my_array_sorting_method(source)\n source.sort_by { |element|\n element.to_s\n }\nend",
"def sort some_array \n\tsortingRec some_array, []\nend",
"def poorly_written_sort(*arrays)\n combined_array = []\n arrays.each do |array|\n array.each do |value|\n combined_array << value\n end\n end\n\n sorted_array = [combined_array.delete_at(combined_array.length-1)]\n\n for val in combined_array\n i = 0\n while i < sorted_array.length\n if val <= sorted_array[i]\n sorted_array.insert(i, val)\n break\n elsif i == sorted_array.length - 1\n sorted_array.insert(i, val)\n break\n end\n i+=1\n end\n end\n\n # Return the sorted array\n sorted_array\nend",
"def sort\n\t@events = @events.sort_by { | e | e.time_from_start }\n\trecalc_delta_from_times()\n end",
"def sort()\n\t\t@events = @events.sort do |a,b| a[0] <=> b[0] end\n\tend",
"def sort(opts = {})\n return [] if not distkey\n \n opts[:by] = sortables[opts[:by]] if opts[:by]\n\n if opts[:start] && opts[:limit]\n opts[:limit] = [opts[:start], opts[:limit]]\n end\n\n objects(distkey.sort(opts))\n end",
"def sort_params=(_arg0); end",
"def sort_params=(_arg0); end",
"def sort1(array)\n\nend",
"def rec_sort unsorted, sorted \n\tif unsorted.length <= 0\n\n# sorted is an array\n\treturn sorted \n\tend\n\n# So if we got here, then it means we still have work to do.\n# take last one out of unsorted, call it smallest\nsmallest = unsorted.pop\n#create en empty 'still unsorted' array \nstill_unsorted = []\n\n#testing if each object in unsorted is smaller than 'smallest' \n\tunsorted.each do |tested_object| \n\t#if tested object is smaller than smallest then push them in still unsorted\n\t\tif tested_object.downcase < smallest.downcase\n\t\t\tstill_unsorted.push smallest\n\t\t\tsmallest = tested_object\n\t\telse\n\t\t\tstill_unsorted.push tested_object\n\t\tend \n\tend\n# Now \"smallest\" really does point to the\n# smallest element that \"unsorted\" contained,\n# and all the rest of it is in \"still_unsorted\". \nsorted.push smallest\n\nrec_sort still_unsorted, sorted\nend",
"def custom_sort (unsorted, sorted = [])\n return sorted.uniq if unsorted.length == 0\n smallest = unsorted[0]\n unsorted.each {|x| smallest = x if x <= smallest}\n\n unsorted.each {|x| sorted << x if x <= smallest }\n\n unsorted.delete(smallest)\n custom_sort(unsorted, sorted)\nend",
"def e5115_sublinear_sort(values)\n end",
"def my_array_sorting_method(source)\n p source.sort_by { |a| a.to_s }\nend",
"def sort(key, **options); end",
"def sort_using(xs, sidebar)\n # caching is possible but doesn't improve significantly the build times\n\n rank_lookup = rank_lookup_from_sidebar(sidebar)\n\n xs.sort {|x, y|\n # The default rank is very high so that pages that don't appear in the sidebar are put at the end\n rx = rank_lookup[x.url] || 10000\n ry = rank_lookup[y.url] || 10000\n\n rx <=> ry\n }\n\n end",
"def merge_sort(fishes)\n return fishes if self.length <= 1\n mid = fishes.length / 2\n sort_left = fishes.take(mid).merge_sort(fishes)\n sort_right = fishes.drop(mid).merge_sort(fishes)\n merge(sort_left, sort_right)\nend",
"def top_sort\n top_sort_visit([]).reverse\n end",
"def my_array_sorting_method(source)\n # sort by converting the integers, if there are, into strings for the purpose of sorting only\n return source.sort {|a,b| a.to_s <=> b.to_s }\nend",
"def bubble_sort_rec(&prc)\n end",
"def dub_sort(arr)\nend",
"def sortById(arr, left, right)\r\n if left < right\r\n \r\n pi = partition(arr, left, right)\r\n sortById(arr, left, pi - 1)\r\n sortById(arr, pi + 1, right)\r\n end\r\n\r\n return arr\r\nend",
"def my_array_sorting_method(source)\n p source.sort {|x,y| x.to_s <=> y.to_s}\nend",
"def sort_input(input, property, order); end",
"def my_array_sorting_method(source)\n source.sort { |a, b| a.to_s <=> b.to_s } \nend",
"def my_array_sorting_method(source)\n return source.sort {|a,b| a.to_s <=> b.to_s }\nend",
"def sortme( names )\n names.sort\nend",
"def grand_sorting_machine(array)\n\n\n\nend",
"def sort(input, property = T.unsafe(nil)); end",
"def using_sort(array)\n sorted_array=array.sort\nend",
"def sort(objects)\n objects.sort_by {|x| x.to_s }\nend",
"def sort(objects)\n objects.sort_by {|x| x.to_s }\nend",
"def my_array_sorting_method(source)\n puts source.map{|x| x.to_s}.sort \n\n #return source.sort_by{|x| x.to_s} => see comment A below regarding this line\nend",
"def sort_data\n sort_cols = @columns.select{ |col| col.sort_order }.sort_by{ |col| col.sort_order }\n if sort_cols.length > 0\n log.fine \"Sorting by #{sort_cols.map(&:header).to_sentence}\"\n @data.sort! do |a, b|\n ord = nil\n sort_cols.each do |col|\n if col.sort_ascending\n a_val = a[col.column_index]\n b_val = b[col.column_index]\n else\n a_val = b[col.column_index]\n b_val = a[col.column_index]\n end\n ord = a_val <=> b_val || (a_val && 1) || (b_val && -1) || 0\n break unless ord == 0\n end\n ord\n end\n end\n end",
"def sort_by(*arguments, &block)\n data.sort_by(*arguments, &block)\n end",
"def sort_all\n\t\t\t\tr=::Hash[self.sort]\n\t\t\t\tr.each do |k,v|\n\t\t\t\t\tr[k]=v.sort\n\t\t\t\tend\n\t\t\t\treturn r\n\t\t\tend",
"def sorted_by_age(people)\nend",
"def sort(key, by: T.unsafe(nil), limit: T.unsafe(nil), get: T.unsafe(nil), order: T.unsafe(nil), store: T.unsafe(nil)); end",
"def sort\n @hits = all.sort {|x,y| y.score <=> x.score }\n end",
"def my_array_sorting_method(source)\n\treturn source.uniq.map{|element| element.to_s}.sort\nend",
"def my_array_sorting_method(source)\n source.sort {|x,y| x.to_s <=> y.to_s }\nend",
"def sean_sort(numbers)\n\n\nend",
"def rec_sort unsorted, sorted\n if unsorted.length <= 0\n return sorted\n end\n#\n#start smallest using 'pop' word and move to sorted list\nsmallest = unsorted.pop\nstill_unsorted = []\n#if tested word from unsorted is less then put\n#smallest into still_unsorted and move tested to smallest\nunsorted.each do |tested_object|\n if tested_object < smallest\n still_unsorted.push smallest\n smallest = tested_object\n#otherwise put tested_object into still_unsorted\n else\n still_unsorted.push tested_object\n end\n#push smallest into sorted\n sorted.push smallest\n #calls method recursively again\n rec_sort still_unsorted, sorted\nend\nend",
"def try_sort\n # Sort the table if the first element next_start_time has changed\n if false && @next_start_time != @sprinkles[0].next_start_time\n @sprinkles.sort_by! {|s| s.next_start_time}\n @next_start_time = @sprinkles[0].next_start_time\n end\n end",
"def my_array_sorting_method(source) \n # sorted = source.dup\n sorted_array = source.sort {|a, b| a.to_s <=> b.to_s}\nend",
"def improved_poorly_written_ruby(*arrays)\n sorted = []\n arrays.flatten.each do |v|\n size = sorted.size\n if sorted.empty?\n sorted.push(v)\n else\n i = 0\n while i < size\n item = sorted[i]\n if item > v\n sorted.insert(i, v)\n break\n elsif i == size - 1\n sorted.push(v)\n break\n end\n i += 1\n end\n end\n end\n sorted\nend",
"def sorted_results\n results.sort\n end",
"def sort_results(results)\n case @metadata[:sort]\n when \"new\"\n results.sort_by do |c|\n [c.set.regular? ? 0 : 1, -c.release_date_i, c.default_sort_index]\n end\n when \"old\"\n results.sort_by do |c|\n [c.set.regular? ? 0 : 1, c.release_date_i, c.default_sort_index]\n end\n when \"newall\"\n results.sort_by do |c|\n [-c.release_date_i, c.default_sort_index]\n end\n when \"oldall\"\n results.sort_by do |c|\n [c.release_date_i, c.default_sort_index]\n end\n when \"cmc\"\n results.sort_by do |c|\n [c.cmc ? 0 : 1, -c.cmc.to_i, c.default_sort_index]\n end\n when \"pow\"\n results.sort_by do |c|\n [c.power ? 0 : 1, -c.power.to_i, c.default_sort_index]\n end\n when \"tou\"\n results.sort_by do |c|\n [c.toughness ? 0 : 1, -c.toughness.to_i, c.default_sort_index]\n end\n when \"rand\"\n results.sort_by do |c|\n [Digest::MD5.hexdigest(@query_string + c.name), c.default_sort_index]\n end\n when \"number\"\n results.sort_by do |c|\n [c.set.name, c.number.to_i, c.number, c.default_sort_index]\n end\n when \"color\"\n results.sort_by do |c|\n [COLOR_ORDER.fetch(c.colors), c.default_sort_index]\n end\n when \"ci\"\n results.sort_by do |c|\n [COLOR_ORDER.fetch(c.color_identity), c.default_sort_index]\n end\n when \"rarity\"\n results.sort_by do |c|\n [-c.rarity_code, c.default_sort_index]\n end\n else # \"name\" or unknown key\n results.sort_by(&:default_sort_index)\n end\n end",
"def my_array_sorting_method(source)\n source.sort {|x, y| x.to_s <=> y.to_s }\nend",
"def sort\r\n @roster.each do |key, value|\r\n value.sort!\r\n end\r\n end",
"def order_by(&blk)\n OrderedCollection.new(@things.sort_by(&blk))\n end",
"def merge_sort(&prc)\n prc || = proc { |num1, num2| num1 <=> num2 }\n return self if length <= 1\n mid = length / 2\n left = self.take(mid).merge_sort(&prc)\n right = self.drop(mid).merge_sort&prc)\n Array.merge(left, right, &prc)\nend",
"def sort(a)\n\t\n\tfor i in 1...a.length\n\n\ttemp=a[i]\n\tj=i-1\n\tx=bsearch(a,temp,0,j)\n\n\twhile j>=x do\n\ta[j+1]=a[j]\n\tj-=1\n\tend #This is for the while loop\n\ta[j+1]=temp\n\tend\n\n\tend",
"def sortarray (sort_me)\n counter = sort_me.length\n a = 0\n b = 1\n while a < (counter-1)\n b = a+1\n while b < (counter)\n if sort_me[a] > sort_me[b]\n temp = sort_me[a]\n sort_me[a] = sort_me[b]\n sort_me[b] = temp\n end\n b += 1\n end\n a += 1\n end\n return sort_me\nend",
"def sort some_array\n\tsorted_array = []\n\trecursive_sort some_array, sorted_array\nend",
"def my_array_sorting_method(source)\n result = source.sort { |a, b| a.to_s <=> b.to_s }\nend",
"def my_array_sorting_method(source)\n source.sort_by{ |x| x.to_s }\nend",
"def test_sort_proc\n ct = []\n @@conn.search( @@naming_context, LDAP::LDAP_SCOPE_ONELEVEL,\n '(objectClass=*)', [ 'createTimestamp' ] ) do |x|\n ct << x['createTimestamp']\n end\n ct.flatten!\n\n sorted_ct = []\n s_proc = proc { |a,b| b <=> a }\n @@conn.search( @@naming_context, LDAP::LDAP_SCOPE_ONELEVEL,\n '(objectClass=*)', [ 'createTimestamp' ], nil, 0, 0,\n 'createTimestamp', s_proc ) do |x|\n sorted_ct << x['createTimestamp']\n end\n sorted_ct.flatten!\n\n assert_not_equal( ct, sorted_ct )\n assert_equal( ct.sort( &s_proc ), sorted_ct )\n end",
"def sort(*arguments, &block)\n data.sort(*arguments, &block)\n end",
"def sort_list!(list)\n list.sort! do |a,b|\n a, b = a.sort_data, b.sort_data\n i = 0\n i += 1 while a[i] == b[i] && (a[i+1] || b[i+1])\n if a[i] && b[i]\n a[i] <=> b[i]\n else\n a[i] ? 1 : -1\n end\n end\n list\n end",
"def sortme(names)\n names.sort\nend",
"def sort(companies)\n companies.sort_by do |company|\n -company.size\n end \nend",
"def sort some_array\n\trecursive_sort some_array, []\nend",
"def sort some_array\n\trecursive_sort some_array, []\nend",
"def sensible_sort(unsorted)\n return unsorted.sort_by {|k| k.to_s.split(/((?:(?:^|\\s)[-+])?(?:\\.\\d+|\\d+(?:\\.\\d+?(?:[eE]\\d+)?(?:$|(?![eE\\.])))?))/ms).map{|v| Float(v) rescue v.downcase}}\nend",
"def sort(to_sort)\n # if the array is of length 0 or 1, consider it is already sorted\n if to_sort.length <= 1\n then return to_sort\n end\n\n # otherwise split the remaining elements in two\n # I had to look this line on the web (sourcerefactormycode.com)\n second_array = to_sort.slice!((to_sort.length / 2.0).round..to_sort.length)\n\n # recursive method call on both arrays\n first_sorted_array = sort(to_sort)\n second_sorted_array = sort(second_array)\n\n # merge the two sorted arrays together\n return merge(first_sorted_array, second_sorted_array)\nend",
"def my_array_sorting_method(source)\n source.sort_by { |x| x.to_s }\nend",
"def sort\[email protected] do |key,value|\n value.sort!\nend \nend"
] | [
"0.76663804",
"0.74764556",
"0.7401979",
"0.6937885",
"0.6924298",
"0.6924298",
"0.69090354",
"0.69090354",
"0.6856841",
"0.6837796",
"0.6810996",
"0.6786145",
"0.67693406",
"0.67565703",
"0.67565703",
"0.67565703",
"0.6746215",
"0.67314345",
"0.6727324",
"0.67243105",
"0.67035174",
"0.67027223",
"0.67021847",
"0.6684661",
"0.6669825",
"0.66605145",
"0.66588527",
"0.6651524",
"0.66510576",
"0.66510576",
"0.6649635",
"0.6642024",
"0.66384494",
"0.66350126",
"0.66335744",
"0.6632146",
"0.66289455",
"0.6624981",
"0.6624177",
"0.66196734",
"0.6611256",
"0.6611256",
"0.66068375",
"0.66018677",
"0.65992916",
"0.6586473",
"0.65764314",
"0.65718997",
"0.65608305",
"0.65437746",
"0.65359",
"0.6529601",
"0.6529224",
"0.652817",
"0.6527703",
"0.65260863",
"0.652379",
"0.65208226",
"0.65199286",
"0.65189546",
"0.65131193",
"0.6501286",
"0.6500899",
"0.6500083",
"0.6500083",
"0.64997494",
"0.6492418",
"0.64899224",
"0.6487436",
"0.6484465",
"0.6484457",
"0.64832574",
"0.6475482",
"0.6474282",
"0.6473179",
"0.64729375",
"0.6468728",
"0.6460712",
"0.6457559",
"0.64565086",
"0.64551395",
"0.64523464",
"0.64449155",
"0.6442104",
"0.644191",
"0.64377624",
"0.6436464",
"0.6435277",
"0.6433981",
"0.64338964",
"0.64318496",
"0.6429143",
"0.64241487",
"0.6421576",
"0.6421075",
"0.64200926",
"0.64200926",
"0.64193785",
"0.64156556",
"0.64138067",
"0.6412362"
] | 0.0 | -1 |
apply some form of assignment with counting index from above (similar to cash register stuff) each team must increment whether win or lose (to be able to sort by wins and losses) | def games(meeting, record)
meeting.each do |play|
if play[:home_score].to_i > play[:away_score].to_i
record[play[:home_team]]["W"] += 1
record[play[:away_team]]["L"] += 1
else play[:home_score].to_i < play[:away_score].to_i
record[play[:away_team]]["W"] += 1
record[play[:home_team]]["L"] += 1
end
end
record
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index\n yes = 1\n no = 0\n Team.all.each do |team|\n team.matches_won = 0\n team.matches_played = 0\n team.save\n end\n\n Match.all.each do |match|\n if match.winner != nil\n if match.team1 == match.winner\n winner_team = Team.find_by_id(match.team1)\n winner_team.matches_played += yes\n winner_team.matches_won += yes\n winner_team.save\n other_team = Team.find_by_id(match.team2)\n other_team.matches_played += yes\n other_team.matches_won += no\n other_team.save\n elsif match.team2 == match.winner\n winner_team = Team.find_by_id(match.team2)\n winner_team.matches_played += yes\n winner_team.matches_won += yes\n winner_team.save\n other_team = Team.find_by_id(match.team1)\n other_team.matches_played += yes\n other_team.matches_won +=no\n other_team.save\n else \n end\n end\n end\n @teams = Team.all.order(:rank)\n end",
"def its_a_tie game\n game.each do |team|\n team_standings = get_team_by_name(team)\n team_standings[:winnings] += 1\n end\nend",
"def rank\n @team_records.sort_by! do |team|\n team.wins\n end #still correct\n @team_records.reverse! #up until here we're okay\n\n @team_records.each_with_index do |team, index| #line that doesn't function as expected\n team.rank = index + 1 #returns only two teams repeated twice, with wrong indexes\n end\n end",
"def determine_winner game\n winner = game.max_by {|team| team[:score]}\n team_standings = get_team_by_name(winner)\n team_standings[:winnings] += 3\nend",
"def increment_win\n self.games_won += 1 \n increment_games_played\n end",
"def track_victory(winnerofturn) #algorythmic\n if winnerofturn == @Player1\n @win_counter[\"P1\"] += 1\n elsif winnerofturn == @Player2\n @win_counter[\"P2\"] += 1\n end\n end",
"def wins_losses\n GAME_INFO.each do |game|\n @team_records.each do |team|\n if game[:home_team] == team.name && game[:home_score] > game[:away_score] #refactor later\n team.wins += 1\n elsif game[:home_team] == team.name && game[:home_score] < game[:away_score]\n team.losses += 1\n end\n end\n end\n\n GAME_INFO.each do |game|\n @team_records.each do |team|\n if game[:away_team] == team.name && game[:away_score] > game[:home_score] #refactor later\n team.wins += 1\n elsif game[:away_team] == team.name && game[:away_score] < game[:home_score]\n team.losses += 1\n end\n end\n end\n\n end",
"def won_set\n if @opponent.games_won == 6 && @games_won == 7\n @games_won = 0\n @sets_won += 1\n elsif @games_won > 4 && @games_won > @opponent.games_won + 1\n @games_won = 0\n @sets_won += 1\n end\n\n @matches_won += 1 if won_match?\n end",
"def update_match_results_and_points(match)\n case match[2]\n when 'W'\n $wins[match[0]] = $wins[match[0]].to_i + 1\n $loses[match[1]] = $loses[match[1]].to_i + 1\n $points[match[0]] = $points[match[0]].to_i + 3\n when 'L'\n $loses[match[0]] = $loses[match[0]].to_i + 1\n $wins[match[1]] = $wins[match[1]].to_i + 1\n $points[match[1]] = $points[match[1]].to_i + 3\n else\n $draws[match[0]] = $draws[match[0]].to_i + 1\n $draws[match[1]] = $draws[match[1]].to_i + 1\n $points[match[0]] = $points[match[0]].to_i + 1\n $points[match[1]] = $points[match[1]].to_i + 1\n end\nend",
"def set_results winner\n winner = winner[0]\n loser = (winner == :white) ? :black : :white\n @state_store[winner].each do |state|\n state = ActiveSupport::JSON.encode(state)\n ai_board_state = AiBoardState.find_or_create_by(state: state)\n ai_board_state.score += 1\n ai_board_state.save!\n end\n\n @state_store[loser].each do |state|\n state = ActiveSupport::JSON.encode(state)\n ai_board_state = AiBoardState.find_or_create_by(state: state)\n ai_board_state.score -= 1\n ai_board_state.save!\n end\n puts \"finished storing!\"\n end",
"def matches_played_by_season(table_of_teams)\n matches_played = Hash.new { |hash, key| hash[key] = Hash.new(0) }\n\n table_of_teams.each do |table_row|\n matches_played[table_row['season']][table_row['team1']] += 1\n matches_played[table_row['season']][table_row['team2']] += 1\n end\n matches_played\nend",
"def update_matches_played(match)\n for i in 0...2\n $matches_played[match[i]] = $matches_played[match[i]].to_i + 1\n end\nend",
"def calculate_team_scorecard(game_matchups, scorecard_template)\n team_scorecard = scorecard_template\n #based on game results, increase appropriate wins/losses/ties values\n game_matchups.each do |game_info|\n home_team = game_info[\"home_team\"]\n away_team = game_info[\"away_team\"]\n home_score = game_info[\"home_score\"].to_i\n away_score = game_info[\"away_score\"].to_i\n if home_score > away_score\n #add 1 win to home_team and add 1 loss to away_team\n team_scorecard[home_team][:wins] += 1\n team_scorecard[away_team][:losses] += 1\n elsif home_score < away_score\n #add 1 win to away_team and add 1 loss to home_team\n team_scorecard[home_team][:losses] += 1\n team_scorecard[away_team][:wins] += 1\n else\n #add 1 tie to both home_team and away_team\n team_scorecard[home_team][:ties] += 1\n team_scorecard[away_team][:ties] += 1\n end\n end\n team_scorecard.to_a\nend",
"def calculate_team_scorecard(game_matchups, scorecard_template)\n team_scorecard = scorecard_template\n #based on game results, increase appropriate wins/losses/ties values\n game_matchups.each do |game_info|\n home_team = game_info[\"home_team\"]\n away_team = game_info[\"away_team\"]\n home_score = game_info[\"home_score\"].to_i\n away_score = game_info[\"away_score\"].to_i\n if home_score > away_score\n #add 1 win to home_team and add 1 loss to away_team\n team_scorecard[home_team][:wins] += 1\n team_scorecard[away_team][:losses] += 1\n elsif home_score < away_score\n #add 1 win to away_team and add 1 loss to home_team\n team_scorecard[home_team][:losses] += 1\n team_scorecard[away_team][:wins] += 1\n else\n #add 1 tie to both home_team and away_team\n team_scorecard[home_team][:ties] += 1\n team_scorecard[away_team][:ties] += 1\n end\n end\n team_scorecard.to_a\nend",
"def update_coach_win_loss\n \t#this should make the coach of the winning team hae one more win\n \t#and the coach of the losing team have one more loss\n winning_coach.update_attribute :wins, winning_coach.wins + 1\n losing_coach.update_attribute :losses, losing_coach.losses + 1\n end",
"def offensive_row_for_ai(board)\n offensive_play = {}\n WINNING_COMBINATIONS.each { |offense| offensive_play[offense] = 0 }\n WINNING_COMBINATIONS.each do |offense|\n offense.each do |is_x|\n offensive_play[offense] += 1 if board[is_x] == COMPUTER_MARKER\n if board[is_x] == PLAYER_MARKER\n offensive_play[offense] = 0\n break\n end\n end\n end\n offensive_play\nend",
"def win\n @score += 1\n end",
"def win\n @score += 1\n end",
"def set_other_games_won()\n @score_count.set_other_games_won()\n end",
"def tally_score(winner)\n\t(session[\"p#{winner}_total_score\"] += 1) unless (winner == 0)\nend",
"def upset_test(limit = 1)\n puts\n (0..14).each do |skill|\n wins = [0,0,0]\n gamecount = 0\n until gamecount == limit\n newgame\n @players << skill\n @players << (skill + 1)\n reset_arrays\n playgame\n wins[0] += 1 if @game_scores[0][-1] > @game_scores[1][-1]\n wins[1] += 1 if @game_scores[0][-1] < @game_scores[1][-1]\n wins[2] += 1 if @game_scores[0][-1] == @game_scores[1][-1]\n gamecount += 1\n end\n print @players.inspect.rjust(8), \" \", wins.inspect, \"\\n\"\n end\nend",
"def set_games_won_for_tests(num)\n @score_count = num\n end",
"def turn_count\n counter = 0\n @board.each do |index_taken|\n if index_taken == \"X\" || index_taken == \"O\"\n counter += 1\n end\n end\n counter\n end",
"def sets_won(team)\n match_sets.reduce(0) do |sum, set|\n winner = set.compute_team_winner\n sum + (winner && winner == team ? 1 : 0)\n end\n end",
"def winner_count\n end",
"def update_record game\n @wins += 1 if game.game_result == 'W'\n @losses += 1 if game.game_result == 'L'\n @ties += 1 if game.game_result == 'T'\n end",
"def tally_comp(f_ind1,r_ind1,f_ind2,r_ind2,f_ind3,r_ind3)\n frame_score = @frame_scores[player - 1][f_ind1][r_ind1] + @frame_scores[player - 1][f_ind2][r_ind2]\t\t# always summing at least two frame_scores\n unless f_ind3.nil? == true\t\t\t\t\t\t\t\t\t\t# need this way b/c nil values break addition\n frame_score += @frame_scores[player - 1][f_ind3][r_ind3]\n end\n @game_scores[player - 1] << frame_score\n # print \"\\n* #{f_ind1} #{r_ind1} #{f_ind2} #{r_ind2} #{f_ind3} #{r_ind3} *\\n\"\t\t# for debug\n unless f_ind1 == 0\t\t# can't use @frame_no here; ==11 via roll_master\n @game_scores[player - 1][-1] = @game_scores[player - 1][-1] + @game_scores[player - 1][-2] \n end\nend",
"def tally_comp(f_ind1,r_ind1,f_ind2,r_ind2,f_ind3,r_ind3)\n frame_score = @frame_scores[player - 1][f_ind1][r_ind1] + @frame_scores[player - 1][f_ind2][r_ind2]\t\t# always summing at least two frame_scores\n unless f_ind3.nil? == true\t\t\t\t\t\t\t\t\t\t# need this way b/c nil values break addition\n frame_score += @frame_scores[player - 1][f_ind3][r_ind3]\n end\n @game_scores[player - 1] << frame_score\n # print \"\\n* #{f_ind1} #{r_ind1} #{f_ind2} #{r_ind2} #{f_ind3} #{r_ind3} *\\n\"\t\t# for debug\n unless f_ind1 == 0\t\t# can't use @frame_no here; ==11 via roll_master\n @game_scores[player - 1][-1] = @game_scores[player - 1][-1] + @game_scores[player - 1][-2] \n end\nend",
"def update_tournament_count\n if self.tournament\n m_with_t = Match.where(\"tournament_id is not null\")\n num = m_with_t.map(&:games).flatten.map(&:runner_user).map(&:userid).uniq.size\n self.tournament.num_players = num\n self.tournament.save\n end\n end",
"def outcome\n if self.final\n \th = home_team\n \ta = away_team\n \t# h.wins=0 if h.wins==nil\n \t# h.losses=0 if h.losses==nil\n \t# a.wins=0 if a.wins==nil\n \t# a.losses=0 if a.losses==nil\n \tif home_score == away_score\n \t\treturn 'T'\n \telsif home_score > away_score\n \t\tif !self.recorded\n \t \t\th.wins += 1\n \t \t\ta.losses += 1\n \t \t\th.save\n \t \t\ta.save\n \t \t\tself.recorded=true\n \t \t\tself.save\n \t \tend\n \t\tif overtime\n \t\t\treturn 'h'\n \t\telse\n \t\t\treturn 'H'\n \t\tend\n \telse\n \t\tif !self.recorded\n \t \t\th.losses += 1\n \t \t\ta.wins += 1\n \t \t\ta.save\n \t \t\th.save\n \t \t\tself.recorded=true\n \t \t\tself.save\n \t \tend\n \t\tif overtime\n \t\t\treturn 'a'\n \t\telse\n \t\t\treturn 'A'\n \t\tend\n \tend\n end\n end",
"def save_winners(winners)\n winners.each do |winner| \n winner.increment_score()\n end\n end",
"def set_determine_set_winner()\n if @score_count > @other_score_count\n @set_winner = 1\n\n elsif @score_count < @other_score_count\n @set_winner = 2\n \n else @score_count == @other_score_count\n @set_winner = 0\n end\n end",
"def compile_move_history\n hash = {\n rock: { won: 0, lost: 0, tie: 0 },\n paper: { won: 0, lost: 0, tie: 0 },\n scissors: { won: 0, lost: 0, tie: 0 },\n lizard: { won: 0, lost: 0, tie: 0 },\n spock: { won: 0, lost: 0, tie: 0 }\n\n }\n\n array = (move_history).zip(result_history)\n\n array.each do |x,y|\n case x\n when \"rock\"\n if y == \"won\"\n hash[:rock][:won] += 1\n self.move_values << \"rock\"\n elsif y == \"lost\"\n hash[:rock][:lost] += 1\n self.move_values.delete_at(move_values.index(\"rock\") || move_values.length )\n else\n hash[:rock][:tie] += 1\n end\n when \"paper\"\n if y == \"won\"\n hash[:paper][:won] += 1\n self.move_values << \"paper\"\n elsif y == \"lost\"\n hash[:paper][:lost] += 1\n self.move_values.delete_at(move_values.index(\"paper\") || move_values.length )\n else\n hash[:paper][:tie] += 1\n end\n when \"scissors\"\n if y == \"won\"\n hash[:scissors][:won] += 1\n self.move_values << \"scissors\"\n elsif y == \"lost\"\n hash[:scissors][:lost] += 1\n self.move_values.delete_at(move_values.index(\"scissors\") || move_values.length )\n else\n hash[:scissors][:tie] += 1\n end\n when \"lizard\"\n if y == \"won\"\n hash[:lizard][:won] += 1\n self.move_values << \"lizard\"\n elsif y == \"lost\"\n hash[:lizard][:lost] += 1\n self.move_values.delete_at(move_values.index(\"lizard\") || move_values.length )\n else\n hash[:lizard][:tie] += 1\n end\n when \"spock\"\n if y == \"won\"\n hash[:spock][:won] += 1\n self.move_values << \"spock\"\n elsif y == \"lost\"\n hash[:spock][:lost] += 1\n self.move_values.delete_at(move_values.index(\"spock\") || move_values.length )\n else\n hash[:spock][:tie] += 1\n end\n end\n end\n\n hash\n end",
"def update_score(score, board)\n if detect_winner(board) == 'Player'\n score[0] += 1\n else\n score[1] += 1\n end\nend",
"def add_to_player_score (player)\r\n\tplayer.player_wins += 1\r\n\t@total_number_of_plays += 1\r\n\tend",
"def get_rankings\n #create tmp hash storage for all the rows in the rankings table\n row_holder = Hash.new { |hash, key| hash[key] =\n {'played' => 0, '3_points' => 0, '2_points' => 0, '1_point' => 0,\n '0_points' => 0, 'won_sets' => 0, 'lost_sets' => 0, 'points' => 0,\n 'name' => key}}\n\n @games.each do |g|\n if g.has_been_played?\n #add played game for both teams\n row_holder[g.home_team]['played'] += 1\n row_holder[g.away_team]['played'] += 1\n\n #add won sets for each team\n row_holder[g.home_team]['won_sets'] += g.home_sets\n row_holder[g.away_team]['won_sets'] += g.away_sets\n\n #add lost sets for each team\n row_holder[g.home_team]['lost_sets'] += g.away_sets\n row_holder[g.away_team]['lost_sets'] += g.home_sets\n\n #handle all different game outcomes, prepare for ugly code\n #handle 3-0 and 3-1\n if (g.home_sets == 3) && (g.away_sets < 2)\n row_holder[g.home_team]['points'] += 3\n row_holder[g.home_team]['3_points'] += 1\n row_holder[g.away_team]['0_points'] += 1\n\n #handle 3-2\n elsif (g.home_sets == 3) && (g.away_sets == 2)\n row_holder[g.home_team]['points'] += 2\n row_holder[g.away_team]['points'] += 1\n row_holder[g.home_team]['2_points'] += 1\n row_holder[g.away_team]['1_point'] += 1\n\n #handle 2-3\n elsif (g.home_sets == 2) && (g.away_sets ==3)\n row_holder[g.away_team]['points'] += 2\n row_holder[g.home_team]['points'] += 1\n row_holder[g.home_team]['1_point'] += 1\n row_holder[g.away_team]['2_points'] += 1\n\n #handle 0-3 and 1-3\n elsif (g.home_sets < 2) && (g.away_sets == 3)\n row_holder[g.away_team]['points'] += 3\n row_holder[g.home_team]['0_points'] += 1\n row_holder[g.away_team]['3_points'] += 1\n end\n\n # make sure hash is generated when no games have been played yet\n else\n row_holder[g.home_team]['played'] += 0\n row_holder[g.away_team]['played'] += 0\n end\n end\n\n\n\n #convert the row_holder hash to a sorted array\n sort_ranking(row_holder)\n end",
"def set_games_won()\n @score_count.set_games_won()\n end",
"def win\n @streak += 1\n end",
"def advance_contestants()\n #logger.debug \"Prior(s): #{all_priors.collect{|bc| bc.contestantcode}.inspect()}\"\n winning_team = self.homecontestant.win ? self.homecontestant.team : self.awaycontestant.team\n losing_team = self.homecontestant.loss ? self.homecontestant.team : self.awaycontestant.team\n self.all_priors().each{|bc| bc.team = bc.contestanttype==\"W\" ? winning_team : losing_team; bc.save! }\n end",
"def matchup_count(season = 2015)\n r = Record.find_by(team_id: self.id, year: season)\n r.wins + r.losses + r.ties\n end",
"def set_win_lose_draw(tictactoe, result)\n if result == \"win\"\n tictactoe.players[0].win += 1\n tictactoe.players[1].lose += 1\n elsif result == \"lose\"\n tictactoe.players[0].lose += 1\n tictactoe.players[1].win += 1\n else\n tictactoe.players[0].draw += 1\n tictactoe.players[1].draw += 1\n end\n end",
"def add_match_results(match)\n if match[0][1] == match[1][1]\n team1 = @teams.find { |team| team.name == match[0][0] }\n team2 = @teams.find { |team| team.name == match[1][0] }\n\n team1.score += 1\n team2.score += 1\n else\n winner = match.max_by { |x| x[1] }\n losser = match.min_by { |x| x[1] }\n\n team1 = @teams.find { |team| team.name == winner[0] }\n team2 = @teams.find { |team| team.name == losser[0] }\n\n team1.score += 3\n end\n team1.goals += match[0][1].to_i\n team2.goals += match[1][1].to_i\n end",
"def winning_team\n final_scores = player_collection.reduce(home: 0, away: 0) { |teams_points, next_player|\n case \n when next_player[:location] === :away\n teams_points[:away] += next_player[:points];\n when next_player[:location] === :home\n teams_points[:home] += next_player[:points];\n end\n teams_points; \n }\n winner = final_scores.reduce { |highest_points, team_points| \n highest_points[1] > team_points[1] ? highest_points : team_points; \n }\n game_hash[winner[0]][:team_name]; \nend",
"def victory\n @wins += 1\n end",
"def update_winners\n return true if draw?\n winner.wins_count.increment\n Player.rank.incr(winner.id)\n looser.loose_count.increment\n true\n end",
"def threat_row_for_ai(board)\n defend_spaces = {}\n WINNING_COMBINATIONS.each { |threat| defend_spaces[threat] = 0 }\n WINNING_COMBINATIONS.each do |threat|\n threat.each do |is_x|\n defend_spaces[threat] += 1 if board[is_x] == PLAYER_MARKER\n if board[is_x] == COMPUTER_MARKER\n defend_spaces[threat] = 0\n break\n end\n end\n end\n defend_spaces\nend",
"def place_mine_indicators\n @board.each_with_index do |r, row|\n r.each_with_index do |_c, col|\n unless @board[row][col].is_a_mine\n count = 0\n if row - 1 >= 0\n count += 1 if col - 1 >= 0 && @board[row - 1][col - 1].is_a_mine\n count += 1 if @board[row - 1][col].is_a_mine\n count += 1 if col + 1 < @board.size && @board[row - 1][col + 1].is_a_mine\n end\n count += 1 if col - 1 >= 0 && @board[row][col - 1].is_a_mine\n count += 1 if col + 1 < @board.size && @board[row][col + 1].is_a_mine\n if row + 1 < @board.size\n count += 1 if col - 1 >= 0 && @board[row + 1][col - 1].is_a_mine\n count += 1 if @board[row + 1][col].is_a_mine\n count += 1 if col + 1 < @board.size && @board[row + 1][col + 1].is_a_mine\n end\n @board[row][col].set_value(count)\n end\n end\n end\n end",
"def count_wins(player, computer, wins)\n if winner?(player, computer)\n wins[:User] += 1\n elsif winner?(computer, player)\n wins[:Computer] += 1\n end\nend",
"def set_games_tied()\n @score_count.set_games_tied\n end",
"def create_match_teams(n, match, sport)\n teams_in_sport = Team.all.select{|t| t.sport_id == sport.id}\n teams_that_played = teams_in_sport.sample(n)\n\n teams_that_played.each do |t|\n match_team = MatchTeam.new\n match_team.match = match\n match_team.team = t\n match_team.is_winner = 0\n\n # if match has been played, give it a random score\n if match.is_completed\n match_team.score = rand(50)\n end\n \n match_team.save\n end\n\n # traverse match_teams and assign winners\n if match.is_completed\n match_teams_for_current_match = MatchTeam.all.select{|mt| mt.match == match}\n winner = match_teams_for_current_match.max{ |match_team_1, match_team_2| match_team_1.score <=> match_team_2.score}\n winner.update(is_winner: 1)\n end\n\n\n \nend",
"def add_points(team)\n games_played = Game.where(\"team_one = #{team.id} or team_two = #{team.id}\")\n @rankings[team.name][\"points_for\"] = 0\n @rankings[team.name][\"points_against\"] = 0\n if !games_played.nil?\n games_played.each do |game|\n if !game.winner.nil? && !game.winner_score.nil?\n if team.id == game.winner # if team won, add winner points to PF and losing points to PA\n @rankings[team.name][\"points_for\"] += game.winner_score\n @rankings[team.name][\"points_against\"] += game.loser_score\n else # if team lost, add winner points to PA and losing points to PF\n @rankings[team.name][\"points_for\"] += game.loser_score\n @rankings[team.name][\"points_against\"] += game.winner_score\n end\n end\n end\n end\n end",
"def create_scorecard_template(game_matchups, team_list)\n scorecard_template = {}\n team_list.map{|team| scorecard_template[team] = {wins: 0, losses: 0, ties: 0}}.uniq\n scorecard_template\nend",
"def create_scorecard_template(game_matchups, team_list)\n scorecard_template = {}\n team_list.map{|team| scorecard_template[team] = {wins: 0, losses: 0, ties: 0}}.uniq\n scorecard_template\nend",
"def update_score_from_games!\n return if self.games.count == 0\n score_by_steam_id = {}\n self.games.each do |g|\n # Add one point to winning team, 0 to losing team so that they show up in the keyset when we check later\n if g.radiant_win === true\n score_by_steam_id[g.radiant_team_id] = score_by_steam_id[g.radiant_team_id].to_i + 1\n score_by_steam_id[g.dire_team_id] = score_by_steam_id[g.dire_team_id].to_i\n elsif g.radiant_win === false\n score_by_steam_id[g.radiant_team_id] = score_by_steam_id[g.radiant_team_id].to_i\n score_by_steam_id[g.dire_team_id] = score_by_steam_id[g.dire_team_id].to_i + 1\n end\n end\n\n # OK the keys are team ids, so now save them\n if score_by_steam_id[self.home_participant.id] != nil && score_by_steam_id[self.away_participant.id] != nil\n self.home_score = score_by_steam_id[self.home_participant.id]\n self.away_score = score_by_steam_id[self.away_participant.id]\n self.save!\n else\n puts score_by_steam_id.inspect\n puts self.home_participant_id.inspect\n puts self.away_participant_id.inspect\n puts \"WARNING: teams did not match, not updating match score\"\n end\n end",
"def won_set(player)\n if player.games_won >= 6 and player.opponent.games_won < 5\n player.sets_won += 1\n @player1.games_won = 0\n @player2.games_won = 0\n won_match(player)\n elsif player.games_won == 7\n player.sets_won += 1\n @player1.games_won = 0\n @player2.games_won = 0\n won_match(player)\n end\n end",
"def player_win\n @player_win += 1\n end",
"def initialize\n @player1wins = 0\n @player2wins = 0\n @ties = 0\n end",
"def turn_count\n @board.count{|value| (value==\"X\" || value==\"O\")}\n #counter = 0\n #@board.each do |value|\n # if value ==\"X\" || value == \"O\"\n # counter+=1\n # end\n #end\n #counter\n end",
"def increment_win_score\n PlayerModelContracts.invariant(self)\n @score = @score + 1\n end",
"def accumulate_series_score(winner)\n if winner == 1\n return @player_1_score +=1\n elsif winner == 2\n return @player_2_score +=1\n end\n end",
"def win_pts\n self.score += 1\n end",
"def rank_players(players)\n players.each do |p|\n p.bit_rank = p.rating << 30 |\n p.team_rating << 25 |\n p.conf_rating << 20 |\n p.id\n end\nend",
"def determine_win\n\t\t@win_combos.each do |combo|\n\t\t\tp1 = (@p1_spaces & combo).length\n\t\t\tp2 = (@p2_spaces & combo).length\n\n\t\t\tif p1 == 3\n\t\t\t\treturn 1\n\t\t\t\tp1.games_won += 1\n\t\t\telsif p2 == 3\n\t\t\t\treturn 2\n\t\t\t\tp2.games_won += 1\n\t\t\tend\n\t\tend\n\t\t0\n\tend",
"def wins_ball(winner)\n # TODO: Think it's gross to pass an integer instead of a player object?\n # Then reimplement this method!\n winner.points += 1\n end",
"def update_rankings\n winner = Player.find(winner_id)\n loser = Player.find(loser_id)\n\n if self.draw\n if (winner.rank - loser.rank) < 1\n winner.update_ranking 1\n elsif winner.rank - loser.rank > 1\n loser.update_ranking 1\n end\n else\n if winner.rank < loser.rank\n return\n else\n diff = winner.rank - loser.rank\n loser.update_ranking 1\n winner.update_ranking (diff/2)*-1\n end\n end\n\n\n end",
"def winning_team\n team_p = []\n team_n = []\n\n game_hash.each do | location, team_data|\n temp = 0\n team_data[:players].each do |p_name, stats|\n temp += stats[:points]\n end\n team_n << team_data[:team_name]\n team_p << temp\n end\n\n team_p[0] > team_p[1] ? team_n[0] : team_n[1]\n\nend",
"def rps\n\n\n @user_move=params[\"the_move\"]\n @computer_move= [\"rock\", \"paper\", \"scissors\"].sample\n\n\n if @user_move == @computer_move\n @outcome = \"tied\"\n elsif @user_move == \"paper\" && @computer_move == \"rock\"\n @outcome = \"won\"\n elsif @user_move == \"paper\" && @computer_move == \"scissors\"\n @outcome = \"lost\"\n elsif @user_move == \"scissors\" && @computer_move == \"rock\"\n @outcome = \"lost\"\n elsif @user_move == \"scissors\" && @computer_move == \"paper\"\n @outcome = \"won\"\n elsif @user_move == \"rock\" && @computer_move == \"paper\"\n @outcome = \"lost\"\n elsif @user_move == \"rock\" && @computer_move == \"scissors\"\n @outcome = \"won\"\n end\n\n\n m = Move.new\n m.user_move = @user_move\n m.computer_move = @computer_move\n if @outcome == \"won\"\n m.user_wins = 1\n m.computer_wins = 0\n m.tie= 0\n elsif @outcome == \"lost\"\n m.user_wins = 0\n m.computer_wins = 1\n m.tie= 0\n else\n m.user_wins = 0\n m.computer_wins=0\n m.tie= 1\n end\n\n m.save\n\n @all_moves= Move.all\n @rockwin=Move.where({:user_move => \"rock\",:user_wins => \"1\"}).count\n @paperwin=Move.where({:user_move => \"paper\",:user_wins => \"1\"}).count\n @scissorswin=Move.where({:user_move => \"scissors\",:user_wins => \"1\"}).count\n\n @rocklose=Move.where({:user_move => \"rock\",:computer_wins => \"1\"}).count\n @paperlose=Move.where({:user_move => \"paper\",:computer_wins => \"1\"}).count\n @scissorslose=Move.where({:user_move => \"scissors\",:computer_wins => \"1\"}).count\n\n\n @rocktie=Move.where({:user_move => \"rock\",:user_wins => \"0\", :computer_wins => \"0\"}).count\n @papertie=Move.where({:user_move => \"paper\",:user_wins => \"0\", :computer_wins => \"0\"}).count\n @scissorstie=Move.where({:user_move => \"scissors\",:user_wins => \"0\", :computer_wins => \"0\"}).count\n\n @totalwin=Move.where({:user_wins => \"1\", }).count\n @totallose=Move.where({:computer_wins => \"1\"}).count\n @totaltie=Move.where({:tie => \"1\",}).count\n\n @total = @totalwin + @totallose + @totaltie\n\n\n\n\n render \"rps.html.erb\"\n end",
"def calculate!\n ov = self[:overall]\n ov[:high_night] = {}\n ov[:winners] = {}\n\n self.each do |player_id, st|\n next if player_id == :overall\n\n ## calculate computed stats for player\n st[:nights] += st[:dates].keys.length # if st[:nights] == 0\n st[:high_night] = st[:dates].values.max\n st[:gold_stars] = 1 if st[:nights] == 29\n st[:warps_per_game] = 1.0 * st[:warps] / st[:games] rescue 0\n st[:warps_per_night] = 1.0 * st[:warps] / st[:nights] rescue 0\n st[:games_per_night] = 1.0 * st[:games] / st[:nights] rescue 0\n st[:wins_per_night] = 1.0 * st[:wins] / st[:nights] rescue 0\n st[:wins_per_game] = 1.0 * st[:wins] / st[:games] rescue 0\n\n ## accumulate overall stats\n [:warps, :wins, :cfbs,\n :mystery_factors, :gold_stars]. each do |field|\n ov[field] += st[field]\n end\n [:wimps, :come_ons].each do |field|\n if st[field]\n ov[field] ||= 0\n ov[field] += st[field]\n end\n end\n # nights won calculation\n st[:dates].each do |date,warps|\n ov[:dates][date] += warps\n hnd = ov[:high_night][date] ||= {:players => [], :warps => 0}\n if hnd[:warps] < warps\n hnd[:players] = [player_id]\n hnd[:warps] = warps\n elsif hnd[:warps] == warps\n hnd[:players].push(player_id)\n end\n end\n end\n\n ## update overall computed stats\n st = self[:overall]\n ov[:games] = ov[:wins]\n ov[:nights] = ov[:dates].keys.length\n ov[:nights] = 29 if ov[:nights] == 0 ## provide sane default\n ov[:nights] = ov[:nights_real] if ov[:nights_real]\n ov[:warps_per_game] = 1.0 * ov[:warps] / ov[:games] rescue 0\n ov[:warps_per_night] = 1.0 * ov[:warps] / ov[:nights] rescue 0\n ov[:games_per_night] = 1.0 * ov[:games] / ov[:nights] rescue 0\n ov[:high_night].each do |date,h|\n h[:players].each {|p| self[p][:nights_won] += 1}\n end\n\n ## determine per-stat winners\n # fuck everyone but the top 50 OR those with 50+ warps\n # the 51 below is not a bug\n sorted_players = self.keys.sort{|a,b| self[b][:warps] <=> self[a][:warps]}\n fifty_plus = self.keys.select{|p| self[p][:warps] >= 50}\n eligible = (sorted_players[0..51] | fifty_plus).\n inject(Hash.new(false)) {|acc,p| acc.merge(p => true)}\n [:warps, :games, :nights, :wins, :nights_won, :cfbs,\n :come_ons, :wimps, :warps_per_game, :warps_per_night,\n :games_per_night, :wins_per_game, :high_night].each do |field|\n owf = ov[:winners][field] = {:players => [], :value => 0}\n self.each do |player, st|\n next if player == :overall\n next unless eligible[player]\n if st[field].to_f > owf[:value]\n owf[:players] = [player]\n owf[:value] = st[field]\n elsif st[field] == owf[:value]\n owf[:players].push(player)\n end\n end\n end\n\n ## mark per-stat winners\n ov[:winners].each do |field, win|\n win[:players].each do |player|\n self[player][:winner][field] = true\n end\n end\n\n self\n end",
"def update_counters\n player.plays_count.increment\n opponent.plays_count.increment\n true\n end",
"def team_hits(hits, team)\n if team.current_units <= hits\n team.units.all.each do |u|\n u.update(count:0)\n end\n else\n u = team.units.where(priority:1).first\n while hits > 0 and team.current_units > 0\n if u.count > 0 and hits > 0\n u.update(count: u.count-1)\n hits-=1\n else\n u = u.next\n end\n end\n return team\n end\n end",
"def GamesForSecond(teams)\n return teams+1\nend",
"def turn_count\n counter = 0\n @board.each do |position|\n\n if position == \"X\" || position == \"O\"\n counter += 1\n end\n\n end\n counter\n end",
"def updateGamesPlayed\n @gamesPlayed += 1\n end",
"def wins\n wins = 0\n self.teams.each do |team|\n wins += team.games_won.length\n end\n wins\n end",
"def ranks\n @teams = Team.where(\"wins > 0\t\").order(win_percentage: :desc)\n end",
"def total_wins_by_season_by_team_id(passed_id)\n @by_team_id_game_objects.each do |game|\n if helper_for_win_count(passed_id, game)\n @total_wins_by_season[game[\"season\"]] += 1\n elsif helper_for_loss_count(passed_id, game)\n @total_wins_by_season[game[\"season\"]] += 0\n end\n end\n end",
"def increment_game\n change_turn\n @turn += 1 if @player_to_move == \"w\"\n end",
"def all_player_tally\n tally = Hash.new(0)\n players.each do |player|\n players.each do |against_player|\n winners_between_two_players(player, against_player).each do |winner|\n tally[winner] += 1\n end\n end\n end\n tally\n end",
"def set_played_games()\n @played_games += 1\n end",
"def update_game_won_count(game_count, game_status)\n player_score = game_status[:player_hand]\n dealer_score = game_status[:dealer_hand]\n status = game_status[:current_game_status]\n\n if dealer_score > player_score && dealer_score <= MAX_HAND_VALUE\n game_count[:dealer_wins] += 1\n elsif status.include?('busted') && dealer_score <= MAX_HAND_VALUE\n game_count[:dealer_wins] += 1\n elsif player_score > dealer_score && player_score <= MAX_HAND_VALUE\n game_count[:player_wins] += 1\n elsif player_score <= MAX_HAND_VALUE && dealer_score > MAX_HAND_VALUE\n game_count[:player_wins] += 1\n end\nend",
"def turn_count #counts occupied positions!\n turn = 0 #start at position 0.\n @board.each do |index| #iterating through each spot on the board. Is it occupied?\n if index == \"X\" || index == \"O\" #if there is an X or O in that spot,\n turn += 1 #then you must turn!\n end\n end\n return turn #if there is not an X or O in that spot, take your turn and put your X or O there.\nend",
"def recompute_team\n teams = CollegiateResult.where(:year => @year).all\n teams.each do |team|\n ctc = CollegiateTeamComputer.new(team.pilot_contests)\n result = ctc.compute_result\n team.qualified = result.qualified\n team.points = result.total\n team.points_possible = result.total_possible\n team.update_results(result.combination)\n team.save\n end\n RankComputer.compute_result_rankings(teams)\nend",
"def runCase player_index\n\tp = player_index.sort_by{|val| val[0].power[1]}.reverse\n\ts = 0\n\ttemp = p[s][0]\n\tfor i in 0..player_index.length-2\n\t\tif(temp.power[1]==p[i+1][0].power[1])\n\t\t\twinner = 0\n\t\telsif(temp.power[1]<p[i+1][0].power[1] && temp.power[1]!=3)\n\t\t\twinner = p[i+1][1]\n\t\t\ttemp = p[i+1][0]\n\t\t\ts =i+1\n\t\telsif(temp.power[1]==3 && p[i+1][0].power[1]==14)\n\t\t\twinner = p[i+1][1]\n\t\t\ttemp = p[i+1][0]\n\t\t\ts =i+1\n\t\telse\n\t\t\twinner = p[s][1]\t\t\t\n\t\tend\t\n\tend\nend",
"def updateGamesLost\n @gamesLost += 1\n end",
"def set_won?\n if @games_won == 6 && @opponent.games_won < 5\n @sets_won += 1\n @games_won = 0\n @opponent.games_won = 0\n end\n if @games_won == 7 && @opponent.games_won < 7\n @sets_won += 1\n @games_won = 0\n @opponent.games_won = 0\n end\n end",
"def play_multiple_games(number_of_games, player, opponent)\n\n score = 0\n\n (number_of_games/2).times do\n # player plays :x\n result = play_a_game(player, opponent)\n score += 3 if result == :x_wins\n score += 1 if result == :tie\n\n # player plays :o\n result = play_a_game(opponent, player)\n score += 3 if result == :o_wins\n score += 1 if result == :tie\n end\n\n return score\n\nend",
"def total_runs_by_teams(table_of_teams)\n hash_of_teams = Hash.new(0)\n table_of_teams.each do |table_row|\n hash_of_teams[table_row['batting_team']] += table_row['total_runs'].to_i\n end\n hash_of_teams['Rising Pune Supergiants'] += hash_of_teams['Rising Pune Supergiant']\n hash_of_teams.delete('Rising Pune Supergiant')\n hash_of_teams\nend",
"def win_bet(winnings)\n @bankroll += winnings\n @@bankroll += winnings\n end",
"def rename_team(oldname, newname)\n\t\tcounter = 0\n\t\[email protected]! do |game|\n\t\t\tif game.teams.index(oldname)\n\t\t\t\tgame.teams[game.teams.index(oldname)] = newname \n\t\t\t\tcounter +=1 \n\t\t\tend\n\t\t\tgame\n\t\tend\n\n\t\treturn counter\n\tend",
"def tricks_won_by(team)\n team.map do |actor|\n tricks.fetch(actor)\n end.reduce(:+)\n end",
"def score(player)\n @players[player][:score] += 1\nend",
"def get_standings(games)\n teams = Hash.new\n games.each do |game|\n division_id = game.division_id\n home_team = game.home_team\n away_team = game.visiting_team\n if(teams[home_team.name].nil?)\n teams[home_team.name] = {:win => 0, :loss => 0, :tie => 0, :point=> 0}\n end\n\n if(teams[away_team.name].nil?)\n teams[away_team.name] = {:win => 0, :loss => 0, :tie => 0, :point => 0}\n end\n if(game.home_team_score && game.visiting_team_score)\n if(game.home_team_score > game.visiting_team_score)\n # home team won\n teams[home_team.name][:win] += 1\n teams[home_team.name][:point] += 5\n # visiting team loss\n teams[away_team.name][:loss] += 1\n elsif(game.home_team_score < game.visiting_team_score)\n # home team loss\n teams[home_team.name][:loss] += 1\n #visiting team won\n teams[away_team.name][:win] += 1\n teams[away_team.name][:point] += 5\n else\n # tie game\n teams[home_team.name][:tie] += 1\n teams[home_team.name][:point] += 1\n teams[away_team.name][:tie] += 1\n teams[away_team.name][:point] += 1\n end\n end\n end\n teams.each do |team, value|\n puts team\n total_games = value[:win] + value[:loss] + value[:tie]\n if total_games > 0 \n win_percentage = value[:win]/total_games.to_f\n else\n win_percentage = 0\n end \n value[:percentage] = win_percentage\n end\n teams_sorted = teams.sort_by{ |k, v| v[:point]}.reverse\n return teams_sorted\n end",
"def calculate_results\n players = {}\n @rounds.each do |round|\n round[:results].each do |player,result|\n if not players.has_key?(player)\n players[player] = 0\n end\n if result[:result] == \"Win\"\n players[player] += 1\n end\n end\n end\n winner = players.max_by{|k,v| v}\n players.each do |player, wins|\n @match[player] = {\n \"result\": (player == winner[0]) ? \"Win\" : \"Loss\",\n \"score\": wins\n }\n\t if @duplicate_players then\n\t\t@match[player][:result]= \"Tie\"\n\t end\n\t \n end\n end",
"def turn_count\n count = 0\n @board.each do |token|\n if token.downcase == \"x\" || token.downcase == \"o\"\n count += 1\n end\n end\n count\nend",
"def player_ix_afterthis(num_players, ix_player)\n ix_res = ix_player + 1\n if ix_res >= num_players\n ix_res = 0\n end\n return ix_res\n end",
"def win_insurance_bet(hand, winnings)\n @bankroll += winnings\n @@bankroll += winnings\n #hand.insurance_bet = 0\n end",
"def set_determine_set_winner()\n @score_count.set_determine_set_winner()\n end",
"def total_num_assignment_teams\n assignment_team_counts.inject(:+)\n end",
"def calculate_results\n players = {}\n @rounds.each do |round|\n round[:results].each do |player, result|\n if not players.has_key?(player)\n players[player] = 0\n end\n if result[:result] == \"Win\"\n players[player] += 1\n end\n end\n end\n winner = players.max_by { |k, v| v }\n players.each do |player, wins|\n @match[player] = {\n \"result\": (player == winner[0]) ? \"Win\" : \"Loss\",\n \"score\": wins,\n }\n if @duplicate_players\n @match[player][:result] = \"Tie\"\n end\n end\n end",
"def turn_count\n count = 0\n cells.each {|pos| count += 1 if pos == \"X\" || pos == \"O\"}\n count\n end"
] | [
"0.69255877",
"0.6921832",
"0.684883",
"0.6677194",
"0.6636549",
"0.6626307",
"0.6529275",
"0.6506562",
"0.64514625",
"0.6441589",
"0.6436975",
"0.64307785",
"0.64294165",
"0.64294165",
"0.6406639",
"0.63885665",
"0.6370099",
"0.6370099",
"0.6339386",
"0.63222283",
"0.6306005",
"0.62956923",
"0.6267739",
"0.6232408",
"0.6215206",
"0.620154",
"0.61898476",
"0.61898476",
"0.6181532",
"0.6179281",
"0.6177555",
"0.61653495",
"0.6135058",
"0.6133767",
"0.6133751",
"0.6128746",
"0.612566",
"0.61243707",
"0.6095073",
"0.6093271",
"0.6088288",
"0.6047579",
"0.60095346",
"0.5998535",
"0.59928066",
"0.5991728",
"0.59876347",
"0.5981871",
"0.5980607",
"0.59692633",
"0.5965223",
"0.5958109",
"0.5958109",
"0.5957092",
"0.59512967",
"0.59489685",
"0.59480745",
"0.5933144",
"0.5928111",
"0.5927339",
"0.59231955",
"0.5922061",
"0.5920657",
"0.5919729",
"0.59141874",
"0.5912634",
"0.59086347",
"0.5903527",
"0.5902553",
"0.59025186",
"0.5901631",
"0.589873",
"0.5891234",
"0.58911675",
"0.58830816",
"0.5879261",
"0.5868253",
"0.58657295",
"0.58615947",
"0.5848822",
"0.5843404",
"0.5839883",
"0.58368856",
"0.5827457",
"0.5819407",
"0.58158624",
"0.58155537",
"0.58112466",
"0.5802361",
"0.58006537",
"0.5799717",
"0.57955146",
"0.57912326",
"0.57900244",
"0.57875305",
"0.5785664",
"0.5781168",
"0.5780402",
"0.57797056",
"0.57732415"
] | 0.635054 | 18 |
here's where the problem is (too many "teams") per ruby doc must set value to nil first | def team_select(rankings, team)
which_team = nil
rankings.each do |squad, record|
if squad == team
which_team = record
end
end
which_team
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def teamMemberNull \n \"teamMemberNull\" \n end",
"def team_name\n self.team == nil ? \"\" : self.team.name\n end",
"def team; end",
"def team; end",
"def team; end",
"def team; end",
"def team; end",
"def team; end",
"def seeded_teams\n raise 'Not Implemented'\n end",
"def create_teams_from_teams_playoffs()\n end",
"def restructure_team_data!\n if !site.data['team'].nil? && site.data['team'].respond_to?(:keys)\n site.data['team'].keys.each do |key|\n site.data['team'][site.data['team'][key]['name']] = site.data['team'].delete(key)\n end\n end\n end",
"def init_teams\n init_org if @org.blank?\n @team = Team.where('name is NOT NULL').first_or_create(name: 'development', org_id: @org.id)\n end",
"def set_player_team!\n player.update!(team_name: team_name) if player.team_name != team_name\n piece.update!(team_name: team_name) if piece.team_name != team_name\n end",
"def team\n @team ||= Struct.new(:name, :domain).new(@team_name, @domain)\n end",
"def associated_teams=(value)\n @associated_teams = value\n end",
"def team=(value)\n @team = value\n end",
"def get_involved_teams\n @involved_teams ||= retrieve_involved_teams\n end",
"def known_teams_table\r\n @known_teams_table ||= TextUtils.build_title_table_for( teams )\r\n end",
"def teams\n @teams\n end",
"def check_for_empty_teams(teams, team)\n if teams[team].size == 0\n return student1_index = nil\n else\n return student1_index = rand(teams[team].size)\n end\n end",
"def initialize\n team_objects\n end",
"def poolplay_team_objects\n self.teams.select { |team| !team.playoffs }\n end",
"def set_team_api_default!\n Team.where(api: nil).update_all(api: false)\n end",
"def current_team\n self.teams\n end",
"def assign_team_from_runner\n self.team ||= self.runner.team # same as self.team = self.runner.current_team if self.team.nil?\n end",
"def ranked_teams\n raise 'Not Implemented'\n end",
"def teams\n standings_data = self.standings\n display_teams = []\n\n object.teams.each do |t|\n display_teams << t if standings_data[:data].key?(t.id) && standings_data[:data][t.id][:played] > 0\n end\n\n display_teams\n end",
"def teams\n return [away_team, home_team].compact\n end",
"def populate_neutral_team(unit)\n @teams[@neutral] = Team.new(2) unless neutral\n @teams[@neutral].populate(unit)\n end",
"def populate_neutral_team(unit)\n @teams[@neutral] = Team.new(2) unless neutral\n @teams[@neutral].populate(unit)\n end",
"def set_team_captain\n update(team_captain: users.first) if team_captain.nil? && !users.empty?\n end",
"def teams\n return [og, oo, cg, co];\n end",
"def teams\n @teams ||= ApiFactory.new 'Orgs::Teams'\n end",
"def populate_empty_team\n unless team_is_full?\n available_participants = participants_remaining\n if available_participants.size > 1\n remaining_combinations = available_participants.combination(event.team_size)\n remaining_combinations.each do |combination|\n participants = combination[0, slots_remaining]\n unless flown_in_event?(participants) || flown_in_round?(participants)\n add_participants(participants)\n end\n end\n else\n participants = available_participants[0, slots_remaining]\n unless flown_in_round?(participants)\n add_participants(participants)\n end\n end\n end\n end",
"def set_team\n @team = current_team\n end",
"def improve_teams\n @teams = steepest_ascent_hill(@teams)\n end",
"def on_a_team?\n !team.nil?\n end",
"def swap_member(team)\n team1= team.keys.sample\n team2= team.keys.sample\n while(team2 == team1) do\n team2= team.keys.sample\n end\n student1_index = check_for_empty_teams(team, team1)\n # puts \"nil check4: \" + team[team1].inspect\n student2_index = check_for_empty_teams(team, team2)\n # puts \"nil check5: \" + student2_index.inspect\n if student1_index.nil?\n temp = nil\n else\n temp = team[team1][student1_index]\n end\n # puts \"nil check6: \" + temp.inspect\n\n # puts \"team check: \" + team.inspect\n if student2_index.nil?\n team[team1] = []\n else\n if student1_index.nil?\n team[team1] << team[team2][student2_index]\n else\n team[team1][student1_index]= team[team2][student2_index]\n end\n end\n # puts \"nil check7: \" + team.inspect\n if temp.nil?\n team[team2] = []\n else\n if student2_index.nil?\n team[team2] << temp\n else\n team[team2][student2_index]= temp\n end\n end\n # puts \"nil check8: \" + team.inspect\n # puts\"after swap is\", team.inspect\n return team\n end",
"def deleted_teams=(value)\n @deleted_teams = value\n end",
"def black_turn\n @teams[:white].current_team = false\n @teams[:black].current_team = true\n @current_team = @teams[:black]\n end",
"def past_teams\n Team.find_by_sql([\"SELECT t.* FROM teams t INNER JOIN teams_people tp ON ( t.id = tp.team_id) INNER JOIN users u ON (tp.person_id = u.id) INNER JOIN courses c ON (t.course_id = c.id) WHERE u.id = ? AND (c.semester <> ? OR c.year <> ?)\", self.id, AcademicCalendar.current_semester(), Date.today.year])\n end",
"def match_teams!( line ) ## fix: rename to map_teams!! - remove match_teams!\r\n ## todo: issue depreciated warning\r\n map_teams!( line )\r\n end",
"def match_teams!( line ) ## fix: rename to map_teams!! - remove match_teams!\r\n ## todo: issue depreciated warning\r\n map_teams!( line )\r\n end",
"def team_params\n params.require(:team).permit(:name, :description, :company_id, :opportunity_ids => [], :team_ids => [])\n end",
"def reset_standings\n\t\[email protected]\n\t\[email protected] { |match| update_standings(match) }\n\tend",
"def set_team_captain\n if users.empty?\n users << team_captain unless team_captain.nil?\n elsif team_captain.nil?\n update(team_captain: users.first)\n end\n end",
"def blue_team\n teams[1]\n end",
"def get_teams\r\n response = HTTParty.get('https://www.balldontlie.io/api/v1/teams')[\"data\"]\r\n response.each do |i|\r\n team = Team.new\r\n \r\n team.full_name = i[\"full_name\"]\r\n team.division = i[\"division\"]\r\n team.conference = i[\"conference\"]\r\n\r\n team.save\r\n\r\n end \r\n end",
"def past_teams\n Team.find_by_sql([\"SELECT t.* FROM teams t INNER JOIN team_assignments ta ON ( t.id = ta.team_id) INNER JOIN users u ON (ta.user_id = u.id) INNER JOIN courses c ON (t.course_id = c.id) WHERE u.id = ? AND (c.semester <> ? OR c.year <> ?)\", self.id, AcademicCalendar.current_semester(), Date.today.year])\n end",
"def red_team\n teams[2]\n end",
"def white_turn\n @teams[:white].current_team = true\n @teams[:black].current_team = false\n @current_team = @teams[:white]\n end",
"def update_team\n \n end",
"def is_not_on_staff\n #Team.find(:all) - self.teams\n Team.all - self.teams\n end",
"def teams_unaccepted\n requests.where(is_accepted: false).map(&:team).flatten\n end",
"def my_team\n self.teams.first\n end",
"def get_team_course\n self.course ||= team.course if team\n end",
"def set_team\n @team = Team.find_by_id( params[:id].to_i )\n #@team = @team.decorate if @team\n end",
"def teams_data\n # selected_team = self.class.all[prompt.to_i-1]\n puts \"\"\n puts \"---------------------------\"\n puts \"Team Name: \" + self.full_name\n puts \"City: \" + self.city\n puts \"Division: \" + self.division\n puts \"Conference: \" + self.conference\n puts \"\"\n puts \"---------------------------\"\n end",
"def refresh_team_info(*)\n reload # SQL caching causing users to be empty when creating team making all teams ineligible\n set_team_captain\n set_slots_available\n set_eligibility\n cleanup\n end",
"def team_information_list\n @teams = Team.find_teams_by_user(current_user.id)\n \n end",
"def team\n return self[:team] if self[:team].is_a? Team\n team = if self[:team].split('-').count > 2 or self[:team].to_i > 0 or self.sport.name == 'FWC'\n Team.where(:stats_id => self[:team])\n else\n Team.where(:abbrev => self[:team])\n end\n team.first\n end",
"def team_names\n teams = []\n teams << game_hash[:home][:team_name]\n teams << game_hash[:away][:team_name]\n return teams\nend",
"def get_teams\n doc = Nokogiri::HTML(open(\"http://www.espn.com/mens-college-basketball/teams\"))\n conferences = doc.css(\"div.mod-teams-list-medium\")\n \n # Cycle through conferences filling in the name of each team along with their homepage url\n x = 1\n conferences.each do |conference|\n conf = Conference.find_or_initialize_by(name: conference.css(\"div.mod-header h4\").text)\n conf.id = x\n conf.save\n teams = conference.css(\"ul li\")\n y = 0 \n teams.each do |row|\n team_link = row.css(\"a.bi\")\n team_name = team_link.text\n team_url = team_link[0]['href']\n team = Team.find_or_initialize_by(school: team_name)\n if team\n team.conference_id = x\n team.home_url = team_url\n team.save\n else\n print row\n end\n end\n x += 1\n end\n # Visit each team URL to get the rest of the team info and correct team name\n Team.all.each do |new_team|\n doc = Nokogiri::HTML(open(new_team.home_url))\n header = doc.css(\"div.global-nav-container ul.first-group\")\n school = header.css(\"li.team-name span.link-text-short\").text\n long_name = header.css(\"li.team-name span.link-text\").text\n logo = header.css(\"span.brand-logo img\").attr('src').to_s\n long_name.slice! school\n long_name.strip!\n logo.slice! \"&h=150&w=150\"\n new_team.school = school\n new_team.nickname = long_name\n new_team.logo_url = logo\n new_team.save\n end\n redirect_to teams_path\n end",
"def unknown?\n home_team.nil? && away_team.nil?\n end",
"def test_teams\n trello = load_conf(TrelloHelper, @config.trello, true)\n assert_equal @std_teams, trello.teams\n end",
"def team_members\n if has_team?\n self.supervised ||= Employee.where(id: team_positions.map(&:efective_id))\n else\n Employee.none\n end\n end",
"def prepare_for_new_round\n @teams.each(&:prepare_for_new_round)\n end",
"def prepare_for_new_round\n @teams.each(&:prepare_for_new_round)\n end",
"def get_teams\n self.get_page\n # this step above sets @ec_HtmlTable equal to the HTML code responsible for displaying !!DONE!!\n # the top 8 Eastern Conference Teams, and their seed, record, and name !!DONE!!\n i = 0\n @ecTeams = []\n @wcTeams = []\n # Tables are divided by conference. Table 1 is Eastern !!DONE!!\n @ec_HtmlTable = @html_doc.css(\".wikitable\")[1]\n until i == 8 \n newTeamHtml = @ec_HtmlTable.css(\"tr\")[2 + i].text.split(\"\\n\")\n thisRank = newTeamHtml[1].to_i\n thisName = newTeamHtml[2]\n thisRecord = newTeamHtml[3]\n newTeam = Team.create(thisName, thisRank, 'Eastern', thisRecord)\n @ecTeams << newTeam\n i = i + 1\n end\n # Tables are divided by conference. Table 2 is Western !!DONE!!\n @wc_HtmlTable = @html_doc.css(\".wikitable\")[2]\n j = 0\n until j == 8\n newTeamHtml = @wc_HtmlTable.css(\"tr\")[2 + j].text.split(\"\\n\")\n thisRank = newTeamHtml[1].to_i\n thisName = newTeamHtml[2]\n thisRecord = newTeamHtml[3]\n newTeam = Team.create(thisName, thisRank, 'Western', thisRecord)\n @wcTeams << newTeam\n j = j + 1\n end\n \n end",
"def set_first_teams\n Game::FIRST_MARKETS.each do |market|\n if @game[\"first_#{market}_team_id\".to_sym]\n instance_variable_set(\n \"@first_#{market}_team\", @game.send(\"first_team_to_get\", market).name)\n end\n end\n end",
"def get_teams\n TeamNode.get(node_object_id)\n end",
"def team\n return group\n end",
"def team_params\n params.require(:team).permit(:name, :code, :description, :project_id, :members_count, :managers_count, :is_deleted, :pending_tasks, :status, :team_lead_ids => [], :user_ids => [])\n end",
"def singles_team!\n team = singles_team\n unless team\n team = Team.new\n team.doubles = false\n team.first_player = self\n team.save!\n end\n team\n end",
"def set_team\n\t\t@team = Team.find(params[:team_id])\n\tend",
"def get_teams\n TeamNode.get(self.node_object_id)\n end",
"def test_players_present\n assert_equal([\"Wee Mac\",\"Big John\",\"Sonic T Hedgehog\"], @football_team.players)\n end",
"def team\n fetch('esport.teams')\n end",
"def associated_teams\n return @associated_teams\n end",
"def set_team (game)\n\n\t\tif bet_type == \"lay\"\n \t\tif game.spread < 0\n \t\tself.team = \"home\"\n \t\tend\n \t\tif game.spread > 0\n \t\tself.team = \"away\"\n \t\tend\n\t\tend\n\t\tif bet_type == \"take\"\n\t\t\tif game.spread > 0\n\t\t\t\tself.team = \"home\"\n\t\t\tend\n\t\t\tif game.spread < 0\n\t\t\t\tself.team = \"away\"\n\t\t\tend\n\t\tend\n\t\tif bet_type == \"over\" || bet_type == \"under\"\n\t\t\t\tself.team = \"-\"\n\t\tend\n\tend",
"def set_nomination\n @saec_team = SaecTeam.find(params[:id])\n end",
"def choose_team_start \n if BattleManager.preemptive\n team = Turn_Player\n elsif BattleManager.surprise\n team = Turn_Enemy\n else\n team = (rand(2) == 0) ? Turn_Enemy : Turn_Player\n end\n if ($game_temp.turn_start != nil)\n team = $game_temp.turn_start;\n $game_temp.turn_start = nil;\n end\n set_turn(team) \n end",
"def team_params\n params.require(:team).permit(:leader, :email, :password, :password_confirmation, :phone, :cin, :contest, :date, :robot, :university, :payment_proof, :member1, :member2, :member3, :member4, :member5, :member6, :member7, :status, :active)\n end",
"def team_information_list\n @teams = Team.find_teams_by_user(session[:user_id])\n \n end",
"def teams\n return team_1 + team_2;\n end",
"def create(_team)\n # stub\n end",
"def set_team\n @team = Team.eager_load(:division => :season).find(params[:id])\n end",
"def teams\n return @teams if @teams\n\n @teams ||= @team_abbreviation.split(\", \").map do |team_abbreviation|\n Team.new(team_abbreviation, season: @season)\n end\n\n end",
"def get_teams_from_conf(conf)\n # Gets the html\n doc = getHTML(\"http://espn.com/ncb/conference?confId=#{conf.webExt}\")\n\n # Gets the table with the information\n table = doc.xpath('//table[@class = \"mod-data\"]')\n rows = table.css('tr')\n rows.each do |row|\n col = row.css(\"td\")\n # Most valid conferences have 4 columns\n if(col.count > 2)\n # Gets name and rank combination, then parses for appropiate information\n nameRank = col[0].text.scan((/(#)*(\\d+ )*(.*)/))\n name = nameRank[0][2]\n if(nameRank[0][1] != nil)\n rank = nameRank[0][1]\n else\n rank = -1\n end\n\n # Gets team web extension\n webpage = doc.at_xpath('//a[text()=\"'+name+'\"]')['href']\n webExt = webpage.scan(/(\\d+).*/)[0][0]\n #webExt = webpage.scan(/\\d+.*/)[0]\n \n if(col.count == 4)\n # Gets team conference win/loss\n confWL = col[1].text.scan((/(\\d+)-(\\d+)/))\n confW = confWL[0][0].to_i\n confL = confWL[0][1].to_i\n \n # Gets overall conference win/loss\n ovrWL = col[3].text.scan((/(\\d+)-(\\d+)/))\n ovrW = ovrWL[0][0].to_i\n ovrL = ovrWL[0][1].to_i\n\n # Creates Team Entry\n Team.create(name: name, rank: rank, webExt: webExt, conferenceWins: confW, conferenceLosses: confL, wins: ovrW, losses: ovrL, conference: conf)\n # Independent (No conference) teams only have 3 columns\n elsif(col.count == 3)\n # Gets overall conference win/loss\n ovrWL = col[2].text.scan((/(\\d+)-(\\d+)/))\n ovrW = ovrWL[0][0].to_i\n ovrL = ovrWL[0][1].to_i\n\n # Creates Team Entry\n Team.create(name: name, rank: rank, webExt: webExt, wins: ovrW, losses: ovrL, conference: conf)\n end\n end\n end\n end",
"def teams_are_tbd?\n return team1_id.nil? || team2_id.nil?\n end",
"def sanitize_entries\n if !self.team_first.blank?\n if self.sport == \"football\"\n self.team_first = SportTrade.team_sanitization(self.team_first)\n else\n self.team_first = SportTrade.team_sanitization(self.team_first, false)\n end\n end\n if !self.team_second.blank?\n if self.sport == \"football\"\n self.team_second = SportTrade.team_sanitization(self.team_second)\n else\n self.team_second = SportTrade.team_sanitization(self.team_second, false)\n end\n end\n end",
"def team_name\n return @team_name\n end",
"def set_team\n @team = Team.find_by_id( params[:id].to_i )\n @team = @team.decorate if @team\n end",
"def wants_to_change_team?\n p = params[:namespace]\n p[:team].present? && p[:team] != @namespace.team.name\n end",
"def team_processor(payload)\n team = payload[:team]\n team_list = Hubstats.config.github_config[\"team_list\"] || []\n if team_list.include? team[:name]\n Hubstats::Team.create_or_update(team.with_indifferent_access)\n hubstats_team = Hubstats::Team.where(name: team[:name]).first\n hubstats_user = Hubstats::User.create_or_update(payload[:member])\n Hubstats::Team.update_users_in_team(hubstats_team, hubstats_user, payload[:github_action])\n end\n end",
"def update_event_teams\n if event_teams.size == 2\n event_teams[0].update_attributes({:team_id => self.team1.id})\n event_teams[1].update_attributes({:team_id => self.team2.id})\n end\n end",
"def test_invalid_without_name\n assert_errors_contain @team, :name, 'blank'\n end",
"def test_team_name\n assert_equal(\"Glasgow Celgers\",@football_team.team)\n end",
"def set_games_team\n @games_team = GamesTeam.find(params[:id])\n end",
"def find_fake_team(team_name)\n owner = Owner::TEAM_NAME_MAP.find do |o|\n o[:team_names].keys.include?(team_name.to_sym)\n end\n owner[:team_names][team_name.to_sym]\n end",
"def team_team_members\n if has_team?\n Employee.where(id: team_team_positions.map(&:efective_id))\n else\n Employee.none\n end\n end"
] | [
"0.6976652",
"0.6760137",
"0.66828823",
"0.66828823",
"0.66828823",
"0.66828823",
"0.66828823",
"0.66828823",
"0.65528",
"0.6525773",
"0.6436899",
"0.64116186",
"0.64112914",
"0.6335967",
"0.6278817",
"0.6274347",
"0.6210974",
"0.6187325",
"0.6145864",
"0.61205935",
"0.6061104",
"0.6032162",
"0.5956602",
"0.5941333",
"0.5935372",
"0.5927786",
"0.5923877",
"0.5923369",
"0.5901537",
"0.5900598",
"0.5899545",
"0.58980113",
"0.58886534",
"0.58854175",
"0.588467",
"0.5883254",
"0.5880548",
"0.5842604",
"0.5814512",
"0.5778139",
"0.5776775",
"0.5774844",
"0.5774844",
"0.5747998",
"0.5742598",
"0.5735279",
"0.5707737",
"0.57036364",
"0.5703142",
"0.57013434",
"0.56883514",
"0.5669872",
"0.5661158",
"0.5651627",
"0.56510514",
"0.5642382",
"0.56387985",
"0.563533",
"0.5629905",
"0.56255347",
"0.56172717",
"0.5599418",
"0.55971074",
"0.55951244",
"0.5590698",
"0.5587537",
"0.5582504",
"0.5582504",
"0.558156",
"0.55785656",
"0.5570303",
"0.55564594",
"0.55514264",
"0.55415964",
"0.5517508",
"0.5517215",
"0.5514264",
"0.5507883",
"0.5504588",
"0.5504529",
"0.5493478",
"0.5490761",
"0.5484946",
"0.54802287",
"0.54797447",
"0.5479121",
"0.54632646",
"0.54630053",
"0.54572415",
"0.54566884",
"0.54508615",
"0.54492354",
"0.5444627",
"0.5444498",
"0.5442509",
"0.54406786",
"0.54371315",
"0.54336137",
"0.54328084",
"0.5428453",
"0.54278"
] | 0.0 | -1 |
just grabs team whether they're home or away | def history(points, franchise)
points.select do |game| game[:home_team] == franchise || game[:away_team] == franchise
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_a_team?\n !team.nil?\n end",
"def home_or_away(team_name)\n game_hash[team_name][:status]\nend",
"def unknown?\n home_team.nil? && away_team.nil?\n end",
"def team_by_name(team_name)\n game_hash[:home].has_value?(team_name) ? game_hash[:home] : game_hash[:away]\n end",
"def underdog\n\t if home_team != favorite\n\t home_team\n\t else\n\t visitor_team\n\t end\n\tend",
"def winning_team\n home_points = collection_by_prop(game_hash[:home], :points).reduce(0, :+)\n away_points = collection_by_prop(game_hash[:away], :points).reduce(0, :+)\n home_points > away_points ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\n end",
"def winning_team\n blue_team.winner? ? blue_team : red_team\n end",
"def battingteam\n if (hometeambatted == true)\n \"#{match.hometeam.name}\"\n else\n \"#{match.awayteam.name}\"\n end\n end",
"def find_a_home?\n return \"INPROC\" if build_your_team? == \"DONE\"\n nil\n end",
"def goals_against(team)\n valid = ((team == self.home_team or team == self.away_team) and self.final)\n\n if (valid)\n if (self.home_team == team)\n return self.awayScore\n else\n return self.homeScore\n end\n else\n return 0\n end\n end",
"def goals_for(team)\n valid = ((team == self.home_team or team == self.away_team) and self.final)\n\n if (valid)\n if (self.home_team == team)\n return self.homeScore\n else\n return self.awayScore\n end\n else\n return 0\n end\n end",
"def teams\n return [away_team, home_team].compact\n end",
"def get_teams\n res = Array.new\n\n @games.each do |g|\n #check if home team is in the result array\n if !res.include?(g.home_team)\n res.push(g.home_team)\n end\n\n #check if away team is in the result array\n if !res.include?(g.away_team)\n res.push(g.away_team)\n end\n end\n\n return res\n end",
"def winner\n if (self.homeScore > self.awayScore)\n return self.home_team\n elsif (self.awayScore > self.homeScore)\n return self.away_team\n else\n return nil\n end\n end",
"def result(team)\n # If this team is not in the match, return none\n valid = ((team.id == self.home_team.id or team.id == self.away_team.id) and self.final)\n \n puts \"Valid: #{valid.to_s}\"\n\n if (valid)\n # Figure out if this team won or lost\n if self.winner == team\n return \"WIN\"\n elsif self.tie\n return \"TIE\"\n else\n return \"LOSS\"\n end\n else\n return nil\n end\n end",
"def winning_team(result)\n goals = result.split(\"-\")\n if goals[0] == goals[1]\n \"draw\"\n elsif goals[0].to_i > goals[1].to_i\n \"home\"\n else\n \"away\"\n end\n end",
"def game_over?\n return @gamestate.checkmate?(@current_player.team)\n end",
"def member_of?(team)\n self.team == team\n end",
"def winning_team\n points_home = 0\n points_away = 0\n result = \"\"\n\n game_hash.each do |side,team|\n team.each do |specs,info|\n if specs == :players\n info.each do |player|\n if side = :home\n points_home += player[:points]\n else\n points_away += player[:points]\n end\n end\n end\n end\n end\n if points_home > points_away\n result = game_hash[:home][:team_name]\n else\n result = game_hash[:away][:team_name]\n end\n result\nend",
"def winner_team(game)\n result = nil\n if game.team1_goals.present? && game.team2_goals.present?\n result = game.team1 if game.team1_goals > game.team2_goals\n result = game.team2 if game.team1_goals < game.team2_goals\n end\n\n result\n end",
"def opponent\n\t\thomeaway=='H' ? self.contest.awaycontestant : self.contest.homecontestant\n\tend",
"def away?\n status == :away\n end",
"def home_stat\n @home.team_stat\n end",
"def one_team_stats(team_name)\n game_hash.each do |home_or_away, team_stats|\n if team_stats[:team_name] == team_name\n return team_stats\n end\n end\nend",
"def active?\r\n self.team.active?\r\n end",
"def completed?\n team_winner\n end",
"def team_hitting_pull_up\n return nil unless pull_up?\n team1.stats.wins > team2.stats.wins ? team1 : team2\n end",
"def winner\n if away_won?\n sql = \"SELECT teams.* FROM teams INNER JOIN matches ON matches.away_team_id = teams.id WHERE teams.id = #{@away_team_id}\"\n return Team.map_item(sql)\n elsif home_won?\n sql = \"SELECT teams.* FROM teams INNER JOIN matches ON matches.home_team_id = teams.id WHERE teams.id = #{@home_team_id}\"\n return Team.map_item(sql)\n elsif tie?\n return \"It's a tie\"\n end\nend",
"def winning_team\n home_team_sum = 0\n away_team_sum = 0\n game_hash.each do |team, team_stats|\n if team_stats[:team_name] == \"Brooklyn Nets\"\n team_stats[:players].each do |player_stats|\n home_team_sum += player_stats[:points]\n end\n elsif team_stats[:team_name] == \"Charlotte Hornets\"\n team_stats[:players].each do |player_stats|\n away_team_sum += player_stats[:points]\n end\n end\n end\n if home_team_sum > away_team_sum\n game_hash[:home][:team_name]\n elsif home_team_sum < away_team_sum\n game_hash[:away][:team_name]\n end\nend",
"def is_on_staff\n self.teams\n end",
"def away?\n online? and (presence.show == :away or presence.show == :xa)\n end",
"def white_turn?\n true if @current_team == @teams[:white]\n end",
"def winning_team\n home_team_points = game_hash[:home][:players].sum { |e| e[:points] }\n away_team_points = game_hash[:away][:players].sum { |e| e[:points] }\n\n if home_team_points > away_team_points\n return game_hash[:home][:team_name]\n else\n return game_hash[:away][:team_name]\n end\nend",
"def away_stat\n @away.team_stat\n end",
"def is_host_team\n return @is_host_team\n end",
"def winning_team\n home_points = 0\n away_points = 0\n result = \"\"\n i = 0\n game_hash.each do |team, about|\n about[:players].each do |name , stats|\n if i == 0\n home_points += stats[:points]\n else\n away_points += stats[:points]\n end\n end\n i += 1\n end\n home_points > away_points ? result = game_hash[:home][:team_name] : result = game_hash[:away][:team_name]\nend",
"def winning_team\n home_score = 0\n away_score = 0\n game_hash[:home][:players].keys.each do |name|\n home_score += game_hash[:home][:players][name][:points]\n end\n game_hash[:away][:players].keys.each do |name|\n away_score += game_hash[:away][:players][name][:points]\n end\n home_score > away_score ? game_hash[:home][:team_name] : game_hash[:away][:team_name]\nend",
"def get_team_games(team)\n res = Array.new\n\n @games.each do |g|\n if team == g.home_team\n res.push(g)\n end\n\n if team == g.away_team\n res.push(g)\n end\n end\n\n return res\n end",
"def stats_when_away(season = nil)\n data = stats_request(\"homeAndAway\", season)\n data.find do |s| !s[\"isHome\"] end\n end",
"def is_on_staff?(team)\n self.teams.include?(team)\n end",
"def all_players_for_a_team(team_name, game)\n player_names = []\n game[:home_team][:players].each do |player_hash|\n player_names << player_hash[:player_name] if game[:home_team][:team_name] == team_name\n end\n game[:away_team][:players].each do |player_hash|\n player_names << player_hash[:player_name] if game[:away_team][:team_name] == team_name\n end\n player_names\nend",
"def goals_against(club)\n if finished?\n if club == local\n return guest_goals\n end\n\n if club == guest\n return local_goals\n end\n end\n\n 0\n end",
"def build_your_team?\n return \"DONE\" if (set_budget? == \"DONE\") && (user.team.has_leadplace_agent?) \n return \"INPROC\" if (set_budget? == \"DONE\") && (!user.team.has_leadplace_agent?)\n return nil\n end",
"def team_names\n game = Game.find(self.game_id)\n type = self.bet_type\n if over_under?\n return \"#{game.away_team} vs #{game.home_team}\"\n elsif type == \"lay\"\n if game.spread <= 0\n return game.home_team\n else\n return game.away_team\n end\n else\n if game.spread <= 0\n return game.away_team\n else\n return game.home_team\n end\n end\n end",
"def black_turn?\n true if @current_team == @teams[:black]\n end",
"def team_colors(team_name)\n (game_hash[:home][:team_name] == team_name.to_s) ? team = :home : team = :away\n game_hash[team][:colors]\nend",
"def stats_when_home(season = nil)\n data = stats_request(\"homeAndAway\", season)\n data.find do |s| s[\"isHome\"] end\n end",
"def winning_team\n if homeTeamPoints.sum > awayTeamPoints.sum\n \"Brooklyn Nets\"\n else\n \"Charlotte Hornets\"\n end\nend",
"def winning_team\n home_points = 0\n away_points = 0\n team1 = \"Brooklyn Nets\"\n team2 = \"Charlotte Hornets\"\n game_hash.each do |team,info|\n info.each do |team_info,team_data|\n if team_data.is_a? (Array) \n if team_info != :colors\n if info[:team_name] == \"Brooklyn Nets\"\n team_data.each do |player_index|\n home_points += player_index[:points]\n end\n else \n team_data.each do |player_index|\n away_points += player_index[:points]\n winning_team end\n end\n end\n end\n end\n end\n\n if home_points > away_points\n team1\n else\n team2\n end\n\nend",
"def near_team_winner?(team)\n unless completed?\n sets_won(team) + 1 == min_sets_to_play\n end\n end",
"def team_for_user(user)\n membership = TeamMembership.find_by user: user, team: teams\n membership && membership.team\n end",
"def is_not_on_staff\n #Team.find(:all) - self.teams\n Team.all - self.teams\n end",
"def team_colors(team_name)\n if team_name == \"Brooklyn Nets\"\n game_hash[:home][:colors]\n else\n game_hash[:away][:colors]\n end\nend",
"def team\n teams.where(hubstats: true).first\n end",
"def team_names\n team_names = []\n game_hash.each do |home_or_away, team_stats|\n team_names << team_stats[:team_name]\n end\n team_names\nend",
"def athlete_result?\n !team_result?\n end",
"def players_in_landings(result)\n @round.group_to_display.players.find_all do |player|\n player_result = player.ball&.result\n if player.ball.nil?\n false\n elsif player.ball.shot.is_layup\n result == 'layup'\n elsif result == 'MC-Ch'\n player_result.to_i > 0\n else\n player_result&.sub(/\\*\\z/, '') == result\n end\n end\n end",
"def singles?\n self.team.singles?\n end",
"def team_names\n teams = []\n teams << game_hash[:home][:team_name]\n teams << game_hash[:away][:team_name]\n return teams\nend",
"def team\n @team = :true\n render '/home/landing'\n end",
"def doubles?\n self.team.doubles?\n end",
"def build_match(home_team, away_team)\n raise 'Not Implemented'\n end",
"def team; end",
"def team; end",
"def team; end",
"def team; end",
"def team; end",
"def team; end",
"def blue_team\n teams[1]\n end",
"def upcoming_matches\n matches = Event.upcoming.map do |ev| \n match = ev.wattball_match\n\n # Get non-null matches that the team is playing in\n match if match and (match.team1 == self or match.team2 == self)\n end\n\n matches.compact\n end",
"def winning_team_with_spread\n\t\tif self.final?\n\t\t\treturn home_team_id if home_team_score > away_team_score + point_spread\n\t\t\treturn away_team_id if away_team_score + point_spread > home_team_score\n\t\t\treturn \"tie\" if home_team_score == away_team_score + point_spread\n\t\telse\n\t\t\treturn nil\n\t\tend\n\tend",
"def on_team?(team)\n\t\tif team.is_a?(Team)\n\t\t\tself.team.id == team.id\n\t\telse\n\t\t\tteam.map(&:id).include?(self.team.id)\n\t\tend\n\tend",
"def update_teams\n if (home_team != nil and away_team != nil)\n puts \"Updating teams\"\n #match = Matchup.new(params)\n home_team.updateResults(self)\n away_team.updateResults(self)\n home_team.save\n away_team.save\n else\n return false\n end\n end",
"def team_colors(team_name)\n if team_name == \"Brooklyn Nets\"\n return game_hash[:home][:colors]\n else\n return game_hash[:away][:colors]\n end \nend",
"def is_looser?(club)\n if self.finished?\n if self.local_goals > self.guest_goals\n if club == guest\n return true\n end\n end\n\n if self.guest_goals > self.local_goals\n if club == local\n return true\n end\n end\n end\n\n return false\n end",
"def team_names\n [\n game_hash.dig(:home, :team_name),\n game_hash.dig(:away, :team_name)\n ]\nend",
"def check_mate(team)\n # If the team's king is under check, and the team has no valid moves -> Check mate\n # If the team's king is not under check, and the team has no valid moves -> Stale mate\n moves = valid_moves(team)\n if team == :white\n if @w_check && moves.empty?\n return true, :check_mate\n elsif !@w_check && moves.empty?\n return true, :stale_mate\n else\n return false, nil\n end\n else\n if @b_check && moves.empty?\n return true, :check_mate\n elsif !@b_check && moves.empty?\n return true, :stale_mate\n else\n return false, nil\n end\n end\n end",
"def is_winner?(club)\n if self.finished?\n if self.local_goals > self.guest_goals\n if local == club\n return true\n end\n end\n\n if self.guest_goals > self.local_goals\n if guest == club\n return true\n end\n end\n end\n return false\n end",
"def winning_team\n final_scores = player_collection.reduce(home: 0, away: 0) { |teams_points, next_player|\n case \n when next_player[:location] === :away\n teams_points[:away] += next_player[:points];\n when next_player[:location] === :home\n teams_points[:home] += next_player[:points];\n end\n teams_points; \n }\n winner = final_scores.reduce { |highest_points, team_points| \n highest_points[1] > team_points[1] ? highest_points : team_points; \n }\n game_hash[winner[0]][:team_name]; \nend",
"def team_of_player(player)\n if player\n if first_team.include_player?(player)\n first_team\n elsif second_team.include_player?(player)\n second_team\n end\n end\n end",
"def player_data_by_team(team)\n players = []\n if team == game_hash[:home][:team_name]\n players << game_hash[:home][:players]\n else\n players << game_hash[:away][:players]\n end\n return players.flatten\nend",
"def team\n\t\t\trobot.team\n\t\tend",
"def lobby\n games(game_state: \"lobby\").any? ? games(game_state: \"lobby\")[0] : false\n end",
"def team_names\n game_hash.collect {|home_or_away, stats| team_name = stats[:team_name].to_s}\nend",
"def team_with_more_points(game)\n home_points = game[:home_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n away_points = game[:away_team][:players].collect do |player|\n player[:stats][:points]\n end.inject {|sum, n| sum + n}\n home_points > away_points ? game[:home_team][:team_name] : game[:away_team][:team_name]\nend",
"def away?\n self.state == :away\n end",
"def goals_favor(club)\n if finished?\n\n if club == local\n return local_goals\n end\n\n if club == guest\n return guest_goals\n end\n end\n\n 0\n end",
"def team\n return self[:team] if self[:team].is_a? Team\n team = if self[:team].split('-').count > 2 or self[:team].to_i > 0 or self.sport.name == 'FWC'\n Team.where(:stats_id => self[:team])\n else\n Team.where(:abbrev => self[:team])\n end\n team.first\n end",
"def teams\n standings_data = self.standings\n display_teams = []\n\n object.teams.each do |t|\n display_teams << t if standings_data[:data].key?(t.id) && standings_data[:data][t.id][:played] > 0\n end\n\n display_teams\n end",
"def player_stats(name)\nhome = game_hash[:home][:players][name]\naway = game_hash[:away][:players][name]\n\nif home != nil\n home\n else\n away\nend\nend",
"def team\n fetch('esport.teams')\n end",
"def go_home\n return unless can_go_home? && wants_to_go_home?\n pack_bags\n get_tickets\n board_plane\nend",
"def get_live_league_games\n\tcurrent_matches = []\n\tDota.live_leagues.each do |match|\n\t\tif match.raw_live_league['dire_team'] && match.raw_live_league['radiant_team']\n\t\t\tcurrent_matches.push(match)\n\n\t\tend\n\tend\n\n\t#puts 'New Matches:'\n\tcurrent_matches.sort! { |a, b| b.lobby_id <=> a.lobby_id }\n\tcurrent_matches\nend",
"def team_names\n data = game_hash\n all_teams = []\n \n data.each_pair do |home_away, home_away_hash|\n home_away_hash.each_pair do |team_key, team_value|\n \n if team_key == :team_name\n all_teams << team_value\n end\n \n end\n end\n all_teams\nend",
"def find_teams(league)\n teams = []\n league.each do |team|\n teams << team[:home_team]\n teams << team[:away_team]\n end\n uniq_teams = teams.uniq!\nend",
"def another_team?\n puts \"Would you Like to view another Team's Players?(Yes or No to Exit)\"\n another_team_input = gets.strip.upcase\n check_end_of_program(another_team_input)\n puts \"Which team Would you Like to view?\"\n list_teams\n start\n another_team?\n end",
"def is_team_member?\n self.dig_for_boolean(\"isTeamMember\")\n end",
"def set_team (game)\n\n\t\tif bet_type == \"lay\"\n \t\tif game.spread < 0\n \t\tself.team = \"home\"\n \t\tend\n \t\tif game.spread > 0\n \t\tself.team = \"away\"\n \t\tend\n\t\tend\n\t\tif bet_type == \"take\"\n\t\t\tif game.spread > 0\n\t\t\t\tself.team = \"home\"\n\t\t\tend\n\t\t\tif game.spread < 0\n\t\t\t\tself.team = \"away\"\n\t\t\tend\n\t\tend\n\t\tif bet_type == \"over\" || bet_type == \"under\"\n\t\t\t\tself.team = \"-\"\n\t\tend\n\tend",
"def poolplay_team_objects\n self.teams.select { |team| !team.playoffs }\n end",
"def standings_including(team)\n placings.reject { |p| p.team.exhibition? && p.team != team }\n end",
"def team_names\n teams = []\n teams << game_hash[:home][:team_name] << game_hash[:away][:team_name]\nend"
] | [
"0.74025136",
"0.73247683",
"0.72621953",
"0.7255744",
"0.71175635",
"0.7105282",
"0.7098272",
"0.7076492",
"0.7028028",
"0.6957928",
"0.683459",
"0.6798574",
"0.6782553",
"0.67339087",
"0.6712164",
"0.6706998",
"0.66466796",
"0.6637259",
"0.6619452",
"0.6613861",
"0.65859944",
"0.6560523",
"0.65568525",
"0.6526947",
"0.651092",
"0.6509825",
"0.648692",
"0.6473519",
"0.646933",
"0.64673233",
"0.6466955",
"0.6446703",
"0.6431226",
"0.64278466",
"0.6423527",
"0.64204484",
"0.6407569",
"0.6402331",
"0.6400199",
"0.63713825",
"0.6358919",
"0.6357931",
"0.6356048",
"0.6353362",
"0.6344771",
"0.6341783",
"0.63411754",
"0.63342834",
"0.63311857",
"0.6330725",
"0.6322924",
"0.62792915",
"0.6263147",
"0.62610096",
"0.6237432",
"0.62366813",
"0.62226325",
"0.62141675",
"0.6192196",
"0.61840534",
"0.617977",
"0.6163779",
"0.6151079",
"0.6151079",
"0.6151079",
"0.6151079",
"0.6151079",
"0.6151079",
"0.6149644",
"0.61475194",
"0.6145303",
"0.61377156",
"0.6132882",
"0.61324465",
"0.61307555",
"0.6122239",
"0.61031383",
"0.60942286",
"0.60740715",
"0.60720044",
"0.606023",
"0.6053152",
"0.60334194",
"0.60268736",
"0.6010534",
"0.6006532",
"0.60015774",
"0.5998319",
"0.59946",
"0.59941703",
"0.59824926",
"0.59799033",
"0.59778607",
"0.597485",
"0.59711504",
"0.59652555",
"0.59610933",
"0.595758",
"0.5953204",
"0.5949618",
"0.5949224"
] | 0.0 | -1 |
Preview this email at | def unlock_instructions
CustomMailer.unlock_instructions
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preview\n @email = Email.find(params[:id])\n render :text => @email.body\n end",
"def preview\n @email = DirectEmail.find(params[:id])\n render :text => @email.body\n end",
"def preview\n @email = EventEmail.find(params[:id])\n render :text => @email.body\n end",
"def preview_email\r\n invitation = Invitation.new(:user => current_user, :code => Code.new)\r\n mail = Mailers::Debate.create_invitation(current_user, @resource, invitation)\r\n @mail_body = mail.body.sub('No message provided', 'YOUR PERSONALIZED NOTE GOES HERE')\r\n\r\n render :inline => %Q{<%= simple_format(@mail_body, {:style => 'margin: 8px 0px'}) %>}\r\n end",
"def demo\n preview(DemoMailer.demo)\n end",
"def demo\n preview(DemoMailer.demo)\n end",
"def call(email, params = {})\n preview = new(params)\n message = preview.public_send(email)\n inform_preview_interceptors(message)\n message\n end",
"def call(email)\n preview = self.new\n preview.public_send(email)\n end",
"def preview_newsletter\n @newsletter = @structure.newsletters.friendly.find params[:id]\n\n # Send email to no recipients to generate mail object\n mail = NewsletterMailer.send_newsletter(@newsletter, nil)\n @body = MailerPreviewer.preview(mail)\n\n render layout: false\n end",
"def preview\n task = MailTasks::Task.new( params[:task] )\n recipient = StoreUser.find( params[:id], :include => \"customer\", :readonly => true )\n mail = task.generate_mails( [recipient], false, mail_layout_options ).first\n render :text => mail.content_with_layout( mail_layout_options ), :layout => false\n # rescue => exception\n # headers[\"Content-Type\"] = \"text/plain\"\n # render :text => exception.to_yaml, :layout => false\n end",
"def preview_to(recipient)\n @newsletter = build_newsletter\n mail = build_mail\n mail.to = recipient.email\n replace_and_send_mail_safely(mail, recipient)\n end",
"def show_body\n I18n.with_locale @email_locale do\n @mail_body = mail_body(@preview, @part_type)\n render :show_body, layout: 'rails_email_preview/email'\n end\n end",
"def process_explanation_mail\n petition = Petition.where(status: 'live').first\n PetitionMailer.process_explanation_mail(Petition.live.first)\n end",
"def content_for_preview( layout_options )\r\n content = self.body.dup\r\n content.gsub!( /<%=\\s?(@[^%]+)\\s?%>/, '<code>\\1</code>' )\r\n mail = Mail.new( :token => \"\" )\r\n mail.content = Render::Base.new( content ).mail_content\r\n template = IO.read(\"#{RAILS_ROOT}/app/views/mail_tasks/mailer/this_mail.text.html.rhtml\")\r\n \r\n render = Render::Base.new( template, layout_options.merge( :mail => mail ) )\r\n render.mail_content\r\n end",
"def preview\n frm.button(:value=>\"Preview\").click\n PreviewAnnouncements.new(@browser)\n end",
"def compose_email\n @title = t 'conclusion_draft_review.send_by_email'\n end",
"def preview\n end",
"def preview\n end",
"def show\n @decrypted = @autocrypt.decrypt(@email)\n @reply_params = {\n to: @email.from,\n subject: 'Re: ' + @email.subject,\n body: (@decrypted || @email.body).gsub(/^/, '> ')\n }\n end",
"def preview\n attachments.first.file.url(:preview)\n rescue StandardError => exc\n logger.error(\"Message for the log file while retrieving preview #{exc.message}\")\n 'empty_file.png'\n end",
"def preview\n redirect_to preview_url\n end",
"def preview\n @text = params[:deliverable][:description]\n render :partial => 'common/preview'\n end",
"def preview_announcement(subject)\n frm.link(:text=>subject).click\n PreviewAnnouncements.new(@browser)\n end",
"def show\n if @sent_email.photo.nil?\n @display_name = ''\n @title = ''\n @flickr_url = ''\n else\n @display_name = @sent_email.photo.member.display_name\n @title = @sent_email.photo.title\n @flickr_url = @sent_email.photo.get_flickr_url\n end\n end",
"def preview\n frm.button(:value=>\"Preview\").click\n AssignmentsPreview.new(@browser)\n end",
"def preview\n frm.button(:value=>\"Preview\").click\n AssignmentsPreview.new(@browser)\n end",
"def send_preview(recipients, personalize=\"fallback\")\n options = { :body => {\n :PreviewRecipients => recipients.kind_of?(String) ? [ recipients ] : recipients,\n :Personalize => personalize }.to_json }\n response = post \"sendpreview\", options\n end",
"def create\n @mail = Mail.new(params[:mail])\n @mail.user = current_user\n \n if params[:preview_button] || [email protected]\n render :action => \"new\"\n else\n flash[:notice] = 'Mail was successfully created.'\n redirect_to(@mail)\n end\n end",
"def last_message_preview=(value)\n @last_message_preview = value\n end",
"def edit\n yield @editor\n @mail = @editor.mail\n @message = @mail.to_s\n end",
"def preview_text\n return @preview_text\n end",
"def preview_text\n return @preview_text\n end",
"def preview\n return @preview\n end",
"def inspect\n \"#<Envelope::Message to=#{formatted_to} from=#{formatted_from} cc=#{formatted_cc} bcc=#{formatted_bcc} reply_to=#{formatted_reply_to} subject=\\\"#{subject}\\\" text_part=\\\"#{preview = (text_part || html_part); (preview && preview.gsub(/\\s+/, ' ') || 'No preview available')[0..50]}...\\\">\"\n end",
"def petition_announcement_mail\n petition = Petition.where(status: 'live').first\n PetitionMailer.petition_announcement_mail(Petition.live.first)\n end",
"def preview\n frm.link(:text=>\"Preview\").click\n PreviewOverview.new(@browser)\n end",
"def preview() @page.find(input_elements[:preview]) end",
"def preview(channel_id, msg_id, data)\n channel_config, message_config, text =\n prepare_message(channel_id, msg_id, data)\n chats = channel_config.chat_ids\n connector = channel_config.connector\n\n if message_allowed?(message_config, data)\n connector.preview(chats, text, message_config)\n else\n puts \"No message sent beacuse it's not allowed\"\n end\n end",
"def improve_and_reopen_mail\n petition = Petition.where(status: 'live').first\n PetitionMailer.improve_and_reopen_mail(Petition.live.first)\n end",
"def hand_over_to_office_mail\n petition = Petition.where(status: 'live').first\n PetitionMailer.hand_over_to_office_mail(Petition.live.first)\n end",
"def content_preview\n self.send(content_preview_method)\n end",
"def write_about_hand_over_mail\n petition = Petition.where(status: 'live').first\n PetitionMailer.write_about_hand_over_mail(Petition.live.first)\n end",
"def preview\n order = current_user.orders.find_by_cookbook_id(params[:id])\n @cookbook = (order) ? order.cookbook : current_cookbook\n preview_path = \"#{PDF_PREVIEW_FOLDER}/preview_cookbook-#{@cookbook.id}_#{Time.now.to_i}.pdf\"\n session[:preview_filename] = preview_path\n preview = CookbookPreviewWorker.new(\n cookbook: @cookbook, \n filename: preview_path\n )\n preview.cookbook\n render \"previews/preview\"\n end",
"def preview=(value)\n @preview = value\n end",
"def preview_path_for_attachment(attachment)\n preview_attachment_path(id: attachment.attachment_data.id, file: attachment.filename.split('.').first, extension: attachment.file_extension)\n end",
"def preview(attachment, options)\n Rails.application.routes.url_helpers.rails_representation_path(attachment.preview(options), only_path: true)\n end",
"def preview_doc\n @tpl = Template.find(params[\"template_id\"]) \n output = @tpl.render_by_model_id(params[:id], 'print', 'www.freightoperations.com:8080')\n render(:text => output, :layout => false) \n end",
"def preview\n frm.button(:value=>\"Preview\").click\n @@file_number=0\n AssignmentStudentPreview.new(@browser)\n end",
"def preview\n frm.button(:value=>\"Preview\").click\n @@file_number=0\n AssignmentStudentPreview.new(@browser)\n end",
"def last_message_preview\n return @last_message_preview\n end",
"def preview\n @preview ||= Preview.new(self) #if has_preview?\n end",
"def tweet_reviewed_by_influencer(tweet)\n @tweet = tweet\n\n set_attachments\n\n mail(to: tweet.campaign.advertiser.user.email, subject: \"Notificaciones @ Social Target - Uno de tus tweets fue revisado/modificado por una empresa\")\n end",
"def body_preview=(value)\n @body_preview = value\n end",
"def preview\n content[0..19]\n end",
"def view(review, recipient)\n @review = review\n\n mail(to: recipient.email, subject: \"#{@review.review_type == \"cto\" ? @review.booking.user.first_name : @review.booking.offer.user.first_name} vous a laissé un commentaire\")\n end",
"def new_review_email (review)\n\t@book = review.book\n\t@review = review\n\tmail :to => @book.readers.collect{|r| r.email},\n\t :subject=>\"New review for #{@book.title}\"\n end",
"def preview(element_key)\n parameter = { basic_auth: @auth }\n self.class.get(\"/elements/#{element_key}/preview\", parameter)\n end",
"def open\n mail = MailTasks::Mail.find_by_token( params[:id] )\n raise ActiveRecord::RecordNotFound unless mail # raise 404 if mail is not found\n \n options = {\n :post_back_url => url_for( :controller => \"/email\", :action => \"red_logo\" ),\n :base => [request.protocol, request.host].join\n }\n render :text => mail.content_with_layout( options ), :layout => false\n end",
"def emailOnMetareview(revieweeId)\r\n puts \"in Metareview\"\r\n participant = Participant.find_by_id(revieweeId).user_id\r\n asstId = Participant.find_by_id(revieweeId).parent_id\r\n user=User.find_by_id(participant)\r\n assignment=Assignment.find_by_id(asstId).name\r\n partialName=\"email_on_review_of_review\"\r\n if(user.email_on_review_of_review)\r\n email(user.email,\"Metareview\",ApplicationHelper::get_user_first_name(user),assignment,partialName)\r\n end\r\n end",
"def body_preview\n return @body_preview\n end",
"def preview(*)\n nil\n end",
"def preview(*)\n nil\n end",
"def preview\n preview_path = \"#{PDF_PREVIEW_FOLDER}/preview_extra_page-#{@extra_page.id}_#{Time.now.to_i}.pdf\"\n session[:preview_filename] = preview_path\n preview = CookbookPreviewWorker.new(\n cookbook: current_cookbook, \n filename: preview_path\n )\n preview.extra_page @extra_page.id\n render \"previews/preview\"\n end",
"def reference_number_mail\n petition = Petition.where(status: 'live').first\n PetitionMailer.reference_number_mail(Petition.live.first)\n end",
"def ask_office_for_answer_mail\n petition = Petition.where(status: 'live').first\n PetitionMailer.ask_office_for_answer_mail(Petition.live.first)\n end",
"def show\n set_retail\n end",
"def preview_name\n name.sub(/Preview$/, '').underscore\n end",
"def preview\n mixpanel_tab_event(\"View Item\", \"Get Preview URL\")\n begin\n embed_url = user_client.embed_url(params[:id])\n redirect_to embed_url\n rescue\n redirect_to no_support_url\n end\n\n end",
"def blog_preview\n object._challenge\n end",
"def show\n session[:applicant_token] = params[:id] unless current_user\n @email = ERB.new(Settings.email_template).result(get_binding)\n p EMAIL: @email\n end",
"def ping_reviewer(review)\n\n to_list = [review[:user].email]\n cc_list = []\n subject = 'Your unresolved Design Review(s)'\n\n @user = review[:user]\n @result = review[:results]\n \n if review[:urgent]\n attachments.inline['warning.png'] = File.read('app/assets/images/warning.png')\n headers['Importance'] = 'high'\n headers['X-Priority'] = '1'\n headers['X-MSMail-Priority'] = 'High'\n end\n\n mail( :to => to_list,\n :subject => subject,\n :cc => cc_list,\n ) \n end",
"def preview_text(maxlength = 30)\n return \"\" if description.blank?\n my_contents = description[\"contents\"]\n return \"\" if my_contents.blank?\n content_flagged_as_preview = my_contents.select { |a| a[\"take_me_for_preview\"] }.first\n if content_flagged_as_preview.blank?\n content_to_take_as_preview = my_contents.first\n else\n content_to_take_as_preview = content_flagged_as_preview\n end\n preview_content = self.contents.select { |content| content.name == content_to_take_as_preview[\"name\"] }.first\n return \"\" if preview_content.blank? || preview_content.essence.blank?\n text = preview_content.essence.preview_text(maxlength)\n text.size > maxlength ? \"#{text[0..maxlength]}...\" : text\n end",
"def link_to_preview(text, type_id, *args)\n link_to_function text, \"CCPEVE.showPreview(#{type_id.inspect})\", *args\n end",
"def preview_text=(value)\n @preview_text = value\n end",
"def preview_text=(value)\n @preview_text = value\n end",
"def resume_confirm(email, username, filename)\n subject 'You have uploaded your resume to YouIntern'\n recipients email\n from '[email protected]'\n sent_on Time.now\n \n body :username => username, :filename => filename\n end",
"def preview_text(max_length = 30)\n attachment&.name.to_s[0..max_length - 1]\n end",
"def display_resume\n\t profile_resume = Profile.find_by_id(params[:id]).resume\n send_data(profile_resume.attachment_binary.data,\n\t\t\t\t :filename => profile_resume.name,\n\t\t\t\t :type => profile_resume.content_type,\n\t\t\t\t :disposition => \"attachment\"\n\t\t\t\t )\n end",
"def generate_complete_timeline_preview_url(given_timeline_id)\n tl_entry_to_use = Timeline.find(given_timeline_id)\n target_page_path = timeline_path(tl_entry_to_use)\n \n protocol_host_port = \"#{request.protocol}#{request.host_with_port}\"\n main_url = \"#{protocol_host_port}#{target_page_path}?preview=true\"\n \n url_to_return = URI::encode(main_url)\n return url_to_return\n end",
"def preview(article)\n unless article.published_at.nil?\n article_path(article)\n else\n preview_path(article.preview_hash)\n end\n end",
"def post_edit_email\n NotificationMailer.post_edit_email('[email protected]')\n end",
"def reviewed(inquiry)\n @inquiry = inquiry\n mail to: inquiry.email, subject: 'Verteo Biopharma Inquiry Reviewed'\n end",
"def update\n @mail = Mail.find(params[:id]) \n if [email protected]_attributes(params[:mail]) || params[:preview_button]\n \n render :action => \"edit\"\n else\n flash[:notice] = 'Mail was successfully updated.'\n redirect_to(@mail)\n end\n end",
"def to_s\n \"Last Modified: #{@modifiedAt}\\nStatus: #{@status}\\nAssigned to: #{@owner}\\nSubject: #{@subject}\\n#{@preview}\"\n end",
"def show\n #TRACKER.track(current_user['email'], \"READ_EMAIL\", {\"email_id\" => @email.id, \"email_reference\" => @email.reference_id})\n TRACKER.track(current_user['email'], \"READ_EMAIL\", @email.id, @email.reference_id)\n end",
"def preview!(purchase)\n post(purchase, \"#{collection_path}/preview\")\n end",
"def preview!(purchase)\n post(purchase, \"#{collection_path}/preview\")\n end",
"def preview\n begin\n page = Comatose::Page.new(params[:page])\n page.author = current_user\n if params.has_key? :version\n content = page.to_html( {'params'=>params.stringify_keys, 'version'=>params[:version]} )\n else\n content = page.to_html( {'params'=>params.stringify_keys} )\n end\n rescue SyntaxError\n content = \"<p>There was an error generating the preview.</p><p><pre>#{$!.to_s.gsub(/\\</, '<')}</pre></p>\"\n rescue\n content = \"<p>There was an error generating the preview.</p><p><pre>#{$!.to_s.gsub(/\\</, '<')}</pre></p>\"\n end\n render :text=>content, :layout => false\n end",
"def show\n # notification_email\n end",
"def preview\n self.content.split(' ')[0...5].join(' ') + '...'\n end",
"def apply(interviewee,interviewer)\n @interviewee = interviewee\n @interviewer = interviewer\n mail(to: @interviewee.email + \",\" + @interviewer.email, subject: '面接日程承認のお知らせ')\n end",
"def to_s\n '#<Twilio::REST::Preview>'\n end",
"def to_s\n '#<Twilio::REST::Preview>'\n end",
"def email_approved_proposal\n ProposalMailer.email_approved_proposal\n end",
"def preview_submit\n @story = Story.find(params[:submission])\n @story_slam_preview = true # to hide/show certain things in the header\n end",
"def set_preview\n @preview = Preview.find(params[:id])\n end",
"def preview_msg(msg_params_with_name)\n uri = 'cgi-bin/operate_appmsg?sub=preview&t=ajax-appmsg-preview'\\\n \"&type=10&token=#{@token}&lang=zh_CN\"\n headers = {\n referer: 'https://mp.weixin.qq.com/cgi-bin/appmsg?t=media/appmsg_edit'\\\n \"&action=edit&type=10&isMul=0&isNew=1&lang=zh_CN&token=#{@token}\",\n host: 'mp.weixin.qq.com',\n x_requested_with: 'XMLHttpRequest'\n }\n resource = RestClient::Resource.new(@home_url, headers: headers, cookies: @cookies)\n\n res = resource[uri].post msg_params_with_name\n # \"ret\":\"0\", \"msg\":\"preview send success!\", \"appMsgId\":\"201796045\", \"fakeid\":\"\"\n JSON.parse res.to_s\n end",
"def review_posted(email,permalink) \n @service_permalink = permalink \n subject = \"A review was posted for your service\"\n setup_email(email, subject)\n end",
"def preview_cover\n preview_path = \"#{PDF_PREVIEW_FOLDER}/preview_cover-#{current_cookbook.id}_#{Time.now.to_i}.pdf\"\n session[:preview_filename] = preview_path\n preview = CookbookPreviewWorker.new(\n cookbook: current_cookbook, \n filename: preview_path\n )\n preview.cover\n render \"previews/preview\"\n end",
"def emailOnReview(revieweeId)\r\n puts \"we are in email on review\"\r\n @team_member = TeamsUser.find_all_by_team_id(revieweeId)\r\n asstId = Team.find_by_id(revieweeId).parent_id\r\n assignment=Assignment.find_by_id(asstId).name\r\n partialName=\"email_on_review\"\r\n @team_member.each do |team_Member|\r\n # get parameters for sending mail\r\n user=User.find_by_id(team_Member.user_id)\r\n puts \"teammate name = #(user.name)\"\r\n if(user.email_on_review)\r\n email(user.email,\"Review\",ApplicationHelper::get_user_first_name(user),assignment,partialName)\r\n end\r\n end\r\n end",
"def preview_edit\n\n layout_style = nil\n if (params[:layout])\n layout_style = params[:layout]\n end\n\n\n begin\n @bulletin = Bulletin.find(params[:id])\n @bulletin_layout = @bulletin.layout_for_editing(layout_style, self)\n headers[\"Content-Type\"] = @bulletin_layout.filetype + \"; charset=\" + @bulletin_layout.charset\n render :text => @bulletin_layout.rendered, :layout => 'bulletin'\n return\n rescue SyntaxError\n @error = _('A fatal error has occurred while compiling the temlpate!') + \n '<br /><br />ERROR: '+$!\n end\n render :action => 'error', :layout => 'bulletin'\n end"
] | [
"0.71475905",
"0.71186084",
"0.70552814",
"0.6985626",
"0.6848472",
"0.6848472",
"0.6832406",
"0.6663229",
"0.64324814",
"0.631654",
"0.6304366",
"0.6181875",
"0.6167911",
"0.61338973",
"0.61305445",
"0.6115152",
"0.61100966",
"0.61100966",
"0.60882556",
"0.60132533",
"0.5982547",
"0.5970752",
"0.5921947",
"0.5854165",
"0.58256847",
"0.58256847",
"0.5801412",
"0.5798907",
"0.57861274",
"0.5756108",
"0.57435614",
"0.57311475",
"0.5694853",
"0.5693586",
"0.56733876",
"0.56689703",
"0.5667859",
"0.56230783",
"0.5584482",
"0.5580056",
"0.556691",
"0.5565034",
"0.553256",
"0.55282027",
"0.5521174",
"0.55182135",
"0.54865557",
"0.54802716",
"0.54802716",
"0.5475045",
"0.54698133",
"0.5462231",
"0.54592174",
"0.5457588",
"0.54561025",
"0.5434102",
"0.54326165",
"0.5418592",
"0.5416024",
"0.5406969",
"0.5398783",
"0.5398783",
"0.5390498",
"0.53865004",
"0.53677875",
"0.5354904",
"0.53483963",
"0.53450906",
"0.53428084",
"0.5339015",
"0.5331245",
"0.5324016",
"0.5320464",
"0.52986485",
"0.52971554",
"0.52956325",
"0.52885884",
"0.52866477",
"0.52858466",
"0.52848935",
"0.5274558",
"0.52651525",
"0.5261375",
"0.5255958",
"0.52543974",
"0.52372897",
"0.52372897",
"0.5235101",
"0.522828",
"0.5226132",
"0.5213765",
"0.52118236",
"0.52118236",
"0.52064675",
"0.5192629",
"0.5186882",
"0.5167913",
"0.51622766",
"0.5158241",
"0.515572",
"0.5152641"
] | 0.0 | -1 |
Preview this email at | def confirmation_instructions
CustomMailer.confirmation_instructions
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preview\n @email = Email.find(params[:id])\n render :text => @email.body\n end",
"def preview\n @email = DirectEmail.find(params[:id])\n render :text => @email.body\n end",
"def preview\n @email = EventEmail.find(params[:id])\n render :text => @email.body\n end",
"def preview_email\r\n invitation = Invitation.new(:user => current_user, :code => Code.new)\r\n mail = Mailers::Debate.create_invitation(current_user, @resource, invitation)\r\n @mail_body = mail.body.sub('No message provided', 'YOUR PERSONALIZED NOTE GOES HERE')\r\n\r\n render :inline => %Q{<%= simple_format(@mail_body, {:style => 'margin: 8px 0px'}) %>}\r\n end",
"def demo\n preview(DemoMailer.demo)\n end",
"def demo\n preview(DemoMailer.demo)\n end",
"def call(email, params = {})\n preview = new(params)\n message = preview.public_send(email)\n inform_preview_interceptors(message)\n message\n end",
"def call(email)\n preview = self.new\n preview.public_send(email)\n end",
"def preview_newsletter\n @newsletter = @structure.newsletters.friendly.find params[:id]\n\n # Send email to no recipients to generate mail object\n mail = NewsletterMailer.send_newsletter(@newsletter, nil)\n @body = MailerPreviewer.preview(mail)\n\n render layout: false\n end",
"def preview\n task = MailTasks::Task.new( params[:task] )\n recipient = StoreUser.find( params[:id], :include => \"customer\", :readonly => true )\n mail = task.generate_mails( [recipient], false, mail_layout_options ).first\n render :text => mail.content_with_layout( mail_layout_options ), :layout => false\n # rescue => exception\n # headers[\"Content-Type\"] = \"text/plain\"\n # render :text => exception.to_yaml, :layout => false\n end",
"def preview_to(recipient)\n @newsletter = build_newsletter\n mail = build_mail\n mail.to = recipient.email\n replace_and_send_mail_safely(mail, recipient)\n end",
"def show_body\n I18n.with_locale @email_locale do\n @mail_body = mail_body(@preview, @part_type)\n render :show_body, layout: 'rails_email_preview/email'\n end\n end",
"def process_explanation_mail\n petition = Petition.where(status: 'live').first\n PetitionMailer.process_explanation_mail(Petition.live.first)\n end",
"def content_for_preview( layout_options )\r\n content = self.body.dup\r\n content.gsub!( /<%=\\s?(@[^%]+)\\s?%>/, '<code>\\1</code>' )\r\n mail = Mail.new( :token => \"\" )\r\n mail.content = Render::Base.new( content ).mail_content\r\n template = IO.read(\"#{RAILS_ROOT}/app/views/mail_tasks/mailer/this_mail.text.html.rhtml\")\r\n \r\n render = Render::Base.new( template, layout_options.merge( :mail => mail ) )\r\n render.mail_content\r\n end",
"def preview\n frm.button(:value=>\"Preview\").click\n PreviewAnnouncements.new(@browser)\n end",
"def compose_email\n @title = t 'conclusion_draft_review.send_by_email'\n end",
"def preview\n end",
"def preview\n end",
"def show\n @decrypted = @autocrypt.decrypt(@email)\n @reply_params = {\n to: @email.from,\n subject: 'Re: ' + @email.subject,\n body: (@decrypted || @email.body).gsub(/^/, '> ')\n }\n end",
"def preview\n attachments.first.file.url(:preview)\n rescue StandardError => exc\n logger.error(\"Message for the log file while retrieving preview #{exc.message}\")\n 'empty_file.png'\n end",
"def preview\n redirect_to preview_url\n end",
"def preview\n @text = params[:deliverable][:description]\n render :partial => 'common/preview'\n end",
"def preview_announcement(subject)\n frm.link(:text=>subject).click\n PreviewAnnouncements.new(@browser)\n end",
"def show\n if @sent_email.photo.nil?\n @display_name = ''\n @title = ''\n @flickr_url = ''\n else\n @display_name = @sent_email.photo.member.display_name\n @title = @sent_email.photo.title\n @flickr_url = @sent_email.photo.get_flickr_url\n end\n end",
"def preview\n frm.button(:value=>\"Preview\").click\n AssignmentsPreview.new(@browser)\n end",
"def preview\n frm.button(:value=>\"Preview\").click\n AssignmentsPreview.new(@browser)\n end",
"def send_preview(recipients, personalize=\"fallback\")\n options = { :body => {\n :PreviewRecipients => recipients.kind_of?(String) ? [ recipients ] : recipients,\n :Personalize => personalize }.to_json }\n response = post \"sendpreview\", options\n end",
"def create\n @mail = Mail.new(params[:mail])\n @mail.user = current_user\n \n if params[:preview_button] || [email protected]\n render :action => \"new\"\n else\n flash[:notice] = 'Mail was successfully created.'\n redirect_to(@mail)\n end\n end",
"def last_message_preview=(value)\n @last_message_preview = value\n end",
"def edit\n yield @editor\n @mail = @editor.mail\n @message = @mail.to_s\n end",
"def preview_text\n return @preview_text\n end",
"def preview_text\n return @preview_text\n end",
"def preview\n return @preview\n end",
"def inspect\n \"#<Envelope::Message to=#{formatted_to} from=#{formatted_from} cc=#{formatted_cc} bcc=#{formatted_bcc} reply_to=#{formatted_reply_to} subject=\\\"#{subject}\\\" text_part=\\\"#{preview = (text_part || html_part); (preview && preview.gsub(/\\s+/, ' ') || 'No preview available')[0..50]}...\\\">\"\n end",
"def petition_announcement_mail\n petition = Petition.where(status: 'live').first\n PetitionMailer.petition_announcement_mail(Petition.live.first)\n end",
"def preview\n frm.link(:text=>\"Preview\").click\n PreviewOverview.new(@browser)\n end",
"def preview() @page.find(input_elements[:preview]) end",
"def preview(channel_id, msg_id, data)\n channel_config, message_config, text =\n prepare_message(channel_id, msg_id, data)\n chats = channel_config.chat_ids\n connector = channel_config.connector\n\n if message_allowed?(message_config, data)\n connector.preview(chats, text, message_config)\n else\n puts \"No message sent beacuse it's not allowed\"\n end\n end",
"def improve_and_reopen_mail\n petition = Petition.where(status: 'live').first\n PetitionMailer.improve_and_reopen_mail(Petition.live.first)\n end",
"def hand_over_to_office_mail\n petition = Petition.where(status: 'live').first\n PetitionMailer.hand_over_to_office_mail(Petition.live.first)\n end",
"def content_preview\n self.send(content_preview_method)\n end",
"def write_about_hand_over_mail\n petition = Petition.where(status: 'live').first\n PetitionMailer.write_about_hand_over_mail(Petition.live.first)\n end",
"def preview\n order = current_user.orders.find_by_cookbook_id(params[:id])\n @cookbook = (order) ? order.cookbook : current_cookbook\n preview_path = \"#{PDF_PREVIEW_FOLDER}/preview_cookbook-#{@cookbook.id}_#{Time.now.to_i}.pdf\"\n session[:preview_filename] = preview_path\n preview = CookbookPreviewWorker.new(\n cookbook: @cookbook, \n filename: preview_path\n )\n preview.cookbook\n render \"previews/preview\"\n end",
"def preview=(value)\n @preview = value\n end",
"def preview_path_for_attachment(attachment)\n preview_attachment_path(id: attachment.attachment_data.id, file: attachment.filename.split('.').first, extension: attachment.file_extension)\n end",
"def preview(attachment, options)\n Rails.application.routes.url_helpers.rails_representation_path(attachment.preview(options), only_path: true)\n end",
"def preview_doc\n @tpl = Template.find(params[\"template_id\"]) \n output = @tpl.render_by_model_id(params[:id], 'print', 'www.freightoperations.com:8080')\n render(:text => output, :layout => false) \n end",
"def preview\n frm.button(:value=>\"Preview\").click\n @@file_number=0\n AssignmentStudentPreview.new(@browser)\n end",
"def preview\n frm.button(:value=>\"Preview\").click\n @@file_number=0\n AssignmentStudentPreview.new(@browser)\n end",
"def last_message_preview\n return @last_message_preview\n end",
"def preview\n @preview ||= Preview.new(self) #if has_preview?\n end",
"def tweet_reviewed_by_influencer(tweet)\n @tweet = tweet\n\n set_attachments\n\n mail(to: tweet.campaign.advertiser.user.email, subject: \"Notificaciones @ Social Target - Uno de tus tweets fue revisado/modificado por una empresa\")\n end",
"def body_preview=(value)\n @body_preview = value\n end",
"def preview\n content[0..19]\n end",
"def view(review, recipient)\n @review = review\n\n mail(to: recipient.email, subject: \"#{@review.review_type == \"cto\" ? @review.booking.user.first_name : @review.booking.offer.user.first_name} vous a laissé un commentaire\")\n end",
"def new_review_email (review)\n\t@book = review.book\n\t@review = review\n\tmail :to => @book.readers.collect{|r| r.email},\n\t :subject=>\"New review for #{@book.title}\"\n end",
"def preview(element_key)\n parameter = { basic_auth: @auth }\n self.class.get(\"/elements/#{element_key}/preview\", parameter)\n end",
"def open\n mail = MailTasks::Mail.find_by_token( params[:id] )\n raise ActiveRecord::RecordNotFound unless mail # raise 404 if mail is not found\n \n options = {\n :post_back_url => url_for( :controller => \"/email\", :action => \"red_logo\" ),\n :base => [request.protocol, request.host].join\n }\n render :text => mail.content_with_layout( options ), :layout => false\n end",
"def emailOnMetareview(revieweeId)\r\n puts \"in Metareview\"\r\n participant = Participant.find_by_id(revieweeId).user_id\r\n asstId = Participant.find_by_id(revieweeId).parent_id\r\n user=User.find_by_id(participant)\r\n assignment=Assignment.find_by_id(asstId).name\r\n partialName=\"email_on_review_of_review\"\r\n if(user.email_on_review_of_review)\r\n email(user.email,\"Metareview\",ApplicationHelper::get_user_first_name(user),assignment,partialName)\r\n end\r\n end",
"def body_preview\n return @body_preview\n end",
"def preview(*)\n nil\n end",
"def preview(*)\n nil\n end",
"def preview\n preview_path = \"#{PDF_PREVIEW_FOLDER}/preview_extra_page-#{@extra_page.id}_#{Time.now.to_i}.pdf\"\n session[:preview_filename] = preview_path\n preview = CookbookPreviewWorker.new(\n cookbook: current_cookbook, \n filename: preview_path\n )\n preview.extra_page @extra_page.id\n render \"previews/preview\"\n end",
"def reference_number_mail\n petition = Petition.where(status: 'live').first\n PetitionMailer.reference_number_mail(Petition.live.first)\n end",
"def ask_office_for_answer_mail\n petition = Petition.where(status: 'live').first\n PetitionMailer.ask_office_for_answer_mail(Petition.live.first)\n end",
"def show\n set_retail\n end",
"def preview_name\n name.sub(/Preview$/, '').underscore\n end",
"def preview\n mixpanel_tab_event(\"View Item\", \"Get Preview URL\")\n begin\n embed_url = user_client.embed_url(params[:id])\n redirect_to embed_url\n rescue\n redirect_to no_support_url\n end\n\n end",
"def blog_preview\n object._challenge\n end",
"def show\n session[:applicant_token] = params[:id] unless current_user\n @email = ERB.new(Settings.email_template).result(get_binding)\n p EMAIL: @email\n end",
"def ping_reviewer(review)\n\n to_list = [review[:user].email]\n cc_list = []\n subject = 'Your unresolved Design Review(s)'\n\n @user = review[:user]\n @result = review[:results]\n \n if review[:urgent]\n attachments.inline['warning.png'] = File.read('app/assets/images/warning.png')\n headers['Importance'] = 'high'\n headers['X-Priority'] = '1'\n headers['X-MSMail-Priority'] = 'High'\n end\n\n mail( :to => to_list,\n :subject => subject,\n :cc => cc_list,\n ) \n end",
"def preview_text(maxlength = 30)\n return \"\" if description.blank?\n my_contents = description[\"contents\"]\n return \"\" if my_contents.blank?\n content_flagged_as_preview = my_contents.select { |a| a[\"take_me_for_preview\"] }.first\n if content_flagged_as_preview.blank?\n content_to_take_as_preview = my_contents.first\n else\n content_to_take_as_preview = content_flagged_as_preview\n end\n preview_content = self.contents.select { |content| content.name == content_to_take_as_preview[\"name\"] }.first\n return \"\" if preview_content.blank? || preview_content.essence.blank?\n text = preview_content.essence.preview_text(maxlength)\n text.size > maxlength ? \"#{text[0..maxlength]}...\" : text\n end",
"def link_to_preview(text, type_id, *args)\n link_to_function text, \"CCPEVE.showPreview(#{type_id.inspect})\", *args\n end",
"def preview_text=(value)\n @preview_text = value\n end",
"def preview_text=(value)\n @preview_text = value\n end",
"def resume_confirm(email, username, filename)\n subject 'You have uploaded your resume to YouIntern'\n recipients email\n from '[email protected]'\n sent_on Time.now\n \n body :username => username, :filename => filename\n end",
"def preview_text(max_length = 30)\n attachment&.name.to_s[0..max_length - 1]\n end",
"def display_resume\n\t profile_resume = Profile.find_by_id(params[:id]).resume\n send_data(profile_resume.attachment_binary.data,\n\t\t\t\t :filename => profile_resume.name,\n\t\t\t\t :type => profile_resume.content_type,\n\t\t\t\t :disposition => \"attachment\"\n\t\t\t\t )\n end",
"def generate_complete_timeline_preview_url(given_timeline_id)\n tl_entry_to_use = Timeline.find(given_timeline_id)\n target_page_path = timeline_path(tl_entry_to_use)\n \n protocol_host_port = \"#{request.protocol}#{request.host_with_port}\"\n main_url = \"#{protocol_host_port}#{target_page_path}?preview=true\"\n \n url_to_return = URI::encode(main_url)\n return url_to_return\n end",
"def preview(article)\n unless article.published_at.nil?\n article_path(article)\n else\n preview_path(article.preview_hash)\n end\n end",
"def post_edit_email\n NotificationMailer.post_edit_email('[email protected]')\n end",
"def reviewed(inquiry)\n @inquiry = inquiry\n mail to: inquiry.email, subject: 'Verteo Biopharma Inquiry Reviewed'\n end",
"def update\n @mail = Mail.find(params[:id]) \n if [email protected]_attributes(params[:mail]) || params[:preview_button]\n \n render :action => \"edit\"\n else\n flash[:notice] = 'Mail was successfully updated.'\n redirect_to(@mail)\n end\n end",
"def to_s\n \"Last Modified: #{@modifiedAt}\\nStatus: #{@status}\\nAssigned to: #{@owner}\\nSubject: #{@subject}\\n#{@preview}\"\n end",
"def show\n #TRACKER.track(current_user['email'], \"READ_EMAIL\", {\"email_id\" => @email.id, \"email_reference\" => @email.reference_id})\n TRACKER.track(current_user['email'], \"READ_EMAIL\", @email.id, @email.reference_id)\n end",
"def preview!(purchase)\n post(purchase, \"#{collection_path}/preview\")\n end",
"def preview!(purchase)\n post(purchase, \"#{collection_path}/preview\")\n end",
"def preview\n begin\n page = Comatose::Page.new(params[:page])\n page.author = current_user\n if params.has_key? :version\n content = page.to_html( {'params'=>params.stringify_keys, 'version'=>params[:version]} )\n else\n content = page.to_html( {'params'=>params.stringify_keys} )\n end\n rescue SyntaxError\n content = \"<p>There was an error generating the preview.</p><p><pre>#{$!.to_s.gsub(/\\</, '<')}</pre></p>\"\n rescue\n content = \"<p>There was an error generating the preview.</p><p><pre>#{$!.to_s.gsub(/\\</, '<')}</pre></p>\"\n end\n render :text=>content, :layout => false\n end",
"def show\n # notification_email\n end",
"def preview\n self.content.split(' ')[0...5].join(' ') + '...'\n end",
"def apply(interviewee,interviewer)\n @interviewee = interviewee\n @interviewer = interviewer\n mail(to: @interviewee.email + \",\" + @interviewer.email, subject: '面接日程承認のお知らせ')\n end",
"def to_s\n '#<Twilio::REST::Preview>'\n end",
"def to_s\n '#<Twilio::REST::Preview>'\n end",
"def email_approved_proposal\n ProposalMailer.email_approved_proposal\n end",
"def preview_submit\n @story = Story.find(params[:submission])\n @story_slam_preview = true # to hide/show certain things in the header\n end",
"def set_preview\n @preview = Preview.find(params[:id])\n end",
"def preview_msg(msg_params_with_name)\n uri = 'cgi-bin/operate_appmsg?sub=preview&t=ajax-appmsg-preview'\\\n \"&type=10&token=#{@token}&lang=zh_CN\"\n headers = {\n referer: 'https://mp.weixin.qq.com/cgi-bin/appmsg?t=media/appmsg_edit'\\\n \"&action=edit&type=10&isMul=0&isNew=1&lang=zh_CN&token=#{@token}\",\n host: 'mp.weixin.qq.com',\n x_requested_with: 'XMLHttpRequest'\n }\n resource = RestClient::Resource.new(@home_url, headers: headers, cookies: @cookies)\n\n res = resource[uri].post msg_params_with_name\n # \"ret\":\"0\", \"msg\":\"preview send success!\", \"appMsgId\":\"201796045\", \"fakeid\":\"\"\n JSON.parse res.to_s\n end",
"def review_posted(email,permalink) \n @service_permalink = permalink \n subject = \"A review was posted for your service\"\n setup_email(email, subject)\n end",
"def preview_cover\n preview_path = \"#{PDF_PREVIEW_FOLDER}/preview_cover-#{current_cookbook.id}_#{Time.now.to_i}.pdf\"\n session[:preview_filename] = preview_path\n preview = CookbookPreviewWorker.new(\n cookbook: current_cookbook, \n filename: preview_path\n )\n preview.cover\n render \"previews/preview\"\n end",
"def emailOnReview(revieweeId)\r\n puts \"we are in email on review\"\r\n @team_member = TeamsUser.find_all_by_team_id(revieweeId)\r\n asstId = Team.find_by_id(revieweeId).parent_id\r\n assignment=Assignment.find_by_id(asstId).name\r\n partialName=\"email_on_review\"\r\n @team_member.each do |team_Member|\r\n # get parameters for sending mail\r\n user=User.find_by_id(team_Member.user_id)\r\n puts \"teammate name = #(user.name)\"\r\n if(user.email_on_review)\r\n email(user.email,\"Review\",ApplicationHelper::get_user_first_name(user),assignment,partialName)\r\n end\r\n end\r\n end",
"def preview_edit\n\n layout_style = nil\n if (params[:layout])\n layout_style = params[:layout]\n end\n\n\n begin\n @bulletin = Bulletin.find(params[:id])\n @bulletin_layout = @bulletin.layout_for_editing(layout_style, self)\n headers[\"Content-Type\"] = @bulletin_layout.filetype + \"; charset=\" + @bulletin_layout.charset\n render :text => @bulletin_layout.rendered, :layout => 'bulletin'\n return\n rescue SyntaxError\n @error = _('A fatal error has occurred while compiling the temlpate!') + \n '<br /><br />ERROR: '+$!\n end\n render :action => 'error', :layout => 'bulletin'\n end"
] | [
"0.71475905",
"0.71186084",
"0.70552814",
"0.6985626",
"0.6848472",
"0.6848472",
"0.6832406",
"0.6663229",
"0.64324814",
"0.631654",
"0.6304366",
"0.6181875",
"0.6167911",
"0.61338973",
"0.61305445",
"0.6115152",
"0.61100966",
"0.61100966",
"0.60882556",
"0.60132533",
"0.5982547",
"0.5970752",
"0.5921947",
"0.5854165",
"0.58256847",
"0.58256847",
"0.5801412",
"0.5798907",
"0.57861274",
"0.5756108",
"0.57435614",
"0.57311475",
"0.5694853",
"0.5693586",
"0.56733876",
"0.56689703",
"0.5667859",
"0.56230783",
"0.5584482",
"0.5580056",
"0.556691",
"0.5565034",
"0.553256",
"0.55282027",
"0.5521174",
"0.55182135",
"0.54865557",
"0.54802716",
"0.54802716",
"0.5475045",
"0.54698133",
"0.5462231",
"0.54592174",
"0.5457588",
"0.54561025",
"0.5434102",
"0.54326165",
"0.5418592",
"0.5416024",
"0.5406969",
"0.5398783",
"0.5398783",
"0.5390498",
"0.53865004",
"0.53677875",
"0.5354904",
"0.53483963",
"0.53450906",
"0.53428084",
"0.5339015",
"0.5331245",
"0.5324016",
"0.5320464",
"0.52986485",
"0.52971554",
"0.52956325",
"0.52885884",
"0.52866477",
"0.52858466",
"0.52848935",
"0.5274558",
"0.52651525",
"0.5261375",
"0.5255958",
"0.52543974",
"0.52372897",
"0.52372897",
"0.5235101",
"0.522828",
"0.5226132",
"0.5213765",
"0.52118236",
"0.52118236",
"0.52064675",
"0.5192629",
"0.5186882",
"0.5167913",
"0.51622766",
"0.5158241",
"0.515572",
"0.5152641"
] | 0.0 | -1 |
return true if the current user has already rated the other user | def rating?(user)
rates.find_by(user_id: user.id, rating_id: id)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rated_by?(user)\n rating && rating.user_ratings.exists?(:user_id => user)\n end",
"def rated_by?(user)\n ratings.where(user_id: user.id).exist?\n end",
"def rated_by_user?(user)\n rtn = false\n if user\n self.ratings.each { |b|\n rtn = true if user.id == b.user_id\n }\n end\n rtn\n end",
"def rated_by_current_user?(user)\n self.appearance_ratings.exists?(:user_id => user)\n end",
"def rated_by?( user )\n\t\t\t\t\tratings.detect {|r| r.user_id == user.id }\n\t\t\t\tend",
"def rated_by_user?(user)\n rtn = false\n if user\n self.ratings.each { |b|\n rtn = true if (user.id == b.rater_id && b.rater_type == \"User\")\n }\n end\n rtn\n end",
"def reviewing?(other_user)\n reviewing.include?(other_user)\n end",
"def rated_by?(user, dimension = nil)\n !rate_by(user, dimension).nil?\n end",
"def voted_on?(user)\n return !self.ratings.find_by_user_id(user.id).nil?\n end",
"def can_rate?(person)\n person != self.reviewer && person != self.reviewee && !self.rated_by?(person)\n end",
"def rated?\n liked_by_count > 0 || disliked_by_count > 0\n end",
"def rateable_by?(user)\n self.user.rateable_by?(user)\n end",
"def rateable_by?(user)\n self.user.rateable_by?(user)\n end",
"def user_rated?(*user_ids)\n users = @user_ratings.map(&:user_id)\n user_ids.map { |user_id| users.include?(user_id) }.all?\n end",
"def is_locked_by_other?(current_user)\n is_locked? and user_locked != current_user.id\n end",
"def can_refresh?(other)\n mrrt? && (authority == other.authority) &&\n (user_info == other.user_info) && (client_id == other.client_id)\n end",
"def user_is_old? user\n return user.logins_number > 1\n end",
"def user_already_reviewed(movie)\n \t@user_already_reviewed = -1\n \tif user_signed_in? \n\n\t reviewFound = movie.reviews.where('user_id' => current_user.id).first\n\t if reviewFound && reviewFound.status == true\n\t @user_already_reviewed = 0\n\t elsif reviewFound && reviewFound.status == false\n\t @user_already_reviewed = 1\n\t elsif movie.user_id == current_user.id\n\t @user_already_reviewed = 2\n\t end\n\tend\n \treturn @user_already_reviewed\nend",
"def donating_to?(other_user)\n return true if self.donating_to == (other_user)\n end",
"def already_liked_by?(current_user)\n return false unless current_user\n self.likes.where(:user_id => current_user.id).count > 0\n end",
"def voted\n\t\tcurrent_user = User.current_user\n\t\tunless current_user.blank?\n\t\t\tcurrent_user.voted?(self)\n\t\telse\n\t\t\tfalse\n\t\tend \n\tend",
"def rated_by?(rater)\n get_rating_for(rater).present?\n end",
"def voted_by?(user)\n !!vote_ups.find_by_user_id(user.id) if user\n end",
"def user_switched?(coop)\n @user.coop_id != coop\n end",
"def user?(user)\n user.id == self.user_id if user\n end",
"def cannot_wink_user_with_the_same_age_type\n\t\twinking_user = User.find(user_id)\n\t\twinked_user = User.find(wink_id)\n\n\t\tif (winking_user.is_old? == winked_user.is_old?)\n\t\t\terrors.add(:base, \"אי אפשר לקרוץ למשתמש באותה קבוצת גיל כמוך\")\n\t\tend\n\tend",
"def require_same_user\n @profile = Profile.find(params[:id])\n if @profile.user_id != current_user.id\n flash[:danger] = \"You are not right User to made this changes\"\n redirect_to root_path\n end\n end",
"def current_user_is_reviewer?(current_user_id)\n get_logged_in_reviewer_id(current_user_id) != nil\n end",
"def user_voted?(user)\n !!users_vote(user)\n end",
"def rated_by\n liked_by + disliked_by\n end",
"def rated_by\n liked_by + disliked_by\n end",
"def rated_by\n liked_by + disliked_by\n end",
"def check_if_current_user\r\n User.current_user && User.current_user != self\r\n end",
"def user_already_voted?(user_ip)\n self.votes.all(:user_ip => user_ip).count > 0\n end",
"def donors?(other_user)\n\t\tdonors.include?(other_user)\n\tend",
"def user?(user)\n self.user_id == user.id if user\n end",
"def user?(user)\n self.user_id == user.id if user\n end",
"def user?(user)\n self.user_id == user.id if user\n end",
"def correct_user(user)\n user == current_user\n end",
"def rated_by?(user_id, opts = {})\n ratings.exists?(:user_id => user_id, :conditions => opts)\n end",
"def is_this_user\n\t\[email protected] == current_user.id\n\tend",
"def already_voted_by_user?(the_user)\n post_vote_array(the_user).present?\n end",
"def matched?(other_user)\n matched.include?(other_user)\n end",
"def following_user?(other_user)\n following_users.include?(other_user)\n end",
"def calculate_rating?\n return true if self.rated_at.nil?\n \n self.rated_at <= [ rand(12), 1 ].max.hours.ago # do not kill the db\n end",
"def operational?\n @user1_confirmed && @user2_confirmed\n end",
"def check (u1, u2)\r\n\t\tif @user_ratings[u1].nil?\r\n\t\t\tputs \"u1 is not registered\"\r\n\t\t\treturn 0\r\n\t\tend\r\n\t\tif @user_ratings[u2].nil?\r\n\t\t\tputs \"u2 is not registered\"\r\n\t\t\treturn 0\r\n\t\tend\r\n\t\treturn 1\r\n\tend",
"def user_voted?(naming, user)\n !lookup_naming(naming).users_vote(user).nil?\n end",
"def advising?(other_user)\n advisees.include?(other_user)\n end",
"def rated?(provider)\n\t\tratings.find_by(provider: provider)\n\tend",
"def following_user?(other_user)\n following.include?(other_user)\n end",
"def subscribing?(other_user)\n subscribing.include?(other_user)\n end",
"def require_same_user\n if current_user != @user\n flash[:error] = \"You do not have permisions to edit a user other than yourself\"\n redirect_to root_path\n end \n end",
"def rated?(rateable)\n 0 < Rating.count(:all, :conditions => [\n \"rater_id = ? AND rater_type = ? AND rateable_id = ? AND rateable_type = ?\",\n self.id, self.class.name, rateable.id, rateable.class.name\n ])\n end",
"def following?(other_user_id)\n following.include?(User.find(other_user_id))\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def unlocked?(user)\n\t\treturn user.totalStars >= @starsRequired\n\tend",
"def ==(other)\n self.class == other.class && user == other.user\n end",
"def current_user?(user)\r\n user == current_user\r\n end",
"def update?\n user.rank > UNIT_RANK\n end",
"def update?\n user.rank > UNIT_RANK\n end",
"def is_owned_by_user?(user)\n self.user == user\n end",
"def current_user?(user)\n user == current_person.user\n end",
"def require_same_user\n if params[:id].to_i != current_actor.id\n flash[:error] = \"Unable to complete withdrawal. Invalid user.\".t\n redirect_to money_path(current_actor) and return\n end\n end",
"def rated_anything?\n likes.count > 0 || dislikes.count > 0\n end",
"def following?(other_user)\n\t following.include?(other_user)\n \tend",
"def current_user?(user)\n user == current_user\n end",
"def current_user?(user)\n user == current_user\n end",
"def current_user?(user)\n user == current_user\n end",
"def current_user?(user)\n user == current_user\n end",
"def current_user?(user)\n user == current_user\n end",
"def current_user?(user)\n user == current_user\n end",
"def current_user?(user)\n user == current_user\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def enrolled?(user)\n return false if user == owner\n users.include?(user)\n end",
"def other_user(user_id)\n if user_1_id == user_id\n user_2_id\n else\n user_1_id\n end\n end",
"def current_user?(user)\n user && user == current_user\n end",
"def update?\n user == identity.user\n end",
"def ordered_on_behalf_of?\n user_id != created_by\n end",
"def current?\n self == User.current\n end",
"def following? other_user\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user) \n end",
"def users_joined?\n true\n end",
"def rate(value, ip_address, user_id)\n if can_rate? ip_address\n UserStore.create(:user_id => user_id, :store_id => self.store_id, :role => 'author') if self.store.user_stores.where(:user_id => user_id).blank?\n r = ratings.find_or_initialize_by_user_id(user_id)\n r.value = value\n r.ip_address = ip_address\n r.save!\n else\n errors.add :base, I18n.t(\"already_rated\")\n false\n end\n end",
"def current_user?(user)\n user == current_user\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def current_user?(user)\n \t\tuser == current_user\n \tend",
"def applies_to?(user); false end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end",
"def following?(other_user)\n following.include?(other_user)\n end"
] | [
"0.7204734",
"0.71171266",
"0.7009953",
"0.6993899",
"0.6932868",
"0.6845935",
"0.6583768",
"0.6580198",
"0.65206873",
"0.65004987",
"0.6467047",
"0.6439141",
"0.6439141",
"0.6309899",
"0.62901086",
"0.6275504",
"0.62464267",
"0.61768514",
"0.6161292",
"0.6134051",
"0.61299527",
"0.6103096",
"0.6095325",
"0.6085961",
"0.60632",
"0.6048681",
"0.60400945",
"0.6033326",
"0.6031556",
"0.6030941",
"0.6030941",
"0.6030941",
"0.6029375",
"0.60240716",
"0.6004692",
"0.599941",
"0.599941",
"0.599941",
"0.59951794",
"0.59937924",
"0.5989054",
"0.59846604",
"0.59835434",
"0.5976218",
"0.59655595",
"0.5954511",
"0.59494215",
"0.5945367",
"0.59403926",
"0.5939286",
"0.59274375",
"0.5903441",
"0.58825856",
"0.5872524",
"0.58701724",
"0.586759",
"0.58565027",
"0.58530444",
"0.58490944",
"0.5834118",
"0.5834118",
"0.5830004",
"0.5829389",
"0.58249044",
"0.58216995",
"0.5814985",
"0.58123696",
"0.58123696",
"0.58123696",
"0.58123696",
"0.58123696",
"0.58123696",
"0.58123696",
"0.5810461",
"0.5810461",
"0.5810461",
"0.5810461",
"0.5800009",
"0.5799287",
"0.57981074",
"0.57976294",
"0.5786243",
"0.5785185",
"0.57831806",
"0.57808244",
"0.5773064",
"0.5772391",
"0.57690644",
"0.57679987",
"0.57573605",
"0.57509935",
"0.57470053",
"0.57470053",
"0.57470053",
"0.57470053",
"0.57470053",
"0.57470053",
"0.57470053",
"0.57470053",
"0.57470053"
] | 0.6059493 | 25 |
Test 2: Empty groups, empty description, no media | def test02_post_open_news_EmptyGDM
login $user_1_email, $master_password
$browser.goto($patch_media)
sleep 2
assert $post_now.exists?
$post_now.fire_event("onclick")
assert $post_now.exists?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_parser_handles_empty_simple_content\n simple_content_assert nil, nil\n simple_content_assert nil, ''\n end",
"def print_group(group)\n puts \"Name: \" + group.name\n puts \"Description: \" + (group.description.nil? ? \"None\" : group.description)\n puts \"Status: \" + group.status\n puts \"Href: \" + group.href\nend",
"def test02_EmptyMPopGD\n\t\t\tloginPost\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\tif $post_pick_group.exists?\n\t\t\t\tpostGroupPop\n\t\t\t\t$post_media_description.set(\"Media Description #{random}.\")\n\t\t\t\t$post_now.fire_event(\"onclick\")\n\t\t\telse puts \"PEV04T02: FAILED! User unable to locate Post button.\"\n\t\t\tend \t\t\t\t\n\t\t\t\n\t\t\tbegin\n\t\t\tassert $post_now.exists?\n\t\t\t\trescue => e\n\t\t\t\tputs (\"PEV04T02: FAILED! User able to Post.\")\n\t\t\t\tputs e\n\t\t\tend\n\t\tend",
"def test03_EmptyGPopDM\n\t\t\tloginPost\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\tif $post_media_description.exists?\n\t\t\t\t$post_media_description.set(\"Media Description #{random}.\")\n \t\t\t\tpostGroupPop\n\t\t\t\t$post_media_button.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t\t$post_now.fire_event(\"onclick\")\n\t\t\telse puts \"PEV04T03: FAILED! User unable to locate Post button.\"\n\t\t\tend\n\t\t\t\n\t\t\tbegin\n\t\t\tsleep 2\n\t\t\tassert $post_new_post.exists?\n\t\t\t\trescue => e\n\t\t\t\tputs (\"PEV04T03: FAILED! User unable to Post.\")\n\t\t\t\tputs e\n\t\t\tend\t\n\t\tend",
"def test_10a\r\n db = build\r\n assert_equal [],db.groups\r\n end",
"def test_require_group\n render text: 'OK'\n end",
"def test02_EmptyMPopGDPublish\n\t\t\tloginPost\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\tif $post_pick_group.exists?\n\t\t\t\tpostGroupPop\n\t\t\t\t$post_media_description.set(\"Media Description #{random}.\")\n\t\t\t\tpostPublishLater\n\t\t\t\t$post_now.fire_event(\"onclick\")\n\t\t\telse puts \"PPL04T02: FAILED! User unable to locate Post button.\"\n\t\t\tend \t\t\t\t\n\t\t\t\n\t\t\tbegin\n\t\t\tassert $post_now.exists?\n\t\t\t\trescue => e\n\t\t\t\tputs (\"PPL04T02: FAILED! User able to Post.\")\n\t\t\t\tputs e\n\t\t\tend\n\t\tend",
"def test03_EmptyGPopDMPublish\n\t\t\tloginPost\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\tif $post_media_description.exists?\n\t\t\t\t$post_media_description.set(\"Media Description #{random}.\")\n \t\t\t\tpostGroupPop\n\t\t\t\t$post_media_button.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t\tpostPublishLater\n\t\t\t\t$post_now.fire_event(\"onclick\")\n\t\t\telse puts \"PPL04T03: FAILED! User unable to locate Post button.\"\n\t\t\tend\n\t\t\t\n\t\t\tbegin\n\t\t\tsleep 2\n\t\t\tassert $post_scheduled_post.exists?\n\t\t\t\trescue => e\n\t\t\t\tputs (\"PPL04T03: FAILED! User unable to Post.\")\n\t\t\t\tputs e\n\t\t\tend\t\n\t\tend",
"def test_room_starts_with_empty_playlist\n assert_equal([], @room1.show_playlist()) #OR DO WE COUNT THIS?\n end",
"def news_and_media\n # blank\n end",
"def test_parser_handles_unsupported_simple_content\n simple_content_assert nil, {}\n simple_content_assert nil, []\n end",
"def test04_post_closed_news_TwoGroupsRepostMedia\n\t\trepostMediaPop\n\t\tsleep 3\n\t\ttwoGroupSelect\n\t\tsleep 3\n\t\t\n\t\tassert $repost_confirmation.exists?\n\tend",
"def test04_EmptyGPopDM\n\t\t\tloginPost\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\tif $post_media_description.exists?\n\t\t\t\t$post_media_description.set(\"Media Description #{random}.\")\n\t\t\t\t$post_media_button.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t\t$post_now.fire_event(\"onclick\")\n\t\t\telse puts \"PEV03T04: FAILED! UUser unable to locate Post button.\"\n\t\t\tend\n\t\t\t\n\t\t\tbegin\n\t\t\tassert $post_now.exists?\n\t\t\t\trescue => e\n\t\t\t\tputs (\"PEV03T04: FAILED! User able to Post.\")\n\t\t\t\tputs e\n\t\t\tend\t\n\t\tend",
"def test_media_find_all\n assert_not_nil @rdigg.media.find_all\n end",
"def test03_MediaAllFields\n\t\tloginPost\n\t\t$browser.goto($patch_media)\n\t\t\t\n\t\t\tsleep 2\n\t\t\tif $post_media_description.exists?\n\t\t\t\t$post_media_description.set(\"pictures of hiking mr. rainier #{random}.\")\n \t\t\t\tpostGroupPop\n \t\t\t\tpostGroupPop2\n\t\t\t\t$post_media_button.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t\t$post_media_button.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t\t$post_now.fire_event(\"onclick\")\n\t\t\telse puts \"P01T03: FAILED! User unable to locate Post button.\"\n\t\t\tend\n\t\t\t\n\t\tbegin\n\t\tsleep 2\n\t\tassert $post_new_post.exists?\n\t\t\trescue => e\n\t\t\tputs (\"P01T03: FAILED! User unable to Post.\")\n\t\t\tputs e\n\t\tend\t\n\tend",
"def test04_post_open_news_EmptyGPopDM\n\t\t\tlogin $user_1_email, $master_password\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\t\n\t\t\tassert $post_media_description.exists?\n\t\t\t$post_media_description.set(\"Media Description #{random}.\")\n\t\t\t$post_media_button.click\n\t\t\tfile_upload \"GlacierBasinTrailMtRainier.JPG\"\n\t\t\t$post_now.fire_event(\"onclick\")\n\n\t\t\tassert $post_now.exists?\n\t\tend",
"def test03_MediaOneComment_TC_24319\n\t\tcommentMediaPop\n\t\tcommentPopSubmit\n\tend",
"def test_media_find_by_type\n assert_not_nil @rdigg.media.find_by_type(\"news\")\n end",
"def test04_post_closed_board_GroupRepostMedia\n\t\trepostMediaPop\n\t\tsleep 3\n\t\tgroupAddRemoveAdd \"Repost text #{random}.\"\n \t\tsleep 3\n\t\t\n\t\tassert $repost_confirmation.exists?\n\tend",
"def test02_MediaTwoComments\n\t\tcommentMediaPop\n\t\tcommentPopSubmit\n\tend",
"def test_no_text_samples\n no_text_samples = [\"go.mod\", \"go.sum\"]\n Samples.each do |sample|\n if sample[:language] == \"Text\"\n refute_includes no_text_samples, sample[:filename], \"#{sample[:filename]} should NOT be added as a sample for #{sample[:language]}\"\n end\n end\n end",
"def test03_4GroupsRepostMedia\n\t\trepostMediaPop\n\t\tsleep 3\n\t\tfourGroupSelect\n\t\tsleep 3\n\t\t\n\t\tbegin \n\t\tassert $repost_confirmation.exists?\n\t\t\trescue => e\n\t\t\tputs \"RS06T03: FAILED! User unable to repost!\"\n\t\t\tputs e\n\t\tend\n\tend",
"def test05_post_open_news_EmptyDMPopG\n\t\t\tlogin $user_1_email, $master_password\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\t\n\t\t\tassert $post_pick_group.exists?\n \t\t\trepostGroupPop\n\t\t\t$post_now.fire_event(\"onclick\")\n\n\t\t\tassert $post_now.exists?\n\t\tend",
"def test04_DraftEmptyGPopDM\n\t\t\tloginPost\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\tif $post_media_description.exists?\n\t\t\t\t$post_media_description.set(\"Media Description #{random}.\")\n\t\t\t\t$post_media_button.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t\tsleep 2\n\t\t\t\tsleep 4\n\t\t\t\t$post_save_draft.fire_event(\"onclick\")\n\t\t\telse puts \"PDEV04T04: FAILED! UUser unable to locate Post button.\"\n\t\t\tend\n\t\t\t\n\t\t\tbegin\n\t\t\tassert $post_draft_error.exists?\n\t\t\t\trescue => e\n\t\t\t\tputs (\"PDEV04T04: FAILED! User able to save incomplete draft.\")\n\t\t\t\tputs e\n\t\t\tend\t\n\t\tend",
"def verify_groups(test_data)\n test_groups = test_data[Org::GROUPS.name]\n errors = []\n test_groups = [{ Org::GROUP.name => ''}] unless test_groups\n test_groups.each_with_index do |test_grp, index|\n text_values_match?(test_grp[Org::GROUP.name], element_value(group_input(index)), errors)\n end\n errors\n end",
"def empty?\n group.empty?\n end",
"def test03_GroupRepostMedia\n\t\trepostMediaPop\n\t\tsleep 3\n\t\tgroupAddRemoveAdd\n \t\tsleep 3\n\t\t\n\t\tbegin \n\t\tassert $repost_confirmation.exists?\n\t\t\trescue => e\n\t\t\tputs \"RS2T03: FAILED! User unable to repost!\"\n\t\t\tputs e\n\t\tend\n\tend",
"def test_creating_public_description\n # We want to create an empty, default public description for a name that\n # doesn't have any descriptions yet -- simplest possible case.\n @name = Name.find_by(text_name: \"Strobilurus diminutivus\")\n assert_equal([], @name.descriptions)\n @description_data = {\n source_type: \"public\",\n source_name: nil,\n readable: true,\n writable: true,\n notes: \"I like this mushroom.\"\n }\n @group_expectations = {\n admins: [UserGroup.reviewers],\n writers: [UserGroup.all_users],\n readers: [UserGroup.all_users],\n authors: [],\n editors: [mary]\n }\n\n admin = open_admin_session(dick)\n reviewer = open_normal_session(rolf)\n owner = open_normal_session(mary)\n random_user = open_normal_session(katrina)\n lurker = open_lurker_session\n\n reviewer.should_be_reviewer\n owner.should_not_be_reviewer\n random_user.should_not_be_reviewer\n\n # sets (not checks) the abilities\n admin.should_be_able_to_do_anything\n reviewer.should_be_able_to_do_anything_but_change_permissions\n owner.should_be_able_to_edit_and_change_name\n random_user.should_be_able_to_edit_text_only\n lurker.should_be_able_to_see_but_needs_to_login\n\n owner.create_name_description\n owner.check_name_description\n\n admin.check_abilities\n reviewer.check_abilities\n owner.check_abilities\n random_user.check_abilities\n lurker.shouldnt_be_able_to_do_anything\n end",
"def test_initialize_group\r\n \ttest_group = ProspectorGroup.new\r\n \ttest_group.intialize_group(33, 3)\r\n \tassert_equal 3, test_group.num_prospectors\r\n \tassert_equal 0 , test_group.iteration_count\r\n end",
"def test_create_empty_word\n assert true,@newTileGroup.tiles.empty?\n end",
"def test_basedata\n assert_not_nil(Cardiotype.find(:first, :conditions => [\"description = ?\", \"Run\"]))\n assert_not_nil(Cardiotype.find(:first, :conditions => [\"description = ?\", \"Swim\"]))\n assert_not_nil(Cardiotype.find(:first, :conditions => [\"description = ?\", \"Cycle\"]))\n end",
"def message\n 'Example grouping has no name'\n end",
"def test_empty\n # Empty.\n end",
"def groups; end",
"def groups; end",
"def groups; end",
"def test05_EmptyDMPopG\n\t\t\tloginPost\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\tif $post_pick_group.exists?\n \t\t\t\tpostGroupPop\n\t\t\t\t$post_now.fire_event(\"onclick\")\n\t\t\telse puts \"PEV03T05: FAILED! User unable to locate Post button.\"\n\t\t\tend \t\t\t\t\n\t\t\t\n\t\t\tbegin\n\t\t\tassert $post_now.exists?\n\t\t\t\trescue => e\n\t\t\t\tputs (\"PEV03T05: FAILED! User able to Post.\")\n\t\t\t\tputs e\n\t\t\tend\n\t\tend",
"def test_data_extraction\n\t\tYAML.load_file('test/groups.yml')[\"groups\"].each do |g_data|\n\t\t\tstub_request(:get, g_data[\"url\"]).\n\t\t\tto_return(:status => 200, :body => File.read(\"test/yahoo_pages/#{g_data['id']}.html\"), :headers => {})\n\n\t\t\tgroup = YahooGroupData.new(g_data[\"url\"])\n\t\t\tassert_equal g_data[\"age_restricted\"], group.age_restricted?\n\t\t\tassert_equal g_data[\"private\"], group.private?\n\t\t\tassert_equal g_data[\"not_found\"], group.not_found?\n\t\t\tassert_equal g_data[\"name\"], group.name\n\t\t\tassert_equal g_data[\"description\"], group.description\n\t\t\tassert_equal g_data[\"post_email\"], group.post_email\n\t\t\tassert_equal g_data[\"subscribe_email\"], group.subscribe_email\n\t\t\tassert_equal g_data[\"owner_email\"], group.owner_email\n\t\t\tassert_equal g_data[\"unsubscribe_email\"], group.unsubscribe_email\n\t\t\tassert_equal g_data[\"founded\"], group.founded\n\t\t\tassert_equal g_data[\"language\"], group.language\n\t\t\tassert_equal g_data[\"num_members\"], group.num_members\n\t\t\tassert_equal g_data[\"category\"], group.category\n\t\tend\n\tend",
"def test_for_empty_result\n assert_not_equal @you_tube.search.length, 0\n end",
"def test03_EmptyGDM\n\t\t\tloginPost\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\tif $post_media_button.exists?\n\t\t\t\t$post_media_button.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t\t$post_now.fire_event(\"onclick\")\n\t\t\telse puts \"PEV03T03: FAILED! User unable to locate Post button.\"\n\t\t\tend\n\t\t\t\n\t\t\tbegin\n\t\t\tassert $post_now.exists?\n\t\t\t\trescue => e\n\t\t\t\tputs (\"PEV03T03: FAILED! User able to Post.\")\n\t\t\t\tputs e\n\t\t\tend\n\t\tend",
"def test_parser_handles_empty_email_text\n empty_string = ''\n\n email_text_assert empty_string, empty_string\n end",
"def test_playlist_is_empty()\n assert_equal(0, @room.room_playlist())\n end",
"def test05_DraftEmptyDMPopG\n\t\t\tloginPost\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\tif $post_pick_group.exists?\n \t\t\t\tpostGroupPop\n\t\t\t\tsleep 4\n\t\t\t\t$post_save_draft.fire_event(\"onclick\")\n\t\t\telse puts \"PDEV04T05: FAILED! User unable to locate Post button.\"\n\t\t\tend \t\t\t\t\n\t\t\t\n\t\t\tbegin\n\t\t\tassert $post_draft_error.exists?\n\t\t\t\trescue => e\n\t\t\t\tputs (\"PDEV04T05: FAILED! User able to save incomplete draft.\")\n\t\t\t\tputs e\n\t\t\tend\n\t\tend",
"def test_attributes\n assert_equal \"Gallery 1\", @gallery.title\n assert @gallery.active?\n assert_equal \"f82dd0bd-4711-4578-ac47-4661257e69a6\", @gallery.guid\n end",
"def description\n [@group.description,@description].join(' ')\n end",
"def has_group?\n @group == ''\n end",
"def test_default_group_pages\n m = Time.now.to_f.to_s.gsub('.', '')\n @s.switch_user(User.admin_user())\n group = create_group(\"g-testgroup-#{m}\")\n path = \"#{group.home_path_for(@s)}/pages\"\n res = @s.execute_get(@s.url_for(\"#{path}.2.json\"))\n assert_equal(\"200\", res.code, \"Should have created pages in postprocessing\")\n json = JSON.parse(res.body)\n assert_not_nil(json[\"index.html\"], \"Expected default page not found\")\n assert_equal(json[\"index.html\"][\"jcr:primaryType\"], \"nt:file\", \"Default home page is not a file\")\n end",
"def test03_DraftEmptyGDM\n\t\t\tloginPost\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\tif $post_media_button.exists?\n\t\t\t\t$post_media_button.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t\tsleep 2\n\t\t\t\tsleep 4\n\t\t\t\t$post_save_draft.fire_event(\"onclick\")\n\t\t\telse puts \"PDEV04T03: FAILED! User unable to locate Post button.\"\n\t\t\tend\n\t\t\t\n\t\t\tbegin\n\t\t\tassert $post_draft_error.exists?\n\t\t\t\trescue => e\n\t\t\t\tputs (\"PDEV04T03: FAILED! User able to save incomplete draft.\")\n\t\t\t\tputs e\n\t\t\tend\n\t\tend",
"def group\n nil\n end",
"def group\n nil\n end",
"def group\n nil\n end",
"def test01_post_open_news_NoNoteRepostMedia\n\t\trepostMediaPop\n\t\tsleep 3\n\t\trepost \"\" #No note\n\t\tsleep 3\n\t\t\n\t\tassert $repost_confirmation.exists?\n\tend",
"def get_tests(children)\n children.each_with_object({}) do |c, memo|\n memo[c.description] = {}\n memo[c.description]['groups'] = get_tests(c.children) unless c.children.empty?\n unless c.examples.empty?\n memo[c.description]['tests'] = c.examples.map { |e|\n e.description unless e.pending?\n }.compact\n end\n next if c.examples.empty?\n memo[c.description]['pending_tests'] = c.examples.map { |e|\n e.description if e.pending?\n }.compact\n end\nend",
"def has_group?\n\t\t@group == ''\n\tend",
"def test04_flag_repost_media_TC_24323\n\t\trepostMediaPop\n\t\tsleep 2\n\t\trepost\n\t\tcommentFlag\n\t\tsleep 2\n\t\t\n\t\tbegin\n\t\tassert $browser.text.include?(\"Comment\")\n\t\trescue => e\n\t\t\tputs e\n\t\tputs \"R8_T4: FAILED! User unable to flag post.\"\n\t\tend\n\tend",
"def test_multiple_images\n two_image_setup\n\n correct = <<~HEREDOC\n <picture>\n <source media=\"mquery\" srcset=\"ss mobile\" type=\"original\">\n <source srcset=\"ss\" type=\"original\">\n <img src=\"good_url\">\n </picture>\n HEREDOC\n\n assert_equal correct, @tested.to_s\n end",
"def group\n nil\n end",
"def test_display\n assert_equal nil, @disc.display\n end",
"def test_ownprovidergroups\n groupnames.each { |group|\n gobj = nil\n comp = nil\n fakeresource = fakeresource(:group, group)\n assert_nothing_raised {\n gobj = @provider.new(fakeresource)\n }\n\n assert(gobj.gid, \"Failed to retrieve gid\")\n }\n end",
"def empty_meta_description?\n return meta_empty?(\"description\")\n end",
"def test_groupdetail_constructor_and_accessors\n\n obj = SmsCountryApi::Group::GroupDetail.new\n refute_nil obj, \"Object wasn't created successfully.\"\n assert_kind_of SmsCountryApi::Group::GroupDetail, obj, \"Object isn't the correct type.\"\n assert_nil obj.id, \"ID isn't nil.\"\n assert_nil obj.name, \"Name isn't nil.\"\n assert_nil obj.tiny_name, \"Tiny name isn't nil.\"\n assert_nil obj.start_call_on_enter, \"Start call on enter isn't nil.\"\n assert_nil obj.end_call_on_exit, \"End call on exit isn't nil.\"\n assert_nil obj.members, \"Members isn't nil.\"\n\n end",
"def test_valid_parse\n test_songs, test_kits = SongParserTest.generate_test_data()\n \n assert_equal(120, test_songs[:no_tempo].tempo)\n assert_equal([:verse], test_songs[:no_tempo].flow)\n \n assert_equal(100, test_songs[:repeats_not_specified].tempo)\n assert_equal([:verse], test_songs[:repeats_not_specified].flow)\n \n # These two songs should be the same, except that one uses a kit in the song header\n # and the other doesn't.\n [:example_no_kit, :example_with_kit].each do |song_key|\n song = test_songs[song_key]\n assert_equal([:verse, :verse,\n :chorus, :chorus,\n :verse, :verse,\n :chorus, :chorus, :chorus, :chorus,\n :bridge,\n :chorus, :chorus, :chorus, :chorus],\n song.flow)\n assert_equal(99, song.tempo)\n assert_equal([\"bridge\", \"chorus\", \"verse\"], song.patterns.keys.map{|key| key.to_s}.sort)\n assert_equal(4, song.patterns[:verse].tracks.length)\n assert_equal(5, song.patterns[:chorus].tracks.length)\n assert_equal(1, song.patterns[:bridge].tracks.length)\n end\n \n song = test_songs[:example_with_empty_track]\n assert_equal(1, song.patterns.length)\n assert_equal(2, song.patterns[:verse].tracks.length)\n assert_equal(\"........\", song.patterns[:verse].tracks[\"test/sounds/bass_mono_8.wav\"].rhythm)\n assert_equal(\"X...X...\", song.patterns[:verse].tracks[\"test/sounds/snare_mono_8.wav\"].rhythm)\n \n song = test_songs[:multiple_tracks_same_sound]\n assert_equal(2, song.patterns.length)\n assert_equal(7, song.patterns[:verse].tracks.length)\n assert_equal([\"agogo\", \"bass\", \"bass2\", \"bass3\", \"bass4\", \"hh_closed\", \"snare\"],\n song.patterns[:verse].tracks.keys.sort)\n assert_equal(\"X...............\", song.patterns[:verse].tracks[\"bass\"].rhythm)\n assert_equal(\"....X...........\", song.patterns[:verse].tracks[\"bass2\"].rhythm)\n assert_equal(\"........X.......\", song.patterns[:verse].tracks[\"bass3\"].rhythm)\n assert_equal(\"............X...\", song.patterns[:verse].tracks[\"bass4\"].rhythm)\n assert_equal(\"..............X.\", song.patterns[:verse].tracks[\"snare\"].rhythm)\n assert_equal(\"X.XXX.XXX.X.X.X.\", song.patterns[:verse].tracks[\"hh_closed\"].rhythm)\n assert_equal(\"..............XX\", song.patterns[:verse].tracks[\"agogo\"].rhythm)\n \n song = test_songs[:with_structure]\n assert_equal([:verse, :verse], song.flow)\n assert_equal(1, song.patterns.length)\n assert_equal(1, song.patterns[:verse].tracks.length)\n assert_equal(\"X...X...\", song.patterns[:verse].tracks[\"test/sounds/bass_mono_8.wav\"].rhythm)\n end",
"def test04_MediaPhotoVideo\n\t\tlogin $editor_1_email, $master_password\n\t\t$browser.goto($patch_boards_pre_closed_article_new)\n\t\t\n#\t\t$post_activate_note.when_present.fire_event(\"onclick\")\n#\t\t$post_media_description.set(\"mt townsend is my favorite mountain #{random}.\")\n\t\tif $environment == 'nixon'\t\n\t\t\trepostGroupPop #category already selected in staging\n\t\tend\n\t\t$post_article_title.set(\"Mountain #{random}\")\n \t\t$browser.execute_script(\"jQuery('iframe.wysihtml5-sandbox').contents().find('body').prepend('mt townsend is my favorite mountain #{random}.')\")\n\t\tsleep 2\n\t\t$post_add_media_article.click\n\t\tfile_upload \"DungenessSpit102.26.2012.mov\"\n\t\tsleep 2\n\t\t$post_add_media_article.click\n\t\tfile_upload \"GlacierBasinTrailMtRainier.JPG\"\n if $environment == 'staging'\n\t\t\tsleep 10 #loads \n\t\tend\n\t\t$post_now_edit.fire_event(\"onclick\")\n\n\t\tsleep 2\n\t\tassert $post_new_post.exists?\n\tend",
"def test_match_sets_discard\n assert_not_equal(nil, @exp.expect(/null/))\n assert_not_equal('', @exp.discard)\n end",
"def test_content_empty\n @work_opinion.content = nil\n assert !@work_opinion.save\n end",
"def ensure_magic_descriptor_presence(ad_group)\n # Use exceptions as activedirectory gem will throw an ArgumentError if no description exists.\n # AD groups don't have to have description fields but we will add one if needed.\n begin\n g_desc = ad_group.description\n rescue ArgumentError\n # description not set\n g_desc = \"\"\n end\n\n unless g_desc and g_desc.index MAGIC_DESCRIPTOR\n ad_group.description = \"#{MAGIC_DESCRIPTOR} #{g_desc}\"\n ad_group.save\n end\nend",
"def create_fake\n record = MediaElement.new\n record.title = params[:title_placeholder] != '0' ? '' : params[:title]\n record.description = params[:description_placeholder] != '0' ? '' : params[:description]\n record.tags = params[:tags_value]\n record.user_id = current_user.id\n record.save_tags = true\n record.valid?\n @errors = convert_media_element_error_messages record.errors\n @errors[:media] = t('forms.error_captions.media_file_too_large').downcase\n end",
"def test03_post_open_news_EmptyGDM\n\t\t\tlogin $user_1_email, $master_password\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\t\n\t\t\tassert $post_media_button.exists?\n\t\t\t$post_media_button.click\n\t\t\tfile_upload \"GlacierBasinTrailMtRainier.JPG\"\n\t\t\t$post_now.fire_event(\"onclick\")\n\n\t\t\tassert $post_now.exists?\n\t\tend",
"def test_optional_fields\n assert_nothing_raised do\n @parser.record_line :record,\n :fields => %w{one two three four},\n :optional => %w{three four},\n :absent => \"*\",\n :separator => \" \" # A single space\n end\n\n { \"a b c d\" => [],\n \"a b * d\" => [:three],\n \"a b * *\" => [:three, :four],\n \"a b c *\" => [:four]\n }.each do |line, absentees|\n record = nil\n assert_nothing_raised do\n record = @parser.parse_line(line)\n end\n\n # Absent field is :absent, not \"*\" inside the record\n absentees.each do |absentee|\n assert_equal(:absent, record[absentee])\n end\n\n # Now regenerate the line\n newline = nil\n assert_nothing_raised do\n newline = @parser.to_line(record)\n end\n\n # And make sure they're equal\n assert_equal(line, newline)\n end\n\n # Now make sure it pukes if we don't provide the required fields\n assert_raise(ArgumentError) do\n @parser.to_line(:record_type => :record, :one => \"yay\")\n end\n end",
"def test02_DraftPopGT_DraftEmptyA\n\t\t\tloginPost\n\t\t\t$browser.goto($patch_article)\n\t\t\tsleep 2\n\t\t\tif $post_pick_group.exists?\n \t\t\t\tpostGroupPop\n \t\t\t\t$post_article_title.set(\"Article #{random}\")\n\t\t\t\tsleep 4\n\t\t\t\t$post_save_draft.fire_event(\"onclick\")\n\t\t\telse puts \"PDEV02T02: FAILED! User able to save incomplete draft.\"\n\t\t\tend\n\t\t\t\n\t\t\tbegin\n\t\t\tassert $post_draft_error.exists?\n\t\t\t\trescue => e\n\t\t\t\tputs (\"PDEV02T02: FAILED! User able to save incomplete draft.\")\n\t\t\t\tputs e\n\t\t\tend\n\t\tend",
"def test_get_all_ad_groups\n test_add_ad_groups() unless (@ad_group_1 and @ad_group_2 and @ad_group_3)\n found_1 = false\n found_2 = false\n found_3 = false\n selector = @ad_group_srv.module::AdGroupSelector.new\n response = @ad_group_srv.get(selector)\n assert_not_nil(response.rval.entries, 'Empty result set returned')\n response.rval.entries.each do |ad_group|\n found_1 = true if ad_group.id == @ad_group_1.id\n found_2 = true if ad_group.id == @ad_group_2.id\n found_3 = true if ad_group.id == @ad_group_3.id\n end\n assert(found_1, 'Ad group #1 not found in returned results')\n assert(found_2, 'Ad group #2 not found in returned results')\n assert(found_3, 'Ad group #3 not found in returned results')\n end",
"def test02_post_closed_news_GroupRepostArticle\n\t\trepostArticlePop\n\t\tsleep 3\n\t\tgroupAddRemoveAdd \"Repost text #{random}.\"\n \t\tsleep 3\n\t\t\n\t\tassert $repost_confirmation.exists?\n\tend",
"def test_parser_handles_unsupported_email_text\n email_text_assert nil, nil\n email_text_assert nil, 123\n email_text_assert nil, {}\n email_text_assert nil, []\n end",
"def videos_test\n end",
"def album\r\n #prepare_new_album extracted for reuse from spec\r\n prepare_new_album unless @content\r\n end",
"def test02_pre_open_board_MediaCancel\n\t\tlogin $user_1_email, $master_password\n\t\t$browser.goto($patch_media)\n\t\t\n\t\tsleep 2\n\t\tassert $post_media_description.exists?\n\t\t$post_media_description.set(\"Media Description #{random}.\")\n \t\trepostGroupPop\n\t\t$post_media_button.click\n\t\tfile_upload \"GlacierBasinTrailMtRainier.JPG\"\n\t\t$post_cancel.click\n\n\t\tsleep 3\n\t\tassert $post_cancel.exists?\n\tend",
"def test_room_starts_with_no_songs\n assert_equal(0, @room.song_count())\n end",
"def test_media_whitespace\n params = 'img.jpg mobile: \"white space.jpg\"'\n\n assert_equal 'white space.jpg', tested(params).source_names[1]\n end",
"def test02_ArticleAllFields\n\t\tloginPost\n\t\t$browser.goto($patch_article)\n\t\t\t\n\t\t\tsleep 2\n\t\t\tif $post_pick_group.exists?\n \t\t\t\tpostGroupPop\n \t\t\t\tpostGroupPop2\n \t\t\t\t$post_article_title.set(\"Article #{random}\")\n \t\t\t\t$browser.execute_script(\"jQuery('iframe.wysihtml5-sandbox').contents().find('body').prepend('lava is hot.')\")\n \t\t\t\t$post_add_media.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t\t$post_add_media.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t\t$post_now.fire_event(\"onclick\")\n\t\t\telse puts \"PS01T02: FAILED! User unable to locate Post button.\"\n\t\t\tend\n\t\t\t\n\t\tbegin\n\t\tsleep 2\n\t\tassert $post_new_post.exists?\n\t\t\trescue => e\n\t\t\tputs (\"P01T02: FAILED! User unable to Post.\")\n\t\t\tputs e\n\t\tend\n\tend",
"def test_should_require_description\n archive = create(:description => nil)\n assert archive.errors.invalid?(:description), \":description should be required\"\n assert_invalid archive, \"archive shouldn't be created\"\n end",
"def test05_news_OpenSports\n\t\tlogin $editor_1_email, $master_password\n\t\t$browser.goto($patch_new_news_group)\n\t\tsleep 5\n\n\t\t$group_name.set(\"Sports Group #{random}\")\n\t\t$group_nickname.set(\"Nickname #{random}\")\n\t\t$group_description.set(\"Description #{random}\")\n\t\t$category_sports.click\n\t\t$boards_arts_ent_image.when_present.fire_event(\"onclick\")\n\t\t$create_group.click\n\t\t\n\t\tcheckIfIncorrectErrorDisplays\n\t\t\n\tend",
"def test04_news_OpenPolitics\n\t\tlogin $editor_1_email, $master_password\n\t\t$browser.goto($patch_new_news_group)\n\t\tsleep 5\n\n\t\t$group_name.set(\"Politics Group #{random}\")\n\t\t$group_nickname.set(\"Nickname #{random}\")\n\t\t$group_description.set(\"Description #{random}\")\n\t\t$category_politics.click\n\t\tsleep 2\n\t\t$boards_arts_ent_image.when_present.fire_event(\"onclick\")\n\t\t$create_group.click\n\t\t\n\t\tcheckIfIncorrectErrorDisplays\n\t\t\n\tend",
"def test_grouping\n make_dummy_source(\"http://groupme/source1\", N::FOAFX.Goat, N::FOAFX.Bee)\n make_dummy_source(\"http://groupme/source2\", N::FOAFX.Goat)\n make_dummy_source(\"http://groupme/source3\", N::FOAFX.Bee)\n results = Source.groups_by_property(:type, [ N::FOAFX.Goat, N::FOAFX.Bee ])\n assert_equal(2, results.size)\n assert_equal(2, results[N::FOAFX.Goat].size)\n assert_equal(2, results[N::FOAFX.Bee].size)\n end",
"def assert_no_streams\n assert subscription.streams.empty?, \"No streams started was expected, but #{subscription.streams.count} found\"\n end",
"def prepare\n insert_recording_reporter\n link_example_groups\n end",
"def test_multiple_formats\n two_format_setup\n\n correct = <<~HEREDOC\n <picture>\n <source srcset=\"ss\" type=\"webp\">\n <source srcset=\"ss\" type=\"original\">\n <img src=\"good_url\">\n </picture>\n HEREDOC\n\n assert_equal correct, @tested.to_s\n end",
"def test_have_types\n @sources.each { |s| assert(!s['type'].blank?, \"No type for #{s['uri']}\") }\n end",
"def group; end",
"def test03_news_OpenOther\n\t\tlogin $editor_1_email, $master_password\n\t\t$browser.goto($patch_new_news_group)\n\t\tsleep 5\n\n\t\t$group_name.set(\"Other Group #{random}\")\n\t\t$group_nickname.set(\"Nickname #{random}\")\n\t\t$group_description.set(\"Description #{random}\")\n\t\t$category_other.click\n\t\t$boards_arts_ent_image.when_present.fire_event(\"onclick\")\n\t\t$create_group.click\n\t\t\n\t\tcheckIfIncorrectErrorDisplays\n\t\t\n\tend",
"def describe\n {}\n end",
"def test05_news_OpenPoliticsSports\n\t\tlogin $editor_1_email, $master_password\n\t\t$browser.goto($patch_new_news_group)\n\t\tsleep 5\n\n\t\t$group_name.set(\"Politics/Sports Group #{random}\")\n\t\t$group_nickname.set(\"Nickname #{random}\")\n\t\t$group_description.set(\"Description #{random}\")\n\t\t$category_politics.click\n\t\t$category_sports.click\n\t\t$boards_arts_ent_image.when_present.fire_event(\"onclick\")\n\t\t$create_group.click\n\t\t\n\t\tcheckIfIncorrectErrorDisplays\n\t\t\n\tend",
"def test_playlist\n end",
"def test_all\n query = \"iphone5s\"\n\n products = ProductHelper.crawl(query)\n products.each do |product|\n #STDERR.puts product\n end\n pgroups = ProductHelper.clustering(products)\n pgroups.each do |pgroup|\n info = \"\"\n unless pgroup.spu.nil?\n info = pgroup.spu['Title']\n end\n STDERR.puts \"#{pgroup.size},#{info}\"\n end\n end",
"def test_group_rule(group_rule, setup_match, remove_match, expected_member_count = 1)\n # Ensure a group has a rule\n group = entities(:groupWithNothing)\n\n assert group.roles.empty?, 'looks like groupWithNothing has a role'\n assert group.rules.empty?, 'looks like groupWithNothing has a rule'\n assert group.owners.empty?, 'looks like groupWithNothing has an owner'\n assert group.operators.empty?, 'looks like groupWithNothing has an operator'\n\n Rails.logger.tagged 'test_group_rule' do\n Rails.logger.debug 'Calling setup ...'\n\n setup_match.call()\n\n # Test basic rule creation matches existing people\n assert group.members.empty?, 'group should have no members'\n\n Rails.logger.debug 'Adding group rule ...'\n group.rules << group_rule\n\n group.reload\n # Subtract a second from the 'updated_at' flag to ensure it is a reliable\n # indicator of a group being touched\n group.updated_at -= 1\n group.save!\n group_last_updated_at = group.updated_at\n\n assert group.members.length == expected_member_count, \"group should have #{expected_member_count} member(s) but has #{group.members.length} member(s)\"\n\n Rails.logger.debug 'Calling remove ...'\n remove_match.call()\n\n Rails.logger.debug 'Checking that group has no members ...'\n group.reload\n assert group.updated_at > group_last_updated_at, 'group should have been touched'\n\n # Subtract a second from the 'updated_at' flag to ensure it is a reliable\n # indicator of a group being touched\n group.updated_at -= 1\n group.save!\n group_last_updated_at = group.updated_at\n assert group.members.empty?, \"group should have no members but has #{group.members.count}\"\n\n Rails.logger.debug 'Calling setup again ...'\n setup_match.call()\n\n group.reload\n assert group.updated_at > group_last_updated_at, 'group should have been touched'\n group_last_updated_at = group.updated_at\n\n assert group.members.length == expected_member_count, \"group should have #{expected_member_count} member(s)\"\n end\n end",
"def test_with_node_none\r\n link1 = @linklist.add_link(@node1, @node2)\r\n link2 = @linklist.add_link(@node2, @node3) \r\n \r\n assert(@linklist.with_node(@node4).length == 0)\r\n end",
"def test_nothing\n end",
"def test_missing_milestone_is_empty_string\n assert_equal( '', @incomplete[ :milestone ] )\n end",
"def full_description(example_group)\n example_group.metadata.fetch(:full_description)\n end",
"def tests\n @tests.ordered_example_groups\n end",
"def tests\n parser.flow_items\n end",
"def includes_description?\n !long_desc.empty? || !desc.empty?\n end"
] | [
"0.6116683",
"0.60720485",
"0.6045338",
"0.5920101",
"0.588386",
"0.5783575",
"0.5782394",
"0.5755139",
"0.5713789",
"0.57085055",
"0.5696538",
"0.5687124",
"0.56804806",
"0.5657587",
"0.56305",
"0.56286055",
"0.56242806",
"0.5603301",
"0.5543483",
"0.5540844",
"0.5537754",
"0.553545",
"0.5524601",
"0.5523322",
"0.54612803",
"0.54394835",
"0.54316103",
"0.54302776",
"0.5423468",
"0.54011893",
"0.5393954",
"0.5393294",
"0.53796405",
"0.53641844",
"0.53641844",
"0.53641844",
"0.5350731",
"0.5333022",
"0.5331989",
"0.53218246",
"0.5316605",
"0.5300865",
"0.5290343",
"0.5287683",
"0.5282173",
"0.5277277",
"0.5272696",
"0.52684987",
"0.5236081",
"0.5236081",
"0.5236081",
"0.5229624",
"0.5215206",
"0.52053005",
"0.5202355",
"0.52003324",
"0.51965505",
"0.51936775",
"0.5186994",
"0.51778007",
"0.5175704",
"0.5175251",
"0.516533",
"0.5159831",
"0.5142024",
"0.5136744",
"0.5129625",
"0.51248604",
"0.51238996",
"0.51235116",
"0.51177406",
"0.5113262",
"0.5109781",
"0.5106729",
"0.51040435",
"0.50987536",
"0.50939286",
"0.50769025",
"0.5074077",
"0.50700945",
"0.50587916",
"0.5056405",
"0.5054465",
"0.5051188",
"0.50459987",
"0.5038687",
"0.50358844",
"0.5032308",
"0.5032239",
"0.50285137",
"0.501068",
"0.50100195",
"0.5009084",
"0.50090164",
"0.50086457",
"0.50038826",
"0.499338",
"0.4991188",
"0.49866873",
"0.49850196",
"0.49849775"
] | 0.0 | -1 |
Test 3: Empty groups, empty description, populated media | def test03_post_open_news_EmptyGDM
login $user_1_email, $master_password
$browser.goto($patch_media)
sleep 2
assert $post_media_button.exists?
$post_media_button.click
file_upload "GlacierBasinTrailMtRainier.JPG"
$post_now.fire_event("onclick")
assert $post_now.exists?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test03_MediaAllFields\n\t\tloginPost\n\t\t$browser.goto($patch_media)\n\t\t\t\n\t\t\tsleep 2\n\t\t\tif $post_media_description.exists?\n\t\t\t\t$post_media_description.set(\"pictures of hiking mr. rainier #{random}.\")\n \t\t\t\tpostGroupPop\n \t\t\t\tpostGroupPop2\n\t\t\t\t$post_media_button.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t\t$post_media_button.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t\t$post_now.fire_event(\"onclick\")\n\t\t\telse puts \"P01T03: FAILED! User unable to locate Post button.\"\n\t\t\tend\n\t\t\t\n\t\tbegin\n\t\tsleep 2\n\t\tassert $post_new_post.exists?\n\t\t\trescue => e\n\t\t\tputs (\"P01T03: FAILED! User unable to Post.\")\n\t\t\tputs e\n\t\tend\t\n\tend",
"def test02_EmptyMPopGD\n\t\t\tloginPost\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\tif $post_pick_group.exists?\n\t\t\t\tpostGroupPop\n\t\t\t\t$post_media_description.set(\"Media Description #{random}.\")\n\t\t\t\t$post_now.fire_event(\"onclick\")\n\t\t\telse puts \"PEV04T02: FAILED! User unable to locate Post button.\"\n\t\t\tend \t\t\t\t\n\t\t\t\n\t\t\tbegin\n\t\t\tassert $post_now.exists?\n\t\t\t\trescue => e\n\t\t\t\tputs (\"PEV04T02: FAILED! User able to Post.\")\n\t\t\t\tputs e\n\t\t\tend\n\t\tend",
"def test03_EmptyGPopDM\n\t\t\tloginPost\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\tif $post_media_description.exists?\n\t\t\t\t$post_media_description.set(\"Media Description #{random}.\")\n \t\t\t\tpostGroupPop\n\t\t\t\t$post_media_button.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t\t$post_now.fire_event(\"onclick\")\n\t\t\telse puts \"PEV04T03: FAILED! User unable to locate Post button.\"\n\t\t\tend\n\t\t\t\n\t\t\tbegin\n\t\t\tsleep 2\n\t\t\tassert $post_new_post.exists?\n\t\t\t\trescue => e\n\t\t\t\tputs (\"PEV04T03: FAILED! User unable to Post.\")\n\t\t\t\tputs e\n\t\t\tend\t\n\t\tend",
"def news_and_media\n # blank\n end",
"def test04_EmptyGPopDM\n\t\t\tloginPost\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\tif $post_media_description.exists?\n\t\t\t\t$post_media_description.set(\"Media Description #{random}.\")\n\t\t\t\t$post_media_button.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t\t$post_now.fire_event(\"onclick\")\n\t\t\telse puts \"PEV03T04: FAILED! UUser unable to locate Post button.\"\n\t\t\tend\n\t\t\t\n\t\t\tbegin\n\t\t\tassert $post_now.exists?\n\t\t\t\trescue => e\n\t\t\t\tputs (\"PEV03T04: FAILED! User able to Post.\")\n\t\t\t\tputs e\n\t\t\tend\t\n\t\tend",
"def test04_post_open_news_EmptyGPopDM\n\t\t\tlogin $user_1_email, $master_password\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\t\n\t\t\tassert $post_media_description.exists?\n\t\t\t$post_media_description.set(\"Media Description #{random}.\")\n\t\t\t$post_media_button.click\n\t\t\tfile_upload \"GlacierBasinTrailMtRainier.JPG\"\n\t\t\t$post_now.fire_event(\"onclick\")\n\n\t\t\tassert $post_now.exists?\n\t\tend",
"def test03_EmptyGPopDMPublish\n\t\t\tloginPost\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\tif $post_media_description.exists?\n\t\t\t\t$post_media_description.set(\"Media Description #{random}.\")\n \t\t\t\tpostGroupPop\n\t\t\t\t$post_media_button.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t\tpostPublishLater\n\t\t\t\t$post_now.fire_event(\"onclick\")\n\t\t\telse puts \"PPL04T03: FAILED! User unable to locate Post button.\"\n\t\t\tend\n\t\t\t\n\t\t\tbegin\n\t\t\tsleep 2\n\t\t\tassert $post_scheduled_post.exists?\n\t\t\t\trescue => e\n\t\t\t\tputs (\"PPL04T03: FAILED! User unable to Post.\")\n\t\t\t\tputs e\n\t\t\tend\t\n\t\tend",
"def create_fake\n record = MediaElement.new\n record.title = params[:title_placeholder] != '0' ? '' : params[:title]\n record.description = params[:description_placeholder] != '0' ? '' : params[:description]\n record.tags = params[:tags_value]\n record.user_id = current_user.id\n record.save_tags = true\n record.valid?\n @errors = convert_media_element_error_messages record.errors\n @errors[:media] = t('forms.error_captions.media_file_too_large').downcase\n end",
"def test02_EmptyMPopGDPublish\n\t\t\tloginPost\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\tif $post_pick_group.exists?\n\t\t\t\tpostGroupPop\n\t\t\t\t$post_media_description.set(\"Media Description #{random}.\")\n\t\t\t\tpostPublishLater\n\t\t\t\t$post_now.fire_event(\"onclick\")\n\t\t\telse puts \"PPL04T02: FAILED! User unable to locate Post button.\"\n\t\t\tend \t\t\t\t\n\t\t\t\n\t\t\tbegin\n\t\t\tassert $post_now.exists?\n\t\t\t\trescue => e\n\t\t\t\tputs (\"PPL04T02: FAILED! User able to Post.\")\n\t\t\t\tputs e\n\t\t\tend\n\t\tend",
"def test_media_find_all\n assert_not_nil @rdigg.media.find_all\n end",
"def test_media_find_by_type\n assert_not_nil @rdigg.media.find_by_type(\"news\")\n end",
"def print_group(group)\n puts \"Name: \" + group.name\n puts \"Description: \" + (group.description.nil? ? \"None\" : group.description)\n puts \"Status: \" + group.status\n puts \"Href: \" + group.href\nend",
"def test03_MediaOneComment_TC_24319\n\t\tcommentMediaPop\n\t\tcommentPopSubmit\n\tend",
"def test04_DraftEmptyGPopDM\n\t\t\tloginPost\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\tif $post_media_description.exists?\n\t\t\t\t$post_media_description.set(\"Media Description #{random}.\")\n\t\t\t\t$post_media_button.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t\tsleep 2\n\t\t\t\tsleep 4\n\t\t\t\t$post_save_draft.fire_event(\"onclick\")\n\t\t\telse puts \"PDEV04T04: FAILED! UUser unable to locate Post button.\"\n\t\t\tend\n\t\t\t\n\t\t\tbegin\n\t\t\tassert $post_draft_error.exists?\n\t\t\t\trescue => e\n\t\t\t\tputs (\"PDEV04T04: FAILED! User able to save incomplete draft.\")\n\t\t\t\tputs e\n\t\t\tend\t\n\t\tend",
"def test04_MediaPhotoVideo\n\t\tlogin $editor_1_email, $master_password\n\t\t$browser.goto($patch_boards_pre_closed_article_new)\n\t\t\n#\t\t$post_activate_note.when_present.fire_event(\"onclick\")\n#\t\t$post_media_description.set(\"mt townsend is my favorite mountain #{random}.\")\n\t\tif $environment == 'nixon'\t\n\t\t\trepostGroupPop #category already selected in staging\n\t\tend\n\t\t$post_article_title.set(\"Mountain #{random}\")\n \t\t$browser.execute_script(\"jQuery('iframe.wysihtml5-sandbox').contents().find('body').prepend('mt townsend is my favorite mountain #{random}.')\")\n\t\tsleep 2\n\t\t$post_add_media_article.click\n\t\tfile_upload \"DungenessSpit102.26.2012.mov\"\n\t\tsleep 2\n\t\t$post_add_media_article.click\n\t\tfile_upload \"GlacierBasinTrailMtRainier.JPG\"\n if $environment == 'staging'\n\t\t\tsleep 10 #loads \n\t\tend\n\t\t$post_now_edit.fire_event(\"onclick\")\n\n\t\tsleep 2\n\t\tassert $post_new_post.exists?\n\tend",
"def album\r\n #prepare_new_album extracted for reuse from spec\r\n prepare_new_album unless @content\r\n end",
"def test03_EmptyGDM\n\t\t\tloginPost\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\tif $post_media_button.exists?\n\t\t\t\t$post_media_button.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t\t$post_now.fire_event(\"onclick\")\n\t\t\telse puts \"PEV03T03: FAILED! User unable to locate Post button.\"\n\t\t\tend\n\t\t\t\n\t\t\tbegin\n\t\t\tassert $post_now.exists?\n\t\t\t\trescue => e\n\t\t\t\tputs (\"PEV03T03: FAILED! User able to Post.\")\n\t\t\t\tputs e\n\t\t\tend\n\t\tend",
"def create_new_media(data_set)\n enter_media_info_data data_set\n click_save_button\n when_exists(delete_button, Config.short_wait)\nend",
"def test02_MediaTwoComments\n\t\tcommentMediaPop\n\t\tcommentPopSubmit\n\tend",
"def test03_4GroupsRepostMedia\n\t\trepostMediaPop\n\t\tsleep 3\n\t\tfourGroupSelect\n\t\tsleep 3\n\t\t\n\t\tbegin \n\t\tassert $repost_confirmation.exists?\n\t\t\trescue => e\n\t\t\tputs \"RS06T03: FAILED! User unable to repost!\"\n\t\t\tputs e\n\t\tend\n\tend",
"def test04_post_closed_news_TwoGroupsRepostMedia\n\t\trepostMediaPop\n\t\tsleep 3\n\t\ttwoGroupSelect\n\t\tsleep 3\n\t\t\n\t\tassert $repost_confirmation.exists?\n\tend",
"def test04_post_closed_board_GroupRepostMedia\n\t\trepostMediaPop\n\t\tsleep 3\n\t\tgroupAddRemoveAdd \"Repost text #{random}.\"\n \t\tsleep 3\n\t\t\n\t\tassert $repost_confirmation.exists?\n\tend",
"def creating_experimental_media(media_hash)\n media_hash.each { |media, quant|\n log_info 'media', media\n if media != -1\n show {\n title \"Creating Experimental Induction Media\"\n separator\n if media.include? 'Kan'\n check \"In an appropriate container, aliquot <b>#{(quant * 3.3).round(2)}mL</b> of <b>M9 + Kan Media</b> and label: <b>#{MEDIA_LABEL_HASH[media]}</b>\"\n else\n check \"In an appropriate container, aliquot <b>#{(quant * 3.3).round(2)}mL</b> of <b>M9 Media</b> and label: <b>#{MEDIA_LABEL_HASH[media]}</b>\"\n end\n if media.include? 'IPTG'\n check \"To the tube labeled #{MEDIA_LABEL_HASH[media]}, add <b>#{(quant * 3.3 * 0.25).round(2)}µl</b> of <b>1M IPTG</b>\" # calculates inducer per 1mL of media\n end\n if media.include? 'arab'\n check \"To the tube labeled #{MEDIA_LABEL_HASH[media]}, add <b>#{(quant * 3.3 * 25).round(2)}µl</b> of <b>1M Arabinose</b>\" # calculates inducer per 1mL of media\n end\n }\n end\n }\n end",
"def ensure_correct_media_id\n # only fandoms tags must have medias\n return unless self[:type] == 'Fandom'\n\n uncategorized = Media.uncategorized\n\n # get the first media of the current tag which is not \"Uncategorized Fandoms\"\n current_media = ([self.media] + self.medias).compact\n media = (current_media - [uncategorized]).first\n\n # if we have a media, we don't need \"Uncategorized Fandoms\" as a media\n if media \n self.remove_media(uncategorized) if self.medias.include?(uncategorized)\n self.update_attribute(:media_id, media.id) if self.media == uncategorized\n end\n\n # make sure the tag has a media id\n if !self.media_id # we don't have a media id\n if !media # and we don't have a media\n # we don't have anything, but we're being wrangled, so add \"Uncategorized Fandoms\"\n self.update_attribute(:media_id, uncategorized.id)\n self.parents << uncategorized unless self.parents.include?(uncategorized)\n else # we do have a media\n # use the one for our first media\n self.update_attribute(:media_id, media.id)\n end\n end\n\n # if the media id isn't for our first media or \"Uncategorized Fandoms\", verify that it's a real media\n if !(self.media_id == uncategorized.id || (media && self.media_id == media.id))\n listed_media = Media.find(self.media_id)\n # it's not a real media or it's been removed\n if !listed_media.is_a?(Media) || !self.medias.include?(listed_media)\n if media\n self.update_attribute(:media_id, media.id)\n else\n self.update_attribute(:media_id, uncategorized.id)\n end\n end\n end\n\n end",
"def createMedia(nameStr, descriptionStr, projectStr)\n s = Sample.creator(\n {\n sample_type_id: SampleType.find_by_name(\"Media\").id,\n description: descriptionStr,\n name: nameStr, \n project: projectStr\n }, User.find(1) )\n end",
"def test05_post_open_news_EmptyDMPopG\n\t\t\tlogin $user_1_email, $master_password\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\t\n\t\t\tassert $post_pick_group.exists?\n \t\t\trepostGroupPop\n\t\t\t$post_now.fire_event(\"onclick\")\n\n\t\t\tassert $post_now.exists?\n\t\tend",
"def prepare\n insert_recording_reporter\n link_example_groups\n end",
"def test03_DraftEmptyGDM\n\t\t\tloginPost\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\tif $post_media_button.exists?\n\t\t\t\t$post_media_button.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t\tsleep 2\n\t\t\t\tsleep 4\n\t\t\t\t$post_save_draft.fire_event(\"onclick\")\n\t\t\telse puts \"PDEV04T03: FAILED! User unable to locate Post button.\"\n\t\t\tend\n\t\t\t\n\t\t\tbegin\n\t\t\tassert $post_draft_error.exists?\n\t\t\t\trescue => e\n\t\t\t\tputs (\"PDEV04T03: FAILED! User able to save incomplete draft.\")\n\t\t\t\tputs e\n\t\t\tend\n\t\tend",
"def tags\n if properties.key?(:media_content) and\n properties[:media_content][:url].present? and\n properties.key?(:media_thumbnail) and\n properties[:media_thumbnail][:url].present?\n %w[image]\n else\n []\n end\n end",
"def create\n media = params[:media]\n record = MediaElement.new :media => media\n record.title = params[:title_placeholder] != '0' ? '' : params[:title]\n record.description = params[:description_placeholder] != '0' ? '' : params[:description]\n record.tags = params[:tags_value]\n record.user_id = current_user.id\n record.save_tags = true\n if record.save\n if !record.image?\n Notification.send_to(\n current_user.id,\n I18n.t(\"notifications.#{record.class.to_s.downcase}.upload.started.title\"),\n I18n.t(\"notifications.#{record.class.to_s.downcase}.upload.started.message\", :item => record.title),\n ''\n )\n end\n else\n if record.errors.added? :media, :too_large\n return render :file => Rails.root.join('public/413.html'), :layout => false, :status => 413\n end\n @errors = convert_media_element_error_messages record.errors\n end\n render :layout => false\n end",
"def test03_GroupRepostMedia\n\t\trepostMediaPop\n\t\tsleep 3\n\t\tgroupAddRemoveAdd\n \t\tsleep 3\n\t\t\n\t\tbegin \n\t\tassert $repost_confirmation.exists?\n\t\t\trescue => e\n\t\t\tputs \"RS2T03: FAILED! User unable to repost!\"\n\t\t\tputs e\n\t\tend\n\tend",
"def test_room_starts_with_empty_playlist\n assert_equal([], @room1.show_playlist()) #OR DO WE COUNT THIS?\n end",
"def test_10a\r\n db = build\r\n assert_equal [],db.groups\r\n end",
"def create_samples data\n data.each do |line|\n if !line.empty?\n if line[0].include? \"sample\"\n # check and see if this sample exists in inventory\n sample_array = line[0].partition(\":\")\n sample_name = sample_array[2].strip #removes leading and trailing whitespace.\n sample_check = Sample.find_by_name(sample_name)\n if sample_check.nil?\n # create the media\n sample = createMedia(sample_name, \"new sample\", \"media\")\n show do\n title \"Sample Created\"\n \n note \"The sample #{sample_name} has been sucessfully created in Aquarium\"\n end\n end\n end\n end\n end \n \n show do\n title \"Samples Created\"\n \n note \"The samples in #{FILENAME} have been sucessfully created in Aquarium.\"\n note \"Please double check and see if you include the word \\\"sample:\\\" before your sample name.\"\n end\n end",
"def test04_group_photo_all\n\t\n\t\tloginGroup\n\t\t$browser.goto($patch_mongooses_settings)\n\t\t$group_image_1.fire_event(\"onclick\")\n\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t$span_3_frames.click\n\t\t$upload_frames_save.click\t\n\tend",
"def test_parser_handles_empty_simple_content\n simple_content_assert nil, nil\n simple_content_assert nil, ''\n end",
"def media() @media = Media.new end",
"def test_attributes\n assert_equal \"Gallery 1\", @gallery.title\n assert @gallery.active?\n assert_equal \"f82dd0bd-4711-4578-ac47-4661257e69a6\", @gallery.guid\n end",
"def medium_names\n primary_media | secondary_media | component_media\n end",
"def load_mediaset\n nil\n end",
"def test04_flag_repost_media_TC_24323\n\t\trepostMediaPop\n\t\tsleep 2\n\t\trepost\n\t\tcommentFlag\n\t\tsleep 2\n\t\t\n\t\tbegin\n\t\tassert $browser.text.include?(\"Comment\")\n\t\trescue => e\n\t\t\tputs e\n\t\tputs \"R8_T4: FAILED! User unable to flag post.\"\n\t\tend\n\tend",
"def videos_test\n end",
"def test05_EmptyDMPopG\n\t\t\tloginPost\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\tif $post_pick_group.exists?\n \t\t\t\tpostGroupPop\n\t\t\t\t$post_now.fire_event(\"onclick\")\n\t\t\telse puts \"PEV03T05: FAILED! User unable to locate Post button.\"\n\t\t\tend \t\t\t\t\n\t\t\t\n\t\t\tbegin\n\t\t\tassert $post_now.exists?\n\t\t\t\trescue => e\n\t\t\t\tputs (\"PEV03T05: FAILED! User able to Post.\")\n\t\t\t\tputs e\n\t\t\tend\n\t\tend",
"def load_media(outputPlate)\r\n show do \r\n title \"Filling new 96-deep well Item ##{outputPlate.id}\" \r\n \r\n note \"In a clean & sterile multichannel reservoir, pour aliquoted media.\" \r\n check \"Grab a new 96-deep well plate and label with the Item ID ##{outputPlate.id}.\" \r\n note \"Using a multichannel P1000 transfer 999uL of media to the following wells.\" \r\n # CollectionDisplay library\r\n table highlight_non_empty(outputPlate) { |r,c| \"999uL\" } \r\n end \r\n end",
"def test02_pre_open_board_MediaCancel\n\t\tlogin $user_1_email, $master_password\n\t\t$browser.goto($patch_media)\n\t\t\n\t\tsleep 2\n\t\tassert $post_media_description.exists?\n\t\t$post_media_description.set(\"Media Description #{random}.\")\n \t\trepostGroupPop\n\t\t$post_media_button.click\n\t\tfile_upload \"GlacierBasinTrailMtRainier.JPG\"\n\t\t$post_cancel.click\n\n\t\tsleep 3\n\t\tassert $post_cancel.exists?\n\tend",
"def test03_post_open_news_251RepostMedia\n\t\trepostMediaPop\n\t\tsleep 3\n\t\trepostPopulate251\n\t\tsleep 3\n\n\t\tassert $repost_confirmation.exists?\n\tend",
"def test01_post_open_news_NoNoteRepostMedia\n\t\trepostMediaPop\n\t\tsleep 3\n\t\trepost \"\" #No note\n\t\tsleep 3\n\t\t\n\t\tassert $repost_confirmation.exists?\n\tend",
"def test05_post_open_news_250RepostMedia\n\t\trepostMediaPop\n\t\tsleep 3\n\t\trepostPopulate250\n\t\tsleep 3\n\n\t\tassert $repost_confirmation.exists?\n\tend",
"def initialize(media_options={})\n @id = media_options[\"id\"]\n @format_type_id= media_options[\"format_type_id\"]\n @anime_series_id= media_options[\"anime_series_id\"]\n @cover_name= media_options[\"cover_name\"]\n end",
"def prepare_attributes\n if media.present? && will_save_change_to_media?\n self.media_content_type = media.file.content_type\n self.media_file_size = media.file.size\n end\n\n if new_record?\n self.folder = folder.sanitize_filename\n tag_list.add(folder)\n tag_list.add(media.file.extension)\n end\n end",
"def test_initialize_group\r\n \ttest_group = ProspectorGroup.new\r\n \ttest_group.intialize_group(33, 3)\r\n \tassert_equal 3, test_group.num_prospectors\r\n \tassert_equal 0 , test_group.iteration_count\r\n end",
"def setupGroupsOfThumbnails(items, header)\n \n lastItem = items.size - 1\n currItem = 0\n\n retval = \"\"\n items.each do |item|\n #if a new row should be made\n if (currItem%3 == 0)\n retval << InitializeRow\n\n #if this is the first item, add the section heading\n if (currItem == 0)\n retval << createHeader(header)\n end\n\n retval << BeginThumbnailSet\n end\n\n \n retval << startIndivThumbnail(item.picture) \n case header\n when \"Organizations\"\n retval << createOrganizationCaption(item)\n when \"People to Know\"\n retval << createLeaderCaption(item) \n end\n\n retval << CreateEndThumbnailItem\n\n\n if (currItem == lastItem || currItem%3 == 2)\n retval << FinishThumbnailList\n end\n\n currItem += 1\nend \n\nreturn retval.html_safe \n end",
"def test_playlist_is_empty()\n assert_equal(0, @room.room_playlist())\n end",
"def test05_DraftEmptyDMPopG\n\t\t\tloginPost\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\tif $post_pick_group.exists?\n \t\t\t\tpostGroupPop\n\t\t\t\tsleep 4\n\t\t\t\t$post_save_draft.fire_event(\"onclick\")\n\t\t\telse puts \"PDEV04T05: FAILED! User unable to locate Post button.\"\n\t\t\tend \t\t\t\t\n\t\t\t\n\t\t\tbegin\n\t\t\tassert $post_draft_error.exists?\n\t\t\t\trescue => e\n\t\t\t\tputs (\"PDEV04T05: FAILED! User able to save incomplete draft.\")\n\t\t\t\tputs e\n\t\t\tend\n\t\tend",
"def test_default_group_pages\n m = Time.now.to_f.to_s.gsub('.', '')\n @s.switch_user(User.admin_user())\n group = create_group(\"g-testgroup-#{m}\")\n path = \"#{group.home_path_for(@s)}/pages\"\n res = @s.execute_get(@s.url_for(\"#{path}.2.json\"))\n assert_equal(\"200\", res.code, \"Should have created pages in postprocessing\")\n json = JSON.parse(res.body)\n assert_not_nil(json[\"index.html\"], \"Expected default page not found\")\n assert_equal(json[\"index.html\"][\"jcr:primaryType\"], \"nt:file\", \"Default home page is not a file\")\n end",
"def test02_ArticleAllFields\n\t\tloginPost\n\t\t$browser.goto($patch_article)\n\t\t\t\n\t\t\tsleep 2\n\t\t\tif $post_pick_group.exists?\n \t\t\t\tpostGroupPop\n \t\t\t\tpostGroupPop2\n \t\t\t\t$post_article_title.set(\"Article #{random}\")\n \t\t\t\t$browser.execute_script(\"jQuery('iframe.wysihtml5-sandbox').contents().find('body').prepend('lava is hot.')\")\n \t\t\t\t$post_add_media.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t\t$post_add_media.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t\t$post_now.fire_event(\"onclick\")\n\t\t\telse puts \"PS01T02: FAILED! User unable to locate Post button.\"\n\t\t\tend\n\t\t\t\n\t\tbegin\n\t\tsleep 2\n\t\tassert $post_new_post.exists?\n\t\t\trescue => e\n\t\t\tputs (\"P01T02: FAILED! User unable to Post.\")\n\t\t\tputs e\n\t\tend\n\tend",
"def test_parser_handles_unsupported_simple_content\n simple_content_assert nil, {}\n simple_content_assert nil, []\n end",
"def test04_MediaPDF\n\t\tlogin $editor_1_email, $master_password\n\t\t$browser.goto($patch_boards_pre_closed_article_new)\n\t\t\n#\t\t$post_activate_note.when_present.fire_event(\"onclick\")\n#\t\t$post_media_description.set(\"mt townsend is my favorite mountain #{random}.\")\n\t\tif $environment == 'nixon'\t\n\t\t\trepostGroupPop #category already selected in staging\n\t\tend\n\t\t$post_article_title.set(\"Mountain #{random}\")\n \t\t$browser.execute_script(\"jQuery('iframe.wysihtml5-sandbox').contents().find('body').prepend('mt townsend is my favorite mountain #{random}.')\")\n\t\tsleep 2\n\t\t$post_add_media_article.click\n\t\tfile_upload \"PDFDocument.pdf\"\n\t\t$post_now_edit.fire_event(\"onclick\")\n\t\tif $environment == 'staging'\n\t\t\tsleep 10 #loads \n\t\tend\n\t\tsleep 2\n\t\tassert $post_new_post.exists?\n\tend",
"def create\n songs = get_kexp_songs()\n idx = 0\n\n while idx < songs['results'].length\n if songs['results'][idx]['playtype']['name'] != \"Media play\"\n idx += 1\n next\n end\n song_title = songs['results'][idx]['track']['name']\n song_artist = songs['results'][idx]['artist']['name']\n \n if !songs['results'][idx]['release']\n song_album = \"\"\n song_release_year = 0\n song_album_img = \"https://cdn.pixabay.com/photo/2019/04/04/18/50/cassette-4103530_1280.jpg\"\n else\n if song_album_img = songs['results'][idx]['release']['largeimageuri'] == nil\n song_album_img = \"https://cdn.pixabay.com/photo/2019/04/04/18/50/cassette-4103530_1280.jpg\"\n else\n song_album_img = songs['results'][idx]['release']['largeimageuri']\n end\n song_album = songs['results'][idx]['release']['name']\n song_release_year = songs['results'][idx]['releaseevent']['year'].to_i\n end\n \n song_is_local = songs['results'][idx]['artist']['islocal']\n #if song|artist|album don't exist -> create \n if Album.find_by(title: song_album) == nil\n song_artist = song_artist.split('feat.')[0]\n mod_artist = song_artist.strip().gsub(/[^0-9a-z ]/i, '').split(' ').join('+')\n parsed_response = get_song_genre(mod_artist)\n \n #if bad status code -> query by song instead\n if parsed_response[\"status_code\"] > 299 || parsed_response[\"status_code\"] < 200 || parsed_response[\"genre\"] == \"\"\n mod_song = song_title.strip().gsub(/[^0-9a-z ]/i, '').split(' ').join('+')\n parsed_response = get_song_genre(mod_song)\n end\n @album = Album.new(title: song_album, album_img: song_album_img, year: song_release_year, genre: parsed_response[\"genre\"])\n @album.save()\n else \n @album = Album.find_by(title: song_album)\n end\n\n if Artist.find_by(name: song_artist) == nil\n @artist = Artist.new(name: song_artist, is_local?: song_is_local, album: @album)\n @artist.save()\n else \n @artist = Artist.find_by(name: song_artist)\n @artist.update(album: @album)\n end\n if Song.find_by(title: song_title) == nil\n @song = Song.new(title: song_title, artist: @artist)\n @song.save()\n else \n @song = Song.find_by(title: song_title)\n @song.update(artist: @artist)\n end\n idx += 1\n end\n redirect_to songs_path\n end",
"def test03_post_open_blog_MediaVideo\n\t\tlogin $user_1_email, $master_password\n\t\t$browser.goto($patch_blogs_post_open)\n\t\t\t\n\t\tsleep 2\n\t\tassert $post_media_description.exists?\n\t\t$post_media_description.set(\"the elwah river original flow was recently restored #{random}.\")\n \t\trepostGroupPop\n\t\t$post_media_button.click\n\t\tfile_upload \"DungenessSpit102.26.2012.mov\"\n\t\t$post_now.fire_event(\"onclick\")\n\t\t\t\n\t\tsleep 2\n\t\tassert $post_new_post.exists?\n\tend",
"def initialize(media)\n @media = media\n end",
"def set_content_defaults\r\n @content.user_id = @user.id\r\n @content.user = @user\r\n @content.is_in_startpage = [email protected]{|a| !a.featured_album?}\r\n @content.is_in_gallery = true\r\n @content_kind_displayname = \"New #{@content.entity_name_for_human.titleize}\".t\r\n @title = @user.login + ' :: ' + @content_kind_displayname\r\n #'New Music Album'.t\r\n #'New Music Contest'.t\r\n end",
"def test_data_extraction\n\t\tYAML.load_file('test/groups.yml')[\"groups\"].each do |g_data|\n\t\t\tstub_request(:get, g_data[\"url\"]).\n\t\t\tto_return(:status => 200, :body => File.read(\"test/yahoo_pages/#{g_data['id']}.html\"), :headers => {})\n\n\t\t\tgroup = YahooGroupData.new(g_data[\"url\"])\n\t\t\tassert_equal g_data[\"age_restricted\"], group.age_restricted?\n\t\t\tassert_equal g_data[\"private\"], group.private?\n\t\t\tassert_equal g_data[\"not_found\"], group.not_found?\n\t\t\tassert_equal g_data[\"name\"], group.name\n\t\t\tassert_equal g_data[\"description\"], group.description\n\t\t\tassert_equal g_data[\"post_email\"], group.post_email\n\t\t\tassert_equal g_data[\"subscribe_email\"], group.subscribe_email\n\t\t\tassert_equal g_data[\"owner_email\"], group.owner_email\n\t\t\tassert_equal g_data[\"unsubscribe_email\"], group.unsubscribe_email\n\t\t\tassert_equal g_data[\"founded\"], group.founded\n\t\t\tassert_equal g_data[\"language\"], group.language\n\t\t\tassert_equal g_data[\"num_members\"], group.num_members\n\t\t\tassert_equal g_data[\"category\"], group.category\n\t\tend\n\tend",
"def check_media\n\t\tif !GroupMedia.where(:media_id => self.media_id).exists?\n\t\t\tMedia.destroy(self.media_id)\n\t\tend\n\tend",
"def list_media_details(gallery_name = \"test\", _browser = @browser)\n wait = Selenium::WebDriver::Wait.new(:timeout => 15)\n Log.logger.info(\"Listing Media properties and ids to edit it (for Gallery: #{gallery_name.inspect})\")\n self.open_gallery(gallery_name)\n wait.until { _browser.find_element(:xpath => @galmgr.edit_media) }.click\n frame = wait.until { _browser.find_element(:xpath => @galmgr.edit_overlay_frame) }\n _browser.switch_to.frame(frame)\n edit_media_ids = Hash.new\n i = 1\n wait.until { _browser.find_element(:xpath => \"//div[contains(@id, 'media-edit-')]\") }\n med_ct = Integer(_browser.find_elements(:xpath => \"//div[contains(@id, 'media-edit-')]\").size)\n Log.logger.info(\"Found editable images: #{med_ct}\")\n while i < med_ct+1\n media_url = _browser.find_element(:xpath => \"//div[contains(@id, 'media-edit-#{i}')]//img[contains(@class, '')]\").attribute(\"src\")\n Log.logger.info(\"Working on image number #{i}: #{media_url.inspect}\")\n if (i == 1)\n if(_browser.find_elements(:xpath => \"//select[@id = 'edit-field-license-und']\").size < 1)\n media_license_setting = \"\"\n media_type = \"video\"\n else\n media_license_setting = \"//select[@id = 'edit-field-license-und']\"\n media_type = \"image\"\n end\n media_title = \"//input[@id = 'edit-media-title-und-0-value']\"\n media_description = \"//textarea[@id = 'edit-media-description-und-0-value']\"\n media_tag = \"//input[@id = 'edit-field-tags-und']\"\n else\n if(_browser.find_elements(:xpath => \"//select[@id = 'edit-field-license-und--#{i}']\").size < 1)\n media_license_setting = \"\"\n media_type = \"video\"\n else\n media_license_setting = \"//select[@id = 'edit-field-license-und--#{i}']\"\n media_type = \"image\"\n end\n media_title = \"//input[@id = 'edit-media-title-und-0-value--#{i}']\"\n media_description = \"//textarea[@id = 'edit-media-description-und-0-value--#{i}']\"\n media_tag = \"//input[@id = 'edit-field-tags-und--#{i}']\"\n end\n\n Log.logger.info(\"image number #{i} media-type: #{media_type.inspect}\")\n Log.logger.info(\"image number #{i} media-title: #{media_title.inspect}\")\n edit_media_ids[media_url] = Hash.new() unless (edit_media_ids[media_url])\n edit_media_ids[media_url][:license] = media_license_setting\n edit_media_ids[media_url][:tag] = media_tag\n edit_media_ids[media_url][:desc] = media_description\n edit_media_ids[media_url][:title] = media_title\n edit_media_ids[media_url][:type] = media_type\n i += 1\n end\n return edit_media_ids\n end",
"def media\n parse(delete('media'))\n end",
"def test_media_whitespace\n params = 'img.jpg mobile: \"white space.jpg\"'\n\n assert_equal 'white space.jpg', tested(params).source_names[1]\n end",
"def test_show_single_photo\n photo_set = photo_sets('lonely_photo_set')\n photo = photos('lonely_photo')\n get :set, { :photo_set => photo_set, :photo => photo }\n assert_response :success\n \n assert long_title = \"#{photo_set.title} - #{photo.title}\"\n assert_select 'h1', long_title\n\n assert_select \"li.thumbs\", false\n assert_select \"#thumbnav\", false\n end",
"def test_groupdetail_constructor_and_accessors\n\n obj = SmsCountryApi::Group::GroupDetail.new\n refute_nil obj, \"Object wasn't created successfully.\"\n assert_kind_of SmsCountryApi::Group::GroupDetail, obj, \"Object isn't the correct type.\"\n assert_nil obj.id, \"ID isn't nil.\"\n assert_nil obj.name, \"Name isn't nil.\"\n assert_nil obj.tiny_name, \"Tiny name isn't nil.\"\n assert_nil obj.start_call_on_enter, \"Start call on enter isn't nil.\"\n assert_nil obj.end_call_on_exit, \"End call on exit isn't nil.\"\n assert_nil obj.members, \"Members isn't nil.\"\n\n end",
"def test_creating_public_description\n # We want to create an empty, default public description for a name that\n # doesn't have any descriptions yet -- simplest possible case.\n @name = Name.find_by(text_name: \"Strobilurus diminutivus\")\n assert_equal([], @name.descriptions)\n @description_data = {\n source_type: \"public\",\n source_name: nil,\n readable: true,\n writable: true,\n notes: \"I like this mushroom.\"\n }\n @group_expectations = {\n admins: [UserGroup.reviewers],\n writers: [UserGroup.all_users],\n readers: [UserGroup.all_users],\n authors: [],\n editors: [mary]\n }\n\n admin = open_admin_session(dick)\n reviewer = open_normal_session(rolf)\n owner = open_normal_session(mary)\n random_user = open_normal_session(katrina)\n lurker = open_lurker_session\n\n reviewer.should_be_reviewer\n owner.should_not_be_reviewer\n random_user.should_not_be_reviewer\n\n # sets (not checks) the abilities\n admin.should_be_able_to_do_anything\n reviewer.should_be_able_to_do_anything_but_change_permissions\n owner.should_be_able_to_edit_and_change_name\n random_user.should_be_able_to_edit_text_only\n lurker.should_be_able_to_see_but_needs_to_login\n\n owner.create_name_description\n owner.check_name_description\n\n admin.check_abilities\n reviewer.check_abilities\n owner.check_abilities\n random_user.check_abilities\n lurker.shouldnt_be_able_to_do_anything\n end",
"def test03_pre_closed_news_NoteVideoPhotoPDF_TC_24302_TC_24304\n\t\tlogin $editor_1_email, $master_password\n\t\t$browser.goto($patch_news_pre_open)\n\t\tsleep 2\n\t\t\n\t\tassert $post_pick_group.exists?\n \t\t$post_pick_group.when_present.fire_event(\"onclick\")\n\t\t$post_media_description.when_present.set(\"All fishing is off limits in the olympic national park.\")\n \t\trepostGroupPop\n \t\t#sleep 2\n \t\t#$post_media_button\n\t\t$post_add_media.when_present.click\n\t\tfile_upload \"DungenessSpit102.26.2012.mov\"\n\t\t$post_add_media.click\n\t\tfile_upload \"GlacierBasinTrailMtRainier.JPG\"\n\t\t$post_add_media.click\n\t\tfile_upload \"PDFDocument.pdf\"\n\t\t$post_add_media.click\n\t\tfile_upload \"PDF2.pdf\"\n\t\t$post_now.fire_event(\"onclick\")\n\t\t\t\n\t\tsleep 2\n\t\tassert $post_new_post.exists?\n\tend",
"def prefill_media_cuvettes op, media_vol, op_collection\n op_collection_item = Item.find(op_collection.id)\n output_obj_type = op_collection_item.object_type.name\n type_of_media = op.input(MEDIA_TYPE).val\n display_matrix = []\n matrix = op_collection.matrix\n show do\n note \"matrix: #{matrix}\"\n end\n \n flattened_matrix = matrix.flatten\n flattened_matrix.each_slice(op_collection.dimensions[1]) do |slice|#matrix.each_slice(collection.dimensions[1]).map{|slice| Array.new(op_collection.dimensions[1]) { |i| media_vol}}.each do |slice| \n display_matrix.push(slice)\n end\n \n op_collection.get_non_empty.each do |tuple|\n display_matrix[tuple[0]][tuple[1]] = media_vol\n end\n \n display_matrix.each do |row|\n row.reject! do |cell|\n cell == -1\n end\n end\n \n # Tells the technician to fill with media.\n show do\n title \"Fill #{output_obj_type} with #{type_of_media} Media\"\n \n check \"Grab a clean <b>#{output_obj_type}</b>.\"\n check \"Label the #{output_obj_type} => <b>#{op_collection_item.id}</b>.\"\n if media_vol != 0\n # note \"Follow the table to transfer the samples from the input collection to the output collection.\"\n note \"The coordinates in the following table are coordinates from the input collection\"\n note \"Fill each well with #{media_vol} uL of #{type_of_media}\"\n table highlight_matrix display_matrix\n end\n end\n\n end",
"def test_require_group\n render text: 'OK'\n end",
"def media_status\n super\n end",
"def test_10b\r\n db = build\r\n nm = File.join(test_data,'image-1.jpg')\r\n db['group1'].store(nm)\r\n assert File.exists?(File.join(db.root,'groups',\r\n 'group1','originals',\r\n 'image-1.jpg'))\r\n end",
"def test04_post_open_blog_MediaTwoVideo\n\t\tlogin $user_1_email, $master_password\n\t\t$browser.goto($patch_blogs_post_open)\n\t\t\t\n\t\tsleep 2\n\t\tassert $post_media_description.exists?\n\t\t$post_media_description.set(\"whiskey bend road has been closed #{random}.\")\n \t\trepostGroupPop\n\t\t$post_media_button.click\n\t\tfile_upload \"DungenessSpit102.26.2012.mov\"\n\t\t$post_media_button.click\n\t\tfile_upload \"DungenessSpit202.26.2012.mpg\"\n\t\t$post_now.fire_event(\"onclick\")\n\t\t\t\n\t\tsleep 2\n\t\tassert $post_new_post.exists?\n\tend",
"def test_playlist\n end",
"def test_basedata\n assert_not_nil(Cardiotype.find(:first, :conditions => [\"description = ?\", \"Run\"]))\n assert_not_nil(Cardiotype.find(:first, :conditions => [\"description = ?\", \"Swim\"]))\n assert_not_nil(Cardiotype.find(:first, :conditions => [\"description = ?\", \"Cycle\"]))\n end",
"def test03_login_search_media_TC_24325\n\t\t$browser.goto($patch)\n\t\t$search_text_field.set(\"Automated media\")\n\t\t$search_button.click\n\t\t$search_result_media.when_present.click\n\t\tsleep 2\n\t\t\n\t\tassert $browser.text.include?(\"Comment\")\n\tend",
"def test03_publish_media_draft\n\t\tloginPost\n\t\t$browser.goto($patch_media)\n\t\tsleep 2\n\t\tif $post_media_description.exists?\n\t\t\t$post_media_description.set(\"Media Description #{random}.\")\n \t\t\tpostGroupPop\n\t\t\t$post_media_button.click\n\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t$post_save_draft.fire_event(\"onclick\")\n\t\telse puts \"PD04T03: FAILED! User unable to save draft.\"\n\t\tend\n\t\t\n\t\tif $post_draft_success.exists?\n\t\t\tcancel_delete\n\t\telse puts \"PD04T01: FAILED! Unable to delete draft.\"\n\t\tend\n\tend",
"def test_book_with_no_image_returns_nil_for_image\n data = post_book('id' => 3)\n assert_equal(nil, data[0]['data']['image'])\n end",
"def test02_post_open_blog_MediaTwoVideoClips\n\t\tlogin $user_1_email, $master_password\n\t\t$browser.goto($patch_blogs_post_open)\n\t\t\t\n\t\tsleep 2\n\t\tassert $post_media_description.exists?\n\t\t$post_media_description.set(\"hiking mt st helens isnt as cool #{random}.\")\n \t\trepostGroupPop\n\t\t$post_media_button.click\n\t\tfile_upload \"DungenessSpit102.26.2012.mov\"\n\t\t$post_media_button.click\n\t\tfile_upload \"DungenessSpit202.26.2012.mpg\"\n\t\t$post_now.fire_event(\"onclick\")\n\t\t\t\n\t\tsleep 2\n\t\tassert $post_new_post.exists?\n\tend",
"def groups; end",
"def groups; end",
"def groups; end",
"def test03_logged_out_search_media_TC_24324\n\t\tpostMediaSetupQuick\n\t\tpostLogout\n\t\tsleep 2\n\t\t$search_text_field.set(\"Automated media\")\n\t\t$search_button.click\n\t\t$search_result_media.when_present.click\n\t\tsleep 2\n\t\t\n\t\tbegin\n\t\t\tassert $browser.text.include?(\"Comment\")\n\t\t\trescue => e\n\t\t\t\tputs e\n\t\t\tputs \"PSL2_T3: FAILED! User unable to locate post.\"\n\t\tend\n\tend",
"def verify_changed_gallery_settings(nom, cols, media_display = \"Show nothing\")\n wait = Selenium::WebDriver::Wait.new(:timeout => 15)\n Log.logger.info(\"Starting test for Verification of Gallery Settings done in previous test\")\n i = 0\n while i < nom\n image_xpath = \"//div[contains(@class, 'media-gallery-sortable-processed') and contains(@class, 'ui-sortable')]/div[contains(@id, 'media-gallery-media-#{i}')]\"\n @browser.find_elements(:xpath => image_xpath).should have_at_least(1).items\n @browser.find_element(:xpath => \"#{image_xpath}//div[@class='gallery-thumb-inner']/a/img\").click\n cbox = wait.until { @browser.find_element(:xpath =>\"//div[@id='cboxClose']\") } #this element is invis...needs hover or js_click\n Log.logger.info(\"Clicking cbox via js...\")\n begin\n elem = @browser.find_element(:xpath => \"//div[@id='cboxClose']\")\n script = \"arguments[0].click();\"\n @browser.execute_script(script, elem)\n rescue Exception => e\n Log.logger.info(\"Caught an exception: #{e.inspect}\")\n end\n if (media_display == \"Show nothing\")\n # Actual element is \"//div[@id='media-gallery-media-#{i}']/div/span/span/span/span[contains(@class, 'media-title')]\". Asertion is for relative path.\n @browser.find_elements(:xpath => \"#{image_xpath}/.//span[contains(@class, 'media-title')]\").should be_empty\n # Actual element is \"//div[@id='media-gallery-media-#{i}']/div/a/span/span/span[contains(@class, 'media-title')]\". Asertion is for relative path. Difference is a tag.\n @browser.find_elements(:xpath => \"#{image_xpath}//a//span[contains(@class, 'media-title')]\").should be_empty\n end\n if (media_display == \"Show title below\")\n # Actual element is \"//div[@id='media-gallery-media-#{i}']/div/span/span/span/span[contains(@class, 'media-title')]\". Asertion is for relative path.\n @browser.find_elements(:xpath => \"#{image_xpath}//span[contains(@class, 'media-title')]\").should have_at_least(1).items\n end\n if (media_display == \"Show title on hover\")\n # Actual element is \"//div[@id='media-gallery-media-#{i}']/div/a/span/span/span[contains(@class, 'media-title')]\". Asertion is for relative path. Difference is a tag.\n @browser.find_elements(:xpath => \"#{image_xpath}//a//span[contains(@class, 'media-title')]\").should have_at_least(1).items\n end\n i += 1\n end\n @browser.find_elements(:xpath => \"//div[contains(@class, 'content')]/div[contains(@class, 'mg-col-#{cols}')]\").should have_at_least(1).items\n # NOTE: This last four assertions will only work if the gallery has number of images more than nom.\n @browser.find_elements(:xpath => \"//a[contains(@title, 'Go to page 2')]\").should have_at_least(1).items\n @browser.find_elements(:xpath => \"//a[contains(@title, 'Go to next page')]\").should have_at_least(1).items\n @browser.find_elements(:xpath => \"//a[contains(@title, 'Go to last page')]\").should have_at_least(1).items\n @browser.find_elements(:xpath => \"//div[contains(@class, 'media-gallery-sortable-processed') and contains(@class, 'ui-sortable')]/div[contains(@id, 'media-gallery-media-#{nom}')]\").should be_empty\n end",
"def media_type; end",
"def media_type; end",
"def audios_test\n end",
"def test02_group_photo_center\n\t\n\t\tloginGroup\n\t\t$browser.goto($patch_mongooses_settings)\n\t\t$group_image_2.fire_event(\"onclick\")\n\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t$upload_frames_save.click\t\t\n\tend",
"def media\n super\n end",
"def test01()\n sourceMovie = File.join($directory, \"images/418_clip5_sd.m4v\")\n begin\n # 1. Get the possible track media types.\n getMediaTypes = CommandModule.make_get_nonobjectproperty(property: :mediatypes,\n type: :movieimporter)\n theResult = Smig.perform_command(getMediaTypes)\n mt = \"soun clcp meta muxx sbtl text tmcd vide\"\n raise 'Different list of media types: ' + theResult unless theResult.eql? mt\n \n # Create the list of commands object, ready to have commands added to it.\n theCommands = CommandModule::SmigCommands.new\n theCommands.saveresultstype = :lastcommandresult\n\n # 2.1. Create a movie importer, get the movie importers base object reference.\n movieImporterName = SecureRandom.uuid\n\n movieObject = theCommands.make_createmovieimporter(sourceMovie,\n name: movieImporterName,\n addtocleanup: false)\n\n # 2.2. Create the get_objectproperty command.\n getReferenceCommand = CommandModule.make_get_objectproperty(movieObject,\n property: :objectreference)\n theCommands.add_command(getReferenceCommand)\n theResult = Smig.perform_commands(theCommands)\n \n # We now use that reference for getting other properties of the movie.\n # 3. So we got the result without an exception being thrown. We have the ref.\n movieObject = SmigIDHash.make_objectid(objectreference: theResult.to_i)\n\n # 4. Get the movie importer object name.\n getObjectTypeCommand = CommandModule.make_get_objectproperty(movieObject,\n property: :objectname)\n res = Smig.perform_command(getObjectTypeCommand)\n raise 'Movie importer name is wrong' unless res.eql? movieImporterName\n\n # 5. Get the movie importer object type.\n getObjectTypeCommand = CommandModule.make_get_objectproperty(movieObject,\n property: :objecttype)\n res = Smig.perform_command(getObjectTypeCommand)\n raise 'Movie importer type not :movieimporter' unless res.eql? 'movieimporter'\n\n # 6. Get the movie importer metadata.\n getObjectTypeCommand = CommandModule.make_get_objectproperty(movieObject,\n property: :metadata)\n res = Smig.perform_command(getObjectTypeCommand)\n meta = '[{\"key\":\"@cmt\",\"keyspace\":\"itsk\",\"stringValue\":\"iTunes metadata: Exported to preset AVAssetExportPresetAppleM4VCellular using avexporter at: 20 Nov 2014 13:25\"}]'\n raise 'Movie metadata has changed' unless res.eql? meta\n \n # 7. Get the number of tracks in the movie\n getObjectTypeCommand = CommandModule.make_get_objectproperty(movieObject,\n property: :numberoftracks)\n res = Smig.perform_command(getObjectTypeCommand).to_i\n raise 'Movie should have 2 tracks: ' unless res.eql? 2\n\n # 8. Get the number of video tracks in the movie\n getObjectTypeCommand = CommandModule.make_get_objectproperty(movieObject,\n property: :numberoftracks)\n getObjectTypeCommand.add_option(key: :mediatype, value: :vide)\n res = Smig.perform_command(getObjectTypeCommand).to_i\n raise 'Movie should have 1 video tracks: ' unless res.eql? 1\n\n # 9. Get the number of audio tracks in the movie\n getObjectTypeCommand = CommandModule.make_get_objectproperty(movieObject,\n property: :numberoftracks)\n getObjectTypeCommand.add_option(key: :mediatype, value: :soun)\n res = Smig.perform_command(getObjectTypeCommand).to_i\n raise 'Movie should have 1 audio track: ' unless res.eql? 1\n\n getPropertiesCommand = CommandModule.make_get_objectproperties(movieObject,\n saveresultstype: :jsonstring)\n res = Smig.perform_command(getPropertiesCommand)\n props = '{\"objectname\":\"67ea7e99-b0c8-413a-9688-9020b4ddf53d\",' +\n '\"objecttype\":\"movieimporter\",\"metadataformats\":\"com.apple.itunes org.mp4ra\",\"file\":' +\n '\"/Volumes/MacintoshHD/Users/ktam/gitlab/movingimages/testing/images/418_clip5_sd.m4v\",' +\n '\"duration\":{\"flags\":1,\"value\":9000,\"timescale\":600,\"epoch\":0},\"objectreference\":1,' +\n '\"numberoftracks\":2}'\n propsH = JSON.parse(props)\n resH = JSON.parse(res)\n unless propsH[:objecttype].eql? propsH[:objecttype]\n raise \"Movie importer object type is wrong: #{res}\"\n end\n\n unless propsH[:file].eql? propsH[:file]\n raise \"file is different: #{res}\"\n end\n\n unless propsH[:duration].eql? propsH[:duration]\n raise \"duration is different: #{res}\"\n end\n\n unless propsH[:numberoftracks].eql? propsH[:numberoftracks]\n raise \"number of tracks is different: #{res}\"\n end\n\n rescue RuntimeError => e\n $errorcode = Smig.exitvalue\n unless $errorcode.zero?\n puts \"Exit string: \" + Smig.exitstring\n puts \" Exit status: \" + $errorcode.to_s\n end\n puts e.message\n puts e.backtrace.to_s\n ensure\n # 11. Close the movie object\n Smig.close_object_nothrow(movieObject)\n end\nend",
"def initialize(media_elem)\n super()\n\n @id = nil\n @media_url = nil # メディアの URL\n @media_url_https = nil # メディアの SSL URL\n @url = nil # メディア URL(展開)\n @display_url = nil\n @expanded_url = nil\n @type = MEDIA_TYPE_PHOTO # only \"photo\" for now\n @sizes = nil\n @indices = nil\n end",
"def create_medium(params)\n self.media.create(message_sid: params[\"MessageSid\"], ext: params[\"MediaContentType0\"].split(\"/\")[1], media_type: params[\"MediaContentType0\"].split(\"/\")[0], url: params[\"MediaUrl0\"])\n end",
"def test05_250RepostMedia\n\t\trepostMediaPop\n\t\tsleep 3\n\t\trepostPopulate250\n\t\tsleep 3\n\t\t\n\t\tbegin \n\t\tassert $repost_confirmation.exists?\n\t\t\trescue => e\n\t\t\tputs \"RS4T05: FAILED! User unable to repost!\"\n\t\t\tputs e\n\t\tend\n\tend",
"def add_media_action(gallery_name, media_url_list = [\"http://testimages.drupalgardens.com/sites/testimages.drupalgardens.com/files/styles/media_gallery_large/public/150x62XMasNeon.gif\"], _browser = @browser)\n wait = Selenium::WebDriver::Wait.new(:timeout => 15)\n Log.logger.info(\"Adding New Images into the Gallery '#{gallery_name}'.\")\n # media_xpath = \"//div[contains(@id, 'media-gallery-media-')]//a[@href and contains(@class, 'media-gallery-thumb')]\"\n media_xpath = \"//div[contains(@class, 'media-gallery-sortable-processed ui-sortable')]/div[contains(@id, 'media-gallery-media-')]\"\n Log.logger.info(\"Opening Gallery #{gallery_name}\")\n self.open_gallery(gallery_name)\n media_url_list.each do |media_url|\n Log.logger.info(\"Working on media item: #{media_url}\")\n switch_to_last_pagination_page\n #Get the amount of items so we later know which ID something that gets added will get (IDs start at 0, so it will get the id 'nom')\n nom = Integer(_browser.find_elements(:xpath => media_xpath).size)\n Log.logger.info(\"Found #{nom} media item(s).\")\n\n Log.logger.info(\"Waiting for 'Add media' link.\")\n wait.until { _browser.find_element(:xpath => @galmgr.add_media) }\n #we have to wait for the WHOLE page to be loaded and it might even refresh itself for some reason.\n #if we don't sleep, we sometimes run into the page refreshing after we clicked on the add media link\n JQuery.wait_for_events_to_finish(_browser)\n Log.logger.info(\"Clicking on'Add media' link.\")\n _browser.find_element(:xpath => @galmgr.add_media).click\n Log.logger.info(\"Waiting for Overlay.\")\n wait.until { _browser.find_element(:xpath => \"//div[@class='ui-widget-overlay']\") }\n Log.logger.info(\"Waiting for media browser iframe.\")\n start_time = Time.now\n frame = wait.until { _browser.find_element(:xpath => @galmgr.media_upload_frame) }\n Log.logger.info(\"Found media browser iframe after #{Time.now - start_time} seconds.\")\n JQuery.wait_for_events_to_finish(_browser)\n if _browser.find_elements(:xpath => @galmgr.media_upload_frame).size > 0 #perhaps unnecessary?\n Log.logger.info(\"Switching to media browser iframe.\")\n _browser.switch_to.frame(_browser.find_element(:xpath => @galmgr.media_upload_frame))\n else\n raise \"Media Browser frame seems to have disappeared after we had waited for it!\"\n end\n Log.logger.info(\"Waiting for media upload tab link\")\n wait.until { _browser.find_element(:xpath => @galmgr.embed_image_video) }.click\n #Wait til the content of the tab is actually visible\n Log.logger.info(\"Waiting for media upload tab to be visible\")\n wait.until { _browser.find_element(:xpath => \"//div[@id='media-tab-upload' and not(@class='ui-tabs-hide')]\") }\n Log.logger.info(\"Waiting for text input field and entering media URL: (#{media_url})\")\n temp = wait.until { _browser.find_element(:xpath => @galmgr.url_textbox) }\n temp.clear\n temp.send_keys(media_url)\n Log.logger.info(\"Waiting for and clicking on submit button\")\n wait.until { _browser.find_element(:xpath => @galmgr.submit_url_btn) }.click\n Log.logger.info(\"Waiting for embed popup to disappear\")\n # wait.until { ! _browser.find_element(:xpath => @galmgr.embed_image_video) }\n Log.logger.info(\"Switching back to main frame.\")\n _browser.switch_to.default_content\n Log.logger.info(\"Waiting for overlay to disappear.\")\n wait.until { _browser.find_elements(:xpath => \"//div[@class='ui-widget-overlay']\").empty? }\n Log.logger.info(\"Overlay is gone.\")\n #Our newly inserted element will show up shortly EITHER on a new paginated page or within this context\n partial_file_name = media_url.split('/').last.split(\".\").first.gsub(\"watch?v=\", \"\")\n Log.logger.info(\"Waiting for the media-gallery-media-#{nom} we just added to show up (with a link inside and an img src that points to a file with #{partial_file_name.inspect}).\")\n #TODO: Find out if this can be handled by an \"OR\" in the xpath\n start_time = Time.now\n if switch_to_last_pagination_page()\n nom = Integer(_browser.find_elements(:xpath => media_xpath).size)\n Log.logger.info(\"Found #{nom} media items on the last page.\")\n end\n inserted_media_item_path = \"//img[contains(@src, '#{partial_file_name}')]\"\n #//div[contains(@id, 'media-gallery-media-#{nom}')].//div[contains(@class, 'media-gallery-draggable-processed')].//a[@href and contains(@class, 'media-gallery-thumb')].\n Log.logger.info(\"Waiting for #{inserted_media_item_path}\")\n wait.until { _browser.find_element(:xpath => inserted_media_item_path) }\n Log.logger.info(\"Inserted media item 'media-gallery-media-#{nom}' showed up (after #{Time.now - start_time} seconds).\")\n end #end each-loop\n JQuery.wait_for_events_to_finish(_browser)\n Log.logger.info(\"Done with media file insertion\")\n end",
"def test_multiple_images\n two_image_setup\n\n correct = <<~HEREDOC\n <picture>\n <source media=\"mquery\" srcset=\"ss mobile\" type=\"original\">\n <source srcset=\"ss\" type=\"original\">\n <img src=\"good_url\">\n </picture>\n HEREDOC\n\n assert_equal correct, @tested.to_s\n end",
"def description\n [@group.description,@description].join(' ')\n end",
"def ensure_others\n self.description ||= self.title\n self.url ||= \"http://www.google.com\"\n self.image_url ||= \"https://s33.postimg.cc/pjju7pp9b/shire.jpg\"\n end"
] | [
"0.621615",
"0.6207188",
"0.61272883",
"0.59761477",
"0.59362775",
"0.5917642",
"0.5912377",
"0.58794636",
"0.58792645",
"0.5844373",
"0.5810699",
"0.5773535",
"0.5735547",
"0.5667927",
"0.56647646",
"0.5631786",
"0.56185323",
"0.5614461",
"0.55711484",
"0.5565385",
"0.55505264",
"0.5536555",
"0.55324",
"0.55302215",
"0.54769933",
"0.54515964",
"0.54461277",
"0.542128",
"0.54157215",
"0.54017913",
"0.5390505",
"0.5383855",
"0.53829",
"0.53793",
"0.53757936",
"0.5358215",
"0.53579205",
"0.53509355",
"0.53502697",
"0.5342591",
"0.5323693",
"0.528743",
"0.5280726",
"0.5270803",
"0.5269653",
"0.525372",
"0.52474135",
"0.52254486",
"0.52230203",
"0.52191025",
"0.51977426",
"0.5192318",
"0.5189377",
"0.5173159",
"0.51649183",
"0.5164242",
"0.51633656",
"0.5156032",
"0.51558447",
"0.5153104",
"0.5149506",
"0.5145297",
"0.51443714",
"0.514339",
"0.51388556",
"0.51363945",
"0.5101828",
"0.5100752",
"0.5096968",
"0.50762886",
"0.50743043",
"0.50674653",
"0.5064131",
"0.50636494",
"0.5056041",
"0.50524056",
"0.5047509",
"0.5036995",
"0.50322646",
"0.5027413",
"0.50250226",
"0.5003781",
"0.5000067",
"0.5000067",
"0.5000067",
"0.4997472",
"0.4997317",
"0.49933976",
"0.49933976",
"0.4980178",
"0.49713922",
"0.49606538",
"0.4960176",
"0.49484676",
"0.4946593",
"0.49446562",
"0.49439898",
"0.4940852",
"0.49403232",
"0.49374607"
] | 0.5395855 | 30 |
Test 4: Empty groups, populated description, populated media | def test04_post_open_news_EmptyGPopDM
login $user_1_email, $master_password
$browser.goto($patch_media)
sleep 2
assert $post_media_description.exists?
$post_media_description.set("Media Description #{random}.")
$post_media_button.click
file_upload "GlacierBasinTrailMtRainier.JPG"
$post_now.fire_event("onclick")
assert $post_now.exists?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test03_MediaAllFields\n\t\tloginPost\n\t\t$browser.goto($patch_media)\n\t\t\t\n\t\t\tsleep 2\n\t\t\tif $post_media_description.exists?\n\t\t\t\t$post_media_description.set(\"pictures of hiking mr. rainier #{random}.\")\n \t\t\t\tpostGroupPop\n \t\t\t\tpostGroupPop2\n\t\t\t\t$post_media_button.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t\t$post_media_button.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t\t$post_now.fire_event(\"onclick\")\n\t\t\telse puts \"P01T03: FAILED! User unable to locate Post button.\"\n\t\t\tend\n\t\t\t\n\t\tbegin\n\t\tsleep 2\n\t\tassert $post_new_post.exists?\n\t\t\trescue => e\n\t\t\tputs (\"P01T03: FAILED! User unable to Post.\")\n\t\t\tputs e\n\t\tend\t\n\tend",
"def print_group(group)\n puts \"Name: \" + group.name\n puts \"Description: \" + (group.description.nil? ? \"None\" : group.description)\n puts \"Status: \" + group.status\n puts \"Href: \" + group.href\nend",
"def test02_EmptyMPopGD\n\t\t\tloginPost\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\tif $post_pick_group.exists?\n\t\t\t\tpostGroupPop\n\t\t\t\t$post_media_description.set(\"Media Description #{random}.\")\n\t\t\t\t$post_now.fire_event(\"onclick\")\n\t\t\telse puts \"PEV04T02: FAILED! User unable to locate Post button.\"\n\t\t\tend \t\t\t\t\n\t\t\t\n\t\t\tbegin\n\t\t\tassert $post_now.exists?\n\t\t\t\trescue => e\n\t\t\t\tputs (\"PEV04T02: FAILED! User able to Post.\")\n\t\t\t\tputs e\n\t\t\tend\n\t\tend",
"def test03_EmptyGPopDM\n\t\t\tloginPost\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\tif $post_media_description.exists?\n\t\t\t\t$post_media_description.set(\"Media Description #{random}.\")\n \t\t\t\tpostGroupPop\n\t\t\t\t$post_media_button.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t\t$post_now.fire_event(\"onclick\")\n\t\t\telse puts \"PEV04T03: FAILED! User unable to locate Post button.\"\n\t\t\tend\n\t\t\t\n\t\t\tbegin\n\t\t\tsleep 2\n\t\t\tassert $post_new_post.exists?\n\t\t\t\trescue => e\n\t\t\t\tputs (\"PEV04T03: FAILED! User unable to Post.\")\n\t\t\t\tputs e\n\t\t\tend\t\n\t\tend",
"def test_media_find_all\n assert_not_nil @rdigg.media.find_all\n end",
"def test04_EmptyGPopDM\n\t\t\tloginPost\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\tif $post_media_description.exists?\n\t\t\t\t$post_media_description.set(\"Media Description #{random}.\")\n\t\t\t\t$post_media_button.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t\t$post_now.fire_event(\"onclick\")\n\t\t\telse puts \"PEV03T04: FAILED! UUser unable to locate Post button.\"\n\t\t\tend\n\t\t\t\n\t\t\tbegin\n\t\t\tassert $post_now.exists?\n\t\t\t\trescue => e\n\t\t\t\tputs (\"PEV03T04: FAILED! User able to Post.\")\n\t\t\t\tputs e\n\t\t\tend\t\n\t\tend",
"def prepare\n insert_recording_reporter\n link_example_groups\n end",
"def test03_MediaOneComment_TC_24319\n\t\tcommentMediaPop\n\t\tcommentPopSubmit\n\tend",
"def test03_EmptyGPopDMPublish\n\t\t\tloginPost\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\tif $post_media_description.exists?\n\t\t\t\t$post_media_description.set(\"Media Description #{random}.\")\n \t\t\t\tpostGroupPop\n\t\t\t\t$post_media_button.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t\tpostPublishLater\n\t\t\t\t$post_now.fire_event(\"onclick\")\n\t\t\telse puts \"PPL04T03: FAILED! User unable to locate Post button.\"\n\t\t\tend\n\t\t\t\n\t\t\tbegin\n\t\t\tsleep 2\n\t\t\tassert $post_scheduled_post.exists?\n\t\t\t\trescue => e\n\t\t\t\tputs (\"PPL04T03: FAILED! User unable to Post.\")\n\t\t\t\tputs e\n\t\t\tend\t\n\t\tend",
"def news_and_media\n # blank\n end",
"def create_fake\n record = MediaElement.new\n record.title = params[:title_placeholder] != '0' ? '' : params[:title]\n record.description = params[:description_placeholder] != '0' ? '' : params[:description]\n record.tags = params[:tags_value]\n record.user_id = current_user.id\n record.save_tags = true\n record.valid?\n @errors = convert_media_element_error_messages record.errors\n @errors[:media] = t('forms.error_captions.media_file_too_large').downcase\n end",
"def test02_EmptyMPopGDPublish\n\t\t\tloginPost\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\tif $post_pick_group.exists?\n\t\t\t\tpostGroupPop\n\t\t\t\t$post_media_description.set(\"Media Description #{random}.\")\n\t\t\t\tpostPublishLater\n\t\t\t\t$post_now.fire_event(\"onclick\")\n\t\t\telse puts \"PPL04T02: FAILED! User unable to locate Post button.\"\n\t\t\tend \t\t\t\t\n\t\t\t\n\t\t\tbegin\n\t\t\tassert $post_now.exists?\n\t\t\t\trescue => e\n\t\t\t\tputs (\"PPL04T02: FAILED! User able to Post.\")\n\t\t\t\tputs e\n\t\t\tend\n\t\tend",
"def test_media_find_by_type\n assert_not_nil @rdigg.media.find_by_type(\"news\")\n end",
"def test02_MediaTwoComments\n\t\tcommentMediaPop\n\t\tcommentPopSubmit\n\tend",
"def test_10a\r\n db = build\r\n assert_equal [],db.groups\r\n end",
"def test04_MediaPhotoVideo\n\t\tlogin $editor_1_email, $master_password\n\t\t$browser.goto($patch_boards_pre_closed_article_new)\n\t\t\n#\t\t$post_activate_note.when_present.fire_event(\"onclick\")\n#\t\t$post_media_description.set(\"mt townsend is my favorite mountain #{random}.\")\n\t\tif $environment == 'nixon'\t\n\t\t\trepostGroupPop #category already selected in staging\n\t\tend\n\t\t$post_article_title.set(\"Mountain #{random}\")\n \t\t$browser.execute_script(\"jQuery('iframe.wysihtml5-sandbox').contents().find('body').prepend('mt townsend is my favorite mountain #{random}.')\")\n\t\tsleep 2\n\t\t$post_add_media_article.click\n\t\tfile_upload \"DungenessSpit102.26.2012.mov\"\n\t\tsleep 2\n\t\t$post_add_media_article.click\n\t\tfile_upload \"GlacierBasinTrailMtRainier.JPG\"\n if $environment == 'staging'\n\t\t\tsleep 10 #loads \n\t\tend\n\t\t$post_now_edit.fire_event(\"onclick\")\n\n\t\tsleep 2\n\t\tassert $post_new_post.exists?\n\tend",
"def test03_4GroupsRepostMedia\n\t\trepostMediaPop\n\t\tsleep 3\n\t\tfourGroupSelect\n\t\tsleep 3\n\t\t\n\t\tbegin \n\t\tassert $repost_confirmation.exists?\n\t\t\trescue => e\n\t\t\tputs \"RS06T03: FAILED! User unable to repost!\"\n\t\t\tputs e\n\t\tend\n\tend",
"def test_initialize_group\r\n \ttest_group = ProspectorGroup.new\r\n \ttest_group.intialize_group(33, 3)\r\n \tassert_equal 3, test_group.num_prospectors\r\n \tassert_equal 0 , test_group.iteration_count\r\n end",
"def test_attributes\n assert_equal \"Gallery 1\", @gallery.title\n assert @gallery.active?\n assert_equal \"f82dd0bd-4711-4578-ac47-4661257e69a6\", @gallery.guid\n end",
"def album\r\n #prepare_new_album extracted for reuse from spec\r\n prepare_new_album unless @content\r\n end",
"def test_data_extraction\n\t\tYAML.load_file('test/groups.yml')[\"groups\"].each do |g_data|\n\t\t\tstub_request(:get, g_data[\"url\"]).\n\t\t\tto_return(:status => 200, :body => File.read(\"test/yahoo_pages/#{g_data['id']}.html\"), :headers => {})\n\n\t\t\tgroup = YahooGroupData.new(g_data[\"url\"])\n\t\t\tassert_equal g_data[\"age_restricted\"], group.age_restricted?\n\t\t\tassert_equal g_data[\"private\"], group.private?\n\t\t\tassert_equal g_data[\"not_found\"], group.not_found?\n\t\t\tassert_equal g_data[\"name\"], group.name\n\t\t\tassert_equal g_data[\"description\"], group.description\n\t\t\tassert_equal g_data[\"post_email\"], group.post_email\n\t\t\tassert_equal g_data[\"subscribe_email\"], group.subscribe_email\n\t\t\tassert_equal g_data[\"owner_email\"], group.owner_email\n\t\t\tassert_equal g_data[\"unsubscribe_email\"], group.unsubscribe_email\n\t\t\tassert_equal g_data[\"founded\"], group.founded\n\t\t\tassert_equal g_data[\"language\"], group.language\n\t\t\tassert_equal g_data[\"num_members\"], group.num_members\n\t\t\tassert_equal g_data[\"category\"], group.category\n\t\tend\n\tend",
"def creating_experimental_media(media_hash)\n media_hash.each { |media, quant|\n log_info 'media', media\n if media != -1\n show {\n title \"Creating Experimental Induction Media\"\n separator\n if media.include? 'Kan'\n check \"In an appropriate container, aliquot <b>#{(quant * 3.3).round(2)}mL</b> of <b>M9 + Kan Media</b> and label: <b>#{MEDIA_LABEL_HASH[media]}</b>\"\n else\n check \"In an appropriate container, aliquot <b>#{(quant * 3.3).round(2)}mL</b> of <b>M9 Media</b> and label: <b>#{MEDIA_LABEL_HASH[media]}</b>\"\n end\n if media.include? 'IPTG'\n check \"To the tube labeled #{MEDIA_LABEL_HASH[media]}, add <b>#{(quant * 3.3 * 0.25).round(2)}µl</b> of <b>1M IPTG</b>\" # calculates inducer per 1mL of media\n end\n if media.include? 'arab'\n check \"To the tube labeled #{MEDIA_LABEL_HASH[media]}, add <b>#{(quant * 3.3 * 25).round(2)}µl</b> of <b>1M Arabinose</b>\" # calculates inducer per 1mL of media\n end\n }\n end\n }\n end",
"def test04_post_closed_board_GroupRepostMedia\n\t\trepostMediaPop\n\t\tsleep 3\n\t\tgroupAddRemoveAdd \"Repost text #{random}.\"\n \t\tsleep 3\n\t\t\n\t\tassert $repost_confirmation.exists?\n\tend",
"def create_new_media(data_set)\n enter_media_info_data data_set\n click_save_button\n when_exists(delete_button, Config.short_wait)\nend",
"def test04_post_closed_news_TwoGroupsRepostMedia\n\t\trepostMediaPop\n\t\tsleep 3\n\t\ttwoGroupSelect\n\t\tsleep 3\n\t\t\n\t\tassert $repost_confirmation.exists?\n\tend",
"def test04_DraftEmptyGPopDM\n\t\t\tloginPost\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\tif $post_media_description.exists?\n\t\t\t\t$post_media_description.set(\"Media Description #{random}.\")\n\t\t\t\t$post_media_button.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t\tsleep 2\n\t\t\t\tsleep 4\n\t\t\t\t$post_save_draft.fire_event(\"onclick\")\n\t\t\telse puts \"PDEV04T04: FAILED! UUser unable to locate Post button.\"\n\t\t\tend\n\t\t\t\n\t\t\tbegin\n\t\t\tassert $post_draft_error.exists?\n\t\t\t\trescue => e\n\t\t\t\tputs (\"PDEV04T04: FAILED! User able to save incomplete draft.\")\n\t\t\t\tputs e\n\t\t\tend\t\n\t\tend",
"def groups; end",
"def groups; end",
"def groups; end",
"def test_groupdetail_constructor_and_accessors\n\n obj = SmsCountryApi::Group::GroupDetail.new\n refute_nil obj, \"Object wasn't created successfully.\"\n assert_kind_of SmsCountryApi::Group::GroupDetail, obj, \"Object isn't the correct type.\"\n assert_nil obj.id, \"ID isn't nil.\"\n assert_nil obj.name, \"Name isn't nil.\"\n assert_nil obj.tiny_name, \"Tiny name isn't nil.\"\n assert_nil obj.start_call_on_enter, \"Start call on enter isn't nil.\"\n assert_nil obj.end_call_on_exit, \"End call on exit isn't nil.\"\n assert_nil obj.members, \"Members isn't nil.\"\n\n end",
"def test04_group_photo_all\n\t\n\t\tloginGroup\n\t\t$browser.goto($patch_mongooses_settings)\n\t\t$group_image_1.fire_event(\"onclick\")\n\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t$span_3_frames.click\n\t\t$upload_frames_save.click\t\n\tend",
"def setupGroupsOfThumbnails(items, header)\n \n lastItem = items.size - 1\n currItem = 0\n\n retval = \"\"\n items.each do |item|\n #if a new row should be made\n if (currItem%3 == 0)\n retval << InitializeRow\n\n #if this is the first item, add the section heading\n if (currItem == 0)\n retval << createHeader(header)\n end\n\n retval << BeginThumbnailSet\n end\n\n \n retval << startIndivThumbnail(item.picture) \n case header\n when \"Organizations\"\n retval << createOrganizationCaption(item)\n when \"People to Know\"\n retval << createLeaderCaption(item) \n end\n\n retval << CreateEndThumbnailItem\n\n\n if (currItem == lastItem || currItem%3 == 2)\n retval << FinishThumbnailList\n end\n\n currItem += 1\nend \n\nreturn retval.html_safe \n end",
"def medium_names\n primary_media | secondary_media | component_media\n end",
"def create_samples data\n data.each do |line|\n if !line.empty?\n if line[0].include? \"sample\"\n # check and see if this sample exists in inventory\n sample_array = line[0].partition(\":\")\n sample_name = sample_array[2].strip #removes leading and trailing whitespace.\n sample_check = Sample.find_by_name(sample_name)\n if sample_check.nil?\n # create the media\n sample = createMedia(sample_name, \"new sample\", \"media\")\n show do\n title \"Sample Created\"\n \n note \"The sample #{sample_name} has been sucessfully created in Aquarium\"\n end\n end\n end\n end\n end \n \n show do\n title \"Samples Created\"\n \n note \"The samples in #{FILENAME} have been sucessfully created in Aquarium.\"\n note \"Please double check and see if you include the word \\\"sample:\\\" before your sample name.\"\n end\n end",
"def createMedia(nameStr, descriptionStr, projectStr)\n s = Sample.creator(\n {\n sample_type_id: SampleType.find_by_name(\"Media\").id,\n description: descriptionStr,\n name: nameStr, \n project: projectStr\n }, User.find(1) )\n end",
"def ensure_correct_media_id\n # only fandoms tags must have medias\n return unless self[:type] == 'Fandom'\n\n uncategorized = Media.uncategorized\n\n # get the first media of the current tag which is not \"Uncategorized Fandoms\"\n current_media = ([self.media] + self.medias).compact\n media = (current_media - [uncategorized]).first\n\n # if we have a media, we don't need \"Uncategorized Fandoms\" as a media\n if media \n self.remove_media(uncategorized) if self.medias.include?(uncategorized)\n self.update_attribute(:media_id, media.id) if self.media == uncategorized\n end\n\n # make sure the tag has a media id\n if !self.media_id # we don't have a media id\n if !media # and we don't have a media\n # we don't have anything, but we're being wrangled, so add \"Uncategorized Fandoms\"\n self.update_attribute(:media_id, uncategorized.id)\n self.parents << uncategorized unless self.parents.include?(uncategorized)\n else # we do have a media\n # use the one for our first media\n self.update_attribute(:media_id, media.id)\n end\n end\n\n # if the media id isn't for our first media or \"Uncategorized Fandoms\", verify that it's a real media\n if !(self.media_id == uncategorized.id || (media && self.media_id == media.id))\n listed_media = Media.find(self.media_id)\n # it's not a real media or it's been removed\n if !listed_media.is_a?(Media) || !self.medias.include?(listed_media)\n if media\n self.update_attribute(:media_id, media.id)\n else\n self.update_attribute(:media_id, uncategorized.id)\n end\n end\n end\n\n end",
"def test_creating_public_description\n # We want to create an empty, default public description for a name that\n # doesn't have any descriptions yet -- simplest possible case.\n @name = Name.find_by(text_name: \"Strobilurus diminutivus\")\n assert_equal([], @name.descriptions)\n @description_data = {\n source_type: \"public\",\n source_name: nil,\n readable: true,\n writable: true,\n notes: \"I like this mushroom.\"\n }\n @group_expectations = {\n admins: [UserGroup.reviewers],\n writers: [UserGroup.all_users],\n readers: [UserGroup.all_users],\n authors: [],\n editors: [mary]\n }\n\n admin = open_admin_session(dick)\n reviewer = open_normal_session(rolf)\n owner = open_normal_session(mary)\n random_user = open_normal_session(katrina)\n lurker = open_lurker_session\n\n reviewer.should_be_reviewer\n owner.should_not_be_reviewer\n random_user.should_not_be_reviewer\n\n # sets (not checks) the abilities\n admin.should_be_able_to_do_anything\n reviewer.should_be_able_to_do_anything_but_change_permissions\n owner.should_be_able_to_edit_and_change_name\n random_user.should_be_able_to_edit_text_only\n lurker.should_be_able_to_see_but_needs_to_login\n\n owner.create_name_description\n owner.check_name_description\n\n admin.check_abilities\n reviewer.check_abilities\n owner.check_abilities\n random_user.check_abilities\n lurker.shouldnt_be_able_to_do_anything\n end",
"def test03_GroupRepostMedia\n\t\trepostMediaPop\n\t\tsleep 3\n\t\tgroupAddRemoveAdd\n \t\tsleep 3\n\t\t\n\t\tbegin \n\t\tassert $repost_confirmation.exists?\n\t\t\trescue => e\n\t\t\tputs \"RS2T03: FAILED! User unable to repost!\"\n\t\t\tputs e\n\t\tend\n\tend",
"def test05_post_open_news_EmptyDMPopG\n\t\t\tlogin $user_1_email, $master_password\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\t\n\t\t\tassert $post_pick_group.exists?\n \t\t\trepostGroupPop\n\t\t\t$post_now.fire_event(\"onclick\")\n\n\t\t\tassert $post_now.exists?\n\t\tend",
"def load_media(outputPlate)\r\n show do \r\n title \"Filling new 96-deep well Item ##{outputPlate.id}\" \r\n \r\n note \"In a clean & sterile multichannel reservoir, pour aliquoted media.\" \r\n check \"Grab a new 96-deep well plate and label with the Item ID ##{outputPlate.id}.\" \r\n note \"Using a multichannel P1000 transfer 999uL of media to the following wells.\" \r\n # CollectionDisplay library\r\n table highlight_non_empty(outputPlate) { |r,c| \"999uL\" } \r\n end \r\n end",
"def test03_EmptyGDM\n\t\t\tloginPost\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\tif $post_media_button.exists?\n\t\t\t\t$post_media_button.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t\t$post_now.fire_event(\"onclick\")\n\t\t\telse puts \"PEV03T03: FAILED! User unable to locate Post button.\"\n\t\t\tend\n\t\t\t\n\t\t\tbegin\n\t\t\tassert $post_now.exists?\n\t\t\t\trescue => e\n\t\t\t\tputs (\"PEV03T03: FAILED! User able to Post.\")\n\t\t\t\tputs e\n\t\t\tend\n\t\tend",
"def tags\n if properties.key?(:media_content) and\n properties[:media_content][:url].present? and\n properties.key?(:media_thumbnail) and\n properties[:media_thumbnail][:url].present?\n %w[image]\n else\n []\n end\n end",
"def test_default_group_pages\n m = Time.now.to_f.to_s.gsub('.', '')\n @s.switch_user(User.admin_user())\n group = create_group(\"g-testgroup-#{m}\")\n path = \"#{group.home_path_for(@s)}/pages\"\n res = @s.execute_get(@s.url_for(\"#{path}.2.json\"))\n assert_equal(\"200\", res.code, \"Should have created pages in postprocessing\")\n json = JSON.parse(res.body)\n assert_not_nil(json[\"index.html\"], \"Expected default page not found\")\n assert_equal(json[\"index.html\"][\"jcr:primaryType\"], \"nt:file\", \"Default home page is not a file\")\n end",
"def test_room_starts_with_empty_playlist\n assert_equal([], @room1.show_playlist()) #OR DO WE COUNT THIS?\n end",
"def set_content_defaults\r\n @content.user_id = @user.id\r\n @content.user = @user\r\n @content.is_in_startpage = [email protected]{|a| !a.featured_album?}\r\n @content.is_in_gallery = true\r\n @content_kind_displayname = \"New #{@content.entity_name_for_human.titleize}\".t\r\n @title = @user.login + ' :: ' + @content_kind_displayname\r\n #'New Music Album'.t\r\n #'New Music Contest'.t\r\n end",
"def videos_test\n end",
"def description\n [@group.description,@description].join(' ')\n end",
"def initialize(media_options={})\n @id = media_options[\"id\"]\n @format_type_id= media_options[\"format_type_id\"]\n @anime_series_id= media_options[\"anime_series_id\"]\n @cover_name= media_options[\"cover_name\"]\n end",
"def test02_ArticleAllFields\n\t\tloginPost\n\t\t$browser.goto($patch_article)\n\t\t\t\n\t\t\tsleep 2\n\t\t\tif $post_pick_group.exists?\n \t\t\t\tpostGroupPop\n \t\t\t\tpostGroupPop2\n \t\t\t\t$post_article_title.set(\"Article #{random}\")\n \t\t\t\t$browser.execute_script(\"jQuery('iframe.wysihtml5-sandbox').contents().find('body').prepend('lava is hot.')\")\n \t\t\t\t$post_add_media.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t\t$post_add_media.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t\t$post_now.fire_event(\"onclick\")\n\t\t\telse puts \"PS01T02: FAILED! User unable to locate Post button.\"\n\t\t\tend\n\t\t\t\n\t\tbegin\n\t\tsleep 2\n\t\tassert $post_new_post.exists?\n\t\t\trescue => e\n\t\t\tputs (\"P01T02: FAILED! User unable to Post.\")\n\t\t\tputs e\n\t\tend\n\tend",
"def list_media_details(gallery_name = \"test\", _browser = @browser)\n wait = Selenium::WebDriver::Wait.new(:timeout => 15)\n Log.logger.info(\"Listing Media properties and ids to edit it (for Gallery: #{gallery_name.inspect})\")\n self.open_gallery(gallery_name)\n wait.until { _browser.find_element(:xpath => @galmgr.edit_media) }.click\n frame = wait.until { _browser.find_element(:xpath => @galmgr.edit_overlay_frame) }\n _browser.switch_to.frame(frame)\n edit_media_ids = Hash.new\n i = 1\n wait.until { _browser.find_element(:xpath => \"//div[contains(@id, 'media-edit-')]\") }\n med_ct = Integer(_browser.find_elements(:xpath => \"//div[contains(@id, 'media-edit-')]\").size)\n Log.logger.info(\"Found editable images: #{med_ct}\")\n while i < med_ct+1\n media_url = _browser.find_element(:xpath => \"//div[contains(@id, 'media-edit-#{i}')]//img[contains(@class, '')]\").attribute(\"src\")\n Log.logger.info(\"Working on image number #{i}: #{media_url.inspect}\")\n if (i == 1)\n if(_browser.find_elements(:xpath => \"//select[@id = 'edit-field-license-und']\").size < 1)\n media_license_setting = \"\"\n media_type = \"video\"\n else\n media_license_setting = \"//select[@id = 'edit-field-license-und']\"\n media_type = \"image\"\n end\n media_title = \"//input[@id = 'edit-media-title-und-0-value']\"\n media_description = \"//textarea[@id = 'edit-media-description-und-0-value']\"\n media_tag = \"//input[@id = 'edit-field-tags-und']\"\n else\n if(_browser.find_elements(:xpath => \"//select[@id = 'edit-field-license-und--#{i}']\").size < 1)\n media_license_setting = \"\"\n media_type = \"video\"\n else\n media_license_setting = \"//select[@id = 'edit-field-license-und--#{i}']\"\n media_type = \"image\"\n end\n media_title = \"//input[@id = 'edit-media-title-und-0-value--#{i}']\"\n media_description = \"//textarea[@id = 'edit-media-description-und-0-value--#{i}']\"\n media_tag = \"//input[@id = 'edit-field-tags-und--#{i}']\"\n end\n\n Log.logger.info(\"image number #{i} media-type: #{media_type.inspect}\")\n Log.logger.info(\"image number #{i} media-title: #{media_title.inspect}\")\n edit_media_ids[media_url] = Hash.new() unless (edit_media_ids[media_url])\n edit_media_ids[media_url][:license] = media_license_setting\n edit_media_ids[media_url][:tag] = media_tag\n edit_media_ids[media_url][:desc] = media_description\n edit_media_ids[media_url][:title] = media_title\n edit_media_ids[media_url][:type] = media_type\n i += 1\n end\n return edit_media_ids\n end",
"def prepare_attributes\n if media.present? && will_save_change_to_media?\n self.media_content_type = media.file.content_type\n self.media_file_size = media.file.size\n end\n\n if new_record?\n self.folder = folder.sanitize_filename\n tag_list.add(folder)\n tag_list.add(media.file.extension)\n end\n end",
"def test_all\n query = \"iphone5s\"\n\n products = ProductHelper.crawl(query)\n products.each do |product|\n #STDERR.puts product\n end\n pgroups = ProductHelper.clustering(products)\n pgroups.each do |pgroup|\n info = \"\"\n unless pgroup.spu.nil?\n info = pgroup.spu['Title']\n end\n STDERR.puts \"#{pgroup.size},#{info}\"\n end\n end",
"def show\n @contentBlock = ContentBlock.find(@group.chunk_id)\n @characterTags = CharacterTag.all\n @characters = GroupHasCharacter.where(:group_id => @group.id)\n @storylineTags = StorylineTag.all\n @storylines = GroupHasStoryline.where(:group_id => @group.id)\n\n end",
"def test_basedata\n assert_not_nil(Cardiotype.find(:first, :conditions => [\"description = ?\", \"Run\"]))\n assert_not_nil(Cardiotype.find(:first, :conditions => [\"description = ?\", \"Swim\"]))\n assert_not_nil(Cardiotype.find(:first, :conditions => [\"description = ?\", \"Cycle\"]))\n end",
"def test05_EmptyDMPopG\n\t\t\tloginPost\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\tif $post_pick_group.exists?\n \t\t\t\tpostGroupPop\n\t\t\t\t$post_now.fire_event(\"onclick\")\n\t\t\telse puts \"PEV03T05: FAILED! User unable to locate Post button.\"\n\t\t\tend \t\t\t\t\n\t\t\t\n\t\t\tbegin\n\t\t\tassert $post_now.exists?\n\t\t\t\trescue => e\n\t\t\t\tputs (\"PEV03T05: FAILED! User able to Post.\")\n\t\t\t\tputs e\n\t\t\tend\n\t\tend",
"def load_mediaset\n nil\n end",
"def test_require_group\n render text: 'OK'\n end",
"def full_description(example_group)\n example_group.metadata.fetch(:full_description)\n end",
"def media() @media = Media.new end",
"def test04_flag_repost_media_TC_24323\n\t\trepostMediaPop\n\t\tsleep 2\n\t\trepost\n\t\tcommentFlag\n\t\tsleep 2\n\t\t\n\t\tbegin\n\t\tassert $browser.text.include?(\"Comment\")\n\t\trescue => e\n\t\t\tputs e\n\t\tputs \"R8_T4: FAILED! User unable to flag post.\"\n\t\tend\n\tend",
"def test_ownprovidergroups\n groupnames.each { |group|\n gobj = nil\n comp = nil\n fakeresource = fakeresource(:group, group)\n assert_nothing_raised {\n gobj = @provider.new(fakeresource)\n }\n\n assert(gobj.gid, \"Failed to retrieve gid\")\n }\n end",
"def create\n media = params[:media]\n record = MediaElement.new :media => media\n record.title = params[:title_placeholder] != '0' ? '' : params[:title]\n record.description = params[:description_placeholder] != '0' ? '' : params[:description]\n record.tags = params[:tags_value]\n record.user_id = current_user.id\n record.save_tags = true\n if record.save\n if !record.image?\n Notification.send_to(\n current_user.id,\n I18n.t(\"notifications.#{record.class.to_s.downcase}.upload.started.title\"),\n I18n.t(\"notifications.#{record.class.to_s.downcase}.upload.started.message\", :item => record.title),\n ''\n )\n end\n else\n if record.errors.added? :media, :too_large\n return render :file => Rails.root.join('public/413.html'), :layout => false, :status => 413\n end\n @errors = convert_media_element_error_messages record.errors\n end\n render :layout => false\n end",
"def test03_DraftEmptyGDM\n\t\t\tloginPost\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\tif $post_media_button.exists?\n\t\t\t\t$post_media_button.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t\tsleep 2\n\t\t\t\tsleep 4\n\t\t\t\t$post_save_draft.fire_event(\"onclick\")\n\t\t\telse puts \"PDEV04T03: FAILED! User unable to locate Post button.\"\n\t\t\tend\n\t\t\t\n\t\t\tbegin\n\t\t\tassert $post_draft_error.exists?\n\t\t\t\trescue => e\n\t\t\t\tputs (\"PDEV04T03: FAILED! User able to save incomplete draft.\")\n\t\t\t\tputs e\n\t\t\tend\n\t\tend",
"def load_group group_id, info_level = \"Full\", include_children = \"true\"\n\t\t\t@response = api_request 'LoadGroup', [group_id, info_level, include_children]\n\t\t\traise ZenfolioAPI::ZenfolioAPISessionError, @response['error']['message'] if @response['result'].nil? && @response['error'].length > 0\n\n\t\t\telements = []\n\t\t\t@response['result']['Elements'].each do |element|\n\t\t\t\tif element['$type'] == \"PhotoSet\"\n\t\t\t\t\telements << ZenfolioAPI::Model::Gallery.new(:id => element['Id'], :type => element['$type'], :caption => element['Caption'], \n\t\t\t\t\t\t:created_on => element['CreatedOn']['Value'], :modified_on => element['ModifiedOn']['Value'], :photo_count => element['PhotoCount'],\n\t\t\t\t\t\t:image_count => element['ImageCount'], :video_count => element['VideoCount'], :photo_bytes => element['PhotoBytes'], :views => element['Views'],\n\t\t\t\t\t\t:featured_index => element['FeaturedIndex'], :is_random_title_photo => element['IsRandomTitlePhoto'], :upload_url => element['UploadUrl'],\n\t\t\t\t\t\t:video_upload_url => element['VideoUploadUrl'], :page_url => element['PageUrl'], :mailbox_id => element['MailboxId'], :text_cn => element['TextCn'], \n\t\t\t\t\t\t:photo_list_cn => element['PhotoListCn'], :group_index => element['GroupIndex'], :title => element['Title'], :owner => element['Owner'])\n\t\t\t\telse\n\t\t\t\t\t#group_elements = load_group element['Id']\n\t\t\t\t\telements << ZenfolioAPI::Model::Group.new(:id => element['Id'], :created_on => element['CreatedOn']['Value'], :modified_on => element['ModifiedOn']['Value'], \n\t\t\t\t\t\t:page_url => element['PageUrl'], :mailbox_id => element['MailboxId'], :immediate_children_count => element['ImmediateChildrenCount'], :text_cn => element['TextCn'], \n\t\t\t\t\t\t:caption => element['Caption'], :collection_count => element['CollectionCount'], :sub_group_count => element['SubGroupCount'], :gallery_count => element['GalleryCount'],\n\t\t\t\t\t\t:featured_index => element['FeaturedIndex'], :is_random_title_photo => element['IsRandomTitlePhoto'], :upload_url => element['UploadUrl'],\n\t\t\t\t\t\t:photo_count => element['PhotoCount'], :parent_groups => element['ParentGroups'], :title => element['Title'])\n\t\t\t\tend\n\t\t\tend\n\n\t\t\t@group = ZenfolioAPI::Model::Group.new(:id => @response['result']['Id'], :created_on => @response['result']['CreatedOn']['Value'], :modified_on => @response['result']['ModifiedOn']['Value'], \n\t\t\t\t:page_url => @response['result']['PageUrl'], :mailbox_id => @response['result']['MailboxId'], :immediate_children_count => @response['result']['ImmediateChildrenCount'], \n\t\t\t\t:text_cn => @response['result']['TextCn'], :caption => @response['result']['Caption'], :collection_count => @response['result']['CollectionCount'], \n\t\t\t\t:sub_group_count => @response['result']['SubGroupCount'], :gallery_count => @response['result']['GalleryCount'], :featured_index => @response['result']['FeaturedIndex'], \n\t\t\t\t:is_random_title_photo => @response['result']['IsRandomTitlePhoto'], :upload_url => @response['result']['UploadUrl'], :photo_count => @response['result']['PhotoCount'], \n\t\t\t\t:parent_groups => @response['result']['ParentGroups'], :title => @response['result']['Title'], :elements => elements)\n\n\t\t\t@group\n\t\tend",
"def test05_post_open_news_250RepostMedia\n\t\trepostMediaPop\n\t\tsleep 3\n\t\trepostPopulate250\n\t\tsleep 3\n\n\t\tassert $repost_confirmation.exists?\n\tend",
"def test03_post_open_news_251RepostMedia\n\t\trepostMediaPop\n\t\tsleep 3\n\t\trepostPopulate251\n\t\tsleep 3\n\n\t\tassert $repost_confirmation.exists?\n\tend",
"def test04_MediaPDF\n\t\tlogin $editor_1_email, $master_password\n\t\t$browser.goto($patch_boards_pre_closed_article_new)\n\t\t\n#\t\t$post_activate_note.when_present.fire_event(\"onclick\")\n#\t\t$post_media_description.set(\"mt townsend is my favorite mountain #{random}.\")\n\t\tif $environment == 'nixon'\t\n\t\t\trepostGroupPop #category already selected in staging\n\t\tend\n\t\t$post_article_title.set(\"Mountain #{random}\")\n \t\t$browser.execute_script(\"jQuery('iframe.wysihtml5-sandbox').contents().find('body').prepend('mt townsend is my favorite mountain #{random}.')\")\n\t\tsleep 2\n\t\t$post_add_media_article.click\n\t\tfile_upload \"PDFDocument.pdf\"\n\t\t$post_now_edit.fire_event(\"onclick\")\n\t\tif $environment == 'staging'\n\t\t\tsleep 10 #loads \n\t\tend\n\t\tsleep 2\n\t\tassert $post_new_post.exists?\n\tend",
"def test_show_single_photo\n photo_set = photo_sets('lonely_photo_set')\n photo = photos('lonely_photo')\n get :set, { :photo_set => photo_set, :photo => photo }\n assert_response :success\n \n assert long_title = \"#{photo_set.title} - #{photo.title}\"\n assert_select 'h1', long_title\n\n assert_select \"li.thumbs\", false\n assert_select \"#thumbnav\", false\n end",
"def test01()\n sourceMovie = File.join($directory, \"images/418_clip5_sd.m4v\")\n begin\n # 1. Get the possible track media types.\n getMediaTypes = CommandModule.make_get_nonobjectproperty(property: :mediatypes,\n type: :movieimporter)\n theResult = Smig.perform_command(getMediaTypes)\n mt = \"soun clcp meta muxx sbtl text tmcd vide\"\n raise 'Different list of media types: ' + theResult unless theResult.eql? mt\n \n # Create the list of commands object, ready to have commands added to it.\n theCommands = CommandModule::SmigCommands.new\n theCommands.saveresultstype = :lastcommandresult\n\n # 2.1. Create a movie importer, get the movie importers base object reference.\n movieImporterName = SecureRandom.uuid\n\n movieObject = theCommands.make_createmovieimporter(sourceMovie,\n name: movieImporterName,\n addtocleanup: false)\n\n # 2.2. Create the get_objectproperty command.\n getReferenceCommand = CommandModule.make_get_objectproperty(movieObject,\n property: :objectreference)\n theCommands.add_command(getReferenceCommand)\n theResult = Smig.perform_commands(theCommands)\n \n # We now use that reference for getting other properties of the movie.\n # 3. So we got the result without an exception being thrown. We have the ref.\n movieObject = SmigIDHash.make_objectid(objectreference: theResult.to_i)\n\n # 4. Get the movie importer object name.\n getObjectTypeCommand = CommandModule.make_get_objectproperty(movieObject,\n property: :objectname)\n res = Smig.perform_command(getObjectTypeCommand)\n raise 'Movie importer name is wrong' unless res.eql? movieImporterName\n\n # 5. Get the movie importer object type.\n getObjectTypeCommand = CommandModule.make_get_objectproperty(movieObject,\n property: :objecttype)\n res = Smig.perform_command(getObjectTypeCommand)\n raise 'Movie importer type not :movieimporter' unless res.eql? 'movieimporter'\n\n # 6. Get the movie importer metadata.\n getObjectTypeCommand = CommandModule.make_get_objectproperty(movieObject,\n property: :metadata)\n res = Smig.perform_command(getObjectTypeCommand)\n meta = '[{\"key\":\"@cmt\",\"keyspace\":\"itsk\",\"stringValue\":\"iTunes metadata: Exported to preset AVAssetExportPresetAppleM4VCellular using avexporter at: 20 Nov 2014 13:25\"}]'\n raise 'Movie metadata has changed' unless res.eql? meta\n \n # 7. Get the number of tracks in the movie\n getObjectTypeCommand = CommandModule.make_get_objectproperty(movieObject,\n property: :numberoftracks)\n res = Smig.perform_command(getObjectTypeCommand).to_i\n raise 'Movie should have 2 tracks: ' unless res.eql? 2\n\n # 8. Get the number of video tracks in the movie\n getObjectTypeCommand = CommandModule.make_get_objectproperty(movieObject,\n property: :numberoftracks)\n getObjectTypeCommand.add_option(key: :mediatype, value: :vide)\n res = Smig.perform_command(getObjectTypeCommand).to_i\n raise 'Movie should have 1 video tracks: ' unless res.eql? 1\n\n # 9. Get the number of audio tracks in the movie\n getObjectTypeCommand = CommandModule.make_get_objectproperty(movieObject,\n property: :numberoftracks)\n getObjectTypeCommand.add_option(key: :mediatype, value: :soun)\n res = Smig.perform_command(getObjectTypeCommand).to_i\n raise 'Movie should have 1 audio track: ' unless res.eql? 1\n\n getPropertiesCommand = CommandModule.make_get_objectproperties(movieObject,\n saveresultstype: :jsonstring)\n res = Smig.perform_command(getPropertiesCommand)\n props = '{\"objectname\":\"67ea7e99-b0c8-413a-9688-9020b4ddf53d\",' +\n '\"objecttype\":\"movieimporter\",\"metadataformats\":\"com.apple.itunes org.mp4ra\",\"file\":' +\n '\"/Volumes/MacintoshHD/Users/ktam/gitlab/movingimages/testing/images/418_clip5_sd.m4v\",' +\n '\"duration\":{\"flags\":1,\"value\":9000,\"timescale\":600,\"epoch\":0},\"objectreference\":1,' +\n '\"numberoftracks\":2}'\n propsH = JSON.parse(props)\n resH = JSON.parse(res)\n unless propsH[:objecttype].eql? propsH[:objecttype]\n raise \"Movie importer object type is wrong: #{res}\"\n end\n\n unless propsH[:file].eql? propsH[:file]\n raise \"file is different: #{res}\"\n end\n\n unless propsH[:duration].eql? propsH[:duration]\n raise \"duration is different: #{res}\"\n end\n\n unless propsH[:numberoftracks].eql? propsH[:numberoftracks]\n raise \"number of tracks is different: #{res}\"\n end\n\n rescue RuntimeError => e\n $errorcode = Smig.exitvalue\n unless $errorcode.zero?\n puts \"Exit string: \" + Smig.exitstring\n puts \" Exit status: \" + $errorcode.to_s\n end\n puts e.message\n puts e.backtrace.to_s\n ensure\n # 11. Close the movie object\n Smig.close_object_nothrow(movieObject)\n end\nend",
"def build_content_metadata record, tags\n # TODO: Further enrich the structured data by marking up FAQ accordions, Video Carousels, Image Galleries, etc.\n # Also ItemList metadata for the meditations archive\n # See here: https://developers.google.com/search/docs/data-types/article\n []\n end",
"def create\n songs = get_kexp_songs()\n idx = 0\n\n while idx < songs['results'].length\n if songs['results'][idx]['playtype']['name'] != \"Media play\"\n idx += 1\n next\n end\n song_title = songs['results'][idx]['track']['name']\n song_artist = songs['results'][idx]['artist']['name']\n \n if !songs['results'][idx]['release']\n song_album = \"\"\n song_release_year = 0\n song_album_img = \"https://cdn.pixabay.com/photo/2019/04/04/18/50/cassette-4103530_1280.jpg\"\n else\n if song_album_img = songs['results'][idx]['release']['largeimageuri'] == nil\n song_album_img = \"https://cdn.pixabay.com/photo/2019/04/04/18/50/cassette-4103530_1280.jpg\"\n else\n song_album_img = songs['results'][idx]['release']['largeimageuri']\n end\n song_album = songs['results'][idx]['release']['name']\n song_release_year = songs['results'][idx]['releaseevent']['year'].to_i\n end\n \n song_is_local = songs['results'][idx]['artist']['islocal']\n #if song|artist|album don't exist -> create \n if Album.find_by(title: song_album) == nil\n song_artist = song_artist.split('feat.')[0]\n mod_artist = song_artist.strip().gsub(/[^0-9a-z ]/i, '').split(' ').join('+')\n parsed_response = get_song_genre(mod_artist)\n \n #if bad status code -> query by song instead\n if parsed_response[\"status_code\"] > 299 || parsed_response[\"status_code\"] < 200 || parsed_response[\"genre\"] == \"\"\n mod_song = song_title.strip().gsub(/[^0-9a-z ]/i, '').split(' ').join('+')\n parsed_response = get_song_genre(mod_song)\n end\n @album = Album.new(title: song_album, album_img: song_album_img, year: song_release_year, genre: parsed_response[\"genre\"])\n @album.save()\n else \n @album = Album.find_by(title: song_album)\n end\n\n if Artist.find_by(name: song_artist) == nil\n @artist = Artist.new(name: song_artist, is_local?: song_is_local, album: @album)\n @artist.save()\n else \n @artist = Artist.find_by(name: song_artist)\n @artist.update(album: @album)\n end\n if Song.find_by(title: song_title) == nil\n @song = Song.new(title: song_title, artist: @artist)\n @song.save()\n else \n @song = Song.find_by(title: song_title)\n @song.update(artist: @artist)\n end\n idx += 1\n end\n redirect_to songs_path\n end",
"def description\n start = Time.now\n debug \"Checking description for device group: \\\"#{resource[:full_path]}\\\"\"\n connection = self.class.get_connection(resource[:account])\n device_group = get_device_group(connection, resource[:full_path],'description')\n debug \"Finished in #{(Time.now-start)*1000.0} ms\"\n device_group['description']\n end",
"def group_items\n @group_items ||= Product.includes(:pictures)\n .where(group: group.presence || '_ZZZZ_', active: true, hidden: false)\n .order(:option_sort, :option_title)\n end",
"def prepare\n super\n\n @test_list = @builder.tests\n\n @test_list.each do |item|\n if @options[\"#{item}_RATIO\"].to_i >= 1\n 1.upto(@options[\"#{item}_RATIO\"].to_i) do\n @tests.push item\n end\n end\n end\n end",
"def index\n # find the galleries in batches so we can render in groups\n @title = @title + \" : Galleries\"\n @meta_description = @meta_description +\" : Galleries\"\n @galleries = @galleries.collect {|x| x}\n if can? :create, Roxiware::Gallery\n @galleries << Roxiware::Gallery.new({:name=>\"Create New Gallery\"}, :as=>@role) \n end \n end",
"def ensure_magic_descriptor_presence(ad_group)\n # Use exceptions as activedirectory gem will throw an ArgumentError if no description exists.\n # AD groups don't have to have description fields but we will add one if needed.\n begin\n g_desc = ad_group.description\n rescue ArgumentError\n # description not set\n g_desc = \"\"\n end\n\n unless g_desc and g_desc.index MAGIC_DESCRIPTOR\n ad_group.description = \"#{MAGIC_DESCRIPTOR} #{g_desc}\"\n ad_group.save\n end\nend",
"def test05_DraftEmptyDMPopG\n\t\t\tloginPost\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\tif $post_pick_group.exists?\n \t\t\t\tpostGroupPop\n\t\t\t\tsleep 4\n\t\t\t\t$post_save_draft.fire_event(\"onclick\")\n\t\t\telse puts \"PDEV04T05: FAILED! User unable to locate Post button.\"\n\t\t\tend \t\t\t\t\n\t\t\t\n\t\t\tbegin\n\t\t\tassert $post_draft_error.exists?\n\t\t\t\trescue => e\n\t\t\t\tputs (\"PDEV04T05: FAILED! User able to save incomplete draft.\")\n\t\t\t\tputs e\n\t\t\tend\n\t\tend",
"def test_playlist\n end",
"def test03_post_open_blog_MediaVideo\n\t\tlogin $user_1_email, $master_password\n\t\t$browser.goto($patch_blogs_post_open)\n\t\t\t\n\t\tsleep 2\n\t\tassert $post_media_description.exists?\n\t\t$post_media_description.set(\"the elwah river original flow was recently restored #{random}.\")\n \t\trepostGroupPop\n\t\t$post_media_button.click\n\t\tfile_upload \"DungenessSpit102.26.2012.mov\"\n\t\t$post_now.fire_event(\"onclick\")\n\t\t\t\n\t\tsleep 2\n\t\tassert $post_new_post.exists?\n\tend",
"def group; end",
"def get_tests(children)\n children.each_with_object({}) do |c, memo|\n memo[c.description] = {}\n memo[c.description]['groups'] = get_tests(c.children) unless c.children.empty?\n unless c.examples.empty?\n memo[c.description]['tests'] = c.examples.map { |e|\n e.description unless e.pending?\n }.compact\n end\n next if c.examples.empty?\n memo[c.description]['pending_tests'] = c.examples.map { |e|\n e.description if e.pending?\n }.compact\n end\nend",
"def test_parser_handles_empty_simple_content\n simple_content_assert nil, nil\n simple_content_assert nil, ''\n end",
"def prefill_media_cuvettes op, media_vol, op_collection\n op_collection_item = Item.find(op_collection.id)\n output_obj_type = op_collection_item.object_type.name\n type_of_media = op.input(MEDIA_TYPE).val\n display_matrix = []\n matrix = op_collection.matrix\n show do\n note \"matrix: #{matrix}\"\n end\n \n flattened_matrix = matrix.flatten\n flattened_matrix.each_slice(op_collection.dimensions[1]) do |slice|#matrix.each_slice(collection.dimensions[1]).map{|slice| Array.new(op_collection.dimensions[1]) { |i| media_vol}}.each do |slice| \n display_matrix.push(slice)\n end\n \n op_collection.get_non_empty.each do |tuple|\n display_matrix[tuple[0]][tuple[1]] = media_vol\n end\n \n display_matrix.each do |row|\n row.reject! do |cell|\n cell == -1\n end\n end\n \n # Tells the technician to fill with media.\n show do\n title \"Fill #{output_obj_type} with #{type_of_media} Media\"\n \n check \"Grab a clean <b>#{output_obj_type}</b>.\"\n check \"Label the #{output_obj_type} => <b>#{op_collection_item.id}</b>.\"\n if media_vol != 0\n # note \"Follow the table to transfer the samples from the input collection to the output collection.\"\n note \"The coordinates in the following table are coordinates from the input collection\"\n note \"Fill each well with #{media_vol} uL of #{type_of_media}\"\n table highlight_matrix display_matrix\n end\n end\n\n end",
"def test04_news_OpenPolitics\n\t\tlogin $editor_1_email, $master_password\n\t\t$browser.goto($patch_new_news_group)\n\t\tsleep 5\n\n\t\t$group_name.set(\"Politics Group #{random}\")\n\t\t$group_nickname.set(\"Nickname #{random}\")\n\t\t$group_description.set(\"Description #{random}\")\n\t\t$category_politics.click\n\t\tsleep 2\n\t\t$boards_arts_ent_image.when_present.fire_event(\"onclick\")\n\t\t$create_group.click\n\t\t\n\t\tcheckIfIncorrectErrorDisplays\n\t\t\n\tend",
"def test03_post_open_news_EmptyGDM\n\t\t\tlogin $user_1_email, $master_password\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\t\n\t\t\tassert $post_media_button.exists?\n\t\t\t$post_media_button.click\n\t\t\tfile_upload \"GlacierBasinTrailMtRainier.JPG\"\n\t\t\t$post_now.fire_event(\"onclick\")\n\n\t\t\tassert $post_now.exists?\n\t\tend",
"def full_description(example_group)\n example_group.metadata.fetch(:example_group).fetch(:full_description)\n end",
"def list_html(medias)\n list = \"\"\n log \"list_html: #{medias.size}\"\n medias.each do |media|\n log \"media: #{media.title}\"\n list << \"<li><img src='\" << media.url << \"'><br>\" << media.title << \"</li>\"\n end\n \"<ul class='gallery_detail'>#{list}</ul>\"\n end",
"def initialize(media)\n @media = media\n end",
"def test_get_group_collection_basic_success\n\n client = create_mock_client\n refute_nil client, \"Client object couldn't be created.\"\n\n g1 = {\n 'Id' => 1,\n 'Name' => 'group 1',\n 'TinyName' => 'sample short name',\n 'StartGroupCallOnEnter' => '91XXXXXXXXXX',\n 'EndGroupCallOnExit' => '91XXXXXXXXXX',\n 'Members' => [\n {\n 'Id' => 1567,\n 'Name' => 'someone',\n 'Number' => '91XXXXXXXXXX'\n },\n {\n 'Id' => 1568,\n 'Name' => 'xyzzy',\n 'Mobile' => '971XXXXXXXX'\n }\n ] }\n g2 = {\n 'Id' => 2,\n 'Name' => 'group 2',\n 'TinyName' => 'sample short name',\n 'StartGroupCallOnEnter' => '91XXXXXXXXXX',\n 'EndGroupCallOnExit' => '91XXXXXXXXXX',\n 'Members' => [\n {\n 'Id' => 1561,\n 'Name' => 'someone',\n 'Number' => '91XXXXXXXXXX'\n },\n {\n 'Id' => 1562,\n 'Name' => 'xyzzy',\n 'Mobile' => '971XXXXXXXX'\n }\n ] }\n group_list = [g1, g2]\n\n stub_request(:get, mock_uri('Groups'))\n .to_return(status: 200, body: { 'Success' => true,\n 'Message' => \"Operation succeeded\",\n 'ApiId' => API_ID,\n 'Groups' => group_list }.to_json)\n\n status, details_list, _, _ = client.group.get_group_collection\n refute_nil status, \"No status object returned.\"\n assert status.success, \"Status did not indicate success: \" + status.message\n refute_nil details_list, \"No list of group detail objects returned.\"\n assert_kind_of Array, details_list, \"Details list isn't an array.\"\n assert_equal 2, details_list.length, \"Details list is the wrong length.\"\n assert_equal \"group 1\", details_list[0].name, \"First group name isn't correct.\"\n assert_equal \"group 2\", details_list[1].name, \"Second group name isn't correct.\"\n\n end",
"def group\n nil\n end",
"def group\n nil\n end",
"def group\n nil\n end",
"def show\n @ordered_group_members = sort_by_name(admins) + sort_by_name(@group.users - admins)\n @group_users = (@group.users - admins).size > NUMBER_OF_SHOWN_USERS ? (@group.users - admins).shuffle : sort_by_name(@group.users - admins)\n @group_admins = admins.size > NUMBER_OF_SHOWN_USERS ? sort_by_name(admins) : admins.shuffle\n\n # RECOMMENDATIONS\n sorted_recommendations = @group.recommendations.sort_by(&:created_at).reverse!\n @recommendations = sorted_recommendations.first(NUMBER_OF_SHOWN_RECOMMENDATIONS)\n @number_of_recommendations = sorted_recommendations.length\n @provider_logos = AmazonS3.instance.provider_logos_hash_for_recommendations(@recommendations)\n\n @group_picture = Group.group_images_hash_for_groups [@group]\n\n # ACTIVITIES\n @activities = PublicActivity::Activity.order(Arel.sql('created_at desc')).select {|activity| (@group.users.collect(&:id).include? activity.owner_id) && activity.group_ids.present? && (activity.group_ids.include? @group.id) }\n @activity_courses = {}\n @activity_courses_bookmarked = {}\n if @activities.present?\n @activities.each do |activity|\n @activity_courses[activity.id] = case activity.trackable_type\n when 'Recommendation' then Recommendation.find(activity.trackable_id).course\n when 'Course' then Course.find(activity.trackable_id)\n when 'Bookmark' then Bookmark.find(activity.trackable_id).course\n end\n @activity_courses_bookmarked[activity.id] = @activity_courses[activity.id].bookmarked_by_user? current_user if @activity_courses[activity.id].present?\n # privacy settings\n if activity.key == 'course.enroll'\n @activities -= [activity] unless activity.owner.course_enrollments_visible_for_group(@group)\n end\n end\n end\n\n # PICTURES\n @profile_pictures = User.author_profile_images_hash_for_activities(@activities)\n @profile_pictures = User.user_profile_images_hash_for_users(@group.users, @profile_pictures)\n end",
"def test_get_group_details_basic_success\n\n client = create_mock_client\n refute_nil client, \"Client object couldn't be created.\"\n\n stub_request(:get, mock_uri('Groups', '1'))\n .to_return(status: 200, body: { 'Success' => true,\n 'Message' => \"Operation succeeded\",\n 'ApiId' => API_ID,\n 'Group' => {\n 'Id' => 1,\n 'Name' => 'group 1',\n 'TinyName' => 'sample short name',\n 'StartGroupCallOnEnter' => '91XXXXXXXXXX',\n 'EndGroupCallOnExit' => '91XXXXXXXXXX',\n 'Members' => [\n {\n 'Id' => 1567,\n 'Name' => 'someone',\n 'Number' => '91XXXXXXXXXX'\n },\n {\n 'Id' => 1568,\n 'Name' => 'xyzzy',\n 'Mobile' => '971XXXXXXXX'\n }\n ]\n } }.to_json)\n status, group_detail = client.group.get_group_details(1)\n refute_nil status, \"No status object returned.\"\n assert status.success, \"Status did not indicate success: \" + status.message\n refute_nil group_detail, \"No group detail object returned.\"\n assert_kind_of SmsCountryApi::Group::GroupDetail, group_detail, \"Returned group detail object isn't the right type.\"\n assert_equal 1, group_detail.id, \"ID isn't correct.\"\n assert_equal 'group 1', group_detail.name, \"Name isn't correct.\"\n assert_equal 'sample short name', group_detail.tiny_name, \"Tiny name isn't correct.\"\n assert_equal '91XXXXXXXXXX', group_detail.start_call_on_enter, \"Start call on enter isn't correct.\"\n assert_equal '91XXXXXXXXXX', group_detail.end_call_on_exit, \"End call on exit isn't correct.\"\n refute_nil group_detail.members, \"Members is nil.\"\n assert_equal 2, group_detail.members.length, \"Members length isn't correct.\"\n\n end",
"def test_10b\r\n db = build\r\n nm = File.join(test_data,'image-1.jpg')\r\n db['group1'].store(nm)\r\n assert File.exists?(File.join(db.root,'groups',\r\n 'group1','originals',\r\n 'image-1.jpg'))\r\n end",
"def test03_pre_closed_news_NoteVideoPhotoPDF_TC_24302_TC_24304\n\t\tlogin $editor_1_email, $master_password\n\t\t$browser.goto($patch_news_pre_open)\n\t\tsleep 2\n\t\t\n\t\tassert $post_pick_group.exists?\n \t\t$post_pick_group.when_present.fire_event(\"onclick\")\n\t\t$post_media_description.when_present.set(\"All fishing is off limits in the olympic national park.\")\n \t\trepostGroupPop\n \t\t#sleep 2\n \t\t#$post_media_button\n\t\t$post_add_media.when_present.click\n\t\tfile_upload \"DungenessSpit102.26.2012.mov\"\n\t\t$post_add_media.click\n\t\tfile_upload \"GlacierBasinTrailMtRainier.JPG\"\n\t\t$post_add_media.click\n\t\tfile_upload \"PDFDocument.pdf\"\n\t\t$post_add_media.click\n\t\tfile_upload \"PDF2.pdf\"\n\t\t$post_now.fire_event(\"onclick\")\n\t\t\t\n\t\tsleep 2\n\t\tassert $post_new_post.exists?\n\tend",
"def test_10d\r\n db = build\r\n nm = File.join(test_data,'image-1.jpg')\r\n nm2 = File.join(test_data,'image-2.jpg')\r\n db['group1']['group2'].store(nm)\r\n assert File.exists?(File.join(db.root,'groups',\r\n 'group1','groups','group2',\r\n 'originals','image-1.jpg'))\r\n assert !File.exists?(File.join(db.root,'groups',\r\n 'group1','originals',\r\n 'image-1.jpg'))\r\n db['group1'].store(nm)\r\n assert File.exists?(File.join(db.root,'groups',\r\n 'group1','originals',\r\n 'image-1.jpg'))\r\n end",
"def validate_data(description, author, artist, type, status, genres, release, html_name, alternative_names, rank, rating, rating_max, cover_xpath)\n Utils_file::dir_create(@dir)\n Utils_connection::write_cover(@manga_data[:index_page], cover_xpath, @dir + 'cover.jpg', @params[:manga_path] + @manga_data[:website][:dir] + 'mangas/' + @manga_data[:name] + '.jpg')\n File.open(@dir + 'description.txt', 'w') do |txt|\n txt << Utils_file::data_concatenation(@manga_data, Utils_file::description_manipulation(description), author, artist, type, status, genres, release, html_name, alternative_names)\n end\n @aff.data_disp(@manga_data[:in_db])\n if @manga_data[:in_db]\n @db.update_manga(@manga_data[:name], description, author, artist, genres, html_name, alternative_names, rank, rating, rating_max)\n else\n @db.add_manga(@manga_data, description, author, artist, type, status, genres, release, html_name, alternative_names, rank, rating, rating_max)\n end\n end",
"def test02_group_photo_center\n\t\n\t\tloginGroup\n\t\t$browser.goto($patch_mongooses_settings)\n\t\t$group_image_2.fire_event(\"onclick\")\n\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t$upload_frames_save.click\t\t\n\tend",
"def test_12a\r\n db = build\r\n db.not_found_image = 'image-1.jpg'\r\n assert_equal 'image-1.jpg',db.not_found_image\r\n assert_equal 'image-1.jpg',db['group1'].not_found_image\r\n assert_equal 'image-1.jpg',db['group1']['group2'].not_found_image\r\n\r\n db['group1'].not_found_image = 'image-2.jpg'\r\n assert_equal 'image-2.jpg',db['group1'].not_found_image\r\n end"
] | [
"0.6135544",
"0.6088162",
"0.6019473",
"0.592721",
"0.5784978",
"0.5718239",
"0.5716423",
"0.57144636",
"0.5696722",
"0.56958914",
"0.5684804",
"0.56783617",
"0.56330377",
"0.56108385",
"0.5594785",
"0.55879605",
"0.5554714",
"0.55505776",
"0.5523801",
"0.5511623",
"0.54983765",
"0.5498084",
"0.5486436",
"0.5481815",
"0.54773116",
"0.5464493",
"0.54644036",
"0.54644036",
"0.54644036",
"0.54561174",
"0.54249084",
"0.54200745",
"0.5371234",
"0.5370268",
"0.5367171",
"0.5351407",
"0.5347574",
"0.53361654",
"0.53216237",
"0.5313668",
"0.52995414",
"0.5289078",
"0.5287484",
"0.52846473",
"0.5269335",
"0.5267182",
"0.52642447",
"0.52506673",
"0.5250643",
"0.52134955",
"0.52069604",
"0.5196825",
"0.5192948",
"0.5171481",
"0.5168836",
"0.5165994",
"0.5161559",
"0.51615286",
"0.5157694",
"0.51541084",
"0.51488125",
"0.5144262",
"0.5127782",
"0.5117344",
"0.5114394",
"0.5114366",
"0.51026636",
"0.5101146",
"0.5098674",
"0.5094748",
"0.5083987",
"0.5083969",
"0.50801194",
"0.50618184",
"0.50518215",
"0.50508744",
"0.5049367",
"0.5047427",
"0.5045006",
"0.5036833",
"0.50359523",
"0.50307494",
"0.50279677",
"0.50277597",
"0.50274116",
"0.5026925",
"0.5024053",
"0.50232774",
"0.5022653",
"0.5021707",
"0.5021707",
"0.5021707",
"0.50161225",
"0.5012793",
"0.50102264",
"0.5009712",
"0.5002525",
"0.49991065",
"0.4989278",
"0.49887982"
] | 0.56265634 | 13 |
Test 5: Populated group, empty description, no media | def test05_post_open_news_EmptyDMPopG
login $user_1_email, $master_password
$browser.goto($patch_media)
sleep 2
assert $post_pick_group.exists?
repostGroupPop
$post_now.fire_event("onclick")
assert $post_now.exists?
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_group(group)\n puts \"Name: \" + group.name\n puts \"Description: \" + (group.description.nil? ? \"None\" : group.description)\n puts \"Status: \" + group.status\n puts \"Href: \" + group.href\nend",
"def test_initialize_group\r\n \ttest_group = ProspectorGroup.new\r\n \ttest_group.intialize_group(33, 3)\r\n \tassert_equal 3, test_group.num_prospectors\r\n \tassert_equal 0 , test_group.iteration_count\r\n end",
"def test02_EmptyMPopGD\n\t\t\tloginPost\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\tif $post_pick_group.exists?\n\t\t\t\tpostGroupPop\n\t\t\t\t$post_media_description.set(\"Media Description #{random}.\")\n\t\t\t\t$post_now.fire_event(\"onclick\")\n\t\t\telse puts \"PEV04T02: FAILED! User unable to locate Post button.\"\n\t\t\tend \t\t\t\t\n\t\t\t\n\t\t\tbegin\n\t\t\tassert $post_now.exists?\n\t\t\t\trescue => e\n\t\t\t\tputs (\"PEV04T02: FAILED! User able to Post.\")\n\t\t\t\tputs e\n\t\t\tend\n\t\tend",
"def test03_EmptyGPopDM\n\t\t\tloginPost\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\tif $post_media_description.exists?\n\t\t\t\t$post_media_description.set(\"Media Description #{random}.\")\n \t\t\t\tpostGroupPop\n\t\t\t\t$post_media_button.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t\t$post_now.fire_event(\"onclick\")\n\t\t\telse puts \"PEV04T03: FAILED! User unable to locate Post button.\"\n\t\t\tend\n\t\t\t\n\t\t\tbegin\n\t\t\tsleep 2\n\t\t\tassert $post_new_post.exists?\n\t\t\t\trescue => e\n\t\t\t\tputs (\"PEV04T03: FAILED! User unable to Post.\")\n\t\t\t\tputs e\n\t\t\tend\t\n\t\tend",
"def test_10a\r\n db = build\r\n assert_equal [],db.groups\r\n end",
"def test_require_group\n render text: 'OK'\n end",
"def full_description(example_group)\n example_group.metadata.fetch(:full_description)\n end",
"def description\n [@group.description,@description].join(' ')\n end",
"def test_data_extraction\n\t\tYAML.load_file('test/groups.yml')[\"groups\"].each do |g_data|\n\t\t\tstub_request(:get, g_data[\"url\"]).\n\t\t\tto_return(:status => 200, :body => File.read(\"test/yahoo_pages/#{g_data['id']}.html\"), :headers => {})\n\n\t\t\tgroup = YahooGroupData.new(g_data[\"url\"])\n\t\t\tassert_equal g_data[\"age_restricted\"], group.age_restricted?\n\t\t\tassert_equal g_data[\"private\"], group.private?\n\t\t\tassert_equal g_data[\"not_found\"], group.not_found?\n\t\t\tassert_equal g_data[\"name\"], group.name\n\t\t\tassert_equal g_data[\"description\"], group.description\n\t\t\tassert_equal g_data[\"post_email\"], group.post_email\n\t\t\tassert_equal g_data[\"subscribe_email\"], group.subscribe_email\n\t\t\tassert_equal g_data[\"owner_email\"], group.owner_email\n\t\t\tassert_equal g_data[\"unsubscribe_email\"], group.unsubscribe_email\n\t\t\tassert_equal g_data[\"founded\"], group.founded\n\t\t\tassert_equal g_data[\"language\"], group.language\n\t\t\tassert_equal g_data[\"num_members\"], group.num_members\n\t\t\tassert_equal g_data[\"category\"], group.category\n\t\tend\n\tend",
"def test03_EmptyGPopDMPublish\n\t\t\tloginPost\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\tif $post_media_description.exists?\n\t\t\t\t$post_media_description.set(\"Media Description #{random}.\")\n \t\t\t\tpostGroupPop\n\t\t\t\t$post_media_button.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t\tpostPublishLater\n\t\t\t\t$post_now.fire_event(\"onclick\")\n\t\t\telse puts \"PPL04T03: FAILED! User unable to locate Post button.\"\n\t\t\tend\n\t\t\t\n\t\t\tbegin\n\t\t\tsleep 2\n\t\t\tassert $post_scheduled_post.exists?\n\t\t\t\trescue => e\n\t\t\t\tputs (\"PPL04T03: FAILED! User unable to Post.\")\n\t\t\t\tputs e\n\t\t\tend\t\n\t\tend",
"def test02_EmptyMPopGDPublish\n\t\t\tloginPost\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\tif $post_pick_group.exists?\n\t\t\t\tpostGroupPop\n\t\t\t\t$post_media_description.set(\"Media Description #{random}.\")\n\t\t\t\tpostPublishLater\n\t\t\t\t$post_now.fire_event(\"onclick\")\n\t\t\telse puts \"PPL04T02: FAILED! User unable to locate Post button.\"\n\t\t\tend \t\t\t\t\n\t\t\t\n\t\t\tbegin\n\t\t\tassert $post_now.exists?\n\t\t\t\trescue => e\n\t\t\t\tputs (\"PPL04T02: FAILED! User able to Post.\")\n\t\t\t\tputs e\n\t\t\tend\n\t\tend",
"def test04_post_closed_board_GroupRepostMedia\n\t\trepostMediaPop\n\t\tsleep 3\n\t\tgroupAddRemoveAdd \"Repost text #{random}.\"\n \t\tsleep 3\n\t\t\n\t\tassert $repost_confirmation.exists?\n\tend",
"def test03_MediaAllFields\n\t\tloginPost\n\t\t$browser.goto($patch_media)\n\t\t\t\n\t\t\tsleep 2\n\t\t\tif $post_media_description.exists?\n\t\t\t\t$post_media_description.set(\"pictures of hiking mr. rainier #{random}.\")\n \t\t\t\tpostGroupPop\n \t\t\t\tpostGroupPop2\n\t\t\t\t$post_media_button.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t\t$post_media_button.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t\t$post_now.fire_event(\"onclick\")\n\t\t\telse puts \"P01T03: FAILED! User unable to locate Post button.\"\n\t\t\tend\n\t\t\t\n\t\tbegin\n\t\tsleep 2\n\t\tassert $post_new_post.exists?\n\t\t\trescue => e\n\t\t\tputs (\"P01T03: FAILED! User unable to Post.\")\n\t\t\tputs e\n\t\tend\t\n\tend",
"def test_groupdetail_constructor_and_accessors\n\n obj = SmsCountryApi::Group::GroupDetail.new\n refute_nil obj, \"Object wasn't created successfully.\"\n assert_kind_of SmsCountryApi::Group::GroupDetail, obj, \"Object isn't the correct type.\"\n assert_nil obj.id, \"ID isn't nil.\"\n assert_nil obj.name, \"Name isn't nil.\"\n assert_nil obj.tiny_name, \"Tiny name isn't nil.\"\n assert_nil obj.start_call_on_enter, \"Start call on enter isn't nil.\"\n assert_nil obj.end_call_on_exit, \"End call on exit isn't nil.\"\n assert_nil obj.members, \"Members isn't nil.\"\n\n end",
"def test04_group_photo_all\n\t\n\t\tloginGroup\n\t\t$browser.goto($patch_mongooses_settings)\n\t\t$group_image_1.fire_event(\"onclick\")\n\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t$span_3_frames.click\n\t\t$upload_frames_save.click\t\n\tend",
"def group\n nil\n end",
"def group\n nil\n end",
"def group\n nil\n end",
"def full_description(example_group)\n example_group.metadata.fetch(:example_group).fetch(:full_description)\n end",
"def test04_EmptyGPopDM\n\t\t\tloginPost\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\tif $post_media_description.exists?\n\t\t\t\t$post_media_description.set(\"Media Description #{random}.\")\n\t\t\t\t$post_media_button.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t\t$post_now.fire_event(\"onclick\")\n\t\t\telse puts \"PEV03T04: FAILED! UUser unable to locate Post button.\"\n\t\t\tend\n\t\t\t\n\t\t\tbegin\n\t\t\tassert $post_now.exists?\n\t\t\t\trescue => e\n\t\t\t\tputs (\"PEV03T04: FAILED! User able to Post.\")\n\t\t\t\tputs e\n\t\t\tend\t\n\t\tend",
"def ensure_magic_descriptor_presence(ad_group)\n # Use exceptions as activedirectory gem will throw an ArgumentError if no description exists.\n # AD groups don't have to have description fields but we will add one if needed.\n begin\n g_desc = ad_group.description\n rescue ArgumentError\n # description not set\n g_desc = \"\"\n end\n\n unless g_desc and g_desc.index MAGIC_DESCRIPTOR\n ad_group.description = \"#{MAGIC_DESCRIPTOR} #{g_desc}\"\n ad_group.save\n end\nend",
"def group\n nil\n end",
"def message\n 'Example grouping has no name'\n end",
"def test04_news_OpenPolitics\n\t\tlogin $editor_1_email, $master_password\n\t\t$browser.goto($patch_new_news_group)\n\t\tsleep 5\n\n\t\t$group_name.set(\"Politics Group #{random}\")\n\t\t$group_nickname.set(\"Nickname #{random}\")\n\t\t$group_description.set(\"Description #{random}\")\n\t\t$category_politics.click\n\t\tsleep 2\n\t\t$boards_arts_ent_image.when_present.fire_event(\"onclick\")\n\t\t$create_group.click\n\t\t\n\t\tcheckIfIncorrectErrorDisplays\n\t\t\n\tend",
"def group; end",
"def groups; end",
"def groups; end",
"def groups; end",
"def description\n start = Time.now\n debug \"Checking description for device group: \\\"#{resource[:full_path]}\\\"\"\n connection = self.class.get_connection(resource[:account])\n device_group = get_device_group(connection, resource[:full_path],'description')\n debug \"Finished in #{(Time.now-start)*1000.0} ms\"\n device_group['description']\n end",
"def test04_post_open_news_EmptyGPopDM\n\t\t\tlogin $user_1_email, $master_password\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\t\n\t\t\tassert $post_media_description.exists?\n\t\t\t$post_media_description.set(\"Media Description #{random}.\")\n\t\t\t$post_media_button.click\n\t\t\tfile_upload \"GlacierBasinTrailMtRainier.JPG\"\n\t\t\t$post_now.fire_event(\"onclick\")\n\n\t\t\tassert $post_now.exists?\n\t\tend",
"def test05_news_OpenPoliticsSports\n\t\tlogin $editor_1_email, $master_password\n\t\t$browser.goto($patch_new_news_group)\n\t\tsleep 5\n\n\t\t$group_name.set(\"Politics/Sports Group #{random}\")\n\t\t$group_nickname.set(\"Nickname #{random}\")\n\t\t$group_description.set(\"Description #{random}\")\n\t\t$category_politics.click\n\t\t$category_sports.click\n\t\t$boards_arts_ent_image.when_present.fire_event(\"onclick\")\n\t\t$create_group.click\n\t\t\n\t\tcheckIfIncorrectErrorDisplays\n\t\t\n\tend",
"def test05_EmptyDMPopG\n\t\t\tloginPost\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\tif $post_pick_group.exists?\n \t\t\t\tpostGroupPop\n\t\t\t\t$post_now.fire_event(\"onclick\")\n\t\t\telse puts \"PEV03T05: FAILED! User unable to locate Post button.\"\n\t\t\tend \t\t\t\t\n\t\t\t\n\t\t\tbegin\n\t\t\tassert $post_now.exists?\n\t\t\t\trescue => e\n\t\t\t\tputs (\"PEV03T05: FAILED! User able to Post.\")\n\t\t\t\tputs e\n\t\t\tend\n\t\tend",
"def test05_news_OpenSports\n\t\tlogin $editor_1_email, $master_password\n\t\t$browser.goto($patch_new_news_group)\n\t\tsleep 5\n\n\t\t$group_name.set(\"Sports Group #{random}\")\n\t\t$group_nickname.set(\"Nickname #{random}\")\n\t\t$group_description.set(\"Description #{random}\")\n\t\t$category_sports.click\n\t\t$boards_arts_ent_image.when_present.fire_event(\"onclick\")\n\t\t$create_group.click\n\t\t\n\t\tcheckIfIncorrectErrorDisplays\n\t\t\n\tend",
"def test04_DraftEmptyGPopDM\n\t\t\tloginPost\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\tif $post_media_description.exists?\n\t\t\t\t$post_media_description.set(\"Media Description #{random}.\")\n\t\t\t\t$post_media_button.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t\tsleep 2\n\t\t\t\tsleep 4\n\t\t\t\t$post_save_draft.fire_event(\"onclick\")\n\t\t\telse puts \"PDEV04T04: FAILED! UUser unable to locate Post button.\"\n\t\t\tend\n\t\t\t\n\t\t\tbegin\n\t\t\tassert $post_draft_error.exists?\n\t\t\t\trescue => e\n\t\t\t\tputs (\"PDEV04T04: FAILED! User able to save incomplete draft.\")\n\t\t\t\tputs e\n\t\t\tend\t\n\t\tend",
"def test_default_group_pages\n m = Time.now.to_f.to_s.gsub('.', '')\n @s.switch_user(User.admin_user())\n group = create_group(\"g-testgroup-#{m}\")\n path = \"#{group.home_path_for(@s)}/pages\"\n res = @s.execute_get(@s.url_for(\"#{path}.2.json\"))\n assert_equal(\"200\", res.code, \"Should have created pages in postprocessing\")\n json = JSON.parse(res.body)\n assert_not_nil(json[\"index.html\"], \"Expected default page not found\")\n assert_equal(json[\"index.html\"][\"jcr:primaryType\"], \"nt:file\", \"Default home page is not a file\")\n end",
"def test02_group_photo_center\n\t\n\t\tloginGroup\n\t\t$browser.goto($patch_mongooses_settings)\n\t\t$group_image_2.fire_event(\"onclick\")\n\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t$upload_frames_save.click\t\t\n\tend",
"def test_10b\r\n db = build\r\n nm = File.join(test_data,'image-1.jpg')\r\n db['group1'].store(nm)\r\n assert File.exists?(File.join(db.root,'groups',\r\n 'group1','originals',\r\n 'image-1.jpg'))\r\n end",
"def test02_news_OpenEducationFamily\n\t\tlogin $editor_1_email, $master_password\n\t\t$browser.goto($patch_new_news_group)\n\t\tsleep 5\n\n\t\t$group_name.set(\"Education/Family Group #{random}\")\n\t\t$group_nickname.set(\"Nickname #{random}\")\n\t\t$group_description.set(\"Description #{random}\")\n\t\t$category_education.click\n\t\t$category_family.click\n\t\t$boards_arts_ent_image.when_present.fire_event(\"onclick\")\n\t\t$create_group.click\n\t\t\n\t\tcheckIfIncorrectErrorDisplays\n\t\t\n\tend",
"def test03_MediaOneComment_TC_24319\n\t\tcommentMediaPop\n\t\tcommentPopSubmit\n\tend",
"def test_creating_public_description\n # We want to create an empty, default public description for a name that\n # doesn't have any descriptions yet -- simplest possible case.\n @name = Name.find_by(text_name: \"Strobilurus diminutivus\")\n assert_equal([], @name.descriptions)\n @description_data = {\n source_type: \"public\",\n source_name: nil,\n readable: true,\n writable: true,\n notes: \"I like this mushroom.\"\n }\n @group_expectations = {\n admins: [UserGroup.reviewers],\n writers: [UserGroup.all_users],\n readers: [UserGroup.all_users],\n authors: [],\n editors: [mary]\n }\n\n admin = open_admin_session(dick)\n reviewer = open_normal_session(rolf)\n owner = open_normal_session(mary)\n random_user = open_normal_session(katrina)\n lurker = open_lurker_session\n\n reviewer.should_be_reviewer\n owner.should_not_be_reviewer\n random_user.should_not_be_reviewer\n\n # sets (not checks) the abilities\n admin.should_be_able_to_do_anything\n reviewer.should_be_able_to_do_anything_but_change_permissions\n owner.should_be_able_to_edit_and_change_name\n random_user.should_be_able_to_edit_text_only\n lurker.should_be_able_to_see_but_needs_to_login\n\n owner.create_name_description\n owner.check_name_description\n\n admin.check_abilities\n reviewer.check_abilities\n owner.check_abilities\n random_user.check_abilities\n lurker.shouldnt_be_able_to_do_anything\n end",
"def album\r\n #prepare_new_album extracted for reuse from spec\r\n prepare_new_album unless @content\r\n end",
"def example_group_started(notification)\n # there is a super method for this\n super(notification)\n doc = {\n 'type' => 'case',\n 'subtype' => 'describe',\n 'label' => \"#{notification.group.description}\",\n 'level' => @example_group_stack.size\n }\n @example_group_stack << example_group\n return doc\n end",
"def test_ownprovidergroups\n groupnames.each { |group|\n gobj = nil\n comp = nil\n fakeresource = fakeresource(:group, group)\n assert_nothing_raised {\n gobj = @provider.new(fakeresource)\n }\n\n assert(gobj.gid, \"Failed to retrieve gid\")\n }\n end",
"def test02_news_OpenOpinion\n\t\tlogin $editor_1_email, $master_password\n\t\t$browser.goto($patch_new_news_group)\n\t\tcheckIfIncorrectErrorDisplays\n\t\t\n\t\tsleep 5\n\n\t\t$group_name.set(\"Opinion Group #{random}\")\n\t\t$group_nickname.set(\"Nickname #{random}\")\n\t\t$group_description.set(\"Description #{random}\")\n\t\t$category_opinion.click\n\t\t$boards_arts_ent_image.when_present.fire_event(\"onclick\")\n\t\t$create_group.click\n\t\t\n\t\tcheckIfIncorrectErrorDisplays\n\t\n\tend",
"def test03_4GroupsRepostMedia\n\t\trepostMediaPop\n\t\tsleep 3\n\t\tfourGroupSelect\n\t\tsleep 3\n\t\t\n\t\tbegin \n\t\tassert $repost_confirmation.exists?\n\t\t\trescue => e\n\t\t\tputs \"RS06T03: FAILED! User unable to repost!\"\n\t\t\tputs e\n\t\tend\n\tend",
"def test05_DraftEmptyDMPopG\n\t\t\tloginPost\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\tif $post_pick_group.exists?\n \t\t\t\tpostGroupPop\n\t\t\t\tsleep 4\n\t\t\t\t$post_save_draft.fire_event(\"onclick\")\n\t\t\telse puts \"PDEV04T05: FAILED! User unable to locate Post button.\"\n\t\t\tend \t\t\t\t\n\t\t\t\n\t\t\tbegin\n\t\t\tassert $post_draft_error.exists?\n\t\t\t\trescue => e\n\t\t\t\tputs (\"PDEV04T05: FAILED! User able to save incomplete draft.\")\n\t\t\t\tputs e\n\t\t\tend\n\t\tend",
"def group\n return nil if item_type != 'group'\n direct_group\n end",
"def setup\n @key = :__first_group__\n zero\n end",
"def test_all\n query = \"iphone5s\"\n\n products = ProductHelper.crawl(query)\n products.each do |product|\n #STDERR.puts product\n end\n pgroups = ProductHelper.clustering(products)\n pgroups.each do |pgroup|\n info = \"\"\n unless pgroup.spu.nil?\n info = pgroup.spu['Title']\n end\n STDERR.puts \"#{pgroup.size},#{info}\"\n end\n end",
"def add_display_only_data(group)\n group[:id] = SecureRandom.uuid\n group[:controls].collect!.with_index do |c, i|\n # i is zero-indexed, and we want the display one-indexed\n c[:sequence_number] = i + 1\n c\n end\n group\n end",
"def test03_GroupRepostMedia\n\t\trepostMediaPop\n\t\tsleep 3\n\t\tgroupAddRemoveAdd\n \t\tsleep 3\n\t\t\n\t\tbegin \n\t\tassert $repost_confirmation.exists?\n\t\t\trescue => e\n\t\t\tputs \"RS2T03: FAILED! User unable to repost!\"\n\t\t\tputs e\n\t\tend\n\tend",
"def group_items\n @group_items ||= Product.includes(:pictures)\n .where(group: group.presence || '_ZZZZ_', active: true, hidden: false)\n .order(:option_sort, :option_title)\n end",
"def setup_group(new_group)\n # original alignment\n @altered_alignment = false\n # set new own group\n @group = new_group\n # set up enemy groups\n @negative = $game_system.alignments[@group].enemies.clone\n # set up ally groups\n @positive = $game_system.alignments[@group].allies.clone\n # set up always-neutral groups\n @neutral = $game_system.alignments[@group].neutral.clone\n end",
"def prepare\n insert_recording_reporter\n link_example_groups\n end",
"def showgroup\n group = groups.map(&:id)\n group.delete(Group.defaultgroup)\n return \"None\" if group.empty?\n Group.find(group.to_s).title \n end",
"def has_group?\n @group == ''\n end",
"def attach_info # :nodoc:\n unless self.info_added\n rsp = @flickr.send_request('flickr.groups.getInfo', :group_id => self.nsid)\n self.info_added = true\n self.description = rsp.group.description.to_s.strip\n self.member_count = rsp.group.members.to_s.strip\n self.icon_server = rsp.group[:iconserver]\n self.icon_farm = rsp.group[:iconfarm]\n end\n end",
"def test03_news_OpenLivingNews\n\t\tlogin $editor_1_email, $master_password\n\t\t$browser.goto($patch_new_news_group)\n\t\tsleep 5\n\n\t\t$group_name.set(\"Living/News Group #{random}\")\n\t\t$group_nickname.set(\"Nickname #{random}\")\n\t\t$group_description.set(\"Description #{random}\")\n\t\t$category_living.click\n\t\t$category_news.click\n\t\t$boards_arts_ent_image.when_present.fire_event(\"onclick\")\n\t\t$create_group.click\n\t\t\n\t\tcheckIfIncorrectErrorDisplays\n\t\t\n\tend",
"def group_builder; end",
"def test04_post_closed_news_TwoGroupsRepostMedia\n\t\trepostMediaPop\n\t\tsleep 3\n\t\ttwoGroupSelect\n\t\tsleep 3\n\t\t\n\t\tassert $repost_confirmation.exists?\n\tend",
"def test04_news_OpenOpinionOther\n\t\tlogin $editor_1_email, $master_password\n\t\t$browser.goto($patch_new_news_group)\n\t\tsleep 5\n\n\t\t$group_name.set(\"Opinion/Other Group #{random}\")\n\t\t$group_nickname.set(\"Nickname #{random}\")\n\t\t$group_description.set(\"Description #{random}\")\n\t\t$category_opinion.click\n\t\t$category_other.click\n\t\t$boards_arts_ent_image.when_present.fire_event(\"onclick\")\n\t\t$create_group.click\n\t\t\n\t\tcheckIfIncorrectErrorDisplays\n\t\t\n\tend",
"def test03_EmptyGDM\n\t\t\tloginPost\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\tif $post_media_button.exists?\n\t\t\t\t$post_media_button.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t\t$post_now.fire_event(\"onclick\")\n\t\t\telse puts \"PEV03T03: FAILED! User unable to locate Post button.\"\n\t\t\tend\n\t\t\t\n\t\t\tbegin\n\t\t\tassert $post_now.exists?\n\t\t\t\trescue => e\n\t\t\t\tputs (\"PEV03T03: FAILED! User able to Post.\")\n\t\t\t\tputs e\n\t\t\tend\n\t\tend",
"def present_group(metric, group)\n occurences = group.size\n case(metric)\n when :reek\n \"found #{occurences} code smells\"\n when :roodi\n \"found #{occurences} design problems\"\n when :churn\n \"detected high level of churn (changed #{group[0].times_changed} times)\"\n when :flog\n complexity = get_mean(group.column(\"score\"))\n \"#{\"average \" if occurences > 1}complexity is %.1f\" % complexity\n when :saikuro\n complexity = get_mean(group.column(\"complexity\"))\n \"#{\"average \" if occurences > 1}complexity is %.1f\" % complexity\n when :flay\n \"found #{occurences} code duplications\"\n when :rcov\n average_code_uncoverage = get_mean(group.column(\"percentage_uncovered\"))\n \"#{\"average \" if occurences > 1}uncovered code is %.1f%\" % average_code_uncoverage\n else\n raise AnalysisError, \"Unknown metric #{metric}\"\n end\n end",
"def test03_news_OpenOther\n\t\tlogin $editor_1_email, $master_password\n\t\t$browser.goto($patch_new_news_group)\n\t\tsleep 5\n\n\t\t$group_name.set(\"Other Group #{random}\")\n\t\t$group_nickname.set(\"Nickname #{random}\")\n\t\t$group_description.set(\"Description #{random}\")\n\t\t$category_other.click\n\t\t$boards_arts_ent_image.when_present.fire_event(\"onclick\")\n\t\t$create_group.click\n\t\t\n\t\tcheckIfIncorrectErrorDisplays\n\t\t\n\tend",
"def enter_groups(test_data)\n test_groups = test_data[Org::GROUPS.name]\n test_groups = [{ Org::GROUP.name => ''}] unless test_groups\n prep_fieldsets_for_test_data([fieldset(Org::GROUPS.name)], test_groups)\n\n test_groups.each_with_index do |test_grp, index|\n wait_for_element_and_type(group_input(index), test_grp[Org::GROUP.name])\n end\n end",
"def test_attributes\n assert_equal \"Gallery 1\", @gallery.title\n assert @gallery.active?\n assert_equal \"f82dd0bd-4711-4578-ac47-4661257e69a6\", @gallery.guid\n end",
"def test02_post_closed_news_GroupRepostArticle\n\t\trepostArticlePop\n\t\tsleep 3\n\t\tgroupAddRemoveAdd \"Repost text #{random}.\"\n \t\tsleep 3\n\t\t\n\t\tassert $repost_confirmation.exists?\n\tend",
"def test02_ArticleAllFields\n\t\tloginPost\n\t\t$browser.goto($patch_article)\n\t\t\t\n\t\t\tsleep 2\n\t\t\tif $post_pick_group.exists?\n \t\t\t\tpostGroupPop\n \t\t\t\tpostGroupPop2\n \t\t\t\t$post_article_title.set(\"Article #{random}\")\n \t\t\t\t$browser.execute_script(\"jQuery('iframe.wysihtml5-sandbox').contents().find('body').prepend('lava is hot.')\")\n \t\t\t\t$post_add_media.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t\t$post_add_media.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t\t$post_now.fire_event(\"onclick\")\n\t\t\telse puts \"PS01T02: FAILED! User unable to locate Post button.\"\n\t\t\tend\n\t\t\t\n\t\tbegin\n\t\tsleep 2\n\t\tassert $post_new_post.exists?\n\t\t\trescue => e\n\t\t\tputs (\"P01T02: FAILED! User unable to Post.\")\n\t\t\tputs e\n\t\tend\n\tend",
"def option_group_description\n data[:option_group_description]\n end",
"def has_group?\n\t\t@group == ''\n\tend",
"def playlist_group\n @playlist_group ||= xpath_optional('/*/pbcoreAnnotation[@annotationType=\"Playlist Group\"]')\n end",
"def test_assign_groups_to_reviews\n\n post(:assign_groups_to_reviews,\n { :review_type => {\n # 1-Final, 2-Routing, 3-Pre-Art, 4-Placement, 5-Release\n '5_1'=>'1', '5_2'=>'0', '5_3'=>'1', '5_4'=>'0', '5_5'=>'0', #HWENG\n '6_1'=>'1', '6_2'=>'1', '6_3'=>'1', '6_4'=>'0', '6_5'=>'1', #VALOR\n '7_1'=>'1', '7_2'=>'1', '7_3'=>'0', '7_4'=>'1', '7_5'=>'1', #CE-DFT\n '8_1'=>'0', '8_2'=>'0', '8_3'=>'1', '8_4'=>'0', '8_5'=>'1', #DFM\n '9_1'=>'1', '9_2'=>'0', '9_3'=>'1', '9_4'=>'1', '9_5'=>'0', #TDE\n '10_1'=>'1', '10_2'=>'0', '10_3'=>'1', '10_4'=>'1', '10_5'=>'0', #MECHANICAL\n '11_1'=>'0', '11_2'=>'1', '11_3'=>'1', '11_4'=>'1', '11_5'=>'0', #MECH-MFG\n '12_1'=>'1', '12_2'=>'0', '12_3'=>'0', '12_4'=>'0', '12_5'=>'1', #PCB DESIGN\n '13_1'=>'1', '13_2'=>'0', '13_3'=>'1', '13_4'=>'0', '13_5'=>'0', #PLANNING\n '14_1'=>'1', '14_2'=>'0', '14_3'=>'0', '14_4'=>'0', '14_5'=>'0', #PCB IG\n '15_1'=>'1', '15_2'=>'0', '15_3'=>'0', '15_4'=>'0', '15_5'=>'0', #LIBRARY\n '16_1'=>'0', '16_2'=>'0', '16_3'=>'1', '16_4'=>'1', '16_5'=>'1', #PCB MECH\n '17_1'=>'1', '17_2'=>'1', '17_3'=>'1', '17_4'=>'1', '17_5'=>'1', #SLM BOM\n '18_1'=>'0', '18_2'=>'1', '18_3'=>'1', '18_4'=>'1', '18_5'=>'0', #SLM-Vendor\n '19_1'=>'1', '19_2'=>'0', '19_3'=>'0', '19_4'=>'0', '19_5'=>'1' #OPS MGR\n } },\n cathy_admin_session)\n\n post :review_type_role_assignment, {}, cathy_admin_session\n\n assert_response :success\n\n roles = assigns(roles)['roles']\n review_types = assigns(review_types)['review_types']\n\n expected_values = [\n {:name => 'Hardware Engineering Manager',\n :review_types => []},\n {:name => 'Operations Manager',\n :review_types => ['Final', 'Release']},\n {:name => 'PCB Design',\n :review_types => ['Final', 'Release']},\n {:name => 'Program Manager',\n :review_types => []},\n {:name => 'DFM',\n :review_types => ['Pre-Artwork', 'Release']},\n {:name => 'CE-DFT',\n :review_types => ['Final', 'Placement', 'Release', 'Routing']},\n {:name => 'Compliance - EMC', \n :review_types => []},\n {:name => 'Compliance - Safety', \n :review_types => []},\n {:name => 'Library',\n :review_types => ['Final']},\n {:name => 'ECN',\n :review_types => []},\n {:name => 'HWENG',\n :review_types => ['Final', 'Pre-Artwork']},\n {:name => 'Mechanical',\n :review_types => ['Final', 'Placement', 'Pre-Artwork']},\n {:name => 'Mechanical-MFG',\n :review_types => ['Placement', 'Pre-Artwork', 'Routing']},\n {:name => 'Planning',\n :review_types => ['Final', 'Pre-Artwork']},\n {:name => 'PCB Input Gate',\n :review_types => ['Final']},\n {:name => 'PCB Mechanical',\n :review_types => ['Placement', 'Pre-Artwork', 'Release']},\n {:name => 'SLM BOM',\n :review_types => ['Final', 'Placement', 'Pre-Artwork', 'Release', 'Routing']},\n {:name => 'SLM-Vendor',\n :review_types => ['Placement', 'Pre-Artwork', 'Routing']},\n {:name => 'TDE',\n :review_types => ['Final', 'Placement', 'Pre-Artwork']},\n {:name => 'Valor', \n :review_types => ['Final', 'Pre-Artwork', 'Release', 'Routing']}\n ]\n\n #assert_equal(expected_values, roles)\n assert_equal(expected_values.size, roles.size)\n assert_equal(5, review_types.size)\n\n roles.each_with_index { |role, i|\n expected_role = expected_values[i]\n assert_equal(expected_role[:name], role.name)\n \n returned_rts = role.review_types.collect { |rt| rt.name }\n\n returned_rts = returned_rts.sort_by { |rt| rt }\n returned_rts.each_with_index { |review_type, j|\n expected_name = expected_role[:review_types][j]\n assert_equal(expected_role[:name]+'::'+expected_name.to_s,\n role.name+'::'+review_type)\n }\n\n }\n\n expected_values = [\n {:name => 'Pre-Artwork',\n :role_names => ['DFM', 'HWENG', 'Mechanical', 'Mechanical-MFG', 'PCB Mechanical', 'Planning', 'SLM BOM', 'SLM-Vendor', 'TDE', 'Valor']},\n {:name => 'Placement', \n :role_names => ['CE-DFT', 'Mechanical', 'Mechanical-MFG', 'PCB Mechanical', 'SLM BOM', 'SLM-Vendor', 'TDE']},\n {:name => 'Routing', \n :role_names => ['CE-DFT', 'Mechanical-MFG', 'SLM BOM', 'SLM-Vendor', 'Valor']},\n {:name => 'Final',\n :role_names => ['CE-DFT', 'HWENG', 'Library', 'Mechanical', 'Operations Manager', 'PCB Design', 'PCB Input Gate', 'Planning', 'SLM BOM', 'TDE', 'Valor']},\n {:name => 'Release', \n :role_names => ['CE-DFT', 'DFM', 'Operations Manager', 'PCB Design', 'PCB Mechanical', 'SLM BOM', 'Valor']}\n ]\n review_types.each { |review_type| \n expected_rt = expected_values.shift\n\n returned_roles = []\n review_type.roles.each { |role| returned_roles.push(role.name) }\n\n returned_roles.sort.each { |role|\n expected_role = expected_rt[:role_names]\n expected_name = expected_role.shift\n assert_equal(expected_rt[:name]+'::'+expected_name, \n review_type.name+'::'+role)\n }\n }\n\n end",
"def create_fake\n record = MediaElement.new\n record.title = params[:title_placeholder] != '0' ? '' : params[:title]\n record.description = params[:description_placeholder] != '0' ? '' : params[:description]\n record.tags = params[:tags_value]\n record.user_id = current_user.id\n record.save_tags = true\n record.valid?\n @errors = convert_media_element_error_messages record.errors\n @errors[:media] = t('forms.error_captions.media_file_too_large').downcase\n end",
"def test_10d\r\n db = build\r\n nm = File.join(test_data,'image-1.jpg')\r\n nm2 = File.join(test_data,'image-2.jpg')\r\n db['group1']['group2'].store(nm)\r\n assert File.exists?(File.join(db.root,'groups',\r\n 'group1','groups','group2',\r\n 'originals','image-1.jpg'))\r\n assert !File.exists?(File.join(db.root,'groups',\r\n 'group1','originals',\r\n 'image-1.jpg'))\r\n db['group1'].store(nm)\r\n assert File.exists?(File.join(db.root,'groups',\r\n 'group1','originals',\r\n 'image-1.jpg'))\r\n end",
"def test_get_group_details_basic_success\n\n client = create_mock_client\n refute_nil client, \"Client object couldn't be created.\"\n\n stub_request(:get, mock_uri('Groups', '1'))\n .to_return(status: 200, body: { 'Success' => true,\n 'Message' => \"Operation succeeded\",\n 'ApiId' => API_ID,\n 'Group' => {\n 'Id' => 1,\n 'Name' => 'group 1',\n 'TinyName' => 'sample short name',\n 'StartGroupCallOnEnter' => '91XXXXXXXXXX',\n 'EndGroupCallOnExit' => '91XXXXXXXXXX',\n 'Members' => [\n {\n 'Id' => 1567,\n 'Name' => 'someone',\n 'Number' => '91XXXXXXXXXX'\n },\n {\n 'Id' => 1568,\n 'Name' => 'xyzzy',\n 'Mobile' => '971XXXXXXXX'\n }\n ]\n } }.to_json)\n status, group_detail = client.group.get_group_details(1)\n refute_nil status, \"No status object returned.\"\n assert status.success, \"Status did not indicate success: \" + status.message\n refute_nil group_detail, \"No group detail object returned.\"\n assert_kind_of SmsCountryApi::Group::GroupDetail, group_detail, \"Returned group detail object isn't the right type.\"\n assert_equal 1, group_detail.id, \"ID isn't correct.\"\n assert_equal 'group 1', group_detail.name, \"Name isn't correct.\"\n assert_equal 'sample short name', group_detail.tiny_name, \"Tiny name isn't correct.\"\n assert_equal '91XXXXXXXXXX', group_detail.start_call_on_enter, \"Start call on enter isn't correct.\"\n assert_equal '91XXXXXXXXXX', group_detail.end_call_on_exit, \"End call on exit isn't correct.\"\n refute_nil group_detail.members, \"Members is nil.\"\n assert_equal 2, group_detail.members.length, \"Members length isn't correct.\"\n\n end",
"def group_params\n params.require(:group).permit(:name, :image, :description, :primary_statistics)\n end",
"def test04_MediaPhotoVideo\n\t\tlogin $editor_1_email, $master_password\n\t\t$browser.goto($patch_boards_pre_closed_article_new)\n\t\t\n#\t\t$post_activate_note.when_present.fire_event(\"onclick\")\n#\t\t$post_media_description.set(\"mt townsend is my favorite mountain #{random}.\")\n\t\tif $environment == 'nixon'\t\n\t\t\trepostGroupPop #category already selected in staging\n\t\tend\n\t\t$post_article_title.set(\"Mountain #{random}\")\n \t\t$browser.execute_script(\"jQuery('iframe.wysihtml5-sandbox').contents().find('body').prepend('mt townsend is my favorite mountain #{random}.')\")\n\t\tsleep 2\n\t\t$post_add_media_article.click\n\t\tfile_upload \"DungenessSpit102.26.2012.mov\"\n\t\tsleep 2\n\t\t$post_add_media_article.click\n\t\tfile_upload \"GlacierBasinTrailMtRainier.JPG\"\n if $environment == 'staging'\n\t\t\tsleep 10 #loads \n\t\tend\n\t\t$post_now_edit.fire_event(\"onclick\")\n\n\t\tsleep 2\n\t\tassert $post_new_post.exists?\n\tend",
"def test03_DraftEmptyGDM\n\t\t\tloginPost\n\t\t\t$browser.goto($patch_media)\n\t\t\tsleep 2\n\t\t\tif $post_media_button.exists?\n\t\t\t\t$post_media_button.click\n\t\t\t\t$post_media_file_upload.set(\"#{$post_media_username}/patch-automation/test/TestData/GlacierBasinTrailMtRainier.JPG\")\n\t\t\t\tsleep 2\n\t\t\t\tsleep 4\n\t\t\t\t$post_save_draft.fire_event(\"onclick\")\n\t\t\telse puts \"PDEV04T03: FAILED! User unable to locate Post button.\"\n\t\t\tend\n\t\t\t\n\t\t\tbegin\n\t\t\tassert $post_draft_error.exists?\n\t\t\t\trescue => e\n\t\t\t\tputs (\"PDEV04T03: FAILED! User able to save incomplete draft.\")\n\t\t\t\tputs e\n\t\t\tend\n\t\tend",
"def test02_MediaTwoComments\n\t\tcommentMediaPop\n\t\tcommentPopSubmit\n\tend",
"def begin_group(kind); end",
"def test_get_ad_group\n test_add_ad_group_cpc() unless @ad_group\n selector = @ad_group_srv.module::AdGroupSelector.new\n selector.adGroupIds = [@ad_group.id]\n response = @ad_group_srv.get(selector)\n assert_not_nil(response.rval.entries, 'Empty result set returned')\n assert_equal(1, response.rval.entries.size,\n 'Unexpected number of entries returned')\n assert_equal(@ad_group.id, response.rval.entries.first.id)\n end",
"def ntest_output_generator_group\n assert_equal(\"SHEPHERD EYE SURGICENTER\", Output835.output_generator_group(facilities(:facility_211)))\n assert_equal(facilities(:facility_24).name, Output835.output_generator_group(facilities(:facility_24)))\n end",
"def set_group\n data[:group]\n end",
"def summarize_suite(suite, tests); end",
"def summarize_suite(suite, tests); end",
"def i_groups; end",
"def test05_blog_OpenPoliticsSports\n\t\tlogin $user_1_email, $master_password\n\t\t\n\t\tsleep 5\n\n\t\t$open_group.fire_event(\"onclick\")\n\t\t$group_name.set(\"Politics/Sports Group #{random}\")\n\t\t$group_nickname.set(\"Nickname #{random}\")\n\t\t$group_description.set(\"Description #{random}\")\n\t\t$category_politics.click\n\t\t$category_sports.click\n\t\t$boards_arts_ent_image.when_present.fire_event(\"onclick\")\n\t\t$create_group.click\n\t\t\n\t\tcheckIfIncorrectErrorDisplays\n\t\t\n\tend",
"def create_new_media(data_set)\n enter_media_info_data data_set\n click_save_button\n when_exists(delete_button, Config.short_wait)\nend",
"def test05_news_OpenLiving_TC_24397\n\t\tlogin $editor_1_email, $master_password\n\t\twait_for_ajax\n\t\t\n\t\t$header_tools_icon.click\n\t\tsleep 2\n\t\t$header_tools_start_news.click\n\n\t\t$group_name.set(\"Living Group #{random}\")\n\t\t$boards_group_nickname.set(\"Nickname #{random}\")\n\t\t$group_description.set(\"Description #{random}\")\n\t\t$group_category_living.click\n\t\t$boards_arts_ent_image.when_present.fire_event(\"onclick\")\n\t\t$group_create.click\n\t\t\n\t\tcheckIfIncorrectErrorDisplays\t\n\t\t\n\t\t#edit group type settings\n\t\twait_for_ajax\n \t\tsleep 2\n \t\t$group_basic_information_link.click\n \t\t$group_group_type.click \n \t\twait_for_ajax\n \t\t$group_setting_pre_moderated.click #make blog pre-moderated\n \t\tsleep 2\n \t\t$group_settings_save.click\n \t\tsleep 3\n \t\t\n \t\tassert $browser.text.include? \"group updated successfully\"\n \t\t\n \t\t$group_back_group.click\n \t\twait_for_ajax\n \t\t$browser.text.include? \"Posts awaiting your approval\"\n\tend",
"def create_samples data\n data.each do |line|\n if !line.empty?\n if line[0].include? \"sample\"\n # check and see if this sample exists in inventory\n sample_array = line[0].partition(\":\")\n sample_name = sample_array[2].strip #removes leading and trailing whitespace.\n sample_check = Sample.find_by_name(sample_name)\n if sample_check.nil?\n # create the media\n sample = createMedia(sample_name, \"new sample\", \"media\")\n show do\n title \"Sample Created\"\n \n note \"The sample #{sample_name} has been sucessfully created in Aquarium\"\n end\n end\n end\n end\n end \n \n show do\n title \"Samples Created\"\n \n note \"The samples in #{FILENAME} have been sucessfully created in Aquarium.\"\n note \"Please double check and see if you include the word \\\"sample:\\\" before your sample name.\"\n end\n end",
"def test_basedata\n assert_not_nil(Cardiotype.find(:first, :conditions => [\"description = ?\", \"Run\"]))\n assert_not_nil(Cardiotype.find(:first, :conditions => [\"description = ?\", \"Swim\"]))\n assert_not_nil(Cardiotype.find(:first, :conditions => [\"description = ?\", \"Cycle\"]))\n end",
"def test_presence_of_group_code\n client = Client.new(:name => \"MVG\", :internal_tat => 11 , :tat => 22,\n :partener_bank_group_code => 'HJ', :max_jobs_per_user_payer_wise => 5,\n :max_jobs_per_user_client_wise => 5, :max_eobs_per_job => 5)\n assert_equal(false, client.save, \"Group Code can't be blank!\")\n end",
"def test_number_of_people_in_group\n group_size = @group2.people() #speak to instructor about output\n assert_equal(6, group_size.count)\n end",
"def creating_experimental_media(media_hash)\n media_hash.each { |media, quant|\n log_info 'media', media\n if media != -1\n show {\n title \"Creating Experimental Induction Media\"\n separator\n if media.include? 'Kan'\n check \"In an appropriate container, aliquot <b>#{(quant * 3.3).round(2)}mL</b> of <b>M9 + Kan Media</b> and label: <b>#{MEDIA_LABEL_HASH[media]}</b>\"\n else\n check \"In an appropriate container, aliquot <b>#{(quant * 3.3).round(2)}mL</b> of <b>M9 Media</b> and label: <b>#{MEDIA_LABEL_HASH[media]}</b>\"\n end\n if media.include? 'IPTG'\n check \"To the tube labeled #{MEDIA_LABEL_HASH[media]}, add <b>#{(quant * 3.3 * 0.25).round(2)}µl</b> of <b>1M IPTG</b>\" # calculates inducer per 1mL of media\n end\n if media.include? 'arab'\n check \"To the tube labeled #{MEDIA_LABEL_HASH[media]}, add <b>#{(quant * 3.3 * 25).round(2)}µl</b> of <b>1M Arabinose</b>\" # calculates inducer per 1mL of media\n end\n }\n end\n }\n end",
"def test_media_find_all\n assert_not_nil @rdigg.media.find_all\n end",
"def empty?\n group.empty?\n end",
"def test_group_rule(group_rule, setup_match, remove_match, expected_member_count = 1)\n # Ensure a group has a rule\n group = entities(:groupWithNothing)\n\n assert group.roles.empty?, 'looks like groupWithNothing has a role'\n assert group.rules.empty?, 'looks like groupWithNothing has a rule'\n assert group.owners.empty?, 'looks like groupWithNothing has an owner'\n assert group.operators.empty?, 'looks like groupWithNothing has an operator'\n\n Rails.logger.tagged 'test_group_rule' do\n Rails.logger.debug 'Calling setup ...'\n\n setup_match.call()\n\n # Test basic rule creation matches existing people\n assert group.members.empty?, 'group should have no members'\n\n Rails.logger.debug 'Adding group rule ...'\n group.rules << group_rule\n\n group.reload\n # Subtract a second from the 'updated_at' flag to ensure it is a reliable\n # indicator of a group being touched\n group.updated_at -= 1\n group.save!\n group_last_updated_at = group.updated_at\n\n assert group.members.length == expected_member_count, \"group should have #{expected_member_count} member(s) but has #{group.members.length} member(s)\"\n\n Rails.logger.debug 'Calling remove ...'\n remove_match.call()\n\n Rails.logger.debug 'Checking that group has no members ...'\n group.reload\n assert group.updated_at > group_last_updated_at, 'group should have been touched'\n\n # Subtract a second from the 'updated_at' flag to ensure it is a reliable\n # indicator of a group being touched\n group.updated_at -= 1\n group.save!\n group_last_updated_at = group.updated_at\n assert group.members.empty?, \"group should have no members but has #{group.members.count}\"\n\n Rails.logger.debug 'Calling setup again ...'\n setup_match.call()\n\n group.reload\n assert group.updated_at > group_last_updated_at, 'group should have been touched'\n group_last_updated_at = group.updated_at\n\n assert group.members.length == expected_member_count, \"group should have #{expected_member_count} member(s)\"\n end\n end",
"def fetch_group_data\n response = fetch_data(@@SETTINGS.group_tab)\n unless response.nil?\n adjust_groups response\n end\n end",
"def test_overriding_description\r\n\t\t# first, a feature with no description assigned\r\n\t\tfeatures = Feature.for_static_page(static_pages(:aboutus).id)\r\n\r\n\t\tassert_equal(\"Short description\", features.first[:short_description])\r\n\r\n\t\t# now, a feature with a description to override\r\n\t\tfeatures = Feature.for_category(categories(:livestock).id)\r\n\r\n\t\tassert_equal(\"Different description\", features.first[:short_description])\r\n\tend",
"def load_group group_id, info_level = \"Full\", include_children = \"true\"\n\t\t\t@response = api_request 'LoadGroup', [group_id, info_level, include_children]\n\t\t\traise ZenfolioAPI::ZenfolioAPISessionError, @response['error']['message'] if @response['result'].nil? && @response['error'].length > 0\n\n\t\t\telements = []\n\t\t\t@response['result']['Elements'].each do |element|\n\t\t\t\tif element['$type'] == \"PhotoSet\"\n\t\t\t\t\telements << ZenfolioAPI::Model::Gallery.new(:id => element['Id'], :type => element['$type'], :caption => element['Caption'], \n\t\t\t\t\t\t:created_on => element['CreatedOn']['Value'], :modified_on => element['ModifiedOn']['Value'], :photo_count => element['PhotoCount'],\n\t\t\t\t\t\t:image_count => element['ImageCount'], :video_count => element['VideoCount'], :photo_bytes => element['PhotoBytes'], :views => element['Views'],\n\t\t\t\t\t\t:featured_index => element['FeaturedIndex'], :is_random_title_photo => element['IsRandomTitlePhoto'], :upload_url => element['UploadUrl'],\n\t\t\t\t\t\t:video_upload_url => element['VideoUploadUrl'], :page_url => element['PageUrl'], :mailbox_id => element['MailboxId'], :text_cn => element['TextCn'], \n\t\t\t\t\t\t:photo_list_cn => element['PhotoListCn'], :group_index => element['GroupIndex'], :title => element['Title'], :owner => element['Owner'])\n\t\t\t\telse\n\t\t\t\t\t#group_elements = load_group element['Id']\n\t\t\t\t\telements << ZenfolioAPI::Model::Group.new(:id => element['Id'], :created_on => element['CreatedOn']['Value'], :modified_on => element['ModifiedOn']['Value'], \n\t\t\t\t\t\t:page_url => element['PageUrl'], :mailbox_id => element['MailboxId'], :immediate_children_count => element['ImmediateChildrenCount'], :text_cn => element['TextCn'], \n\t\t\t\t\t\t:caption => element['Caption'], :collection_count => element['CollectionCount'], :sub_group_count => element['SubGroupCount'], :gallery_count => element['GalleryCount'],\n\t\t\t\t\t\t:featured_index => element['FeaturedIndex'], :is_random_title_photo => element['IsRandomTitlePhoto'], :upload_url => element['UploadUrl'],\n\t\t\t\t\t\t:photo_count => element['PhotoCount'], :parent_groups => element['ParentGroups'], :title => element['Title'])\n\t\t\t\tend\n\t\t\tend\n\n\t\t\t@group = ZenfolioAPI::Model::Group.new(:id => @response['result']['Id'], :created_on => @response['result']['CreatedOn']['Value'], :modified_on => @response['result']['ModifiedOn']['Value'], \n\t\t\t\t:page_url => @response['result']['PageUrl'], :mailbox_id => @response['result']['MailboxId'], :immediate_children_count => @response['result']['ImmediateChildrenCount'], \n\t\t\t\t:text_cn => @response['result']['TextCn'], :caption => @response['result']['Caption'], :collection_count => @response['result']['CollectionCount'], \n\t\t\t\t:sub_group_count => @response['result']['SubGroupCount'], :gallery_count => @response['result']['GalleryCount'], :featured_index => @response['result']['FeaturedIndex'], \n\t\t\t\t:is_random_title_photo => @response['result']['IsRandomTitlePhoto'], :upload_url => @response['result']['UploadUrl'], :photo_count => @response['result']['PhotoCount'], \n\t\t\t\t:parent_groups => @response['result']['ParentGroups'], :title => @response['result']['Title'], :elements => elements)\n\n\t\t\t@group\n\t\tend"
] | [
"0.6571844",
"0.6249539",
"0.618921",
"0.6072438",
"0.5932298",
"0.5918369",
"0.5862924",
"0.5860587",
"0.58422035",
"0.58410794",
"0.5837634",
"0.5801118",
"0.5771843",
"0.5769351",
"0.57549065",
"0.57511306",
"0.57511306",
"0.57511306",
"0.57490784",
"0.57428426",
"0.5741676",
"0.57364416",
"0.56470454",
"0.56439537",
"0.5640437",
"0.5582899",
"0.5582899",
"0.5582899",
"0.5581343",
"0.55704474",
"0.5562983",
"0.5562393",
"0.55543196",
"0.5550488",
"0.55485463",
"0.55450493",
"0.55417705",
"0.5522881",
"0.5517863",
"0.5517068",
"0.5515572",
"0.55096215",
"0.5488411",
"0.54652596",
"0.54388005",
"0.5435403",
"0.5428507",
"0.5425995",
"0.5422911",
"0.54182464",
"0.54174596",
"0.54123634",
"0.54000175",
"0.5379882",
"0.5376417",
"0.53713787",
"0.5358733",
"0.53515613",
"0.5349218",
"0.5346023",
"0.5341695",
"0.5329056",
"0.5319882",
"0.53157735",
"0.5313158",
"0.5309553",
"0.5303318",
"0.52994347",
"0.529124",
"0.52863306",
"0.5280892",
"0.5265846",
"0.5261558",
"0.52560157",
"0.52459866",
"0.524438",
"0.5243782",
"0.52386105",
"0.5238552",
"0.5236398",
"0.5232289",
"0.522438",
"0.5221473",
"0.52214116",
"0.52214116",
"0.5220579",
"0.5216944",
"0.5192714",
"0.5192249",
"0.5191963",
"0.5185567",
"0.51794046",
"0.51767486",
"0.5165832",
"0.51634324",
"0.51540434",
"0.5148736",
"0.5147858",
"0.51407516",
"0.51381654"
] | 0.5643465 | 24 |
Operation that the IP currently points to | def op
sequence[ip]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ip; end",
"def ip; end",
"def check_ip; end",
"def regist_ip\n puts 'Registering IP address of this node'\n\n sock = TCPSocket.open($leader_ip)\n sock.write(\"regist\")\n ret_ip = sock.gets\n sock.close\n return ret_ip\n end",
"def ip\n @actions << :ip\n self.class.mocked_ip\n end",
"def ip_lkup(ip)\n send_req({a: :ip_lkup, ip: ip})\n end",
"def ip\n self.IP\n end",
"def ipaddr?; end",
"def send_change_ip(new_ip)\n @conn.send_msg({ :type => 'change_ip', :client => @current_name, :ip_old => @current_ip, :ip_new => new_ip }.to_json)\n @current_ip == new_ip\n end",
"def ipaddr; end",
"def set_current_ip(ip)\n @ip = ip\n end",
"def remote_ip; end",
"def ip\n @vps.ip \n end",
"def local_ip\n\nend",
"def ip\n TestLab::Utility.ip(self.address)\n end",
"def jump(loc)\n @ip = loc\n end",
"def jump(loc)\n @ip = loc\n end",
"def jump(loc)\n @ip = loc\n end",
"def getIp()\n return @ip\n\tend",
"def check_address(ip)\n @r.rule(:check, src: ip, chain: @allow, jump: 'ACCEPT').do?\n end",
"def check_address(ip)\n @r.rule(:check, src: ip, chain: @allow, jump: 'ACCEPT').do?\n end",
"def update_kvm_ip(name)\n new_ip = (available_ips - used_ips).pop\n raise 'no ips available' unless new_ip\n update_network_interfaces(name, new_ip)\n new_ip\nend",
"def ip\n TestLab::Utility.ip(self.address)\n end",
"def release_address!(public_ip)\n action = 'ReleaseAddress'\n params = {\n 'Action' => action,\n 'PublicIp' => public_ip\n }\n\n response = send_query_request(params)\n response.is_a?(Net::HTTPSuccess)\n end",
"def get_ip(ip)\n\n #Recorremos todas las reservaciones del usuario\n Reservation.all.each do |reservation|\n #Si la ip de la reservacion es igual a la ip solicitante y tiene un asiento reservado\n # entonces le asigna una ip\n if reservation.ip == ip && (reservation.seat.reserved)\n #se le asigna una nueva ip\n ip = get_ip(add_number(ip))\n end\n end\n return ip\n end",
"def update_ip(ip, url, membersite, username, password)\n result = \"\"\n Net::HTTP.start(url) {|http|\n req = Net::HTTP::Get.new(\"/nic/update?hostname=#{membersite}&myip=#{ip}&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG\")\n req.basic_auth username, password\n req.add_field 'User-Agent', 'simpleddns'\n response = http.request(req)\n result = response.body\n }\n return result\nend",
"def release_address(public_ip)\n address = address(public_ip)\n\n if address.instance_id.nil?\n action = 'ReleaseAddress'\n params = {\n 'Action' => action,\n 'PublicIp' => public_ip\n }\n\n response = send_query_request(params)\n response.is_a?(Net::HTTPSuccess)\n else\n raise 'Address is currently allocated' #FIXME: Add a proper Awsum error here\n end\n end",
"def release\n requires :ip\n raise Fog::Errors::Error.new('You can\\'t release a ip that is attached to a server') if attached?\n service.ip_release(\n :ipaddress => identity\n )\n end",
"def ip\n super\n end",
"def device_ipaddress=(_arg0); end",
"def device_ipaddress=(_arg0); end",
"def my_ip\n get(\"/tools/myip\")\n end",
"def wip\n end",
"def release_address(public_ip)\n link = generate_request(\"ReleaseAddress\", \n \"PublicIp\" => public_ip.to_s)\n request_info(link, RightBoolResponseParser.new(:logger => @logger))\n rescue Exception\n on_exception\n end",
"def release_address(public_ip)\n link = generate_request(\"ReleaseAddress\", \n \"PublicIp\" => public_ip.to_s)\n request_info(link, RightBoolResponseParser.new(:logger => @logger))\n rescue Exception\n on_exception\n end",
"def ip_address; end",
"def ip_address; end",
"def ip_address; end",
"def ip_address; end",
"def ip_address; end",
"def ip_address; end",
"def set_ip\n @ip = get_ip(request.remote_ip.to_s)\n end",
"def after_ip_authentication(_remote_ip); end",
"def accessipv4\n @instance.accessipv4\n end",
"def set_ip_address\n @ip_address = IpAddress.find(params[:id])\n end",
"def update_ip\n ip = ip_from_request_env\n logger.debug \"Built notice from #{ip}, current host ip is #{@host.ip}, updating\" if @host.ip != ip\n\n # @host has been changed even if the save fails, so we have to change it back\n old_ip = @host.ip\n @host.ip = old_ip unless @host.update_attributes({'ip' => ip})\n end",
"def ip_exist?\n return false if current_resource.addresses.nil?\n current_resource.addresses.include?(new_resource.address)\n end",
"def ping(ip)\n @logger.debug(\"ping from #{ip}\")\n \"pong\"\n end",
"def next_ip\n\t\t@ip_pos += 1\n\t\t@ip_pos = 0 if @ip_pos >= @arry_ips.length\n\tend",
"def ip\n nil\n end",
"def device_ipaddress; end",
"def device_ipaddress; end",
"def ip\n @data[\"ip\"]\n end",
"def addr(*) end",
"def addr(*) end",
"def peerip=(_arg0); end",
"def authorize_ip_address(ip)\n authorize_cidrip(\"#{ip}/32\")\n end",
"def increment(count)\n @ip += count\n end",
"def increment(count)\n @ip += count\n end",
"def increment(count)\n @ip += count\n end",
"def reverse_ip(ipaddress)\n reverse_ip = IPAddr.new ipaddress\n reverse_ip.reverse\nend",
"def get_ip(node)\n provisioning.ipaddress(node)\n end",
"def check\n uri = URI.parse(\"https://ifconfig.co/ip\")\n begin\n response = Net::HTTP.get_response(uri)\n if response.code == \"200\" || response.code == 200\n current_ip = \"#{response.body}\".strip\n saved_ip = \"#{read_current_ip}\".strip\n if current_ip != saved_ip\n logger.log(\"New IP: #{current_ip}\")\n slack_notifier.log(\"New IP: #{current_ip}\")\n write_current_ip(current_ip)\n end\n else\n logger.log(\"Cannot Reach ifconfig.co\")\n end\n rescue => e\n logger.log(\"Error checking IFCONFIG\")\n logger.log(\"#{e.inspect}\")\n end\n nil\n end",
"def ip?(ip_or_name)\n # Get address always returns an IP, so if nothing changes this was one\n Resolv.getaddress(ip_or_name) == ip_or_name\n rescue Resolv::ResolvError\n false\n end",
"def set_ip_adress\n @ip_adress = IpAddress.find(params[:id])\n end",
"def ipn_endpoint=(_arg0); end",
"def get_ipaddress(asset_tag=asset_tag, pool)\n @connection.ipaddress_allocate!(asset_tag, pool, count = 1)\n end",
"def ip\n ''\n end",
"def ip\n @values.fetch('ai.device.ip') { \n @values['ai.device.ip'] = nil\n }\n end",
"def update\n @ip = AllowedIpAddress.find(params[:id])\n\n respond_to do |format|\n if @ip.update_attributes(params[:ip])\n flash[:notice] = 'Host was successfully updated.'\n format.html { redirect_to allowed_ip_address_path(@ip) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @ip.errors.to_xml }\n end\n end\n end",
"def hander_ip method,ip,vlan_ip_hash = nil\n\t\tmethod = method.to_sym\n\t\tpath = \"/network/vlan/ip/#{ip}\"\n\t\tparams_hash = nil\n\t\tparams_hash = {:ModifyVlanIpRequest => vlan_ip_hash} if method == :put\n\t\tres,req = Connection.restreq method,path,params_hash,true\n\tend",
"def add_forward_lookup(_ip, _hostname)\n end",
"def ip_reachable?(ip)\n external = Net::Ping::External.new(ip)\n\n log_info %(attempting to contact host \"#{ip}\")\n reachable = external.ping || external.ping6\n if reachable\n log_success %(host \"#{ip}\" is reachable)\n else\n log_error %(unable to contact host \"#{ip}\")\n end\n\n reachable\n end",
"def set_IP(value)\n set_input(\"IP\", value)\n end",
"def get_ip_address \t\t\t\n\t\trequest.remote_ip \n\tend",
"def next_ip\n\t\treturn false if not valid?\n\t\tif (@curr_addr > @ranges[@curr_range][1])\n\t\t\tif (@curr_range >= @ranges.length - 1)\n\t\t\t\treturn nil\n\t\t\tend\n\t\t\t@curr_range += 1\n\t\t\t@curr_addr = @ranges[@curr_range][0]\n\t\tend\n\t\taddr = Rex::Socket.addr_itoa(@curr_addr, @ranges[@curr_range][2])\n\t\t@curr_addr += 1\n\t\treturn addr\n\tend",
"def ipn_endpoint; end",
"def ipn_endpoint; end",
"def release_public_ip params\n params.to_sym!\n\n vn = onblock(:vn, params[:vn], @client)\n vn.info!\n\n if vn.rm_ar(params[:ar]).nil? then\n AR.where(vnid: params[:vn], arid: params[:ar], owner: vn['//UID']).update(etime: Time.now.to_i)\n true\n else\n false\n end\n end",
"def current_ip(inter)\n net_info = `ifconfig`\n section_index = net_info.index(inter)\n line_index = net_info.index('inet', section_index)\n ip_address = net_info[line_index..-1].match(/\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}/)[0]\n return ip_address\nend",
"def nodeIP(num)\n return \"10.17.4.#{num+200}\"\nend",
"def ping\n\t\tputs \"Pinging #{@ip} ...\"\n\t\tsystem \"ping #{ip_string}\"\n\tend",
"def ping()\n #This is a stub, used for indexing\n end",
"def index\n \n @ip_joins = @ipobject.saveIP(@virtualmachine.RemoteID,@virtualmachine.id)\n @ipaddresses = @virtualmachine.ipaddresses\n end",
"def ping()\n #This is a stub, used for indexing\n end",
"def remove_ip(ip)\n send_req({a: :nul, key: ip})\n end",
"def change_ip\n self.connect\n self.authenticate self.password\n send_command(:signal, 'NEWNYM')\n self.close\n end",
"def save_ip_addr\n self.ip_address = IPAddr.new(self.ip_address).to_i.to_s(16).rjust(8, \"0\")\n end",
"def peer_ip; end",
"def after_ip_authentication\n end",
"def set_ip_name\n @ip_name = IpName.find(params[:id])\n end",
"def &(in_ip)\n raise RuntimeError, \"Can not compare IPV4 with IPV6!\" if @version != in_ip.version\n Ip.new(@ip_int & in_ip.to_i, @version)\n end",
"def ip?\n return (proto == 'ip')\n end",
"def next_assigned\n Ip.find(:first, :conditions => \n ['address_i > ? AND service = ? and network_id is not null', self.address_i, self.service], :order => 'address_i asc')\n end",
"def SetIp(node)\n \tnode.GetInterfaces().each do |ifn|\n\t self.GetGroupInterface(node, ifn).ip=\"1.1.1.1\"\n \t #self.GetGroupInterface(node, ifn).up\n\tend\n end",
"def ip\n self['ip'] = get_public_ip || get_ip\n end",
"def rcptto(to_addr); end",
"def ip\n unless @vm\n warn 'No Vm assigned to locate IP'\n return\n end\n @ip ||= detect_ip\n end",
"def public_ip() ; info[:public_ip] ; end",
"def resolve(adr)\n adr.ip = program.size\n end"
] | [
"0.645203",
"0.645203",
"0.64207983",
"0.6293085",
"0.626267",
"0.60952765",
"0.6078643",
"0.6076898",
"0.6049108",
"0.6030761",
"0.6026945",
"0.599994",
"0.598811",
"0.59868735",
"0.59730214",
"0.59614176",
"0.59614176",
"0.59614176",
"0.5916549",
"0.5894968",
"0.5894968",
"0.58720595",
"0.5869189",
"0.58593327",
"0.5848215",
"0.58365124",
"0.5814121",
"0.579736",
"0.5775756",
"0.5771669",
"0.5771669",
"0.5754175",
"0.57391447",
"0.5726832",
"0.5726832",
"0.571935",
"0.571935",
"0.571935",
"0.571935",
"0.571935",
"0.571935",
"0.5712423",
"0.57104594",
"0.56965566",
"0.568604",
"0.56790733",
"0.5673955",
"0.56644106",
"0.5655442",
"0.5647673",
"0.5640032",
"0.5640032",
"0.5621335",
"0.56162745",
"0.56162745",
"0.56109643",
"0.56062716",
"0.5591109",
"0.5591109",
"0.5591109",
"0.55783474",
"0.5555755",
"0.5537054",
"0.55368",
"0.5519606",
"0.5517519",
"0.5511546",
"0.55093",
"0.5503936",
"0.5501263",
"0.54979664",
"0.54957306",
"0.5489991",
"0.5489171",
"0.5488284",
"0.54841185",
"0.547709",
"0.547709",
"0.5476334",
"0.54703975",
"0.5465465",
"0.54561883",
"0.54534954",
"0.5449302",
"0.5441787",
"0.5427776",
"0.5421951",
"0.54209465",
"0.5415263",
"0.5409404",
"0.5408251",
"0.5405563",
"0.5400838",
"0.5400111",
"0.53992224",
"0.537943",
"0.53630644",
"0.5357277",
"0.53444225",
"0.53416073"
] | 0.64821863 | 0 |
Access memory at the provided location | def [](loc)
sequence[loc]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read(off, sz=4096); Ragweed::Wrap32::read_process_memory(@h, off, sz); end",
"def get_object(offset)\n io = to_shm_io\n io.seek(offset)\n Marshal.load(io)\n end",
"def read_memory(address)\n # nes.memory.readWord(address)\n # Memory Manager readWord above\n # return read(address) | (read(address + 1) << 8);\n end",
"def fetch_memory(address)\n # カートリッジのアドレス空間から取得\n if address < 0x8000\n @cartridge[address]\n elsif 0x8000 <= address && \n end\n end\n end",
"def memread(address, size, buffer = nil)\n if buffer.nil?\n return railgun.memread(address, size)\n else\n return buffer[address .. (address + size - 1)]\n end\n end",
"def fetch(name, offset=0)\n addr = pfa(name)\n @vm.fetch(addr + cells(offset))\n end",
"def read(address)\n check_address(address)\n @storage[address]\n end",
"def read_pointer(buffer, offset = 0)\n unpack_pointer(buffer[offset, (offset + pointer_size)])\n end",
"def read_memory(addr, num_elements, options = {}, &block)\n check_alive! # this would set @pid\n options[:as] = block if block_given?\n MemoryIO.attach(@pid).read(addr, num_elements, **options)\n end",
"def peek\n @emulator.memory.fetch(@sp)\n end",
"def read_at (pos)\r\n @data[pos]\r\n end",
"def memadr; RAtlas::memadr(@storage);end",
"def read( addr )\n row_idx, col_idx = address_to_indices( addr )\n return nil if row_idx > rows\n @data[ row_idx-1 ][ col_idx-1 ]\n end",
"def read_pointer\n to_ptr.ptr\n end",
"def at(pos)\n pos = pos.to_int\n\n if 0 <= pos && !has_size?\n return read_access(pos)\n elsif 0 <= pos && pos < size\n return read_access(pos)\n elsif -size <= pos && pos < 0\n return read_access(size + pos)\n else\n return nil\n end\n end",
"def get_memory(i, opts={})\r\n refresh opts\r\n read(@memlist[i][0], @memlist[i][1])\r\n end",
"def get_pointer_at(index)\n IO.binread(@path, POINTER_SIZE, HEADER_SIZE + POINTER_SIZE * index).unpack(\"N\").first\n end",
"def get_addr(mem, m, index, rb)\n # position mode\n if m == 0\n return mem[index]\n end\n\n # relative base mode\n if m == 2\n return mem[index] + rb\n end\n\n puts \"💥 Error, unsupported mode, abort mission 💥\"\n\n return 0\nend",
"def read_process_memory(h, ptr, len)\r\n val = \"\\x00\" * len\r\n r = CALLS[\"kernel32!ReadProcessMemory:LLPLL=L\"].call(h, ptr.to_i, val, len, NULL)\r\n raise WinX.new(:read_process_memory) if r == 0\r\n return val ## don't handle short reads XXX\r\n end",
"def print_pointer_location(ptr, t)\n if t.respond_to? :get_area_memlocation\n page_number = (ptr.size.to_f / $page_size).ceil\n base_address = ptr.address - ( ptr.address % $page_size )\n ptrs = page_number.times.collect { |i|\n FFI::Pointer::new(base_address + i*$page_size).slice(0, $page_size)\n }\n ptrs.each { |ptr|\n p t.get_area_memlocation(ptr, :MEMBIND_BYNODESET)\n }\n else\n puts \"pagemap #{Process::pid} -n #{ptr.address.to_s(16)}-#{(ptr.address+ptr.size-1).to_s(16)}\"\n puts `pagemap #{Process::pid} -n #{ptr.address.to_s(16)}-#{(ptr.address+ptr.size-1).to_s(16)}`\n end\nend",
"def memory\n mem = @memory\n @memory = nil\n return mem\n end",
"def [](loc, idx)\n case flag(idx)\n when :immediate then loc\n when :position then read(loc)\n when :relative then read(loc + relative_base)\n end\n end",
"def read(address)\n tag, slot_num, block_offset = split_address(address)\n slot = @slots[slot_num.to_i(16)]\n hit_miss = hit_miss(slot, tag)\n if hit_miss == \"hit\"\n value = slot.saved_blocks[block_offset.to_i(16)]\n else\n value = @main_memory.content[address.to_i(16)]\n range = (tag + slot_num + \"0\").to_i(16)..(tag + slot_num + \"F\").to_i(16)\n write_to_slot(slot, tag, @main_memory.content[range])\n end\n return value, hit_miss\n end",
"def load(ptr)\n if [email protected]_key?(ptr)\n raise \"Address #{ptr} was never allocated!\"\n end\n\n @store[ptr]\n end",
"def read(location)\n # We don't need to establish a lock while reading, but we don't want to read if\n # a lock has already been established (e.g. by a write process).\n raise Hyacinth::Exceptions::LockError, \"Cannot read #{location} because it is locked by another process.\" if Hyacinth::Config.lock_adapter.locked?(location)\n storage_adapter_for_location(location).read(location)\n end",
"def value_with_addr(block_num = nil)\n\t\t\t\tblock_num ||= @auth_block\n \traise Mifare::Error, \"Not authenticated\" unless block_num\n\n\t\t\t\tvalue_ptr = FFI::MemoryPointer.new(:int32, 1)\n\t\t\t\taddr_ptr = FFI::MemoryPointer.new(:uchar, 1)\n\t\t\t\tres = Mifare.mifare_classic_read_value(@pointer, block_num, value_ptr, addr_ptr)\n raise Mifare::Error, \"Can't read value block 0x%02x\" % block_num if 0 != res\n\n\t\t\t\t[value_ptr.get_int32(0), addr_ptr.get_uchar(0)]\n end",
"def mem=(p0) end",
"def get_data_at(index)\n $test_logger.log(\"Get data from location #{index}\")\n raise \"No data available\" if !@data\n raise \"No data found at index '#{index}'\" if @data.length<index+1 \n BioPacket.swap_dword(@data[index])\n end",
"def call_in(reg_key, addr, i_reg, device_num)\n to_addr = get_mem_addr(addr, i_reg)\n dev = @computer.get_device(device_num)\n word = dev.read\n @computer.memory.write(to_addr, word)\n end",
"def [](*args) \n # TODO: change args from vma to offset!\n contents.[](*args)\n end",
"def read(offset, how_much)\n @str[offset, how_much]\n end",
"def read(offset, how_much)\n @str[offset, how_much]\n end",
"def store_word(loc,out_register,offset)\n\t#Get Location in memory.\n\tlocation = (offset+REGISTERS[loc])/4\n\tsetnum = getSet(location).to_i(2)\n\ttag = getTag(location).to_i(2)\n\t#Hit Block 1?\tIf Hit: UPDATE CACHE\n\tif((CACHE[setnum.to_i][0]).tag == tag && (CACHE[setnum.to_i][0]).valid == 1)\n\t\t(CACHE[setnum.to_i][0]).data = REGISTERS[out_register]\n\t\tprint \"hit\\n\"\n\t#Hit Block 2?\tIf Hit: UPDATE CACHE\n\telsif((CACHE[setnum.to_i][1]).tag == tag && (CACHE[setnum.to_i][0]).valid == 1)\n\t\t(CACHE[setnum.to_i][1]).data = REGISTERS[out_register]\n\t\tprint \"hit\\n\"\t\t\n\telse\n\t\t#If Miss:UPDATE MEMORY\n\t\tprint \"miss\\n\"\n\t\t#Store register value in memory.\n\t\tMAIN_MEMORY[location] = REGISTERS[out_register]\n\tend\nend",
"def cell(loc)\n @map[loc]\n end",
"def memory\n return (@lead != nil ? @lead.ai.memory : @memory)\n end",
"def mem(*) end",
"def [] index\n if index.class != Fixnum or index >= 2**(@mar.length) or index < 0\n raise ArgumentError.new \"wrong address #{ index.inspect }\"\n end\n\n return Array.new(@mdr.length, 0) if @memory[index].nil?\n @memory[index]\n end",
"def read(vaddr)\n st_entry = @segment_table.get_segment(vaddr.segment)\n return \"pf\" if st_entry == -1\n return \"err\" if st_entry == 0\n\n pt = $frames.get_word(st_entry / 512)\n\n pt_entry = pt.get_page(vaddr.page)\n return \"pf\" if pt_entry == -1\n return \"err\" if pt_entry == 0\n\n $tlb.add(vaddr, pt_entry)\n pt_entry + vaddr.offset\n end",
"def [] address\n @content[address]\n end",
"def memory\n\t\treturn self.class.instance_variable_get(:@memory)\n\tend",
"def [](offset)\n iterator = self.iterator\n iterator[offset]\n end",
"def read_at_offset(offset, size)\n return nil unless offset < @size && (offset + size) <= @size\n\n data_file = data_file_for_offset(offset)\n data_file.file.seek(offset - data_file.offset)\n data_file.file.read(size)\n end",
"def [](offset, size = nil)\n seek offset\n read size\n end",
"def at(position)\n self[position]\n end",
"def initial_address(memory, process)\n initial_address = nil\n memory.each_with_index {|elem, index|\n next unless elem.nil?\n memory_slot = memory[index, process.memory_blocks]\n break if memory_slot.size < process.memory_blocks\n return index if memory_slot.all?(&:nil?)\n }\n initial_address\n end",
"def ram_read size = 1\n pc = registers[:eip].value\n read = ram[pc, size]\n\n registers[:eip].value += size\n\n read\n end",
"def ptr\n TestLab::Utility.ptr(self.address)\n end",
"def read(base, length)\n request = Packet.create_request(COMMAND_ID_STDAPI_SYS_PROCESS_MEMORY_READ)\n\n request.add_tlv(TLV_TYPE_HANDLE, process.handle)\n request.add_tlv(TLV_TYPE_BASE_ADDRESS, base)\n request.add_tlv(TLV_TYPE_LENGTH, length)\n\n response = process.client.send_request(request)\n\n return response.get_tlv_value(TLV_TYPE_PROCESS_MEMORY)\n end",
"def get_operand(memory)\n op = @operands.pop\n if op.is_a?(Memory::Value) || op.is_a?(VarAccess)\n op\n elsif op.is_a? Memory::Entry\n VarAccess.new addr: op.addr, is_temp: op.is_temp\n else\n entry = memory.get op[:name]\n VarAccess.new addr: entry.addr, index: op[:index]\n end\n end",
"def jump(x)\n @memory_position = x\n end",
"def memory\n case @game.view\n when :world_map\n current_memory = :world_map\n when :current_map\n current_memory = @game.world_map.current_seed\n end\n \n if !@memory[current_memory]\n map = @game.map\n @memory[current_memory] = Matriz.new(map.width, map.height, false) \n end\n\n return @memory[current_memory]\n end",
"def memory(arg=nil)\n set_or_return(:memory, arg, :kind_of => Integer)\n end",
"def at(p0) end",
"def tell\n @offset\n end",
"def unit_at(x,y)\n cell = @cells.find {|cell| cell.x == x and cell.y == y }\n cell.unit.view if cell\n end",
"def load_word(loc,in_register,offset)\n\t#Loads from memory with offset into memory[register location]\n\t#Get Location in memory.\n\tlocation = (offset+REGISTERS[loc])/4\n\tsetnum = getSet(location).to_i(2)\n\ttag = getTag(location).to_i(2)\n\t#Hit Block 1? If so use it.\n\tif((CACHE[setnum.to_i][0]).tag == tag && (CACHE[setnum.to_i][0]).valid == 1)\n\t\tprint \"hit\\n\"\n\t\tREGISTERS[in_register] = (CACHE[setnum.to_i][0]).data\n\t#Hit Block 2? If so use it.\n\telsif((CACHE[setnum.to_i][1]).tag == tag && (CACHE[setnum.to_i][0]).valid == 1)\n\t\tprint \"hit\\n\"\n\t\tREGISTERS[in_register] = (CACHE[setnum.to_i][1]).data\t\n\telse\n\tprint \"miss\\n\"\n\t#No Hits, Then move to CACHE and then load into the register.\n\t\t#If left is LRU\n\t\tif(LRU[setnum.to_i] == 0)\n\t\t\tLRU[setnum.to_i] = 1\n\t\t\t(CACHE[setnum.to_i][0]).valid = 1\n\t\t\t(CACHE[setnum.to_i][0]).tag = tag\n\t\t\t(CACHE[setnum.to_i][0]).data = MAIN_MEMORY[location]\n\t\t\tREGISTERS[in_register] = (CACHE[setnum.to_i][0]).data\n\t\telse\n\t\t#If right is LRU\n\t\t\tLRU[setnum.to_i] = 0\n\t\t\t(CACHE[setnum.to_i][1]).valid = 1\n\t\t\t(CACHE[setnum.to_i][1]).tag = tag\n\t\t\t(CACHE[setnum.to_i][1]).data = MAIN_MEMORY[location]\n\t\t\tREGISTERS[in_register] = (CACHE[setnum.to_i][1]).data\t\t\t\n\t\tend\n\tend\nend",
"def memory()\n\n instructions = 'free -h'\n\n puts ('instructions: ' + instructions.inspect).debug if @debug\n r = @ssh ? @ssh.exec!(instructions) : `#{instructions}`\n puts ('memory: ' + r.inspect).debug if @debug\n a = r.lines\n total, used, avail = a[1].split.values_at(1,2,-1) \n @results[:memory] = {total: total, used: used, available: avail}\n\n end",
"def lookup(obj, pos)\n @cache[pos][obj.object_id] \n end",
"def eval_memory_expression\n Assam.logger.debug \"Starting memory access...\"\n\n case ram_read\n when DIRECT\n # Direct memory reference, just read a memory address from RAM and\n # return it.\n value = ram_read(address_size)\n\n Assam.logger.debug \"Direct memory access. Read: #{value}\"\n return value\n when REGISTER\n # Register reference. Read the register code from memory, look it up in\n # the register table and return the value.\n register = register_codes[ram_read]\n\n if register.nil?\n raise \"Attempted to access a register that does not exist.\"\n else\n Assam.logger.debug \"Register value memory access. Read: #{register.value}\"\n return register.value\n end\n when EXPRESSION\n size = ram_read\n pc = MemoryLocation.from(registers[:eip])\n initial_pc = pc.read\n expression = []\n\n # Read the expression up until the size has been reached.\n until pc.read == (initial_pc + size)\n case ram_read\n when REGISTER\n expression << register_codes[ram_read].value\n when DIRECT\n expression << ram_read(address_size)\n when MEM_ADD\n expression << :+\n when MEM_SUB\n expression << :-\n when MEM_MUL\n expression << :*\n end\n end\n\n Assam.logger.debug \"Memory expression disassembled: #{expression}\"\n\n # We want to find if there's a multiplier and then group it with its\n # left and right operands so it gets evaluated in the correct\n # precedence.\n mul = expression.find_index :*\n\n # Messyish bit of code but all it does is turn something like:\n # [1, :+, 2, :*, 3]\n #\n # Into:\n #\n # [1, :+, 6]\n if mul\n # Grab the left and right sides of the expression.\n left = expression[mul - 1]\n right = expression[mul + 1]\n\n # Multiply them and insert them back into the expression.\n expression[(mul - 1)..(mul + 1)] = left * right\n end\n\n # Initialise the memory_location to the first value in expression.\n memory_location = expression.shift\n\n # Loop over the rest of the expression two elements at a time, modifying\n # the memory location appropriately as we go along.\n expression.each_slice(2) do |op, val|\n memory_location = memory_location.send(op, val)\n end\n\n Assam.logger.debug \"Calculated memory expression to refer to \" +\n \"0x#{memory_location.to_s(16)} which currently holds the value \" +\n \"0x#{ram[memory_location, 1]}\"\n return memory_location\n end\n end",
"def locate(address)\n do_locate(address, false)\n end",
"def read(offset, len)\n _isource.read(offset, len)\n end",
"def read_and_free(pointer)\n result = pointer.to_s\n pointer.free\n result\n end",
"def read_and_free(pointer)\n result = pointer.to_s\n pointer.free\n result\n end",
"def memory(name = nil)\n if name.nil?\n data_for_server[:memory]\n else\n @memory[name] ||\n @memory[name.is_a?(String) ? name.to_sym : String(name)]\n end\n end",
"def read(y, x)\n cy, cx = Vedeu::Geometry::Position[y, x].as_indices\n\n row = fetch(cells, cy)\n cell = fetch(row, cx)\n\n cell\n end",
"def get_at(point)\n board[coords_to_pos(point)]\n end",
"def pointer\n\n @pointer\n end",
"def read(offset, size)\n @file.seek(@offset + offset, IO::SEEK_SET)\n @file.read(size)\n end",
"def get_mem\n lines = `free -m`.split(\"\\n\")\n header = lines[0]\n w_cache = lines[1].split(/\\s+/)[2].to_i\n mem = lines[2].split(/\\s+/)[2].to_i\n [mem, w_cache]\n end",
"def memory_view(cols = nil,start_at = 8,end_at = 43808,skip_empties = false)\n cols = @memory_view_width\n str = \"\"\n puts Benchmark.measure {\n tag_open = \"\"\n bytes_left = -1\n empty_row = Array.new(cols,0)\n mem_address = start_at\n row_index = 0\n while mem_address <= end_at\n #row = @vm.memory[mem_address..(mem_address+cols)]\n row = @vm.memory.raw_read(mem_address...(mem_address+cols))\n next if skip_empties && row == empty_row\n row_address = start_at + (row_index * cols)\n mem_hex = \"\"\n str << %(<tr class=\"memory_row_address_#{row_address}\"><td class=\"address\">#{row_address}</td><td>)\n row.bytes.each_with_index{ |b,i|\n address = row_address + i\n\n if @vm.allocations[address]\n #bytes_left = Vm::TYPE_SIZES[ @vm.allocations[address][0] ]\n bytes_left = 4 # vars in memory are always 32-bit ints/floats?\n classes = \"allocated hl_address hl_address_#{address} data_type_#{@vm.allocations[address][0]} allocation_id_#{@vm.allocations[address][1]}\"\n bytes = @vm.read(address,bytes_left)\n native = @vm.arg_to_native(@vm.allocations[address][0],bytes)\n tag_open = %(<a class=\"#{classes}\" href=\"#\" data-native=\"#{native}\" data-bytes=\"#{hex(bytes)}\" data-data_type=\"#{@vm.allocations[address][0]}\" data-allocation_id=\"#{@vm.allocations[address][1]}\" data-address=\"#{address}\">)\n str << tag_open\n elsif i == 0 && bytes_left > 0\n str << tag_open\n end\n\n bytes_left -= 1\n str << %(<span class=\"address_#{address} hl_address hl_address_#{address}\">) << hex(b) << %(</span>)\n\n if bytes_left == 0 || bytes_left > 0 && i == cols-1\n str << \"</a>\"\n end\n\n str << \" \"\n }\n str << %(</td></tr>\\n)\n mem_address += cols\n row_index += 1\n end\n }\n str\n end",
"def query(base)\n request = Packet.create_request(COMMAND_ID_STDAPI_SYS_PROCESS_MEMORY_QUERY)\n\n request.add_tlv(TLV_TYPE_HANDLE, process.handle)\n request.add_tlv(TLV_TYPE_BASE_ADDRESS, base)\n\n response = process.client.send_request(request)\n\n # Build out the hash from the response information\n info = {}\n\n info['BaseAddress'] = response.get_tlv_value(TLV_TYPE_BASE_ADDRESS)\n info['AllocationBase'] = response.get_tlv_value(TLV_TYPE_ALLOC_BASE_ADDRESS)\n info['AllocationProtect'] = specific_prot_to_gen(response.get_tlv_value(TLV_TYPE_ALLOC_PROTECTION))\n info['RegionSize'] = response.get_tlv_value(TLV_TYPE_LENGTH)\n\n # Translate the memory state\n state = response.get_tlv_value(TLV_TYPE_MEMORY_STATE)\n\n if (state == MEM_FREE)\n info['Available'] = true\n elsif (state == MEM_COMMIT)\n info['Available'] = false\n elsif (state == MEM_RESERVE)\n info['Reserved'] = true\n end\n\n # Translate the region protections\n info['Protect'] = specific_prot_to_gen(response.get_tlv_value(TLV_TYPE_PROTECTION))\n\n # Translate the memory type\n type = response.get_tlv_value(TLV_TYPE_MEMORY_TYPE)\n\n if (type == MEM_IMAGE)\n info['ImageMapping'] = true\n elsif (type == MEM_MAPPED)\n info['MemoryMapping'] = true\n elsif (type == MEM_PRIVATE)\n info['PrivateMapping'] = true\n end\n\n return info\n end",
"def read(key)\n key.freeze if key.is_a? String\n\n if @memory_store.has_key? key\n @memory_store[key]\n else\n @file_store.transaction do\n @memory_store[key] = @file_store[key]\n end\n @memory_store[key]\n end\n end",
"def at(pos)\n @map[pos]\n end",
"def set_memory\n @memory = Memory.find(params[:id])\n end",
"def set_memory\n @memory = Memory.find(params[:id])\n end",
"def set_memory\n @memory = Memory.find(params[:id])\n end",
"def set_memory\n @memory = Memory.find(params[:id])\n end",
"def set_memory\n @memory = Memory.find(params[:id])\n end",
"def set_memory\n @memory = Memory.find(params[:id])\n end",
"def set_memory\n @memory = Memory.find(params[:id])\n end",
"def get_objects_at_coord(x_location, y_location)\n get_world_array[Matrix.two_to_one(x_location, y_location, @x_size)]\n end",
"def lookup(obj, pos); end",
"def display_read(address)\n puts \"What address would you like read?\"\n puts address\n value, hit_miss = read(address)\n puts \"At that byte, there is the value #{value} (Cache #{hit_miss})\"\n end",
"def locate(address)\n get :location => address\n end",
"def locate(place)\n locations, = get :q => place\n return locations.first\n end",
"def at( index )\r\n @ary.at(index + @offset)\r\n end",
"def memory\n @__memory ||= Memory.new\n end",
"def read_cell(x, y)\n offset = (y * @height) + x\n\n @cells[offset] if x >= 0 && y >= 0 && x < @width && y < @height\n end",
"def read r\n if @m\n res = @m[r]\n return res if res\n \n # Falling back on IO.read - mmap failed\"\n @m = nil\n end\n \n @io.sysseek(r.first, IO::SEEK_SET)\n return @io.sysread(r.last-r.first+1)\n end",
"def loc; end",
"def loc; end",
"def loc; end",
"def call_ent(reg_key, addr, i_reg, m_spec)\n val = get_mem_addr(addr, i_reg)\n @registers[reg_key].word.from_int(val)\n end",
"def read(key)\n _key = Digest::SHA1.hexdigest key\n\n unless @memory_store.has_key? _key\n response = @conn.get \"/rest/jbossdeveloper/#{@profile}_#{_key}\"\n if response.success?\n @memory_store[_key] = Marshal.load(response.body)\n end\n end\n @memory_store[_key]\n end",
"def memory\n @pagesize ||= Vmstat.pagesize\n has_available = false\n\n total = free = active = inactive = pageins = pageouts = available = 0\n procfs_file(\"meminfo\") do |file|\n content = file.read(2048) # the requested information is in the first bytes\n\n content.scan(/(\\w+):\\s+(\\d+) kB/) do |name, kbytes|\n pages = (kbytes.to_i * 1024) / @pagesize\n\n case name\n when \"MemTotal\" then total = pages\n when \"MemFree\" then free = pages\n when \"MemAvailable\"\n available = pages\n has_available = true\n when \"Active\" then active = pages\n when \"Inactive\" then inactive = pages\n end\n end\n end\n\n procfs_file(\"vmstat\") do |file|\n content = file.read\n\n if content =~ /pgpgin\\s+(\\d+)/\n pageins = $1.to_i\n end\n\n if content =~ /pgpgout\\s+(\\d+)/\n pageouts = $1.to_i\n end\n end\n\n mem_klass = has_available ? LinuxMemory : Memory\n mem_klass.new(@pagesize, total-free-active-inactive, active,\n inactive, free, pageins, pageouts).tap do |mem|\n mem.available = available if has_available\n end\n end",
"def current_memory\n nil\n end",
"def[]( addr )\n range( addr ).value\n end",
"def [](n)\n @locations[n]\n end",
"def get_memory_rasd_item(id)\n request(\n :expects => 200,\n :idempotent => true,\n :method => 'GET',\n :parser => Fog::ToHashDocument.new,\n :path => \"vApp/#{id}/virtualHardwareSection/memory\"\n )\n end",
"def read_binary_object_at(fname,fd,pos)\n position = @offsets[pos]\n fd.seek(position,IO::SEEK_SET)\n return read_binary_object(fname,fd)\n end",
"def get x, y\n @pixels[pixel(x,y)]\n end"
] | [
"0.6399281",
"0.63791585",
"0.63005406",
"0.62971354",
"0.61796755",
"0.6171931",
"0.61365575",
"0.61267996",
"0.6123963",
"0.6122663",
"0.6115358",
"0.610928",
"0.61025006",
"0.6041607",
"0.6029811",
"0.59960794",
"0.5906712",
"0.5814971",
"0.5803863",
"0.5787122",
"0.5715333",
"0.57149523",
"0.5701665",
"0.56926197",
"0.56777686",
"0.5626832",
"0.5623929",
"0.5621792",
"0.5619058",
"0.55962676",
"0.558985",
"0.5557541",
"0.5512309",
"0.5511227",
"0.54861945",
"0.5467215",
"0.5463866",
"0.54587746",
"0.54539376",
"0.5451581",
"0.54431444",
"0.5442758",
"0.5403085",
"0.53840214",
"0.53415495",
"0.5320884",
"0.5320452",
"0.5320391",
"0.5318466",
"0.5292917",
"0.52864033",
"0.5281846",
"0.5258664",
"0.5257668",
"0.52569664",
"0.52419966",
"0.5240091",
"0.52389294",
"0.5236961",
"0.52324486",
"0.52300894",
"0.5230048",
"0.5230048",
"0.5214214",
"0.52123654",
"0.521181",
"0.5207371",
"0.5195204",
"0.51887095",
"0.51876175",
"0.5177575",
"0.51722455",
"0.5150759",
"0.5144876",
"0.5144876",
"0.5144876",
"0.5144876",
"0.5144876",
"0.5144876",
"0.5144876",
"0.5131996",
"0.51279783",
"0.5127101",
"0.5125187",
"0.51236993",
"0.5116641",
"0.5107952",
"0.5107897",
"0.5090326",
"0.5089749",
"0.5089749",
"0.5089749",
"0.50747263",
"0.50739294",
"0.5065484",
"0.5062441",
"0.5062267",
"0.5025275",
"0.5024357",
"0.5022692",
"0.50183815"
] | 0.0 | -1 |
Write memory at the provided location | def []=(loc, val)
sequence[loc] = val
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write!\n ensure_mode(:privileged)\n exec('write memory')\n end",
"def write(memory, address, process)\n memory[address, process.memory_blocks] = Concurrent::Array.new(process.memory_blocks, process.id)\n end",
"def write_to(offset,args)\r\n\t\t\tif !@rw\r\n\t\t\t\traise \"The file #{@filename} is not writable\\n\"\r\n\t\t\tend\r\n\t\t\tself.seek_to(offset) or return\r\n\t\t\[email protected](args) or raise \"Error writing to offset #{offset} in file #{@filename}: $!\\n\"\r\n\t\t\toffset==0 ? '0E0' : offset\r\n\t\tend",
"def write( addr, val )\n row_idx, col_idx = address_to_indices( addr )\n ( row_idx - rows ).times { @data << [] }\n @data[ row_idx-1 ][ col_idx-1 ] = val\n calc_dimensions if row_idx > rows || col_idx > cols\n val\n end",
"def write(handle, offset, data)\n send_request(FXP_WRITE, :string, handle, :int64, offset, :string, data)\n end",
"def write_data_at_offset(offset, data)\n\t\[email protected](offset.to_i, IO::SEEK_END)\n\t\t@file << data\n\tend",
"def write(location, content)\n Hyacinth::Config.lock_adapter.with_lock(location) do\n storage_adapter_for_location(location).write(location, content)\n end\n end",
"def write_to_memory\n len = Vips::SizeStruct.new\n ptr = Vips.vips_image_write_to_memory self, len\n raise Vips::Error if ptr.nil?\n\n # wrap up as an autopointer\n ptr = FFI::AutoPointer.new(ptr, GLib::G_FREE)\n\n ptr.get_bytes 0, len[:value]\n end",
"def write(val)\n @file.seek(@address)\n @file.putc(val)\n @file.flush\n end",
"def write(block_name, src_buffer)\n if block_name == @mem_file.size\n @mem_file << alloc_buffer\n end\n dest = @mem_file[block_name]\n ByteArray.copy(src_buffer,0,@block_size,dest,0)\n end",
"def write!\n @dev = File.open(@device, \"w\") if (@dev.nil? || @dev.closed?)\n @dev.write @bytes.pack(\"c*\")\n @dev.flush\n end",
"def write(p0) end",
"def write(p0) end",
"def write(p0) end",
"def store_word(loc,out_register,offset)\n\t#Get Location in memory.\n\tlocation = (offset+REGISTERS[loc])/4\n\tsetnum = getSet(location).to_i(2)\n\ttag = getTag(location).to_i(2)\n\t#Hit Block 1?\tIf Hit: UPDATE CACHE\n\tif((CACHE[setnum.to_i][0]).tag == tag && (CACHE[setnum.to_i][0]).valid == 1)\n\t\t(CACHE[setnum.to_i][0]).data = REGISTERS[out_register]\n\t\tprint \"hit\\n\"\n\t#Hit Block 2?\tIf Hit: UPDATE CACHE\n\telsif((CACHE[setnum.to_i][1]).tag == tag && (CACHE[setnum.to_i][0]).valid == 1)\n\t\t(CACHE[setnum.to_i][1]).data = REGISTERS[out_register]\n\t\tprint \"hit\\n\"\t\t\n\telse\n\t\t#If Miss:UPDATE MEMORY\n\t\tprint \"miss\\n\"\n\t\t#Store register value in memory.\n\t\tMAIN_MEMORY[location] = REGISTERS[out_register]\n\tend\nend",
"def write_process_memory(h, dst, val)\r\n val = val.to_s if not val.kind_of? String\r\n r = CALLS[\"kernel32!WriteProcessMemory:LLPLL=L\"].call(h, dst.to_i, val, val.size, NULL)\r\n raise WinX.new(:write_process_memory) if r == 0\r\n return r\r\n end",
"def write_s_pointer(value) \n write_bytecode_to(S_POINTER, @temp_bytecode)\n write_4B_to(value, @temp_bytecode)\n end",
"def write(buf, addr)\n hex = Rex::Text.to_hex(buf, '')\n send_cmd \"M#{addr},#{buf.length.to_s(16)}:#{hex}\"\n read_response\n end",
"def write(base, data)\n request = Packet.create_request(COMMAND_ID_STDAPI_SYS_PROCESS_MEMORY_WRITE)\n\n request.add_tlv(TLV_TYPE_HANDLE, process.handle)\n request.add_tlv(TLV_TYPE_BASE_ADDRESS, base)\n request.add_tlv(TLV_TYPE_PROCESS_MEMORY, data)\n\n response = process.client.send_request(request)\n\n return response.get_tlv_value(TLV_TYPE_LENGTH)\n end",
"def write_to_main_memory(slot)\n block_start_address = slot.tag + slot.num + \"0\"\n block_address = block_start_address.to_i(16)\n slot.saved_blocks.each do |block|\n @main_memory.content[block_address] = block\n block_address += 1\n end\n slot.is_dirty = 0\n end",
"def write(buf); end",
"def write!(handle, offset, data, &callback)\n wait_for(write(handle, offset, data, &callback))\n end",
"def syscall_write\n buffer = \"\"\n addr = vm.read_mem(vm.read_reg(:sp) + 1)\n vm.read_mem(vm.read_reg(:sp) + 2).times do |i|\n buffer << vm.read_mem(addr + i).chr\n end\n print buffer\n end",
"def call_out(reg_key, addr, i_reg, device_num)\n word = @computer.memory.read( get_mem_addr(addr, i_reg) )\n dev = @computer.get_device(device_num)\n dev.write(word)\n end",
"def write(dest); end",
"def write(dest); end",
"def write(dest); end",
"def put(position)\n # don't update unless position has changed\n if position != @last_position_written\n pos_file = File.open(@position_file, \"w\")\n pos_file.write(\"#{position}\\n\")\n pos_file.close\n @last_position_written = position\n end\n end",
"def write(key, value)\n key.freeze if key.is_a? String\n\n @memory_store[key] = value\n @file_store.transaction do\n @file_store[key] = value\n end\n end",
"def write(address, data)\n tag, slot_num, block_offset = split_address(address)\n slot = @slots[slot_num.to_i(16)]\n hit_miss = hit_miss(slot, tag)\n if hit_miss == \"miss\"\n range = (tag + slot_num + \"0\").to_i(16)..(tag + slot_num + \"F\").to_i(16)\n write_to_slot(slot, tag, @main_memory.content[range])\n end\n slot.saved_blocks[block_offset.to_i(16)] = data\n slot.is_dirty = 1\n return hit_miss\n end",
"def []=(loc, idx, val)\n puts \"#{ip} <- #{val}\" if debug\n case flag(idx)\n when :position then write(loc, val)\n when :relative then write(loc + relative_base, val)\n else\n raise \"flag #{flag(idx)} for assignment\"\n end\n end",
"def write(bytes)\r\n end",
"def write_s_pointer(value) \n @codegen.write_s_pointer(value)\n end",
"def write(path, str, offset = 0, opts = {})\n mode = (offset || 0) > 0 ? 'r+' : (opts[:mode] || 'w')\n\n file.open(path, mode, opts[:perm] || 0o644) do |io|\n io.pos = offset if offset != 0\n io.write(str)\n end\n end",
"def write(vaddr)\n st_entry = @segment_table.get_segment(vaddr.segment)\n return \"pf\" if st_entry == -1\n\n if st_entry == 0\n idx = $bm.find_free_slot(2)\n create_page_table(idx)\n st_entry = idx * 512\n segment_table.set_segment(vaddr.segment, st_entry)\n end\n\n page_table = $frames.get_word(st_entry / 512)\n\n pt_entry = page_table.get_page(vaddr.page)\n return \"pf\" if pt_entry == -1\n\n if pt_entry == 0\n idx = $bm.find_free_slot(1)\n create_page(idx)\n pt_entry = idx * 512\n page_table.set_page(vaddr.page, pt_entry)\n end\n\n $tlb.add(vaddr, pt_entry)\n pt_entry + vaddr.offset\n end",
"def store(name, value, offset=0)\n addr = pfa(name)\n @vm.store(addr + cells(offset), value)\n end",
"def store_location expected_location, variable_name\r\n command 'storeLocation', expected_location, variable_name\r\n end",
"def write_buffer(io = T.unsafe(nil)); end",
"def syswrite(p0) end",
"def syswrite(p0) end",
"def syswrite(p0) end",
"def write(data); end",
"def write(data); end",
"def write(data); end",
"def write(data); end",
"def write data\n _data[:out].write data\n _data[:out].flush\n end",
"def write(chunk)\n @size += chunk.bytesize\n # Worth noting that size always appears larger during this check than it\n # is in reality since the size is updated prior to writing out the data to\n # ensure that the amount of data stored in RAM doesn't exceed the maximum\n # in memory size.\n update_io if @in_memory && @size > @max_in_memory_size\n @io << chunk\n chunk\n end",
"def display_write(address, data)\n puts \"What address would you like to write to?\"\n puts address\n puts \"What data would you like to write at that address?\"\n puts data\n hit_miss = write(address, data)\n puts \"Value #{data} has been written to address #{address} (Cache #{hit_miss})\"\n end",
"def write(data)\n end",
"def write(block)\n @filemgr.write(block, @contents)\n end",
"def write(buf, *args)\n Polyphony.backend_write(self, buf, *args)\n end",
"def update(location, bytes)\n absolute_offset = @offset + location\n bytes_length = bytes.bytesize\n if absolute_offset >= @read_buffer.bytesize\n @write_buffer[absolute_offset - @read_buffer.bytesize, bytes_length] = bytes\n else\n overflow = absolute_offset + bytes_length - @read_buffer.bytesize\n read_buffer_portion = bytes_length - overflow\n @read_buffer[absolute_offset, read_buffer_portion] = bytes[0, read_buffer_portion]\n if overflow > 0\n @write_buffer[0, overflow] = bytes[read_buffer_portion, bytes_length - 1]\n end\n end\n self\n end",
"def write; end",
"def write; end",
"def vm_write(task, addr, val)\n addr = dl_bignum_to_ulong(addr)\n val = val.to_ptr\n r = CALLS[\"libc!vm_write:IPPI=I\"].call(task, addr, val, val.size).first\n raise KernelCallError.new(:vm_write, r) if r != 0\n return nil\n end",
"def write_binary(file:, data:, address: nil)\n File.open(file, 'wb') do |f|\n f.write Array(address).pack('S') if address\n f.write Array(data.flatten).pack('C*')\n end\n end",
"def write(*data); end",
"def record_write bytes\n @reader.record_write bytes, @state\n end",
"def write\n end",
"def write(data)\r\n Win32API.new(\"msvcrt\", \"_write\", \"lpl\", \"l\").call(@fd, data, 1)\r\n end",
"def write\n write_data\n end",
"def write(val)\n @writer.call(@address, val)\n end",
"def perform( handle, data, offset=0 )\n @handle = handle\n @offset = offset\n @data = data\n @pos = 0\n\n @driver.write( nil, handle, offset, data[0,CHUNK_SIZE] )\n end",
"def write(chunk, last_chunk = T.unsafe(nil)); end",
"def write(chunk, last_chunk = T.unsafe(nil)); end",
"def write(chunk, last_chunk = T.unsafe(nil)); end",
"def write(chunk, last_chunk = T.unsafe(nil)); end",
"def write_to buffer, metadata: {}\n labels = {}\n comments = {}\n unresolved = []\n instructions = @instructions.dup\n backup = @instructions.dup\n @instructions.clear\n\n while insn = instructions.shift\n if insn.label?\n labels[insn.name] = buffer.pos\n elsif insn.comment?\n comments.update({buffer.pos => insn.message}) { |_, *lines| lines.join($/) }\n elsif insn.lazy?\n write_instruction insn, buffer, labels\n instructions.unshift(*@instructions)\n @instructions.clear\n else\n if insn.retry?\n retry_req = RetryRequest.new(insn, buffer.pos)\n unresolved << retry_req\n end\n\n write_instruction insn, buffer, labels\n end\n end\n\n metadata[:comments] = comments\n @instructions = backup\n\n if !unresolved.empty?\n pos = buffer.pos\n unresolved.each do |req|\n insn = req.insn\n buffer.seek req.io_seek_pos, IO::SEEK_SET\n write_instruction insn, buffer, labels\n end\n buffer.seek pos, IO::SEEK_SET\n end\n\n if !@performance_warnings.empty?\n raise Errors::SuboptimalPerformance.new(@performance_warnings)\n end\n\n buffer\n end",
"def write\n open(@fname,\"wb\") do |file|\n Marshal.dump(@data,file)\n end\n end",
"def syswrite( buf )\n\t\treturn _write( buf )\n\tend",
"def shell_write(buf)\n raise NotImplementedError\n end",
"def write(location, raw_data)\n SitemapGenerator::FileAdapter.new.write(location, raw_data)\n directory = File.dirname(location.path_in_public)\n if directory != '.'\n self.store_dir = directory\n end\n store!(open(location.path, 'rb'))\n end",
"def write(data)\n @handle.writeData(data)\n end",
"def block_write_access(address, block_data = [], options = {})\n options = { write: true, # whether to write or read the block\n width: 32 # width default to 32 bits\n }.merge(options)\n block_data.each_index do |i|\n if i == 0 # first do single write access with count > 1\n single_write_access(address, block_data[0], options.merge(count: block_data.count))\n if options[:width] > 32\n reg(:rwd).write(block_data[i = i + 1])\n if options[:write]\n write_nexus_register(reg(:rwd), options)\n else\n read_nexus_register(reg(:rwd), options)\n end\n end\n else\n next if i.odd? && options[:width] > 32\n reg(:rwd).write(block_data[i])\n if options[:write]\n write_nexus_register(reg(:rwd), options)\n else\n read_nexus_register(reg(:rwd), options)\n end\n if options[:width] > 32\n reg(:rwd).write(block_data[i = i + 1])\n if options[:write]\n write_nexus_register(reg(:rwd), options)\n else\n read_nexus_register(reg(:rwd), options)\n end\n end\n end\n end\n end",
"def store_buffer\n return unless buffer?\n @buffer.binmode\n @buffer.pos = 0 # TODO: なんか頭が落ちるので!\n File.open(stored_file_path, \"wb\") do |f|\n f.write(@buffer.read)\n end\n end",
"def write(buffer)\n QRUtil.stringToBytes(self.getData() ).each { |d|\n buffer.put(d, 8)\n }\n end",
"def write(&block)\n @write_block = block\n end",
"def write_chunk(start, buffer)\n @local_file.seek(start)\n @local_file.write(buffer)\n end",
"def write_word(addr, word)\n write_byte addr, ( word & 0xFF )\n write_byte addr + 1, ( word >> 8 )\n end",
"def write(s)\n binary_to_store = Marshal.dump(s)\n bytes = @ioctx.write(@oid, binary_to_store, binary_to_store.size, @offset)\n # add an xattr :\n set_attribut(@@size_xattr, binary_to_store.size)\n \n @offset += bytes\n bytes\n end",
"def write(fragment); end",
"def write(path, buffer)\n entries[self.class.path(path)] = buffer\n end",
"def write(x)\n File.open(\"/tmp/mount/x\", \"w\") { |xf| xf.puts x.map(&:to_s).join(\"\\n\") }\nend",
"def write(location, raw_data)\n SitemapGenerator::FileAdapter.new.write(location, raw_data)\n\n create_bucket unless bucket_exists?\n put_sitemap(location)\n end",
"def write_to_ai_memory(value1, position1, value2, position2)\n @ai.receive_revealed_card(value1, position1)\n @ai.receive_revealed_card(value2, position2)\n end",
"def write_cache\n data = cache_data\n open(writable_file, \"wb\") do |f|\n\tf.puts Marshal.dump(data)\n end\n end",
"def store(ptr, val)\n if [email protected]_key?(ptr)\n raise \"Address #{ptr} was never allocated!\"\n end\n\n @store[ptr] = val\n end",
"def write(chunk)\n # dummy\n end",
"def save_current_page\n @file.sysseek @current_page.id * PAGE_SIZE, IO::SEEK_SET\n @file.syswrite @current_page.to_bytes\n end",
"def alloc_and_write_string(value)\n return nil if value == nil\n\n data = str_to_ascii_z(value)\n result = railgun.kernel32.VirtualAlloc(nil, data.length, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE)\n if result['return'].nil?\n return nil\n end\n addr = result['return']\n if railgun.memwrite(addr, data, data.length)\n return addr\n else\n return nil\n end\n end",
"def write_to(io)\n end",
"def write_to(io)\n end",
"def syswrite(buffer)\n\t\t\t\tremaining = buffer.bytesize\n\t\t\t\t\n\t\t\t\t# Fast path:\n\t\t\t\twritten = @io.write(buffer)\n\t\t\t\treturn if written == remaining\n\t\t\t\t\n\t\t\t\t# Slow path:\n\t\t\t\tremaining -= written\n\t\t\t\t\n\t\t\t\twhile remaining > 0\n\t\t\t\t\twrote = @io.write(buffer.byteslice(written, remaining))\n\t\t\t\t\t\n\t\t\t\t\tremaining -= wrote\n\t\t\t\t\twritten += wrote\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\treturn written\n\t\t\tend",
"def store_field(data)\n @io.write [data.size].pack(\"V\") \n offset = @io.pos\n @io.write data\n @io.write \"\\0\"\n offset \n end",
"def writeBlock(pieceIndex, offset, block)\n regions = @pieceMapper.findBlock(pieceIndex, offset, block.length)\n indexInBlock = 0\n regions.each do |region|\n # Get the IO for the file with path 'path'. If we are being used in a reactor, this is the IO facade. If we\n # are not then this is a real IO.\n io = @ioManager.get(region.path)\n if ! io\n # No IO for this file. \n raise \"This process doesn't have write permission for the file #{region.path}\" if File.exists?(region.path) && ! File.writable?(region.path)\n\n # Ensure parent directories exist.\n dir = File.dirname region.path\n FileUtils.mkdir_p dir if ! File.directory?(dir)\n\n begin\n io = @ioManager.open(region.path)\n rescue\n @logger.error \"Opening file #{region.path} failed: #{$!}\"\n raise \"Opening file #{region.path} failed\"\n end\n end\n\n io.seek region.offset, IO::SEEK_SET\n begin\n io.write(block[indexInBlock, region.length])\n indexInBlock += region.length\n rescue\n # Error when writing...\n @logger.error \"Writing block to file #{region.path} failed: #{$!}\"\n piece = nil\n break\n end\n\n break if indexInBlock >= block.length\n end\n end",
"def write\n\n # output to disk\n File.open(@outfile, 'w:UTF-8') { |file|\n file.write(@buffer)\n }\n end",
"def write_register(reg, options = {})\n arm_debug.mem_ap.write_register(reg, options)\n end",
"def write_i(i)\n z.write i.p32\nend",
"def record_write bytes, state=nil\n begin\n do_record_write bytes, state\n rescue\n nil\n end\n end",
"def write( &block )\n compile!( :write!, &block )\n end",
"def print_pointer_location(ptr, t)\n if t.respond_to? :get_area_memlocation\n page_number = (ptr.size.to_f / $page_size).ceil\n base_address = ptr.address - ( ptr.address % $page_size )\n ptrs = page_number.times.collect { |i|\n FFI::Pointer::new(base_address + i*$page_size).slice(0, $page_size)\n }\n ptrs.each { |ptr|\n p t.get_area_memlocation(ptr, :MEMBIND_BYNODESET)\n }\n else\n puts \"pagemap #{Process::pid} -n #{ptr.address.to_s(16)}-#{(ptr.address+ptr.size-1).to_s(16)}\"\n puts `pagemap #{Process::pid} -n #{ptr.address.to_s(16)}-#{(ptr.address+ptr.size-1).to_s(16)}`\n end\nend"
] | [
"0.7013797",
"0.6935818",
"0.6615015",
"0.65895456",
"0.6540519",
"0.6462389",
"0.63741934",
"0.6300883",
"0.62062633",
"0.61951685",
"0.6165523",
"0.6135923",
"0.6135923",
"0.6135178",
"0.6064887",
"0.60578775",
"0.60098433",
"0.60010594",
"0.5993549",
"0.5973125",
"0.5972917",
"0.5895656",
"0.5891165",
"0.588398",
"0.5832495",
"0.5832495",
"0.5832495",
"0.5828741",
"0.5825417",
"0.5818441",
"0.57985604",
"0.5791997",
"0.5784847",
"0.57732844",
"0.5764032",
"0.57024777",
"0.56980485",
"0.5696488",
"0.5690274",
"0.5690274",
"0.5689953",
"0.5683491",
"0.5683491",
"0.5683491",
"0.5683491",
"0.56459856",
"0.5605748",
"0.56004554",
"0.5598603",
"0.5595087",
"0.5592938",
"0.55756706",
"0.55580914",
"0.55580914",
"0.55546546",
"0.55535114",
"0.5526463",
"0.5512332",
"0.55095166",
"0.5509403",
"0.55009174",
"0.54980695",
"0.5488114",
"0.5484752",
"0.5484752",
"0.5484752",
"0.5484752",
"0.54763114",
"0.5455203",
"0.54511267",
"0.5442508",
"0.542956",
"0.5426611",
"0.5420849",
"0.541976",
"0.541493",
"0.53903997",
"0.537748",
"0.53695583",
"0.53665894",
"0.5357237",
"0.53512996",
"0.53487206",
"0.53368694",
"0.5332906",
"0.5332264",
"0.5328757",
"0.5308523",
"0.5273386",
"0.5273151",
"0.52684414",
"0.52684414",
"0.5251573",
"0.5250813",
"0.5250807",
"0.52491087",
"0.5244981",
"0.5244525",
"0.5239034",
"0.52309144",
"0.522064"
] | 0.0 | -1 |
Read the provided number of instruction args. Omits the current operation. | def args(count)
sequence[ip+1, count]
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def args(count)\n resp = sequence[ip+1, count]\n puts ([opcode] + resp).inspect\n resp\n end",
"def args(count)\n resp = count.times.map { |i| read(ip + 1 + i) }\n\n puts(([opcode] + resp).inspect) if debug\n\n resp\n end",
"def parse(args)\n @args = args\n @instruction = args.join(' ')\n until @args.empty?\n arg = @args[0]\n if @instructions.key? arg\n @args.shift\n buff = args_extract(arg, @instructions[arg][0])\n @to_exec << [arg, buff]\n else\n bad_argument_exit(arg)\n end\n end\n run\n end",
"def get_args\n <<-CODE\n stack_push(I2N(c->args));\n CODE\n end",
"def read(arg0, arg1, *rest)\n end",
"def readline(*rest) end",
"def readline(*rest) end",
"def readline(arg0, arg1, *rest)\n end",
"def instructions\n STDIN.read.split(\"\\n\")\nend",
"def args() return @args end",
"def build_args\n @scope.argument_descriptors = build_arg_descriptor\n add CheckArityInstr.new(2, 0, false, false, -1)\n _in = @scope.get_new_local_variable(\"_in\", 0)\n add ReceivePreReqdArgInstr.new(_in, 0)\n _out = @scope.get_new_local_variable(\"_out\", 0)\n add ReceivePreReqdArgInstr.new(_out, 1)\n end",
"def args(*) end",
"def readlines(arg0, arg1, *rest)\n end",
"def set_args\n <<-CODE\n t1 = stack_pop();\n c->args = N2I(t1);\n CODE\n end",
"def args()\n #This is a stub, used for indexing\n end",
"def extract_args *args, &block\n [extract_id(*args), extract_selector(*args), extract_markup(*args, &block), extract_action(*args, &block)]\n end",
"def sysread(*rest) end",
"def sysread(*rest) end",
"def process(args)\n args\n end",
"def process_args\n args = @args.dup\n @options[:operands] = nil\n unless args.length >= 2\n puts @opts\n exit 1\n end\n @options[:operands] = args.shift(2)\n @options[:output_filename] = args.shift unless args.empty?\n @options[:output] ||= @options[:output_filename] || $stdout\n\n run\n end",
"def extract_arguments!\n return ARGV[0], nil, nil if ARGV.length == 1\n\n raise(ArgumentError, \"Usage: mixtape-bu SOURCE [CHANGES] [DEST]\") unless ARGV.length == 3\n\n ARGV.take(3)\nend",
"def read(*args, **kwd); end",
"def instructions\n @instructions ||= STDIN.read.split(\"\\n\")\nend",
"def extract_build_args args # :nodoc:\n return [] unless offset = args.index('--')\n build_args = args.slice!(offset...args.length)\n build_args.shift\n build_args\n end",
"def args\n @payload['args']\n end",
"def next_argument\n @remaining_arguments.shift\n end",
"def how_many_args (*input)\n input.count\n end",
"def read(*rest) end",
"def read(*rest) end",
"def inflamed _args\n \"inflamed _args;\" \n end",
"def read(*args)\n #This is a stub, used for indexing\n end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def args; end",
"def cmdarg_stack; end",
"def cmdarg_stack; end",
"def cmdarg_stack; end",
"def parse(cmd)\n inst = instructions.find { |i| i.match?(cmd) }\n raise ArgumentError, \"Not implemented instruction in #{cmd}\" if inst.nil?\n [inst, inst.fetch_args(cmd)]\n end",
"def [](index); @args[index] end",
"def read(*args)\n io.read(*args)\n end",
"def binread(*args, **kwd); end",
"def process_inputs(args)\n @input = ((name = args[:in_file]) && (IO.read(name, mode: \"rb\"))) ||\n args[:in_str] ||\n fail(\"An input must be specified.\")\n\n @generator = args[:generator] ||\n ((key = args[:key]) && Generator.new(key)) ||\n fail(\"A key or generator must be specified.\")\n\n @window = args[:window] || 16\n\n #The filler value is for testing purposes only. It should\n #not be specified when secure operation is desired.\n @fill_value = args[:filler]\n end",
"def read_opcode_and_params(instruction)\n # since digits is reversed, modes, is in order from param 1 to n\n opcode_digit2, opcode_digit1, *modes = instruction.digits\n opcode = \"#{opcode_digit1}#{opcode_digit2}\".to_i\n\n raise \"Invalid Opcode: #{opcode}\" unless OPCODES.key?(opcode)\n num_params = OPCODES[opcode][:num_params]\n\n param_modes = num_params.times.map.with_index { |i| modes[i] || 0 }\n param_vals = num_params.times.map { next_instruction }\n\n params = param_vals.map.with_index do |val, i|\n mode = param_modes[i] == 1 ? :immediate : :position\n Param.new(mode: mode, value: val)\n end\n return opcode, params\n end",
"def required_arguments(args, n)\n n = (n..n) if Fixnum === n\n unless n.include? args.size\n STDERR.puts usage_text()\n exit!\n end\n args\n end",
"def readlines(*rest) end",
"def readlines(*rest) end",
"def spot_opcall_for_args\n _nd_recv, _op, nd_arg = @node.children\n if nd_arg && nd_arg.first_lineno == nd_arg.last_lineno\n # binary operator\n fetch_line(nd_arg.first_lineno)\n @beg_column = nd_arg.first_column\n @end_column = nd_arg.last_column\n end\n end",
"def arguments; end",
"def arguments; end",
"def arguments; end",
"def args\n raw_args\n end",
"def extract_extras(*args)\n args.extract_options!\n args.shift\n args\n end",
"def extra_args; end",
"def instruction name, instruction\n end",
"def _loop_args\n @index = 0\n size = @arguments.args.size\n\n # use an incrementing index, to be able to peek to the next in the list\n # and to skip an item\n while @index < size\n yield @arguments.args[@index]\n\n _skip_next\n end\n\n self\n end",
"def func *args\n puts \"Argument's length is #{args.length}\"\n for arg in args\n puts \"arg: #{arg}\"\n end\nend",
"def extract_commands_from_input_file(args)\n\t\tcommands = []\n\t\tFile.open(args[0], \"r\").each do | line |\n\t\t\tcommands << extract_command_from_line(line)\n\t\tend\n\t\tcommands\n\tend",
"def arg_size; end",
"def action_arguments(data, position)\n data[:arguments]\n end",
"def extract_args(*args)\n options = args.extract_options!\n if options.length.positive?\n [args.pop, options.fetch(:keys) { [] }, options.fetch(:argv) { [] }]\n else\n keys, argv = args.shift(2)\n keys ||= []\n argv ||= []\n [args.pop, keys, argv]\n end\n end",
"def how_many_args(*args)\n\targs.length\nend",
"def how_many_args(*args)\n args.count\n end",
"def visit_ProcessingInstruction(pi, *rest)\n end",
"def load_args\n hash = instance_eval(File.read(File.join(__dir__, 'consts', 'sys_arg.rb')))\n Hash.new do |_h, k|\n next hash[k] if hash[k]\n next hash[k.to_s[4..].to_sym] if k.to_s.start_with?('x32_')\n\n nil\n end\n end",
"def slice_args(out)\n out.shape.map {:*}\n end",
"def run(memory)\n pointer = 0\n\n loop do\n opcode = memory[pointer]\n break if opcode == HALT\n\n command = INSTRUCTIONS[opcode]\n\n parameters = memory.slice((pointer + 1)..(pointer + command.arity - 1))\n command.call(memory, *parameters)\n pointer += command.arity\n\n # p memory; readline\n end\n\n memory\nend",
"def how_many_args *args\n args.length\n # accepts any number of arguments without complaint\n # returns the total number of arguments passed to the function\n # Hint: google ruby *args\nend",
"def read_input()\n input = []\n \n until ARGV.empty? do\n input.push Integer(ARGV.shift)\n end \n return input\nend",
"def third_method(*my_args)\n puts \"I have benn passed #{my_args.length} arguments in #{my_args}\"\n for arg in my_args\n puts \"Argument: #{arg}\"\n end\nend",
"def how_many_args *args\n args.length\nend",
"def args_unleashed(a, b=1, *c, d, e)\n puts \"Arguments:\"\n p a,b,c,d,e\nend",
"def args\n @args \n end",
"def how_many_args *args\n args.count\nend",
"def argument(idx)\n case idx\n when 0 then registers['rdi']\n when 1 then registers['rsi']\n when 2 then registers['rdx']\n when 3 then registers['rcx']\n when 4 then registers['r8']\n when 5 then registers['r9']\n end\n end",
"def how_many_args(*args)\n args.length\nend",
"def raw\n @args\n end",
"def how_many_args(*arg)\n arg.length\nend",
"def grab_arg\n msg = \"Invalid argument source!\"\n @argsrc.source.size == @argsrc.grab_method.size or fail ArgumentError, msg\n grab = case @argsrc.grab_method.last\n when :shift then \".shift\"\n when :ref then \"\"\n when :dup then \".dup\"\n else\n msg = \"Unknown arg. grab method #{@argsrc.grab_method.last}!\"\n fail ArgumentError, msg\n end\n case @argsrc.source.last\n when :args_counted\n x = ( @arg_count += 1 ) - 1\n \"args[#{x}]\" + grab\n when :args then # now this is a bit difficult, cause\n case @argsrc.grab_method.last # it's necessary to discard the used\n when :shift then # args (shift #@arg_count):\n if @arg_count == 0 then\n \"args.shift\"\n else\n \"(args.shift(#@arg_count); args.shift)\"\n end\n when :ref then \"args\"\n else fail TypeError, \"Unknown grab method #{@argsrc.grab_method.last}!\"\n end\n when :alpha then alpha_touch; 'alpha' + grab\n when :beta then beta_touch; 'beta' + grab\n when :delta, :epsilon, :zeta then @argsrc.source.last.to_s + grab\n when :psi then \"args[-2]\" + grab\n when :omega then \"args[-1]\" + grab\n else fail TypeError, \"Unknown argument source #{@argsrc.src.last}!\"\n end.tap do\n if @argsrc.source.size > 1 then\n @argsrc.source.pop\n @argsrc.grab_method.pop\n end\n end\n end",
"def manage_args(*args)\n end",
"def xargs *args\r\n m = args.shift\r\n args.slice!(-1).each {|a|\r\n method(m).call(*(args + [a]))\r\n }\r\nend",
"def read_and_execute(inp)\n args = inp.split(' ') # Split the input by space\n cmd_name = args[0] # First argument of the command name\n cmd_args = args[1..inp.length] # Second argument is the argument of the commands\n @commands_available[cmd_name].execute(cmd_args)\n end",
"def how_many_args(*args)\n args.count\nend",
"def run(args)\n state = @proc.state\n context = @proc.context\n max_frame = context.stack_size - state.frame_pos\n if args.size == 1\n frame_pos = state.frame_pos\n else\n count_str = args[1]\n count_opts = {\n :msg_on_error => \n \"The '#{NAME}' command argument must eval to an integer. Got: %s\" % \n count_str,\n :min_value => 0,\n :max_valiue => context.stack_size - state.frame_pos\n }\n count = @proc.get_an_int(count_str, count_opts)\n return unless count\n frame_pos = count - 1 \n end\n context.stop_frame = frame_pos\n state.frame_pos = 0\n state.proceed\n @proc.leave_cmd_loop = true\n end"
] | [
"0.66800547",
"0.66115946",
"0.6391388",
"0.6336367",
"0.6197972",
"0.594532",
"0.594532",
"0.5940319",
"0.5894053",
"0.58464044",
"0.58305585",
"0.5786359",
"0.57703453",
"0.5749989",
"0.5704644",
"0.56823015",
"0.5678692",
"0.5678692",
"0.56578594",
"0.5650234",
"0.5626782",
"0.5603582",
"0.5567705",
"0.55676836",
"0.55629283",
"0.555622",
"0.5530162",
"0.54981124",
"0.54981124",
"0.5497386",
"0.54885834",
"0.5472866",
"0.5472866",
"0.5472866",
"0.5472866",
"0.5472866",
"0.5472866",
"0.5472866",
"0.5472866",
"0.5472866",
"0.5472866",
"0.5472866",
"0.5472866",
"0.5472866",
"0.5472866",
"0.5472866",
"0.5472866",
"0.5472866",
"0.5472866",
"0.5472866",
"0.5472866",
"0.5472629",
"0.5472629",
"0.5472629",
"0.54654366",
"0.5454514",
"0.54390764",
"0.54352105",
"0.541995",
"0.54171914",
"0.5409773",
"0.5383749",
"0.5383749",
"0.537971",
"0.5368525",
"0.5368525",
"0.5368525",
"0.5368476",
"0.5362825",
"0.53449637",
"0.5335824",
"0.53205615",
"0.5310152",
"0.5309259",
"0.53079045",
"0.5284445",
"0.5265561",
"0.5260134",
"0.5235117",
"0.52182835",
"0.5214706",
"0.5207421",
"0.5206772",
"0.5205097",
"0.52013767",
"0.5198381",
"0.5198208",
"0.5194318",
"0.5191453",
"0.5190632",
"0.5183113",
"0.51645267",
"0.51598024",
"0.51589936",
"0.51429236",
"0.51384187",
"0.51353204",
"0.5129783",
"0.51290864",
"0.5124132"
] | 0.6173161 | 5 |
Increment the instruction pointer by `count` | def increment(count)
@ip += count
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def incr_count\n @count ||= 0\n @count += 1\n end",
"def increment(att, count = 1)\n key[:counters].call(\"HINCRBY\", att, count)\n end",
"def add_to_count\n @count += 1\n end",
"def next_instruction\n inst = @program[@current_inst]\n @current_inst += 1\n inst\n end",
"def increment_count(current_count)\n current_count.to_i + 1\n end",
"def increment_counter\n unless self.count.nil?\n self.count += 1\n else\n self.count = 1\n end\n end",
"def increment!\n\t\t\t\t@vertices += 1\n\t\t\t\t@count += 1\n\t\t\tend",
"def increase_item_count(index)\n current_value = @item_counts[index] ||= 0\n\n @item_counts[index] = current_value + 1\n end",
"def increment\n @counter = @counter + 1\n end",
"def insn_stack_increase(opcode_index, ary)\n call_info = [:send, :invokesuper, :opt_send_simple, :invokeblock]\n name = RubyVM::INSTRUCTION_NAMES[opcode_index].to_sym\n unless call_info.include?(name)\n return _insn_stack_increase(opcode_index, ary)\n else\n case name\n when :opt_send_simple\n inc = -ary[0][:orig_argc]\n when :invokeblock\n inc = 1-ary[0][:orig_argc]\n when :send, :invokesuper\n inc = -ary[0][:orig_argc]\n inc += -1 if (ary[0][:flag] & VM_CALL_ARGS_BLOCKARG) != 0\n else\n raise \"unknown state\"\n end\n return inc\n end\n end",
"def inc(ptr, amount=1)\n ptr = Convert(ptr, :pointer)\n val = @builder.load(ptr)\n @builder.store(add(val, amount), ptr)\n return ptr\n end",
"def next_instruction()\n opcode = (@memory[@instruction_ptr] << 8) + @memory[@instruction_ptr+1]\n\n if opcode == 0\n kill_program()\n end\n\n do_instruction(opcode)\n @instruction_ptr += 2\n end",
"def increment(*)\n @build += 1\n end",
"def next\n @pointer += 1\n end",
"def increment \n\t\t@counter = @counter + 1\n\tend",
"def increase_index\n @i +=1\n end",
"def increment_count\n session[:count] += 1\n @count = session[:count]\n end",
"def args(count)\n sequence[ip+1, count]\n end",
"def inc\n $i + 1\n end",
"def increment(points_count)\n\t\t@story_count += 1\n\t\t@points_count += points_count\n\tend",
"def count\n @count ||= 0\n @count += 1\n end",
"def next\n @count += 1\n self\n end",
"def inc_usage\n @mutex.synchronize { @usage_count += 1 }\n end",
"def increment_click_count\n update(click_count: click_count + 1)\n end",
"def increment_click_count!\n self.increment! :click_count\n end",
"def increment\n @value += 1\n end",
"def skip!(count = 1)\n @next += count * (@upwards ? 1 : -1)\n end",
"def count number\r\n number.times do\r\n number += 1\r\n end\r\nend",
"def increment_counter(counter)\n\tcounter += 1\n\treturn counter\nend",
"def increment(packet_length); end",
"def count!\n if not self.count.nil? then self.count += 1; else self.count = 1; end\n end",
"def increment *args\n accumulators.incr(scope(*args))\n end",
"def args(count)\n resp = sequence[ip+1, count]\n puts ([opcode] + resp).inspect\n resp\n end",
"def increment(name, amount = T.unsafe(nil), options = T.unsafe(nil)); end",
"def increment(stat, sample_rate=1); count stat, 1, sample_rate end",
"def incr\n add(1)\n end",
"def increment(start, inc)\n\t\t\t\tProc.new{start +=inc}\nend",
"def incr(x) x + 1 end",
"def add_count(count)\r\n counter = Count.find(:first, :conditions => [\"countable_id = ? and countable_type = ?\", count.countable_id, self.type.name ])\r\n if counter.nil?\r\n counts << count \r\n else\r\n counter.update_attribute(:count, counter.count + 1)\r\n end\r\n end",
"def advance n\n @index += n\n self\n end",
"def to count\n take count + 1\n end",
"def increment_transaction_count!\n @transaction_count += 1\n end",
"def increment_guess_count(count)\n\treturn count += 1\nend",
"def increment(key)\n @counter[key] += 1\n end",
"def increment_order!\n @current += 1\n end",
"def increment_iteration\n @iteration += 1\n end",
"def next!\r\n @cur = @cache[@idx+=1]\r\n end",
"def accumulate *_\n self.count += 1\n end",
"def increment!\n @value += @increment\n \n self\n end",
"def args(count)\n resp = count.times.map { |i| read(ip + 1 + i) }\n\n puts(([opcode] + resp).inspect) if debug\n\n resp\n end",
"def _rl_insert_next(count)\r\n rl_setstate(RL_STATE_MOREINPUT)\r\n c = rl_read_key()\r\n rl_unsetstate(RL_STATE_MOREINPUT)\r\n\r\n if c.is_a?(Integer) && c < 0\r\n return -1\r\n end\r\n\r\n _rl_insert_char(count, c)\r\n end",
"def advance(count_lsn_no, group)\n new_lsn_no = @lsn_no + count_lsn_no\n reposition(new_lsn_no, group)\n end",
"def increment_sequence_number\n @sequence_number += 1\n @sequence_number = 0 if @sequence_number > 0xFFFFFFFF\n end",
"def add_allocated_memory(count)\n self.allocated_memory += count\n if (allocated_memory - last_allocated_memory) > allocated_memory_threshold\n GC.start\n @last_allocated_memory = allocated_memory\n end\n end",
"def do_something_with_my_count\r\n @my_count += 1\r\n end",
"def increment\n self.class.increment(self)\n end",
"def add_actions(count)\n update_attributes(actions: actions + count)\n end",
"def call_inc(reg_key, addr, i_reg, m_spec)\n reg = @registers[reg_key]\n val = get_mem_addr(addr, i_reg) + reg.word.to_i\n reg.word.from_int(val)\n end",
"def increment element\n element.perform :increment\n end",
"def next\n peek.tap { @position += 1 }\n end",
"def increment(by: 1)\n return @lock.synchronize do\n @current += by.to_i\n end\n end",
"def opn_while\n -> do\n if mem[dp].zero?\n @ff += 1\n elsif @call_stack.last != ip\n @call_stack.push(ip)\n end\n end\n end",
"def next!\n id = @counter.next!\n id = @counter.next! while @map[id]\n register id\n end",
"def increment_use_count\n if @temporary \n @instance_count += 1\n end\n return\n end",
"def update(n)\n @uncounted.add(n)\n end",
"def perform(count = 1, *args)\n @operations ||= { }\n\n _sequence = @sequence += 1\n @operations[_sequence] = true\n\n fiber = Fiber.new do\n called = false\n should_resume = false\n\n callback = lambda {\n called = true\n\n if (should_resume)\n fiber.resume\n end\n }\n\n count.times do\n called = false\n\n yield(callback, *args)\n\n unless (called)\n should_resume = true\n Fiber.yield\n end\n end\n\n @operations.delete(_sequence)\n\n if (self.finished?)\n self.finish!\n end\n end\n\n (@fibers ||= [ ]) << fiber\n end",
"def scan(count)\n scanned = tape.slice(position, count)\n move_to(position + count - 1)\n scanned\n end",
"def increment(name)\n update(name)\n end",
"def fetch!\n @last_instruction = @code[@instruction_pointer,3]\n @instruction_pointer += 3\n @last_instruction\n end",
"def next\n @counter += 1\n @counter = 0 if @counter >= @buffers.size\n @buffers[@counter]\n end",
"def shift(count=1)\n\t self.class[to_a.shift(count)]\n\tend",
"def instructions_counter\n @instructions_counter\n end",
"def shift(count=1)\n\t Point[Array.new(count, 1)]\n\tend",
"def advance!\n @state = (@state + 1) % @@states.length\n end",
"def step count\n @algorithm.call count\n end",
"def increment\n curr_value = counter\n self.counter = curr_value + 1\n save\n curr_value\n end",
"def log_incr(*args)\n log(*args) unless args.empty?\n @log_indents[Thread.current] += 1\n end",
"def increment\n Dictionary.db.zincrby @key, 1, @value\n end",
"def increment_assertion_count\n end",
"def count_with_increment(start, inc)\n lambda do\n tmp = start\n start += inc\n tmp\n end\nend",
"def skip(n = 1)\n @pointer += n\n self\n end",
"def incrby(key, increment); end",
"def incrby(key, increment); end",
"def reg_addr\n @cnt ||= -1\n buffer = 0x61a080\n @cnt += 1\n buffer + @cnt * 8\nend",
"def make_fast_nops(count)\n max_nop_chunk_size = 100\n\n if count < max_nop_chunk_size\n return make_nops(count)\n end\n\n nops = make_nops(max_nop_chunk_size)\n nops += nops while nops.length < count\n\n nops[0, count]\n end",
"def inc(v = 1)\n sync { @v += v }\n end",
"def incr!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 17 )\n\n type = INCR\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 138:8: '++'\n match( \"++\" )\n\n \n @state.type = type\n @state.channel = channel\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 17 )\n\n end",
"def store_externcount(count) #:nodoc:\n record = 0x0016 # Record identifier\n length = 0x0002 # Number of bytes to follow\n\n cxals = count # Number of external references\n\n header = [record, length].pack('vv')\n data = [cxals].pack('v')\n\n prepend(header, data)\n end",
"def use(n=1)\n self.used += n\n end",
"def offset(count=nil)\n if count\n @offset = count\n self\n else\n @offset\n end\n end",
"def increment_by amount, *args\n accumulators.incrby(scope(*args), amount)\n end",
"def increment(stat, sample_rate=1)\n count stat, 1, sample_rate\n end",
"def sequence(count, num)\n result = 0\n Array.new(count).map {|_| result += num }\nend",
"def increment\n self.visits = self.visits.to_i.next\n self.save\n end",
"def increment!\n self.times += 1\n self.save\n end",
"def increment\n @attempt += 1\n log\n end",
"def increment(node)\n change_by node, 1\n end",
"def next()\n @array[@k+=1]\n end"
] | [
"0.6813269",
"0.6762807",
"0.6594867",
"0.6569928",
"0.6567397",
"0.63058823",
"0.62714237",
"0.61310047",
"0.61190856",
"0.6071661",
"0.6053236",
"0.5995766",
"0.59712267",
"0.59497184",
"0.5948654",
"0.59271514",
"0.59042454",
"0.58976644",
"0.5873836",
"0.58130646",
"0.57433426",
"0.5712789",
"0.5697057",
"0.56800556",
"0.5669106",
"0.5645729",
"0.5627892",
"0.5625348",
"0.56214345",
"0.55766135",
"0.5574965",
"0.5568278",
"0.5566058",
"0.556347",
"0.55628467",
"0.55542386",
"0.5546064",
"0.5530138",
"0.5505747",
"0.55020046",
"0.5491635",
"0.54792666",
"0.5470451",
"0.5464616",
"0.5457252",
"0.5456949",
"0.5453449",
"0.5430702",
"0.5421776",
"0.54134774",
"0.54104316",
"0.54066545",
"0.53522843",
"0.53493476",
"0.53332806",
"0.53330415",
"0.5316376",
"0.5302898",
"0.52868366",
"0.5279825",
"0.52751625",
"0.5267588",
"0.526564",
"0.52404535",
"0.5225578",
"0.52255523",
"0.522433",
"0.5217375",
"0.5203689",
"0.52014387",
"0.51950854",
"0.51913905",
"0.51862943",
"0.5185843",
"0.51852965",
"0.5179339",
"0.51708704",
"0.5166107",
"0.51573896",
"0.5145257",
"0.5144781",
"0.51429284",
"0.51429284",
"0.513952",
"0.5138184",
"0.5136337",
"0.5126287",
"0.51224494",
"0.5114487",
"0.51084244",
"0.51063114",
"0.51025283",
"0.5099134",
"0.50950086",
"0.50947666",
"0.5081924",
"0.507797",
"0.50739056"
] | 0.7579032 | 2 |
Assign the instruction pointer to the provided location | def jump(loc)
@ip = loc
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def jump(x)\n @memory_position = x\n end",
"def on(instruction, arguments, &bloc)\n @instructions[instruction] = [arguments, bloc]\n end",
"def jump(address)\n @pc = address\n end",
"def set_jump_for(position)\n at = position.at\n code = position.object\n return unless code.next_code #dont jump beyond and\n jump = Branch.new(\"BinaryCode #{at.to_s(16)}\" , code.next_code)\n translator = @platform.translator\n cpu_jump = translator.translate(jump)\n pos = at + code.padded_length - cpu_jump.byte_length\n Position.create(cpu_jump).set(pos)\n cpu_jump.assemble(JumpWriter.new(code))\n end",
"def execute_LEA(register, memory_operand)\n\t\tregister.direct_value = memory_operand.offset\n\tend",
"def replace_instruction(iseq, ip, inst)\n @iseq = iseq\n @offset = start = ip\n\n old_inst = iseq2int\n old_op = InstructionSet[old_inst]\n new_op = inst.first\n unless new_op.kind_of? InstructionSet::OpCode\n new_op = InstructionSet[inst.first]\n end\n @offset += old_op.arg_count\n old_op.size.upto(new_op.size-1) do\n next_inst = iseq2int\n unless next_inst == 0\n raise ArgumentError, \"Cannot replace an instruction with a larger instruction (existing #{old_op.opcode} / new #{new_op.opcode})\"\n end\n end\n\n @offset = start\n replaced = [old_op.opcode]\n 1.upto(old_op.arg_count) do\n replaced << iseq2int\n int2iseq(0) # Replace any old opcode args with 0 (i.e. noop)\n end\n\n @offset = start\n encode inst\n replaced\n end",
"def set_breakpoint(ip, obj)\n Rubinius.primitive :compiledmethod_set_breakpoint\n raise ArgumentError, \"Unable to set breakpoint on #{inspect} at invalid bytecode address #{ip}\"\n end",
"def jmp(pos=0)\n @pos = pos\n end",
"def pre_cycle\n copy_value_fetch_from_memory\n initialize_memory_instruction_registers\n move_instruction_pointer_to_a_next_address\n end",
"def assignment\n name = get_name\n comment name\n define_variable name\n match \"=\"\n comment \"=\"\n expression\n emitln \"leaq #{name}(%rip), %rdx\"\n emitln \"movl %eax, (%rdx)\"\nend",
"def result=(value)\n target_address = @memory[@instruction_pointer + 3]\n @memory[target_address] = value\n end",
"def call_jmp(reg_key, addr, i_reg, m_spec)\n mem_addr = get_mem_addr(addr, i_reg)\n @registers['J'].word.from_int(mem_addr)\n @pc = mem_addr\n end",
"def goto\n <<-CODE\n next_int;\n c->ip = _int;\n cpu_cache_ip(c);\n CODE\n end",
"def execute_JMP(offset)\n\t\tjump_conditionally_to_signed_displacement(offset, true)\n\tend",
"def []=(loc, val)\n sequence[loc] = val\n end",
"def []=(loc, val)\n sequence[loc] = val\n end",
"def next_instruction()\n opcode = (@memory[@instruction_ptr] << 8) + @memory[@instruction_ptr+1]\n\n if opcode == 0\n kill_program()\n end\n\n do_instruction(opcode)\n @instruction_ptr += 2\n end",
"def []=(i, v)\n C.LLVMSetOperand(@user, i, v)\n end",
"def store(val, ptr)\n raise \"val must be a Value, got #{val.class.name}\" unless Value === val\n Instruction.from_ptr(C.build_store(self, val, ptr))\n end",
"def opcode_8XY0(helper)\n\t\thelper.registry_X = helper.registry_Y\n\tend",
"def store_rax_at(at)\n # 0x000000000008dd76 : mov qword ptr [rdi + 8], rax ; ret\n flat(pop_rdi, at - 8, libc + 0x8dd76)\nend",
"def mem=(p0) end",
"def set_loc(x, y)\n @curr_x = x\n @curr_y = y\n end",
"def position(block, instruction)\n raise ArgumentError, \"Block must be LLVM::BasicBlock\" if !block.is_a?(LLVM::BasicBlock)\n\n raise ArgumentError, \"Instruction must be LLVM::Instruction\" if !instruction.is_a?(LLVM::Instruction)\n\n C.position_builder(self, block, instruction)\n self\n end",
"def do_assignment(leadin)\n ident = leadin.type == :LET ? (expect [:ident]).value : leadin.value\n\n expect [:assign]\n\n @variables[ident] = if @lexer.peek_next_type == :string\n @lexer.next.value\n else\n expression_value\n end\n end",
"def initialize\n @instr_type = LABEL_GOTO\n @label_addr = UNINITIALIZED\n end",
"def jmp(jmp_pos = 0)\n @io.pos = jmp_pos + @base_pos\n end",
"def mov_rax_prax; libc + 0x145c98; end",
"def execute\n instruction = @emulator.instruction_register\n\n source = instruction.operand(2)\n @emulator.register_write(@destination, @emulator.register_read(@source))\n end",
"def move(instruction)\n self.class.new(instruction.execute(@position))\n end",
"def instruction_pointer\n return @state[:fiber][:instruction_pointer]\n end",
"def set_at(coords, piece)\n @board[coords[0]][coords[1]] = piece\n end",
"def move_to(locator, offset = {})\n x = offset.fetch(:x, 0)\n y = offset.fetch(:y, 0)\n\n element = find_element(locator)\n\n action\n .move_to(element, x, y)\n .perform\n end",
"def set_instruction\n @instruction = Instruction.find(params[:id])\n end",
"def set_instruction\n @instruction = Instruction.find(params[:id])\n end",
"def set_instruction\n @instruction = Instruction.find(params[:id])\n end",
"def fetch!\n @last_instruction = @code[@instruction_pointer,3]\n @instruction_pointer += 3\n @last_instruction\n end",
"def assignment\n @name = get_name\n match '='\n expression\n emit_ln \"LEA #{@name} (PC),A0\"\n emit_ln 'MOVE D0,(A0)'\nend",
"def store_register (instruction)\n op_code, f = extract_op_code_and_modifier(instruction)\n register = select_register_from_op_code(op_code, Instructions::OP_STA)\n word = extract_word_from_memory(instruction)\n left, right = explode_f(f)\n @logger.debug('Setting %s (%d,%d) word at location %d' %[register.to_s, left, right, calculate_modified_address(instruction)]) if @logger.debug?\n word.store_value(register, left, right)\n end",
"def write_in_register(instruction)\n op_code, f = extract_op_code_and_modifier(instruction)\n register = select_register_from_op_code(op_code, Instructions::OP_ENTA)\n modified_address = calculate_modified_address(instruction)\n\n if f == Instructions::F_INCA or f == Instructions::F_DECA\n operation = 'increment_value'\n else\n operation = 'store_long'\n end\n if f == Instructions::F_DECA or f == Instructions::F_ENNA\n modified_address = 0 - modified_address\n end\n @logger.debug('Applying operation %s to %s ' % [operation, register]) if @logger.debug?\n register.send(operation, modified_address)\n end",
"def execute_JMPFAR(pointer)\n\t\[email protected]_value = pointer.next_word_value # Segment\n\t\tjump_conditionally_to_signed_displacement(pointer, true) # Offset\n\tend",
"def inst_movq(dst, src)\n if self.class.bits == 64 && xmm_reg?(dst) && src.start_with?('r') && register?(src)\n dst = arg_to_lambda(dst)\n src = arg_to_lambda(src)\n dst[0] = src\n return\n end\n dst, src = check_xmm_sp(dst, src) { raise_unsupported('movq', dst, src) }\n off = src.evaluate(eval_dict)\n (64 / self.class.bits).times do |i|\n dst[i] = sp_based_stack[off + i * size_t]\n end\n end",
"def moveto(x, y)\n @x = x \n @y = y \n @real_x = @x * 128\n @real_y = @y * 128\n @prelock_direction = 0\n end",
"def set_breakpoint(source, pos, condition = nil)\n #This is a stub, used for indexing\n end",
"def set_breakpoint(cm, ip)\n @breakpoint_tracker.on(cm, :ip => ip)\n end",
"def call_ent(reg_key, addr, i_reg, m_spec)\n val = get_mem_addr(addr, i_reg)\n @registers[reg_key].word.from_int(val)\n end",
"def decode_instruction(iseq, ip)\n @iseq = iseq\n @offset = ip\n\n decode\n end",
"def next_instruction\n inst = @program[@current_inst]\n @current_inst += 1\n inst\n end",
"def TXS(address:)\n @stack_pointer = @x_register\n end",
"def insert(pixel, x, y)\n self.matrix[x,y]=pixel\n end",
"def execute_IRET\n\t\[email protected]_value = pop_stack_word\n\t\[email protected]_value = pop_stack_word\n\t\[email protected]_value = pop_stack_word\n\tend",
"def step\n instcode = @memory[@ip]\n raise \"nil opcode encountered\" if instcode.nil?\n\n opcode = instcode % 100\n argcount = ARGCOUNT[opcode] || 0\n addressing_modes = argcount.times.map { |ix| (instcode / (10 ** (ix + 2))) % 10 }\n args = addressing_modes.each_with_index.map do |am, ix|\n raw_arg = @memory[@ip + ix + 1]\n translate_arg(opcode, ix, raw_arg, am)\n end\n\n if TRACE\n STDERR.puts \"#{@id} @ip=#{@ip} @base=#{@base} inst=#{@memory[@ip..@ip+argcount].inspect} opcode=#{opcode} am=#{addressing_modes.inspect} args=#{args.inspect}\"\n end\n\n jump_target = nil\n case opcode\n when 1 # add\n @memory[args[2]] = args[0] + args[1]\n when 2 # mul\n @memory[args[2]] = args[0] * args[1]\n when 3 # in\n if @inputs.any?\n @memory[args[0]] = @inputs.shift\n else\n return :need_input\n end\n when 4 # out\n @outputs << args[0]\n when 5 # jnz\n jump_target = args[1] if args[0] != 0\n when 6 # jz\n jump_target = args[1] if args[0] == 0\n when 7 # lt\n @memory[args[2]] = (args[0] < args[1]) ? 1 : 0\n when 8 # eq\n @memory[args[2]] = (args[0] == args[1]) ? 1 : 0\n when 9 #base\n @base += args[0]\n when 99\n return nil\n else\n raise \"invalid opcode #{opcode} at position #{@ip}\"\n end\n\n if jump_target\n @ip = jump_target\n else\n @ip += argcount + 1\n end\n end",
"def simple_assign(symbol, rexp)\n @engine.assign(symbol.to_s, rexp, nil)\n end",
"def relocate_arena(new_location)\n @arena = new_location\n end",
"def load_in_register (instruction)\n op_code, f = extract_op_code_and_modifier(instruction)\n negate = op_code >= Instructions::OP_LDAN\n register = select_register_from_op_code(op_code,\n negate ? Instructions::OP_LDAN : Instructions::OP_LDA)\n word = extract_word_from_memory(instruction)\n word.negate if negate\n left, right = explode_f(f)\n @logger.debug('Setting %s (%d,%d) from word at location %d into register' %[word.to_s, left, right, calculate_modified_address(instruction)]) if @logger.debug?\n register.load_value(word, left, right)\n end",
"def set_sp(sp)\n pp('Patch the Stack Pointer') do\n reg(:sp).write!(sp)\n end\n end",
"def set_cursor_position locator, position\r\n command 'setCursorPosition', locator, position\r\n end",
"def set(x, y)\n @registers[x] = @registers.fetch(y, y.to_i)\n end",
"def put_val(val, addr)\n idx = rand(14) # 0~13\n set_reg(idx, addr)\n scall(:set_tid_address, val)\n scall(:prctl, PR_GET_TID_ADDRESS, Reg.new(idx))\nend",
"def set_instruction\r\n @instruction = Instruction.find(params[:id])\r\n end",
"def parse_and_set_offset(offset)\n if @handle.ptr == nil\n raise \"this is disposed\"\n end\n result = Native.RunEditor_parse_and_set_offset(@handle.ptr, offset)\n result\n end",
"def set_const_at\n <<-CODE\n next_literal;\n t2 = stack_pop();\n t3 = stack_pop();\n stack_push(cpu_const_set(state, c, _lit, t2, t3));\n CODE\n end",
"def resolveJMP(command)\r\n splitString = command.split(' ')\r\n currSymbol = splitString[1]\r\n intVal = Integer(currSymbol)\r\n @PC = intVal\r\n puts \"Changing control to instruction at \" + @PC.to_s\r\n end",
"def assign_bytecode(g, value)\n g.compile_error \"Can't change the value of self\" if @name == :self\n\n g.push_cpath_top\n g.find_const :Apricot\n g.send :current_namespace, 0\n g.push_literal @name\n value.bytecode(g)\n g.send :set_var, 2\n end",
"def move_to (x, y)\n @x, @y = x, y\n end",
"def to_mem( source , from )\n reg_to_slot = Risc.reg_to_slot(source , from , register, index)\n compiler.add_code(reg_to_slot) if compiler\n reg_to_slot.register\n end",
"def []=(loc, idx, val)\n puts \"#{ip} <- #{val}\" if debug\n case flag(idx)\n when :position then write(loc, val)\n when :relative then write(loc + relative_base, val)\n else\n raise \"flag #{flag(idx)} for assignment\"\n end\n end",
"def set_position at\n @position = at\n @codes.each do |code|\n begin\n code.set_position( at)\n rescue => e\n puts \"BLOCK #{self.to_s[0..5000]}\"\n raise e\n end\n raise code.inspect unless code.byte_length\n at += code.byte_length\n end\n end",
"def int2ptr(val, ty, name = \"\")\n Instruction.from_ptr(C.build_int_to_ptr(self, val, LLVM::Type(ty), name))\n end",
"def set_instruction\n @instruction = Instruction.find(params[:id])\n end",
"def move_to(x, y)\n super(x, y)\n update_memory!(self.memory)\n end",
"def ass_ip(instance_id, ip)\n @connection.get 'AssociateEip', {\n eip: ip,\n instance: instance_id,\n zone: 'sh1a'\n }\n end",
"def set_breakpoint(cm, ip, condition=nil)\n @breakpoint_tracker.on(cm, :ip => ip, :condition => condition)\n end",
"def execute_DynamicJump\n method = get_register(@instruction.register)\n log.debug \"Register at: #{@instruction.register} , has #{method.class}\"\n pos = Position.get(method.binary)\n log.debug \"Jump to binary at: #{pos} #{method.name}:#{method.binary.class}\"\n raise \"Invalid position for #{method.name}\" unless pos.valid?\n pos = pos + Parfait::BinaryCode.byte_offset\n set_pc( pos )\n false\n end",
"def jump_conditionally_to_signed_displacement(operand, condition)\n\t\[email protected]_value = operand.value if condition\n\tend",
"def initialize\n @instr_type = UNINITIALIZED\n @addr = UNINITIALIZED\n end",
"def []=(offset, value)\n iterator = self.iterator\n iterator[offset] = value\n end",
"def store(ptr, val)\n if [email protected]_key?(ptr)\n raise \"Address #{ptr} was never allocated!\"\n end\n\n @store[ptr] = val\n end",
"def define(instruction)\n @def_instr = instruction\n end",
"def at(p0) end",
"def ld_mnn_sp\n @mmu.word[next_word] = sp\n @clock += 5\n end",
"def begin_assign\n assign_stack.push(true)\n end",
"def []=( addr, val )\n range( addr ).value = val\n end",
"def set_data_at(index,raw_data)\n $test_logger.log(\"Set data at location #{index}\")\n @data[index] = BioPacket.swap_dword(raw_data)\n build_cmd\n end",
"def moveto(x, y)\n @ox = @x = x\n @oy = @y = y\n @real_x = @x * 128\n @real_y = @y * 128\n end",
"def execute_RET(operand=nil)\n\t\[email protected]_value = pop_stack_word\n\t\[email protected] += operand.value if operand\n\tend",
"def setPosition _obj, _args\n \"_obj setPosition _args;\" \n end",
"def result= value\n raise \"called\"\n class_for(MoveInstruction).new(value , self , :opcode => :mov)\n end",
"def do_instruction(opcode)\n sym_op = get_opcode(opcode)\n\n # Byte components\n b1 = (opcode & 0xf000) >> 12\n b2 = (opcode & 0x0f00) >> 8\n b3 = (opcode & 0x00f0) >> 4\n b4 = (opcode & 0x000f)\n\n # print \"Op: \", sym_op, \" | \"\n # print \"Desc: \", get_opcode_desc(opcode), \"\\n\"\n\n # Massive opcode conditional incoming.\n case sym_op\n\n when \"00E0\"\n # Clear the screen.\n @display.each do |row|\n row.each do |col|\n col = 0\n end\n end\n\n when \"00EE\"\n # Return from a subroutine.\n @instruction_ptr = @stack[@stack_ptr]\n @stack_ptr -= 1;\n\n when \"0NNN\"\n # This one isn't actually used by games. Skip it.\n\n when \"1NNN\"\n # Jump to address NNN.\n @instruction_ptr = opcode & 0x0fff\n\n when \"2NNN\"\n # Call subroutine at NNN.\n @stack_ptr += 1\n @stack[@stack_ptr] = @instruction_ptr\n @instruction_ptr = opcode & 0x0fff\n\n when \"3XNN\"\n # Skips next instruction if VX == NN.\n if @registers[b2] == opcode & 0x00ff\n @instruction_ptr += 2\n end\n\n when \"4XNN\"\n # Skips next instruction if VX != NN.\n if @registers[b2] != opcode & 0x00ff\n @instruction_ptr += 2\n end\n\n when \"5XY0\"\n # Skips next instruction if VX == VY.\n if @registers[b2] == @registers[b3]\n @instruction_ptr += 2\n end\n\n when \"6XNN\"\n # Sets VX to NN.\n @registers[b2] = opcode & 0x00ff\n\n when \"7XNN\"\n # Adds NN to VX.\n @registers[b2] += opcode & 0x00ff\n\n when \"8XY0\"\n # Sets VX to VY.\n @registers[b2] += @registers[b3]\n\n when \"8XY1\"\n # Sets VX to (VX or VY).\n @registers[b2] |= @registers[b3]\n\n when \"8XY2\"\n # Sets VX to (VX and VY).\n @registers[b2] &= @registers[b3]\n\n when \"8XY3\"\n # Sets VX to (VX xor VY).\n @registers[b2] ^= @registers[b3]\n\n when \"8XY4\"\n # Adds VY to VX. Sets VF to 1 when carry, 0 otherwise.\n # Only keep lowest 8 bits.\n @registers[b2] += @registers[b3]\n if @registers[b2] > 0xff\n @registers[0xf] = 1\n else\n @registers[0xf] = 0\n end\n @registers[b2] &= 0xff\n\n when \"8XY5\"\n # Subtracts VY from VX. Sets VF to 0 when borrow, 1 otherwise.\n # Only keep lowest 8 bits.\n @registers[b2] -= @registers[b3]\n if @registers[b2] < 0\n @registers[0xf] = 0\n else\n @registers[0xf] = 1\n end\n @registers[b2] &= 0xff\n\n when \"8XY6\"\n # Shifts VX right by one. Sets VF to the LSB of VX before the shift.\n @registers[0xf] = @registers[b2] % 2\n @registers[b2] >>= 1\n\n when \"8XY7\"\n # Sets VX to (VY - VX). Sets VF to 0 when borrow, otherwise 1.\n # Only keep lowest 8 bits.\n @registers[b2] = @registers[b3] - @registers[b2]\n if @registers[b2] < 0\n @registers[0xf] = 0\n else\n @registers[0xf] = 1\n end\n @registers[b2] &= 0xff\n\n when \"8XYE\"\n # Shifts VX left by one. Sets VF to the MSB of VX before the shift.\n @registers[0xf] = (@registers[b2] / 0b1000 > 0 ? 1 : 0)\n @registers[b2] = @registers[b2] << 1 & 0b0111\n\n when \"9XY0\"\n # Skips next instruction if VX == VY.\n if @registers[b2] != @registers[b3]\n @instruction_ptr += 2\n end\n\n when \"ANNN\"\n # Set address register to NNN.\n @addr_register = opcode & 0x0fff\n\n when \"BNNN\"\n # Set instruction pointer to address NNN + V0\n @instruction_ptr = (opcode & 0x0fff) + @registers[0]\n\n when \"CXNN\"\n # Set VX to a random number and NN.\n @registers[b2] = [*0..(opcode & 0x00ff)].sample\n\n when \"DXYN\"\n # TODO this should draw sprites, not just memory bits.\n # Draw N bytes of sprites starting from address register I,\n # at coordinates VX, VY. XORd onto screen. If any sprites overwritten,\n # set VF to 1, otherwise, 0. Wrap sprites if they go outside coordinates.\n overwritten = 0\n for i in 0..b4\n col_offset = (b2 + i) / 0x40\n new_row = (b3 + col_offset) % 0x20\n new_col = b2 % 0x40\n old_pixel = @display[new_row][new_col]\n new_pixel = @memory[@addr_register+i]\n result = old_pixel ^ new_pixel\n\n @display[new_row][new_col] = result\n if old_pixel == 1 and new_pixel == 0\n overwritten = 1\n end\n end\n\n @registers[0xf] = overwritten\n\n when \"EX9E\"\n # Skip the next instruction if the key stored in VX is pressed.\n if keypad[b2] == 1\n @instruction_ptr += 2\n end\n\n when \"EXA1\"\n # Skip the next instruction if the key stored in VX isn't pressed.\n if keypad[b2] == 0\n @instruction_ptr += 2\n end\n\n when \"FX07\"\n # Set VX to the value of the delay timer.\n @registers[b2] = @timers[:delay]\n\n # TODO\n when \"FX0A\"\n # A key press is awaited, and then stored in VX.\n\n when \"FX15\"\n # Sets the delay timer to VX.\n @timers[:delay] = b2\n\n when \"FX18\"\n # Sets the sound timer to VX.\n @timers[:sound] = b2\n\n when \"FX1E\"\n # Adds VX to I\n @instruction_ptr += b2\n\n # TODO\n when \"FX29\"\n # Set I to the location of the sprite for the character in VX. Characters\n # 0-F (in hexadecimal) are represented by a 4x5 font.\n\n # TODO\n when \"FX33\"\n # Store the BCD representation of Vx in memory locations I, I+1, and I+2.\n # The interpreter takes the decimal value of Vx, and places the hundreds\n # digit in memory at location in I, the tens digit at location I+1, and\n # the ones digit at location I+2.\n\n when \"FX55\"\n # Store V0 to VX in memory starting at address I.\n for i in 0..b2\n @memory[@instruction_ptr + i] = @registers[i]\n end\n\n when \"FX65\"\n # Fill V0 to VX with values from memory starting at address I.\n for i in 0..b2\n @registers[i] = @memory[@instruction_ptr + i]\n end\n end\n end",
"def execute_current_instruction\n case read_register(REGISTER_C0)\n when SUM\n write_register(REGISTER_R0, read_register(read_register(REGISTER_D0)) + read_register(read_register(REGISTER_D1)))\n when COPY\n write_register(read_register(REGISTER_D1), read_register(read_register(REGISTER_D0)))\n when WRITE\n write_register(read_register(REGISTER_D1), read_register(REGISTER_D0))\n when JUMP\n write_register(REGISTER_M0, read_register(read_register(REGISTER_D0)))\n when JUMPX\n write_register(REGISTER_M0, read_register(read_register(REGISTER_D0))) if read_register(read_register(REGISTER_D1)) == 0\n when READ_MEM\n write_register(REGISTER_M4, Memory::READ)\n write_register(REGISTER_M5, read_register(read_register(REGISTER_D0)))\n write_register(REGISTER_M6, read_register(REGISTER_D1))\n when WRITE_MEM\n write_register(REGISTER_M4, Memory::WRITE)\n write_register(REGISTER_M5, read_register(read_register(REGISTER_D0)))\n write_register(REGISTER_M6, read_register(read_register(REGISTER_D1)))\n else\n raise UnknownInstruction.new(\"Instruction '#{read_register(REGISTER_C0)}' is undefined\")\n end\n end",
"def moveto(x, y)\n @ox = @x = x\n @oy = @y = y \n @real_x = @x * 128\n @real_y = @y * 128 \n end",
"def call_ioc(reg_key, addr, i_reg, device_num)\n change_amount = get_mem_addr(addr, i_reg)\n dev = @computer.get_device(device_num)\n dev.move_word_pointer(change_amount)\n end",
"def put_dest(mode, dst_r)\n case mode\n when 1 # Register direct\n temp = @reg[dst_r]\n x = yield temp\n @reg[dst_r] = x\n when 2 # Indirect\n dst_address = @mem.read(@pc)\n @pc += 1\n temp = @mem.read(dst_address)\n new_value = yield temp\n @mem.write(dst_address, new_value)\n when 3 # Register indirect\n dst_address = @reg[dst_r]\n temp = @mem.read(dst_address)\n new_value = yield temp\n @mem.write(dst_address, new_value)\n end\n end",
"def set_position(y = 1, x = 1, &block)\n Position.new(y, x).to_s(&block)\n end",
"def goto(obj, tile=nil)\r\n @x = obj.x\r\n @y = obj.y\r\n @mapx = tile.mapx\r\n @mapy = tile.mapy\r\n @tile = tile\r\n if @tile != nil\r\n @tile.occupy(self)\r\n end\r\n end",
"def call(jmp_addr, no_params, level) \n base << [level, sp-no_params+1]\n s[base.last[1]-1] = ni + 4\n self.ni = jmp_addr\n @jump = true\n end",
"def set_ivar\n <<-CODE\n next_literal;\n t2 = stack_pop();\n object_set_ivar(state, c->self, _lit, t2);\n stack_push(t2);\n CODE\n end",
"def store(val, at)\n flat(pop_rcx, at, pop_rdx, val, mov_prcx_rdx)\nend"
] | [
"0.6128202",
"0.587118",
"0.5754626",
"0.5651612",
"0.5630579",
"0.5609524",
"0.55176514",
"0.54754156",
"0.54529804",
"0.54029834",
"0.53694016",
"0.5329408",
"0.5328008",
"0.5300557",
"0.5297072",
"0.5297072",
"0.5253452",
"0.523424",
"0.5206441",
"0.5199096",
"0.51965857",
"0.51732445",
"0.51358837",
"0.5130488",
"0.5127601",
"0.5116256",
"0.51096165",
"0.50962824",
"0.5092445",
"0.5090572",
"0.50883335",
"0.5081053",
"0.50729483",
"0.50634986",
"0.50634986",
"0.50634986",
"0.50549465",
"0.5054457",
"0.505127",
"0.5045974",
"0.5030544",
"0.50270694",
"0.50264895",
"0.5022372",
"0.5015184",
"0.50091773",
"0.49830925",
"0.49793652",
"0.49651942",
"0.4964788",
"0.49607778",
"0.495079",
"0.4948136",
"0.49340218",
"0.49305627",
"0.4927238",
"0.49123445",
"0.49076012",
"0.49055418",
"0.4902158",
"0.4895773",
"0.48896977",
"0.48827854",
"0.48377675",
"0.48375878",
"0.4837447",
"0.4827475",
"0.4824185",
"0.48187047",
"0.4815566",
"0.4806517",
"0.47999853",
"0.47991925",
"0.47954243",
"0.47788924",
"0.47555032",
"0.4755359",
"0.4749579",
"0.47485492",
"0.47471118",
"0.47366065",
"0.4728085",
"0.47213545",
"0.47200593",
"0.46928793",
"0.46925077",
"0.4691316",
"0.46910125",
"0.46849895",
"0.46830842",
"0.46830297",
"0.46802077",
"0.467997",
"0.46791062",
"0.4675626",
"0.46749693",
"0.4673859",
"0.46586773"
] | 0.635694 | 2 |
GET /options/new GET /options/new.xml | def new
@option = OptionModel.new
respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @option }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new\n @option = Option.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @option }\n end\n end",
"def new\n @option = Option.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @option }\n end\n end",
"def new\n @opt = Opt.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @opt }\n end\n end",
"def new\n @auto_option = AutoOption.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @auto_option }\n end\n end",
"def new\n @poll_option = PollOption.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @poll_option }\n end\n end",
"def new\n @option = Option.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @option }\n end\n end",
"def new\n @option = Option.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @option }\n end\n end",
"def new\n @option = Vger::Resources::Mrf::Option.new\n respond_to do |format|\n format.html\n end\n end",
"def new\n @item_option = ItemOption.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @item_option }\n end\n end",
"def new\n @question_option = QuestionOption.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @question_option }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => new_vurl }\n end\n end",
"def new\n @survey_option = SurveyOption.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @survey_option }\n end\n end",
"def new(options) \n Client.get(\"/patterns/new\", :query => options)\n end",
"def new\n @price_option_name = PriceOptionName.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @price_option_name }\n end\n end",
"def new\n @payment_option = PaymentOption.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @payment_option }\n end\n end",
"def new\n @option = Vger::Resources::Suitability::Option.new\n respond_to do |format|\n format.html\n end\n end",
"def new\n @goods_auto_option = GoodsAutoOption.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @goods_auto_option }\n end\n end",
"def new\n @reunion_option = ReunionOption.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @reunion_option }\n end\n end",
"def new\n @preset = Preset.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @preset }\n end\n end",
"def new\n @hybridization_option = HybridizationOption.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @hybridization_option }\n end\n end",
"def new\n @poll_options_set = PollOptionsSet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @poll_options_set }\n end\n end",
"def new\n @merchandise_option_set = MerchandiseOptionSet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @merchandise_option_set }\n end\n end",
"def create\n @opt = Opt.new(params[:opt])\n\n respond_to do |format|\n if @opt.save\n flash[:notice] = 'Opt was successfully created.'\n format.html { redirect_to(@opt) }\n format.xml { render :xml => @opt, :status => :created, :location => @opt }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @opt.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def new\n @poll = Poll.new\n @poll.poll_options = PollOptions.new\n @title = \"Create a new poll\"\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @poll }\n end\n end",
"def new\n @auto_option = AutoOption.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @auto_option }\n end\n end",
"def new\n respond_to do |format|\n format.html\n format.xml\n end\n end",
"def new\n @quick_poll_option = QuickPollOption.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quick_poll_option }\n end\n end",
"def new\n @option_value = OptionValue.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @option_value }\n end\n end",
"def new\n @protocol = Protocol.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @protocol }\n end\n end",
"def new\n @via = Via.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @via }\n end\n end",
"def new(options) \n Client.get(\"/colors/new\", :query => options)\n end",
"def new \n @how_to = HowTo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render xml: @how_to }\n end\n end",
"def new\n @uri_type = UriType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @uri_type }\n end\n end",
"def new\n @selection = Selection.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @selection }\n end\n end",
"def new\n @modes = Mode.all\n @mode = Mode.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @mode }\n end\n end",
"def new\n @reqinfo = Reqinfo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @reqinfo }\n end\n end",
"def new\n @howto = Howto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @howto }\n end\n end",
"def new\n @questions_option = QuestionsOption.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @questions_option }\n end\n end",
"def new\n @tso = Tso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @tso }\n end\n end",
"def new\n\t@option = Option.new\n\t@question=Question.find(params[:question_id])\n\t@questionnaire_question=QuestionnaireQuestion.find_by_question_id(@question.id)\n\t@questionnaire_id=@questionnaire_question.questionnaire_id\n\trespond_to do |format|\n\t format.html # new.html.erb\n\t format.xml { render :xml => @option }\n\tend\n end",
"def new\n @service_version = ServiceVersion.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @service_version }\n end\n end",
"def new\n @node = Node.scopied.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml \n end\n end",
"def new\n @prop = Prop.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @prop }\n end\n end",
"def new\n @countries = Countries.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @countries }\n end\n end",
"def new\n @lookup_set = LookupSet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lookup_set }\n end\n end",
"def new\n @attr_type = AttrType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @attr_type }\n end\n end",
"def new\n @selector_site = SelectorSite.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @selector_site }\n end\n end",
"def new\n @service = Service.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @show }\n end\n end",
"def new\n @title = \"New Operations\"\n @operation = Operation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @operation }\n end\n end",
"def new\n @route = Route.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @route }\n end\n end",
"def new\n @route = Route.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @route }\n end\n end",
"def new\n @resource = Resource.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @resource }\n end\n end",
"def new\n @resource = Resource.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @resource }\n end\n end",
"def new\n @resource = Resource.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @resource }\n end\n end",
"def new\n @url_migration = UrlMigration.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @url_migration }\n end\n end",
"def new\n @mainoption = Mainoption.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @mainoption }\n end\n end",
"def new\n @node = Node.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end",
"def new\n @node = Node.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @node }\n end\n end",
"def new\n @recurso = Recurso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @recurso }\n end\n end",
"def new\n @protocolo = Protocolo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @protocolo }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @instituto }\n end\n end",
"def new\n @config_file = ConfigFile.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @config_file }\n end\n end",
"def new\n @omatsuri = Omatsuri.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @omatsuri }\n end\n end",
"def new\n @conf = Conf.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @conf }\n end\n end",
"def new\n respond_to do |format|\n format.html { render :layout => 'application' }\n format.xml { render :xml => @recommand }\n end\n end",
"def new\n @curta = Curta.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @curta }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @ontology }\n end\n end",
"def new\n @peca = Peca.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @peca }\n end\n end",
"def new\n @setting = Setting.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @setting }\n end\n end",
"def new\n @setting = Setting.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @setting }\n end\n end",
"def new\n @discovery = Discovery.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @discovery }\n end\n end",
"def new\n @rails_url = RailsUrl.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @rails_url }\n end\n end",
"def new\n @pool = Pool.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @pool }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @chronopay_link }\n end\n end",
"def new\n @thing = Thing.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @thing }\n end\n end",
"def new\n @lotto_type = LottoType.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @lotto_type }\n end\n end",
"def new\n @info = Info.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @info }\n end\n end",
"def new\n @info = Info.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @info }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @eco_parameter }\n end\n end",
"def new\n @car_option = CarOption.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @car_option }\n end\n end",
"def new\n @domain = Domain.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @domain }\n end\n end",
"def new\n @want = Want.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @want }\n end\n end",
"def new\n @periodista = Periodista.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @periodista }\n end\n end",
"def new\n @descriptor_generico = DescriptorGenerico.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @descriptor_generico }\n end\n end",
"def new\n @add_on = AddOn.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @add_on }\n end\n end",
"def new\n @seta = Seta.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @seta }\n end\n end",
"def new\n @novel = Novel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @novel }\n end\n end",
"def new\n @subway = Subway.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @subway }\n end\n end",
"def new\n @permiso = Permiso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @permiso }\n end\n end",
"def new\n @service_length = ServiceLength.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @service_length }\n end\n end",
"def new\n @request = Request.new\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @request }\n end\n end",
"def new\n @radio = Radio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @radio }\n end\n end",
"def new\n @radio = Radio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @radio }\n end\n end",
"def new\n @poll = Poll.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @poll }\n end\n end",
"def new\n \n load_quiz_section_and_question\n @option = Option.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @option }\n end\n end",
"def new\n @request = Request.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @request }\n end\n end",
"def new\n @request = Request.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @request }\n end\n end",
"def new\n @request = Request.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @request }\n end\n end"
] | [
"0.7570545",
"0.7570545",
"0.74550205",
"0.701233",
"0.6894441",
"0.68835485",
"0.68835485",
"0.68163115",
"0.6813543",
"0.6754595",
"0.67398703",
"0.67339754",
"0.6731938",
"0.65230775",
"0.65215486",
"0.6495427",
"0.6408086",
"0.63814545",
"0.6369065",
"0.63475317",
"0.6323063",
"0.63164264",
"0.63052344",
"0.62976664",
"0.6291562",
"0.62690943",
"0.6239125",
"0.6233989",
"0.62044644",
"0.6196764",
"0.61933213",
"0.61886245",
"0.6177856",
"0.617333",
"0.61615527",
"0.615647",
"0.61536807",
"0.61536753",
"0.61466414",
"0.6136534",
"0.61331075",
"0.6126224",
"0.6098312",
"0.60961914",
"0.6094633",
"0.6086606",
"0.608116",
"0.6070368",
"0.6057656",
"0.6056022",
"0.60480404",
"0.6045274",
"0.6045274",
"0.60442585",
"0.604424",
"0.604424",
"0.6039353",
"0.6034742",
"0.6032358",
"0.6032358",
"0.60258245",
"0.6023839",
"0.6022305",
"0.60202265",
"0.60187",
"0.6016772",
"0.6016456",
"0.60160613",
"0.601393",
"0.60086113",
"0.6004933",
"0.6004933",
"0.6002402",
"0.59991074",
"0.5996287",
"0.5979048",
"0.5977951",
"0.5976167",
"0.5969641",
"0.5969641",
"0.59662515",
"0.596466",
"0.5960861",
"0.5960765",
"0.595423",
"0.59486437",
"0.59476316",
"0.5942594",
"0.5939544",
"0.59395295",
"0.59385693",
"0.5936997",
"0.59365",
"0.5934748",
"0.5934748",
"0.59331656",
"0.5933052",
"0.5926148",
"0.5926148",
"0.5926148"
] | 0.73395056 | 3 |
POST /options POST /options.xml | def create
@option = OptionModel.new(params[:option_model])
saved = @option.save
session[:option_model] = @option.to_hash
respond_to do |format|
if saved
format.html { redirect_to(@option) }
format.xml { render :xml => @option, :status => :created, :location => @option }
else
format.html { render :action => "new" }
format.xml { render :xml => @option.errors, :status => :unprocessable_entity }
end
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post options\n rest_request({ method: :post }.merge(options))\n end",
"def post options\n rest_request({ method: :post }.merge(options))\n end",
"def options!\n request! :options\n end",
"def options\n\t\t# we don't support sending a payload in options' body.\n\t\treq = Net::HTTP::Options.new(@uri.path)\n\t\tdo_http req\n\tend",
"def set_config(options)\n return @api.do_request(\"POST\", get_base_api_path() + \"/config\", options)\n end",
"def post(options = {})\n url = build_url(options)\n ret = post_response(url, options)\n ret\n end",
"def option_params\n params.require(:option).permit(:name, :value)\n end",
"def options_to_patch_request(options)\n json = []\n Array[options.delete(:remove)].flatten.compact.each { |i| json << {'op' => 'remove', 'path' => \"/#{camelize_words(i)}\"} }\n options.each { |k, v| json << {'op' => 'add', 'path' => \"/#{camelize_words(k)}\", 'value' => v} }\n json.collect { |i| Hash[i.each_pair.to_a] }\n end",
"def options=(opts)\n @parsed_options = opts\n write_attribute :options, @parsed_options.to_json\n end",
"def add_options; end",
"def option_params\n params.require(:option).permit(:name, :description, :value_x, :value_y)\n end",
"def post(path, options={})\n request :post, path, options\n end",
"def settings\n request(Resources::RESOURCE_SETTINGS, HTTP_METHOD_POST)\n end",
"def create\n @opt = Opt.new(params[:opt])\n\n respond_to do |format|\n if @opt.save\n flash[:notice] = 'Opt was successfully created.'\n format.html { redirect_to(@opt) }\n format.xml { render :xml => @opt, :status => :created, :location => @opt }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @opt.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options; end",
"def options() end",
"def options(request, response)\n OK\n end",
"def process_options(cli, request)\r\n vprint_status(\"OPTIONS #{request.uri}\")\r\n headers = {\r\n 'MS-Author-Via' => 'DAV',\r\n 'DASL' => '<DAV:sql>',\r\n 'DAV' => '1, 2',\r\n 'Allow' => 'OPTIONS, TRACE, GET, HEAD, DELETE, PUT, POST, COPY, MOVE, MKCOL, PROPFIND, PROPPATCH, LOCK, UNLOCK, SEARCH',\r\n 'Public' => 'OPTIONS, TRACE, GET, HEAD, COPY, PROPFIND, SEARCH, LOCK, UNLOCK',\r\n 'Cache-Control' => 'private'\r\n }\r\n resp = create_response(207, \"Multi-Status\")\r\n headers.each_pair {|k,v| resp[k] = v }\r\n resp.body = \"\"\r\n resp['Content-Type'] = 'text/xml'\r\n cli.send_response(resp)\r\n end",
"def post_update!(options = {})\n rsp = post(prepare_update_xml(options))\n success?(rsp.body) or log_error(rsp.body)\n end",
"def export_option\n s = \"\"\n output_xml_node = get_xml_node(\"SettingsOptions\");\n\n s << c(output_xml_node,\"options_displacement\",\"geom_displacement\")\n # s << cnv(\".\")\n s << c(output_xml_node,\"options_dontRenderImage\",\"gi_dontRenderImage\")\n s << c(output_xml_node,\"options_displacement\",\"geom_displacement\")\n s << c(output_xml_node,\"options_filterMaps\",\"mtl_filterMaps\")\n s << c(output_xml_node,\"options_geom_backfaceCull\",\"geom_backfaceCull\")\n s << c(output_xml_node,\"options_glossyEffects\",\"mtl_glossy\")\n s << c(output_xml_node,\"options_glossyEffects\",\"mtl_glossy\")\n\n\n# s << c(output_xml_node,\"options_defaultLights\",\"default\")\n# s << c(output_xml_node,\"options_displacement\",\"default\")\n# s << c(output_xml_node,\"options_dontRenderImage\",\"default\")\n# s << c(output_xml_node,\"options_filterMaps\",\"default\")\n# s << c(output_xml_node,\"options_geom_backfaceCull\",\"default\")\n# s << c(output_xml_node,\"options_glossyEffects\",\"default\")\n# s << c(output_xml_node,\"options_hiddenLights\",\"default\")\n# s << c(output_xml_node,\"options_lights\",\"default\")\n# .options_limitDepth (alias for options_overrideDepth_on)\n# s << c(output_xml_node,\"options_maps\",\"default\")\n# .options_maxDepth (alias for options_overrideDepth)\n# s << c(output_xml_node,\"options_maxRayIntensity\",\"default\")\n# s << c(output_xml_node,\"options_maxRayIntensity_on (options_clampRayIntensity)\",\"default\")\n# s << c(output_xml_node,\"options_mtl_filterMaps_indirect\",\"default\")\n# s << c(output_xml_node,\"options_overrideDepth\",\"default\")\n# s << c(output_xml_node,\"options_overrideDepth_on\",\"default\")\n# s << c(output_xml_node,\"options_overrideMtl_mtl\",\"default\")\n# s << c(output_xml_node,\"options_overrideMtl_on\",\"default\")\n# s << c(output_xml_node,\"options_probabilisticLights\",\"default\")\n# s << c(output_xml_node,\"options_probabilisticLightsCount\",\"default\")\n# s << c(output_xml_node,\"options_ray_bias\",\"default\")\n# s << c(output_xml_node,\"options_reflectionRefraction\",\"default\")\n# s << c(output_xml_node,\"options_shadows\",\"default\")\n# s << c(output_xml_node,\"options_showGIOnly\",\"default\")\n# s << c(output_xml_node,\"options_transpCutoff\",\"default\")\n# s << c(output_xml_node,\"options_transpMaxLevels\",\"default\")\n# s << c(output_xml_node,\"options_use3dsMaxPhotometricUnits\",\"default\")\n# s << c(output_xml_node,\"options_useLegacyModels\",\"default\")\n# s << c(output_xml_node,\"options_ui_view\",\"default\")\n\n puts s\n\nend",
"def post(uri, options = T.unsafe(nil)); end",
"def create\n @option = Option.new(params[:option])\n @option.question_id = @question.id\n\n respond_to do |format|\n if @option.save\n flash[:notice] = 'Option was successfully created.'\n format.html { redirect_to(question_option_path(@question, @option)) }\n format.xml { render :xml => @option, :status => :created, :location => @option }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @option.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def post(path, options = {})\n request(:post, path, options)\n end",
"def post(path, options = {})\n request(:post, path, options)\n end",
"def post(path, options = {})\n request(:post, path, options)\n end",
"def options\n data[:options]\n end",
"def process_options\n \n end",
"def post(path, options = {})\n request(:post, path, options)\n end",
"def post(path, options = {})\n request(:post, path, options)\n end",
"def post(path, options = {})\n request(:post, path, options)\n end",
"def options(opt)\n end",
"def post_config(url_prefix, xml)\n post_data(url_prefix, xml, 'application/xml;charset=UTF-8')\n end",
"def option_params\n params.require(:option).permit(:auto_complete, :validate_address, :pobox_warning, :streetnum_warning, :domain)\n end",
"def option_params\n params.permit(:name, :value)\n end",
"def options; [] end",
"def create\n @survey_option = SurveyOption.new(params[:survey_option])\n\n respond_to do |format|\n if @survey_option.save\n format.html { redirect_to(@survey_option, :notice => 'Survey option was successfully created.') }\n format.xml { render :xml => @survey_option, :status => :created, :location => @survey_option }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @survey_option.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def send options\n nuntium.send_ao(options)\n end",
"def options(changes = {}, optionname = nil, optionvalue = nil, reset = false)\n form_data = { 'action' => 'options', 'token' => get_options_token }\n\n if changes.present?\n form_data['change'] = changes.map { |key, value| \"#{key}=#{value}\" }.join('|')\n end\n\n if optionname.present?\n form_data[optionname] = optionvalue\n end\n\n if reset\n form_data['reset'] = true\n end\n\n res, dummy = make_api_request(form_data)\n res\n end",
"def serialize_options(options)\n options.collect {|k,v| \"#{k}=#{CGI.escape(v.to_s)}\"}.join('&')\n end",
"def create\n @option = @question.options.new(option_params)\n authorize(@option)\n respond_to do |format|\n if @option.save\n format.html { redirect_to question_options_url(@option.question), notice: \"Option was successfully created.\" }\n format.json { render :show, status: :created, location: question_options_url(@option.question) }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @option.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post(path, options={}, format=format)\n request(:post, path, options, format)\n end"
] | [
"0.66542524",
"0.66542524",
"0.6446557",
"0.6011126",
"0.5971675",
"0.5816911",
"0.5788307",
"0.5736625",
"0.56720096",
"0.5657573",
"0.5641129",
"0.564042",
"0.5603561",
"0.55975896",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55861926",
"0.55797607",
"0.5571885",
"0.5559563",
"0.54967386",
"0.54928476",
"0.5492227",
"0.5491673",
"0.5479279",
"0.5479279",
"0.5479279",
"0.54699427",
"0.5469554",
"0.54675514",
"0.54675514",
"0.54675514",
"0.54644114",
"0.54615706",
"0.54535645",
"0.54506993",
"0.54432863",
"0.5442095",
"0.54332674",
"0.54206765",
"0.5419774",
"0.54085064",
"0.54024017"
] | 0.0 | -1 |
and returns an Array with the same number of elements, and each element has the running total from the original Array. | def running_total(arr)
new_arr = []
running_total = arr[0]
arr.each_with_index do |element, index|
new_arr.push(running_total)
running_total = running_total + arr[index + 1].to_s.to_i
end
new_arr
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def running_total(array)\r\n new_arr = []\r\n total = 0\r\n array.map do |x|\r\n total += x\r\n new_arr << total\r\n end\r\n new_arr\r\n end",
"def running_total(array)\n run_total = []\n \n index = 1\n while index <= array.length\n element = array.slice(0,index)\n run_total << element.inject(:+)\n index += 1\n end\n run_total\nend",
"def running_total(array)\n total = 0\n new_array = []\n while array.size > 0\n total += array.shift\n new_array << total\n end\n new_array\nend",
"def running_total arr\n totals = []\n sum = 0\n arr.each do |elm|\n sum += elm\n totals << sum\n end\n totals\nend",
"def running_total(array)\n result = []\n array.each_index do |i|\n result[i] = (0..i).to_a.map { |e| array[e] }.inject(:+)\n end\n result\nend",
"def running_total(array)\n sum = 0\n new_array = []\n array.each do |num|\n sum += num\n new_array << sum\n end\n new_array\nend",
"def running_total(array)\n new_array = []\n i = 0\n while i <= array.length - 1\n new_array << array[0..i].reduce(:+)\n i += 1\n end\n new_array\nend",
"def running_total(array)\n result = []\n count = 0\n total = 0\n\n while count < array.size\n total += array[count]\n result << total\n count += 1\n end\n result\nend",
"def running_total(array)\n new_array = []\n sum = 0\n count = 0\n\n while count < array.size\n array.each do |num|\n sum += num\n new_array << sum\n count += 1\n end\n end\n new_array\nend",
"def running_total(array)\n array.map.with_index { |e, i| array[0..i].reduce(:+) }\nend",
"def running_total(array)\n output = []\n return output if array.empty?\n output[0] = array[0]\n counter = 1\n\n while counter < array.size\n output << (output[counter - 1] + array[counter])\n counter += 1\n end\n output\n end",
"def running_total(array)\n sum = 0\n running_total = []\n\n array.each do |element|\n sum += element\n running_total << sum\n end\n\n running_total\nend",
"def running_total(arr)\n res = []\n running_total = 0\n\n arr.each do |element|\n running_total += element\n res << running_total\n end\n\n res\nend",
"def running_total(old_array)\n counter = 0\n new_array = []\n loop do \n break if counter >= old_array.length\n if counter == 0\n new_array[counter] = old_array[counter]\n else \n new_array[counter] = old_array[counter] + new_array[counter-1]\n end\n counter += 1\n end\n new_array\nend",
"def running_total(input_array)\n sum = 0 # => 0, 0, 0, 0\n new_array = input_array.map do |value| # => [2, 5, 13], [14, 11, 7, 15, 20], [3], []\n sum += value # => 2, 7, 20, 14, 25, 32, 47, 67, 3\n end # => [2, 7, 20], [14, 25, 32, 47, 67], [3], []\nend",
"def running_total(array)\n sum = 0\n array.each_with_object([]) do |el, new_array|\n new_array << sum += el\n end\nend",
"def running_total(arr)\n tot = []\n arr.size.times do |i|\n tot << arr[0..i].reduce(&:+)\n end\n tot\nend",
"def running_total1(array)\n r_total = 0\n array.map { |n| r_total += n }\nend",
"def running_total(arr)\n totals = []\n arr.inject(0) do |total, num|\n totals << num + total\n total += num\n end\n return totals\nend",
"def running_total(array)\n p array.each_with_index { |_, index| array[0..index].reduce(:+) }\nend",
"def running_total(arr)\n results = []\n total = 0\n arr.each do |el|\n total += el\n results << total\n total = total\n end\n results\nend",
"def running_total(array)\n result = []\n sum = 0\n index = 0\n\n while array.size > index\n result << sum += array[index]\n index += 1\n end\n result\nend",
"def running_total(array)\n # new_array = []\n sum = 0\n array.inject([]) do |arr, val| \n sum += val\n arr << sum \n arr\n end\nend",
"def my_running_total(array)\n result_array = []\n result_array << array.shift unless array.empty?\n\n until array.empty?\n result_array << result_array.last + array.shift\n end\n\n result_array\nend",
"def running_total(array)\n sum = 0\n\n array.each_with_object([]) do |number, new_array|\n new_array << sum += number\n end\nend",
"def running_total(array)\n sum = 0\n array.map { |value| sum += value }\nend",
"def running_total(array)\n sum = 0\n array.map { |value| sum += value }\nend",
"def running_total(array)\n sum = 0\n array.map { |value| sum += value }\nend",
"def running_total(array)\n sum = 0\n array.map { |value| sum += value }\nend",
"def running_total(array)\n\n\treturn array if array.empty?\n\n\ttotal = 0\n\n\tarray.map! do |num|\n\t\ttotal += num\n\tend\n\nend",
"def running_total(array)\n sum = 0\n total = array.map { |num| sum += num }\nend",
"def running_total(array)\n total = 0\n array.map { |num| total += num }\nend",
"def running_total(arr)\n totals_arr = []\n acc = 0\n arr.each do |num|\n acc = acc + num\n totals_arr << acc\n end\n totals_arr\nend",
"def running_total(arry)\n total = 0\n arry.map { |n| total += n }\nend",
"def running_total(array)\r\n total = 0\r\n array.map { |num| total += num} \r\nend",
"def running_total(input_arr)\n total = 0\n input_arr.map do |current_element|\n total += current_element\n end\nend",
"def running_total(array)\n\n sum = 0\n\n array.map { |value| sum += value }\n\nend",
"def running_total(array)\n total = 0\n array.map do |e|\n total += e\n end\n total\nend",
"def running_total(arr)\n running_total_arr = []\n sum = 0\n arr.each do |num|\n sum += num\n running_total_arr << sum\n end\n running_total_arr\nend",
"def running_total(arr)\n sum = 0\n arr.inject([]) { |running_sum, num| running_sum << sum += num }\nend",
"def running_total(input_arr)\n running_total_arr = []\n input_arr.each_with_index do |elem, idx|\n if idx == 0\n running_total_arr[idx] = input_arr[idx]\n p running_total_arr\n else\n running_total_arr[idx] = running_total_arr[idx - 1] + input_arr[idx]\n p running_total_arr\n end\n end\n return running_total_arr\nend",
"def running_total(arr)\n arr.map.with_index { |_, index| arr[0..index].sum }\nend",
"def running_total(array_of_nums)\n increment = 0\n running_total_array = []\n\n array_of_nums.each do |num|\n running_total_array << num + increment\n increment += num\n end\n\n running_total_array\nend",
"def running_total(arr)\n sum = 0\n arr.map { |ele| sum += ele }\nend",
"def running_total(array)\n result = []\n\n array.inject(0) do |sum, num|\n result << sum += num\n sum # have to return sum\n end\n result\nend",
"def running_total(array)\n result = 0\n array.map {|num| result += num }\n array.map do |num|\n result += num\n end\nend",
"def running_total(arr)\n arr.map.with_index { |_int, i| arr[0..i].sum }\nend",
"def running_total(arr)\n total_sum = 0\n arr.map { |elem| total_sum += elem }\nend",
"def running_total(arr)\n total = 0\n arr.map { |num| total += num}\nend",
"def running_total(arr)\n return [] if arr.empty?\n running_sum = [arr[0]]\n counter = 1\n loop do \n break if counter == arr.size\n \n current_value = arr[counter]\n last_number = running_sum.last\n running_sum << current_value + last_number\n \n counter += 1\n end\n running_sum\nend",
"def running_total(arr)\n total = 0\n arr.map { |num| total += num }\nend",
"def running_total(array)\n total = 0\n array.map do |e|\n total = total * 10 + e\n end\n total\nend",
"def running_total(array)\n total = 0\n array.map do |e|\n total = total * 10 + e\n end\n total\nend",
"def running_total(array)\n num = 0\n array.map do |number|\n num = number + num\n end\nend",
"def efficient_running_total(array)\n sum = 0\n array.map { |value| sum += value }\nend",
"def running_total(arr)\n sum = 0\n arr.map { |num| sum += num }\nend",
"def running_total(arr)\n sum = 0\n arr.map do |n|\n sum += n\n end\nend",
"def running_total(array_nums)\n total = 0\n array_nums.map { |num| total += num }\nend",
"def running_total2(array)\n total = 0\n array.each_with_object([]) do |num, arr|\n total += num\n arr << total\n end\nend",
"def running_total_2(array)\n total = 0\n array.map do |x|\n total += x\n end\nend",
"def running_total_with_reduce_2(array)\n array.map.with_index do |el, idx|\n array[0..idx].reduce(:+)\n end\nend",
"def running_total(numbers)\n numbers.map.with_index { |_, i| numbers[0..i].reduce(:+)}\nend",
"def running_total1(array)\n array_new = []\n loop do\n break if array.empty?\n array_new << array[0]\n array[1] = array[0] + array[1] if array.size >= 2\n array.shift\n end\n array_new\nend",
"def running_total(nums_ary)\n ary = []\n\n nums_ary.reduce(0) do |sum, num|\n ary << sum + num\n sum + num\n end\n ary\nend",
"def reduce_to_total(source_array, starting_point = 0)\n #source_array.reduce(starting_point) {|sum, n| sum + n}\n i = 0\n sum = starting_point\n while i < source_array.length do\n sum = sum + source_array[i]\n i += 1\n end\n return sum\nend",
"def running_total_3(array)\n #total = 0\n #array_new = []\n array.each_with_object([]) do |i,x|\n next if i == 0\n x += array[i-1]\n end\nend",
"def running_total3(array)\n sum = 0\n array.map do |num|\n sum = [sum, num].inject(:+)\n end\nend",
"def running_total(int_arr)\n sum = 0\n int_arr.map do |x|\n sum += x\n end\nend",
"def running_total_2 arr\n arr.each_with_index { |elm, idx| idx == 0 ? next : arr[idx] += arr [idx-1] }\nend",
"def reduce_to_total(source_array, starting_point=0)\n i = 0\n total = starting_point\n while i < source_array.length do\n total = total + source_array[i]\n i += 1\n end\n total\nend",
"def reduce_to_total(source_array, starting_point = 0)\n return source_array.reduce() {|sum,n| sum + n}\nend",
"def running_total(numbers)\n index = 1\n while index < numbers.length\n numbers[index] = numbers[index] + numbers[index - 1]\n index += 1\n end\n numbers\nend",
"def running_total(array1)\n array2 = []\n sum = 0\n array1.each do |num|\n array2 << sum += num \n end\n puts \"running_total(#{array1}) == #{array2}\"\nend",
"def reduce_to_total(source_array, starting_point = 0 )\n \n new_total = starting_point\n i = 0\n while i < source_array.length do\n new_total += source_array[i]\n i += 1\n end\n return new_total\n \n end",
"def reduce_to_total(source_array, starting_point = 0)\n \n source_array.sum + starting_point\n \nend",
"def run_total(array)\n sum = 0\n array.map { |num| sum += num }\nend",
"def reduce_to_total(source_array, starting_point=0)\n temp = starting_point\n i = 0\n while i < source_array.length do\n temp += source_array[i]\n i += 1\n end\n return temp\nend",
"def reduce_to_total(source_array, starting_point = 0)\n total = starting_point\n index = 0\n while index < source_array.size do\n total += source_array[index]\n index += 1\n end\n total\nend",
"def array_num_total array\r\n i = 0\r\n\tnum_total = 0\r\n\tinteger_array = array.collect { |item| item.to_i }\r\n\twhile i < integer_array.length\r\n\t num_total = integer_array[i] + num_total\r\n\t\ti = i + 1\r\n\tend\r\n num_total\r\nend",
"def total array\n\tsum = 0\n\tarray.each do |x|\n\t\tsum = sum + x\n\tend\n\treturn sum\nend",
"def reduce_to_total(array,starting_point=0)\n total = starting_point\n counter = 0 \n while counter < array.size do \n total += array[counter]\n counter += 1\n end\n total\nend",
"def reduce_to_total(source_array, starting_point = 0)\n new_sum = source_array.reduce(starting_point, :+)\n return new_sum\nend",
"def reduce_to_total(source_array, starting_point=0)\n\n i = 0\n\n while i < source_array.length do\n starting_point += source_array[i]\n i += 1\n end\n\n starting_point\nend",
"def reduce_to_total(source_array, starting_point)\n source_array.reduce(100) { |sum, n| sum + n }\nend",
"def total array\n array.inject(0){|sum,x| sum + x }\nend",
"def total array\n array.reduce(0, :+)\nend",
"def parts_sums(input_array)\n total = input_array.sum\n output = [total]\n input_array.size.times do \n total = total - input_array.shift\n output << total\n end\n output\nend",
"def accumulate(array)\n cumulative = 0\n array.map { |value| cumulative += value }\n end",
"def total(array)\n sum = 0\n new_array = []\n \n array.each do |number|\n sum += number\n new_array.push(sum)\n end\n \nreturn new_array[-1]\nend",
"def reduce_to_total(array)\n total = 0 \n count = 0 \n while count < array.length do\n total = total + array[count]\n count += 1\n end\n total\nend",
"def reduce_to_total(arr, starting_point=0)\n arr.reduce(starting_point) do |acc, cur_val|\n acc + cur_val\n end\nend",
"def running_total(array)\n result = []\n\n array.inject(0) do |sum, num| # without (0) after inject method does not work?\n result << sum += num\n sum # without returning sum here, method does not work?\n end\n result\nend",
"def sum_of_sums(array)\n n = 1\n running_total = 0\n while n <= array.size\n running_total += array.first(n).reduce(:+)\n n += 1\n end\n running_total\nend",
"def total(array)\n array[0..-1].reduce(:+)\nend",
"def total(array)\n x = 0\n while x < array.length\n array.each do |n|\n x += n\n end\n end\n return x\nend",
"def running_total4(numbers)\n sums = []\n numbers.each_with_index do |_, idx|\n current_total = numbers[0..idx].sum\n sums << current_total\n end\n\n sums\nend",
"def arraysum\n return self.inject(0){|acc,i|acc +i}\n end",
"def sum_array a\n t = 0\n a.each{|i|t+=i.to_i}\n [a,t]\nend",
"def total(array)\n\tx = array.length\n\tsum = 0\n\t\twhile x > 0\n\t\t\tsum += array[x-1]\n\t\t\tx -= 1\n\t\tend\n\n\treturn sum\n\nend",
"def running_total(numbers)\n total = 0\n numbers.map { |number| total += number }\nend"
] | [
"0.8644924",
"0.85115325",
"0.84803355",
"0.8399224",
"0.83926857",
"0.83744156",
"0.8360413",
"0.8355934",
"0.8341929",
"0.8339863",
"0.82941985",
"0.82936525",
"0.8277946",
"0.8268809",
"0.82534724",
"0.82292014",
"0.8227137",
"0.8213202",
"0.81834996",
"0.81821924",
"0.8180741",
"0.817698",
"0.81549555",
"0.8143473",
"0.8141647",
"0.81412387",
"0.81402415",
"0.81402415",
"0.81402415",
"0.8129798",
"0.81152797",
"0.81085646",
"0.8098641",
"0.80791336",
"0.8064221",
"0.8049549",
"0.8015081",
"0.8014918",
"0.79919446",
"0.79613024",
"0.7956968",
"0.79484683",
"0.7945464",
"0.7936923",
"0.7920419",
"0.79155684",
"0.7885191",
"0.7862691",
"0.7858248",
"0.78463227",
"0.78459257",
"0.78349495",
"0.78349495",
"0.7826281",
"0.77625084",
"0.7739388",
"0.76984817",
"0.7697572",
"0.76698214",
"0.7667105",
"0.76087165",
"0.7588015",
"0.7582758",
"0.7574398",
"0.75300306",
"0.7518992",
"0.7508132",
"0.7469474",
"0.74564415",
"0.74558413",
"0.7445701",
"0.7441749",
"0.74277526",
"0.74274755",
"0.74069905",
"0.7376958",
"0.7372242",
"0.7350998",
"0.7349846",
"0.73360914",
"0.7335274",
"0.73150593",
"0.7308394",
"0.7301286",
"0.729668",
"0.7290364",
"0.7284922",
"0.72824657",
"0.7274405",
"0.72653323",
"0.7240076",
"0.7219862",
"0.72148556",
"0.72072977",
"0.71982086",
"0.71937585",
"0.7188749",
"0.71737075",
"0.7163935",
"0.71586627"
] | 0.8123076 | 30 |
indexes the array elemens by a block | def index_by
map { |n| [yield(n), n] }.to_hash
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def my_each_with_index(arr)\n \n\n for element in arr\n index = arr.index(element)\n yield(element, index)\n end\n \n \nend",
"def each_byte_with_index\n\t\[email protected]_with_index { |a,i| yield a,i }\n\tend",
"def each(&block_)\n @indexes.each(&block_)\n end",
"def index(element); end",
"def each_with_index(zeroes = false, &_block)\n return enum_for :each_with_index, zeroes unless block_given?\n if zeroes\n row_count.times do |row|\n column_count.times do |_col|\n element = self[row, column]\n yield [element, row, column]\n end\n end\n else\n ia.each_cons(2).each_with_index do |indexes, row|\n row_start, row_end = *indexes\n a[row_start...row_end].each_with_index do |element, index|\n yield [element, row, ja[row_start + index]]\n end\n end\n end\n end",
"def each_with_index(&block)\n to_a.each_with_index(&block)\n end",
"def each_with_index(&block)\n to_a.each_with_index(&block)\n end",
"def each_with_index\n\t\[email protected]_with_index do |v,i|\n\t\t\tyield v & 0x0F, i * 2 #Bottom Nibble\n\t\t\tyield (v >> 4) & 0x0F, i * 2 + 1#Top Nibble\n\t\tend\n\tend",
"def map_with_index(array, &block)\n result = []\n index = 0\n array.each do |element|\n result << block.call(element, index)\n index += 1\n end\n result\nend",
"def each_with_index(&blk)\n (0..@size-1).each { |i| blk.call(self.[](i),i) }\n end",
"def find_indexes(val=nil, &block)\n block = lambda{|e| e == val} if val\n (0...self.size).inject([]) do |list, i|\n list << i if block.call(self[i])\n list\n end\n end",
"def each_with_index(arr)\n arr.size.times do |i|\n yield(arr[i], i)\n end\n arr\nend",
"def each(&block)\n @index.each(&block)\n end",
"def my_each_with_index\n i = 0\n while i < self.size\n yield self[i], i\n i += 1\n end\n end",
"def each_with_index # :yields: e, i, j\n (0...hsize).each { |j|\n (0...vsize).each { |i|\n yield self[i,j], i, j\n }\n }\n self\n end",
"def find_index list, &block #were taking a list, and a block we want to find, find_index = func name\n list.index(&block) #look in list using .index(&block) to find the index of the block \nend",
"def each_with_index(type = TLV_TYPE_ANY, &block)\n\t\tget_tlvs(type).each_with_index(&block)\n\tend",
"def each_with_index(type = TLV_TYPE_ANY, &block)\n\t\tget_tlvs(type).each_with_index(&block)\n\tend",
"def map_with_index(array, index = 0, &block)\n result = []\n i = index\n array.each do |element|\n result << block.call(element, i)\n i += 1\n end\n result\nend",
"def each_index\n (0...hsize).each { |j|\n (0...vsize).each { |i|\n yield i, j\n }\n }\n self\n end",
"def each(&block)\n @index.each do |key, start_length|\n block.call([key, self[key]])\n end\n end",
"def each_index(*_arg0); end",
"def my_each_with_index\n i = 0\n while i < self.length\n yield self[i], i\n i += 1\n end\n self\n end",
"def my_each_with_index\n\t\tself.length.times do |index|\n\t\t\tyield(self[index], index)\n\t\tend\n\tend",
"def my_each_with_index\n i = 0\n while i < self.length\n yield(self[i], i)\n i += 1\n end\n self\n end",
"def each(&b)\n @index.each(&b)\n end",
"def each_with_index(&block)\n @tree.each_with_index(&block)\n end",
"def elements_in_same_block(region_size = 3)\n row_del = @row_idx % region_size\n col_del = @column_idx % region_size\n\n region_shift = region_size -1\n\n start_row_idx = @row_idx - row_del\n start_col_idx = @column_idx - col_del\n\n block_elements = []\n (start_row_idx..start_row_idx+region_shift).each do |row_idx|\n (start_col_idx..start_col_idx+region_shift).each do |col_idx|\n block_elements << @map.element_at(row_idx, col_idx)\n end\n end\n block_elements\n end",
"def each_with_index(&block)\n examples.each_with_index(&block)\n end",
"def my_each_with_index(&block)\n return to_enum(:my_each_with_index) unless block_given?\n n = 0\n while n < length\n block.call(self[n], n) if is_a?(Array)\n block.call(keys[n], self[keys[n]]) if is_a?(Hash)\n block.call(self[n]) if is_a?(Range)\n n += 1\n end\n self\n end",
"def my_each_with_index\n i = 0\n while i < self.size\n yield(self[i], i)\n i += 1\n end\n self\n end",
"def index(p0) end",
"def index(p0) end",
"def each(&block)\n @array.each(&block)\n end",
"def slow_dance(tile, array)\n array.each_with_index do |el, i|\n return i if el == tile\n end\nend",
"def _multi_array_indexes(i)\n element_list_sizes_tmp = _element_list_sizes\n array_indexes = []\n\n while element_list_size = element_list_sizes_tmp.pop\n i, remainder = i.divmod(element_list_size)\n array_indexes.unshift remainder\n end\n\n array_indexes\n end",
"def my_each_with_index\n i = 0\n while i < size\n yield(self[i], i)\n i += 1\n end\n self\n end",
"def my_each_with_index\n return to_enum unless block_given?\n\n i = 0\n while i < length\n yield(self[i], i)\n i += 1\n end\n end",
"def my_each_with_index\n for i in 0...self.length do\n yield(self[i], i)\n end\n return self\n end",
"def each(&block)\n @array.each(&block)\n end",
"def each(&block)\n @array.each(&block)\n end",
"def my_each_with_index\n for i in 0..self.length-1\n yield(self[i], i) if block_given?\n end\n self\n end",
"def each &block\n each_with_index {|x, i| block.call(x)}\n end",
"def index value, &compare_block\n compare_block ||= lambda{|a,b| a == b}\n (0...size).detect{|i| compare_block[value, self[i]] }\n end",
"def my_each_with_index\n i = 0\n while i < self.to_a.length\n yield self.to_a[i], i\n i += 1\n end\n end",
"def each_mid(&block)\n \n end",
"def find_index array, item\n\tl,r = 0, array.length-1\n\n\twhile l <= r\n\t\tm = (r+l) / 2\n\t\tcomp = yield item, array[m]\n\t\tif comp == false\n\t\t\t# Items compare the same\n\t\t\treturn false\n\t\telsif comp == -1 \n\t\t\tr = m - 1\n\t\telse\n\t\t\tl = m + 1\n\t\tend\n\tend\n\n\tl\nend",
"def at(array, i)\n array[i]\nend",
"def at(index); end",
"def my_each_with_index\n return to_enum unless block_given?\n i = 0\n array = []\n while i < size\n yield to_a[i], i\n array << to_a[i]\n i += 1\n end\n array\n end",
"def each(&block)\n array.each(&block)\n end",
"def my_each_with_index\n return to_enum unless block_given?\n\n i = 0\n while i < size\n yield(self[i], i)\n i += 1\n end\n self\n end",
"def each(&block)\r\n @arr.each &block\r\n end",
"def each(&block)\r\n @arr.each &block\r\n end",
"def block_at(x, y)\n if x >= 0 && y >= 0 && x < @rows.length && y < @rows[x].size\n @rows[x][y]\n else\n nil\n end\n end",
"def each(arr)\n # set index value, beginning with the first element at 0\n i = 0\n # while the current index value still exists in the array, run the block of code, stored in yield, on each index, then increase the index value by 1 until the end of the array\n while i < arr.length\n yield(arr[i])\n i += 1\n end\nend",
"def each(&block)\n @size.times { |position| yield self[position] }\n end",
"def each(&block)\n @size.times { |position| yield self[position] }\n end",
"def [](indx)\n elements[indx]\n end",
"def my_each_with_index\n \ti = 0\n \twhile i < self.length\n \t\tif block_given?\n \t\t\tyield(self[i], i)\n \t\telse\n \t\t\treturn self\n \t\tend\n \t\ti +=1\n \tend\n \tself\n end",
"def each(array)\n idx = 0\n while idx < array.size\n yield(array[idx]) if block_given?\n idx += 1\n end\n\n array\nend",
"def each_index(&block)\n if block_given?\n @indexes.each(&block)\n self\n else\n @indexes.freeze\n end\n end",
"def my_each_with_index\n a = (is_a? Hash) ? to_a : self\n i = 0\n while i < a.count\n yield a[i], i\n i += 1\n end\n end",
"def index_of(list, element)\n raise NotImplementedError\n end",
"def []( index )\r\n @ary.at(index + @offset)\r\n end",
"def each_with_index\n if block_given?\n @fm.each_with_index do |el, index|\n yield el, get_row_from_index(index), get_col_from_index(index)\n end\n end\n end",
"def each_index(&block)\n @size.times { |index| yield index}\n end",
"def each(&block)\n @size.times { |position| yield self[position] }\n end",
"def each(&block)\n @size.times { |position| yield self[position] }\n end",
"def each(&block)\n @size.times { |position| yield self[position] }\n end",
"def all_indices(elem, array)\r\n indices = []\r\n array.each_with_index do |element, index|\r\n (indices << index) if element == elem\r\n end\r\n indices\r\n end",
"def indices(*rest) end",
"def indices(*rest) end",
"def magic_index(array)\n array.each_with_index do |val, index|\n return index if val == index\n end\n \"no magic index\"\nend",
"def nc_my_each(array, &block)\n array.length.times do |i|\n block.call(array[i])\n end\n array\nend",
"def each_index\n @block_args.each_index do |i|\n yield i\n end\n end",
"def each_entry_with_index\n @index.each_with_index do |hash, idx|\n next if hash.nil?\n entry = '' \n hash.each {|x| entry << pack(x.sha1, @block_ary[x.block].start, @block_ary[x.block].size, x.buflocation, x.size) }\n yield entry, idx \n end\n end",
"def each_index(&block)\n enum = Enumerator.new do |yielder|\n begin\n @each_index = {}\n\n count = 0\n self.each do |ele|\n # Remove previous element to not take up memory.\n count_before = count - 1\n @each_index.delete(count_before) if @each_index.key?(count_before)\n\n # Add current element to cache.\n @each_index[count] = ele\n yield(count)\n\n # Increase count for next run.\n count += 1\n end\n ensure\n @each_index = nil\n end\n end\n\n if block\n enum.each(&block)\n return nil\n else\n return enum\n end\n end",
"def index\n @array = [45, 6, 32, 0]\n end",
"def each_lower_with_index # :yields: e, i, j\n (0...hsize).each { |j|\n ((j+1)...vsize).each { |i|\n yield self[i,j], i, j\n }\n }\n self\n end",
"def magic_slow(arr)\n arr.each_with_index do |val, index|\n return index if val === index\n end\nend",
"def each_value_with_index\n @nz.each do |i, j, v|\n yield v, i, j\n end\n end",
"def iter_bindex(array, element)\n\tupper = array.size\n\tlower = 0\n\twhile upper >= lower\n\t\tmid = (upper + lower) /2\n\t\tif array[mid] < element\n\t\t\tlower = mid + 1\n\t\telsif array[mid] > element\n\t\t\tupper = mid -1\n\t\telse \n\t\t\treturn mid\n\t\tend\n\tend\n\treturn nil\nend",
"def each_index\n\t\[email protected]_index do |y|\n\t\t\t@data[y].each_index do |x|\n\t\t\t\tyield x, y\n\t\t\tend\n\t\tend \n\tend",
"def each_sample_with_index( &block )\n @data[:samples].each_with_index do |sample, i|\n block.call( sample,i )\n end\n end",
"def index(loc, offset=0) end",
"def each_with_index(&block)\n return to_enum :each_with_index unless block\n\n i = 0\n self.each{|*val|\n block.call(val.__svalue, i)\n i += 1\n }\n self\n end",
"def spiral_access (spiral_array, &block)\n r_array = unravel(spiral_array)\n r_array.map(&block)\nend",
"def slow_dance(tile, tiles_array)\n tiles_array.each_with_index do |direction, idx|\n return idx if direction == tile\n end\nend",
"def my_each_with_index\n return self unless block_given?\n\n if is_a? Array\n length.times { |idx| yield(self[idx], idx) }\n elsif is_a? Hash\n keys = self.keys\n vals = values\n length.times { |idx| yield([keys[idx], vals[idx]], idx) }\n else\n warn 'Incompatible type!'\n end\n self\n end",
"def slow_dance(direction, array)\n array.each_with_index do |tile, idx|\n return idx if tile == direction\n end\nend",
"def indices(start=0, ar_of_indices=[], final=[], level=shape.size-1, &block)\r\n if level >= 0\r\n (0...(shape[level])).each do |s|\r\n new_indices = ar_of_indices.dup\r\n new_indices.unshift(s)\r\n if (new_indices.size == (shape.size - start))\r\n block.call(new_indices)\r\n final << new_indices \r\n end\r\n indices(start, new_indices, final, level-1, &block)\r\n end\r\n end\r\n final\r\n end",
"def index_of element\n @index.key @data.index(element)\n end",
"def square_each_idx(array)\n final = Array.new(array.length)\n array.each_index { |i| final[i] = array[i]**2 }\n final\nend",
"def each_with_index(&block)\n @delegate.each_with_index(&block)\n end",
"def each_with_index\n\t\[email protected]_index do |y|\n\t\t\t@data[y].each_with_index do |val, x|\n\t\t\t\tyield x,y,val\n\t\t\tend\n\t\tend\n\n\tend",
"def each(&block)\n @extent.each(&block)\n end",
"def each(&blk)\n (0..@size-1).each { |i| blk.call(self.[](i)) }\n end",
"def [](i)\n @elements[i]\n end",
"def at(index)\n \t@array[index]\n end",
"def each_tile_with_index level\n\t\t\tidx = 0\n\t\t\tsize = tile_size level\n\t\t\t(0...size).each do |y|\n\t\t\t\t(0...size).each do |x|\n\t\t\t\t\tyield(x, y, idx) if block_given?\n\t\t\t\t\tidx += 1\n\t\t\t\tend\n\t\t\tend\n\t\tend"
] | [
"0.6711639",
"0.668588",
"0.6576321",
"0.6517592",
"0.6486002",
"0.6432336",
"0.6432336",
"0.63813215",
"0.6275402",
"0.6251584",
"0.62025326",
"0.6141902",
"0.61359894",
"0.61329776",
"0.610723",
"0.60900164",
"0.60785735",
"0.60785735",
"0.6078277",
"0.60780054",
"0.6073401",
"0.60617095",
"0.6061381",
"0.6041977",
"0.60215324",
"0.6010614",
"0.6007776",
"0.6001224",
"0.5993613",
"0.5981615",
"0.5980906",
"0.5977302",
"0.5977302",
"0.5976777",
"0.59498674",
"0.5947994",
"0.5943878",
"0.59378225",
"0.5930631",
"0.5924489",
"0.5924489",
"0.5920484",
"0.59088546",
"0.5899995",
"0.5889033",
"0.5879476",
"0.5858644",
"0.5857127",
"0.5849792",
"0.58477736",
"0.58470684",
"0.5815545",
"0.5760949",
"0.5760949",
"0.5744663",
"0.5722856",
"0.5708055",
"0.57079595",
"0.5703347",
"0.5680438",
"0.5679247",
"0.567271",
"0.56692123",
"0.56588686",
"0.565824",
"0.5653542",
"0.5648634",
"0.5646248",
"0.5646248",
"0.5646248",
"0.5643993",
"0.5639594",
"0.5639594",
"0.56176627",
"0.5605684",
"0.5600107",
"0.55978394",
"0.559515",
"0.55940634",
"0.5592706",
"0.5585689",
"0.55732346",
"0.5569531",
"0.55688334",
"0.5568529",
"0.5565001",
"0.5558872",
"0.5552785",
"0.5548317",
"0.5547421",
"0.5547083",
"0.55434436",
"0.5542168",
"0.55387753",
"0.5538009",
"0.55379224",
"0.55345684",
"0.55211294",
"0.5513804",
"0.55014867",
"0.5499645"
] | 0.0 | -1 |
counts the number of times the argument is present as a subarray as list in the array | def subarray_count(subarray)
each_cons(subarray.length).count(subarray)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def element_count(array)\n\nend",
"def count_elements(array)\n\nend",
"def count_positive_subarrays(arr) \n return arr.count{|ele| ele.sum > 0}\nend",
"def count_positive_subarrays(two_d_arr)\n #debugger\n # ([[-2, 5], [1, -9, 1], [4, 7]]).count(*(any args))\n two_d_arr.count{ |subarr| subarr.sum > 0}\nend",
"def count_elements(arr)\n count = 0\n\n arr.each do |x|\n if arr.include?(x+1)\n count += 1\n end\n end\n \n count\nend",
"def count_positive_subarrays(arr2d)\n arr2d.count { |el| el.sum > 0 }\nend",
"def deep_count(arr)\n count = 0\n arr.each do |el|\n if el.class != Array\n count += 1\n else\n count += 1 + deep_count(el)\n end\n end\n count\nend",
"def count_positive_subarrays(two_arr)\n # two_arr.count { |sub_arr| sub_arr.sum > 0 } \n two_arr.count { |sub_arr| sub_arr.sum.positive? }\nend",
"def get_length(arr)\n arr.flatten(2).count\nend",
"def count_items(elective_array)\n return elective_array.length\nend",
"def count_elements(array)\n array.group_by(&:itself).map { |key, value| key.merge(count: value.length)} # counts number of times occur\nend",
"def count(array)\n if array == []\n 0\n else\n 1 + count(array[1..-1])\n end\nend",
"def count_occurrences(arr)\n unique_elements = arr.uniq\n unique_elements.each { |element| puts \"#{element} => #{arr.count(element)}\"}\nend",
"def num_occur(array, target)\n return 0 if array.empty?\n count = 0\n count += 1 if array.first == target \n count + num_occur(array.drop(1), target)\nend",
"def length_finder(input_array)\n input_array.map { |elem| elem.size }\nend",
"def count_list(array)\n counter = 0\n array.each do |num|\n counter +=1\n end\ncounter\nend",
"def num_occur(array, target)\n count = 0\n if array.empty?\n 0\n else\n count = 1 if array.first == target\n count += num_occur(array.drop(1), target)\n count\n end\nend",
"def count_elements(arr)\n counter = Array.new\n counter_helper = Array.new\n arr.each do |element|\n if counter_helper.include?(element)\n counter[counter_helper.find_index(element)][:count] += 1\n else\n counter_helper.push(element.clone)\n element[:count] = 1\n counter.push(element)\n end\n end\n counter\nend",
"def count(array)\n count = 0\n array.each do |x|\n count += 1\n end\n\n return count\nend",
"def cnts a\n r = []\n found = false\n a.each do |x|\n r.each do |y|\n if y[0] === x\n y[1] += 1\n found = true\n break\n end\n end\n if !found\n r.push([x, 1])\n else\n found = false\n end\n end\n r\nend",
"def num_occur(array, target)\n count = 0\n first_ele = array[0]\n count += 1 if first_ele == target\n\n return count if array.empty?\n\n count += num_occur(array[1..-1],target)\n count\nend",
"def count(*arr)\n arr.inject(0) { |count, el| yield(el) ? count + 1 : count }\nend",
"def num_occur(array, target)\n @base ||= 0\n @base += 1 if array[0] == target\n num_occur(array.drop(1),target) unless array.empty?\n @base\nend",
"def num_occur(array, target)\n return 0 if array.empty?\n occurrence = array.first == target ? 1 : 0\n occurrence + num_occur(array.drop(1))\nend",
"def num_occur(array, target)\n return 0 if array.length <= 0\n count = 0\n if array[0] == target\n count += 1\n count += num_occur(array[1..-1], target)\n else \n count += num_occur(array[1..-1], target)\n end \n count\nend",
"def plain_ruby_count(array, sum=0)\n return sum if array == []\n a, *b = array\n plain_ruby_count(b, sum + 1)\n end",
"def num_occur(array, target)\n return 0 if array.empty?\n \n occurrences = 0\n\n if array[0] == target\n occurrences = 1\n end\n\n occurrences + num_occur(array[1..-1], target)\nend",
"def num_occur(array, target)\n return 0 if array.empty?\n count = array.first == target ? 1 : 0\n count += num_occur(array.drop(1), target)\nend",
"def count_elements(array)\n\t# My attempt:\n\t# hash = {}\n\t# array.each do |e|\n\t# \thash[e] = 1\n\t# end\n\t# new_array = []\n\t# hash.each do |animal, count|\n\t# \tnew_array = hash.select{|animal2, count2| animal2 == animal}\n\t# end\n\t# new_array\n\n\t# Stack Overflow:\n\tcounts = Hash.new(0) # sets default value (the value that is returned when trying to access key that does not exist) to 0 instead of nil\n\tarray.each { |e| counts[e] += 1 }\n\tcounts\nend",
"def num_occur(array, target)\n return 0 if array == []\n #every element appears zero times\n dup_array = array.dup\n value = dup_array.shift\n #previous\n if value == target\n count = num_occur(dup_array, target) + 1 #return previous, add one\n else\n count = num_occur(dup_array, target) #return previous value\n end\n count #ensures count is used for prior calls\n\nend",
"def count_elements(arr)\n hash = {}\n count = 0\n\n arr.each do |x|\n if !hash.key?(x)\n hash[x] = true\n end\n end\n\n arr.each do |x|\n if hash.key?(x+1)\n count += 1\n end\n end\n\n count\nend",
"def count_in_array(number)\n first = first_in_array(number)\n return 0 if first == -1\n\n last = last_in_array(number)\n (last - first + 1)\n end",
"def gem_element arr\n freq = Hash.new(0)\n count = 0\n\n combo = arr.map(&:chars).map(&:uniq).flatten\n combo.each{ |key| freq[key]+=1 }\n freq.each{ |k,v| count +=1 if v == arr.size }\n count\n \nend",
"def dimension_finder(array)\n if array.any? { |nested_array| nested_array.is_a?(Array) }\n dim = array.group_by { |nested_array| nested_array.is_a?(Array) && dimension_finder(nested_array) }.keys\n [array.size] + dim.first if dim.size == 1 && dim.first\n else\n [array.size]\n end\n end",
"def count_stops_in_array(stops_array)\n result = stops_array.length()\n return result\nend",
"def length_of_array(array)\n array.length\nend",
"def count_occurrences(array)\n\toccurences = {}\n\n\tarray.each do |element|\n\t\toccurences[element] = array.count(element)\n\tend\n\n\toccurences.each do |element, count|\n\t\tputs \"#{element} => #{count}\"\n\tend\t\nend",
"def count(*array)\n total = 0\n array.each { |element| total += 1 if yield(element) }\n total\nend",
"def count_all (array)\n count = 0\n i = 0\n while i < array.length\n count += array[i].length\n i += 1\n end\n return count\nend",
"def count(arr, item)\n\tarr.count { |x| x == item }\nend",
"def num_occur(array, target)\n dup = array.dup\n if dup.length == 1 \n return (dup.pop == target) ? 1 : 0\n end\n increment_count_by = (dup.pop == target) ? 1 : 0\n count = increment_count_by + num_occur(dup, target)\nend",
"def Occurrence_count(arr)\n\th1={}\n\tarr.each do |element|\n\t\th1[\"#{element}\"].nil? ? h1[\"#{element}\"]=1 : h1[\"#{element}\"]+=1\n\tend\n\th1.each do |key,value|\n\t\tputs \"\tOccurrence of #{ key } in the array is #{value} times \"\n\tend\t\nend",
"def length_of_array (array)\n array.size\nend",
"def count(arr, val)\n if arr.length == 0\n return 0\n end\n\n if val == arr[0] \n cnt = 1\n else \n cnt = 0\n end\n \n cnt + count(arr[1..-1], val)\nend",
"def count_items(electives)\n electives.length #counts number of items in the array\nend",
"def length_finder(input_array)\n input_array.map(&:length)\nend",
"def solution(a)\n a.uniq.count\nend",
"def countSheeps2 array\n array.count(true)\nend",
"def count_elements(array)\n counts = Hash.new 0\n unique_elements = array.uniq\n\n unique_elements.each do |item|\n item[:count] = array.count(item)\n end\n\n unique_elements\nend",
"def count_occurrences_improved(arr)\n counts = Hash.new { |h, k| h[k] = 0 }\n arr.each { |element| counts[element] += 1 }\n counts.each { |element, count| puts \"#{element} => #{count}\" }\nend",
"def length_of_array(array)\n return array.length\nend",
"def count(arr)\n count = 0\n arr_length_half = arr.length / 2\n\n arr_length_half.times do |i|\n if arr [i] > arr[- i - 1]\n count += arr[i]\n else\n count += arr[-i - 1]\n end\n end\n count\nend",
"def count_elements(array)\n new_array = array.uniq\n new_array.each do |hash|\n hash[:count] = array.count(hash)\n end\n new_array\nend",
"def custom_count(array)\n counter = 0\n array.each do |elem|\n if elem != nil\n counter += 1\n end\n end\n counter\nend",
"def countSheeps array\n array.count(true)\nend",
"def count_occurrences(array)\n result = {}\n array.each do |x|\n result[x] = if !result.key?(x)\n 1\n else\n result.fetch(x) + 1\n end\n end\n result.each do |k, count|\n p \"#{k} => #{count}\"\n end\nend",
"def solution(a)\r\n # write your code in Ruby 2.2\r\n \r\n arr =[]\r\n a.each_with_index{|el,i|\r\n \r\n if !arr.index(el) \r\n arr << el\r\n end\r\n \r\n }\r\n arr.count\r\nend",
"def stock_count(stock_count_array)\n stock_count_array[:pets].count\nend",
"def solution0(a)\n\n total_count = 0\n elem_counts = Hash.new(0)\n\n a.each do |elem|\n elem_counts[elem] += 1\n total_count += 1 if elem_counts[elem] == 2\n end\n\n return total_count\n\nend",
"def checkArray(a)\n\tn = a.length-1\n\tcount = 0\n\tfor i in 0..n do\n\t\tfor j in (i+1)..n do\n\t\t\tfor k in (j+1)..n do\n\t\t\t\tif (a[i] + a[j] + a[k] == 0)\n\t\t\t\t\tcount += 1\n\t\t\t\t\treturn count;\n\t\t\t\telse\n\t\t\t\t\treturn count;\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\nend",
"def count_elements\nend",
"def num_occur(array, target)\n return 0 if array.empty?\n count_update = array.first == target ? 1 : 0\n count_update + num_occur(array.drop(1), target)\nend",
"def num_occur(array, target)\n return 0 if array.empty?\n count_update = array.first == target ? 1 : 0\n count_update + num_occur(array.drop(1), target)\nend",
"def count(n,ar)\r\n result = Array.new(100){|x| x = 0}\r\n ar.each { |x| result[x] = result[x]+1 }\r\n return result\r\nend",
"def number_of(val)\n res = 0\n @array.each { |row| row.each { |v| res +=1 if v == val } }\n res\n end",
"def element_count(arr)\n fre = {}\n fre.default = 0\n arr.each { |el| fre[el] += 1 }\n return fre\nend",
"def character_count(array)\nend",
"def count_array(array, val)\n i = 0\n output = 0\n while i < array.length\n if array[i] == val\n output += 1\n end\n i += 1\n end\n return output\nend",
"def PowerSetCount(arr)\n combinations = []\n (0..arr.size).each { |combo| combinations += arr.combination(combo).to_a }\n combinations.size\nend",
"def count\n underlying_array.length\n end",
"def array_total(array)\t\n\tputs \"This list has #{array.length} elements in it\"\nend",
"def get_length(arr)\n $index = 0\n def reroute(arr)\n arr.each do |entry| # bad because if array then the remaining numbers will not be counted but works\n if entry.class != Array \n $index += 1\n else \n reroute(entry)\n end\n end \n end\n reroute(arr)\n return $index\nend",
"def count_primes(array)\n select_primes(array).count\nend",
"def count_occurrences(array)\n number_of_occurrences = {}\n array.each do |element|\n if number_of_occurrences.include?(element)\n number_of_occurrences[element] += 1\n else\n number_of_occurrences[element] = 1\n end\n end\n number_of_occurrences\nend",
"def count_occurrences(array)\n count = Hash.new\n counter = 0\n array.each { |i| \n if count[i] == nil\n count[i] = 1\n else\n count[i] = count[i] += 1\n end\n counter += 1\n }\n count.each_pair { |k, v| puts \"#{k} => #{v}\"}\nend",
"def num_occur(array, target)\n array[0] == target ? val = 1 : val = 0\n return val if array.length == 1\n\n val + num_occur(array.drop(1), target)\nend",
"def count_occurrences(array)\n occurrences = {}\n\n array.uniq.each do |element|\n occurrences[element] = array.count(element)\n end\n\n occurrences.each do |element, count|\n puts \"#{element} => #{count}\"\n end\nend",
"def num_occur(array, target)\n if array.empty?\n return 0\n end\n \n if array[-1] == target\n return num_occur(array[0...-1], target) + 1\n else\n return num_occur(array[0...-1], target)\n end\n \nend",
"def lcount(arr)\n (1...arr.length).reduce(1) { |c, i| arr[i] > arr[0...i].max ? c + 1 : c }\nend",
"def count_elements(array)\n new_array = []\n\n array.each do |original_array_element|\n\n #now inside the array looking at each indv hash\n \tif new_array.empty?\n\n \t\tfirst_new_element = {name: original_array_element[:name], count: 1}\n \t\tnew_array.push(first_new_element)\n\n \telse\n name_found = false\n \t\tnew_array.each do |new_hash_item|\n \t\t\t#binding.pry\n \t\t\tif new_hash_item.has_value?(original_array_element[:name])\n \t\t\t\tnew_hash_item[:count] += 1\n name_found = true\n \t\t\tend\n end\n if name_found == false\n new_element = {name: original_array_element[:name], count: 1}\n new_array.push(new_element)\n end\n \tend\n end\n return new_array\nend",
"def total_in_subarr(arr)\n sum = 0\n for item in arr do\n sum += item\n end\n sum\nend",
"def subarray_sum(nums, k)\n subarray_count = 0\n map = {0 => 1}\n sum = 0\n \n nums.each_with_index do |n, idx|\n \n new_sum = sum += n\n # newsum = 1\n \n # if key exists\n if map[new_sum - k]\n \n subarray_count += map[new_sum - k]\n end\n \n map[new_sum].nil? ? map[new_sum] = 1 : map[new_sum] += 1\n \n sum = new_sum\n end\n \n return subarray_count\nend",
"def element_count(arr)\n\n # initialize 0 as needed to count\n count = Hash.new(0)\n arr.each do |c|\n count[c] += 1 \n end\n return count\n\nend",
"def count_elements(array)\n newArray = []\n array.each do |obj|\n newArray.push(obj)\n obj[:count] = 0\n #if newArray.length > 0\n newArray.each do |obj|\n if obj.include?(:count)\n obj[:count] += 1\n else\n obj[:count] = 1\n end\n #binding.pry\n end\n #end\n end\n newArray.shift\n return newArray\nend",
"def frequency(a)\r\n a.group_by do |e|\r\n e\r\n end.map do |key, values|\r\n [values.size]\r\n end\r\nend",
"def minSubLength(arr, i)\n subs = find_sub_arrays(arr)\n correct = subs.select { |array| array.sum >= i }.min_by { |x| x.length }\n p correct\n correct == nil ? 0 : correct.size\nend",
"def span_count ary\n ([0] + ary).lazy\n .each_cons(2)\n .count{|c,n| c == 0 && n != 0 }\nend",
"def get_length(array)\n return array.inject (0) { |length, el| length + 1 }\nend",
"def count(arr)\n arr.select { |el| yield(el) }.size\nend",
"def count(arr)\n counter = 0\n arr.each { |el| counter += 1 if yield(el) }\n counter\nend",
"def find_length(array)\n \n array.map {|elem| elem.length}\n \nend",
"def merge_sort_count(array)\n return 0, array if array.size == 1\n n = array.size / 2\n first_count = 0\n last_count = 0\n first_array = array.take(n)\n last_array = array.drop(n)\n # binding.pry\n first_count, array_b = merge_sort_count(first_array)\n last_count, array_c = merge_sort_count(last_array)\n split_count, array_a = count_split_inversions(array_b,array_c)\n return (split_count + first_count + last_count), array_a\nend",
"def count(*args)\n arr = [*args]\n counter = 0\n\n arr.each do |el|\n counter += 1 if yield(el)\n end\n\n counter\nend",
"def size\n \[email protected]\n end",
"def customer_pet_count(customer_array)\n customer_array[:pets].count\nend",
"def count(*_args)\n to_a.size\n end",
"def numUnique(array)\n\n uniques = {}\n counter = 0\n\n for element in array\n if uniques[element]\n uniques[element] = uniques[element] + 1\n else\n uniques[element] = 1\n end\n end\n\n count_uniques = 0\n\n for element in uniques\n count_uniques += 1\n end\n\n return count_uniques\n\nend",
"def run\n # Digits 1,4,7,8 have 2,4,3,7 segments respectively\n @list.map{|line| line[1]}.flatten.map(&:length).filter{|len| [2, 4, 3, 7].include?(len)}.count\n end",
"def length_finder(input_array)\n #input_array.map { |s| s.length }\n input_array.map(&:length)\nend",
"def array_length(array)\n array.length\nend"
] | [
"0.7792966",
"0.7725135",
"0.7427933",
"0.73195374",
"0.7199882",
"0.7183751",
"0.71461487",
"0.70884186",
"0.7065079",
"0.7054021",
"0.7024071",
"0.6965469",
"0.6928716",
"0.6916114",
"0.6912451",
"0.6910643",
"0.6863588",
"0.68600655",
"0.68514043",
"0.681722",
"0.68087673",
"0.6788601",
"0.676974",
"0.6738768",
"0.6732032",
"0.6725147",
"0.6699861",
"0.6699798",
"0.669398",
"0.66869307",
"0.66850376",
"0.6682527",
"0.66761404",
"0.66558295",
"0.6645939",
"0.66416174",
"0.6635499",
"0.6615568",
"0.66130465",
"0.6605833",
"0.6600316",
"0.65933716",
"0.65862006",
"0.6577213",
"0.6563965",
"0.65573466",
"0.65572196",
"0.654721",
"0.6539058",
"0.6538151",
"0.6525226",
"0.651079",
"0.65004706",
"0.64760745",
"0.64724016",
"0.64614266",
"0.6456834",
"0.6456733",
"0.64550084",
"0.64542615",
"0.6451978",
"0.64437574",
"0.64437574",
"0.6436209",
"0.6425192",
"0.6425163",
"0.6412645",
"0.63989",
"0.6391507",
"0.639103",
"0.6390601",
"0.63723385",
"0.6366295",
"0.63649565",
"0.63626045",
"0.63583195",
"0.6351565",
"0.6347374",
"0.63415366",
"0.633138",
"0.63295144",
"0.6328514",
"0.6325902",
"0.6323915",
"0.63091666",
"0.63052785",
"0.6303567",
"0.6301793",
"0.6300461",
"0.6293344",
"0.6289662",
"0.62817454",
"0.6276513",
"0.6276014",
"0.6273751",
"0.62737274",
"0.6273694",
"0.62665117",
"0.62631774",
"0.6262578"
] | 0.83554095 | 0 |
counts how many times an element is present in an array | def occurences_count
Hash.new(0).tap do |result|
each { |item| result[item] += 1 }
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_elements(array)\n\t# My attempt:\n\t# hash = {}\n\t# array.each do |e|\n\t# \thash[e] = 1\n\t# end\n\t# new_array = []\n\t# hash.each do |animal, count|\n\t# \tnew_array = hash.select{|animal2, count2| animal2 == animal}\n\t# end\n\t# new_array\n\n\t# Stack Overflow:\n\tcounts = Hash.new(0) # sets default value (the value that is returned when trying to access key that does not exist) to 0 instead of nil\n\tarray.each { |e| counts[e] += 1 }\n\tcounts\nend",
"def count_occurrences(arr)\n unique_elements = arr.uniq\n unique_elements.each { |element| puts \"#{element} => #{arr.count(element)}\"}\nend",
"def count_occurrences_improved(arr)\n counts = Hash.new { |h, k| h[k] = 0 }\n arr.each { |element| counts[element] += 1 }\n counts.each { |element, count| puts \"#{element} => #{count}\" }\nend",
"def count_elements(arr)\n hash = {}\n count = 0\n\n arr.each do |x|\n if !hash.key?(x)\n hash[x] = true\n end\n end\n\n arr.each do |x|\n if hash.key?(x+1)\n count += 1\n end\n end\n\n count\nend",
"def count_elements(array)\n array.group_by(&:itself).map { |key, value| key.merge(count: value.length)} # counts number of times occur\nend",
"def count_occurrences(array)\n\toccurences = {}\n\n\tarray.each do |element|\n\t\toccurences[element] = array.count(element)\n\tend\n\n\toccurences.each do |element, count|\n\t\tputs \"#{element} => #{count}\"\n\tend\t\nend",
"def element_count(arr)\n fre = {}\n fre.default = 0\n arr.each { |el| fre[el] += 1 }\n return fre\nend",
"def count_elements(arr)\n count = 0\n\n arr.each do |x|\n if arr.include?(x+1)\n count += 1\n end\n end\n \n count\nend",
"def element_count(array)\n\nend",
"def count_occurrences(array)\n count = Hash.new\n counter = 0\n array.each { |i| \n if count[i] == nil\n count[i] = 1\n else\n count[i] = count[i] += 1\n end\n counter += 1\n }\n count.each_pair { |k, v| puts \"#{k} => #{v}\"}\nend",
"def Occurrence_count(arr)\n\th1={}\n\tarr.each do |element|\n\t\th1[\"#{element}\"].nil? ? h1[\"#{element}\"]=1 : h1[\"#{element}\"]+=1\n\tend\n\th1.each do |key,value|\n\t\tputs \"\tOccurrence of #{ key } in the array is #{value} times \"\n\tend\t\nend",
"def count_occurrences(array)\n number_of_occurrences = {}\n array.each do |element|\n if number_of_occurrences.include?(element)\n number_of_occurrences[element] += 1\n else\n number_of_occurrences[element] = 1\n end\n end\n number_of_occurrences\nend",
"def count_occurrences(array)\n result = {}\n array.each do |x|\n result[x] = if !result.key?(x)\n 1\n else\n result.fetch(x) + 1\n end\n end\n result.each do |k, count|\n p \"#{k} => #{count}\"\n end\nend",
"def count_elements(arr)\n counter = Array.new\n counter_helper = Array.new\n arr.each do |element|\n if counter_helper.include?(element)\n counter[counter_helper.find_index(element)][:count] += 1\n else\n counter_helper.push(element.clone)\n element[:count] = 1\n counter.push(element)\n end\n end\n counter\nend",
"def count_occurrences(array)\n hash = {}\n array.each do |element|\n if hash.has_key?(element)\n hash[element] += 1\n else\n hash[element] = 1\n end\n end\n hash.each { |key, value| puts \"#{key} => #{value}\" }\nend",
"def element_count(arr)\n\n # initialize 0 as needed to count\n count = Hash.new(0)\n arr.each do |c|\n count[c] += 1 \n end\n return count\n\nend",
"def numUnique(array)\n\n uniques = {}\n counter = 0\n\n for element in array\n if uniques[element]\n uniques[element] = uniques[element] + 1\n else\n uniques[element] = 1\n end\n end\n\n count_uniques = 0\n\n for element in uniques\n count_uniques += 1\n end\n\n return count_uniques\n\nend",
"def gem_element arr\n freq = Hash.new(0)\n count = 0\n\n combo = arr.map(&:chars).map(&:uniq).flatten\n combo.each{ |key| freq[key]+=1 }\n freq.each{ |k,v| count +=1 if v == arr.size }\n count\n \nend",
"def count_occurrences(array)\n occurrences = {}\n\n array.uniq.each do |element|\n occurrences[element] = array.count(element)\n end\n\n occurrences.each do |element, count|\n puts \"#{element} => #{count}\"\n end\nend",
"def count_elements(array)\n counts = Hash.new 0\n unique_elements = array.uniq\n\n unique_elements.each do |item|\n item[:count] = array.count(item)\n end\n\n unique_elements\nend",
"def count_elements(array)\n\nend",
"def count_occurrences(array)\n return puts('Invalid Array') unless array.is_a?(Array)\n return puts('There is nothing to count') if array.empty?\n\n counts = array.each_with_object(Hash.new(0)) do |word, hash|\n hash[word] += 1\n end\n\n counts.each do |word, count|\n puts \"#{word} => #{count}\"\n end\nend",
"def count_occurrences(array)\n occurences = {}\n array.each do |element|\n if occurences.key?(element)\n occurences[element] += 1\n else\n occurences[element] = 1\n end\n end\n\n occurences.each { |key, value| puts \"#{key}: #{value}\" }\nend",
"def count_occurrences(arr)\n answer = Hash.new(0)\n arr.each { |item| answer[item] += 1}\n answer.each {|key, value| puts \"#{key} => #{value}\" }\nend",
"def count_occurences(array)\n\n # interate over array and add unique values as keys to a new hash\n unique_values = {}\n\n array.each do |item|\n if unique_values.keys.include?(item) == false\n unique_values[item] = 0\n end\n end\n # ------------\n\n\n # interate over hash and array, +1 the value of key for every match in array\n unique_values.each_key do |key|\n array.each do |item|\n if key == item\n unique_values[key] += 1\n end\n end\n end\n\n unique_values\nend",
"def find_elements(arr)\n elements = Hash.new(0)\n\n arr.each { |ele| elements[ele] += 1 }\n\n elements\nend",
"def count_elements(array)\n new_array = array.uniq\n new_array.each do |hash|\n hash[:count] = array.count(hash)\n end\n new_array\nend",
"def count(array)\n count = 0\n array.each do |x|\n count += 1\n end\n\n return count\nend",
"def solution0(a)\n\n total_count = 0\n elem_counts = Hash.new(0)\n\n a.each do |elem|\n elem_counts[elem] += 1\n total_count += 1 if elem_counts[elem] == 2\n end\n\n return total_count\n\nend",
"def count_occurrences(arr)\n keys = arr.uniq\n keys.map do|key| \n [key, arr.count {|v| v == key }]\n end\nend",
"def count_array(array, val)\n i = 0\n output = 0\n while i < array.length\n if array[i] == val\n output += 1\n end\n i += 1\n end\n return output\nend",
"def count_elements(array)\n new_hash = {}\n count = 0\n array.each do |x|\n if new_hash.key? x\n new_hash[x] = new_hash[x] + 1\n #binding.pry\n else\n new_hash[x] = 1\n end\n end\n new_hash\n # code goes here\nend",
"def count_freq(array)\n array.each_with_object(Hash.new(0)) { |obj, counts| counts[obj] += 1 }\n end",
"def num_occur(array, target)\n return 0 if array.empty?\n count = 0\n count += 1 if array.first == target \n count + num_occur(array.drop(1), target)\nend",
"def cnts a\n r = []\n found = false\n a.each do |x|\n r.each do |y|\n if y[0] === x\n y[1] += 1\n found = true\n break\n end\n end\n if !found\n r.push([x, 1])\n else\n found = false\n end\n end\n r\nend",
"def num_duplicates\n count = 0\n nums = Hash.new(0)\n @array.each do |num|\n nums[num] += 1\n count += 1 if nums[num] > 1\n end\n count\nend",
"def count_occurences(array = [])\n elements = {}\n array.each { |e| elements[e] = array.count(e) }\n elements.each { |key, value| puts \"#{key} => #{value}\" }\nend",
"def custom_count(array)\n counter = 0\n array.each do |elem|\n if elem != nil\n counter += 1\n end\n end\n counter\nend",
"def element_count(arr)\n hash = {} \n\n # debugger \n arr.each {|ele| hash[ele] = arr.count(ele) }\n\n hash \nend",
"def num_occur(array, target)\n return 0 if array == []\n #every element appears zero times\n dup_array = array.dup\n value = dup_array.shift\n #previous\n if value == target\n count = num_occur(dup_array, target) + 1 #return previous, add one\n else\n count = num_occur(dup_array, target) #return previous value\n end\n count #ensures count is used for prior calls\n\nend",
"def num_occur(array, target)\n count = 0\n if array.empty?\n 0\n else\n count = 1 if array.first == target\n count += num_occur(array.drop(1), target)\n count\n end\nend",
"def num_occur(array, target)\n return 0 if array.empty?\n count = array.first == target ? 1 : 0\n count += num_occur(array.drop(1), target)\nend",
"def subarray_count(subarray)\n\t\t\t\t\teach_cons(subarray.length).count(subarray)\n\t\t\t end",
"def count_elements(array)\n array.uniq.collect do |word|\n word[:count] = array.count(word)\n word\n end\nend",
"def numUnique(array)\n uniq_nums = {}\n if array.length == 0\n uniq_nums = {}\n end\n for i in 0...array.length\n uniq_nums[array[i]] = true\n end\n return uniq_nums.keys.length\nend",
"def num_occur(array, target)\n return 0 if array.empty?\n occurrence = array.first == target ? 1 : 0\n occurrence + num_occur(array.drop(1))\nend",
"def element_frequency_count\n collection.each_with_object(Hash.new(0)) {|element, occurrence| occurrence[element] += 1}\n end",
"def count_occurrences(array)\n array.uniq.each { |word| puts \"#{word} => #{array.count(word)}\"}\nend",
"def number_of(val)\n res = 0\n @array.each { |row| row.each { |v| res +=1 if v == val } }\n res\n end",
"def count(element = nil)\n if element.nil?\n return size\n end\n filter { |x| x == element }.size\n end",
"def element_count(arr)\n # Write your code here\n array = arr.uniq\n result = {}\n i = 0\n x = array.length\n loop do\n result.store(array[i],arr.count(array[i]))\n i += 1\n break if i == x\n end \nreturn result\nend",
"def count(arr, item)\n\tarr.count { |x| x == item }\nend",
"def count(array)\n hash = {}\n array.each do |item|\n hash[item] = array.count(item)\n end\n hash\nend",
"def count_occurrences(array)\n occurances = {}\n\n array.each do |item|\n if occurances[item]\n occurances[item] += 1\n else \n occurances[item] = 1\n end\n end\n \n occurances.each do |key, value| \n puts \"#{key} => #{value}\"\n end\nend",
"def num_occur(array, target)\n dup = array.dup\n if dup.length == 1 \n return (dup.pop == target) ? 1 : 0\n end\n increment_count_by = (dup.pop == target) ? 1 : 0\n count = increment_count_by + num_occur(dup, target)\nend",
"def num_occur(array, target)\n count = 0\n first_ele = array[0]\n count += 1 if first_ele == target\n\n return count if array.empty?\n\n count += num_occur(array[1..-1],target)\n count\nend",
"def num_occur(array, target)\n return 0 if array.empty?\n \n occurrences = 0\n\n if array[0] == target\n occurrences = 1\n end\n\n occurrences + num_occur(array[1..-1], target)\nend",
"def count(*arr)\n arr.inject(0) { |count, el| yield(el) ? count + 1 : count }\nend",
"def count_occurrences(array)\n occurrences = {}\n array.each do |word|\n if occurrences.include?(word)\n occurrences[word] = occurrences[word] + 1\n else\n occurrences[word] = 1\n end\n end\n occurrences.each { |word, count| puts \"#{word} => #{count}\" }\nend",
"def count_occurence(array)\n counts = Hash.new(0)\n array.each { |name| counts[name] += 1 }\n puts counts\n\n price_calculator=PriceCalculator.new\n price_calculator.sepitem_quantity(counts)\n\n end",
"def count_elements(array)\n new_array = []\n\n array.each do |original_array_element|\n\n #now inside the array looking at each indv hash\n \tif new_array.empty?\n\n \t\tfirst_new_element = {name: original_array_element[:name], count: 1}\n \t\tnew_array.push(first_new_element)\n\n \telse\n name_found = false\n \t\tnew_array.each do |new_hash_item|\n \t\t\t#binding.pry\n \t\t\tif new_hash_item.has_value?(original_array_element[:name])\n \t\t\t\tnew_hash_item[:count] += 1\n name_found = true\n \t\t\tend\n end\n if name_found == false\n new_element = {name: original_array_element[:name], count: 1}\n new_array.push(new_element)\n end\n \tend\n end\n return new_array\nend",
"def freq(array)\n hash = Hash.new(0)\n array.each{|key| hash[key] += 1}\n hash\nend",
"def num_unique2(arr)\n count = 0\n new_number = nil\n arr.each do |number|\n if new_number != number\n new_number = number\n count += 1\n end\n end\n return count\n end",
"def element_count(arr)\n newHash = Hash.new(0)\n arr.each{|x|newHash[x]+=1}\n return newHash\n\nend",
"def word_count(arr)\n count = Hash.new(0)\n arr.each { |i| count[i] += 1 }\n \n return count\nend",
"def count_hash(arr)\n count = {}\n arr.each {|e|\n count[e] ||= 0\n count[e] += 1\n }\n count\n end",
"def count_list(array)\n counter = 0\n array.each do |num|\n counter +=1\n end\ncounter\nend",
"def count_occurrences(array)\n count = ''\n output = { }\n\n array.each do |item|\n count = array.count(item)\n output[item] = count\n end\n output.each do |key, value|\n puts \"#{key} => #{value}\"\n end\nend",
"def count_occurrences_ord(arr)\n arr = arr.compact.sort\n ind1 = 0\n ind2 = 1\n while ind2 < arr.size\n current = arr[ind1]\n counter = 1\n while (ind2 < arr.size && arr[ind1] == arr[ind2])\n counter += 1\n ind2 += 1\n end\n ind1 = ind2\n ind2 += 1\n puts \"#{current} => #{counter}\"\n # take care of last item of array\n if ind2 == arr.size \n puts \"#{arr[ind1]} => 1\"\n end\n end\nend",
"def count_occurrences(array)\n frequncies = Hash.new(0)\n\n array.each do |word|\n frequncies[word] += 1\n end\n\n frequncies.each do |word, frequency|\n puts \"#{word} => #{frequency}\"\n end\nend",
"def count_elements(array)\n newArray = []\n array.each do |obj|\n newArray.push(obj)\n obj[:count] = 0\n #if newArray.length > 0\n newArray.each do |obj|\n if obj.include?(:count)\n obj[:count] += 1\n else\n obj[:count] = 1\n end\n #binding.pry\n end\n #end\n end\n newArray.shift\n return newArray\nend",
"def counts\n count = Hash.new(0)\n self.each{|ele| count[ele] += 1}\n count\n end",
"def compute_element_occurrence(values)\n uniq_elements = Hash.new(0)\n values.map { |x| uniq_elements[x] += 1 }\n uniq_elements\nend",
"def count(array, item)\n i = 0\n output = []\n count = 0\n while i <= array.length-1\n if array[i] == item\n count += 1\n end\n i += 1\n end\n return count\nend",
"def repeated(array)\n counts = Hash.new(0)\n array.each { |val| counts[val] += 1 }\n return counts.reject { |_, count| count == 1 }.keys\n end",
"def num_occur(array, target)\n return 0 if array.empty?\n count_update = array.first == target ? 1 : 0\n count_update + num_occur(array.drop(1), target)\nend",
"def num_occur(array, target)\n return 0 if array.empty?\n count_update = array.first == target ? 1 : 0\n count_update + num_occur(array.drop(1), target)\nend",
"def num_occur(array, target)\n @base ||= 0\n @base += 1 if array[0] == target\n num_occur(array.drop(1),target) unless array.empty?\n @base\nend",
"def solution(a)\r\n # write your code in Ruby 2.2\r\n \r\n arr =[]\r\n a.each_with_index{|el,i|\r\n \r\n if !arr.index(el) \r\n arr << el\r\n end\r\n \r\n }\r\n arr.count\r\nend",
"def count(arr)\n counter = 0\n arr.each { |el| counter += 1 if yield(el) }\n counter\nend",
"def solution(a)\n h = {}\n a.each do |num|\n h[num] ? h[num] += 1 : h[num] = 1\n end\n h.keys.count\nend",
"def num_occur(array, target)\n return 0 if array.length <= 0\n count = 0\n if array[0] == target\n count += 1\n count += num_occur(array[1..-1], target)\n else \n count += num_occur(array[1..-1], target)\n end \n count\nend",
"def count_occurrences(array)\n counts = {}\n array.each { |word| counts.include?(word) ? \\\n counts[word] += 1 : counts[word] = 1}\n counts.each_pair { |key, value| puts \"#{key} => #{value}\" }\nend",
"def count(*array)\n total = 0\n array.each { |element| total += 1 if yield(element) }\n total\nend",
"def solution(a)\n a.uniq.count\nend",
"def count_occurences_w_hash(arry)\n occurrences = {}\n \n arry.each {|ele|\n occurrences[ele] = arry.count(ele)\n }\n \n occurrences.each {|k,v|\n puts \"#{k.to_s} => #{v}\"\n }\nend",
"def count_elements(array)\n array.each_with_object(Hash.new(0)){|arr, hash| hash[arr[:name]] += 1}.map{|key, value|{:name=>key, :count=>value}}\nend",
"def count_occurrences1(array)\n occurrences = {}\n\n array.map(&:downcase).each do |element|\n occurrences[element] = array.count(element)\n end\n\n occurrences.each do |element, count|\n puts \"#{element} => #{count}\"\n end\nend",
"def frequency(a)\r\n a.group_by do |e|\r\n e\r\n end.map do |key, values|\r\n [values.size]\r\n end\r\nend",
"def countSheeps array\n array.count(true)\nend",
"def array_to_count_hash(arr)\n h = {}\n arr.each do |el|\n if h.has_key?(el)\n h[el] += 1\n else\n h[el] = 1\n end\n end\n return h\n end",
"def countSheeps2 array\n array.count(true)\nend",
"def count_clumps(array)\n count = []\n current_num = 0\n array.each do |num|\n if ((num === current_num) && (count.include?(num) == false))\n count << num\n end\n current_num = num\n end\n return count.length\nend",
"def unique_occurrences(arr)\n hash = {}\n arr.each {|i| hash[i.to_s] ? (hash[i.to_s]+=1) : (hash[i.to_s]=1)}\n return hash.values.count == hash.values.uniq.count ? true : false\nend",
"def count_items(elective_array)\n return elective_array.length\nend",
"def count(r)\n c = Hash.new(0)\n r.each { |z| c[z] += 1}\n c\nend",
"def solution(a)\n counter = Hash.new(0)\n a.each do |elem|\n counter[elem] += 1\n end\n\n (1..a.size).each do |number|\n return 0 if counter[number] != 1\n end\n\n 1\nend",
"def count\n elements.count\n end",
"def count_elements(array)\n #Build hash where key = name and val = count\n counts = Hash.new(0)\n array.each do |element|\n counts[element[:name]] += 1\n end\n\n #Turn this into array of hashes\n ret = []\n counts.map do |key, val|\n h = {}\n h[:name] = key\n h[:count] = val\n ret << h\n end\n ret\nend",
"def count_occurences(arr)\n count = Hash.new(0)\n arr.each { |item| count[item.downcase] += 1 }\n count.each { |key, value| puts \"#{key} => #{value}\"}\nend",
"def count_elements (array)\n result_array = []\n\n array.each do |data|\n flag =0\n result_array.each do |k|\n if k[:name] == data[:name]\n k[:count] +=1\n flag =1\n end\n end\n if(flag == 0)\n data[:count] = 1\n result_array << data\n end\n end\n result_array\nend"
] | [
"0.81561077",
"0.80567336",
"0.80441225",
"0.80303264",
"0.80174536",
"0.79930115",
"0.7985508",
"0.79849",
"0.79320467",
"0.7910068",
"0.7881951",
"0.787101",
"0.783135",
"0.781528",
"0.780535",
"0.780194",
"0.7773519",
"0.7746347",
"0.7745694",
"0.7695702",
"0.7679753",
"0.76486456",
"0.7636062",
"0.7629596",
"0.76196295",
"0.75875914",
"0.7583713",
"0.7556489",
"0.75255257",
"0.7517306",
"0.7510023",
"0.75010735",
"0.7494027",
"0.7488119",
"0.74813277",
"0.74638575",
"0.7454712",
"0.7443",
"0.7430989",
"0.74228805",
"0.74216866",
"0.7413301",
"0.74119896",
"0.7393041",
"0.7380664",
"0.73758394",
"0.7353759",
"0.73471296",
"0.73444223",
"0.73355764",
"0.73273826",
"0.73180175",
"0.73041326",
"0.72938067",
"0.72913915",
"0.728007",
"0.7269436",
"0.7248511",
"0.72214985",
"0.72202104",
"0.72137564",
"0.72115153",
"0.7203616",
"0.718478",
"0.717859",
"0.71745837",
"0.7171599",
"0.71588993",
"0.7151003",
"0.714838",
"0.71464163",
"0.71358204",
"0.7119792",
"0.71101516",
"0.709817",
"0.7092139",
"0.7092139",
"0.7088823",
"0.70854884",
"0.7064068",
"0.7061296",
"0.7039767",
"0.7038644",
"0.703608",
"0.7034087",
"0.7008849",
"0.6999772",
"0.6993701",
"0.6982016",
"0.6975195",
"0.6974534",
"0.6974369",
"0.6970128",
"0.69490224",
"0.693582",
"0.693078",
"0.6930359",
"0.69253844",
"0.6916653",
"0.69157237",
"0.6906592"
] | 0.0 | -1 |
maps each element to the number of occurences in the original array | def densities
map { |n| count n }
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def element_count(arr)\n fre = {}\n fre.default = 0\n arr.each { |el| fre[el] += 1 }\n return fre\nend",
"def count_elements(array)\n array.group_by(&:itself).map { |key, value| key.merge(count: value.length)} # counts number of times occur\nend",
"def count_occurrences(array)\n\toccurences = {}\n\n\tarray.each do |element|\n\t\toccurences[element] = array.count(element)\n\tend\n\n\toccurences.each do |element, count|\n\t\tputs \"#{element} => #{count}\"\n\tend\t\nend",
"def count_occurrences(array)\n number_of_occurrences = {}\n array.each do |element|\n if number_of_occurrences.include?(element)\n number_of_occurrences[element] += 1\n else\n number_of_occurrences[element] = 1\n end\n end\n number_of_occurrences\nend",
"def count_occurrences(array)\n result = {}\n array.each do |x|\n result[x] = if !result.key?(x)\n 1\n else\n result.fetch(x) + 1\n end\n end\n result.each do |k, count|\n p \"#{k} => #{count}\"\n end\nend",
"def count_occurrences_improved(arr)\n counts = Hash.new { |h, k| h[k] = 0 }\n arr.each { |element| counts[element] += 1 }\n counts.each { |element, count| puts \"#{element} => #{count}\" }\nend",
"def count_occurrences(array)\n hash = {}\n array.each do |element|\n if hash.has_key?(element)\n hash[element] += 1\n else\n hash[element] = 1\n end\n end\n hash.each { |key, value| puts \"#{key} => #{value}\" }\nend",
"def count_occurrences(arr)\n answer = Hash.new(0)\n arr.each { |item| answer[item] += 1}\n answer.each {|key, value| puts \"#{key} => #{value}\" }\nend",
"def count_occurrences(array)\n count = Hash.new\n counter = 0\n array.each { |i| \n if count[i] == nil\n count[i] = 1\n else\n count[i] = count[i] += 1\n end\n counter += 1\n }\n count.each_pair { |k, v| puts \"#{k} => #{v}\"}\nend",
"def count_elements(array)\n\t# My attempt:\n\t# hash = {}\n\t# array.each do |e|\n\t# \thash[e] = 1\n\t# end\n\t# new_array = []\n\t# hash.each do |animal, count|\n\t# \tnew_array = hash.select{|animal2, count2| animal2 == animal}\n\t# end\n\t# new_array\n\n\t# Stack Overflow:\n\tcounts = Hash.new(0) # sets default value (the value that is returned when trying to access key that does not exist) to 0 instead of nil\n\tarray.each { |e| counts[e] += 1 }\n\tcounts\nend",
"def count_occurrences(array)\n occurrences = {}\n\n array.uniq.each do |element|\n occurrences[element] = array.count(element)\n end\n\n occurrences.each do |element, count|\n puts \"#{element} => #{count}\"\n end\nend",
"def array_to_count_hash(arr)\n h = {}\n arr.each do |el|\n if h.has_key?(el)\n h[el] += 1\n else\n h[el] = 1\n end\n end\n return h\n end",
"def element_count(arr)\n\n # initialize 0 as needed to count\n count = Hash.new(0)\n arr.each do |c|\n count[c] += 1 \n end\n return count\n\nend",
"def count_elements(array)\n new_array = array.uniq\n new_array.each do |hash|\n hash[:count] = array.count(hash)\n end\n new_array\nend",
"def count_freq(array)\n array.each_with_object(Hash.new(0)) { |obj, counts| counts[obj] += 1 }\n end",
"def count_occurrences(array)\n occurences = {}\n array.each do |element|\n if occurences.key?(element)\n occurences[element] += 1\n else\n occurences[element] = 1\n end\n end\n\n occurences.each { |key, value| puts \"#{key}: #{value}\" }\nend",
"def count_occurences(array)\n\n # interate over array and add unique values as keys to a new hash\n unique_values = {}\n\n array.each do |item|\n if unique_values.keys.include?(item) == false\n unique_values[item] = 0\n end\n end\n # ------------\n\n\n # interate over hash and array, +1 the value of key for every match in array\n unique_values.each_key do |key|\n array.each do |item|\n if key == item\n unique_values[key] += 1\n end\n end\n end\n\n unique_values\nend",
"def count_elements(array)\n counts = Hash.new 0\n unique_elements = array.uniq\n\n unique_elements.each do |item|\n item[:count] = array.count(item)\n end\n\n unique_elements\nend",
"def count_elements(array)\n array.each_with_object(Hash.new(0)){|arr, hash| hash[arr[:name]] += 1}.map{|key, value|{:name=>key, :count=>value}}\nend",
"def count_occurrences1(array)\n occurrences = {}\n\n array.map(&:downcase).each do |element|\n occurrences[element] = array.count(element)\n end\n\n occurrences.each do |element, count|\n puts \"#{element} => #{count}\"\n end\nend",
"def count_occurences(array = [])\n elements = {}\n array.each { |e| elements[e] = array.count(e) }\n elements.each { |key, value| puts \"#{key} => #{value}\" }\nend",
"def count_occurrences(arr)\n keys = arr.uniq\n keys.map do|key| \n [key, arr.count {|v| v == key }]\n end\nend",
"def find_elements(arr)\n elements = Hash.new(0)\n\n arr.each { |ele| elements[ele] += 1 }\n\n elements\nend",
"def count(array)\n hash = {}\n array.each do |item|\n hash[item] = array.count(item)\n end\n hash\nend",
"def count_elements(array)\n new_hash = {}\n count = 0\n array.each do |x|\n if new_hash.key? x\n new_hash[x] = new_hash[x] + 1\n #binding.pry\n else\n new_hash[x] = 1\n end\n end\n new_hash\n # code goes here\nend",
"def count_hash(arr)\n count = {}\n arr.each {|e|\n count[e] ||= 0\n count[e] += 1\n }\n count\n end",
"def freq(array)\n hash = Hash.new(0)\n array.each{|key| hash[key] += 1}\n hash\nend",
"def count_elements(arr)\n hash = {}\n count = 0\n\n arr.each do |x|\n if !hash.key?(x)\n hash[x] = true\n end\n end\n\n arr.each do |x|\n if hash.key?(x+1)\n count += 1\n end\n end\n\n count\nend",
"def element_frequency_count\n collection.each_with_object(Hash.new(0)) {|element, occurrence| occurrence[element] += 1}\n end",
"def count_elements(arr)\n counter = Array.new\n counter_helper = Array.new\n arr.each do |element|\n if counter_helper.include?(element)\n counter[counter_helper.find_index(element)][:count] += 1\n else\n counter_helper.push(element.clone)\n element[:count] = 1\n counter.push(element)\n end\n end\n counter\nend",
"def element_count(arr)\n hash = {} \n\n # debugger \n arr.each {|ele| hash[ele] = arr.count(ele) }\n\n hash \nend",
"def count_elements(array)\n array.uniq.collect do |word|\n word[:count] = array.count(word)\n word\n end\nend",
"def count_occurrences(array)\n occurances = {}\n\n array.each do |item|\n if occurances[item]\n occurances[item] += 1\n else \n occurances[item] = 1\n end\n end\n \n occurances.each do |key, value| \n puts \"#{key} => #{value}\"\n end\nend",
"def element_count(arr)\n newHash = Hash.new(0)\n arr.each{|x|newHash[x]+=1}\n return newHash\n\nend",
"def count_occurrences(array)\n return puts('Invalid Array') unless array.is_a?(Array)\n return puts('There is nothing to count') if array.empty?\n\n counts = array.each_with_object(Hash.new(0)) do |word, hash|\n hash[word] += 1\n end\n\n counts.each do |word, count|\n puts \"#{word} => #{count}\"\n end\nend",
"def count_occurrences(array)\n count = ''\n output = { }\n\n array.each do |item|\n count = array.count(item)\n output[item] = count\n end\n output.each do |key, value|\n puts \"#{key} => #{value}\"\n end\nend",
"def frequency(a)\r\n a.group_by do |e|\r\n e\r\n end.map do |key, values|\r\n [values.size]\r\n end\r\nend",
"def counts\n count = Hash.new(0)\n self.each{|ele| count[ele] += 1}\n count\n end",
"def occurences_count\n\t\t\t\t\t\tHash.new(0).tap do |result|\n\t\t\t\t\t\t each { |item| result[item] += 1 }\n\t\t\t\t\t\tend\n\t\t\t\tend",
"def count_occurrences(array)\n frequncies = Hash.new(0)\n\n array.each do |word|\n frequncies[word] += 1\n end\n\n frequncies.each do |word, frequency|\n puts \"#{word} => #{frequency}\"\n end\nend",
"def cnts a\n r = []\n found = false\n a.each do |x|\n r.each do |y|\n if y[0] === x\n y[1] += 1\n found = true\n break\n end\n end\n if !found\n r.push([x, 1])\n else\n found = false\n end\n end\n r\nend",
"def count_elements(array)\n #Build hash where key = name and val = count\n counts = Hash.new(0)\n array.each do |element|\n counts[element[:name]] += 1\n end\n\n #Turn this into array of hashes\n ret = []\n counts.map do |key, val|\n h = {}\n h[:name] = key\n h[:count] = val\n ret << h\n end\n ret\nend",
"def numUnique(array)\n\n uniques = {}\n counter = 0\n\n for element in array\n if uniques[element]\n uniques[element] = uniques[element] + 1\n else\n uniques[element] = 1\n end\n end\n\n count_uniques = 0\n\n for element in uniques\n count_uniques += 1\n end\n\n return count_uniques\n\nend",
"def Occurrence_count(arr)\n\th1={}\n\tarr.each do |element|\n\t\th1[\"#{element}\"].nil? ? h1[\"#{element}\"]=1 : h1[\"#{element}\"]+=1\n\tend\n\th1.each do |key,value|\n\t\tputs \"\tOccurrence of #{ key } in the array is #{value} times \"\n\tend\t\nend",
"def word_count(arr)\n count = Hash.new(0)\n arr.each { |i| count[i] += 1 }\n \n return count\nend",
"def count_occurrences(array)\n occurrences = {}\n array.each do |word|\n if occurrences.include?(word)\n occurrences[word] = occurrences[word] + 1\n else\n occurrences[word] = 1\n end\n end\n occurrences.each { |word, count| puts \"#{word} => #{count}\" }\nend",
"def count_occurences(arr)\n count = Hash.new(0)\n arr.each { |item| count[item.downcase] += 1 }\n count.each { |key, value| puts \"#{key} => #{value}\"}\nend",
"def compute_element_occurrence(values)\n uniq_elements = Hash.new(0)\n values.map { |x| uniq_elements[x] += 1 }\n uniq_elements\nend",
"def gem_element arr\n freq = Hash.new(0)\n count = 0\n\n combo = arr.map(&:chars).map(&:uniq).flatten\n combo.each{ |key| freq[key]+=1 }\n freq.each{ |k,v| count +=1 if v == arr.size }\n count\n \nend",
"def count_occurrences(arr)\n unique_elements = arr.uniq\n unique_elements.each { |element| puts \"#{element} => #{arr.count(element)}\"}\nend",
"def num_duplicates\n count = 0\n nums = Hash.new(0)\n @array.each do |num|\n nums[num] += 1\n count += 1 if nums[num] > 1\n end\n count\nend",
"def count_elements(array)\n new_array = []\n\n array.each do |original_array_element|\n\n #now inside the array looking at each indv hash\n \tif new_array.empty?\n\n \t\tfirst_new_element = {name: original_array_element[:name], count: 1}\n \t\tnew_array.push(first_new_element)\n\n \telse\n name_found = false\n \t\tnew_array.each do |new_hash_item|\n \t\t\t#binding.pry\n \t\t\tif new_hash_item.has_value?(original_array_element[:name])\n \t\t\t\tnew_hash_item[:count] += 1\n name_found = true\n \t\t\tend\n end\n if name_found == false\n new_element = {name: original_array_element[:name], count: 1}\n new_array.push(new_element)\n end\n \tend\n end\n return new_array\nend",
"def count_occurrences(array)\n \n count_hash = {}\n \n array.map(&:downcase!)\n \n array.uniq.each do |ele|\n count_hash[ele] = 0\n end\n \n array.each do |ele|\n count_hash[ele] += 1\n end\n \n puts count_hash\nend",
"def count(r)\n c = Hash.new(0)\n r.each { |z| c[z] += 1}\n c\nend",
"def solution0(a)\n\n total_count = 0\n elem_counts = Hash.new(0)\n\n a.each do |elem|\n elem_counts[elem] += 1\n total_count += 1 if elem_counts[elem] == 2\n end\n\n return total_count\n\nend",
"def count_occurences_w_hash(arry)\n occurrences = {}\n \n arry.each {|ele|\n occurrences[ele] = arry.count(ele)\n }\n \n occurrences.each {|k,v|\n puts \"#{k.to_s} => #{v}\"\n }\nend",
"def counts_one_line(array)\n array.each_with_object(hello = Hash.new(0)) {|x, counts| counts[x] += 1}\n hello\nend",
"def count_freq\n hash = Hash.new(0)\n self.each do |element|\n hash[element] +=1\n end\n return hash\n end",
"def count_occurrences(array)\n counts = {}\n array.each { |word| counts.include?(word) ? \\\n counts[word] += 1 : counts[word] = 1}\n counts.each_pair { |key, value| puts \"#{key} => #{value}\" }\nend",
"def solution(a)\n h = {}\n a.each do |num|\n h[num] ? h[num] += 1 : h[num] = 1\n end\n h.keys.count\nend",
"def element_count(array)\n\nend",
"def element_count(arr)\n # Write your code here\n array = arr.uniq\n result = {}\n i = 0\n x = array.length\n loop do\n result.store(array[i],arr.count(array[i]))\n i += 1\n break if i == x\n end \nreturn result\nend",
"def count_elements(array)\n new_array = []\n for person in array.uniq\n new_array.push{:name => person[:name], :count => array.count(name)}\n end\nend",
"def count_occurence(array)\n counts = Hash.new(0)\n array.each { |name| counts[name] += 1 }\n puts counts\n\n price_calculator=PriceCalculator.new\n price_calculator.sepitem_quantity(counts)\n\n end",
"def number_of(val)\n res = 0\n @array.each { |row| row.each { |v| res +=1 if v == val } }\n res\n end",
"def count(array)\n count = 0\n array.each do |x|\n count += 1\n end\n\n return count\nend",
"def frequencies\n inject(Hash.new(0)) { |h,v| h[v] += 1; h }\n end",
"def count_elements(array)\n newArray = []\n array.each do |obj|\n newArray.push(obj)\n obj[:count] = 0\n #if newArray.length > 0\n newArray.each do |obj|\n if obj.include?(:count)\n obj[:count] += 1\n else\n obj[:count] = 1\n end\n #binding.pry\n end\n #end\n end\n newArray.shift\n return newArray\nend",
"def char_count (arr, hash)\n arr.each_with_index do |k, i|\n hash[k] = 0\n end\n \n arr.each_with_index do |char, j|\n if hash.has_key?(char)\n hash[char] += 1\n end\n end\n\n return hash\nend",
"def num_unique2(arr)\n count = 0\n new_number = nil\n arr.each do |number|\n if new_number != number\n new_number = number\n count += 1\n end\n end\n return count\n end",
"def count_occurrences_ord(arr)\n arr = arr.compact.sort\n ind1 = 0\n ind2 = 1\n while ind2 < arr.size\n current = arr[ind1]\n counter = 1\n while (ind2 < arr.size && arr[ind1] == arr[ind2])\n counter += 1\n ind2 += 1\n end\n ind1 = ind2\n ind2 += 1\n puts \"#{current} => #{counter}\"\n # take care of last item of array\n if ind2 == arr.size \n puts \"#{arr[ind1]} => 1\"\n end\n end\nend",
"def count_occurrences(arr)\n dc_arr = arr.map { |i| i.downcase }\n dc_arr.each do |i|\n i = ??\n end\nend",
"def count_occurrences(array)\n array.uniq.each { |word| puts \"#{word} => #{array.count(word)}\"}\nend",
"def count_elements(collections)\n counts = Hash.new(0)\n collections.collect {|element| counts[element]+=1 }\n counts.collect do |hash, number|\n hash[:count] = number\n end\n counts.keys\nend",
"def strange_sums(arr)\n hash = Hash.new(0)\n arr.map do |ele|\n hash[ele.abs] += 1\n end\n \n hash.count do |h,v|\n v == 2\n end\nend",
"def count(*arr)\n arr.inject(0) { |count, el| yield(el) ? count + 1 : count }\nend",
"def chromosome_count(genome_array)\n ccount = Hash.new(0)\n genome_array.each {|entry| ccount[entry[1]] += 1}\n ccount.each {|chromosome, count| puts \"Chromosome \" + chromosome.to_s + \" has \" + count.to_s + \" SNP data points\" }\n total = 0\n ccount.values.each {|count| total+= count }\n puts \"----\"\n puts total.to_s + \" total data points\"\n return ccount\nend",
"def count(arr)\n counter = 0\n arr.each { |el| counter += 1 if yield(el) }\n counter\nend",
"def count_elements (array)\n result_array = []\n\n array.each do |data|\n flag =0\n result_array.each do |k|\n if k[:name] == data[:name]\n k[:count] +=1\n flag =1\n end\n end\n if(flag == 0)\n data[:count] = 1\n result_array << data\n end\n end\n result_array\nend",
"def score( array )\r\n array = array.each_with_object(Hash.new(0)){|key,hash|\r\n hash[key] += 1}\r\n return array\r\nend",
"def count_elements(arr)\n count = 0\n\n arr.each do |x|\n if arr.include?(x+1)\n count += 1\n end\n end\n \n count\nend",
"def count_list(array)\n counter = 0\n array.each do |num|\n counter +=1\n end\ncounter\nend",
"def key_indexed_counting(arr, max)\n count = Array.new(max + 1, 0)\n\n arr.each { |num| count[num + 1] += 1 }\n idx = 0\n while idx < max\n count[idx + 1] += count[idx]\n idx += 1\n end\n\n aux = []\n arr.each do |num|\n aux[count[num]] = num\n count[num] += 1\n end\n\n arr.each_index do |idx|\n arr[idx] = aux[idx]\n end\n\n arr\nend",
"def numUnique(array)\n uniq_nums = {}\n if array.length == 0\n uniq_nums = {}\n end\n for i in 0...array.length\n uniq_nums[array[i]] = true\n end\n return uniq_nums.keys.length\nend",
"def count_elements(array)\n\nend",
"def length_finder(input_array)\n input_array.map { |elem| elem.size }\nend",
"def num_occur(array, target)\n dup = array.dup\n if dup.length == 1 \n return (dup.pop == target) ? 1 : 0\n end\n increment_count_by = (dup.pop == target) ? 1 : 0\n count = increment_count_by + num_occur(dup, target)\nend",
"def my_count(arr, &prc)\n arr.inject(0) { |acc, ele| prc.call(ele) ? acc += 1 : acc }\nend",
"def count_occurrences(arr)\noccurrences = {}\n arr.each do |word|\n word = word.downcase\n if occurrences.has_key?(word)\n occurrences[word] = occurrences[word] + 1\n else\n occurrences[word] = 1\n end\n occurrences\n end\n occurrences.each {|k,v| puts \"#{k} => #{v}\"}\nend",
"def count_elements(animals)\n animal_hash = {}\n animals.each do |animal| \n animals.count(animal)\n animal_hash[animal] = animals.count(animal)\n end\n animal_hash\nend",
"def count\n @map.count\n end",
"def custom_count(array)\n counter = 0\n array.each do |elem|\n if elem != nil\n counter += 1\n end\n end\n counter\nend",
"def count(n,ar)\r\n result = Array.new(100){|x| x = 0}\r\n ar.each { |x| result[x] = result[x]+1 }\r\n return result\r\nend",
"def num_occur(array, target)\n return 0 if array == []\n #every element appears zero times\n dup_array = array.dup\n value = dup_array.shift\n #previous\n if value == target\n count = num_occur(dup_array, target) + 1 #return previous, add one\n else\n count = num_occur(dup_array, target) #return previous value\n end\n count #ensures count is used for prior calls\n\nend",
"def num_occur(array, target)\n return 0 if array.empty?\n occurrence = array.first == target ? 1 : 0\n occurrence + num_occur(array.drop(1))\nend",
"def freq_calc(mult_arr)\n\tresult_arr = []\n\tsubarrs_by_index = reorder_on_index(mult_arr)\n\tsubarrs_by_index.uniq.each do |arr|\n\t\tarr.uniq.each do |letter|\n\t\t\tresult_arr << {letter => (count(arr, letter))}\n\t\tend\n\t\tp arr.uniq\n\tend\n\treturn result_arr\nend",
"def subarray_count(subarray)\n\t\t\t\t\teach_cons(subarray.length).count(subarray)\n\t\t\t end",
"def repeated(array)\n counts = Hash.new(0)\n array.each { |val| counts[val] += 1 }\n return counts.reject { |_, count| count == 1 }.keys\n end",
"def count_elements (array_of_hashes)\n#array_of_hashes = [ {:name=>'blake'}, {:name=>'blake'}, {:name=>'ashley'} ]\ncount_hash=Hash.new(0)\narray_of_hashes.each {|hash|\n count_hash[hash]+=1\n }\n #puts new_hash\n #output: {{:name=>\"blake\"}=>2, {:name=>\"ashley\"}=>1}\n merge_count_hash= count_hash.keys.map { |key| \n \tkey[:count]=count_hash[key] \n \tkey\n }\nend",
"def analysis\n hash = {}\n @array.each do |item|\n chars = item.chars.to_a - @used_chars\n\n chars.each do |char|\n if hash[char] == nil\n hash[char] = 1\n else\n hash[char] += 1\n end\n end\n end\n\n hash.sort_by { |_, v| -v }\n end",
"def num_occur(array, target)\n return 0 if array.empty?\n count = 0\n count += 1 if array.first == target \n count + num_occur(array.drop(1), target)\nend"
] | [
"0.8055612",
"0.7852904",
"0.7741645",
"0.7730528",
"0.77238196",
"0.76910156",
"0.7637037",
"0.76022387",
"0.7561815",
"0.7542652",
"0.7519835",
"0.75107825",
"0.7494289",
"0.74699837",
"0.7463726",
"0.7438153",
"0.7430159",
"0.74193585",
"0.741881",
"0.74098176",
"0.735316",
"0.7349505",
"0.7349468",
"0.7345691",
"0.73394525",
"0.7323508",
"0.73220426",
"0.7318037",
"0.7313594",
"0.7290374",
"0.72600627",
"0.7257417",
"0.7242771",
"0.7232489",
"0.7212285",
"0.72060806",
"0.7204513",
"0.7198742",
"0.7187669",
"0.71663105",
"0.7159566",
"0.7154361",
"0.71143943",
"0.7102816",
"0.71026874",
"0.7092598",
"0.70511425",
"0.70498526",
"0.7047416",
"0.70401514",
"0.7036252",
"0.70343614",
"0.7026361",
"0.70251405",
"0.69891715",
"0.6954191",
"0.6945984",
"0.6944049",
"0.6906096",
"0.6884956",
"0.68625027",
"0.6842566",
"0.6832518",
"0.6809824",
"0.679033",
"0.6789382",
"0.678525",
"0.6766037",
"0.67390144",
"0.6697966",
"0.6692752",
"0.66670156",
"0.6663361",
"0.66554916",
"0.66519755",
"0.66143465",
"0.6608682",
"0.6584135",
"0.65772504",
"0.65677035",
"0.6567522",
"0.65452605",
"0.65286285",
"0.65214825",
"0.65132505",
"0.65098816",
"0.6463929",
"0.6453529",
"0.64522785",
"0.6426628",
"0.6423564",
"0.6422701",
"0.6422193",
"0.6417045",
"0.64088994",
"0.6401596",
"0.6397581",
"0.6386824",
"0.63781124",
"0.6351656",
"0.63127226"
] | 0.0 | -1 |
Get a single release asset = Examples github = Github.new github.repos.releases.assets.get 'owner', 'repo', 'id' | def get(*args)
params = arguments(args, required: [:owner, :repo, :id]).params
get_request("/repos/#{owner}/#{repo}/releases/assets/#{id}" , params)
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show\n repo = assets_repo\n @v_asset = repo.get(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @v_asset }\n end\n end",
"def get_release(release_id)\n query_and_build \"releases/#{release_id}\"\n end",
"def get_asset(id)\r\n # Prepare query url.\r\n _path_url = '/gem_assets/{id}'\r\n _path_url = APIHelper.append_url_with_template_parameters(\r\n _path_url,\r\n 'id' => id\r\n )\r\n _query_builder = Configuration.get_base_uri\r\n _query_builder << _path_url\r\n _query_url = APIHelper.clean_url _query_builder\r\n # Prepare headers.\r\n _headers = {\r\n 'accept' => 'application/json'\r\n }\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.get(\r\n _query_url,\r\n headers: _headers\r\n )\r\n CustomHeaderAuth.apply(_request)\r\n _context = execute_request(_request)\r\n validate_response(_context)\r\n # Return appropriate response type.\r\n decoded = APIHelper.json_deserialize(_context.response.raw_body)\r\n AssetDetail.from_hash(decoded)\r\n end",
"def asset(id, params = {})\n get \"assets/#{id}\", {query: params}\n end",
"def asset_url\n URI(\"https://github.com/#{repo}/releases/download/#{release}/\" <<\n app_name)\n end",
"def get_latest_release(project, bin)\n api_url = \"https://api.github.com/repos/#{project}/releases/latest\"\n data = URI.parse(api_url).read\n obj = JSON.parse(data)\n version = obj[\"name\"]\n sha_url = \"https://github.com/#{project}/releases/download/#{version}/#{bin}.sha256\"\n sha = URI.parse(sha_url).read\n url = \"https://github.com/#{project}/releases/download/#{version}/#{bin}\"\n sha256 = sha.split(\" \").first\n\n return url, sha256, version\nend",
"def get_release(project)\n info = get_github_api(project, \"releases\")\n release = 'master'\n if info.length > 0\n unpublishedDraftLimit = 5\n x = 0\n release = info[x]['tag_name']\n # Unpublished drafts need to be skipped.\n while (unpublishedDraftLimit > x) && info[x]['draft']\n release = info[x]['tag_name']\n x += 1\n end\n end\n release\n end",
"def show\n @release = @environment.releases.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @release }\n end\n end",
"def fetch_asset(asset)\n return Asset.find(asset) if Asset.exists?(asset)\n end",
"def asset(asset_id)\n get \"/video/v1/assets/##{asset_id}\"\n end",
"def get(*args)\n arguments(args, required: [:owner, :repo, :id]).params\n\n get_request(\"/repos/#{arguments.owner}/#{arguments.repo}/releases/#{arguments.id}\" , arguments.params)\n end",
"def asset(name:)\n self[:assets].select { |asset| asset[:name] =~ /#{name}/ }.first\n end",
"def [](*args)\n find_asset(*args)\n end",
"def [](*args)\n find_asset(*args)\n end",
"def get(id, asset_reference_type)\n\t\t\tkparams = {}\n\t\t\tclient.add_param(kparams, 'id', id)\n\t\t\tclient.add_param(kparams, 'assetReferenceType', asset_reference_type)\n\t\t\tclient.queue_service_action_call('asset', 'get', 'KalturaAsset', kparams)\n\t\t\tif (client.is_multirequest)\n\t\t\t\treturn nil\n\t\t\tend\n\t\t\treturn client.do_queue()\n\t\tend",
"def release(project_id, release_id, options = {})\n get \"projects/#{project_id}/releases/#{release_id}\", options\n end",
"def get\n raise_method_not_available(__method__, 'is nested asset') if nested_asset?\n assets = client.get(asset_type)\n assets.map { |data| self.new_from_payload(data) }\n end",
"def get_release_info(author, repository, options)\n url = Kernel.format(\n 'https://api.github.com/repos/%{author}/%{repository}/releases/%{tag}%{release}',\n author: author,\n repository: repository,\n tag: (options[:is_tag]) ? 'tags/' : '',\n release: options[:release],\n )\n\n release_info_json = fetch_from_url(\n url,\n options[:username],\n options[:password],\n options[:use_auth],\n options[:use_oauth],\n )\n\n return nil unless release_info_json\n\n # Read in release info from JSON file\n\n Puppet.debug('Parsing release info')\n\n # noinspection RubyResolve\n PSON.load(release_info_json)\nend",
"def get_asset(release_info, filepattern, contenttype)\n filepattern_regexp = Regexp.new(\n filepattern,\n Regexp::IGNORECASE,\n )\n\n contenttype_regexp = Regexp.new(\n contenttype,\n Regexp::IGNORECASE,\n )\n Puppet.debug('Checking assets')\n release_info['assets'].each do |release_asset|\n Puppet.debug(\n Kernel.format(\n 'Checking asset %{name} for RegExp %{regexp}',\n name: release_asset['name'],\n regexp: filepattern_regexp.to_s,\n ),\n )\n Puppet.debug(\n Kernel.format(\n 'Checking content type %{content_type} for RegExp %{regexp}',\n content_type: release_asset['content_type'],\n regexp: contenttype_regexp.to_s,\n ),\n )\n next unless filepattern_regexp.match(\n release_asset['name'],\n ) && contenttype_regexp.match(release_asset['content_type'])\n\n Puppet.debug(\n Kernel.format(\n 'Both are matching. Returning URL %{url}',\n url: release_asset['browser_download_url'],\n ),\n )\n\n return release_asset['browser_download_url'] if release_asset.key?('browser_download_url')\n end\n\n ''\nend",
"def get_asset(namespace, asset_type, asset_id, opts = {})\n data, _status_code, _headers = get_asset_with_http_info(namespace, asset_type, asset_id, opts)\n return data\n end",
"def load_asset\n @asset = Asset.accessible_by(current_ability).find(params[:id])\n end",
"def get(id)\n\t\t\tkparams = {}\n\t\t\tclient.add_param(kparams, 'id', id);\n\t\t\tclient.queue_service_action_call('fileasset', 'get', kparams);\n\t\t\tif (client.is_multirequest)\n\t\t\t\treturn nil;\n\t\t\tend\n\t\t\treturn client.do_queue();\n\t\tend",
"def campaign_release(id)\n rest.get(:releasesms, id: id)['data']\n end",
"def get(id)\n\t\t\tkparams = {}\n\t\t\tclient.add_param(kparams, 'id', id);\n\t\t\tclient.queue_service_action_call('flavorasset', 'get', kparams);\n\t\t\tif (client.is_multirequest)\n\t\t\t\treturn nil;\n\t\t\tend\n\t\t\treturn client.do_queue();\n\t\tend",
"def get_asset(url)\n uri = URI.parse(url)\n\n unless File.exists?(File.join(['public', uri.path]))\n FileManager.new(['public', uri.path], Downloader.get(url, URI.decode_www_form(uri.query)), true).write!\n end\n\n replace_url(url, uri.path)\n end",
"def get_last_release\n r = api_get(\"/releases\")\n\n return r[0]['tag_name']\nend",
"def get_download_url(author, repository, options)\n release_info = get_release_info(author, repository, options)\n\n if options[:asset] && release_info\n download_url = get_asset(release_info, options[:asset_filepattern], options[:asset_contenttype])\n return download_url unless download_url == ''\n\n get_archive_from_release_info(release_info, options[:use_zip])\n elsif release_info\n get_archive_from_release_info(release_info, options[:use_zip])\n elsif options[:asset_fallback] || !options[:asset]\n build_asset_url(\n author,\n repository,\n options,\n )\n else\n raise ArgumentError(\"Can't find download url for given criteria\")\n end\nend",
"def get_asset(asset_id, opts = {})\n data, _status_code, _headers = get_asset_with_http_info(asset_id, opts)\n data\n end",
"def get_artifact\n key = \"#{ @environment_name }/#{ @artifact }/#{ @version }.gpg\"\n @artifact_gpg = run(file_cache: (@file_cache or is_compat_mode?), extension: '.gpg') do\n subsection \"Get artifact from s3://#{ @bucket.name }/#{ key }\", color: :green, prefix: @output_prefix unless @silent\n object = @bucket.object(key)\n object.get.body\n end\n\n if @verify\n @artifact_sign = run(file_cache: (@file_cache or is_compat_mode?), extension: '.sign') do\n signature_key = \"#{ key }.sig\"\n subsection \"Get signature from s3://#{ @bucket.name }/#{ signature_key }\", color: :green, prefix: @output_prefix unless @silent\n object = @bucket.object(signature_key)\n object.get.body\n end\n end\n end",
"def fetch_id\n return unless @name\n\n begin\n response = Inventory.request[\"assets/#{@name}\"].get :content_type => :json, :accept => :json \n asset = JSON.parse(response)\n asset['id']\n rescue RestClient::ResourceNotFound\n nil\n rescue => exception\n puts exception.message\n puts exception.response\n exit 1\n end\n end",
"def get_asset(*params); raise('Stub or mock required.') end",
"def release\n case new_resource.version\n when 'latest'\n require 'octokit'\n Octokit.releases(repo).first[:tag_name]\n else\n \"v#{new_resource.version}\"\n end\n end",
"def versioned_asset\r\n s=self.sop\r\n s=s.parent if s.class.name.end_with?(\"::Version\")\r\n if version.nil?\r\n s.latest_version\r\n else\r\n s.find_version(sop_version)\r\n end\r\n end",
"def find_asset(path, options = {})\n if uri = resolve_asset_uri(path, options)\n Asset.new(self, build_asset_by_uri(uri))\n end\n end",
"def get_json\n return JSON(@asset_repo.get_json(@pid.gsub(\"druid:\", \"\")))\n rescue => e\n return nil\n end",
"def first_release\n self.releases.where(status: STATUS[:completed]).first\n end",
"def get(namespace, asset_type, opts = {})\n data, _status_code, _headers = get_with_http_info(namespace, asset_type, opts)\n return data\n end",
"def release_url(api_url, title)\n # \"subject\": {\n # \"title\": \"v1.4.4\",\n # \"url\": \"https://api.github.com/repos/typed-ember/ember-cli-typescript/releases/13191777\",\n # \"latest_comment_url\": \"https://api.github.com/repos/typed-ember/ember-cli-typescript/releases/13191777\",\n # \"type\": \"Release\"\n # },\n api_index = api_url.index(\"api\")\n repos_index = api_url.index(\"repos\")\n releases_index = api_url.index(\"releases\")\n\n # https://github.com/typed-ember/ember-cli-typescript/releases/tag/v1.4.4\n html_url = api_url[0..api_index - 1] +\n api_url[api_index + \"api.\".length..repos_index - 1] +\n api_url[repos_index + \"repos/\".length..releases_index + \"releases\".length] +\n \"tag/#{title}\"\n html_url\n end",
"def set_asset\n @asset = @org.assets.find(params[:id])\n end",
"def show\n @asset = Asset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @asset }\n end\n end",
"def show\n @asset = Asset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @asset }\n end\n end",
"def show\n @asset = Asset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @asset }\n end\n end",
"def show\n @asset = Asset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @asset }\n end\n end",
"def show\n @asset = Asset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @asset }\n end\n end",
"def show\n if signed_in?\n @author = User.find(@game_asset[:user_id])\n @is_bought_asset = BoughtAsset.exists?(user_id: current_user.id, game_asset_id: params[:id])\n @license = @game_asset.license\n else\n redirect_to signin_path, :notice => \"ログインしてください。\"\n end\n end",
"def asset(key, query = {})\n resp =\n _instrument 'entries', type: 'Asset', id: key, query: query do\n get(\"assets/#{key}\", query)\n end\n resp.assert_ok!\n end",
"def get_selected_asset(convert=true)\n selected_asset = Asset.find_by(:organization_id => @organization_list, :object_key => params[:inventory_id]) unless params[:inventory_id].blank?\n if convert\n asset = get_typed_asset(selected_asset)\n else\n asset = selected_asset\n end\n return asset\n end",
"def get_entry(path, commit = @commit)\n entry_hash = get_entry_hash(path, commit)\n if entry_hash.nil?\n entry = nil\n else\n entry = @repo.lookup(entry_hash[:oid])\n end\n entry\n end",
"def show\n @release = Release.find(params[:id])\n \n # send to release page if not archived\n redirect_to(:controller => 'releases', :action => 'show', :id => @release.id) and return if [email protected]\n \n # populate release fixes from mantis\n if @release.mantis_project_version_id\n @issues = Issue.fixed(@release.mantis_project_id, @release.mantis_project_version_name)\n end\n @version_released = @release.released?\n @version_release_date = Time.at(@release.release_date).strftime(\"%Y-%m-%d\") if @version_released && @release.release_date\n \n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @release }\n end\n end",
"def show\n\t\t@asset = Asset.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tformat.html #index.html.erb\n\t\t\tformat.json { render json: @asset }\n\t\tend\n\tend",
"def get_by_entry_id(entry_id)\n\t\t\tkparams = {}\n\t\t\tclient.add_param(kparams, 'entryId', entry_id);\n\t\t\tclient.queue_service_action_call('flavorasset', 'getByEntryId', kparams);\n\t\t\tif (client.is_multirequest)\n\t\t\t\treturn nil;\n\t\t\tend\n\t\t\treturn client.do_queue();\n\t\tend",
"def asset(name)\n path = Root.join name.to_s.sub(/^\\//, '')\n path.file? && path.readable? ? path : nil\n end",
"def show\n @environment = @project.environments.find_by_slug!(params[:id])\n @releases = @environment.releases\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @environment }\n end\n end",
"def view_asset\n @assets = Asset.find(:all, :conditions => 'is_deleted = 0')\n @currency_type = currency\n end",
"def retrieve_bundle\n VCR.use_cassette('bundle_download') do\n bundle_resource = RestClient::Request.execute(method: :get,\n url: 'https://cypress.healthit.gov/measure_bundles/fixture-bundle-2020.zip',\n user: ENV.fetch('VSAC_USERNAME', nil),\n password: ENV.fetch('VSAC_PASSWORD', nil),\n raw_response: true,\n headers: { accept: :zip })\n\n return bundle_resource.file\n end\n end",
"def release_info\n @release_info ||= @connection.get(RELEASE_INFO_PATH)['release']\n end",
"def show\n @release = Release.find(params[:id])\n @total_downloads = 0\n @release.versions.each do |v|\n @total_downloads += v.downloads\n end\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @release }\n end\n end",
"def release\n _init\n\n @release = Release.find_by_name(params[:release]) if params[:release]\n @release = Release.actived.first unless @release\n\n render :template => 'sprint/release', :layout => 'release'\n end",
"def show\n @global_asset = GlobalAsset.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @global_asset }\n end\n end",
"def get_archive_from_release_info(release_info, use_zip)\n use_zip ? release_info['zipball_url'] : release_info['tarball_url']\nend",
"def get_asset_with_http_info(namespace, asset_type, asset_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: AssetsApi.get_asset ...\"\n end\n \n \n # verify the required parameter 'namespace' is set\n fail ArgumentError, \"Missing the required parameter 'namespace' when calling AssetsApi.get_asset\" if namespace.nil?\n \n \n \n \n \n \n # verify the required parameter 'asset_type' is set\n fail ArgumentError, \"Missing the required parameter 'asset_type' when calling AssetsApi.get_asset\" if asset_type.nil?\n \n \n \n \n \n \n # verify the required parameter 'asset_id' is set\n fail ArgumentError, \"Missing the required parameter 'asset_id' when calling AssetsApi.get_asset\" if asset_id.nil?\n \n \n \n \n \n # resource path\n local_var_path = \"/{namespace}/assets/{assetType}/{assetId}\".sub('{format}','json').sub('{' + 'namespace' + '}', namespace.to_s).sub('{' + 'assetType' + '}', asset_type.to_s).sub('{' + 'assetId' + '}', asset_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n\n # HTTP header 'Accept' (if needed)\n local_header_accept = ['application/vnd.api+json']\n local_header_accept_result = @api_client.select_header_accept(local_header_accept) and header_params['Accept'] = local_header_accept_result\n\n # HTTP header 'Content-Type'\n local_header_content_type = ['application/json']\n header_params['Content-Type'] = @api_client.select_header_content_type(local_header_content_type)\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n \n auth_names = ['oauth2']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'AssetBody')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AssetsApi#get_asset\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def build_asset_url(author, repository, options)\n Puppet.warning('Building URL myself.')\n\n tag = options[:release]\n\n if tag == 'latest'\n # Rework \"latest\" to \"master\"\n tag = 'master'\n end\n\n suffix = (options[:use_zip]) ? '.zip' : '.tar.gz'\n\n Kernel.format(\n 'https://github.com/%{author}/%{repository}/archive/%{tag}%{suffix}',\n author: author,\n repository: repository,\n tag: tag,\n suffix: suffix,\n )\nend",
"def latest\n releases.first\n end",
"def show\n @asset = Asset.find(params[:asset_id])\n @tag = @asset.tags.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => asset_manager_asset_tag_path(@asset, @tag) }\n end\n end",
"def show\n @release = Release.find(params[:id])\n\n # respond_to do |format|\n # format.html show.html.erb\n # format.json { render json: @release }\n # end\n end",
"def get(repository, tag)\n images = Docker::Image.all.select { |i|\n i.info[\"RepoTags\"].include? \"#{repository}:#{tag}\"\n }\n # I don't think it's possible to have multiple images from the same\n # repository with the same tag, so this shouldn't be an issue.\n @raw = images[0]\n end",
"def manifest\n repo_name = url_path[0] == \"/\" ? url_path[1..-1] : url_path\n\n GithubRepositoryResource.new(repo_name, @client).to_h\n end",
"def get_url\n heroku_app = options[:heroku_app]\n uriString = \"https://api.heroku.com/apps/#{heroku_app}/releases\"\n accept = '\"Accept: application/vnd.heroku+json; version=3\"'\n order = '\"Range: version ..; order=desc, max=10;\"'\n uri = URI(uriString)\n puts \"URI: #{uri}\"\n\n res = `curl -n --silent #{uriString} -H #{accept} -H #{order}`\n\n result = JSON.parse(res)\n\n id = nil\n ver = nil\n hash = nil\n result.each { |i|\n puts i\n if !id && i[\"slug\"] && i[\"slug\"][\"id\"] && i[\"slug\"][\"id\"] != \"\"\n id = i[\"slug\"][\"id\"]\n ver = i[\"version\"]\n hash = i[\"description\"]\n end\n }\n\n #puts id if id\n if id != nil\n\n uriStringSlug = \"https://api.heroku.com/apps/#{heroku_app}/slugs/#{id}\"\n uriSlug = URI(uriStringSlug)\n\n resSlug = `curl -n --silent #{uriStringSlug} -H #{accept}`\n resultSlug = JSON.parse(resSlug)\n p \"--------------------------------\"\n p \"Version: #{ver}\"\n p \"Hash: #{hash}\"\n p resultSlug[\"blob\"][\"url\"]\n p \"--------------------------------\"\n end\n end",
"def edit\n @asset = Assetabler::Asset.find(params[:id])\n end",
"def get_asset_name()\n uri = @stock_page.canonical_uri()\n match = uri.to_s.match(/.*\\/(.*)-Aktie/)\n raise RuntimeError, \"Could not extract stock asset name\", caller if match.nil?\n Rails.logger.debug(\"#{self.class}: Stock asset name: #{match[1]}\")\n return match[1]\n end",
"def get_asset_with_http_info(asset_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: AssetsApi.get_asset ...'\n end\n # verify the required parameter 'asset_id' is set\n if @api_client.config.client_side_validation && asset_id.nil?\n fail ArgumentError, \"Missing the required parameter 'asset_id' when calling AssetsApi.get_asset\"\n end\n # resource path\n local_var_path = '/video/v1/assets/{ASSET_ID}'.sub('{' + 'ASSET_ID' + '}', CGI.escape(asset_id.to_s))\n\n # query parameters\n query_params = opts[:query_params] || {}\n\n # header parameters\n header_params = opts[:header_params] || {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n\n # form parameters\n form_params = opts[:form_params] || {}\n\n # http body (model)\n post_body = opts[:debug_body]\n\n # return_type\n return_type = opts[:debug_return_type] || 'AssetResponse'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['accessToken']\n\n new_options = opts.merge(\n :operation => :\"AssetsApi.get_asset\",\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => return_type\n )\n\n data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: AssetsApi#get_asset\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def file\n f = nil\n if self.asset_clone_id.present?\n x = self.asset_clone\n f = x.asset if x.present?\n else\n f = self.asset\n end\n return f\n end",
"def show\n @gitHubRepo = GitHubRepo.where(:id => @git_hub_issue.repo_id).first.repo\n end",
"def find(id)\n data = client.get(asset_type, id: id )\n self.new_from_payload(data)\n end",
"def new\n repo = assets_repo\n @v_asset = repo.new\n\n respond_to do |format|\n format.html new.html.erb\n format.json { render json: @v_asset }\n end\n end",
"def get_release( dbh, name )\n\tstmta = \"SELECT id, COUNT(id) AS count FROM releases WHERE name = '#{name}'\"\n\trsa = dbh.query( stmta )\n\tif rsa.any?\n\t rsa.each do |release|\n\t c = release['count']\n\t return release['id'] unless c == 0\n\t end\n\tend\n\treturn nil\nend",
"def find_asset(asset_name) # , views)\n search_path = proc do |path| \n full_path = path + asset_name\n return full_path if File.exist?(full_path)\n end \n check_meta(@meta, \"find_asset\")\n views = @meta.views\n views.each do |view| search_path.call(\"#{view.dir}/#{@meta.slug}/assets/\") end\n views.each do |view| search_path.call(view.dir + \"/assets/\") end\n search_path.call(@root + \"/assets/\", asset_name)\n # If all fail... return nil\n return nil\n end",
"def show\n\t\t@asset = @campaign.assets.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @asset }\n end\n end",
"def edit\n @asset = Asset.find(params[:id])\n end",
"def name\n asset_id\n end",
"def first_asset\n assets.find(:first, :order => \"position ASC\") unless assets.blank?\n end",
"def find_asset_json\n res = Asset.find(@params['id'])\n render :string => res.to_json, :content_type => \"application/json\", :layout => false\n end",
"def show\n @asset_disposal = AssetDisposal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @asset_disposal }\n end\n end",
"def get_assets(category = nil)\r\n # Prepare query url.\r\n _path_url = '/gem_assets'\r\n _query_builder = Configuration.get_base_uri\r\n _query_builder << _path_url\r\n _query_builder = APIHelper.append_url_with_query_parameters(\r\n _query_builder,\r\n {\r\n 'category' => category\r\n },\r\n array_serialization: Configuration.array_serialization\r\n )\r\n _query_url = APIHelper.clean_url _query_builder\r\n # Prepare headers.\r\n _headers = {\r\n 'accept' => 'application/json'\r\n }\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.get(\r\n _query_url,\r\n headers: _headers\r\n )\r\n CustomHeaderAuth.apply(_request)\r\n _context = execute_request(_request)\r\n validate_response(_context)\r\n # Return appropriate response type.\r\n decoded = APIHelper.json_deserialize(_context.response.raw_body)\r\n decoded.map { |element| Asset.from_hash(element) }\r\n end",
"def get_latest_release_tag\n\trooturl = get_svn_repo_root()\n\treleaseurl = rooturl + \"/#{SVN_RELEASES_DIR}\"\n\t\n\ttags = svn_ls( releaseurl ).grep( RELEASE_VERSION_PATTERN ).sort_by do |tag|\n\t\ttag[RELEASE_VERSION_PATTERN].split('.').collect {|i| Integer(i) }\n\tend\n\treturn nil if tags.empty?\n\n\treturn releaseurl + '/' + tags.last\nend",
"def show\n @asset = Asset.find(params[:id])\n @assets = @uploadable.assets\n respond_to do |format|\n format.html\n format.json { render json: @asset}\n end\n end",
"def get_master_release(master_release_id)\n query_and_build \"masters/#{master_release_id}\"\n end",
"def show\n @asset = Asset.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @asset }\n end\n end",
"def show\n @asset = Asset.find(params[:id])\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @asset }\n end\n end",
"def retrieve_app_asset(required_asset)\n required_asset = PathInfo.new(required_asset)\n\n dir = \"#{app_path}#{required_asset.match(/^\\//) ? '' : \"/#{@controller}/\"}\"\n asset = \"#{required_asset}#{required_asset.with_ext? ? '' : \".#{asset_extension}\"}\"\n PathInfo.new(dir + asset).rel\n end",
"def show\n #@assets = @project.assets.all\n\n end",
"def show\n @asset_file = current_user.asset_files.find(params[:id]) \n end",
"def download_asset(prog_id)\n return download_data(\"http://www.channel4.com/programmes/asset/#{prog_id}\")\n end",
"def discover_asset(asset_id: nil)\n # TODO: ...\n end",
"def asset_by_id( id )\r\n\t\t(@graph_by_id[id] && asset_for_el( @graph_by_id[id] ))\r\n\tend",
"def getLogoData(data)\n data && data['asset_id'] && data['width'] && data['height'] or return nil\n return { url: \"/assets/#{data['asset_id']}\", width: data['width'], height: data['height'] }\nend",
"def set_release\n @release = Admin::Release.find(params[:id])\n end",
"def set_asset\n @asset = Asset.find(params[:id])\n end",
"def index\n @assets = @org.assets\n end",
"def repo (slug, githubToken)\n\n puts \"Retrieving #{slug} from GitHub...\"\n\n urlString = 'https://api.github.com/repos/' + slug + '?access_token=' + githubToken\n\n uri = URI(urlString)\n\n client = Net::HTTP.new(uri.host, uri.port)\n client.use_ssl = (uri.scheme == 'https')\n\n request = Net::HTTP::Get.new(uri)\n request['Accept'] = 'application/vnd.github.v3+json'\n\n result = client.request (request)\n\n case result\n when Net::HTTPSuccess, Net::HTTPRedirection\n repoData = JSON.parse(result.body)\n return repoData\n else\n\treturn nil\n end\nend"
] | [
"0.70067394",
"0.69598156",
"0.6759065",
"0.6752624",
"0.66346973",
"0.6596524",
"0.65734065",
"0.655549",
"0.6503357",
"0.6477614",
"0.62979877",
"0.6269648",
"0.6209054",
"0.6209054",
"0.61817837",
"0.61773974",
"0.6174258",
"0.6151368",
"0.61507773",
"0.60510087",
"0.6026244",
"0.6020925",
"0.6012465",
"0.60109913",
"0.5943565",
"0.5912742",
"0.58656466",
"0.58645934",
"0.58627355",
"0.58380616",
"0.57606363",
"0.5699701",
"0.56958103",
"0.5679531",
"0.56753755",
"0.56664723",
"0.5642776",
"0.5630844",
"0.563084",
"0.5627003",
"0.5627003",
"0.5627003",
"0.5627003",
"0.5627003",
"0.56217533",
"0.56205004",
"0.5610237",
"0.5603931",
"0.55994815",
"0.55994576",
"0.55976",
"0.55797344",
"0.55772656",
"0.55517197",
"0.5545812",
"0.5521201",
"0.5519025",
"0.5518736",
"0.5514534",
"0.5508809",
"0.5497271",
"0.5488142",
"0.54854894",
"0.5476714",
"0.5441901",
"0.54288447",
"0.54217273",
"0.54216003",
"0.5418916",
"0.5405504",
"0.54041195",
"0.540361",
"0.54029375",
"0.5400636",
"0.5385286",
"0.5385046",
"0.5365684",
"0.5363963",
"0.5363936",
"0.53545237",
"0.5344041",
"0.5339797",
"0.53335327",
"0.53260636",
"0.53094",
"0.5305976",
"0.5301243",
"0.52950215",
"0.52950215",
"0.5294381",
"0.5293845",
"0.5290087",
"0.52837706",
"0.5274981",
"0.52724326",
"0.52693236",
"0.5258943",
"0.52566296",
"0.52527857",
"0.5252031"
] | 0.7887219 | 0 |
Return paths based off Rails default plus some customization. These paths are Ecrire's, not the users's theme. For the user's paths, look at Ecrire::Theme::Engine.paths | def paths
@paths ||= begin
paths = super
paths.add 'config/routes.rb', with: 'routes.rb'
paths.add 'config/locales', with: 'locales', glob: "**/*.{rb,yml}"
paths
end
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def paths\n @paths ||= begin\n paths = super\n paths.add 'config/secrets', with: Ecrire::Theme.path + 'secrets.yml'\n paths.add 'config/database', with: Ecrire::Theme.path + 'secrets.yml'\n paths.add 'config/routes.rb', with: 'routes.rb'\n paths.add 'config/locales', with: 'locales', glob: \"**/*.{rb,yml}\"\n\n paths.add 'lib/tasks', with: 'tasks', glob: '**/*.rake'\n paths\n end\n end",
"def themes_path\n File.join(RAILS_ROOT, 'themes')\n end",
"def cheap_themes_setup_view_paths #:nodoc:\n theme = self.send(self.class.theme_finder_method)\n self.view_paths = ::ActionController::Base.view_paths.dup.unshift(\"#{RAILS_ROOT}/themes/#{theme}/views\") \\\n if theme and theme =~ /^[\\w\\.\\-\\+]+$/i\n end",
"def themes_path\n \"#{Rails.root}/app/themes\"\n end",
"def theme_path\n \"#{ThemesForRails.config.themes_path}/#{current_theme}\"\n end",
"def default_paths\n [ '.' ]\n end",
"def default_application_paths\n paths = []\n\n # Followed by the standard includes.\n paths.concat %w(\n config\n lib\n lib/core_ext\n app\n app/models\n app/controllers\n app/converters\n app/helpers\n ).map { |dir| \"#{root_path}/#{dir}\" }.select { |dir| File.directory?(dir) }\n end",
"def theme_path\n Rails.root.join('themes', account_prefix)\n end",
"def theme_path\n File.join(themes_path, theme)\n end",
"def default_load_paths\n application_load_paths.collect { |lp| File.join(lp, \"widgets\") }\n end",
"def base_paths\n @base_paths ||= find_base_paths\n end",
"def template_paths\n paths = Engines.plugins.by_precedence.map { |p| \"#{p.directory}/app/views/#{mailer_name}\" }\n paths.unshift(template_path_without_engine_additions) unless Engines.disable_application_view_loading\n paths\n end",
"def paths\n @paths ||= [\"#{Rails.root}/public/stylesheets\"]\n end",
"def template_paths\n paths = Rails.plugins.by_precedence.map { |p| \"#{p.root}/app/views/#{mailer_name}\" }\n paths.unshift(template_path_without_engine_additions) unless Engines.disable_application_view_loading\n paths\n end",
"def default_path\n Gem.default_path + [@home]\n end",
"def default_path\n Pathname.pwd.join(*base_config_path, self.class.config_folder)\n end",
"def add_theme_view_path_for(name)\n #--- first add the parent theme, to handle any view not found in main theme\n if !ThemesForRails.config.parent_theme(name).blank?\n self.view_paths.insert 0, ::ActionView::FileSystemResolver.new(theme_view_path_for(ThemesForRails.config.parent_theme(name)))\n end\n self.view_paths.insert 0, ::ActionView::FileSystemResolver.new(theme_view_path_for(name))\n end",
"def default_path\n \"archangel/fallback/\" + [version_name, \"asset.png\"].compact.join(\"_\")\n end",
"def template_search_path_with_cl_as\r\n frontends_path = \"../../vendor/plugins/#{ActiveScaffold::Config::Core.cl_as_plugin_directory}/frontends\"\r\n search_path = template_search_path_without_cl_as\r\n search_path << \"#{frontends_path}/#{frontend}/views\" if frontend.to_sym != :default\r\n search_path << \"#{frontends_path}/default/views\"\r\n return search_path\r\n end",
"def dir_list\n path_from_env || default_path\n end",
"def calculate_paths\n raise ApplicationSetupError.new(\"Please define 'app_file' option for #{self.name} app!\") unless self.app_file\n set :views, find_view_path if find_view_path\n set :images_path, File.join(self.public, \"/images\") unless self.respond_to?(:images_path)\n end",
"def active_configuration_path\n configuration_paths.find do |path|\n File.file? path\n end || theme_configuration_path\n end",
"def path\n root? ? boot_path : user_path\n end",
"def path\n root? ? boot_path : user_path\n end",
"def in_theme_dir(*paths)\n return nil unless theme\n\n paths.reduce(theme.root) do |base, path|\n Jekyll.sanitized_path(base, path)\n end\n end",
"def set_view_paths\n node = @node\n\n unless node\n node = current_site\n node.layout_variant = 'default'\n end\n\n @layout_configuration = node.own_or_inherited_layout_configuration\n @layout = node.own_or_inherited_layout\n @layout_variant = node.own_or_inherited_layout_variant\n parent = @layout.parent\n\n prepend_view_path(\"#{parent.path}/views\") if parent.present?\n prepend_view_path(\"#{@layout.path}/views\")\n\n if @layout_variant && @layout_variant[:id] != 'default'\n prepend_view_path(\"#{parent.path}/#{@layout_variant[:id]}/views\") if parent.present?\n prepend_view_path(\"#{@layout.path}/#{@layout_variant[:id]}/views\")\n end\n end",
"def paths_from_project_root\n @paths_from_project_root ||=\n [Config.project_root]\n end",
"def default_directories\n [Texas.contents_subdir_name, \"lib/\", Texas.texas_dir]\n end",
"def public_path\n \"themes/#{self.dir}\"\n end",
"def path\n File.join( File::SEPARATOR+'layouts', \"t#{self.theme_id}_r#{self.id}\")\n end",
"def search_path\n Options.custom_dir\n end",
"def themes_root(path)\n @themes_root = path\n end",
"def paths\n {\n :homepage => '/',\n :people => '/people',\n :work => '/work',\n :labs => '/labs',\n :\"find-us\" => '/find-us',\n :\"pebbles-good-code\" => '/pebbles-good-code'\n }\nend",
"def default_path; end",
"def default_install_path\n begin\n ::Rails.root.join 'config', 'initializers', ''\n rescue NameError\n File.join Dir.pwd, 'config', 'initializers', ''\n end\n end",
"def defined_paths()\n return root_defined_path_part\n end",
"def recreate_user_themes_from_default_ones\n FileUtils.mkdir_p(USER_THEMES_DIR) unless File.exists?(USER_THEMES_DIR)\n default_themes = Dir.entries(DEF_THEMES_DIR) - %w{. ..}\n\n default_themes.each do |theme|\n user_theme_path = File.join(USER_THEMES_DIR, theme)\n unless File.exists?(user_theme_path)\n def_theme_path = File.join(DEF_THEMES_DIR, theme)\n FileUtils.cp(def_theme_path, USER_THEMES_DIR)\n end\n end\n end",
"def append_paths\n @append_paths ||= begin\n Wedge::Opal.append_path method(:assets_url).source_location.first.sub('/wedge.rb', '')\n Wedge::Opal.append_path \"#{Dir.pwd}/#{config.app_dir}\"\n end\n end",
"def html_path\n self.path + \"theme\"\n end",
"def default_path\n \"archangel/\" + [version_name, \"asset.png\"].compact.join(\"_\")\n end",
"def all_svg_paths\n if defined?(Rails)\n @svg_paths + rails_paths\n else\n @svg_paths\n end\n end",
"def base_dir_for_path_parameters; end",
"def default_role_path\n Pathname.new(Dir.pwd).ascend do |path|\n possible = File.join(path, 'roles')\n return possible if File.exists?(possible)\n end\n\n nil\n end",
"def default_path\n [ (std_path || key).to_s ]\n end",
"def paths\n configuration.paths\n end",
"def paths\n Array(@ruhoh.cascade.paths.map{|h| h[\"path\"]}).map { |path|\n collection_path = File.join(path, resource_name)\n next unless File.directory?(collection_path)\n\n collection_path\n }.compact\n end",
"def theme_resolver\n theme(current_account.account_prefix) if DmCore.config.enable_themes\n end",
"def base_paths\n [Pkg::Config.yum_repo_path, Pkg::Config.apt_repo_staging_path, Pkg::Config.apt_repo_path, '/opt/downloads'].compact\n end",
"def paths\n self.config[:paths]\n end",
"def default_load_paths_with_test_helper\n paths = default_load_paths_without_test_helper\n paths.concat %w(\n app\n app/controllers\n config\n lib\n vendor\n ).map { |dir| \"#{HELPER_RAILS_ROOT}/#{dir}\" }\n end",
"def all_paths\n # memoize so we only calculate once\n @all_paths ||= platform_font_paths\n end",
"def default_plugin_paths_with_test_helper\n paths = default_plugin_paths_without_test_helper\n paths << \"#{HELPER_RAILS_ROOT}/vendor/plugins\"\n end",
"def default_search_path\n @default_search_path ||= %{\"$user\", public}\n end",
"def default_load_paths_with_milkshake\n Milkshake.environment.gemspecs.each do |gemspec|\n app_path = File.join(gemspec.full_gem_path, 'app', 'controllers', 'application_controller.rb')\n if File.file?(app_path)\n return default_load_paths_without_milkshake\n end\n end\n \n path = File.expand_path(File.join(File.dirname(__FILE__), *%w( .. rails_fallbacks )))\n default_load_paths_without_milkshake.push(path)\n end",
"def prepend_view_paths\n return unless current_user.present?\n if current_user.entities.empty?\n role_view_path = 'signer'\n else\n role_view_path = current_entity.is_counsel? ? 'counsel' : 'client'\n end\n prepend_view_path ['app/views/app', \"app/views/app/#{role_view_path}\"]\n end",
"def path\n # self.id is not accurate, it may use imported theme of design site.\n # on other side, design site may release template first time. current_template_release = nil\n if self.current_template_release.present?\n File.join( File::SEPARATOR+'layouts', \"t#{self.current_template_release.theme_id}_r#{self.release_id}\")\n else\n File.join( File::SEPARATOR+'layouts', \"t#{self.id}_r#{self.release_id}\")\n end\n end",
"def path\n # self.id is not accurate, it may use imported theme of design site.\n # on other side, design site may release template first time. current_template_release = nil\n if self.current_template_release.present?\n File.join( File::SEPARATOR+'layouts', \"t#{self.current_template_release.theme_id}_r#{self.release_id}\")\n else\n File.join( File::SEPARATOR+'layouts', \"t#{self.id}_r#{self.release_id}\")\n end\n end",
"def view_paths; end",
"def view_paths; end",
"def view_paths; end",
"def template_search_path_with_export(frontend = self.frontend)\n frontends_path = \"../../vendor/plugins/#{ActiveScaffold::Config::Core.export_plugin_directory}/frontends\"\n\n search_path = template_search_path_without_export\n search_path << \"#{frontends_path}/#{frontend}/views\" if frontend.to_sym != :default\n search_path << \"#{frontends_path}/default/views\"\n return search_path\n end",
"def paths\n @paths ||= [STYLESHEETS_PATH]\n end",
"def default_search_directory\n Figgy.config[\"default_search_directory\"]\n end",
"def base_path_for(resource_name)\n {\n 'Role' => 'roles',\n 'Space' => 'spaces',\n 'Asset' => 'assets',\n 'Entry' => 'entries',\n 'Locale' => 'locales',\n 'Upload' => 'uploads',\n 'ApiKey' => 'api_keys',\n 'UIExtension' => 'extensions',\n 'Environment' => 'environments',\n 'ContentType' => 'content_types',\n 'PreviewApiKey' => 'preview_api_keys',\n 'SpaceMembership' => 'space_memberships'\n }[resource_name]\n end",
"def path\n @path ||=\n if user_configuration.has_key?('solr')\n \"#{user_configuration['solr']['path'] || '/solr'}\"\n end\n end",
"def paths\n Array(config.path).map(&:to_s)\n end",
"def available_managed_paths_for_site_creation\n return @available_managed_paths_for_site_creation\n end",
"def dirs\n @dirs.each { |_, dir| apply_defaults_to_dir(dir) }\n end",
"def append_paths\n @append_paths ||= begin\n Wedge::Opal.append_path method(:assets_url).source_location.first.sub('/wedge.rb', '')\n Wedge::Opal.append_path \"#{Dir.pwd}/#{config.app_dir}\"\n\n true\n end\n end",
"def paths_from_env(env_var, default)\n split_paths(ENV.fetch(env_var, default))\n end",
"def set_paths(site)\n @public_path = site.public_path\n @view_path = site.view_path\n end",
"def in_theme_dir(*paths); end",
"def setup_paths\n # This REPLACE_DEFAULT_PATH_WITH_DRIVER constant gets defined by bin/driver when we want\n # to run a command in the context of a driver instead of the main rails app.\n if defined?(REPLACE_DEFAULT_PATH_WITH_DRIVER)\n replace_rails_paths_with_driver(REPLACE_DEFAULT_PATH_WITH_DRIVER)\n else\n add_every_driver_to_rails_paths\n end\n end",
"def base_path\n # starts out like \"users/index\"\n @view.virtual_path.sub(%r{/[^/]*$}, '')\n end",
"def get_path\n if self.presentation.user.role==\"guest\"\n \"#{Rails.root}/public/guestdata/\"+self.presentation.user_id.to_s+\"/\"+self.presentation.id.to_s+\"/images/:filename\"\n else\n \"#{Rails.root}/public/userdata/\"+self.presentation.user.name.downcase.gsub(\" \", \"_\")+\"/\"+self.presentation.name.downcase.gsub(\" \", \"_\")+\"/images/:filename\"\n #\"#{Rails.root}/public/userdata/\"+self.presentation.user.name.downcase.gsub(\" \", \"_\")+\"/\"+self.presentation.name.downcase.gsub(\" \", \"_\")+\"/images/:attachment/:id_:style.:extension\"\n end\n end",
"def view_paths\n _view_paths\n end",
"def view_paths\n _view_paths\n end",
"def locales_path\n unless defined?(@locales_path)\n self.locales_path = \"#{public_path}/#{DEFAULT_LOCALES_LOCATION}\"\n end\n\n @locales_path\n end",
"def inherit_view_paths\n self.class.inherit_view_paths\n end",
"def file_path\n PATH_USER_DEFAULTS\n end",
"def paths\n root.paths\n end",
"def look_up_configured_path(path_type, options = {})\n return @cached_paths[path_type] if @cached_paths.has_key?(path_type)\n if user_defined_path = user_configured_path(path_type)\n if path_resolves?(user_defined_path, :file => options[:file])\n return user_defined_path\n else\n raise Bumbleworks::InvalidSetting, \"#{Bumbleworks::Support.humanize(path_type)} not found (looked for #{user_defined_path || defaults.join(', ')})\"\n end\n end\n\n first_existing_default_path(options[:defaults], :file => options[:file])\n end",
"def get_themes\n themes_dir = File.join(File.dirname(__FILE__), '/public/themes')\n\n themes = []\n Dir.entries(themes_dir).sort.each do |dir|\n themes.push dir if ((dir != 'fonts') and (dir[0] != '.'))\n end\n themes\n end",
"def layout_path\n File.join( \"t#{self.theme_id}_r#{self.id}\", template_theme.file_name( \"ehtml\" ))\n end",
"def default_routes_path\n basedir = @config.get(\"GEAR_BASE_DIR\")\n token = \"#{@container_uuid}_#{@namespace}_#{@container_name}\"\n File.join(basedir, '.httpd.d', token, \"routes.json\")\n end",
"def default_routes_path\n basedir = @config.get(\"GEAR_BASE_DIR\")\n token = \"#{@container_uuid}_#{@namespace}_#{@container_name}\"\n File.join(basedir, '.httpd.d', token, \"routes.json\")\n end",
"def inherit_view_paths\n instance_variable_get('@inherit_view_paths') || instance_variable_set('@inherit_view_paths', [controller_path] + (superclass.inherit_view_paths rescue []))\n end",
"def default_base_path_name\n self.name.split('::').last.downcase\n end",
"def default_modules_paths\n dirs = []\n do_initialize if Puppet[:codedir].nil?\n # add the puppet-repl directory so we can load any defined functions\n dirs << File.join(Puppet[:environmentpath],default_puppet_env_name,'modules') unless Puppet[:environmentpath].empty?\n dirs << Puppet.settings[:basemodulepath].split(':')\n dirs.flatten\n end",
"def pathTemplates\n \"./templates/\"\nend",
"def find_default_ca_path; end",
"def inject_theme_views\n if home_page_theme && home_page_theme != 'default_home'\n original_paths = view_paths\n home_theme_view_path = Rails.root.join('app', 'views', \"themes\", home_page_theme.to_s)\n prepend_view_path(home_theme_view_path)\n yield\n # rubocop:disable Lint/UselessAssignment, Layout/SpaceAroundOperators, Style/RedundantParentheses\n view_paths=(original_paths)\n # rubocop:enable Lint/UselessAssignment, Layout/SpaceAroundOperators, Style/RedundantParentheses\n else\n yield\n end\n end",
"def rails_root\n @path\n end",
"def list_paths\n @paths = RouteRecognizer.new.initial_path_segments.reject do |path|\n %w(assets rails).include? path\n end\n end",
"def asset_paths\n paths = @parts.values.map(&:asset_path)\n paths << File.dirname(script) if script\n paths << File.dirname(stylesheet) if stylesheet\n paths.compact.uniq\n end",
"def ignore_paths\n Dir.glob(\"**/*\").select { |f| File.directory? f }\n .collect { |name| \"#{name}/\" }\n - [\"app/\",\n \"app/views/\",\n \"app/views/branded/\",\n \"app/views/branded/public_pages/\",\n \"app/views/branded/home/\",\n \"app/views/branded/contact_us/\",\n \"app/views/branded/contact_us/contacts/\",\n \"app/views/branded/shared/\",\n \"app/views/branded/layouts/\",\n \"app/views/branded/static_pages/\"]\nend",
"def default_assembly_paths\n paths = []\n paths.concat %w( bin ).map{ |dir| \"#{root_path}/#{dir}\"}.select{ |dir| File.directory?(dir) }\n end",
"def default_path\n nil\n end",
"def inherit_view_paths\n instance_variable_get('@inherit_view_paths') || instance_variable_set('@inherit_view_paths', [controller_path] + (superclass.inherit_view_paths rescue []))\n end",
"def paths\n unless @paths\n @paths = []\n @paths << project._(:source, :main, :assets) if File.exist?(project._(:source, :main, :assets))\n end\n @paths\n end"
] | [
"0.71200037",
"0.69200456",
"0.68518096",
"0.685117",
"0.68304205",
"0.6652521",
"0.65689915",
"0.6420999",
"0.63978094",
"0.6230695",
"0.61454517",
"0.6057452",
"0.6049732",
"0.6005849",
"0.59851974",
"0.5984927",
"0.59672743",
"0.59381944",
"0.5921982",
"0.5906433",
"0.5888663",
"0.5888036",
"0.5877944",
"0.5877944",
"0.58360225",
"0.5815356",
"0.5805531",
"0.5783864",
"0.5775375",
"0.5753803",
"0.5728327",
"0.57256967",
"0.57247835",
"0.5724498",
"0.57163846",
"0.57031256",
"0.5699661",
"0.5695855",
"0.56935805",
"0.56611186",
"0.56498873",
"0.56483626",
"0.5634268",
"0.5633836",
"0.5633583",
"0.5631834",
"0.5628483",
"0.5625171",
"0.5622326",
"0.5618315",
"0.56151396",
"0.5609365",
"0.5606977",
"0.56060034",
"0.56050175",
"0.55991834",
"0.55991834",
"0.55887306",
"0.55887306",
"0.55887306",
"0.55836034",
"0.5556324",
"0.55400246",
"0.5529715",
"0.5528657",
"0.5524538",
"0.5524412",
"0.55139923",
"0.5507791",
"0.54849666",
"0.5473415",
"0.54684126",
"0.5467335",
"0.5465713",
"0.546431",
"0.5461886",
"0.5461886",
"0.5458031",
"0.54579085",
"0.5447808",
"0.54463536",
"0.5445342",
"0.5443213",
"0.5435801",
"0.542137",
"0.542137",
"0.54129815",
"0.541062",
"0.54056233",
"0.54003507",
"0.53994167",
"0.53989965",
"0.5392528",
"0.539171",
"0.53895235",
"0.5388499",
"0.53877544",
"0.5384267",
"0.5370026",
"0.53647465"
] | 0.66247696 | 6 |
reply send location message | def reply_send_location(event)
client.reply_message(event["replyToken"], {
type: "template",
altText: I18n.t("chat.line_bot.service.send_location"),
template: {
type: "buttons",
text: I18n.t("chat.line_bot.service.send_location"),
actions: [
{
type: "uri",
label: I18n.t("chat.line_bot.service.set_location"),
uri: "line://nv/location"
}
]
}
})
end | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_location(bot, message)\n buttons = [\n Telegram::Bot::Types::InlineKeyboardButton.new(\n text: 'przystanek', \n callback_data: {\n 'type' => 'bus',\n 'lat' => message.text, \n 'lng' => message.text\n }.to_json\n ),\n Telegram::Bot::Types::InlineKeyboardButton.new(\n text: 'pogoda', \n callback_data: {\n 'type' => 'weather',\n 'lat' => message.text, \n 'lng' => message.text\n }.to_json\n ),\n ]\n markup = Telegram::Bot::Types::InlineKeyboardMarkup.new(inline_keyboard: buttons)\n bot.api.send_message(\n chat_id: message.chat.id, \n text: 'Co chcesz uzyskać?', \n reply_markup: markup)\nend",
"def reply\n end",
"def set_message_location\n @message = if @locations.blank? \n NO_RESULT_MESSAGE\n else\n SUCCESS_MESSAGE\n end\n end",
"def send_response(location, service_type, service_name, device)\n server_info = \"Ruby SSDP/#{SSDP::VERSION}\"\n device_info = \"#{device.root_device.class}/#{device.root_device.version}\"\n\n http_response = <<-HTTP_RESPONSE\nHTTP/1.1 200 OK\\r\nCACHE-CONTROL: max-age=120\\r\nEXT:\\r\nLOCATION: #{location}\\r\nSERVER: #{server_info} UPnP/1.0 #{device_info}\\r\nST: #{service_type}\\r\nNTS: ssdp:alive\\r\nUSN: #{service_name}\\r\nContent-Length: 0\\r\n\\r\n HTTP_RESPONSE\n\n log :debug, \"SSDP sent M-SEARCH OK #{service_type}\"\n\n @socket.send http_response, 0, @broadcast, @port\n end",
"def feed_location\n @locations = Location.fetch_by_organization_id(location_params)\n set_message_location\n render_location\n end",
"def send_and_register(phone_number, location_id, type, kind)\n phone = register_phone_number(phone_number, :set_last_account => true)\n location = find_location(location_id)\n\n response = service_layer.send_message(phone_number, MessageBuilder.send(type, @account, location))\n if response && response.kind_of?(Hash)\n dlr_message_id = response[\"message_ids\"].to_s.split(',')\n dlr_message_id = dlr_message_id.first\n end\n \n register_session_message(kind, phone, location, dlr_message_id)\n end",
"def reply msg\n\t\t# get message from user\n\t\trep = @@client.message(msg)\n\t\t# handle the message\n\t\tputs handle_message(rep)\n\t\t\n\t\t# interactive Wit\n\t\t#@@client.interactive(method(:handle_message))\n\tend",
"def create_arp_reply message\nend",
"def send_location(geo_uri, name, thumbnail_url = nil, thumbnail_info = {})\n client.api.send_location(id, geo_uri, name, thumbnail_url: thumbnail_url, thumbnail_info: thumbnail_info)\n end",
"def answer(msg)\n logger.debug(\"Answering to (#{info[:uri]}): #{msg.chomp.strip}\")\n client.puts(msg)\n end",
"def SendCourtHouseLocationMessage(senderId, messageText, url)\n\t\t\n\t\tcourtHouseLocationButton = CreateButtonWithURLPayload(\"Courthouse Location\", url)\n\t\tbuttons = Array.new\n\t\tbuttons.push(courtHouseLocationButton)\n\t\tjsonPayload = {\n\t\t\t\"template_type\":\"button\",\n\t\t\t\"text\":messageText,\n\t\t\t\"buttons\":buttons\n\t\t}\n\n\t\tjsonMessage = {\n\t\t\t\"attachment\":{\n\t\t\t\t\"type\":\"template\",\n\t\t\t\t\"payload\":jsonPayload\n\t\t\t}\n\t\t}\n\t\t\n\t\tSendURLButtonMessageToUser(senderId, jsonMessage)\n\tend",
"def reply\n @reply\n end",
"def locationPosition _args\n \"locationPosition _args;\" \n end",
"def location\n # and call a private getter method within\n puts \"I live on #{address.split[1]} street.\"\n end",
"def reply( r )\n @main << r\n end",
"def reply_to_sender(phone_number, msg)\n Rails.logger.debug('TropoController::reply_to_sender')\n #get_system_org.create_gateway!.send_raw(phone_number, msg)\n @tropo.say(msg)\n end",
"def route_command(message_body)\n route(\"#{robot.mention_name} #{message_body}\")\n end",
"def locate(address)\n location = (address.is_a?(String) ? address : location_from_params(address).to_s(:country => false))\n # yahoo pukes on line breaks\n get :location => location.gsub(\"\\n\", ', ')\n end",
"def locate(address)\n location = (address.is_a?(String) ? address : location_from_params(address).to_s(:country => false))\n # yahoo pukes on line breaks\n get :location => location.gsub(\"\\n\", ', ')\n end",
"def reply(message)\n return @mouth.reply(message)\n end",
"def reply(content)\n @greeting = \"Hi\"\n @admin = content[:from]\n @contact = content[:to]\n @message = content[:message]\n mail to: content[:to].email, subject: \"RE: \"+content[:to].subject\n end",
"def admin_open_request_success(place) #when the admin user makes an open request successfully\n self.message = \"SUCCESS ! You requested to open -> #{place.nickname}\"\n end",
"def location\n\t\t@location\n\tend",
"def reply(word: :message)\n # DelayInfomationExtractor\n if word.include?('電車')\n DelayInfomationExtractor.new.search_for_delaying_railway(word)\n\n # elsif\n\n # UserLocalAPI\n else\n word = refine_msg(msg: word)\n call_user_local_api(msg: word)\n end\n end",
"def reply\n @options[:method] = 'getsmsreply'\n @options[:clientmessagereference] = clientmessagereference\n response = ta_response(status_params)\n return response\n end",
"def address(location, options = {})\n raise ArgumentError, 'Method must receive a location (string)' unless location\n options[:location] = location\n call_api self, @mapquest.version, 'address', options\n end",
"def reply # acts as endpoint\n \tmessage_body = params[\"Body\"] # grab params from Twilio's request\n \tfrom_number = params[\"From\"]\n \tboot_twilio\n \tsms = @client.messages.create( # send to inbound number made by end user\n from: Rails.application.secrets.twilio_from_number,\n to: from_number,\n body: \"Hello there, thanks for texting me. Your number is #{from_number}.\"\n \t)\n end",
"def answer(privMsg,ans)\n if !privMsg \n return\n end\n if(privMsg.private_message?)\n talk(privMsg.who,ans)\n else\n talk(privMsg.place,ans)\n end\n end",
"def reply_address\n if !block_given?\n return @j_del.java_method(:replyAddress, []).call()\n end\n raise ArgumentError, \"Invalid arguments when calling reply_address()\"\n end",
"def location\n @client.get(\"#{path}/location\")\n end",
"def location(location,types=nil)\n handle_response(get(\"/content/location.json\", :query => {:location => location,:types=>types}))\n end",
"def reply_to(m)\n @message_type = METHOD_RETURN\n @reply_serial = m.serial\n @destination = m.sender\n self\n end",
"def onRequest(req)\n\t\tif req.request == 'WHEREAMI?'\n\t\t\tloc = location.space\n\t\t\tresp = {:x => loc.x, :y => loc.y, :sectorx => loc.sector.offsetX, :sectory => loc.sector.offsetY}.to_json\n\t\t\treq.reply('YOURPOS', resp)\n\t\telsif req.request == 'NEARBY?'\n\t\t\tdistOfSight = req.message.to_i\n\t\t\tdistOfSight = SolarSystem::SolarSystemRadius if distOfSight > SolarSystem::SolarSystemRadius\n\t\t\tdistOfSight = 1000 if distOfSight < 1000\n\t\t\t\n\t\t\tresp = []\n\t\t\tloc = location.space\n\t\t\tloc.sector.solarsystemsWithin(loc.x, loc.y, distOfSight).each do |system|\n\t\t\t\tsystem.celestialBodiesWithin(loc.x, loc.y, distOfSight).each do |cb|\n\t\t\t\t\tbodyinfo = {:x => cb.x, :y => cb.y, :type => cb.type}\n\t\t\t\t\tresp.push bodyinfo\n\t\t\t\tend\n\t\t\tend\n\t\t\treq.reply('NEARBY', {:cbs => resp}.to_json)\n\t\telsif req.request == 'DISTANT?'\n\t\t\tloc = location.space\n\t\t\tresp = []\n\t\t\tloc.sector.solarsystems().each do |system|\n\t\t\t\tsystem.distantCelestialBodies.each do |cb|\n\t\t\t\t\tbodyinfo = {:x => cb.x, :y => cb.y, :type => 'star'}\n\t\t\t\t\tresp.push bodyinfo\n\t\t\t\tend\n\t\t\tend\n\t\t\treq.reply('DISTANT', {:cbs => resp}.to_json)\n\t\telsif req.request == 'RESOURCES'\n\t\t\tresourceinfo = {}\n\t\t\tcelestialbody = getCelestialBody(@db, req.getmessage())\n\t\t\tif (celestialbody.solarsystem.sector == location.space.sector)\n\t\t\t\tdist = Math.sqrt((location.space.x - celestialbody.x)**2 + (location.space.y - celestialbody.y)**2)\n\t\t\t\tif (dist <= D)\n\t\t\t\t\tresourceinfo = celestialbody.inventory.resources.to_json\n\t\t\t\tend\n\t\t\tend\n\t\t\treq.reply('RESOURCES', resourceinfo)\n\t\telsif req.request == 'INVENTORY'\n\t\t\tinvinfo = inventory.resources.to_json\t\n\t\t\treq.reply('INVENTORY', invinfo)\n\t\telsif req.request == 'IMOVED'\n\t\t\treqjson = req.json\n\t\t\tif reqjson.include?('sx') && reqjson.include?('sy') && reqjson.include?('x') && reqjson.include?('y')\n\t\t\t\t# TODO: Handle other sectors\n\t\t\t\t# TODO: Check validity of move\n\t\t\t\tlocation.setSpace(astroLocationFromCoords(location.space.sector, reqjson['x'].to_i, reqjson['y'].to_i))\n\t\t\tend\n\t\telsif req.request == 'NEARBYENT?'\n\t\t\tdistOfSight = req.message.to_i\n\t\t\tdistOfSight = SolarSystem::SolarSystemRadius if distOfSight > 10 * SolarSystem::SolarSystemRadius\n\t\t\tdistOfSight = 1000 if distOfSight < 1000\n\t\t\t\n\t\t\tresp = nearbyObservable(distOfSight)\n\t\t\treq.reply('NEARBYENT', {:ent => resp}.to_json)\n\t\tend\n\tend",
"def sendmessage\n @notification = Notifications.new\n @current_user = User.find(params[:current_user_id])\n @restaurant = Location.find_by_id(params[:restaurant])\n @prizes = StatusPrize.get_location_prizes(@restaurant.id)\n end",
"def location\n puts \"I live on #{address.split[-2, 2].join(' ')}\"\n end",
"def reply_to\n address_list_fetch('reply-to')\n end",
"def reply(options)\n say(\n body: options[:body],\n from: options[:to].to,\n to: options[:to].from,\n type: options[:to].type,\n )\n end",
"def reply_to\n @reply_to\n end",
"def publishLoc(niUri, locList, destHost, msgId)\n url=URI::parse(\"http://#{destHost}/netinfproto/publish\")\n\n res=nil\n req=nil\n\n loc1=locList[0]\n loc2=locList[1]\n \n if loc2\n req = Net::HTTP::Post::Multipart.new(url.path,\n \"URI\" => niUri.to_s,\n \"msgid\" => msgId,\n \"loc1\" => loc1,\n \"loc2\" => loc2)\n elsif loc1\n req = Net::HTTP::Post::Multipart.new(url.path,\n \"URI\" => niUri.to_s,\n \"msgid\" => msgId,\n \"loc1\" => loc1)\n end\n if req\n print \"Sending request: #{req.to_s} to #{url}\\n\"\n \n res = Net::HTTP.start(url.host, url.port) do |http|\n http.request(req)\n end \n end\n res\n \n end",
"def tweet(message, lat, long)\n # tweet tweet...\nend",
"def locate(address)\n get :location => address\n end",
"def reply\n message_body = params[\"Body\"]\n from_number = params[\"From\"]\n @recent_msg = Message.where(number: from_number).last # Get the name of this user if possible\n\n # Some random schmoe not in our db is trying to text me.\n if @recent_msg.blank?\n head 200, \"content_type\" => 'text/html'\n return\n end\n\n user = @recent_msg.user\n\n # Store reply in db and send back a simple text.\n @message = Message.new(user: user, number: from_number, text: message_body, action: 'REPLY')\n if @message.save\n boot_twilio\n sms = @client.messages.create(\n from: Rails.application.secrets.twilio_number,\n to: from_number,\n body: \"Hello from the other side! Your number is #{from_number}.\"\n )\n end\n head 200, \"content_type\" => 'text/html'\n end",
"def send_direction(direction) \n msg = Message.new(\"update_direction\", direction)\n puts JSON.dump(msg)\n @socket.puts(JSON.dump(msg))\n\n\n end",
"def reply(*args, &block)\n self.rooms.each do |room|\n room.reply(*args, &block)\n end\n end",
"def tweet(message, lat, long)\n #\nend",
"def tweet(message, lat, long)\n #\nend",
"def location\n ans = location_answers.first\n ans ? ans.location : nil\n end",
"def address(m)\n replies = [\"#{m.user.nick}?\",'yes?','you called?','what?']\n my_reply = replies[rand(replies.size)]\n m.reply my_reply\n end",
"def send_reply(from, to, title, message)\n RestClient.post API_URL+\"/messages\",\n :from => from.email,\n :to => to.email,\n :subject => \"Follow Up: UROP Application for \"+title,\n :text => message\n end",
"def tweet(message, lat = nil, long = nil, reply_id = nil)\n #\nend",
"def tweet(message, lat = nil, long = nil, reply_id = nil)\n #\nend",
"def execute(m, query, location)\n request = ::Yelp::V2::Search::Request::Location.new({\n :term => query,\n :address => location,\n :consumer_key => config['consumer_key'],\n :consumer_secret => config['consumer_secret'],\n :token => config['token'],\n :token_secret => config['token_secret']\n })\n\n response = @client.search(request)\n\n m.reply(\"Oops, Yelp didn't understand that location!\", true) and return if response['error']\n m.reply(\"Sorry, Yelp doesn't have any businesses matching \\\"#{query}\\\" near \\\"#{location}\\\"!\") and return if response['businesses'].empty?\n\n business = response['businesses'].sample\n name = business['name']\n rating = business['rating']\n reviews = business['review_count']\n url = business['url']\n address = business['location']['address'].first\n\n m.reply \"You should try #{name} at #{address}! It's rated #{rating} stars with #{reviews} reviews: #{url}\", true\n end",
"def broadcast_messages\n @info = ['Gol', 'Zmiana','Żółta Kartka','Druga Żółta Kartka','Czerwona Kartka',]\n end",
"def reply(code, message)\n if message.is_a?(Array)\n last = message.pop # remove last element\n lines = message.map {|param| \"#{code}-#{param}\\r\\n\"}\n write lines.join + \"#{code} #{last}\\r\\n\"\n else\n write \"#{code} #{message}\\r\\n\"\n end\n end",
"def send_request\n if latitude && longitude\n response = RestClient::Request.execute(\n method: :get,\n url: \"http://climateapi.scottpinkelman.com/api/v1/location/#{latitude}/#{longitude}\"\n )\n parsed = JSON.parse(response)\n self.climate_zone = parsed[\"return_values\"][0][\"koppen_geiger_zone\"]\n else\n p \"Unable to get geocoding location\"\n end\n end",
"def get_geolocation(action)\n if GeoLocation.known_position?\n show_popup_message(Localization::Request[:address_lookup], Localization::Request[:address],['Cancel'], url_for(:action => :geo_popup_callback)) if action == \"location\"\n GeoLocation.set_notification( url_for(:action => :geo_location_callback), \"action=#{action}\", 0)\n else\n show_popup_message(Localization::Request[:no_gps], \"Adresse\",['Retry','Cancel'], url_for(:action => :geo_popup_callback))\n end\n end",
"def reply_to_line(reply_text)\n return nil if reply_text.nil?\n\n #Get reply token\n reply_token = params['events'][0]['replyToken'] \n \n #Set reply message\n message = {\n type: 'text',\n text: reply_text\n }\n\n #Send message\n line.reply_message(reply_token, message)\n end",
"def reply(event)\n msg = event.message['text']\n mk_reply(msg)\nend",
"def print_location\n\t\[email protected]_point\t\n\tend",
"def _on_reply(wi)\n Ruote.participant_send(self, :on_reply, 'workitem' => wi)\n end",
"def postLocation(location)\n api.bgEvents.postEvent(\"JourneyLocationPost\",\n JourneyLocationEventData.new(postingRoute, location, postingRole))\n end",
"def tweet(message, lat, long)\n #..\nend",
"def tweet(message, lat, long)\n # ..\nend",
"def answer(priv_msg, ans)\n return unless priv_msg\n if priv_msg.private_message?\n talk(priv_msg.who, ans, priv_msg.server_id)\n else\n talk( priv_msg.place, ans, priv_msg.server_id)\n end\n end",
"def nearby_geo_callback1\n\t\twebview_navigate_for_type(:index) if @params[\"known_position\"].to_i != 0 && @params[\"status\"] == \"ok\"\n \t# Try again if the first call failed, seems to be needed on the simulator...\n \tif @params[\"known_position\"].to_i == 0 || @params[\"status\"] != \"ok\" \n\t\t\tGeoLocation.set_notification( url_for_type(:action => :nearby_geo_callback2), default_query_hash_str, GeoTimeout) \n\t\t\tredirect_for_type :action => :wait, :query => { :message => \"Finding location...\" }\n\t\tend\n\tend",
"def locate(location)\n get :q => location.is_a?(String) ? location : location_from_params(location).to_s, :output => 'locations'\n end",
"def test_create_reply_to_reply_to_reply_to_standalone_message_about_nothing\r\n about = nil\r\n reply_to = messages(:matt_reply_to__kevin_reply_to__andy_to_kevin_about_nothing)\r\n send_message(@tim, @matt, reply_to, about)\r\n end",
"def update_location(location={})\n\t\tclient.update(location)\n\tend",
"def show_location\n\n end",
"def test_create_reply_to_reply_to_standalone_message_about_nothing\r\n about = nil\r\n reply_to = messages(:kevin_reply_to__andy_to_kevin_about_nothing)\r\n send_message(@matt, @kevin, reply_to, about)\r\n end",
"def viewMap(address, to_lat, to_lng, callback)\n puts \"viewMap(address:#{address}, to_lat:#{to_lat}, to_lng:#{to_lng}, callback:#{callback}\"\n\n if GeoLocation.known_position?\n from_lat = GeoLocation.latitude\n from_lng = GeoLocation.longitude\n else\n from_lat = 34.3932857\n from_lng = 132.4705439\n from_lat = 34.4893270\n from_lng = 133.3614320\n from_lat = 35.005018\n from_lng = 135.889155\n end\n\n if callback\n #GeoLocation.set_notification(url_for(:action => :geo_callback), \"\")\n GeoLocation.set_notification(callback, \"\")\n end\n\n puts \"from:#{from_lat},#{from_lng} => to:#{to_lat},#{to_lng}\"\n puts \"distance: #{GeoLocation.haversine_distance(from_lat,from_lng,to_lat,to_lng)}\"\n\n #region = [@params['latitude'], @params['longitude'], 1/69.0, 1/69.0] #miles\n #region = [@params['latitude'], @params['longitude'], 1/111.0, 1/111.0] #km\n region = [(to_lat + from_lat) / 2, (to_lng + from_lng) / 2,\n (to_lat - from_lat).abs, (to_lng - from_lng).abs]\n\n url = \"http://maps.google.jp/maps/api/directions/json?\" +\n \"origin=#{from_lat},#{from_lng}&\" +\n \"destination=#{to_lat},#{to_lng}&\" +\n \"mode=walking&\" +\n \"language=ja&\" +\n \"sensor=true\"\n #puts url\n\n res2 = Rho::AsyncHttp.get(\n :url => url,\n #:headers => {\"Cookie\" => cookie},\n )\n #puts res2.inspect\n #puts res2[\"status\"]\n\n# if res2[\"status\"] == \"ok\"\n# end\n\n myannotations = []\n\n #puts res2[\"body\"].inspect\n #puts res2[\"body\"][\"status\"]\n #puts res2[\"body\"][\"routes\"].size\n #puts res2[\"body\"][\"routes\"][0][\"legs\"].size\n #puts res2[\"body\"][\"routes\"][0][\"legs\"][0][\"steps\"].size\n\n res2[\"body\"][\"routes\"][0][\"legs\"][0][\"steps\"].each do |step|\n #puts step.inspect\n\n title = step[\"html_instructions\"]\n title = title.gsub(/\\<\\/?[bB]\\>/, \"\")\n #puts title\n\n myannotations << {\n :latitude => step[\"start_location\"][\"lat\"],\n :longitude => step[\"start_location\"][\"lng\"],\n :title => title,\n :subtitle => step[\"distance\"][\"text\"],\n #:url => \"/app/GeoLocation/show?city=Original Location\",\n #:image => '/public/images/marker_blue.png', :image_x_offset => 8, :image_y_offset => 32\n }\n end\n\n myannotations << {\n :latitude => to_lat,\n :longitude => to_lng,\n :title => address,\n #:subtitle => @params['map']['address'],\n #:url => \"/app/GeoLocation/show?city=Original Location\"\n }\n\n map_params = {\n #:provider => \"Google\",\n :provider => \"ESRI\",\n :settings => {\n #:map_type => \"roadmap\",\n :map_type => \"standard\",\n :region => region,\n :zoom_enabled => true, :scroll_enabled => true, :shows_user_location => true,\n #:api_key => '0jDNua8T4Teq0RHDk6_C708_Iiv45ys9ZL6bEhw'\n },\n :annotations => myannotations\n }\n\n #puts map_params.inspect\n puts \"-------------------------\"\n MapView.create map_params\n end",
"def tweet(message:, lat: nil, long: nil, reply_id: nil)\n # do tweety things\nend",
"def send_geo_request(postcode)\n Response.new(\n response(postcode),\n response_type: :json\n )\n end",
"def receive_reply(reply)\n FSR::Log.debug reply.inspect\n end",
"def location\n puts 'A female voice appears from a tiny speaker somewhere in the room'\n puts 'Thank you for using this device. Where and when would you like to go'.colorize(:red)\n puts 'To make your travelling more efficent please type a single location and time'\n puts 'Enter a location:'\n location = gets.chomp\n puts \"Great! You have answered #{location}\".colorize(:light_blue)\n return location\nend",
"def reply_pos\n puts 'aw yeah!!!!'\n # byebug\n # we've got user from cookie\n # we're passing in the 2nd user from follow_params[:user2]\n ret_errors=[]\n half_follow_a = Follow.new(follower_id: decode_jwt(cookies.signed[:jwt])[\"user_id\"], followee_id: follow_params[:user2])\n if !half_follow_a.save\n ret_errors.push(\"Failure in the first half of follow. \")\n end\n\n if !!ret_errors\n render json: {ret_errors: ret_errors}\n else\n render json: {friend_request: \"friendship established\"}\n end\n end",
"def my_location\n\t\t\"#{address}, #{city}, GA\"\n\tend",
"def send_message(msg); end",
"def respond( message )\n\n\n # If a joining message adds address to routing table and gateway table before sending a routing info message\n # to it and a joining relay message to a node with a GUID closer to the joining node\n if message[\"type\"] == \"JOINING_NETWORK_SIMPLIFIED\"\n tnh, tm, tn = nextHop( message[\"node_id\"] )\n @gateway_table[message[\"node_id\"]] = { :ip_address => message[\"ip_address\"], :port => message[\"port\"] }\n if @routing_table.has_key?([0,tm,tn]) == false # || diff( joining_guid ) < diff( @routing_table[[0,jm,jn]][\"node_id\"] )\n @routing_table[[0,tm,tn]] = { :node_id => message[\"node_id\"], :ip_address => message[\"ip_address\"], \\\n :port => message[\"port\"] }\n end\n if tnh.ip != nil\n joinMesgRelay = { :type => \"JOINING_NETWORK_RELAY_SIMPLIFIED\", :node_id => message[\"node_id\"], \\\n :gateway_id => @guid, :ip_address => message[\"ip_address\"], \\\n :port => message[\"port\"] }.to_json\n @s.send joinMesgRelay, 0, tnh.ip, tnh.port\n end\n tempRouteTable = []\n @routing_table.each_value { |addr|\n tempRouteTable.push( addr )\n }\n routingInfoMesg = { :type => \"ROUTING_INFO\", :gateway_id => @guid, :node_id => message[\"node_id\"], \\\n :ip_address => @localInetAddr.ip, :port => @localInetAddr.port, :route_table => tempRouteTable }.to_json\n @s.send routingInfoMesg, 0, message[\"ip_address\"], message[\"port\"]\n end\n\n\n # Behalves identically to above except responce to the gateway node instead of the joining node\n if message[\"type\"] == \"JOINING_NETWORK_RELAY_SIMPLIFIED\"\n tnh, tm, tn = nextHop( message[\"node_id\"] )\n nh, gm, gn = nextHop( message[\"gateway_id\"] )\n if @routing_table.has_key?([0,tm,tn]) == false # || diff( joining_guid ) < diff( @routing_table[[0,jm,jn]][\"node_id\"] )\n #puts \"h6\"\n @routing_table[[0,tm,tn]] = { :node_id => message[\"node_id\"], :ip_address => message[\"ip_address\"], \\\n :port => message[\"port\"] }\n end\n if tnh.ip != nil\n joinMesgRelay = { :type => \"JOINING_NETWORK_RELAY_SIMPLIFIED\", :node_id => message[\"node_id\"], \\\n :gateway_id => message[\"gateway_id\"], \\\n :ip_address => message[\"ip_address\"], :port => message[\"port\"] }.to_json\n @s.send joinMesgRelay, 0, tnh.ip, tnh.port\n end\n tempRouteTable = []\n @routing_table.each_value { |addr|\n tempRouteTable.push( addr )\n }\n routingInfoMesg = { :type => \"ROUTING_INFO\", :gateway_id => message[\"gateway_id\"], :node_id => message[\"node_id\"], \\\n :ip_address => @localInetAddr.ip, :port => @localInetAddr.port, :route_table => tempRouteTable }.to_json\n if nh.ip != nil\n @s.send routingInfoMesg, 0, nh.ip, nh.port\n end\n end\n\n\n # When we get a routing info message extract as much useful information out of it as we can and forward it onto the\n # intended target node unless it was intended for our node\n if message[\"type\"] == \"ROUTING_INFO\"\n useRouteInfo( message[\"route_table\"] )\n if message[\"node_id\"] == @guid\n return\n elsif message[\"gateway_id\"] == @guid\n if @gateway_table.has_key?( message[\"node_id\"] )\n p @s.send message.to_json, 0, @gateway_table[message[\"node_id\"]][:ip_address].to_s, @gateway_table[message[\"node_id\"]][:port]\n else\n puts \"Routing_Info message receave error not key in gatewayTable!\"\n end\n else\n nh, gm, gn = nextHop( message[\"node_id\"] )\n message = message.to_json\n if nh.ip != nil\n @s.send message, 0, nh.ip, nh.port\n end\n end\n end\n\n # If we get a leaving message remove the node from the network\n if message[\"type\"] == \"LEAVING_NETWORK\"\n removeAddr( message[\"node_id\"])\n end\n\n # When we receave an index message check it is intended for us and if not forward to next hop otherwise process\n # increase the rank of urls in @linkHash or create a new entry if\n # We have not seen that URL before\n if message[\"type\"] == \"INDEX\"\n if message[\"target_id\"] == @guid\n flag = true\n for i in [email protected]\n if @linkHash[i][:url] == message[\"link\"]\n @linkHash[i][:rank] += 1\n flag = false\n end\n end\n if flag\n @linkHash << { :url => message[\"link\"], :rank => 1 }\n end\n ackIndexMesg = { :type => \"ACK_INDEX\", :node_id => message[\"sender_id\"], :keyword => message[\"keyword\"] }.to_json\n if message[\"sender_id\"] == @guid\n puts \" \"\n print @name, \" INDEXING myself\" # If we are processing our own indexing message no need to send an ACK\n puts \" \"\n return\n end\n nh, sm, sn = nextHop( message[\"sender_id\"] )\n @s.send ackIndexMesg, 0, nh.ip, nh.port\n else\n nh, tm, tn = nextHop( message[\"target_id\"] )\n if nh.ip != nil\n @s.send message.to_json, 0, nh.ip, nh.port\n end\n end\n end\n\n\n # Keept forwarding until this ACK_INDEX message reaches its destination, when it does set the appropriate flag\n if message[\"type\"] == \"ACK_INDEX\"\n if message[\"node_id\"] == @guid\n wordHash = Hash_Func( message[\"keyword\"] )\n @indexAckWait[ wordHash ] = 2\n else\n nh, m, n = nextHop( message[\"node_id\"] )\n if nh.ip != nil\n @s.send message.to_json, 0, nh.ip, nh.port\n end\n end\n end\n\n\n # Keep forwarding search message until it reaches correct location in which case we append @linkHash to a search\n # responce message and send it to the sending ID\n if message[\"type\"] == \"SEARCH\"\n if message[\"node_id\"] == @guid\n searchResponceMesg = { :type => \"SEARCH_RESPONSE\", :word => message[\"word\"], :node_id => message[\"sender_id\"],\n :sender_id => @guid, :response => @linkHash }.to_json\n nh, sm, sn = nextHop( message[\"sender_id\"] )\n @s.send searchResponceMesg, 0, nh.ip, nh.port\n else\n nh, tm, tn = nextHop( message[\"node_id\"] )\n message = message.to_json\n if nh.ip != nil\n @s.send message, 0, nh.ip, nh.port\n end\n end\n end\n\n # Keep forwarding responce until we reach intended recipient and then put results in flag so origional\n # search thread can process the results\n if message[\"type\"] == \"SEARCH_RESPONSE\"\n if message[\"node_id\"] == @guid\n @searchAckWait[ message[\"sender_id\"] ] = message[\"response\"]\n else\n nh, tm, tn = nextHop( message[\"node_id\"] )\n if nh.ip != nil\n @s.send message.to_json, 0, nh.ip, nh.port\n end\n end\n end\n\n # Upon receaving a PING send onto next hop and generate ACK\n if message[\"type\"] == \"PING\"\n ackMesg = { :type => \"ACK\", :node_id => @guid, :ip_address => @localInetAddr.ip, \\\n :port => @localInetAddr.port }.to_json\n @s.send ackMesg, 0, message[\"ip_address\"], message[\"port\"]\n if message[\"target_id\"] != @guid\n #puts @name, \"PNH\", message[\"target_id\"], Time.now\n nh, m, n = nextHop( message[\"target_id\"] )\n if nh.ip != nil\n message[\"ip_address\"] = @localInetAddr.ip\n message[\"port\"] = @localInetAddr.port\n @s.send message.to_json, 0, nh.ip, nh.port\n end\n end\n end\n\n # Upon receiving an ACK message we know this node is still alive\n if message[\"type\"] == \"ACK\"\n @checkAckWait[ message[\"node_id\"] ] = 2\n end\n end",
"def do_move_to_location(klass, target_loc, msg_out = nil, msg_in = nil)\n do_move(klass, target_loc.preposition || 'in', target_loc.item, target_loc.coord, msg_out, msg_in)\n end",
"def travel\r\n puts \"I am traveling to #{@big_location}.\"\r\nend",
"def send_message(message); end",
"def send_message(message); end",
"def _send_message data\n response << data\n end",
"def say(recipient_id, text, quick_replies = nil)\n message_options = {\n recipient: { id: recipient_id },\n message: { text: text }\n }\n if quick_replies\n message_options[:message][:quick_replies] = quick_replies\n end\n Bot.deliver(message_options, access_token: ENV['ACCESS_TOKEN'])\nend",
"def test_create_reply_to_up_in_chain_reply_to_standalone_message_about_nothing\r\n about = nil\r\n reply_to = messages(:kevin_reply_to__andy_to_kevin_about_nothing)\r\n send_message(@tim, @kevin, reply_to, about)\r\n end",
"def reply(message, to = nil)\n if to == :room\n reply_to.reply(message, nil)\n else\n reply_to.reply(message, to || private_sender)\n end\n end",
"def location\n fetch('hey_arnold.locations')\n end",
"def share_location_on_twitter options={}\n if from_twitter?\n\n c_id = id\n c_id = \"4f696467043bac0001000002\" if Rails.env != \"production\"\n\n oauth = providers.where(provider: \"twitter\").first\n \n status_msg = self.swap_stat\n status_msg.gsub! /you/, \"me\" \n status_msg = \"On @myradddar! #{status_msg} http://www.radddar.com/#{c_id}\"\n\n Twitter.configure do |config|\n config.consumer_key = ENV[\"RDR_TWITTER_KEY\"]\n config.consumer_secret = ENV[\"RDR_TWITTER_SECRET\"]\n config.oauth_token = oauth[:token]\n config.oauth_token_secret = oauth[:secret]\n end\n\n client = Twitter::Client.new\n client.update(status_msg,{\n lat: self.loc[0],\n long: self.loc[1],\n }) rescue nil\n\n end\n end",
"def reply_to\n (@reply_to || self.from)\n end",
"def reply (workitem)\n\n reply_to_parent(workitem)\n end",
"def reply (workitem)\n\n reply_to_parent(workitem)\n end",
"def send_reply(text)\n @bot.api.send_message(chat_id: @last_message.chat.id, text: text)\n end",
"def respond(m, cl, msg)\n m2 = Message.new(m.from, msg)\n m2.type = m.type\n cl.send(m2)\nend",
"def map\n @recipient = Recipient.find(params[:recipient_id])\n @destination = [@recipient.address.to_s, @recipient.city.to_s].join(\", \")\n @origin = params[:from_destination]\n \n render :action => 'map'# , :layout => false\nend",
"def location\n @location\n end",
"def reply_request(request , assigned_room)\n request.room = assigned_room\n request.done = true\n request.save\n request.needers.each do |needer|\n Notification.send_notification(needer,\n 2,\n 2,\n (\"The Room ( \" << assigned_room << \" ) was Assigned for your Session/Meeting\"))\n end\n end",
"def send_reply msg, str, prefix = true\n if str.empty?\n str = \"I tried to send you an empty message. Oops!\"\n end\n\n # TODO: Hold additional content for later sending or something.\n # Just don't try to send it all in multiple messages without\n # the user asking for it!\n unless msg.query?\n use_prefix = Bot::Conf[:core][:replyprefix] rescue true\n\n str = \"#{msg.nick}: #{str}\" if prefix and use_prefix\n\n send_privmsg msg.destination, str\n else\n send_notice msg.nick, str\n end\n end",
"def reply_ping(user, str)\n sendmsg \"NOTICE #{user} :\\001PING #{str}\\001\"\n end",
"def send_messages(event)\n begin\n scheme = request.scheme\n host = request.host\n rescue NameError\n scheme = 'http'\n host = 'testing'\n end\n message = <<EOL\nPlease attend this blood drive event and help save lives.\n#{scheme}://#{host}/events/#{event.id}\nEOL\n Donor.where(zipcode: event.zipcode).map(&:phone).each do |ph|\n @client.messages.create(:from => twilio_number, :to => ph , :body =>message)\n end\n end"
] | [
"0.6639069",
"0.64361334",
"0.63614446",
"0.6064309",
"0.5987063",
"0.58139586",
"0.5801013",
"0.5735889",
"0.570898",
"0.57033324",
"0.5689853",
"0.5686033",
"0.56789947",
"0.5631206",
"0.56280404",
"0.5619926",
"0.5616567",
"0.5597107",
"0.5597107",
"0.5592948",
"0.5584025",
"0.5550589",
"0.55397856",
"0.55368894",
"0.5528494",
"0.55025804",
"0.5483199",
"0.5479472",
"0.5478931",
"0.5470389",
"0.5467967",
"0.546047",
"0.5458731",
"0.5455553",
"0.5445644",
"0.54416233",
"0.5440232",
"0.54364365",
"0.5418604",
"0.5414299",
"0.54116654",
"0.5407811",
"0.5402283",
"0.53894925",
"0.5388291",
"0.5388291",
"0.53848994",
"0.53847647",
"0.53469765",
"0.53447765",
"0.53447765",
"0.53438056",
"0.5335115",
"0.53319347",
"0.53170216",
"0.5311232",
"0.52901477",
"0.5289687",
"0.52888834",
"0.52744365",
"0.5269962",
"0.5268727",
"0.52584344",
"0.5253186",
"0.5252265",
"0.5250391",
"0.5250001",
"0.52493256",
"0.52439564",
"0.52363145",
"0.5224873",
"0.5223128",
"0.5218003",
"0.5213662",
"0.52121586",
"0.52118236",
"0.52055615",
"0.5202023",
"0.5200117",
"0.5199837",
"0.51974756",
"0.5187",
"0.5187",
"0.5185097",
"0.5183387",
"0.5181565",
"0.5179733",
"0.5177791",
"0.51715744",
"0.51696205",
"0.51695544",
"0.51695544",
"0.5147322",
"0.5147096",
"0.51370054",
"0.5134497",
"0.5133645",
"0.5133202",
"0.51308286",
"0.5130316"
] | 0.7803032 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.