query
stringlengths 7
9.5k
| document
stringlengths 10
1.07M
| negatives
listlengths 19
19
| metadata
dict |
---|---|---|---|
if target is _, returns false if we've guessed the word's char already if target is az, returns false if our word has a different char
|
def char_valid?(char, guesses, target)
if target == '_'
return !guesses.include?(char)
end
char == target
end
|
[
"def guess?(letter)\n @word.downcase.include?(letter)\n end",
"def all_letters_guessed?\n word_guessed = true\n @player_work.each { |c| word_guessed = false if c == '_' }\n word_guessed\n end",
"def guessed?\n \t(word.split('') - selected_letters).empty?\n\tend",
"def check(char)\n found = false\n @word.value.each_with_index do |val, index|\n if val == char.upcase\n @word.progress[index] = char.upcase\n found = true\n end\n end\n return if @word.bad_guesses.include?(char)\n puts \"Bad guess!\" unless found\n @word.bad_guesses << char.upcase unless found\n end",
"def guess?(letter)\n # puts \"guess letter for the word\"\n @word.include?(letter)\n end",
"def check_word(guess)\n\t\tguess_used = false\n\t\t@guess_history.each do |x|\n\t\t\t\tif x == guess\n\t\t\t\t\tguess_used = true\n\t\t\t\tend\n\t\t\tend\n\t\tif !guess_used\n\t\t\t@guess_count += 1\n\t\t\t@guess_history << guess\n\t\tend\n\t\tif guess == @target_word\n\t\t\t@win = true\n\t\t\t@is_over = true\n\t\telse\n\t\t\tfalse\n\t\tend\n\tend",
"def compare(word, guess)\n (0..word.split('').count).each do |i|\n return false if guess[i] != '_' && word[i] != guess[i]\n end\n true\n end",
"def test_word(character)\r\n #Once the character is passed through, delete it as we dont want to use it again\r\n @alpha.delete(character)\r\n #If the word includes this charater, store it in variable, correct\r\n correct = word.include?(character)\r\n #Iterate through each value of word as an array\r\n #Item will equal the letter and index will equal the index (per using each_with-index)\r\n word.chars.each_with_index do |item, index| # item = \"p\", index = 0\r\n #The index from word that matches within placeholder, should equal the random \r\n #character if the character is equal to the item from word\r\n @placeholder[index] = character if character == item \r\n #End method\r\n end\r\n #Return correct\r\n correct\r\n #End method\r\n end",
"def guessed_all_correct?\n if letter_counter == word.length\n return true\n end\n false\n end",
"def hit?(letter)\n\t\n\t# Check number of occurences of the letter in the array\n\tmatches = 0\n\trx = Regexp.new(letter)\n\tmatches = $words.count { |word| word =~ rx }\n\n\t# puts matches.to_s + \" words contain the letter \" + letter\n\n\tif (matches == 1)\n\t\t# Remove all words from the array that\n\t\t# do not match\n\t\t$words.keep_if { |word| word =~ rx }\n\t\t# puts \"Found target word: \" + $words.inspect\n\t\treturn true\n\telsif (matches == $words.size)\n\t\trindex = rand($words.size)\n\t\t# puts \"Random index = \" + rindex.to_s\n\t\tword = $words[rindex]\n\t\t# puts \"Selected word = \" + word\n\t\t$words.clear\n\t\t$words << word\n\t\t# puts \"$words = \" + $words.to_s\n\t\treturn true\n\telse\n\t\t# Remove all the words from the array\n\t\t# that contain the letter\n\t\t$words.delete_if {|word| word =~ rx}\n\n\t\tmatches = 0\n\t\trx = Regexp.new(letter)\n\t\t$words.each do |word|\n\t\t\tif (rx.match(word) != nil)\n\t\t\t\t# print word + \" \"\n\t\t\t\tmatches += 1\n\t\t\tend\n\t\tend\n\t\treturn false\n\tend\nend",
"def extra_letter_match(word)\n result = \"NO SUGGESTION\"\n\n word.scan(/(\\w)\\1/) do\n # We want to leave the original word intact\n shortened_word = word.dup\n\n shortened_word.slice!(Regexp.last_match.offset(0).first)\n break if (result = check(shortened_word)) != \"NO SUGGESTION\"\n end\n\n result\n end",
"def any_letters?(guess)\n\t\t @secret_word.include?(guess) ? true : false\n\t end",
"def check_within(guess)\n\t\t@target_word.include? guess\n\tend",
"def anagram?(test_word)\n return false if test_word == @word\n\n master_word = @word.chars.sort == test_word = test_word.chars.sort\n end",
"def check_word_for_char(char)\n @word.include?(char) ? true : false\n end",
"def include_letter?\n @guess_ind = (0 ... @word.length).find_all { |i| @word[i,1] == @used_guesses[-1]}\n return @guess_ind\n end",
"def valid_word?\n if @guessed_words.include? @guess\n print \"You've already guessed that one. Guess again.\"\n @valid = false\n else\n @valid = true\n end\n end",
"def fail_letter?(letter)\n return @secret_word.include?(letter) ? false : letter\n end",
"def check_player_words(player_guess_word)\n word.chomp.chars.each_with_index{\n |item, index|\n if item == player_guess_word.chomp.chars[index].to_s # exactly equal and in the same postion\n result = \"Exact\"\n elsif word.chomp.include?(player_guess_word.chars[index].to_s) # just includes the letter\n result = \"Near\"\n else # other condition that either not exact nor includes is.\n result = \"Miss\"\n end\n sleep(SLEEP_TIME) # just stop for a time make a good user experience\n puts \"Letter: #{player_guess_word.chars[index]} : #{result}\"\n }\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Create new connection between BeaconCtrl and BeaconClient New oauth token should be returned by server.
|
def connect!
@connection = user ? connection_for_user : connection_for_application
@auth_token = @connection.token
BeaconClient.logger.debug("Client token: #{@auth_token}") if BeaconClient.config.debug?
@auth_token
rescue OAuth2::Error => error
BeaconClient.logger.error(error.message)
BeaconClient.logger.error(error.backtrace.join("\n"))
end
|
[
"def oauth2_client(token, params = {})\n @oauth2_client = RubyLokaliseApi::OAuth2Client.new token, params\n end",
"def create_client\n @client = LinkedIn::API.new(auth_hash[\"token\"])\n end",
"def connect!\n retrieve_auth_token unless connected?\n auth_token[:token]\n end",
"def connection_for_user\n BeaconClient.logger.debug([user.email.inspect, user.password.inspect].join(' : '))\n oauth_client.password.get_token(\n user.email, user.password,\n email: user.email\n )\n end",
"def client\n @client ||= Bitlyr::Client.new(@access_token)\n end",
"def new\n gon.client_token = generate_client_token\n end",
"def connect!(user=nil)\n @@client = ::BeaconClient::Client.new(user || BeaconClient.config.user)\n end",
"def oauth_client\n @oauth_client ||= OAuth2::Client.new(api_key, api_secret,\n site: \"https://openapi.baidu.com\",\n authorize_url: \"/oauth/2.0/authorize\",\n token_url: \"/oauth/2.0/token\")\n\n end",
"def create_connection\n\t\t@connection = Faraday.new(:url => @base_url) do |faraday|\n\t\t\tfaraday.headers['Accept'] = 'application/json'\n\t\t\tfaraday.adapter Faraday.default_adapter\n\t\tend\n\tend",
"def initialize(options= {})\n @login = options[:login] || ENV['VZAAR_LOGIN'] || ''\n application_token = options[:application_token] || ENV['VZAAR_APPLICATION_TOKEN'] || ''\n server = options[:server] || ENV['VZAAR_SERVER'] || VZAAR_LIVE_SERVER\n @logger = options[:logger] || Logger.new(STDOUT)\n\n server.gsub! 'http://', ''\n server.gsub! 'https://', ''\n consumer = OAuth::Consumer.new '', '', { :site => \"http://#{server}\" }\n @public_connection = OAuth::AccessToken.new consumer, '', ''\n consumer = OAuth::Consumer.new '', '', { :site => \"https://#{server}\" }\n if @login.length > 0 and application_token.length > 0\n @auth_connection = OAuth::AccessToken.new consumer, @login, application_token\n else\n # Authenticated requests won't be possible\n @auth_connection = nil\n log_info \"Authenticated calls won't be possible\"\n end\n end",
"def connection(access_token)\n @connection ||= RestClient.new(\n access_token: access_token,\n api_host: AIRTABLE_API_HOST\n )\n end",
"def create_client\n @client = TwitterOAuth::Client.new(\n :consumer_key => CONFIG[:tw_consumer_key], \n :consumer_secret => CONFIG[:tw_consumer_secret]) \n end",
"def initialize(client_id: nil, access_token: nil)\n if client_id.nil? && access_token.nil?\n raise \"An identifier token (client ID or bearer token) is required\"\n elsif !!client_id && !!access_token\n warn(%{WARNING:\nIt is recommended that only one identifier token is specified.\nUnpredictable behavior may follow.})\n end\n\n headers = {\n \"User-Agent\": \"twitch-api ruby client #{Twitch::VERSION}\"\n }\n unless client_id.nil?\n headers[\"Client-ID\"] = client_id\n end\n unless access_token.nil?\n access_token = access_token.gsub(/^Bearer /, \"\")\n headers[\"Authorization\"] = \"Bearer #{access_token}\"\n end\n \n @conn = Faraday.new(API_ENDPOINT, { headers: headers }) do |faraday|\n faraday.request :json\n faraday.response :json\n faraday.adapter Faraday.default_adapter\n end\n end",
"def create_new_persistent_connection\n app_name = if @data[:options][:connection_ca_file] ||\n @data[:credentials][:cert] ||\n @data[:credentials][:key]\n 'right_cloud_api_gem_%s' % Utils::generate_token\n else\n 'right_cloud_api_gem'\n end\n connection = Net::HTTP::Persistent.new(app_name)\n set_persistent_connection_options!(connection)\n # Register a callback to close current connection\n @data[:callbacks][:close_current_connection] = Proc::new do |reason|\n connection.shutdown\n log \"Current connection closed: #{reason}\"\n end\n connection\n end",
"def initialize(access_token=nil)\n @connection = Twelve::Connection.new(access_token)\n end",
"def new_client\n Client.new(self)\n end",
"def initialize(client_id: nil, access_token: nil, with_raw: false)\n if client_id.nil? && access_token.nil?\n raise \"An identifier token (client ID or bearer token) is required\"\n elsif !!client_id && !!access_token\n warn(%{WARNING:\nIt is recommended that only one identifier token is specified.\nUnpredictable behavior may follow.})\n end\n\n headers = {\n \"User-Agent\": \"twitch-api ruby client #{Twitch::VERSION}\"\n }\n unless client_id.nil?\n headers[\"Client-ID\"] = client_id\n end\n unless access_token.nil?\n access_token = access_token.gsub(/^Bearer /, \"\")\n headers[\"Authorization\"] = \"Bearer #{access_token}\"\n end\n \n @conn = Faraday.new(API_ENDPOINT, { headers: headers }) do |faraday|\n faraday.request :json\n faraday.response :json\n faraday.adapter Faraday.default_adapter\n end\n\n @with_raw = with_raw\n end",
"def connect(access_token)\n @y = Yammer::Client.new(\n :consumer => {\n :key => Yamr::OAUTH_APP_KEY, \n :secret => Yamr::OAUTH_APP_SECRET\n },\n :access => { \n :token => access_token.token,\n :secret => access_token.secret\n }\n )\n\n # Save token and secret for next time\n @config.oauth.token = access_token.token\n @config.oauth.secret = access_token.secret\n save\n\n set_hint_text\n\n # Grab initial messages\n fetch_messages\n end",
"def initialize\n self.http_client = HTTPClient.new(:base_url => Rdioid::BASE_URL, :force_basic_auth => true)\n\n http_client.set_auth(Rdioid::OAUTH_TOKEN_ENDPOINT, Rdioid.config.client_id, Rdioid.config.client_secret)\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Connect as an User Require ApplicationID, ApplicationSecret, UserEmail, UserPassword
|
def connection_for_user
BeaconClient.logger.debug([user.email.inspect, user.password.inspect].join(' : '))
oauth_client.password.get_token(
user.email, user.password,
email: user.email
)
end
|
[
"def login\n client.login(\n params[:user],\n params[:password],\n authParams: {\n scope: 'openid name email'\n },\n connection: 'Username-Password-Authentication'\n )\n end",
"def connect\n @user = User.where(:email => params[:user][:email]).first\n # If there is no user, create one\n if @user.nil? then\n @user = User.new(user_params)\n end\n authorize @user\n @user.apartment_id = params[:user][:apartment_id]\n respond_to do |format|\n if @user.save!\n format.html { redirect_to @user, notice: 'User was successfully connected.' }\n format.json { render :show, status: :connected, location: @user }\n else\n format.html { render :new }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n end\n end\n end",
"def app_credentials\n {user: @config['mysql_app_user'], pass: @config['mysql_app_password']}\n end",
"def connect_init_user\n body = body_init_user\n response = self.class.post('/connect', :query => body)\n\n handle(response) { PlaidResponse.new(response, \"Successfully added user; Wait on Webhook Response\") }\n end",
"def create_user\n params = {\n :client_id => Swiftype.platform_client_id,\n :client_secret => Swiftype.platform_client_secret\n }\n post(\"users.json\", params)\n end",
"def sign_in\n puts \"Enter your '#{Wow::Config.remote}' credentials.\"\n puts \"Don't have an account yet? Create one at #{Wow::Config.remote}/users/sign_up\"\n email = Wow::ApiClient::Config.username || shell.ask(\"\\tEmail: \")\n password = Wow::ApiClient::Config.password || shell.password(\"\\tPassword: \")\n begin\n result = post('users/sign_in', email: email, password: password)\n data = result.data\n @current_user = { id: data[:id], token: data[:authentication_token] }\n rescue RestClient::Unauthorized => e\n raise Wow::Error, e.response.data[:error]\n end\n end",
"def user_from_credentials\n if user = User.find_for_database_authentication(email: params[:email])\n if user.valid_password? params[:password]\n user\n end\n end\n end",
"def setup_user_applications\n @user = User.find_by(email: 'state1_epi@example.com')\n # Make sure API access is enabled for this user.\n @user.update!(api_enabled: true)\n\n # Create OAuth applications\n @user_patient_read_write_app = OauthApplication.create(\n name: 'user-test-patient-rw',\n redirect_uri: 'urn:ietf:wg:oauth:2.0:oob',\n scopes: 'user/Patient.*'\n )\n\n # Create OAuth applications\n @user_everything_app = OauthApplication.create(\n name: 'user-test-patient-rw',\n redirect_uri: 'urn:ietf:wg:oauth:2.0:oob',\n scopes: 'user/Patient.* user/QuestionnaireResponse.read user/Observation.read user/RelatedPerson.* user/Immunization.*'\n )\n\n # Create access tokens\n @user_patient_token_rw = Doorkeeper::AccessToken.create(\n resource_owner_id: @user.id,\n application_id: @user_patient_read_write_app.id,\n scopes: 'user/Patient.*'\n )\n\n # Create access tokens\n @user_everything_token = Doorkeeper::AccessToken.create(\n resource_owner_id: @user.id,\n application_id: @user_everything_app.id,\n scopes: 'user/Patient.* user/QuestionnaireResponse.read user/Observation.read user/RelatedPerson.* user/Immunization.*'\n )\n end",
"def associate_user\n \tfbUserIdString = params[:idString]\t\n \tuser = User.new(fbUserId:fbUserIdString)\n \tif user.valid?\t\n\t\t\t user = User.create(fbUserId:fbUserIdString)\n\t\t\t success = true\n\t\t end\n\t\t start_session(fbUserIdString)\n end",
"def connect!\n if wechat_api_connect_solver.success?\n signin! user\n true\n else\n failed! wechat_api_connect_solver.error\n false\n end\n end",
"def create_user(application_name, application_id)\n res = nil\n user_id = VaultDriver.generate_uid\n uri = URI(@url + \"auth/#{application_name}/map/user-id/#{user_id}\")\n req = Net::HTTP::Post.new(uri)\n req['X-Vault-Token'] = @token\n application_data = { 'value' => application_id }\n res = Net::HTTP.start(uri.hostname, uri.port) do |http|\n req.body = application_data.to_json\n http.request(req)\n end\n [user_id, res.code.to_i]\n end",
"def to_app_user\n raise MissingUIDError unless auth_hash.uid\n Kracken.config.user_class.find_or_create_from_auth_hash(auth_hash)\n end",
"def set_connect_credentials(connect_tenant_user_id, connect_tenant_password)\r\n @connect_tenant_user_id = connect_tenant_user_id\r\n @connect_tenant_password = connect_tenant_password\r\n end",
"def initialize(app_key, username, password)\n @app_key = app_key\n @username = username\n @password = password\n end",
"def acquia_conf_auth\n user_data = JSON.parse(File.read(acquia_conf_path))\n { username: user_data['email'], password: user_data['key'] }\n end",
"def authenticate\n authenticate_or_request_with_http_basic('Application') do |email, password|\n user = User.find_by_email(email)\n\n if user.present?\n user.authenticate(password)\n end\n end\n end",
"def setup_user_applications\n @user = User.find_by(email: 'state1_epi@example.com')\n # Make sure API access is enabled for this user.\n @user.update!(api_enabled: true)\n\n # Create OAuth applications\n @user_patient_read_write_app = create(\n :oauth_application,\n name: 'user-test-patient-rw',\n redirect_uri: 'urn:ietf:wg:oauth:2.0:oob',\n scopes: 'user/Patient.*'\n )\n\n # Create OAuth applications\n @user_everything_app = create(\n :oauth_application,\n name: 'user-test-patient-rw',\n redirect_uri: 'urn:ietf:wg:oauth:2.0:oob',\n scopes: 'user/Patient.* user/QuestionnaireResponse.read user/Observation.* user/RelatedPerson.* user/Immunization.* user/Provenance.read'\n )\n\n # Create access tokens\n @user_patient_token_rw = Doorkeeper::AccessToken.create(\n resource_owner_id: @user.id,\n application_id: @user_patient_read_write_app.id,\n scopes: 'user/Patient.*'\n )\n\n # Create access tokens\n @user_everything_token = Doorkeeper::AccessToken.create(\n resource_owner_id: @user.id,\n application_id: @user_everything_app.id,\n scopes: 'user/Patient.* user/QuestionnaireResponse.read user/Observation.* user/RelatedPerson.* user/Immunization.* user/Provenance.read'\n )\n end",
"def update_application_credentials_for_assigned_user(app_id, user_id, options = {})\n post(\"/apps/#{app_id}/users/#{user_id}\", options)\n end",
"def connect(_username, _password)\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
GET /time/time_reports GET /time/time_reports.json
|
def index
@time_time_reports = Time::TimeReport.all
end
|
[
"def show\n @time_report = TimeReport.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_report }\n end\n end",
"def index\n get_todays_data\n\n respond_to do |format|\n format.html { }\n format.json { json_response(@set_times) }\n end\n end",
"def index\n @time_entries = TimeEntry.all\n render :json => @time_entries, status: :ok\n end",
"def index\n @timecharts = Timechart.find(:all, order: \"stop_time DESC\")\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @timecharts }\n end\n end",
"def index\n @time_sheets = @user.time_sheets\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @time_sheets }\n end\n end",
"def index\n @timecards = TimeCard.all\n render :json => @timecards.to_json(:include => :time_entry), status: :ok\n end",
"def index\n @hour_logs = HourLog.all\n render json: @hour_logs, status: 200\n end",
"def new\n @time_report = TimeReport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @time_report }\n end\n end",
"def get_client_throughput_time_series_data(args = {}) \n get(\"/clients.json/stats/throughput\", args)\nend",
"def index\n @class_times = ClassTime.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @class_times }\n end\n end",
"def index\n @service_times = ServiceTime.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @service_times }\n end\n end",
"def index\n @stop_times = StopTime.all\n respond_to do |format|\n format.html { render :index }\n format.xml { render xml: @stop_times, status: :ok }\n format.json { render json: @stop_times, status: :ok }\n end\n end",
"def download_report(name, request_time, format)\n response = @client.get('arborws/reports/configured',\n api_key: @api_key, name: name,\n request_time: request_time, format: format)\n\n response\n end",
"def types\n @client.make_request :get, reports_path\n end",
"def index\n @period_times = PeriodTime.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @period_times }\n end\n end",
"def index\n @timings = Timing.all\n end",
"def index\n @attendance_reports = AttendanceReport.all\n\n render json: @attendance_reports\n end",
"def index\n @tea_times = TeaTime.all\n respond_to do |format|\n format.html { render layout: !request.xhr? }\n format.json { render json: @tea_times }\n end\n end",
"def index\n @recorded_times = RecordedTime.all\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
POST /time/time_reports POST /time/time_reports.json
|
def create
@time_time_report = Time::TimeReport.new(time_time_report_params)
respond_to do |format|
if @time_time_report.save
format.html { redirect_to @time_time_report, notice: 'Time report was successfully created.' }
format.json { render :show, status: :created, location: @time_time_report }
else
format.html { render :new }
format.json { render json: @time_time_report.errors, status: :unprocessable_entity }
end
end
end
|
[
"def create\n @time_report = TimeReport.new(params[:time_report])\n\n respond_to do |format|\n if @time_report.save\n format.html { redirect_to @time_report, notice: 'Time report was successfully created.' }\n format.json { render json: @time_report, status: :created, location: @time_report }\n else\n format.html { render action: \"new\" }\n format.json { render json: @time_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @time_time_reports = Time::TimeReport.all\n end",
"def create\n @time_chart = TimeChart.new(time_chart_params)\n\n amount_donated = item_amount_calculator(params['report_date'])\n value_donated = item_value_calculator(params['report_date'])\n @time_chart.report_date = params['report_date']\n @time_chart.amount_donated = amount_donated\n @time_chart.value_donated = value_donated\n\n respond_to do |format|\n if @time_chart.save\n format.html { redirect_to backoffice_time_charts_path, notice: 'Relatório temporal criado com sucesso.' }\n format.json { render :show, status: :created, location: @time_chart }\n else\n format.html { render :new }\n format.json { render json: @time_chart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @time_report = TimeReport.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @time_report }\n end\n end",
"def add_report_template(args = {}) \n post(\"/reports.json/template\", args)\nend",
"def create_hourly_report(url)\n @total_serv_time = 0\n @time_spent_g = 0\n @time_spent_p = 0\n @user_list = []\n @g_count = 0\n @p_count = 0\n @n = 1\n puts \"24 Hour Report for #{url}\"\n puts \"---------------------------------------------------------------------------------------------\"\n puts \"TH HOUR---# USER---# GET---# POST---TOTAL_TIME_GET(ms)---TOTAL_TIME_POST(ms)---TOTAL_TIME(ms)\"\n puts \"---------------------------------------------------------------------------------------------\"\n for n in 1..24\n $all_user_data.each do |k,v|\n if v[:th_hour] == n && !v[:uri].to_s.string_contains(url).nil? \n @total_serv_time += v[:time].to_i\n if v[:method] == 'G'\n @time_spent_g += v[:time].to_i\n @g_count += 1 \n end\n if v[:method] == 'P'\n @time_spent_p += v[:time].to_i\n @p_count += 1 \n end\n @user_list << v[:user].to_s\n end \n end\n #puts \"#{n}TH HOUR---#{@user_list.uniq.length} users---#{@g_count} GET REQs---#{@p_count} POST REQs---#{@time_spent_g}ms in GET---#{@time_spent_p}ms in POST---#{@total_serv_time}ms in Total\"\n puts \"#{n}TH HOUR---#{@user_list.length} users---#{@g_count} GET REQs---#{@p_count} POST REQs---#{@time_spent_g}ms in GET---#{@time_spent_p}ms in POST---#{@total_serv_time}ms in Total\"\n #pp @@user_list.uniq\n @total_serv_time = 0\n @time_spent_g = 0\n @time_spent_p = 0\n @g_count = 0\n @p_count = 0\n @user_list.clear\n end\n end",
"def create_reported_hours\n \n rh = ReportedHours.find_by_user_id_and_task_id(params[:user_id],params[:id])\n @status = Status.find(params[:status_id])\n @project = Project.find(params[:project_id])\n task = Task.find(params[:id])\n \n Task.report_hours(rh, params[:rh],current_user,task)\n\n redirect_to boards_project_path(@project)\n end",
"def report_data_request(options)\n request.headers['Content-Type'] = 'application/json'\n post :report_data, :params => report_data_request_data(options)\n end",
"def reports_hours_users \n @initial_date = Date.strptime(params[:initial_date], \"%m/%d/%Y\")\n @final_date = Date.strptime(params[:final_date], \"%m/%d/%Y\")\n @count = @project.count_confirmed_users\n\n respond_to do |format|\n format.json\n end \n end",
"def generate_report(start_date, end_date)\n @resource = Resource.new\n @resource.name = \"report - #{Time.now.strftime(\"%T - %m/%e/%Y\")}\"\n @recorded_hours_series = Hash.new\n @recorded_hours_series[\"name\"] = \"Recorded Hours\"\n @recorded_hours_series[\"data\"] = Array.new\n @organization_volunteers = []\n @volunteer_table = []\n @top_opportunities = []\n @volunteer_table << [\"Name\", \"Email\", \"Organization\",\"Opportunity\",\"Instance\",\"Hours\"]\n @opportunities_table = []\n if organization_type.name === \"Volunteer Group\"\n @opportunities_table << [\"Opportunity Name\", \"Organization Name\", \"Organization Contact\",\"# of Volunteers\",\"Total Hours\"]\n elsif organization_type.name === \"Nonprofit\"\n @opportunities_table << [\"Opportunity Name\",\"# of Volunteers\",\"Total Hours\"]\n end\n\n @total_hours = 0\n summary_graph = Hash.new\n summary_graph[\"Total Volunteers Added\"] = Hash.new\n summary_graph[\"Total Recorded Hours\"] = Hash.new\n @email_suffixes = []\n top_suffixes = [\"gmail.com\", \"hotmail.com\",\"aol.com\",\"yahoo.com\"]\n daily_statistics.where(date: start_date..end_date).each do |ds|\n summary_graph[\"Total Volunteers Added\"][ds.date.strftime(\"%m/%e\")] = ds.total_added_volunteers\n summary_graph[\"Total Recorded Hours\"][ds.date.strftime(\"%m/%e\")] = ds.total_recorded_hours\n end\n organization_recorded_hours.each do |rh|\n if rh.hours && rh.person && rh.instance && (start_date..end_date).cover?(rh.instance)\n @total_hours += rh.hours\n if rh.opportunity && !rh.opportunity.nil?\n opportunity_name = \"#{rh.opportunity.name.to_s}\"\n else\n opportunity_name = \"No Opportunity Name\"\n end\n if organization_type.name === \"Nonprofit\"\n if rh.organization && !rh.organization.nil?\n organization_name = \"#{rh.organization.name.to_s}\"\n else\n organization_name = \"No Organization\"\n end\n elsif organization_type.name === \"Volunteer Group\"\n if rh.opportunity && Opportunity.exists?(id: rh.opportunity.id) && rh.opportunity.organization && Organization.exists?(id: rh.opportunity.organization.id)\n organization_name = \"#{rh.opportunity.organization.name.to_s}\"\n else\n organization_name = \"No Organization\"\n end\n end\n if !rh.person.first_name.nil?\n person_first_name = \"#{rh.person.first_name}\"\n else\n person_first_name = \"\"\n end\n if !rh.person.last_name.nil?\n person_last_name = \"#{rh.person.last_name}\"\n else\n person_last_name = \"\"\n end\n if !rh.person.email.nil?\n person_email = \"#{rh.person.email}\"\n else\n person_email = \"\"\n end\n if rh.instance\n instance = rh.instance.strftime(\"%I:%M%p - %m/%d/%Y\")\n else\n instance = \"\"\n end\n @volunteer_table <<\n [\n \"#{person_first_name} #{person_last_name}\",\n person_email,\n organization_name,\n opportunity_name,\n instance,\n \"#{rh.hours.to_f}\"\n ]\n existing_volunteer = @organization_volunteers.find { |ov| ov[:id] == rh.person_id }\n if existing_volunteer\n existing_volunteer[:hours] += rh.hours\n else\n @organization_volunteers.push({\n id: rh.person_id,\n name: \"#{rh.person.first_name} #{rh.person.last_name}\",\n hours: rh.hours\n })\n end\n if rh.person.email\n existing_suffix = @email_suffixes.find { |es| es[:suffix] == rh.person.email.split(\"@\").last }\n if existing_suffix && !top_suffixes.include?(existing_suffix[:suffix])\n existing_suffix[:hours] += rh.hours\n else\n @email_suffixes.push({\n suffix: rh.person.email.split(\"@\").last,\n hours: rh.hours\n })\n end\n end\n end\n end\n\n # This is the pie chart for roles\n @opportunities_series = Hash.new\n @opportunities_series[\"name\"] = \"Opportunities\"\n @opportunities_series[\"data\"] = Array.new\n opportunities_options = {\n title: {\n text: \"\"\n },\n chart: {\n type: 'pie'\n },\n xAxis: {\n title: {\n text: 'Percentage'\n }\n }\n }\n opportunities_options[\"series\"] = Array.new\n if !opportunities.empty?\n opportunities.each do |opr|\n @people = []\n total_recorded_hours = 0\n total_volunteers = 0\n if IceCube::Schedule.from_yaml(opr.schedule).occurs_between?(start_date, end_date)\n opr.recorded_hours.each do |rh|\n if rh.hours && (start_date..end_date).cover?(rh.instance) && (rh.organization_id === id || rh.opportunity.organization.id === id)\n total_recorded_hours += rh.hours\n end\n if rh.person && !@people.include?(rh.person)\n total_volunteers += 1\n @people << rh.person\n end\n end\n end\n if opr.name\n opportunity_name = \"#{opr.name.to_s}\"\n else\n opportunity_name = \"No Opportunity Name\"\n end\n if opr.organization && opr.organization.name\n organization_name = \"#{opr.organization.name.to_s}\"\n else\n organization_name = \"No Organization Name\"\n end\n if !opr.organization && !opr.organization.users.empty?\n ap opr.organization.users.first\n if opr.organization.users.first.email?\n contact_email = \"#{opr.organization.users.first.email}\"\n end\n else\n contact_email = \"\"\n end\n if organization_type.name === \"Volunteer Group\"\n @opportunities_table <<\n [\n opportunity_name,\n organization_name,\n contact_email,\n total_volunteers,\n total_recorded_hours\n ]\n elsif organization_type.name === \"Nonprofit\"\n @opportunities_table <<\n [\n opportunity_name,\n total_volunteers,\n total_recorded_hours\n ]\n end\n\n @top_opportunities << {name: \"#{opr.name}\", hours: total_recorded_hours}\n @opportunities_series[\"data\"].push({name: \"#{opr.name}\", y: total_recorded_hours})\n end\n end\n\n opportunities_options[\"series\"].push(@opportunities_series)\n opportunities = \"#{name}_opportunity_hours.png\"\n open(opportunities, 'wb') do |file|\n file << open(\"http://export.highcharts.com/?async=false&type=png&width=300&options=#{URI.encode(JSON.generate(opportunities_options))}\").read\n end\n\n top_volunteers = @organization_volunteers.sort_by { |i| i[:hours] }.reverse!.take(10)\n top_suffixes = @email_suffixes.sort_by { |i| i[:hours] }.reverse!.take(10)\n\n\n\n pdf = OrganizationReportPdf.new(self,\n summary_graph,\n start_date,\n end_date,\n top_volunteers,\n top_suffixes,\n @organization_volunteers.count,\n @total_hours,\n @volunteer_table,\n opportunities,\n @top_opportunities.take(3),\n @opportunities_table)\n pdf.render_file \"#{self.name} report #{Time.now.strftime(\"%m.%e.%Y.%H%M\")}.pdf\"\n\n @resource.resource = File.open(\"#{self.name} report #{Time.now.strftime(\"%m.%e.%Y.%H%M\")}.pdf\")\n @resource.resourceable = self\n @resource.save\n File.delete(\"#{self.name} report #{Time.now.strftime(\"%m.%e.%Y.%H%M\")}.pdf\")\n File.delete(opportunities)\n\n return @resource\n end",
"def create\n @user = @account.users.find(params[:user_id])\n @timing = @user.timings.new(params[:timing])\n authorize @timing, :create?\n\n respond_to do |format|\n\t if !can_create_timing?(@user, @timing)\n\t format.json { render :json => { :status => 'Unauthorized' }, :status => :unauthorized }\n elsif @timing.save\n format.json { render :json => @timing.to_json(:include => [:project,\n :task => { :only => [:name, :count_towards_time_worked] }]\n ), :status => :created }\n else\n format.json { render :json => @timing.errors.full_messages, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @report = Report.new(report_params)\n\n respond_to do |format|\n if @report.save\n \n @report.test_suite.test_cases.each do |test_case|\n @report.results.create({ status: 'Queued', report_id: @report, test_case_id: test_case.id})\n end\n \n format.html { redirect_to [:admin, @report], notice: 'Report was successfully created.' }\n format.json { render action: 'show', status: :created, location: @report }\n else\n format.html { render action: 'new' }\n format.json { render json: @report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @time_report = TimeReport.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @time_report }\n end\n end",
"def report_watermill\n @events = Event.order :punchtime\n @events = @events.where :employee_id => params[:employee_id] if params[:employee_id]\n @events = @events.where :job_id => params[:job_id] if params[:job_id]\n\n @jobs = Job.where({:active => true})\n @employees = Employee.order(:lastname)\n\n @periods = periods\n\n respond_to do |format|\n format.html # report.html.erb\n format.json { render json: periods }\n end\n end",
"def create\n @time_tracker = TimeTracker.new({ started_at: Time.current, status: 'running' }.merge(time_tracker_params))\n\n respond_to do |format|\n if @time_tracker.save\n format.html { redirect_to @time_tracker, notice: 'Time tracker was successfully created.' }\n format.json { render :show, status: :created, location: @time_tracker }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @time_tracker.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @report = Report.new(report_params)\n\n if @report.save\n render json: @report, status: :created, location: @report\n else\n render json: @report.errors, status: :unprocessable_entity\n end\n end",
"def create\n @report = Report.new(report_params)\n if @report.save\n render :show, status: :created, location: api_v1_report_url(@report)\n else\n render json: @report.errors, status: :unprocessable_entity\n end\n end",
"def reports_tasks_project\n @initial_date = Date.strptime(params[:initial_date], \"%m/%d/%Y\")\n @final_date = Date.strptime(params[:final_date], \"%m/%d/%Y\")\n \n respond_to do |format|\n format.json\n end\n end",
"def create\n begin\n @sea_report = SeaReport.new(sea_report_params)\n\n respond_to do |format|\n if @sea_report.save\n # Calculate smt and utc time of sea report\n # Update the 'smt_time' and 'created_at'.\n smt_time_string = \"#{params[:date]} #{params[:hours]}:#{params[:minutes]}:#{params[:seconds]} #{params[:sea_report][:zone_time]}\"\n utc_time = Time.parse(smt_time_string).getutc\n @sea_report.update_attributes(:opened_time_in_smt => smt_time_string, :created_at => utc_time)\n\n # update the report_number, sea_port_id of sea_report\n @sea_port = SeaPort.last\n\n if @sea_port\n\n @sea_report.report_number = @sea_port.sea_reports.count + 1\n @sea_report.sea_port_id = @sea_port.id\n @sea_report.is_closed = false\n @sea_report.save\n\n # Update the total_reports in sea_port\n @sea_port.total_reports += 1\n @sea_port.save\n\n format.html { redirect_to edit_sea_report_path(@sea_report.id), notice: 'Sea report is successfully created.' }\n format.json { render :show, status: :created, location: @sea_report }\n else\n format.html { redirect_to sea_reports_path, notice: 'First create the Sea Passage' }\n end\n\n else\n format.html { render :new }\n format.json { render json: @sea_report.errors, status: :unprocessable_entity }\n end\n end\n rescue\n format.html { render :new, notice: 'Some errors occured. Please try again' }\n end\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
PATCH/PUT /time/time_reports/1 PATCH/PUT /time/time_reports/1.json
|
def update
respond_to do |format|
if @time_time_report.update(time_time_report_params)
format.html { redirect_to @time_time_report, notice: 'Time report was successfully updated.' }
format.json { render :show, status: :ok, location: @time_time_report }
else
format.html { render :edit }
format.json { render json: @time_time_report.errors, status: :unprocessable_entity }
end
end
end
|
[
"def update\n @time_report = TimeReport.find(params[:id])\n\n respond_to do |format|\n if @time_report.update_attributes(params[:time_report])\n format.html { redirect_to @time_report, notice: 'Time report was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @time_report.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @time_chart = TimeChart.find(params[:id])\n\n amount_donated = item_amount_calculator(params['report_date'])\n value_donated = item_value_calculator(params['report_date'])\n @time_chart.report_date = params['report_date']\n @time_chart.amount_donated = amount_donated\n @time_chart.value_donated = value_donated\n\n respond_to do |format|\n if @time_chart.update(time_chart_params)\n format.html { redirect_to backoffice_time_charts_path, notice: 'Relatório temporal editado com sucesso.' }\n format.json { render :show, status: :ok, location: @time_chart }\n else\n format.html { render :edit }\n format.json { render json: @time_chart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_report_template(args = {}) \n put(\"/reports.json/template/#{args[:templateId]}\", args)\nend",
"def update\n respond_to do |format|\n if @set_time.update(set_time_params)\n format.html { redirect_to @set_time, notice: 'Set time was successfully updated.' }\n format.json { render :show, status: :ok, location: @set_time }\n else\n format.html { render :edit }\n format.json { render json: @set_time.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n \n respond_to do |format|\n @oven_time = OvenTime.find(params[:id])\n \n if @oven_time.update(oven_time_params)\n format.json { head :no_content }\n else\n format.json { render json: @oven_time.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @timechart = Timechart.find(params[:id])\n\n respond_to do |format|\n if @timechart.update_attributes(params[:timechart])\n format.html { redirect_to @timechart, notice: 'Timechart was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @timechart.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n set_time = SetTime.find(params[:id])\n respond_to do |format|\n if set_time.update_attributes(set_time_params)\n format.html { redirect_to @set_time, notice: 'Set time was successfully updated.' }\n format.json { render json: @set_time, status: :ok }\n else\n format.html { render :edit }\n format.json { render json: @set_time.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @endtime = Time.now\n begin\n # Submit the half-finished object via a post request\n response = Inventory.request[\"reports/#{@id}\"].put self.to_json, :content_type => :json, :accept => :json\n report = JSON.parse(response)\n rescue => exception\n puts exception.message\n puts exception.response\n exit 1\n end\n end",
"def update\n @hour_report = HourReport.find(params[:id])\n @hour_report.state = HourReport::Pending\n\n enforce_update_permission(@hour_report)\n \n respond_to do |format|\n if @hour_report.update_attributes(params[:hour_report])\n flash[:notice] = 'HourReport was successfully updated.'\n format.html { redirect_to(@hour_report) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @hour_report.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @oncall_time = OncallTime.find(params[:id])\n\n respond_to do |format|\n if @oncall_time.update_attributes(params[:oncall_time])\n format.html { redirect_to @oncall_time, :notice => 'Oncall time was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @oncall_time.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @recorded_time.update(recorded_time_params)\n format.html { redirect_to @recorded_time, notice: 'Recorded time was successfully updated.' }\n format.json { render :show, status: :ok, location: @recorded_time }\n else\n format.html { render :edit }\n format.json { render json: @recorded_time.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @my_time_trial = MyTimeTrial.find(params[:id])\n\n respond_to do |format|\n if @my_time_trial.update_attributes(params[:my_time_trial])\n format.html { redirect_to @my_time_trial, :notice => 'My time trial was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @my_time_trial.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @timing = Timing.find(params[:id])\n if @timing.update_attributes(params[:timing].slice(:start, :stop, :days, :active))\n render json: @timing\n else\n render json: { error: 'error: could not update timing' }\n end\n end",
"def update\n respond_to do |format|\n if @time_tracker.update(time_tracker_params)\n format.html { redirect_to @time_tracker, notice: 'Time tracker was successfully updated.' }\n format.json { render :show, status: :ok, location: @time_tracker }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @time_tracker.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @time_clock.update(time_clock_params)\n format.html { redirect_to time_sheet_index_path(@time_clock), notice: 'Time clock entry was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @time_clock.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @reports_task = ReportsTask.find(params[:id])\n\n if @reports_task.update(params[:reports_task])\n head :no_content\n else\n render json: @reports_task.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @poi_time.update(poi_time_params)\n format.html { redirect_to @poi_time, notice: 'Poi time was successfully updated.' }\n format.json { render :show, status: :ok, location: @poi_time }\n else\n format.html { render :edit }\n format.json { render json: @poi_time.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @task_time = @task.task_times.find(params[:id])\n\n respond_to do |format|\n if @task_time.update_attributes(params[:task_time])\n format.html { redirect_to task_time_path(@task,@task_time), notice: 'Task time was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @task_time.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @time_off_request = TimeOffRequest.find(params[:id])\n respond_to do |format|\n if @time_off_request.update_attributes(params[:time_off_request])\n format.html { redirect_to time_off_requests_url, notice: 'Time off request was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @time_off_request.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
DELETE /time/time_reports/1 DELETE /time/time_reports/1.json
|
def destroy
@time_time_report.destroy
respond_to do |format|
format.html { redirect_to time_time_reports_url, notice: 'Time report was successfully destroyed.' }
format.json { head :no_content }
end
end
|
[
"def destroy\n @time_report = TimeReport.find(params[:id])\n @time_report.destroy\n\n respond_to do |format|\n format.html { redirect_to time_reports_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report.destroy!\n render json: {status: :ok}\n end",
"def destroy\n @last_report.destroy\n respond_to do |format|\n format.html { redirect_to last_reports_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @time_log = TimeLog.find(params[:id])\n @time_log.destroy\n\n respond_to do |format|\n format.html { redirect_to time_logs_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @api_report = Report.find(params[:id])\n @api_report.destroy\n\n head :no_content\n end",
"def destroy\n @time_clock.destroy\n respond_to do |format|\n format.html { redirect_to time_sheet_index_path }\n format.json { head :no_content }\n end\n end",
"def destroy\n @time_period.destroy\n format.json { head :no_content }\n end",
"def destroy\n @reportdate.destroy\n respond_to do |format|\n format.html { redirect_to reportdates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @report_date.destroy\n respond_to do |format|\n format.html { redirect_to report_dates_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @my_time_trial = MyTimeTrial.find(params[:id])\n @my_time_trial.destroy\n\n respond_to do |format|\n format.html { redirect_to my_time_trials_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @time_getter.destroy\n respond_to do |format|\n format.html { redirect_to time_getters_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @timechart = Timechart.find(params[:id])\n @timechart.destroy\n\n respond_to do |format|\n format.html { redirect_to timecharts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @daily_report.destroy\n respond_to do |format|\n format.html { redirect_to daily_reports_url, notice: 'Daily report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @showtime.destroy\n respond_to do |format|\n format.html { redirect_to showtimes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @timelog = Laptimelog.find(params[:id])\n @timelog.destroy\n\n respond_to do |format|\n format.html { redirect_to timelogs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @daily_report.destroy\n respond_to do |format|\n format.html { redirect_to admin_daily_reports_url, notice: 'Daily report was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recorded_time.destroy\n respond_to do |format|\n format.html { redirect_to recorded_times_url, notice: 'Recorded time was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @time_record = TimeRecord.find(params[:id])\n @time_record.destroy\n\n respond_to do |format|\n format.html { redirect_to time_records_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tee_time.destroy\n respond_to do |format|\n format.html { redirect_to root_url}\n format.json { head :no_content }\n end\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
shims from Blacklight 6 controller fetch to BL 7 search service
|
def search_service
Blacklight::SearchService.new(config: blacklight_config, user_params: {})
end
|
[
"def search_service\n Dcv::SearchService.new(config: blacklight_config, user_params: {})\n end",
"def search\r\n SearchController.instance\r\n end",
"def search\n SearchController.instance\n end",
"def search_service_context\n {}\n end",
"def search_model\n end",
"def fetch_data\n return @data if @data[\"/type/reflect/any_master\"]\n @data = Basuco.search.mqlread(define_query.merge!(:id => id))\n end",
"def search_api\n engine = requested_engine(SearchService)\n # noinspection RubyMismatchedReturnType\n engine ? SearchService.new(base_url: engine) : api_service(SearchService)\n end",
"def index \n @search = MobileClient.search(params[:q]) \n @mobile_clients = @search.result.page(params[:page]).per(current_user.list_page_size)\n @client_types = ['Android', 'WinMobile']\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @mobile_clients }\n end\n end",
"def classes_supported_by_rest_api\n [\n 'Search'\n ]\n end",
"def search\n status_not_acceptable && return unless accept_header?\n\n resource_type = params.permit(:resource_type)[:resource_type]&.downcase\n search_params = params.slice('family', 'given', 'telecom', 'email', 'subject', 'active',\n '_count', '_id')\n case resource_type\n when 'patient'\n return if doorkeeper_authorize!(\n :'user/Patient.read',\n :'user/Patient.*',\n :'system/Patient.read',\n :'system/Patient.*'\n )\n\n resources = search_patients(search_params)\n resource_type = 'Patient'\n when 'observation'\n return if doorkeeper_authorize!(\n :'user/Observation.read',\n :'system/Observation.read'\n )\n\n resources = search_laboratories(search_params) || []\n resource_type = 'Observation'\n when 'questionnaireresponse'\n return if doorkeeper_authorize!(\n :'user/QuestionnaireResponse.read',\n :'system/QuestionnaireResponse.read'\n )\n\n resources = search_assessments(search_params) || []\n resource_type = 'QuestionnaireResponse'\n else\n status_not_found && return\n end\n\n page_size = params.permit(:_count)[:_count].nil? ? 10 : params.permit(:_count)[:_count].to_i\n page_size = 500 if page_size > 500\n summary_mode = page_size.zero?\n page = params.permit(:page)[:page].to_i\n page = 1 if page.zero?\n results = []\n unless summary_mode || resources.blank?\n results = resources.paginate(per_page: page_size, page: page).collect do |r|\n FHIR::Bundle::Entry.new(fullUrl: full_url_helper(r.as_fhir), resource: r.as_fhir)\n end\n end\n\n # Construct bundle from search query\n bundle = FHIR::Bundle.new(\n id: SecureRandom.uuid,\n meta: FHIR::Meta.new(lastUpdated: DateTime.now.strftime('%FT%T%:z')),\n type: 'searchset',\n total: resources&.size || 0,\n link: summary_mode ? nil : bundle_search_links(page, page_size, resources, resource_type, search_params),\n entry: results\n )\n\n status_ok(bundle) && return\n rescue StandardError\n render json: operation_outcome_fatal.to_json, status: :internal_server_error\n end",
"def omdb_pull(search_key, search_val)\n\n result = Typhoeus.get(\"http://www.omdbapi.com/\", :params => {search_key => search_val})\n result = JSON.parse(result.body)\n result\n\nend",
"def software_search(opts={})\r\n Rakuten::Request.get(\"https://app.rakuten.co.jp/services/api/BooksSoftware/Search/20130522\", Rakuten::Api.merge(opts))\r\n end",
"def load_bills_search(query, enacted = true)\n query = URI.escape(query)\n params = {'query' => query}\n params['history.enacted'] = true if enacted\n @bills = process('bills', 'bills/search', params) \n end",
"def search\n Api.search_all_apis params[:postcode]\n end",
"def request_components; end",
"def autocomplete\r\n # table parameter must be defined. If not, get it from search parameter\r\n if params['table'].nil? && params['search'].match(/\\./)\r\n name = params['search'].split('.').first\r\n params['table'] = name.underscore\r\n end\r\n if params['table'].match('_control')\r\n # it must be at least logged on\r\n return render json: { label: t('drgcms.not_authorized') } unless dc_user_can(DcPermission::CAN_VIEW, 'dc_memory')\r\n else\r\n return render json: { label: t('drgcms.not_authorized') } unless dc_user_can(DcPermission::CAN_VIEW)\r\n end\r\n\r\n table = params['table'].classify.constantize\r\n input = params['input'].gsub(/\\(|\\)|\\[|\\]|\\{|\\|\\.|\\,}/, '')\r\n # call method in class if search parameter contains . This is for user defined searches\r\n a = if params['search'].match(/\\./)\r\n #method, additional_params = params['search'].split('.')\r\n #data = additional_params ? table.send(method, input, additional_params, self) : table.send(method, input)\r\n name, method = params['search'].split('.')\r\n data = table.send(method, input)\r\n data.map do |v|\r\n { label: v[0], value: v[0], id: (v[1] || v[0]).to_s }\r\n end\r\n # will search and return field_name defined in params['search']\r\n else\r\n table.where(params['search'] => /#{input}/i).limit(20).map do |v|\r\n { label: v[params['search']], value: v[params['search']], id: v.id.to_s }\r\n end\r\n end\r\n\r\n render json: a\r\nend",
"def search\n status_not_acceptable && return unless accept_header?\n\n resource_type = params.permit(:resource_type)[:resource_type]&.downcase\n search_params = params.slice('family', 'given', 'telecom', 'email', 'subject', 'active',\n '_count', '_id')\n case resource_type\n when 'patient'\n resources = search_patients(search_params)\n resource_type = 'Patient'\n when 'observation'\n resources = search_laboratories(search_params) || []\n resource_type = 'Observation'\n when 'questionnaireresponse'\n resources = search_assessments(search_params) || []\n resource_type = 'QuestionnaireResponse'\n else\n status_bad_request && return\n end\n\n page_size = params.permit(:_count)[:_count].nil? ? 10 : params.permit(:_count)[:_count].to_i\n page_size = 500 if page_size > 500\n summary_mode = page_size.zero?\n page = params.permit(:page)[:page].to_i\n page = 1 if page.zero?\n results = []\n unless summary_mode || resources.blank?\n results = resources.paginate(per_page: page_size, page: page).collect do |r|\n FHIR::Bundle::Entry.new(fullUrl: full_url_helper(r.as_fhir), resource: r.as_fhir)\n end\n end\n\n # Construct bundle from search query\n bundle = FHIR::Bundle.new(\n id: SecureRandom.uuid,\n meta: FHIR::Meta.new(lastUpdated: DateTime.now.strftime('%FT%T%:z')),\n type: 'searchset',\n total: resources&.size || 0,\n link: summary_mode ? nil : bundle_search_links(page, page_size, resources, resource_type, search_params),\n entry: results\n )\n\n status_ok(bundle) && return\n rescue StandardError\n render json: operation_outcome_fatal.to_json, status: :internal_server_error\n end",
"def index\n authorize KlasiusSrv\n @klasius_srvs = KlasiusSrv.order(:code).search(params[:search]).page(params[:page])\n end",
"def macro_search\n @cities_search = City.ransack(name_cont: params[:q]).result(distinct: true).limit(5)\n @users_search = User.ransack(name_cont: params[:q]).result(distinct: true).limit(6)\n respond_to do |format|\n format.json # Renders json for the macro_search.json.jbuilder file in views/searches folder\n format.html {\n flash[:alert] = \"Please select a search result from the dropdown\"\n redirect_to request.referrer\n }\n end \n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
:only=>[:edit, :index, :new, :show] GET /user_device_configurations GET /user_device_configurations.json
|
def index
@user_device_configurations = UserDeviceConfiguration.all
respond_to do |format|
format.html # index.html.erb
format.json { render json: @user_device_configurations }
end
end
|
[
"def show\n @user_device_configuration = UserDeviceConfiguration.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user_device_configuration }\n end\n end",
"def show\n render json: @device_configuration.to_json\n end",
"def new\n @user_device_configuration = UserDeviceConfiguration.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user_device_configuration }\n end\n end",
"def index\n @device_configurations = DeviceConfiguration.all.order(:id)\n render json: @device_configurations.to_json\n end",
"def index\n @user_config = current_user.conf\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @user_configs }\n end\n end",
"def show\n @user_config = UserConfig.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user_config }\n end\n end",
"def update\n if !current_user.manager?\n head :forbidden\n else\n if @device_configuration.update(device_configuration_params)\n render json: @device_configuration.to_json, status: :ok\n else\n render json: @device_configuration.errors, status: :unprocessable_entity\n end\n end\n end",
"def show\n #@config_file = ConfigFile.find(params[:id])\n @config_file = current_user.developer.config_files.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @config_file }\n end\n end",
"def device_configurations=(value)\n @device_configurations = value\n end",
"def show\n @setting_device = SettingDevice.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @setting_device }\n end\n end",
"def update\n @user_device_configuration = UserDeviceConfiguration.find(params[:id])\n\n respond_to do |format|\n if @user_device_configuration.update_attributes(params[:user_device_configuration])\n format.html { redirect_to @user_device_configuration, notice: 'User device configuration was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user_device_configuration.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @api_v1_user_device_infos = Api::V1::UserDeviceInfo.all\n end",
"def create\n if !current_user.manager?\n head :forbidden\n else\n @device_configuration = DeviceConfiguration.new(device_configuration_params)\n device = Device.find(params[:device_id])\n @device_configuration.device_type = device.device_type\n if @device_configuration.save\n device.update(device_configuration_id: @device_configuration.id)\n render json: @device_configuration.to_json, status: :created\n else\n render json: @device_configuration.errors, status: :unprocessable_entity\n end\n end\n end",
"def get_resource_configurations(user_id)\n []\n end",
"def device_configurations\n return @device_configurations\n end",
"def show\n @my_configuration = MyConfiguration.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @my_configuration }\n end\n end",
"def show\n @device_config = DeviceConfig.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.xml { render :xml => @device_config }\n end\n end",
"def create\n @user_device_configuration = UserDeviceConfiguration.new(params[:user_device_configuration])\n\n respond_to do |format|\n if @user_device_configuration.save\n format.html { redirect_to @user_device_configuration, notice: 'User device configuration was successfully created.' }\n format.json { render json: @user_device_configuration, status: :created, location: @user_device_configuration }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user_device_configuration.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @admin_config = Admin::Config.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @admin_config }\n end\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
GET /user_device_configurations/1 GET /user_device_configurations/1.json
|
def show
@user_device_configuration = UserDeviceConfiguration.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @user_device_configuration }
end
end
|
[
"def index\n @user_device_configurations = UserDeviceConfiguration.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @user_device_configurations }\n end\n end",
"def show\n render json: @device_configuration.to_json\n end",
"def get_resource_configurations(user_id)\n []\n end",
"def index\n @device_configurations = DeviceConfiguration.all.order(:id)\n render json: @device_configurations.to_json\n end",
"def device_configurations=(value)\n @device_configurations = value\n end",
"def new\n @user_device_configuration = UserDeviceConfiguration.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user_device_configuration }\n end\n end",
"def device_configurations\n return @device_configurations\n end",
"def _get_config(key)\n data = @client.session.get_device_config @device.id, key\n JSON.parse(base64.b64decode(data).decode('utf8'))\n end",
"def index\n @user_config = current_user.conf\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @user_configs }\n end\n end",
"def show\n @user_config = UserConfig.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user_config }\n end\n end",
"def index\n @api_v1_user_device_infos = Api::V1::UserDeviceInfo.all\n end",
"def client_config\r\n JSON.parse(api_get('Configurations.egg', 'IphoneClient').body)\r\n end",
"def device_configurations()\n return MicrosoftGraph::DeviceManagement::DeviceConfigurations::DeviceConfigurationsRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def devices(user_id: '-')\n return get(\"#{API_URI}/#{DEVICES_API_VERSION}/user/#{user_id}/devices.json\")\n end",
"def get_resource_configurations(user_id)\n PrivateMachineCredentials.where(user_id: user_id).map do |credentials|\n {name: short_name.to_sym, params: {credentials_id: credentials.id.to_s}}\n end\n end",
"def get_profile_configuration(args = {}) \n get(\"/profiles.json/#{args[:profileId]}/configuration\", args)\nend",
"def get_resource_configurations(user_id)\n instance_types_list = instance_types.map { |type, _| type }\n image_secrets_ids = CloudImageSecrets\n .find_all_by_query(user_id: user_id, cloud_name: self.class.short_name.to_s)\n .map { |i| i.id }\n\n instance_types_list.flat_map do |instance_type|\n image_secrets_ids.flat_map do |image_secret_id|\n {name: self.class.short_name.to_sym, params: {image_secrets_id: image_secret_id, instance_type: instance_type}}\n end\n end\n end",
"def device_configuration\n return @device_configuration\n end",
"def retrieve_system_configuration()\n start.uri('/api/system-configuration')\n .get()\n .go()\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
GET /user_device_configurations/new GET /user_device_configurations/new.json
|
def new
@user_device_configuration = UserDeviceConfiguration.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @user_device_configuration }
end
end
|
[
"def create\n @user_device_configuration = UserDeviceConfiguration.new(params[:user_device_configuration])\n\n respond_to do |format|\n if @user_device_configuration.save\n format.html { redirect_to @user_device_configuration, notice: 'User device configuration was successfully created.' }\n format.json { render json: @user_device_configuration, status: :created, location: @user_device_configuration }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user_device_configuration.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n if !current_user.manager?\n head :forbidden\n else\n @device_configuration = DeviceConfiguration.new(device_configuration_params)\n device = Device.find(params[:device_id])\n @device_configuration.device_type = device.device_type\n if @device_configuration.save\n device.update(device_configuration_id: @device_configuration.id)\n render json: @device_configuration.to_json, status: :created\n else\n render json: @device_configuration.errors, status: :unprocessable_entity\n end\n end\n end",
"def new\n @user_config = UserConfig.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user_config }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @system_configuration }\n end\n end",
"def new\n @user_device = UserDevice.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user_device }\n end\n end",
"def new\n @system_configuration = SystemConfiguration.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @system_configuration }\n end\n end",
"def create\n @user_config = UserConfig.new(params[:user_config])\n\n respond_to do |format|\n if @user_config.save\n format.html { redirect_to @user_config, notice: 'User config was successfully created.' }\n format.json { render json: @user_config, status: :created, location: @user_config }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user_config.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @device_user = DeviceUser.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @device_user }\n end\n end",
"def new\n @setting_device = SettingDevice.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @setting_device }\n end\n end",
"def new\n @device = Device.new\n\n render json: @device\n end",
"def new\n @system_config = SystemConfig.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @system_config }\n end\n end",
"def new\n @my_configuration = MyConfiguration.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @my_configuration }\n end\n end",
"def new\n @sys_configuration = SysConfiguration.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sys_configuration }\n end\n end",
"def new\n @install_tracking_device_user = InstallTracking::DeviceUser.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @install_tracking_device_user }\n end\n end",
"def new\n @device_config = DeviceConfig.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @device_config }\n end\n end",
"def new\n @device = Device.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @device }\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 @configtable = Configtable.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @configtable }\n end\n end",
"def create\n @graphium_configuration = Graphium::Configuration.new(graphium_configuration_params)\n\n respond_to do |format|\n if @graphium_configuration.save\n format.html { redirect_to @graphium_configuration, notice: 'Configuration was successfully created.' }\n format.json { render :show, status: :created, location: @graphium_configuration }\n else\n format.html { render :new }\n format.json { render json: @graphium_configuration.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
POST /user_device_configurations POST /user_device_configurations.json
|
def create
@user_device_configuration = UserDeviceConfiguration.new(params[:user_device_configuration])
respond_to do |format|
if @user_device_configuration.save
format.html { redirect_to @user_device_configuration, notice: 'User device configuration was successfully created.' }
format.json { render json: @user_device_configuration, status: :created, location: @user_device_configuration }
else
format.html { render action: "new" }
format.json { render json: @user_device_configuration.errors, status: :unprocessable_entity }
end
end
end
|
[
"def create\n if !current_user.manager?\n head :forbidden\n else\n @device_configuration = DeviceConfiguration.new(device_configuration_params)\n device = Device.find(params[:device_id])\n @device_configuration.device_type = device.device_type\n if @device_configuration.save\n device.update(device_configuration_id: @device_configuration.id)\n render json: @device_configuration.to_json, status: :created\n else\n render json: @device_configuration.errors, status: :unprocessable_entity\n end\n end\n end",
"def device_configurations=(value)\n @device_configurations = value\n end",
"def new\n @user_device_configuration = UserDeviceConfiguration.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user_device_configuration }\n end\n end",
"def index\n @user_device_configurations = UserDeviceConfiguration.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @user_device_configurations }\n end\n end",
"def create\n # No permite registrar nada si el usuario ya creo su configuración\n @userconfig = current_user.build_userconfig(userconfig_params) unless current_user.userconfig\n\n respond_to do |format|\n if !@userconfig.nil? and @userconfig.save\n format.html { redirect_to taskstorages_path, notice: \"Userconfig was successfully created.\" }\n format.json { render :show, status: :created, location: taskstorages_path }\n else\n @userconfig = Userconfig.new\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: taskstorages_path.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user_config = UserConfig.new(params[:user_config])\n\n respond_to do |format|\n if @user_config.save\n format.html { redirect_to @user_config, notice: 'User config was successfully created.' }\n format.json { render json: @user_config, status: :created, location: @user_config }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user_config.errors, status: :unprocessable_entity }\n end\n end\n end",
"def device_configuration=(value)\n @device_configuration = value\n end",
"def update\n if !current_user.manager?\n head :forbidden\n else\n if @device_configuration.update(device_configuration_params)\n render json: @device_configuration.to_json, status: :ok\n else\n render json: @device_configuration.errors, status: :unprocessable_entity\n end\n end\n end",
"def device_enrollment_configurations=(value)\n @device_enrollment_configurations = value\n end",
"def create\n @api_v1_user_device_info = Api::V1::UserDeviceInfo.new(api_v1_user_device_info_params)\n\n respond_to do |format|\n if @api_v1_user_device_info.save\n format.html { redirect_to @api_v1_user_device_info, notice: 'User device info was successfully created.' }\n format.json { render :show, status: :created, location: @api_v1_user_device_info }\n else\n format.html { render :new }\n format.json { render json: @api_v1_user_device_info.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @device = @user.devices.new(device_params)\n\n respond_to do |format|\n if @device.save\n format.html { redirect_to user_devices_path(@user), notice: 'Device was successfully added.' }\n format.json { render :show, status: :created, location: @device }\n else\n format.html { render :new }\n format.json { render json: @device.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @users_device = UsersDevice.new(users_device_params)\n\n respond_to do |format|\n if @users_device.save\n format.html { redirect_to @users_device, notice: 'Users device was successfully created.' }\n format.json { render action: 'show', status: :created, location: @users_device }\n else\n format.html { render action: 'new' }\n format.json { render json: @users_device.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @user_device = UserDevice.new(params[:user_device])\n\n respond_to do |format|\n if @user_device.save\n format.html { redirect_to @user_device, notice: 'User device was successfully created.' }\n format.json { render json: @user_device, status: :created, location: @user_device }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user_device.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @user_device_configuration = UserDeviceConfiguration.find(params[:id])\n\n respond_to do |format|\n if @user_device_configuration.update_attributes(params[:user_device_configuration])\n format.html { redirect_to @user_device_configuration, notice: 'User device configuration was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @user_device_configuration.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @user_device_configuration = UserDeviceConfiguration.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user_device_configuration }\n end\n end",
"def mobile_app_configurations=(value)\n @mobile_app_configurations = value\n end",
"def device_configurations()\n return MicrosoftGraph::DeviceManagement::DeviceConfigurations::DeviceConfigurationsRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def destroy\n @user_device_configuration = UserDeviceConfiguration.find(params[:id])\n @user_device_configuration.destroy\n\n respond_to do |format|\n format.html { redirect_to user_device_configurations_url }\n format.json { head :ok }\n end\n end",
"def device_configurations\n return @device_configurations\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
PUT /user_device_configurations/1 PUT /user_device_configurations/1.json
|
def update
@user_device_configuration = UserDeviceConfiguration.find(params[:id])
respond_to do |format|
if @user_device_configuration.update_attributes(params[:user_device_configuration])
format.html { redirect_to @user_device_configuration, notice: 'User device configuration was successfully updated.' }
format.json { head :ok }
else
format.html { render action: "edit" }
format.json { render json: @user_device_configuration.errors, status: :unprocessable_entity }
end
end
end
|
[
"def update\n if !current_user.manager?\n head :forbidden\n else\n if @device_configuration.update(device_configuration_params)\n render json: @device_configuration.to_json, status: :ok\n else\n render json: @device_configuration.errors, status: :unprocessable_entity\n end\n end\n end",
"def device_configurations=(value)\n @device_configurations = value\n end",
"def create\n if !current_user.manager?\n head :forbidden\n else\n @device_configuration = DeviceConfiguration.new(device_configuration_params)\n device = Device.find(params[:device_id])\n @device_configuration.device_type = device.device_type\n if @device_configuration.save\n device.update(device_configuration_id: @device_configuration.id)\n render json: @device_configuration.to_json, status: :created\n else\n render json: @device_configuration.errors, status: :unprocessable_entity\n end\n end\n end",
"def create\n @user_device_configuration = UserDeviceConfiguration.new(params[:user_device_configuration])\n\n respond_to do |format|\n if @user_device_configuration.save\n format.html { redirect_to @user_device_configuration, notice: 'User device configuration was successfully created.' }\n format.json { render json: @user_device_configuration, status: :created, location: @user_device_configuration }\n else\n format.html { render action: \"new\" }\n format.json { render json: @user_device_configuration.errors, status: :unprocessable_entity }\n end\n end\n end",
"def device_configuration=(value)\n @device_configuration = value\n end",
"def update\n respond_to do |format|\n if @api_v1_user_device_info.update(api_v1_user_device_info_params)\n format.html { redirect_to @api_v1_user_device_info, notice: 'User device info was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_v1_user_device_info }\n else\n format.html { render :edit }\n format.json { render json: @api_v1_user_device_info.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @user_device_configuration = UserDeviceConfiguration.find(params[:id])\n @user_device_configuration.destroy\n\n respond_to do |format|\n format.html { redirect_to user_device_configurations_url }\n format.json { head :ok }\n end\n end",
"def update\n respond_to do |format|\n if @userconfig.update(userconfig_params)\n format.html { redirect_to taskstorages_path, notice: \"Userconfig was successfully updated.\" }\n format.json { render :show, status: :ok, location: taskstorages_path }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: taskstorages_path.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @device.update(device_params)\n head :no_content\n end",
"def update\n @device_config = DeviceConfig.find(params[:id])\n\n respond_to do |format|\n if @device_config.update_attributes(params[:device_config])\n flash[:notice] = 'DeviceConfig was successfully updated.'\n format.html { redirect_to(@device_config) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @device_config.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def show\n @user_device_configuration = UserDeviceConfiguration.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @user_device_configuration }\n end\n end",
"def create_or_update_profile_configuration(args = {}) \n id = args['profileId']\n temp_path = \"/profiles.json/{profileId}/configuration\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"profileId\")\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\n respond_to do |format|\n if @users_device.update(users_device_params)\n format.html { redirect_to @users_device, notice: 'Users device was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @users_device.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @user_device_configuration = UserDeviceConfiguration.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @user_device_configuration }\n end\n end",
"def update\n respond_to do |format|\n if @device.update(device_params)\n format.json { head :no_content }\n else\n format.json { render json: {errors: @device.errors}, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @user_device_configurations = UserDeviceConfiguration.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @user_device_configurations }\n end\n end",
"def update\n @device_config = Probe::DeviceConfig.find(params[:id])\n\n respond_to do |format|\n if @device_config.update_attributes(params[:device_config])\n flash[:notice] = 'Probe::DeviceConfig.was successfully updated.'\n format.html { redirect_to(@device_config) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @device_config.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @device = Device.find(params[:id])\n\n if @device.update(device_params)\n head :no_content\n else\n render json: @device.errors, status: :unprocessable_entity\n end\n end",
"def update\n respond_to do |format|\n if @app_configuration.update(app_configuration_params)\n format.html { redirect_to @app_configuration, notice: 'App configuration was successfully updated.' }\n format.json { render :show, status: :ok, location: @app_configuration }\n else\n format.html { render :edit }\n format.json { render json: @app_configuration.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
DELETE /user_device_configurations/1 DELETE /user_device_configurations/1.json
|
def destroy
@user_device_configuration = UserDeviceConfiguration.find(params[:id])
@user_device_configuration.destroy
respond_to do |format|
format.html { redirect_to user_device_configurations_url }
format.json { head :ok }
end
end
|
[
"def destroy\n @user_config = UserConfig.find(params[:id])\n @user_config.destroy\n\n respond_to do |format|\n format.html { redirect_to user_configs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @graphium_configuration.destroy\n respond_to do |format|\n format.html { redirect_to graphium_configurations_url, notice: 'Configuration was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @device_config = Probe::DeviceConfig.find(params[:id])\n @device_config.destroy\n\n respond_to do |format|\n format.html { redirect_to(device_configs_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @user_conf = UserConf.find(params[:id])\n @user_conf.destroy\n\n respond_to do |format|\n format.html { redirect_to user_confs_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @my_configuration = MyConfiguration.find(params[:id])\n @my_configuration.destroy\n\n respond_to do |format|\n format.html { redirect_to my_configurations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @gpu_conf.destroy\n respond_to do |format|\n format.html { redirect_to gpu_confs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @userconfig.destroy\n respond_to do |format|\n format.html { redirect_to userconfigs_url, notice: \"Userconfig was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @api_v1_user_device_info.destroy\n respond_to do |format|\n format.html { redirect_to api_v1_user_device_infos_url, notice: 'User device info was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @user_device = UserDevice.find(params[:id])\n @user_device.destroy\n\n respond_to do |format|\n format.html { redirect_to user_devices_url }\n format.json { head :no_content }\n end\n end",
"def removeDevice deviceId\n options = { 'device' => deviceId }\n post REMOVE_DEVICE, options\n end",
"def destroy\n conf.delete 'api'\n end",
"def destroy\n @app_configuration.destroy\n respond_to do |format|\n format.html { redirect_to app_configurations_url, notice: 'App configuration was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @configuration_key.destroy\n respond_to do |format|\n format.html { redirect_to configuration_keys_url }\n format.json { head :no_content }\n end\n end",
"def delete\n client.delete_launch_configuration(resource_options)\n nil\n end",
"def destroy\n @users_device.destroy\n respond_to do |format|\n format.html { redirect_to users_devices_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @otg_config.destroy\n respond_to do |format|\n format.html { redirect_to otg_configs_url, notice: 'Otg config was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @system_configuration = SystemConfiguration.find(params[:id])\n @system_configuration.destroy\n\n respond_to do |format|\n format.html { redirect_to system_configurations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @app_config = AppConfig.find(params[:id])\n @app_config.destroy\n\n respond_to do |format|\n format.html { redirect_to app_configs_url }\n format.json { head :no_content }\n end\n end",
"def delete\n Device.find(params[:device_id]).destroy\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Save output to the output file (one paragraph per line). Include additional HTML and CSS if attr additional_html = true
|
def save_to_file
File.open(@output, 'w+') do |file|
file.puts HEADER if @additional_html
file.puts @data_for_output.join("\n")
file.puts FOOTER if @additional_html
end
end
|
[
"def write_html(html)\n File.open(\"assignment02-output.html\", \"w\") do |file|\n file.write html\n end\n end",
"def save(path)\n File.open(path, \"w\") { |outfile| outfile.print self.render }\n end",
"def output(contents, filename = \"output.html\")\n out_file = File.new(filename, \"w\")\n out_file.puts(contents)\n out_file.close\n end",
"def write_to_html filename = \"#{title}.html\", options = {}\n File.open(filename, \"w\") { |f| f.write(to_html(options)) }\n filename\n end",
"def writeWebPage\n File.open(@dest, \"w\") do |output|\n @out = output\n @out.puts @@templatefront\n writeHtmlBody\n @out.puts @@templateend\n end\n end",
"def save_output(content, dir, file='index.html')\n open(\"#{dir}/#{file}\", \"w\") do |f|\n f.puts content\n end\n end",
"def write_html_to(io, options = {})\n write_format_to(SaveOptions::DEFAULT_HTML, io, options)\n end",
"def finish_html_file\n @htmllogfile.puts <<-HTML\n </table>\n </body>\n</html>\n HTML\n end",
"def write(data)\n begin\n File.open(@filename, \"w\") { |file| file.puts data.to_html }\n rescue \n puts \"Error: \" + $!.to_s\n end \n end",
"def to_html_file( html_file )\n\n File.open( html_file, 'w') do |f|\n f << to_html()\n end\n end",
"def save\n receipt = File.new(@save_path, 'w')\n receipt.write(render)\n receipt.close\n end",
"def save\n File.open(@output_file, 'w') {|f| f.write(@snippet_xml) }\n end",
"def save(file)\n File.open(file, 'w') { |file| render(WizRtf::RtfIO.new(file)) }\n end",
"def html_report!(file)\n puts \"Generating output to #{file}\"\n\n Html.new(events_query).save!(file)\n end",
"def html\n File.open(@outfile).read\n end",
"def write_html_file(name, type, html)\n if ENV['WRITE_HTML_FILE'] != 'false'\n file_name = \"#{File.dirname(__FILE__)}/results/#{name.gsub('.xml', '')}-#{Time.now.strftime(\"%d%b\")}_#{type}.html\"\n file = File.open(file_name, 'w+')\n file.puts html\n file.close\n end\nend",
"def export_txt\n if !File.directory?(\"#{Rails.root}/tmp/txt/\") \n Dir.mkdir(Rails.root.join('tmp/txt'))\n end\n\n txt_directory = \"#{Rails.root}/tmp/txt/#{self.id}.txt\"\n txt = \"\"\n\n txt = txt + (HTMLEntities.new.decode ActionView::Base.full_sanitizer.sanitize(self.description)) + \"\\n \\n\"\n\n self.steps.not_labels.order(\"published_on\").each do |step|\n if step.description.present?\n # add step description\n txt = txt + (HTMLEntities.new.decode ActionView::Base.full_sanitizer.sanitize(step.description)) + \"\\n \\n\"\n end\n end\n File.open(txt_directory, 'w') do |f|\n f.puts txt\n end\n end",
"def add_html_output_options(opt)\n end",
"def print_to_output(text)\n if Object.const_defined?('Shamus')\n asset = Shamus.current.current_step.add_inline_asset('.txt', Shamus::Cucumber::InlineAssets::RENDER_AS_TEXT)\n File.open(asset, 'w') { |f| f.puts(\"#{text}\") }\n end\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Actions for Fulfillment Rights subform
|
def add_fulfillment_rights_row
@organization = Organization.find(params[:organization_id])
@new_fr_identity = Identity.find_or_create(params[:new_fr_identity_id])
@fulfillment_rights = fulfillment_rights(@organization_id)
set_registrar_enabled(@organization)
end
|
[
"def claim_form\n end",
"def single_item_action_form_fields(form, document, action)\n render '/collections/single_item_action_fields', form: form, document: document, action: action\n end",
"def reseller_allow_edit(permission)\n return reseller_right(permission) == 2\n end",
"def authorize_edit_parent_rights!\n authorize! :edit, parent_id\n end",
"def update\n # this action is not provided for partyroles\n end",
"def single_item_action_form_fields(form, document, action)\n render 'hyrax/dashboard/collections/single_item_action_fields', form: form, document: document, action: action\n end",
"def edit\n authorize! :update, @grading_level1\n end",
"def update_access_controls!\n update!(edit_users: permission_template.agent_ids_for(access: 'manage', agent_type: 'user'),\n edit_groups: permission_template.agent_ids_for(access: 'manage', agent_type: 'group'))\n end",
"def edit\n authorize! :update, @elective_group\n end",
"def create\n @company = Company.find(params[:company_id])\n @role = Role.find(params[:role_id])\n access_right_hash = params[:access_right]\n \n if current_user.super_admin\n is_ok = true\n else\n current_user.roles.each { |r|\n r.access_rights.each { |ar|\n puts access_right_hash['model_name']\n if ar.model_name == access_right_hash['model_name'] && ar.action == access_right_hash['action']\n is_ok = true\n end\n }\n }\n end\n \n respond_to do |format|\n if is_ok\n @access_right = @role.access_rights.create(params[:access_right])\n @access_right.company_id = current_user.company_id\n @access_right.save\n format.html { redirect_to company_role_path(@company, @role) }\n else\n format.html { redirect_to company_role_path(@company, @role), notice: 'Usted no puede conceder este permiso.' }\n end\n end\n end",
"def edit\n authorize @goal\n end",
"def permissions\n frm.link(:text=>\"Permissions\").click\n AssignmentsPermissions.new(@browser)\n end",
"def rbac_role_set_form_vars\n @edit = {}\n @edit[:role_id] = @record.id if @sb[:typ] != \"copy\"\n @edit[:new] = {}\n @edit[:current] = {}\n @edit[:key] = \"rbac_role_edit__#{@edit[:role_id] || \"new\"}\"\n\n @edit[:new][:name] = @record.name\n vmr = @record.settings.fetch_path(:restrictions, :vms) if @record.settings\n @edit[:new][:vm_restriction] = vmr || :none\n str = @record.settings.fetch_path(:restrictions, :service_templates) if @record.settings\n @edit[:new][:service_template_restriction] = str || :none\n @edit[:new][:features] = rbac_expand_features(@record.miq_product_features.map(&:identifier)).sort\n\n @edit[:current] = copy_hash(@edit[:new])\n\n @role_features = @edit[:new][:features]\n @rbac_menu_tree = build_rbac_feature_tree\n\n @right_cell_text = if @edit[:role_id]\n _(\"Editing Role \\\"%{name}\\\"\") % {:name => @record.name}\n else\n _('Adding a new Role')\n end\n end",
"def campus_patron_permissions\n end",
"def edit\n # Make sure admission cannot be edited indirectly\n # Only: under admitted and scheduled\n if !@admission.discharged? && (@admission.admitted? || @admission.scheduled?)\n render(:edit)\n else\n flash.now[:alert] = 'This admission cannot be edited.'\n redirect_to(request.referrer || root_path)\n end\n end",
"def discovery_permissions\n if params[:owner]==\"mine\"\n [\"edit\"]\n else\n super\n end\n end",
"def discovery_permissions\n if params[:owner]==\"mine\"\n [\"edit\"]\n else\n super\n end\n end",
"def grant_rights_for rights_hash\n current_rights.merge! rights_hash\n end",
"def check_user_form_authorization\n @action = if action_name == 'new'\n 'create'\n elsif ['update', 'destroy'].include? action_name \n 'edit'\n else\n action_name\n end\n redirect_to main_app.root_path unless (instance_variable_get \"@forms_to_#{@action}\").include? @custom_form\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Temporarily merges the migration files by copying them over and then deletes them. Sequel's migration class cannot work with migrations in different directories even if sequelrails can. This is the simplest solution that works until ::Sequel::Migrator supports merging of multiple migration directories.
|
def temporarily_merge_migration_files(explanation=nil)
copy_files = []
Rails.application.config.paths["db/migrate"].expanded.each do |specified_migration_dir|
if migrations_dir.to_s != specified_migration_dir
Dir[File.join(specified_migration_dir, '*')].each do |file_name|
copy_files.push([file_name, migrations_dir.join(File.basename(file_name)).to_s])
end
end
end
if explanation && copy_files.any?
puts "SequelRails: Detected migration files outside of the main db/migrate directory. Copying them to db/migrate temporarily to #{explanation}:"
copy_files.each { |o, _| puts " - #{o}"}
end
copy_files.each { |original, destination| FileUtils.cp(original, destination) }
yield
ensure
copy_files.each { |_, destination| FileUtils.rm_f(destination) }
end
|
[
"def update_migration_files\n migration_templates = Dir.children(File.join(TEMPLATES, 'migrations')).sort\n migration_templates.each do |template_file|\n destination_file = template_file.match(/^\\d*_(.*\\.rb)/)[1] # 01_create_good_jobs.rb.erb => create_good_jobs.rb\n migration_template \"migrations/#{template_file}\", File.join(db_migrate_path, destination_file), skip: true\n end\n end",
"def migrate\n self.class.pending_migration_files.each do |file|\n # clear migrations array before loading\n @migrations = nil\n # load last migration for rollback\n load file\n # migration class will be loaded to @migrations\n migration = @migrations.last\n next unless migration\n\n # apply migration if can be rolled UP\n if migration.can_rollup?\n Sequel::Model.db.transaction(savepoint: true) {\n migration.up.apply\n report_with.applied(migration)\n }\n end\n # create log entry in data migrations table\n TradeTariffBackend::DataMigration::LogEntry.log!(file)\n end\n end",
"def copy_migration_files\n # Copy migration files except when you pass --no-migrations.\n return if no_migrations?\n\n migration_template \"migration/core.rb\", \"db/migrate/sorcery_core.rb\"\n\n if submodules\n submodules.each do |submodule|\n unless submodule == \"http_basic_auth\" || submodule == \"session_timeout\" || submodule == \"core\"\n migration_template \"migration/#{submodule}.rb\", \"db/migrate/sorcery_#{submodule}.rb\"\n end\n end\n end \n end",
"def remove_schema_migration_files\n (untracked_schema_migrations + committed_schema_migrations).each do |schema_migration|\n FileUtils.rm(schema_migration)\n end\n end",
"def fix_skel_migrations(skel_dir = File.dirname(__FILE__) + '/../skel')\n # expect, remove and modify need to be fixed, add doesn't\n for verb in %w(expect remove modify)\n skel_targets(skel_dir, verb, '/db/migrate') do |src_file, target_file|\n pattern = target_file.sub(/\\d{14}/, '*')\n matches = Dir.glob(pattern)\n raise FileNotFound, pattern if matches.empty?\n raise AmbiguousMigration, matches.inspect if matches.size > 1\n File.rename(matches.first, target_file)\n end\n end\n end",
"def migrate_to_new_file_structure!\n gas_directory = File.expand_path '~/.gas'\n old_gas_users_filename = 'gas.authors'\n gas_users_filename = 'users'\n\n oldest_config_file = File.expand_path '~/.gas'\n old_config_file = File.join gas_directory, old_gas_users_filename\n new_config_file = File.join gas_directory, gas_users_filename\n\n # Check for first structure\n if File.file? oldest_config_file\n contents = File.read oldest_config_file\n\n File.delete oldest_config_file\n Dir::mkdir(gas_directory)\n\n file = File.new(old_config_file, \"w\")\n file.puts contents\n file.close\n end\n\n # Check for second structure\n if File.file? old_config_file\n FileUtils.mv old_config_file, File.join(gas_directory, gas_users_filename)\n end\nend",
"def copy_templates\n migrations_to_be_applied do |m|\n migration_template \"#{m}.rb\", \"db/migrate/#{m}.rb\"\n end\n end",
"def remove_moved_files\n scan_for_merges.each do |file|\n if File.amp_lexist?(@repo.working_join(file))\n UI.debug(\"removing #{file}\")\n File.unlink(@repo.working_join(file))\n end\n end\n end",
"def initial_migration\n apartment_copy_path = 'init/apartment.rb'\n apartment_path = 'Pearlception/config/initializers/apartment.rb'\n FileUtils.cp(apartment_path, 'init/apartment_copy' ) #Copy the original file back\n FileUtils.rm(apartment_path) #Remove the original file\n FileUtils.cp(apartment_copy_path,apartment_path) #Copy the blank copy into init\n Dir.chdir('Pearlception') do \n puts `rake db:setup`\n puts `rake db:migrate` #Run the migration\n end\n FileUtils.rm(apartment_path) #Remove the blank copy\n FileUtils.cp('init/apartment_copy',apartment_path)\n FileUtils.rm('init/apartment_copy')\nend",
"def delete_migrations\n migrations.each_child(&:delete)\n end",
"def append_migrations\n initializer :append_migrations do |app|\n unless app.root.to_s.match root.to_s\n config.paths['db/migrate'].expanded.each do |path|\n app.config.paths['db/migrate'] << path\n ActiveRecord::Migrator.migrations_paths << path\n end\n end\n end\n end",
"def unhide_migrations\n error = nil\n\n MIGRATION_DIRS.each do |dir|\n File.rename(\"#{dir}__\", dir)\n rescue Errno::ENOENT\n nil\n rescue StandardError => e\n # Save error for later, but continue with other dirs first\n error = e\n end\n\n raise error if error\n end",
"def create_migrations_file\n # Stop if the migrations file exists\n return if test \"[[ -f #{shared_path}/executed_migrations ]]\"\n\n # Create an empty executed_migrations file\n upload! StringIO.new(''), \"#{shared_path}/executed_migrations\"\n\n # If we just created the executed_migrations file, add all existing migrations\n execute_initial_migration\n end",
"def schema_migrations_cleanup\n # Read all schema_migrations values from the dump.\n values = dump.scan(/^(\\(\\'\\d{14}\\'\\))[,;]\\n/).flatten.sort\n\n # Replace the schema_migrations values.\n dump.sub!(\n /(?<=INSERT INTO \"schema_migrations\" \\(version\\) VALUES).+;\\n*/m,\n \"\\n #{values.join(\"\\n,\")}\\n;\\n\\n\"\n )\n end",
"def create_migrations_and_models\n src = \"#{@gem_path}/lib/modules/migrations\"\n dest = \"#{@target_dir}/db/migrate\"\n copy_files(src,dest,AUTH_MIGRATE)\n if @module_name == \"oauth\"\n copy_files(src,dest,OAUTH_MIGRATE)\n end\n src_path = \"#{@gem_path}/lib/modules/models\"\n dest_path = \"#{@target_dir}/app/models\" \n copy_files(src_path,dest_path,AUTH_MODELS)\n if @module_name == \"oauth\"\n copy_files(src_path,dest_path,OAUTH_MODELS)\n end\n end",
"def rollback(step = 1)\n files = File.migrated.reverse.first(step)\n Migrate::Down.new(files).perform\n end",
"def migrate!\n @logger.fine('Dropping schema...')\n\n migrate(0) # migrate to version 0.\n migrate # migrate to latest version.\n end",
"def prepare_to_migrate\n if active_table_name != base_table_name\n connection.execute( \"truncate table #{base_table_name}\" )\n connection.execute( \"insert into #{base_table_name} select * from #{active_table_name}\" )\n end\n suffixed_table_names.each do |stn|\n connection.execute( \"drop table if exists #{stn}\" )\n end\n connection.execute( \"drop table if exists #{switch_table_name}\" )\n end",
"def revert_database_config\n database_temp = @database + '.tmp'\n return unless File.exist?(database_temp)\n\n File.delete(@database) if File.exist?(@database)\n File.rename(database_temp, @database)\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Returns the Zlist to the list of comments for this config item.
|
def _zlist
@config.ffi_delegate.comments
end
|
[
"def comments\r\n return node_list(TYPE_COMMENT, nil)\r\n end",
"def comments\n get_ticket_property_list(\"comments\" , Unfuddled::Comment)\n end",
"def comments\n return @comments\n end",
"def comments\n item.comments ? item.comments.strip : ''\n end",
"def comments\n @properties[\"C\"]\n end",
"def comments\n @comments = Resource.client.comments(self) if @comments.nil?\n @comments ||= []\n end",
"def comments\n [ comment, inline_comment ].compact\n end",
"def get_comments_list(comments, post)\n if comments.any?\n content_tag(:ul, :class => 'comments-list') do\n comments.collect do |h|\n concat(content_tag(:li, :class => 'comment') do\n concat(gravatar_image(h[:comment][:author_email]))\n concat(simple_format(h[:comment].comment, :class => 'comment-text'))\n concat(content_tag(:p ,{:class => 'comment-meta'}) do\n concat(['By %s' % h[:comment].author_name, h[:comment].created_at.strftime(global_settings.date_format)].join(', '))\n concat(link_to 'Reply to this comment', post_url(post.slug, :reply_to_comment => h[:comment].id) + '#post-comment-form', :class => 'reply-to')\n end)\n concat(get_comments_list(h[:children],post)) if h[:children].any?\n end)\n end\n end\n end\n end",
"def comments(options={})\n @comment_list ||= []\n return @comment_list if @comment_list.any?\n\n fetch_comments(options)\n end",
"def getComments\r\n\tend",
"def cached_comments\n Rails.cache.fetch([self, 'comments']) { comments.to_a }\n end",
"def order_comments\n end",
"def comments\n splitComments(@comments)\n end",
"def comments\n results = []\n return results unless @comments\n\n comment = ''\n @comments.split(\"\\n\").each do |line|\n if line =~ /^\\S/\n results << comment unless comment.empty?\n comment = line\n else\n comment += \"\\n\" + line\n end\n end\n\n results << comment unless comment.empty?\n return results\n end",
"def comment_list(list, base_indent='')\n commented_list = \"\"\n ids = list.split(/,/)\n ids.each do |id|\n id.gsub!(/\\s*$/, '')\n id.gsub!(/^\\s*/, '')\n list_id = \"#{id}\"\n list_id += ',' if id != ids.last\n id.gsub!(/\\=.*$/, '') \n id.gsub!(/\\[.*\\]/, '') \n id.gsub!(/\\s*$/, '')\n id.gsub!(/^\\s*/, '') \n id.gsub!(/;/, '') \n id.gsub!(/\\s*\\:\\s*\\d+/,'') \n doc_id = id.split(/\\s/).last\n doc_id.gsub!(/\\*/, '') \n commented_list += \"#{base_indent}\" if id != ids.first \n commented_list += \"#{@indent}\\t#{list_id} /**< <##{doc_id} description#> */\"\n commented_list += \"\\n\" if id != ids.last \n end\n commented_list \n end",
"def comments\n worksheet_comments.comments if worksheet_comments.has_comments?\n end",
"def comments\n Sifter.\n get(api_comments_url).\n fetch(\"comments\", []).\n map { |i| Sifter::Comment.new(i) }\n end",
"def comments\n request_str = \"/gallery/appliances/#{id.to_i}/comments\"\n response = GenericRequest.new(self.class.studio_connection).get request_str\n tree = XmlSimple.xml_in response, \"ForceArray\" => [\"comment\"]\n tree[\"appliance\"][\"comments\"][\"comment\"].collect do |c|\n Comment.parse(self,c)\n end\n end",
"def comments\n if @comment_feed.comments.nil?\n @comment_feed.fetch\n end\n\n @comment_feed.comments\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Last push button helper. push_job_class is FtpPushJob, RhnStagePushJob or RhnLivePushJob
|
def last_push_link(push_job_class, errata)
if (last_push = push_job_class.last_push(errata))
push_job_link(last_push, 'Last job')
end
end
|
[
"def last_push_link(push_job_class, errata)\n \"<a href='#'>Last job</a>\"\n end",
"def last_prepush_link(push_job_class, errata)\n jobs_since_respin = errata.push_jobs_since_last_state(push_job_class, 'NEW_FILES')\n if (job = jobs_since_respin.nochannel.order('id desc').first)\n push_job_link(job, 'Pre-push')\n end\n end",
"def push_history_link(push_job_class, errata)\n if push_job_class.for_errata(errata).any?\n workflow_action_link(\"Push History\", { :controller => 'push', :action => 'push_history_for_errata', :id => errata })\n end\n end",
"def get_push_job\n job = RhnLivePushJob.create!(:errata => @rhn_cdn_advisory, :pushed_by => releng_user)\n job.pub_options['push_metadata'] = true\n job.pub_options['push_files'] = true\n job\n end",
"def unsubmitted_push_job\n e = RHBA.push_ready.first\n RhnLivePushJob.create!(:errata => e, :pushed_by => User.system,\n :pub_options => {'push_files'=> true, 'push_metadata' => true})\n end",
"def job_ready_for_post_push_tasks\n pj = PushJob.find(37571)\n\n # Start with empty log, and ready to run tasks\n pj.update_attributes(:log => '', :status => 'POST_PUSH_PROCESSING')\n\n # Arbitrary realistic set of tasks\n pj.post_push_tasks = %w[update_jira move_pushed_errata request_translation\n update_push_count update_bugzilla]\n\n pj.save!\n\n pj\n end",
"def last_button\n last_ele button_class\n end",
"def default_job(klass, attributes)\n out = nil\n ActiveRecord::Base.transaction do\n out = klass.new(attributes)\n out.set_defaults\n # Must always have some associated pub task, otherwise the job\n # is considered to not have really performed a push, which\n # affects some logic.\n out.pub_task_id = PushJob.pluck('max(pub_task_id)').first + 100\n out.save!\n raise ActiveRecord::Rollback\n end\n out\n end",
"def to_s\n \"Push\"\n end",
"def has_pushed_since_last_respin?(type)\n jobs = push_jobs_since_last_state(type, 'NEW_FILES').where('pub_task_id is not null')\n jobs.reject(&:is_nochannel?).any?(&:is_committed?)\n end",
"def push_job_options_for_display(push_job)\n out = []\n\n add_label = lambda do |content, help|\n out << content_tag(:span, content, :class => 'label label-info',\n :title => help)\n end\n\n if push_job.is_nochannel?\n add_label['nochannel', NOCHANNEL_HELP]\n end\n\n if push_job.skip_pub_task_and_post_process_only?\n add_label['tasks-only', TASKS_ONLY_HELP]\n end\n\n options = push_job.pub_options\n if options['push_metadata'] && !options['push_files']\n add_label['metadata-only', METADATA_ONLY_HELP]\n end\n\n if out.empty?\n out << '-'\n end\n\n safe_join(out, ' ')\n end",
"def current_push\n Push.where(\"step is not null\").where(:user_id => current_user.id).all[0]\n end",
"def get_queue_url_by_class klass\n job_info = config[:jobs].select{ |k,v| v[:class] == klass.name}.first.last\n create_queue_url job_info[:queue_name]\n end",
"def last(queue=nil)\n job_or_raise send_request('last', {queue: queue||'default'})\n end",
"def last_submission\n submissions.last\n end",
"def push(notif)\n\n end",
"def execute\n if oldrev.nil? || newrev.nil? || ref.nil?\n raise \"Incorrect data\"\n end\n\n RequestStore.store[:current_user] = current_user # unless current_user.present?\n\n push = Push.new(project: project, user: current_user, revbefore: oldrev, revafter: newrev, ref: ref)\n push.fill_push_data\n push.save\n\n @push_data = push.data.dup\n @push_commits = push.commits.dup\n\n # For issue Feature #43932 add categories list to hook json\n @push_data[:repository][:categories] = project.categories.map {|c| c.name }\n\n create_push_event\n\n project.ensure_satellite_exists\n project.repository.expire_cache\n project.update_repository_size\n\n if push.to_existing_branch?\n project.update_merge_requests(oldrev, newrev, ref, @current_user)\n process_commit_messages(push)\n end\n\n if push.tag?\n project.execute_hooks(@push_data.dup, :tag_push_hooks)\n else\n Resque.enqueue(Elastic::RepositoryIndexer, push.id)\n project.execute_hooks(@push_data.dup, :push_hooks)\n end\n\n project.execute_services(@push_data.dup)\n\n if push.created_branch?\n # Re-find the pushed commits.\n if push.to_default_branch?\n # Initial push to the default branch. Take the full history of that branch as \"newly pushed\".\n @push_commits = project.repository.commits(newrev)\n else\n # Use the pushed commits that aren't reachable by the default branch\n # as a heuristic. This may include more commits than are actually pushed, but\n # that shouldn't matter because we check for existing cross-references later.\n @push_commits = project.repository.commits_between(project.default_branch, newrev)\n end\n\n process_commit_messages(push)\n end\n end",
"def lastCompletedBuild\n id = @msg.fetch(\"lastCompletedBuild\").fetch(\"number\")\n JobInstance.new(@jobname, id)\n end",
"def render_push_activity(activity)\n render_repo_activity(activity, \"pushed\")\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Shows link to last nochannel job, if any. This is represented to the user as a "prepush" of the live content
|
def last_prepush_link(push_job_class, errata)
jobs_since_respin = errata.push_jobs_since_last_state(push_job_class, 'NEW_FILES')
if (job = jobs_since_respin.nochannel.order('id desc').first)
push_job_link(job, 'Pre-push')
end
end
|
[
"def last_push_link(push_job_class, errata)\n \"<a href='#'>Last job</a>\"\n end",
"def last_push_link(push_job_class, errata)\n if (last_push = push_job_class.last_push(errata))\n push_job_link(last_push, 'Last job')\n end\n end",
"def push_history_link(push_job_class, errata)\n if push_job_class.for_errata(errata).any?\n workflow_action_link(\"Push History\", { :controller => 'push', :action => 'push_history_for_errata', :id => errata })\n end\n end",
"def tv_last_channel \n send_cmd(\"tv_last_channel\")\n end",
"def formatted_link\n host = ENV['HEROKU_APP_NAME'] ? \"#{ENV['HEROKU_APP_NAME']}.herokuapp.com\" : 'localhost:3000'\n \"<#{Rails.application.routes.url_helpers.thread_url(id, host: host, format: :json)}|this thread>\"\n end",
"def job_link(href)\n @in_job_url + href\n end",
"def unsubmitted_push_job\n e = RHBA.push_ready.first\n RhnLivePushJob.create!(:errata => e, :pushed_by => User.system,\n :pub_options => {'push_files'=> true, 'push_metadata' => true})\n end",
"def last_news\n limit = @opts[:limit] || 3\n entries = DcNews.only(:created_by_name, :link, :subject, :created_at)\n .where(active: true) \n .order_by(created_at: -1).limit(limit).to_a\n\n entries.inject('') do |result, element|\n result << @parent.link_to(\"/news/#{element.link}\") do \n %Q[<div>\n <span class=\"date\">#{@parent.dc_pretty_date(element.created_at)} : </span>\n <span class=\"title\">#{element.subject}</span>\n </div>].html_safe\n end\n end\nend",
"def get_push_job\n job = RhnLivePushJob.create!(:errata => @rhn_cdn_advisory, :pushed_by => releng_user)\n job.pub_options['push_metadata'] = true\n job.pub_options['push_files'] = true\n job\n end",
"def show\n botbot_base_url = \"https://botbot.me/freenode/\"\n github_repo_url = \"https://github.com/chef/irc_log_archives\"\n\n channel = params[:channel]\n date_str = params.fetch(:date, nil)\n\n begin\n date = Date.parse(date_str) unless date_str.nil?\n rescue ArgumentError\n not_found!\n else\n cutoff_date = Date.parse(\"2013-08-08\")\n\n if date_str.nil?\n redirect_to(botbot_base_url + channel)\n elsif date > cutoff_date\n redirect_to(botbot_base_url + channel + \"/\" + date_str)\n else\n redirect_to(github_repo_url)\n end\n end\n end",
"def channel_link(channel_id)\n \"<##{channel_id}>\"\n end",
"def current_latest_url\n current_url.sub(_archive, 'latest')\n end",
"def last_build_output(jobname, build_no = nil)\n url = \"#{@hudson_url}/job/#{jobname}/#{build_no.nil? ? \"lastBuild\" : build_no}/consoleText\"\n xmlBuild = get_url(url)\nend",
"def print_works_link(user)\n total = user.visible_work_count\n prefix = (@user == current_user) ? \"My \" : \"\"\n link_to_unless_current prefix + \"Works\" + \" (\" + total.to_s + \")\", user_works_path(@user)\n end",
"def auto_prepush_failed?(job)\n job.pub_options['nochannel'] &&\n job_changed_to_status?(job, 'FAILED') &&\n job.pushed_by == User.system\n end",
"def notification_channel_url\n return @notification_channel_url\n end",
"def text_for(channel)\n case channel.name\n when \"job-offers\"\n <<~END_OF_TEXT\n Welcome to our job posting channel. This channel is specifically for posting job offers.\n\n If you are seeking work, please use #job-seekers.\n\n For all other discussion of jobs, workplaces, career paths, etc. other than job opportunities, please use #job-chat.\n\n Your job offer should include the location, remote friendliness, company name, as well as instructions on how to apply.\n\n Be courteous and do not cross-post to other channels or post repeatedly for the same job offer. Do not pin your job post.\n\n Please use Slack threads to followup to keep the main channel's signal to noise ratio high.\n\n NOTE: To help keep this channel on topic for the community, we're asking that the job postings be related in some way to ruby or ruby on rails development (this include frontend work as well). If we don't feel the job aligns with that heuristic we'll be taking down posts without warning.\n\n Thank you!\n END_OF_TEXT\n end\n end",
"def view_last_news_helper\n out = ''\n @news = Newse.joins(:city).where('cities.subdomain' => request.subdomain).order('created_at desc').limit(8)\n if !@news.empty?\n @news.each do |news|\n out += \"<li>\"\n out += \"<em class='date'>#{news.created_at}</em>\"\n out += \"#{link_to news.name, {:controller => :tidings, :action=>:show, :id => news.id, :subdomain => request.subdomain}}\"\n out += \"</li>\"\n end\n else\n out += \"<li>Извините, новостей не добавлено!\"\n out += \"</li>\"\n end\n out.html_safe\n end",
"def captionLink\n nil\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Won't show the link if here are no pushes of the given type since having the button there tends to imply there might be a relevant push job to look at.
|
def push_history_link(push_job_class, errata)
if push_job_class.for_errata(errata).any?
workflow_action_link("Push History", { :controller => 'push', :action => 'push_history_for_errata', :id => errata })
end
end
|
[
"def type_link_up(type)\n text = type.is_a?(String) ? type : class_label(type)\n w.remote_link(text,\n {\n :javascript => :ipod_up,\n :navigation_type => type.is_a?(String) ? \"root\" : type.to_name_s('#'),\n :fallback => static_url_for(type)\n },\n { :class => \"ipodStyle\" } )\n end",
"def push_type_for_validate\n if advisory_rhn_live_pushed?\n 'cdn_if_live_push_succeeds'\n end\n end",
"def sidebar_action_link_to_remote_if(condition, name, options = {}, html_options={})\n sidebar_action_link_to_remote(name, options, html_options) if condition \n end",
"def last_push_link(push_job_class, errata)\n \"<a href='#'>Last job</a>\"\n end",
"def action_buttons_display\n if member.kind_of?(Work)\n if size == :large\n download_button + view_button + info_button\n else\n info_button\n end\n else\n if size == :large\n download_button + view_button\n else\n download_button\n end\n end\n end",
"def has_pushed_since_last_respin?(type)\n jobs = push_jobs_since_last_state(type, 'NEW_FILES').where('pub_task_id is not null')\n jobs.reject(&:is_nochannel?).any?(&:is_committed?)\n end",
"def display_link_to?(action)\n @display_link.include?(action)\n end",
"def link_for(type)\n if link = self.links.find { |link| link.type == type }\n link.to_s\n end\n end",
"def link_to_pm_model_link_status(pm_model)\n \tif pm_model.not_imported? \n \t\t\"项目中新建\"\n\t\telse\n\t\t\tif(count = pm_model.pm_links.count) > 0\n\t\t\t\tlink_to_popup \"#{count}个项目\", link_status_pm_model_path(pm_model)\n\t\t\telse\n\t\t\t\t\"无\"\n\t\t\tend\n\t\t\t\n\t\tend \t\n end",
"def last_prepush_link(push_job_class, errata)\n jobs_since_respin = errata.push_jobs_since_last_state(push_job_class, 'NEW_FILES')\n if (job = jobs_since_respin.nochannel.order('id desc').first)\n push_job_link(job, 'Pre-push')\n end\n end",
"def have_link_or_button_to_show(instance)\n path = polymorphic_path(instance)\n have_tag(\n \"a[href='#{path}'],\n form[action='#{path}'][method='get'] input,\n form[action='#{path}'][method='get'] button,\n form[action='#{path}'] input[name='_method'][value='get'] + input,\n form[action='#{path}'] input[name='_method'][value='get'] + button\"\n )\n end",
"def uplink_has_network_of_type?(uplink, type)\n uplink_networks(uplink).map do |network|\n network[\"type\"].downcase\n end.include?(type.downcase)\n end",
"def link?\n type == LINK_TYPE\n end",
"def post_type_link(text, type = nil)\n type = text if type.nil?\n link_to text, :controller => 'tumble', :action => 'list_by_post_type',\n :type => type\n end",
"def is_linktype?(); @type == GRT_LINKTYPE; end",
"def streamlined_auto_discovery_link_tag()\n return if @syndication_type.nil? || @syndication_actions.nil?\n \n if @syndication_actions.include? params[:action]\n \"<link rel=\\\"alternate\\\" type=\\\"application/#{@syndication_type.downcase}+xml\\\" title=\\\"#{@syndication_type.upcase}\\\" href=\\\"#{params[:action]}/xml\\\" />\"\n end\n end",
"def receive_push\n return if data['user'] == nil\n return if data['pass'] == nil\n return if data['url'] == nil\n return if data['title'] == nil\n # The line we add looks like: <msg> <commit URL>\n line_add = \"\\n* #{summary_message}: #{summary_url}\"\n # Log in to the install.\n mw = MediaWiki::Gateway.new(data['url'])\n mw.login(data['user'], data['pass'])\n # Good. Fetch page if it exists somehow.\n page_text = mw.get(data['title'])\n if page_text == nil\n mw.create(data['title'], '<!-- autocreated -->', :summary => 'Creating page -- did not exist during push')\n page_text = \"\"\n end\n # Append our line to the end of the page_text\n page_text << line_add\n # Save the page\n mw.edit(data['title'], page_text, :summary => 'Updated commits upon push')\n end",
"def suppress_link?(item)\n item.url.nil?\n end",
"def link_button_pressed?\n json = get_configuration\n json['linkbutton']\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
People that merged (not necessarily through pull requests) up to months_back from the time the built PR was created. if months_back is nil, don't take create time into consideration
|
def merger_team(pr, months_back = nil)
recently_merged = prs.find_all do |b|
close_reason[b[:github_id]] != :unknown and
(months_back.nil? ? true : b[:created_at].to_i > (pr[:created_at].to_i - months_back * 30 * 24 * 3600))
end.map do |b|
b[:github_id]
end
q = <<-QUERY
select u1.login as merger
from reduced_users u, reduced_projects p, reduced_pull_requests pr, reduced_pull_request_history prh, reduced_users u1
where prh.action = 'closed'
and prh.actor_id = u1.id
and prh.pull_request_id = pr.id
and pr.base_repo_id = p.id
and p.owner_id = u.id
and u.login = ?
and p.name = ?
and pr.pullreq_id = ?
QUERY
log q
recently_merged.map do |pr_num|
a = db.fetch(q, pr[:login], pr[:project_name], pr_num).first
if not a.nil? then a[:merger] else nil end
end.select {|x| not x.nil?}.uniq
end
|
[
"def merger_team(pr, months_back)\n @close_reason.map do |k,v|\n created_at = @prs.find{|x| x[:github_id] == k}\n [created_at[:created_at], v[2]]\n end.find_all do |x|\n x[0].to_i > (pr[:created_at].to_i - months_back * 30 * 24 * 3600)\n end.map do |x|\n x[1]\n end.select{|x| x != ''}.uniq\n end",
"def merger_team(pr, months_back)\n recently_merged = @prs.find_all do |b|\n @close_reason[b[:github_id]][1] != :unknown and\n b[:created_at].to_i > (pr[:created_at].to_i - months_back * 30 * 24 * 3600)\n end.map do |b|\n b[:github_id]\n end\n\n q = <<-QUERY\n select u1.login as merger\n from users u, projects p, pull_requests pr, pull_request_history prh, users u1\n where prh.action = 'closed'\n and prh.actor_id = u1.id\n and prh.pull_request_id = pr.id\n and pr.base_repo_id = p.id\n and p.owner_id = u.id\n and u.login = ?\n and p.name = ?\n and pr.pullreq_id = ?\n QUERY\n\n recently_merged.map do |pr_num|\n a = db.fetch(q, pr[:login], pr[:project_name], pr_num).first\n if not a.nil? then a[:merger] else nil end\n end.select {|x| not x.nil?}.uniq\n\n end",
"def merger_team(owner, repo, build, months_back)\n\n recently_merged = @builds.select do |b|\n not b[:pull_req].nil?\n end.find_all do |b|\n @close_reason[b[:pull_req]] != :unknown and\n b[:started_at].to_i > (build[:started_at].to_i - months_back * 30 * 24 * 3600)\n end.map do |b|\n b[:pull_req]\n end\n\n q = <<-QUERY\n select u1.login as merger\n from users u, projects p, pull_requests pr, pull_request_history prh, users u1\n where prh.action = 'closed'\n and prh.actor_id = u1.id\n and prh.pull_request_id = pr.id\n and pr.base_repo_id = p.id\n and p.owner_id = u.id\n and u.login = ?\n and p.name = ?\n and pr.pullreq_id = ?\n QUERY\n\n recently_merged.map do |pr_id|\n a = db.fetch(q, owner, repo, pr_id).first\n if not a.nil? then a[:merger] else nil end\n end.select {|x| not x.nil?}.uniq\n\n end",
"def commits_last_x_months(pr, exclude_pull_req, months_back)\n q = <<-QUERY\n select count(c.id) as num_commits\n from projects p, commits c, project_commits pc, pull_requests pr,\n pull_request_history prh\n where p.id = pc.project_id\n and pc.commit_id = c.id\n and p.id = pr.base_repo_id\n and prh.pull_request_id = pr.id\n and prh.action = 'opened'\n and c.created_at < prh.created_at\n and c.created_at > DATE_SUB(prh.created_at, INTERVAL #{months_back} MONTH)\n and pr.id=?\n QUERY\n\n if exclude_pull_req\n q << ' and not exists (select * from pull_request_commits prc1 where prc1.commit_id = c.id)'\n end\n\n db.fetch(q, pr[:id]).first[:num_commits]\n end",
"def pushed_within(months, collection=repos)\n (collection - no_push).select { |r| r.pushed_at >= months.months.ago }\n end",
"def months_ago(months); end",
"def commits_on_pr_files(pr, months_back)\n\n oldest = Time.at(Time.at(pr[:created_at]).to_i - 3600 * 24 * 30 * months_back)\n pr_against = pull_req_entry(pr)['base']['sha']\n commits = commit_entries(pr[:id], at_open = true)\n\n commits_per_file = commits.flat_map { |c|\n unless c['files'].nil?\n c['files'].map { |f|\n [c['sha'], f['filename']]\n }\n else\n []\n end\n }.select{|x| x.size > 1}.group_by {|c|\n c[1]\n }\n\n commits_per_file.keys.reduce({}) do |acc, filename|\n commits_in_pr = commits_per_file[filename].map{|x| x[0]}\n\n walker = Rugged::Walker.new(git)\n walker.sorting(Rugged::SORT_DATE)\n walker.push(pr_against)\n\n commit_list = walker.take_while do |c|\n c.time > oldest\n end.reduce([]) do |acc1, c|\n if c.diff(paths: [filename.to_s]).size > 0 and\n not commits_in_pr.include? c.oid\n acc1 << c.oid\n end\n acc1\n end\n acc.merge({filename => commit_list})\n end\n end",
"def commits_last_x_months(pr_id, exclude_pull_req, months)\n q = <<-QUERY\n select count(c.id) as num_commits\n from projects p, commits c, project_commits pc, pull_requests pr,\n pull_request_history prh\n where p.id = pc.project_id\n and pc.commit_id = c.id\n and p.id = pr.base_repo_id\n and prh.pull_request_id = pr.id\n and prh.action = 'opened'\n and c.created_at < prh.created_at\n and c.created_at > DATE_SUB(prh.created_at, INTERVAL #{months} MONTH)\n and pr.id=?\n QUERY\n\n if exclude_pull_req\n q << ' and not exists (select * from pull_request_commits prc1 where prc1.commit_id = c.id)'\n end\n q << ';'\n\n if_empty(db.fetch(q, pr_id).all, :num_commits)\n end",
"def commits_on_pr_files(pr, months_back)\n\n oldest = Time.at(Time.at(pr[:created_at]).to_i - 3600 * 24 * 30 * months_back)\n pr_against = pull_req_entry(pr[:id])['base']['sha']\n commits = commit_entries(pr[:id])\n\n commits_per_file = commits.flat_map { |c|\n c['files'].map { |f|\n [c['sha'], f['filename']]\n }\n }.group_by {|c|\n c[1]\n }\n\n commits_per_file.keys.reduce({}) do |acc, filename|\n commits_in_pr = commits_per_file[filename].map{|x| x[0]}\n\n walker = Rugged::Walker.new(repo)\n walker.sorting(Rugged::SORT_DATE)\n walker.push(pr_against)\n\n commit_list = walker.take_while do |c|\n c.time > oldest\n end.reduce([]) do |acc1, c|\n if c.diff(paths: [filename.to_s]).size > 0 and\n not commits_in_pr.include? c.oid\n acc1 << c.oid\n end\n acc1\n end\n acc.merge({filename => commit_list})\n end\n end",
"def committer_team(pr, months_back)\n q = <<-QUERY\n select distinct(u.login) as committer\n from commits c, project_commits pc, pull_requests pr, users u, pull_request_history prh\n where pr.base_repo_id = pc.project_id\n and not exists (select * from pull_request_commits where commit_id = c.id)\n and pc.commit_id = c.id\n and pr.id = ?\n and u.id = c.committer_id\n and u.fake is false\n and prh.pull_request_id = pr.id\n and prh.action = 'opened'\n and c.created_at > DATE_SUB(prh.created_at, INTERVAL #{months_back} MONTH)\n and c.created_at < prh.created_at;\n QUERY\n db.fetch(q, pr[:id]).all.map{|x| x[:committer]}\n end",
"def months_ago(months)\n if months >= self.month\n change(:year => self.year - 1, :month => 12).months_ago(months - self.month)\n else\n change(:year => self.year, :month => self.month - months)\n end\n end",
"def commits_on_pr_files(pr, months_back)\n\n oldest = Time.at(Time.at(pr[:created_at]).to_i - 3600 * 24 * 30 * months_back)\n commits = commit_entries(pr, at_open = true)\n\n commits_per_file = commits.flat_map { |c|\n unless c[:files].nil?\n JSON.parse(c[:files]).map { |f|\n [c[:sha], f[\"filename\"]]\n }\n else\n []\n end\n }.select{|x| x.size > 1}.group_by {|c|\n c[1]\n }\n\n commits_per_file.keys.reduce({}) do |acc, filename|\n commits_in_pr = commits_per_file[filename].map{|x| x[0]} # get the shas of pr related commits\n\n walker = Rugged::Walker.new(git)\n walker.sorting(Rugged::SORT_DATE)\n walker.push(pr[:base_commit])\n\n commit_list = walker.select do |c|\n c.time > oldest\n end.reduce([]) do |acc1, c|\n if c.diff(paths: [filename.to_s]).size > 0 and\n not commits_in_pr.include? c.oid # (oid is the object id - c.oid gets the commit sha). this commit is not part of pr's commits\n acc1 << c.oid\n end\n acc1\n end\n acc.merge({filename => commit_list})\n end\n end",
"def checkin_at_last_month\n Time.now.ago(1.month).ago(from_9_am)\n end",
"def commented_pull_requests(pr, user_id, months_back)\n oldest = Time.at(Time.at(pr[:created_at]).to_i - 3600 * 24 * 30 * months_back)\n q = <<-QUERY\n select pr.pullreq_id as github_id\n from reduced_pull_requests pr, reduced_pull_request_comments prc\n where prc.user_id = ?\n and pr.base_repo_id = ?\n and pr.id = prc.pull_request_id\n and prc.created_at > ?\n and prc.created_at < ?\n QUERY\n db.fetch(q, user_id, pr[:project_id], oldest, pr[:created_at]).all.map {|x| x[:github_id]}\n end",
"def commits_on_files_touched(pr, months_back)\n commits_on_pr_files(pr, months_back).reduce([]) do |acc, commit_list|\n acc + commit_list[1]\n end.flatten.uniq.size\n end",
"def main_team_member?(pr, months_back)\n (committer_team(pr, months_back) + merger_team(pr, months_back)).uniq.include? requester(pr)\n end",
"def prior_interaction_issue_events(pr, months_back)\n q = <<-QUERY\n select count(distinct(i.id)) as num_issue_events\n from issue_events ie, pull_request_history prh, pull_requests pr, issues i\n where ie.actor_id = prh.actor_id\n and i.repo_id = pr.base_repo_id\n and i.id = ie.issue_id\n and prh.pull_request_id = pr.id\n and prh.action = 'opened'\n and ie.created_at > DATE_SUB(prh.created_at, INTERVAL #{months_back} MONTH)\n and ie.created_at < prh.created_at\n and prh.pull_request_id = ?\n QUERY\n db.fetch(q, pr[:id]).first[:num_issue_events]\n end",
"def filter_merged_pull_requests(pull_requests)\n print \"Fetching merged dates...\\r\" if options[:verbose]\n closed_pull_requests = @fetcher.fetch_closed_pull_requests\n\n pull_requests.each do |pr|\n fetched_pr = closed_pull_requests.find do |fpr|\n fpr[\"number\"] == pr[\"number\"]\n end\n if fetched_pr\n pr[\"merged_at\"] = fetched_pr[\"merged_at\"]\n closed_pull_requests.delete(fetched_pr)\n end\n end\n\n pull_requests.reject! do |pr|\n pr[\"merged_at\"].nil?\n end\n\n pull_requests\n end",
"def month_contributions\r\n # Query contributions only if not already done\r\n @contribs ||= @leaderboard.member_contributions(@username)\r\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
GET /insider_deals/1 GET /insider_deals/1.json
|
def show
@insider_deal = InsiderDeal.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @insider_deal }
end
end
|
[
"def index\n @deals = @business.deals \n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @deals }\n end\n end",
"def show_deal(id)\n get(\"deals/#{id}\")\n end",
"def deal(id, options={})\n get(\"/v2/deals/#{id}\", options)\n end",
"def deals(query={})\n division = query.delete(:division)\n query.merge! :client_id => @api_key\n path = division ? \"/#{division}\" : \"\"\n path += \"/deals.json\"\n self.class.get(path, :query => query).deals\n end",
"def index\n @deals = Deal.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @deals }\n end\n end",
"def index\n @meals = Meal.all\n render json: @meals, status: 200\n end",
"def index\n @meals = Meal.all\n\n render json: @meals\n end",
"def deal_detail(id:, **args)\n params = parameters(args) do\n optional_params\n end\n request(:get, \"deals/#{id}\", params)\n end",
"def show\n @deals_wizard = DealsWizard.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @deals_wizard }\n end\n end",
"def all_deals(**args)\n params = parameters(args) do\n optional_params :user_id, :filter_id, :stage_id, :status, :start, :limit, :sort, :owned_by_you\n end\n request(:get, 'deals', params)\n end",
"def person_deals(id:, **args)\n params = parameters(args) do\n optional_params :start, :limit, :status, :sort\n end\n request(:get, \"persons/#{id}/deals\", params)\n end",
"def organization_deals(id:, **args)\n params = parameters(args) do\n optional_params :start, :limit, :status, :sort, :only_primary_association\n end\n request(:get, \"organizations/#{id}/deals\", params)\n end",
"def index\r\n @daily_deals = DailyDeal.all\r\n\r\n respond_to do |format|\r\n format.html # index.html.erb\r\n format.json { render json: @daily_deals }\r\n end\r\n end",
"def index\n @meals = Meal.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @meals }\n end\n end",
"def show\n @idea_deal = IdeaDeal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @idea_deal }\n end\n end",
"def new\n @insider_deal = InsiderDeal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @insider_deal }\n end\n end",
"def show\n @redeemed_deal = RedeemedDeal.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @redeemed_deal }\n end\n end",
"def show\n @dealsdirect = Dealsdirect.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @dealsdirect }\n end\n end",
"def meal(meal_id)\n get(\"user/#{user_id}/meals/#{meal_id}.json\")\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
GET /insider_deals/new GET /insider_deals/new.json
|
def new
@insider_deal = InsiderDeal.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @insider_deal }
end
end
|
[
"def new\n @meal = Meal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @meal }\n end\n end",
"def new\n @dental = Dental.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dental }\n end\n end",
"def new\n @dealsdirect = Dealsdirect.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dealsdirect }\n end\n end",
"def new\n @inspiration = Inspiration.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @inspiration }\n end\n end",
"def new\n @inspiration = Inspiration.new\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @inspiration }\n end\n end",
"def new\n @idea_deal = IdeaDeal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @idea_deal }\n end\n end",
"def new\n @list_of_deal = ListOfDeal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @list_of_deal }\n end\n end",
"def new\n @lease = Lease.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lease }\n end\n end",
"def new\n @deal_detail = DealDetail.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @deal_detail }\n end\n end",
"def new\n @diary_entry = DiaryEntry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @diary_entry }\n end\n end",
"def new\n @drip = Drip.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @drip }\n end\n end",
"def new\n @rateddeal = Rateddeal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @rateddeal }\n end\n end",
"def new\n @journal = @journals.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @journal }\n end\n end",
"def new\n @apeal = Apeal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @apeal }\n end\n end",
"def new\n @lease = Lease.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @lease }\n end\n end",
"def new\r\n @daily_deal = DailyDeal.new\r\n\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @daily_deal }\r\n end\r\n end",
"def new\n @indonation = Indonation.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @indonation }\n end\n end",
"def new\n # this assigns new pedals to the current user\n @pedal = current_user.pedals.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pedal }\n end\n end",
"def new\n @redeemed_deal = RedeemedDeal.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @redeemed_deal }\n end\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
DELETE /insider_deals/1 DELETE /insider_deals/1.json
|
def destroy
@insider_deal = InsiderDeal.find(params[:id])
@insider_deal.destroy
respond_to do |format|
format.html { redirect_to insider_deals_url }
format.json { head :no_content }
end
end
|
[
"def delete_deals(**args)\n params = parameters(args) do\n required_params :ids\n optional_params :ids\n end\n request(:delete, 'deals', params)\n end",
"def destroy\n @deal = Deal.find(params[:id])\n @deal.destroy\n\n respond_to do |format|\n format.html { redirect_to api_v1_deals_url }\n format.json { head :no_content }\n end\n end",
"def delete_deal(id)\n delete(\"deals/#{id}\")\n end",
"def destroy\n @indication_for_meal.destroy\n respond_to do |format|\n format.html { redirect_to indication_for_meals_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @hold_deal.destroy\n respond_to do |format|\n format.html { redirect_to hold_deals_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @meal.destroy\n\n respond_to do |format|\n format.html { redirect_to meals_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @meal = Meal.find(params[:id])\n @meal.destroy\n\n respond_to do |format|\n format.html { redirect_to meals_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @driver_meal.destroy\n respond_to do |format|\n format.html { redirect_to driver_meals_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @meal = Meal.find(params[:id])\n @meal.destroy\n\n respond_to do |format|\n format.html { redirect_to meals_url }\n format.json { head :ok }\n end\n end",
"def destroy\n if @item_meal.destroy\n head :no_content, status: 204\n else\n render json: @item_meal.errors, status: 405\n end\n end",
"def destroy\n @dental = Dental.find(params[:id])\n @dental.destroy\n\n respond_to do |format|\n format.html { redirect_to dentals_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @deals_wizard = DealsWizard.find(params[:id])\n @deals_wizard.destroy\n\n respond_to do |format|\n format.html { redirect_to deals_wizards_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @idea_deal = IdeaDeal.find(params[:id])\n @idea_deal.destroy\n\n respond_to do |format|\n format.html { redirect_to idea_deals_url }\n format.json { head :ok }\n end\n end",
"def destroy\r\n @daily_deal = DailyDeal.find(params[:id])\r\n @daily_deal.destroy\r\n\r\n respond_to do |format|\r\n format.html { redirect_to daily_deals_url }\r\n format.json { head :no_content }\r\n end\r\n end",
"def destroy\n @seal.destroy\n respond_to do |format|\n format.html { redirect_to seals_url, notice: 'Seal was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @list_of_deal = ListOfDeal.find(params[:id])\n @list_of_deal.destroy\n\n respond_to do |format|\n format.html { redirect_to list_of_deals_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dealocity_deal = DealocityDeal.find(params[:id])\n @dealocity_deal.destroy\n\n respond_to do |format|\n format.html { redirect_to dealocity_deals_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @redeemed_deal = RedeemedDeal.find(params[:id])\n @redeemed_deal.destroy\n\n respond_to do |format|\n format.html { redirect_to redeemed_deals_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @rateddeal = Rateddeal.find(params[:id])\n @rateddeal.destroy\n\n respond_to do |format|\n format.html { redirect_to rateddeals_url }\n format.json { head :no_content }\n end\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
disable the callbacks that are used for workflow; this ensures that we control sgtate changes, etc better during ingest, and various other
|
def disable_workflow_callbacks
# disable the allocate DOI callback
LibraWork.skip_callback( :save, :after, :allocate_doi )
LibraWork.skip_callback( :update, :before, :update_doi )
# disable the email send callback
LibraWork.skip_callback( :save, :after, :determine_email_behavior )
end
|
[
"def disable_callback_methods\n StashEngine::Resource.skip_callback(:create, :after, :init_state_and_version)\n # StashEngine::Resource.skip_callback(:create, :after, :create_share)\n end",
"def replicate_disable_callbacks(instance)\n if ::ActiveRecord::VERSION::MAJOR >= 3\n # AR 3.1.x, 3.2.x\n def instance.run_callbacks(*args); yield if block_given?; end\n\n # AR 3.0.x\n def instance._run_save_callbacks(*args); yield if block_given?; end\n def instance._run_create_callbacks(*args); yield if block_given?; end\n def instance._run_update_callbacks(*args); yield if block_given?; end\n def instance._run_commit_callbacks(*args); yield if block_given?; end\n else\n # AR 2.x\n def instance.callback(*args)\n end\n def instance.record_timestamps\n false\n end\n end\n end",
"def skip_faye_callbacks\n Protocol.skip_callback :save, :after, :update_faye\n Participant.skip_callback :save, :after, :update_faye\n end",
"def disable_closures!\n @enable_closures = false\n end",
"def exclusive_hook; end",
"def suppress_touch_callbacks(name)\n save, touch_callback_statuses[name] = touch_callback_statuses[name], true\n yield\n ensure\n touch_callback_statuses[name] = save\n end",
"def disable!\n swap_out_delegator\n end",
"def disable\n return unless enabled?\n @_enabled = false\n i = _trigger_disable_hooks\n i.send :init if i.respond_to? :init\n end",
"def disable!\n run(:disable)\n end",
"def skip_actions; end",
"def disable!\n @events_tracker = NullTracker.new(events)\n end",
"def without_auditing(&block)\n auditing_was_enabled = auditing_enabled\n disable_auditing\n block.call\n ensure\n enable_auditing if auditing_was_enabled\n end",
"def without_auditing(&block)\n auditing_was_enabled = auditing_enabled\n disable_auditing\n block.call.tap { enable_auditing if auditing_was_enabled }\n end",
"def cancel_callback block\n @callbacks ||= []\n @callbacks.delete block\n end",
"def without_update_callbacks\n class_eval do\n CALLBACKS.each do |attr_name|\n alias_method \"orig_#{attr_name}\".to_sym, attr_name\n alias_method attr_name, :empty_callback\n end\n end\n yield\n ensure\n class_eval do\n CALLBACKS.each do |attr_name|\n alias_method attr_name, \"orig_#{attr_name}\".to_sym\n end\n end\n end",
"def disable!\n set_enabled!(false)\n end",
"def without_approval(&block)\n enable = approvals_on? # If we use #approvals_enabled? the global state might be incorrectly applied.\n approvals_off\n yield(self)\n ensure\n approvals_on if enable\n end",
"def set_flow_control_off\n\t\tsend_command( 0x3B )\n\tend",
"def skip_callback\n @@skip_callback = true\n result = yield\n @@skip_callback = false\n result\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
construct a default email address given a computing Id
|
def default_email( cid )
return "#{cid}@#{DEFAULT_DOMAIN}"
end
|
[
"def email_address\n require \"mail\"\n address = Mail::Address.new email\n address.display_name = name.dup\n address.format\n end",
"def generateEmailAddress()\n uuid = SecureRandom.hex(3)\n return \"%s.%s@mailosaur.in\" % [uuid, @MAILBOX]\n end",
"def generate_email\n formatted_name = email_address_pattern.method(email_address_pattern.pattern).call(Person.new(target_name))\n construct_email_address(formatted_name)\n end",
"def email_address\n (email_addresses.where(primary: true).first || email_addresses.first).try(:email) ||\n current_address.try(:email) ||\n permanent_address.try(:email) ||\n user.try(:username)\n end",
"def email_address\n (email_addresses.where(primary: true).first || email_addresses.first).try(:email) ||\n current_address.try(:email) ||\n permanent_address.try(:email) ||\n user.try(:username)\n end",
"def generate_email(specifier = nil)\n Faker::Internet.email(name)\n end",
"def email_address\n authentications.emails.active.first.uid rescue nil\n end",
"def rep_email\r\n return if self.assigned_to.nil?\r\n \r\n if (bomb_squad = AppConfig.CUSTOMER_STAFF[self.assigned_to])\r\n return \"\\\"#{name}\\\" <#{bomb_squad_email}>\"\r\n else\r\n raise \"BombSquad \\\"#{self.assigned_to}\\\" is not existing for \\\"#{self.account_num}\\\"\"\r\n end\r\n end",
"def email_address\n element_with_value('EMailAddress', opts[:email_address].to_s[0..50])\n end",
"def generate_random_email_address\n random_email_account = SecureRandom.hex(@number_of_random_characters)\n random_domain_name = SecureRandom.hex(@number_of_random_characters)\n return random_email_account + \"@\" + random_domain_name + @email_suffix\n end",
"def email_address\n self.dig_for_string(\"emailAddress\")\n end",
"def default_email_address_header\n default_email_address.nil? ? original_email_address_header : default_email_address.to_header\n end",
"def primary_email\n email_addresses.find(:first, :conditions => {:preferred => true}) || email_addresses.first\n end",
"def free_email_address\n @free_email_address ||= \"#{username}@#{self.class.free_email_domains.shuffle.first}\"\n end",
"def convert_to_guest_email(email)\n id = id_from_uniquized_attribute(email)\n GuestUserHelper.new.random_email + \"$$#{id}\"\n end",
"def address\n @address ||= Mail::Address.new(self.to_s) rescue nil\n end",
"def address_formal(fallback_to_email = true)\n return address_prefix + \" #{surname}\" unless surname.blank?\n return firstname unless firstname.blank?\n return nickname unless nickname.blank?\n return email if fallback_to_email\n return address_role\n end",
"def primary_email\n primary_email_object = emails.find_by(is_primary: true)\n return if primary_email_object.blank?\n\n primary_email_object.address\n end",
"def supplier_email=(str)\n composite = find_or_create_supply_detail\n composite.email_address = str\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
get a work by the specified ID
|
def get_work_by_id( work_id )
begin
return LibraWork.find( work_id )
rescue => e
end
return nil
end
|
[
"def get_work_by_id( work_id )\n\n begin\n return GenericWork.find( work_id )\n rescue => e\n end\n\n return nil\n end",
"def get_run(id)\n get_runs.each {|run| return run if run.id==id}\n end",
"def set_work\n work.first.id\n end",
"def get_task_by_id(id)\n require_relative 'task'\n Task.new(@api, @api.do_request(\"GET\", get_base_api_path() + \"/tasks/#{id}\"))\n end",
"def retrieve_workflow(id)\n @url = \"#{@url}/#{id}\"\n retrieve_resource\n end",
"def find_job_by_id(id)\n plan.find_tasks(Job).with_arguments(job_id: id).to_a.first\n end",
"def find_or_new_work(primary_id, title)\n work_found = Work.where(identifier_ssi: primary_id).last\n return work_found if work_found\n Work.new(\n identifier: primary_id,\n title: title,\n depositor: job_owner,\n admin_set: admin_set_for_work\n )\n end",
"def get_job(id)\n conn = @client.get do |req|\n req.url \"/api/v2/job/#{id}\"\n req.headers[\"Authorization\"] = @token\n end\n conn.body\n end",
"def find_worker id\n self.workers.find{ |worker| worker[:id] == id } \n end",
"def find_workshop(id)\n @workshop ||= Workshop.find_by_id(id)\n end",
"def find(id)\n res = transmit(\"peek #{id}\")\n Job.new(client, res)\n rescue Beaneater::NotFoundError\n nil\n end",
"def getTaskByID(id) \n ret = nil \n\n @Tasks.each do |task| \n ret = task if task.ID == id\n end \n end",
"def getTaskByID(id) \n @Tasks.each do |task|\n return task if task.ID == id\n end\n return nil \n end",
"def fetch(workitem_or_fei)\n\n hfei = Ruote::FlowExpressionId.extract_h(workitem_or_fei)\n\n @context.storage.get('workitems', to_id(hfei))\n end",
"def find_by_id(client, id, options: {})\n\n self.new(parse(client.get(\"/workspaces/#{id}\", options: options)).first, client: client)\n end",
"def find(workflow_id)\n end",
"def work\n\t\tif params[:id]\n\t\t\tif Employee.exists?(params[:id])\n\t\t\t\t@employee = Employee.find(params[:id])\n\t\t\t\t@employee_works = @employee.works.paginate(:page => params[:page], :per_page => 10)\n\t\t\telse\n\t\t\t\trender :\"errors/notfound\"\n\t\t\tend\n\t\tend\n\tend",
"def get_by_id(id)\n fetch(@database, id)\n end",
"def administration\n @work = Work.find(params[:id])\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
download a random cat image
|
def get_random_image( )
print "getting image... "
dest_file = "#{File::SEPARATOR}tmp#{File::SEPARATOR}#{SecureRandom.hex( 5 )}.jpg"
Net::HTTP.start( "lorempixel.com" ) do |http|
resp = http.get("/640/480/cats/")
open( dest_file, "wb" ) do |file|
file.write( resp.body )
end
end
puts "done"
return dest_file
end
|
[
"def fetchImage\n url = \"https://dog.ceo/api/breeds/image/random\"\n uri = URI(url)\n response = Net::HTTP.get(uri)\n imgURL = JSON.parse(response)\n output = imgURL[\"message\"]\nend",
"def randomOctocat\n\t\tcURL($baseURL+\"?random\")\n\tend",
"def random_image(query = 'safe, cute', nsfw = false)\n img = get(url: 'search/images', query: \"q=#{query.present? ? query : 'safe, cute'}&sf=random&per_page=1\", nsfw: nsfw)\n\n if img\n img_data = img['images'][0]\n image img_data.id, nsfw if img_data\n end\n end",
"def random_image_old(horizontal=600,vertical=600)\n image_categories = ['abstract','city','people','transport','animals','food','nature','business', 'nightlife', 'sports','cats','fashion','technics']\n image_category = image_categories[Random.rand(image_categories.length)]\n #append a random id to trick the cache\n return \"http://lorempixel.com/\" + horizontal.to_s + \"/\" + vertical.to_s + \"/\" + image_category + \"/\" + random_id()[0,5]\n end",
"def download_image\n Net::HTTP.start(@uri.host, @uri.port) do |http|\n\tif http.head(@uri.request_uri).code == \"200\"\n\tresp = http.get(@tempo.link)\n\topen(\"public/images/original/#{@original_image_name}\", \"wb\") do |file|\n\t file.write(resp.body)\n\tend\n end\n end\n end",
"def download_imgur( url, filename )\n image = open( \"#{url}.jpg\" ).read\n File.write(\"#{filename}.jpg\", image)\nend",
"def download_image(image)\n url = FlickRaw.url(image)\n Dir.mkdir('tmp') unless File.exists? 'tmp'\n open(url) do |f|\n File.open(\"tmp/#{image['id']}.jpg\",\"wb\") do |file|\n file.puts f.read\n end\n end\n end",
"def get_random_gif\n @gifs.sample[:url]\n end",
"def get_random_gif_by_category(category)\n gif_set = get_category_gifs(category)\n\n if gif_set.kind_of?(Array)\n unless gif_set.empty?\n gif_set.sample[:url]\n else\n 'No GIF found.'\n end\n else\n gif_set[:url]\n end\n end",
"def fetch_image(rant)\n url = rant['attached_image']['url']\n download = open(url)\n path = @store.images + url.split('/')[-1]\n IO.copy_stream(download, path)\n end",
"def random_default_image\n Random.new.rand(1..6).to_s + '.jpg'\n end",
"def rand_banner_img\n [\n 'http://song-dev.qiniudn.com/g0.jpg',\n 'http://song-dev.qiniudn.com/g1.jpg',\n 'http://song-dev.qiniudn.com/g2.jpg',\n 'http://song-dev.qiniudn.com/g3.jpg',\n 'http://song-dev.qiniudn.com/g4.jpg',\n 'http://song-dev.qiniudn.com/g5.jpg',\n 'http://song-dev.qiniudn.com/g6.jpg'\n ].sample\n end",
"def generate_png\n img = IMGKit.new(url).to_png\n file = File.new(\"#{id}-full.png\", \"w\", :encoding => 'ascii-8bit')\n file.write(img)\n return file.path\n end",
"def cover_fetcher\n if ENV['CI']\n File.open('./spec/factories/images/crysis.jpg')\n else\n # TODO: Make the dimensions more random.\n URI.open(\"#{Faker::LoremPixel.image(size: '560x800', is_gray: false)}/\")\n end\nend",
"def cover_fetcher\n if ENV['CI']\n File.open('./spec/factories/images/crysis.jpg')\n else\n # TODO: Make the dimensions more random.\n URI.open(\"#{Faker::LoremPixel.image('560x800', false)}/\")\n end\nend",
"def random(tag: nil, rating: nil)\n # TODO: Add tag and rating parameters\n response = get_response(\n api_path: '/v1/gifs/random',\n query_object: { tag: tag, rating: rating }\n )\n\n OpenStruct.new(\n page_url: response.parsed_response['data']['url'],\n image_url: response.parsed_response['data']['image_url']\n )\n end",
"def png()\n\n filename = \"#{$MYDIR}/#{@z}-#{@x}-#{@y}.png\"\n\n if File.exist?(filename) then return filename end\n\n # if the file doesn't exist, use curl to pull the image\n\n url = \"https://tile.openstreetmap.org/#{@z}/#{@x}/#{@y}.png\"\n\n debug(\"Downloading: #{url}\")\n\n # TODO: silence curl\n system(\"curl -o #{filename} #{url}\")\n return filename\n\n end",
"def get_random_content\n random_content = []\n fetch_all_categories.each do |link_to_send|\n random_content = link_to_send.url\n\n end\n random_content.sample\n end",
"def image_get\n @image = Tempfile.new('scrobbler-notify')\n if @track.image(:small).nil? || @track.image(:small).empty?\n if @track.album.nil? || @track.album.image(:small).nil? || @track.album.image(:small).empty?\n if @track.artist.nil? || @track.artist.image(:small).nil? || @track.artist.image(:small).empty?\n image_uri = nil\n else\n image_uri = URI.parse(@track.artist.image(:small))\n end\n else\n image_uri = URI.parse(@track.album.image(:small))\n end\n else\n image_uri = URI.parse(@track.image(:small))\n end\n @image.print(Net::HTTP.get(image_uri)) unless image_uri.nil?\n @image.close\n @image.path\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
get user information from an email address
|
def user_info_by_email( email )
id = User.cid_from_email( email )
return user_info_by_cid( id )
end
|
[
"def user_by_email(email)\n get(\"get_user_by_email&email=#{email}\")\n end",
"def get_user_email\n useremail[:value]\n end",
"def get_email(email)\n self.api_get(:email, {:email => email})\n end",
"def return_user_email(username, client)\n user_list = client.user_search(username: username)\n user_list.first.email_address || nil\nend",
"def read_user_emailtoken(emailtoken)\n filter = Net::LDAP::Filter.eq(ENTITY_ATTR_MAPPING[:emailtoken].to_s, emailtoken)\n return search_map_user_fields(filter, 1)[0]\n end",
"def get_user_by_email(email)\n @user_manager.get_user_by(email: email)\n end",
"def get_email_address\n response = get_current_user_meta('email')\n email = response['query']['userinfo']['email']\n return if email == ''\n\n email\n end",
"def find_by_email(email)\n if email.strip.length > 0\n result = Ripple::client.search('users', \"email:#{email.downcase}\")\n if result['response']['numFound'] == 1\n return User.find(result['response']['docs'][0]['id']) # is this the best way?\n end\n end\n nil # Returned if no conditions met (explicit to avoid IDE griping)\n end",
"def get_user_by_email(order)\n response = HTTParty.get(\"#{Rails.application.secrets.mapp_integration[:api_endpoint]}\"+\"/user/getByEmail\", headers: headers, query: user_get_by_email_query(order.email))\n user_id_from_response = response.parsed_response[\"id\"]\n\n begin\n if user_id_from_response.nil?\n guest_user_response = Workarea::MappIntegration::MappIntegrationGateway.new.user_creation_for_guest_user(order)\n user_id = guest_user_response.parsed_response[\"id\"]\n Workarea::MappIntegration::MappIntegrationGateway.new.mapp_integration_for_order_placed(order, user_id)\n else\n Workarea::MappIntegration::MappIntegrationGateway.new.mapp_integration_for_order_placed(order, user_id_from_response)\n end\n rescue Timeout::Error => e\n Rails.logger.info \"Rescued #{e.message}\"\n end\n end",
"def fetch_users_info(emails)\n endpoint = \"/api/#{@version}/user/info/\"\n custom_params = {\n 'emails' => emails.join(',')\n }\n make_get_request(endpoint, custom_params)\n end",
"def find_user_by_email(email: user&.email)\n users = client.list_users(\"active\", {\n filter: email,\n order: \"ascending\",\n page: 1\n })\n\n users.first\n end",
"def email_address\n self.dig_for_string(\"emailAddress\")\n end",
"def find_slack_user_from_email(client, email)\n begin\n resp = client.users_lookupByEmail(email: email)\n if resp.ok?\n return resp.user\n end\n rescue => e\n puts e\n end\n nil\nend",
"def efind(email)\n User.find_by_email email\n end",
"def lookup_user_from(*args)\n emails = []\n args.each do |person|\n # Match a valid email address (not perfect)\n emails << person.match(/\\b[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\\.[a-zA-Z0-9-.]+\\b/i).to_s\n end\n\n emails.uniq!\n if emails.count == 1\n return User.find_by email: emails.first\n else\n emails.each do |email|\n u = User.find_by email: email\n return u unless u.nil?\n end\n end\n\n nil\n end",
"def lookup_by_email(email, token)\n return nil if email.blank?\n\n ## Create URI\n uri = get_slack_api_url() + '/users.lookupByEmail'\n\n ## Create http header\n header = {}\n header['Content-Type'] = 'application/json; charset=UTF-8'\n header['Authorization'] = \"Bearer #{token}\"\n https_proxy = ENV['https_proxy'] || ENV['HTTPS_PROXY']\n\n ## Create http query\n query = {}\n query['email'] = email\n\n ## Get http response\n res = nil\n begin\n client = HTTPClient.new(https_proxy)\n client.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE\n res = client.get uri, :query => query, :header => header\n rescue Exception => e\n Rails.logger.warn(\"Cannot connect to #{url}\")\n Rails.logger.warn(e)\n end\n\n return nil if res.nil?\n return nil if res.status_code.nil?\n return nil unless res.status_code == 200\n return nil if res.http_body.nil?\n return nil if res.http_body.content.nil?\n\n begin\n res_body = JSON.parse(res.http_body.content)\n rescue Exception => e\n Rails.logger.warn(\"Cannot parse JSON string: #{res.http_body.content}\")\n Rails.logger.warn(e)\n end\n\n return nil if res_body['ok'].nil?\n return nil unless res_body['ok']\n return nil if res_body['user'].nil?\n return nil if res_body['user']['id'].nil?\n\n return res_body['user']['id']\n end",
"def parse_user(name, email, trailer)\n link_to_user User.find_by_any_email(email),\n name: name,\n email: email,\n trailer: trailer\n end",
"def entity_from_email\n ServiceUser.where('email=?', auth_params[:email]).first\n end",
"def get_user(email)\n #faço a chamada para buscar o id do usuario com find que vai trazer uma lista de usuarios\n #mas com essa condição que passo do email coloco o firt que vai trazer a esperada\n user = @users.find({ email: email }).first\n\n #capturo somente o _id do usuario e faço o return do metodo\n return user[:_id]\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
get user information from a computing id
|
def user_info_by_cid( id )
print "Looking up user details for #{id}..."
# lookup the user by computing id
user_info = Helpers.lookup_user( id )
if user_info.nil?
puts "not found"
return nil
end
puts "done"
return user_info
end
|
[
"def user_info_by_cid( id )\n\n print \"Looking up user details for #{id}...\"\n\n # lookup the user by computing id\n user_info = Helpers::EtdHelper::lookup_user( id )\n if user_info.nil?\n puts \"not found\"\n return nil\n end\n\n puts \"done\"\n return user_info\n end",
"def fetch_user(id)\n client.user(id)\n end",
"def user_info\n get(api_get.body.identity).body\n end",
"def get_user_from_serial\n device_info = DeviceInfo.find_by_serial_number(serial_number)\n user_id = device_info.user_id unless device_info.blank?\n end",
"def get_user_id!(params)\n get_value_for_key(params, \"user_id\")\n end",
"def get_user(id)\n @users[id]\n end",
"def get_user_id!(params)\n get_value_for_key!(params, \"user_id\")\n end",
"def userid\n user_id\n end",
"def info(session, id)\n read_task('rvpe.user.info', session) do\n session_uname = get_user_from_session(session)\n session_user = User.find_by_name(session_uname).last\n\n user = User.find_by_id(id).last\n raise \"User[#{id}] is not found.\" unless user\n\n if session_user.id != 0 && session_user.id != id\n raise \"You don't have permission to see info. of User[#{user.name}].\"\n end\n\n doc = REXML::Document.new\n doc.add(user.to_xml_element(session))\n [true, doc.to_s]\n end\n end",
"def get_user_id(reaktoruser_id)\n IdStore.get(:reaktoruser, reaktoruser_id)\n end",
"def get_user(id)\n return @client.raw(\"get\", \"/config/users/#{id}\")\n end",
"def request_user_information\n user_id = ask((@lang_handler.get_str :login_id_request), Integer) do |q| \n q.in = 0..999999\n end\n \n user_pin = ask((@lang_handler.get_str :login_pin_request), Integer) do |q| \n q.echo = false\n q.in = 0..9999\n end\n \n return user_id, user_pin\n end",
"def user_from_id_hash\n User.find_by_id_hash params[:id_hash]\n end",
"def user_details\n user_details_for(@qualified_username).first\n end",
"def get_userid(url=USERID_URL)\n get(url)\n end",
"def get_external_id_by_user_id(id)\n get_user_by_id(id)[\"external_user_id\"]\n end",
"def get_user_info\n response = send_method(:get_user_info)\n user_from(response)\n end",
"def get_user_info\n request :get_user_info\n end",
"def get_user(username)\n Chef::Log.info username\n user = @node[:users][username]\n Chef::Log.info user.inspect\n user\nend"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
lookup a user by computing id and create their account if we locate them
|
def lookup_and_create_account( id )
# lookup locally with the default email
user = User.find_by_email( User.email_from_cid( id ) )
return user if user.present?
# if we cannot find them, lookup in LDAP
user_info = user_info_by_cid( id )
return nil if user_info.nil?
# now look them up with the located email
user = User.find_by_email( user_info.email )
return user if user.present?
# create their account
return User.new_user( user_info, user_info.email )
end
|
[
"def get_account_user user_id, role\n AccountUser.where( account_id: self.id, \n user_id: user_id\n )\n .first_or_create( account_id: self.id, \n user_id: user_id, \n role: role\n ) \n end",
"def create_user user\n begin\n customers = @openpay.create(:customers)\n customer_hash = {\n #external_id: user.id,\n name: user.first_name,\n last_name: user.last_name,\n email: user.email,\n requires_account: true,\n }\n result_hash = customers.create(customer_hash)\n if result_hash[\"error_code\"]\n raise result_hash[\"error_code\"] \n else\n return result_hash[\"id\"]\n end\n rescue Exception => e\n raise \"Error creando usuario en Openpay - #{e.message}\"\n end\n end",
"def associate_with_user\n if user_id.nil? || user.email == Address::PLACEHOLDER_EMAIL\n self.user_id = User.find_or_create_by_details(\n email: email_address, name: billing_full_name\n ).id\n end\n end",
"def existing_user_by_get_an_identity_id\n return if get_an_identity_id.blank?\n return if user_with_get_an_identity_id.blank?\n\n if user_with_email.present?\n if user_with_email == user_with_get_an_identity_id\n return response_with_user(user_with_get_an_identity_id)\n else\n return user_with_get_an_identity_id_different_to_user_with_email_response\n end\n end\n\n user_with_get_an_identity_id.update!(email:)\n response_with_user(user_with_get_an_identity_id)\n end",
"def find_or_create_user(params, relocation)\n if User.exists?(email: params[:user][:email])\n User.find_by_email params[:user][:email]\n else\n relocation.create_user params[:user]\n end\n end",
"def acts_as_universal_and_determines_user()\n include ::Milia::InviteMember\n has_and_belongs_to_many :accounts\n\n acts_as_universal()\n\n # validate that a account exists prior to a user creation\n before_create do |new_user|\n if Thread.current[:account_id].blank? ||\n !Thread.current[:account_id].kind_of?(Integer) ||\n Thread.current[:account_id].zero?\n\n raise ::Milia::Control::InvalidAccountAccess,\"no existing valid current account\"\n\n end\n end # before create callback do\n\n # before create, tie user with current account\n # return true if ok to proceed; false if break callback chain\n after_create do |new_user|\n account = Account.find( Thread.current[:account_id] )\n unless account.users.include?(new_user)\n account.users << new_user # add user to this account if not already there\n end\n\n end # before_create do\n\n before_destroy do |old_user|\n old_user.accounts.clear # remove all accounts for this user\n true\n end # before_destroy do\n\n end",
"def _user_add f = {}\n\t\tf[:salt] \t\t= _random_string 5\n\t\tf[:created] \t= Time.now\n\n\t\trequire \"digest/sha1\"\n\t\tf[:pawd] \t\t= Digest::SHA1.hexdigest(f[:pawd] + f[:salt])\n\n\t\t_throw L[:'the user is existing'] if _user? f[:name]\n\n\t\tDB[:_user].insert(f)\n\t\tuid = DB[:_user].filter(:name => f[:name]).get(:uid)\n\t\tuid ? uid : 0\n\tend",
"def create_user_account\n Account.cache_or_create_by! @current_user\n rescue => e\n log_error(e, account: 'cannot_create_unique_account_record')\n end",
"def find_or_create_user\n name = get_user_name\n while name == nil\n puts ''\n puts \"*** Please enter a valid name. ***\".colorize(:color => :red)\n puts ''\n name = get_user_name\n end\n @user = User.find_or_create_by(name: name)\n @id = @user.id\n end",
"def create_user_and_accounts\n User.create(uuid: @auth_payload[:sub]) unless current_user\n AccountsGenerator.generate_accounts_for_user(current_user) if Account.for_user(current_user).empty?\n end",
"def check_user(user_name)\n\tUser.find_or_create_by(name: user_name)\nend",
"def find_or_create_user(extractor)\n Email.find_by_email(extractor.email).try(:user) ||\n IclaSignature.find_by_email(extractor.email).try(:user) ||\n User.create! do |user|\n user.first_name = extractor.first_name\n user.last_name = extractor.last_name\n end\n end",
"def find_or_create_identity!(auth)\n ident = Identity.from_oauth auth\n\n # Identity already exist. Make sure it's valid...\n if ident.persisted? && ident.user != self\n raise \"Identity is associated with another user (#{ident.user}).\"\n end\n\n ident.user = self\n ident.save!\n ident\n end",
"def create_account_for_user\n # # if age.exists?\n # balance = age >= 18 ? 350 : 250\n # create_account(balance: balance)\n # # end\n create_account(balance: 250)\n end",
"def associate_user(service, user, external_user_id, external_user_password)\n case service.booking_profile\n when AGENCY[:ecolane]\n ecolane_profile = service.ecolane_profile\n\n es = EcolaneServices.new\n result, first_name, last_name = es.validate_passenger(external_user_id, external_user_password, ecolane_profile.system, ecolane_profile.token)\n if result\n #For Ecolane, we create a new user if the user doesn't exist\n user_service = get_or_create_ecolane_traveler(external_user_id, external_user_password, service, first_name, last_name)\n end\n return result, user_service\n\n when AGENCY[:trapeze]\n trapeze_profile = service.trapeze_profile\n ts = TrapezeServices.new\n result = ts.pass_validate_client_password(trapeze_profile.endpoint, trapeze_profile.namespace, trapeze_profile.username, trapeze_profile.password, external_user_id, external_user_password)\n us = nil\n if result\n us = UserService.where(service: service, user_profile: user.user_profile).first_or_initialize\n us.external_user_id = external_user_id\n us.user_password = external_user_password\n us.save\n end\n return result, us\n when AGENCY[:ridepilot]\n ridepilot_profile = service.ridepilot_profile\n rs = RidepilotServices.new\n result, body = rs.authenticate_customer(ridepilot_profile.endpoint, ridepilot_profile.api_token, ridepilot_profile.provider_id, external_user_id, external_user_password)\n us = nil\n if result\n us = UserService.where(service: service, user_profile: user.user_profile).first_or_initialize\n us.external_user_id = external_user_id\n us.user_password = external_user_password\n us.save\n end\n return result, us\n end\n end",
"def user(id)\n if id\n cached_user = users.detect {|u| u[:id] == id }\n user = cached_user || fetch_user(id)\n self.users << user\n user\n end\n end",
"def identity_create\n # Potential threat of overlap\n identity = Identity.create(uid:rand(100000000..9999999999), provider: 'registration')\n identity.user_id = resource.id\n identity.name = params['user']['name'] #Looks very ugly\n identity.email = resource.email\n identity.save\n end",
"def create_new_user_and_identity(auth, params)\n user = User.create!(\n first_name: auth.info[:first_name],\n last_name: auth.info[:last_name],\n email: auth.info[:email],\n oauth_signup: true,\n # referred_by_user_id => params.andand[\"rid\"]\n )\n user.confirm!\n create_new_identity(user, auth)\n end",
"def get_user_from_db(user)\n User.find_or_create_by(name: user)\nend"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
batch process a group of SOLR works
|
def batched_process_solr_works( solr_works, &f )
solr_works.each do |gw_solr|
begin
gw = LibraWork.find( gw_solr['id'] )
f.call( gw )
rescue => e
puts e
end
end
end
|
[
"def batched_process_solr_works( solr_works, &f )\n\n solr_works.each do |gw_solr|\n begin\n gw = GenericWork.find( gw_solr['id'] )\n f.call( gw )\n rescue => e\n puts e\n end\n end\n\n end",
"def run_bulk; end",
"def perform\n Rails.logger.info \"<< Scanning for new batch packages in existing collections >>\"\n Admin::Collection.all.each do |collection|\n Avalon::Batch::Ingest.new(collection).scan_for_packages\n end\n end",
"def solrize_objects(opts={})\n # retrieve a list of all the pids in the fedora repository\n num_docs = 1000000 # modify this number to guarantee that all the objects are retrieved from the repository\n puts \"WARNING: You have turned off indexing of Full Text content. Be sure to re-run indexer with @@index_full_text set to true in main.rb\" if index_full_text == false\n\n if @@index_list == false\n \n objects = ::Fedora::Repository.instance.find_objects(:limit=>num_docs)\n\n puts \"Shelving #{objects.length} Fedora objects\"\n objects.each do |object|\n solrize( object, opts )\n end\n \n else\n \n if File.exists?(@@index_list)\n arr_of_pids = FasterCSV.read(@@index_list, :headers=>false)\n \n puts \"Indexing from list at #{@@index_list}\"\n puts \"Shelving #{arr_of_pids.length} Fedora objects\"\n \n arr_of_pids.each do |row|\n pid = row[0]\n solrize( pid )\n\t end #FASTERCSV\n else\n puts \"#{@@index_list} does not exists!\"\n end #if File.exists\n \n end #if Index_LISTS\n end",
"def handle_batch_multiple_actions\n # TODO: improve handling of errors in the batch response\n actions = []\n @batch.each do |action|\n actions << to_query(action[:params])\n end\n\n results = really_make_call({'method' => 'batch.run','methodFeed' => JSON.dump(actions)}, :post)\n @batch = nil\n extract_session_key results\n results\n end",
"def indexAllItems\n begin\n Thread.current[:name] = \"index thread\" # label all stdout from this thread\n batch = emptyBatch({})\n\n # The resolver and catalog stuff below is to prevent BioMed files from loading external DTDs\n # (which is not only slow but also unreliable)\n classPath = \"/apps/eschol/erep/xtf/WEB-INF/lib/saxonb-8.9.jar:\" +\n \"/apps/eschol/erep/xtf/control/xsl/jing.jar:\" +\n \"/apps/eschol/erep/xtf/normalization/resolver.jar\"\n Nailgun.run(classPath, 0, \"-Dxml.catalog.files=/apps/eschol/erep/xtf/normalization/catalog.xml\") { |nailgun|\n loop do\n # Grab an item from the input queue\n Thread.current[:name] = \"index thread\" # label all stdout from this thread\n itemID, timestamp = $indexQueue.pop\n itemID or break\n\n # Extract data and index it (in batches)\n begin\n Thread.current[:name] = \"index thread: #{itemID}\" # label all stdout from this thread\n indexItem(itemID, timestamp, batch, nailgun)\n rescue Exception => e\n puts \"Error indexing item #{itemID}\"\n raise\n end\n\n # To avoid Saxon's Java process from growing gigantic, restart it once in a while.\n nailgun.callCount == 1000 and nailgun.restart\n end\n }\n\n # Finish off the last batch.\n batch[:items].empty? or $batchQueue << batch\n rescue Exception => e\n puts \"Exception in indexAllItems: #{e} #{e.backtrace}\"\n ensure\n $batchQueue << nil # marker for end-of-queue\n end\nend",
"def rebuild_solr_index(batch_size=300, options = {}, &finder)\n finder ||= lambda do |ar, sql_options|\n ar.all sql_options.merge!({:order => self.primary_key, :include => configuration[:solr_includes].keys})\n end\n start_time = Time.now\n options[:offset] ||= 0\n options[:threads] ||= 2\n options[:delayed_job] &= defined?(Delayed::Job)\n\n if batch_size > 0\n items_processed = 0\n offset = options[:offset]\n end_reached = false\n threads = []\n mutex = Mutex.new\n queue = Queue.new\n loop do\n items = finder.call(self, {:limit => batch_size, :offset => offset})\n add_batch = items.collect { |content| content.to_solr_doc }\n offset += items.size\n end_reached = items.size == 0\n break if end_reached\n\n if options[:threads] == threads.size\n threads.first.join \n threads.shift\n end\n\n queue << [items, add_batch]\n threads << Thread.new do\n iteration_start = Time.now\n\n iteration_items, iteration_add_batch = queue.pop(true)\n if options[:delayed_job]\n delay.solr_add iteration_add_batch\n else\n solr_add iteration_add_batch\n solr_commit\n end\n\n last_id = iteration_items.last.id\n time_so_far = Time.now - start_time\n iteration_time = Time.now - iteration_start \n mutex.synchronize do\n items_processed += iteration_items.size\n if options[:delayed_job]\n logger.info \"#{Process.pid}: #{items_processed} items for #{self.name} have been sent to Delayed::Job in #{'%.3f' % time_so_far}s at #{'%.3f' % (items_processed / time_so_far)} items/sec. Last id: #{last_id}\"\n else\n logger.info \"#{Process.pid}: #{items_processed} items for #{self.name} have been batch added to index in #{'%.3f' % time_so_far}s at #{'%.3f' % (items_processed / time_so_far)} items/sec. Last id: #{last_id}\"\n end\n end\n end\n end\n\n solr_commit if options[:delayed_job]\n threads.each{ |t| t.join }\n else\n items = finder.call(self, {})\n items.each { |content| content.solr_save }\n items_processed = items.size\n end\n\n if items_processed > 0\n solr_optimize\n time_elapsed = Time.now - start_time\n logger.info \"Index for #{self.name} has been rebuilt (took #{'%.3f' % time_elapsed}s)\"\n else\n \"Nothing to index for #{self.name}\"\n end\n end",
"def batch_add_document_packages(current_batch)\n begin\n a = current_batch.collect {|package| package.solr_document }\n solr_server.add( a )\n\n $stderr.write \"%\" if @debug_ascii_progress\n rescue Exception => e\n # Error in batch, none of the docs got added, let's try to re-add\n # em all individually, so those that CAN get added get added, and those\n # that can't get individually logged.\n logger.warn \"Error encountered in batch solr add, will re-try documents individually, at a performance penalty...\\n\" + Traject::Util.exception_to_log_message(e)\n current_batch.each do |package|\n add_one_document_package(package)\n end\n end\n end",
"def indexAllItems\n begin\n Thread.current[:name] = \"index thread\" # label all stdout from this thread\n batch = emptyBatch({})\n\n # The resolver and catalog stuff below is to prevent BioMed files from loading external DTDs\n # (which is not only slow but also unreliable)\n classPath = \"/apps/eschol/erep/xtf/WEB-INF/lib/saxonb-8.9.jar:\" +\n \"/apps/eschol/erep/xtf/control/xsl/jing.jar:\" +\n \"/apps/eschol/erep/xtf/normalization/resolver.jar\"\n Nailgun.run(classPath, 0, \"-Dxml.catalog.files=/apps/eschol/erep/xtf/normalization/catalog.xml\") { |nailgun|\n loop do\n # Grab an item from the input queue\n Thread.current[:name] = \"index thread\" # label all stdout from this thread\n itemID = $indexQueue.pop\n itemID or break\n\n # Extract data and index it (in batches)\n begin\n Thread.current[:name] = \"index thread: #{itemID}\" # label all stdout from this thread\n indexItem(itemID, batch, nailgun)\n rescue Exception => e\n puts \"Error indexing item #{itemID}\"\n raise\n end\n\n # To avoid Saxon's Java process from growing gigantic, restart it once in a while.\n nailgun.callCount == 1000 and nailgun.restart\n end\n }\n\n # Finish off the last batch.\n batch[:items].empty? or $batchQueue << batch\n rescue Exception => e\n if $preindexMode\n raise e\n else\n puts \"Exception in indexAllItems: #{e} #{e.backtrace}\"\n end\n ensure\n $batchQueue << nil # marker for end-of-queue\n end\nend",
"def transform_and_load_compounds!\n compound_records.each_slice(batch_size) do |compound_records_batch|\n transformer_worker_klass.perform_async(\n compound_records_batch,\n solr_config,\n cdm_endpoint,\n oai_endpoint,\n field_mappings,\n batch_size\n )\n end\n end",
"def process(requests)\n by_broker = requests.group_by {|request| broker_for(request)}\n\n if by_broker.count > 1 && @cluster.config.parallel_batches\n # Run in separate threads for parallelism\n by_broker.map do |broker, requests|\n Thread.new do\n process_broker(broker, requests)\n end\n end.each(&:join)\n else\n # Run in current thread\n by_broker.each do |broker, requests|\n process_broker(broker, requests)\n end\n end\n end",
"def perform_processing_run(faids)\n perform_analysis(faids)\n perform_processing!\n end",
"def test_using_rebuild_solr_index_with_batch\n assert_equal 2, Movie.count_by_solr('office OR napoleon')\n Movie.find(:all).each(&:solr_destroy)\n assert_equal 0, Movie.count_by_solr('office OR napoleon')\n\n Movie.rebuild_solr_index 100\n assert_equal 2, Movie.count_by_solr('office OR napoleon')\n end",
"def work_transform( work_hashes )\n\n res = []\n work_hashes.each do |w|\n res << SolrDocument.new( w )\n end\n return res\n end",
"def process_foreach(options, filter, vars)\n agent = rpcclient('rpcutil')\n set_filter(agent, filter, vars)\n nodes = agent.discover\n nodes.each do |node|\n options['tasks'].each do |task|\n vars.merge!('node' => node)\n process_task(task, {:discovery => [node]}, vars)\n end\n end\nend",
"def processing_batches(w)\n dir = join(@basedir, DIR_PROCESSING)\n w.sftp.dir[dir, '*'].map do |entry|\n Model::Batch.new(:path => join(dir, entry.name), :state => :processing)\n end\n end",
"def update_works\n batch.each do |doc_id|\n obj = ActiveFedora::Base.find(doc_id, :cast=>true)\n previous_visibility = obj.visibility\n update_document(obj)\n obj.save\n VisibilityCopyJob.perform_later(obj) unless previous_visibility == obj.visibility\n InheritPermissionsJob.perform_later(obj) if work_params.fetch(:permissions_attributes, nil)\n end\n flash[:notice] = \"Batch update complete\"\n after_update\n end",
"def bulk_update_document index, data\n Parallel.each( data.each_slice(4), in_threads: ENV['NUMBER_OF_THREADS'].to_i ) do |slice|\n # Hardcoded for slice of 4 elements, of which we need to combine 2\n enriched_slice = slice.map do |document|\n { doc: document, serialization: document.to_json }\n end\n\n nested_slice = []\n\n if enriched_slice.any? { |s| s[:serialization].length > 50_000_000 }\n log.debug(\"Splitting bulk update document into separate requests because one document more than 50Mb\")\n enriched_slice.each_slice(2) do |tuple|\n nested_slice << tuple\n end\n else\n nested_slice = [enriched_slice]\n end\n\n nested_slice.each do |enriched_postable_slice|\n begin\n uri = URI(\"http://#{@host}:#{@port_s}/#{index}/_doc/_bulk\")\n req = Net::HTTP::Post.new(uri)\n body = \"\"\n enriched_postable_slice.each do |enriched_document|\n body += enriched_document[:serialization] + \"\\n\"\n end\n req.body = body\n\n req[\"Content-Type\"] = \"application/x-ndjson\"\n\n run(uri, req)\n rescue SocketError => e\n log.warn(e)\n tries = 1\n while ! up\n log.info \"Waiting for elastic search\"\n sleep tries\n tries +=1\n end\n log.debug \"Retrying request\"\n run(uri, req)\n rescue StandardError => e\n log.warn( \"Failed to upload #{enriched_postable_slice.length} documents\" )\n\n ids = enriched_postable_slice.map do |enriched_document|\n enriched_document && enriched_document[:doc][:index] && enriched_document[:doc][:index][:_id]\n end\n\n log.warn( e )\n log.warn( \"Failed to upload documents #{ids.join(\", \")} with total length #{body.length}\" )\n log.warn( \"Failed documents #{ids.join(\", \")} are not ginormous\" ) if body.length < 100_000_000\n end\n end\n end\n end",
"def all_works\n #start = numeric( params[:start], DEFAULT_START )\n #limit = numeric( params[:limit], DEFAULT_LIMIT )\n\n works = batched_get( {} )\n respond_to do |format|\n format.json do\n if works.empty?\n render_json_works_response(:not_found )\n else\n # dont provide fileset information here, it takes too long and we just want work information\n render_json_works_response(:ok, work_transform( works, EXCLUDE_FILESETS ) )\n end\n end\n format.csv do\n # provide fileset information here because this is used for work export\n render_csv_works_response( work_transform( works, INCLUDE_FILESETS ) )\n end\n end\n\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
show full details of a libra work
|
def show_libra_work( work )
return if work.nil?
j = JSON.parse( work.to_json )
j.keys.sort.each do |k|
val = j[ k ]
if k.end_with?( '_id' ) == false && k.end_with?( '_ids' ) == false
show_field( k, val, ' ' )
end
end
show_field( 'visibility', work.visibility, ' ' )
Author.sort( work.authors ).each_with_index do |p, ix|
show_person( " author #{ix + 1}:", p )
end
Contributor.sort( work.contributors ).each_with_index do |p, ix|
show_person( " contributor #{ix + 1}:", p )
end
if work.file_sets
file_number = 1
fs = work.file_sets.sort { |x, y| x.date_uploaded <=> y.date_uploaded }
fs.each do |file_set|
puts " file #{file_number} => #{file_set.label}/#{file_set.title[0]} (/downloads/#{file_set.id})"
file_number += 1
end
end
puts '*' * 40
end
|
[
"def workspace_info\n link_to_workspace_info(\"http://library.nyu.edu/info/myworkspace.html\", \"left\")\n end",
"def show_generic_work( work )\n\n return if work.nil?\n j = JSON.parse( work.to_json )\n j.keys.sort.each do |k|\n val = j[ k ]\n if k.end_with?( \"_id\" ) == false\n show_field( k, val )\n end\n end\n\n show_field( 'visibility', work.visibility )\n #show_field( 'embargo_end_date', work.embargo_end_date )\n #show_field( 'embargo_release_date', work.embargo_end_date )\n show_field( 'registrar_computing_id', work.registrar_computing_id )\n show_field( 'sis_id', work.sis_id )\n show_field( 'sis_entry', work.sis_entry )\n\n if work.file_sets\n file_number = 1\n work.file_sets.each do |file_set|\n puts \" file #{file_number} => #{file_set.label}/#{file_set.title[0]} (/downloads/#{file_set.id})\"\n file_number += 1\n end\n end\n\n puts '*' * 40\n\n end",
"def display_help\n puts \"Dev Sync : report or sync your development files\"\n puts \" report nas_directory(optional)\"\n puts \" sync reported_file_name\"\nend",
"def show_repo_info_full (repo, verbose)\n name=File.basename(repo.workdir)\n Display::show \"► #{name}\", :title\n Display::show \" (#{repo.workdir})\", :info\n\n if verbose >= Display::VERBOSE_LIGHT\n # Rugged::Repository repo\n Display::show ' • Remotes :', :title2\n repo.remotes.each { |remote|\n Display::show \" » #{remote.name} (#{remote.url})\", :notice\n }\n if verbose >= Display::VERBOSE_MEDIUM\n Display::show ' • Local Branches :', :title2\n repo.branches.each(:local) { |branch|\n show_branch(branch, repo, true)\n Display::show ''\n }\n if verbose >= Display::VERBOSE_FULL\n Display::show ' • Remote Branches :', :title2\n repo.branches.each(:remote) { |branch|\n show_branch(branch, repo, false)\n Display::show ''\n }\n end\n end\n Display::show \"----\"\n end\n end",
"def about_worker\n print \"Name-#{name}, Specialty-#{@specialty}, Experience-#{@experience}\"\n end",
"def display_usage\n end",
"def show_prepare_workspace\n show do\n title 'Prepare workspace'\n\n note \"All tasks in this protocol occur in the #{RNA_FREE_WORKSPACE}.\"\n note 'As you retrieve reagents, place them on ice or in a cold-block.'\n end\n end",
"def workspace_diagnostics; end",
"def details\n lid = params[:id]\n @experiments = get_library_experiments_details(lid)\n render json: {\n experiments_html: render_to_string(partial: \"shared/details_experiments\")\n }\n end",
"def more_info; end",
"def get_work_details work_id\n work = current_user.works.find_by_id( work_id )\n work_description = {'title'=> 'date', 'desc'=>'work description'}\n if work\n work_description[:title] = work.from.strftime(\"%F %H:%M-\") + work.to.strftime(\"%H:%M\")\n work_description[:desc] = \"Description: \" + work.description + \". Duration: \" + work.duration.to_s + \" min.\"\n end\n work_description\n end",
"def show_job_details(job)\n @scraper.scrape_details(job)\n job.print_info\n job\n end",
"def display_summary\n self.directory_name + ' -> ' + self.board.platform.name + ' / ' +\n self.board.project.name\n end",
"def show_status\n puts \"You want '#{@target_gem}' at version #{@target_version}. Currently it's at:\"\n @repos.each do |repo|\n puts \"%s : %s\" % [repo.version(@target_gem), repo.path]\n end\n end",
"def print_detail(org_name)\n org = @organizations[org_name]\n print \"Agent : \", org.org_name, \"\\n\"\n activities = org.org_activities\n activities.each do |activity|\n if activity != nil\n print \" Activity : \", activity.name, \"\\n\"\n print \" URL: \", activity.url_fragment, \"\\n\"\n print \" OP_TEMPO: \", activity.op_tempo, \" \"\n print \" START_OFFSET: \", activity.start_offset, \" \"\n print \" END_OFFSET: \", activity.end_offset, \"\\n\"\n end\n end\n end",
"def overview\n storage.lists.each do |project|\n output \" #{project.name} (#{project.items.size})\"\n end\n\n s = \"You don't have anything yet! To start out, create a new project:\"\n s << \"\\n $ looper <project-name>\"\n s << \"\\nAnd then assigns a new source to your project!\"\n s << \"\\n $ looper <project-name> src <value>\"\n s << \"\\nYou can then take a peek at project:\"\n s << \"\\n $ looper <project-name> peek\"\n output s if storage.lists.size == 0\n end",
"def results\r\n print_books\r\n print_toys\r\n print_classes\r\n end",
"def show_test_results(testrun_name)\n depends :init\n\n if testrun_name.strip.downcase == 'latest'\n record = TestRunRecord.latest_record(@build_results.build_dir, @module_set)\n else\n record = named_testrun_record(testrun_name)\n end\n\n puts record.dump\n end",
"def display_info(book)\n puts \"Title: #{book.format_title}\"\n puts \"Author: #{book.author}\"\n puts \"Description: #{book.description}\"\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
show the contents of a person subfield
|
def show_person( title, person )
#puts "#{title} #{person}"
puts "#{title}"
show_field( 'ix', person.index, ' ' )
show_field( 'cid', person.computing_id, ' ' )
show_field( 'first_name', person.first_name, ' ' )
show_field( 'last_name', person.last_name, ' ' )
show_field( 'department', person.department, ' ' )
show_field( 'institution', person.institution, ' ' )
end
|
[
"def field_content\n f = ''\n subfields.each do |sf|\n f += \"|#{sf.code}#{sf.value}\"\n end\n f\n end",
"def render_marc_subfields(field)\n content_tag(:div, class: 'subfields') do\n field.map { |sf| render_marc_subfield(sf) }.join(\"\\n\").html_safe\n end\n end",
"def add_show_field(*) super end",
"def render_person_info(person)\n partial :sidebar_person_info, :locals => {:person => person}\n end",
"def display_fields\n @form.fields.each {|f| puts f.name}\n end",
"def subfield(tag)\n subfields.find { |sf| sf.tag == tag.to_s }\n end",
"def display_fields\n @form.fields.each {|f| puts f.name}\n end",
"def telecom_fields\n @template.render 'telecoms/edit', :parent => self, :telecom => object.telecom\n end",
"def render_document_show_field_value field, options={}\n super\n end",
"def render_document_show_field_label *args\n options = args.extract_options!\n document = args.first\n\n field = options[:field]\n\n html_escape document_show_fields(document)[field].label\n end",
"def localized_info_field(f, name, lang = current_person.locale) # :nodoc:\n render({:partial => '/partials/localized_info_form_content',\n :locals => {:f => f, :name => name, :lang => lang}})\n end",
"def address_fields\n @template.render 'addresses/edit', :parent => self, :address => object.address\n end",
"def sub_field(named, human_name = nil, &block)\n human_name ||= named\n @sub_fields << QueryBuilder::Field.new(named, human_name, self.depth+1, &block)\n end",
"def display_for(object, field_name)\n fdef = field_called(field_name)\n fdef.display_proc.call(fdef.reader_proc.call(object))\n end",
"def field_content record, field\n\t return '' if field == :socioeconomically_disadvantaged && hide_socioeconomic_status\n\t content = auto_link(cell_content(record, field))\n\t content_tag(:p, content_tag(:b, field.to_s.titleize) << content)\n\tend",
"def bio\n Section::Bio.new(person).data\n end",
"def subtitle_fields\n %i[subtitle]\n end",
"def custom_field(label, contents)\r\n render_field(label, {}, contents)\r\n end",
"def each_field\n each_name do |fieldname|\n yield SubTextField.new(fieldname)\n end\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
show a field if it is not empty
|
def show_field( name, val, indent )
return if val.nil?
return if val.respond_to?( :empty? ) && val.empty?
puts "#{indent}#{name} => #{val}"
end
|
[
"def show_field( name, val )\n return if val.nil?\n return if val.respond_to?( :empty? ) && val.empty?\n puts \" #{name} => #{val}\"\n end",
"def field_check_display(item, field)\n return true if item.item_type.display_emtpy_fields\n\n if %w[Field::Geometry Field::File Field::Image Field::Embed].include?(field.type)\n field_presenter(item, field).value?\n else\n strip_tags(field_value(item, field)).present?\n end\n end",
"def filled_fields\n fields.select { |f| !f.value.nil? && f.value != '' }\n end",
"def no_show?(fld, options)\n fld_value(fld).nil? && read_only(options) && @options[:show_nil] == false\n end",
"def not_null_field\n msg = \"<div style='display:inline;'>\"\n msg += image_tag(icon16('bullet_red'),\n \"data-toggle\" => 'tooltip',\n \"data-placement\" => 'right',\n :title => I18n.t('required_field'),\n :alt => I18n.t('required_field'),\n :style => 'padding-left:4px;padding-top:4px')\n msg += \"</div>\"\n msg.html_safe\n end",
"def field_empty?(field)\n if field.piece == nil\n return true\n else\n return false\n end\n end",
"def empty?(field_value)\n field_value.nil? || (field_value.respond_to?(:empty?) && field_value.empty?)\n end",
"def allowBlank; end",
"def validate_display_blanks_as(v); end",
"def text_field?(field_name); end",
"def warn_if_any_page_field_is_empty\n warn 'name is empty' if name == ''\n warn 'query_data is empty' if query_date == ''\n warn 'rows is empty' if rows == []\n end",
"def put_field_unless_blank(obj, field, as=nil, &block)\n put_field_unless :blank?, obj, field, as, &block\n end",
"def should_render_show_field?(doc, field_def)\n document_has_value?(doc, field_def) && should_render_field?(field_def, doc)\n end",
"def show_field?(key)\n !Comatose.config.hidden_meta_fields.include? key\n end",
"def allow_blank?\n true unless allow_blank == false\n end",
"def skip_blanks?(value) #:nodoc:\n ShowFor.skip_blanks && value.blank? && value != false\n end",
"def d(field_value = nil)\n if field_value.blank?\n content_tag('em', 'not specified')\n else\n field_value\n end\n end",
"def blank=(use_blank); end",
"def display_field\n current_field_values_with_field_type_id(field_types.first.id).first.try(:value) || 'no display field available'\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
upload the specified file to the specified work on behalf of the specified user
|
def upload_file( user, work, filename, title, visibility )
print "uploading #{filename}... "
fileset = ::FileSet.new
fileset.title << title unless title.nil?
file_actor = ::CurationConcerns::Actors::FileSetActor.new( fileset, user )
file_actor.create_metadata( work )
file_actor.create_content( File.open( filename ) )
fileset.visibility = visibility
fileset.save!
puts "done"
return fileset
end
|
[
"def upload_file( user, work, filename, title, visibility = Hydra::AccessControls::AccessRight::VISIBILITY_TEXT_VALUE_PUBLIC )\n\n print \"uploading #{filename} (#{title})... \"\n\n fileset = ::FileSet.new\n fileset.title << title unless title.nil?\n file_actor = ::CurationConcerns::Actors::FileSetActor.new( fileset, user )\n file_actor.create_metadata( work )\n file_actor.create_content( File.open( filename ) )\n fileset.visibility = visibility\n fileset.save!\n\n puts \"done\"\n return fileset\n\n end",
"def file_upload(params_userfile)\n content_upload(params_userfile.read)\n end",
"def creator_upload(username, file_name, file)\r\n dir = \"creators/#{username}\"\r\n file.original_filename = file_name + (File.extname file.original_filename)\r\n return write(dir, file)\r\n end",
"def upload_file(upload, user, client_name)\n if upload != nil\n if user.link_picture != nil\n File.delete('public/images/' << user.link_picture)\n end\n name = upload['img'].original_filename\n directory = 'public/images/' + client_name + '/users/' + user.username\n path = File.join(directory, name)\n File.open(path, 'wb') { |f| f.write(upload['img'].read) }\n path_img = client_name + '/users/' + user.username + '/' + name\n User.where(:id => user.id).update_all(link_picture: path_img)\n end\n end",
"def upload_profile(config, owner, profile_name, path)\r\n Compliance::API.upload(config, owner, profile_name, path)\r\nend",
"def upload\n user = current_user\n # Get params from the request\n picture = upload_image_params\n # Convert Base64 to binary data\n picture_bin = Base64.decode64(picture[:base64])\n picture_name = picture[:fname]\n # Create a new file for saving image\n file_name = Time.new.to_s.gsub!(' ', '_') + '.jpg' \n file_name_rpath = File.join('public', 'uploads', file_name)\n image_file = File.new(file_name_rpath, File::CREAT|File::TRUNC|File::RDWR, 0644)\n image_file.syswrite(picture_bin)\n image_file.close()\n # Update image file name to user object\n user.profile_pic = file_name\n user.save\n # Expose to response\n @pub_filename = file_name\n end",
"def upload\n end",
"def upload_profile(config, owner, profile_name, path)\n Compliance::API.upload(config, owner, profile_name, path)\nend",
"def perform(server)\n server.upload_file(self, @target_path, @file_contents)\n end",
"def transmit_file\n Net::SFTP.start(ENV['PROQUEST_SFTP_HOST'], ENV['PROQUEST_SFTP_USER'], password: ENV['PROQUEST_SFTP_PASSWORD']) do |sftp|\n Rails.logger.debug \"Uploading #{@upload_file} to ProQuest\"\n sftp.upload!(@upload_file, \"#{@work.upload_file_id}.zip\")\n end\n end",
"def auth_multipart_req(params, user = nil)\n user ||= create_authed_user\n multipart_req(params, user.create_new_auth_token)\n end",
"def upload_roster\n end",
"def share_file_with_user(user_id, file_id)\n $db.execute(\"INSERT INTO shared_files (user_id, file_id) VALUES (?, ?)\", user_id, file_id)\nend",
"def upload_file\n\tproject = self.use_case.project\n\n\tfile = url_path.read\n whole_name = url_path.original_filename\n final_name = self.name + \".v1.0\" + File.extname(whole_name)\n file_path = project.name + \"/UseCases/\" + self.name + \"/\" + final_name\n dbsession = DropboxSession.deserialize(project.dropbox_token)\n client = DropboxClient.new(dbsession)\n response = client.put_file(file_path, file)\n link = client.shares(response[\"path\"])\n self.url_path = link[\"url\"]\n end",
"def upload_file\n project = self.task.project\n task = self.task\n\n file = url_path.read\n self.original_name = url_path.original_filename\n self.version = DocumentTask.where(:name => self.name).count + 1\n\n final_name = \"#{self.name}.v#{self.version}#{File.extname(original_name)}\"\n file_path = project.name + \"/\" + task.name + \"/\" + final_name\n dbsession = DropboxSession.deserialize(project.dropbox_token)\n client = DropboxClient.new(dbsession)\n response = client.put_file(file_path, file)\n link = client.shares(response[\"path\"])\n self.url_path = link[\"url\"]\n end",
"def file_upload(*paths); net_scp_transfer!(:upload, false, *paths); end",
"def do_upload(f_path, r_path)\n with_exp_backoff(LokaliseRails.max_retries_export) do\n api_client.upload_file project_id_with_branch, opts(f_path, r_path)\n end\n end",
"def upload_media_file( wikipath, filename, raw )\n p filename\n headers = {\n 'Content-Type' => 'application/octet-stream',\n 'X-File-Name' => filename\n }\n url = upload_url( wikipath, filename )\n p url\n wait_second\n pp @agent.post( url, raw, headers )\n save_uploaded( filename )\n end",
"def upload(moss_server, to_upload, id = 0, option = { is_file: true })\n\t\tif option[:is_file]\n\t\t\tfilename = to_upload.strip.encode('UTF-8', invalid: :replace, undef: :replace, replace: '').gsub /[^\\w\\-\\/.]/, '_'\n\t\t\tcontent = IO.read(to_upload)\n\t\telse\n\t\t\t# Moss server need a file name, so when isn't a file that is been uploaded\n\t\t\t# (and so haven't a name), a random name is generated.\n\t\t\tfilename = (0...15).map { ('a'..'z').to_a[rand(26)] }.join\n\t\t\tcontent = to_upload\n\t\tend\n\n\t\tsize = content.size\n\n\t\tif size > 0\n\t\t\tmoss_server.write \"file #{id} #{@options[:language]} #{size} #{filename}\\n\"\n\t\t\tmoss_server.write content\n\t\tend\n\tend"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
load a file containing xml data and return an oga document
|
def load_xml_doc( filename )
File.open( filename, 'r') do |file|
return Oga.parse_xml( file )
end
puts "ERROR: loading #{filename}"
return nil
end
|
[
"def load_xml_doc( filename )\n File.open( filename, 'r') do |file|\n return Oga.parse_xml( file )\n end\n end",
"def load_xml file\n f = File.open file\n doc = Nokogiri::XML f\n f.close\n doc\n end",
"def get_xml_data\n begin\n file = File.open(@xml_file)\n @document = Nokogiri::XML(file)\n file.close\n rescue Exception => e\n throw e.message\n end\n end",
"def load_xml_document file_name\n xml_file = File.new file_name, \"r\"\n return Document.new xml_file\n end",
"def loadXML(file)\n\txmlfile = File.new(file.strip)\n\txmldoc = Document.new(xmlfile)\n\txmldoc.root\t\nend",
"def load_xml(file_path)\n # Read the source XML file.\n puts \"file_path: #{file_path}\"\n raw_xml = File.read(file_path)\n\n # Parse raw_xml using Nokogiri.\n parsed_doc = Nokogiri.XML(raw_xml)\nend",
"def parse_file\n tempfile = gpx.queued_for_write[:original]\n doc = Nokogiri::XML(tempfile)\n parse_xml(doc)\n end",
"def nokogiri_xml(file_path)\n Nokogiri::XML(File.open(file_path), nil, 'UTF-8')\n end",
"def read_xml(file)\n file.open { |f| REXML::Document.new f }\n end",
"def load_doc file_name\n\n file = File.open(file_name, \"r\")\n data = file.read\n file.close\n\n @log.info \"Nokogiri tries to load the file\"\n @doc = Nokogiri::HTML data if file_name.end_with? \"html\"\n @doc = Nokogiri::XML data if file_name.end_with? \"xml\"\n\n if @doc.nil?\n raise 'Nokogiri could not handle the format (xml / html) ?'\n end\n end",
"def load_xml_file(filename)\n parse(File.readlines(filename).to_s)\n end",
"def load_slideshow_xml\n File.open(self.path, \"r\") do |slideshow_file|\n # We want strict parsing to ensure we are given a valid XML file\n @xml_doc = Nokogiri::XML(slideshow_file) do |config|\n config.strict\n end\n end\n end",
"def read(xml_path) \n @file = Nokogiri::XML(File.open(xml_path)){ |cfg| cfg.noblanks } \n end",
"def DataLoadFromFile(filename)\n file = File.new(filename)\n \n @xml_data = file\n self.ScrapAnalyse()\n end",
"def load_xml(source)\n #begin\n if source.is_a? Nokogiri::XML::Document\n @document = source\n else\n #source =~ /\\<DIF\\>/\n if source.size < 255 and File.exists? source\n source = File.read source\n end\n @document = Nokogiri::XML::Document.parse( source, nil, nil ) #, Nokogiri::XML::ParseOptions::NOBLANKS\n end\n # Sets all properties like Entry_ID for this instance\n load_hash(document_to_hash)\n \n #rescue => e\n #puts e.backtrace\n #raise ArgumentError, \"Cannot load DIF XML: \" + e.message[0..255]\n #end\n end",
"def load_workspace file\r\n raise LoadError, \"File does not exist at:\\n#{file}\" unless File.exists? file\r\n \r\n doc = nil\r\n File.open file, 'r' do |f|\r\n doc = REXML::Document.new f\r\n end\r\n \r\n parse_xml_element doc\r\n end",
"def parse\n file = File.open(@file_name)\n @doc = Nokogiri::XML(wrap(file.readlines)) do |config|\n config.strict\n end\n rescue\n log(\"Error parsing file #{@file_name}, couldn't continue. Probably faulty HTML\")\n ensure\n file.close\n end",
"def initialize(file_content)\n # Open XML file\n self.fichero = file_content\n # Initialize XML Document\n @doc = Document.new self.fichero\n # Initialize attribute default values\n self.lista_devoluciones = []\n end",
"def parse\n Ox.parse(@xml)\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
DELETE /ab_teams/1 DELETE /ab_teams/1.json
|
def destroy
@ab_team.destroy
respond_to do |format|
format.html { redirect_to ab_teams_url, notice: 'Record was destroyed.' }
format.json { head :no_content }
end
end
|
[
"def destroy\n @api_team.destroy\n respond_to do |format|\n format.html { redirect_to api_teams_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team = Team.find(params[:id])\n @team.destroy\n\n respond_to do |format|\n format.html { redirect_to teams_url(audit: '0') }\n format.json { head :no_content }\n end\n end",
"def destroy\n team.destroy\n\n respond_to do |format|\n format.html { redirect_to teams_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @test_team = TestTeam.find(params[:id])\n @test_team.destroy\n\n respond_to do |format|\n format.html { redirect_to test_teams_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @team = Team.find(params[:id])\n @team.destroy\n\n respond_to do |format|\n format.html { redirect_to teams_url }\n format.json { head :ok }\n end\n end",
"def delete(_team)\n # stub\n end",
"def destroy\n @ultimate_team = UltimateTeam.find(params[:id])\n @ultimate_team.destroy\n\n respond_to do |format|\n format.html { redirect_to ultimate_teams_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @real_team.destroy\n respond_to do |format|\n format.html { redirect_to real_teams_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bowling_team.destroy\n respond_to do |format|\n format.html { redirect_to bowling_teams_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @teams_test = TeamsTest.find(params[:id])\n @teams_test.destroy\n\n respond_to do |format|\n format.html { redirect_to teams_tests_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @user_team = UserTeam.find(params[:id])\n @user_team.destroy\n\n respond_to do |format|\n format.html { redirect_to user_teams_url }\n format.json { head :no_content }\n end \n end",
"def destroy\n @member_team = MemberTeam.find(params[:id])\n @member_team.destroy\n\n respond_to do |format|\n format.html { redirect_to member_teams_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @afl_team = AflTeam.find(params[:id])\n @afl_team.destroy\n\n respond_to do |format|\n format.html { redirect_to(afl_teams_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @nba_team = NbaTeam.find(params[:id])\n @nba_team.destroy\n\n respond_to do |format|\n format.html { redirect_to nba_teams_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @team = subdomain.teams.find(params[:id])\n @team.destroy\n\n respond_to do |format|\n format.html { redirect_to(teams_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @users_team.destroy\n respond_to do |format|\n format.html { redirect_to users_teams_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @bet_team.destroy\n respond_to do |format|\n format.html { redirect_to bet_teams_url, notice: \"Team was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n match_day_team = MatchDayTeam.find(params[:id])\n match_day_team.destroy\n head 204\n end",
"def delete(team_name_or_team_id)\n @client.team.delete(team_name_or_team_id)\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Denies access for public users to private projects
|
def require_proj_access
if params[:gr]
@project ||= Group.find(params[:gr]).project
else
@project = Project.find(params[:id] || params[:pr])
end
if ((not is_logged?) || current_user.is_public?) && @project.is_private?
flash_msgs(1, "Access denied.")
redirect_to root_path
end
end
|
[
"def project_private! if_metageneration_match: nil\n update_predefined_acl! \"projectPrivate\", if_metageneration_match: if_metageneration_match\n end",
"def project_private! if_metageneration_match: nil\n update_predefined_default_acl! \"projectPrivate\", if_metageneration_match: if_metageneration_match\n end",
"def hide_unpublished_single\n unless @project.viewable_by_user? @current_user\n raise ForbiddenError, error_messages[:forbidden_teacher_only]\n end\n end",
"def check_project_privacy\r\n unless @project.active?\r\n @project = nil\r\n render_404\r\n return false\r\n end\r\n return true if @project.is_public?\r\n return false unless logged_in_user\r\n return true if logged_in_user.admin? || logged_in_user_membership\r\n render_403\r\n false\r\n end",
"def check_project_privacy\n unless @project.active?\n @project = nil\n render_404\n return false\n end\n return true if @project.is_public?\n return false unless logged_in_user\n return true if logged_in_user.admin? || logged_in_user_membership\n render_403\n false\n end",
"def authorize_manageable\n unless @project_group.is_child_of?(@project)\n deny_access\n end\n true\n end",
"def restrict_access\n head :unauthorized and return false unless current_user\n end",
"def restrict_access\t\n\t\tif current_user.owner == false\n\t\t\tredirect_to user_path(current_user), notice: \"You can't view this page, contact your box owner\"\n\t\tend\t\n\tend",
"def cannot_any?(user, projects)\n !can_any?(user, :reader, projects)\n end",
"def check_acess(project, user)\n return true unless project.private\n ProjectMember.member? project, user\n end",
"def deny_project_access_request(project, user_id)\n delete(\"/projects/#{url_encode project}/access_requests/#{user_id}\")\n end",
"def cannot_all?(user, projects)\n !can_all?(user, :reader, projects)\n end",
"def access_forbidden\n false\n end",
"def admin_only\n deny_access(\"Necesitas tener privilegios de administrador para entrar.\") unless signed_in_as_admin?\n end",
"def restrict_access\n redirect_to auth_path unless @current_user\n end",
"def authorize_read_group!\n unless projects.present? or can?(current_user, :manage_group, @group)\n return render_404\n end\n end",
"def current_user_can_edit_public_project?(p = @project)\n logged_in? && current_user.projects_editable_on_public_site.include?(p)\n end",
"def can_access_project?\n developer = Developer.where(gamer_id: current_gamer.id).first\n owned = Project.where(owner_id: developer.id)\n shared = developer.projects_shared\n current_project = Project.find(params[:project_id])\n if !owned.include?(current_project) && !shared.include?(current_project)\n flash[:error] = t(:developer_cant_see_project)\n redirect_to projects_path, flash: flash\n end \n end",
"def skip_authorization; end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
GET /step_commands GET /step_commands.json
|
def index
@step_commands = StepCommand.all
end
|
[
"def get_a_page_of_cli_command_execution_history(args = {}) \n get(\"/commands.json/\", args)\nend",
"def steps\n steps = @request[\"steps\"]\n end",
"def index\n \n @steps = @quest.steps\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @steps }\n end\n end",
"def create\n @step_command = StepCommand.new(step_command_params)\n\n respond_to do |format|\n if @step_command.save\n format.html { redirect_to @step_command, notice: 'Step command was successfully created.' }\n format.json { render :show, status: :created, location: @step_command }\n else\n format.html { render :new }\n format.json { render json: @step_command.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @commands = Command.all\n render :json => @commands\n end",
"def commands\n require 'launchy'\n Launchy.open('https://github.com/igvteam/igv/wiki/Batch-commands')\n end",
"def index\n @steps = Step.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @steps }\n end\n end",
"def steps\n @steps\n end",
"def index\n @commands = Command.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @commands }\n end\n end",
"def destroy\n @step_command.destroy\n respond_to do |format|\n format.html { redirect_to step_commands_url, notice: 'Step command was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def show\n @step = Elaboration.find(params[:elaboration_id]).steps.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @step }\n end\n end",
"def update\n respond_to do |format|\n if @step_command.update(step_command_params)\n format.html { redirect_to @step_command, notice: 'Step command was successfully updated.' }\n format.json { render :show, status: :ok, location: @step_command }\n else\n format.html { render :edit }\n format.json { render json: @step_command.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @step = Step.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @step }\n end\n end",
"def get_list_of_cli_command_executions_by_jobid_and_serial_number(args = {}) \n get(\"/commands.json/device\", args)\nend",
"def index\n @instructions = @game.instructions.all\n\n respond_to do |format|\n format.html { render action: :index }\n format.json do\n render json: { instructions: @instructions.map { |i| i.command.data } }\n end\n end\n end",
"def show\n find_game\n @step = Step.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @step }\n end\n end",
"def steps\n %w[/14/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /ASSESSMENT/educations\n /12/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /13/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /ASSESSMENT/client_scores\n /41/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /42/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /15/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /ASSESSMENT/work/characteristics/index\n /29/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /ASSESSMENT/client_immunization/show\n /ASSESSMENT/disability/characteristics/index\n /ASSESSMENT/mental/characteristics/index\n /35/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /ASSESSMENT/substance_abuse/characteristics/index\n /32/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /ASSESSMENT/domestic/characteristics/index\n /38/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /39/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /ASSESSMENT/clients/medical_pregnancy/show\n /19/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /21/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /22/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /23/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /24/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /25/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /26/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /2/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /ASSESSMENT/employments\n /ASSESSMENT/legal/characteristics/index\n /7/assessment_edit/session[:CLIENT_ASSESSMENT_ID]/edit_common_assessment\n /assessment_careers/interest_profiler_questions/interest_profiler_question_wizard_initialize\n ]\n\n end",
"def jobs\n @mallet_run = MalletRun.find(params[:id])\n @commands = @mallet_run.mallet_commands.job( params[:job])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @commands }\n end\n end",
"def view_command(command_id)\n @client.get(\"/commands/#{command_id}\")\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
POST /step_commands POST /step_commands.json
|
def create
@step_command = StepCommand.new(step_command_params)
respond_to do |format|
if @step_command.save
format.html { redirect_to @step_command, notice: 'Step command was successfully created.' }
format.json { render :show, status: :created, location: @step_command }
else
format.html { render :new }
format.json { render json: @step_command.errors, status: :unprocessable_entity }
end
end
end
|
[
"def create\n @step = Step.new(step_params)\n @step.save\n render json: @step\n end",
"def create\n @step = @tutorial.steps.new(params[:step])\n\n respond_to do |format|\n if @step.save\n format.html { redirect_to [@tutorial, @step], notice: 'Step was successfully created.' }\n format.json { render json: @step, status: :created, location: @step }\n else\n format.html { render action: \"new\" }\n format.json { render json: @step.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @step = Step.new(step_params)\n\n respond_to do |format|\n if @step.save\n format.html { redirect_to api_v1_step_url(@step), notice: 'Step was successfully created.' }\n format.json { render :show, status: :created, location: @step }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @step.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @step_commands = StepCommand.all\n end",
"def create\n @step = Step.new(step_params)\n\n respond_to do |format|\n if @step.save\n format.html { redirect_to @step, notice: 'Step was successfully created.' }\n format.json { render :show, status: :created, location: @step }\n else\n format.html { render :new }\n format.json { render json: @step.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @done_step = DoneStep.new(done_step_params)\n @done_step.save\n render json: @done_step\n end",
"def create\n @step = Step.new(params[:step])\n @step.test_case_id = params[:test_case_id].to_i\n\n respond_to do |format|\n if @step.save\n @step_activity = StepActivity.new(:activity_type => 'edit', :description => @step.description)\n @step_activity.user = current_user\n @step_activity.step = @step\n @step_activity.save!\n format.json { render :json => @step, :status => :created, :location => @step }\n format.html { redirect_to(project_test_case_path(@step.test_case.project, @step.test_case)) }\n else\n format.html { render :action => \"new\" }\n format.json { render :json => @step.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @teststep = Teststep.new(params[:teststep])\n\n respond_to do |format|\n if @teststep.save\n format.html { redirect_to @teststep, notice: 'Teststep was successfully created.' }\n format.json { render json: @teststep, status: :created, location: @teststep }\n else\n format.html { render action: \"new\" }\n format.json { render json: @teststep.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @step = Elaboration.find(params[:elaboration_id]).steps.build(params[:step])\n\n respond_to do |format|\n if @step.save\n format.html { redirect_to [@step.elaboration, @step], notice: 'Step was successfully created.' }\n format.json { render json: @step, status: :created, location: @step }\n else\n format.html { render action: \"new\" }\n format.json { render json: @step.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_steps(stage_steps)\n sequence = 1\n stage_steps.map do |stage_step|\n step = Step.new\n step.sequence = sequence\n\n begin\n action_name = stage_step['action']\n plugin = Cyclid.plugins.find(action_name, Cyclid::API::Plugins::Action)\n\n step_action = plugin.new(stage_step)\n raise if step_action.nil?\n rescue StandardError => ex\n # XXX Rescue an internal exception\n halt_with_json_response(404, INVALID_ACTION, ex.message)\n end\n\n # Serialize the object into the Step and store it in the database.\n step.action = Oj.dump(step_action)\n step.save!\n\n sequence += 1\n\n step\n end\n end",
"def create\n @task_step = TaskStep.new(params[:task_step])\n\n respond_to do |format|\n if @task_step.save\n format.html { redirect_to @task_step, notice: 'Task step was successfully created.' }\n format.json { render json: @task_step, status: :created, location: @task_step }\n else\n format.html { render action: \"new\" }\n format.json { render json: @task_step.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @run_step = RunStep.new(params[:run_step])\n\n respond_to do |format|\n if @run_step.save\n format.html { redirect_to @run_step, notice: 'Run step was successfully created.' }\n format.json { render json: @run_step, status: :created, location: @run_step }\n else\n format.html { render action: \"new\" }\n format.json { render json: @run_step.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @recipe = Recipe.find(params[:recipe_id])\n @recipe_step = @recipe.recipe_steps.build(params[:recipe_step])\n\n respond_to do |format|\n if @recipe_step.save\n format.html { redirect_to @recipe, notice: 'Recipe step was successfully created.' }\n format.json { render json: @recipe_step, status: :created, location: @recipe_step }\n else\n format.html { render action: \"new\" }\n format.json { render json: @recipe_step.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @step_command.destroy\n respond_to do |format|\n format.html { redirect_to step_commands_url, notice: 'Step command was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def steps\n steps_keywords = %w(Given When Then And But)\n nsteps = 0\n @steps = []\n while true\n print \"Add step [Y/n]: \"\n choice = gets\n if choice.downcase.strip != \"n\"\n puts \"Step #{nsteps +1}:\"\n step = gets.capitalize\n init_step_word = step.split(' ').first\n if steps_keywords.include?(init_step_word)\n @steps << step\n nsteps = nsteps ++ 1\n else\n puts \"Error: #{init_step_word} unsupported initial value\"\n puts \"Use only #{steps_keywords} keywords\"\n end\n elsif choice.downcase.strip == \"n\"\n break\n else\n \"please enter a valid choice.\"\n end\n end\n write_feature\n end",
"def create\n @step = @experiment.steps.new(params[:step])\n @step.autogenerated=false\n\n respond_to do |format|\n if @step.save\n format.html { \tflash[:notice] = 'Step was successfully created.'\n\t\t\tredirect_to( experiment_path( @experiment ) ) }\n format.xml { render :xml => @step, :status => :created, :location =>[ @experiment, @step ]}\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @step.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @process_step = ProcessStep.new(process_step_params)\n\n respond_to do |format|\n if @process_step.save\n format.html { redirect_to @process_step, notice: 'Process step was successfully created.' }\n format.json { render :show, status: :created, location: @process_step }\n else\n format.html { render :new }\n format.json { render json: @process_step.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @instruction_step = InstructionStep.new(instruction_step_params)\n respond_to do |format|\n if @instruction_step.save\n format.html { redirect_to @instruction_step, notice: 'Instruction step was successfully created.' }\n format.json { render :show, status: :created, location: @instruction_step }\n else\n format.html { render :new }\n format.json { render json: @instruction_step.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @step_command.update(step_command_params)\n format.html { redirect_to @step_command, notice: 'Step command was successfully updated.' }\n format.json { render :show, status: :ok, location: @step_command }\n else\n format.html { render :edit }\n format.json { render json: @step_command.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
PATCH/PUT /step_commands/1 PATCH/PUT /step_commands/1.json
|
def update
respond_to do |format|
if @step_command.update(step_command_params)
format.html { redirect_to @step_command, notice: 'Step command was successfully updated.' }
format.json { render :show, status: :ok, location: @step_command }
else
format.html { render :edit }
format.json { render json: @step_command.errors, status: :unprocessable_entity }
end
end
end
|
[
"def update\n scenario = Scenario.find(params[:id])\n scenario.update(scenario_params)\n scenario.steps = []\n json_response(step_builder(scenario), status: :updated)\n rescue => e\n render json: {error: e.message}, status: 422\n end",
"def update\n @step.update(step_params)\n render json: @step\n end",
"def update\n @step = Step.find(params[:id])\n\n respond_to do |format|\n if @step.update_attributes(params[:step])\n format.html { redirect_to @step, notice: 'Step was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @step.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @step1 = Step1.find(params[:id])\n\n respond_to do |format|\n if @step1.update_attributes(params[:step1])\n format.html { redirect_to @step1, notice: 'Step1 was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @step1.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @step = @guide.steps.find(params[:id])\n\n respond_to do |format|\n if @step.update_attributes(params[:step])\n format.html { redirect_to [@guide, @step], notice: 'Step was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @step.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @step = Elaboration.find(params[:elaboration_id]).steps.find(params[:id])\n\n respond_to do |format|\n if @step.update_attributes(params[:step])\n format.html { redirect_to [@step.elaboration, @step], notice: 'Step was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @step.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @step = Step.find(params[:id])\n\n respond_to do |format|\n if @step.update_attributes(params[:step])\n @step_activity = StepActivity.new(:activity_type => 'edit', :description => @step.description)\n @step_activity.user = current_user\n @step_activity.step = @step\n @step_activity.save!\n format.html { redirect_to(project_test_case_path(@step.test_case.project, @step.test_case)) }\n format.json { head :no_content }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @step.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @task_step = TaskStep.find(params[:id])\n\n respond_to do |format|\n if @task_step.update_attributes(params[:task_step])\n format.html { redirect_to @task_step, notice: 'Task step was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @task_step.errors, status: :unprocessable_entity }\n end\n end\n end",
"def edit(id, recipe_step_id, options = {})\n \toptional = [:script,\n \t\t\t\t\t\t\t:result_source,\n :pass_anything_else,\n :pass_values,\n :on_success,\n :success_goto_step,\n :fail_anything_else,\n :fail_values,\n :on_failure,\n :failure_goto_step\n ]\n \tparams.accepts(optional).validate! options\n \tresponse = request(:put, \"/recipes/#{id}/recipe_steps/#{recipe_step_id}.json\", default_params(options))\n \tresponse['status']\n end",
"def update\n respond_to do |format|\n if @change_request_step.update(change_request_step_params)\n format.html { redirect_to @change_request_step, notice: 'Change request step was successfully updated.' }\n format.json { render :show, status: :ok, location: @change_request_step }\n else\n format.html { render :edit }\n format.json { render json: @change_request_step.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @done_step.update(done_step_params)\n render json: @done_step\n end",
"def update\n respond_to do |format|\n if @action_step.update(action_step_params)\n format.html { redirect_to action_steps_path, notice: 'Action step was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @action_step.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @config_step.update(config_step_params)\n format.html { redirect_to @config_step, notice: 'Step was successfully updated.' }\n format.json { render :show, status: :ok, location: @config_step }\n else\n format.html { render :edit }\n format.json { render json: @config_step.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @sequence = PillSequence.find(params[:id])\n @steps = @sequence.steps\n\n params[:pill_sequence_step].each_with_index do |step, idx|\n if @steps[idx]\n @steps[idx].update_attributes(step)\n else\n @steps.create(step)\n end\n end\n\n # remove unused pill sequence steps\n diff = @steps.size - params[:pill_sequence_step].size\n @steps.destroy(@steps.last(diff)) if diff > 0\n\n respond_to do |format|\n if @sequence.update_attributes(params[:pill_sequence])\n format.html { redirect_to @sequence, notice: 'Recording sequence was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @sequence.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @step = Step.find(params[:id])\n\n respond_to do |format|\n if @step.update_attributes(params[:step])\n flash[:notice] = 'Step was successfully updated.'\n format.html { redirect_to(steps_url) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @step.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @pre_step = PreStep.find(params[:id])\n\n respond_to do |format|\n if @pre_step.update_attributes(params[:pre_step])\n format.html { redirect_to @pre_step, notice: 'Pre step was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @pre_step.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @stepsnippet = Stepsnippet.find(params[:id])\n\n respond_to do |format|\n if @stepsnippet.update_attributes(params[:stepsnippet])\n format.html { redirect_to stepsnippets_url, notice: 'Stepsnippet was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @stepsnippet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @instruction_step.update(instruction_step_params)\n format.html { redirect_to @instruction_step, notice: 'Instruction step was successfully updated.' }\n format.json { render :show, status: :ok, location: @instruction_step }\n else\n format.html { render :edit }\n format.json { render json: @instruction_step.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @process_step.update(process_step_params)\n format.html { redirect_to @process_step, notice: 'Process step was successfully updated.' }\n format.json { render :show, status: :ok, location: @process_step }\n else\n format.html { render :edit }\n format.json { render json: @process_step.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
DELETE /step_commands/1 DELETE /step_commands/1.json
|
def destroy
@step_command.destroy
respond_to do |format|
format.html { redirect_to step_commands_url, notice: 'Step command was successfully destroyed.' }
format.json { head :no_content }
end
end
|
[
"def destroy\n @step = RunStep.find(params[:id])\n @step.destroy\n\n respond_to do |format|\n format.json { render :json => \"success\" }\n end\n end",
"def destroy\n @step.destroy\n respond_to do |format|\n format.html { redirect_to steps_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @step1 = Step1.find(params[:id])\n @step1.destroy\n\n respond_to do |format|\n format.html { redirect_to step1s_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @step = Step.find(params[:id])\n @step.destroy\n\n respond_to do |format|\n format.html { redirect_to steps_url }\n format.json { head :no_content }\n end\n end",
"def delete(id, recipe_step_id)\n \trequest(:delete, \"/recipes/#{id}/recipe_steps/#{recipe_step_id}.json\")\n end",
"def destroy\n @step = @tutorial.steps.find(params[:id])\n @step.destroy\n\n respond_to do |format|\n format.html { redirect_to tutorial_steps_path(@tutorial) }\n format.json { head :no_content }\n end\n end",
"def destroy\n @step = Step.find(params[:id])\n @step.destroy\n\n respond_to do |format|\n format.html { redirect_to game_steps_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @teststep = Teststep.find(params[:id])\n @teststep.destroy\n\n respond_to do |format|\n format.html { redirect_to teststeps_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @action_step.destroy\n respond_to do |format|\n format.html { redirect_to action_steps_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @step_definition.destroy\n respond_to do |format|\n format.html { redirect_to step_definitions_url, notice: 'Step definition was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @run_step = RunStep.find(params[:id])\n @run_step.destroy\n\n respond_to do |format|\n format.html { redirect_to run_steps_url }\n format.json { head :no_content }\n end\n end",
"def delete_workflow_step(id)\n @client.raw('delete', \"/crm/steps/#{id}\")\n end",
"def destroy\n @stepsnippet = Stepsnippet.find(params[:id])\n @stepsnippet.destroy\n\n respond_to do |format|\n format.html { redirect_to stepsnippets_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n elaboration = Elaboration.find(params[:elaboration_id])\n @step = elaboration.steps.find(params[:id])\n @step.destroy\n\n respond_to do |format|\n format.html { redirect_to elaboration_steps_url(elaboration) }\n format.json { head :ok }\n end\n end",
"def destroy\n @task_step = TaskStep.find(params[:id])\n @task_step.destroy\n\n respond_to do |format|\n format.html { redirect_to task_steps_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @step_repeat = StepRepeat.find(params[:id])\n @step_repeat.destroy\n\n respond_to do |format|\n format.html { redirect_to step_repeats_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @step1 = Proce.find(params[:id])\n @step1.destroy\n\n respond_to do |format|\n format.html { redirect_to(step1s_url) }\n format.xml { head :ok }\n format.json { render :text => '{status: \"success\"}'}\n end\n end",
"def destroy\n @step_scenario.destroy\n respond_to do |format|\n format.html { redirect_to step_scenarios_url, notice: 'Step scenario was successfully destroyed.' }\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"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Connect to the SmartView provider and obtain a session id. Two methods of connection are supported: 1. Userid and password 2. SSO token If only a single parameter is passed, the SSO method is assumed; if two parameters are passed, these are assumed to be userid and password.
|
def connect(user_or_sso, password = nil)
if @provider
raise AlreadyConnected, "Cannot change provider once connected" if @provider
end
# Obtain a session id
if password.nil?
# Connect via SSO token
@sso = user_or_sso
@logger.info "Connecting to #{@url} using SSO token"
@req.ConnectToProvider do |xml|
xml.ClientXMLVersion CLIENT_XML_VERSION
xml.sso @sso
xml.lngs({:enc => 0}, "en_US")
end
else
# Connect via userid and password
@user = user_or_sso
@password = password
@logger.info "Connecting to #{@url} using userid/password"
@req.ConnectToProvider do |xml|
xml.ClientXMLVersion CLIENT_XML_VERSION
xml.usr @user
xml.pwd @password
xml.lngs({:enc => 0}, "en_US")
end
end
doc = invoke
@session_id = doc.at('//res_ConnectToProvider/sID').inner_html
set_provider doc.at('//res_ConnectToProvider/provider').inner_html
end
|
[
"def connect_session(vcenter_connection)\n if @cached_powercli_sessions.key?(vcenter_connection['server'])\n session_id = @cached_powercli_sessions[vcenter_connection['server']]\n else\n # our session is nil, so we need to conenct\n session_cmd = <<-EOF\n $session = Connect-VIServer -Server '#{vcenter_connection['server']}' -Username '#{vcenter_connection['username']}' -Password '#{vcenter_connection['password']}'\n $session.SessionId\n EOF\n resp = ps(session_cmd)\n Puppet.debug(\"connect session response = #{resp}\")\n # remove quotes from the session id string, it returns us something in the format of:\n # \"abc123\"\n # we strip because it returns us some new lines and white space in there as well\n session_id = resp[:stdout].delete('\"').strip\n Puppet.debug(\"connect session parsed and stripped session id = #{session_id}\")\n\n # save the session ID to our cache\n @cached_powercli_sessions[vcenter_connection['server']] = session_id\n end\n session_id\n end",
"def login(username, password, token)\n self.login_url ||= self.config_login_url \n binding = RForce::Binding.new self.login_url\n \n self.login_info = binding.login username, (password + token)\n \n if(login_info && login_info[:loginResponse] && login_info[:loginResponse][:result])\n self.session_id = login_info[:loginResponse][:result][:sessionId]\n server_url = login_info[:loginResponse][:result][:serverUrl]\n self.detect_server_instance(server_url)\n end\n \n return self.session_id\n end",
"def start_session_with_smart_token\n require_relative '../../../lib/util/smart_token'\n smart_token = SmartToken.from_str(params['smart_token'])\n user = smart_token ? User.first(:guid => smart_token.guid) : nil\n\n if user and user.is_smart_token_valid? smart_token\n return user\n else\n return nil\n end\n end",
"def open_session\n return if @session_id\n json = api_get('authenticate')\n @session_id = json['session_id'] or raise RuntimeError, \"No session id returned\"\n end",
"def connect!\n retrieve_auth_token unless connected?\n auth_token[:token]\n end",
"def connect\n\n # Initialize the gem\n ShopifyAPI::Session.setup({api_key: @api_key, secret: @shared_secret})\n\n # Instantiate the session\n session = ShopifyAPI::Session.new(@url, @password)\n\n # Activate the Session so that requests can be made\n return ShopifyAPI::Base.activate_session(session)\n\n end",
"def login\n begin\n response = self.pclient.request :login do\n soap.body = { :username => self.username, :password => self.password }\n end\n rescue Savon::SOAP::Fault => fault\n raise Exception.new(fault.to_s)\n end\n \n res = response.to_hash\n self.metadata_server_url = res[:login_response][:result][:metadata_server_url]\n self.sid = res[:login_response][:result][:session_id].to_s\n end",
"def activate\n result = remote_call(\"auth.getSession\", {:auth_token => @desktop_auth_token}, true)\n if result != nil\n @session_user_id = result.at(\"uid\").inner_html\n @session_key = result.at(\"session_key\").inner_html\n @session_secret = result.at(\"secret\").inner_html\n end\n end",
"def login(params = {})\n begin\n params.merge!(common_params)\n document = MagentoApiWrapper::Requests::Login.new(params)\n request = MagentoApiWrapper::Request.new(magento_url: params[:magento_url], call_name: :login)\n request.body = document.body\n login = MagentoApiWrapper::Login.new(request.connect!)\n @session_id = login.key\n login.key\n rescue MagentoApiWrapper::AuthenticationError => e\n raise e\n end\n end",
"def login\n client.login(\n params[:user],\n params[:password],\n authParams: {\n scope: 'openid name email'\n },\n connection: 'Username-Password-Authentication'\n )\n end",
"def connect!\n @connection = user ? connection_for_user : connection_for_application\n @auth_token = @connection.token\n BeaconClient.logger.debug(\"Client token: #{@auth_token}\") if BeaconClient.config.debug?\n @auth_token\n rescue OAuth2::Error => error\n BeaconClient.logger.error(error.message)\n BeaconClient.logger.error(error.backtrace.join(\"\\n\"))\n end",
"def login\n options = {\n type: 'OneView',\n file_env_var: 'ONEVIEW_AUTH_FILE',\n env_var_url: 'ONEVIEW_URL',\n filename: '/login.json'\n }\n credentials = load_authentication_settings(options)\n credentials[:hardware_variant] ||= 'C7000'\n credentials[:hardware_variant] = credentials[:hardware_variant].to_s.capitalize\n credentials\nend",
"def connect_to_server\n puts \"==>connect_to_server\"\n if session[:client_id].length == 0 \n @client = FHIR::Client.new(session[:iss_url])\n @client.use_r4\n return # We do not have authentication\n end\n if session.empty? \n err = \"Session Expired\"\n # binding.pry \n redirect_to root_path, alert: err\n end\n if session[:iss_url].present?\n @client = FHIR::Client.new(session[:iss_url])\n @client.use_r4\n token_expires_in = session[:token_expiration] - Time.now.to_i\n if token_expires_in.to_i < 10 # if we are less than 10s from an expiration, refresh\n get_new_token\n end\n @client.set_bearer_token(session[:access_token])\n end\n rescue StandardError => exception\n reset_session\n err = \"Failed to connect: \" + exception.message\n redirect_to root_path, alert: err\n end",
"def login\n @lookup_service_helper = LookupServiceHelper.new(sample)\n Sample.log.info \"Connecting to lookup service: #{lookup_service_helper.soap_url}\"\n lookup_service_helper.connect()\n\n @sts_url = lookup_service_helper.find_sso_url()\n raise 'sts_url not found' if sts_url.nil?\n\n Sample.log.info \"Retrieving a SAML bearer token from STS: #{sts_url}\"\n sso = SSO::Connection.new(sts_url)\n sso.login(sample.sso_username, sample.sso_password)\n @bearer_token = sso.request_bearer_token()\n @bearer_token_context =\n VAPI::Security.create_saml_bearer_security_context(bearer_token.to_s)\n end",
"def session_token\n obtain_credentials\n @session_token\n end",
"def authenticate\n options = {\n body: \"username=#{@user}&password=#{@pass}\"\n }\n\n # Have to clear out the cookies or the old SID gets sent while requesting\n # the new SID (and it fails).\n self.class.cookies.clear\n\n res = self.class.post('/login', options)\n if res.success?\n token = res.headers[\"Set-Cookie\"]\n raise QbtClientError.new(\"Login failed: no SID (cookie) returned\") if token.nil?\n\n token = token.split(\";\")[0]\n @sid = token\n else\n raise QbtClientError.new(res)\n end\n end",
"def getSessionID()\n\t uri=\"http://#{@host}/login_sid.lua\"\n\t xml = open(uri)\n\t data = XmlSimple.xml_in(xml)\n\t sessionID = data[\"SID\"][0]\n\t if sessionID.eql?(\"0000000000000000\")\n\t challenge = data[\"Challenge\"][0]\n\t response = getResponse(challenge,@password)\n\t uri = \"http://#{@host}/login_sid.lua?username=#{@user}&response=#{response}\"\n\t xml = open(uri)\n\t data = XmlSimple.xml_in(xml)\n\t sessionID = data[\"SID\"][0]\n\t @sessionID = sessionID\n\t return sessionID\n\t else\n \t \traise FritzBoxError.new(\"FritzBoxLogin\"), \"login failed\"\n\t return sessionID\n\t end\n\tend",
"def logon\n @session_token = (client.request :logon do\n soap.body = {\n :user => Ecircle.configure.user,\n :realm => Ecircle.configure.realm,\n :passwd => Ecircle.configure.password\n }\n end).body[:logon_response][:logon_return].to_s\n rescue Savon::SOAP::Fault => e\n @session_token = nil\n raise LoginFailed, \"Msg: #{e.message}\"\n end",
"def oidc_login\n identity_provider_login(\"oidc_login\")\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Close the connection to the current application cube.
|
def close_app
if @session_id && @app
@logger.info "Disconnecting from #{@app}.#{@cube}"
@req.Logout do |xml|
xml.sID @session_id
end
invoke
@app = nil
@cube = nil
@dimensions = nil
@default_pov = nil
end
end
|
[
"def close\n try{ @cube_view.close() }\n @cube_view = nil\n end",
"def close\n @ole_connection.Close\n end",
"def close\n inactive!\n close_connections\n end",
"def close!\n live_queries = @volt_app.channel_live_queries[@channel]\n\n if live_queries\n live_queries.each do |live_query|\n live_query.remove_channel(@channel)\n end\n end\n\n @volt_app.channel_live_queries.delete(@channel)\n end",
"def close()\n @connection.disconnect\n @connection = nil\n end",
"def disconnect\n $emsConnections.close\n end",
"def close\n @channel.close\n @conn.close\n end",
"def close\n @connection.close # Close the active mailbox\n @connection.logout # Send the logout command\n @connection.disconnect # Close the actual connection\n end",
"def close\n @pool.all_connections do |conn|\n conn.unregister_from_event_loop\n conn.close\n end\n end",
"def close\n @channel.close\n @connection.close\n end",
"def close!\n live_queries = @@channel_live_queries[@channel]\n\n if live_queries\n live_queries.each do |live_query|\n live_query.remove_channel(@channel)\n end\n end\n\n @@channel_live_queries.delete(@channel)\n end",
"def close\n @con_factory = nil\n\n @context.close if @context\n @context = nil\n end",
"def close_app\n @bridge.close_app\n end",
"def event_loop_connection_close\n @em_connection.close_connection if @em_connection\n end",
"def on_close(env)\n @@connections[@id].delete(self)\n\n p \"<DEBUG> Client disconnected\"\n end",
"def event_loop_connection_close\n key = em_connection_with_pool_key\n @fiber[key].close_connection if @fiber[key]\n end",
"def close!\n\n\t @wordnet_connection.close!\n\n\tend",
"def close\n channels.each { |channel| channel.close }\n self\n end",
"def quit\n\t\tDistributed.debug \"ConnectionSpace #{self} quitting\"\n execution_engine.remove_propagation_handler(@at_cycle_begin_handler)\n execution_engine.remove_propagation_handler(@at_cycle_end_handler)\n execution_engine.finalizers.delete(method(:quit))\n\n (ring_discovery_publishers.values + ring_discovery_listeners.values).\n each do |d|\n if d.listening?\n d.stop_listening\n end\n if d.registered?\n d.deregister\n end\n end\n\n\t ensure\n\t\tif server_socket\n\t\t begin\n\t\t\tserver_socket.close \n\t\t rescue IOError\n\t\t end\n\t\tend\n\n\t\texecution_engine.finalizers.delete(method(:quit))\n\t end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Retrieve a list of dimensions for the current connection.
|
def get_dimensions
check_attached
@logger.info "Retrieving list of dimensions"
@req.EnumDims do |xml|
xml.sID @session_id
xml.alsTbl @preferences.alias_table
end
@dimensions = []
invoke.search('//res_EnumDims/dimList/dim').each do |dim|
@dimensions[dim['id'].to_i] = dim['name']
end
@dimensions
end
|
[
"def dimensions() Dimension.find(dimension_ids) end",
"def dimensions(node_id)\n database.getlist(\"#{prefix}#{node_id}:dimensions\") || []\n end",
"def list_dimensions\n puts 'STUB: list_dimensions in importer.rb'\n end",
"def dimension_names\n unless @dimensions\n log.detail \"Retrieving dimension names...\"\n @dimensions = @conn.fetch(DIMENSION_SQL).to_hash(:dimension_name, :dimension_type)\n end\n @dimensions\n end",
"def dimensions\n data[:dimensions]\n end",
"def dimensions\n data.dimensions\n end",
"def list_dimensions(opts = {})\n data, _status_code, _headers = list_dimensions_with_http_info(opts)\n data\n end",
"def dimensions(*args)\n []\n end",
"def dimensions\n @dimensions ||= fact_class.dimension_relationships.collect{|k,v| k}\n end",
"def dimensions\n inject(Dimensions.dimensionless) { |dimension,base| dimension * base.dimensions }\n end",
"def retrieve_dimensions\n require_relative 'dimension'\n @dimensions = {}\n try{ @cube.get_dimensions.get_all }.each do |ess_dim|\n dim = Dimension.new(self, ess_dim)\n @dimensions[dim.name.upcase] = dim\n end\n end",
"def dimensions\n return @dimensions if @dimensions\n @dimensions = {}\n (raw['Dimensions'] || {}).each do |name, values|\n values = [values] unless Array === values\n @dimensions[name] = values.map{|value| Dimension.new(value)}\n end\n @dimensions\n end",
"def dimensions()\r\n @dimensions ||= questions.inject([]) do |l, question|\r\n question_dimension = question.dimension\r\n l << question_dimension unless l.include?(question_dimension) or question_dimension == \"unknown\"\r\n l\r\n end\r\n end",
"def dimensions\n option[:dimensions]\n end",
"def list_monitoring_dimensions(opts = {})\n data, _status_code, _headers = list_monitoring_dimensions_with_http_info(opts)\n data\n end",
"def load_dimensions\n dimensions = {}\n # Retrieve the total number of dimensions.\n nb_dim_ptr = FFI::MemoryPointer.new(:int)\n err = LibNetCDF.nc_inq_ndims(@id, nb_dim_ptr)\n fail NetCDFError.new(nc_strerror(err)) unless err == NC_NOERR\n # Retrieve the IDs of the unlimited dimensions.\n unlim_ids = fetch_unlimdims_ids()\n # Load each dimension.\n nb_dim_ptr.read_int.times do |dim_id|\n dim = Dimension.load_dimension(@id, dim_id, unlim_ids.include?(dim_id))\n dimensions[dim.name] = dim\n end\n\n return dimensions\n end",
"def slicer_dimensions\n @slicer && map_names(try{ @slicer.get_all_dimensions }) || []\n end",
"def list_dimensions_with_http_info(opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: DimensionsApi.list_dimensions ...'\n end\n # resource path\n local_var_path = '/data/v1/dimensions'\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] || 'ListDimensionsResponse'\n\n # auth_names\n auth_names = opts[:debug_auth_names] || ['accessToken']\n\n new_options = opts.merge(\n :operation => :\"DimensionsApi.list_dimensions\",\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: DimensionsApi#list_dimensions\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def get_dimensions(details)\n details.select{ |k,v| k.include?('Dimension') }.first.last\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Returns a list of available member filters for the specified dimension. A filter can be used to restrict a member query to a certain subset of members, such as the members in a member list.
|
def get_filters(dimension, force = false)
check_attached
if @fiters && @filters[dimension] && !force
@logger.debug "Retrieving filters for #{dimension} from cache"
filters = @filters[dimension]
else
@logger.info "Retrieving list of available member filters for #{dimension}"
@req.EnumFilters do |xml|
xml.sID @session_id
xml.dim dimension
end
filters = []
invoke.search('//res_EnumFilters/filterList/filter').each do |filter|
filters << Filter.new(filter)
end
@filters = {} unless @filters
@filters[dimension] = filters
end
filters
end
|
[
"def get_members(dimension, filter_spec = nil, all_gens = true)\n check_attached\n\n @logger.info \"Retrieving list of members for #{dimension}\"\n filter_name, filter_args = process_filter(dimension, filter_spec)\n @req.EnumMembers do |xml|\n xml.sID @session_id\n xml.dim dimension\n xml.memberFilter do |xml|\n xml.filter('name' => filter_name) do |xml|\n insert_filter_args xml, filter_args\n end\n end\n xml.getAtts '0'\n xml.alsTbl @preferences.alias_table\n xml.allGenerations all_gens ? '1' : '0'\n end\n doc = invoke\n members = doc.at('//res_EnumMembers/mbrs').to_plain_text.split('|')\n members\n end",
"def filters\n mentos(:get_all_filters)\n end",
"def members(filters={})\n members = Barton::Models::Member.find filters\n results = []\n if members.respond_to? :each\n members.each do |elec|\n results.push elec\n end\n else\n results.push members\n end\n results.compact\n end",
"def filter_fields\n fields.each.select(&:show_in_filters)\n end",
"def filter_predicates\n @query.getFilterPredicates\n end",
"def get_team_filters\n filters = []\n self.feed_teams.each do |ft|\n if ft.sharing_enabled?\n filters << ft.filters.to_h.reject{ |k, _v| PROHIBITED_FILTERS.include?(k.to_s) }.merge({ 'team_id' => ft.team_id })\n end\n end\n filters\n end",
"def list_filters\n if @filters.empty?\n fetch_configuration()\n end\n return @filters.keys\n end",
"def get_filters\n params_hash = {}\n uri = SERVER + GET_FILTERS_URL\n xml_doc = call_api(uri, params_hash)\n\n\n filters = []\n xml_doc.xpath(\"//filter\").each do |f|\n filter= FilterInfo.new_from_xml(f)\n filters.push filter\n end\n\n return filters\n end",
"def get_generated_filters\n filters = []\n @columns.each do |column|\n filters << ::Schema::Mapping::Filter.new(\"#{column.name}_gen_filter_eql\",\n \"{{#{@table_name}.#{column.name}}} = #{::Schema::Mapping::Filter::VARIABLE_REPLACE_STRING}\", self.table_name)\n filters << ::Schema::Mapping::Filter.new(\"#{column.name}_gen_filter_like\",\n \"{{#{@table_name}.#{column.name}}} LIKE #{::Schema::Mapping::Filter::VARIABLE_REPLACE_STRING}\", self.table_name)\n filters << ::Schema::Mapping::Filter.new(\"#{column.name}_gen_filter_lt\",\n \"{{#{@table_name}.#{column.name}}} < #{::Schema::Mapping::Filter::VARIABLE_REPLACE_STRING}\", self.table_name)\n filters << ::Schema::Mapping::Filter.new(\"#{column.name}_gen_filter_gt\",\n \"{{#{@table_name}.#{column.name}}} > #{::Schema::Mapping::Filter::VARIABLE_REPLACE_STRING}\", self.table_name)\n end\n \n @relations.each do |relation|\n filters << ::Schema::Mapping::Filter.new(\"#{relation.name}_exists\",\n \"{{#{relation.to_table}.#{relation.to_model.get_primary_column.name}}} IS NOT NULL\")\n end\n \n return filters\n end",
"def member_filter(entry = nil)\n if entry\n entry = entry.dn if entry.respond_to?(:dn)\n MEMBERSHIP_NAMES.\n map {|n| Net::LDAP::Filter.eq(n, entry) }.reduce(:|)\n else\n MEMBERSHIP_NAMES.\n map {|n| Net::LDAP::Filter.pres(n) }. reduce(:|)\n end\n end",
"def filters\n @filters\n end",
"def allowed_filter_fields\n @allowed_filter_fields ||= each_field_with_object(Set.new) { |field_name, field_definition, results|\n if field_definition.type.filter_type\n results << field_name\n end\n }.to_a\n end",
"def lookup_user_filters(miq_group)\n filters = miq_group.try!(:get_filters).try!(:dup) || {}\n filters[\"managed\"] ||= []\n filters[\"belongsto\"] ||= []\n filters\n end",
"def potential_filters\n [:date_filter,:classroom_filter, :sort_by]\n end",
"def filters\n _filters = []\n self.each do |_filter|\n _filters.add(_filter.filters)\n end\n _filters \n end",
"def filter_list\n @filter_names ||= self.scopes.map{|s| s.first.to_s}\n end",
"def filter_conditions\n if params[:filter]\n generate_filter_conditions\n else\n []\n end\n end",
"def registered_filters\n # Initialize if it doesn't exist\n @filters ||= {}\n return @filters\n end",
"def potential_filters\n [:date_filter, :reward_status_filter, :teachers_filter, :reward_creator_filter, :sort_by]\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Retrieves a list of members for the specified dimension, optionally satisfying a filter.
|
def get_members(dimension, filter_spec = nil, all_gens = true)
check_attached
@logger.info "Retrieving list of members for #{dimension}"
filter_name, filter_args = process_filter(dimension, filter_spec)
@req.EnumMembers do |xml|
xml.sID @session_id
xml.dim dimension
xml.memberFilter do |xml|
xml.filter('name' => filter_name) do |xml|
insert_filter_args xml, filter_args
end
end
xml.getAtts '0'
xml.alsTbl @preferences.alias_table
xml.allGenerations all_gens ? '1' : '0'
end
doc = invoke
members = doc.at('//res_EnumMembers/mbrs').to_plain_text.split('|')
members
end
|
[
"def members(filters={})\n members = Barton::Models::Member.find filters\n results = []\n if members.respond_to? :each\n members.each do |elec|\n results.push elec\n end\n else\n results.push members\n end\n results.compact\n end",
"def find_member(dimension, pattern, filter_spec = nil)\n check_attached\n\n @logger.info \"Finding members of #{dimension} matching '#{pattern}'\"\n filter_name, filter_args = process_filter(dimension, filter_spec)\n @req.FindMember do |xml|\n xml.sID @session_id\n xml.dim dimension\n xml.mbr pattern\n xml.filter 'name' => filter_name do |xml|\n insert_filter_args xml, filter_args\n end\n xml.alsTbl @preferences.alias_table\n end\n doc = invoke\n path_list = []\n doc.search('//res_FindMember/pathList/path').each do |path|\n path_list << path.at('mbrs').to_plain_text.split('|')\n end\n path_list\n end",
"def retrieve_members\n @root_member = nil\n @members = []\n shared = []\n @member_lookup = {}\n log.finer \"Retrieving members of dimension '#{@name}'\"\n alias_tbls = try{ @cube.get_alias_table_names.to_a }\n mbr_sel = try{ @cube.open_member_selection(\"MemberQuery\") }\n begin\n spec = %Q{@IDESCENDANTS(\"#{self.name}\")}\n query = <<-EOQ.strip\n <OutputType Binary\n <SelectMbrInfo(MemberName, MemberAliasName, ParentMemberName,\n MemberGeneration, MemberLevel, Consolidation,\n ShareOption, MemberFormula, UDAList)\n EOQ\n @cube.instrument 'retrieve_members', dimension: self do\n try{ mbr_sel.execute_query(query, spec) }\n end\n mbr_sel.get_members.get_all.each do |ess_mbr|\n mbr = Member.new(self, ess_mbr, alias_tbls)\n @members << mbr\n if mbr.shared?\n shared << mbr\n else\n @member_lookup[mbr.name.upcase] = mbr\n end\n end\n # Link shared members to non-shared member (and vice versa)\n shared.each do |smbr|\n mbr = @member_lookup[smbr.name.upcase]\n smbr.instance_variable_set(:@non_shared_member, mbr)\n mbr.instance_variable_get(:@shared_members) << smbr\n end\n @root_member = @member_lookup[self.name.upcase]\n # Convert parent names to references to the parent Member object\n # This can only be done after we've seen all members, since the\n # member selection query returns parents after children\n @members.each do |mbr|\n par = @member_lookup[mbr.parent.upcase]\n mbr.instance_variable_set(:@parent, par)\n par.instance_variable_get(:@children) << mbr if par\n end\n ensure\n try{ mbr_sel.close }\n end\n log.finer \"Retrieved #{@members.size} members\"\n end",
"def get_filters(dimension, force = false)\n check_attached\n\n if @fiters && @filters[dimension] && !force\n @logger.debug \"Retrieving filters for #{dimension} from cache\"\n filters = @filters[dimension]\n else\n @logger.info \"Retrieving list of available member filters for #{dimension}\"\n @req.EnumFilters do |xml|\n xml.sID @session_id\n xml.dim dimension\n end\n filters = []\n invoke.search('//res_EnumFilters/filterList/filter').each do |filter|\n filters << Filter.new(filter)\n end\n @filters = {} unless @filters\n @filters[dimension] = filters\n end\n\n filters\n end",
"def getOrganizationMembersFilter(orgId, filter)\n\tresponse = RestClient.get(\"https://api.trello.com/1/organizations/\"+orgId+\"/members/\"+filter+\"?key=\"+$key+\"&token=\"+$token+\"&filter=open\")\n\tresponse = JSON.parse(response)\nend",
"def get_member_ids_sql(dim_name, member)\n sql = <<-EOQ\n SELECT M.MEMBER_ID\n FROM HSP_MEMBER M\n JOIN HSP_OBJECT D\n ON M.DIM_ID = D.OBJECT_ID\n JOIN HSP_OBJECT N\n ON M.MEMBER_ID = N.OBJECT_ID\n WHERE D.OBJECT_NAME = '#{dim_name}'\n AND N.OBJECT_NAME = '#{member}'\n ORDER BY CASE M.DATA_STORAGE WHEN 3 THEN 99 ELSE M.DATA_STORAGE END\n EOQ\n end",
"def member_filter(entry = nil)\n if entry\n entry = entry.dn if entry.respond_to?(:dn)\n MEMBERSHIP_NAMES.\n map {|n| Net::LDAP::Filter.eq(n, entry) }.reduce(:|)\n else\n MEMBERSHIP_NAMES.\n map {|n| Net::LDAP::Filter.pres(n) }. reduce(:|)\n end\n end",
"def member_query(spec)\n mbrs = []\n mbr_sel = try{ @cube.open_member_selection(\"MemberQuery\") }\n begin\n mbr_sel.execute_query(<<-EOQ.strip, spec)\n <OutputType Binary\n <SelectMbrInfo(MemberName, ParentMemberName, DimensionName)\n EOQ\n mbr_sel.get_members && mbr_sel.get_members.get_all.each do |ess_mbr|\n dim = self[ess_mbr.getDimensionName()]\n mbr = MemberLite.new(dim, ess_mbr)\n mbrs << mbr\n end\n ensure\n mbr_sel.close\n end\n mbrs\n end",
"def members\n all = []\n\n # Add all people\n all += entities.where(:type => \"Person\").all\n\n # Add all (flattened) groups\n entities.where(:type => \"Group\").all.each do |group|\n all += group.flattened_members\n end\n\n # Return a unique list\n all.uniq{ |x| x.id }\n end",
"def members\n groups, members = groups_and_members\n results = members\n\n cache = load_cache(groups)\n\n loop_cached_groups(groups, cache) do |_, users|\n results.concat users\n end\n\n results.uniq {|m| m.dn }\n end",
"def dimensions() Dimension.find(dimension_ids) end",
"def getBoardMembersFilter(boardId, filter)\n\tresponse = RestClient.get(\"https://api.trello.com/1/boards/\"+boardId+\"/members/\"+filter+\"?&key=\"+$key+\"&token=\"+$token)\n\tresponse = JSON.parse(response)\t\nend",
"def get_family_members (people, family)\n people.select { |key,person| person.family == family }\nend",
"def get_all(name, dimensions_subset = {})\n @metrics[\"values\"].each do |metric|\n if metric[\"name\"] == name && subset_of(metric[\"dimensions\"], dimensions_subset)\n return metric\n end\n end\n nil\n end",
"def only_members items\n only_ items, :member\nend",
"def query_collection_members\n params[:q] = params[:cq]\n @response = repository.search(query_for_collection_members)\n @member_docs = @response.documents\n end",
"def vdc_module_intf_members(vdc, mod, all_members: false)\n cmd = \"show vdc #{vdc} membership module #{mod} | incl Ethernet\"\n if agent\n out = on(agent, get_vshell_cmd(cmd), pty: true).stdout\n else\n out = nxapi_test_get(cmd, false)\n end\n return nil unless out\n return out.split if all_members\n out.split[0]\n end",
"def get_members(group)\n members = []\n\n if (Group.where(event_id: group.event_id).count <= 1)\n members << self\n else\n similar_groups = Group.where(event_id: group.event_id)\n \n similar_groups.each do |group|\n user = User.find(group.user_id)\n\n members << user unless members.include?(user) || !interested_in(user)\n end\n end\n\n if (Group.where(event_id: group.event_id).count > 1 && members.size < 5)\n similar_groups = Group.where(event_id: group.event_id)\n \n similar_groups.each do |group|\n user = User.find(group.user_id)\n\n members << user unless members.include?(user) || members.size == 5\n end\n end\n\n return members\n end",
"def get_members(group_ldap_dn)\n ldap = Net::LDAP.new :host => SiteSetting.ldap_hostname,\n :port => SiteSetting.ldap_port,\n :auth => {\n :method => :simple,\n :username => SiteSetting.ldap_bind_dn,\n :password => SiteSetting.ldap_password\n }\n\n filter = Net::LDAP::Filter.construct('(memberOf='+ group_ldap_dn +')')\n \n treebase = SiteSetting.ldap_base\n\n result_attrs =[\"mail\"]\n \n group_members = []\n ldap.search(:base => treebase, :filter =>\n filter, :attributes => result_attrs,:return_result =>\n false) do |entry|\n group_members.append(entry[\"mail\"])\n end\n group_members\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Search for the specified member name or pattern in a dimension. Returns an array of arrays, each inner array representing a path to a matching member.
|
def find_member(dimension, pattern, filter_spec = nil)
check_attached
@logger.info "Finding members of #{dimension} matching '#{pattern}'"
filter_name, filter_args = process_filter(dimension, filter_spec)
@req.FindMember do |xml|
xml.sID @session_id
xml.dim dimension
xml.mbr pattern
xml.filter 'name' => filter_name do |xml|
insert_filter_args xml, filter_args
end
xml.alsTbl @preferences.alias_table
end
doc = invoke
path_list = []
doc.search('//res_FindMember/pathList/path').each do |path|
path_list << path.at('mbrs').to_plain_text.split('|')
end
path_list
end
|
[
"def children_lookup(cube_unique_name, member = nil, recursive = false)\n return dimensions cube_unique_name if member.nil?\n\n if member.split(\".\").length == 1\n cube(cube_unique_name).get_dimensions.reject { |dimension| dimension.get_unique_name != member }.first.get_hierarchies.map { |hierarchy| hierarchy.get_root_members.map { |member| dimension(member, recursive)} }.flatten\n else\n children cube(cube_unique_name).send(:lookup_member, Java::OrgOlap4jMdx::IdentifierNode.parse_identifier(member).get_segment_list()), recursive\n end\n end",
"def retrieve_members\n @root_member = nil\n @members = []\n shared = []\n @member_lookup = {}\n log.finer \"Retrieving members of dimension '#{@name}'\"\n alias_tbls = try{ @cube.get_alias_table_names.to_a }\n mbr_sel = try{ @cube.open_member_selection(\"MemberQuery\") }\n begin\n spec = %Q{@IDESCENDANTS(\"#{self.name}\")}\n query = <<-EOQ.strip\n <OutputType Binary\n <SelectMbrInfo(MemberName, MemberAliasName, ParentMemberName,\n MemberGeneration, MemberLevel, Consolidation,\n ShareOption, MemberFormula, UDAList)\n EOQ\n @cube.instrument 'retrieve_members', dimension: self do\n try{ mbr_sel.execute_query(query, spec) }\n end\n mbr_sel.get_members.get_all.each do |ess_mbr|\n mbr = Member.new(self, ess_mbr, alias_tbls)\n @members << mbr\n if mbr.shared?\n shared << mbr\n else\n @member_lookup[mbr.name.upcase] = mbr\n end\n end\n # Link shared members to non-shared member (and vice versa)\n shared.each do |smbr|\n mbr = @member_lookup[smbr.name.upcase]\n smbr.instance_variable_set(:@non_shared_member, mbr)\n mbr.instance_variable_get(:@shared_members) << smbr\n end\n @root_member = @member_lookup[self.name.upcase]\n # Convert parent names to references to the parent Member object\n # This can only be done after we've seen all members, since the\n # member selection query returns parents after children\n @members.each do |mbr|\n par = @member_lookup[mbr.parent.upcase]\n mbr.instance_variable_set(:@parent, par)\n par.instance_variable_get(:@children) << mbr if par\n end\n ensure\n try{ mbr_sel.close }\n end\n log.finer \"Retrieved #{@members.size} members\"\n end",
"def path_components\n self[path_column].scan(PATH_SCAN)\n end",
"def indicesFor(pattern)\n @arrays_of_indices[pattern]\n end",
"def read_members(member_paths, options={})\n member_paths.map{|f| read_member(f, options) }\n end",
"def search(pattern, options={})\n matches = []\n load_path.each do |path|\n list = Dir.glob(File.join(path, match))\n list = list.map{ |d| d.chomp('/') }\n matches.concat(list)\n end\n matches\n end",
"def search(pattern, node, *args)\n if (match = match?(pattern, node, *args))\n yield node, match if block_given?\n match != true ? [node, match] : [node]\n else\n node.each_child_node\n .flat_map { |child| search(pattern, child, *args) }\n .compact.flatten\n end\n end",
"def search(search_str)\n # get list of dimensions\n dimensions = search_str.downcase.split.map do |token|\n @search_dw.keys(\"*#{token}*\")\n end.each do |result_arr|\n # remove datasets, allow dimensions\n result_arr.reject! { |ii| !ii.include? \"|\" }\n end.flatten\n\n # look up each dimension's metadata\n dimensions.map do |dim_key|\n dataset, dim = dim_key.split(\"|\")\n meta = get_metadata(dataset)\n units = meta['units'][dim]\n\n dim_name = if dim_key.include? \"|\"\n meta['name'] + \"|\" + meta['depvars'].find{ |depvar| to_r(depvar)==dim }\n else\n meta['name']\n end\n\n { \"dim_key\" => dim_key,\n \"dim_name\" => dim_name,\n \"description\" => meta[\"description\"],\n \"units\" => units,\n \"default\" => meta[\"default\"],\n \"url\" => meta[\"url\"],\n \"source_name\" => meta[\"source\"],\n \"publish_date\" => meta[\"publish_date\"] }\n end.compact\n end",
"def find(pattern)\n matches = []\n\n each_entry do |entry, _|\n next unless entry.pathname.match(pattern)\n\n matches << entry.pathname\n end\n\n matches\n end",
"def find_items pattern = nil\n items.values_at(*find_names(pattern))\n end",
"def search_gadget(base, offset_start, offset_end, pattern)\r\n mem = base + offset_start\r\n length = offset_end - offset_start\r\n mem_contents = session.railgun.memread(mem, length)\r\n return mem_contents.index(pattern)\r\n end",
"def getMemberArray(object, accessor, memberArray=nil)\n logger.debug(\"start getMemberArray: \" + object.to_s + \" \" + accessor.to_s + \" \" + memberArray.to_s )\n \n return if object.nil?\n \n if memberArray.nil?\n memberArray = Array.new\n end\n \n if object.respond_to? :each\n for o in object\n getMemberFromObject(o,accessor,memberArray) \n end \n else\n getMemberFromObject(object, accessor, memberArray) \n end\n \n raise \"Couldn't find data in \" + object.to_s + \" using accessor \" + accessor.to_s if memberArray.empty?\n # TODO flatten the collection if there is only one entry\n logger.debug(\"end getMemberArray: \" + object.to_s + \" \" + accessor.to_s + \" \" + memberArray.to_s )\n return memberArray\n end",
"def nested_block_reference_matching_pattern(pattern:, nodes:)\n value = []\n traverse_nodes_depth_first(nodes) {|node|\n if string_matches_pattern(pattern, node['string'])\n value << node[\"uid\"]\n end\n }\n\n value\nend",
"def member_for(message)\n @members.find { |m| /#{m.pattern}/i =~ message }\n end",
"def search(pattern)\n cache_data.map do |source, sic_entry|\n sic_entry.source_index.search pattern\n end.flatten\n end",
"def find(name, deep=true)\n sym = name.to_sym\n ms = matches.select {|m| m.has_name?(sym) }\n ms.concat(matches.map {|m| m.find(name, deep) }.flatten) if deep\n ms\n end",
"def find_piece(piece_name)\n\n for row in 0..@board.length do\n for col in 0..@board[row].length do\n return [row, col] if @board[row][col] == piece_name\n end\n end\n\n return nil\n end",
"def search(node, pattern)\n if (match = match?(node, pattern))\n yield node, match if block_given?\n match != true ? [node, match] : [node]\n else\n node.each_child_node\n .flat_map { |e| search(e, pattern) }\n .compact.flatten\n end\n end",
"def search(points)\n if points.is_a?(String)\n points = [points]\n end\n stones = []\n @groups.each do |group|\n group.each do |stone|\n stones << stone if points.include? stone.point\n end\n end\n return stones\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Sets the current POV
|
def pov=(new_pov)
new_pov
@pov = pov.merge(new_pov)
end
|
[
"def current_waypoint= _wp\n @current_waypoint = _wp\n SQF.setCurrentWaypoint @this, _wp\n end",
"def viewpoint=(value)\n @viewpoint = value\n end",
"def data=(pokemon)\n self.sy = pokemon.status if (self.visible = (pokemon ? true : false))\n end",
"def cvv=(value)\n # This is a stub, used for indexing. The method is dynamically generated.\n end",
"def set(v)\n @change_manager.before_change(self)\n __setobj__(v)\n @change_manager.after_change(self, SimpleChange.shallow)\n end",
"def view_point=(value)\n @view_point = value\n end",
"def set_Vote(value)\n set_input(\"Vote\", value)\n end",
"def viewpoint=(vp)\n connection_options[:viewpoint] = vp\n end",
"def assign_points\n if self.response == \"Yes\"\n self.points = 1\n elsif self.response == \"No\"\n self.points = 0\n end\n self.save\n end",
"def set_current_parking\n @@current_parking = self\n end",
"def setpoint\n @setpoint\n end",
"def set_Vote(value)\n set_input(\"Vote\", value)\n end",
"def set_PotentialStage(value)\n set_input(\"PotentialStage\", value)\n end",
"def v13_0=(value)\n @v13_0 = value\n end",
"def velocity=(velocity)\n @velocity = velocity\n end",
"def setVelocity(velocity)\n @velocity = velocity\n end",
"def v10_13=(value)\n @v10_13 = value\n end",
"def aumentar_velocidad\r\n @velocidad = @velocidad_alta\r\n end",
"def set_next_veg(vgg)\n\t# Check if the next vegetable to eat is valid\n\t#check_veg(vgg)\n\t\n\t$cur_veg = vgg\nend"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Get the default POV
|
def default_pov
# Make sure we are connected
check_attached
@logger.info "Retrieving default POV"
@req.GetDefaultPOV do |xml|
xml.sID @session_id
xml.getAtts '0'
xml.alsTbl @preferences.alias_table
end
doc = invoke
dims = doc.at('//res_GetDefaultPOV/dims').to_plain_text.split('|')
@dimensions = dims unless @dimensions
mbrs = doc.at('//res_GetDefaultPOV/mbrs').to_plain_text.split('|')
@pov = {}
0.upto(dims.size-1) do |i|
@pov[dims[i]] = mbrs[i]
end
@pov
end
|
[
"def default\n _default_id = ENV['MB_DEFAULT_PROVISIONER'] || self.default_id\n get!(_default_id) if _default_id\n end",
"def default_variant\n return nil if self.parent\n @default_variant ||= self.variants.select { |v| v.default? }.first\n end",
"def default_value\n property_values.detect { |pv| pv.default }\n end",
"def select_default_or_first_vpn\n if vpn = @vpns.find{|x| x.default}\n self.select_vpn(vpn.name)\n elsif @vpns.any?\n self.select_vpn(@vpns.first.name)\n else\n self.select_vpn(nil, reset:true)\n end\n end",
"def default_version\n config_get_default('vtp', 'version')\n end",
"def default_variant\n return nil if parent\n @default_variant ||= variants.find(&:default?)\n end",
"def sensible_default\n get\n end",
"def get_default_preference(prefs_section, pref)\n @driver.getDefaultPref(prefs_section, pref)\n end",
"def default\n options[:default]\n end",
"def getDefaultVersion(project)\n default_version = data[project].versions.select { |v| v.default? }\n return default_version.first[\"version\"]\n end",
"def get_default_preference(prefs_section, pref)\n driver.getDefaultPref(prefs_section, pref)\n end",
"def default_option\n @attributes[:default_option]\n end",
"def po_box\n \"PO BOX #{po_box_number}\" unless po_box_number.vacant?\n end",
"def default_variant_id\n @default_variant_id ||= default_variant.id\n end",
"def get_default\n list.each do |plan|\n return plan if plan['default']\n end\n nil\n end",
"def default_config\n UvConfiguration.new\n end",
"def current_poset_type\n case poset_id\n when bubble_group.full_poset_id\n \"Full\"\n when bubble_group.forward_poset_id\n \"Forward\"\n when bubble_group.backward_poset_id\n \"Backward\"\n else\n \"Unknown\"\n end\n end",
"def get_default(name)\n key_name = if name.is_a?(Symbol) then name else name.to_s end\n @default[key_name][:default] if @default[key_name]\n end",
"def default_photo\n @default_photo ||= if property_photos.present?\n property_photos.where(primary: true).first || property_photos.first\n else\n PropertyPhoto.new\n end\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Gets a default grid with the specified POV
|
def default_grid
# Make sure we are attached to a cube
check_attached
@logger.info "Retrieving default grid"
@req.GetDefaultGrid do |xml|
xml.sID @session_id
@preferences.inject_xml xml, @provider_type
xml.backgroundpov do |xml|
pov.each do |dim,mbr|
xml.dim :name => dim, :pov => mbr
end
end
end
doc = invoke
Grid.from_xml(doc)
end
|
[
"def default_grid\n\t\t\t\tguesses_and_hints_grid + solution_grid\n\t\t\tend",
"def default_grid\n Array.new(3) { Array.new(3) { BoardCase.new } }\n end",
"def default_grid\n Array.new(3) { Array.new(3) { Cell.new } }\n end",
"def default_grid\n Array.new(9) { Array.new(9) { Cell.new } }\n end",
"def default_grid\n Array.new(7) { Array.new(6) { Cell.new } }\n end",
"def default_pov\n # Make sure we are connected\n check_attached\n\n @logger.info \"Retrieving default POV\"\n @req.GetDefaultPOV do |xml|\n xml.sID @session_id\n xml.getAtts '0'\n xml.alsTbl @preferences.alias_table\n end\n doc = invoke\n dims = doc.at('//res_GetDefaultPOV/dims').to_plain_text.split('|')\n @dimensions = dims unless @dimensions\n mbrs = doc.at('//res_GetDefaultPOV/mbrs').to_plain_text.split('|')\n @pov = {}\n 0.upto(dims.size-1) do |i|\n @pov[dims[i]] = mbrs[i]\n end\n @pov\n end",
"def default_grid\n Array.new(7) { Array.new(6) { CellNode.new }}\n end",
"def free_form_grid(rows, cols, grid_pov=nil)\n # Make sure we are attached to a cube\n check_attached\n get_dimensions unless @dimensions\n\n # Update the POV if one is specified\n if grid_pov\n self.pov = grid_pov\n end\n\n grid = Grid.define(@dimensions, pov, rows, cols)\n\n @logger.info \"Retrieving free-form grid\"\n @req.ProcessFreeFormGrid do |xml|\n xml.sID @session_id\n @preferences.inject_xml xml, @provider_type\n xml.backgroundpov do |xml|\n pov.each do |dim,mbr|\n xml.dim :name => dim, :pov => mbr\n end\n end\n grid.to_xml(xml, false)\n grid.dims_to_xml(xml)\n end\n doc = invoke\n grid = Grid.from_xml(doc)\n\n # The grid returned does not contain data, so perform a refresh\n refresh(grid)\n end",
"def points_to_grid(points, width, height, zeroItem = 0, oneItem=1)\n grid = Grid.new(width, height, zeroItem) \n points.each {|point| grid[int_point(point)] = oneItem} \n return grid \n end",
"def grid(index)\r\n out_short_name = FFI::MemoryPointer.new(:string)\r\n out_full_name = FFI::MemoryPointer.new(:string)\r\n out_package_name = FFI::MemoryPointer.new(:string)\r\n out_url = FFI::MemoryPointer.new(:string)\r\n out_direct_download = FFI::MemoryPointer.new(:int)\r\n out_open_license = FFI::MemoryPointer.new(:int)\r\n out_available = FFI::MemoryPointer.new(:int)\r\n\r\n result = Api.proj_coordoperation_get_grid_used(self.context, self, index,\r\n out_short_name, out_full_name, out_package_name,\r\n out_url, out_direct_download ,\r\n out_open_license, out_available)\r\n\r\n if result != 1\r\n Error.check_object(self)\r\n end\r\n\r\n name_ptr = out_short_name.read_pointer\r\n full_name_ptr = out_full_name.read_pointer\r\n package_name_ptr = out_package_name.read_pointer\r\n url_ptr = out_url.read_pointer\r\n downloadable_ptr = out_direct_download \r\n open_license_ptr = out_open_license\r\n available_ptr = out_available\r\n\r\n unless name_ptr.null?\r\n Grid.new(name_ptr.read_string_to_null, self.context,\r\n full_name: full_name_ptr.null? ? nil : full_name_ptr.read_string_to_null,\r\n package_name: package_name_ptr.null? ? nil : package_name_ptr.read_string_to_null,\r\n url: url_ptr.null? ? nil : url_ptr.read_string_to_null,\r\n downloadable: downloadable_ptr.null? ? nil : downloadable_ptr.read_int == 1 ? true : false,\r\n open_license: open_license_ptr.null? ? nil : open_license_ptr.read_int == 1 ? true : false,\r\n available: available_ptr.null? ? nil : available_ptr.read_int == 1 ? true : false)\r\n end\r\n end",
"def grid\n return @grid\n end",
"def get_grid(x, y)\n grid = Array.new(x) {Array.new(y){0}}\n end",
"def create_grid\n @battle_grid = HexGrid.new(@viewport0)\n return @battle_grid\n end",
"def get_grid(grid_name)\n @grids[grid_name.to_sym]\n end",
"def create_grid\n grid = Array.new(6, Array.new(7, BLANK))\n end",
"def create_grid\n @grid = Array.new(@width) do |x|\n Array.new(@height) do |y|\n {x: x * $board_size + 2, # screen left - border is 2\n y: y * $board_size + 2, # screen bottom\n w: $board_size - 4, # reduce a bit for grid lines - spaces are 4\n h: $board_size - 4,\n r: 192,\n g: 192, # lighter gray than the default background\n b: 192,\n piece: :empty} # see Piece class for values\n end\n end\n end",
"def calc_grid_waypoints(waypoints)\n w0 = waypoints[-3]\n wx = waypoints[-2]\n wy = waypoints[-1]\n end",
"def grid\n @grid ||= [\n %w[HL HM HN HO HP JL JM JN JO JP],\n %w[HQ HR HS HT HU JQ JR JS JT JU],\n %w[HV HW HX HY HZ JV JW JX JY JZ],\n %w[NA NB NC ND NE OA OB OC OD OE],\n %w[NF NG NH NJ NK OF OG OH OJ OK],\n %w[NL NM NN NO NP OL OM ON OO OP],\n %w[NQ NR NS NT NU OQ OR OS OT OU],\n %w[NV NW NX NY NZ OV OW OX OY OZ],\n %w[SA SB SC SD SE TA TB TC TD TE],\n %w[SF SG SH SJ SK TF TG TH TJ TK],\n %w[SL SM SN SO SP TL TM TN TO TP],\n %w[SQ SR SS ST SU TQ TR TS TT TU],\n %w[SV SW SX SY SZ TV TW TX TY TZ]\n ].reverse\n end",
"def rails_grid(default_columns_options={})\n \n grid=RGhost::Grid::Rails.new(default_columns_options)\n yield grid\n grid.style(default_columns_options[:style]) if default_columns_options[:style]\n grid.data(default_columns_options[:data]) if default_columns_options[:data]\n set grid\n \n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Refresh a grid from the current provider
|
def refresh(grid)
# Make sure we are attached to a cube
check_attached
@logger.info "Refreshing grid"
@req.Refresh do |xml|
xml.sID @session_id
@preferences.inject_xml xml, @provider_type
grid.to_xml(xml)
end
doc = invoke
Grid.from_xml(doc)
end
|
[
"def reload_grid\n render :text => grid_reload\n end",
"def refresh\n do_refresh\n end",
"def reload_generic_grid\n conn = User.connection\n @recordset = conn.select_all(Globals.cleanup_where(dm_session[:final_statement]))\n @stat = dm_session[:search_engine_query_definition]\n @columns_list = dm_session[:columns_list]\n @grid_configs = dm_session[:grid_configs]\n @se_grid_action_columns = dm_session[:search_engine_grid_action_columns]\n @multi_sel = dm_session[:search_engine_multi_select]\n\n @se_summary_details_grid = false\n @se_grid = true\n render :inline => %{\n\n <% grid = build_generic_grid(@recordset, @stat, @columns_list,@se_grid_action_columns,@multi_sel, @grid_configs)%>\n <% grid.caption = 'view results' if grid.caption == DataGridJquery::DataGrid::DEFAULT_CAPTION %>\n <% grid.fullpage = true %>\n <% grid.reload_url = \"http://#{request.host_with_port}/reports/reports/reload_generic_grid\" %>\n <% @header_content = grid.build_grid_data %>\n\n <%= grid.render_html %>\n <%= grid.render_grid %>\n }, :layout=>'content'\n end",
"def grid_reload\n <<-JS\n $('##{parent.dom_id}_grid').setCaption('#{parent.caption}');\n $('##{parent.dom_id}_grid').trigger('reloadGrid');\n JS\n end",
"def refresh!\n fetch_data\n end",
"def refresh\n raise _(\"no Provider credentials defined\") if missing_credentials?\n raise _(\"Provider failed last authentication check\") unless authentication_status_ok?\n\n EmsRefresh.refresh(self)\n end",
"def grid_modified!\n end",
"def refresh_data\n raise NotImplementedError\n end",
"def refresh_view\n\t\t\tself.db.refresh_view( self.table_name )\n\t\tend",
"def refresh\n raise \"Source classes must implement their own `refresh` method\"\n end",
"def refresh_all\n\t\t\t@clients.each do |x|\n\t\t\t\tx.refresh\n\t\t\tend\n\t\tend",
"def refresh!\n @aggregators.each { |aggregator| aggregator.refresh! }\n end",
"def refresh\n refreshed_view = View.from_query(self.to_query)\n self.clear\n self.merge(refreshed_view)\n end",
"def refresh\n Codeclimate::Api::Repository.refresh(id, branch)\n end",
"def refresh\n send(:flush_cache) if respond_to?(:flush_cache)\n end",
"def refreshhosts\n assert_privileges(\"host_refresh\")\n host_button_operation('refresh_ems', _('Refresh'))\n end",
"def reload_grid(dom_id)\n dom_id = \"##{dom_id}\" unless dom_id.start_with?('#')\n self << \"jQuery('#{dom_id}').trigger('reloadGrid');\"\n end",
"def refresh!\n refreshed = cloud_provider.describe_instance(:instance_id => self.instance_id)\n self.dsl_options.merge!(refreshed.dsl_options)\n self\n end",
"def refresh\n FeedSource.find(params[:feed_source_id]).refresh\n feed_sources = params[:feed_sources]\n @feed_source_titles = {}\n FeedSource.find(feed_sources).each { |source| @feed_source_titles[source.id] = source.title}\n @feed_items = FeedItem.where(\"feed_source_id IN (?)\", feed_sources).order(pub_date: :desc).limit(20).offset(0)\n @feed_items = @feed_items.sort_by{ |item| item.pub_date.to_i }.reverse\n render :index\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Return a grid for the spcified rows and columns and optional POV The rows must be a hash whose key is a single dimension name, or array of dimension names. The value of the hash must be an array containing tuples of member names for the dimension(s) in the rows. The cols must be a hash whose key is a single dimension name, or array of dimension names. The value of the hash must be an array containing tuples of member names for the dimension(s) in the cols. The pov is an optional POV that will be merged with the current POV to determine the retrieved POV.
|
def free_form_grid(rows, cols, grid_pov=nil)
# Make sure we are attached to a cube
check_attached
get_dimensions unless @dimensions
# Update the POV if one is specified
if grid_pov
self.pov = grid_pov
end
grid = Grid.define(@dimensions, pov, rows, cols)
@logger.info "Retrieving free-form grid"
@req.ProcessFreeFormGrid do |xml|
xml.sID @session_id
@preferences.inject_xml xml, @provider_type
xml.backgroundpov do |xml|
pov.each do |dim,mbr|
xml.dim :name => dim, :pov => mbr
end
end
grid.to_xml(xml, false)
grid.dims_to_xml(xml)
end
doc = invoke
grid = Grid.from_xml(doc)
# The grid returned does not contain data, so perform a refresh
refresh(grid)
end
|
[
"def prepare_grid\n Array.new(rows) do |row|\n Array.new(columns) do |column|\n Cell.new(row: row, column: column)\n end\n end\n end",
"def three_row_grid\n grid = []\n grid << [\n Cell.new(:alive, 0, 0),\n Cell.new(:alive, 0, 1),\n Cell.new(:dead, 0, 2)\n ]\n grid << [\n Cell.new(:alive, 1, 0),\n Cell.new(:dead, 1, 1),\n Cell.new(:dead, 1, 2)\n ]\n grid << [\n Cell.new(:dead, 2, 0),\n Cell.new(:dead, 2, 1),\n Cell.new(:dead, 2, 2)\n ]\n grid\nend",
"def prepare_grid\n\t\tArray.new(rows) do |row|\n\t\t\tArray.new(columns) do |col|\n\t\t\t\tCell.new(row, col)\n\t\t\tend\n\t\tend\n\tend",
"def gen_cells args = {}\n\t\t\tx = args[:x] || 0\n\t\t\ty = args[:y] || 0\n\t\t\tw = args[:w] || 32\n\t\t\th = args[:h] || 32\n\n\t\t\tcell_count = {\n\t\t\t\tx: (current_room.w.to_f / w.to_f).floor,\n\t\t\t\ty: (current_room.h.to_f / h.to_f).floor\n\t\t\t}\n\n\t\t\treturn cell_count[:y].times.map do |row|\n\t\t\t\tnext cell_count[:x].times.map do |col|\n\t\t\t\t\tnext Cell.new(\n\t\t\t\t\t\tx: (w * col),\n\t\t\t\t\t\ty: (h * row),\n\t\t\t\t\t\tw: w, h: h,\n\t\t\t\t\t\tindex: { x: col, y: row },\n\t\t\t\t\t\tsolid: false\n\t\t\t\t\t)\n\t\t\t\tend\n\t\t\tend .flatten\n\t\tend",
"def grid_rect_for row, col\n { x: col * 16, y: row * 16, w: 16, h: 16 }\nend",
"def grid\n Matrix.build(@row_count, @column_count) { Cell.new }.to_a\n end",
"def create_grid\n @grid = Array.new(@width) do |x|\n Array.new(@height) do |y|\n {x: x * $board_size + 2, # screen left - border is 2\n y: y * $board_size + 2, # screen bottom\n w: $board_size - 4, # reduce a bit for grid lines - spaces are 4\n h: $board_size - 4,\n r: 192,\n g: 192, # lighter gray than the default background\n b: 192,\n piece: :empty} # see Piece class for values\n end\n end\n end",
"def grid\n @grid ||= [\n %w[HL HM HN HO HP JL JM JN JO JP],\n %w[HQ HR HS HT HU JQ JR JS JT JU],\n %w[HV HW HX HY HZ JV JW JX JY JZ],\n %w[NA NB NC ND NE OA OB OC OD OE],\n %w[NF NG NH NJ NK OF OG OH OJ OK],\n %w[NL NM NN NO NP OL OM ON OO OP],\n %w[NQ NR NS NT NU OQ OR OS OT OU],\n %w[NV NW NX NY NZ OV OW OX OY OZ],\n %w[SA SB SC SD SE TA TB TC TD TE],\n %w[SF SG SH SJ SK TF TG TH TJ TK],\n %w[SL SM SN SO SP TL TM TN TO TP],\n %w[SQ SR SS ST SU TQ TR TS TT TU],\n %w[SV SW SX SY SZ TV TW TX TY TZ]\n ].reverse\n end",
"def competition_grid(caption = nil, cssclass = nil)\n hash_grid = to_hash_grid(@database.handler[:master_grid])\n grid(caption, cssclass){ |sparsity, alph, range| \n tuple = hash_grid[alph][sparsity]\n label = tuple ? \"#{tuple[:nickname]}/#{tuple[:algorithm]}\" : \"\"\n css_class = CELL_STATUS_TO_CSS_CLASS[tuple ? tuple[:cell_status] : 0]\n {:label => label, :css_class => css_class}\n }\n end",
"def create_grid\n reset_grid!\n\n 0.upto(width - 1) do |row_index|\n 0.upto(height - 1) do |column_index|\n grid[row_index][column_index] =\n Cell.new(board: self, row: row_index, col: column_index)\n end\n end\n end",
"def draw_grid x, y, h, w, lines_h, lines_v\n\n # The grid starts off empty.\n grid = []\n\n # Calculates the placement and adds horizontal lines or separators into the grid.\n curr_y = y # start at the bottom of the box\n dist_y = h / (lines_h + 1) # finds distance to place horizontal lines evenly throughout 500 height of grid\n lines_h.times do\n curr_y += dist_y # increment curr_y by the distance between the horizontal lines\n grid << horizontal_separator(curr_y, x, x + w - 1) # add a separator into the grid\n end\n\n # Calculates the placement and adds vertical lines or separators into the grid.\n curr_x = x # now start at the left of the box\n dist_x = w / (lines_v + 1) # finds distance to place vertical lines evenly throughout 500 width of grid\n lines_v.times do\n curr_x += dist_x # increment curr_x by the distance between the vertical lines\n grid << vertical_separator(curr_x, y + 1, y + h) # add separator\n end\n\n # paint_grid uses a hash to assign values to keys.\n state.paint_grid ||= {\"x\" => x, \"y\" => y, \"h\" => h, \"w\" => w, \"lines_h\" => lines_h,\n \"lines_v\" => lines_v, \"dist_x\" => dist_x,\n \"dist_y\" => dist_y }\n\n return grid\n end",
"def grid_data(sparql_results, rows_dimension_uri, columns_dimension_uri)\n\n rows_hash = {}\n\n sparql_results.each do |result|\n row_uri = result[\"row\"][\"value\"]\n column_uri = result[\"column\"][\"value\"]\n val = result[\"val\"][\"value\"]\n obs = result[\"obs\"][\"value\"]\n row_label = result[\"rowlabel\"][\"value\"] if result[\"rowlabel\"]\n rows_hash[row_uri] ||= {}\n rows_hash[row_uri][\"rowlabel\"] = row_label\n rows_hash[row_uri][column_uri] = {val: val, obs: obs}\n end\n\n # we now have a fully popluated rows_hash.\n # {\n # \"row-1-uri\": {\"col-1-uri\": {val: blah, obs: obs-uri}, \"col-2-uri\": {val: blah, obs: obs-uri},\n # \"row-2-uri\": ....\n # }\n\n # now build the actual rows to return\n rows = []\n rows_hash.each_pair do |row_uri, row_data|\n\n # init the results row with just the row uri\n row = {}\n row[rows_dimension_uri] = row_uri\n\n row_data.each_pair do |column_uri, column_value|\n row[column_uri] = column_value\n end\n\n rows << row\n end\n\n rows\n end",
"def grid(index)\r\n out_short_name = FFI::MemoryPointer.new(:string)\r\n out_full_name = FFI::MemoryPointer.new(:string)\r\n out_package_name = FFI::MemoryPointer.new(:string)\r\n out_url = FFI::MemoryPointer.new(:string)\r\n out_direct_download = FFI::MemoryPointer.new(:int)\r\n out_open_license = FFI::MemoryPointer.new(:int)\r\n out_available = FFI::MemoryPointer.new(:int)\r\n\r\n result = Api.proj_coordoperation_get_grid_used(self.context, self, index,\r\n out_short_name, out_full_name, out_package_name,\r\n out_url, out_direct_download ,\r\n out_open_license, out_available)\r\n\r\n if result != 1\r\n Error.check_object(self)\r\n end\r\n\r\n name_ptr = out_short_name.read_pointer\r\n full_name_ptr = out_full_name.read_pointer\r\n package_name_ptr = out_package_name.read_pointer\r\n url_ptr = out_url.read_pointer\r\n downloadable_ptr = out_direct_download \r\n open_license_ptr = out_open_license\r\n available_ptr = out_available\r\n\r\n unless name_ptr.null?\r\n Grid.new(name_ptr.read_string_to_null, self.context,\r\n full_name: full_name_ptr.null? ? nil : full_name_ptr.read_string_to_null,\r\n package_name: package_name_ptr.null? ? nil : package_name_ptr.read_string_to_null,\r\n url: url_ptr.null? ? nil : url_ptr.read_string_to_null,\r\n downloadable: downloadable_ptr.null? ? nil : downloadable_ptr.read_int == 1 ? true : false,\r\n open_license: open_license_ptr.null? ? nil : open_license_ptr.read_int == 1 ? true : false,\r\n available: available_ptr.null? ? nil : available_ptr.read_int == 1 ? true : false)\r\n end\r\n end",
"def points_to_grid(points, width, height, zeroItem = 0, oneItem=1)\n grid = Grid.new(width, height, zeroItem) \n points.each {|point| grid[int_point(point)] = oneItem} \n return grid \n end",
"def get_grid\n curr_x = state.centerX - (state.gridSize / 2) # starts at left of grid\n deltaX = state.gridSize / state.lineQuantity # finds distance to place vertical lines evenly through width of grid\n (state.lineQuantity + 2).times do\n state.gridX << curr_x # adds curr_x to gridX collection\n curr_x += deltaX # increment curr_x by the distance between vertical lines\n end\n\n curr_y = state.centerY - (state.gridSize / 2) # starts at bottom of grid\n deltaY = state.gridSize / state.lineQuantity # finds distance to place horizontal lines evenly through height of grid\n (state.lineQuantity + 2).times do\n state.gridY << curr_y # adds curr_y to gridY collection\n curr_y += deltaY # increments curr_y to distance between horizontal lines\n end\n end",
"def represent\n # grid_array will be an array of strings that represent our grid in NxN format\n grid_array=[]\n @h.times{|r| grid_array<<@grid[r*@w,@w].split('')*' '}\n grid_array\n end",
"def create_grid\n grid = Array.new(6, Array.new(7, BLANK))\n end",
"def load_grid()\n columns = \"ABCDEFGHI\".chars\n print \" \"\n for i in columns\n print \" #{i} \".colorize(:cyan)\n end\n puts \"\"\n \n for point_value in @grid_values\n if point_value[1] == 1 \n print \"#{point_value[0]} \".colorize(:cyan)\n end\n if point_value[2] == 0\n print \"[ ]\".colorize(:green)\n end \n if point_value[2] == \"S\"\n print \" \"\n end \n if (1..8).include?(point_value[2])\n print \" #{point_value[2]} \".colorize(:blue)\n end \n if point_value[2] == \"X\" and @game_state == \"lost\"\n print \" #{point_value[2]} \".colorize(:red)\n end \n if point_value[2] == \"X\" and @game_state == \"win\"\n print \" #{point_value[2]} \".colorize(:magenta)\n end \n if point_value[2] == \"X\" and @game_state != \"lost\" and @game_state != \"win\"\n print \" \"\n end \n if point_value[1] == 9\n puts \"\"\n end\n end \n end",
"def grid_setup\n widths, rows = get_grid_info\n @grid = page.all(:xpath,\n \".//div[contains(@class, 'x-grid-item-container')]\").\n reject { |e| e.text.include?('DataGrid1') }.first\n @gridx = @grid.native.rect.x\n @gridy = @grid.native.rect.y\n height = @grid.native.size.height\n @perr = (height / rows).to_i\n col_preh = widths.each_with_index.map do |c, i|\n [i, [c[:x] + @gridx, c[:width]]]\n end\n @colh = Hash[col_preh]\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Checks to see that a session has been established, raising a NotConnected exception if one has not.
|
def check_connected
raise NotConnected unless @session_id && @sso && @provider
end
|
[
"def session_check!\n raise CAError.new(\"You are not connected to the server.\") if !connected?\n end",
"def assert_connected\n raise ConnectionError, 'not connected' unless @connected\n end",
"def check\n begin\n unless @client.connected?\n self.logging \"[#{Time.now}]Disconnected! Try Reconnecting!\"\n @client.reconnect\n end\n @client.status(nil, \"\")\n rescue => e\n raise CONNECTOR_ERR + e\n end\n end",
"def check_server_connection\n\t\tsession[:foo] = \"bar\" unless session.id \n\t\traise \"session.id is nil\" unless session.id\n\t\tunless @client = ClientConnections.get(session.id.public_id)\n\t\t\tredirect_to root_path, flash: { error: \"Please connect to a formulary server\" }\n\t\tend\n\tend",
"def checkConnection\n unless connected?\n raise DictError.new(), \"Not connected.\"\n end\n end",
"def connected?\n @connection && !@connection.expired?\n end",
"def check_formulary_server_connection\n session[:foo] = \"bar\" unless session.id\n raise \"session.id is nil\" unless session.id\n unless @client = ClientConnections.get(session.id.public_id)\n reset_session\n redirect_to root_path, flash: { error: \"Please connect to a formulary server\" }\n end\n end",
"def connected_session\n raise Bunny::Exception.new(\"Too many attempts to connect\") if @attempts > 3\n @connection.start\n rescue Bunny::NetworkFailure => e\n log.warn(\"type=measure.queue.attempt connection=#{connection_info} msg=#{e.message} status=retry\")\n @attempts = @attempts + 1\n self.connected_session unless @connection.open?\n ensure\n @attempts = 0 if @connection.open?\n end",
"def connected?\n !!@session_id && !!@cluster\n end",
"def check_client\n unless client\n raise ClientNotSetup\n end\n unless client.connected?\n if raise_on_error\n raise ClientNotConnected\n else\n @logger.error 'Client not connected! Check internet connection'\n return false\n end\n end\n true\n end",
"def check_connection!\n if not @ssh\n raise Acme::Distributed::ServerError, \"Challenge server name=#{self.name} is not connected.\"\n end\n end",
"def connected?\n response = execute('status')\n valid_response?(response)\n rescue VlcProxy::AccessDeniedError, Errno::ECONNREFUSED => e\n @logger.error(e.message)\n false\n end",
"def ensure_connection!\n fail \"Must have active connection\" unless connection\n end",
"def is_connected?\n return @status == CONNECTED\n end",
"def ready?\n @connected && @logged_in\n end",
"def connect_error?\n @connerror || false\n end",
"def is_connected?\n return @status == CONNECTED\n end",
"def connected?\n !connections.empty?\n end",
"def established?\n @handshake.complete? && @handshake.valid?\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Checks that a cube is open, raising a NotAttached exception if one is not.
|
def check_attached
check_connected
raise NotAttached unless @app && @cube
end
|
[
"def attached?\n\t\tCommon.device_status(@handle);\n end",
"def attached?\n not send(self.class.container_name).nil?\n end",
"def check()\n # check if teh volume still exists\n begin\n volumes = $ec2.describe_volumes([self.id])\n rescue RightAws::AwsError\n if $!.errors[0][0] == \"InvalidVolume.NotFound\"\n puts \"WARN: Volume #{self.id} is not running\"\n delete()\n return\n else\n p $!.code\n end\n end\n\n # check that it is attached\n if volumes[0][:aws_attachment_status] == 'attached'\n if self.attached_instance != volumes[0][:aws_instance_id]\n self.attached_instance = volumes[0][:aws_instance_id]\n self.save()\n puts \"WARN: volume #{self.id} is now attached to #{self.attached_instance}\"\n end\n elsif self.attached_instance.nil?\n puts \"WARN: volume #{self.id} is no longer attached\"\n self.attached_instance = nil\n self.save()\n end\n end",
"def attached?\n !@parent.nil?\n end",
"def attached?\n !mount[:instance].nil?\n end",
"def open?\n envelope.state == \"OPEN\"\n end",
"def open?(direction)\r\n ! @exits[direction].nil?\r\n end",
"def ensure_attachment_present\n if attachments.empty?\n false\n else\n errors.add(:base, 'Attachment needed')\n true\n end\n end",
"def check_client\n unless client\n raise ClientNotSetup\n end\n unless client.connected?\n if raise_on_error\n raise ClientNotConnected\n else\n @logger.error 'Client not connected! Check internet connection'\n return false\n end\n end\n true\n end",
"def ensure_actively_connected\n c = Connection.connection(self.from_id, self.to_id)\n if c.nil? or c.connected? == false\n errors.add(:contact_me_back, I18n.t('cmb.from-and-to-not-connected'))\n return false \n end\n end",
"def cube?\n (self**(1.0/3.0).floor)**3 == self\n end",
"def can_open?\n errors.add(:status, \"Can't open challenge unless space is accepted\") if active? && !space&.accepted?\n end",
"def has_channel?\n if PropertyChannel.find_by_pool_id(self.id).blank?\n false\n else\n true\n end\n end",
"def attached?\n attachment.present?\n end",
"def check_state\n EM.stop if @setup.report_state.content =~ /operational|stranded/\n end",
"def is_connection_exists(arg_host_name, arg_volume_name)\n url = '/host/' + arg_host_name + '/volume/' + arg_volume_name\n output = get_rest_call(url)\n\n if !output['vol'].nil?\n return true\n else\n return false\n end\n end",
"def face?\n faces.any?\n end",
"def check_face(face)\n raise StandardError, 'Wrong face choose between north, south, west, east' unless FACES.include?(face)\n end",
"def openedboxeserror\n\t\t@output.puts \"Error: You can't open a box you have already opened!.\"\n\tend"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Sends the current request XML to the SmartView provider, and parses the response with hpricot. If an exception was returned, an SmartViewException is raised with the details of the error.
|
def invoke
resp = nil
ms = Benchmark.realtime do
resp = @http.post @url, @req.to_s
end
@logger.info 'SmartView request %s completed in %.1fs' % [@req.method, ms]
doc = Hpricot::XML(resp.body.content)
if !doc.at("//res_#{@req.method}")
@logger.error "Error invoking SmartView method #{@req.method}"
@logger.debug "Request was:\n#{@req}"
@logger.debug "Response was:\n#{resp.body.content}"
if ex = doc.at('//exception')
ex = SmartViewException.new(ex)
@logger.error "An exception occurred in #{@req.method}"
@logger.error ex
raise ex
else
@logger.error "Unexpected response from SmartView provider:\n#{doc.to_plain_text}"
raise RuntimeError, "Unexpected response from SmartView provider: #{doc.to_plain_text}"
end
end
doc
end
|
[
"def send_request( xml )\n write( xml )\n read\n end",
"def send_request\n @request = to_xml\n @response = post_webex_request(security_context.site_name, @request)\n check_response_and_return_data(@response)\n end",
"def send_raw(xml)\n open\n @soap_client.ProcessRequest(@ticket, xml)\n close \n end",
"def op_send_request_xml(params)\n return '' unless valid?\n\n # update the ticket with the metadata sent at the first request for XML (i.e. if not blank)\n @ticket.update!(\n hpc_response: (@ticket.hpc_response || params[:hcpresponse]),\n company_file_name: (@ticket.company_file_name || params[:company]),\n country: (@ticket.country || params[:country]),\n qbxml_major_version: (@ticket.qbxml_major_version || params[:major_ver]),\n qbxml_minor_version: (@ticket.qbxml_minor_version || params[:minor_ver])\n )\n\n # only process when in the Authenticated or Processing states\n unless ['Authenticated', 'Processing'].include?(@ticket.state)\n @ticket.request_error!(@last_log_message)\n return ''\n end\n\n # either grab the current request or create a new one\n request = @ticket.qb_request\n unless request\n request = create_request\n @ticket.qb_request = request\n end\n\n # if we don't have a request, then we are done.\n unless request\n log \"There is no more work to be done. Marking ticket state as finished\"\n @ticket.update!(state: 'Finished')\n return ''\n end\n\n request.update!(qb_ticket: @ticket, request_sent_at: Time.zone.now)\n qb_xml = request.to_qb_xml\n request.update!(request_qbxml: qb_xml)\n\n # set the ticket into a Processing state\n @ticket.state = 'Processing'\n\n # save the changes.\n @ticket.save!\n\n log \"Sending request [#{request.state}] XML to QuickBooks\"\n\n qb_xml\n end",
"def send_request\n\n # create the connection object\n uri = URI.parse \"#{MoovAtom::API_URL}/#{@action}.#{@format}\"\n http = Net::HTTP.new uri.host, uri.port\n http.use_ssl = true\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\n # open the connection and send request\n http.start do |http|\n req = Net::HTTP::Post.new(uri.request_uri)\n req.set_form_data(all_attributes, '&')\n @response = http.request(req)\n end\n\n # parse the response if request was successful\n if @response.code == \"200\"\n case @format\n when \"json\"\n @response = JSON.parse @response.body\n when \"xml\"\n @response = REXML::Document.new @response.body\n end\n end\n\n end",
"def send_request(xml)\n send_frame(xml)\n response = get_frame\n end",
"def send_request\n @query = Builder::XmlMarkup.new(:indent => 2)\n @query.Query do\n @query << @body.target!\n end\n \n begin\n # ask Domino what this is?\n # @request, @raw_response = @http.post(@uri.path, @query.target!, 'Content-type' => 'application/xml')\n\n @response = Nokogiri::XML(fetch_response.body)\n\n build_records\n build_breadcrumbs\n build_dimensions\n build_business_rules\n build_search_reports\n build_selected_dimension_value_ids\n build_keyword_redirect\n rescue Timeout::Error, Errno::EINVAL, Errno::ECONNRESET, Errno::ECONNREFUSED, EOFError, Net::HTTPBadResponse, Net::HTTPHeaderSyntaxError, Net::ProtocolError => error\n @error = error\n end\n end",
"def send(xml)\n msg = <<EOL\n<?xml version=\"1.0\"?>\n<?qbxml version=\"#{QBXML_VERSION}\"?>\n<QBXML>\n <QBXMLMsgsRq onError=\"continueOnError\">\n #{xml}</QBXMLMsgsRq>\n</QBXML>\nEOL\n puts msg\n @soap_client.ProcessRequest(@ticket, xml)\n end",
"def send_request(xml)\n send_frame(xml)\n get_frame\n end",
"def call\n request = http_request_class.new(uri.request_uri, headers)\n request.body = body if body\n http = http_setup\n # http.set_debug_output($stdout)\n response = wait_for_completion(HttpResponse.new(http.request(request)))\n Nokogiri::XML response.body unless response.nil?\n end",
"def handle_xml_response(rawXML)\n facepricotXML = Facepricot.new(rawXML)\n\n # error checking \n if facepricotXML.at(\"error_response\")\n \n # get the error code\n errorCode = facepricotXML.at(\"error_code\").inner_html.to_i\n errorMessage = facepricotXML.at(\"error_msg\").inner_html\n log_debug \"** RFACEBOOK(GEM) - RFacebook::FacebookSession\\#remote_call - remote call failed (#{errorCode}: #{errorMessage})\"\n \n # TODO: remove these 2 lines\n @last_error_message = \"ERROR #{errorCode}: #{errorMessage}\" # DEPRECATED\n @last_error_code = errorCode # DEPRECATED\n \n # check to see if this error was an expired session error\n case errorCode\n\n # the remote method did not exist, convert that to a standard Ruby no-method error\n when 3\n raise NoMethodError, errorMessage unless quiet? == true\n \n # the parameters were wrong, or not enough parameters...convert that to a standard Ruby argument error\n when 100,606\n raise ArgumentError, errorMessage unless quiet? == true\n \n # when the session expires, we need to record that internally\n when 102\n @expired = true\n raise ExpiredSessionStandardError.new(errorMessage, errorCode) unless quiet? == true\n \n # otherwise, just raise a regular remote error with the error code\n else\n raise RemoteStandardError.new(errorMessage, errorCode) unless quiet? == true\n end\n \n # since the quiet flag may have been activated, we may not have thrown\n # an actual exception, so we still need to return nil here\n return nil\n end\n \n # everything was just fine, return the Facepricot XML response\n return facepricotXML\n end",
"def request( xml )\n # open_connection\n\n # @logged_in = true if login\n\n begin\n @response = send_request( xml )\n ensure\n if @logged_in && !old_server\n @logged_in = false if logout\n end\n end\n\n return @response\n end",
"def execute\r\n\r\n begin\r\n logger.debug \"generating request\" if logger.debug?\r\n\r\n generate_request_xml\r\n self.save!\r\n\r\n logger.debug \"request: #{self.request}\" if logger.debug?\r\n\r\n req = create_base_request\r\n req.set_form_data( { :qf => 'xml', :xml => self.request} )\r\n\r\n http = Net::HTTP.new(ET_URI.host, ET_URI.port)\r\n http.use_ssl = true\r\n http.read_timeout = 300 # 5 mins\r\n res = do_http http, req\r\n\r\n logger.debug \"response: #{res.body}\" if logger.debug?\r\n\r\n case res.code\r\n when '200'\r\n self.response = res.body\r\n doc = REXML::Document.new self.response\r\n error_node = REXML::XPath.first doc.root, \"//error\"\r\n if error_node\r\n error_code = error_node.text\r\n error_description_node = REXML::XPath.first doc.root, \"//error_description\"\r\n error_description = (error_description_node ? error_description_node.text : nil)\r\n error_description_detail_node = REXML::XPath.first doc.root, \"//error_detail\"\r\n error_description_detail = (error_description_detail_node ? error_description_detail_node.text : nil)\r\n\r\n self.error_code = error_code\r\n\r\n return new_state_for_error(error_code, error_description, error_description_detail)\r\n else\r\n self.status = :et_success\r\n self.error_code = nil\r\n self.next_try_at = nil\r\n end\r\n else\r\n logger.error \"unexpected result executing message: #{res}\"\r\n return :retry\r\n end\r\n\r\n if !completed?\r\n return :retry\r\n end\r\n\r\n # save the updates to the message\r\n unless save\r\n errs = []\r\n self.errors.each do |n,v|\r\n errs << \"#{n}: #{v}\"\r\n end\r\n logger.error \"unabled to update etmessage #{self.id} after server communication: #{errs.join(';')} \"\r\n return :fail\r\n end\r\n \r\n # allow for any subclass-specific behavior after execution\r\n if :et_success == self.status\r\n if after_execute\r\n self.status = :success\r\n save!\r\n end\r\n end\r\n\r\n return :success\r\n rescue Exception => e\r\n logger.fatal \"unexpected exception encountered executing message: #{e.message}:\\n#{e.backtrace.join(\"\\n\")}\"\r\n return :retry\r\n end\r\n end",
"def parse_to_xml\n raise_if_error\n response_xml\n end",
"def send_query query\n url = ENDPOINT + query\n # send Amazon FPS query to endpoint\n url = URI.parse(url)\n http = Net::HTTP.new(url.host, url.port)\n http.use_ssl = true\n req = Net::HTTP::Get.new(query)\n response = http.start { |http|\n http.request(req)\n }\n xml_response = response.body.to_s\n xml_response.gsub! \"ns3:\", \"\"\n xml_response.gsub! \"ns2:\", \"\"\n return xml_response;\n \n # 200s and 401s HTTP responses return XML\n case response\n when Net::HTTPSuccess then \n return xml_response\n when Net::HTTPUnauthorized then\n return xml_response\n when Net::HTTPInternalServerError then\n return xml_response\n when Net::HTTPBadRequest then\n return xml_response\n else\n false\n end\n end",
"def relay_response\n sim_response = AuthorizeNet::SIM::Response.new(params)\n if sim_response.success?(AUTHORIZE_NET_CONFIG['api_login_id'], AUTHORIZE_NET_CONFIG['merchant_hash_value'])\n render text: sim_response.direct_post_reply(payments_receipt_url(only_path: false), include: true)\n else\n render\n end\n end",
"def relay_response\n sim_response = AuthorizeNet::SIM::Response.new(params)\n if sim_response.success?(AUTHORIZE_NET_CONFIG['api_login_id'], AUTHORIZE_NET_CONFIG['merchant_hash_value'])\n render :text => sim_response.direct_post_reply(payments_receipt_url(:only_path => false), :include => true)\n \n else\n render\n end\n end",
"def relay_response\n sim_response = AuthorizeNet::SIM::Response.new(params)\n if sim_response.success?(AUTHORIZE_NET_CONFIG['api_login_id'], AUTHORIZE_NET_CONFIG['merchant_hash_value'])\n render :text => sim_response.direct_post_reply(payments_receipt_url(:only_path => false), :include => true)\n else\n render\n end\n end",
"def send\n http = Net::HTTP.new(@uri.host, @uri.port)\n http.read_timeout = @http_timeout\n\n # Output request XML if debug flag is set\n if debug == true\n logger.info \"Request URL: #{@uri.to_s}\"\n logger.info \"Request Timeout: #{@http_timeout}\"\n logger.info \"Request headers: #{headers}\"\n logger.info \"Request body: #{body}\"\n end\n\n if @uri.port == 443\n http.use_ssl = true\n http.ssl_timeout = @http_timeout\n http.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n\n post = Net::HTTP::Post.new(@uri.path, headers)\n post.body = body\n post.content_type = 'text/xml'\n\n response = http.start { |http| http.request(post) }\n\n if debug == true\n logger.info \"Response: #{response}\"\n end\n\n if response.is_a? Net::HTTPInternalServerError\n logger.info \"#{response.class.to_s}: #{response.message}\"\n return Hashie::Mash.new({})\n end\n\n @response = Hashie::Mash.new(Response.new(self, response))\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Insert filter arguments to a request
|
def insert_filter_args(xml, filter_args)
if filter_args
filter_args.each_with_index do |filter_arg, i|
xml.arg({'id' => "#{i}"}, filter_arg)
end
end
end
|
[
"def add_to_filter_parameters; end",
"def add_to_filter_parameters=(_arg0); end",
"def add_filtered_parameters\n append_to_file('config/initializers/filter_parameter_logging.rb', 'Rails.application.config.filter_parameters += %i[email ip]')\n end",
"def excluded_from_filter_parameters=(_arg0); end",
"def filter_args(filter)\n {\n list_position: filter.list_position.en.ordinate,\n real_size: filter.real_size.en.numwords,\n requested_size: filter.requested_size.en.numwords,\n filtered_size: filter.filtered_size.en.numwords,\n list_order: filter.list_order,\n filtered_position_offset: (filter.list_position + filter.filtered_size - 1).en.ordinate\n }\n end",
"def filter_argument; end",
"def filter_params_for_log(request, env)\n request.params.merge(env['halcyon.route'])\n end",
"def inclusion_filter=(filter); end",
"def request_filters\n\t\t\treturn self.filters[ :request ] + self.filters[ :both ]\n\t\tend",
"def set_arguments\n exclusion_list = %w[client_tag api request_name]\n all_parameters = request.request_parameters\n applicable_params = all_parameters.reject { |param_name, _value| exclusion_list.include?(param_name) }\n @arguments = {}\n applicable_params.each do |k, v|\n @arguments[k] = v.chomp\n end\n end",
"def add_filter(*args)\n raise ArgumentError, \"wrong number of arguments (#{args.length} for 2..3)\" if args.length != 2 and args.length != 3\n\n field = args.shift.to_sym\n self.fields[field] = [] unless self.fields.has_key?(field)\n\n if args.length == 1\n self.fields[field] << args.first\n else\n self.fields[field] << { operator: args.first, value: args.last }\n end\n\n self\n end",
"def query_filters; end",
"def before_filter(*filters)\n @before_filters += filters\n end",
"def add_filter(permitted = [])\n @filter = JsonApiServer::Filter.new(request, model, permitted)\n self\n end",
"def before filter\n @befores << filter\n end",
"def apply_request_filters( request )\n\t\tself.log.debug \"Applying request filters:\"\n\t\tself.class.request_filters.each do |filter|\n\t\t\tself.log.debug \" filter: %p\" % [ filter ]\n\t\t\tfilter.call( request )\n\t\tend\n\tend",
"def parse_filter_params\n unless request.query_string.blank?\n parse_search_params(params)\n end\n end",
"def addargs(*args)\n ## Add all additional arguments to the request sentence list:\n args.each do |arg|\n if arg.is_a?(Hash)\n ## Prepend argument keys that don't begin with the API-\n ## command-specific parameter character '.', nor the\n ## normal parameter charactre '=', nor the query character\n ## '?' with the ordinary parameter character '=':\n arg.each do |key, value|\n key = '=' + key unless /^[\\?\\=\\.]/.match(key)\n addarg(key + '=' + value)\n end\n else\n addarg(arg)\n end\n end\n end",
"def to_param\n \"filter[#{name}]=#{value}\"\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
store the countries information and create region list
|
def store_countries
Countries::Data.get_data
@regions = Countries::Country.create_region_list
end
|
[
"def countries_and_regions=(value)\n @countries_and_regions = value\n end",
"def add_to_region\r\n western_states = [\"Arizona\", \"Colorado\", \"Idaho\", \"Montana\", \"Nevada\", \"New Mexico\", \"Utah\", \"Wyoming\", \"Alaska\", \"California\", \"Hawaii\", \"Oregon\", \"Washington\"]\r\n southern_states = [\"Alabama\", \"Arkansas\", \"Delaware\", \"Florida\", \"Georgia\", \"Kentucky\", \"Louisiana\", \"Maryland\", \"Mississippi\", \"North Carolina\", \"Oklahoma\", \"South Carolina\", \"Tennessee\", \"Texas\", \"Virgina\", \"West Virginia\"]\r\n eastern_states = [\"Maine\", \"New Hampshire\", \"Vermont\", \"Massachusetts\", \"Rhode Island\", \"Connecticut\", \"New York\", \"Pennsylvania\", \"New Jersey\"]\r\n midwest_states = [\"Wisconsin\", \"Michigan\", \"Illinois\", \"Indiana\", \"Ohio\", \"North Dakota\", \"South Dakota\", \"Nebraska\", \"Kansas\", \"Minnesota\", \"Iowa\", \"Missouri\"]\r\n\r\n if western_states.include?(name)\r\n @@wregion[:confirmed_cases] += self.confirmed_cases\r\n @@wregion[:overall_deaths] += self.overall_deaths\r\n elsif southern_states.include?(name)\r\n @@sregion[:confirmed_cases] += self.confirmed_cases\r\n @@sregion[:overall_deaths] += self.overall_deaths\r\n elsif eastern_states.include?(name)\r\n @@eregion[:confirmed_cases] += self.confirmed_cases\r\n @@eregion[:overall_deaths] += self.overall_deaths\r\n elsif midwest_states.include?(name)\r\n @@mregion[:confirmed_cases] += self.confirmed_cases\r\n @@mregion[:overall_deaths] += self.overall_deaths\r\n end\r\n\r\n end",
"def regions\n\t\tignore_nil { country.regions }\n\tend",
"def load_country_index\n zones = {}\n \n File.open(File.join(@zoneinfo_dir, 'zone.tab')) do |file|\n file.each_line do |line|\n line.chomp!\n \n if line =~ /\\A([A-Z]{2})\\t(?:([+\\-])(\\d{2})(\\d{2})([+\\-])(\\d{3})(\\d{2})|([+\\-])(\\d{2})(\\d{2})(\\d{2})([+\\-])(\\d{3})(\\d{2})(\\d{2}))\\t([^\\t]+)(?:\\t([^\\t]+))?\\z/\n code = $1\n \n if $2\n latitude = dms_to_rational($2, $3, $4)\n longitude = dms_to_rational($5, $6, $7)\n else\n latitude = dms_to_rational($8, $9, $10, $11)\n longitude = dms_to_rational($12, $13, $14, $15)\n end\n \n zone_identifier = $16\n description = $17\n \n (zones[code] ||= []) << \n CountryTimezone.new(zone_identifier, latitude.numerator, latitude.denominator, \n longitude.numerator, longitude.denominator, description)\n end\n end\n end\n \n countries = {}\n \n File.open(File.join(@zoneinfo_dir, 'iso3166.tab')) do |file|\n file.each_line do |line|\n line.chomp!\n \n if line =~ /\\A([A-Z]{2})\\t(.+)\\z/\n code = $1\n name = $2\n countries[code] = ZoneinfoCountryInfo.new(code, name, zones[code] || [])\n end\n end\n end\n \n countries\n end",
"def regions_and_countries_from(countries = [])\n country_items = []\n region_items = []\n potential_regions = {}\n\n # First try to sort countries into potential regions.\n countries.each do |country|\n region = region_by_country(country)\n if region.present?\n region_key = region[:slug]\n unless potential_regions.key? region_key\n potential_regions[region_key] = []\n end\n potential_regions[region_key].push(country)\n else\n country_items.push(country)\n end\n end\n\n # Next find out how many potential region entries are complete.\n potential_regions.each_value do |country_list|\n region = region_by_countries(country_list)\n if region.present?\n region_items.push(region)\n else\n country_items.concat(country_list)\n end\n end\n\n # Return the (hopefully) sorted countries and regions\n { regions: region_items, countries: country_items }\n end",
"def filter_regions\n regions = if @country_list.present?\n filtered_region_list\n else\n regions_list\n end\n {\n 'name': 'regions[]',\n 'options': regions,\n 'selected': @filter.regions,\n }\n end",
"def countries\n countries = YAML.load_file(Rails.root.join('data', 'locale_countries.yml'))\n countries.select! { |_, flag| File.exist? Rails.root.join('app', 'assets', 'images', 'country-flags', \"#{flag.downcase}.png\") }\n # apply potential region values too\n Dir.glob(Rails.root.join('app', 'assets', 'images', 'country-flags', '*.png')).each do |file|\n base = File.basename(file, '.png')\n next if base.starts_with?('_')\n countries[base.upcase] = base\n end\n\n countries.each { |key, flag| countries[key] = view_context.image_path(\"country-flags/#{flag.downcase}.png\") }\n\n render json: countries.to_json\n end",
"def populate(countries)\n countries.each { |country| upsert_on_code(*rc_extract_data(country)) }\n end",
"def get_region_data(countries, states)\n\n\tFileUtils.mkdir_p \"../weather_data/\"\n\n\tprocessed_data = {}\n\n\tcountries.each do |ea|\n\t\tprocessed_data.merge!(processed_data_for_country(ea))\n\tend\n\n\tstates.each do |ea|\n\t\tprocessed_data.merge!(processed_data_for_state(ea))\n\tend\n\n\twrite_to_json_file(processed_data.to_json)\n\nend",
"def load_countries\n puts 'load_countries'\n\n # iso3166.tab is ASCII encoded, but is planned to change to UTF-8 (a\n # superset of ASCII) in the future.\n open_file(File.join(@input_dir, 'iso3166.tab'), 'r', :external_encoding => 'UTF-8', :internal_encoding => 'UTF-8') do |file|\n file.each_line do |line|\n\n if line =~ /^([A-Z]{2})\\t(.*)$/\n code = $1\n name = $2\n @countries[code] = TZDataCountry.new(code, name)\n end\n end\n end\n\n primary_zones = {}\n secondary_zones = {}\n\n # zone1970.tab is UTF-8 encoded.\n open_file(File.join(@input_dir, 'zone1970.tab'), 'r', :external_encoding => 'UTF-8', :internal_encoding => 'UTF-8') do |file|\n file.each_line do |line|\n\n line.chomp!\n\n if line =~ /^([A-Z]{2}(?:,[A-Z]{2})*)\\t([^\\t]+)\\t([^\\t]+)(\\t(.*))?$/\n codes = $1\n location_str = $2\n zone_name = $3\n description = $5\n\n location = TZDataLocation.new(location_str)\n\n zone = @zones[zone_name]\n raise \"Zone not found: #{zone_name}\" if zone.nil?\n\n description = nil if description == ''\n\n country_timezone = TZDataCountryTimezone.new(zone, description, location)\n\n codes = codes.split(',')\n\n (primary_zones[codes.first] ||= []) << country_timezone\n\n codes[1..-1].each do |code|\n (secondary_zones[code] ||= []) << country_timezone\n end\n end\n end\n end\n\n [primary_zones, secondary_zones].each do |zones|\n zones.each_pair do |code, country_timezones|\n country = @countries[code]\n raise \"Country not found: #{code}\" if country.nil?\n\n country_timezones.each do |country_timezone|\n country.add_zone(country_timezone)\n end\n end\n end\n end",
"def country_list_by_region(region)\n # select list of countries based on the region\n @countries = Countries::Country.find_by_region(region)\n \n # print the list of countries as table format\n Table.display_as_table(@countries)\n end",
"def location\n # Retrieve info for dropdown\n @nationwide = Location.get_nationwide\n #@provinces = Location.provinces.where('id != ?', @nationwide.id).order('denorm_sort').collect {|p| [p.name.capitalize, p.id]}.insert(0, [@nationwide.name.capitalize, @nationwide.id])\n @provinces = Location.provinces.where('id != ?', @nationwide.id).order('denorm_sort')\n\n # Retrieve previously selected locations\n @curr_locations = current_user.present? ? current_user.locations.pluck(:id) : []\n\n # Get all regions for the map display \n @regions = Region.order('region_iso').all\n end",
"def identify_countries\n names = YAML.load_file( File.dirname(File.expand_path(__FILE__)) + '/lang/' + @lang + '/countries.yml' )\n names.each do |code,name|\n @svg.gsub!(\"class=\\\"land #{code}\\\"\", \"class=\\\"land #{code}\\\" country-name=\\\"#{name}\\\" country-value=\\\"#{@data[code]}\\\" onmouseover=\\\"worldMapOver(this)\\\" onmouseout=\\\"worldMapOut(this)\\\" onclick=\\\"worldMapClick(this)\\\" ondblclick=\\\"worldMapDblClick(this)\\\"\")\n end\n end",
"def retrieve_countries\n countries = []\n countries_request.css('.country-list li').each do |node|\n country = {}\n country[:url] = node.css('a').map{|link| link['href']}.first\n country[:total] = node.css('a strong').text\n node.css('a span').remove\n country[:name] = node.css('a').text\n\n puts \"Saving country: #{country[:name]}\"\n save_country(country)\n countries << country\n end\n\n countries\n end",
"def countries_and_regions\n return @countries_and_regions\n end",
"def list_regions_by_country(country, options={}) path = \"/api/v2/definitions/countries/#{country}/regions\"\n get(path, options, AvaTax::VERSION) end",
"def load_countries_and_zones\n \n IO.foreach(@input_dir + File::SEPARATOR + 'iso3166.tab') {|line| \n if line =~ /^([A-Z]{2})\\t(.*)$/\n code = $1\n name = $2\n @countries[code] = TZDataCountry.new(code, name)\n end\n }\n\n\n IO.foreach(@input_dir + File::SEPARATOR + 'zone.tab') {|line| \n line.chomp! \n\n if line =~ /^([A-Z]{2})\\t([^\\t]+)\\t([^\\t]+)(\\t(.*))?$/\n code = $1\n location_str = $2\n zone_name = $3\n description = $5\n\n country = @countries[code]\n raise \"Country not found: #{code}\" if country.nil?\n \n location = TZDataLocation.new(location_str)\n \n zone = @zones[zone_name] \n raise \"Zone not found: #{zone_name}\" if zone.nil? \n\n description = nil if description == ''\n \n country.add_zone(TZDataCountryTimezone.new(zone, description, location))\n\n lo_n = location.longitude.to_s.gsub(/\\/[0-9]*/, '')\n lo_d = location.longitude.to_s.gsub(/[0-9]*\\//, '')\n la_n = location.latitude.to_s.gsub(/\\/[0-9]*/, '')\n la_d = location.latitude.to_s.gsub(/[0-9]*\\//, '')\n\n @timezones << [code, zone_name, lo_n, lo_d, la_n, la_d, description]\n end\n }\n\n # Creates CountryInfo for each country with all the associated timezones\n @countries.each do |code,country|\n # Creates CountryInfo for each country\n info = CountryInfo.new(code, country.name)\n\n # Adds timezones to CountryInfo for each country\n @timezones.each do |t|\n if code == t[0]\n info.timezone t[1], t[2], t[3], t[4], t[5], t[6]\n end\n end\n\n Country.add(code,Country.new(info))\n end\n\n end",
"def create_countries(country_table)\n country_table.each do |country|\n abbreviation = country[0]\n name = country[1]\n info_link = country[2]\n name = Country.new(name, abbreviation, info_link)\n end\nend",
"def registered_country; end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
get the country list of given region
|
def country_list_by_region(region)
# select list of countries based on the region
@countries = Countries::Country.find_by_region(region)
# print the list of countries as table format
Table.display_as_table(@countries)
end
|
[
"def country_list\n return [] if type == \"state\"\n return countries if type == \"country\"\n members.collect { |zone| zone.country_list }.flatten\n end",
"def regions\n\t\tignore_nil { country.regions }\n\tend",
"def country_list\n return [] if kind == \"state\"\n return members.collect { |zone_member| zone_member.zoneable } if kind == \"country\"\n members.collect { |zone_member| zone_member.zoneable.country_list }.flatten\n end",
"def country_list\n price_list('countries')\n end",
"def country_list\n @countries ||= case kind\n when 'country' then\n zoneables\n when 'state' then\n zoneables.collect(&:country)\n when 'county'\n zone_member.zoneable.country_list\n else\n []\n end.flatten.compact.uniq\n end",
"def countries_and_regions\n return @countries_and_regions\n end",
"def list_regions_by_country(country, options={}) path = \"/api/v2/definitions/countries/#{country}/regions\"\n get(path, options, AvaTax::VERSION) end",
"def region_by_country(country)\n found = nil\n regions_list.each do |region|\n if region[:countries].include? country[:slug]\n found = region\n break\n end\n end\n found\n end",
"def countries_or_regions_of_origin\n return @countries_or_regions_of_origin\n end",
"def countries()\n sql = \"SELECT * FROM countries WHERE continent_id = $1\"\n values = [@id]\n countries = SqlRunner.run(sql, values)\n return countries.map {|country|Country.new(country)}\n end",
"def country_list\n @countries ||=\n case kind\n when 'country'\n zoneables\n when 'state'\n zoneables.collect(&:country)\n else\n nil\n end.flatten.compact.uniq\n end",
"def countries\n [ 'au', 'br', 'de', 'es', 'fr', 'in', 'it', 'mx', 'uk' ]\n end",
"def filter_regions\n regions = if @country_list.present?\n filtered_region_list\n else\n regions_list\n end\n {\n 'name': 'regions[]',\n 'options': regions,\n 'selected': @filter.regions,\n }\n end",
"def regions_and_countries_from(countries = [])\n country_items = []\n region_items = []\n potential_regions = {}\n\n # First try to sort countries into potential regions.\n countries.each do |country|\n region = region_by_country(country)\n if region.present?\n region_key = region[:slug]\n unless potential_regions.key? region_key\n potential_regions[region_key] = []\n end\n potential_regions[region_key].push(country)\n else\n country_items.push(country)\n end\n end\n\n # Next find out how many potential region entries are complete.\n potential_regions.each_value do |country_list|\n region = region_by_countries(country_list)\n if region.present?\n region_items.push(region)\n else\n country_items.concat(country_list)\n end\n end\n\n # Return the (hopefully) sorted countries and regions\n { regions: region_items, countries: country_items }\n end",
"def country_list\n members.map {|zone_member|\n case zone_member.zoneable_type\n when \"Zone\"\n zone_member.zoneable.country_list\n when \"Country\"\n zone_member.zoneable\n when \"State\"\n zone_member.zoneable.country\n else\n nil\n end\n }.flatten.compact.uniq\n end",
"def geographic_regions\n self.dig_for_array(\"geographicRegions\")\n end",
"def countries_with_data\n all_countries.map(&:epcountry).compact\n end",
"def all\n countries\n end",
"def listRegions\n\t\t\treturn MU::Config.listRegions\n\t\tend"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
country details based on region and country
|
def country_details(region, input)
country = @countries[input - 1]
Table.display_as_summary(country)
browse_online(country)
end
|
[
"def get_country\n @single_city_data[\"sys\"][\"country\"]\n end",
"def represented_country; end",
"def registered_country; end",
"def region_of_country(country_code = 'JP')\n result = @regions['asia'].to_s\n @regions.each do |region, countries|\n countries.each do |country|\n return result = region.to_s unless country[country_code].nil?\n end\n end\n rescue NoMethodError\n return 'asia'\n end",
"def to_country(region)\n code = region.to_s.upcase\n high, low = code.bytes.take(2)\n (high << 8) | low\n end",
"def country_or_region\n return @country_or_region\n end",
"def region_by_country(country)\n found = nil\n regions_list.each do |region|\n if region[:countries].include? country[:slug]\n found = region\n break\n end\n end\n found\n end",
"def country\n :england\n end",
"def countries_and_regions\n return @countries_and_regions\n end",
"def country_code\n raw_profile['loccountrycode']\n end",
"def country_info\n begin\n config['ip_country'].info(remote_ip)\n rescue\n nil\n end\n end",
"def country\n 'Australia'\n end",
"def country\n fetch('fma_brotherhood.countries')\n end",
"def country(code, name); end",
"def country_or_region=(value)\n @country_or_region = value\n end",
"def country_name\n country = ISO3166::Country[country_code].name unless country_code.blank?\n end",
"def r_country\n i_country_def, i_country_win_ini = @bytes.read(4).unpack('vv')\n\n {\n iCountryDef: i_country_def, # iCountryDef (2 bytes): An unsigned integer that specifies the country/region code determined by the locale in effect when the workbook was saved.\n iCountryDef_d: Unxls::Biff8::Constants::COUNTRIES[i_country_def],\n iCountryWinIni: i_country_win_ini, # iCountryWinIni (2 bytes): An unsigned integer that specifies the system regional settings country/region code in effect when the workbook was saved.\n iCountryWinIni_d: Unxls::Biff8::Constants::COUNTRIES[i_country_win_ini]\n }\n end",
"def country\n @country || @default_country || 'GB'\n end",
"def contact_country\n details? ? details[\"Contact\"][\"country\"] : ''\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Convert a cart into an order go through and check each cart entry, if in stock and valid then convert to an order entry. If the order is valid after the creation of the entry then ammend stock levels. Once all valid entries are generated save the whole thing and clear the shopping cart
|
def create
candidateOrder = Order.new(email: params[:order][:Email],
totalCost: cart_total,
user: curr_user)
cart.each do |pId, info|
if (prod = Product.find_by(id: pId))
if prod.stockCount > info["Num"].to_i
candidateOrder.order_entries.new(
product: prod,
quantity: info["Num"].to_i,
unitprice: prod.price,
totalprice: prod.price * info["Num"].to_i,
order_id: candidateOrder.id
)
candidateOrder.order_entries.last.validate!
if candidateOrder.valid?
prod.stockCount -= info["Num"].to_i
Product.update(prod.id, stockCount: prod.stockCount)
end
end
end
end
if candidateOrder.save!
clear_cart
redirect_to order_path(candidateOrder), notice: t(:order_placed)
else
redirect_to carts_path, error: t(:order_failed)
end
end
|
[
"def transfer cart\n \t\tself.order_items.destroy_all\n \t\tcart.cart_items.each do |item|\n \t\t\t@order_item = order_items.build(price: item.price, quantity: item.quantity, sku_id: item.sku_id, weight: item.weight, order_id: id)\n \t\t\t@order_item.build_order_item_accessory(accessory_id: item.cart_item_accessory.accessory_id, price: item.cart_item_accessory.price, quantity: item.cart_item_accessory.quantity) unless item.cart_item_accessory.nil?\n \t\t\t@order_item.save!\n \t\tend\n \tend",
"def check_cart!\n ActiveRecord::Base.transaction do\n # for each item in the cart\n cart_items.includes_default.find_each do |item|\n case item.item_type\n when 'group'\n group = item.group\n # remove groups that is not grouping\n if group.blank? || group.state != 'grouping'\n item.destroy\n next\n end\n # remove groups that is not in the user's organization\n if group.organization_code != self.organization_code\n item.destroy\n next\n end\n # updates the item's name and price\n item.item_price = group.book.price\n item.item_name = \"#{group.book.name} (#{group.book.isbn}) - #{group.pickup_datetime.strftime('%-m/%-d')}\"\n item.save!\n when 'package'\n book = Book.for_org(self.organization_code).find_by(id: item.item_code)\n # remove items with non-existing book\n if book.blank?\n item.destroy\n next\n end\n # updates the item's name and price\n item.item_price = book.price\n item.item_name = \"#{book.name} (#{book.isbn}) - 包裹專送\"\n item.save!\n end\n end\n end\n reload\n cart_items\n end",
"def validate_product_quantity_in_stock\n init_order_and_order_item\n session[:cart].values.each do |item|\n product = Product.find_by id: item[\"product_id\"].to_i\n next if conditional_checking(product, item)\n @order.errors.add(:unit_in_stock, add_flash_danger(product))\n end\n return if @order.errors.blank?\n render :new\n end",
"def create\n\t\t@cart = Cart.find(params[:cart])\n\t\t@order = @cart.orders.create()\n\t\tif @order.save\n\t\t\t@cart.items.each do |item|\n\t\t\t\t# add items and respective shopkeepers to order\n\t\t\t\t# make a copy of the item so that item remains if order if deleted by shopkeeper\n\t\t\t\t@order.items << Item.create(:name => item.name, :description => item.description, :price => item.price)\n\t\t\t\tif !@order.shopkeepers.include?(item.shopkeeper)\n\t\t\t\t\t@order.shopkeepers << item.shopkeeper\n\t\t\t\tend\n\t\t\tend \n\n\t\t\t# empty the cart\n\t\t\t@cart.items = []\n\t\t\tredirect_to :back, :flash => { :alert => \"Checkout complete. Go to 'Orders' to view.\"}\n\t\telse\n\t\t\tredirect_to :back, :flash => { :alert => \"Checkout not completed: Cart cannot be empty\" }\n\t\tend\n\tend",
"def validate_stock_levels\n if in_stock?\n false\n else\n self.quantity = self.ordered_item.stock\n self.quantity == 0 ? self.destroy : self.save!\n self\n end\n end",
"def import_to_cart()\n\n cart = List.find(self.id).user.cart\n list_item=List.find(self.id).list_items.all\n\n #Importing the list will delete all the existing items in the cart\n cart.clear_cart\n\n list_item.each do |item|\n cart.cart_items.build(:item_id => item.item_id, :quantity => item.quantity)\n end\n cart.save\n end",
"def validate_stock!\n return {} if empty?\n stock_levels.each_with_object({}) do |stock_level, obj|\n line_items.detect { |li| li.item.sku == stock_level.id }.tap do |li|\n next if li.nil?\n if stock_level.stock_available <= 0\n obj[li.item.sku] = {\n stock_level: 0,\n line_item_quantity: li.unit_quantity,\n message: \"Out of stock\"\n }\n elsif stock_level.stock_available < li.unit_quantity\n obj[li.item.sku] = {\n stock_level: stock_level.stock_available,\n line_item_quantity: li.unit_quantity,\n message: \"Only #{stock_level.stock_available} in stock\"\n }\n end\n li.errors.add(:unit_quantity, obj.dig(li.item.sku, :message)) unless obj.dig(li.item.sku, :message).nil?\n end\n end\n end",
"def convert_to_global\n return false unless self.has_stocks\n\n\t\tActiveRecord::Base.transaction do\n\t\t\titemlog =\tcreate_log(\"convert_to_global\", 0)\n\t\t\tself.stocks.each do |f|\n\t\t\t\tsil = StockItemLog.new(:item_log_id => itemlog, :stock_id => f.id, :curr_serial_tag => f.serial_tag)\n\t\t\t\tsil.save!\n\t\t\tend\n\t\n\t Stock.destroy_all(item_id: self.id)\n \t self.has_stocks = false\n \tself.save!\n\t\tend\n\n end",
"def restore_products\n order_items.each do |item|\n item.product.in_stock += item.quantity\n item.product.save\n end\n end",
"def make_cart_compatible\n return if session[:cart].items.is_a? Hash\n session[:cart] = Cart.new\n end",
"def confirm\n elements=CartItem.where(:cart_id=>current_user.cart.id)\n\n # if there are no items in the cart, the order will not be placed\n if elements.length==0\n redirect_to carts_path, :notice => \"EMPTY CART!!!\"\n end\n\n # Checks to see if any item in the cart is low in stock. If so, abort. If not, update the sales, and stock quantity of the items\n out_of_stock_items=Item.check_validity(elements)\n\n # This actually checks if any items are below stock\n if out_of_stock_items.length!=0\n redirect_to carts_path, :notice => Item.show_low_stock_message(out_of_stock_items)\n else\n # Save the changes in sales and stocks.\n Item.save_sales(elements)\n #after all the validations are processed, the pre-place order view will be rendered\n @item_list=CartItem.where(:cart_id => current_user.cart.id)\n end\n end",
"def update_quantities\n if params[:quantities]\n params[:quantities].each do |id, num|\n li = @cart.update_quantity(id, num)\n\n if !li\n p = @cart.line_items.find(id) rescue nil\n if p\n (flash[:notice] ||= '') << \"Unable to change quantity of \" +\n \"#{p.name} to #{num}, there are not \"+\n \"enough available at this time.\"\n end\n else #updated quantity\n # update any coupon generated lines for this line\n if cl = li.coupon_line\n cl.coupon.update_quantity_of_coupon_line(cl)\n end \n end\n end\n\n # if any master lines for coupon lines were destroyed,\n # remove their coupon lines as well\n @cart.line_items.select{|x| x.custom_double_line_id}.each do |cl|\n unless @cart.line_items.find_by_id(cl.custom_double_line_id)\n cl.destroy\n end\n end\n\n # (and their coupons)\n @cart.coupons.each do |x|\n @cart.coupons.delete(x) unless x.applies_to?(@cart)\n end\n\n end\n\n # update comments as well\n if params[:cart] and params[:cart][:comments]\n @cart.comments = params[:cart][:comments]\n end\n\n # build the redirect Url Options based on submitted action and\n # what already exists in the session\n uo = {}\n if params[:commit] == 'Checkout'\n uo = build_url_options_for_checkout\n else # just update\n uo = {:controller => 'cart', :action => 'show'}\n end\n\n # save the cart, so we know when the last action was taken on it\n unless @cart.save\n flash[:warning] = \"Unable to save cart: <ul><li>\" +\n \"#{@cart.errors.full_messages.join('</li><li>')}\" + \n \"</li></ul>\"\n end\n\n redirect_to uo\n end",
"def reduction_product_stock\n if order_items.present?\n order_items.each do |item|\n product = item.product\n product.stock = product.stock - item.quantity\n product.save\n end\n end\n end",
"def checkInventory\n # Check if purchase order needed. Do not restock if there are\n # preexisting purchase orders for a product\n products = DataStore.instance.products\n products.each do |prod|\n if prod.quantityOnHand < prod.reorderThreshold\n # reorder\n DataStore.instance.createPurchaseOrder(prod.productId, prod.reorderAmount)\n end\n end\n end",
"def wholesale_order_form\r\n\t\tif (params[:order] && !params[:order].empty?)\r\n\t\t\t@cart = find_cart\r\n\t\t\t@cart.priced = 1\r\n\r\n\t\t\tparams[:qty].each_pair do |prod_ov_ids, cur_qty|\r\n\t\t\t\tif cur_qty && !cur_qty.empty? && cur_qty.to_i > 0\r\n\t\t\t\t\toption_values = []\r\n\r\n\t\t\t\t\tbits = prod_ov_ids.split(\"_\")\r\n\r\n\t\t\t\t\tproduct = Product.find(bits[0])\r\n\r\n\t\t\t\t\tif bits.length > 1\r\n\t\t\t\t\t\tbits.each_with_index do |cur_bit, i|\r\n\t\t\t\t\t\t\tif i > 0\r\n\t\t\t\t\t\t\t\toption_values << cur_bit.to_i\r\n\t\t\t\t\t\t\tend\r\n\t\t\t\t\t\tend\r\n\t\t\t\t\tend\r\n\r\n\t\t\t\t\t@cart.add_product(product, cur_qty, option_values, true)\r\n\t\t\t\tend\r\n\t\t\tend\r\n\r\n\t\t\tredirect_to :controller => :cart, :action => :checkout\r\n\t\telsif (params[:draft] && !params[:draft].empty?)\r\n\t\t\tdraft_order = Draft.new\r\n\t\t\tdraft_order.user = @current_user\r\n\r\n\t\t\tparams[:qty].each_pair do |prod_ov_ids, cur_qty|\r\n\t\t\t\tif cur_qty && !cur_qty.empty? && cur_qty.to_i > 0\r\n\t\t\t\t\tbits = prod_ov_ids.split(\"_\")\r\n\r\n\t\t\t\t\tcur_item = DraftItem.new\r\n\t\t\t\t\tcur_item[:product_id] = bits[0]\r\n\t\t\t\t\tcur_item[:option_value_id] = bits[1]\r\n\t\t\t\t\tcur_item[:quantity] = cur_qty\r\n\r\n\t\t\t\t\tdraft_order.items << cur_item\r\n\t\t\t\tend\r\n\t\t\tend\r\n\r\n\t\t\tdraft_order.save\r\n\r\n\t\t\tflash[:notice] = \"Order saved as draft ##{draft_order.id}\"\r\n\t\t\tredirect_to :action => :drafts\r\n\t\tend\r\n\r\n\t\t# so prices always appear in NZD\r\n\t\t@currency = Currency.find(:first)\r\n\r\n\t\t@products = Product.find(:all, :conditions => [ \"products.wholesale_only=true OR option_values.wholesale_only=true\" ], :include => [ :option_values ])\r\n\r\n\t\t# sorted by cat, product name\r\n\t\t@products.sort! do |a, b|\r\n\t\t\ta_cat = nil\r\n\t\t\tb_cat = nil\r\n\r\n\t\t\t# D'oh... if a or b don't belong to any categories (which is a feature of v1.4) then we get crashes.\r\n\t\t\tif a.categories.length == 0 || b.categories.length == 0\r\n\t\t\t\t(a.categories.length == 0) <=> (b.categories.length == 0)\r\n\t\t\tend\r\n\r\n\t\t\tif a.categories.first[:parent_id] == 1\r\n\t\t\t\ta_cat = a.categories.first\r\n\t\t\telsif a.categories.first.parent[:parent_id] == 1\r\n\t\t\t\ta_cat = a.categories.first.parent\r\n\t\t\telsif a.categories.first.parent.parent[:parent_id] == 1\r\n\t\t\t\ta_cat = a.categories.first.parent.parent\r\n\t\t\telsif a.categories.first.parent.parent.parent[:parent_id] == 1\r\n\t\t\t\ta_cat = a.categories.first.parent.parent.parent\r\n\t\t\tend\r\n\r\n\t\t\tif b.categories.first[:parent_id] == 1\r\n\t\t\t\tb_cat = b.categories.first\r\n\t\t\telsif b.categories.first.parent[:parent_id] == 1\r\n\t\t\t\tb_cat = b.categories.first.parent\r\n\t\t\telsif b.categories.first.parent.parent[:parent_id] == 1\r\n\t\t\t\tb_cat = b.categories.first.parent.parent\r\n\t\t\telsif b.categories.first.parent.parent.parent[:parent_id] == 1\r\n\t\t\t\tb_cat = b.categories.first.parent.parent.parent\r\n\t\t\tend\r\n\r\n\t\t\tif a_cat == b_cat\r\n\t\t\t\ta[:product_name] <=> b[:product_name]\r\n\t\t\telse\r\n\t\t\t\ta_cat[:sequence] <=> b_cat[:sequence]\r\n\t\t\tend\r\n\t\tend\r\n\r\n\t\t@products.each do |cur_product|\r\n\t\t\tcur_product.option_values.sort! do |a, b|\r\n\t\t\t\ta[:wholesale_extra_cost] <=> b[:wholesale_extra_cost]\r\n\t\t\tend\r\n\t\tend\r\n\tend",
"def merge_carts(from_cart, to_cart)\n cart_item_ids_to_move = []\n\n from_cart.items.each do |from_cart_item|\n cart_item = to_cart.items.where(ticket_id: from_cart_item.ticket_id).take\n if cart_item\n # when we have cart item with the same ticket just use the beggest quantity\n cart_item.quantity = [cart_item.quantity, from_cart_item.quantity].max\n cart_item.save\n else\n # when session cart has new for user's cart ticket, mark it to move in cart later\n cart_item_ids_to_move << from_cart_item.id\n end\n end\n\n CartItem.where(id: cart_item_ids_to_move).each do |cart_item|\n cart_item.cart = to_cart\n cart_item.save\n end if cart_item_ids_to_move.any?\n\n # if just from_cart.destroy all moved items will be destroyed too so\n Cart.where(id: from_cart.id).destroy_all\n end",
"def create\n @transaction = Transaction.new(params[:transaction])\n #@item = Item.find(@transaction.item_id)\n #@item.buyer_id = current_user.id\n @transaction.user_id = current_user.id\n @shopping_cart = ShoppingCart.find_by_user_id(current_user.id)\n error_flag = 0\n error_message = \"\"\n available_item = Array.new\n eval(@shopping_cart.item_list).each do |item_id, quantity|\n item = Item.find(Integer(item_id))\n if item.quantity < quantity\n error_message = \"Sorry! Only #{item.quantity} of #{item.title} is available at the moment\"\n error_flag = 1\n else\n available_item += [item]\n item.quantity -= quantity\n end\n end\n\n if error_flag == 1\n redirect_to @shopping_cart, notice: error_message\n else\n item_list = Hash.new\n eval(@shopping_cart.item_list).each do |item_id, item_quantity|\n index = Item.find(Integer(item_id)).attributes.except(\"created_at\", \"updated_at\", \"product_file_name\",\n \"product_content_type\", \"product_file_size\", \"product_updated_at\")\n item_list[index] = item_quantity\n end\n @transaction.item_list = item_list.to_s\n\n respond_to do |format|\n if @transaction.save\n available_item.each do |item|\n item.save\n end\n @shopping_cart.delete\n format.html { redirect_to @transaction, notice: 'Transaction successful.' }\n format.json { render json: @transaction, status: :created, location: @transaction }\n else\n format.html { render action: \"new\" }\n format.json { render json: @transaction.errors, status: :unprocessable_entity }\n end\n end\n end\n end",
"def validate_cart(cart)\n if @inventory_managed\n cart.cart_items.each do |cart_item|\n unless validate_cart_item(cart_item)\n cart.errors.clear\n if cart.product_total <= 0\n cart.errors.add_to_base(\"Our apologies, all items in your cart were no longer available.\")\n else\n cart.errors.add_to_base(\"The quantity of certain items in your cart exceeded availability\" +\n \" and were adjusted\")\n end\n end\n end\n end\n end",
"def save_order\n @order = Order.new(params[:order]) \n @order.line_items << @cart.items \n if @order.save \n @cart.empty!\n redirect_to_index('Thank you for your order.')\n else\n render(:action => 'checkout') \n end\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Empty the user's shopping cart
|
def clear_cart
update_cart({})
end
|
[
"def clear_carts\n current_user.carts.each_with_index do |cart, i|\n cart.delete if i != current_user.carts.length - 1\n end\n end",
"def empty_to_buy\n self.cart_items.delete(self.items_to_buy)\n end",
"def empty!\n self.cart_items.each { |ci| ci.destroy }\n end",
"def clear\n Cart.destroy_all(user_id: params[:user_id])\n\n return render json: {message: \"clear was successfull\"}, status: 200\n end",
"def empty_cart\n clear_cart_and_order\n redirect_to_index(\"All items have been removed from your order.\")\n end",
"def clear!\n cart_items.clear\n coupons.clear\n end",
"def remove_all_from_cart\n Cart.clear\nend",
"def clear_cart_after_checkout\n puts \" \"\n puts \"************Bye Bye************\"\n puts \" \"\n Cart.destroy_all\n end",
"def clear_cart\r\n session[:cart] = []\r\n flash[:info] = 'Cart has been emptied!'\r\n redirect_to root_url\r\n end",
"def clear_cart\n self.order_status_id = 4\n self[:subtotal] = 0\n self.order_items.destroy_all\n end",
"def empty_basket\n basket.basket_items.clear if basket\n end",
"def clear_cart\n this_cart = self.cart\n if this_cart.present?\n Rails.logger.info \" - session ID:#{self.id} destroyed with cart ID:#{this_cart.id}\"\n this_cart.empty_and_destroy\n end\n end",
"def clear_current_cart\n @person.cart.empty! if @person\n self.current_cart = @cart = nil\n true\n end",
"def destroy\n session[:user_id] = nil\n session[:shopping_cart_id] = nil\n redirect_to root_path\n end",
"def clear_cart(cart)\n cart(:CartClear, {:CartId => cart.cart_id, :HMAC => cart.hmac})\n end",
"def remove_items_from_cart\n line_items.each { |i| i.cart = nil }\n end",
"def complete\n @user = User.find(params[:user_id])\n @cart_items = @user.cart_items.where.not(inventory_count: 0)\n\n @cart_items.each do |item|\n Product.transaction do\n i = Product.lock.find(item.p_id)\n i.inventory_count = item.inventory_count - 1\n i.save!\n @user.purchased_items.create(title: i.title, price: i.price)\n item.destroy\n end\n end\n\n # To reset id from 1 if cart is empty\n if(CartItem.count == 0)\n CartItem.destroy_all\n ActiveRecord::Base.connection.execute(\"DELETE from sqlite_sequence where name = 'cart_items'\")\n end\n\n redirect_to user_purchased_items_path(@user)\n end",
"def delCart\n session.delete(:cart_id)\n end",
"def reset_current_cart\n current_cart.destroy\n @current_cart = create_cart\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
returns first of the given paths that exists, or the last one if none exists
|
def first_existing(*paths)
last_path = nil
paths.each do |path|
last_path = path
break if @io.exist?(path)
end
last_path
end
|
[
"def find_first(*paths)\n xpath(*paths).first\n end",
"def path_find_first(path)\n node = @root\n return node.value unless node.value.nil?\n path.each { |path_item|\n node = node.get_child(path_item)\n return nil unless node\n return node.value unless node.value.nil?\n }\n nil\n end",
"def first_path_from_loaded_features_set(paths)\n paths.detect { |path| @loaded_features_set.include?(path) }\n end",
"def find_first_atom_by_path(atoms, *atom_types)\n type_to_find = atom_types.shift\n requisite = atoms.find { |e| e.atom_type == type_to_find }\n\n # Return if we found our match\n return requisite if atom_types.empty?\n\n # Return nil if we didn't find the match at this nesting level\n return unless requisite\n\n # ...otherwise drill further down\n find_first_atom_by_path(requisite.children || [], *atom_types)\n end",
"def find_first_path(start, filename)\n Dir.foreach(start) do |x|\n path = File.join(start, x)\n if x == '.' or x == '..'\n next\n elsif File.directory?(path)\n found_path = find_first_path(path, filename)\n if found_path\n return found_path\n end\n else\n if x == filename && path.include?('drawable-')\n return File.join(start, x)\n end\n end\n end\n return nil\nend",
"def shortest_path(paths)\n l = paths[0].length\n shortest = paths[0]\n for i in 1...paths.length\n if l > paths[i].length\n l = paths[i].length\n shortest = paths[i]\n end\n end\n shortest\n end",
"def first_path(file)\n possible_paths = ENV['PATH'].split(File::PATH_SEPARATOR).\n collect { |x| File.join(x, file) }\n possible_paths.find { |f| File.file?(f) }\n end",
"def find_exist_first_file\n if !(local_webs = ENV[\"APP_LOCAL_WEBS\"].split.find_all { |dir| File.basename(dir) == params[:level1] }).empty?\n File.join(local_webs.first, \"index.html\")\n else\n params_path = params.map(&:first).grep(/level/).sort.map(¶ms.method(:fetch)).join(\"/\")\n ENV[\"APP_LOCAL_WEBS\"].split.concat([ENV[\"APP_ROOT_PATH\"]])\n .map { |dir| File.join(dir, params_path) }\n .find_all(&File.method(:file?)).first\n end\n end",
"def find_by_path(path,flags={})\n if parseit = path.match(/^.*?(([^\\/]+)\\/)?([^\\/]+?)(\\.git)?$/)\n if proj = Project.find_by_identifier(parseit[3]) || !GitHosting.multi_repos?\n # return default or first repo with blank identifier (or first Git repo--very rare?)\n proj && (proj.repository || proj.repo_blank_ident || proj.gl_repos.first)\n elsif repo_ident_unique? || flags[:loose] && parseit[2].nil?\n find_by_identifier(parseit[3])\n elsif parseit[2] && proj = Project.find_by_identifier(parseit[2])\n find_by_identifier_and_project_id(parseit[3],proj.id) ||\n flags[:loose] && find_by_identifier(parseit[3]) || nil\n else\n nil\n end\n else\n nil\n end\n end",
"def xpath_search_first(path)\n\t\tself.xs(path).first\n\tend",
"def find_existing_path(typed_name)\n is_global = global?\n smart_paths.effective_paths(typed_name.type).each do |sp|\n next unless sp.valid_name?(typed_name)\n origin = sp.effective_path(typed_name, is_global ? 0 : 1)\n unless origin.nil?\n if sp.fuzzy_matching?\n # If there are multiple *specific* paths for the file, find\n # whichever ones exist. Otherwise, find all paths that *might* be\n # related to origin\n if origin.is_a?(Array)\n origins = origin.map { |ori| existing_path(ori) }.compact\n return [origins, sp] unless origins.empty?\n else\n origins = candidate_paths(origin)\n return [origins, sp] unless origins.empty?\n end\n else\n existing = existing_path(origin)\n return [origin, sp] unless existing.nil?\n end\n end\n end\n nil\n end",
"def find_by_path(path, flags={})\n if parseit = path.match(/^.*?(([^\\/]+)\\/)?([^\\/]+?)(\\.git)?$/)\n if proj = Project.find_by_identifier(parseit[3]) || !GitHosting.multi_repos?\n # return default or first repo with blank identifier (or first Git repo--very rare?)\n proj && (proj.repository || proj.repo_blank_ident || proj.gitolite_repos.first)\n elsif repo_ident_unique? || flags[:loose] && parseit[2].nil?\n find_by_identifier(parseit[3])\n elsif parseit[2] && proj = Project.find_by_identifier(parseit[2])\n find_by_identifier_and_project_id(parseit[3],proj.id) ||\n flags[:loose] && find_by_identifier(parseit[3]) || nil\n else\n nil\n end\n else\n nil\n end\n end",
"def find_shortest_pathname_brute(path)\n path_split, path_index, stack = path.split(\"/\"), 0, []\n\n if path_split.first == \"\"\n is_absolute = true\n path_split.shift\n else\n is_absolute = false\n end\n\n path_split.each do |s|\n if s == \"..\" && stack.last != \"..\"\n stack.pop\n elsif s != \".\"\n stack.push s\n end\n\n end\n\n result = \"\"\n\n while !stack.empty?\n result.prepend \"#{stack.pop}/\"\n end\n\n #remove trailing slash\n if result[-1] == \"/\"\n result.slice!(-1,1)\n end\n\n #If absolute, lead with slash\n if is_absolute\n result.prepend \"/\"\n end\n\n result\nend",
"def longest_common_subpath(paths)\n return if paths.empty?\n\n lcsp = Pathname.new(paths[0])\n\n paths[1..-1].each do |path|\n until ascendant_of?(lcsp, path)\n if lcsp.root?\n # If we get here a root directory is not an ascendant of path.\n # This may happen if there are paths in different drives on\n # Windows.\n return\n else\n lcsp = lcsp.parent\n end\n end\n end\n\n lcsp\n end",
"def path_find_last(path)\n node = @root\n value = @root.value\n path.each { |path_item|\n node = node.get_child(path_item)\n return value unless node\n value = node.value unless node.value.nil?\n }\n value\n end",
"def next_path\n if @paths.nil?\n # Start the paths listing out from the targetted set of paths for this selector\n # In reverse order since using a LIFO structure\n @paths = target_paths.reverse\n end\n\n # No more paths to return\n return nil if @paths&.empty?\n\n # Get the most recently added path for depth first traversal of selected paths\n path = @paths.pop\n until path.nil? do\n @app_config.location_manager.verify_path_in_location(path)\n physical_path = @physical_provider.get_physical_path(path)\n separate_logical = physical_path != path\n if separate_logical\n @app_config.location_manager.verify_path_in_location(physical_path)\n end\n\n if File.exist?(physical_path)\n if File.directory?(physical_path)\n if separate_logical\n raise InvalidStoragePathError.new(\"Cannot specify physical path to a directory: #{physical_path}\")\n end\n logger.debug(\"Expanding directory #{path}\")\n # For a directory, add all children to file_paths\n Dir.entries(path).sort.reverse_each do |child|\n @paths << File.join(path, child) unless child == '.' or child == '..'\n end\n else\n logger.debug(\"Returning file #{path}\")\n return path\n end\n else\n raise InvalidStoragePathError.new(\"File #{physical_path} does not exist.\")\n end\n\n # Returned path was not a suitable file, try the next path\n path = @paths.pop\n end\n end",
"def common_dir(*paths)\n paths.map do |path|\n new(path).dirname.ascend\n end.inject(:&).first\n end",
"def last_for_path(repo, ref, path = nil)\n where(\n repo: repo,\n ref: ref,\n path: path,\n limit: 1\n ).first\n end",
"def compare_paths(path1, path2)\n enum1 = path1.descend\n enum2 = path2.descend\n out_path = \"/\"\n\n loop do\n begin\n val1 = enum1.next\n val2 = enum2.next\n return out_path unless val1 == val2\n out_path = val1\n rescue StopIteration\n return out_path\n end\n end\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
matt's sweet code def clamp_to_edgeeee(node, x, y base=BASE) originX = node % base originY = node / base if originX + x > base node = originX + x base end if originY + y > base node = base (originY + y base) end return node end
|
def clamp_to_edge(node, x, y, base=BASE)
while base - (node % base) < x
node -= 1
end
while (node + (base*(y-1))) >= (base*base)
node -= base
end
return node
end
|
[
"def fineTuneEdge(start_x, start_y, inc_x, inc_y, edge, inc_edge, min, max)\n x, y = self.send(start_x), self.send(start_y)\n while (x <= @right) and (y <= @bottom) and (self.send(edge) > min) and (self.send(edge) < max)\n top_x, top_y = (inc_x != 0) ? [x, y+inc_edge] : [x+inc_edge, y]\n idx_top = @image.index(top_x, top_y)\n if @image.data[idx_top] and (@image.data[idx_top] <= @image.attrib[:threshold])\n eval %~@#{edge} += inc_edge~\n x, y = [self.send(start_x), self.send(start_y)]\n end\n x += inc_x\n y += inc_y\n end\n self.send(edge)\n end",
"def clamp(x, low, hi)\n x = low if x < low\n x = hi if x > hi\n return x\n end",
"def clamp(vector, min, max)\n end",
"def update_vertex_extrema_of vertex\n @x_min = vertex.x if vertex.x <= @x_min\n @x_max = vertex.x if vertex.x >= @x_max\n\n @y_min = vertex.y if vertex.y <= @y_min\n @y_max = vertex.y if vertex.y >= @y_max\n\n @z_min = vertex.z if vertex.z <= @z_min\n @z_max = vertex.z if vertex.z >= @z_max\n end",
"def limit\n @nodes.each do |node|\n norm = normal(node.disposition.x, node.disposition.y)\n if 0 < norm\n node.position.x += (node.disposition.x / norm) * [norm, @temperature].min\n node.position.y += (node.disposition.y / norm) * [norm, @temperature].min\n end\n end\n end",
"def test_find_lonely_edge\n a = Node.create!\n b = Node.create!\n e = Default.create_edge(a,b)\n e = Default.find_edge(a,b)\n assert_equal e.ancestor, a\n assert_equal e.descendant, b\n end",
"def remove_edge(x, y)\n raise\n end",
"def lower_left(obj)\n check_pre(graphobj?(obj))\n if one_dimension?(obj)\n (-(bounds(obj)).first)\n else\n Point2d[-(bounds(obj).x_range.first), -(bounds(obj).y_range.first)]\n end\n\nend",
"def lower_left(obj)\n check_pre(graphobj?(obj))\n if one_dimension?(obj) then (-(bounds(obj)).first)\n else Point2d[-(bounds(obj).x_range.first), -(bounds(obj).y_range.first)]\n end\nend",
"def other_node(node)\n if node == start_node\n return end_node\n elsif node == end_node\n return start_node\n else\n raise \"Node #{node.inspect} is neither start nor end node\"\n end\n end",
"def clamp!(rect)\n nself = self.normalize\n rect = Rect.new_from_object(rect)\n #If self is inside given, there is no need to move self\n unless rect.contain?(nself)\n\n #If self is too wide:\n if nself[2] >= rect[2]\n self[0] = rect.centerx - nself[2].div(2)\n #Else self is not too wide\n else\n #If self is to the left of arg\n if nself[0] < rect[0]\n self[0] = rect[0]\n #If self is to the right of arg\n elsif nself.right > rect.right\n self[0] = rect.right - nself[2]\n #Otherwise, leave x alone\n end\n end\n\n #If self is too tall:\n if nself[3] >= rect[3]\n self[1] = rect.centery - nself[3].div(2)\n #Else self is not too tall\n else\n #If self is above arg\n if nself[1] < rect[1]\n self[1] = rect[1]\n #If self below arg\n elsif nself.bottom > rect.bottom\n self[1] = rect.bottom - nself[3]\n #Otherwise, leave y alone\n end\n end\n end\n return self\n end",
"def clamp_vector(min_vector, max_vector)\n self.class.new(Vector2.clamp(@x, min_vector.x, max_vector.x),\n Vector2.clamp(@y, min_vector.y, max_vector.y))\n end",
"def down_half_line\n Kernel.raise NotImplementedError\n end",
"def test_create_lonely_edge\n a = Node.create!\n b = Node.create!\n e = Default.create_edge(a,b)\n assert e\n end",
"def test_create_exla_lonely_edge\n a = Node.create!\n b = Node.create!\n e = Default.create_edge!(a,b)\n assert_equal e.ancestor, a\n assert_equal e.descendant, b\n end",
"def get_edge(x, y)\n return nil unless edge?(x, y)\n w = @g.get_edge(index(x), index(y))\n Edge.new(x, y, w) if w\n end",
"def clamp(val, min, max)\n\treturn min if val < min\n\treturn max if val > max\n\treturn val\nend",
"def get_edge_value(x, y)\n e = x.connection_to(y)\n e.nil? ? nil : e.value\n end",
"def between_inclusive(node, left, right)\n if left == right\n true\n else\n node_position = Integer(\"0x#{node}\")\n left_position = Integer(\"0x#{left}\")\n right_position = Integer(\"0x#{right}\")\n\n if left_position < right_position\n (left_position <= node_position && right_position >= node_position)\n else\n (left_position <= node_position || right_position >= node_position)\n end\n end\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Public: serves as the getter and setter for the Array of Symbol column names. Union join the existing column names with those passed Example: ``` header.columns :name, :age, :location ``` `args` Array of Symbol arguments passed Returns as Array of Symbols
|
def columns(*args)
@columns = @columns | args.map(&:to_sym)
end
|
[
"def named_columns( names )\n @columns.values_at( *names )\n end",
"def multiple_columns(*args)\n @records.inject([]){ |memo, record|\n memo << args.map{ |arg| record.send(arg) }\n memo\n }\n end",
"def column_names\n columns.map(&:name)\n end",
"def columns(names, options)\n names.flatten.each do |name|\n column(name, options)\n end\n end",
"def header_array\n @columns.collect {|c|\n if @table[c]\n @table[c][:name].to_s\n else\n \"\"\n end\n }.compact\n end",
"def column_list(columns)\n if columns.empty?\n WILDCARD\n else\n m = columns.map do |i|\n i.is_a?(Hash) ? i.map{|kv| \"#{literal(kv[0])} AS #{quote_identifier(kv[1])}\"} : literal(i)\n end\n m.join(COMMA_SEPARATOR)\n end\n end",
"def column_list(columns)\n if columns.empty?\n WILDCARD\n else\n m = columns.map do |i|\n i.is_a?(Hash) ? i.map {|kv| \"#{literal(kv[0])} AS #{kv[1]}\"} : literal(i)\n end\n m.join(COMMA_SEPARATOR)\n end\n end",
"def implicit_columns\n sql = [STAR, column_list_for(@extensions)]\n sql.reject! { |fragment| fragment.empty? }\n sql.join(SEPARATOR)\n end",
"def column_names\n columns.map { |c| c.name }\n end",
"def columns(cols, options = {})\n if cols.is_a? Array\n cols.each.map{|c| columns(c.first, c.count >= 2 ? c.second : {}) if c.is_a? Array }\n return\n end\n cols.split(/,\\s/).each do |col|\n n = col.split(':')\n id = n.first\n name = n.count > 1 ? n.second : nil\n search = col_by_id id\n tmp = search.nil? ? Flexigrid::Column.new(self, id, name) : search\n options.map{|key,value| tmp.send(key.to_s + \"=\",value)}\n tmp.update!\n @columns << tmp\n @columns_hash[tmp.id] = tmp\n end\n end",
"def columns(*array)\n unless array.empty?\n if (array.class == Array)\n options[:columns] = array\n else\n raise \"Report columns must be specified.\"\n end\n else\n options[:columns]\n end\n end",
"def list_columns\n result = []\n result << 'list of columns to update:'\n result.push *COLUMNS.map { |k, v| \" #{k} #{v}\" }\n result << ' other can accept variables and concatenated by space'\n result\n end",
"def user_columns(*args)\n if args.size > 0\n convert_args_to_columns(:@user_columns, *args)\n else\n @user_columns ||= all_columns.reject do |v|\n v.name.to_s.match /(_at|_on|position|lock_version|_id|password_hash|id)$/\n end\n end\n end",
"def column_names\n @columns.keys\n end",
"def column_full_names\n attributes.keys.collect{ |key| \"#{@column_family_name}:#{key}\"}\n end",
"def datatables_columns\n columns = self.param_index_array(:columns)\n columns = columns.select { |col| col[:data] }\n columns.map do |col|\n { :name => (col[:name] || '-').to_s,\n :field => col[:data].to_s\n }\n end\n end",
"def column_names\n columns_in_order.map { |c| c.name }\n end",
"def columns_param(column_names)\n column_names.map! { |name| escape(name) }\n \"columns:!(#{column_names.join(',')})\"\n end",
"def columns\n @columns ||= []\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Public: converts columns and mappings into mapped columns ready for encoding. If a mapped value is found that is used, else the Symbol column name is humanized by default or can be specified with header_inflector option Returns an Array of Strings
|
def mapped_columns
@columns.map do |column|
@mappings[column] || column.to_s.send(@inflector)
end
end
|
[
"def mapped_columns\n @columns.map do |column|\n @mappings[column] || column.to_s.humanize\n end\n end",
"def symbol cols\n decode_values :symbol, cols\n end",
"def header_array\n @columns.collect {|c|\n if @table[c]\n @table[c][:name].to_s\n else\n \"\"\n end\n }.compact\n end",
"def column_names\n columns.map { |c| c.name }\n end",
"def column_full_names\n attributes.keys.collect{ |key| \"#{@column_family_name}:#{key}\"}\n end",
"def column_names\n columns.map(&:name)\n end",
"def translate_column(col, mapping)\n if mapping[col][:name]\n mapping[col][:name]\n else\n if col[-3,3] == \"_id\"\n col = col[0, col.length - 3]\n end\n col.humanize\n end\n end",
"def options_to_columns(options)\n columns = []\n options[:columns].each do |column|\n if column.kind_of? Symbol # a column from the database, we don't need to do anything\n columns << {:name => column, :attribute => column}\n elsif column.kind_of? Hash\n columns << {:name => column[:name], :special => column}\n end\n end\n columns\n end",
"def to_headers\n ActsAsTable::Headers::Array.new(self.column_models)\n end",
"def _all_flex_column_names\n _flex_column_classes.map(&:column_name)\n end",
"def column_mappings\n @column_mappings ||= task_config[\"column_mappings\"]\n end",
"def shipments_columns\n column_names.map do |column|\n case column\n when 'taxon_name'\n 'taxon_concept_id'\n when 'appendix'\n column\n when 'year'\n column\n when /(.+)_code$/\n $1 + '_id'\n when /(.+)_id$/\n column\n else\n column + '_id'\n end\n end\n end",
"def association_columns(*by_associations) #:nodoc:\n if @object.present?\n @object.class.reflections.collect do |name, _|\n if by_associations.present?\n name if by_associations.include?(_.macro)\n else\n name\n end\n end.compact\n else\n []\n end\n end",
"def string cols\n decode_values :string, cols\n end",
"def options_to_columns(options)\n columns = []\n options[:columns].each do |column|\n if column.kind_of? Symbol # a column from the database, we don't need to do anything\n columns << {:name => column, :attribute => column}\n elsif column.kind_of? Hash\n col_hash = { :name => column[:name], :special => column }\n col_hash[:attribute] = column[:attribute] if column[:attribute]\n columns << col_hash\n end\n end\n columns\n end",
"def map_columns\n @map_columns ||= attribute_definitions.values.select { |c| c.type == :map }\n end",
"def association_columns(*by_associations) #:nodoc:\n if @object.present? && @object.class.respond_to?(:reflections)\n @object.class.reflections.collect do |name, association_reflection|\n if by_associations.present?\n name if by_associations.include?(association_reflection.macro)\n else\n name\n end\n end.compact\n else\n []\n end\n end",
"def options_to_columns(options)\n columns = []\n options[:columns].each do |column|\n if column.kind_of? Symbol # a column from the database, we don't need to do anything\n columns << {:name => column, :attribute => column}\n elsif column.kind_of? Hash\n col_hash = { :name => column[:name], :special => column }\n col_hash[:attribute] = column[:attribute] if column[:attribute]\n columns << col_hash\n end\n end\n columns\n end",
"def column_names\n columns_in_order.map { |c| c.name }\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
GET /tipo_convenios/1 GET /tipo_convenios/1.json
|
def show
@tipo_convenio = TipoConvenio.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @tipo_convenio }
end
end
|
[
"def show\n @tipo_contrato = TipoContrato.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_contrato }\n end\n end",
"def show\n @conversazione = Conversazione.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @conversazione }\n end\n end",
"def show\n @tipo_seguro = TipoSeguro.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_seguro }\n end\n end",
"def index\n @convos = Convo.all\n render json: @convos\n end",
"def index\n @cooperativas = Cooperativa.where(:status_id => Status.find_by_descricao('Ativo'))\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render :json => @cooperativas }\n end\n end",
"def show\n @consumo = Consumo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @consumo }\n end\n end",
"def show\n @concurso = Concurso.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @concurso }\n end\n end",
"def show\n @tipo_vehiculo = TipoVehiculo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_vehiculo }\n end\n end",
"def show\n @tipo_negocio = TipoNegocio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_negocio }\n end\n end",
"def show\n @clientetipo = Clientetipo.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @clientetipo }\n end\n end",
"def show\n @tipo_organo_de_gobierno = TipoOrganoDeGobierno.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_organo_de_gobierno }\n end\n end",
"def show\n @consignado = Consignado.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @consignado }\n end\n end",
"def show\n @tipo_imovel = TipoImovel.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_imovel }\n end\n end",
"def index\n @tipo_concursos = TipoConcurso.all\n end",
"def show\n @punto_servicio = PuntoServicio.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @punto_servicio }\n end\n end",
"def show\n @tipo_pensum = TipoPensum.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_pensum }\n end\n end",
"def index\n @concursos = Concurso.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @concursos }\n end\n end",
"def show\n @congregacion = Congregacion.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @congregacion }\n end\n end",
"def show\n @tipo_webnota = TipoWebnota.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @tipo_webnota }\n end\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
GET /tipo_convenios/new GET /tipo_convenios/new.json
|
def new
@tipo_convenio = TipoConvenio.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @tipo_convenio }
end
end
|
[
"def new\n @tipo_seguro = TipoSeguro.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_seguro }\n end\n end",
"def new\n @tipo_negocio = TipoNegocio.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_negocio }\n end\n end",
"def new\n @tipo_cargo = TipoCargo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_cargo }\n end\n end",
"def new\n @tipo_nota = TipoNota.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_nota }\n end\n end",
"def new\n @contrato = Contrato.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @contrato }\n end\n end",
"def new\n @conversazione = Conversazione.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @conversazione }\n end\n end",
"def new\n @tipo_pensum = TipoPensum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_pensum }\n end\n end",
"def new\n @tipo_vehiculo = TipoVehiculo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_vehiculo }\n end\n end",
"def new\n @tipo_imovel = TipoImovel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_imovel }\n end\n end",
"def new\n @tipo_actividad = TipoActividad.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_actividad }\n end\n end",
"def new\n @tipo_entidad = TipoEntidad.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_entidad }\n end\n end",
"def new\n @tipo_personaje = TipoPersonaje.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_personaje }\n end\n end",
"def new\n @categorias_tipo = CatTipo.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @categorias_tipo }\n end\n end",
"def create\n @tipo_concurso = TipoConcurso.new(tipo_de_concurso_params)\n\n respond_to do |format|\n if @tipo_concurso.save\n format.html { redirect_to @tipo_concurso, notice: 'Tipo de concurso was successfully created.' }\n format.json { render action: 'show', status: :created, location: @tipo_concurso }\n else\n format.html { render action: 'new' }\n format.json { render json: @tipo_concurso.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @tipo_usuario = TipoUsuario.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_usuario }\n end\n end",
"def new\n @recurso = Recurso.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @recurso }\n end\n end",
"def new\n @tipo_apuestum = TipoApuestum.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_apuestum }\n end\n end",
"def new\n @tipo_producto = TipoProducto.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipo_producto }\n end\n end",
"def new\n @tipolog = Tipolog.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @tipolog }\n end\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
DELETE /tipo_convenios/1 DELETE /tipo_convenios/1.json
|
def destroy
@tipo_convenio = TipoConvenio.find(params[:id])
@tipo_convenio.destroy
respond_to do |format|
format.html { redirect_to tipo_convenios_url }
format.json { head :no_content }
end
end
|
[
"def destroy\n @tipo_concurso.destroy\n respond_to do |format|\n format.html { redirect_to tipo_de_concursos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipo_contrato = TipoContrato.find(params[:id])\n @tipo_contrato.destroy\n\n respond_to do |format|\n format.html { redirect_to tipo_contratos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @conversazione = Conversazione.find(params[:id])\n @conversazione.destroy\n\n respond_to do |format|\n format.html { redirect_to conversazioni_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipo_seguro = TipoSeguro.find(params[:id])\n @tipo_seguro.destroy\n\n respond_to do |format|\n format.html { redirect_to tipo_seguros_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @condominios = Condominio.find(params[:id])\n @condominios.destroy\n\n respond_to do |format|\n format.html { redirect_to condominia_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @consumo = Consumo.find(params[:id])\n @consumo.destroy\n\n respond_to do |format|\n format.html { redirect_to consumos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @convenente.destroy\n respond_to do |format|\n format.html { redirect_to convenentes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipo_servico.destroy\n respond_to do |format|\n format.html { redirect_to tipo_servicos_url, notice: 'Tipo servico apagado com sucesso!.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipo_negocio = TipoNegocio.find(params[:id])\n @tipo_negocio.destroy\n\n respond_to do |format|\n format.html { redirect_to tipo_negocios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipo_apuestum = TipoApuestum.find(params[:id])\n @tipo_apuestum.destroy\n\n respond_to do |format|\n format.html { redirect_to tipo_apuesta_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipo_analise.destroy\n respond_to do |format|\n format.html { redirect_to tipo_analises_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @core_tipo_detalhe = Core::TipoDetalhe.find(params[:id])\n @core_tipo_detalhe.destroy\n\n respond_to do |format|\n format.html { redirect_to core_tipo_detalhes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipo_vehiculo = TipoVehiculo.find(params[:id])\n @tipo_vehiculo.destroy\n\n respond_to do |format|\n format.html { redirect_to tipo_vehiculos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @condo = Condo.find(params[:id])\n @condo.destroy\n\n respond_to do |format|\n format.html { redirect_to condos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @concedente.destroy\n respond_to do |format|\n format.html { redirect_to concedentes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipo_estado.destroy\n respond_to do |format|\n format.html { redirect_to tipo_estados_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @tipo_acidente.destroy\n respond_to do |format|\n format.html { redirect_to tipo_acidentes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @concedente = Concedente.find(params[:id])\n @concedente.destroy\n\n respond_to do |format|\n format.html { redirect_to concedentes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @datos_insumos_reactivo.destroy\n respond_to do |format|\n format.html { redirect_to datos_insumos_reactivos_url }\n format.json { head :no_content }\n end\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
PATCH/PUT /faxes/1 PATCH/PUT /faxes/1.json
|
def update
respond_to do |format|
if @fax.update(fax_params)
format.html { redirect_to @fax, notice: 'Fax was successfully updated.' }
format.json { render :show, status: :ok, location: @fax }
else
format.html { render :edit }
format.json { render json: @fax.errors, status: :unprocessable_entity }
end
end
end
|
[
"def update\n @faxis = Fax.find(params[:id])\n\n respond_to do |format|\n if @faxis.update_attributes(params[:faxis])\n format.html { redirect_to @faxis, notice: 'Fax was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @faxis.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n\n format.json { render json: Axis.find(params[:id]).update( name: params[:name]) }\n end\n\n # end\n end",
"def update\n json_update(factType,factType_params, FactType)\n end",
"def update\n @fax_typ = FaxTyp.find(params[:id])\n\n respond_to do |format|\n if @fax_typ.update_attributes(params[:fax_typ])\n format.html { redirect_to @fax_typ, notice: 'Fax typ was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @fax_typ.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @f1.update(f1_params)\n format.html { redirect_to @f1, notice: \"F1 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @f1 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @f1.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @axis.update(axis_params)\n format.html { redirect_to @axis, notice: 'Axis was successfully updated.' }\n format.json { render :show, status: :ok, location: @axis }\n else\n format.html { render :edit }\n format.json { render json: @axis.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @spoofer = Spoofer.find(params[:id])\n\n respond_to do |format|\n if @spoofer.update_attributes(params[:spoofer])\n format.html { redirect_to @spoofer, notice: 'Spoofer was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @spoofer.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @fotky = Fotky.find(params[:id])\n\n respond_to do |format|\n if @fotky.update_attributes(params[:fotky])\n format.html { redirect_to @fotky, notice: 'Fotky was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @fotky.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @fabricsofaset.update(fabricsofaset_params)\n format.html { redirect_to @fabricsofaset, notice: 'Fabricsofaset was successfully updated.' }\n format.json { render :show, status: :ok, location: @fabricsofaset }\n else\n format.html { render :edit }\n format.json { render json: @fabricsofaset.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @fiber = Fiber.find(params[:id])\n respond_to do |format|\n if @fiber.update_attributes(params[:fiber])\n format.html { render(:json => {:success => true}) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @fiber.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @foo25.update(foo25_params)\n format.html { redirect_to @foo25, notice: \"Foo25 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo25 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo25.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @foo75.update(foo75_params)\n format.html { redirect_to @foo75, notice: \"Foo75 was successfully updated.\" }\n format.json { render :show, status: :ok, location: @foo75 }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @foo75.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @fokey.update(fokey_params)\n format.html { redirect_to @fokey, notice: 'Fokey was successfully updated.' }\n format.json { render :show, status: :ok, location: @fokey }\n else\n format.html { render :edit }\n format.json { render json: @fokey.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @farmako.update(farmako_params)\n format.html { redirect_to @farmako, notice: 'Farmako was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @farmako.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @firefly.update(firefly_params)\n format.html { redirect_to @firefly, notice: 'Firefly was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @firefly.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @fab_quarterly_status = FabQuarterlyStatus.find(params[:id])\n\n respond_to do |format|\n if @fab_quarterly_status.update_attributes(params[:fab_quarterly_status])\n format.html { redirect_to fab_quarterly_statuses_url, notice: 'Fab quarterly status was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @fab_quarterly_status.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @rfx.update(rfx_params)\n format.html { redirect_to rfxes_url, notice: 'Rfx was successfully updated.' }\n format.json { render :show, status: :ok, location: @rfx }\n else\n format.html { render :edit }\n format.json { render json: @rfx.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @fes.update(fes_params)\n format.html { redirect_to @fes, notice: 'Fes was successfully updated.' }\n format.json { render :show, status: :ok, location: @fes }\n else\n format.html { render :edit }\n format.json { render json: @fes.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @fleemarket.update(fleemarket_params)\n format.html { redirect_to @fleemarket, notice: 'Fleemarket was successfully updated.' }\n format.json { render :show, status: :ok, location: @fleemarket }\n else\n format.html { render :edit }\n format.json { render json: @fleemarket.errors, status: :unprocessable_entity }\n end\n end\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
DELETE /faxes/1 DELETE /faxes/1.json
|
def destroy
@fax.destroy
respond_to do |format|
format.html { redirect_to faxes_url, notice: 'Fax was successfully destroyed.' }
format.json { head :no_content }
end
end
|
[
"def destroy\n @faxis = Fax.find(params[:id])\n @faxis.destroy\n\n respond_to do |format|\n format.html { redirect_to faxes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @axis.destroy\n respond_to do |format|\n format.html { redirect_to axes_url, notice: 'Axis was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @fax_typ = FaxTyp.find(params[:id])\n @fax_typ.destroy\n\n respond_to do |format|\n format.html { redirect_to fax_typs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @flowchart = Flowchart.find(params[:id])\n @flowchart.destroy\n\n respond_to do |format|\n format.html { redirect_to flowcharts_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @customf.destroy\n respond_to do |format|\n format.html { redirect_to customfs_url }\n format.json { head :no_content }\n end\n end",
"def delete_floor_plan(args = {}) \n delete(\"/files.json/floorplan/images\", args)\nend",
"def destroy\n @fab_quarterly_status = FabQuarterlyStatus.find(params[:id])\n @fab_quarterly_status.destroy\n\n respond_to do |format|\n format.html { redirect_to fab_quarterly_statuses_url }\n format.json { head :no_content }\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 destroy\n @json.destroy\n\n head :no_content\n end",
"def destroy\n @fcq.destroy\n respond_to do |format|\n format.html { redirect_to fcqs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @f1.destroy\n respond_to do |format|\n format.html { redirect_to f1s_url, notice: \"F1 was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def delete_complete\n @todolist_chart = TodolistChart.find(:all, :conditions => {:status => \"completed\"})\n \n @todolist_chart.each do |todolist_chart|\n todolist_chart.destroy\n end\n \n respond_to do |format|\n format.html { redirect_to(todolist_charts_url) }\n format.xml { head :ok }\n end\n end",
"def delete_tenant_circle(args = {}) \n delete(\"/tenantcircles.json/#{args[:circleId]}\", args)\nend",
"def destroy\n @fumbl = Fumbl.find(params[:id])\n @fumbl.destroy\n\n respond_to do |format|\n format.html { redirect_to fumbls_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @fax_request.destroy\n respond_to do |format|\n format.html { redirect_to fax_requests_url, notice: 'Fax request was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @fokey.destroy\n respond_to do |format|\n format.html { redirect_to fokeys_url, notice: 'Fokey was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @rfq_line = RfqLine.find(params[:id])\n @rfq_line.destroy\n\n respond_to do |format|\n format.html { redirect_to rfq_lines_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @fabricsofaset.destroy\n respond_to do |format|\n format.html { redirect_to fabricsofasets_url, notice: 'Fabricsofaset was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @flowchart.destroy\n respond_to do |format|\n format.html { redirect_to flowcharts_url, notice: 'Flowchart was successfully destroyed.' }\n format.json { head :no_content }\n end\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
GET /descuento_adicionals GET /descuento_adicionals.json
|
def index
@descuento_adicionals = DescuentoAdicional.all
end
|
[
"def index\n @adicionals = Adicional.all\n end",
"def index\n @recurso_adicionals = RecursoAdicional.all\n end",
"def index\n @item_adicionals = ItemAdicional.all\n end",
"def index\n @descuentos ||= Descuento.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @descuentos }\n end\n end",
"def destroy\n @descuento_adicional.destroy\n respond_to do |format|\n format.html { redirect_to descuento_adicionals_url, notice: 'Descuento adicional was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def index\n @atividades = Atividade.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @atividades }\n end\n end",
"def index\n @lista_acuerdos = ListaAcuerdo.where(sesion_id: @sesion.id).all\n \n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @lista_acuerdos }\n end\n end",
"def index\n @anuncios = Anuncio.all\n render json: @anuncios, status: :ok\n end",
"def destroy\n @descuento_adicional.destroy\n respond_to do |format|\n format.html { redirect_to descuento_adicionals_url, notice: 'Descuento adicional fue eliminado exitosamente.' }\n format.json { head :no_content }\n end\n end",
"def index\n @apoio_educacioanls = ApoioEducacioanl.all\n end",
"def index\n @solicitacao_alts = SolicitacaoAlt.all\n end",
"def index\n @descuento_clientes = DescuentoCliente.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @descuento_clientes }\n end\n end",
"def index\n @deals = @business.deals \n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @deals }\n end\n end",
"def show\n @descuento = Descuento.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @descuento }\n end\n end",
"def index\n @dioceses = Diocese.all\n\n render json: @dioceses\n end",
"def etiquetas_por_aluno\n logger.info(params)\n @etiquetas_aluno = Etiqueta.all.where(aluno_id: params[:aluno_id])\n respond_with @etiquetas_aluno\n end",
"def index\n @atividade_extras = AtividadeExtra.all\n end",
"def index\n @atividades_extras = AtividadesExtra.all\n end",
"def index\n @adhesions = Adhesion.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @adhesions }\n end\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
POST /descuento_adicionals POST /descuento_adicionals.json
|
def create
@descuento_adicional = DescuentoAdicional.new(descuento_adicional_params)
respond_to do |format|
if @descuento_adicional.save
format.html { redirect_to @descuento_adicional, notice: 'Descuento adicional fue creado exitosamente.' }
format.json { render :show, status: :created, location: @descuento_adicional }
else
format.html { render :new }
format.json { render json: @descuento_adicional.errors, status: :unprocessable_entity }
end
end
end
|
[
"def create\n @descuento_adicional = DescuentoAdicional.new(descuento_adicional_params)\n\n respond_to do |format|\n if @descuento_adicional.save\n format.html { redirect_to @descuento_adicional, notice: 'Descuento adicional was successfully created.' }\n format.json { render :show, status: :created, location: @descuento_adicional }\n else\n format.html { render :new }\n format.json { render json: @descuento_adicional.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @descuento_adicionals = DescuentoAdicional.all\n end",
"def destroy\n @descuento_adicional.destroy\n respond_to do |format|\n format.html { redirect_to descuento_adicionals_url, notice: 'Descuento adicional was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def create\n @recurso_adicional = RecursoAdicional.new(recurso_adicional_params)\n\n respond_to do |format|\n if @recurso_adicional.save\n format.html { redirect_to @recurso_adicional, notice: 'Recurso adicional was successfully created.' }\n format.json { render :show, status: :created, location: @recurso_adicional }\n else\n format.html { render :new }\n format.json { render json: @recurso_adicional.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @descuento_adicional.destroy\n respond_to do |format|\n format.html { redirect_to descuento_adicionals_url, notice: 'Descuento adicional fue eliminado exitosamente.' }\n format.json { head :no_content }\n end\n end",
"def index\n @adicionals = Adicional.all\n end",
"def create\n @adicional_desconto = AdicionalDesconto.new(params[:adicional_desconto])\n\n respond_to do |format|\n if @adicional_desconto.save\n flash[:notice] = 'Adicional / Desconto cadastrado com sucesso.'\n #format.html { redirect_to(@adicional_desconto) }\n format.html { redirect_to(adicional_descontos_path) }\n format.xml { render :xml => @adicional_desconto, :status => :created, :location => @adicional_desconto }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @adicional_desconto.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def create\n @item_adicional = ItemAdicional.new(item_adicional_params)\n\n respond_to do |format|\n if @item_adicional.save\n format.html { redirect_to @item_adicional, notice: 'Item adicional was successfully created.' }\n format.json { render :show, status: :created, location: @item_adicional }\n else\n format.html { render :new }\n format.json { render json: @item_adicional.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @descuento_adicional.update(descuento_adicional_params)\n format.html { redirect_to @descuento_adicional, notice: 'Descuento adicional was successfully updated.' }\n format.json { render :show, status: :ok, location: @descuento_adicional }\n else\n format.html { render :edit }\n format.json { render json: @descuento_adicional.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @indicadoresacumulado = Indicadoresacumulado.new(indicadoresacumulado_params)\n\n respond_to do |format|\n if @indicadoresacumulado.save\n format.html { redirect_to @indicadoresacumulado, notice: 'Indicadoresacumulado was successfully created.' }\n format.json { render :show, status: :created, location: @indicadoresacumulado }\n else\n format.html { render :new }\n format.json { render json: @indicadoresacumulado.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @adocao_animal = AdocaoAnimal.find(params[:cancelamento_adocao][:adocao_animal_id])\n CancelamentoAdocao.cancela_adocao_animal(@adocao_animal)\n @cancelamento_adocao = CancelamentoAdocao.new(params[:cancelamento_adocao])\n \n respond_to do |format|\n if @cancelamento_adocao.save\n format.html { redirect_to @cancelamento_adocao, notice: 'Cancelamento adocao was successfully created.' }\n format.json { render json: @cancelamento_adocao, status: :created, location: @cancelamento_adocao }\n else\n format.html { render action: \"new\" }\n format.json { render json: @cancelamento_adocao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\r\n\r\n @ativ_aut = AtivAut.new(ativ_aut_params)\r\n\r\n respond_to do |format|\r\n if @ativ_aut.save\r\n format.html { redirect_to ativ_auts_path(@ativ_aut, egresso_id: @ativ_aut.egresso_id), notice: 'Atividade autônoma criada com sucesso.' }\r\n format.json { render :show, status: :created, location: ativ_auts_path }\r\n else\r\n format.html { render :new }\r\n format.json { render json: @ativ_aut.errors, status: :unprocessable_entity }\r\n end\r\n end\r\n end",
"def update\n respond_to do |format|\n if @descuento_adicional.update(descuento_adicional_params)\n format.html { redirect_to @descuento_adicional, notice: 'Descuento adicional fue actualizado exitosamente.' }\n format.json { render :show, status: :ok, location: @descuento_adicional }\n else\n format.html { render :edit }\n format.json { render json: @descuento_adicional.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @descuento = Descuento.new(params[:descuento])\n\n respond_to do |format|\n if @descuento.save\n format.html { redirect_to @descuento, notice: 'Descuento was successfully created.' }\n format.json { render json: @descuento, status: :created, location: @descuento }\n else\n format.html { render action: \"new\" }\n format.json { render json: @descuento.errors, status: :unprocessable_entity }\n end\n end\n end",
"def index\n @recurso_adicionals = RecursoAdicional.all\n end",
"def create\n @atividades_extra = AtividadesExtra.new(atividades_extra_params)\n\n respond_to do |format|\n if @atividades_extra.save\n format.html { redirect_to @atividades_extra, notice: 'Atividades extra was successfully created.' }\n format.json { render :show, status: :created, location: @atividades_extra }\n else\n format.html { render :new }\n format.json { render json: @atividades_extra.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @serv_adicionale = ServAdicionale.new(params[:serv_adicionale])\n\n respond_to do |format|\n if @serv_adicionale.save\n format.html { redirect_to @serv_adicionale, notice: 'Serv adicionale was successfully created.' }\n format.json { render json: @serv_adicionale, status: :created, location: @serv_adicionale }\n else\n format.html { render action: \"new\" }\n format.json { render json: @serv_adicionale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @indicador = Indicador.new(params[:indicador])\n\n respond_to do |format|\n if @indicador.save\n format.html { redirect_to indicadores_path, notice: 'Indicador criado com sucesso.' }\n format.json { render json: @indicador, status: :created, location: @indicador }\n else\n format.html { render action: \"new\" }\n format.json { render json: @indicador.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @opcion = Opcion.new(params[:opcion])\n\n if @opcion.save\n render json: @opcion, status: :created, location: @opcion\n else\n render json: @opcion.errors, status: :unprocessable_entity\n end\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
PATCH/PUT /descuento_adicionals/1 PATCH/PUT /descuento_adicionals/1.json
|
def update
respond_to do |format|
if @descuento_adicional.update(descuento_adicional_params)
format.html { redirect_to @descuento_adicional, notice: 'Descuento adicional fue actualizado exitosamente.' }
format.json { render :show, status: :ok, location: @descuento_adicional }
else
format.html { render :edit }
format.json { render json: @descuento_adicional.errors, status: :unprocessable_entity }
end
end
end
|
[
"def update\n respond_to do |format|\n if @descuento_adicional.update(descuento_adicional_params)\n format.html { redirect_to @descuento_adicional, notice: 'Descuento adicional was successfully updated.' }\n format.json { render :show, status: :ok, location: @descuento_adicional }\n else\n format.html { render :edit }\n format.json { render json: @descuento_adicional.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @recurso_adicional.update(recurso_adicional_params)\n format.html { redirect_to @recurso_adicional, notice: 'Recurso adicional was successfully updated.' }\n format.json { render :show, status: :ok, location: @recurso_adicional }\n else\n format.html { render :edit }\n format.json { render json: @recurso_adicional.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @serv_adicionale = ServAdicionale.find(params[:id])\n\n respond_to do |format|\n if @serv_adicionale.update_attributes(params[:serv_adicionale])\n format.html { redirect_to @serv_adicionale, notice: 'Serv adicionale was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @serv_adicionale.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @opcion = Opcion.find(params[:id])\n\n if @opcion.update(params[:opcion])\n head :no_content\n else\n render json: @opcion.errors, status: :unprocessable_entity\n end\n end",
"def update\n @indicador = Indicador.find(params[:id])\n\n respond_to do |format|\n if @indicador.update_attributes(params[:indicador])\n format.html { redirect_to indicadores_path, notice: 'Indicador atualizado com sucesso.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @indicador.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @descuento = Descuento.find(params[:id])\n\n respond_to do |format|\n if @descuento.update_attributes(params[:descuento])\n format.html { redirect_to @descuento, notice: 'Descuento was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @descuento.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @adicional_desconto = AdicionalDesconto.find(params[:id])\n\n respond_to do |format|\n if @adicional_desconto.update_attributes(params[:adicional_desconto])\n flash[:notice] = 'Adicional / Desconto alterado com sucesso.'\n #format.html { redirect_to(@adicional_desconto) }\n format.html { redirect_to(adicional_descontos_path) }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @adicional_desconto.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def update\n @cancelamento_adocao = CancelamentoAdocao.find(params[:id])\n\n respond_to do |format|\n if @cancelamento_adocao.update_attributes(params[:cancelamento_adocao])\n format.html { redirect_to @cancelamento_adocao, notice: 'Cancelamento adocao was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cancelamento_adocao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @inventario = Inventario.find(params[:id])\n\n respond_to do |format|\n if @inventario.update_attributes(params[:inventario])\n format.html { redirect_to @inventario, notice: 'Inventario was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @inventario.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @cardapio = cardapio\n @cardapio_item = cardapio_itens.find(params[:id])\n\n respond_to do |format|\n if @cardapio_item.update_attributes(\n description: params[:cardapio_item][:description],\n ingredients: params[:cardapio_item][:ingredients],\n price: params[:cardapio_item][:price],\n order: params[:cardapio_item][:order]\n )\n format.html { redirect_to cardapio_item_path(@cardapio_item, :cardapio => @cardapio.id), notice: 'Cardapio item was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @cardapio_item.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @dis_generic_alcohol_interaction.update(dis_generic_alcohol_interaction_params)\n format.html { redirect_to @dis_generic_alcohol_interaction, notice: 'Dis generic alcohol interaction was successfully updated.' }\n format.json { render :show, status: :ok, location: @dis_generic_alcohol_interaction }\n else\n format.html { render :edit }\n format.json { render json: @dis_generic_alcohol_interaction.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\n @cliente = find_cliente\n @descuento_cliente = @cliente.descuento_clientes.find(params[:id])\n\n respond_to do |format|\n\n if @descuento_cliente.update_attributes(params[:descuento_cliente])\n #format.html { redirect_to redirigir(@contelefono), :notice => 'El telefono fue actualizado correctamente.' }\n format.json { render json: @descuento_cliente }\n else\n #format.html { render :action => \"edit\" }\n format.json { render json: @descuento_cliente.errors }\n end\n\n end\n\n end",
"def update\n respond_to do |format|\n if @dis_alcohol_interaction.update(dis_alcohol_interaction_params)\n format.html { redirect_to @dis_alcohol_interaction, notice: 'Dis alcohol interaction was successfully updated.' }\n format.json { render :show, status: :ok, location: @dis_alcohol_interaction }\n else\n format.html { render :edit }\n format.json { render json: @dis_alcohol_interaction.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @apologetic.update(apologetic_params)\n format.html { redirect_to @apologetic, notice: 'Apologetic was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @apologetic.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @indicativo = Indicativo.find(params[:id])\n\n respond_to do |format|\n if @indicativo.update_attributes(params[:indicativo])\n format.html { redirect_to @indicativo, notice: 'Indicativo was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @indicativo.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @aactio = Aactio.find(params[:id])\n\n respond_to do |format|\n if @aactio.update_attributes(params[:aactio])\n format.html { redirect_to @aactio, notice: 'Aactio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @aactio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @solicitacao = Solicitacao.find(params[:id])\n\n respond_to do |format|\n if @solicitacao.update_attributes(params[:solicitacao])\n format.html { redirect_to @solicitacao, notice: 'Solicitacao was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @solicitacao.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @anuncio = Anuncio.find(params[:id])\n\n respond_to do |format|\n if @anuncio.update_attributes(params[:anuncio])\n format.html { redirect_to @anuncio, notice: 'Anuncio was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @anuncio.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @asiento = Asiento.find(params[:id])\n respond_to do |format|\n if @asiento.update_attributes(params[:asiento])\n format.html { redirect_to @asiento, :notice => 'El apunte fue cambiado.' }\n format.json { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.json { render :json => @asiento.errors, :status => :unprocessable_entity }\n end\n end\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
DELETE /descuento_adicionals/1 DELETE /descuento_adicionals/1.json
|
def destroy
@descuento_adicional.destroy
respond_to do |format|
format.html { redirect_to descuento_adicionals_url, notice: 'Descuento adicional fue eliminado exitosamente.' }
format.json { head :no_content }
end
end
|
[
"def destroy\n @descuento_adicional.destroy\n respond_to do |format|\n format.html { redirect_to descuento_adicionals_url, notice: 'Descuento adicional was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @recurso_adicional.destroy\n respond_to do |format|\n format.html { redirect_to recurso_adicionals_url, notice: 'Recurso adicional was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @item_adicional.destroy\n respond_to do |format|\n format.html { redirect_to item_adicionals_url, notice: 'Item adicional was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @descuento = Descuento.find(params[:id])\n @descuento.destroy\n\n respond_to do |format|\n format.html { redirect_to descuentos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @anotacion = Anotacion.find(params[:id])\n @anotacion.destroy\n\n respond_to do |format|\n format.html { redirect_to anotacions_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @indicacao = Indicacao.find(params[:id])\n @indicacao.destroy\n\n respond_to do |format|\n format.html { redirect_to indicacaos_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @indicador = Indicador.find(params[:id])\n @indicador.destroy\n\n respond_to do |format|\n format.html { redirect_to indicadores_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @aactio = Aactio.find(params[:id])\n @aactio.destroy\n\n respond_to do |format|\n format.html { redirect_to aactios_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @anunciante = Anunciante.find(params[:id])\n @anunciante.destroy\n\n respond_to do |format|\n format.html { redirect_to anunciantes_url }\n format.json { head :no_content }\n end\n \n end",
"def destroy\n @indicador.destroy\n respond_to do |format|\n format.html { redirect_to indicadores_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @serv_adicionale = ServAdicionale.find(params[:id])\n @serv_adicionale.destroy\n\n respond_to do |format|\n format.html { redirect_to serv_adicionales_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @explaination = Explaination.find(params[:id])\n @explaination.destroy\n\n respond_to do |format|\n format.html { redirect_to explainations_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @humanidades1 = Humanidades1.find(params[:id])\n @humanidades1.destroy\n\n respond_to do |format|\n format.html { redirect_to humanidades1s_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @dis_generic_alcohol_interaction.destroy\n respond_to do |format|\n format.html { redirect_to dis_generic_alcohol_interactions_url, notice: 'Dis generic alcohol interaction was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @respuesta = Respuesta.find(params[:id])\n @respuesta.destroy\n\n respond_to do |format|\n format.html { redirect_to respuestas_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @apuesta_detail = ApuestaDetail.find(params[:id])\n @apuesta_detail.destroy\n\n respond_to do |format|\n format.html { redirect_to apuesta_details_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @apologetic.destroy\n respond_to do |format|\n format.html { redirect_to apologetics_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @apoio_educacioanl.destroy\n respond_to do |format|\n format.html { redirect_to apoio_educacioanls_url, notice: 'Apoio educacioanal foi excluído com Sucesso !' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @indicativo = Indicativo.find(params[:id])\n @indicativo.destroy\n\n respond_to do |format|\n format.html { redirect_to indicativos_url }\n format.json { head :no_content }\n end\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Creates a pipeline on AWS Elastic Transcoder
|
def create_pipeline name, input_bucket, output_bucket, role
begin
@elastictranscoder.create_pipeline(
name: name,
input_bucket: input_bucket,
output_bucket: output_bucket,
role: role
)
rescue
#Raise informative exception
end
end
|
[
"def create_pipeline_object(actions:, environment:, resources:, timeout: nil)\n Google::Apis::GenomicsV2alpha1::Pipeline.new(\n actions: actions,\n environment: environment,\n resources: resources,\n timeout: timeout\n )\n end",
"def pipeline(name)\n return PipelineT.new(name)\n end",
"def create_pipeline_object(actions:, environment:, resources:, timeout: nil)\n Google::Apis::LifesciencesV2beta::Pipeline.new(actions:, environment:, resources:, timeout:)\n end",
"def create_pipeline(options = {})\n options[:accept] = 'application/vnd.go.cd.v1+json'\n post 'admin/pipelines', options\n end",
"def create(json_file)\n pipeline_json = File.read(json_file)\n @http.pipelines.post pipeline_json\n rescue StandardError => e\n puts \"Error creating pipeline: #{e}\"\n Process.exit(1)\n end",
"def pipeline(uri)\n builder = PipelineBuilder.new(context())\n builder.uri = uri\n __builders.push(builder)\n return builder\n end",
"def construct_pipeline(raw_pipeline)\n\t\tpipeline = raw_pipeline.collect do |raw_cmd|\n if builtin? raw_cmd\n cmd = Command.new(raw_cmd, get_builtin(raw_cmd))\n else\n cmd = Command.new(raw_cmd)\n end\n\n ContractRunner.new(cmd)\n end\n\n\t\t# leave first command input and last command output alone. i.e. as\n\t\t# constructed by Command.new. chain the rest together with pipes.\n\t\t(1...pipeline.length).each do |idx|\n\t\t\trd, wr = IO.pipe\n\t\t\tpipeline[idx - 1].out = wr\n\t\t\tpipeline[idx].in = rd\n\t\tend\n\n\t\tpipeline\n end",
"def new(*args)\n Knuckles::Pipeline.new(*args)\n end",
"def create\n @pipeline = Pipeline.new(params[:pipeline])\n\n respond_to do |format|\n if @pipeline.save\n format.html { redirect_to @pipeline, notice: 'Pipeline was successfully created.' }\n format.json { render json: @pipeline, status: :created, location: @pipeline }\n else\n format.html { render action: \"new\" }\n format.json { render json: @pipeline.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create(body = {})\n @client.pipeline_transfer.create(body)\n end",
"def transform(options = {}, &block)\n check_options('transformer', options)\n @stages << Transformer.new(options,&block)\n end",
"def register_pipeline(name, proc = T.unsafe(nil), &block); end",
"def create_pipeline(settings, config = nil)\n if config.nil?\n begin\n config = fetch_config(settings)\n rescue => e\n @logger.error(\"failed to fetch pipeline configuration\", :message => e.message)\n return nil\n end\n end\n\n begin\n LogStash::Pipeline.new(config, settings, metric)\n rescue => e\n increment_reload_failures_metrics(settings.get(\"pipeline.id\"), e.message, e.backtrace)\n return nil\n end\n end",
"def make_pipeline(process_names_or_string)\n names = \n if process_names_or_string.kind_of?(String)\n process_names_or_string.split(\"|\")\n else\n process_names_or_string\n end\n processes = names.map{|n| process(n)}\n Germinate::Pipeline.new(processes)\n end",
"def create_delivery_pipeline 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_delivery_pipeline_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 create_pipeline(pipeline_name, pipeline_path, repository, system_config)\n cmdline = Schott::AzureCLI::Commandlines.create_pipeline(pipeline_name, pipeline_path, repository)\n cmd = run_command(\"Create #{pipeline_name}\", cmdline, system_config)\n return cmd.success?\n end",
"def initialize(name)\n # Check and set the name\n @name = name.to_sym\n\n # Initialize the internals of the pipeline.\n\n\n # Initialize the environment for building the pipeline\n\n # The stages\n @stages = []\n\n # The event synchronizing the pipeline\n @mk_ev = proc { $clk.posedge }\n\n # The reset\n @mk_rst = proc { $rst }\n\n # Creates the namespace to execute the pipeline block in.\n @namespace = Namespace.new(self)\n\n # Generates the function for setting up the pipeline.\n obj = self # For using the right self within the proc\n HDLRuby::High.space_reg(@name) do |&ruby_block|\n if ruby_block then\n # Builds the pipeline.\n obj.build(&ruby_block)\n else\n # Return the pipeline as is.\n return obj\n end\n end\n\n end",
"def create_pipeline(name, uniqueId, description) \n output = call_with_retry(@retries) {\n @client.create_pipeline(:name => name,\n :unique_id => uniqueId,\n :description => description)\n }\n output[\"pipelineId\"]\n end",
"def pipeline\n Offer.pipeline(self)\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Deletes a pipeline on AWS Elastic Transcoder given an id
|
def delete_pipeline id
begin
@elastictranscoder.delete_pipeline(id: id)
rescue
#Raise informative exception
end
end
|
[
"def delete_pipeline(id:, **args)\n params = parameters(args) do\n optional_params\n end\n request(:delete, \"pipelines/#{id}\", params)\n end",
"def delete_pipeline(id)\n delete(\"dealGroups/#{id}\")\n end",
"def delete(pipeline_id)\n @client.pipeline.delete(pipeline_id)\n end",
"def delete(app, pipeline_name)\n @http.pipelines[URI.escape(\"#{app}/#{pipeline_name}\")].delete\n rescue StandardError => e\n puts \"Error deleting pipeline: #{e}\"\n Process.exit(1)\n end",
"def destroy\n @pipeline = Pipeline.find(params[:id])\n @pipeline.destroy\n\n respond_to do |format|\n format.html { redirect_to pipelines_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @rnaseq_pipeline = RnaseqPipeline.find(params[:id])\n @rnaseq_pipeline.destroy\n\n respond_to do |format|\n format.html { redirect_to(rnaseq_pipelines_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @pipeline.destroy\n\n respond_to do |format|\n format.html { redirect_to(pipelines_url) }\n format.xml { head :ok }\n format.json { head :ok }\n end\n end",
"def destroy\n @pipeline_item = PipelineItem.find(params[:id])\n @pipeline_item.destroy\n\n respond_to do |format|\n format.html { redirect_to pipeline_items_url }\n format.json { head :no_content }\n end\n end",
"def delete(pipeline_coupling_id)\n @client.pipeline_coupling.delete(pipeline_coupling_id)\n end",
"def delete_deal_stage(id)\n delete(\"dealStages/#{id}\")\n end",
"def delete_pipeline_schedule(project, pipeline_schedule_id)\n delete(\"/projects/#{url_encode project}/pipeline_schedules/#{pipeline_schedule_id}\")\n end",
"def delete_delivery_pipeline 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_delivery_pipeline_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 delete\n @@all_stages.delete(self.id)\n end",
"def remove id\r\n id = get_validated_id id\r\n\r\n return @@executors.delete id\r\n end",
"def destroy\n @kf_pipe = Kf::Pipe.find(params[:id])\n @kf_pipe.destroy\n\n respond_to do |format|\n format.html { redirect_to kf_pipes_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n pipeline_request.destroy\n head :no_content\n rescue StandardError => e\n render json: { data: { errors: e.message } }, status: :unprocessable_entity\n end",
"def remove_asset_from_stage\n @stage = Stage.find(params[:id])\n params[:asset_ids].each { |asset|\n @stage.assets.delete(Asset.find(asset)) }\n if @stage.save\n redirect_to :back, :notice =>\"Successfully deleted from stage.\"\n else\n redirect_to :back, :notice => \"An error occured\"\n end\n end",
"def destroy\n @local_law_pipeline.destroy\n respond_to do |format|\n format.html { redirect_to local_law_pipelines_url, notice: 'Local law pipeline was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @transformer = Transformer.find(params[:id])\n @transformer.destroy\n\n respond_to do |format|\n format.html { redirect_to transformers_url }\n format.json { head :no_content }\n end\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Tells if a free trial is defined in the price group
|
def has_free_trial?
return (trial and trial.free?)
end
|
[
"def has_free_trial_lesson?\n return self.prices.where( Price.arel_table[:type].eq('Price::Trial').and(\n (Price.arel_table[:amount].eq(nil).or(Price.arel_table[:amount].eq(0)))) ).any?\n end",
"def free?\n if prices.blank?\n !word_document.paid?\n else\n current_price.retail_price == 0 && prices.length == 1\n end\n end",
"def trial?\n (plan_type == 'free_trial')\n end",
"def free_plan?\n self.price == 0\n end",
"def multipricing?\n if pricingset && pricingset&.active && pricingset&.pricingoptions&.with_preset&.count > 0 && !free?\n #(type == \"StandardEvent\" || type == \"IndividualEvent\" || type == \"BundleEvent\" || type == \"OnlineEvent\")\n true\n else\n false\n end\n end",
"def has_chosen_free_item_from_expense_group(expense_group)\n registrant_expense_items.each do |rei|\n next unless rei.free\n if rei.expense_item.expense_group == expense_group\n return true\n end\n end\n paid_details.each do |pei|\n next unless pei.free\n if pei.expense_item.expense_group == expense_group\n return true\n end\n end\n\n return false\n end",
"def free_plan?\n self.account_plan == 'free'\n end",
"def free?\n self.setupFee == 0 && self.laborFee == 0 && self.oneTimeFee == 0 && self.recurringFee == 0 && self.hourlyRecurringFee == 0\n end",
"def available?\n if tenant == false && @units != @number\n return true\n else \n return false\n end\n end",
"def trial?\n bookings.current.trial?\n end",
"def chosen_free_item?\n registrant_expense_items.each do |rei|\n next unless rei.free\n if yield(rei.line_item)\n return true\n end\n end\n\n paid_details.each do |pei|\n next unless pei.free\n if yield(pei.line_item)\n return true\n end\n end\n\n false\n end",
"def paid_subscriptions?\r\n !self.subscriptions.map { |sub| sub.periods.paid }.flatten.empty?\r\n end",
"def chosen_free_item_from_expense_group?(expense_group)\n chosen_free_item? { |expense_item| expense_item.expense_group == expense_group }\n end",
"def can_be_paid?\n on_hold? && order_items.all? {|e| e.product.available?(self.system) && e.product.quantity(self.system) >= e.quantity}\n end",
"def allow_free_trial\n result = api_request(:post, \"/subscribers/#{self.customer_id}/allow_free_trial.xml\")\n self.attributes = result[\"subscriber\"]\n true\n end",
"def partially_paid?\n state_name == :partially_paid\n end",
"def payment_possible_for?(listing)\n listing.price && listing.price > 0 && payments_in_use?\n end",
"def payment_possible_for?(listing)\n listing.price && listing.price > 0 && stripe_in_use?\n end",
"def validate_premium_features\n\t\treturn if is_closed?\n\t\tif !owner.active_subscription.present? && !owner.active_ios_subscription.present? && (owner.trial_expiration.present? && owner.trial_expiration < DateTime.now)\n\t\t\terrors.add(:price_in_dollars, 'can only be free without a subscription') if price_in_cents > 0\n\t\tend\n\tend"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
sieve of eratosthenes page 16 for each i, a[i] true if prime for each i, setting array element corresponding to each multiple of i to false then loop through again, printing them out
|
def primes
arr=Array.new
arr[1]=false
(2..1000).each {|i| arr[i]=true}
(2..1000).each {|i| (i/2).floor
(2..1000).each {|j| (j/i).floor
arr[i*j] = false
}}
for i in 1..1000
if arr[i] == true
puts i
end
end
end
|
[
"def revised_sieve(limit)\r\n\t# Create boolean array from 0 to limit\r\n\tcrosslimit = Math.sqrt(limit)\r\n\tsieve = Array.new(limit,false)\r\n\tstart = Time.now\r\n\r\n\t# Set all even numbers to true (not prime)\r\n\t(4..limit).step(2).each do |n|\r\n\t\tsieve[n] = true\r\n\tend\r\n\r\n\t# Iterate from 3 to squareroot of limit\r\n\t(3..crosslimit).step(2).each do |n|\r\n\t\t# If n is prime,\r\n\t\tif !sieve[n]\r\n\t\t\t# Access all multiples of n above crosslimit and set not prime\r\n\t\t\t(n**2..limit).step(2*n).each do |m|\r\n\t\t\t\tsieve[m] = true\r\n\t\t\tend\r\n\t\tend\r\n\tend\r\n\r\n\t# Add all prime numbers in sieve for answer\r\n\tsum = 0\r\n\t(2..limit).each do |n|\r\n\t\tsum += n if !sieve[n]\r\n\tend\r\n\r\n\tputs sum\r\n\tputs Time.now-start\r\nend",
"def primes()\n return [] if @number < 2\n # build Boolean array to use for sieve with buffer to align indices\n sieve_array = Array.new(2, false) + Array.new(@number-1, true)\n # perform Sieve of Eratosthenes eliminations\n (2..Math.sqrt(@number).to_i).each do |i|\n (i**2..@number).step(i) {|j| sieve_array[j] = false} if sieve_array[i] == true\n end\n # return numbers by corresponding index that are still true\n (2..@number).collect {|index| index if sieve_array[index] == true}.compact\n end",
"def prime_num_gen( array_size )\n\n # array_size == array.length\n\n array = []\n\n divisors = []\n\n i = 0\n while( array_size != array.length )\n\n # p i\n\n if( i >= 2 ) # 0 and 1 are not prime\n\n if( i == 2 ) # two is a prime\n # p \" 2 is pushed\"\n array.push(i)\n end\n\n if( i % 2 != 0 ) # prime numbers cannot be even\n\n # p \" i #{i}\"\n # p \" divisors #{divisors}\"\n\n # START extra check - if i has more than 2 divisors\n #\n # IMPROVEMENT!!!!\n #\n # Could have simply called is_prime?( i ) --> returns true if prime\n # if is_prime? ? array.push(i) : p \"do nothing\"\n #\n j = 1\n while( i >= j )\n\n #p \" j #{j}\"\n\n if( i % j == 0)\n\n divisors.push(j)\n # p \" divisors #{divisors}\"\n end #if\n\n j += 1\n end # while\n\n if( divisors.length == 2 ) # prime should have 1 and itself as divisors\n array.push(i)\n # p \"#{i} is pushed\"\n end\n\n divisors.clear\n # p divisors\n\n # END of extra check\n #\n # extra check - if i has more than 2 divisors\n\n end # if (prime numbers cannot be even)\n\n end # if outter most\n\n i += 1\n end # while\n\n p array\n return array\n\nend",
"def prime_number(n)\n res = []\n prime = Array.new(n + 1, true)\n (2..n).each do |x|\n num = x * x\n break if num > n\n\n if prime[x]\n (num..n).step(x).each do |multiples|\n prime[multiples] = false\n end\n end\n end\n \n (2..n).each do |primes|\n res << primes if prime[primes]\n end\n res\nend",
"def simpleSieve(limit)\n\n i = 2\n\tmark = initArray(limit);\n\tuntil i*i >= limit do\n\n\t\tif mark[i] == false\n\t\t\t# If not marked yet, then its a prime\n\t\t\t$prime.push(i);\n\n\t\t\tj = i;\n\t\t\tuntil j >= limit do\n\n\t\t\t mark[j] = true\n\t\t\t j += i\n\n\t\t\tend\n\t\tend\n\t\ti=1+i\n\n\tend\n\nend",
"def sieve()\n @primeList = []\n @space[0][0].color = @space[0][1].color = \"red\"\n @space[0][0].truth = @space[0][1].truth = false\n for i in 2..Math.sqrt(@input+1)\n j = i**2\n if @space[i / @numcols][i % @numcols].truth == true\n while (j < @input+1)\n @space[j / @numcols][j % @numcols].truth = false\n @space[j / @numcols][j % @numcols].color = \"red\"\n j += i\n end\n end\n end\n # Color the remaining boxes green\n for i in 2..@input\n if @space[i / @numcols][i % @numcols].truth == true\n @space[i / @numcols][i % @numcols].color = \"green\"\n @primeList.push @space[i / @numcols][i % @numcols].value\n end\n end\n end",
"def primes(n, m)\n larger_number = [n, m].max\n smaller_number = [n,m].min\n primes = []\n \n (smaller_number..larger_number).each do |index|\n is_prime = true\n (2..(index-1)).each do |inner_index|\n if index % inner_index == 0\n is_prime = false\n break\n end\n end\n primes << index if is_prime\n end\n \n puts primes.join(', ')\nend",
"def primes_upto(n)\n sieve = [].fill(true, (2..n))\n\n 2.upto Math.sqrt(n) do |i|\n (i * i).step(n, i) { |j| sieve[j] = false } if sieve[i]\n end\n\n sieve.each_index.select { |i| i if sieve[i] }\nend",
"def flag_prime_numbers primes\n\tis_prime = Array.new(Maxvalue + 1, false)\n\tis_prime[primes[0]] = true\n\tfor i in (1...primes.size)\n\t\tis_prime[primes[i]] = true\n\tend\n\treturn is_prime\nend",
"def prime_set(n)\n\t\tprimes_arr =[]\n\t\ti = 1\n\t\t# keep inserting prime numbers into array until its length is equal to 'n'\n\t\tuntil primes_arr.count == n\n\t\t\tif is_prime(i) == true \n\t\t\t\tprimes_arr << i \n\t\t\tend \n\t\t\ti+=1\n\t\tend \n\t\tp primes_arr\n\tend",
"def generate_sieve(max)\n @sieve = Array.new(max, false)\n @sieve[2] = true\n 3.step(max, 2) { |x| @sieve[x] = true}\n 3.step(Math.sqrt(max).to_i, 2) { |i|\n if @sieve[i]\n (i**2).step(max, 2*i) { |x| @sieve[x] = false}\n end\n }\n end",
"def getPrimes()\n oldlimit = $primelimit + 1\n $primelimit *= 2\n\n for i in oldlimit...$primelimit\n isPrime = true\n $primes.each do |p|\n if i % p == 0\n isPrime = false\n break\n end\n end\n if isPrime\n $primes << i\n end\n end\n\nend",
"def select_primes(array)\n array.delete(1)\n array.select do |num|\n (2...num).to_a.all? {|int| num % int != 0}\n end\nend",
"def prime?(integer)\n arr=Array(2..integer-1)\n if integer <=1\n return false\n elsif integer ==2\n return true\n #binding.pry\n end\n arr.each do |i|\n if (integer % i) ==0\n return false\n end\n end\n true\nend",
"def primes\t\n\t\t@prime_numbers = []\t\n\t\ti = 2\n\t\tuntil prime_numbers.size > num-1\n\t\t\t# adding elements to array : time complexity - O(1)\n\t\t\tprime_numbers << i if (is_prime?(i) == 1)\n\t\t\ti += 1\n\t\tend\n\t\tputs \"\\n\\nPrime numbers for the chosen limit are: \" + @prime_numbers.to_s\n\tend",
"def build_out_prime_list\n new_size = prime_list.size + prime_list.size\n loop_end = Math.sqrt( idx_to_value( new_size ) ).ceil\n\n (prime_list.size..new_size).each { |idx| prime_list[idx] = true }\n\n prime_list.each_with_index do |prime, idx|\n next unless prime\n\n divisor = idx_to_value( idx )\n break if divisor > loop_end\n\n (idx+1..new_size).each { |i| prime_list[i] = false if idx_to_value( i ) % divisor == 0 }\n end\n end",
"def pick_primes(numbers)\n\n checker = []\n final = []\n\n numbers.each do |num|\n if num == 2\n checker << 2\n end \n\n if num > 2 \n checker << num\n\n (2...num).each do |ele| \n if num % ele == 0\n checker << false\n else \n checker << true\n end \n end\n end\n if !checker.include?(false)\n final << checker[0]\n end\n checker = []\n end\n return final\nend",
"def find_primes_with_sieve (n, limit=10000000)\n\n sieve = Array.new(limit, true)\n primes = []\n\n for i in 2 .. Math.sqrt(limit)\n if sieve[i]\n range = i**2..limit\n range.step(i) do | j |\n sieve[j] = false\n end\n end\n end\n\n index = 2\n while primes.length < n && index < sieve.length do\n if sieve[index]\n primes.push(index)\n end\n index += 1\n end\n\n return primes\n\n end",
"def sieve_of_atkin(max)\n if max < 1 || !(max.is_a?(Integer))\n raise TypeError.new \"the number given must be an integer greater than zero\"\n end\n\n root = Integer.sqrt(max)\n sieve = Array.new(max){ |i| i == 2 || i == 3 }\n\n for i in 1..root do\n for j in 1..root do\n n = 4 * (i * i) + (j * j)\n # All numbers with modulo-sixty remainder 1, 13, 17, 29, 37, 41, 49, or 53 have a modulo-twelve remainder of 1 or 5.\n if (n <= max) and (n % 12 == 1 || n % 12 == 5)\n sieve[n] = !sieve[n]\n end\n n = 3 * (i * i) + (j * j)\n # All numbers with modulo-sixty remainder 7, 19, 31, or 43 have a modulo-six remainder of 1.\n # These numbers are prime if and only if the number of solutions to 3x^2 + y^2 = n is odd and the number is square free.\n if (n <= max) and (n % 12 == 7)\n sieve[n] = !sieve[n]\n end\n n = 3 * (i * i) - (j * j)\n # All numbers with modulo-sixty remainder 11, 23, 47, or 59 have a modulo-twelve remainder of 11.\n # These numbers are prime if and only if the number of solutions to 3x^2 – y^2 = n is odd and the number is square free.\n if (i > j) and (n <= max) and (n % 12 == 11)\n sieve[n] = !sieve[n]\n end\n end\n end\n\n # If n is prime, omit all multiples of its square\n (5..root).each { |i|\n if sieve[i]\n (i * i).step(max, i * i) do |j|\n sieve[j] = false\n end\n end\n }\n\n #Select all prime numbers\n 2.upto(max).select { |i| sieve[i] }\nend"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
3.1 fill in 2d array of bools by setting a[i,j] to true if gcd i,j is 1 and false otherwise uses ruby's built in gcd function
|
def twoDArray(m,n)
arr = Hash.new
for m in 0..m
for n in 0..n
if m.gcd(n) == 1
arr[[m,n]] = true
else
arr[[m,n]] = false
end
end
end
for m in 0..m
for n in 0..n
if arr[[m,n]] == true
puts "#{m} :m and #{n} :n"
end
end
end
end
|
[
"def coprime?(i,j)\n\tmygcd(i,j) == 1\nend",
"def solve_array(array)\n check_array = Array.new(9){Array.new(9){Array.new(9){0}}}\n # p array\n for i in 0..8\n for j in 0..8\n if array[i][j] == 0\n p \"for each variable\\n\\n\\n\\n\\n\\n\\n\\n #{i}, #{j}\"\n p \"before_modify #{check_array[i][j]} 1\"\n modify_check_array(array, check_array, i, j)\n p check_array[i][j]\n if count_value(check_array[i][j]) == 1\n p check_array[i][j]\n p \"for ij #{i}, #{j}\"\n array[i][j] = get_value(check_array[i][j])\n end\n end\n end\n end\n end",
"def combinatorial_test\n\t\t# how this works:\n\t\t\t# \tpopulate array of every combination of the matrix_array rows\n\t\t\t# \tfor each member of the combination array:\n\t\t\t# \t\tfind min row assignments permitted\n\t\t\t# \t\tfind max column assignments possible\n\t\t\t# \t\tcheck if min_row_assmts_permitted > max_col_assmts_poss\n\t\t\t# \t\t\treturn false\n\t\t# this seems to catch all of the cases where min allowable column assignments > max num of possible row assignments\n\t\t# so I didn't write a corresponding test for that\n\n\t\t# this method seems to be the single slowest, most costly method in the whole algorithm; steps towards speeding it up:\n\t\t# (1) I could just invert when there are a lot of rows; but this doesn't solve the issue, it just pushes it back;\n\t\t# the algorithm remains extremely slow and costly to memory when you get arrays that are square with sidelengths beyond 15;\n\t\t# (2) another option: the problem here occurs when you have zeros in only n columns, and then occurs in combinations of rows\n\t\t# with n or more members such that each row in the combination contains zeros IN JUST THOSE COLUMNS; so you could do something\n\t\t# like this:\t\t\n\t\t\t# ALGORITHM SKETCH:;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\n\t\t\t# take the first column\n\t\t\t# \t(it's guaranteed to have a zero;\n\t\t\t# \t\tby now each column will contain at least one zero, otherwise solveable? would have dealt with it)\n\t\t\t# \tput it in a col_array\n\t\t\t# \tfind the zeros in the column\n\t\t\t# \t\tif there are no zeros, break the loop\n\t\t\t# \tlook in the rows that contain those zeros\n\t\t\t# \t\tput those rows in a row_array\n\t\t\t# \tnow look in the rows just identified\n\t\t\t# \t\twhat columns are their zeros in?\n\t\t\t# \t\tadd those columns to the col_array\n\t\t\t# \t\tif there are no columns to add, break the loop\n\t\t\t# \tnow look in those columns...\n\t\t\t# \t\tyoure repeating at this point\n\t\t\t# \t\tonce there are no more rows / cols to add to your arrays, stop\n\t\t\t# \tnow count the number of columns in the col_array\n\t\t\t# \tnow count the number of rows in the row_array\n\t\t\t# \tif the former is less than the latter, you have a failure\n\n\n# [[1,0,1,0,5,6],\n# [6,7,1,0,1,0],\n# [1,0,3,9,1,0],\n# [2,6,1,0,1,8]]\n\n\n\n\t# what you want to do is this: test each ROW; find a zero in that row (doesn't matter which), then run the rest of the test as is;\n\t# because of how the test works, there is no need to go through each column for a given row; once you've found one zero, it will\n\t# identify the rest; but there is a need to go through each row\n\t\t# No, this won't be able to see the problematic rows in the examples in quick_spec....\n \t\tcolumns = self.transpose\n\n \t\tcolumns.each.with_index do |col, col_id|\n \t\t\t# no point running this on columns that don't contain zeros\n \t\t\tbreak if !col.include?(0)\n\n \t\t\t# put the col_id in the col_array\n \t\t\tcol_array = [col_id]\n\n \t\t\t# find the zeros in that column, put their row_ids in the row_array\n \t\t\trow_array = col.each.with_index.with_object([]) {|(cell, row_id), obj|\n \t\t\t\tobj << row_id if cell==0}\n\n \t\t\tloop do\n \t\t\t\t# make duplicates of col and row_arrays\n\t \t\t\tc_dup = col_array.dup\n\t \t\t\tr_dup = row_array.dup\n\n\t \t\t\t# find the zeros in the rows just identified, add their col_ids to the col_array, only keep unique entries\n\t \t\t\trow_array.each.with_object(col_array) {|row_id, obj|\n\t \t\t\t\tself[row_id].each.with_index {|cell, col_id|\n\t \t\t\t\t\tobj << col_id if cell==0\n\t \t\t\t\t}\n\t \t\t\t}.uniq!\n\n\t \t\t\t# find the zeros in the cols just identified, add their row_ids to the row_array, only keep unique entries\n\t \t\t\tcol_array.each.with_object(row_array) {|col_id, obj|\n\t \t\t\t\tcolumns[col_id].each.with_index {|cell, row_id|\n\t \t\t\t\t\tobj << row_id if cell==0\n\t \t\t\t\t}\n\t \t\t\t}.uniq!\n\n\t \t\t\t# if nothing has been added to either col_array or row_array, break the method\n\t \t\t\tbreak if col_array == c_dup && row_array == r_dup\n\t \t\tend\n\n\t \t\treturn \"fail\" if col_array.count < row_array.count\n\t \tend\n\n\n\n\n\n\t\t# test_cases = self.every_combination_of_its_members\n\t\t# test_cases.each do |submatrix|\n\t\t# \tmin_row_assignments_permitted = self.min_row_assignment * submatrix.length\n\t\t# \tif min_row_assignments_permitted > submatrix.max_column_assmts_possible(self.max_col_assignment)\n\t\t# \t\treturn \"fail\"\n\t\t# \tend\n\t\t# end\n\t\treturn \"pass\"\n\tend",
"def jaccard(a, b)\n a_i = a.map { |i| i > 0 }\n b_i = b.map { |i| i > 0 } \n n = (0 .. (a.size - 1)).map { |i| (a_i[i] && b_i[i]) ? 1 : 0 }.inject(:+)\n u = (0 .. (a.size - 1)).map { |i| (a_i[i] || b_i[i]) ? 1 : 0 }.inject(:+)\n return n.to_f / u\n #b = bray_curtis(a, b)\n #return 2.0*b/(1+b)\n end",
"def gcdR(i, j)\n if j != 0\n return gcdR(j, i%j)\n else\n return i\n end\nend",
"def gcd(p0) end",
"def perfect_range(y)\n @j = (2..y)\n @g = Array.new\n @temp = 0\n\n @j.each do |n|\n if (perfect_number n) == true\n @g.append(n)\n end\n end\n\n return @g\nend",
"def reciprocal_array?\n true\n end",
"def reduce_to_all_true(array)\n counter = 0;\n while counter < array.length do\n return false if !array[counter];\n counter += 1;\n end\n return(true);\nend",
"def reduce_to_all_true(array)\n i = 0\n while i < array.length do\n if !!(array[i]) == false\n return false\n end\n i += 1\n end\n return true\nend",
"def reciprocal_array?\n true\n end",
"def coolio_array(arr)\n i = 0\n j = arr.length - 1\n\n while i <= j\n p i\n p j\n\n if i == j\n if arr[i] != 100\n return \"false 1\"\n end\n elsif arr[i] + arr[j] != 100\n return \"false 2\"\n end\n i += 1\n j -= 1\n end\n\n return \"true\"\nend",
"def coolio_array(array)\n i = 0\n j = -1\n if array.length % 2 === 0\n while i < array.length / 2 && (j).abs <= array.length / 2\n if array[i] + array[j] != 100 \n return false\n break\n else\n i += 1\n j -= 1\n end\n end\n return true\n else\n while i < array.length / 2 && (j).abs <= array.length / 2\n if array[i] + array[j] != 100 || array[array.length / 2] != 100\n return false\n break\n else\n i += 1\n j -= 1\n end\n end\n return true\n end\nend",
"def solve?(steps)\n # sum = steps.sum\n sum = 0\n steps.each do |s|\n sum += s\n end\n\n return false if sum.odd?\n half = sum / 2\n\n steps = steps.sort.reverse\n # f(steps, half, 0)\n size = steps.size\n\n dp = Array.new(size + 1) { Array.new(half + 1) }\n (half + 1).times do |j|\n dp[0][j] = (j == 0)\n end\n\n (size + 1).times do |i|\n next if i == 0\n (half + 1).times do |j|\n if dp[i-1][j]\n dp[i][j] = true\n else\n if j >= steps[i-1]\n dp[i][j] = dp[i-1][j-steps[i-1]]\n else\n dp[i][j] = false\n end\n end\n end\n end\n dp[-1][-1]\nend",
"def primes\n arr=Array.new\n arr[1]=false\n (2..1000).each {|i| arr[i]=true}\n (2..1000).each {|i| (i/2).floor\n (2..1000).each {|j| (j/i).floor\n arr[i*j] = false\n }}\n for i in 1..1000\n if arr[i] == true\n puts i\n end\n end\nend",
"def comp(array1, array2)\n return false if array1.empty? || array2.empty?\n\n array1_sq = []\n\n array1.each do |num|\n array1_sq << (num ** 2)\n end\n\n array2.each do |num|\n return false if array1_sq.include?(num) == false\n end\n true\nend",
"def random_boolean_array(elements)\r\n remaining = elements\r\n arr = []\r\n while remaining > 0\r\n arr.push random_boolean\r\n remaining -= 1\r\n end\r\n return arr\r\n end",
"def circular_graph?(array)\n\treturn false if array.size.zero?\n\tvisited = array.size.times.map{ |i| false }\n\tvisited[0] = true\n\n\tarray.each do |index|\n\t\tif index > array.size \n\t\t\treturn false\n\t\tend\n\n\t\tif visited[index]\n\t\t\treturn true\n\t\tend\n\n\t\tvisited[index] = true\n\tend\n\tfalse\nend",
"def divisible_sub_x(arr, n)\n for len in 1..arr.size\n arr.combination(len) {|g| return true if g.sum % n == 0}\n end\n false\nend"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
3.4 solve the josephus problem with an array N people have decided to commit mass suicide by arranging themselves in a circle and killing the mth person around the circle, closing ranks as each person drops out of the circle. find out the order in which the people die
|
def josephus(n,m)
arr = Array.new
order = Array.new
for i in 1..n
arr[i] = i
end
arr.compact!
for i in 0..n-1
arr= arr.rotate(m-1)
order << arr[0]
arr[0] = nil
arr.compact!
end
puts "order: #{order.to_s}"
end
|
[
"def josephus_survivor(n,k)\n result = 1\n for i in 1...n + 1\n result = (result + k - 1) % i + 1\n end\n \n result\nend",
"def judge(n, trusts)\n puts \"Trusts: #{trusts}\"\n judge = -1\n\n #Build Unique Towns People \n unique_townspeople = []\n n.times do |i|\n unique_townspeople.push(i+1)\n end\n puts \"Unique Towns People: #{unique_townspeople}\"\n\n #Build \"Trust Circles Hash\"\n trust_circles = {}\n #Loop through trusts\n i = 0\n while i < trusts.length\n #get the trustor (A)\n trustor = trusts[i][0]\n #get the trustee (B)\n trustee = trusts[i][1]\n #check if trustor exists\n if !trust_circles.key?(trustor)\n #if does not exist, add trustor in array\n trust_circles[trustor] = []\n trust_circles[trustor].push(trustee)\n else #does exist, push trustee to array\n trust_circles[trustor].push(trustee)\n end \n i += 1\n end\n puts \"Trust circles: #{trust_circles}\"\n\n #Determine the judge\n # 1. The town judge trusts nobody.\n #compare values in unique townspeople against keys in trust circle\n trustors = trust_circles.keys\n potential_judges = []\n\n i = 0\n while i < unique_townspeople.length\n if !trustors.include?(unique_townspeople[i])\n # puts \"trustors #{trustors} : townpeople #{unique_townspeople[i]}\"\n potential_judges.push(unique_townspeople[i])\n # puts \"potential_judges #{potential_judges}\"\n end\n i += 1\n end\n puts \"Potential Judges: #{potential_judges} (Townspeople who trust no one)\"\n\n # 2. Everybody (except for the town judge) trusts the town judge.\n #loop through potential judges\n\n #add potential judges to the trust circle\n potential_judges.each do |pjudge|\n trust_circles[pjudge] = []\n end\n puts \"Trust Circle: #{trust_circles} (Added Potential Judges to trust circle)\"\n\n i = 0\n while i < potential_judges.length\n is_trusted =true\n \n #loop through trust cirlce \n trust_circles.each do |trustor, trustees|\n #check if potential judge is not a value to key(trustor)\n #and do not evaluate yourself\n if (trustor!=potential_judges[i]) && (!trustees.include?(potential_judges[i]))\n #puts \"trustees #{trustees}, potential judge #{potential_judges[i]}\"\n potential_judges.delete_at(i)\n i = i-1 #offset i because shift during delete_at\n is_trusted = false\n break #breaks trust circle\n end\n end\n i += 1\n end\n puts \"Potential Judges: #{potential_judges} (Remaining judges who are trusted by everyone)\"\n\n # 3. There is exactly 1 person that satisfies properties 1 and 2.\n if potential_judges.length == 1\n judge = potential_judges[0]\n else\n return -1\n end\n\n return judge\nend",
"def josephus_survivor(n,k)\n # initialize array, variables\n array = (1..n).to_a\n index = k-1\n\n # there can be only one\n until array.length === 1\n index -= array.length until index < array.length\n array.slice!(index, 1)\n index += (k-1)\n end\n array[0]\nend",
"def kill_sequence(n, m)\n people = Array.new(n, true) # true = alive\n sequence = []\n index = -1\n\n while sequence.length < n\n # Advance through list until we've landed on the mth alive person\n count = 0\n while count < m\n index = (index + 1) % n\n count += 1 if people[index]\n end\n\n # Kill them\n people[index] = false\n sequence << index\n end\n\n sequence\nend",
"def josephus(input1, input2)\n n = input1.to_i\n\tk = input2.to_i\n\n\tprisoners = (0...n).to_a\n\tprisoners.rotate!(k-1).shift while prisoners.length > 1\n\treturn (prisoners.first + 1)\nend",
"def find_judge(n, trust)\r\n arr = (1..n).to_a\r\n hash = {}\r\n arr.each {|num| hash[num] = 0}\r\n trust.each do |tuple|\r\n hash.delete(tuple[0]) if hash[tuple[0]]\r\n hash[tuple[1]] += 1 if hash[tuple[1]]\r\n end\r\n hash.keys.each {|key| return key if hash[key] == n-1}\r\n return -1\r\nend",
"def modify_pool (people_array)\n x = 0\n\n while x < people_array.count - 1\n if people_array[x][3] > people_array[x + 1][3]\n people_array.delete_at(x)\n x = 0\n elsif people_array[x][3] < people_array[x + 1][3]\n people_array.delete_at(x + 1)\n x = 0\n else\n x += 1\n end\n end\n return people_array\nend",
"def eliminate(n, immunity)\n\tlosers = []\n\t\tputs @borneo.immunity_challenge.class\n\tn.times do\n\tputs '*'*200\n\t\tlosers.push @borneo.immunity_challenge.tribal_council if immunity == 'tribe'\n\t\tlosers.push @merge_tribe.tribal_council if immunity == 'individual'\n\tend\n\tprint_losers(losers)\n\tlosers\nend",
"def solution(a)\n leader, count = array_leader(a)\n return 0 unless leader\n\n n = a.size\n head_count = 0\n total_equis = 0\n a.each_with_index do |e, i|\n head_count += 1 if e == leader\n tail_count = count - head_count\n\n if (head_count > (i + 1)/2) && (tail_count > (n - 1 - i)/2)\n total_equis += 1\n end\n end\n\n total_equis\nend",
"def josephus(items,k)\n killed = []\n # loop the following two until items == []\n until items.length == 0 do\n items = items.rotate(k)\n killed << items.pop\n end\n killed\nend",
"def solve( n = 2_000 )\n # We can classify every tile according to its angular position around the\n # unit circle, setting position 0 at the top since that's where each row\n # starts in the problem statement. Positions 1-5 then follow every 60° as\n # we work our way counter-clockwise. Depending on which of these positions\n # each tile falls (or between which pair of positions), we use different\n # formulae to calculate its six neighbors to the N, NW, SW, S, SE, and NE:\n # \n # Pos 0: n even = fhp\n # N = n + ring (g) S = n - ring + 6 (a)\n # NW = n + ring + 1 (h) SE = n + ring - 1 (f)\n # SW = n + 1 NE = n + (2*ring + 5) (p)\n #\n # Pos 0-1: n even = bh, n odd = ag \n # N = n + ring (g) S = n - ring + 6 (a)\n # NW = n + ring + 1 (h) SE = n - ring + 5 (b)\n # SW = n + 1 NE = n - 1\n #\n # Pos 1: n even = bh, n odd = gi\n # N = n + ring (g) S = n + 1\n # NW = n + ring + 1 (h) SE = n - ring + 5 (b)\n # SW = n + ring + 2 (i) NE = n - 1\n #\n # Pos 1-2: n even = bh, n odd = ci\n # N = n - 1 S = n + 1\n # NW = n + ring + 1 (h) SE = n - ring + 5 (b)\n # SW = n + ring + 2 (i) NE = n - ring + 4 (c)\n #\n # Pos 2: n even = hj\n # N = n - 1 S = n + ring + 3 (j)\n # NW = n + ring + 1 (h) SE = n + 1\n # SW = n + ring + 2 (i) NE = n - ring + 4 (c)\n #\n # Pos 2-3: n even = dj, n odd = ci\n # N = n - ring + 3 (d) S = n + ring + 3 (j)\n # NW = n - 1 SE = n + 1\n # SW = n + ring + 2 (i) NE = n - ring + 4 (c)\n #\n # Pos 3: n even = dj, n odd = ik\n # N = n - ring + 3 (d) S = n + ring + 3 (j)\n # NW = n - 1 SE = n + ring + 4 (k)\n # SW = n + ring + 2 (i) NE = n + 1\n #\n # Pos 3-4: n even = dj, n odd = ek\n # N = n - ring + 3 (d) S = n + ring + 3 (j)\n # NW = n - ring + 2 (e) SE = n + ring + 4 (k)\n # SW = n - 1 NE = n + 1\n #\n # Pos 4: n even = jl\n # N = n + 1 S = n + ring + 3 (j)\n # NW = n - ring + 2 (e) SE = n + ring + 4 (k)\n # SW = n - 1 NE = n + ring + 5 (l)\n #\n # Pos 4-5: n even = fl, n odd = ek\n # N = n + 1 S = n - 1\n # NW = n - ring + 2 (e) SE = n + ring + 4 (k)\n # SW = n - ring + 1 (f) NE = n + ring + 5 (l)\n #\n # Pos 5: n even = fl, n odd = km\n # N = n + ring + 6 (m) S = n - 1\n # NW = n + 1 SE = n + ring + 4 (k)\n # SW = n - ring + 1 (f) NE = n + ring + 5 (l)\n #\n # Pos 5-0, except last: n even = fl, n odd = gm\n # N = n + ring + 6 (m) S = n - ring (g)\n # NW = n + 1 SE = n - 1\n # SW = n - ring + 1 (f) NE = n + ring + 5 (l)\n #\n # Pos 5-0, only last: n even = flo, n odd = gmo\n # N = n + ring + 6 (m) S = n - ring (g)\n # NW = n - ring + 1 (f) SE = n - 1\n # SW = n - (2*ring - 7) (o) NE = n + ring + 5 (l)\n #\n # From these formula, we can derive the difference between a tile and each\n # of its neighbors. If we arrange all potential differences in ascending\n # order, it becomes obvious that for n even or odd, some deltas will al-\n # ways be even, and thus can never be prime (>2).\n #\n # Furthermore, we can see that only in certain positions will a tile ever\n # differ from three neighbors by odd amounts (position 0 and just to the\n # right of position 0). In all other cases, at most two deltas will be\n # odd, meaning PD(n) will be 2 or less.\n #\n # n even n odd\n # a = ring - 6 even a\n # b = ring - 5 b even\n # c = ring - 4 even c\n # d = ring - 3 d even\n # e = ring - 2 even e\n # f = ring - 1 f even\n # g = ring even g\n # h = ring + 1 h even\n # i = ring + 2 even i\n # j = ring + 3 j even\n # k = ring + 4 even k\n # l = ring + 5 l even\n # m = ring + 6 even m\n # o = 2ring - 7 o o\n # p = 2ring + 5 p p\n pd3 = [1, 2]\n base, ring = 8, 12\n \n while pd3.size < n\n # Only at position 0 and one tile to the right will there ever be three\n # odd deltas, so those are the only ones we have to check for primality.\n # Both share a delta of f = ring - 1.\n if (ring - 1).prime?\n # Check the other odd deltas for position 0. \n pd3 << base if (ring + 1).prime? && (2*ring + 5).prime?\n\n # Check the other odd deltas for one tile to the right of position 0.\n pd3 << base + ring - 1 if (ring + 5).prime? && (2*ring - 7).prime?\n end\n\n # Advance the first tile of the current ring (base), and the number of\n # tiles it contains (ring). \n base += ring\n ring += 6\n end\n\n pd3[-1]\n end",
"def replace_worst_ranked(offsprings)\n size = offsprings.length\n @population = @population [0..((-1*size)-1)] + offsprings\n end",
"def sol inp\n k, ins = inp.split(' ',2)\n k = k.to_i\n ps, pr, pi, pu, pw, pd, pl = ins.split.map(&:to_f)\n\n @ps = ps\n @pr = pr\n @pu = pu\n @pw = pw\n @pd = pd\n @pl = pl\n\n #\n # required_wins = 2\n # # winning 1st set\n # first_set = ps*pi + pr*(1-pi)\n # # winning 2nd set\n # first_set * winning_another_set + (1-first_set)*winning_another_set\n #\n # required_wins.times do |i|\n # count = 0\n # while count <= i\n # wins[i] = win_scene(pi,ps,pr, count)\n # count+=1\n # break if count == i\n # lose_scene(pi,ps,pr, pr,count)\n # end\n # end\n\n # winning second set after winning first + winning second set after winning one\n # wins[0]*win_scene(pi,ps,pr) + (1-wins[0])*lose_scene(pi,ps,pr)\n\n def win_scene(pi,round,required_wins,current_wins)\n return 0 if round >= required_wins\n # puts \"w #{' '*round},#{required_wins},#{current_wins})\"\n sunny = (round == 0) ? pi : (pi+(@pu*@pw))\n sunny = 1.0 if sunny > 1\n sunny = 0.0 if sunny < 0\n chance = sunny*@ps + (1-sunny)*@pr\n binding.pry if chance > 1\n\n if required_wins == current_wins+1\n chance\n else\n # return 0 if round > 100\n return 0 if (10**7*chance).to_i < 1\n wins = win_scene(sunny,round+1,required_wins,current_wins+1)\n # lose = lose_scene(sunny,round+1,required_wins,current_wins+1)\n chance * (wins)#+ (1-chance)*lose\n end\n end\n\n def lose_scene(pi,round,required_wins,current_wins)\n return 0 if round >= required_wins\n # puts \"l #{' '*round},#{required_wins},#{current_wins})\"\n sunny = (round == 0) ? pi : (pi-(@pd*@pl))\n sunny = 1.0 if sunny > 1\n sunny = 0.0 if sunny < 0\n chance = sunny*@ps + (1-sunny)*@pr\n binding.pry if chance > 1\n\n if required_wins == current_wins\n chance\n else\n # return 0 if round > 100\n return 0 if (10**7*chance).to_i < 1\n wins = win_scene(sunny,round+1,required_wins,current_wins+1)\n # lose = lose_scene(sunny,round+1,required_wins,current_wins+1)\n chance * (wins) #+ (1-chance)*lose\n end\n end\n\n # a = win_scene(pi,0,1,0)\n b = win_scene(pi,0,k,0)\n c = lose_scene(pi,0,k,0)\n # c = (k > 1) ? lose_scene(pi,1,k,0) : 0\n\n puts b\n puts c\n b +c\n # wtf?\n # 0.4* win_scene(pi,0,k,0)+ (1-0.6)*lose_scene(pi,0,k,0)\n\n# def smth(pi, ps, pr, setcount=0)\n# arr[1] = arr[0]\n# end\n# # set 2+ ?\n# set2 = ((ps+pu)*pw + ps*(1-pw))*pi\n# (1-set1)*((ps-pd)*pl + ps*(1-pl))\n# if k > 1\n# (k-1).times do\n#\n# end\n# end\nend",
"def josephus(arr, k)\n removed_elements = []\n while arr.length > 0 do\n arr = arr.rotate(k)\n removed_elements << arr.pop\n end\n removed_elements\nend",
"def solve( n = 16 )\n max = 0\n \n (1..10).each do |a|\n (1..10).each do |b|\n next if b == a\n (1..10).each do |c|\n next if c == b || c == a\n (1..10).each do |d|\n next if d == c || d == b || d == a\n (1..10).each do |e|\n next if e == d || e == c || e == b || e == a\n\n rotate = 3*[a, b, c, d, e].each_with_index.min[1]\n (1..10).each do |f|\n next if f == e || f == d || f == c || f == b || f == a\n (1..10).each do |g|\n next if g == f || g == e || g == d || g == c || g == b || g == a\n \n t = a + f + g\n (1..10).each do |h|\n next if h == g || h == f || h == e || h == d || h == c || h == b || h == a\n next unless t == b + g + h\n\n (1..10).each do |i|\n next if i == h || i == g || i == f || i == e || i == d || i == c || i == b || i == a\n next unless t == c + h + i\n\n (1..10).each do |j|\n next if j == i || j == h || j == g || j == f || j == e || j == d || j == c || j == b || j == a\n next unless t == d + i + j && t == e + j + f\n\n s = [a, f, g, b, g, h, c, h, i, d, i, j, e, j, f]\n rotate.times {s.push s.shift}\n\n s = s.join\n next if n != s.length\n\n max = [max, s.to_i].max\n end\n end\n end\n end\n end\n end\n end\n end\n end\n end\n\n max\n end",
"def problem_86a\n m = 1818\n# m = 100\n\n p3 = lambda do |mm,nn|\n raise \"bad value\" if mm == nn\n mm,nn = nn,mm if mm < nn\n m2 = mm*mm\n n2 = nn*nn\n a,b,c = [m2 - n2, 2*mm*nn, m2 + n2]\n [m2 - n2, 2*mm*nn, m2 + n2]\n end\n\n in_range = lambda {|a,b,c| a <= m && b <= 2*m}\n\n solutions = lambda do |ret,x,b,c|\n return unless x <= m\n# puts \"#{x} #{b} #{c}\"\n bm = (b >= m) ? m-1 : b-1\n bm = x-1 if x <= bm\n if x < b \n ys = b - x\n else\n ys = 1\n end\n p1 = c.to_f # Math.sqrt(x**2 + (y+z)**2)\n z = b - ys\n if p1 <= Math.sqrt(ys**2 + (x+z)**2) &&\n p1 <= Math.sqrt(z**2 + (x+ys)**2)\n if false\n p = [b,x].sort\n if r = ret[p]\n puts \"dup r = #{r} #{bm-ys+1}\"\n end\n ret[p] = bm-ys+1\n else\n ys.upto(bm) do |y|\n ret[[x,y,b-y].sort] = true\n end\n end\n end\n end\n\n hits = Hash.new\n hit = 0\n (1..(m/2)).each do |x|\n ((x+1)..(m/2+1)).each do |y|\n next unless (x+y).odd? && x.gcd(y) == 1\n sides = p3.call(x,y).sort\n next unless in_range.call(*sides)\n hits[sides] = true\n hit += 1\n end\n end\n puts \"Generated primative triangles\"\n good = {}\n # Sort the primative triangles into sets according to\n # max M value. Then for each increase, pick the groups with\n # factors into the M and solutions.call.\n # This should let us slide out.\n \n hits.each_key do |p|\n a,b,c = p\n (1..(2*m/([a,b].max))).each do |k|\n aa,bb,cc = a*k, b*k, c*k\n solutions.call(good,aa,bb,cc)\n solutions.call(good,bb,aa,cc)\n# good += solutions.call(aa,bb,cc)\n# good += solutions.call(bb,aa,cc)\n end\n end\n# good.compact!\n puts good.length\n puts \"Triangles => #{hit}\"\n puts \"Unique Triangles => #{hits.length}\"\n# good = good.map {|a| a.sort }.uniq.sort\n# good = good.sort.uniq\n puts \"sorted\"\n\n# hit = 0\n# good.each_pair do |p,v|\n# puts \"#{p} => #{v}\"\n# hit += v\n# end\n# puts \"Hit = #{hit}\"\n\n good.length\nend",
"def josephus(count,skip)\n\tx = 0\n\ti = 2\n\twhile i <= count\n\t\tx = (x+skip) % i\n\t\ti += 1\n\tend\n\treturn (x+1)\nend",
"def puppy_golden_age(arr)\r\n puppies = 0 # set the var for puppies born for later comparison\r\n years = [] # set empty array to later push the results of the comparison\r\n\r\n arr.each_with_index do |x, i| # looping through entire array. could have used #each_index without x.\r\n for i2 in i + 1...arr.length # set up loop for i2 which is needed to compare all elements in array above i1 and for return of second index. i + 1 protects against the return of the same index twice. see written test 3.\r\n if puppies < arr[i..i2].reduce(&:+) # comparison of the value puppies with the sum of the elements in arr where index > i.\r\n puppies = arr[i..i2].reduce(&:+) # if the net gain between these two indices is > the previous value for puppies, the new gain becomes the value\r\n years = [i, i2] # sets the indicies for the larger gain compared here: puppies < arr[i..i2].reduce(&:+)\r\n end\r\n end\r\n end\r\n\r\n years # when the loop is complete, the largest gain and their indicies will be set for the variables puppies/ years. question asks for the index of the years.\r\nend",
"def pythagoreans (n)\n triples = []\n a = 1\n b = 1\n c = 1\n\n for c in (1..n)\n for b in (1..c)\n for a in (1..b)\n if a**2 + b**2 == c**2\n triples << [a,b,c]\n end\n end\n end\n end\n\n return triples.sort\nend"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
load the lines from the file, remove comments, blank lines, whitespace, set the ivar
|
def load_lines file
lines = Array.new
lines = @file.split("\n")
#fuck that, i dont like the dyanmic feed, just pre-parse it
lines.map! do |line| #map overwrites the old array
if line.include? '#'
split = line.split '#'
#puts split.to_s
split.shift
else
line
end
end
#removing blank lines
lines.delete_if do |line|
true if line.empty?
end
lines.each { |line| line.chomp! }
lines
end
|
[
"def refresh!\n @lines = load_from_file\n end",
"def to_set\n @lines ||= load_from_file\n end",
"def populate_from_file(dec_line, infile)\n comment_count = blank_count = 0\n done = false\n \n if /^\\s*(\\w+\\s+)?object\\s+(\\w+)(:(\\d*))?\\s+{/.match(dec_line) && !$2.nil?\n @class = $2\n self[:id] = $1.strip unless $1.nil? # this will usually be nil, but some objects are named\n self[:num] = $4 unless $4.nil?\n end\n \n until done do\n l = infile.gets.strip\n case l\n when /^\\}/\n done = true\n @semicolon = l[-1] == ';'\n when ''\n self[('blank' + blank_count.to_s).to_sym] = ''\n blank_count += 1\n when /^\\/\\//\n self[('comment' + comment_count.to_s).to_sym] = l\n comment_count += 1\n when GLMWrangler::OBJ_REGEX\n push_nested self.class.new(@wrangler, {dec_line: l, infile: infile}, self)\n when /^([\\w.]+)\\s+([^;]+);(.*)$/\n # note: there will be trouble here if a property is set to a quoted\n # string that contains a ';'\n key = $1.to_sym\n self[key] = $2\n # Preserve any non-whitespace that appeared on this line after the\n # semicolon. There's no facility for editing this trailing junk,\n # it's just preserved.\n @trailing_junk[key] = $3 unless $3.empty?\n else\n raise \"Object property parser hit a line it doesn't understand: '#{l}'\"\n end\n end\n self\n end",
"def parse_file!\n File.open(@filepath, 'r') do |f|\n last_line = ''\n while this_line = f.gets\n coll = case this_line\n when /^\\s*def / : @methods\n when /^\\s*class / : @classes\n when /^\\s*module / : @modules\n when /^\\s*(attr_reader|attr_accessor|attr_writer) / : @attrs\n when /^\\s*[^a-z =]+\\s*=/ : @constants\n else nil\n end\n # add a true entry if comment precedes declaration or follows on same line\n coll << is_comment?(last_line) || has_comment?(this_line) if coll\n last_line = this_line\n end\n end\n end",
"def initialize(file_name)\n if ::File.exists?(file_name)\n file_contents = ::File.read(file_name)\n @lines = file_contents.split(\"\\n\")\n else\n @lines = []\n end\n @comments = []\n @current_comment = []\n @in_multi_comment = false\n end",
"def parse_file\n line_count = 0\n @text.each_line do |line|\n if line == nil || line == '' || line.size == 0 || line[0] == '#' || line[0] == \"\\n\"\n next\n end\n elements = line.split(' ')\n if elements.size > 2\n puts 'Waring : '.red + 'in file \"' + @file_name.yellow + '\" ignoring line ' + line_count.to_s.yellow + ' ( it has more than one space and is not a comment )'\n else\n if elements.size == 1\n @ret << Manga_data.new(nil, nil, nil, elements[0], nil)\n else\n @ret << Manga_data.new(nil, elements[0], elements[1], nil, nil)\n end\n end\n line_count += 1\n end\n end",
"def load_data\n @data=[]\n marker_found=false\n @file.rewind\n @file.each_line do |line|\n if !marker_found && @sentinel.call(line) then\n marker_found=true\n end\n\n @data << line if marker_found\n end\n end",
"def modified_lines_in_file(_file)\n EMPTY_SET\n end",
"def read_lines\n\t\t@open_file.read.split(/\\n/).reject{ |r| r == \" \"}\n\tend",
"def initialize(lines, options = {})\n if lines.is_a?(String)\n lines = lines.split(\"\\n\")\n end\n self.meta = {}\n in_meta = true\n while in_meta and line = lines.shift do\n line.strip!\n matches = line.match /^([^:]+):\\s+(.+)/\n if matches\n if matches[1] =~ /(Chapter|Number|Position)/i and matches[2] =~ /\\d+/ and number.nil?\n self.number = matches[2].strip.to_i\n end\n self.meta[matches[1].downcase.to_sym] = matches[2]\n else\n lines = [line] + lines if line\n in_meta = false \n end\n end\n self.meta.merge!(options)\n self.file_name = self.meta[:file_name]\n self.content = lines.join\n end",
"def unparsed\n @lines\n end",
"def textLoadFile(w,file)\n w.delete('1.0', 'end')\n f = open(file, 'r')\n while(!f.eof?)\n w.insert('end', f.read(1000))\n end\n f.close\nend",
"def loadChar(fileName, set)\n # input file\n File.open(fileName, \"r\") do |inputFile|\n while line = inputFile.gets\n line.chomp!\n next if line.empty? || line[0,1] == '#'\n set << line\n end\n end\nend",
"def initialize(file, lineno)\n lines = file_cache(file)\n @source = match_tabs(lines, lineno, \"def\")\n @comment = preceding_comment(lines, lineno)\n @defn = lines[lineno].strip.gsub(/^def\\W+(.*)/){$1}\n if @defn =~ /.*?\\(.*?\\)/\n @params = @defn.gsub(/.*?\\((.*?)\\)/){$1}.split(',').map{|p| p.strip}\n else\n @params = []\n end\n end",
"def initialize(file)\n @lines = []\n command_file = File.open(file)\n command_file.each_line{|x| @lines.push(x.chomp)}\n command_file.close\n process_command_file.g\n end",
"def lines_backup; end",
"def read_source(source_file)\n @source_lines = source_file.readlines()\n end",
"def load_file(filename)\n File.open(filename, \"r\").each_line do |line|\n @file_content << line\n end\n @file_content\n end",
"def initialize(filename, count) \n @filename = filename\n @count = count\n @LINES = Hash[]\n f = File.open(filename)\n # gets how many lines are in the file\n @lineCount = f.readlines.size\n # can't initialize the lexer if the line provided is out of range of the number of lines in the file\n if @count > @lineCount\n return\n end\n f = File.open(filename)\n # splits out all the comments in the file\n @temp = f.read.split(/(\\/\\/.*)/)\n # removes the comments from the lexer\n @temp = @temp.reject { |c| c.include?(\"//\") }\n @temp = @temp.join(\" \")\n # puts each line in a hash table with the appropriate line number\n @temp.split(\"\\n\").each_with_index do |line, index|\n @LINES.store(index+1, line.split(\" \"))\n end\n @arr = @LINES[@count].join(\" \")\n f = File.open(filename)\n # splits out the rest of the important tokens\n @tokens = @arr.split(/\\s*(:=)\\s*|\\s*(;)\\s*|\\s*(\\+)\\s*|\\s*(\\<=)\\s*|\\s*(\\<)\\s*|\\s*(\\=)\\s*|\\s*(\\/\\/.*)|\\s*(\\/)\\s*|\\s*(\\()\\s*|\\s*(\\))\\s*|\\s*(\\*)\\s*|\\s*(\\-)\\s*|\\s/)\n @tokensize = @tokens.size\n @index = 0\n @idx = 0\n # if the line used to initialize the lexer is the same as the total number of lines, then EOF is added to the end of the file\n if @count == @lineCount\n @tokens[@tokensize] = \"EOF\"\n end\n # symbols contains the numerical representations of the tokens, excluding empty lines/strings and comments\n @symbols = Array.new\n @tokens = @tokens.reject { |c| c.empty? }\n @tokens = @tokens.reject { |c| c.include?(\"//\")}\n \n # fills the symbols array according the to tokens parsed\n for i in @tokens\n getTokenKind()\n nextToken()\n end\n \n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
primary access control point: returns all tenant permissions for user currently not used as user will only have one tenant with current implementation
|
def current_tenant_permissions
if current_or_guest_user
current_or_guest_user.tenant_ids
else
nil
end
end
|
[
"def primary_tenant_permission\n if current_or_guest_user\n current_or_guest_user.tenant_ids.first\n else\n nil\n end\n end",
"def permission_grants\n return @permission_grants\n end",
"def get_active_permissions\n set_access_token\n if @access_token && !@permissions && set_uid\n # if we don't have permissions set but have an access token\n # grab the user's info\n @rest = Facebook::RestAPI.new(@access_token) \n result = @rest.fql_query(\"select #{all_permissions.join(\",\")} from permissions where uid = #{@uid.to_s}\")\n result.first\n end \n end",
"def quota_viewable\n return Quotum.none if @force_empty\n if @user.present?\n if @user.tenant_ids\n Quotum.where(tenant_id: @user.tenant_ids).or(Quotum.where(tenant_id: nil))\n else\n Quotum.where(tenant_id: nil)\n end\n else\n Quotum.where(tenant_id: nil)\n end\n end",
"def oauth2_permission_grants()\n return MicrosoftGraph::ServicePrincipals::Item::Oauth2PermissionGrants::Oauth2PermissionGrantsRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def permissions\n @permissions = if current_token.present?\n ClientApplication.all_permissions.select { |p| current_token.read_attribute(p) }\n elsif current_user\n ClientApplication.all_permissions\n else\n []\n end\n end",
"def mapping_tenant\n @tenants = Tenant.where(:client_id => current_user.id, :is_active => true)\n @users = current_user.corporate_user\n end",
"def oauth2_permission_grants\n return @oauth2_permission_grants\n end",
"def index\n @applicants = current_user.applicants rescue nil\n end",
"def permission_grants()\n return MicrosoftGraph::Me::JoinedTeams::Item::PermissionGrants::PermissionGrantsRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def permission_grants()\n return MicrosoftGraph::Users::Item::Chats::Item::PermissionGrants::PermissionGrantsRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def permission_grants()\n return MicrosoftGraph::Groups::Item::PermissionGrants::PermissionGrantsRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def core_getUsersPermissions\n # definisco permessi iniziali\n initial_permissions = (1...11).to_a\n\n unpermitted = core_getHideUsersPermissionsSettings\n permitted_permissions = initial_permissions\n permitted_permissions = initial_permissions - unpermitted if unpermitted\n\n permissions = []\n names = core_getUsersPermissionsNamesSettings\n return permitted_permissions if !names\n\n permitted_permissions.each do |permission|\n names.each do |name|\n permissions.push([permission, name.last]) if permission === name.first.to_i\n end\n end\n\n return permissions\n end",
"def get_user_permissions\n user_permissions = Set.new\n return user_permissions if @user.nil?\n user_permissions << :DEFAULT_PERMISSION\n add_permissions_for_rules(user_permissions)\n user_permissions\n end",
"def all_users_permissions user\n can :list, LimeSurvey #if user.role_aggregates.count > 0\n end",
"def apply_superuser_permissions(permission_types)\n []\n end",
"def user_permissions\n @user_permissions ||= user.permissions_given.active.map(&:label)\n end",
"def admin_grant_permissions\n @user = User.includes(:perms).find(params[:id])\n authorize @user\n user_perms = current_user.perms\n @perms = user_perms & [Perm.grant_permissions, Perm.modify_templates, Perm.modify_guidance, Perm.use_api, Perm.change_org_details]\n end",
"def oauth2_permission_grants()\n return MicrosoftGraph::Oauth2PermissionGrants::Oauth2PermissionGrantsRequestBuilder.new(@path_parameters, @request_adapter)\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
returns primary (base) tenant permission for user
|
def primary_tenant_permission
if current_or_guest_user
current_or_guest_user.tenant_ids.first
else
nil
end
end
|
[
"def current_tenant_permissions\n if current_or_guest_user\n current_or_guest_user.tenant_ids\n else\n nil\n end\n end",
"def tenant\n #OPTIMIZE Add a tenant_id to SipAccount\n case self.phone_numberable\n when SipAccount\n self.phone_numberable.tenant\n when Conference\n case self.phone_numberable.conferenceable\n when Tenant\n self.phone_numberable.conferenceable\n when User\n self.phone_numberable.conferenceable.current_tenant #OPTIMIZE\n when UserGroup\n self.phone_numberable.conferenceable.tenant\n end\n end\n end",
"def current_tenant\n ActsAsTenant.current_tenant\n end",
"def set_tenant_from_user\n return unless current_user.present?\n\n set_current_tenant(current_user.accounts.first)\n end",
"def create?\n # true # anyone can create a tenant\n user_is_admin?\n end",
"def user_permission(user)\n if @users.has_key? user.id\n @users[user.id]\n else\n if @parent_org\n @parent_org.user_permission(user)\n else\n :disabled\n end\n end\n end",
"def tenant_id\n return @tenant_id\n end",
"def acts_as_universal_and_determines_account()\n include ::Milia::InviteMember\n has_and_belongs_to_many :tenants\n\n acts_as_universal()\n\n # validate that a tenant exists prior to a user creation\n before_create do |new_user|\n if Thread.current[:tenant_id].blank? ||\n !Thread.current[:tenant_id].kind_of?(Integer) ||\n Thread.current[:tenant_id].zero?\n\n raise ::Milia::Control::InvalidTenantAccess, \"no existing valid current tenant\"\n\n end\n end # before create callback do\n\n # before create, tie user with current tenant\n after_create do |new_user|\n tenant = Tenant.find(Thread.current[:tenant_id])\n unless tenant.users.include?(new_user)\n\t\t\t\t\t\tnew_user.skip_reconfirmation! # For details why this is needed see milia issue #68\n tenant.users << new_user # add user to this tenant if not already there\n end\n end # before_create do\n\n before_destroy do |old_user|\n old_user.tenants.clear # remove all tenants for this user\n end # before_destroy do\n\n end",
"def tenant_type\n return @tenant_type\n end",
"def current_tenant()\n begin\n tenant = (\n Thread.current[:tenant_id].blank? ?\n nil :\n Tenant.find(Thread.current[:tenant_id])\n )\n\n return tenant\n\n rescue ActiveRecord::RecordNotFound\n return nil\n end\n end",
"def mapping_tenant\n @tenants = Tenant.where(:client_id => current_user.id, :is_active => true)\n @users = current_user.corporate_user\n end",
"def acts_as_tenant?\n respond_to? :tenant_identifier\n end",
"def is_tenant? item_in\n\t\titem_in.tenant_id == current_user.id\n\tend",
"def get_permission\n project_id_key = get_project_id_key()\n project = Project.find(params[project_id_key])\n\n if (current_user)\n permission = Permission.where({\n user_id: current_user.id,\n project_id: params[project_id_key]\n }).first\n end\n\n project.try(:public) || permission\n end",
"def pundit_user\n local_user\n end",
"def cross_tenant_access_policy\n return @cross_tenant_access_policy\n end",
"def current_tenant\n Thread.current[:current_tenant]\n end",
"def current_tenant\n Thread.current[:current_tenant]\n end",
"def tenant_directory\n 'tenant_identifier' # customize with your own multi-tenancy strategy\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Parses the given stream and returns a node tree
|
def load(stream, root_class = nil)
root_class ||= PrisonParser::Node
line_num = 0
nodes = []
@tokens = []
current_node = root_class.new
while !stream.eof? do
line = stream.readline.strip
line_num += 1
tokenize(line)
next if tokens.size == 0
# start a new node
if "BEGIN" == tokens[0]
nodes.push(current_node)
label = tokens[1]
current_node = current_node.create_node(label)
if tokens.size > 2
# inline node
if tokens.size % 2 != 1
raise UnevenTokenError.new("Unexpected number of tokens in an inline node definition on line #{line_num}")
end
unless "END" == tokens[tokens.size - 1]
raise UnexpectedEndOfLineError.new("Unexpected end of inline node definition on line #{line_num}")
end
# Don't iterate the 'BEGIN', label, 'END'
tokens[2..-2].each_slice(2) do |parts|
current_node.add_property(parts[0], parts[1])
end
upper_node = nodes.pop
upper_node.finished_reading_node(current_node)
current_node = upper_node
else
current_node.prevent_inlining!
end
elsif "END" == tokens[0]
# end of multi-line section
upper_node = nodes.pop
upper_node.finished_reading_node(current_node)
current_node = upper_node
else
# inside a multi-line section
current_node.add_property(tokens[0], tokens[1])
end
end
if nodes.size != 0
raise UnexpectedEndOfFileError.new("Unexpected end of file!")
end
current_node
end
|
[
"def parse(stream, encoding=nil)\n _parse(stream, false, encoding)\n @tree.get_document\n end",
"def parse(stream, encoding=nil)\r\n _parse(stream, false, encoding)\r\n return @tree.getDocument\r\n end",
"def parse!(stream,options={})\n\t\tparse(stream,options.merge(debug: true))\n\tend",
"def decode( inputstream)\n #Helper method on inputstream to read single bits\n class << inputstream\n def init\n @byte = 0\n @bit_count = 0\n end\n def read_bit\n if 0 == @bit_count\n @byte = read( 1)[0]\n @bit_count = 8\n end\n bit = @byte & 0b10000000 == 0 ? 0 : 1\n @bit_count -= 1\n @byte <<= 1\n return bit\n end\n end\n \n inputstream.init\n node = @root_node\n tokens = []\n loop do\n bit = inputstream.read_bit\n branch = node.branches[bit]\n if branch.is_a?( Node)\n node = branch\n else\n token = branch\n break if TERMINATOR == token\n tokens << token\n node = @root_node\n end\n end\n tokens\n end",
"def parse stream\n @stack = []\n @iv = 0\n @repeat_range = [] \n @range_rules = [] \n @gram = Grammar.new \n state = :start\n \n stream.each do |token|\n trans = @transitions.fetch state\n action = trans.fetch( token.type, nil )\n raise \"Parser: unexpected token '#{token.type}' when in #{state}\" if action.nil?\n state = action.call( self, token )\n end\n @gram\n end",
"def parse (io, &block)\n close_stream = false\n if io.is_a?(String)\n if io.include?('<') and io.include?('>')\n io = StringIO.new(io)\n else\n io = open(io)\n end\n close_stream = true\n elsif io.is_a?(Pathname)\n io = io.open\n close_stream = true\n elsif io.is_a?(URI)\n io = io.open\n close_stream = true\n end\n\n begin\n parser = parser_class(parser_name).new(&block)\n parser.parse_stream(io)\n return parser.root\n ensure\n io.close if close_stream\n end\n end",
"def parse_stream(stream, options = {}, &block)\n parse_io(stream, options, &block)\n end",
"def parse\n @parser.parse(::File.open(@file))\n NodeCache.root\n end",
"def match(ptr, depth = 0)\n children = []\n loop do\n ptr.skip(/\\s+/)\n break if ptr.eos?\n ptr.unscan if ptr.matched?\n if ast = @root.match(ptr, depth + 1)\n children << ast\n else\n raise ParserJam.new(ptr, \"StreamParser[#{depth}]\")\n end\n end\n AST.new(:root, children: children, pos: 0)\n end",
"def process(input_stream)\n debug 'Beginning tokenization of input'\n\n @stream = input_stream\n @stream_char = 1\n\n @output = [] if @state == :root\n\n until @stream.strip.empty?\n tk = tokenize\n @output.append(tk) if tk.instance_of? Token\n end\n\n @output\n end",
"def parse(stream, base, options = {}, &block) # :yields: triple\n @doc = case stream\n when Nokogiri::HTML::Document then stream\n when Nokogiri::XML::Document then stream\n else Nokogiri::XML.parse(stream, base)\n end\n \n @strict = options[:strict]\n @base = base.to_s\n raise ParserException, \"Empty document\" if @doc.nil? && @strict\n @callback = block\n\n # If the doc has a default, use that as \"html\"\n ns = @doc.namespaces[\"xmlns\"]\n ns ||= \"http://www.w3.org/1999/xhtml\" # FIXME: intuite from DOCTYPE, or however\n @namespace = Namespace.new(ns, \"html\") if ns\n \n # parse\n parse_whole_document(@doc, @base)\n\n @graph\n end",
"def parse(stream,options={})\n\t\traise(\"no start rule supplied\") unless @start_rule || options[:rule]\n\t\trule = @start_rule\n\t\trule = @rules[options[:rule]] || raise(\"rule '#{options[:rule]}' not found\") if options[:rule]\n\t\tlogger.level = DEBUG if options[:debug]\n\n\t\tlogger.debug(\"##### Parsing(#{options[:rule]}): #{stream.inspect}\")\n\n\t\t#context = Grammy::ParseContext.new(self,nil,stream,options.only(:ast_module))\n\t\tcontext = Grammy::ParseContext.new(self,options[:source],stream,options.only(:ast_module))\n\n\t\tbegin\n\t\t\tmatch = rule.match(context)\n\t\trescue Exception => e\n\t\t\t# TODO debug only\n\t\t\tputs e\n\t\t\tputs e.backtrace\n\t\t\tLog4r::NDC.clear\n\t\t\tlogger.level = WARN if options[:debug]\n\t\t\traise e\n\t\tend\n\t\t\n\t\tresult = ParseResult.new(match,context)\n\t\tlogger.debug(\"##### success: #{result.match}\")\n\n\t\tlogger.level = WARN if options[:debug]\n\n\t\tif options[:debug]\n\t\t\tputs result\n\t\t\tresult.tree.to_image('DEBUG_'+rule.name)\n\t\tend\n\t\tresult\n\tend",
"def parse\n @started = false\n begin\n parser = REXML::Parsers::SAX2Parser.new @stream \n parser.listen( :start_element ) do |uri, localname, qname, attributes|\n case qname\n when \"stream:stream\"\n openstream = ParsedXMLElement.new(qname)\n attributes.each { |attr, value| openstream.add_attribute(attr, value) } \n @listener.receive(openstream)\n @started = true\n else \n if @current.nil?\n @current = ParsedXMLElement.new(qname)\n else\n @current = @current.add_child(qname)\n end\n attributes.each { |attr, value| @current.add_attribute(attr, value) }\n end\n end\n parser.listen( :end_element ) do |uri, localname, qname|\n case qname\n when \"stream:stream\"\n @started = false\n else\n @listener.receive(@current) unless @current.element_parent\n @current = @current.element_parent\n end\n end\n parser.listen( :characters ) do | text |\n @current.append_data(text) if @current\n end\n parser.listen( :cdata ) do | text |\n @current.append_data(text) if @current\n end\n parser.parse\n rescue REXML::ParseException\n @listener.parse_failure\n end\n end",
"def create_parser\n @parser = Parser.new.tap do |p|\n p.stream_open {|node| @nodes.push(node) }\n p.stream_close { close_connection }\n p.stanza {|node| @nodes.push(node) }\n end\n end",
"def parse_to_tree\n node = @root\n @tokenized.each do |e|\n if e.match(/^<[\\/].+>/)\n node = node.parent\n node.children << TagNode.new(e, Tag.new((e.match(/<(.+?)>/).captures[0]), nil, nil, nil, nil, nil), node, [])\n elsif e.match(/^<img.+?>|^<hr.+?>|^<!doctype.+?>/)\n node.children << TagNode.new(e, Tag.new((e.match(/<(.+?)>/).captures[0]), nil, nil, nil, nil, nil), node, [])\n elsif e.match(/<.+>/)\n node.children << TagNode.new(e, parse_tag(e), node, [])\n node = node.children[-1]\n else\n node.children << TagNode.new(e, Tag.new('text', nil, nil, nil, nil, nil), node, [])\n end\n end\n end",
"def parse\n @started = false\n \n parser = XMLParser.new(\"UTF-8\")\n def parser.unknownEncoding(e)\n raise \"Unknown encoding #{e.to_s}\"\n end\n def parser.default\n end\n \n begin\n parser.parse(@stream) do |type, name, data|\n begin\n case type\n when XMLParser::START_ELEM\n case name\n when \"stream:stream\"\n openstream = ParsedXMLElement.new(name)\n data.each {|key, value| openstream.add_attribute(key, value)}\n @listener.receive(openstream)\n @started = true\n else \n if @current.nil?\n @current = ParsedXMLElement.new(name.clone)\n else\n @current = @current.add_child(name.clone)\n end\n data.each {|key, value| @current.add_attribute(key.clone, value.clone)}\n end\n when XMLParser::CDATA\n @current.append_data(data.clone) if @current\n when XMLParser::END_ELEM\n case name\n when \"stream:stream\"\n @started = false\n else\n @listener.receive(@current) unless @current.element_parent\n @current = @current.element_parent\n end\n end\n rescue\n puts \"Error #{$!}\"\n end\n end\n rescue XMLParserError\n line = parser.line\n print \"XML Parsing error(#{line}): #{$!}\\n\"\n end\n end",
"def parse_tree\n File.open(html_file, 'r') do |file|\n current = nil\n file.each_line do |line|\n line.scan(%r{(<(.*?>.*?)<(\\/.*?)>|<(.*?)>(.*))}).each do |tag|\n if !tag[3].nil? && tag[3].start_with?('/') # ending tag\n current = current.parent\n else\n node = Node.new(tag)\n if @root.nil?\n @root = node\n else\n node.parent = current\n current.childs << node\n end\n @tags << node.tag\n current = node\n current = current.parent if !tag[2].nil? && tag[2].start_with?('/')\n end\n end\n end\n end\n end",
"def parse(filename)\n file = File.open(filename, \"r\").readlines\n\n $root = Node.new('root')\n $context = $root\n\n file.each_with_index do |line, index|\n process_line(line, index) if line.match(/\\S/)\n end\n\n return $root\n\nend",
"def parse\n @started = false\n\n parser = XMLParser.new(\"UTF-8\")\n def parser.unknownEncoding(e)\n raise \"Unknown encoding #{e.to_s}\"\n end\n def parser.default\n end\n\n begin\n parser.parse(@stream) do |type, name, data|\n begin\n case type\n when XMLParser::START_ELEM\n case name\n when \"stream:stream\"\n openstream = ParsedXMLElement.new(name)\n data.each {|key, value| openstream.add_attribute(key, value)}\n @listener.receive(openstream)\n @started = true\n else\n if @current.nil?\n @current = ParsedXMLElement.new(name.clone)\n else\n @current = @current.add_child(name.clone)\n end\n data.each {|key, value| @current.add_attribute(key.clone, value.clone)}\n end\n when XMLParser::CDATA\n @current.append_data(data.clone) if @current\n when XMLParser::END_ELEM\n case name\n when \"stream:stream\"\n @started = false\n else\n @listener.receive(@current) unless @current.element_parent\n @current = @current.element_parent\n end\n end\n rescue\n puts \"Error #{$!}\"\n end\n end\n rescue XMLParserError\n line = parser.line\n print \"XML Parsing error(#{line}): #{$!}\\n\"\n end\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Retrieves all entity type identifiers related to a given type identifier
|
def get_entity_types_related_to(type_identifier)
Occi::Log.debug("Getting entity type identifiers related to #{type_identifier}")
collection = @model.get type_identifier
collection.kinds.collect { |kind| kind.type_identifier }
end
|
[
"def get_entity_type_identifiers\n get_entity_types_related_to Occi::Core::Entity.kind.type_identifier\n end",
"def types_by_entity_id\n @types_by_entity_id\n end",
"def get_resource_type_identifiers\n get_entity_types_related_to Occi::Core::Resource.kind.type_identifier\n end",
"def retrieve_entity_types()\n start.uri('/api/entity/type')\n .get()\n .go()\n end",
"def get_resource_type_identifiers\n get_entity_types_related_to Occi::Core::Resource.kind.type_identifier\n\n end",
"def id_types\n identifiers.map(&:type).uniq\n end",
"def get_entity_types\n get_types(Occi::Core::Entity.kind)\n end",
"def get_entity_types\n Occi::Log.debug(\"Getting entity types ...\")\n @model.kinds.collect { |kind| kind.term }\n end",
"def entity_types\n self.class.entity_types.flatten.flatten.compact\n end",
"def entities_of_type(type)\n @entities.select { |entity| entity['type'] == type }.map { |entity| Entity.new entity }\n end",
"def index\n @identifier_types = IdentifierType.all\n end",
"def get_link_type_identifiers\n get_entity_types_related_to Occi::Core::Link.kind.type_identifier\n end",
"def identifier_type_facet\n return nil if identifier_type.empty? || with_doi\n q = referenced_klass.joins(:identifiers)\n w = identifier_table[:type].eq_any(identifier_type)\n q.where(w)\n end",
"def all( type )\n SheldonClient::Read.fetch_node_type_ids(type)\n end",
"def list(type)\n get(resource_path_for_entity_type(type) + \"?rows=all\")\n end",
"def get_entity_type_identifier(type)\n get_type_identifier(type, Occi::Core::Entity.kind)\n end",
"def ids(type)\n\n @h[type].keys.sort\n end",
"def ids (type)\n\n @h[type].keys.sort\n end",
"def find_event_types\n event_type_ids = []\n\n # Avoid query build-up if no search text is given:\n if @query_term\n # Search among linked EventTypes:\n event_type_ids = EventType\n .joins(:stroke_type)\n .includes(:stroke_type)\n .find_all do |row|\n (row.i18n_short =~ /#{@query_term}/i) ||\n (row.i18n_compact =~ /#{@query_term}/i) ||\n (row.i18n_description =~ /#{@query_term}/i)\n end.map(&:id).flatten.uniq\n end\n\n # Return the results:\n event_type_ids.uniq\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Retrieves all available entity types.
|
def get_entity_types
Occi::Log.debug("Getting entity types ...")
@model.kinds.collect { |kind| kind.term }
end
|
[
"def retrieve_entity_types()\n start.uri('/api/entity/type')\n .get()\n .go()\n end",
"def get_entity_types\n get_types(Occi::Core::Entity.kind)\n end",
"def entity_types\n self.class.entity_types.flatten.flatten.compact\n end",
"def types_by_entity_id\n @types_by_entity_id\n end",
"def _get_valid_types\n types = Entities::Base.descendants\n end",
"def list(type)\n get(resource_path_for_entity_type(type) + \"?rows=all\")\n end",
"def get_entity_type_identifiers\n get_entity_types_related_to Occi::Core::Entity.kind.type_identifier\n end",
"def default_entity_types(*args)\n Epiphany::Tokenizer::Cache.all_entity_types\n end",
"def get_workspace_entity_types(workspace_namespace, workspace_name)\n path = self.api_root + \"/api/workspaces/#{uri_encode(workspace_namespace)}/#{uri_encode(workspace_name)}/entities\"\n process_firecloud_request(:get, path)\n end",
"def available_types\n gather do |c|\n c.respond_to?(:model_types) ? c.model_types : []\n end\n end",
"def index\n @finnancial_entity_types = FinnancialEntityType.all\n end",
"def get_resource_types\n Occi::Log.debug(\"Getting resource types ...\")\n collection = @model.get Occi::Core::Resource.kind\n collection.kinds.collect { |kind| kind.term }\n end",
"def search_entity_types(request)\n start.uri('/api/entity/type/search')\n .body_handler(FusionAuth::JSONBodyHandler.new(request))\n .post()\n .go()\n end",
"def index\n @type_ents = TypeEnt.all\n end",
"def entity_types=(value)\n @entity_types = value\n end",
"def get_resource_type_identifiers\n get_entity_types_related_to Occi::Core::Resource.kind.type_identifier\n end",
"def get_entity_classes(resource)\n process_query(entity_classes(resource))\n end",
"def get_resource_type_identifiers\n get_entity_types_related_to Occi::Core::Resource.kind.type_identifier\n\n end",
"def get_entity_type(options = {})\n options = argument_cleaner(required_params: %i( entityid ), optional_params: %i( select ), options: options )\n authenticated_get cmd: \"getentitytype\", **options\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Retrieves all available entity type identifiers.
|
def get_entity_type_identifiers
get_entity_types_related_to Occi::Core::Entity.kind.type_identifier
end
|
[
"def retrieve_entity_types()\n start.uri('/api/entity/type')\n .get()\n .go()\n end",
"def get_entity_types\n get_types(Occi::Core::Entity.kind)\n end",
"def get_entity_types\n Occi::Log.debug(\"Getting entity types ...\")\n @model.kinds.collect { |kind| kind.term }\n end",
"def entity_types\n self.class.entity_types.flatten.flatten.compact\n end",
"def types_by_entity_id\n @types_by_entity_id\n end",
"def get_resource_type_identifiers\n get_entity_types_related_to Occi::Core::Resource.kind.type_identifier\n end",
"def get_resource_type_identifiers\n get_entity_types_related_to Occi::Core::Resource.kind.type_identifier\n\n end",
"def get_entity_types_related_to(type_identifier)\n Occi::Log.debug(\"Getting entity type identifiers related to #{type_identifier}\")\n collection = @model.get type_identifier\n collection.kinds.collect { |kind| kind.type_identifier }\n end",
"def list(type)\n get(resource_path_for_entity_type(type) + \"?rows=all\")\n end",
"def index\n @identifier_types = IdentifierType.all\n end",
"def _get_valid_types\n types = Entities::Base.descendants\n end",
"def id_types\n identifiers.map(&:type).uniq\n end",
"def all( type )\n SheldonClient::Read.fetch_node_type_ids(type)\n end",
"def default_entity_types(*args)\n Epiphany::Tokenizer::Cache.all_entity_types\n end",
"def get_link_type_identifiers\n get_entity_types_related_to Occi::Core::Link.kind.type_identifier\n end",
"def entity_types=(value)\n @entity_types = value\n end",
"def get_entity_type(options = {})\n options = argument_cleaner(required_params: %i( entityid ), optional_params: %i( select ), options: options )\n authenticated_get cmd: \"getentitytype\", **options\n end",
"def index\n @type_ents = TypeEnt.all\n end",
"def datatype_ids\n @datatypes.keys\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Retrieves all available resource types.
|
def get_resource_types
Occi::Log.debug("Getting resource types ...")
collection = @model.get Occi::Core::Resource.kind
collection.kinds.collect { |kind| kind.term }
end
|
[
"def get_resource_types\n get_types(Occi::Core::Resource.kind)\n end",
"def list_resource_types(feed = nil)\n if feed.nil?\n ret = http_get('/resourceTypes')\n else\n the_feed = hawk_escape feed\n ret = http_get('/feeds/' + the_feed + '/resourceTypes')\n end\n val = []\n ret.each { |rt| val.push(ResourceType.new(rt)) }\n val\n end",
"def all_of_type\n Resource::AllOfType.new(type)\n end",
"def index\n @type_resources = TypeResource.all\n end",
"def resources_for_type(type)\n resources typeId: type\n end",
"def list_resource_types(feed_id = nil)\n if feed_id.nil?\n ret = http_get('/resourceTypes')\n else\n the_feed = hawk_escape_id feed_id\n ret = http_get(\"/feeds/#{the_feed}/resourceTypes\")\n end\n ret.map { |rt| ResourceType.new(rt) }\n end",
"def resources_by_type(type)\n @resources_by_type[type] || []\n end",
"def index\n @resource_types = ResourceType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @resource_types }\n end\n end",
"def get_resource_type_identifiers\n get_entity_types_related_to Occi::Core::Resource.kind.type_identifier\n end",
"def get_resource_type_identifiers\n get_entity_types_related_to Occi::Core::Resource.kind.type_identifier\n\n end",
"def retrieve_entity_types()\n start.uri('/api/entity/type')\n .get()\n .go()\n end",
"def list_resource_file_types(options={}) path = \"/api/v2/definitions/resourcefiletypes\"\n get(path, options, AvaTax::VERSION) end",
"def available_types\n gather do |c|\n c.respond_to?(:model_types) ? c.model_types : []\n end\n end",
"def types\n get_objects_on(N::RDF.type.to_s)\n end",
"def types\n get(\"/project/types\")[\"types\"]\n end",
"def getresources(name, type=Types.A, klass=Classes.IN)\n ret = []\n each_resource(name, type, klass) {|resource| ret << resource}\n return ret\n end",
"def get_report_types\n \n LOGGER.info \"list all report types\"\n Reports::ReportFactory::REPORT_TYPES.collect{ |t| get_uri(t) }.join(\"\\n\")\n end",
"def list(type)\n get(resource_path_for_entity_type(type) + \"?rows=all\")\n end",
"def all_types\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Retrieves all available resource type identifiers.
|
def get_resource_type_identifiers
get_entity_types_related_to Occi::Core::Resource.kind.type_identifier
end
|
[
"def get_resource_types\n get_types(Occi::Core::Resource.kind)\n end",
"def get_resource_type_identifiers\n get_entity_types_related_to Occi::Core::Resource.kind.type_identifier\n end",
"def get_resource_types\n Occi::Log.debug(\"Getting resource types ...\")\n collection = @model.get Occi::Core::Resource.kind\n collection.kinds.collect { |kind| kind.term }\n end",
"def resources_for_type(type)\n resources typeId: type\n end",
"def list_resource_types(feed = nil)\n if feed.nil?\n ret = http_get('/resourceTypes')\n else\n the_feed = hawk_escape feed\n ret = http_get('/feeds/' + the_feed + '/resourceTypes')\n end\n val = []\n ret.each { |rt| val.push(ResourceType.new(rt)) }\n val\n end",
"def list_resource_types(feed_id = nil)\n if feed_id.nil?\n ret = http_get('/resourceTypes')\n else\n the_feed = hawk_escape_id feed_id\n ret = http_get(\"/feeds/#{the_feed}/resourceTypes\")\n end\n ret.map { |rt| ResourceType.new(rt) }\n end",
"def all_of_type\n Resource::AllOfType.new(type)\n end",
"def retrieve_entity_types()\n start.uri('/api/entity/type')\n .get()\n .go()\n end",
"def id_types\n identifiers.map(&:type).uniq\n end",
"def index\n @type_resources = TypeResource.all\n end",
"def resources_by_type(type)\n @resources_by_type[type] || []\n end",
"def all( type )\n SheldonClient::Read.fetch_node_type_ids(type)\n end",
"def index\n @identifier_types = IdentifierType.all\n end",
"def types\n get_objects_on(N::RDF.type.to_s)\n end",
"def list(type)\n get(resource_path_for_entity_type(type) + \"?rows=all\")\n end",
"def asset_type_ids\n assets.scope.uniq.pluck(:asset_type_id)\n end",
"def index\n @resource_types = ResourceType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @resource_types }\n end\n end",
"def resource_type_filter\n return filter_for(:resource_type_id, \n objects_to_names_and_ids(current_user.company.resource_types),\n session[:resource_filters], _(\"Resource Type\"))\n end",
"def tracked_types\n types = connection.collections - (account[:exclude_resources] || [])\n types.map {|type| type.to_s}\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Retrieves all available link types.
|
def get_link_types
Occi::Log.debug("Getting link types ...")
collection = @model.get Occi::Core::Link.kind
collection.kinds.collect { |kind| kind.term }
end
|
[
"def get_link_types\n get_types(Occi::Core::Link.kind)\n end",
"def get_link_type_identifiers\n get_entity_types_related_to Occi::Core::Link.kind.type_identifier\n end",
"def index\n @code_link_types = CodeLinkType.all\n end",
"def index\n @link_types = LinkType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @link_types }\n end\n end",
"def types\n get_objects_on(N::RDF.type.to_s)\n end",
"def available_types\n gather do |c|\n c.respond_to?(:model_types) ? c.model_types : []\n end\n end",
"def get_resource_types\n Occi::Log.debug(\"Getting resource types ...\")\n collection = @model.get Occi::Core::Resource.kind\n collection.kinds.collect { |kind| kind.term }\n end",
"def list_resource_types(feed = nil)\n if feed.nil?\n ret = http_get('/resourceTypes')\n else\n the_feed = hawk_escape feed\n ret = http_get('/feeds/' + the_feed + '/resourceTypes')\n end\n val = []\n ret.each { |rt| val.push(ResourceType.new(rt)) }\n val\n end",
"def all_types\n end",
"def get_report_types\n \n LOGGER.info \"list all report types\"\n Reports::ReportFactory::REPORT_TYPES.collect{ |t| get_uri(t) }.join(\"\\n\")\n end",
"def types\n types = JSON.parse(connection.get(\"/Contact/Types\").body )\n end",
"def get_lesson_types\n get \"lessonTypes.json\"\n end",
"def list_resource_types(feed_id = nil)\n if feed_id.nil?\n ret = http_get('/resourceTypes')\n else\n the_feed = hawk_escape_id feed_id\n ret = http_get(\"/feeds/#{the_feed}/resourceTypes\")\n end\n ret.map { |rt| ResourceType.new(rt) }\n end",
"def media_types\n self.class.get('/media-types', @options)\n end",
"def download_types\n downloads_by_format\n end",
"def print_types\n list = list_types\n\n puts 'The available types are:'\n puts list\n end",
"def retrieve_entity_types()\n start.uri('/api/entity/type')\n .get()\n .go()\n end",
"def payment_types\n url = \"#{@url}reference/payment-types\"\n make_request(url)\n end",
"def all_activity_types(**args)\n params = parameters(args) do\n optional_params\n end\n request(:get, 'activityTypes', params)\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Retrieves all available link type identifiers.
|
def get_link_type_identifiers
get_entity_types_related_to Occi::Core::Link.kind.type_identifier
end
|
[
"def get_link_types\n get_types(Occi::Core::Link.kind)\n end",
"def get_link_types\n Occi::Log.debug(\"Getting link types ...\")\n collection = @model.get Occi::Core::Link.kind\n collection.kinds.collect { |kind| kind.term }\n end",
"def index\n @code_link_types = CodeLinkType.all\n end",
"def all( type )\n SheldonClient::Read.fetch_node_type_ids(type)\n end",
"def id_types\n identifiers.map(&:type).uniq\n end",
"def index\n @identifier_types = IdentifierType.all\n end",
"def types\n get_objects_on(N::RDF.type.to_s)\n end",
"def get_resource_type_identifiers\n get_entity_types_related_to Occi::Core::Resource.kind.type_identifier\n end",
"def get_resource_type_identifiers\n get_entity_types_related_to Occi::Core::Resource.kind.type_identifier\n\n end",
"def ref_types\n response = request(:eve, :ref_types)\n result = {}\n response.ref_types.each do |row|\n result[row.ref_type_id] = row.ref_type_name\n end\n result\n end",
"def retrieve_entity_types()\n start.uri('/api/entity/type')\n .get()\n .go()\n end",
"def get_link_type_identifier(type)\n get_type_identifier(type, Occi::Core::Link.kind)\n end",
"def ids (type)\n\n @h[type].keys.sort\n end",
"def ids(type)\n\n @h[type].keys.sort\n end",
"def type_names\n return @types.keys\n end",
"def all_types\n end",
"def index\n @link_types = LinkType.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @link_types }\n end\n end",
"def index\n @referral_types = ReferralType.root.ordered\n end",
"def get_resource_types\n Occi::Log.debug(\"Getting resource types ...\")\n collection = @model.get Occi::Core::Resource.kind\n collection.kinds.collect { |kind| kind.term }\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Looks up a mixin using its name and, optionally, a type as well. Will return mixin's full location (a link) or a description.
|
def find_mixin(name, type = nil, describe = false)
Occi::Log.debug("Looking for mixin #{name} + #{type} + #{describe}")
# is type valid?
if type
raise "Unknown mixin type! [#{type}]" unless @mixins.has_key? type.to_sym
end
# TODO: extend this code to support multiple matches and regex filters
# should we look for links or descriptions?
if describe
# we are looking for descriptions
if type
# get the first match from either os_tpls or resource_tpls
case
when type == "os_tpl"
get_os_templates.select { |mixin| mixin.term == name }.first
when type == "resource_tpl"
get_resource_templates.select { |template| template.term == name }.first
else
nil
end
else
# try in os_tpls first
found = get_os_templates.select { |os| os.term == name }.first
# then try in resource_tpls
found = get_resource_templates.select {
|template| template.term == name
}.first unless found
found
end
else
# we are looking for links
# prefix mixin name with '#' to simplify the search
name = "#" + name
if type
# return the first match with the selected type
@mixins[type.to_sym].select {
|mixin| mixin.to_s.reverse.start_with? name.reverse
}.first
else
# there is no type preference, return first global match
@mixins.flatten(2).select {
|mixin| mixin.to_s.reverse.start_with? name.reverse
}.first
end
end
end
|
[
"def find_mixin(name, type = nil, describe = false)\n\n Occi::Log.debug(\"Looking for mixin #{name} + #{type} + #{describe}\")\n\n # is type valid?\n if type\n raise \"Unknown mixin type! [#{type}]\" unless @mixins.has_key? type.to_sym\n end\n\n # TODO: extend this code to support multiple matches and regex filters\n # should we look for links or descriptions?\n if describe\n # we are looking for descriptions\n if type\n # get the first match from either os_tpls or resource_tpls\n case\n when type == \"os_tpl\"\n get_os_templates.select { |mixin| mixin.term == name }.first\n when type == \"resource_tpl\"\n get_resource_templates.select { |template| template.term == name }.first\n else\n nil\n end\n else\n # try in os_tpls first\n found = get_os_templates.select { |os| os.term == name }.first\n\n # then try in resource_tpls\n found = get_resource_templates.select {\n |template| template.term == name\n }.first unless found\n\n found\n end\n else\n # we are looking for links\n # prefix mixin name with '#' to simplify the search\n name = \"#\" + name\n if type\n # return the first match with the selected type\n @mixins[type.to_sym].select {\n |mixin| mixin.to_s.reverse.start_with? name.reverse\n }.first\n else\n # there is no type preference, return first global match\n @mixins.flatten(2).select {\n |mixin| mixin.to_s.reverse.start_with? name.reverse\n }.first\n end\n end\n end",
"def find_mixin(name, type = nil, describe = false)\n Occi::Log.debug(\"Looking for mixin #{name} + #{type} + #{describe}\")\n raise \"Unknown mixin type! [#{type}]\" if type && !@mixins.has_key?(type.to_sym)\n\n # TODO: extend this code to support multiple matches and regex filters\n # should we look for links or descriptions?\n describe ? describe_mixin(name, type) : list_mixin(name, type)\n end",
"def describe_mixin(name, type = nil)\n mixins = get_mixins(type)\n\n mixins = mixins.to_a.select { |m| m.term == name }\n mixins.any? ? mixins.first : nil\n end",
"def lookup_mixin(name)\n @mixins.fetch(name.to_s) { |k| @parent ? @parent.lookup_mixin(k) : nil }\n end",
"def get_mixin_type_identifier(type)\n return type if (type =~ URI::ABS_URI) || (type && type.start_with?('/'))\n\n mixins = @model.mixins.to_a.select { |m| m.term == type }\n tis = mixins.collect { |m| m.type_identifier }\n tis.uniq!\n\n if tis.length > 1\n raise Occi::Api::Client::Errors::AmbiguousNameError,\n \"Mixin type #{type.inspect} is ambiguous, use a type identifier!\"\n end\n\n tis.first\n end",
"def resolve_mixin name\n return @mixins[name] if @mixins[name]\n return @parent.resolve_mixin(name) if @parent\n return nil\n end",
"def resolve_standard_mixin(name)\n @mixin_lookup.lookup(name)\n end",
"def get_mixins(type = nil)\n if type\n # is type valid?\n raise \"Unknown mixin type! #{type}\" unless @mixins.has_key? type.to_sym\n @mixins[type.to_sym]\n else\n # we did not get a type, return all mixins\n mixins = []\n get_mixin_types.each { |ltype| mixins.concat @mixins[ltype.to_sym] }\n mixins\n end\n end",
"def get_mixins(type = nil)\n if type\n # is type valid?\n raise \"Unknown mixin type! #{type}\" unless @mixins.has_key? type.to_sym\n\n # return mixin of the selected type\n @mixins[type.to_sym]\n else\n # we did not get a type, return all mixins\n mixins = []\n\n # flatten the hash and remove its keys\n get_mixin_types.each do |ltype|\n mixins.concat @mixins[ltype.to_sym]\n end\n\n mixins\n end\n end",
"def update_mixin_from_model(mixin, model)\n return if mixin.blank?\n\n if mixin.kind_of? String\n # it's just an identifier\n model.get_by_id(mixin)\n elsif mixin.kind_of?(::Occi::Core::Mixin)\n # it's already a mix-in\n orig_mixin = model.get_by_id(mixin.type_identifier)\n if orig_mixin\n mixin.location = orig_mixin.location\n mixin.title = orig_mixin.title if mixin.title.blank?\n end\n\n mixin\n else\n # nothing we can do here\n nil\n end\n end",
"def is_mixin?\n type == :mixin\n end",
"def default_mixin_lookup\n ModuleLookup.new.add_path(\"toys/standard_mixins\")\n end",
"def add(type, mixin)\n for_type(type).add(mixin)\n end",
"def get_mixin_type_identifiers\n list_mixins(nil)\n end",
"def mixin!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 23 )\n\n type = MIXIN\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 161:9: 'mixin'\n match( \"mixin\" )\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__, 23 )\n\n end",
"def mixin!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 28 )\n\n type = MIXIN\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 162:9: 'mixin'\n match( \"mixin\" )\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__, 28 )\n\n end",
"def get_mixins_ary(mixin_type)\n mixins = []\n\n send(\"get_#{mixin_type.to_s}s\".to_sym).each do |mixin|\n next if mixin.nil? || mixin.type_identifier.nil?\n\n tid = mixin.type_identifier.strip\n mixins << tid unless tid.empty?\n end\n\n mixins\n end",
"def get_mixins(type = nil, include_self = false)\n unless type.blank?\n type_id = get_mixin_type_identifier(type)\n unless type_id\n raise ArgumentError,\n \"There is no such mixin type registered in the model! #{type.inspect}\"\n end\n\n mixins = @model.mixins.to_a.select { |m| m.related_to?(type_id) }\n\n # drop the type mixin itself\n mixins.delete_if { |m| m.type_identifier == type_id } unless include_self\n else\n # we did not get a type, return all mixins\n mixins = Occi::Core::Mixins.new(@model.mixins)\n end\n\n unless mixins.kind_of? Occi::Core::Mixins\n col = Occi::Core::Mixins.new\n mixins.each { |m| col << m }\n else\n col = mixins\n end\n\n col\n end",
"def add_mixin(name, mixin_module = nil, &block)\n name = name.to_s\n if @mixins.key?(name)\n raise ToolDefinitionError,\n \"A mixin named #{name.inspect} has already been defined in tool\" \\\n \" #{display_name.inspect}.\"\n end\n @mixins[name] = mixin_module || Mixin.create(&block)\n self\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Retrieves available mixins of a specified type or all available mixins if the type wasn't specified. Mixins are returned in the form of mixin identifiers.
|
def get_mixins(type = nil)
if type
# is type valid?
raise "Unknown mixin type! #{type}" unless @mixins.has_key? type.to_sym
# return mixin of the selected type
@mixins[type.to_sym]
else
# we did not get a type, return all mixins
mixins = []
# flatten the hash and remove its keys
get_mixin_types.each do |ltype|
mixins.concat @mixins[ltype.to_sym]
end
mixins
end
end
|
[
"def get_mixins(type = nil)\n if type\n # is type valid?\n raise \"Unknown mixin type! #{type}\" unless @mixins.has_key? type.to_sym\n @mixins[type.to_sym]\n else\n # we did not get a type, return all mixins\n mixins = []\n get_mixin_types.each { |ltype| mixins.concat @mixins[ltype.to_sym] }\n mixins\n end\n end",
"def get_mixins(type = nil, include_self = false)\n unless type.blank?\n type_id = get_mixin_type_identifier(type)\n unless type_id\n raise ArgumentError,\n \"There is no such mixin type registered in the model! #{type.inspect}\"\n end\n\n mixins = @model.mixins.to_a.select { |m| m.related_to?(type_id) }\n\n # drop the type mixin itself\n mixins.delete_if { |m| m.type_identifier == type_id } unless include_self\n else\n # we did not get a type, return all mixins\n mixins = Occi::Core::Mixins.new(@model.mixins)\n end\n\n unless mixins.kind_of? Occi::Core::Mixins\n col = Occi::Core::Mixins.new\n mixins.each { |m| col << m }\n else\n col = mixins\n end\n\n col\n end",
"def get_mixins_ary(mixin_type)\n mixins = []\n\n send(\"get_#{mixin_type.to_s}s\".to_sym).each do |mixin|\n next if mixin.nil? || mixin.type_identifier.nil?\n\n tid = mixin.type_identifier.strip\n mixins << tid unless tid.empty?\n end\n\n mixins\n end",
"def get_mixin_types\n get_mixins.to_a.collect { |m| m.term }\n end",
"def describe_mixin(name, type = nil)\n mixins = get_mixins(type)\n\n mixins = mixins.to_a.select { |m| m.term == name }\n mixins.any? ? mixins.first : nil\n end",
"def get_mixin_type_identifiers\n list_mixins(nil)\n end",
"def mixins\n select { |e| e.is_a?(Mixin) }\n end",
"def find_mixin(name, type = nil, describe = false)\n\n Occi::Log.debug(\"Looking for mixin #{name} + #{type} + #{describe}\")\n\n # is type valid?\n if type\n raise \"Unknown mixin type! [#{type}]\" unless @mixins.has_key? type.to_sym\n end\n\n # TODO: extend this code to support multiple matches and regex filters\n # should we look for links or descriptions?\n if describe\n # we are looking for descriptions\n if type\n # get the first match from either os_tpls or resource_tpls\n case\n when type == \"os_tpl\"\n get_os_templates.select { |mixin| mixin.term == name }.first\n when type == \"resource_tpl\"\n get_resource_templates.select { |template| template.term == name }.first\n else\n nil\n end\n else\n # try in os_tpls first\n found = get_os_templates.select { |os| os.term == name }.first\n\n # then try in resource_tpls\n found = get_resource_templates.select {\n |template| template.term == name\n }.first unless found\n\n found\n end\n else\n # we are looking for links\n # prefix mixin name with '#' to simplify the search\n name = \"#\" + name\n if type\n # return the first match with the selected type\n @mixins[type.to_sym].select {\n |mixin| mixin.to_s.reverse.start_with? name.reverse\n }.first\n else\n # there is no type preference, return first global match\n @mixins.flatten(2).select {\n |mixin| mixin.to_s.reverse.start_with? name.reverse\n }.first\n end\n end\n end",
"def find_mixin(name, type = nil, describe = false)\n\n Occi::Log.debug(\"Looking for mixin #{name} + #{type} + #{describe}\")\n\n # is type valid?\n if type\n raise \"Unknown mixin type! [#{type}]\" unless @mixins.has_key? type.to_sym\n end\n\n # TODO: extend this code to support multiple matches and regex filters\n # should we look for links or descriptions?\n if describe\n # we are looking for descriptions\n if type\n # get the first match from either os_tpls or resource_tpls\n case\n when type == \"os_tpl\"\n get_os_templates.select { |mixin| mixin.term == name }.first\n when type == \"resource_tpl\"\n get_resource_templates.select { |template| template.term == name }.first\n else\n nil\n end\n else\n # try in os_tpls first\n found = get_os_templates.select { |os| os.term == name }.first\n\n # then try in resource_tpls\n found = get_resource_templates.select {\n |template| template.term == name\n }.first unless found\n\n found\n end\n else\n # we are looking for links\n # prefix mixin name with '#' to simplify the search\n name = \"#\" + name\n if type\n # return the first match with the selected type\n @mixins[type.to_sym].select {\n |mixin| mixin.to_s.reverse.start_with? name.reverse\n }.first\n else\n # there is no type preference, return first global match\n @mixins.flatten(2).select {\n |mixin| mixin.to_s.reverse.start_with? name.reverse\n }.first\n end\n end\n end",
"def get_mixin_type_identifier(type)\n return type if (type =~ URI::ABS_URI) || (type && type.start_with?('/'))\n\n mixins = @model.mixins.to_a.select { |m| m.term == type }\n tis = mixins.collect { |m| m.type_identifier }\n tis.uniq!\n\n if tis.length > 1\n raise Occi::Api::Client::Errors::AmbiguousNameError,\n \"Mixin type #{type.inspect} is ambiguous, use a type identifier!\"\n end\n\n tis.first\n end",
"def get_mixin_types\n @mixins.keys.map { |k| k.to_s }\n end",
"def find_mixin(name, type = nil, describe = false)\n Occi::Log.debug(\"Looking for mixin #{name} + #{type} + #{describe}\")\n raise \"Unknown mixin type! [#{type}]\" if type && !@mixins.has_key?(type.to_sym)\n\n # TODO: extend this code to support multiple matches and regex filters\n # should we look for links or descriptions?\n describe ? describe_mixin(name, type) : list_mixin(name, type)\n end",
"def get_resource_tpl_mixins_ary\n mixins = get_resource_tpls\n mixins.to_a.collect { |m| m.type_identifier }\n end",
"def mixins(*scopes)\n return class_mixins if scopes == [:class]\n return instance_mixins if scopes == [:instance]\n class_mixins | instance_mixins\n end",
"def mixins\n typed_set(categories, Occi::Core::Mixin)\n end",
"def get_os_tpl_mixins_ary\n mixins = get_os_tpls\n mixins.to_a.collect { |m| m.type_identifier }\n end",
"def all(type = nil)\n list = []\n @plugins.each do |plugin|\n list << plugin if plugin.superclass == type or type.nil?\n end\n return list\n end",
"def index\n @mixins = Mixin.all\n end",
"def is_mixin?\n type == :mixin\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Retrieves available mixin types. Mixin types are presented in a shortened format (i.e. not as type identifiers).
|
def get_mixin_types
@mixins.keys.map { |k| k.to_s }
end
|
[
"def get_mixin_types\n get_mixins.to_a.collect { |m| m.term }\n end",
"def get_mixin_type_identifiers\n list_mixins(nil)\n end",
"def get_mixins(type = nil)\n if type\n # is type valid?\n raise \"Unknown mixin type! #{type}\" unless @mixins.has_key? type.to_sym\n @mixins[type.to_sym]\n else\n # we did not get a type, return all mixins\n mixins = []\n get_mixin_types.each { |ltype| mixins.concat @mixins[ltype.to_sym] }\n mixins\n end\n end",
"def get_mixins(type = nil)\n if type\n # is type valid?\n raise \"Unknown mixin type! #{type}\" unless @mixins.has_key? type.to_sym\n\n # return mixin of the selected type\n @mixins[type.to_sym]\n else\n # we did not get a type, return all mixins\n mixins = []\n\n # flatten the hash and remove its keys\n get_mixin_types.each do |ltype|\n mixins.concat @mixins[ltype.to_sym]\n end\n\n mixins\n end\n end",
"def get_mixins_ary(mixin_type)\n mixins = []\n\n send(\"get_#{mixin_type.to_s}s\".to_sym).each do |mixin|\n next if mixin.nil? || mixin.type_identifier.nil?\n\n tid = mixin.type_identifier.strip\n mixins << tid unless tid.empty?\n end\n\n mixins\n end",
"def get_mixin_type_identifiers\n identifiers = []\n\n get_mixin_types.each do |mixin_type|\n identifiers << 'http://schemas.ogf.org/occi/infrastructure#' + mixin_type\n end\n\n identifiers\n end",
"def get_mixins(type = nil, include_self = false)\n unless type.blank?\n type_id = get_mixin_type_identifier(type)\n unless type_id\n raise ArgumentError,\n \"There is no such mixin type registered in the model! #{type.inspect}\"\n end\n\n mixins = @model.mixins.to_a.select { |m| m.related_to?(type_id) }\n\n # drop the type mixin itself\n mixins.delete_if { |m| m.type_identifier == type_id } unless include_self\n else\n # we did not get a type, return all mixins\n mixins = Occi::Core::Mixins.new(@model.mixins)\n end\n\n unless mixins.kind_of? Occi::Core::Mixins\n col = Occi::Core::Mixins.new\n mixins.each { |m| col << m }\n else\n col = mixins\n end\n\n col\n end",
"def describe_mixin(name, type = nil)\n mixins = get_mixins(type)\n\n mixins = mixins.to_a.select { |m| m.term == name }\n mixins.any? ? mixins.first : nil\n end",
"def mixins\n select { |e| e.is_a?(Mixin) }\n end",
"def get_os_tpl_mixins_ary\n mixins = get_os_tpls\n mixins.to_a.collect { |m| m.type_identifier }\n end",
"def get_resource_tpl_mixins_ary\n mixins = get_resource_tpls\n mixins.to_a.collect { |m| m.type_identifier }\n end",
"def get_mixin_type_identifier(type)\n return type if (type =~ URI::ABS_URI) || (type && type.start_with?('/'))\n\n mixins = @model.mixins.to_a.select { |m| m.term == type }\n tis = mixins.collect { |m| m.type_identifier }\n tis.uniq!\n\n if tis.length > 1\n raise Occi::Api::Client::Errors::AmbiguousNameError,\n \"Mixin type #{type.inspect} is ambiguous, use a type identifier!\"\n end\n\n tis.first\n end",
"def mixins\n typed_set(categories, Occi::Core::Mixin)\n end",
"def is_mixin?\n type == :mixin\n end",
"def getTypesPlugins\n return get_plugins_descriptions('Type')\n end",
"def find_mixin(name, type = nil, describe = false)\n\n Occi::Log.debug(\"Looking for mixin #{name} + #{type} + #{describe}\")\n\n # is type valid?\n if type\n raise \"Unknown mixin type! [#{type}]\" unless @mixins.has_key? type.to_sym\n end\n\n # TODO: extend this code to support multiple matches and regex filters\n # should we look for links or descriptions?\n if describe\n # we are looking for descriptions\n if type\n # get the first match from either os_tpls or resource_tpls\n case\n when type == \"os_tpl\"\n get_os_templates.select { |mixin| mixin.term == name }.first\n when type == \"resource_tpl\"\n get_resource_templates.select { |template| template.term == name }.first\n else\n nil\n end\n else\n # try in os_tpls first\n found = get_os_templates.select { |os| os.term == name }.first\n\n # then try in resource_tpls\n found = get_resource_templates.select {\n |template| template.term == name\n }.first unless found\n\n found\n end\n else\n # we are looking for links\n # prefix mixin name with '#' to simplify the search\n name = \"#\" + name\n if type\n # return the first match with the selected type\n @mixins[type.to_sym].select {\n |mixin| mixin.to_s.reverse.start_with? name.reverse\n }.first\n else\n # there is no type preference, return first global match\n @mixins.flatten(2).select {\n |mixin| mixin.to_s.reverse.start_with? name.reverse\n }.first\n end\n end\n end",
"def find_mixin(name, type = nil, describe = false)\n Occi::Log.debug(\"Looking for mixin #{name} + #{type} + #{describe}\")\n raise \"Unknown mixin type! [#{type}]\" if type && !@mixins.has_key?(type.to_sym)\n\n # TODO: extend this code to support multiple matches and regex filters\n # should we look for links or descriptions?\n describe ? describe_mixin(name, type) : list_mixin(name, type)\n end",
"def find_mixin(name, type = nil, describe = false)\n\n Occi::Log.debug(\"Looking for mixin #{name} + #{type} + #{describe}\")\n\n # is type valid?\n if type\n raise \"Unknown mixin type! [#{type}]\" unless @mixins.has_key? type.to_sym\n end\n\n # TODO: extend this code to support multiple matches and regex filters\n # should we look for links or descriptions?\n if describe\n # we are looking for descriptions\n if type\n # get the first match from either os_tpls or resource_tpls\n case\n when type == \"os_tpl\"\n get_os_templates.select { |mixin| mixin.term == name }.first\n when type == \"resource_tpl\"\n get_resource_templates.select { |template| template.term == name }.first\n else\n nil\n end\n else\n # try in os_tpls first\n found = get_os_templates.select { |os| os.term == name }.first\n\n # then try in resource_tpls\n found = get_resource_templates.select {\n |template| template.term == name\n }.first unless found\n\n found\n end\n else\n # we are looking for links\n # prefix mixin name with '#' to simplify the search\n name = \"#\" + name\n if type\n # return the first match with the selected type\n @mixins[type.to_sym].select {\n |mixin| mixin.to_s.reverse.start_with? name.reverse\n }.first\n else\n # there is no type preference, return first global match\n @mixins.flatten(2).select {\n |mixin| mixin.to_s.reverse.start_with? name.reverse\n }.first\n end\n end\n end",
"def cmdSkinTypesGetList\n params = {\n \"skin_types_get_list\" => \"\",\n \"app_version\" => @config[\"version\"],\n }\n response = @client.request(params, @sid, true, false)\n serializer = Serializer.new(response)\n return serializer.parseSkinTypes\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Retrieves available mixin type identifiers.
|
def get_mixin_type_identifiers
identifiers = []
get_mixin_types.each do |mixin_type|
identifiers << 'http://schemas.ogf.org/occi/infrastructure#' + mixin_type
end
identifiers
end
|
[
"def get_mixin_type_identifiers\n list_mixins(nil)\n end",
"def get_mixin_types\n @mixins.keys.map { |k| k.to_s }\n end",
"def get_mixin_types\n get_mixins.to_a.collect { |m| m.term }\n end",
"def get_mixins_ary(mixin_type)\n mixins = []\n\n send(\"get_#{mixin_type.to_s}s\".to_sym).each do |mixin|\n next if mixin.nil? || mixin.type_identifier.nil?\n\n tid = mixin.type_identifier.strip\n mixins << tid unless tid.empty?\n end\n\n mixins\n end",
"def get_os_tpl_mixins_ary\n mixins = get_os_tpls\n mixins.to_a.collect { |m| m.type_identifier }\n end",
"def get_resource_tpl_mixins_ary\n mixins = get_resource_tpls\n mixins.to_a.collect { |m| m.type_identifier }\n end",
"def get_mixins(type = nil)\n if type\n # is type valid?\n raise \"Unknown mixin type! #{type}\" unless @mixins.has_key? type.to_sym\n @mixins[type.to_sym]\n else\n # we did not get a type, return all mixins\n mixins = []\n get_mixin_types.each { |ltype| mixins.concat @mixins[ltype.to_sym] }\n mixins\n end\n end",
"def get_mixins(type = nil)\n if type\n # is type valid?\n raise \"Unknown mixin type! #{type}\" unless @mixins.has_key? type.to_sym\n\n # return mixin of the selected type\n @mixins[type.to_sym]\n else\n # we did not get a type, return all mixins\n mixins = []\n\n # flatten the hash and remove its keys\n get_mixin_types.each do |ltype|\n mixins.concat @mixins[ltype.to_sym]\n end\n\n mixins\n end\n end",
"def mixins\n select { |e| e.is_a?(Mixin) }\n end",
"def get_mixin_type_identifier(type)\n return type if (type =~ URI::ABS_URI) || (type && type.start_with?('/'))\n\n mixins = @model.mixins.to_a.select { |m| m.term == type }\n tis = mixins.collect { |m| m.type_identifier }\n tis.uniq!\n\n if tis.length > 1\n raise Occi::Api::Client::Errors::AmbiguousNameError,\n \"Mixin type #{type.inspect} is ambiguous, use a type identifier!\"\n end\n\n tis.first\n end",
"def get_mixins(type = nil, include_self = false)\n unless type.blank?\n type_id = get_mixin_type_identifier(type)\n unless type_id\n raise ArgumentError,\n \"There is no such mixin type registered in the model! #{type.inspect}\"\n end\n\n mixins = @model.mixins.to_a.select { |m| m.related_to?(type_id) }\n\n # drop the type mixin itself\n mixins.delete_if { |m| m.type_identifier == type_id } unless include_self\n else\n # we did not get a type, return all mixins\n mixins = Occi::Core::Mixins.new(@model.mixins)\n end\n\n unless mixins.kind_of? Occi::Core::Mixins\n col = Occi::Core::Mixins.new\n mixins.each { |m| col << m }\n else\n col = mixins\n end\n\n col\n end",
"def describe_mixin(name, type = nil)\n mixins = get_mixins(type)\n\n mixins = mixins.to_a.select { |m| m.term == name }\n mixins.any? ? mixins.first : nil\n end",
"def mixins\n typed_set(categories, Occi::Core::Mixin)\n end",
"def index\n @mixins = Mixin.all\n end",
"def registered_types\n end",
"def id_types\n identifiers.map(&:type).uniq\n end",
"def type_names\n return @types.keys\n end",
"def is_mixin?\n type == :mixin\n end",
"def known_types\n known.keys\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Retrieves descriptions for available resources specified by a type identifier or resource location. If no type identifier or location is specified, all available resources in all available resource types will be described.
|
def describe(resource_type_identifier=nil)
# convert type to type identifier
resource_type_identifier = @model.kinds.select {
|kind| kind.term == resource_type_identifier
}.first.type_identifier if @model.kinds.select {
|kind| kind.term == resource_type_identifier
}.any?
# check some basic pre-conditions
raise "Endpoint is not connected!" unless @connected
descriptions = []
if resource_type_identifier.nil?
descriptions << get('/')
elsif @model.get_by_id resource_type_identifier
# we got type identifier
# get all available resources of this type
locations = list resource_type_identifier
# make the requests
locations.each do |location|
descriptions << get(sanitize_resource_link(location))
end
elsif resource_type_identifier.start_with?(@endpoint) || resource_type_identifier.start_with?('/')
# we got resource link
# make the request
descriptions << get(sanitize_resource_link(resource_type_identifier))
else
raise "Unkown resource type identifier! [#{resource_type_identifier}]"
end
descriptions
end
|
[
"def describe(resource_type_identifier=nil); end",
"def find_all_resources(resource_descr, resource_type, authorizer)\n debug \"find_resources: descr: '#{resource_descr.inspect}'\"\n if resource_descr.kind_of? Hash\n can_handle = eval(\"OMF::SFA::Model::#{resource_type.classify}\").respond_to? :handle_rest_get_resource\n if can_handle\n cls = eval(\"OMF::SFA::Model::#{resource_type.classify}\")\n resources = cls.handle_rest_get_resource(resource_descr)\n else\n resources = eval(\"OMF::SFA::Model::#{resource_type.classify}\").where(resource_descr)\n end\n else\n raise FormatException.new \"Unknown resource description type '#{resource_descr.class}' (#{resource_descr})\"\n end\n\n # raise UnknownResourceException.new \"Resource '#{resource_descr.inspect}' is not available or doesn't exist\" if resources.nil? || resources.empty?\n raise UnknownResourceException.new \"Resource '#{resource_descr.inspect}' is not available or doesn't exist\" if resources.nil?\n\n resources.map do |r|\n begin\n raise InsufficientPrivilegesException unless authorizer.can_view_resource?(r)\n r\n rescue InsufficientPrivilegesException\n nil\n end\n end.compact\n end",
"def resources_for_type(type)\n resources typeId: type\n end",
"def resources_by_type(type)\n @resources_by_type[type] || []\n end",
"def resource_type_description\n @resource_type_description ||= resource_type_descriptions\n end",
"def resources_of_type(type, graph)\n graph.query([nil, RDF.type, type])\n .lazy\n .map { |rdf_statement|\n describe(rdf_statement.subject, graph)\n }\n end",
"def descriptive_resources\n find_related_frbr_objects( :is_described_by, :which_resources?) \n end",
"def resources_of_type(type, graph)\n graph.query([nil, ::RDF.type, type])\n .lazy\n .map { |rdf_statement|\n describe(rdf_statement.subject, graph)\n }\n end",
"def get_resource_types\n Occi::Log.debug(\"Getting resource types ...\")\n collection = @model.get Occi::Core::Resource.kind\n collection.kinds.collect { |kind| kind.term }\n end",
"def get_resource_types\n get_types(Occi::Core::Resource.kind)\n end",
"def find_associated_resources(resource_descr, resource_type, target_type, authorizer)\n debug \"find_associated_resources: descr: '#{resource_descr.inspect}'\"\n source_resource = nil\n target_resources = nil\n if resource_descr.kind_of? OMF::SFA::Model::Resource\n source_resource = resource_descr\n elsif resource_descr.kind_of? Hash\n model = eval(\"OMF::SFA::Model::#{resource_type.camelize}\")\n if resource_descr[:or]\n source_resource = nil\n resource_descr[:or].keys.each do |key|\n if source_resource.nil?\n source_resource = model.where({key => resource_descr[:or][key]})\n else\n source_resource = source_resource.or({key => resource_descr[:or][key]})\n end\n end\n else\n source_resource = model.where(resource_descr)\n end\n source_resource = source_resource.first\n if source_resource.kind_of? OMF::SFA::Model::Account and target_type.to_s.pluralize == 'leases'\n target_resources = []\n source_resource.resources.each { |res|\n if res.resource_type == 'lease'\n target_resources << res\n end\n }\n elsif !source_resource.nil? and source_resource.class.method_defined?(target_type)\n target_resources = source_resource.send(target_type)\n else\n raise OMF::SFA::AM::Rest::BadRequestException.new \"Invalid URL.\"\n end\n else\n raise FormatException.new \"Unknown resource description type '#{resource_descr.class}' (#{resource_descr})\"\n end\n unless source_resource\n raise UnknownResourceException.new \"Resource '#{resource_descr.inspect}' is not available or doesn't exist\"\n end\n raise InsufficientPrivilegesException unless authorizer.can_view_resource?(source_resource)\n return source_resource, target_resources\n end",
"def list_location_descriptions # :nologin:\n query = create_query(:LocationDescription, :all, :by => :name)\n show_selected_location_descriptions(query)\n end",
"def type_description(type, description)\n request.get(\"/#{type}/#{description}\")\n end",
"def get_resources\n routes_doc = get_routes_doc\n resources_names = routes_doc.get_resources_names - resources_black_list\n\n resources_names.map do |resource|\n puts \"Generating #{resource} documentation...\" if trace?\n ResourceDoc.new( resource, routes_doc.get_actions_route_info( resource ) )\n end\n end",
"def catalog_resources(io)\n if block_given?\n YAML.load(io).ivars[\"resource_table\"].each_value do |resource|\n if resource.ivars[\"reference\"]\n yield resource.ivars[\"reference\"], resource.ivars[\"parameters\"]\n else\n yield \"#{resource.ivars[\"type\"]}[#{resource.ivars[\"title\"]}]\", resource.ivars[\"parameters\"]\n end\n end\n else\n hash = {}\n catalog_resources io, &hash.method(:[]=)\n hash\n end\n end",
"def get_fhir_resources(fhir_client, type, resource_id, patient_id = nil)\n if patient_id == nil\n search = { parameters: { _id: resource_id } }\n else\n search = { parameters: { _id: resource_id, patient: patient_id } }\n end\n results = fhir_client.search(type, search: search)\n results.resource.entry.map(&:resource)\n end",
"def query_resources\n powershell_exec(\"get-dscresource\").result\n end",
"def list(type)\n get(resource_path_for_entity_type(type) + \"?rows=all\")\n end",
"def entries_for(resource_type, opts={})\n with_hidden = opts[:hidden] || :none\n\n language = opts[:language] || preferred_language\n platform = opts[:platform] || preferred_platform\n mode = (opts[:build_mode] || build_mode).to_sym\n manifest = manifest_for(language, mode, platform)\n\n ret = manifest.entries_for(resource_type)\n\n case with_hidden\n when :none\n ret = ret.reject { |x| x.hidden }\n when :only\n ret = ret.reject { |x| !x.hidden }\n end\n return ret\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Deploys a compute resource based on an OVF/OVA descriptor available on a local file system.
|
def deploy(location)
media_types = self.class.head(@endpoint).headers['accept'].to_s
raise "File #{location} does not exist" unless File.exist? location
file = File.read(location)
if location.include? '.ovf'
if media_types.include? 'application/ovf'
headers = self.class.headers.clone
headers['Content-Type'] = 'application/ovf'
self.class.post(@endpoint + '/compute/',
:body => file,
:headers => headers)
end
elsif location.include? '.ova'
if media_types.include? ' application/ova '
headers = self.class.headers.clone
headers['Content-Type'] = 'application/ova'
self.class.post(@endpoint + '/compute/',
:body => file,
:headers => headers)
end
end
end
|
[
"def deploy_ovf(descriptor); end",
"def deploy_ova(descriptor); end",
"def add_file(filename)\n cookbook_file '/var/opt/dynatrace-managed/sources/' + filename do\n source '' + filename\n owner node['dynatrace-quickstart-gcp']['user']\n group node['dynatrace-quickstart-gcp']['user']\n mode '644'\n action :create\n end\nend",
"def save\n file = Chef::Resource::File.new(hostsfile_path, node.run_context)\n file.content(new_content)\n file.atomic_update false if docker_guest?\n file.run_action(:create)\n end",
"def tf_action(provision, action, tf = {})\n Terraform.p_load\n\n provider = provision.provider\n terraform = Terraform.singleton(provider, tf)\n\n terraform.generate_deployment_file(provision)\n terraform.send(action, provision)\n end",
"def install_custom!\n remote_file local_path do\n source new_resource.source.to_s\n checksum new_resource.checksum unless new_resource.checksum.nil?\n end\n dpkg_package local_path\n end",
"def create\n mkfs\n @property_hash[:ensure] = :present\n @property_hash[:uuid] = uuid\n resource\n end",
"def deploy(id, host, remote_dfile, not_used)\n local_dfile = get_local_deployment_file(remote_dfile)\n\n if !local_dfile || File.zero?(local_dfile)\n send_message(ACTION[:deploy],RESULT[:failure],id,\n \"Can not open deployment file #{local_dfile}\")\n return\n end\n \n local_action(\"#{@actions_path}/deploy #{host} #{local_dfile}\",id,:deploy)\n end",
"def provision\n Dir.chdir(\"#{Ros.tf_root}/#{infra.provider}/provision/#{infra.type}\") do\n system('terraform init')\n system('terraform apply')\n end\n after_provision\n end",
"def deploy(provision)\n tempdir = init(provision, false, false)\n\n if @file_credentials\n c_key = Provider::CREDENTIALS_FILE[@provider.type]\n credentials = @provider.connection[c_key.upcase]\n\n File.open(\"#{tempdir}/credentials.json\", 'w') do |file|\n file.write(Base64.decode64(credentials))\n end\n end\n\n # Apply\n Driver.retry_loop(\"Driver action 'tf deploy' failed\", provision) do\n _, e, s = Driver.run(\n \"cd #{tempdir}; \" \\\n \"export TF_LOG=#{OneProvisionLogger.tf_log}; \" \\\n 'terraform apply -auto-approve'\n )\n\n unless s && s.success?\n conf = Base64.encode64(Zlib::Deflate.deflate(@conf))\n state = ''\n\n if File.exist?(\"#{tempdir}/terraform.tfstate\")\n @state = File.read(\"#{tempdir}/terraform.tfstate\")\n state = Base64.encode64(Zlib::Deflate.deflate(@state))\n end\n\n provision.add_tf(state, conf)\n\n provision.update\n\n STDERR.puts '[ERROR] Hosts provision failed!!! ' \\\n 'Please log in to your console to delete ' \\\n 'left resources'\n\n raise OneProvisionLoopException, e\n end\n end\n\n @state = File.read(\"#{tempdir}/terraform.tfstate\")\n\n # Get IP information and deploy IDs\n info = output(tempdir)\n\n # Filter ids\n hash_ids = info.select do |key, _value|\n key.to_s.match(/^device_[0-9]*_id/)\n end\n ids = hash_ids.values.map {|h| h['value'] }\n\n # Filter ips\n hash_ips = info.select do |key, _value|\n key.to_s.match(/^device_[0-9]*_ip/)\n end\n ips = hash_ips.values.map {|h| h['value'] }\n\n conf = Base64.encode64(Zlib::Deflate.deflate(@conf))\n state = Base64.encode64(Zlib::Deflate.deflate(@state))\n\n [ips, ids, state, conf]\n ensure\n FileUtils.rm_r(tempdir) if tempdir && File.exist?(tempdir)\n end",
"def deploy_application\n deploy new_resource.name do\n provider Chef::Provider::Deploy::Revision\n enable_submodules new_resource.enable_submodules\n deploy_to application_full_path\n repo new_resource.repo\n revision new_resource.revision\n purge_before_symlink new_resource.shared_dirs.values\n symlink_before_migrate new_resource.shared_files\n create_dirs_before_symlink new_resource.create_dirs_before_symlink\n symlinks new_resource.shared_dirs\n user new_resource.user\n group www_group\n migrate new_resource.migrate\n environment new_resource.environment\n migration_command new_resource.migration_command\n before_migrate new_resource.before_migrate\n before_restart new_resource.before_restart\n ssh_wrapper new_resource.ssh_wrapper || node['mo_application']['ssh_wrapper']\n restart_command new_resource.restart_command\n before_symlink new_resource.before_symlink\n action (new_resource.force_deploy ? :force_deploy : :deploy)\n end\n\n file ::File.join(application_full_path, 'REVISION') do\n content new_resource.revision\n user new_resource.user\n end\n end",
"def deploy_remote_sdfile(application_package, sd_filename, params={})\n remotehost = hostlist.first\n proxy = @vespa.nodeproxies[remotehost]\n content = proxy.readfile(sd_filename)\n local_sdfilename = selfdir+File.basename(sd_filename)\n File.open(local_sdfilename, \"w\") do |file|\n file.write(content)\n end\n deploy(application_package, local_sdfilename, params)\n FileUtils.rm_rf(local_sdfilename)\n end",
"def mkfs\n mkfs_options = options :mkfs\n mkfs_options << \"#{resource[:host]}/#{resource[:name]}\"\n\n mkfs_xtreemfs mkfs_options\n end",
"def copy_artifact\n recipe_eval do\n execute \"copy artifact\" do\n command Chef::Artifact.copy_command_for(cached_tar_path, release_path)\n user new_resource.owner\n group new_resource.group\n end\n end\nend",
"def install_apply\n namespace nsprefix do\n desc 'Apply a terraform plan that will provision your resources; ' \\\n 'specify optional CSV targets'\n task :apply, [:target] => [\n :\"#{nsprefix}:init\",\n :\"#{nsprefix}:write_tf_vars\",\n :\"#{nsprefix}:plan\"\n ] do |t, args|\n @before_proc.call(t.name, @tf_dir) unless @before_proc.nil?\n cmd_arr = %w[terraform apply]\n cmd_arr << '-auto-approve' if tf_version >= Gem::Version.new('0.10.0')\n cmd_arr << \"-var-file #{var_file_path}\"\n cmd = cmd_with_targets(\n cmd_arr,\n args[:target],\n args.extras\n )\n terraform_runner(cmd)\n\n update_consul_stack_env_vars unless @consul_env_vars_prefix.nil?\n @after_proc.call(t.name, @tf_dir) unless @after_proc.nil?\n end\n end\n end",
"def import_ovf(ovf, path, image_type, qemu_bin, cpu_model)\n @logger.info(\"Importing OVF definition for VM\")\n # create vm definition from ovf\n definition = File.open(ovf) { |f|\n Util::VmDefinition.new(f.read, 'ovf') }\n\n # create volume to storage pool\n box_disk = definition.disk\n new_disk = File.basename(box_disk, File.extname(box_disk)) + \"-\" +\n Time.now.to_i.to_s + \".img\"\n tmp_disk = File.basename(box_disk, File.extname(box_disk)) + \".img\"\n # path settings\n old_path = File.join(File.dirname(ovf), box_disk)\n new_path = File.join(path, new_disk)\n tmp_path = File.join(File.dirname(ovf), tmp_disk)\n\n if image_type == get_box_disk_format(old_path)\n @logger.info(\"Disk #{old_path} is already in requested format not converting it.\")\n FileUtils.cp(old_path, new_path)\n else\n case image_type\n when 'qcow2'\n unless File.file?(tmp_path)\n @logger.info(\"Creating native qcow2 base box image #{tmp_disk}\")\n if system(\"qemu-img convert -p #{old_path} -c -S 16k -O #{image_type} #{tmp_path}\")\n File.unlink(old_path)\n else\n raise Errors::KvmFailImageConversion\n end\n end\n @logger.info(\"Creating volume #{new_disk} backed by #{tmp_disk}\")\n system(\"qemu-img create -f qcow2 -b #{tmp_path} #{new_path}\")\n when 'raw'\n if File.file?(tmp_path)\n @logger.info(\"Converting volume #{tmp_disk} to #{new_disk}\")\n system(\"qemu-img convert ${tmp_path} -O ${image_type} #{new_path}\")\n else\n @logger.info(\"Converting volume #{old_path} to #{new_disk}\")\n system(\"qemu-img convert ${old_path} -O ${image_type} #{new_path}\")\n end\n else\n @logger.info(\"Unknown Image type #{image_type}\")\n end\n end\n @pool.refresh\n volume = @pool.lookup_volume_by_name(new_disk)\n definition.disk = volume.path\n # Create vm\n\n # Add custom Settings from ProviderConfig\n definition.memory = @memory unless @memory.nil?\n definition.cpus = @vcpus unless @vcpus.nil?\n definition.set_mac(@mac) unless @mac.nil?\n definition.name = @name\n definition.disk_type = @disk_type\n definition.machine = get_system_machine\n definition.image_type = image_type\n definition.qemu_bin = qemu_bin unless qemu_bin.nil?\n definition.arch = cpu_model unless cpu_model.nil?\n definition.interface_source = @interface_source unless @interface_source.nil?\n definition.interface_type = @interface_type unless @interface_type.nil?\n definition.set_gui if @gui\n # create vm\n @logger.info(\"Creating new VM\")\n @logger.debug(\"==============================\")\n @logger.debug(\"Using VM definition\\n #{definition.as_libvirt}\")\n @logger.debug(\"==============================\")\n domain = @conn.define_domain_xml(definition.as_libvirt)\n domain.uuid\n end",
"def run_proc(name)\n execute_run_proc(\"artifact_file\", new_resource, name)\n end",
"def post_provision_configure\n add_stack_to_resource\n link_orchestration_template\n assign_vms_owner\n apply_provisioning_tags\n end",
"def deploy\n system %Q[ssh -lroot \"#{server}\" <<'EOF'\n \tcat >\"#{remote_script_name}\" <<'EOS'\n#{generate}EOS\nchmod +x \"#{remote_script_name}\"\nsource \"#{remote_script_name}\"\nEOF\n ]\n end"
] |
{
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.